#help-development

1 messages · Page 14 of 1

worldly ingot
#

Main is a misnomer

#

It should be reserved for the class that holds the main method. That's it

tender shard
#

yeah well, kinda true, but also not really any problem

worldly ingot
#

No, not a problem. As much as

public void myMethod()
{

}```
also isn't a problem
#

It's just wrong lol

azure hawk
#

still doeant work

tender shard
#

I'd also not name my new plugin's main classes "Main" but it also would not cause any problems, ever

worldly ingot
#

Unless, of course, you're importing the wrong Main

#

Because both CraftBukkit and NMS have a Main

#

(both of which contain the main method btw ;p)

river oracle
#

its causing you issues

#

your making a listener from presumably spoon fed java code and named your class incorrectly expecting it to work

tender shard
#

but people shouldn't use OBS or NMS anyway 😄 And whoever does, probably knows which class to import. But yeah, you're right, Main is not a good name but it also doesn't kill anyone

worldly ingot
#

I also don't kill anyone

#

Unless you use Main in your plugin

tender shard
#

yet

worldly ingot
azure hawk
#

so do i have do rename my main

#

or what

worldly ingot
#

No you're fine lol

tender shard
#

well

azure hawk
#

ok

tender shard
#

obviously rplace that with your actual plugin name

#

lol

worldly ingot
#

You can if you want, we generally discourage the use of Main as a class name, but it won't be the cause of your issues

#

I'd imagine you're just importing the wrong Main

azure hawk
#

yeah

#

thats obvius

tender shard
#

I usually call my main ChestSort, Drop2Inventory, etc (however the plugin is called), unless I already have another class called like that. e.g. for AngelChest, there's an "AngelChest" class so that'd be called "AngelChestPlugin"

river oracle
azure hawk
river oracle
#

your clas is interactListener when it should be InteractListener

azure hawk
#

how do i fix that xd

tender shard
#

fix your class name

#

interactListener != InteractListener

fleet comet
#

registereevents?

tender shard
#

and DO NOT register the listener in the constructor

azure hawk
#

its getting better

#

xd+

tender shard
#

that's against the "single responsibility" idea

fleet comet
tender shard
#

your main class / onenable should register the listener

#

a listener should only register itself in very few usecases

azure hawk
#

it does

#

LMAO

tender shard
azure hawk
#

ok

#

it was from the video

#

xd

tender shard
#

shitty video then :/

azure hawk
#

so like this

worldly ingot
#

Yes, just the class and constructor names don't match

tender shard
#

rename the class to InteractListener

quaint mantle
#

this shit pisses me off on god im gonna make my own jvm at this point

azure hawk
tender shard
#

good luck

brave goblet
azure hawk
#

thx you guys

worldly ingot
tender shard
#

do not moddify collectiosn while looping over them

  1. use a second "copied collection"
  2. use an iterator
  3. use a threadsafe variant (e.g. ConcurrentHashMap)
brave goblet
tender shard
fleet comet
#

bump

azure hawk
#

brruuuuh

#

whyyy

fleet comet
#

use this in the constructer

brave goblet
#

also why don't you register ur events in onEnable?

tender shard
worldly ingot
#

It requires his plugin instance

#

You can pass this to the constructor

azure hawk
#
package buildserver.main.listeners;

import buildserver.main.Buildserver;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;

public class interactListener  implements Listener {
    private Buildserver plugin;
    public interactListener(Buildserver main) {
        this.plugin = main;
    }

    //ArrayList<String> hidden = new ArrayList<>();
    //String prefix = getConfig().getString("Config.prefix");

    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent event) {
        Player player = event.getPlayer();
        if(event.getAction() == Action.RIGHT_CLICK_AIR | event.getAction() == Action.RIGHT_CLICK_BLOCK) {
            if(event.getMaterial().equals(Material.COMPASS)) {
                Bukkit.dispatchCommand(player, "kill");
            }
        }
    }
}
#

Thats the whole code

fleet comet
#

?paste

brave goblet
#

ok

undone axleBOT
fleet comet
#

^

brave goblet
#

just confused why u made a different class for it then

tender shard
#

you should take a look at this:

#

?learnjava

undone axleBOT
fleet comet
#

learn. java.

tender shard
chrome beacon
#

Use Plugin instead of JavaPlugin. Use a constant for the Namespace. If you're on a modern version you can use instanceof Player player. So you can skip the cast line

tender shard
#

and ?learnjava

azure hawk
tender shard
fleet comet
fleet comet
tender shard
fleet comet
#

final is constant?

azure hawk
#

please i just wanna get on coding

fleet comet
#

wow i never knew

tender shard
fleet comet
azure hawk
#

im not that far into java jet

#

xd

fleet comet
#

i would not start making minecraft plugins if ur brand new to java

azure hawk
#

and i dont know this stuff yet

tender shard
azure hawk
#

and you're helping me

fleet comet
#

then dont use that stuff yet

brave goblet
fleet comet
#

make a hello world program, work on proper class names

brave goblet
#

spigot != coding

azure hawk
#

and there are errors

brave goblet
#

ur making it hard for urself

azure hawk
#

so i ask you guys

#

lol

fleet comet
#

you ask us with almost no expierence

#

get some

brave goblet
#

what does != mean?

fleet comet
#

then come back

fleet comet
brave goblet
#

was asking the other guy...

fleet comet
#

i answer

tender shard
#

?learnjava

undone axleBOT
brave goblet
#

and it's cool how u can use ! to toggle booleans

#

! is amazing!

tender shard
#

is there any language that doesnt have this? o0

brave goblet
#

idddk

#

i found it out in java first

#

since it's what i only coded in for like 2 years

#

until i started learning other stuff

#

and i haven't worked with other languages that do booleans yet

tender shard
#

I think every language has this, or at least a similar thing :3

brave goblet
#

just css and html

chrome beacon
#

They are stylesheets and markup

brave goblet
#

ik

#

i am just saying thats the only other stuff ik to code in

#

starting to learn js now tho

#

then python

tender shard
subtle folio
#

jeff

tender shard
#

Ntdi

chrome beacon
#

;/

tender shard
#

clogger

subtle folio
#

i read your blogs

tender shard
#

toilet clogger

subtle folio
#

LOL

tender shard
#

lol

#

😄

#

for real

#

everyone has clogged a toilet at least once in their life

opal juniper
fleet comet
#

hey how do i make non-final vars in a interface class?

tender shard
tender shard
fleet comet
#

O:

tender shard
#

if you want to have a non-final variable in an interface, I fear you haven't understood the purpose of interfaces yet 😛

fleet comet
#

well have this but like i needa change it 2 the item when i implement this class

opal juniper
#

i’m gonna assume my answer is yes

tender shard
azure hawk
#

it's like the same

#

what did i do wrong

tender shard
fleet comet
opal juniper
#

you didn’t do it wrong

azure hawk
#

that

#

i guess

azure hawk
tender shard
#

an interface is merely a "contract"

tender shard
#

oooh

#

now I see it

opal juniper
#

you need to pass for constructor

tender shard
#

you still didnt pass "this" into the constructor

#

idk why you refuse to ?learnjava

#

?learnjava

undone axleBOT
azure hawk
#

like that

opal juniper
#

yep

tender shard
opal juniper
vast raven
#

Effect.LAVA_POP is deprecated, how am I supposed to spawn the lava particles

tender shard
# azure hawk sorry

no problem, ?learnjava isn't meant as insult. It's just a suggestion because it's hard to learn java by just going into spigot without knowing the basics 🙂

brave goblet
tender shard
tender shard
#

I'm hungry since 2 days

#

gimme your mom's phone number

#

imma message her and ask for food

#

if your grandma is still alive, gimme her phone number instead

brave goblet
#

where the cookies at

tender shard
#

gotta craft'em yourself D:

opal juniper
chrome beacon
#

^

brave goblet
tender shard
brave goblet
#

oh bruh

#

can u atleast send the recipe then?

tender shard
#

here

brave goblet
#

thaaaanks!!!!

tender shard
#

I got you one cookie and it only cost me 100% cpu usage

brave goblet
#

I appreciate that

tender shard
brave goblet
#

you just saved my life ill do saves urs one day

tender shard
#

❤️

brave goblet
azure hawk
#

?learnjava

undone axleBOT
tender shard
#

I also kinda learnt java while doing spigot plugins and it was a pain. I learnt the very basics in school, like 12 years ago, so I didnt have to start from scratch. But learning at least the basic concepts (e.g. like "WHYYYY can I not use new MyClass() when I defined a constructor that does MyClass(SomeObject)") is ofc a huge help. So yeah, sounds frustrating but you really have to go through at least half of one of those linked tutorials. It'll be very helpful, I promise

azure hawk
#

WHAT THA FUCK. I searched everywhere and i nowhere i import buildserver.main.main >.<

azure hawk
#

oh

#

ok

#

thanks

azure hawk
brave goblet
#

can i see ur pom.xml?

azure hawk
#

to long for dc

chrome beacon
#

I've already told them what the issue is

brave goblet
delicate lynx
#

?paste

undone axleBOT
brave goblet
fleet comet
fleet comet
#

not sure why

chrome beacon
#

They're not holding an item

fleet comet
#

but they are

tender shard
#

PlayerInteractEvent get called twice, once for offhand and once for main hand

#

so probably the offhand is empty

chrome beacon
#

^

fleet comet
tender shard
#

what's your listener code

fleet comet
#
@Override
    public void handleAttack(EntityDamageByEntityEvent event) {
        if (event.getEntity() instanceof Player) {
            Player victim = (Player) event.getEntity();
            victim.addPotionEffect(new PotionEffect(PotionEffectType.DARKNESS, 10, 1));
        }
        Player victim = (Player) event.getDamager();
        victim.addPotionEffect(new PotionEffect(PotionEffectType.DARKNESS, 10, 1));
    }```
