#help-development

1 messages Ā· Page 1887 of 1

tulip owl
#

tasks.compileJava.sourceCompatibility = JavaVersion.VERSION_1_8

trail bough
#

yeah try 1.8

tulip owl
unreal quartz
#

That just means only allow up to 1.8 for the language features

tulip owl
#

so i can use J17 fine?

unreal quartz
#

Yes

tulip owl
#

okay šŸ‘

quasi patrol
#

How can I send a message to a webhook inside my plugin... with embeded messages?

tulip owl
#

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

trail bough
#

weird

somber hull
#
     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

proud forum
#
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?
sleek pond
sleek pond
#

well yea

somber hull
#

it can set a static variable?

sleek pond
#

yes

trail bough
#

do ```java
not
```
java

somber hull
#

I thought it couldnt

somber hull
sleek pond
#

that's what utils classes do

trail bough
#

he just added java to the first line

somber hull
sleek pond
#

Utils.WORLD_TYPE

#

for example

somber hull
#

ahh

sleek pond
#

that's basically the whole point of a static variable, so that non-static things don't need to instance anything

somber hull
#

So why shouldnt you make every variable/objkect static?

#

I get that thats a terrible thing to do

#

But why specifically

sleek pond
#

Because it ruins the point of using an OOP language

proud forum
#
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

somber hull
#

item.setItemMeta()

sleek pond
#

he isn't using item meta

somber hull
#

Oh

#

Wait

sleek pond
#

but he probably should

proud forum
#

how would i implement that

#

sorry im pretty new to plugin development lol

#

just learnin

somber hull
sleek pond
#

ItemMeta meta = sword.getItemMeta()
meta.addEnchantment(stuff)
sword.setItemMeta(meta)

trail bough
#

so pretty much:

#

true

sleek pond
#

Smh

somber hull
#

Spoonfeeding

#

bruh

trail bough
#

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

thorny python
#

btw why getItemMeta() is nullable

dusk flicker
#

Cause it might not exist

thorny python
#

in what case?

somber hull
#

Like

dusk flicker
#

I presume if nothing is edited

somber hull
#

Only time ive encountered it

#

I was getting stuff form a config

#

Like serialized itemstacks

dusk flicker
#

Interesting

thorny python
#

uh

dusk flicker
#

JavaDocs prob have more info on it

#

BUT always include a check

proud forum
paper viper
#

i hate how a lot of bukkit just returns null

#

its honestly so annoying

thorny python
#

I currently just assert it != null

paper viper
#

you still need to null check sometimes

thorny python
#

but really no idea when it will return null

somber hull
paper viper
#

assert never works in a real enviornment

proud forum
#

am i close btw

paper viper
somber hull
paper viper
#

if users dont specify the assert flag

#

its useless

somber hull
paper viper
#

no

#

like an actual

#

JVM flag

somber hull
#

Sorry, is that like a @thing over a method?

paper viper
#

No

#

like when you run a server for example

#

java -jar server.jar [some jvm arguments]

somber hull
#

Oh

#

So asserting really is useless

#

In spigot

thorny python
#

it just for me to remove IDEA compile warning

somber hull
#

Dont ask me how tho

thorny python
#

I did need it some time tho

#

just like, no always

dusk flicker
#

asserting is stupid in general

sleek pond
#

^^

thorny python
#

currently I never encounter a case which getItemMeta() give me null yet

dusk flicker
#

Still good to have a null check

#

Even if you think it's impossible

sleek pond
#

like in what situation?

dusk flicker
#

It is, just rare

#

Hyper said a case above

thorny python
#

it marked as nullable

visual tide
#

assert is for "this should never be false, but for some reason is annotated as being nullable"

thorny python
#

I looked into the implementation and I just found that it will only happen when Material is AIR

paper viper
#

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

dusk flicker
#

Optionals are nice but can be a bitch

#

Not a fan of the syntax personally

paper viper
#

yeah thats like a 1head move

wide coyote
#

does bungeecord work totally async?

dusk flicker
#

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

wide coyote
#

im asking this because i didnt see any method to run tasks sync in TaskScheduler

sleek pond
#

why would you need that?

wide coyote
#

i dont

#

actually i was looking for a async method lol

thorny python
#

for my understanding bungee just a proxy and did no touch spigot game thread :v

#

or very limited

paper viper
#

if you need async use a runnable, thread, or future

thorny python
#

but most likely it is async all the time

paper viper
#

