#help-development
1 messages Ā· Page 1887 of 1
yeah try 1.8
That just means only allow up to 1.8 for the language features
so i can use J17 fine?
Yes
okay š
How can I send a message to a webhook inside my plugin... with embeded messages?
huh?! it's building with JRE 11 according to running java --verison in the ctrlx2 "run anything" screen. I have JDK 17 as my JAVA_HOME btw
oh it was using 1.18 nor 1.18.1
weird
private static Communicator instance;
@Override
public void onEnable() {
instance = this;
}
Why does this work?
How are we assigning a static variable in a non-static method
package me.mrhonbon.firstplugin;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.inventory.ItemStack;
public class Opmob implements Listener {
@EventHandler
public void creatureSpawn(CreatureSpawnEvent event) {
if(event.getEntityType() == EntityType.CREEPER) {
Creeper creeper = (Creeper) event.getEntity();
creeper.setPowered(true);
}
if(event.getEntityType() == EntityType.ZOMBIE) {
Zombie zombie = (Zombie) event.getEntity();
zombie.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET));
zombie.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
zombie.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS));
zombie.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS));
ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
sword.addEnchantment(Enchantment.DAMAGE_ALL, 5);
zombie.getEquipment().setItemInMainHand(sword);
}
}
}```
zombie still gets the sword but isnt enchanted?
code
because a non-static method can reference a static thing, but not the other way around
Really?
But like
well yea
it can set a static variable?
yes
do ```java
not
```
java
I thought it couldnt
lol
that's what utils classes do
he just added java to the first line
hmm didnt know that
ahh
that's basically the whole point of a static variable, so that non-static things don't need to instance anything
So why shouldnt you make every variable/objkect static?
I get that thats a terrible thing to do
But why specifically
Because it ruins the point of using an OOP language
package me.mrhonbon.firstplugin;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.inventory.ItemStack;
public class Opmob implements Listener {
@EventHandler
public void creatureSpawn(CreatureSpawnEvent event) {
if(event.getEntityType() == EntityType.CREEPER) {
Creeper creeper = (Creeper) event.getEntity();
creeper.setPowered(true);
}
if(event.getEntityType() == EntityType.ZOMBIE) {
Zombie zombie = (Zombie) event.getEntity();
zombie.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET));
zombie.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
zombie.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS));
zombie.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS));
ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
sword.addEnchantment(Enchantment.DAMAGE_ALL, 5);
zombie.getEquipment().setItemInMainHand(sword);
}
}
}```
zombie still gets the sword but isnt enchanted?
finally there we go
did you set the itemMeta
item.setItemMeta()
he isn't using item meta
but he probably should
how would i implement that
sorry im pretty new to plugin development lol
just learnin
ItemMeta itemMeta = item.getItemMeta();
ItemMeta meta = sword.getItemMeta()
meta.addEnchantment(stuff)
sword.setItemMeta(meta)
Smh
you have to get the ItemMeta, and apply enchants to meta instead of to the ItemStack directly, and then re-set the meta
removed it
btw why getItemMeta() is nullable
Cause it might not exist
in what case?
I presume if nothing is edited
No
Only time ive encountered it
I was getting stuff form a config
Like serialized itemstacks
Interesting
uh
I currently just assert it != null
you still need to null check sometimes
but really no idea when it will return null
Pretty sure that just makes it throw a nicer looking error if it is null
assert never works in a real enviornment
am i close btw
only if the flag is set
Check the javadocs
by flag you mean assert != null?
Sorry, is that like a @thing over a method?
No
like when you run a server for example
java -jar server.jar [some jvm arguments]
it just for me to remove IDEA compile warning
You can turn it off in settings
Dont ask me how tho
asserting is stupid in general
^^
currently I never encounter a case which getItemMeta() give me null yet
I don't even know if it's possible
like in what situation?
it marked as nullable
assert is for "this should never be false, but for some reason is annotated as being nullable"
I looked into the implementation and I just found that it will only happen when Material is AIR
this is why Optional is superior cause its easier to use then a separate condition which is a pain in the ass to write and takes sapce
holy shit i remember that now
yeah thats like a 1head move
does bungeecord work totally async?
Yeah me too lmao
Well bungee has to have atleast one main thread so it isn't full asynchronous
Not sure what the extent of multithreading in it is
im asking this because i didnt see any method to run tasks sync in TaskScheduler
why would you need that?
for my understanding bungee just a proxy and did no touch spigot game thread :v
or very limited
if you need async use a runnable, thread, or future
but most likely it is async all the time
() -> { some code };
new Thread(() -> { some code });
CompletableFuture.runAsync(() -> { some code });
ye ik just curiosity
i havent coded for a month now so im not sure if the syntax is correct lol
Dope
i think 0,1,2,3,4,5,6,7,8,9 is valid ?
more than that
yeah .,... but i understand exactly that ^^ š
why is making a new Location nullable
Isnāt
blaze it cannot
declaration: package: org.bukkit, class: Location
Location has a constructor
you meant World object?
because World object could be stale
in case the dimension get unloaded
lets say i load the world via multiverse and unload it
world doesnt exist in the server anymore
and World object is stale
i need to make an example Location for a Location-returning object
if it isnt in a yml file
and its nullable for because sometimes its convenient to have a location object without a world object
or maybe i should just make it IOEcception
whenever you need some kind of container to store coordinate data
what about using a Vector ?
that way you need to store location into two objects
EulerAngle (for pitch and yaw)
and Vector (for coordinates of x, y and z axis)
ah smart
only if you need the rotation ^^
throwing methods is not the safest thing to do
just try catch
what if some dumb ape deletes your config file
i expect it to fail regularly
anyway
since it's used in finding homes so if it doesnt exist
it should return something
What?
public Location grabHomeFromUser(String dir, String uuid, String key, String home) {
YamlConfiguration yC = YamlConfiguration.loadConfiguration(new File("./teleportutilities/" + dir + uuid + ".yml"));
return (yC.getObject(home, Location.class) != null ? yC.getObject(home, Location.class) : /* this is if it doesnt exist */);
}```
i meant throwing methods inside method
for example it could halt the code below
Throwing exceptions is totally fine
and corrupt the object
As long as something else is catching the exception
especially in constructors
what should i do in that case then
try {
throw new Exception("uff");
} catch(Exception exception) {
exception.printStackTrace();
}
so just try/catch it and throw an ioexception if it fails that instantly gets caught?
Id expect this to be the block underneath me no?
location.add(0,-1,0).getBlock().getType()
but it keeps returning air eventhough im on the ground?
well these are just addition operators wrapped inside the method
so it should work
if you use location more then once you should use copy before adding
Are you dividing up your file interaction from your functionality implementation, or do you just have it all in one
If you have it all in one then use the try catch
yea, sometimes events return copies of the objects and sometimes not
for example MoveEvent returns location
File interaction is seperate from commands
it's in YamlHandler [extends YamlConfiguration]
Then have the file interaction throw an exception, and in the command you can do the try catch to replace it with a default case
Your file interaction shouldnāt necessarily be specifying a fallback case if the file throws an error
The implementation should be allowed to decide that
Okay
It exits the method exceptionally, so whatever method called that method then can try-catch
So if I call A() which calls B() which calls C(), if C throws an exception and B also throws that exception then A will receive the exception to try catch it
This Java tutorial describes exceptions, basic input/output, concurrency, regular expressions, and the platform environment
i never thought i would understand regex (at least a bit)
public Location grabHomeFromUser(String dir, String uuid, String key, String home) {
YamlConfiguration yC = YamlConfiguration.loadConfiguration(new File("./teleportutilities/" + dir + uuid + ".yml"));
if (yC.getObject(home, Location.class) != null) {
return yC.getObject(home, Location.class)
} else {
throw new IOException("The YAML file does not exist.");
}
}``` pretty much?
oh ok
this matches every word that either has any letter (ASCII or not),
or a number or a special character
regex god
woah why u got so much whitespace
didnt mean to lol
guyz how i can get a block from a xyz
declaration: package: org.bukkit, class: Location
yeah..
@sage patio
i totally forgot how to format it lol
thats something you should learn then
try learning how to read javadocs
how
I'm looking for some advice on how to go about reading the online documentation of various packages classes and methods for java.
i mean all this stuff: http://java.sun.com/javase/6/docs/api/
read javadocs
thanks
this indent 
whitespace too the moooooon
wow vscode really doesnt like me throwing an IOException
Wdym
FileNotFoundException?
Just add throws IOException after the method definition
ah ok
https://paste.md-5.net/ronexubako.java anyone know why once i eat the apple the sound isnt playing? the string check should be correct no?
How can I get the clear name of a material to print it properly?
You're checking if the lore contains ChatColor.MAGIC + "Easter Apple 2022" when that's the display name.
They both have to pass for the sound to play.
Ill try
With that setup anyways
use an or, not an and
I should probably also throw a FileNotFoundException if the file doesn't exist
Like, as what the client would see?
you're being vague, where
mhm
"Golden Pickaxe"?
A translatable component, i assume
didnt work
But the spigot component api doesn't support the same nesting system as vanilla does
its a consume item event so would work with the setup i got?
it's literally the only check in that entire file afaik
right now its checking if [x] then if [y] and inside y its doing the function
it should check if [x] or [y] do function
i removed the other if statement if thats what you're saying
?paste
wait are you not importing anything or did you just not show them
didnt show
ItemStack stack = dropTable.get(i);
TextComponent component = new TextComponent(String.format("%d) [%s]%s", i, stack.getType(), (tableIndex != i ? "" : " <-- Current Index")));
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new BaseComponent[]{ toChatComponent(stack) }));
sender.spigot().sendMessage(component);```
Here's the current snipped, but needless to say it does not format properly
What does it send
A simple chat message that includes a hover event to show a item
With the square brackets holding the item name
Hmmm I'll try messing around with it
what is unbreaking enchant in 1.12.2 ?
Durability
Are you opposed to NMS @halcyon mica
This entire project is half nms
I need Java 17 for MC 1.17.1 +
But the problem is that maven-shade-plugin doesn't support Java 17

some versions do
declaration: package: org.bukkit.configuration, class: MemorySection
ProxiedPlayer#sendData sends a plugin message to player's current server, right?
whoever asked this
There are snapshots available that support java 17
I'm surprised they've still not released it
so?
Yeah I believe so
Should I just use nms then
Pretty close actually, gimme a few more mins
bump
I always get thrown off when I compile for java 17 and then get the error for it not being supported lmfao. I always forget
(on paper you can do just itemStack.displayName())
Thanks guys, snapshot works - but I get another error. But at least I can use Java 17 now š
@halcyon mica
ItemStack item = new ItemStack(Material.RED_GLAZED_TERRACOTTA);
//Gets the NMS Component, I couldn't figure out how to convert this back into a Spigot Component, but maybe you can experiment more.
Component component = CraftItemStack.asNMSCopy(item).getItem().getDescription();
//Since it's not a Spigot Component, more NMS! :D
((CraftPlayer) player).getHandle().sendMessage(component, Util.NIL_UUID);
But, prints "Red Glazed Terracotta", and if I change languages it changes also.
spigot cringe
Then why are you here
is there a seemless way to move players to a different bungee proxy?
Why NMS
packets?
or performance reasons?
Getting the display name for a Material, is there an API way to do it?
Cringe spigot doesnt properly support components
We could probably add a method for that
Welp, if spigot supports translatable components there is a way no lie
Itās just a TranslateableComponent
Yeah, there's just no API way to get the key as far as I could tell.
how do translatablecomponent work in NMS?
does it send translation key for the client
or what
yes
Yes
Actually wait
i've always thought that the item names are retrieved serverside via locale json files, but there are only english locale included inside the nms afaik
until i switched languages
and saw that item names are not static
Thatās what ItemMeta#getLocalizedName does
yea but it only supports english
i mean
i could probably
switch json files
and rename it
and it'll work but
If there isnāt a method to get that translatable name one could be added
kinda hacky
Although that means I have to face the material enum again :p

dovidas you're on paper no?
but it depends on the language or not ?
so you have to import language import
then use api
š”
So is there any way to get projectile which has killed entity and check if there is FixedMetadataValue on it ?
In EntityDeathEvent
i don't need it actually im just discussing
im just criticising for no apparent reason
continuation of airplane.gg server software to 1.18
EntityDeathEvent getKiller ?
im trying to put an anticheat plugin on my server and it uses protocollib however it tries to load the protocollib classes from my plugin, ive gotten rid of protocollib from my dependencies but it keeps giving me this error
Loaded class com.comphenix.protocol.events.PacketListener from StaticPrisons v1.0-SNAPSHOT which is not a depend, softdepend or loadbefore of this plugin.
ItemStack item = new ItemStack(Material.RED_GLAZED_TERRACOTTA);
String key = CraftItemStack.asNMSCopy(item).getItem().getDescriptionId();
TranslatableComponent component = new TranslatableComponent(key);
player.spigot().sendMessage(component);
This seems to be the best way I could get it. getLocalizedName() doesn't work if the item doesn't have any meta, which could be a problem I suppose.
wait
Why are you shading protocollib classes
don't IRegistry objects store
names or keys of the translateablecomponents?
block state ids are stored there, if you supply a minecraft namespace and key for it
Well I would need arrow entity
i dont want to, im trying to figure out how to NOT do that
You can check if the last damage cause was an EntityDamageByEntity event and then use that
Pretty sure that's what I'm doing with getDescriptionId()
any idea what i could do to change it and stop it from shading protocollib
Are you using maven?
yeah
Set the scope of the dependency to provided
Does maven cache stuff? If so you can try mvn clean
why the hack did md5 this:
he rly hates custom non api related stuff -.-
i think i fixed it, im building my plugin using an artifact and even after removing protocollib from my pom.xml it still put it in my jar file
weird
You can replace that with your own array
Itās as if you arenāt meant to add custom effects
"Custom stuff" was never supported
yeah but it looked soooo easy at first ... and now it rly sucks to do it xD
not supported.... but he intentionally blocks the easy way to do it š
I dont believe that would ever work that easy
Its not enchantments which are just strings in nbt
yeah... its more then 1 string ... its also some numbers and stuff but still saved in nbt of entity ^^
Good luck having it display on the client
this is the future problem ^
maybe all this would need is something in the language file
Yeah that doesnāt even work with enchants afaik
idk ... enchantments were easy af
and still not supported
what's wrong with that?
he saved precious memory
he did not probably since the ids already exist in minecraft registry ^^
hmmm i could be evil and change it in a pr .... so he thinks i wanne save memory ^ but instead i abuse the api once again xD
i think this is to make porting to newer versions a lot easier
it is not going to be accepted
he would rather update one method that populates that Array, rather than manually editing calls to NMS Registry, to get what he wants to achieve from that code
but that's just a theory
i haven't looked it up myself
what would be best way to tp 2 random players somewhere
Iām pretty sure spigot does intend to switch to wrapping registries some day
hmm since PR would take too long i will just use some magic here and there
Stop doing trasht unsupported things
never. this is boring
Gotta love some bytebuddy
He's crazy
Epic guy
Friendly reminder that ByteBuddy woudlnt work on spigot without bootstrap
so not working plugin or something that breaks every version is not boring?
Sorry for the late response, but does that mean that data leaks only matter if you forget to remove from your hashmap?
i dont know any other thing to waste time on then updating nms plugins š
my last try to add smth as pr was canceled because it was to much changing ^^
okay you jusr make me angry
is there somthing to get all active players and tp 2 random players
or somthing like that
hm ok
"SWITCHAROO!! ==> Teleported you to Coolioplayz54"
what you want is very simple java so shouldent be hard
help me or someone else
š
?
i was just looking at you 2 talking
whoe r u replying to
very intensly
probably gonna take a break from coding fir a but
you
yes, v e r y
id love some guidence š
would you rather dms or pings
can I simulate a player command event from a unit test?
wdym
Yes. There should be a few libraries you can use for this
I'm using MockBukkit atm
it doesn't have a simulateCommand function
so I assume I have to create one or use another library(?)
?jd
this is for me btw
create a thread in this channel
so others can join if they want
i wanna join in and probably just talk
Making random players tp
What'd you end up using
ItemStack stack = dropTable.get(i);
ComponentBuilder b = new ComponentBuilder()
.event(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new BaseComponent[]{ toChatComponent(stack) }))
.append(i + ") [")
.append( new TranslatableComponent(CraftItemStack.asNMSCopy(stack).getItem().f(null)))
.append("] " + (i == tableIndex ? "<-- Next Drop" : ""));
sender.spigot().sendMessage(b.create());``` a mix of both

