#help-development

1 messages · Page 1723 of 1

tender shard
#

this

acoustic pendant
#

hmm

#

isn't it the same?

arctic moth
#

is there an event or smth for when an entity gets a certain distance from another entity

acoustic pendant
#

?javadocs

arctic moth
#

lol

acoustic pendant
#

well, search it in javadocs

tender shard
acoustic pendant
#

?jd

tender shard
acoustic pendant
#

stand.armorStand.getEquipment().setHelmet(itemStack);

#

somthing like that?

tender shard
#

if your armorstand is called willy, just do willy.getEquipment().setHelmet(willysHelmet)

eternal oxide
#

no need to get equipment

tender shard
#

^^

tender shard
acoustic pendant
#

but, i want to set the armor by a menu

#

well

eternal oxide
#

ah sorry, yes deprecated

acoustic pendant
#

it doesn't make much sense

#

but still

#

idk

tender shard
tender shard
#

armor stands aren't the only things that can have equipment

#

so instead of adding all those methods to every single entity, they made an interface for it that can be reused

acoustic pendant
#

i mean, giving armor to a armor stand by a menu

#

but

tender shard
acoustic pendant
#

but, stand. is the hashmap

tender shard
#

no, stand is not a hashmap, otherwise it wouldn't have the getEquipment method

#

second, please just read the docs

acoustic pendant
#

well

#

i did a hashmap with "stand" name

#

oh

#

nvm

tender shard
#

your "stand" thing is an ArmorStand

acoustic pendant
#

ArmorStand stand = plugin.armorstands.get(p);

tender shard
#

and the setHelmet method requires an ItemStack

#

as parameter

acoustic pendant
#

ArmorStand is the hashmap defined in the main class

tender shard
#

no, "armorstands" is the hashmap

#

and you cannot set the helmet to be a material

acoustic pendant
#

yes

tender shard
#

you have to set it to an itemstack

#

like you did here

arctic moth
#

how do u set nbt

tender shard
arctic moth
#

ik it sounds dumb but my search results are outdated

tender shard
#

an entity?

#

an itemstack?

arctic moth
#

ye

#

entity

#

im trying to set SkeletonTrap:1b on skele horse

tender shard
#

do you have to access the vanilla NBT tags, or do you simply want to store your own data inside the entity?

acoustic pendant
#

stand.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET));

#

like this?

tender shard
#

Is SkeletonTrap a vanilla NBT value?

acoustic pendant
#

but

tender shard
#

NBT is only possible using NMS and you do not need it

#

you can instead use the PersistentDataContainer

arctic moth
#

lol

acoustic pendant
#

so i don't know how to follow this code

tender shard
tender shard
# acoustic pendant

you literally only have to add "getEquipment" between stand and setHelmet everytime...