() -> { some code };
new Thread(() -> { some code });
CompletableFuture.runAsync(() -> { some code });

wide coyote
paper viper
#

i havent coded for a month now so im not sure if the syntax is correct lol

mortal hare
#

whoever likes regex

#

[\p{L}0-9@#$%^&+=]+

#

crack this

#

without online tools

spiral light
#

i think 0,1,2,3,4,5,6,7,8,9 is valid ?

mortal hare
#

more than that

spiral light
#

yeah .,... but i understand exactly that ^^ šŸ˜„

trail bough
#

why is making a new Location nullable

ivory sleet
#

Isn’t

mortal hare
#

blaze it cannot

mortal hare
#

Location has a constructor

#

you meant World object?

#

because World object could be stale

trail bough
#

huh

#

ok

mortal hare
#

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

trail bough
#

i need to make an example Location for a Location-returning object

#

if it isnt in a yml file

mortal hare
#

and its nullable for because sometimes its convenient to have a location object without a world object

trail bough
#

or maybe i should just make it IOEcception

mortal hare
#

whenever you need some kind of container to store coordinate data

spiral light
#

what about using a Vector ?

mortal hare
#

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)

trail bough
#

ah smart

spiral light
#

only if you need the rotation ^^

trail bough
#

should I just IOException it if a file doesn't exist?

#

since it's for a home thing

mortal hare
#

throwing methods is not the safest thing to do

#

just try catch

#

what if some dumb ape deletes your config file

trail bough
#

i expect it to fail regularly

#

anyway

#

since it's used in finding homes so if it doesnt exist

#

it should return something

