#help-development
1 messages ยท Page 2066 of 1
oh, in the current file it makes a error (which is the main plugin java class) but in the listener it doesnt make an error
show meh tha error
no?
oh
it should work fine if your listener class implements Listener
and the second parameter extends JavaPlugin
how do I check if damage cause/damager is sweet berry bush then
how do i do that?
well ur registering in ur main class right?
yes
actually my bad, use EntityDamageByBlockEvent that has a method to get the block
i read that plugin name wrong
[INFO] ------------< org.golde.bukkit.corpsereborn:CorposeReborn >-------------
[INFO] Building corpose reborn 3.0 BETA 1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ CorposeReborn ---
[INFO] Deleting C:\Users\manfr\Desktop\intellij idea\corpose reborn\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ CorposeReborn ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ CorposeReborn ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 68 source files to C:\Users\manfr\Desktop\intellij idea\corpose reborn\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/manfr/Desktop/intellij idea/corpose reborn/src/main/java/org/golde/bukkit/corpsereborn/nms/nmsclasses/NMSCorpses_v1_18_R2.java:[61,61] cannot access net.minecraft.server.v1_16_R3.PacketPlayOutPlayerInfo.PlayerInfoData
bad class file: C:\Users\manfr\.m2\repository\org\spigotmc\spigot\1.16.5-R0.1-SNAPSHOT\spigot-1.16.5-R0.1-SNAPSHOT.jar(/net/minecraft/server/v1_16_R3/PacketPlayOutPlayerInfo$PlayerInfoData.class)
bad RuntimeInvisibleParameterAnnotations attribute: PlayerInfoData(com.mojang.authlib.GameProfile,int,net.minecraft.server.v1_16_R3.EnumGamemode,net.minecraft.server.v1_16_R3.IChatBaseComponent)
Please remove or make sure it appears in the correct subdirectory of the classpath.
[INFO] 1 error
[INFO] -------------------------------------------------------------```
Pls help me
it says that it cannot access playerinfodata and it has a bad class file...
and it sais the exact same error still?
thanks
can u show me the whole main class and the whole listener class?
?paste
How can I fix it
lol
is there a difference between
public record MyListener(MyPlugin plugin) implements Listener {}
and
public class MyListener implements Listener {
private final MyPlugin plugin;
public MyListener(MyPlugin plugin) {
this.plugin = plugin;
}
}```
yea
erm why would you use a record
that's just
disgusting
they both extend javaplugin
i dunno intellij suggested it
i havent changed it
don't do it pls
oh yeah intellij added it i think
well thats bad
i dont even know how they work lo
don't just randomly do what your IDE suggests if you don't understand what it does
make the listener class implement listener only
yeah i havent
thats why i asked here
i didnt accept it
I was answering to Alanek in this case ๐
o
alright thanks theres no error now
:)
furry, don't make your listeners records
alanek, only extend javaplugin once
lol
bro
stop calling me furry i stg
no
. @tender shard maybe u know dis?
full stacktrace pls ๐
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.acentramc.clans.ClanSystem.<init>(ClanSystem.java:39)
at com.acentramc.clans.Bootstrap.main(Bootstrap.java:11)
Caused by: java.lang.IllegalArgumentException
at com.google.gson.internal.$Gson$Preconditions.checkArgument($Gson$Preconditions.java:46)
at com.google.gson.GsonBuilder.registerTypeAdapter(GsonBuilder.java:526)
at com.acentramc.clans.util.GlobalGson.<clinit>(GlobalGson.java:17)
... 2 more
its not a plugin btw
standalone application
what's your Gson version?
public class BanInventoryListener implements Listener {
@EventHandler
public void onMenuClick(InventoryClickEvent e) {
Player player = (Player) e.getWhoClicked();
if (e.getView().getTitle().equalsIgnoreCase(ChatColor.BLUE + "Player List")){
if(e.getCurrentItem() == null) {
return;
}
if (e.getCurrentItem().getType() == Material.PLAYER_HEAD){
Player whoToBan = BanGUI.getPlugin().getServer().getPlayerExact(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()));
if(whoToBan == null) {
return;
}
BanMenuUtils.openPlayerMenu(player, whoToBan);
}
} else if(e.getView().getTitle().equalsIgnoreCase("Ban This Player")){
switch(e.getCurrentItem().getType()){
case BARRIER:
BanMenuUtils.openBanMenu(player);
break;
case WOODEN_AXE:
//Get name
String name = e.getClickedInventory().getItem(4).getItemMeta().getDisplayName();
player.getServer().getBanList(BanList.Type.NAME).addBan(ChatColor.stripColor(name), "Banned by A Moderator.", null, null);
player.sendMessage(ChatColor.GREEN + "Banned Player");
break;
}
}
e.setCancelled(true);
}
}
``` this code doesnt throw any errors but it doesnt work
2.8.9
your problem is thiss:
is it outdated again? xd
you pass a .class (Class object) to the second argument of registerTypeAdapter
but it should be an instance of the class that deserializes your object
e.g.
.registerTypeAdapter(String.class, new MyStringDeserializer())
lol it can happen
i have been cracking my head on this for 2hours
lol
but you also decided to ping me, so you got that going ๐
(tbh I only googled registertypeadapter illegalargumentexceptiona and read the first stackoverflow answer lmao)
i was desperate 
I want to have a custom snowball which does something when it hits entities and that works fine, but I have to check if its my custom snowball which hit the entity by checking the main hand of the player who threw it, which doesn't work if it's the last one or they switch hands before it damages the entity.
Any other way to check wether the snowball hitting the entity is my own custom one?
well programming is bassicaly just being a professional googler some people say
that's at least part of it
everyone who says otherwise is just too vain to admit it
agreed
There's two types of programmers those that google when they need it and liars
That's a script kiddy
I mean copy paste is totally fine, if you unterstand what you copy
guys don't spam please I want my question answered
sowwy
Write custom data to the PDC
apply some PDC data on the projectile in ProjectileLaunchEvent
Hi!
i'm working on a multiverse core plugin
and i'm have trouble by stopping the server and starting again.
because it forgot all of the worlds made by the plugin
(they are still in the folder)
(im using WorldCreator)
ok, thanks
basically I'd do sth like this
@EventHandler
public void onSnow(ProjectileLaunchEvent event) {
Player player = (Player) event.getEntity().getShooter(); // Check before casting, ofc
if(!isMyCustomSnowball(player.getInventory().getItemInMainHand())) return;
event.getEntity().getPersistentDataContainer().set(new NamespacedKey(myPlugin,"this is my custom snowball lol"), PersistentDataType.BYTE, (byte) 1);
}
then you can later check for this PDC tag
store them in a yaml file or similar
you will definitely not need a database, just use a yaml file
wait the world or just its name?
The name of the folder so you can easily grab it
but how do i load it!?
Good question
the name of the world folder
the world or the yaml?
the world
what
?
Bukkit.createWorld
Creates or loads a world with the given name using the specified options.
682 ๐
Them newlines
by typing
oh
i understand xd
EventHandler methods obviously only take exactly ONE event
and not an event and a player
you have something wrong with events
you have to get the player from the event
You know
oh, how?
Back in my day dark theme didnโt exist
@EventHandler
public void onEdwardSnowden(ProjectileHitEvent event) {
if(event.getEntity().getPersistentDataContainer().has(new NamespacedKey(myPlugin, "this is my custom edward snowden ball lol"), PersistentDataType.BYTE)) {
// This is my custom Edward Snowden ball
}
}
this is correct ^
@EventHandler
public void onEdwardSnowden(ProjectileHitEvent event, Player player) {
if(event.getEntity().getPersistentDataContainer().has(new NamespacedKey(myPlugin, "this is my custom edward snowden ball lol"), PersistentDataType.BYTE)) {
// This is my custom Edward Snowden ball
}
}
this is not good ^
When you're squinting from a hangover light theme becomes dark theme
oh alright
if its PlayerQuitEvent pqe i need to do Player player = pqe.getPlayer();?
beacuse i have it like that
yes
but
oh wait
I know
It's better to just name it event. You know what method it's in and what it's full name is
This is how da real pros do it
public void onEvent(Event event) {
if(event instanceof PlayerJoinEvent pje) {
// do PlayerJoinEventStuff
} else if(event instanceof PlayerQuitEvent pqe) {
// do PlayerQuitEventStuff
} else if ...
}```
Man I think it was JDA I used to do that back in 1.0 days
lol
I don't know how it used to work 5 years ago, I only know that today JDA uses by overriding methods per event
How can I get all the sections in a section? I did something like this but it doesn't work https://paste.md-5.net/woyenapija.java
?paste
you can get all Keys
configurationSection.getKeys(boolean)
pls help me
Oh I have the perfect tip for you
I used it but it doesn't work; /
They have an event that all events run through so you can instance of your way around like a blind man in a hurricane
what exactly "doesn't work"
ExpBottleEvent doesn't have a player
Youโd have to get the shooter of the bottle
everything returns null, which is just not reading correctly
get the entity, then get the thrower
yeah thats why
show your code
but idk how to get the entity then the thrower
this makes no sense
but i use intellij, not eclipse
a
getKeys(false) returns this:
ironSword
diamondSword
How do I choose the right jdk version in .bat?
I have 3 different versions of jdk installed
thanks!
provide the full path
e.g. C:\Program Files\Java\jdk1.8\bin\java.exe ...
not worked
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
@royal oxide OFF
chcp 1251 > nul
Title Paper
C:\Program Files\Java\jdk-16.0.2\bin -Dfile.encoding=cp1251 -Xmx1G -jar Paper-1.16.5.jar
and what exactly "not worked"?
you have a space in Program and Files
also
you only provided the path to the bin folder
They won 't start at all
You need the path to the executable, not just the bin
you obviously have to provide a path to the java.exe file
And I believe you need to use โ โ if you have a space
yep
C:\Program Files\Java\jdk-16.0.2\bin\java.exe?
"C:\Program Files\myjava\bin\java.exe" -jar myjar.jar
with quotes
not worked(
A
this guide is for eclipse compiler
i can use it?
...
yes
you can use it
you must use it
Yes, it worked, thank you very much
ah ok
you must it use it to access this weird PlayerInfoPacket class
idk why but javac has problems with that class
Failed to run the ecj compiler: source level should be in '1.1'...'1.8','9'...'14' (or '5.0'..'14.0'): 17
use a newer versio nof the eclipse compiler
basically update the version of plexus compiler in the pom
how do i get the entity when i have a expbottleevent event?
Hi, i need help, i search a way to block a craft of an item if the player doesn't have a permission but i can't get the player with the event PrepareItemCraftEvent
you can
get the inventory
then get the viewers
it'll only return one viewer
and that's the player
player, but idk how
Viewer is always return the player ?
actually
the player who threw the bottle?
yeah
i dont think so
I already told you, get the bottle's thrower
that's fine
but you can also
wait
do something like
yes but you don't have to write everything twice
it isn't IIRC
just checked, global is not a keyword
got it mixed up with NodeJS
getEntityType? or what?
event.getEntity() = the XP bottle
XP bottle is a "projectile"
so
oh
getThrower() on the XP bottle
getShooter()*
I think too but how can i get just the player ?
how, i see the latest version https://mvnrepository.com/artifact/org.codehaus.plexus/plexus-compiler-eclipse/2.11.1, but i have an error whit intellij
Cannot resolve method 'getShooter' in 'ExpBottleEvent'
oh yeah-
and forr maven compiler plugin https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin
hit the maven reload button
get entity then get shooter?
yes, as I already explained
i dont know how tho
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
'java.util.List org.codehaus.plexus.compiler.CompilerConfiguration.getProcessorModulePathEntries()'
for real, I explained it to you in detail
@EventHandler
public void onXpBottle(ExpBottleEvent event) {
Player thrower = (Player) event.getEntity().getShooter();
}
obviously check before casting
are you using lombok?
sorry, but what is?
do you have "lombok" as dependency in your pom.xml?
i just searched up random stuff on google and found this
no
to use
?paste
whats plexus-compiler-eclipse
that is exactly what I sent you
a java compiler
yeah but diffrent way
no
Now check and cast ProjectileShooter to player
for real, learn java, this is just a waste of my time
alright
u have ur dependencies in ur plugins it seems
yes yes
then paste the full log
.getPlayer() if i remember right
wtf is CorposeReborn lol
I look this now
try to update maven-compiler-plugin to 3.10.1
mfnalex how do i set the world to server?
i basicaly doesn't use nms
?
the weird PlayerInfoPacket is the only one that has this problem
It work, big thanks
sorry I don't understand this sentence
you know you told me how to recover back the worlds
i'm done with saving the names into a yml file
what does your yaml look like
asd: 0
hello: 0
xd: 0
๐
why 0?
idk
how do i set it as a string list?
(i fist wanted this version)
List<String> list = new ArrayList<>();
list.add("asd");
list.add("hello");
getConfig().set("worlds",list);
https://paste.md-5.net/owuyulukog.sql, i know i waste your time, but you are the only person can help me
everything's good lol
your problem now is simply that you don't have spigot remapped
run buildtools.jar --rev 1.18.2 --remapped
the other error is fixed now as it seems
i have it remapped, i need to remove spigot api?
run the first command in that post
you have remapped in your pom.xml but you don't have the remapped .jar file on your hard disk
so, please read the above blog post
you can ignore all the pom.xml stuff in that post
just run the first command from that blog post
you added it manually
that won't do anything
you have to let maven handle your dependencies
just
RUn
the
command
ah ok
Hello, I want to extract the HEAD 2d image (from front) of a player's minecraft skin image;
I could find the image thanks to PlayerProfile.textures,although i'm unsure where is the head in all that parts; is there maybe an easier way?
or i guess i should crop the image to a specific area (to extract only the head from front)?
I know there is two types of skin: slim & normal, where should i crop the 8x8 area representing the head? and i guess i should also extract the hat layer and put it on top?
by running the buildtools command I've been sending to you three times? :p
deleting this: <plugin> <groupId>net.md-5</groupId> <artifactId>specialsource-maven-plugin</artifactId> <version>1.2.3</version> <executions> <execution> <phase>package</phase> <goals> <goal>remap</goal> </goals> <id>remap-obf</id> <configuration> <srgIn>org.spigotmc:minecraft-server:1.18-R2.1-SNAPSHOT:txt:maps-mojang</srgIn> <reverse>true</reverse> <remappedDependencies>org.spigotmc:spigot:1.18-R2.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies> <remappedArtifactAttached>true</remappedArtifactAttached> <remappedClassifierName>remapped-obf</remappedClassifierName> </configuration> </execution> <execution> <phase>package</phase> <goals> <goal>remap</goal> </goals> <id>remap-spigot</id> <configuration> <inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile> <srgIn>org.spigotmc:minecraft-server:1.18-R2.1-SNAPSHOT:csrg:maps-spigot</srgIn> <remappedDependencies>org.spigotmc:spigot:1.18-R2.1-SNAPSHOT:jar:remapped-obf</remappedDependencies> </configuration> </execution> </executions> </plugin>
?paste
thank you
what version is your server?
1.18.2
is CorpseReborn your plugin?
No, I try to update it for my server
ah
I download it from GitHub, is open source
alright
I'll try update it for you if you'd like
I get off my horse and cancel the event. When I hold the shift, I may not be on a horse. It shouldn't work like that. Canceling the SneakEvent doesn't work.
are there alternatives?
If you can yes, thanks
lmao
this won't help you at all
now your whole NMS stuff won't work anymore
Ah
Because I delete this, I have the error?
@tender shard
no, it will only break compatibility with 1.18.2
the error you have is simply because the plugin doesn't support 1.16.5 at all
Ah ok, after I try
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
manager.addPacketListener(new PacketAdapter(plugin, PacketType.Play.Server.PLAYER_INFO) {
@Override
public void onPacketSending(PacketEvent e) {
try {
if (e.getPacket().getPlayerInfoAction().read(0) != EnumWrappers.PlayerInfoAction.ADD_PLAYER)
return;
} catch (Exception ex) {
return;
}
e.getPacket().getPlayerInfoDataLists().write(0, new ArrayList<>());
}
});
To update
it seems like CorpseReborn only supports latest 1.18
do you have ProtocolLib as depend in plugin.yml?
softdepend: [ ProtocolLib ]
Corpose reborn support 1.7 to 1.16.4
check Main.java
there's an import to 1.16.4 / 1.16.5 classes
and obviously a 1.18.2 server doesn't have any classes for 1.16.4 stuff
don't get the protocollib thing immediately but only in your onEnable method
@Override
public void onEnable() {
if (getServer().getPluginManager().getPlugin("ProtocolLib") != null) {
this.packets = new Packets(this);
} else {
getLogger().warning("not ProtocolLib");
}
}
After I try, now I canโt, When I try, if I have problem, I can ping you?
hm that should work fine then
I don't know then
public Packets(Plugin plugin) {
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
manager.addPacketListener(new PacketAdapter(plugin, PacketType.Play.Server.PLAYER_INFO) {
@Override
public void onPacketSending(PacketEvent e) {
try {
if (e.getPacket().getPlayerInfoAction().read(0) != EnumWrappers.PlayerInfoAction.ADD_PLAYER)
return;
} catch (Exception ex) {
return;
}
e.getPacket().getPlayerInfoDataLists().write(0, new ArrayList<>());
}
});
}
looks good to me
sorry I can't help, maybe ask on ProtocolLib's discord if they have any
got a question, I'm trying to set up remote debugging for intellij but I am supposed to be building this with gradle, when I just hit the build (not gradle) button it tells me that some classes have changed and prompts me to reload classes and then immediately says hot swap failed; I know there's some limitations with hot swapping but I am just adding a console message to an existing method here
oh wait
send your whole plugin.yml pls @quaint mantle
you might have "cycling" dependencies
This worked for a very long time on version 1.12.2
name: AuthProtect
version: '${project.version}'
main: konghure.authprotect.AuthProtect
api-version: 1.16
softdepend: [ ProtocolLib ]
it could have failed due to not detecting that one small change
it did detect it
hm yeah looks good, I don't know, unless you have any other plugins that depend on your plugin, it seems 100% fine
Retrieving skin of a player
when I build without changes it tells me that everything is up-to-date
I found more of this
I had this:
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.8.0</
</dependency>
oh
I know your problem
you shaded protocollib into your plugin
really strange then that the hotswap failed. The only thing I can think of is that because strings are immutable that whatever class was trying to be swapped out was being used at the time
They said to add this
add <scope>provided</scope> to your dependency of protocollib
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.8.0</version>
<scope>provided</scope>
</dependency>
This doesn't work either(
are you 100% sure? check if your .jar file contains protocollib
if yes, you fucked up
if no, sorry i don't know
I checked before adding
they only create an instance of their packet listener class in onenable when getPlugin("ProtocolLib") doesn't return null, and they have protocollib as soft-dep
this issue has always stopped me from using the debugger and I do feel like I've been missing out
so it looks good to me
only thing I can think of is that they somehow accidently shaded protocollib
java.lang.NullPointerException: Cannot invoke "com.comphenix.protocol.ProtocolManager.addPacketListener(com.comphenix.protocol.events.PacketListener)" because "manager" is null
I don't use the debugger a lot myself, but that is because most of the time I don't have a reason for it as I usually know what is going on. However with your hotswap the only thing that comes to mind is that however that class you are trying to hotswap was designed it doesn't allow it to do so easily without causing all kinds of problems and it could be due to how its linked to other stuff.
latest
honestly I just resent not being able to use the debugger when I can't find where code execution stops and I just keep adding debug messages
lol
otherwise I don't really have a use for it
Well, in this case the debugger might help but it would probably only confirm in that it can't be hotswapped without destroying other object instances that are derive from it
I would pay JetBrains $1000 if they create a hotkey to quickly dump debug messages at possible code execution stopping points
What do you mean?
Doesn't JetBrains have a debugger you can use?
ye it has
hi conc โค๏ธ
hello :3
that sort of warps all the way back around to not manageable unfortunately
I'm blessed with one of those issues that seem to be arbitrary and time-based
what I need is code jesus to exorcise the evil code bugs from my codebase
it's tricky, ultimately I need to find a way to replicate the issue in the first place, I think I got a good hint earlier from one of my testers so I was about to start testing it just wanted to see if I could hotswap some debug messages while I was at it
you could do so, but it depends on the class really
if its a base class for many things, odds are no you won't be able to
it really wasn't, hell the code runs on a timer that is based on an action so I was sort of hoping to get away with it
ah that could be it then, the timer code is probably what prevents it from being hotswapped
not a repeating task a delayed one
once a timer task is queued in the JVM, hotswapping isn't going to be possible without throwing all kinds of NPE's in the scheduler
yeah it shouldn't schedule until I did an action but eh I guess I'll take a look at this later
well that is the only thing that would prevent it from what you are saying
because once you hotswap once it is scheduled, the instance the scheduler has is no longer valid and there is nothing to tell the scheduler that ahead of time
I can tell nothing was schedules because it wasn't the only debug message on there
but I need to keep on trucking or I will genuinely never fix this issue
.
private static ProtocolManager pm;
public static ProtocolManager getManager() {
return pm;
}
AuthProtect.getManager().addPacketListener(new PacketAdapter(plugin, PacketType.Play.Server.PLAYER_INFO) {
getManager() is null
Whats the maven import for ProtocolWrapper?
package index
why that
all i found is this
use that
well i cant get player from this event
so i assumed its the wrong one :/
You cant?
yeah
ok i found out its this one but you need to add
player.updateInventory();;
if you cancel the event
after canceling it
to fix
Is it possible to set a player to be the damage cause of damage caused by the plugin?
Shouldn't be nececcary
Try it in survival
oki
does anybody know why "item" is null? java @EventHandler public void onJoin(PlayerJoinEvent e){ for(ItemStack item : e.getPlayer().getInventory().getContents()){ if(item.getType().name().endsWith("_AXE")){ new Enchant(item, EnchantAbility.Enchants.DEFAULT); } } }
Because they donโt have an item in every slot
so how can i fix that?
Check for null?
ItemStack itemStack = new ItemStack(Material.GOLD_BLOCK);
if (balance_int == 1) {
e.getPlayer().getInventory().addItem(itemStack);
balance_int = balance_int-1;
}
ItemMeta meta = itemStack.getItemMeta();
meta.setDisplayName("balance");
itemStack.setItemMeta(meta);
if i do this ill get an gold block but its name isnt balance. why?
its on player movement
Add the item after you edit the meta
oh yeah bruhhh thxx
@EventHandler
public void onMove(PlayerMoveEvent e) {
ItemStack itemStack = new ItemStack(Material.GOLD_BLOCK);
ItemMeta meta = itemStack.getItemMeta();
meta.setDisplayName(MyFirstPlugin.balance.toString());
meta.setLore(Arrays.asList("line 1", "line2"));
itemStack.setItemMeta(meta);
if (balance_int == 1) {
e.getPlayer().getInventory().addItem(itemStack);
balance_int = balance_int-1;
}
}
file name: MyFirstPlugin
public static Integer balance;
error: Could not pass event PlayerMoveEvent to firstplugintest v1 org.bukkit.event.EventException: null why does it print this?
anyone familiar with the point to point protocol ?
wouldnt this throw an error if the player is offline ?
Hey, I want to split my world into 42x42 squares. Each square should have an ID. I did that too! But now I want a 15 block wide space between each square. How do I do that? I calculate the squares like this:
public static String getID(Location location){
// Welt in 100x100 block groรe quadrate aufteilen
int x = (int) (location.getX() / 42);
int z = (int) (location.getZ() / 42);
return x + ";" + z;
}```
bro u give the item before the item meta
Why does my plugin work on spigot and not paper?
lol
How are we supposed to answer this questions when you haven't told us what "not work" means, what the errors or incorrect behavior are, or literally anything about your plugin?
Bukkit#getPlayer(...) != null //hes online
when i click the head it always returns null
Again, that tells me almost nothing
What is the expected behavior? What is returning null? Can you share some code?
We're not mind readers
Use a paste link please
i put in some debug stuff
?paste
Delete your code block and paste your code in there
yeah thats what i did, i was just wondering if its useful
Thank you
how can i send a player to a different server using spigot ?
Now what is returning null
like what /server <server> does
What sound is played when a splash potion breaks?
e.getCurrentItem().getType()
``` this works on spigot but not on paper
Please don't use the phrase "works" or "doesn't work"
Because it explains nothing about the behavior
I'm guessing you mean that in spigot, getCurrentItem returns null when the item is empty
Whereas in paper it returns an item with the type air
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
@west oxide
You already have a guard clause in your first conditional
Line 12
It will return if the item is null
is it GLASS?
But there's no such check in the first else-if, for "Ban This Player"
how do shulker boxes save inventory data?
is it just saved in the pdc of the container or whatever?
yes but the plugin doesnt return null when i tried it on spigot
ay thank you
So if you go to that branch there's no null check
just on paper it does
That's just an implementation detail
You need to properly check that the item isn't empty
You get the type of the item either way
Why don't you just add a single if at the very top outside of any of the other branches that will return if the item is null?
As in, move the if statement currently at line 12 to before line 6
Hi, i get this line wrong
e.getPlayer().teleport(frozenplayers.get(e.getPlayer()));```
i get so i can't have e.getPlayer in the same line way and how do i fix it tag me
What
i updated the code https://paste.md-5.net/wabuhaduru.java
Player whoToBan = BanGUI.getPlugin().getServer().getPlayerExact(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()));
A lot is going on in this line
Split it up and add debug output for the name
It could be trying to get an offline player
well im testing it on myself and im online so its not getting an offline plauer
so should i do
System.out.println(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()));
ItemStack item = event.getPlayer().getItemInUse();
assert item != null;
if (item.getType().equals(Material.NAME_TAG)) {
if (item.getItemMeta() == null)
return;
event.setCancelled(true);
if (!Objects.equals(CustomConfig.get().getString("nests." + nestID + ".members." + player.getUniqueId() + "role"), "leader")) {
player.sendMessage(ChatColor.DARK_RED + "You must be the owner to rename a Nest");
return;
}
String name = item.getItemMeta().getDisplayName();
setName(nestID,name);
player.sendMessage(ChatColor.DARK_GREEN + "Renamed nest");
player.getInventory().getItemInMainHand().setAmount(player.getInventory().getItemInMainHand().getAmount()-1);
return;
}```
`item` is always null, why?
i'm trying to retrieve the item that a player is right clicking with
in a PlayerInteractAtEntity event
?jd
is there a way to remove an entity in the tick the method is run?
because entity.remove() only applies on the enxt tick
@waxen plinth ?
Could always teleport the entity somewhere distant
Please don't ping me
ok
I said to add debug output for that, so yes
But use a variable
Don't duplicate the code
welp ig then i gotta use nms and make it die
can i get a server i just need to starte?
ok
it calls bukkit's .remove iirc
Would teleporting them somewhere distant not work
No
Yeah exactly
So it appears to die that tick
But it would still be removed the following tick
but that wouldnt solve the problem
xy moment lmao
I want to remove some entities in onDisable
sunburn
Auto-generating getters and setters makes you weak
Smol brain: Lombok
Normal brain: Auto-generate
Big brain: Manually typing them out
Galaxy brain: Just making everything public
hey, idk why it took me this long to realize this is for bungee xD
i need one for spigot
ok then im sometimes big brain and sometimes smol
public void sendPlayerToServer(Player player, String server) {
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
try {
out.writeUTF("Connect");
out.writeUTF(server);
} catch (Exception e) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&fThere was an problem connecting to " + server + "!"));
return;
}
player.sendPluginMessage(Main.getInstance(), "BungeeCord", b.toByteArray());
}
}```
@west oxide
thats to send a player to a server thats connected with the current one
with Bungee
you cant send the player to a server thats not connected with the current one with bungee
ay thank you
yeah i understand
thank you
how do you make a custom plugin logger?
i got this message
[16:22:27 WARN]: Nag author(s): '[Axure]' of 'BanGUI' about their usage of System.out/err.print. Please use your plugin's logger instead (JavaPlugin#getLogger)
It does tell you exactly what to do
Well that is the way
still sends the message
Did you remove your sys out
yes
ok now i see what the issue is, its getting my display name like [Admin] _Axure
its not getting my actual name
sorry i just replied to you since you told me what to do
Iโm looking for someone to commission a plug-in for me.
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
ok
Thanks
i can do that if u want
I'm trying to create a custom chat room, but this isnt working, any ideas?
my config layout:
testchannel:
format: "blah"
code in the asyncplayerchatevent
YamlDocument customChannels = YamlDocument.create(new File(plugin.getDataFolder(), "customchannels.yml"), Objects.requireNonNull(plugin.getResource("customchannels.yml")),
GeneralSettings.DEFAULT, LoaderSettings.builder().setAutoUpdate(true).build(), DumperSettings.DEFAULT, UpdaterSettings.builder().setAutoSave(true).setVersioning(new Pattern(Segment.range(1, Integer.MAX_VALUE), Segment.literal("."), Segment.range(0, 10)), "file-version").build());
List<Object> keys = List.of(customChannels.getKeys());
if (keys.contains(e.getPlayer().getPersistentDataContainer().get(key, PersistentDataType.STRING))) {
String k = e.getPlayer().getPersistentDataContainer().get(key, PersistentDataType.STRING);
for (Player player : Bukkit.getOnlinePlayers()) {
if (player.hasPermission("chatchannels.see." + e.getPlayer().getPersistentDataContainer().get(key, PersistentDataType.STRING))) {
player.sendMessage(Replace.rep(customChannels.getString(k + ".format"), "%player%", e.getPlayer().getDisplayName(), "%message%", e.getMessage(), "%coordinates%", LocationUtils.convert(e.getPlayer().getLocation()), "%world%", e.getPlayer().getWorld().getName(), "%blocks%", String.valueOf(MathUtils.round(MathUtils.calculateDistance3D(e.getPlayer().getLocation(), player.getLocation()), 2))));
}
}
}```
bruh i give up
i followed a forum post
but for some reason
my commands still don't show up
how do i go trough all of these to get "minecraft" and "spigot"?
minecraft:
name: "&d&DisplayName"
spigot:
name: "&d&DisplayName"
```
those are the routes i guess
config.getString(route)
o oke
Hey, I want to split my world into 42x42 squares. Each square should have an ID. I did that too! But now I want a 15 block wide space between each square. How do I do that? I calculate the squares like this:
public static String getID(Location location){
// Welt in 100x100 block groรe quadrate aufteilen
int x = (int) (location.getX() / 42);
int z = (int) (location.getZ() / 42);
return x + ";" + z;
}```
still doesn't work
it just says unknown command
no
do i need to restart the server, im currently using plugman
but its so much more convinent
xd
whats that?
also can i stop my server from loading all dimensions everytime i restart it
r
Well
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
oh hey i restarted my server and now it works!
theres no real way to understand what a problem is if you dont have some basic idea of whats causing it
No errors in the console, just doesnt send a message when i type something in chat
Debug it
also
are you performing your code with Bukkit.getScheduler().runTask()?
if youre not, then do it
How can I split a world into squares with paths in between? Each square should have an ID
hi, i got a problem with my freeze command but the player does not get freezed
https://paste.md-5.net/itumivexol.java
tag me
use e.getPlayer().teleport(e.getfrom());
yes, but i don't want to do it. I am trying to do so players don,t be able to move afte some one in staff have done /freee (playername)
well i mean it has to be which way they are facing
so is player.setVelocity
yea, so apply velocity in the direction u want
going to change it based on their current movement?
it did not work
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
show current code
declaration: package: org.bukkit.event.player, class: PlayerMoveEvent
please just use this ^
a teleport inside the player move is a pretty not good idea
this is it
https://paste.md-5.net/isexalohod.java
yea u should do what lynx suggested
and its still wrong
trying to make it when a player has mined a block it becomes bedrock and then returns to normal again, however my code is not working. here is my code:
owner.getWorld().getBlockAt(miningLocation).setType(Material.BEDROCK);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask((Plugin)Main.instance, (Runnable)new Runnable() {
@Override
public void run() {
owner.getWorld().getBlockAt(miningLocation).setType(miningMaterial);
}
}, 100L);
please dont use a runnable for each block broken.
https://paste.md-5.net/cetusosizo.cs
cancelling the event does not actually cancel the event
it doesnt set it to bedrock, just keeps it
yes
how do i do it though?
wait
have 1 runnable
orrrrrr
it did not work
.
the location, time left and block to set
e.getPlayer().teleport(frozenplayers.get(e.getPlayer()));
this is what my friend coded but not working
..
You can even skip the teleport by using https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerMoveEvent.html#setTo(org.bukkit.Location) ๐ข
https://paste.md-5.net/cetusosizo.cs
Can anyone answer why the event is not cancelled by line 27?
or 7 in this ig
well probably because the nest does not exist
that does not work eather
Do you recommend calling async events on spigot listeners?
its the same???
is it possible to have a dictionary which accepts strings as keys and locations, materials and longs as values?
...
..
.
pyramid of periods
anyway
is it possible to have a dictionary with multiple types as values?
i really hope it is as it would be a shame to have to create multiple dictionaries
What do you need?
what?
i can stile move
so, is it possible
Hey,
I made a plugin which places structure evenly spaced between each other.
My current way to space them, is by going through every single structure and check if the distance is high enough.
Problem is... At some point this is extremely slow and lags out the whole server.
Does anyone know a better way?
anyway to differniate from a monster combusting from the sunlight or any other source
p.setLevel(100);
p.setExp(1);
p.setLevel(p.getLevel() - 1);
p.setExp(p.getExp() - 0.01F);
100 seconds
How can the number be changed and so that exp changes as it should
Here the school of experience and the level are reduced
Both go up to 0
Scheduler
no
It works
I want to make a number through which the player will kick
p.setLevel(100);
p.setExp(1);
task = Bukkit.getScheduler().runTaskTimer(AuthProtect.getPlugin(), () -> {
if (p.getLevel() < 1) {
p.sendMessage("kick");
} else {
p.setLevel(p.getLevel() - 1);
p.setExp(p.getExp() - 0.01F);
}
}, 30L, 20L);
yes
Oh fuck
how can i make a 5 * 5 inventory
Not possible
bru
Not in a clean way, that is
i mean i dont care about clean
You could block out the spaces in a 9*6.
its a personal project
3x3
It'd have to be a 9x6
Workbench
Then you just lock out the spots you don't want used
im tyna createa a inventory for a bingo that has 25 possbilityis
hm
so ig i mean 9 * 9
whats the not clean way
That's not possible either.
Not possible
I just gave it to you
There are only a limited number of GUI sizes that you can leverage.
There's really only one way to do it
how to make a 6 * 5 e i have never done this stuff
ahhhhhhhhhhhh
just create the max inventory
You can have any 9 x 1-6 inventories. You can use the 3x3 inventories for workbenches, droppers, etc. You can also use the 5x1 from hoppers.
which is?
6*9
ew
see how like, hypixel does it on skyblock etc
ye
Who can help me?
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
p.setLevel(100);
p.setExp(1);
task = Bukkit.getScheduler().runTaskTimer(AuthProtect.getPlugin(), () -> {
if (p.getLevel() < 1) {
p.sendMessage("kick");
} else {
p.setLevel(p.getLevel() - 1);
p.setExp(p.getExp() - 0.01F);
}
}, 30L, 20L);
What's the problem here? Gonna need an explanation.
I want to make sure I can drive seconds through the config
just made my first ever plugin that i actually semi finished
first resource at least
yeah
Wdym seconds?
I want it to be exposed through the config
What specifically? The interval at which the runnable runs? The experience to decrement? The delay?
Ok, then create a section in your config. Then grab the value using ConfigurationSection#get("path.to.your.value") and use it as needed.
What should I do with the experience?
I need to reduce both the experience and the level
Up to 0 smoothly
.-. This is your project. How would I know?
Well if you need it to go smoothly, then you'll need to use some math.
I'm asking how do I do this
That's what I couldn't do (
guys why is my recipes isnt loading?
I've written everything
Are you registering them?
I have like 4 recipes and none of them is working
I can't send screenshots here
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
Is there a way for the Client to See, If a Block is a Fake Block or Not?
?paste
Not directly no. You'd have to compare packets sent and received for both the player and the server. If they don't match then it's fake. Otherwise, it's legit.
U are my hero
package me.amxyargaming.testing.recipes;
import me.amxyargaming.testing.Testing;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
public class OpPickaxe {
private final Testing plugin;
public OpPickaxe(Testing testing) {this.plugin = testing;}
public void DiamondRecipe() {
ItemStack i = new ItemStack(Material.DIAMOND_PICKAXE, 1);
ItemMeta meta = i.getItemMeta();
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&cSuper Work &bPickaxe"));
meta.addEnchant(Enchantment.LOOT_BONUS_BLOCKS, 10, true);
meta.addEnchant(Enchantment.DIG_SPEED, 7, true);
i.setItemMeta(meta);
NamespacedKey key = new NamespacedKey(plugin, "super_work_pickaxe");
ShapedRecipe recipe = new ShapedRecipe(key, i);
recipe.shape(
"DPD",
" O ",
" O "
);
recipe.setIngredient('D', Material.DIAMOND_BLOCK);
recipe.setIngredient('P', Material.DIAMOND_PICKAXE);
recipe.setIngredient('O', Material.OBSIDIAN);
Bukkit.addRecipe(recipe);
}
}
``` can I just send it like this
@onyx fjord lol i have no idea how to make a dev api.
yeh my internet is shitty rn sadly
lmao
i might help u later
add src
would be interested though, something like a ChatChannels#createChannel() ? is that what you mean
okay the source is questionable
Player#switchChanngel for example
i don't know how to hook intellij to github
hm?
engnlish?
if u need fancy stuff then gitkraken
VCS ---> Github
i never did it from intellij itself
(btw nice dracula)
lmao
then how do I call it?
oh right, how do i do that then?
The same way you call any other method. ClassName.methodName().
it used to be fine before but now its all just broken
u have githuv desktop @sacred mountain ?
nah
shouldi download it
@sacred mountain Custom-made channels will not tab-complete. any particular reason why? i might help with that aswell
So this is My code and its suport to be freeze command player does not stop moving is stil poseble to move @quaint mantle
https://paste.md-5.net/usariwugan.java
currently its using an enum
ArgType<Channels> channelType = new ArgType<>("channel", s -> Channels.valueOf(s.toUpperCase()))
.tabStream(c -> Arrays.stream(Channels.values())
.map(Channels::getAbilityName).map(String::toLowerCase));```
i'm using redlib bbtw
@waxen plinth
show all of your code
it's still called abilityname woops
is it registered?
ok @onyx fjord i have git desktop
Cancel the event instead of using #setTo()
What do you mean?
also this
ctrl + n @sacred mountain
sorry what does this mean?
for the repo name, just ChatCHannels right
Have don it
Hello Guys. I want to get out of the config the members of every Guild to check if the player is in a Guild. I do this with :
Set<String> Guildsearch2 = Guildconfig.get().getConfigurationSection("Guilds" + Guildsearch + ".members").getKeys(false);
This shoud get me from every guild the members.
but i have a java.lang.NullPointerException: . How do i fix that?
ye
It's not shown in the code you provided. ๐
new OpPickaxe(this);
OpPickaxe.DiamondRecipe();
``` now good?
Does the array get updated with new instances?
no i dont think
ig time to learn redlib
Huh?
Well that's why
I live in 2 different places, can the local path be changed in future?
You tab complete using that array
So of course it's not showing the tab completions
ill just add more onto it
u can clone repo on any device if u want if thats what you mean
You said that you were cancelling the event. That statement doesn't match up with the code you provided.
not sure what that is but ok ill create the repo now
ok ive created the rep
what now
u should be able to upload it to github
is it possible to remove entities in onDisable? entity#remove() wont work since it only applies on the next tick
you're going to need to be more specific
i've never used github
in this, tell me what third button says
could we go to dms instead
@last temple is this now correct?
OpPickaxe op = new OpPickaxe(this);
OpPickaxe.DiamondRecipe();
ChainmailArmor ca = new ChainmailArmor(this);
ChainmailArmor.ChainmailRecipe();
TotemOfUndying tod = new TotemOfUndying(this);
TotemOfUndying.TOD();
EnchantedFoods ef = new EnchantedFoods(this);
EnchantedFoods.EChickenRecipe();
It's not.
The method DiamondRecipe is not static.
So he can't call OpPickaxe.DiamondRecipe();
hm yes agreed
it is static
- naming conventions, please name your methods with camelCase
ok i'm incredibly confused about using damageables, how the hell do i set the durability of an item?
ItemStack item = new ItemStack(Material.WOODEN_AXE);
ItemMeta meta = item.getItemMeta();
item.setDurability((short) 3);
meta.addEnchant(Enchantment.VANISHING_CURSE,1, true);
item.setItemMeta(meta);
respawnItems.add(item);```
i already made it all static lol
You don't need to though. ๐ You just need to learn the language.
i actually do want to use the var, how do i redo this static
Item damage is weird. I believe it counts upwards. So you can get the max durability and subtract what you need.
*abuse of static is bad
Facts. There are plenty of valid use cases for the static keyword.
Utility methods are a big one.
ok i got it fixed lol
OpPickaxe op = new OpPickaxe(this);
op.DiamondRecipe();
ChainmailArmor ca = new ChainmailArmor(this);
ca.ChainmailRecipe();
TotemOfUndying tod = new TotemOfUndying(this);
tod.TOD();
EnchantedFoods ef = new EnchantedFoods(this);
ef.EChickenRecipe();
ez pz
why would I do that?
You could also clean up your code by creating a method for registering the recipies.
public void registerRecipies() {
OpPickaxe op = new OpPickaxe();
op.registerDiamondRecipe();
op.registerChainmailRecipe();
op.registerChickenRecipe();
}
because it's more readable
but I like cases in every names
Conventions. It makes it easier for anyone that reads it to make sense of it.
If everyone is on the same page, it reduces confusion.
well because that's unneunnecessary
that's beacus i've tried it before
Unnecessary*
methods should be camelCase
fields should be camelCase
classes should be PascalCase
enums should be SCREAMING_SNAKE_CASE
It's Called Title Case And It's Fucking Terrible
why is it so impossibly hard to set the durability of a new item
Who Ever Speaks Like This Is Definitely Using A Phone
Or Is A 5 Year Old Who Doesn't Understand Basic Capitalization
XD
I think you mean:
methods should be lowerCamelCase
fields should be lowerCamelCase
classes should be UpperCamelCase
enums should be SCREAMING_SNAKE_CASE
also if you publish code that doesnt abide by naming conventions its not gonna look very professional
Hi so I'm having some issues with this plugin called ajqueue, and I asked the dev of the plugin and he said this, "ajQueue simply tells bungeecord to send the player. Bungeecord handles actually sending the player. We know ajQueue is telling bungeecord to send the player, so any issue after that would be either bungee or the target server"
lowerCamelCase is camelCase
UpperCamelCase is PascalCase
I was just going by the Oracle definitions. That's how they called it in the book.
hm, interesting
ok next question im asking is