tender shard
acoustic pendant
#
        } else if (e.getCurrentItem().getType().equals(Material.DIAMOND_HELMET)) {
            if (plugin.armorstands.containsKey(p)) {
                ArmorStand stand = plugin.armorstands.get(p);
                stand.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET));
                p.sendMessage();
                if (stand.getEquipment().getHelmet().getType() == Material.DIAMOND_HELMET) {
                    stand.getEquipment().setHelmet(null);
                    p.sendMessage("Remove.");
#

like that?

tender shard
# arctic moth thx

the syntax is a bit ugly at first, but this one will work in all versions from 1.14.1 onwards without needing dirty NMS stuff. and you can store ANYTHING inside it

tender shard
acoustic pendant
#

ok

#

ty

tender shard
#

np. you should always avoid deprecated methods because that means they might be removed soon

acoustic pendant
#

oh

#

i see

tender shard
# arctic moth thx

"this" of course is an instance of your plugin^^

and to retrieve the value later:

byte value = myEntity.getPersistentDataContainer().get(new NamespacedKey(this,"skeleontrapped"),PersistentDataType.BYTE);
arctic moth
#

lol thx

#

um im getting like error spams so fast i cant read it

eternal oxide
#

logs

tender shard
#

Sgol

arctic moth
#

its over the limit

#

for mb

tender shard
#

`paste

arctic moth
#

its 246 mb

eternal oxide
#

cut out the relevant sections

#

?paste

undone axleBOT
tender shard
#

yeah ok 250mb is a bit much for paste

arctic moth
#

lol

tender shard
#

just send part of it

arctic moth
#

i cant even copy part of it cuz my text editor is crashing

eternal oxide
#

then delete teh log and get a fresh one

arctic moth
#

k

vital yacht
#

It’s probably the same error repeatedly

arctic moth
#

ik

tender shard
#

if you're on linux just do tail -n10000 latest.log > error.log

arctic moth
#

lol i started it and then stopped it after 1 second

#

still 1 mb

tender shard
#

what's Listeners line 96?

young knoll
#

Are you spawning an entity in the creature spawn event

arctic moth
#

ye

#

is that bad

#

lol

young knoll
#

You’ve made a loop

tender shard
#

erm

eternal oxide
#

me.tristandasavage.trollmc.Listeners.creatureSpawn(

tender shard
#

Bukkit calls event -> You spawn entity -> Bukkit calls event again -> You spawn entity -> ...

young knoll
#

Switch a Boolean before you spawn the entity, and ignore the event when that Boolean is set

eternal oxide
#

you are spawning a mob in teh spawn event

arctic moth
#

im trying to replace 10% of skeletons with skeleton horses

vital yacht
#

What’s your code?

tender shard
#

that's like saying "every time I drink a shot of vodka, I immediately drink another shot of vodka" and boom you're dead

young knoll
#

Switch a Boolean before you spawn the entity, and ignore the event when that Boolean is set

arctic moth
tender shard
#

 private boolean ignoreNextEvent = false;

@EventHandler
    public void onSpawn(CreatureSpawnEvent event) {
        if(ignoreNextEvent) {
            ignoreNextEvent = false;
            return;
        }
        ignoreNextEvent = true;
        // Spawn your entity
    }
arctic moth
#

thx

vital yacht
#

That’s not the best way to do that

arctic moth
#

k

#

lol

tender shard
#

it's the easiest, you got a better idea?

arctic moth
#

what is

young knoll
#

Set it to true before the spawn

arctic moth
#

the better way

young knoll
#

Set it to false right after

vital yacht
#

Store entity UUIDS in a set

tender shard
#

right

tender shard
vital yacht
#

Check if the uuid is in the set, if so, ignore the event and remove the uuid

young knoll
#

You can use a set, but there is no need

tender shard
acoustic pendant
tender shard
vital yacht
#

It guarantees it’s the same entity

young knoll
#

It already is guaranteed

tender shard
#

it MUST be the same entity

#

it's running sync

arctic moth
acoustic pendant
tender shard
acoustic pendant
#

wdym?

tender shard
#

in every if statement, do System.out.println("1");

#

then 2, 3 etc

#

then you can see where your code stops

acoustic pendant
#

ok

#

let me see

acoustic pendant
tender shard
#

inside every if statement, do "System.out.println(1)", then in the next if, use a 2 instead 1, and so on

acoustic pendant
#

do you mean in mc console?

tender shard
#

?

acoustic pendant
#

i mean i have the sout

#

in all statement

#

but where is the debug mode option?

young knoll
#

It should show in console

acoustic pendant
#

ok ig

tender shard
#

like this:

@EventHandler
    public void onSpawn(CreatureSpawnEvent event) {
        System.out.println(1);
        if(event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.BEEHIVE) {
            System.out.println(2);
            // Do something when beehives spawn a creature
        } else if(event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.BREEDING) {
            System.out.println(3);
            // Do something when two entities fucked
        }
    }
vital yacht
tender shard
vital yacht
#

So a set would be better right?

tender shard
#

yes

young knoll
#

No

#

A Boolean is fine

tender shard
#

no, @young knoll imagine this:

#

oh wait now that I think about it

#

I will just try it before thinking too much lmao

vital yacht
#

Lol I can try to come up with it

young knoll
#

I’ve done it before

acoustic pendant
#
ok, when i enter the } else if (e.getCurrentItem().getType().equals()){

//asd
}
young knoll
#

For both entity spawns and block breaks

vital yacht
#

Listener spawns an entity. More than one listener for EntitySpawn is registered.
Another listener gets handled first, it spawns an entity.
The latest entity spawned is now not the original entity, but an entity spawned by a different registered listener.

acoustic pendant
#

where sout("a");

tender shard
#

you should give your variables better names

acoustic pendant
#

Player p = (Player) e.getWhoClicked();

tender shard
#

obviously your list of armorstands doesn't include any player ever

vital yacht
#

I might be wrong

tender shard
#

oh sorry

#

it's a HashMap<Player,ArmorStand> right?

acoustic pendant
#

yes

young knoll
#

if bool return;

bool = true;
SpawnEntity
bool = false;

arctic moth
#

lol

vital yacht
#

What?

#

That doesn't explain anything

young knoll
#

That’s all you need until minecraft starts spawning stuff async

eternal oxide
# acoustic pendant yes

Don;t store players as a key. the Player object can go stale. Store against the players UUID

vital yacht
#

How do you know your listener is first?

tender shard
eternal oxide
tender shard
vital yacht
eternal oxide
#

Player#getUniqueId()

young knoll
#

Doesn’t matter, all other listeners will run in between the true and false

eternal oxide
vital yacht
#

There is more than one plugin on a server

young knoll
#

Other plugin listeners don’t matter

vital yacht
#

How come?

acoustic pendant
young knoll
#

Everything is still sync

tender shard
arctic moth
#

for some reason every time i spawn a skeleton it will mostly spawn a skeleton horse and rarly spawn a skeleton, but that skeleton wont have the stuff i gave it

acoustic pendant
#

ok

#

so i change

vital yacht
#

But spawning an entity inside an event doesn’t guarantee the same listener is listened to first does it?

acoustic pendant
tender shard
arctic moth
young knoll
#

Listeners always run in the same order

eternal oxide
acoustic pendant
#

but the code, is still not working

eternal oxide
#

The boolean is a field so accessible by everything in that class

vital yacht
#

That’s not the argument

tender shard
#

imagine this code:

    private boolean dontSpawnHorse = false;
    private boolean dontSpawnPig = false;

    @EventHandler
    public void spawnPig(CreatureSpawnEvent event) {
        if(dontSpawnPig) {
            return;
        }
        dontSpawnPig = true;
        event.getLocation().getWorld().spawnEntity(event.getLocation(), EntityType.PIG);
        dontSpawnPig = false;
    }

    @EventHandler
    public void spawnHorse(CreatureSpawnEvent event) {
        if(dontSpawnHorse) {
            return;
        }
        dontSpawnHorse = true;
        event.getLocation().getWorld().spawnEntity(event.getLocation(), EntityType.HORSE);
        dontSpawnHorse = false;
    }

(Obviously that's supposed to be two different plugins)

arctic moth
#

thx

#

o

tender shard
#

sooo

#

that's NOT the way to go

#

instead, do as suggested and simply store a Map<Entity>

vital yacht
#

Set you mean?

#

And UUID not the entity

arctic moth
#

like

tender shard
#

I mean Set, nopt Map

arctic moth
#

all the entities?

tender shard
#

wait, the set also doesn't work

#

because to store the entity, it has to be spawned first, which already calls the event

vital yacht
#

When you spawn an entity add its uuid to a set, if the set contains the spawned entity when you listen to the event, remove the uuid and don’t spawn another.

tender shard
young knoll
#

You can use a callback in the spawn method to do stuff before it’s spawned

vital yacht
#

Yeah

tender shard
vital yacht
#

It will

young knoll
#

The entity hasn’t been spawned yet

#

So no events have been called

tender shard
acoustic pendant
vital yacht
#

The entity will be spawned in the same listener

#

But you can get the UUID beforehand

acoustic pendant
tender shard
#

yep just tested the Set<Entity> thing and it's working fine, thanks I learned sth new

    private Set<Entity> ignoredMobs = new HashSet();

    @EventHandler
    public void spawnPig(CreatureSpawnEvent event) {
        if(ignoredMobs.contains(event.getEntity())) {
            ignoredMobs.remove(event.getEntity());
            return;
        }

        event.getLocation().getWorld().spawn(event.getLocation(), Pig.class, (entity) -> ignoredMobs.add(entity));
    }
tender shard
acoustic pendant
vital yacht
#

I also feel like it’s cleaner

tender shard
#

it would be very helpful if you could tell use what's supposed to happen

tender shard
acoustic pendant
#

and it's supposed to only spawn when i click the armor stand

tender shard
acoustic pendant
#

i have the hashmap in Player and now it doesn't happen that

acoustic pendant
tender shard
#

no

#

the listener

acoustic pendant
#

i have 4 classes

tender shard
#

the class that handles the GUI clicks

acoustic pendant
tender shard
#

I'll explain it

#

Line 27: You assign the player who clicked to "p" (btw name it "player" instead)

acoustic pendant
#

but "player" is longer so i prefer just "p"

tender shard
#

Line 29: You check if your HashMap<UUID,ArmorStand> contains the object "p" which is a player

tender shard
young knoll
#

Single letter variables are bad practice

#

Variables should be descriptive

tender shard
tender shard
#

bu now, especially in long methods like yours, "e" could also be an entity, etc

acoustic pendant
#

i see

tender shard
#

and tbh you only have to write "player" once, after that just enter pl, hit enter and IntelliJ turns it into "player"

#

it also helps other people read your code

#

btw "p" could also be "plugin"

#

^^

acoustic pendant
#

yea yea

#

i got it

tender shard
#

soo since you changed your HashMap from Player to UUID

#

you now have to change it everywhere else, too of course

acoustic pendant
#

well, exept of line 29 all the rest i know

tender shard
#

ok

acoustic pendant
#

if (!plugin.armorstands.containsKey(p.getUniqueID())){

Maybe?

tender shard
#

yep

#

btw if you select your "p" variable and hit Shift+F6, you can rename it to "player" and IntelliJ renames it automatically everywhere in your code

acoustic pendant
#

ooh

#

ty

tender shard
#

np^^

acoustic pendant
#

well, but the thing for what i was here, was something different xD

tender shard
#

what was it again? ^^

acoustic pendant
#

that i have a code

#

that doesn't work at all

tender shard
#

upload it to the paste site too pls

acoustic pendant
#

sure

vital yacht
#

That’s a lot of arrow code

#

Also materials can be compared with == because they are constants

tender shard
#

yeah was just going to mention this 😄

acoustic pendant
#

yea

#

xd

#

that makes any problem with the code?

vital yacht
#

Lol

tender shard
#

it's a bad habit and leads to complicated, ugly code

#

use this to debug it

#

run it and when it doesn't work, send the console output

#

I simply added a single debug line inside every if and else block

unreal quartz
tender shard
#

that's the easiest way to see what exactly your code did

acoustic pendant
#

but i tried before

#

and that wasn't executed

tender shard
#

also what I want to mention about your code:

acoustic pendant
#

well i tried with the code

tender shard
#

You basically do this:

1. Do one thing for the helmet stuff
2. Do the exact same thing for the chestplate stuff
3. Do it again...
4. Do it again...

You could remove 75% of the code when you would turn it into a function

acoustic pendant
#

and it doesn't execute nothing

tender shard
#

It will DEFINITELY have printed something in the console

acoustic pendant
#

it doesn't

tender shard
#

then you didnt register this listener

acoustic pendant
#

i did

#

getServer().getPluginManager().registerEvents(new MenuHandler4(this), this);

tender shard
#

then you didnt click in any inventory

vital yacht
#

What I like to do is loop up to 100 and print a line for each number so I can’t miss it lol

tender shard
#

there's another option

#

none of your if conditions are true

young knoll
#

You can always try broadcastMessage instead

tender shard
#

tbh I'd rewrite the whole class from scratch

acoustic pendant
#

it cancels moving items event

tender shard
#

that's literally sooo many nested if/elses

acoustic pendant
#

the only thing that works

tender shard
#

if it did cancel it

#

it would have printed 1

#

it's the line directly above where you cancel it

acoustic pendant
#

well

tender shard
#

if the event gets cancelled, it WILL have printed "1" to console

acoustic pendant
#

it doesn't

tender shard
#

then it didnt cancel the event

young knoll
#

Hence why I suggest trying bukkit.broadcastMessage

acoustic pendant
#

it does

tender shard
#

okay then your computer must have magically ignored all the debug statements I inserted and decided to only compile the lines you already had in there

#

however that's a bit unlikely

acoustic pendant
#

do you want a video maybe?

tender shard
#

maybe just upload your whole thing on github

acoustic pendant
#

it just send errors when i click in empty slots and it shouldn't because
if (e.getCurrentItem() == null) {
return;

tender shard
acoustic pendant
#

hmm

#

don't think so

tender shard
acoustic pendant
#

it compiles into the plugins folder

tender shard
#

it would be helpful to stick to one problem at one time

acoustic pendant
#

well

tender shard
#

ugh are you having two listeners that both listen to inventoryclickevent?

acoustic pendant
#

i have that code in the other 3 events

#

and works

tender shard
#

it would also be helpful if you would show the errors you get

acoustic pendant
#

    public MenuHandler4(ArmorStandGUI plugin) {
        this.plugin = plugin;
    }

    @EventHandler
    public void click(InventoryClickEvent e) {
        Player player = (Player) e.getWhoClicked();
        if (e.getView().getTitle().equals(ChatColor.BLUE + "Choose some armor.")) {
            e.setCancelled(true);
        }
        if (e.getClickedInventory().contains(Material.//someitem)) {
            if (e.getCurrentItem() == null) {
                return;
            }
tender shard
acoustic pendant
golden turret
#

?paste

undone axleBOT
acoustic pendant
tender shard
#

but you cannot tell me that all your event listener classes are called MenuHandler4

golden turret
tender shard
#

uuugh

#

math

#

I'm out 😄

golden turret
#

:C

tender shard
#

I literally only studied law because I knew it would not involve ANY math

#

maybe that question would better fit in the forum

#

sometimes there's some math experts around

golden turret
#

maybe

#

but i fixed the base code here

acoustic pendant
tender shard
unreal quartz
golden turret
#

ok

unreal quartz
#

your issue comes from getLocationInCircle(radPerTick * tick + separator * i);, since every time you change radPerTick the items will move to the position where it would have been had the circle started with that rotation speed

tender shard
#

when you forget to uninstall the test plugin...

quaint mantle
#

lol

vital yacht
muted sand
#

How do I kick a player?
it wants a Component, no clue how to make it

quaint mantle
young knoll
#

I imagine they are

vital yacht
#

Who knows, could be using a random method

young knoll
#

What random method uses a component

vital yacht
#

Doesn’t bungeecord have components?

#

Or only ChatComponent?

young knoll
#

The chat component API is components

tender shard
vital yacht
#

Me neither

#

Oh well

#

We had that whole discussion for nothing lol

tender shard
#

it wasn't for nothing

#

I learnt that the consumer in spawnEntity is called before any events get triggered

#

I didn't know that before

vital yacht
#

Well that’s good at least then

tender shard
#

yes 😄

vital yacht
#

I can't imagine spawning and interacting with entities in the old versions of spigot without that method

tender shard
#

All those nested ifs... ugh

vital yacht
#

Who doesn't love a good couple hundred nested if statements?

tender shard
#

yeah if a class doesn't end with }}}}}}}}}}}}}}}}}} where's the fun?

vital yacht
#

Yeah

#

All those brackets make it look so clean

tender shard
#

the code looked worse than a bash script lol

young knoll
#

Honestly I don’t use the consumer much

tender shard
#

I never used it in the spawnEntity method but all the time in streams or other stuff

vital yacht
#

I've used it a decent amount

tender shard
#

however I also never spawn any entities ^^

vital yacht
#

(In the spawn entity method)

tender shard
#

besides armorstands or area effect clouds for holograms

young knoll
#

Generally you do those client side

tender shard
#

never had any problems with server side holograms. it's not like I'm spawning 300 of them in one chunk

muted sand
vital yacht
tender shard
#

it's an ADDITIONAL method to kick a player with a message

#

paper also works fine with the normal kickPlayer(String) method

muted sand
muted sand
tender shard
#

I wouldn't use the kick(Component) method. It has like no advantage over the normal thing and it makes the plugin not be working with spigot anymore

young knoll
#

It lets you use gradients and such

muted sand
#

well theres two options

young knoll
#

Well, easily

tender shard
#

I just use my lib for gradients^^

muted sand
#

theres kickPlayer, but that's deprecated

muted sand
vital yacht
lavish hemlock
#

Adventure is cool

#

Pretty sure Paper's text component API uses/is Adventure

young knoll
#

It is

lavish hemlock
#

I haven't heard of MiniMessage before tho

#

I should probably be more invested in the Spigot ecosystem lmao

vital yacht
#

MiniMessage is for Adventure

#

Spigot doesn't even use Adventure

lavish hemlock
tender shard
lavish hemlock
#

Bukkit does

vital yacht
lavish hemlock
#

gn

vital yacht
young knoll
#

No

lavish hemlock
#

it's just that with the context I presented with "Spigot ecosystem" and you responding "Spigot doesn't even use Adventure" I assumed we were referring to Adventure's available platforms

#

but ye Adventure uses Bukkit as a platform as opposed to Spigot

#

(mainly bc more compatibility and also Spigot is essentially just Bukkit but with additional patches and minor API changes)

muted sand
#

How do I drop uh, items from a chest?

#

i am setting a block break even to cancel, and then dropping the chest contents by hand, but idk how to get the contents of the chest

young knoll
#

Get the block state and cast it to container

muted sand
#

ah thank you

#

this would drop it?

                    Container container = (Container) state;
                    container.getInventory().clear();
#

state is the getBlock#getState()

#

nvm

young knoll
#

That will just empty it

muted sand
#

oh

#

i tried this

#
BlockState state = event.getBlock().getState();
Container container = (Container) state;
container.getInventory().clear();
ItemStack[] items = container.getInventory().getStorageContents();

event.getBlock().breakNaturally();
event.getBlock().setType(Material.AIR);
for (ItemStack i :items) {
    if (i == null) {
        continue;
    }
    event.getBlock().getWorld().dropItem(event.getBlock().getLocation(), i);
}

it no work

#

it'll drop my chest, but nothing else

#

oh wait i am clearing the fucking thing

raw coral
#

Anyone know why its not transfering the player to the hub?

#

@EventHandler
fun playerJoin(event: PostLoginEvent){
val player = event.player
val hub = main.serverHandler.getHub()
player.connect(hub)
}

#

the ServerInfo is valid

final fog
#
public void drawLine(Location from, Location to, Particle particle) {
        double between = from.distance(to);
        for (int i = 0; i < between; i++) {
            Location particleLocation = from.getDirection().toLocation(from.getWorld());
            System.out.println(particleLocation);
            particleLocation.getWorld().spawnParticle(particle, 1, 1, 1, 10);
        }
    }``` I am getting an error on the last line. could someone assist me with this?
young knoll
#

You have the params wrong

final fog
#

It's right

#

just accidentally cut it out

young knoll
#

It’s not

#

Hence the error

final fog
#

this? }?