brave sparrow
trail bough
#
    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 */);
    }```
mortal hare
#

for example it could halt the code below

brave sparrow
#

Throwing exceptions is totally fine

mortal hare
#

and corrupt the object

brave sparrow
#

As long as something else is catching the exception

mortal hare
#

especially in constructors

trail bough
#

what should i do in that case then

mortal hare
#

i suggest catching

#

but its your choice

spiral light
#
try {
    throw new Exception("uff");
} catch(Exception exception) {
    exception.printStackTrace();
}
trail bough
#

so just try/catch it and throw an ioexception if it fails that instantly gets caught?

opal juniper
#

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?

mortal hare
#

so it should work

spiral light
brave sparrow
#

If you have it all in one then use the try catch

mortal hare
#

yea, sometimes events return copies of the objects and sometimes not

#

for example MoveEvent returns location

trail bough
#

File interaction is seperate from commands

#

it's in YamlHandler [extends YamlConfiguration]

mortal hare
#

which you can edit and manipulate player's getTo() location

#

iirc

brave sparrow
#

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

trail bough
#

Should I return an all-0 location then?

#

[and null world]

brave sparrow
#

No

#

If you throw something you don’t return

trail bough
#

Okay

brave sparrow
#

It exits the method exceptionally, so whatever method called that method then can try-catch

trail bough
#

oh ok

#

Sorry I'm not... that good at coding yet so

brave sparrow
#

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

trail bough
#

ah ok

#

So just try/catch where it's used?

brave sparrow
mortal hare
#

i never thought i would understand regex (at least a bit)

trail bough
#
    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?
visual tide
#

data folder

#

not ./

#

plugin.getDataFolder()

trail bough
#

oh ok

mortal hare
visual tide
#

regex god

mortal hare
trail bough
#

woah why u got so much whitespace

foggy estuary
#

didnt mean to lol

trail bough
#

lol

#

it's getting angry at me for throwing an ioexception

#

damn

sage patio
#

guyz how i can get a block from a xyz

trail bough
dusk flicker
#

DEAR LORD

#

Use a paste

#

?paste

undone axleBOT
foggy estuary
#

yeah..

foggy estuary
#

i totally forgot how to format it lol

trail bough
#

make sure its structured as a Location but

#

other than that it should work

sage patio
#

i can't userstand java docs its just says some methods and what they return

dusk flicker
#

thats something you should learn then

trail bough
#

try learning how to read javadocs

sage patio
trail bough
#

dude i literally don't know how to make while loops

#

and i can still

dusk flicker
trail bough
#

read javadocs

dusk flicker
#

google

sage patio
#

thanks

opal juniper
#

this indent bruh

trail bough
#

whitespace too the moooooon

#

wow vscode really doesnt like me throwing an IOException

hasty prawn
#

Wdym

trail bough
hasty prawn
#

FileNotFoundException?

trail bough
#

Well it should be YAML item

#

because the file could exist

hasty prawn
#

Just add throws IOException after the method definition

trail bough
#

ah ok

foggy estuary
halcyon mica
#

How can I get the clear name of a material to print it properly?

hasty prawn
foggy estuary
#

which is why i also did the other too

#

double checking it

hasty prawn
#

They both have to pass for the sound to play.

foggy estuary
#

Ill try

hasty prawn
#

With that setup anyways

trail bough
#

use an or, not an and

#

I should probably also throw a FileNotFoundException if the file doesn't exist

hasty prawn
foggy estuary
halcyon mica
hasty prawn
#

"Golden Pickaxe"?

halcyon mica
#

A translatable component, i assume

foggy estuary
halcyon mica
#

But the spigot component api doesn't support the same nesting system as vanilla does

foggy estuary
#

its a consume item event so would work with the setup i got?

trail bough
#

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

foggy estuary
#

i removed the other if statement if thats what you're saying

trail bough
#

use [x] || [y]

#

adnd thatll chec kif X or Y

foggy estuary
#

?paste

undone axleBOT
foggy estuary
trail bough
#

wait are you not importing anything or did you just not show them

foggy estuary
#

didnt show

halcyon mica
#
            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
hasty prawn
#

What does it send

halcyon mica
#

A simple chat message that includes a hover event to show a item

#

With the square brackets holding the item name

hasty prawn
#

Hmmm I'll try messing around with it

sage patio
#

what is unbreaking enchant in 1.12.2 ?

hasty prawn
#

Durability

sage patio
#

Enchantment.?

#

thanks

hasty prawn
#

Are you opposed to NMS @halcyon mica

halcyon mica
#

This entire project is half nms

hybrid ledge
#

I need Java 17 for MC 1.17.1 +
But the problem is that maven-shade-plugin doesn't support Java 17

hasty prawn
opal juniper
#

some versions do

mortal hare
wide coyote
#

ProxiedPlayer#sendData sends a plugin message to player's current server, right?

chrome beacon
ancient plank
#

3.3.0-SNAPSHOT

#

iirc

worldly ingot
#

I'm surprised they've still not released it

halcyon mica
chrome beacon
halcyon mica
#

Should I just use nms then

hasty prawn
ancient plank
#

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

worldly ingot
#

Suspected release: March

quaint mantle
hybrid ledge
#

Thanks guys, snapshot works - but I get another error. But at least I can use Java 17 now šŸ˜„

hasty prawn
#

@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.

quaint mantle
#

spigot cringe

hasty prawn
#

Then why are you here

glossy scroll
#

is there a seemless way to move players to a different bungee proxy?

quaint mantle
#

no

#

or maybe redisbungee

mortal hare
#

packets?

#

or performance reasons?

hasty prawn
#

Getting the display name for a Material, is there an API way to do it?

quaint mantle
#

Cringe spigot doesnt properly support components

young knoll
#

We could probably add a method for that

quaint mantle
#

Welp, if spigot supports translatable components there is a way no lie

young knoll
#

It’s just a TranslateableComponent

hasty prawn
#

Yeah, there's just no API way to get the key as far as I could tell.

mortal hare
#

how do translatablecomponent work in NMS?

#

does it send translation key for the client

#

or what

quaint mantle
#

yes

young knoll
#

Yes

hasty prawn
#

Actually wait

mortal hare
#

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

young knoll
#

That’s what ItemMeta#getLocalizedName does

mortal hare
#

yea but it only supports english

#

i mean

#

i could probably

#

switch json files

#

and rename it

#

and it'll work but

young knoll
#

If there isn’t a method to get that translatable name one could be added

mortal hare
#

kinda hacky

young knoll
#

Although that means I have to face the material enum again :p

hasty prawn
quaint mantle
#

dovidas you're on paper no?

spiral light
#

but it depends on the language or not ?
so you have to import language import

mortal hare
#

im on pufferfish

quaint mantle
#

then use api

young knoll
#

🐔

wary harness
#

So is there any way to get projectile which has killed entity and check if there is FixedMetadataValue on it ?
In EntityDeathEvent

mortal hare
quaint mantle
#

ok ok

#

whats pufferfish tho

mortal hare
#

im just criticising for no apparent reason

young knoll
#

getKiller is only players

#

I believe entity has a getLastDamageCause

sick herald
#

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.

hasty prawn
#
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.

mortal hare
#

wait

young knoll
mortal hare
#

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

wary harness
sick herald
wary harness
#

Because arrow is custom

#

FixedMetadataValue

young knoll
#

You can check if the last damage cause was an EntityDamageByEntity event and then use that

hasty prawn
sick herald
chrome beacon
#

Are you using maven?

sick herald
#

yeah

chrome beacon
#

Set the scope of the dependency to provided

sick herald
#

i did but it still shaded it

#

i even deleted the dependency

#

it still shaded it

chrome beacon
#

Not possible

#

You might just have used an old jar

sick herald
young knoll
#

Does maven cache stuff? If so you can try mvn clean

spiral light
#

why the hack did md5 this:
he rly hates custom non api related stuff -.-

sick herald
#

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

chrome beacon
young knoll
#

It’s as if you aren’t meant to add custom effects

quaint mantle
#

"Custom stuff" was never supported

spiral light
spiral light
quaint mantle
#

I dont believe that would ever work that easy

#

Its not enchantments which are just strings in nbt

spiral light
#

yeah... its more then 1 string ... its also some numbers and stuff but still saved in nbt of entity ^^

young knoll
#

Good luck having it display on the client

spiral light
dusk flicker
#

its minecraft

#

its DEF not that simple

young knoll
#

Yeah that doesn’t even work with enchants afaik

spiral light
#

idk ... enchantments were easy af

quaint mantle
#

and still not supported

mortal hare
#

he saved precious memory

spiral light
#

he did not probably since the ids already exist in minecraft registry ^^

mortal hare
#

its not only in potionEffects

#

i've seen something like this before too

spiral light
#

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

mortal hare
#

i think this is to make porting to newer versions a lot easier

quaint mantle
#

it is not going to be accepted

mortal hare
#

what if Registry system gets changed

#

in the future

quaint mantle
mortal hare
#

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

karmic grove
#

what would be best way to tp 2 random players somewhere

young knoll
#

I’m pretty sure spigot does intend to switch to wrapping registries some day

spiral light
#

hmm since PR would take too long i will just use some magic here and there

mortal hare
#

i've seen some dude here who edited bytecode in runtime

#

to change method's code

quaint mantle
#

Stop doing trasht unsupported things

mortal hare
#

now that's persistence

#

he patched spigot.jar via plugin in runtime

spiral light
young knoll
#

Gotta love some bytebuddy

quaint mantle
quaint mantle
#

Friendly reminder that ByteBuddy woudlnt work on spigot without bootstrap

quaint mantle
woeful crescent
#

Sorry for the late response, but does that mean that data leaks only matter if you forget to remove from your hashmap?

spiral light
#

my last try to add smth as pr was canceled because it was to much changing ^^

quaint mantle
#

okay you jusr make me angry

karmic grove
#

is there somthing to get all active players and tp 2 random players

#

or somthing like that

young knoll
#

getOnlinePlayers

#

Stick that in a list and then just grab 2 random indexes

karmic grove
#

hm ok

woeful crescent
#

ohhh that sounds fun

#

lol

karmic grove
#

:]

#

idk what im signing up for yet but ig well see

woeful crescent
#

"SWITCHAROO!! ==> Teleported you to Coolioplayz54"

dusk flicker
#

what you want is very simple java so shouldent be hard

woeful crescent
#

^^

#

I can help if you need it as well

karmic grove
#

help me or someone else

trail bough
#

šŸ‘€

woeful crescent
#

?

trail bough
#

i was just looking at you 2 talking

karmic grove
#

whoe r u replying to

karmic grove
trail bough
#

probably gonna take a break from coding fir a but

woeful crescent
trail bough
#

yes, v e r y

karmic grove
#

id love some guidence šŸ˜…

woeful crescent
#

ok

#

welp @ me if you need anything

#

it sounds like a very fun concept

karmic grove
fathom cobalt
#

can I simulate a player command event from a unit test?

karmic grove
#

wdym

chrome beacon
fathom cobalt
#

I'm using MockBukkit atm

#

it doesn't have a simulateCommand function

#

so I assume I have to create one or use another library(?)

karmic grove
#

?jd

karmic grove
#

this is for me btw

fathom cobalt
#

wait, I'm wrong

#

there is a "performCommand" method

woeful crescent
#

so others can join if they want

trail bough
#

i wanna join in and probably just talk

karmic grove
#

Making random players tp

halcyon mica
#

Lets go

hasty prawn
#

What'd you end up using

halcyon mica
#
            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
hasty prawn
halcyon mica
#

Apperantly the hover event constructor is deprecated though

tulip owl
#

😠

#

Using depreciated things

halcyon mica
#

idk, they take something called content now

trail bough
#

probably json content

tulip owl
#

Not Minimessage 😦

young shell
#
[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
fleet imp
#

is it possible to tell if an advancement is gaining a recipe

kind hatch
fleet imp
kind hatch
#

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.

fleet imp
kind hatch
fleet imp
#

would it be in criteria

young knoll
#

There is a recipe reward

kind hatch
#

You might want to check both.

fleet imp
sullen marlin
#

Don’t they always just have the same name

#

Just check that

kind hatch
#

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.

fleet imp
#

@sullen marlin I'm trying to find if an advancement is a reward. Would it be in criteria?

sullen marlin
#

Idk what that means

#

Idk what a recipe reward is

#

Though that was just exp for smelting

trail bough
#

like the advancement gives you a recipe

#

i think

fleet imp
#

no other way around

#

recipe gives an achievment

sullen marlin
#

Should be ez pz

fleet imp
#

maybe

spiral light
#

md_5 are you going to rewrite some stuff in the future where you can use the minecraft registry instead of own Maps/Arrays ?

kind hatch
#

Minecraft registry?

spiral light
#

yes minecraft registry

sullen marlin
#

There’s a Registry class already

young knoll
#

And yes that means there are like a billion advancements just for recipes

spiral light
young knoll
#

No

sullen marlin
#

No, plugins are not for custom additions. That’s mods

young knoll
#

They only have a get method

spiral light
young knoll
#

I believe there are tentative plans to redo some enums to use registries

spiral light
#

for example PotionEffectTypes are stored in byName, byKey and also byId .... but i think that stuff could be replaced with the nms registry

young knoll
#

Specifically ones that are keyed

spiral light
karmic grove
#

how do i turn an in to location

young knoll
#

You don’t

#

A location is at minimum 3 ints and a world

spiral light
#

new Location(Bukkit.getWorld(int),int,int,int) ^^

karmic grove
#

oh and a world

spiral light
desert vigil
#

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:

desert vigil
#

It's my plugin

#

I'm developing it and there is that bug

spiral light
#

thought your talking about the script api

desert vigil
#

No

#

Sry

young knoll
#

Skript has a k

desert vigil
#

Yes, it's not skript

#

It's java

spiral light
desert vigil
#

My file

spiral light
#

#1 Name your classes UpperCamelCase
#2 Name your Methods lowerCamelCase

young knoll
#

lowerCamelCase

spiral light
#

#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

karmic grove
#

so im doin this do i enter somthing in the brakcets in .getworld

spiral light
#

maybe the name of your world ?

chrome beacon
#

^

karmic grove
#

so just world

spiral light
#

or world_nether
or world_the_end

karmic grove
#

ok

desert vigil
spiral light
#

you want the player to keep only hotbar + armor right?

desert vigil
#

& offhand

#

But that's less important

spiral light
#

you will need to save the "hotbar" for each player

chrome beacon
#

^

spiral light
#

OR setDrops to false and drop everything that is not hotbar/offhand/armor manually

desert vigil
#

Ok

#

Thanks

#

And for some of the convention stuff, I came from C#, and we start our methods with uppercases there

chrome beacon
#

Yeah and it's annoying to read ;/

#

One of the things that bothers me the most about C#

spiral light
#

but you write UCC on Class-names too ^^

desert vigil
#

Yeah, I fixed that

spiral light
#

ohhhh who was writing some time ago that custom potion effects wont be that easy like enchantments ? XD

young knoll
#

Functionality is easy

#

But how will you display them

spiral light
young knoll
#

Just make your own

#

It’s just a countdown

spiral light
young knoll
#

It won’t

#

Same way enchantments don’t display

spiral light
# young knoll Just make your own

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

spiral light
young knoll
#

Doubt it

#

The server appears to send them by id

#

And that id won’t exist on the client

chrome beacon
#

^^

spiral light
#

sucks to be minecraft

chrome beacon
#

It works just fine

young knoll
#

What does

spiral light
#

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^^)

chrome beacon
#

^

echo basalt
#

Question: What's the zstd implementation with the lowest file space?

young knoll
#

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

echo basalt
#

I need zstd compression for a project and shading it in makes my jar to to 20mb

young knoll
#

Because that sends them by id

chrome beacon
#

Yeah

young knoll
#

Which means I gotta make my own enchanting GUI

chrome beacon
#

No

sterile token
#

Oh sorry

#

Olivo can i tell you smth?

chrome beacon
#

Sure

karmic grove
#

ping?

chrome beacon
sterile token
#

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

chrome beacon
#

Yeah

sterile token
#

I have been debugging InventoryEvent#getSlot() and InventoryEvent#getRawSlot() are different. But i cannot find why

#

Hahaha i will prob need to continue reading

young knoll
#

RawSlot is over the entire view iirc

#

Slot is unique to which inv you click on, top or bottom

sterile token
hexed hatch
#

are potion recipes data driven yet or accessible via the api?

young knoll
#

No

#

They are hardcoded

hexed hatch
#

might actually cry

#

jarvis open intellij, create project and name it BetterBrewing

trail bough
#

WorseBrewingā„¢ļø

hexed hatch
#

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

young knoll
#

I’m down

#

Haste potion time

#

Let me know when it’s done

hexed hatch
#

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

young knoll
#

Same

sterile token
hexed hatch
#

just realized that if I want this plugin to be good, I'd have to give it hopper support

#

not very motivating

hexed hatch
#

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

young knoll
#

Removal would be easy

#

Insertion, not so much

hexed hatch
#

it will be janky

trail bough
#

jaaaaank

buoyant viper
hexed hatch
#

brewing stand ingredient slot now accepts whatever the fuck I want to give it

left swift
#

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

ivory sleet
#

no cluie

buoyant viper
#

?paste

undone axleBOT
gleaming grove
#

Can you paste full error?

buoyant viper
#

@quasi patrol youll get a more descriptive error if you replace ur plugin.getLogger().severe with an e.printStackTrace()

buoyant viper
#

instead of just printStackTrace

quasi patrol
#

Ok.

gleaming grove
#

IK

quasi patrol
#

I get an error in my IDE saying cannot resolve method 'severe(void)'.

gleaming grove
#

it means that this method not exists

quasi patrol
#

So uh...

#

I think I miss understood what they said lol.

buoyant viper
#

replace the whole line

quasi patrol
#

I realized that. Lol.

buoyant viper
#

replace the whole plugin.getLogger().severe(e.getStackTrace().toString()) with e.printStackTrace()

#

ye

quasi patrol
#

Got it!

gleaming grove
#

the 400 HTTP error in general means bad request, so maybe your URL is invalid

buoyant viper
#

send the code ur using for the webhook?

gleaming grove
#

and you should not trigger HTTP request inside Spigot command, it slows server a lot

#

use Bukkit task for HTTP requests

proud forum
#

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?

paper viper
gleaming grove
gleaming grove
proud forum
#

do i use that in the main class or do i add that to the command class i am currently in?

gleaming grove
#

in command

buoyant viper
#

the command ur running it from

sullen marlin
buoyant viper
#

^

sullen marlin
#

if(!enabled) return;

buoyant viper
#

if (plugin.shouldBeOverpowered) dostuff

proud forum
#

šŸ‘ thanks!

sterile token
#

What its best comparing the whole inventory or the name? (for custom inventory)

gleaming grove
#

inventory object i guess

sterile token
#

Allright thanks

#

I was in dought because sometimes copare the object consume more resources

gleaming grove
#

when?

young knoll
#

When they have a custom .equals

gleaming grove
#

comparing object is faster then comparing strings content

sterile token
#

Oh i didnt know that before

#

Thanks

gleaming grove
#

@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...

ā–¶ Play video
sterile token
#

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

young knoll
#

That should work

#

Ideally you compare views

sterile token
#

Yes because i wanna do it for custom inventory/guis

gleaming grove
#

yes event.getInventory() == inventory will work

sterile token
#

Because when i click on player inv detect the same as clicking on custom gui

gleaming grove
#

what kind of bugs?

wintry badger
#

hi, what is the event for picking up xp orbs?

sterile token
gleaming grove
#

right to prevent that you would need to check the slot index

buoyant viper
#

?jd

sterile token
young knoll
#

openInventory returns a view

young knoll
#

Add that to a set and check .contains in the event

sterile token
#

So on click event i loops througt openInventory

#

And check if contains my custom right?

young knoll
#

No?

#

I told you, use a set and .contains

sterile token
#

So with this code. When i click on the player menu wont get executed right? Only when i click on custom menu

gleaming grove
#

so to detect if player clicked on custom gui make just if(slot < 30) { customGUIClick()} else {playerGUiClick();

young knoll
sterile token
young knoll
#

You should

sterile token
#

But im using it or not on my code

young knoll
sterile token
#

Because im confused right now

wintry badger
#

is there helper library / class to handle config files easier?

sterile token
#

Do you want it?

wintry badger
#

yes please!

gleaming grove
#

the - 999 slot comes when player click out of his Inventory

young knoll
#

Or you can check if the clicked inv is null

#

Rather than magic values

sterile token
#

Wait i forget something

sterile token
wintry badger
sterile token
#

Your welcome

#

When i finish fixing my menu gui and testing others things in the library. I will publish it on github

proud forum
#
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?

hexed hatch
#

lol

hasty prawn
#

Because your braces are wrong

sterile token
golden turret
#

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

young knoll
#

Is you event set to be async

golden turret
#

yes

worldly quest
#

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

golden turret
young knoll
hexed hatch
#

I am completely convinced that BrewingStand#setBrewingTime simply does not function lol

trail bough
young knoll
hexed hatch
#

consider BetterBrewing cannedā„¢ļø

young knoll
trail bough
#

rest in plugin development hekk

hexed hatch
#

that might be the teensy itty bitty little problem here

trail bough
#

is it uncanned now

hexed hatch
#

potentially

golden turret
worldly quest
hexed hatch
#

so that fixed my little issue

wintry badger
#

how to fix: org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml ?

young knoll
#

Show the full error

golden turret
hexed hatch
#

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

wintry badger
#

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

trail bough
#

just recode a brewing stand entirely

young knoll
#

ā€œJar does not contain a plugin.ymlā€

hexed hatch
#

tell you what blaze

#

you make the brewing stand do the move move

wintry badger
hexed hatch
#

and I'll do the data bullshit

trail bough
#

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

wintry badger
#

actually it contains a plugin.yml

#

in resources folder

sterile token
#

Send cap

#

I think you have smth wrong

young knoll
#

Are you building with maven/gradle

wintry badger
#

name: MoreXP
version: '${project.version}'
main: com.testchambr.morexp.Main
api-version: 1.18

golden turret
hexed hatch
#

the dream dies here

trail bough
#

f

wintry badger
#

maven

golden turret
#

which is not async

#

:C

young knoll
#

Are you actually building with maven

#

Ie mvn install or whatever

hexed hatch
#

plus all of this hard work will become immediately redundant when spijang adds api support or mojgot supports datapack recipes for brewing stands

trail bough
#

sadly yeah

#

my home plugin is doing decent though

hexed hatch
#

no no, that's the good ending

sterile token
#

So we can see your structure

#

And notice if something its wrong

wintry badger
#

yeah the problem was how i was building it. thanks guys!

trail bough
sterile token
hexed hatch
trail bough
#

true

wintry badger
sterile token
hexed hatch
#

they can't expect me to solve all their problems

trail bough
#

i probably need a /delhome command

void mason
#

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.

left swift
#

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

shell bluff
#

Is there a way to check if player isn't holding a left click anymore?

quaint mantle
#

nope

shell bluff
#

Ugh...

wintry badger
#

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.

hexed hatch
#

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

young knoll
#

Do the thing

sterile token
#

Its possible to change the export jar directory? So intellij export my jar to another directory?

hexed hatch
young knoll
#

Use the fancy new switch stuff

hexed hatch
#

that's what I'm doing

#

still not happy about it

hardy swan
#

Must field accessibility be true for MethodHandles to lookup on it?

hexed hatch
#
    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
young knoll
#

3long

buoyant viper
hexed hatch
#

maybe someone in 2 years will find this with the search feature and I will have saved them 6 minutes and 23 seconds

hexed hatch
young knoll
#
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;
        };
    }
hexed hatch
#

oh

young knoll
#

Wee java 16

buoyant viper
young knoll
#

I'll shorten you

hexed hatch
#

I had no idea that was possible

buoyant viper
#
public static DyeColor getDyeFromMat(Material mat) {
        return DyeColor.valueOf(mat.name().substring(0, mat.name().lastIndexOf('_') - 1));
    }``` i think?