worldly ingot
#

Well I mean...

#

Your console has a ClassCastException doesn't it? lol

fleet comet
#

no

worldly ingot
#

It will when any other entity damages another entity

tender shard
#
            CustomItem item  = getItemFromDataContainer(((Player) event.getDamager()).getInventory().getItemInMainHand().getItemMeta());

#

this is probalby null then

worldly ingot
#

but yeah, you need an EventHandler annotation there

#

Didn't even notice that

chrome beacon
#

They use an interface

fleet comet
#

abstract*

tender shard
worldly ingot
#

wot

#

Well now that's just confusing

fleet comet
#

how?

tender shard
#

ItemManager passes the event to the CustomItem thing

chrome beacon
#

Actually wait no

fleet comet
#

?

chrome beacon
#

CustomItem item  = getItemFromDataContainer(event.getItem().getItemMeta());

#

getItem is null

#

Or can be

fleet comet
#

why is it?

tender shard
#

also instead of doing !(item == null), just use item != null

#

it's way easier to read

chrome beacon
#

IO should be done async

#

Yes

fleet comet
chrome beacon
#

Fix one thing at a time

fleet comet
#

oh wait

#

thats not even related

#

the effect just isnt being given

#

thats before i hit that entity-

#

i have no idea where 2 start debugging lol

chrome beacon
#

Fix the error mentioned above. Then put a sysout in the attack listener/method

#

Make sure it fires and we'll work from there

fleet comet
#