#

oh that

#

nvm

#

whats wrong with it

young knoll
#

Depends what your goal is

final fog
#

it's actually particleLocation.getWorld().spawnParticle(particle, 1, 1, 1, 10, 10);

young knoll
#

There are like 10 overloads of that method

final fog
#

I just want a single particle in one area

#

kind of like a dot

final fog
#

Which one

#

this one? <T> void spawnParticle​(@NotNull Particle particle, double x, double y, double z, int count, @Nullable T data)?

young knoll
#

The one I just linked

final fog
#

There's 5 of them

young knoll
#

I linked directly to one

final fog
#

I see 5

#

ig that one then

young knoll
#

You can even see the arguments in the URL

#

Particle, location, count

final fog
#

I cant see the particles

#
    public void drawLine(Location from, Location to) {
        double between = from.distance(to);
        for (int i = 0; i < between; i++) {
            Location particleLocation = from.getDirection().toLocation(from.getWorld());
            particleLocation.getWorld().spawnParticle(Particle.SMOKE_NORMAL, 1.0, 1.0, 1.0, 10);
        }
    }
}``` no errors this time, so that's better
#

might be another part of my code ill check that out first

young knoll
#

Because you are spawning them at 1 1 1

#

Which is in bedrock at the centre of the world

final fog
#

ok im slow

#

nvm

#

for some reason I thought that was the area around the location

young knoll
raw coral
#

So right now I have this code:

class SandboxReconnectHandler(val main:SandboxServerManager) : ReconnectHandler {
    init {
        ProxyServer.getInstance().reconnectHandler = this
    }
    override fun getServer(player: ProxiedPlayer): ServerInfo? {
        val server = main.serverHandler.getHub()!!
        println("Player ${player.displayName} is being sent to hub: ${server.name}")
        return main.serverHandler.getHub()
    }

    override fun setServer(p0: ProxiedPlayer?) {
    }

    override fun save() {
    }

    override fun close() {
    }
}

And this is the console output:

[03:58:37 INFO]: Player PrinceOfToxicity is being sent to hub: sandbox_hub_1
[03:58:37 INFO]: [PrinceOfToxicity|/REDACTED] <-> ServerConnector [sandbox_hub_2] has connected
[03:58:37 INFO]: [PrinceOfToxicity|/REDACTED] <-> ServerConnector [sandbox_hub_2] has disconnected

But I'm just getting a ReadTimeoutException:

solid cargo
#

is there an event that checks what are you wearing

#

like, if an entity is wearing that and that, do that and that

tender shard
#

events are called when something happens / changes etc

tacit drift
#

🤪 🤪

#

nvm, doesn't work for everything still 😅

tender shard
torn shuttle
#

I am very tempted to create a bot to automatically pull posts from discord to post on trello as issues just so I can keep track of reported issues

#

I'm starting to spend a silly amount of time just scrolling back and forth trying to remember what got reported to me

tender shard
torn shuttle
#

🤷

#

hm it doesn't look like it would be too hard to make such a bot

#

I've never really made something quite like this

tender shard
torn shuttle
#

that's what I try to do but it's hell to do when I'm on mobile

dull whale
#

is it posibble to make a custom gui using a server resource pack without overriding any other gui

tender shard
#

One sec

#

you mean something like thsi?

dull whale
#

yes

tender shard
#

that's simply using CustomModelData

#

every material can have up to about 4 billion different textures

dull whale
#

i saw some tutorial for custom items but

tender shard
#

so for example above they simply have a glass pane in every slot with different custom model data

#

or, idk if that's possible, it could even be one large item that has the whole GUI as texture and overlays all the other slots

dull whale
#

it is ok for me

#

how can I do that?

tender shard
#

you need some photoshop skills and patience^^ then create an item that has a texture that looks like your GUI

#

then in your resource pack you can override for example a glass pane's texture when it's custommodeldata is a specific number

#

then simply add a glasspane with that custom model data to your inventory

dull whale
#

I mean idk how to convert ```json
{
"parent": "item/generated",
"textures": {
"layer0": "item/iron_ingot"
},

"overrides": [
{"predicate": {"custom_model_data":1234567}, "model": "item/gold_ingot"}
]
}```
for items to something handles guis

tender shard
dull whale
#

ive been searching for something like this for a day thanks a lot

tender shard
#

tbh I havent watched the video, I don't know whether he also explains on how to do it exactly or only explains the general idea

solid cargo
#

what can i blame this on?

tender shard
#

com.codingforcookies.armorequip.ArmorListener.playerInteractEvent(ArmorListener.java:128)

#

is this your plugin?

solid cargo
#

ah no

#

its an event i found in internet

#

ig its faulty :(

tender shard
#

but the HelmetEvent is your listener, right?

#

if yes, please show your HelmetEvent class

#

especially line 15

solid cargo
#

while (e.getNewArmorPiece().equals(CustomItems.minerHelmet))

tender shard
#

show the full code please

solid cargo
#

ok

tender shard
#

it seems like the while loop is running endlessly

solid cargo
#
public class HelmetEvent implements Listener {
    @EventHandler
    public static void onWear(ArmorEquipEvent e) {
        while (e.getNewArmorPiece().equals(CustomItems.minerHelmet)) {
e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 100, 0));

        } while (!(e.getNewArmorPiece().equals(CustomItems.minerHelmet))) {

        }
    }
}
tender shard
#

okay so

#

e.getNewArmorPiece() will never change

#

CustomItems.minerHelmet will never change

#

so once that while loop starts, it will forever add PotionEffects and never end

solid cargo
#

and gets overwhelmed?

tender shard
#

so the server just keeps executing "e.getPlayer().addPotionEffect"

tender shard
#

your event is not called async, meaning the server only continues to do its normal job when it's done executing your event listener

#

what are you actually trying to do?

solid cargo
#

so.

tender shard
#

to me it seems like: you want players who wear your custom helmet have FAST_DIGGING effect, and remove it again when they don't wear it anymore, right?

solid cargo
#

while the player is wearing my custom item

#

i want them to have fast digging

tender shard
#

Yes, but you cannot simply run a while-loop forever in any event

tender shard
#

here's the correct approach:

#
  1. Loop through all online players
  2. Check if they have your helmet
  3. If yes: Give the potion effect for 2 seconds
  4. Repeat all of this every second
solid cargo
#

alright thanks

tender shard
#

np

#

so you basically do not need any events for this

#

oh by the way you have another problem:

#

you are checking whether the player's helmet equals your custom item

#

but

#

the helmet will probably get damage from time to time

#

once it got its first damage, the helmet will not equals() your original helmet anymore

#

(unless you made it unbreakable or something)

solid cargo
#

then ==

#

?

tender shard
#

no, that's even worse

#

There's a ton of different ways to solve this

solid cargo
#

might as well just set it to unbreakable

tender shard
#

Can you show the method where you create the custom item?

tender shard
solid cargo
#

ok

#

public class CustomItems {

public static ItemStack minerHelmet;
   
 public static void init(){
createMinerHelmet();
    }

    public static void createMinerHelmet(){


        {
            ItemStack item = new ItemStack(Material.IRON_HELMET);
            ItemMeta meta = item.getItemMeta();
            meta.setDisplayName("§6Miner helmet");
            List<String> minerHelmetLore = new ArrayList<>();
            minerHelmetLore.add("§7Wear this helmet");
            minerHelmetLore.add("§7to gain §e:pick: Haste 1!");
            minerHelmetLore.add("");
            minerHelmetLore.add("§6§lLEGENDARY");
            meta.setLore(minerHelmetLore);
            item.setItemMeta(meta);
            minerHelmet = item;
        }
    }
}
tender shard
#

alrighty. Sooo

#

First of all I'd create another method called "isMinerHelmet" that takes an ItemStack

#

that returns a boolean

#

inside that you have different possibilities:

#

Most stupid solution: Check whether the item contains the lore "§6Miner helmet"

solid cargo
#

how smart could players be to give it to an anvil

tender shard
#

Smartest solution: Use PersistentDataContainer (that's "modern NBT tags") to add a simple tag to your object that you can use to check if this is your helmet

tender shard
#

then, in your checking method, just check whether the item has that tag

#

if yes, it's your custom helmet

#

@solid cargo Did you ever use PersistentDataContainer?

solid cargo
#

i have never used that

tender shard
#

okay this is the perfect opportunity to learn it then

solid cargo
#

yay

tender shard
#

it's actually totally easy

#

wait a minute pls, I'm currently finishing a small tutorial on how to use it anyway

solid cargo
#

im having english courses rn

#

expect me not to reply instantly

solid cargo
#

thanks

tender shard
# solid cargo thanks

For example, this could be your main class:

public class Test extends JavaPlugin implements Listener {

    private ItemStack minerHelmetItem;

    @Override
    public void onEnable() {
        minerHelmetItem = createMinerHelmet();
    }

    private ItemStack createMinerHelmet() {
        ItemStack item = new ItemStack(Material.NETHERITE_HELMET);
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName("My awesome Miner Helmet");
        
        // Now we apply the custom PDC tag
        meta.getPersistentDataContainer().set(new NamespacedKey(this,"minerhelmet"), PersistentDataType.BYTE, (byte) 1);
        
        item.setItemMeta(meta);
        return item;
    }
    
    public boolean isMinerHelmet(ItemStack itemToCheck) {
        if(!itemToCheck.hasItemMeta()) return false;
        return itemToCheck.getItemMeta().getPersistentDataContainer().has(new NamespacedKey(this, "minerhelmet"), PersistentDataType.BYTE);
    }
    
}
eternal night
#

?pdc

eternal night
#

Also exists but might be outdated

#

Well, it doesn't include chunks

tender shard
#

yeah the linked guide is definitely awesome, but I actually wrote the post more to show why it's better than NBT and also I think the shown tutorial looks a bit complicated at first place, and also starts with focussing on the differences between the CustomItemTagContainer and the new PDC, so I felt like writing my own at some point 😄

solid cargo
#

so just put that thing in my main?

#

move all to main?

tender shard
#

understand what it does and recreate that

eternal night
tender shard
#

oh I just see that it's your post 😄

#

Thanks very much for writing it, I think that's how I learned how the custom data types work

eternal night
#

Ah no problem XD flattered by "biggest improvement that (in my opinion) ever made it into the Bukkit API"

tender shard
#

yeah it made my life so much easier

#

I never used NBT tags because of NMS

#

so

#

I was finally able to store custom data inside items and entities

#

I mean I COULD HAVE used NMS, but I really hate the idea of having to update everything on every update

eternal night
#

Glad to help 😂 sad I never got around to implementing lists of persistent data types

tender shard
#

I was so annoyed that by default it doesn't support booleans, so I made the more persistent data types library lol

#

but the forum doesn't like it 😄 33% voted that it's useless lol

eternal night
#

I mean 33% is not too many XD and well for just booleans idk if a library is too useful 😅

tender shard
#

it's not just booleans

#

it's for everything that's serializable

#

and also allows to create own datatypes without creating a huge new class but just providing two functions 😄

eternal night
#

Oh so just converting everything into bytes using the Bukkit serialisation ?

#

Storing offline players in PDC

#

Perfect XD

tender shard
#

yeah I just thought I'd add everything because someone MIGHT have a use lol

#

like protection plugins

#

simply storing the OfflinePlayer in a block that that player placed

#

idk

#

😄

#

I mainly made it for ItemStacks and because I was annoyed by missing booleans

eternal night
#

True. Tho I usually suggest papers byte serialisation for itemstacks :>

tender shard
#

Does it do something different?

#

anyway I never use any Paper API because 35% of servers are still on regular spigot

eternal night
#

True. Anyway, nice library tho 👍 don't think too much of 33% of peeps not supporting it.

tender shard
#

thanks 🙂 yeah it's actually not really that useful, just nice to have. what I think is a real lifesaver is the CustomBlockData lib, I couldn't live without it anymore

solid cargo
#

my whole main class is just a one single mess.

tender shard
solid cargo
#

yeah true

#

how do i use the boolean tho

tender shard
#

I'm still scared when I see code I wrote three years ago

tender shard
solid cargo
#

i can only use the boolean in the

#

uh class its defined?

solid cargo
tender shard
#

Two possibilities:

#

You could make the method static when the original Helmet item you saved is static too. That's considered bad practice by some people, however I disagree on this case because you will never need more than one instance of the helmet item

#

Or, you pass a reference to your main instance to all the classes that need to access non-static methods defined in your main class

#

Go for the second solution

#

So basically something like this: (one minute pls)

solid cargo
#

i wish i was like my dad- organized PHP projects

#

well organized projects in general

tender shard
#

in your main class, where you create the other class instances, pass your main instance:

#
@Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(new MyAwesomeListener(this), this);
    }
#

The important part is the "this" inside MyAwesomeListener(..)

solid cargo
#

ah so 2 this's?

tender shard
#

now, in MyAwesomeListener, of course you have to define the parameter as well, like this:

#
public class MyAwesomeListener implements Listener {
    
    private final MyPlugin plugin;
    
    public MyAwesomeListener(MyPlugin plugin) {
        this.plugin = plugin;
    }
}
#

Of course MyPlugin is your main class

#

then you can access all methods by using plugin.isMinerHelmet(...)

solid cargo
#

ah ok

#

thanks

tender shard
#

np

#

there are other ways to achieve this but this is the most easiest solution

#

and it's also basically considered the most cleanest solution

solid cargo
#

while my dad is creating cloud accounting solutions i am making some stupid shit lol

tender shard
#

your dad probably is also a bit older than you and thus has more experience 😄

solid cargo
#

yeah true...

tender shard
#

it would be strange if you were older than your dad

solid cargo
#

i wish my dad went the java way

#

not php way

tender shard
#

I also started with PHP

#

but the language is a mess

solid cargo
#

yeah when ur dad is one of the best php'ers in the country, there will be a lot of swearing lol

tender shard
#

some methods are_using_method_names_like_this(), other's are completelylowercase(), others are camelCase() etc

solid cargo
#

java earns so much more

#

afaik

sullen marlin
#

Who cares how they’re formatted, you have an ide

#

Like of all the criticisms that’s not one I’d pick

tender shard
#

yeah true but anyway, it's just something I wanted to mention

solid cargo
#

my dad also kinda regrets going the php way ._.

sullen marlin
#

Java is the one true language

tender shard
#

yeah and kotlin baaad

#

lol

sullen marlin
#

Correct

tender shard
#

I should really start looking into learning kotlin one day

solid cargo
#

java is life
life is java

tender shard
#

or people should finally switch to java 16+ but all those mc 1.8 people will never do that

solid cargo
#

cough minikloon cough

sullen marlin
#

*17

tender shard
#

miniwhat?

solid cargo
#

cough hypixel cough

#

ok ik their network is large

#

they never will do it

sullen marlin
#

Mojang going 16 was a mistake

solid cargo
tender shard
solid cargo
#

more optimized

sullen marlin
#

Because now people will sit on 16

solid cargo
#

as far it uses less ram im in

sullen marlin
#

Rather than 11 or 17 which are the versions they should be sittin on

#
  • those are the versions distros usually package
tender shard
#

even Centos 7 includes java 11 meanwhile

solid cargo
#

md_5 give ownership to spigot thanks

tender shard
#

will you maintain it as well or just sack the donations @solid cargo ?

tender shard
#

Then I approve this request

solid cargo
#

i will donate all money to my dad's company

civic apex
#

how can i see all possible (shaped recipes for an item (for example chest), like acacia_planks for the slots instead of oak_planks?

sullen marlin
#

Those are probably using MaterialChoice

#

So just look for that and see what’s allowed

civic apex
#

is that a property/method of shapedrecipe?

sullen marlin
#

Yes

civic apex
#

is it in recipechoices?

sullen marlin
#

Yes

civic apex
#

how do I use it

#

?

#

with choice map?

sullen marlin
#

Check the docs, there’s only a couple methods. One will return a list of materials

civic apex
#

ok

#

is the list of materials the possible materials for the slot?

sullen marlin
#

Yes

civic apex
#

ok ty

#

wait how do I get a material choice from a recipe choice

#

there's no getMaterialChoice

tender shard
#

MaterialChoice is an implentation/subclass of RecipeChoice IIRC

#

how did you get the RecipeChoice object?

civic apex
#

getChoiceMap

tender shard
#

Hm there's probably a better way, but I think you should be able to check if your RecipeChoice is instanceof MaterialChoice, and then just cast it

#

(Never used any RecipeChoices so no idea but I'm sure this should work)

civic apex
#

but then

#

how am I supposed to get materialchoices

#

from a shapedrecipe

tender shard
#

Imagine you have this:

#
ShapedRecipe recipe = ...;
Map<Character,RecipeChoice> map = recipe.getChoiceMap();
RecipeChoice firstRecipeItem = map.get(0);
#

Now you can easily do this:

civic apex
#

cast?

#

thats basically what im doing

#

but you said that there was probs a better way

tender shard
#
if(firstRecipeItem instanceof MaterialChoice) {
  MaterialChoice materialChoice = (MaterialChoice) firstRecipeItem;
  // Do stuff
}
civic apex
#

yes

tender shard
civic apex
#

thats what i planned on doing

tender shard
#

I just looked at the docs and didn't find anything else

civic apex
#

but idk seems weird that sr doesnt give you materialchoice map

#

instead gives recipechoice map

tender shard
#

why is it weird?

sullen marlin
#

MaterialChoice is a subclass of RecipeChoice

tender shard
#

After all the RecipeChoice could also consist of ExactChoices or however it's called

#

like imagine a jukebox

civic apex
#

or the recipechoice having a material choice method

#

even if it returned the cast to material choice

tender shard
#

it has 8 materialchoices (the wood planks) and one "exact" thing, the diamond

sullen marlin
#

You cast it

civic apex
tender shard
civic apex
#

getingredient map should also work

tender shard
#

Just imagine you have a EntityDeathEvent

#

should that now have methods like getPig(), getZombie(), ... ?

sullen marlin
#

No because ingredientmap wont return the alternatives

tender shard
#

No, it has getEntity() and then you can cast it if you need more specific things

civic apex
#

for the diamond

tender shard
#

that's why it's not a MaterialChoice but an ExactChoice..

civic apex
#

you dont just add methods with unique names for everything

sullen marlin
#

Yes, but you were asking about doors not diamonds

tender shard
#

because a Diamond is a diamond

#

it's exact

sullen marlin
#

Or whatever the wood thin was

civic apex
#

but yes

civic apex
tender shard
#

A Jukebox recipe will return a map like this:
W=MaterialChoice (Wood)
D=ExactChoice (Diamond)

sullen marlin
#

Nah it wont alex

tender shard
#

oh

sullen marlin
#

ExactChoice is only used by plugins

tender shard
#

I misunderstood it then

civic apex
#

only 2 methods implement it iirc so why not just have a getMatchoice method directly?

sullen marlin
#

It means itemstack with meta

tender shard
#

ah alright

sullen marlin
#

Because what if 3 do

#

Do we add a new method every time a subclass is made

civic apex
#

in the getPig example it makes more sense cause they keep adding new entities

sullen marlin
#

What does the returned map include if some choices are exact and some are material?

solid cargo
#

so @tender shard like this?

tender shard
solid cargo
#

uh oh

tender shard
#

you probably want to check whether ANOTHER item is a copy / similar to your original item

civic apex
#

each material choice has its own material list

#

with differrent length

#

does it make sense?

tender shard
solid cargo
#

i think i will need a spoonfeed 🥄 😮

tender shard
civic apex
tender shard
#
for(Player player: Bukkit.getOnlinePlayers()) {
  if(isMinerHelmet(player.getInventory().getHelmet()) {
    getLogger.info("This player is wearing one of your custom helmets");
  }
}```
tender shard
solid cargo
#