Apperantly the hover event constructor is deprecated though
idk, they take something called content now
probably json content
Not Minimessage š¦
[23:01:13 ERROR]: [IOSteinPolls] Unhandled exception occured in onPacketReceiving(PacketEvent) for IOSteinPolls
net.minecraft.server.CancelledPacketHandleException: null
[23:01:13 ERROR]: Parameters:
net.minecraft.network.protocol.game.PacketPlayInUpdateSign@5a47732d[
b=BlockPosition{x=177, y=255, z=145}
c={test,,,}
]``` any Idea what this could be caused by? I'm using ProtocolLib and this is the code https://paste.jordanosterberg.com/duvibuceki.java
is it possible to tell if an advancement is gaining a recipe
You mean as a reward?
like, when a player learns a recipe, they also get an advancement. i want to tell if the advancement comes from a recipe
Ah, not sure if that is something achievable with the api. Those might be client side, but Iām unsure.
You might be able to compare what recipes the player has unlocked with a runnable. However it might not be the most efficient way to check for that.
im certain it isnt. i made a plugin print out different events and when i do /recipe, it prints a recipe and advancement
If you can get the advancement information, is there a recipe reward? Or is it just blank? Because if you listen for the advancements, you might be able to determine what itās for. If the advancement is for granting recipes, then there would be your solution.
would it be in criteria
There is a recipe reward
It might be or it might be under advancement rewards.
You might want to check both.
how would i get that
Currently unsure. Iāve had to deal with advancement packets because the api doesnāt do what I need it to. But there are some Advancement classes in the api.
@sullen marlin I'm trying to find if an advancement is a reward. Would it be in criteria?
Idk what that means
Idk what a recipe reward is
Though that was just exp for smelting
Just check the advancement name (or criteria?) has recipe in it
Should be ez pz
maybe
md_5 are you going to rewrite some stuff in the future where you can use the minecraft registry instead of own Maps/Arrays ?
Minecraft registry?
yes minecraft registry
Thereās a Registry class already
Recipes are unlocked via advancements that award a recipe unlock
And yes that means there are like a billion advancements just for recipes
wait what?
did you rly add Enchantment as Registry so ppl can register custom stuff or what is this ?
No
No, plugins are not for custom additions. Thatās mods
They only have a get method
ah yes i see ... hmm not exactly what i mean with that^^
I believe there are tentative plans to redo some enums to use registries
for example PotionEffectTypes are stored in byName, byKey and also byId .... but i think that stuff could be replaced with the nms registry
Specifically ones that are keyed
and i hope its getting added soon ^^ cant wait to hack the shit out of the new stuff
how do i turn an in to location
new Location(Bukkit.getWorld(int),int,int,int) ^^
oh and a world
by default this will only work for int=0,1 or 2
There is a wipe and dupe glitch in this script. What it's supposed to do is drop everything except hotbar, armor and offhand if killed by a player, and drop only XP if killed by not a player. But sometimes it's wiping the hotbar, armor and offhand and sometimes it straight up dupes the hotbar. I don't know what's going on! Here is my script:
"script" ^^
thought your talking about the script api
Skript has a k
weird
#1 Name your classes UpperCamelCase
#2 Name your Methods lowerCamelCase
lowerCamelCase
#3 you can also simplify the long stuff there
#4 you need to create an "hotbar" for each player... at the moment your creating just 1 and use it for every player each time xD
#5 Dont use "e.getDrops()" 20 times ... save it in a local var
#6 You set keepInventory to false with the CMD and also in the Event... and if the killer wasnt an Player you set it to true again... with CMD and in the Event ... you dont need the CMD if you use the event
so im doin this do i enter somthing in the brakcets in .getworld
maybe the name of your world ?
^
so just world
or world_nether
or world_the_end
ok
I'm not sure how to go about that, since if I declare the variable in LoseHearts, I can't access it in Respawn
you want the player to keep only hotbar + armor right?
you will need to save the "hotbar" for each player
^
OR setDrops to false and drop everything that is not hotbar/offhand/armor manually
Ok
Thanks
And for some of the convention stuff, I came from C#, and we start our methods with uppercases there
Yeah and it's annoying to read ;/
One of the things that bothers me the most about C#
but you write UCC on Class-names too ^^
Yeah, I fixed that
ohhhh who was writing some time ago that custom potion effects wont be that easy like enchantments ? XD
actually crashed the server because the potioneffecttype is hardcoded at so many places ^^
goal was to have at least the potioneffect-field displayd in inventory
just bad because own saving is needed (pdc i know)
and something has to tick it every time + attribute modifications are not that simple .... sad to not get the hacky way working
if you edit the language file and add the key it may work
Doubt it
The server appears to send them by id
And that id wonāt exist on the client
^^
sucks to be minecraft
It works just fine
What does
i think he says minecraft works just fine ... but i think it could be a lot more interesting with the ability to create new(custom) things that are supported by client( and maybe api^^)
^
Question: What's the zstd implementation with the lowest file space?
Tbf I never tried to add a localization with a resource pack, I just heard it doesnāt work
I know it doesnāt work in the enchantment table
I need zstd compression for a project and shading it in makes my jar to to 20mb
Because that sends them by id
Yeah
Which means I gotta make my own enchanting GUI
No
Sure
ping?
Blame @sterile token
Me. But the answer was wrong. Sorry for the tag
I have seen that using intellij i dont need to put the <build> label to export my jar. I can just directly do it from maven/project name/lifecycle/package
I didnt know that before
Yeah
I have been debugging InventoryEvent#getSlot() and InventoryEvent#getRawSlot() are different. But i cannot find why
Hahaha i will prob need to continue reading
RawSlot is over the entire view iirc
Slot is unique to which inv you click on, top or bottom
Ah alright
are potion recipes data driven yet or accessible via the api?
WorseBrewingā¢ļø
gonna make a plugin that's sole purpose is to hijack brewing stands and make a mojang-style json shitshow to handle all recipes and their outputs
it's going to be so hot
you see
I don't finish plugins
so you'll get the barebones and then I'll lose interest and you'll never hear of it again
Same
Oh thanks. Because i find it on spigot site but i got more confused than that i were
just realized that if I want this plugin to be good, I'd have to give it hopper support
not very motivating
just make it an api
will be an api and a plugin ideally, as a plugin it will use a datapack style json structure for handling all recipes, including vanilla ones
the fun part will be making the brewing stand bullshit work to begin wtih
it will be janky
jaaaaank
sounds like a job for Piping
brewing stand ingredient slot now accepts whatever the fuck I want to give it
how can i set item on slot using remapped nms?i tried with setItemSlot(EquipmentSlot.HEAD, new ItemStack(<ItemLike here>)); but idk what is itemlike, and how can i set this
no cluie
?paste
Can you paste full error?
@quasi patrol youll get a more descriptive error if you replace ur plugin.getLogger().severe with an e.printStackTrace()
he doesnt have a full error bc hes catching it and only printing a tostring of the class i think
instead of just printStackTrace
Ok.
IK
There is a small problem.
I get an error in my IDE saying cannot resolve method 'severe(void)'.
it means that this method not exists
replace the whole line
I realized that. Lol.
replace the whole plugin.getLogger().severe(e.getStackTrace().toString()) with e.printStackTrace()
ye
the 400 HTTP error in general means bad request, so maybe your URL is invalid
send the code ur using for the webhook?
and you should not trigger HTTP request inside Spigot command, it slows server a lot
use Bukkit task for HTTP requests
i gotta question, so i am making a plugin that basically makes all the mobs in the game over powered, and was wondering how do i make a command that enables and disables the plugin in game?
*async
right Async
Bukkit.getPluginManager().disablePlugins(); you can disable/enable one or more plugins with pluginManager
do i use that in the main class or do i add that to the command class i am currently in?
in command
the command ur running it from
Better to just add a Boolean lol
^
if(!enabled) return;
if (plugin.shouldBeOverpowered) dostuff
š thanks!
What its best comparing the whole inventory or the name? (for custom inventory)
inventory object i guess
Allright thanks
I was in dought because sometimes copare the object consume more resources
when?
When they have a custom .equals
comparing object is faster then comparing strings content
@sterile token https://www.youtube.com/watch?v=N-TxY647XaM&list=PLqaRFPLG-HxNd4jDPWMKQwcKkNi6wmYA3&ab_channel=javaunderthehood this is pretty good tutorial about how JAVA is working under the hood
Java under the Hood - playlists:
"Stack & Heap Memory Fundamentalsā
https://www.youtube.com/playlist?list=PLqaRFPLG-HxNd4jDPWMKQwcKkNi6wmYA3
"Java Collections Framework: List"
https://www.youtube.com/playlist?list=PLqaRFPLG-HxNhiJruJ57wMD1Wqpazu-BD
In this demo I'll introduce the concepts of the Java Virtua...
Should be: event#getView()#getInventory() == menu.getInventory()?
Because i had some problems before, when i click on the player inventory the buttons where executed and aswell on the custom gui
Yes because i wanna do it for custom inventory/guis
yes event.getInventory() == inventory will work
Yes but with bugs
Because when i click on player inv detect the same as clicking on custom gui
what kind of bugs?
hi, what is the event for picking up xp orbs?
I only want to execute the actions when you click on custom menu items
right to prevent that you would need to check the slot index
?jd
Explain more that please and thanks for answer
openInventory returns a view
i wanna say its this? https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerExpChangeEvent.html
declaration: package: org.bukkit.event.player, class: PlayerExpChangeEvent
Add that to a set and check .contains in the event
So on click event i loops througt openInventory
And check if contains my custom right?
thanks!
So with this code. When i click on the player menu wont get executed right? Only when i click on custom menu
so full gui has let say 60 slots and the custom one has 30 slots
so to detect if player clicked on custom gui make just if(slot < 30) { customGUIClick()} else {playerGUiClick();
Thatās what getTopInventory is for
Im not using it?
Here i think im using it
You should
But im using it or not on my code
Or follow this
Because im confused right now
is there helper library / class to handle config files easier?
I have mine
Do you want it?
yes please!
and better include this IF
the - 999 slot comes when player click out of his Inventory
Wait i forget something
Here. If you need help tag me
thank you man!
Your welcome
When i finish fixing my menu gui and testing others things in the library. I will publish it on github
public class OverPoweredZombie implements Listener {
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
if (event.getEntityType() == EntityType.CREEPER)
Creeper creeper = (Creeper) event.getEntity();
Creeper.setPowered(true);
}
if (event.getEntityType() == EntityType.CREEPER)
}
}```
why does the 2nd event always turn red?
lol
Because your braces are wrong
An spoiler for you, its will have many things. File system, Messages, Menus, Databases, ItemBuilder, Time
hello
im firing a custom event async
but
im adding some breakpoints to my code
because it is not having the expected behaviour
and when it reaches the callevent line
the next line is not called
meaning that an exception happend
but the console shows nothing
Is you event set to be async
yes
i need to store some data that needs to save when the server turns off and on - is json or something similar good for that
Show the event class
I am completely convinced that BrewingStand#setBrewingTime simply does not function lol
you could use yaml too but yeah that'd be good
Did you update the state after using it
consider BetterBrewing cannedā¢ļø
Hmm, does a try catch catch anything?
rest in plugin development hekk
oh
that might be the teensy itty bitty little problem here
is it uncanned now
potentially
oh yea
whats the difference? or does it not matter
so that fixed my little issue
how to fix: org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml ?
Show the full error
cool
but it appears that I cannot reasonably set the brewing stand progress bar without a hardcoded brewing item in the slot
I think this is where the dream dies
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:178) ~[purpur-api-1.18.1-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:158) ~[purpur-api-1.18.1-R0.1-SNAPSHOT.jar:?] at org.bukkit.craftbukkit.v1_18_R1.CraftServer.loadPlugins(CraftServer.java:422) ~[purpur-1.18.1.jar:git-Purpur-1503] at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:320) ~[purpur-1.18.1.jar:git-Purpur-1503] at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1218) ~[purpur-1.18.1.jar:git-Purpur-1503] at net.minecraft.server.MinecraftServer.lambda$spin$1(MinecraftServer.java:322) ~[purpur-1.18.1.jar:git-Purpur-1503] at java.lang.Thread.run(Thread.java:833) ~[?:?] Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml ... 7 more
just recode a brewing stand entirely
āJar does not contain a plugin.ymlā
literally never touched protocol in my life
tell you what blaze
you make the brewing stand do the move move
thanks!
and I'll do the data bullshit
oh no ive been actually challenged to do stuff
imma be real with you i can barely actually code a home plugin but if you absolutely want i could try
Are you building with maven/gradle
nah don't worry about it
name: MoreXP
version: '${project.version}'
main: com.testchambr.morexp.Main
api-version: 1.18
so the "error" was that it wasnt async
the dream dies here
f
maven
because my code was returning a CompletableFuture.completedFuture
which is not async
:C
plus all of this hard work will become immediately redundant when spijang adds api support or mojgot supports datapack recipes for brewing stands
no no, that's the good ending
Please send capture of your project
So we can see your structure
And notice if something its wrong
yeah the problem was how i was building it. thanks guys!
it is but what if it never comes and you keep delaying it
Ah no problems
it's not my fault minecraft is made terribly
true
š
Please accept my request i wanna talk with you if its possible
they can't expect me to solve all their problems
i probably need a /delhome command
hey. if a plant cannot be placed on a block, is it possible with a plugin to allow it to be placed on this block?
I would like to be able to place the chorus plants on other blocks.
how can i set item on slot using remapped nms?i tried with setItemSlot(EquipmentSlot.HEAD, new ItemStack(<ItemLike here>)); but idk what is itemlike, and how can i set this
Is there a way to check if player isn't holding a left click anymore?
nope
Ugh...
hi, i want to debug my plugin with intellij, and i followed the tutorial on spigotmc but i dont get, how to get my plugin installed to the debug server
i tried package, install and deploy from maven lifecycle but ofc it doesnt know where to install it lol.
is there a simple, easy peasy way to get DyeColor from a Material that happens to be a dye?
or do I really have to do the thing
I really don't want to do the thing
Do the thing
Its possible to change the export jar directory? So intellij export my jar to another directory?
I'm extremely angry
Use the fancy new switch stuff
Must field accessibility be true for MethodHandles to lookup on it?
DyeColor getColor(Material material) {
DyeColor color;
switch(material) {
case WHITE_DYE:
color = DyeColor.WHITE;
case BLACK_DYE:
color = DyeColor.BLACK;
break;
case GRAY_DYE:
color = DyeColor.GRAY;
break;
case LIGHT_GRAY_DYE:
color = DyeColor.LIGHT_GRAY;
break;
case BROWN_DYE:
color = DyeColor.BROWN;
case RED_DYE:
color = DyeColor.RED;
case ORANGE_DYE:
color = DyeColor.ORANGE;
break;
case YELLOW_DYE:
color = DyeColor.YELLOW;
break;
case GREEN_DYE:
color = DyeColor.GREEN;
break;
case LIME_DYE:
color = DyeColor.LIME;
break;
case BLUE_DYE:
color = DyeColor.BLUE;
break;
case LIGHT_BLUE_DYE:
color = DyeColor.LIGHT_BLUE;
break;
case CYAN_DYE:
color = DyeColor.CYAN;
break;
case PURPLE_DYE:
color = DyeColor.PURPLE;
break;
case MAGENTA_DYE:
color = DyeColor.MAGENTA;
break;
case PINK_DYE:
color = DyeColor.PINK;
default:
color = null;
}
return color;
}```
For any poor soul wanting to get DyeColor from dye material
3long
i wonder if i can shorten this
maybe someone in 2 years will find this with the search feature and I will have saved them 6 minutes and 23 seconds
please papito
private ChatColor dyeToChatColor(Material type) {
return switch (type) {
case WHITE_DYE -> ChatColor.WHITE;
case ORANGE_DYE -> ChatColor.GOLD;
case MAGENTA_DYE -> ChatColor.of("#C968C3");
case LIGHT_BLUE_DYE -> ChatColor.AQUA;
case YELLOW_DYE -> ChatColor.YELLOW;
case LIME_DYE -> ChatColor.GREEN;
case PINK_DYE -> ChatColor.LIGHT_PURPLE;
case GRAY_DYE -> ChatColor.DARK_GRAY;
case LIGHT_GRAY_DYE -> ChatColor.GRAY;
case CYAN_DYE -> ChatColor.DARK_AQUA;
case PURPLE_DYE -> ChatColor.DARK_PURPLE;
case BLUE_DYE -> ChatColor.BLUE;
case BROWN_DYE -> ChatColor.of("#794521");
case GREEN_DYE -> ChatColor.DARK_GREEN;
case RED_DYE -> ChatColor.RED;
case BLACK_DYE -> ChatColor.BLACK;
default -> ChatColor.WHITE;
};
}
oh
Wee java 16
i think it couldd still be shortened
I'll shorten you
I had no idea that was possible
public static DyeColor getDyeFromMat(Material mat) {
return DyeColor.valueOf(mat.name().substring(0, mat.name().lastIndexOf('_') - 1));
}``` i think?
I mean mayble
hey. if a plant cannot be placed on a block, is it possible with a plugin to allow it to be placed on this block?
I would like to be able to place the chorus plants on other blocks.
Ah
we were doing Material to DyeColor
DyeColor
not dye Material to ChatColor
it should, the pattern looks to be that the DyeColor equiv is just Material name with the _DYE removed
jank
as long as bukkit api doesnt change its names... š
please i need help
I was going to do something like this but I figured I would save a non-existent amount of performance not doing that
just cache it in a hashmap ezpz
hahahaha
that was not funny
Omg really it not possible?
Omg i hate this type of problems
I have tried it on more than 6 directories and the same inssue
š”
If i can join the directory?
if that yes
can someone help me? please š
BE pacient
ok XD
If no one answer its because they are in their own things or they dont know how to do it
k
when spawning campfire cozy smoke particle it spawns dif sizes can i make it just the biggest size or no?
hacky nms I believe
setBlock might not be enough
try it and see
u wut
the end times
jan 19th 2038
3:14 am UTC
specifically the end of unix time, that's when it overflows
that doesnt help lmfao
i mean like is there a way to make it just large using the extra data value or what
I want to make a kotlin project in intelliJ with gradle.
but kotlin plugin is not configured with these errors
> Task :prepareKotlinBuildScriptModel UP-TO-DATE
Could not resolve: org.jetbrains.kotlin:kotlin-stdlib:1.6.10
Could not resolve: org.jetbrains.kotlin:kotlin-stdlib:1.6.10
BUILD SUCCESSFUL in 7s
build.gradle
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.6.10'
}
group 'io.github.kelton208'
version '0.0.1'
repositories {
mavenCentral()
gradlePluginPortal()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib"
}
I'm using Gradle 6.8.2
hello, i am relatively new to plugin development, and was wondering how i could disable an event/listener using a command?
ex. /opmobs enable (enables the spawning of over powered mobs)
/opmobs disable (disables the spawning of over powered mobs, spawn like normal)
here is my current code:
package me.mrhonbon.overpoweredmobs.overpoweredmobs;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.inventory.ItemStack;
public class Opmobs implements Listener {
@EventHandler
public void creatureSpawn(CreatureSpawnEvent event) {
if(event.getEntityType() == EntityType.CREEPER) {
Creeper creeper = (Creeper) event.getEntity();
creeper.setPowered(true);
}
if(event.getEntityType() == EntityType.ZOMBIE) {
Zombie zombie = (Zombie) event.getEntity();
zombie.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET));
zombie.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
zombie.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS));
zombie.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS));
ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
sword.addEnchantment(Enchantment.DAMAGE_ALL, 5);
zombie.getEquipment().setItemInMainHand(sword);
}
}
}```
Just have a boolean somewhere that you toggle with the command
Then return if the boolean is set in the spawn event
Which is faster, Field#get(Object) or MethodHandle#invokeExact(Object) (specifically for Java 8 and above)
online sources giving mixed reviews
For j18 theyāll be negligibly different
But rn use latter if possible
Given that you donāt just unreflect ofc
I unreflect to get the methodhandle cause I have to set accessibility to true anyways
You probably want to use lambda meta factory
In that case the latter will be extremely much faster
Almost like a normal method invocation
is this the lookup inner class
probably, since MethodHandles can be used for fields too
Ye
Anyways just unreflecting a mh can actually be worse than normal reflection invocation
Wym?
So even when using LambdaMetafactory you are still calling MethodHandle#invokeExact(Object) subsequently right
and for every repeated calls after
and then get mh from callsite
and invoke
oh ok, what i meant was what is faster for repeated calls
assuming I store this mh
Idk
I am not an expert regarding this
But yes you invoke the mh from cs and then cast to the sam and run that
Like for both I believe caching the objects are important
Tho not entirely sure
Probably more important for reflection that you cache the field
For mh, just the sam instance should be sufficient
but probably handled by them
Wym
ok nvm i misunderstood that statement :/
Ye
Thing is I believe you have to cache it since itāll always grab a new instance due to how class loading and all that stuff is made etc
(Reflection)
hey i was wondering if you could help me? i am pretty new to this stuff and don't know where to start
^
unregister the listener
I normally will have an unregister method for my Listener classes (cuz a Listener can have multiple EventHandlers) if I may want to unregister them at some point or when config is reloaded, a lot of other ways to do it
hmmmm
One way of doing it
im looking things up on google cuz i know google is an easy way to find answers, i just like coming here for help because its direct and i can ask questions directly
Yeah
Well
I usually have a boolean that I switch on, or well sometimes I have something more intricate but letās not go over that
And since youāre new that might be just what you want
yeah, i am currently learning python in my hs classes so hopefully by the end of the course ill be better with java as well
Yeah python is amazing
but as of right now this is my 3rd day working with plugin development because its so cool and fun to do
Keep learning (:
and java
Ah yeah good luck
thanks man :D most people usually say "lol" if i ask a stupid question
lol
I need to go sleep but maybe solarrabbit can assist you :>
too political
its alr man you don't have to, i know its hard to kind of tell beginners what to do without spoonfeeding
haha, It's fine, I was just joking about :)
I need help
python is a very flexible language and has a lot of applications because of that, not a bad language
the thing is spoonfeeding is the easiest way to solve the problem at hand
i know, thats how i knew how to code everything else in this code:
package me.mrhonbon.overpoweredmobs.overpoweredmobs;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.inventory.ItemStack;
public class Opmobs implements Listener {
@EventHandler
public void creatureSpawn(CreatureSpawnEvent event) {
if(event.getEntityType() == EntityType.CREEPER) {
Creeper creeper = (Creeper) event.getEntity();
creeper.setPowered(true);
}
if(event.getEntityType() == EntityType.ZOMBIE) {
Zombie zombie = (Zombie) event.getEntity();
zombie.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET));
zombie.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
zombie.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS));
zombie.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS));
ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
sword.addEnchantment(Enchantment.DAMAGE_ALL, 5);
zombie.getEquipment().setItemInMainHand(sword);
}
}
}```
just learning by watching other people code
what's that
... this is not the right place to ask for help for that issue lol
isn't minecoins the bedrock edition currency or smth
LOL i would just google search it if i were you
cuz this place is for java plugin development
for spigot
yeahhhh
spigot.
anyways i made a new class and im gonna try and go off of this to see if i can get it to work
wait u can use MethodHandles and LMF on fields?/
lambdametafactory