and it doesnt fire (:

chrome beacon
#

Well there you have the problem

fleet comet
#

aha

fossil lily
#

I'm trying to get his nametag away

#

and its just not

fleet comet
#
public void onAttack(EntityDamageByEntityEvent event) {
        if (event.getDamager() instanceof Player) {
            Bukkit.getLogger().info(((Player) event.getDamager()).getDisplayName());
            CustomItem item  = getItemFromDataContainer(((Player) event.getDamager()).getInventory().getItemInMainHand().getItemMeta());
            Bukkit.getLogger().info(item.key);
            if (!(item == null)) {
                Bukkit.getLogger().info("gets here");
                item.handleAttack(event);
            }
        }
    }``` okay so `item` is null for some reason
#

not sure why

#

@chrome beacon

chrome beacon
#

Use variables to make the code easier to read ;/
Anyways I need the getItemFromDataContainer method

fleet comet
#
public CustomItem getItemFromDataContainer(ItemMeta itemMeta) {
        PersistentDataContainer container = itemMeta.getPersistentDataContainer();
        NamespacedKey nk = NamespacedKey.fromString("custom_item", mainPlugin);
        if (!(container.get(nk, PersistentDataType.STRING) == null)) {
            return getCustomItem(NamespacedKey.fromString(container.get(nk, PersistentDataType.STRING), mainPlugin));
        }
        return null;
    }```
#

ik ima fix that later

chrome beacon
#

No. It will throw an error

fleet comet
#

idk how to get around that

#

??

tender shard
#

you should cache NamespacedKeys when possible if you need them frequently

chrome beacon
quaint mantle
#

If I'd like to modify the behaviour of horses, where can I start? Would I create a class CustomHorse extends Horse?

chrome beacon
#

You would need to extend the NMS horse yeah

tender shard
fleet comet
#

what would i init it to? also why

tender shard
fleet comet
#

thens it not changable?

quaint mantle
fleet comet
#

but the new instance is for every item? that would ruin it??

quaint mantle
#

1.19

fleet comet
#

pdc?

tender shard
#

PersistentDataContainer

fleet comet
#

oh

fleet comet
#

im so confused rn

tender shard
fleet comet
#

what you guys mean

#

and how i would do it

tender shard
#

I sent you a link above

#

that explains how PDC works

fleet comet
#

but i did use pdcs?

tender shard
#

what are you trying to do, and what's the problem?

chrome beacon
#

I still haven't seen where you add the pdc to the item

fleet comet
#
@Override
    public void init(EternityItems plugin) {
        key = "dark_sword";
        this.plugin = plugin;
        ItemStack item = new ItemStack(Material.NETHERITE_SWORD);
        ItemMeta meta = item.getItemMeta();
        meta.addEnchant(Enchantment.DAMAGE_ALL, 2, false);
        List<String> lore = new ArrayList<>();
        lore.add(ChatColor.WHITE + "The souls of the damned.");
        lore.add(ChatColor.BLACK + "Gather into the blade of darkness");
        meta.setLore(lore);
        meta.setDisplayName(ChatColor.BLACK + "The Blade Of Darkness");
        meta.addAttributeModifier(Attribute.GENERIC_ATTACK_SPEED, new AttributeModifier("dark_sword_speed", 5.0, AttributeModifier.Operation.ADD_NUMBER));
        plugin.itemManager.generateDataContainer(key, meta.getPersistentDataContainer());
        item.setItemMeta(meta);
        NamespacedKey namespacedKey = NamespacedKey.fromString(key + "_rec", plugin);
        ShapedRecipe recipe = new ShapedRecipe(namespacedKey, item);

        recipe.shape("OOO", "ONO", "OOO");

        recipe.setIngredient('O', Material.OBSIDIAN);
        recipe.setIngredient('N', Material.NETHERITE_SWORD);

        Bukkit.addRecipe(recipe);
    }```
#

here

tender shard
#

I repeat: what are you trying to do, and what's the problem?

fleet comet
#

custom item plugins, it wont fire the handleAttack

chrome beacon
#

I have a feeling you're making things more complicated then they need to be

tender shard
chrome beacon
#

We know which one fails

tender shard
#

just add something like System.out.println("...") before and after everx if

balmy valve
#

Is it possible to add durability to an item that doesnt normally have it? say a spawn egg?

tender shard
chrome beacon
chrome beacon
#

You will still need the lore though

balmy valve
#

alr 👍

chrome beacon
#

For what? What are you using the string for?

tender shard
#

why do you need it to be a string o0

chrome beacon
#

Use a yaml config or smth

#

Don't make it hard for yourself

tender shard
#

ItemStacks are serializable

chrome beacon
#

?configs

undone axleBOT
chrome beacon
#

We just told you?

tender shard
#

yes

#

myYamlConfiguration.set("item",itemStack);

#

almost everything in bukkit implements ConfigurationSeriazable

#

even Player 😄

#

(although serialization for players and offlineplayers is useless)

tender shard
noble lantern
#

By the offchance, i need to generate a Random int every tick, would ThreadLocalRandom be more efficient, or a static Random instance for the entire plugin?

chrome beacon
#

Are you on a modern version like 1.18+

noble lantern
#

Yep

#

1.19

chrome beacon
#

Then you can use the new random classes

noble lantern
#

ill google that ty, didnt know there was new random

chrome beacon
worldly ingot
#

I mean, a bit excessive tbh

worldly ingot
noble lantern
#

Yes but its something i need to call every tick or every other tick, multiple times in said tick

worldly ingot
#

That's fine

#

ThreadLocalRandom#current() returns a constant anyways

#

(constant for the current thread, that is)

noble lantern
#

So say 100 times per tick, shouldn't be an issue? with a max bounds of -20 to 20?

worldly ingot
#

Yeah, no issue whatsoever

#

Generating random numbers isn't necessarily performance intensive

noble lantern
#

add i always thought it was

#

i guess I must be thinking of the noob way new Random().nextInt()

#

i remember when first learning java there was something with randoms that was necesarily bad, maybe that was it

#

cant quite remember

noble lantern
#

yep

worldly ingot
#

Yeah, if you're doing new Random().nextInt() every time, you're going to break some computers

noble lantern
worldly ingot
#
public final class Main {

    public static void main(String[] args) throws Exception {
        int amountToGenerate = 100000;
        int[] values = new int[amountToGenerate];

        long start = System.currentTimeMillis();
        for (int i = 0; i < amountToGenerate; i++) {
            values[i] = ThreadLocalRandom.current().nextInt(-20, 20);
        }

        long end = System.currentTimeMillis();

        System.out.println("Done in " + (end - start) + "ms");
    }

}```
#

This took 5ms

noble lantern
#

oh shit

#

okay

#

yeah certainly fine for 100-1000 then ahahhhh

#

I just use randoms to offset a location while a NPC is syncing location to player

A lot nicer then them pathfinding straight into your face

worldly ingot
#

You'll be okay ;p

noble lantern
#

god the namespace for custom recipes is weird

#

" X "

#

like 3 length string cx on the namespace

#

Yes but IMO it should be more programatically available for setting what slots accept what

#

ie set(0, "X");

#

indeed, its easy to make a wrapper around it tho

#

but always something that slightly annoyed me when working with the raw api

#

if you do it right you could have some sick chaining

#

so like

rough drift
noble lantern
#
set(0, null).set(1, "X").set(2, null).
set(3, null).set(4, "X").set(5, null).
set(6, null).set(7, "B").set(8, null);
rough drift
#

wrong reply

noble lantern
#

fuck that hurt my arm typing

rough drift
#

also there's a random you can use fo ra sped

noble lantern
#

you can just set only slots you dont want air

rough drift
#

for sped random

chrome beacon
#

If you want speed there are benchmarks in the random guide I sent

noble lantern
#

more or less just for programatic friendlyness

#

its awkward to manipulate raw strings, especially with dynamic stuff

rough drift
#

it's a huge library of fast as fuck utils that are extremely good at what they do

#

anyways gtg

#

bugs are on my screen (it's night)

noble lantern
chrome beacon
#

Higher score is worse

#

That's time

#

ns/op

noble lantern
noble lantern
#

or lower

chrome beacon
#

You want low time per operation

noble lantern
#

So L64X256MixRandom

#

at .090

#

seems like an odd graph to read lmao

never really benchmarked stuff using ns/op

#

Il bookmark this tab and take a look into it later tonight

When i get nit picky for performance ill shove the new random generator in

chrome beacon
#

Yeah go for thread local

noble lantern
#

Yeh that's currently what I'm using, only reason i really even did in the first place is because nextInt supported a min and max value that was negative easily without any math haha

tender shard
#

you create a new inventory, or fill the one you already have

#

you have to loop over it, yes

river oracle
#

are there negative side effects of setting an item in the inventory as 0 to get rid of it apposed to removing it from the slot directly. I'm working with an item I want to be consumed and its easiest to set the amount to 0 than override the inventory slot its in based on my design structure

noble lantern
#

remove -1 from amount on consume is best

river oracle
#

ok thank you

noble lantern
#

use getItem(slot).setAmount(- 1)

cause if you override the slot a different item may be there by the time you try to set it to null/air (IE in a task)

#

sorry discord crashed so took a min to send

river oracle
noble lantern
#

ahh so your already dealing with just a raw ItemStack already in the use method

In that case it still applies for - 1, just as long as you arent cloning the ItemStack getting used

#

What version is this

#

on newer versions you use GameProfile's to set skull owners iirc

#

that method is from 1.8, thats how it was done back in the day

#

yeh

#

thres an article somewhere on it

river oracle
#

you can use PlayerProfile from spigot iirc

#

no need for Mojang api anymore

#

Bukkit#createPlayerProfile

noble lantern
noble lantern
river oracle
#

that method is outdated use PlayerProfile which has a similar way of working just minus the reflection

noble lantern
#

the method for the skull setting should still be the same, but just take in PlayerProfile instead of the GameProfile

#

so everything GameProfile in that thread is irrelevent

#

because you rly need the Base64Texture the skin provides

#

if you already have the base64

#

im like 99% sure thats all you need

river oracle
#
        PlayerProfile file = Bukkit.createProfile(UUID.randomUUID());
        file.setTextures(file.getTextures().setSkin("url"););
noble lantern
#

^^

#

bam

river oracle
#

way shorter and easier

#

just do url its super easy

#

most websites host links to the url

chrome beacon
#

Decode the base64 for the url :)

#

It's inside a piece of json

river oracle
#

lol

#
new URL("https://textures.minecraft.net/texture/32bb65a10d0162ba63f84deedd3e678ba0904751aeff5ba077e094f1cf27feec");
#

if you need a url object do that

sterile token
#
private static void createProfile() {
  PlayerProfile file = Bukkit.createPlayerProfile(UUID.randomUUID());
  file.setTextures(file.getTextures().setSkin(new URL("https://textures.minecraft.net/texture/32bb65a10d0162ba63f84deedd3e678ba0904751aeff5ba077e094f1cf27feec")));   
}
#

You will have to add a try-catch

tender shard
sterile token
#

or is it from mojang auth package

tender shard
somber hull
#

How does the default config get created with all your saved values?

tender shard
#

GameProfile is from authlib

somber hull
#

Like

#

If i wanted to make a second config

tender shard
#

PlayerProfile is API since 1.18.1

chrome beacon
undone axleBOT
somber hull
#

That i can put preexisting values into how

#

thank

tender shard
sterile token
cedar oyster
#

I keep getting this error in the console when my plugin loads a config. Does anyone know of a common solution to this if there is one? Cannot load configuration from stream org.bukkit.configuration.InvalidConfigurationException: unacceptable code point '' (0x0) special characters are not allowed in "'reader'", position 0

chrome beacon
cedar oyster
#

interesting

#

but it still gets the data from the config

chrome beacon
#

Did you specify defaults?

cedar oyster
#

I don't think so

echo basalt
#

Hey, does anyone know the process for sending a lever change?

#

Anything else works so I might need some other packets?

#

file.getTextures().setSkin

arctic moth
#

How do I hide my directory or make it work with a team of people when exporting to a specific path in pom.xml

echo basalt
#

no need to call setTextures

arctic moth
chrome beacon
#

Get the skull meta and call setPlayerProfile

#

You need to set the variable type to SkullMeta

severe turret
#

why is that static

hard socket
#

i use authlib it works really fine

#

GameProfile is better

echo basalt
#

authlib is made by mojang

#

and nms uses it internally

hard socket
#
        ItemStack item = new ItemStack(Material.LEGACY_SKULL_ITEM, 1, (short) 3);
        if (url.isEmpty()) return item;


        SkullMeta itemMeta = (SkullMeta) item.getItemMeta();
        GameProfile profile = new GameProfile(UUID.randomUUID(), null);
        byte[] encodedData = Base64.getEncoder().encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
        profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
        Field profileField = null;
        try {
            profileField = itemMeta.getClass().getDeclaredField("profile");
            profileField.setAccessible(true);
            profileField.set(itemMeta, profile);
        } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
            e.printStackTrace();
        }
        item.setItemMeta(itemMeta);
        return item;

    }```
echo basalt
#

so I don't see a reason not to

hard socket
#

this is the code I use, use it or dont

#

yes

#

just build it in your project

#

its just 60 kb

knotty meteor
#

Someone knows how i can get all players in a range of 5 blocks
And pick 1 of them to die?

#

But then i check nearby entities instance of player
But how will i pick 1 player if there are more players in the range?

#

Alright thanks! I will try that :D

#

Hahaha thanks i will!

wet breach
#

make sure to keep your range the limit of players detected

noble lantern
#

Anyone good with AI in NMS

When setting the zza of an entity, does this gradually go down as the entity travels? What exactly is zza? Its effective velocity i assume?

echo basalt
#

it's the effective velocity for the z axis

noble lantern
#

thank you

#

currently modifying citizens cause i need to figure out when the entity stops traveling on zza Thonk

sterile token
sharp verge
#

Anyone awake that could help me out

wet breach
#

yes

sharp verge
#

Possibly in dms aswell

noble lantern
sharp verge
noble lantern
#

Dalton

sharp verge
#

yeaa

#

i think i remember you

wet breach
#

you could do that, but something that might be better is using enums to stick them in

sharp verge
#

How are your Java skills ?

sterile token
noble lantern
wet breach
#

more organized and can be called anywhere when needed

noble lantern
# sharp verge How are your Java skills ?

Exceptional, why so?

Ive offered to make plugins for saiyan gens in the past 😛

Not accepting any current work though, if you need a java dev you may need to go check services

But i can help with any java question you have

noble lantern
#

zza is infinite in decremention

sharp verge
noble lantern
#

Ask away then, if i cant answer others will 🙂

sharp verge
#

Alright

noble lantern
wet breach
#

your way is perfectly fine if that is how you want to do it, most people just don't know you could use enums for such things too lol

sharp verge
wet breach
#

lol

noble lantern
undone axleBOT
wet breach
#

I use netbeans, there is a config file where you can change the resources and jvm flags 😉

noble lantern
#

hard to read from txt file

sharp verge
#

alr

#

?paste

undone axleBOT
sterile token
#

EntityTypegetType() uses NMS interally right? Because i need to stop player killing mobs and i need

sharp verge
noble lantern
#

LETS GO PATHFINFING QUESTIOn

#

one sec verano

wet breach
#

will have to ask me in about 10 hours when I get off work. Heading to work now 🙂

bitter path
noble lantern
undone axleBOT
sharp verge
#

Alright so what im trying to do is create a .yml file for each player which shall be stored in a subfolder. example: /plugins/HoldPlugin/PlayerData/<PLAYER UUID>.yml

#

The problem is neither the subfoler (PlayerData) or the files are anywhere to be found

#

Do i have to load the something in my Main class for everything to work ?

noble lantern
#

Any more hiding elsewhere?

sharp verge
#

Thats the PlayerConfigManager

#

You want the main class aswell ?

noble lantern
#

When you want to create a new file, you need to make its dirs leading up to file + the file itself

#

Unless im overlooking i just see you opening an int/out stream to a File instance

#

he doesnt need that

#

getDataFolder() for the parent is just fine

#

hes just not actually creating the file

#

eg File#createNewFile

#

Hes just initializing a new File()

Which yes works, but if you want data to save you need to write its data to it then save

#

hes already doing that

sharp verge
#

soo from this

this.playerConfigFile = new File(this.plugin.getDataFolder(), "PlayerData" + File.separator + uuid.toString() + ".yml");```