can i replace getLogger with something else

#

cause it doesnt recognize that for me

#

like a sysout

tender shard
#

of course you can o0

solid cargo
#

ok im dead ig

#

:(

tender shard
sullen marlin
#

MaterialChoice and ExactChoice are different

#

MaterialChoice checks the material, ExactChoice checks the item

civic apex
solid cargo
#

so something like this. and then how can i apply the haste? something like a runtaskasynckoaghf [oawgba[

#

?

sullen marlin
#

MaterialChoice with one choice is different to ExactChoice

#

No vanilla recipes use ExactChoice, only plugins

tender shard
civic apex
#

does the material list from material choice always have the same size for all items in a shaped recipe?

tender shard
mossy laurel
#

Hello, I'm sending OPEN_SIGN_EDITOR packet and before that I'm setting Sign#setEditable to true, but after changing some lines there is a warning:

Player luv1ly just tried to change non-editable sign

and the content doesn't change.

sullen marlin
#

Did you call .update after setEditable

mossy laurel
#

yes

tender shard
#

sniped

vestal moat
#

guys

#

i keep getting NoClassDefFound but the error doesn't tell me where exactly i use the class

#

like where

tender shard
solid cargo
#

my plugin is apporaching 100kb very rapidly!

mossy laurel
# sullen marlin Did you call .update after setEditable
    @SneakyThrows
    private void openSignEditor(@NonNull Player player, @NonNull Sign sign) {
        sign.setEditable(true);
        sign.update();

        PacketContainer packetContainer = new PacketContainer(PacketType.Play.Server.OPEN_SIGN_EDITOR);
        packetContainer.getBlockPositionModifier()
                .write(0, new BlockPosition(sign.getX(), sign.getY(), sign.getZ()));

        protocolManager.sendServerPacket(player, packetContainer);
    }
civic apex
#

Recipe Choices

vestal moat
#

wait no im importing tons of other classes that should also error with them, and it doesn't

#

i've tested

#

pretty sure its somewhere static but where

solid cargo
#

it doesnt print anything out tho

#

@tender shard

#

i have this

#

and it doesnt tell me anything

tender shard
solid cargo
#

could be cause im in /gmc

#

?

#

nope

tender shard
solid cargo
#

i changed if to while

solid cargo
#

and still doesnt

vestal moat
tender shard
tender shard
#

Only import the classes inside that class

#

then in onEnable check if the plugin is installed. If yes create an instanceof your wrapper class

vestal moat
#

this is tons of methods to get moved

tender shard
#

yes

solid cargo
tender shard
#

If you depend on the other plugin, you can also add it as depends to your plugin.yml

vestal moat
#

its softdepend

tender shard
tender shard
#

This is my wrapper class

#

it tries to use the WorldEditHandler, which is a class that actually imports WorldEdit things, and if that doesn'T work, it throws an exception

vestal moat
#

dude ok no custom error message

#

i don't have time to do these breaking changes

tender shard
tender shard
vestal moat
#

i will have to move some methods to a new class... and also change the instance in every class that uses it

tender shard
#

yeah next time you should do that like that from the beginning 😛 I also learnt it the hard way

vestal moat
#

i might do bungee support so ig i will have to do that one day anyway

civic apex
#

how do mirrored recipes work?

#

like axes, hoes, shears, etc.

#

i thought they were different recipe choices

#

but they arent

#

and there's no separated recipe for mirror

tender shard
#

RecipeChoices only map a Material/ItemStack to one of the characters

civic apex
#

yes

#

i realised that later

tender shard
#

as for the mirrored recipes... yeah that's a good question lmao

#

maybe md_5 is still here?

civic apex
#

cause rc can have different list lenghts

tender shard
#

he will probably know it lol

civic apex
#

can ALL recipes be mirrored

#

?

#

and theyll work

tender shard
#

good question. Maybe add a custom recipe and just try it

civic apex
#

?

tender shard
#

create your own recipe and see if it works when you craft it mirrored

civic apex
#

no

#

not what i mean

#

so

#

im trying to get the itemstack that would return from a grid of 9 items

#

like a crafting table gui

#

recreation

#

so i checked for all kinds of recipes

#

shaped and shapeless

#

i checked for smaller recipes in all places they could be

#

and i checked for recipe choices

#

everything works (afaik) except mirrored recipes

#

cause there is no recipe that is

tender shard
#

ah okay I get it

civic apex
#

add
ada
asa

tender shard
#

I could imagine that you have to use NMS for that

civic apex
#

air, diamond and stick

tender shard
#

but

#

I have a way better idea

tender shard
#

I have an extremely simple idea

#

so

#

you have a matrix of itemstacks right?

civic apex
#

instance of craft table

tender shard
#

and want to check if that results in a recipe

civic apex
#

and simulate it?

tender shard
#

no

tender shard
#

Imagine you have a matrix[][]

#

simply switch the first and third row

civic apex
#

yes

#

thats what i was thinking of

#

but

#

i need to know

#

if all recipes can be mirrored

#

or theres some kind of parameter that im missing

tender shard
#

not sure, but would be so bad if all recipes would work mirrored with your custom crafting system?

#

I just wouldn't mind about that and would see it as bonus feature 😄

civic apex
#

when its mirrored

#

in a grid

tender shard
#

I couldn't think of anything where it wouldnt make sense

civic apex
#

in vertical it doesnt work

#

for example you cant craft a bed if you mirror it vertically

#

but what if there was a vertical bed

#

it wouldnt make sense to flip it horizontally would it

#

it would be inconsistent

#

so idk if there are any items like that

tender shard
#

why not? imagine this is a vertical bed

#

Wood Wool
Wood Wool
Wood Wool

#

why shouldnt

Wool Wood
Wool Wood
Wool Wood

not make sense?

civic apex
#

wouldnt it make sense to be able to craft regular beds mirrored vertically then?

#

you just kinda flip it after you craft it ig

tender shard
#

oh I'm not talking about upside down mirroring

#

only left/right

civic apex
#

but my question remains

#

why is vertical more important ALWAYS than lr

#

imagine a recipe that was like that but vertical mirroring didnt matter

#

but lr did

#

tbf i cant find any recipe

charred summit
#

plugin dont work

rigid hazel
#

Hey guys!

#

When I make a custom inv, I want to disable the player inventory,

#

Is that possible, that just the custom gui is shown?

rigid hazel
#

Sad.

tender shard
#

players will always see their own inventory

#

What you COULD do is...

#

clear the player's inventory and use that for your GUI

#

and after that give them their items back

#

buuut

#

I just wouldn't mind seeing the inv

#

it's like that for all GUIs and has ever been

civic apex
tender shard
#

that's the way it is 😄