#help-development
1 messages · Page 1773 of 1
that is what I did without gradle and maven, is it the same now that I have gradle? wouldnt it leave out the dependencies?
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class FlyCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player){
Player p = ((Player) sender).getPlayer();
boolean flying = false;
if(flying == false) { //
p.setAllowFlight(true);
p.setFlying(true);
flying = true;
System.out.println("Fly var is in !flying" + flying);
} else {
p.setAllowFlight(false);
p.setFlying(false);
System.out.println("Fly var is" + flying);
}
}
return true;
}
}```
@hollow spindle So i assume you only want it to be executed once right?
Can someone help me it keeps returning true
Yea, at the moment i think I have to use an internal variable to keep that in check
Yeah, the easy way is just to create a private field that keeps track with a counter
aye that seems to be the case haha
Called when an ItemStack is inserted in an enchantment table - can be called multiple times
create a hashmap and save your boolean on hashmap and that thing might be work perfectly
@static crane
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class FlyCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player){
Player p = ((Player) sender).getPlayer();
boolean flying = false;
if(flying == false) { //
p.setAllowFlight(true);
p.setFlying(true);
flying = true;
System.out.println("Fly var is in !flying" + flying);
} else {
p.setAllowFlight(false);
p.setFlying(false);
System.out.println("Fly var is" + flying);
}
return false //True or false
}
return true;
}
}
Nah the event fires 3 times, the entries looped 3 times per offer, totaling up to 9 logs
tnx
so i guess for each slot once then
Yeah that sounds about right
I'm glad that I could help you out

hehe
anyone know how to get the EntityEquipment for ArmorStand instance? I'm trying to set the armor stand's main hand into something but armorstand#setiteminhand() is deprecated
guys
i did login with Telegram
and my plugin weight is 10-11MB
how i can less my plugin weight?
are you shading spigot again
nope
you can always use external source like i said before
like to make everything dependencies in order to reduce weight?
How many dependencies are you shading?
Shade as few dependencies as possible and minify the jar
ok ty!
player.getEquipment().setItemMainHand(item here);
thanks!
Glad i could help you out

Hey, I'm programming a few plugins for a server of mine and I'd like to streamline the process as much as possible. I use maven, and I'd prefer to have all my external plugin dependencies available from a repository instead of having to include the jar files in my project directory.
Is there a service which packages spigot resources under a maven repository?
you can use jitpack for turning github repo into a maven repo, but it's free only if you repo is public, otherwise, you have to pay. https://jitpack.io/
These plugins may be proprietary, and listed on spigot without a link to a GitHub, but thanks for the suggestion. I'll make use of that elsewhere!
Wouldn't work for premium plugins anyways.
There are no premium plugins in my dependencies
Either way public repos are up to the author.
Would the best way be to just create a lib folder with the plugins in my project directory, and mark them as provided in the pom?
i mean you could also make a jar which contains every jar you need
so it would be your central jar jar
which you can shade into your jar
so you have a jar jar jar
But if the servers in question already run the plugins and I shade the dependencies into the jar, wouldn't that cause potential conflicts?
At the very least it would increase the plugin size
I assume they meant a big jar for dependency
But I don’t know why you’d bother doing that
so just mark them as provided
I don't see why making a monolithic dependency jar would provide any benefits over including them individually
Only if you run their onEnable methods
Right, thanks
Remember though shading adds the entire plugin to your resource, so if you give out the jar to others you need the authors perms.
you can use the free jfrog artifactory software
no fees if you are on the free plan, and also its forever
for dependencies (non plugin) use the libraries entry in plugin.yml
Thank you so much!
can someone give me a basic help or information that how can i make a plugin, when u right click a item with enchanting book, the item gets enchanted, there will be no use of anvils
InventoryClickEvent, getCursor, and addEnchantment
um is it simple to make?
hope its not complicated
ye ik
depends on how far your knowledge is
to build my plugin for a different server version, do i have to change the dependency 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT'? or just the api-version: 1.17 in plugin.yml
why build for different server version?
one plugin can work on multiple versions
just have to check if u use version specific things
I tested my plugin on a 1.17 server and it worked, then I moved it to a 1.8.9 server and it's not working, when i do /plugins it is marked as red
Because its made for 1.17 lol
rewind?
viaversion. will prob do
I cant update the server to 1.17, i have to build the pl for 1.8 but idk what to change to do so
I already have viaversion, rewind and backwards btw
would 1.8 plugins still work? some of them are legacy af and not updated anymore
so my choice here is to either find out how to build 1 plugin or recode half of the plugins I use & get annoying players to cry about it .-.
You dont need to recode your plugin for each version
Determine the lowest spigot version that your plugin will work on
Java is backwards compatible not upwards
only if you need pve. Pvp with OCM is the worst thing inventend by humanity
com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated object at line 1 column 35 path $.extra[0].bold
How? My JSON is valid, I have used serval online JSON parsers
Something’s obviously not syntactically correct
any help with this?
is it normal that chunkSnapshot#getBiome(x, y, z) doesn't return the acutal biome that is gonna get generated?
ChunkSnapshot chunkSnapshot = world.getEmptyChunkSnapshot(x,z, true, false);
int chunkBlock = chunkSnapshot.getHighestBlockYAt(7, 7);
if (chunkSnapshot.getBiome(7, chunkBlock, 7).equals(Biome.FOREST)) {{
//saves the coordinates for teleport the player when needed
}
Is that:
public static <T> void async(Supplier<T> task, Consumer<T> callback) {
BukkitScheduler bs = Bukkit.getScheduler();
bs.runTaskAsynchronously(plugin, () -> {
T returnValue = task.get();
bs.runTask(plugin, () -> callback.accept(returnValue));
});
}
```the same as that:
```java
public static <T> void async(Supplier<T> task, Consumer<T> callback) {
BukkitScheduler bs = Bukkit.getScheduler();
bs.runTaskAsynchronously(plugin, () -> {
bs.runTask(plugin, () -> callback.accept(task.get()));
});
}
```I'm unsure if `runTask` is executed before `task.get()`
guys how to detect right click on a specific block?
PlayerInteractevent
PlayerInteteractEvent
PlayerInteractEvent
ik how to detect the right click but how to make it detect on a specific block that it clicks on
check the type of the block
woops
o:
how?
block#getType
event.getBlock().getType()
And make sure that the block is not null, because it can
How can I ask here some question, that requires to post a screenshot?
You are not verified ig
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (e.getClickedBlock() != null) {
Player p = e.getPlayer();
e.getClickedBlock().getLocation();
p.sendMessage("§7test event");
}
}
``` so how?
verify first i think
Hmm, that's a problem, because I have bugged the verify system, that I can't verify
if you only accept right click block, the block cant be null no?
or does air block counts as null?
Theoretically yes, but a safety check doesn't hurt
it does 
alright so how do i make it detect a specific block?
check if the type equals a material you choose
e.getClickedBlock().getType() == Material.SOME_TYPE
^ for example
wait i put it in an if statement right?
yes
if (e.getClickedBlock().getType() == Material.block)
you need both
if (e.getClickedBlock() != null && e.getClickedBlock().getType() == Material.block)
null check and type check
oh thanks
Hi Elgar, can you help me?
alright so
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (e.getClickedBlock() != null && e.getClickedBlock().getType() == Material.OAK_STAIRS) {
Player p = e.getPlayer();
e.getClickedBlock().getLocation();
p.getWorld().spawnEntity(p.getLocation(), EntityType.ARMOR_STAND);
p.sendMessage("§7test thing");
}
}
``` is this correct?
Looks good
no runTask is executed teh next tick
Okay, so task.get() is executed async even if i already pass it as argument?
when you schedule anything it attempts to run in the next tick
doesn;t matter if sync or async
its processed next tick
ok, so the both code snippets are equivalent
i mean it would be weird if they were not, but it somehow looks wrong idk
they look the same to me
Ok so I can summarize it to bs.runTaskAsynchronously(plugin, () -> bs.runTask(plugin, () -> callback.accept(task.get())));
Thankyou :)
guys what does this mean
[00:02:25] [Server thread/ERROR]: Could not load 'plugins\My plugin testing.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: Cannot find main class `amxyargaming.testing.Testing'
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:73) ~[patched_1.17.1.jar:git-Paper-266]
at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:153) ~[patched_1.17.1.jar:git-Paper-266]
at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:414) ~[patched_1.17.1.jar:git-Paper-266]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:322) ~[patched_1.17.1.jar:git-Paper-266]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.loadPlugins(CraftServer.java:410) ~[patched_1.17.1.jar:git-Paper-266]
at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:276) ~[patched_1.17.1.jar:git-Paper-266]
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1212) ~[patched_1.17.1.jar:git-Paper-266]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[patched_1.17.1.jar:git-Paper-266]
at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.ClassNotFoundException: amxyargaming.testing.Testing
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:146) ~[patched_1.17.1.jar:git-Paper-266]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:103) ~[patched_1.17.1.jar:git-Paper-266]
at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
at java.lang.Class.forName0(Native Method) ~[?:?]
at java.lang.Class.forName(Class.java:467) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:71) ~[patched_1.17.1.jar:git-Paper-266]
... 8 more
It can't find your main class
that no amxyargaming.testing.Testing class exist
did you put your class in proper package? is your class name in plugin.yml and in actual project same?
oh
my plugin yml is
name: Testing
version: '${project.version}'
main: amxyargaming.testing.Testing
api-version: 1.17
authors: [ amxyargaming ]
description: yuh
and where is your actual Testing.java file located?
right so your package name is wrong
change main to me.amxyargaming.testing.Testing
in plugin.yml
you need me.amxyargaming.testing.Testing
mm.
its okay now?
looks alright to me
yes
alright thanks!
man I hate that I have to have my forum name, wanted to ditch that long ago
lol
Explain what does Object is an instance of an Class mean ?
?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.
Probably is explained in one of those
this is help channel for spigot development, not java basics. please consider asking help in java related channels/forums
yup
OK
Which one is the best ?
/most recomended
just google it
docs oracle
or this too
i mostly google it online
sorry if i sound dumb here but what does this mean
Error occurred while enabling Testing v1.0 (Is it up to date?)
java.lang.IllegalStateException: Duplicate recipe ignored with ID testing:super_work_pickaxe
at net.minecraft.world.item.crafting.CraftingManager.addRecipe(CraftingManager.java:89) ~[patched_1.17.1.jar:git-Paper-266]
at org.bukkit.craftbukkit.v1_17_R1.inventory.CraftShapedRecipe.addToCraftingManager(CraftShapedRecipe.java:58) ~[patched_1.17.1.jar:git-Paper-266]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.addRecipe(CraftServer.java:1371) ~[patched_1.17.1.jar:git-Paper-266]
at org.bukkit.Bukkit.addRecipe(Bukkit.java:831) ~[patched_1.17.1.jar:git-Paper-266]
at me.amxyargaming.testing.Testing.onEnable(Testing.java:69) ~[My plugin testing.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[patched_1.17.1.jar:git-Paper-266]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.17.1.jar:git-Paper-266]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.17.1.jar:git-Paper-266]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:535) ~[patched_1.17.1.jar:git-Paper-266]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:449) ~[patched_1.17.1.jar:git-Paper-266]
at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:725) ~[patched_1.17.1.jar:git-Paper-266]
at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:306) ~[patched_1.17.1.jar:git-Paper-266]
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1212) ~[patched_1.17.1.jar:git-Paper-266]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[patched_1.17.1.jar:git-Paper-266]
Duplicate recipe ignored with ID
probably you copy-pasted them and forgot to change ids?
hm wait
lemme show
NamespacedKey key = new NamespacedKey(this, "super_work_pickaxe");
this the id right?
this is your plugin instance
let me just show the thing
show the other
ItemStack i = new ItemStack(Material.DIAMOND_PICKAXE, 1);
ItemMeta meta = i.getItemMeta();
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&',"&cSuper Work &bPickaxe"));
i.setItemMeta(meta);
i.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 3);
i.addEnchantment(Enchantment.DIG_SPEED, 3);
NamespacedKey key = new NamespacedKey(this, "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);
``` this is the first recipe
ItemStack item = new ItemStack(Material.TOTEM_OF_UNDYING, 1);
ItemMeta m = item.getItemMeta();
m.setDisplayName(ChatColor.translateAlternateColorCodes('&',"Totem Of Undying"));
item.setItemMeta(meta);
NamespacedKey k = new NamespacedKey(this, "totem_of_undying");
ShapedRecipe r = new ShapedRecipe(key, item);
r.shape(
"GGG",
"GEG",
" G "
);
r.setIngredient('G', Material.GOLD_BLOCK);
r.setIngredient('E', Material.EMERALD);
Bukkit.addRecipe(r);
``` this is the second
When are you running this
yes?
That might be why
oh
Idk if it unregisters recipes when you do /reload
oohh
wait let me
stop and start
i stopped it and then start it again but still says the same thing
hm
unless you are unregistering them they are there permanently
unregister them in onDisable, maybe?
or just check for their existance before you attempt to recreate/register them
Recipes are saved persistently? :o
though guide from wiki don't say anything about that. according to that guide amxyargaming did everything right: https://www.spigotmc.org/wiki/recipe-example/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
hm
well heres something i did to fix it
i removed the second recipe
but now its telling me the commandexecutor is null which i think is because i didnt put them in the plugin.yml so im trying it rn
commands:
hello:
usage: /hello
description: hi
minus:
usage: /minus
description: yes
``` is this how to write the commands in plugin.yml
yeah, so they're both going to be named superpickaxe whatever
You already made the other NamespacedKey for totem_of_undying, it's called k.
So just use that in your recipe constructor
huh?
ShapedRecipe r = new ShapedRecipe(key, item);
You should be making that with k, not key. key is the other NamespacedKey for super_work_pickaxe
ooohhh
i see it now
thanks you
also is there a way for me to put these recipes in one class
it hurts me to see them out in the open in the main class
Yes, you can
how?
also the thing is fixed, it loads in without any error now
yey
but where do i need to make a class for it to be alone
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (e.getClickedBlock() != null && e.getClickedBlock().getType() == Material.OAK_STAIRS) {
Player p = e.getPlayer();
e.getClickedBlock().getLocation();
p.getWorld().spawnEntity(p.getLocation(), EntityType.ARMOR_STAND);
p.sendMessage("§5test");
}
}
``` how to make the armor stand spawn in the block
e.getClickedBlock().getLocation().add(0.5,0.5,0.5)
also dont use color char §
thanks
then? use ColorChat?
ChatColor*
oop
well this is just a test first
so later ill use chatcolor
im just seeing if i can do the code first then play with it yk
like this ChatColor.translateAlternateColorCodes('&', string)
ik-
whats even wrong with that? The fact that some systems replace it with a square?
i know how to use chatcolor 💀
not that i use it
why not 😐
right?
its not like chatcolor does anything else
ChatColor.RED + "No!"
also why did this not work
you use it in the spawn call
where?
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (e.getClickedBlock() != null && e.getClickedBlock().getType() == Material.OAK_STAIRS) {
Player p = e.getPlayer();
e.getClickedBlock().getLocation().add(0.5,0.5,0.5);
p.getWorld().spawnEntity(p.getLocation(), EntityType.ARMOR_STAND);
p.sendMessage("§5test");
}
}
NMS; 1.17.1 | Pathfindergoal doesn`t work properly
actually yes, it may cause problems on some systems, why just don't avoid using it? why to put yourself into a potential trouble?
...
you didnt listen to what elgar said
the new location is e.getClickedBlock().getLocation().add(0.5,0.5,0.5)
thats what i did no?
no
youre just doing e.getClickedBlock().getLocation().add(0.5,0.5,0.5); and ignoring its output
Can anyone help me - when teleporting a player I get this error: java.lang.IllegalArgumentException: location.world?
you still using p.getLocation() in spawnEntity method
location.getWorld()
the new location is the output of e.getClickedBlock().getLocation().add(0.5,0.5,0.5)
what?
my server is saying there isnt a plugin.yml file in my plugin but there is and it is formatted correctly
where do i put it?
where it is located?
src
This error comes up when executing this:
player.teleport(teamOneSpawn);
where you put the p.getLocation() in your spawnEntity
ooohhh
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (e.getClickedBlock() != null && e.getClickedBlock().getType() == Material.OAK_STAIRS) {
Player p = e.getPlayer();
e.getClickedBlock().getLocation();
p.getWorld().spawnEntity(e.getClickedBlock().getLocation().add(0.5,0.5,0.5), EntityType.ARMOR_STAND);
p.sendMessage("§5test");
}
}
``` is this correct?
can you screenshot your directory in plugin project
also why the e.getClickedBlock().getLocation()
almost, just remove line
e.getClickedBlock().getLocation();
oh ok
move it outside of package "org...."
alright it works the armor stand spawns on it
but how do i make the armor stand spawn in it
like one block under it
when I'm doing
player.teleport(teamOneSpawn);
where teamOneSpawn is a location, I am getting the error:
null
Caused by: java.lang.IllegalArgumentException: location.world
can someone tell me whats happening here?
add(0.5,-1,0.5)
replace add(0.5, 0.5, 0.5) with add(0.5 -0.5, 0.5)
oh ok
or -1
well i want the head of the armor stand at the middle
what is ur import
then play with it
import com.mini.minimcc.lobby.SendToLobby;
import com.mini.minimcc.minigames.GameType;
import com.mini.minimcc.teams.TeamManager;
import com.mini.minimcc.util.SendTitle;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
I should note that afterwards it says
com.google.common.base.Preconditions.checkArgument(Preconditions.java:141)
can u send ur entire method or class
and the entire stacktrace
ok
Your world doesn't exist
not loaded
as all the other classes have no trouble accessing it
elgarl do you know how to ride an entity
also I am in the world at the time
that error is saying teh world is invalid, its not loaded
oop thanks
how do I fix this
full err log ?
where are you setting the location?
If I restart the server the error comes up until I do /reload and then the error doesnt come up
public static Location teamOneSpawn = new Location(Bukkit.getWorld("MCC"), -258, 9, 324);
thats why
what?
i didnt understand any of this
a static variable is initialized before the worlds are loaded
hmm ok
can someone tell me how? 😅
you need to set yoru location at teh earliest in onEnable
entity#addPassanger(Entity)
I think I understand
what-
entityYouWantRide.addPassanger(entityPassanger)
why does everyone put # instead of . when showing the methods thing - surely it shoyuold be entity.addPassenger
sorry i still dont get it let me watch a youtube tutorial
that means it isn't a static method
No
it's how you reference an instance method in javadoc.
It's just for referencing in documentation/talk https://www.reddit.com/r/javahelp/comments/593ppb/what_is_the_meaning_of_a_hashtag_symbol_as_method/
~~an instance method?
one that isn't static
I mean you can reference static methods the same way
a static method isnt an instance method?
No
No
because you don't need an instance of an object to call it
does that mean it isnt or it is? just no
It's not
but in the program it has a dot so surely it'll confuse ppl
well i say it is not static 🌝
If you know enough Java, you'll know that a # isn't used for calling methods 
use . or use # I use both so don;t care 😉
^ It doesn't really matter
yup
I mean Elgar uses semicolons instead of apostrophes, but we know what he means anyways
why are we even arguing about this 😆
and teh
Yeah that too lol
consider example you have myStaticMethod static method and myMethod in MyClass.
how would you write them?
MyClass.myStaticMethod();
MyClass.myMethod();
how people understend which one is static and which one is not?
It's probably the one that has static in the name 
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (e.getClickedBlock() != null && e.getClickedBlock().getType() == Material.OAK_STAIRS) {
Player p = e.getPlayer();
Entity entity = Bukkit.getWorld("world").spawnEntity(e.getClickedBlock().getLocation().add(0.5,-1,0.5), EntityType.ARMOR_STAND);
p.sendMessage("§5test");
}
}
``` how to make the armor stand invisible
We can't just write this plugin for you
i know how to make it invulnerable
You need to Google some stuff and figure things out for yourself
pls, help - #910575582536958032
.setVisible(false);?
armorStand.setVisible(false) - both: invisible, invulnarable
full code?
🧠
you still havent figured it out?
Does anyone know which event i must listen to avoid the "no damage" sound?
Currently tried EntityDamageByEntityEvent, but it seems not be triggered. And PlayerInteractEntityEvent seems only for right click.
oh hey morice
Well, more then register the event and print debug things to check it isnt possible?
No
As i said: "Currently tried EntityDamageByEntityEvent, but it seems not be triggered. And PlayerInteractEntityEvent seems only for right click."
The event works fine, but this not works in case of "no damage"
is there a EntityDamageEvent?
isn't it that one?
@wraith kettle
smh why am i tagging people
You mean for my problem?
yes
No, the player is still alive.
But if you just spam attack, then "ENTITY_PLAYER_ATTACK_NODAMAGE" sound will be played.
And try to "listen" on this event
Damage
This event will only be triggered for me if there are any damage
Probably packets then? But I'm no sure
it has to work with an event
I do that already to disable this sound. But i want it only disabled on attack
i'm sure
Why not prevent players from hitting eachother with teams. That would solve your issue
I only want to disable the sound. Not disabling pvp
Oh
oh
hmm i just check the javadoc and still cant find any event that seems to work in this case
Yeah, the problem is, that i not want to disable it all over the time.
Only if a player tries to attack an player
hey can some help me? and yeah yeah I know don't ask to ask, but my thing will fill up the whole screen lol
?paste
so when you say anything in the server it gives an error in the server console
it's like "event (or e) AsyncPlayerChatEvent can not pass to EternalPlugin v1.0"
wait what am i looking at?
basically I'm trying to highlight someone's name when it's mentioned in a message
and make like a ping sound
basically chat colors but only on a person's name
Ok i found an event 😄
EntityDamageEvent
you are trying to cast a Player object to a CharSequence
but would that cause a AsyncPlayerChatEvent error?
yes
oh lol
its an impossible cast
it said it needed to be a char sequence
you read it wrong
are there alternatives?
@EventHandler
public void onChat(PlayerAsyncChatEvent event) {
Player player = event.getPlayer();
Bukkit.getOnlinePlayers().forEach(p -> {
if (event.getMessage().contains(p.getName()))
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1.0f, 1.0f);
});
}``` i guess
I'm taking about when I used strings
me liking .forEach 
I have to go through the player list to make sure it's a person
for (Player player: Bukkit.getOnlinePlayers()) {
if (message.contains(player.getName())) {```
the code you sent would highlight the sender's name if they said it
I think
oooooh
alright thanks man
why do you like forEach
@eternal oxide would that loop through every player and find a match though?
that's what I previous code kinda did
im struggling with this armor stand thing rn
like a for loop or whatever it's called can't think atm lol
it spawns on the block but when i ride it i float
screenshot?
why do i float
can't you adjust the posistioning?
i tried but some of it just makes me sit inside the block
adjust teh y position when spawning
hold on
but yeah @eternal oxide should I just use my old looping method?
does the code that you sent me loop it?
That is a simple for loop
so when you check if the message has anyone from the player list does that loop through every name?
yes, thats what the for loop is for
if its -1 it stil float but if i make it -1.1 and so on, it breaks it
i tried -0.5 and so on stil didnt work
breaks?
i mean like it still makes me inside the stair
and -1 makes you float?
yup
disable teh AI on the stand. It probably has none, but it will prevent anything affecting it
okay let me try
it will not be affected by gravity
i made it "stand.setAI(false);
I have a question about the Mojang API. Do I have to integrate a system to not go over the request limit or should I just get the info from the API itself?
yeah this looks like it'll work. thanks again @eternal oxide
for whatever I forgot player.getName() existed so I was sitting there wondering how to get a string xD
oh should I check the message for the player name instead?
(instead of the Player)
nvm it already is I'm blind
lol thanks though man
could use Player#getDisplayName() instead, it is sometimes diffrerent
a custom name of entity
is it like one of those floating texts
if visible set to false, player will see the name only if he targets entity
declaration: package: org.bukkit, interface: Nameable
yeah.. you can use this for it
Does anyone know how to silently run a console command?
I can run it but I don't want to see feedback in the console
uh i dont think thats a thing?
do you mean you want to run a command without console detecting it?
There is a gamerule called logAdminCommands. If set to false, command feedback will not be sent to the console anymore.
If you mean that
what is a good workaround for a custom itemstack to continue working after its enchants or durability changes? could it be ItemStack#isSimilar ?
isSimilar compares all bar stack size
Use pdc to identify custom items
if you want to detect your custom items add to its PDC
?pdc
i remember long ago
Since when does PDC exist?
1.14
Im using 1.16 and ItemStack has only Metadata and no PDC
On 1.13 there's an deprecated alternative
Or is it the Meta?
Yes meta
Aight
help
i forgot how can i check what pdc it has
something like
.getItemInMainHand()
further i forgot
Its in the item meta
.getItemMeta
Yes, you have to set ignoreLevelRestriction to true
oh
For example: item.addEnchant(Enchantment.WHATEVER, 10, true)
im too lazy to start up my localhost, this should work... right?
oh wait how to add this to a custom recipe
or i cant
i.addEnchantment(Enchantment.LOOT_BONUS_BLOCKS, 8, true);
``` because this clearly doesnt work
Hello, I need help with BuildTools
public ShapedRecipe getRecipeProt(){
ItemStack item = new ItemStack(Material.ENCHANTED_BOOK);
NamespacedKey key = new NamespacedKey(this, "prot_six_book");
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item.getItemMeta();
meta.addStoredEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 5, true);
meta.setDisplayName(ChatColor.GOLD + "Enchanted Book");
List<String> lore = Arrays.asList(ChatColor.AQUA + "Apply this book to your armor", ChatColor.AQUA + "To get this custom enchant", "", "§6§lLEGENDARY");
meta.setLore(lore);
item.setItemMeta(meta);
ShapedRecipe recipe = new ShapedRecipe(key, item);
recipe.shape("KHK",
"CAL",
"KBK");
recipe.setIngredient('H', Material.DIAMOND_HELMET);
recipe.setIngredient('B', Material.DIAMOND_BOOTS);
recipe.setIngredient('C', Material.DIAMOND_CHESTPLATE);
recipe.setIngredient('L', Material.DIAMOND_LEGGINGS);
recipe.setIngredient('K', Material.BOOKSHELF);
recipe.setIngredient('A', Material.BOOK);
return recipe;
}
``` this is code for a protection 6 book
Use the item meta
yes,
meta.addStoredEnchant(Enchantment.YOUR_ENCHANT, LEVEL, true)
for an enchanted book ^^
or just meta.addEnchant
if you want an enchant for a weapon or something, then do
meta.addEnchant()
okay
okay so i need to
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item.getItemMeta();
``` add this?
and then do meta.addEnchant() ?
if thats for a book
then yes
but instead of .addEnchant
do .addStoredEnchant
BUT
if you want it for a custom itemstack
then do
ItemMeta meta = item.getItemMeta();
and do meta.addEnchant
thats what i did before-
itemstack
ah
lol
ok brb
okie
lets move this to dms so less polution
Or just open a thread lol
how would i go about making a crafting table inventory similar to that of hypixel skyblock's where i can give multiple amounts of item for a single recipe
Thats hard
So I'm trying to detect if a block exists or not after an explosion in the EntityExplodeEvent. However, whenever I blow up the block i'm checking, and the event triggers, it says the block is still there (event though it isn't)
here is my function:
@EventHandler
public static boolean onExplosion(EntityExplodeEvent event) {
if (gamePlaying) {
for (Block b: event.blockList()) {
if (b.getType() == Material.GOLD_BLOCK) {
Block block = new Location(Bukkit.getWorld("mcc"), -260, 10, 324).getBlock();
System.out.println(block.getType());
if (block.getType() != Material.GOLD_BLOCK) {
allowedAcrossVoid = true;
teamOneRespawn = false;
for (UUID uuid : teamOne) {
Player player = Bukkit.getPlayer(uuid);
assert player != null;
player.sendMessage(ChatColor.RED + "Your gold is destroyed! You can no longer respawn!");
}
for (UUID uuid : teamTwo) {
Player player = Bukkit.getPlayer(uuid);
assert player != null;
player.sendMessage(ChatColor.GOLD + "You destroyed the enemy gold!");
}
return true;
}
Even though I blew up the gold block, the console still outputs that it is there?
Afaik, they map recipes through hashing a max of 9 ingredients, to make it fast. Then the matrix logic is somewhat similar to what spigot normal minecraft got, so you might wanna look into that.
still, any ideas?
afaik?
static boolean no no
I did that so the loop would stop when I found the block
normally eventhandlers have to be a non static void method no?
that could be a problem
but it's still running fine
just not doing what it's meant to
means As Far As I Know
Wtf
what
oh
iirc it can be static
could you elaborate a bit please
Since Bukkit just loops through your listeners declared methods and then just filter them based if they’re annotated or not.
I’m not an expert surrounding maths but I assume you want a 3x3 crafting implementation?
oh
eh wanted to say that static event handlers may not work on paper because of asm method executors
yes
for the changing of the barrier block into the crafted item i can either do a bukkit runnable to check every 10 ticks or so, what the player puts in the crafting inventory or just inventory click event to find out when the player put something
typing intensifying intensly
What you probably want is to have one square matrix with size 3, which mirrors what the player puts in the gui. Then for every recipe I’d suggest having a separate matrix. And yes, the matrix class will have to be implemented by you.
Once you’ve got that, with the proper methods of course, you might want to map the recipes with a Map<Matrix,Recipe>.
Now, when a player puts down an item, you just fetch the item/material, and then put it in square matrix that is supposed to mirror the player’s input in the gui. Then you try accessing the recipe through the matrix with Map::get simply. Now for this to work, it requires you to properly hash every material/ingredient and also properly hash the matrix itself.
And for your question, using InventoryClickEvent would do fine here.
inv click event prob
What I wrote now might not support shapeless recipes
Consumer<InventoryClickEvent> 
But usually you could just, if the Map::get fails, take the ingredients and match them non ordered to another map which keeps track of the shapeless recipes.
is this intented to work with recipes that has 2x1 or 3x1 shapes?
i have a code
i do not understand it
but it effectively recreated the crafting table
if someone could explain it I would be very glad
Yeah, of course you’d need to properly deal with the empty ingredient or whatever you call that
the code
ew List<Integer> craftingSlots = new ArrayList<>();
craftingSlots.add(10);
craftingSlots.add(11);
craftingSlots.add(12);
craftingSlots.add(19);
craftingSlots.add(20);
craftingSlots.add(21);
craftingSlots.add(28);
craftingSlots.add(29);
craftingSlots.add(30);
Arrays.asList(10, 11, 12,...)
xD it isnt my code
Yuh the code seems to be running with a time complexity of O(n) where n is the amount of recipes if I haven’t read that wrongly
Which is probably not a huge deal in your case
code can be simplfied many times
how
One instance is what FourteenBrush just mentioned
ArrayList() without passing anything to its constructor will use an array of length 10, which is somewhat unnecessary. With the assumption they’re not in need of expanding the list.
im almost a beginner just tryna have a custom crafting table ;-;
and it made me wonder why tf is it not a thing on spigot
The primary issue is that it may be slow
i did remember i proposed an algorithm, but not really anyone implemented it tbh
but it is to use a hashed base database and combine all 9 slots into a key
but i have to think some more for shapeless recipes
i have no clue about what u just said :D
How do I teleport a vehicle with passengers on it? The Entity#teleport() method does not seem to work for it.
anyone here using intellij minecraft development plugin to make plugins?
I need help, when I build my plugin to .jar file it doesn't obtain source code classes
Well
Are you using maven?
You could make just hash the ingredients unordered, if it happens to be the case there is no such shaped recipe with the given ingredients.
And then have another hash table for the shapeless recipes
so?
Of course it doesn’t give you source code classes
no just java extends library
Java compiles down to jvm bytecode
i thought of download the lastest to fix it
Anyone knows how to solve this, don't really want to have to write a replacement for the Entity#teleport() method.
The entity I'm trying to teleport is:
You d have to
How would I go about saving a hashmap with string keys and arraylist of ints as value
but when I decompile .jar file it shows older code than what it should be
depends on how you want to save it. I would probably try to use json for that, or maybe mongodb (if there's a java repo for that)
what for thing is that?
ah a boat
tell me 
Hmm, its a bit more complicated than that, its a minecart riding a boat riding a minecart (and more, but I don't remember fully)
Correction... XD :
"cow riding a Minecart with a chest, which is riding a boat, which is riding a minecart.
riding the same minecart is a cod, riding an axolotl.
Loads of tags and nbt as well."
its the same like teleporting a player on a horse i guess
the horse wont get teleported
i really have to check it out
i swear it is just to there annoy me
i didn't have that in my old plugin
satan looks under his bed every night making sure that thing isnt there
is json faster than yml
Yes. Yaml is more made for config files
I need help, when I build my plugin to .jar file it doesn't obtain source code classes, when I decomiple it, it has older code in it
im trying to log some stuff in the console but is doesnt look like getLogger().info(); accepts things not in ""s
I don't know the compiler your using.. but it feels like you haven't included the Towny API repository
pls use maven / gradle
the logger use string maybe you can use itemJsonReader.toString if this class handle correctly this..
Im getting StreamCorruptedErrors while trying to read from sqlite3 bytes, does anyone know the issue?
I personally think the problem is caused by the fact that im not writing the correct bytes, but I don't really know.
Heres my toByteArray function
public static byte[] toByteArray(Object object) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream output = new ObjectOutputStream(bos);
output.writeObject(object);
byte[] result = bos.toByteArray();
output.close();
bos.flush();
bos.close();
return result;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
send a full stack trace. What objects are you serializing? What data type you use for bytes in your sql?
Use try-with-resources instead of .close()
so? will anyone help?
try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(bos)) {
// ...
}
You set the damage to the final damage you desire and then you set the damage again but this time you set it to the damage you wanna do squared divided by the final damage
I'll send a better example when im at my pc later
How can you register the instance of essentialsx?
What
I'd like to store the instance of Essentials within my plugin so I can access things such as: essentials.getUser(player).isMuted()
PluginManager.getPlugin("Essentials")
have you checked that line
what
fUnNy
what?
Works perfectly!! Thank you java private boolean setupEssentials() { if (getServer().getPluginManager().getPlugin("Essentials") == null) { return false; } this.essentials = (Essentials) getServer().getPluginManager().getPlugin("Essentials"); if (this.essentials == null) { return false; } return true; }
hell I'm pretty sure IDEA lets you click the file link to jump to that line
i didnt make a joke
well your end quote is missing somewhere
error here
inefficient
use ""
'' is for single characters like 'A'
You can’t use ‘ ‘ for strings in java
"" is for strings
This ain’t python or js
"a" = string; 'a' = char
||never gonna give you up||
after the change, even worse
i wish it was python 
same
what would you recommend
You dont need to get Essentials 2 times :)
Separate the getPlugin's return value into its own variable.
Check if that variable is null, if not, set your field to it and return true, otherwise return false.
You don't need to check if the variable you just set to a non-null value is non-null.
And you don't need to call the same method twice.
I was thinking that, yeah 😅 I just wrote it quick to see if I could actually do it
Thanks :>
still does not work
private boolean setupEssentials() {
Plugin essentials = getServer().getPluginManager().getPlugin("Essentials");
if (essentials == null) {
return false;
}
this.essentials = (Essentials) essentials;
return true;
}```any more suggestions?
you could actually cast essentials to Essentials on declaration but it makes no difference
also this would throw a NoClassDefError on Essentials not being found I believe but that's a harder problem to solve
Does just having the import throw ncdf
I believe if it's part of the constant pool, yes.
Or do you need to actually hit code that uses the import
if (!setupEssentials() ) {
Bukkit.getLogger().severe(("[Yu-Craft] - Disabled due to no Essentials dependency found!"));
getServer().getPluginManager().disablePlugin(this);
return;
}```I have this in the onEnable to just disable it
Since the classloader resolves all dependency classes from the ctpool.
Is Essentials necessary for your plugin to run?
What if you only use the import in local scope
Not yet, but I plan to add features that would require it such as checking if a player is muted or not within Essentials
Imports are technically fake.
import java.lang.String; just tells the compiler to turn String into java.lang.String
So it should be fine if the code never references it
Sure, but the constant pool is the first thing loaded in a class, and that will always contain Class entries.
I don't actually know how the classloader resolves classes but I'm pretty sure it looks at the ctpool first.
hey am interested in pvp plugins with minigames any tutorials someone can suggest me PLEASE
cuz i cant see to find any
This is why referencing other plugins is annoying
indeed
Gotta have all the stuff in its own class that isn’t touched unless the plugin is present
actually gimme a sec I'll make a small test
hey what are the tutorials you watched when you first started ?
I'm not actually sure thats always true
obviously good advice though
Oh gosh I don’t know if the person I watched even still exists
Do you know java already
Java was not designed for soft dependencies.
no
learn Java
?learnjava first
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.
you cannot go from 0 to creating minigames plugins
Trust me, it will save you some forehead wrinkles
the concept is too complicated for someone who does not know the language
I wouldn't recommend Codecademy or Oracle's.
The mackup in the document following the root element must be well-formed
Codecademy is only good if you have their subscription, otherwise you can only go through a crash course
And Oracle's is not designed for beginners, plus is just ugly to look at.
F
then where i learn it ?
You can only have one root tag in an XML file.
wut i'm doing wrong?
hey i need some help, i accidentally removed a method and its not in my local file history on eclipse;
i forgot how to get the difference between two timestamps
you just remove timestamp 1 from timestamp 2, right?
so like...
long - long
okay
its just to format the dates
because SimpleDateFormat wasnt getting the job done
so that should in theory work?
why isnt SDF getting the job done
dont reinvent the wheel
java is smarter than you
Java has Date and Time
@young knoll I found out you can avoid class def errors.
SimpleDateFormat("dd", ' days, ', "MM:ss"); then?
how do you change a horse variant now?
Framework is literally just a generic class that has a method that only returns false for this purposes.
Dependency is empty, and although I compile it alongside the other classes, I delete its class file before running.
So ye, conditional resolution.
Variant doesn't work for me
how long have you been doing it and can i see some plugins you made ? just curious to get an idea xD
your terminal wtf
2 years.
if you dont mind me asking of course or idk
do you hate yourself
Nope I'm just a fan of style.
I’ve been messing with spigot for 9 years now I believe
You can see stuff in the GitHub linked to my discord
The plugins I have made were shit and I made them when I was a beginner so I just ended up deleting them.
I think my old plugins are still somewhere on my hard drive
this
But if I don’t look at them, are they really even there
Oh nice
I think 3 in just a few months.
What plugins u made ?
Again, they were shit so I deleted them. I haven't made a plugin since as I haven't had any ideas.
I made this framework: https://github.com/Spigot-MSPL
Although I have yet to use it
Or test it
And I'm unsure if it's even good.
Lol
Oh i understand that
Honestly eventually I might just split this thing up into its actually unique functionalities.
how should i format the remaining hours, and minutes in the formatDatesAs
because im looking at https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html and its fairly confusing tbh
uh?
You can only have one root tag.
Which means you can't do
<tag>
</tag>
<tag2>
</tag2>
at root level
I dont think simple data format is ideal for timespans
isn't there an Interval time api in java 8
I’ll just act like i understand lol
that's why i couldnt use SDF
wut root tag?
jesus christ do you know what the fuck XML is
no i just click made new file .XML
android has DateIntervalFormat
not sure, i tried using math but i get a - number of things... but if i were to Math.abs(), the date would appear as never ending
I think you ought to learn how XML is structured.
Because if you can't understand what "root tag" means, it means you don't know how XML works.
It's not a difficult format, soooo
there's cool time api in java 8 yes
never heard of it normally i just use blank template from maven
Thats boring! Every second dev makes the common libraries for plugins and moslty they are same!
Yes
You are correct
Its just that I prefer my own code over other people's
Because I am usually more competent than other people
:)
||selfish||
||you mean egotistical - selfish would assume I'm keeping the code to myself||
ajwiwhama
yeah kinda
so i tried TimeUnit, but im still getting negative values, i must be doing Long math wrong?
you want older - younger
which is probably d2 - d1
ahh
md_5 we are so smart uwu
damn
idk man
but
my plugin way better
show me
fair enough
You made two fatal mistakes:
sendMessagecan be separated into its own method for reduced noisiness.- Adventure > Bukkit chat API
wdym its technovision that made them i just copied his code from the tutorial
lol
what
too smart for me
amma go back to learning about variables on java
;-;
good plan
lol
i dont even know what this is
Thsts funny the most smartest developers has only 1-2 projects
"most smartest"
lol
tsk tsk
just better
i just realized how hard it is to make plugins
;-; me who thought i can make a practice plugin in a week
thats scary to do a lots of projects! What if you accidently do the bad design??? A time spent for nothing!! Because you actually care about the code quality
personally I think it's easier to improve if you don't stay attached to the same project for too long
why? because you're no longer working with decades old code that, if you're trying to stay consistent, will keep you consistently bad
besides, new projects = new experience
i agree
imagine anyone working with decades old code
they just dont make code like they used to
excuse me
I will use Vector, Stack, and Hashtable if I want
thank you very much :p
Who tf is hashtable
Map/HashMap's predecessor.
I doubt maven did that
Was introduced in Java 1.0 but replaced in Java 1.4
all the bunch problems with my eclipse
Aha
oh and Vector is List, and Stack is Deque
oh plus we have Enumeration which older parts of Java's stdlib still use
which is basically just Iterable/Iterator except you can't foreach like for (elem : thing)
yeah enumeration is weird af
isnt enumeration just iteration while keeping track of the index
pretty much
then why is it so bad
you can't foreach