to this?
```this.playerConfigFile = new File(this.plugin.getDataFolder(), "PlayerData" + File.separator + uuid.toString() + ".yml").createNewFile;```?
noble lantern
#

so, first i would make a single method just for checking the PlayerData directory

#

eg new File(dataFolder, "PlayerData");

Then you need to check if it exists calling exists() on it

If its false, call mkdirs() on it, if not continue to load the player data files

when loading the player data files, do the same thing with exists(), but instead of mkdirs() afterwards, its gonna be createNewFile()

From there, you can just use Bukkits Yaml api for saving/writing to said file

#

Do note

sharp verge
#

brb in 2 min i really have to take a bi piisss

noble lantern
#

some of these methods need try/catch so listen to your ide for that

#

iirc only createNewFile needs it

#

You can likely actually make the process smoother, but thats the most basic way to make sure the files exists before opening a Yaml stream to them

echo basalt
#

lowercase

noble lantern
#

NamespacedKeys cant have spaces

So yeah

sterile token
#

?bump EntityTypegetType() uses NMS interally right? Because i need to stop player killing mobs and i need

sharp verge
hard socket
#

I didnt challenge you I showed my method so idrc

noble lantern
#

yep, i would reccomend creating a local variable for that file, other than that alls good

#

mkdirs() returns a boolean btw