young knoll
#

I mean mayble

void mason
#

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.

young knoll
#

Actually no

#

case PINK_DYE -> ChatColor.LIGHT_PURPLE;

#

For example

buoyant viper
#

what

young knoll
#

Ah

buoyant viper
#

we were doing Material to DyeColor

young knoll
#

DyeColor

buoyant viper
#

not dye Material to ChatColor

young knoll
#

Yeah that will probably work then

#

Even if it's jank

buoyant viper
#

it should, the pattern looks to be that the DyeColor equiv is just Material name with the _DYE removed

young knoll
#

jank

buoyant viper
#

as long as bukkit api doesnt change its names... šŸ˜Ž

hexed hatch
buoyant viper
#

just cache it in a hashmap ezpz

hexed hatch
#

potato tomato

#

I'll cache you in a hashmap

sterile token
hexed hatch
#

that was not funny

sterile token
#

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

#

😔

buoyant viper
#

well

#

do u have access to them? LULW

sterile token
#

if that yes

void mason
sterile token
void mason
#

ok XD

sterile token
#

If no one answer its because they are in their own things or they dont know how to do it

void mason
#

k

quaint mantle
#

when spawning campfire cozy smoke particle it spawns dif sizes can i make it just the biggest size or no?

echo basalt
#

setBlock might not be enough

torn shuttle
#

man

#

january 19th 2038 is going to suuuuuuuuck

young knoll
#

u wut

torn shuttle
#

the end times

#

jan 19th 2038

#

3:14 am UTC

#

specifically the end of unix time, that's when it overflows

void mason
#

am

quaint mantle
#

i mean like is there a way to make it just large using the extra data value or what

prisma dove
#

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

proud forum
#

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);
        }
    }

}```
young knoll
#

Just have a boolean somewhere that you toggle with the command

#

Then return if the boolean is set in the spawn event

hardy swan
#

Which is faster, Field#get(Object) or MethodHandle#invokeExact(Object) (specifically for Java 8 and above)

#

online sources giving mixed reviews

ivory sleet
#

For j18 they’ll be negligibly different

#

But rn use latter if possible

#

Given that you don’t just unreflect ofc

hardy swan
#

I unreflect to get the methodhandle cause I have to set accessibility to true anyways

ivory sleet
#

You probably want to use lambda meta factory

#

In that case the latter will be extremely much faster

#

Almost like a normal method invocation

hardy swan
ivory sleet
#

I think it’s possible to use for fields also

hardy swan
#

probably, since MethodHandles can be used for fields too

ivory sleet
#

Ye

hardy swan
#

But all this probably happens only once in the entire program

#

?

ivory sleet
#

Anyways just unreflecting a mh can actually be worse than normal reflection invocation

#

Wym?

hardy swan
#

So even when using LambdaMetafactory you are still calling MethodHandle#invokeExact(Object) subsequently right

#

and for every repeated calls after

ivory sleet
#

Well

#

You use the CallSite

#

then ::getTarget

hardy swan
#

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

ivory sleet
#

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

hardy swan
ivory sleet
#

Wym

hardy swan
#

ok nvm i misunderstood that statement :/

ivory sleet
#

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)

proud forum
# ivory sleet Ye

hey i was wondering if you could help me? i am pretty new to this stuff and don't know where to start

hardy swan
#

unregister the listener

ivory sleet
#

^

#

Easiest way frankly

hardy swan
#

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

proud forum
#

hmmmm

ivory sleet
#

One way of doing it

proud forum
#

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

ivory sleet
#

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

proud forum
#

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

ivory sleet
#

Yeah python is amazing

proud forum
#

but as of right now this is my 3rd day working with plugin development because its so cool and fun to do

ivory sleet
#

Keep learning (:

proud forum
#

and java

ivory sleet
#

Ah yeah good luck

proud forum
#

thanks man :D most people usually say "lol" if i ask a stupid question

hardy swan
#

lol

ivory sleet
#

I need to go sleep but maybe solarrabbit can assist you :>

vale cradle
proud forum
#

its alr man you don't have to, i know its hard to kind of tell beginners what to do without spoonfeeding

hardy swan
#

im done pretending python isn't amazing

#

and pretending java is amazing

vale cradle
#

haha, It's fine, I was just joking about :)

quaint mantle
#

I need help

vale cradle
#

python is a very flexible language and has a lot of applications because of that, not a bad language

hardy swan
proud forum
# hardy swan 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

quaint mantle
#

Guysi need help

#

How do i get minecoin on minerewards

hardy swan
#

what's that

proud forum
#

... this is not the right place to ask for help for that issue lol

#

isn't minecoins the bedrock edition currency or smth

quaint mantle
#

Oh

proud forum
#

LOL i would just google search it if i were you

#

cuz this place is for java plugin development

hardy swan
#

for spigot

proud forum
#

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

buoyant viper
#

wait u can use MethodHandles and LMF on fields?/

hardy swan
#

mh yes

#

what lmf

buoyant viper
#

lambdametafactory