#

you can return its value instead of always false

sharp verge
#
    private boolean playerDirectory = false;

    public PlayerConfigManager(HoldMain plugin) {
        this.plugin = plugin;
    }

    public boolean playerDataDir() {
        if (!(new File(this.plugin.getDataFolder(), "PlayerData").exists())) {
            playerDirectory = new File(this.plugin.getDataFolder(), "PlayerData").mkdirs();
        }
        return playerDirectory;
    }```
noble lantern
#

yes

sharp verge
#

Like this @noble lantern or do you mean return playerDataDir();

noble lantern
#

well

#

return new File().mkdirs()

#

and outisde your if return true;

#

no need for that boolean variable you have sec

#

that way will work, but its better to return the values of the methods directly

sharp verge
#
    public boolean playerDataDir() {
        if (!(new File(this.plugin.getDataFolder(), "PlayerData").exists())) {
            return new File(this.plugin.getDataFolder(), "PlayerData").mkdirs();
        }
        return true;
    }``` 🙏
noble lantern
#

yep!

#

and from there, you do the exact same thing but for each player data file individually

And use createNewFile() instead of mkdirs() for actual files

sharp verge
#

so an on join event and then just check if the player already have a file?

noble lantern
#

Yep, and if they dont createNewFile and then open yaml stream to write and defaults you need

#

YamlConfiguration.loadConfiguration(file); iirc

#

and you can call save(file) on that option (I assume your using yaml)

sharp verge
#

and if not new File(this.plugin.getDataFolder(), "PlayerData" + File.seperator + uuid.toString + ".yml").createNewFile; ?

noble lantern
#

then you just get theyre file

noble lantern
#

new File() and then open the YamlConfiguration if it exists

#

I recommend using Json or sqllite for flat file storage, but for now learn this and get used to just creating files and whatnots 🙂

#

Once you learn all this you can do really crazy cool stuff with JSON + POJO classes when you learn json

eternal oxide
#

PDC

sharp verge
#

?paste

undone axleBOT
vocal cloud
#

😭 Why can't people use DBs like a normal person

dusk flicker
#

lol

late sonnet
#

i mean the plugin need unregister this recipes

sharp verge
eternal oxide
sharp verge
#

btw ElgarL

#

You wrote a comment "Not create directory" ?

#

What do you mean?

vocal cloud
echo basalt
#

simple databases are the best databases

sharp verge
echo basalt
#

mysql is popular

vocal cloud
#

That or a regular SQL DB.

echo basalt
#

I've had exotic customers ask for amazon s3

vocal cloud
#

Either or. SQLite is used in enterprise software so shrug1

echo basalt
#

windows uses sqlite

vocal cloud
#

Adobe, Google, etc.

echo basalt
#

I mean

#

google has google cloud

#

🤔

dusk flicker
#

Mongo is nice

echo basalt
#

sqlite is nice due to its offline support

vocal cloud
#

It's used in Android

echo basalt
#

it's literally a file

vocal cloud
#

And Chrome

echo basalt
#

yeah sqlite is basically local database

#

with offline support

vocal cloud
#

I prefer it over an actual hosted DB unless I plan on having that data be accessed by multiple applications

echo basalt
#

I prefer to just support the most popular choices

#

instead of convincing people to stick to a solution

noble lantern
#

too much work

#

"use mongo"

echo basalt
#

each class has like 100 lines

dusk flicker
#

once you get it made once, its the best option

#

for public plugins, as is

vocal cloud
#

I mean it really depends what the data is used for

#

Yikes, that's a lot of nested ifs

echo basalt
#

I might impl some system on my redis packet system to tell other servers about fetch and save status

#

might help with latency and anti-desyncing

dusk flicker
#

redis pub/sub is great

#

I use it for so much lol

echo basalt
#

I don't like the string forms

#

or how people send json messages

#

just serialize the data to a byte[] and send it bia binarypub

dusk flicker
#

hmm yeah

#

I personally use json

echo basalt
#

I have a packet system

#

for that

dusk flicker
#

speaking of I was actually just working on one of my packets that I should resume work on lol

echo basalt
#

it has a "packetprocessor" system where you can add redis, rabbitmq or just use sockets

#

and not have to rewrite communication to add rabbitmq

#

everything is modular

dusk flicker
#

ugh the entire system I just wrote won't work

noble lantern
#

because isSimilar matches meta data to some extent

#

and your making a new item stack

#

check its type, or if your item stacks are statics/singletons then just use that instance for isSimilar

#

yep

#

but your gonna need to tell if its a player head from your plugin ofc, likely using pdc

#

?pdc

noble lantern
#

^

mystic sky
#

Based+

noble lantern
#

Its essentially NBT, but wrapped in BukkitValues NBTCompound

echo basalt
#

Sound.valueOf

golden turret
#

?jd-s

undone axleBOT
golden turret
echo basalt
#

He was passing a bukkit sound name

#

playSound's string param is the minecraft namespaced key, made for playing a sound present in a resourcepack

hardy swan
#

Can i get an npm package idea

#

get the player’s equipment, get item in main hand. Set amount, set item in main hand.

golden turret
#

awnser: use .toLowerCase

noble lantern
#

Whats the max distance a player can be off a block before they fall off of it? Is there a specific decimal amount?

vocal cloud
#

Well doesn't it depend if they're shifting too?

noble lantern
#

yeah, without shifting is what ide likely need

#

cause what im doing wont involve shifting

#

seems like quite a lot, but not sure of the actual float amount, couldnt find anything online

#

wait

#

im stupid f3 exists

#

its about .3

#

actually its .3 both ways

#

when walking off, and shifting up to it then walking

somber hull
#

So i have a map of <ItemStack, Double> I need to calculate the amount of items to give the player based off of a int of how many minutes. Double is the chance of that item to be given every minute

#

I dont want to loop through the list for however many minutes there are

#

But i cant figure out a better way

somber hull
#

I could also just get the amount of items per minute and then divide by the percentage. But then it would be the same if minutes are the same. I want it to feel random

#

Oh well

#

Imma go with that one

somber hull
#

How do i calculate the amount of items per minute

#

Without looping through every minute and adding the itemstack to a list

#

Cause if its been 9999 minutes. And it has to loop 9999 times

#

Seems like there should be another way

#

I mean i guesse i could just save it to a map with an amount of items, and then use that later

#

thats what imma do

river oracle
#

How often are you giving the items to the player

somber hull
#

Whenever they run a certain command

#

It has to put them into a gui

somber hull
#

But still

river oracle
#

Math is the key here

somber hull
#

Ik, but how would i apply that to the amount of objhects i need to add

river oracle
#

You need time in milliseconds on last click and on nw click

somber hull
#

In minutes

#

So what im gonna do rn is this: (Leme type it rq)

river oracle
#

You don't need to loop over time all your doing is looping over a map full of items and giving a reward based off an algorithm of time passage and percentage chance of item retrieval

somber hull
#

Check the item, multiply the amount of that item by the minutes int. Then divide by the chance.

#

The only issue being

#

That i have no idea how im gonna add the amount of items based off the number

somber hull
river oracle
#

Why would you loop over time at all that'd be overly costly and slow

somber hull
#

Yes. So im trying to figure out an alternative

#

But i cant think of anything

#

At some point im gonna have to loop over the amount of time

#

Are they placing it?

#

Yea do that

river oracle
#

Log the name of the block placed and thays your answer

somber hull
river oracle
#

My math b3ain is dead this late gimme a second

somber hull
#

Alr

rain mason
#

i uh huh?? how did it just break out of a sudden

somber hull
#

Restart intellij

#

Delete intellij cache

#

Etc

rain mason
#

alr

river oracle
river oracle
#

Before I write I want to confirm you want to give player a 30% chance to recieve 1 item after every X milliseconds from last execution

somber hull
#

X% chance to receive X amount of items every X minutes

#

I will

#

one sec leme read it

#

Use interact event

#

In that situation yea

#

yes

#

I think

#

Hold up, idk if ive ever done that specifically before

#

Leme double check for you

#

@quaint mantle

#

My b

#

I havent used block place before

#

Use block place event

#

But check the block not the item

#

Or

#

Even better

#

Use event.getItemInHand

#

Excuse my schizophrenic ramblings

somber hull
noble lantern
somber hull
#

lmao

river oracle
# somber hull X% chance to receive X amount of items every X minutes

If you want a player to have x% chance to recieve y amount every z minutes first you need previous time and current time. Now you'd need to form something to run that x% chance z/current times. This can actually be modeled by

p^x(1-.3)^y

X mean succeses
Y meaning times it can process
You should beable to use a log to achieve this fairly easily

hasty obsidian
#

getHealth for Entities,

somber hull
river oracle
#

Oh idk then I'm tired lol I gotta go to bed

somber hull
#

But im having an issue because i cant simply modify an ItemStacks amount to be more than 64

somber hull
#

Get some sleep

#

wdym

river oracle
somber hull
#

BlockData

somber hull
#

Then im still looping

#

Its more efficient

#

But

#

Is it the most efficient

#

Wdym metadata

river oracle
#

Metadata isn't permanent so make sure you don't use it like persistent data containers

bright jasper
#

How tf did origin realms do this?

In most places text is rendered, a shadow appears beneath every character. This shadow is a copy of the character's bitmap, with the brightness subtracted by 90%, and positioned 12.5% south-west of the character, relative to its spacing. Regardless of the resolution of the character's texture, the shadow is always moved by 12.5%. In the default font (assets/minecraft/textures/font/ascii.png), the shadow is equivalent to being moved 1 pixel down and right.


https://i.kawaii.sh/Bl~I4BZ.png
the background is dynamically resizable and that bar doesn't have a shadow. I'm wondering if by one pixel they just put a pixel that was 90% more opacity to negate it?

#

Someone said if you don't use a default font there is a way to disable it but i havent figured that out

somber hull
#

huh

#

what lmao

#

Your trying to get the material?

#

What do you need

#

Ohhhhhh

#

Check the event.getHeldItem()

#

That gets the item before it was placed

rain mason
somber hull
#

leme get the right one

somber hull
#

probably

#

check the docs

#

Yea

#

thats it

somber hull
#

Show your imports?

#

Are any of them broken/red

#

@rain mason Multiple modules?

#

lmao does it work?

rain mason
somber hull
rain mason
#

still the advancement thingy tho

somber hull
somber hull
rain mason
somber hull
#

Delete the imports

#

And then find whatever turns red

#

push ctrl+1

#

or whatever your bind is

#

To open the tips thing

#

And find what its suggested fix is

#

Odd that your getting that issue with only a few things

rain mason
delicate lynx
#

pass only the event

rain mason
#

no wait wtf, if I put AdvancementDisplayType and the bottom of all imports, it only screams about AdvancementDisplaytype

#

but if I import it at the top, it screams about literally everything I imported

#

ahaha I wanna die

somber hull
#

It checks everything except item amount

noble lantern
#

i said this earlier didnt i lol xD

#

^^

somber hull
#

So you would wanna do if(getType == Material.PlayerHead)

noble lantern
#

you need to use a singleton of the custom item you have if you wanna use isSimilar, if not what hyper said + pdc

somber hull
#

No

#

Is similar is the same as equals just doesnt consider stack size

rain mason
# somber hull no idea lmao

anyways I removed the ADVANCEMENT THINGY!! >> thing and it magically works!! it was probably bugging out because of the advancement.getType lmao

somber hull
#

I have no idea how to use the bot

#

So imma screenshot it

#

Hes trying to check if its a playerhead

#

So he would check if the item.getType == player head

noble lantern
somber hull
noble lantern
#

Hes making a custom item plugin

#

he was in here a few hours ago

#

with the same question xD

somber hull
#

See

noble lantern
#

Yes, and then you need PDC checks

#

i said this earlier

somber hull
#

Yea

#

Use pdc

#

Its really simple

noble lantern
#

^ I linked an article earlier, not sure if you saw

#

?pdc this one

somber hull
#

Make a class like this to hold your keys

public class Keys {
    
    public final NamespacedKey ENTITY_TYPE_KEY;
    public final NamespacedKey MULTIPLIER_KEY;
    public final NamespacedKey MINED_KEY;
    public final NamespacedKey OWNER_KEY;
    public final NamespacedKey LAST_GEN_KEY;
    
    public Keys(StartupClass pluginClass) {
        MainClass plugin = pluginClass.getPlugin();
        
        ENTITY_TYPE_KEY = new NamespacedKey(plugin, "bs.entityType");
        MULTIPLIER_KEY = new NamespacedKey(plugin, "bs.multiplier");
        MINED_KEY = new NamespacedKey(plugin, "bs.wasMined");
        OWNER_KEY = new NamespacedKey(plugin, "bs.ownerName");
        LAST_GEN_KEY = new NamespacedKey(plugin, "bs.lastGen");
    }

@quaint mantle And then have a getter somewhere to get this class.

#

And get the key

#

So you dont create a bunch of namespaced keys everywhere

#

And then after that its pretty simple

#

leme give an example

#

With my plugin

#
        ItemStack spawner = new ItemStack(Material.SPAWNER);

        ItemMeta spawnerMeta = spawner.getItemMeta();
        if (spawnerMeta == null) return null;

        PersistentDataContainer spawnerData = spawnerMeta.getPersistentDataContainer();

        spawnerData.set(plugin.KEYS.ENTITY_TYPE_KEY, PersistentDataType.STRING, spawnerType.name());
        spawnerData.set(plugin.KEYS.MULTIPLIER_KEY, PersistentDataType.INTEGER, multiplier);
        spawnerData.set(plugin.KEYS.LAST_GEN_KEY, PersistentDataType.LONG, System.currentTimeMillis());

@quaint mantle

#

PDC is very easy

#

Huh

#

Lmao

#

Its super easy Facepalm

#

Show me your checks

#

Wait

#

so whats happening?

#

Also, dont do the pyramid of doom

#

Or whatever its called

#

Callback hell

#

use if(event.getBlockPlaced().getType() != Material.PLAYER_HEAD || !event.getItemInHand().getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) return;

#

It checks if its not, and returns if it isnt

somber hull
#

Weird

#

Very weird

#

Look it up?

#

lmao

#

What was the issue

#

very odd

#

Check if its null, and return

#

That should stop the error but still allow you to place it on the side

#

Just try it

#

gn

buoyant viper
#

probably using a copy of the item

#

try something like

Item(or ItemStack?) item = event.getItem();
item.setType(Material.AIR);
event.setItem(item);```
#

if the event ur using has a setItem at least

eternal oxide
#

Air has no ItemMeta

hardy swan
#

Yes

#

Just maybe, BlockPlaceEvent is triggered before the block is registered as placed?

eternal oxide
#

BlockPlaceEvents.java:22 you are testing an Item which has no Meta

#

Air

#

BlockPlace fires before teh block is placed so you can cancel it

#

Your second hand is empty

#

MainHand OffHand

#

No but some events will fire for each hand.

#

easy test, put a torch in yoru offhand

#

The fix is to always test .hasItemMeta() before attempting to .getItemMeta()

#

What item is in your MainHand?

#
ItemStack item = event.getItemInHand();
if (!item.hasItemMeta()) return;
...```
barren nebula
#

Pretty new to all of this so got a quick beginner question:
Is there a simpler/cleaner way to wait some time? I'm currently using Bukkit Scheduler and it seems really messy. Also applying to while loops, is it possible to just use while loops or am I required to use runTaskTimer

Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
    @Override
    public void run() {
        p.setVelocity(new Vector(0, -10, 0));

        Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
            @Override
            public void run() {
                p.playSound(p.getLocation(), Sound.ENTITY_DRAGON_FIREBALL_EXPLODE, 1, 0.2f);
                p.setInvulnerable(false);
            }
        }, 10);
    }
}, 10);
drowsy helm
#

runnables are your best option

#

wait do you want to pause WITHIN the runnable?

barren nebula
#

Correct, I'm currently using a scheduleSyncDelayedTask inside of another scheduleSyncDelayedTask

#

The while loop is elsewhere

drowsy helm
#

i mean you could just delegate both to a method to make it a bit cleaner

#

but theres no other option really

#

or make it into a class instead of an anonymous class

hybrid spoke
barren nebula
#

Gotcha, as long as what I'm doing is standard, I'll deal with it being messy. Appreciate you both! 😄

tender shard
#

Lol wtf DO NOT DOWNLOAD

bright jasper
#

How does one send a bossbar using a TextComponent

#

someone said protocollib on spigot but i think the packet structure changed

#

I get an error while intercepting it

#

com.comphenix.protocol.reflect.FieldAccessException: No field with type net.minecraft.network.chat.IChatBaseComponent exists in class PacketPlayOutBoss.

torn shuttle
#

Is there a getDefaultWorld somewhere hidden in the api?

eternal oxide
#
Properties server = new Properties();
try {
    server.load(new FileInputStream("server.properties")); //$NON-NLS-1$
    serverDefaultWorldName = server.getProperty("level-name").toLowerCase(); //$NON-NLS-1$
} catch (IOException ex) {
    GroupManager.logger.log(Level.SEVERE, "Failed to load server.properties", ex);
}```
hardy swan
quaint mantle
#

How to create Craft Recipe?

drowsy helm
#

my remap isnt working for some reason

bright jasper
#

Need to set it to use that font

#

Can only be done using json messages

#

Aka textcomponents

#

Spigot/Bukkit can't do it by default but the client will accept it so

eternal oxide
drowsy helm
#

oop thanks

bright jasper
#

oh btw forgot to post code with it

#
class ProtocolTagChanger(plugin: Plugin?, listenerPriority: ListenerPriority?, packetType: PacketType?) :
    PacketAdapter(plugin, listenerPriority, packetType) {
    override fun onPacketSending(event: PacketEvent) {
        val packet = event.packet
        if (packet.type === PacketType.Play.Server.BOSS) {
            var baseWrap = packet.chatComponents.read(0)
            if (baseWrap != null && !Strings.isNullOrEmpty(baseWrap.json)) {
                val firstPass =
                    ChatColor.stripColor(TextComponent.toLegacyText(*ComponentSerializer.parse(baseWrap.json)))
                baseWrap = ComponentConverter.fromBaseComponent(*ComponentSerializer.parse(firstPass))
                packet.chatComponents.write(0, baseWrap)
            }
        }
    }
}
        val bar = Bukkit.createBossBar("", BarColor.YELLOW, BarStyle.SOLID)

        val x = TextComponent("\uE233\uE234\uE234\uE234\uE234\uE234\uE234\uE234\uE234\uE234\uE234\uE234\uE234\uE234")
        x.font = "yume:bossbar"
        bar.setTitle(ComponentSerializer.toString(x))
        bar.addPlayer(event.player)

(sorry that its in kotlin)

cunning canopy
#

I am making my own file format for saving builds. I want it to be efficient so I figured using numbers instead of strings would save me some bytes. Does blocks have texture ids or something? I want to like get the material I'd of a block. Would I have to make my own hashmap?

eternal oxide
#

id's are no longer used

#

bad design

hasty obsidian
#

Check for entities health

cunning canopy
eternal oxide
#

hard coded indexes

#

inflexible

cunning canopy
#

Then how should I proceed?

hushed spindle
#

my custom damage system occasionally has the issue where mobs get into like an invincible state, i saw the same issue has occurred with plugins like mcmmo and advancedenchantments but it wasn't clear on what causes mobs to get into this state. does anyone know?

wispy monolith
#

I want to edit the login protocol
how? and can i use ProtocolLib for that?

tender shard
tender shard
tender shard
drowsy helm
#

nah managed to fix it

#

had to redownload bt for some reason

severe turret
#

by would you use j8

#

🥲

torn shuttle
eternal oxide
#

Generally yes

#

But no guarantee

torn shuttle
#

hm

#

thanks

eternal oxide
#

Which is why its a good idea to read the properties to be sure

tender shard
tender shard
#

The default world cannot be unloaded

#

And it always gets loaded first

eternal oxide
#

Not always. If a plugin loads world early World will not be 0

tender shard
#

Are you sure? Ive never seen this happen

eternal oxide
#

I've never seen it happen, but it's possible

tender shard
#

Hm well ok

eternal oxide
#

When I get time later I'll test it to be sure

#

I just remember md5 saying its not guaranted

azure hawk
#
package buildserver.main.listeners;

import buildserver.main.Buildserver;
import org.bukkit.*;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;

import java.util.ArrayList;

public class interactListener  implements Listener {
    private final Buildserver plugin;
    public interactListener(Buildserver main) {
        this.plugin = main;
    }

    ArrayList<String> hidden = new ArrayList<>();
    String prefix = Buildserver.getPlugin(Buildserver.class).getConfig().getString("Config.prefix");

    @EventHandler
    public void onPlayerInteract(PlayerInteractEvent event) {
        Player player = event.getPlayer();
        Location playerLoc = player.getLocation();
        if(event.getAction() == Action.RIGHT_CLICK_AIR | event.getAction() == Action.RIGHT_CLICK_BLOCK) {
            if(event.getMaterial().equals(Material.GHAST_TEAR)) {
                for(Player players : Bukkit.getOnlinePlayers()) {
                    if(hidden.contains(player.getName())) {
                        hidden.remove(player.getName());
                        player.showPlayer(players);
                        player.playSound(playerLoc, Sound.CLICK, 1 ,1);
                        player.sendMessage(prefix + "Alle spieler sind nun §asichtbar§7 für dich!");

                    }else if(!hidden.contains(player.getName())) {
                            hidden.add(player.getName());
                            player.hidePlayer(players);
                            player.playSound(playerLoc, Sound.CLICK, 1 ,1);
                            player.sendMessage(prefix + "Alle spieler sind nun §cunsichtbar§7 für dich!");
                        }
                    }

                }
            } else if(event.getMaterial().equals(Material.ARROW)) {```
#

                player.playSound(playerLoc, Sound.CLICK, 1 ,1);
                player.teleport(player.getEyeLocation().add(0,0.1,0));
            }
        }
    }

Why is this not working?` There are no error in the console

noble lantern
noble lantern
azure hawk
#

i will try debugging rn

#

thats the result

tender shard
noble lantern
azure hawk
#

no

#

i clicked on Debug "MyCode"

tender shard
#

thats not how it works