#help-development

1 messages · Page 540 of 1

remote swallow
#

user error

young knoll
#

“Can this be reopened? This as the current fix still can cause a memory leak. Entity metadata doesn't automatically delete on entity delete, so you need to either do it yourself or use a custom system for storing this data.”

worldly ingot
#

Yeah, in that regards it's leaky. Though that's sort of tough to fix tbh

#

Java doesn't have destructors

young knoll
#

Can’t you remove it on death

worldly ingot
#

It should persist across deaths

young knoll
#

On entities?

worldly ingot
#

Yes

young knoll
#

I see

young knoll
#

Can it be fixed with weak references

worldly ingot
#

Dunno. Haven't looked at the impl super in-depth enough to know how to resolve leaky API like that. I don't even really think you can resolve it without destructors

young knoll
#

Hmm

quaint mantle
#
                    if (item1.getType() == Material.IRON_HORSE_ARMOR && itemd1.getCustomModelData() == 1) {
                        if (e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR) {
                            List<Block> los = e.getPlayer().getLineOfSight(null, 5);
                            for (Block b : los) {
                                if (b.getType() == Material.WATER) {
                                    itemd1.setCustomModelData(2);
                                    world.playSound(block.getLocation(), Sound.ITEM_BUCKET_FILL_LAVA, 5,2);
                                    item1.setItemMeta(itemd1);
                                    Bukkit.broadcastMessage("test");
                                    break;
                                }
                            }
                        }
                    }``` @eternal oxide
#

this code not working btw

young knoll
#

Might be something to look at if I get bored

quaint mantle
#

i mean works but if click block in water not working

worldly ingot
#

Point being, super super useful API, people just don't know how to use it correctly. Deprecating it isn't an option

young knoll
#

Fair enough

#

Might be good to add a warning that you should explicitly remove any metadata you add

worldly ingot
#

If it's not in the Javadocs currently then yeah, could probably be set on Metadatable

#

Although imho I think metadata should extend beyond a player disconnecting

#

For the same reason a Player instance still exists so long as a reference is held

young knoll
#

Yeah I guess as long as the instance is still valid it can be useful

eternal oxide
quaint mantle
#

17

#

1.16.5

young knoll
#

I think flowing water is a separate material

#

FYI

eternal oxide
#

do you have an api version in your plugin.yml?

quaint mantle
eternal oxide
#

ok

#

code looks fine to me, so long as your model data is correct

#

add debugs

quaint mantle
#

i added

#

not work

quaint mantle
#

but for to work i need click block inwater

eternal oxide
#

you are on paper then

quaint mantle
#

spigot

eternal oxide
#

I forget what the default is for ignoreCancelled on events

young knoll
#

I believe it’s false

eternal oxide
#

won;t be that then

quaint mantle
#

what i need cancel event ?

eternal oxide
#

no

#

you need more debugs to see what path through yoru code it takes

young knoll
quaint mantle
#

already u guys know this

#

but i wan't to send

hybrid spoke
wise mesa
#

I had an idea for using lombok/manifold extension methods but i want to know if its an appropriate use

#

we have a lot of "manager" classes, like party manager, level manager, etc.

#

its a pain to pass all these around, and it'd be nice to use object methods like player.getLevel instead of levelManager.getLevel(player)

#

so I was planning to use have some special player wrapper class

#

like PluginPlayer or whatever

#

that has all those methods

#

and then has .asPlayer()

#

this is all fine

#

the only problem is that it's a pain to go from player to plugin player

#

is it unreasonable to add like a .asPluginPlayer method to the bukkit player interface

remote swallow
#

PluginPlayerManager#asPluginPlayer(player)

wise mesa
#

not literally but using an extension method

hybrid spoke
remote swallow
#

all the managers

hybrid spoke
#

wrapping the playerdata is good

#

then you only need to pass one "manager" around

#

lets name it repository

#

the PluginPlayerRepository f.e.

#

which caches your wrapper instances

young knoll
#

I have a lot of managers in my recent plugin

#

Sadly they don’t all connect to a player tho

hybrid spoke
#

manager classes are the pure evil

#

you usually dont want to have them

#

and there is most likely a better way to approach what you do

#

despite that "Manager" is an awful suffix

wise mesa
#

it's more the name than anything

hybrid spoke
#

they really are

#

its the reason why it exists

wise mesa
#

as long as you give them a more descriptive name

#

i disagree

hybrid spoke
#

good for you

wise mesa
#

I'm avoiding using static, and using dependency injection to get them into my classes

#

I have to manage state thats built upon builtin classes somehow

hybrid spoke
#

why are you avoiding static

wise mesa
#

so i can use DI?

#

not all static but static state

hybrid spoke
#

singletons are not always wrong

young knoll
#

private SpellPartRegistry spellPartRegistry;
    private CustomInventoryManager inventoryManager;
    private ConfigurationManager configurationManager;
    private PlayerManager playerManager;
    private AltarManager altarManager;
    private StorageAdapter storageAdapter;

tragic

hybrid spoke
#

also manager classes break so many principles

#

and can overcomplicate your code

carmine mica
hybrid spoke
#

once done ugly your code's shit

wise mesa
#

I think they do a much better job of OOP principles than singletons do

#

di all the way

hybrid spoke
wise mesa
#

how else shall you unit test

young knoll
#

Tbf I like singletons

wise mesa
#

my managers are all interfaces

young knoll
#

But many people disagree

hybrid spoke
wise mesa
#

i do like singletons

#

but I'm avoiding using them because I like unit testing

hybrid spoke
hybrid spoke
#

and voila

wise mesa
#

if I were to

young knoll
wise mesa
#

rename them to BlahBlahBlahService

#

and change nothing about them

#

would that be preferable

hybrid spoke
#

ASM is pretty okay done, wouldv'e understood if you would've complained about antiac lmao

hybrid spoke
#

what do they do

#

the architecture is important

wise mesa
#

for example LevelManager

#

actually that one's called LevelController

#

because I made it more recently

#

the managers are all old

#

but anyways

#
public interface LevelController {
    /**
     * Gives back the level of the player
     * @param player player to check the level of
     * @return the level of player
     */
    int getPlayerLevel(OfflinePlayer player);

    /**
     * Levels up the player by 1
     * @param player the player to level up
     */
    default void levelUp(OfflinePlayer player) {
        addLevels(player, 1);
    }
    void addLevels(OfflinePlayer player, int amount);

    /**
     * Sets the players level - should be used for like
     * an admin command or something
     * @param player the player to set the level of
     * @param level the level to set the player to
     */
    void setLevel(OfflinePlayer player, int level);
}
hybrid spoke
#

for that I would do what you initially said

#

make your own player class which wraps around the UUID of a player storing extra attributes

#

f.e. the level

young knoll
#

And then have a manager to keep track of them

hybrid spoke
#

not a manager, please

wise mesa
#

I already mentioned that I plan to make a wrapper class

hybrid spoke
#

yeah but dont extend or reimplement the bukkit api

wise mesa
#

im not doing that

#

i mentioned using lombok extension methods

#

where you add a fake new method to a class

#

which is really just a static method

hybrid spoke
#

a fake new method what

idle yacht
#

inventory.getViewers().forEach(HumanEntity::closeInventory); inside a sync bukkit tasktimer throws java.util.ConcurrentModificationException: null what am I doing wrong

hybrid spoke
#

that wont work

wise mesa
#

new fake method

#

not fake new method

#

basicallyh

hybrid spoke
#

that doesnt change the fact that im confused

idle yacht
hybrid spoke
young knoll
#

Aren’t Lombok extension methods just fancy ways to have a static method

wise mesa
#
public static void doACoolThing(Player thizz) {
    // Do something
}

Player player;
player.doACoolThing() // valid

// which is compiled to
doACoolThing(player);
#

its just a way to make static methods look a little nicer

idle yacht
hybrid spoke
#

or better, java.

#

you cant operate on a list while looping over it

carmine mica
#

you could just copy the collection too, I think that's better than delaying stuff

young knoll
#

You are supposed to delay certain things by a tick in the inventory click event

#

That’s just how the event is

carmine mica
#

what event, there was no event given in the context

young knoll
#

InventoryClickEvent

#

Idk I was just guessing

hybrid spoke
young knoll
hybrid spoke
#

cant advice without context

idle yacht
#

thanks though

young knoll
#

And yes a lot of code is just thrown together atm, don’t question the random try catch in the onEnable for example :p

hybrid spoke
#

yeah was about to say, this is all so entangled

worldly ingot
#

Exceptions in constructors Kreygasm

hybrid spoke
#

there are many things to criticise

young knoll
#

I know

#

Not enough async

hybrid spoke
#

nah fuck that

worldly ingot
#

More async makes everything better

hybrid spoke
#

start in the first layer

young knoll
#

Exactly

worldly ingot
#

Surprised so few of Bukkit's events are async. They should all be!

#

Bukkit would perform so much better!

hybrid spoke
#

time to build out the async catcher

river oracle
#

SuperDuperAsyncSpigot

young knoll
#

Gotta go for that deluxe async multithreaded data driven object oriented uhh

#

<Insert a bunch more buzzwords> code

river oracle
hybrid spoke
#

and it functions better

worldly ingot
#

Annotate it with a new annotation, @FunctionalClass. It's like @FunctionalInterface only it's not

hybrid spoke
#

methods are functions anyways

#

so why not go functional always

worldly ingot
#

Actually just annotate it with a new @Functional annotation instead. That way API users know that the class is working as intended

young knoll
#

Is there also a @NonFunctional

young knoll
#

No that’s spigot in F#

worldly ingot
hybrid spoke
young knoll
#

How do I stop the eye bleeding

hybrid spoke
#

not sure

worldly ingot
#

A tampon

young knoll
#

Eye period

worldly ingot
#

Good for nose bleeds, must be good for eyes

river oracle
young knoll
#

Note to self

#

Get tampons for nose bleeds

river oracle
hybrid spoke
#

tried to catch the blood with your eyelids?

river oracle
#

I feel like a pad would be more effective

young knoll
#

It’s too late the Amazon drone is already here

river oracle
#

FUCK

#

well

young knoll
#

Yeah idk I notice all my recent projects have a lot of managers to pass around

#

That’s probably the biggest issue

river oracle
#

the most annoying thing

#

jesus I just make a ManagerManagerBuilder and call it a day

young knoll
#

Yeah but like what else do I useeeee

ivory sleet
young knoll
#

Ah yes a ManagerManager

hybrid spoke
#

just a tiny big issue

young knoll
#

Why didn’t I think of that

river oracle
ivory sleet
#

like sometimes compromising design for usability (like with managers) may be justifiable

young knoll
#

I mean technically they are all accessible from the main class so I could just pass that to everything

river oracle
#

💀

#

don't hurt me

hybrid spoke
#

chunk them together to a ManagerBundle

river oracle
#

frrr ^

hybrid spoke
#

have that in your main class

#

and pass your main class around

#

get.get.get.get

young knoll
#

Exactly

hybrid spoke
#

before i knew what i was doing, and i still dont, i made infinite sub classes in my class to have a this.class.doesthat.cando.with.cool.shit effect.takethispath.andyes.store

undone axleBOT
hybrid spoke
#

i dont think i have that anymore

#

was in 2013 or whatever

young knoll
#

Maybe I’ll just convert some of them to singletons

#

Idfk

hybrid spoke
#

first of all work at the names

river oracle
#

I had to come in and fix this code when the dev before me got fired

hybrid spoke
#

then SRP, then untie the knots

#

and after all that refactorating you can think of how do i get that in this class

young knoll
#

We have singletons but what about doubletons

#

Exactly 2 instances exist

hybrid spoke
#

Pair sadly got removed

young knoll
#

This is why you keep all your code closed source, then nobody can judge it

hybrid spoke
#

thats for sure

young knoll
#

Unless they decompile it, in which case you can just blame it on the decompiler

hybrid spoke
#

it just have to work

#

f.e. twitter algo

young knoll
#

Pretty much

#

If it’s stupid and it works

#

Then it still makes money

hybrid spoke
#

never change only add

river oracle
#

It may not be good, but it needs to be maintainable

#

if I can't add to it its shit code

#

non functional

hybrid spoke
#

you always can add

#

if not force add with reflection or bytecode manipulation

river oracle
young knoll
#

Just try harder

hybrid spoke
#

add a singleton

#

make it 31

ancient plank
#

code debt go brrrr

young knoll
#

Takes less time to add more garbage than it does to clean up garbage

river oracle
#

?paste

undone axleBOT
river oracle
#

this is my equivalent

#

not perfect, but better and you can add to it

river oracle
hybrid spoke
#

only thing

#

why does it need a gameprofile

#

and not just directly a player or whatever

river oracle
#

its a internal impl of something

hybrid spoke
#

ohhhhh so they just named it stupid

river oracle
#

😭 rude asf man, but yeah makes sense lol

hybrid spoke
#

oh then

#

you just named it stupid

#

copy that

river oracle
#

yep I did, but we don't use mojang code in the game engine so its fine 😎

young knoll
#

Clearly it should be PlayerProfile

hybrid spoke
#

why do names never have an S in it

#

PlayersGameProfile

young knoll
#

PlayersGamesProfiles

worldly ingot
#

Just a convention to avoid pluralization

hybrid spoke
#

choco, respectfully, no.

worldly ingot
#

Only reasonable case to use a plural class name would be for a class containing constants or utility methods

young knoll
#

Enums are constants

#

Pluralize them

worldly ingot
#

Enums contain constants but are data types

hybrid spoke
worldly ingot
#

Collections is a utility class

young knoll
#

org.bukkit.Materials

compact haven
#

Or something made to hold multiples

worldly ingot
#

So is Arrays, or Utils (I hate this naming convention, but technically valid)

compact haven
#

for example I have a class ILoadoutItems because it's the wrapper of a Map

#

(it's not actually wrapping a Map but the result is similar)

hybrid spoke
#

Managers to group manager classes

young knoll
#

Quick someone judge him for using the I prefix

worldly ingot
young knoll
#

IAbstractAsyncLoadout

hybrid spoke
#

the good old Listeners class

worldly ingot
young knoll
#

I feel attacked

#

Well

#

Me from 5 years ago feels attacked but still

compact haven
#

I mean, I don't see the problem with plurals

remote swallow
#

Why does 19 ur old coll feel attacked

compact haven
#

if it feels right then I do it

#

the reason I have prefixed my interfaces with I here is because I wanted it to be clear that it isnt the implementation, because I'm providing both

#

(albeit under different class names)

#

ILoadoutItems is only provided anonymously, though my others have default implementations

young knoll
#

Something tells me people will disagree on design choices throughout all of time and space

compact haven
#

definitely

worldly ingot
#

I disagree >:(

#

okay

hybrid spoke
#

L

young knoll
#

Alright well

worldly ingot
#

first of all, fuck you

#

second, nice

young knoll
#

Choco and cipher are the same person

#

Confirmed

compact haven
#

bro wait a minute

#

wtf is this bullshit

#

why there an automatic new line after my end class brackets

#

i know its convention but like in C or some bs

ancient plank
#

I can't think of any classes where I've named them with plural words

compact haven
#

I have an IKitsConfig and YamlKitsConfig in the same project

#

but that isnt really "plural"

#

its plural but only in the adjective

#

not the noun

hybrid spoke
#

Credentials

ancient plank
#

I have some, but it's "Utils"

compact haven
#

oh wtf

#

there's 2 immediately I can think of in the Java stdlib

#

stop making trouble

#

Collectors and Collections

hybrid spoke
#

i avoid using them because they are plurals

compact haven
#

aint no way 💀

#

bro doesn't use streams or immutable collections

ancient plank
#

though recently I've been typing out "Utility" instead of Utils

hybrid spoke
#

oh i also have a class called TaskForce1

ancient plank
#

nope I've got nothin, no (recent) projects where a class name is plural

young knoll
#

Just make them all plural

#

Problem solved

hazy parrot
#

Those are not really any kind of instance classes

hybrid spoke
#

oh so i can start using them?

hazy parrot
#

It's fine ig

hybrid spoke
#

how do i instantiate them

young knoll
#

Kek

#

I’ll just get ChatGPT to write all my code

#

If it writes it then it can’t be bad

hybrid spoke
#

automate it and force chatgpt to check itself 10 times

young knoll
#

See because a computer can’t write bad code that will be run on another computer

#

That’s like, poisoning someone

#

And that’s illegal

hybrid spoke
#

cannibalism

#

or something like that

sharp bough
#

is it possible to listen when a fence updates visually? for example a player places a block next to a fence and this updates connecting to this block, or a player places a fence and this updates connecting to nearby blocks?
i have tried using BlockPhysicsEvent but it didnt work as expected

#

i have also checked out NMS to try and capture the package that updates the fence, but didnt get it to work

#

using 1.19+ java

#
public void onBlockPhysics(BlockPhysicsEvent event) {
        Block block = event.getBlock();
        if (block.getType() == Material.COBBLESTONE_WALL || block.getType() == Material.MOSSY_COBBLESTONE_WALL) {
            event.setCancelled(true);
        }
    }
``` this kinda works but its quite buggy
worldly ingot
#

Yeah I think physics is the only one that would be fired in this instance

sharp bough
#

but that means theres a deaper level with packages, something is changing that fence

#

something somewhere is udpating that fence because a new block was placed

young knoll
#

I think the internal method is called updateStateForNeighbours

#

When a block is placed it notifies all neighbouring blocks which can then react however they see fit

candid kindle
#

Is this static abuse?

opaque scarab
#

Anyone know how to properly rotate a display entity to set degrees on XYZ using the setTranslation method?

pliant wind
#

Is the only way to change the required spawning light level for mob spawners through nms?

wise mesa
#

is it possible to get an offline player by name if they've been on the server before

#

using their previously known name

#

I don't want the server asking mojang or anything in the middle of a tick

#

Bukkit.getOfflinePlayer(string) is deprecated and idk if there's anything better for this

#

this is for commands

#

I don't want it to run a blocking io call

#

if its to the hard drive that's fine if its to the network it isn't

quaint mantle
#

<plugin>#getServer#getOfflinePlayer isnt deprecated

wise mesa
#

yes it is

#

getOfflinePlayer with string is

#

with uuid isn't

#

but I am trying to get it with their name

quaint mantle
#

It isnt deprecated for me

wise mesa
#

I want those using the command to be able to type the name of the player

quaint mantle
#

In intellaJ it isnt saying deprecated, also it being deprecated doesnt matter

#

The reasoning is because "Persistent storage of users should be by UUID as names are no longer unique past a single session."

#

If you are not planning on accessing users too far into the future after they logged off then its fine

#

also they are correct, you should use UUID and not username since usernames are not unique after a session is ended

wise mesa
#

did you read my usecase though?

#

I'm writing a command

#

my users are not going to check people's uuid's then they want to refer to them

quaint mantle
#

Then use the username

#

Did you read my message?

wise mesa
#

yes I did

quaint mantle
#

Obviously not

wise mesa
#

it just seems like you contradicted yourself

#

when you put that last part

quaint mantle
#

Not at all

wise mesa
#

you said that its okay for me to not use uuid

#

and then you said that I should use uuid

quaint mantle
#

not a contridiction

wise mesa
#

well anyways

#

I knew all of this

quaint mantle
#

a contridiction would be me saying its okay to use uuid then to say its not okay to use uuid

wise mesa
#

what I wanted to know is if there's a method that won't potentially make a blocking web request

quaint mantle
#

I said you should use uuid, I never stated its not okay to use uuid thus I never contridicted myself

wise mesa
#

because I was reading quickly

quaint mantle
#

Double check your reading before you blame people then :/

lethal coral
#
        MiniMessage miniMessage = MiniMessage.miniMessage();
        Player target = player;
        if (args.length > 0) {
            target = Bukkit.getPlayer(args[0]);
            if (target == null) {
                player.sendMessage(miniMessage.deserialize("<red>The referenced player was not found."));
                return;
            }
        }

I have this code in like 8 classes for commands to get an optional player argument. I've considered making this a method but even then I feel like it won't really reduce the amount of code in the method? any ideas?

wise mesa
#

like your username lol

quaint mantle
#

fairs

#

also Hexic, you can make that if statement only 1 or 2 lines

wise mesa
#

in exactly the same way

#

then it'd probably be nice to have

#

as a method

quaint mantle
#

Id say its better if he just simplifies it into 1 line then make a method but its his choice

wise mesa
#

like what if you want to change that and then you have to change all 8 (and likely soon to be more) versions of it

lethal coral
wise mesa
#

well you could get rid of the first if

wise mesa
#

oh wait nvm

lethal coral
wise mesa
#

that won't work

#

yea yea

#

wait no it will

quaint mantle
#

oh okay well you cant do statement && return like in js so its 3 lines

wise mesa
#

just gotta slightly modify my idea

#
Player target = args.length > 0 ? Bukkit.getPlayer(args[0]) : player;
#

there's your one liner

#

and then just check if target is null

quaint mantle
#
if (args.length > 0 && Bukkit.getPlayer(args[0]) == null) {
  player.sendMessage();
  return true;};
lethal coral
#

that never sets the target variable

quaint mantle
#

(wrong reply)

wise mesa
#

lol

lethal coral
quaint mantle
lethal coral
#

yes if it's null

#

or no actually I'm throwing

wise mesa
#

yea

lethal coral
#

cause that's not what I want here

wise mesa
#

or returning or something

lethal coral
#

yeah

wise mesa
#

my statement is exactly the same as the code you already have

#

without the second if statement

#

not exactly

#

but similar enough

lethal coral
#

I'm still gonna have repeated code though

wise mesa
#

move it to a function

lethal coral
#

I'll make it work and come back

wise mesa
#

wonderful

#

good luck

lethal coral
#

🫡

split gull
#

omg hapily

lethal coral
#

hi jake

lethal coral
#

I have the method to get the player argument right

#

then I check if it's null in the execute method and then send them a response and stop the execute method right then and there

#

but that's what

#

4 lines

#

of repeated code

#

which is equal to what I already have

#

or actually like 1 line less

quaint mantle
#

just make a method which takes in the args and the executing player then do all the checks and messages in the method, return either true of false and then do if (!method(args, executor)) return true;;

quaint mantle
#

I think he needs it to be an online player (im assuming)

lethal coral
#

yes

wet breach
#

Why?

quaint mantle
#

does it matter?

wet breach
#

Yes

quaint mantle
#

no not really

lethal coral
#

cause the operations I'm performing on the player are them being there

quaint mantle
#

if he needs it to be an online player then he needs it to be an online player, doesnt matter to us what for

wet breach
quaint mantle
#

I assume he knows enough to know whether he needs a player to be online or offline to perform the desired action on them :/

#

I get where your coming from but it just doesnt apply here

wet breach
#

If you understand then everything you said was pointless as it will not change how i provide help

#

I dont make assumptions and therefore why i ask questions of their code

quaint mantle
#

I do not need to change how you provide help to get my point across

lethal coral
wet breach
lethal coral
#

commands and the issue I'm having is repeated code

wet breach
#

So i can understand better and provide appropriate input if able lol

quaint mantle
# lethal coral I have literally zero clue what you mean

Alright so, make a method that takes in 2 arguments, one being the args from the command and one being the sender (or player), then inside the method check for the args length, check for the player and whatever other checks you need, if all checks pass return true in the method, if any check fails use the sender arg to send them a message about it then in the method return false, Back in your command code check whether the method returned true of false by if (!methodName(args, sender)) return true;
(i dont know your level in java so incase you dont know the !method() in the if statement is a replacement for doing method() == false)

wet breach
#

Depending on what you are doing i may have some example code for you

lethal coral
quaint mantle
#

Why?

lethal coral
#

to assign the variable

#

!paste

wet breach
#

Well i guess i can show you how i do commands

lethal coral
#

?paste

undone axleBOT
quaint mantle
#

Is it allowed to feed code in this server or no?

lethal coral
#

that's what I have rn

wet breach
#

This is how i setup my commands

quaint mantle
#

Hes not having issues with creating commands

lethal coral
#

I know how to make commands I'm using my own command system

wet breach
#

I typically make use of sub commands unless it doesnt make sense to

quaint mantle
#

Please leave us be for now frost

quaint mantle
wet breach
round finch
wet breach
#

So it may help to see how others do it

lethal coral
wet breach
#

Oh you want tab completions

quaint mantle
lethal coral
#

it's just made to be a little bit better than BukkitCommand (commandmap way of registering commands, not plugin.yml) and does like half of the things for you

quaint mantle
wet breach
quaint mantle
#

Tab completions do not force the argument to match them (from what ive seen)

#

It doesnt matter if you give the end user all the options if they can input something else to break it

#

Passing completions does not fix his issue unless there is a way to force the completions as the only accepted arguments which I do not know about if there is

wet breach
#

Well you can provide possible completions as they type but you cant force the completion as that is client side

quaint mantle
#

Exactly my point

#

so please

#

leave us be since you are not helping

#

I appreciate the efforts but it will only cause more confusion

wet breach
#

Then go to dms if you dont like public forums

quaint mantle
#

I am more then welcome to have him privatly message me if he so prefers

wet breach
#

Then it seems it isnt solely your decision

quaint mantle
#

I politely asked you to please refrain from trying to help since what you are saying could only cause more confusion

#

I am not making any choices for anyone I am simple suggesting something

#

You are not forced to listen but it would be more helpful if you did

wet breach
#

Sure everyone here is free to do so. But you suggesting someone to not talk is not constructive either

quaint mantle
#

@lethal coral im sorry about this, we can continue this here or in dms whichever you would prefer

lethal coral
#

idrc but in-case anybody else runs into the problem maybe here

quaint mantle
#

Alrighty!

#

Here ill write some example code to show you what I mean with explanations

wet breach
#

You both failed to explain the situation adequately. But in either case it seems their problem isnt all that trivial if they are looking to not repeat code

quaint mantle
#

I understand his problem perfectly

#

Please refrain from speaking if you wish to help

#

moving on

wet breach
quaint mantle
#

I only hush people whose input is not needed

wet breach
#

And you are in a public space

quaint mantle
#

I still have the right to express my opinion as much as you do

wet breach
#

Do you need reminding again?

quaint mantle
#

I have the right to express my opinion as much as you do

wet breach
#

Never said otherwise

quaint mantle
#

I do not have to listen to you and you do not have to listen to me

#

Speaking of which I am now going to ignore you since this conversation has no positive effect on anything relating to spigot, spigot developers or any developers in general

wet breach
#

Sure doesnt bother me in the least

#

Anyways time to look at the pastes

#

To see what they are saying in regards to repeated code

quaint mantle
# lethal coral idrc but in-case anybody else runs into the problem maybe here

I think personally in this situation the repeated code for checking if the player input is valid is not an issue since the repeated code is necessary and even if you made it into a method it would still require a few lines to set the target variable

Player Target = Bukkit.getPlayer(<username>);
if (args.length == 0 && Target == null) {
  <executing_player>.sendMessage(<message>)
  return true;
}

Would be your best bet, <username> being the provided username, <executing_player> being a reference to the player running the command and <message> being the message you want to send to them for inputing an invalid player
I am no means an expert but I personally dont think repeated code in this sort of context is bad for the reasons above

wet breach
#

That piece of code seems fine and is similar to what others suggested. I dont see how this is repeated code unless they are referring in that they dont want to repeat that code in all their sub commands. If that is the case then move it either to the main class or to its own class. If its something expected to run all the time probably wise to make such methods static regardless where its at.

#

This would be the only way to avoid repeating such code and keeping it optimal

quaint mantle
#

Yes they meant they didnt want that code in other commands/subcommands but even if you made it a method in a main class it would still use 2-3 lines just to check the method and assign the target variable

wet breach
#

I would say use recursion but i probably wouldnt recommend it in case simply for the fact it seems it may get used too much and recursion can be bad for that somtimes lol

wet breach
#

Purpose of a function is repeated use, not how many lines the function needs

quaint mantle
#

He already implied before that he didnt think it was worth it if it already used the same amount of lines

wet breach
#

I hope their concern wasnt how large the method function would be?

wet breach
wet breach
#

Hope that answers their concern in regards to that

#

Also the other advantage is that if something is wrong with it or it needs tweaking

#

Instead of changing that repeated code in however many command classes you only have a central point for it

quaint mantle
#

I dont feel like a check for user input being a player would change that much

wet breach
#

In fact this code would fit perfectly in a utility class where you could override it if necessary

wet breach
#

Sometimes 3 lines of code may seem insignificant but if you actually trace all those objects and methods back to where they come from as well as understand how the jvm and jit try to optimize. Then those 3 lines becomes clear that they are not as insignificant as you assumed them to be

#

One of the main objectives in objective programming is object reuse and code reuse

lethal coral
quaint mantle
#

sorry yes

lethal coral
#

and I gotta check the length is greater than 0 before trying to do Bukkit#getPlayer(String)

quaint mantle
#

I copied the part of code from my plugin

#

I meant > not ==

lethal coral
#

but I would still have to extract that if before

wet breach
#

So if you are able to reuse code that means put it in its own method and many things can use it, then this is generally the best choice

lethal coral
#

otherwise I would get a potential indexoutofbounds exception

lethal coral
#

but I can't because I have to set the variable and in certain circumstances also stop the code

#

so I thought of throwing an exception

#

but even then I would have to have a try catch and then it doesn't reduce anything really

lethal coral
#

the target variable

#

yes

wet breach
#

That is easy

#

Use a default

lethal coral
#

I do that

wet breach
#

Default should be the same as the player doing the command in this manner its never null and easier to check

lethal coral
#

yes I have that already

wet breach
#

Alright i think that covers setting the variable

lethal coral
#

no

wet breach
#

Then i think you misunderstand a default

lethal coral
#

I don't

wet breach
#

If there is a default variable is always set

lethal coral
#

what I'm saying is I have to set the variable to the argument

wet breach
#

Alright, and why is it that a function couldnt do that part for you?

#

There is more pieces. You can feed a function any number of objects you want and with recent java versions you can even use optionals

#

Is the issue at hand in trying to make the function return what you are wanting?

lethal coral
#

ok frostalf

#

I think you should give this a go yourself

#

and explain to me what you did to improve it

#

so I can learn

wet breach
#

Well i think we need to work out the part where you say a function wouldnt work, because i am failing to see how it wouldnt. At least given my knowledge in how objects and methods work.

#

The piece of code to check for a player for example can be returned in 3 different ways for example

#

The code above that is

lethal coral
#

yes frostalf we are not understanding each other

flint coyote
#

Since this seems to go for a while already - where's the code?

lethal coral
#

so if you give it a try maybe you will understand what I'm trying to say

wet breach
#

You could return a boolean, return a string, return a player object and the 4th is returning nothing but instead setting something aka void method

lethal coral
#

and we cannot seem to figure out how to effectively reduce the code repetition

flint coyote
#

Usually you can trust on frostalf's advice. I just wanted to take a look because you two seem to not be on the same track

wet breach
lethal coral
#

the code is repeated

#

intellij yells at me

#

it looks bad

flint coyote
#
if (args.length > 0) {
            target = Bukkit.getPlayer(args[0]);
            if (target == null) {
                player.sendMessage(miniMessage.deserialize("<red>The referenced player was not found."));
                return;
            }
        }

That part?

lethal coral
#

yes perfect and the Player target = player;'

wet breach
#

Well it was suggested to be moved to main class or its own class and you feed the method what it needs. So in this case i would recommend the constructor taking in a command, and spitting out a command.

#

And it would be the first thing your commands go through

#

Then you can interact with it however you want

#

If further interaction is needed

lethal coral
#

see that sounds great in theory but I just tried to connect the bridges in my head and they didn't connect

wet breach
#

Fantastic, we have identified the problem then

lethal coral
#

no we did not

wet breach
lethal coral
#

idk I think we're going to run into problems pretty quickly

wet breach
#

For me to properly help with this particular problem i need to be at my computer. Currently at work on a phone and its not adequate. Unless maybe fabsi here understands and can demonstrate

wary topaz
#

proof im tired

flint coyote
#

What frostalf is suggesting would work but I can understand how that's hard to understand for devs without years of experience.
And simpler approach would be to have a function with the args array and the commandsender and then sending the message & returning null or returning the target player.

Would reduce the repeated code to

Player target = getTarget(player, args)
if(target == null) return;
wary topaz
#

if ((Player target = getTarget(player, args)) == null) return;

flint coyote
lethal coral
#

that idea was proposed earlier

flint coyote
lethal coral
#

but it's still repeated code

flint coyote
#

Well a function call is one "repeated" line aswell

lethal coral
#

sure

wet breach
flint coyote
#

Unless that command framework has some function where you put code to run before every command - then there's actually 0 repeated code

wary topaz
#

whats a good yaml editor?

lethal coral
wet breach
#

Repeated code doesnt include function calls. Because otherwise how are you suppose to call the function, the only way to have this not be the case is if the initial entry was the function to begin with

flint coyote
#

you can send the error inside your function aswell

wary topaz
#

if ((Player target = getTarget(player, args)) == null) return;

lethal coral
#

ig

flint coyote
#

that's why I put the player in there in the first place

wet breach
lethal coral
#

well no the player has to be in there to be able to set it to the player possibly anyways

wet breach
#

My idea earlier was on the basis of initial entry point, but fabsi did bring up a good point that it does depend on your framework

flint coyote
#

Oh. I overlooked that part.
In that case you would have to return the player itself if the args length is 0 instead of null

#

maybe you did that already

wet breach
onyx fjord
#

Optionals are cool

wet breach
#

Maybe i am just too advanced to help

#

Am i really that knowledgeable that i cant help right now with something like this? Lol

wary topaz
#

public boolean isNull(String[] args) {
return Bukkit.getPlayer(args[0]) == null;
}

#

if (isNull) return true;

flint coyote
onyx fjord
#

Why not accept argument as the argument

#

@wary topaz

wary topaz
#

you could do that too

wary topaz
#

im just giving an example

hybrid spoke
#

you are not funky enough anymore

wet breach
hybrid spoke
#

what even is the problem

#

and what are the brought solutions

wet breach
onyx fjord
wet breach
flint coyote
#

@lethal coral

private Player getTarget(Player player, String[] args) {
  if(args.length == 0) return player;
  Player target = Bukkit.getPlayer(args[0]);
  if(target == null) {
    player.sendMessage(miniMessage.deserialize("<red>The referenced player was not found."));
  }
  return target;
}

Something along those lines should do the job. Just don't forget the null check when you call it.

wet breach
#

Their other issue is when doing so how to handle errors or other problems with said abstracted code

lethal coral
#

I didn't need that but thank you

wary topaz
#

I do not know why

lethal coral
#

🚎

wary topaz
#

public void saveConfig(FileConfiguration config, String configName) { try { config.save(new File(plugin.getDataFolder(), configName)); } catch (IOException e) { logError("Error while saving config,", e); } } If you want to know

flint coyote
hybrid spoke
lethal coral
flint coyote
#

Or did I not sleep enough? lol

onyx fjord
#

Haha lmfao

#

😂😂😂😂😂

hybrid spoke
lethal coral
hybrid spoke
onyx fjord
#

🐗 hihiha

wary topaz
#

fixed

hybrid spoke
#

YOU ACTIVATED MY TRAP CARD 🚙

flint coyote
#

I'm confused

onyx fjord
#

GG

wet breach
lethal coral
#

and it makes no sense so ha funny

onyx fjord
#

🧌

#

Check this one out

wary topaz
#

02:26:02] [Server thread/WARN]: java.io.FileNotFoundException: plugins\BetterServer\playerdata\homes (Access is denied)

but the file is there

lethal coral
#

bad troll emoji

flint coyote
#

Now I'm speechless

onyx fjord
#

Did you know GitHub has a real trollface

wet breach
wary topaz
#

might be spelling

flint coyote
onyx fjord
#

Tf is that path

flint coyote
wary topaz
#

public void saveConfig(FileConfiguration config, String configName) { try { config.save(new File(plugin.getDataFolder(), configName)); } catch (IOException e) { e.printStackTrace(); } }

this is the file saver

wet breach
wary topaz
#

plugin.getFileApi().saveConfig(getConfig(player, plugin), "/playerdata/homes");

this is how I called it

hybrid spoke
onyx fjord
#

That path looks absolute

wet breach
flint coyote
#

I only ever use optionals because streams provide them on findFirst() to which I just go with orElse(null) to create fancy one-liners that probably everyone will hate when seeing them.

wet breach
#

Lol

hybrid spoke
#

optionals are cool and all but also very annoying if overused

#

but once you design your shit optional based its over

glossy venture
#
.map(value -> /* ... */)
.orElse(default);
``` is pretty nice tho
tardy delta
#

Optional.None when

glossy venture
#

Optional.empty()?

tardy delta
#

Cant afford An if check at Runtime 💀

hybrid spoke
#

Optional != null

wet breach
# lethal coral I didn't need that but thank you

I hope this was a good learning experience in that sometimes the issue is your understanding and not necessarily the code. Which i hope helps you to better convey problems in the future and to not assume when others are asking questions its not due to lack of experience but rather trying to grasp what is really the problem. As you seen for someone like me, it can be hard to convey the solution if i dont know your level of understanding and knowledge and inadvertently tell you things that seem impossible or make no sense

tardy delta
#

Those icons back?

wet breach
#

Thought i should put that out there

flint coyote
#
             currentField = actionFields.stream()
                     .filter(field -> {
                         String configKey = field.getAnnotation(ConfigurableValue.class).configKey();
                         if (configKey.isBlank()) {
                             configKey = field.getName();
                         }
                         return configKey.equals(fieldName);
                     })
                     .findFirst()
                     .orElse(null);
            if (currentField == null) {
                continue;
            }

The more I code the more I use streams and the less readable the code gets :(

lethal coral
#

if it was the compiler's fault I wouldn't have come here

hybrid spoke
#

thats my role

lethal coral
#

and I also didn't say you lacked experience which is why I told you to give me an example so we could bridge the gap between what you were saying

wet breach
#

Well regardless i hope you learned something nonetheless

wet breach
echo basalt
wet breach
# lethal coral and I also didn't say you lacked experience which is why I told you to give me a...

While true you did end up saying this, the other issue is i couldnt provide you with an example in more ways then one. The major one was me failing to grasp the level of understanding you had or your experience level. And also could be that i typically dont spoonfeed code more so if i dont know if you would understand it. But yeah seems like you are getting the proper help now. And with that i have some work to do

#

So sorry i couldnt do that

#

And i need to learn to not be so abstract as well it seems

hybrid spoke
#

signal writing a novel rn

wet breach
#

Ok signal here is killling me

#

Been waiting for their message lmao

hybrid spoke
wet breach
flint coyote
#

Seeing you reflecting yourself like that hurts my feelings frostalf. What you did or suggested wasn't bad at all. Sure he wasn't quite understanding what you said but that's neither yours nor his fault. You suggested what came to your mind based on your knowledge. He could have asked for a simpler solution - he chose to try to understand what you suggested. You both did a great job and none of you should feel bad at this point ♥️

echo basalt
#

y'all both having a mental breakdown over misjudging someone

hybrid spoke
elfin pilot
#

Optimization question. I have a large set of data used for a wide variety of items, mechanics, and dialogue ingame (stat blocks, requirement lists, that sort of thing.) Sadly, the data can't be hard-coded, I can explain more if needed, but I retrieve it from an SQL server using a String object, but I'm puzzling over what to do next.
My question is, which is better: to deserialize into one giant JsonObject that we can pull from? Or separate into multiple smaller, different JsonObjects?
Assume the data is going to be accessed at random by different players and game elements (we might need to reference a stat-block when spawning a mob, for example.) Which is better? Or should I be approaching this in a different way?

hybrid spoke
#

ahh there it is

elfin pilot
wet breach
hybrid spoke
#

not yet

echo basalt
hybrid spoke
echo basalt
#

Fetching one giant json object is just going to spike your RAM usage

elfin pilot
#

Perfect

#

Thank you

#

So it'd be better to create multiple smaller ones for what we need

echo basalt
#

And your CPU for processing that json

#

Correct

wet breach
# hybrid spoke not yet

I dont think i ever will but i will be poking your brain later on the looks of it being ego cause i dont see it

echo basalt
#

Same reason we use multiple individual player files when dealing with file-based storage instead of making a giant one

elfin pilot
#

Perfect. Thank you!

quaint mantle
#

Guys what plugin do you use for custom GUIs?

hybrid spoke
hybrid spoke
#

or do you mean like a lib

echo basalt
quaint mantle
#

I tried CommandPanels but i don t know how to configure it

hybrid spoke
tardy delta
flint coyote
tardy delta
#

coding facebook would just be easy :)

hybrid spoke
flint coyote
#
if(!facebook.isPresent()) {
  createFacebook();
}
tardy delta
#

facebook.orElseGet smh

hybrid spoke
#

indirectly, yes.

hybrid spoke
#

im a fan of satire if you didnt noticed yet

flint coyote
#

He provided a solution that was hard to understand but I doubt he did that to "play god". More like because he's used to solve his own problems like that.

hybrid spoke
#

i dont want to boo anyone. he asked what i see, and i told him. what he does with it is not my beer

hybrid spoke
#

therefore we have ?learnjava

#

so, ive shown enough humanity. y'all suck noobs

flint coyote
#

exactly that is the reason I'm not always motivated to help.
As long as I notice the person on the other side is trying their best and is listening to feedback instead of saying "but chatgpt said that's better" I'm willing to help.
If "you don't have enough knowledge to achieve X yet and should start with Y" makes them mad then I'm out

sour folio
#
                String coordkey = loreLine.substring(19);
                int length = pigsection.getInt(coordkey + ".length");
                long expiration = pigsection.getLong(coordkey + ".expiration") - System.currentTimeMillis();
                int amount = pigsection.getInt(coordkey + ".amount");
                long experience = pigsection.getLong(coordkey + ".experiance") - System.currentTimeMillis();

                if(e.getCurrentItem().getType() == PLAYER_HEAD) {
                    double moneytogivepercent = (((100.0 - (((double)expiration / length) * 100.0)) / 100.0));
                    if (moneytogivepercent <= 100 && moneytogivepercent > 0.005) {
                        double moneytogive = ((moneytogivepercent) * amount) * pigmake;
                        String playerName = p.getName();
                        String moneycmd = "economy give " + playerName + " " + moneytogive;
                        Bukkit.dispatchCommand(Bukkit.getConsoleSender(), moneycmd);
                        pigsection.set(coordkey + ".expiration", System.currentTimeMillis() + 14400000);

                    }else if(moneytogivepercent  < 0.005){
                        p.sendMessage(ChatColor.RED + "You need to have the GENERATOR at least 0.5% full before claiming");
                    } else {
                        double moneytogive = pigmake * amount;
                        String playerName = p.getName();
                        String moneycmd = "economy give " + playerName + " " + moneytogive;
                        Bukkit.dispatchCommand(Bukkit.getConsoleSender(), moneycmd);
                        pigsection.set(coordkey + ".expiration", System.currentTimeMillis() + 14400000);

                    }``` When the 'amount' is less tham 1,000,000 this works fine, but as soon as it goes abouve 1M it stops working, any ideas?
hybrid spoke
#

?paste please

undone axleBOT
hybrid spoke
#

never said that

#

and couldnt care less

flint coyote
#

Some people just join this discord and pretend that we are forced to help them. Nobody here has a contract or gets paid to do so. And if you are unfriendly and unable to deal with feedback then it's quite obvious that people don't like to help

half bane
#

How do I define and get maps/dictionaries in config.yml

hybrid spoke
flint coyote
flint coyote
half bane
hybrid spoke
flint coyote
#

It's a configurationSection. You can iterate it and turn it into a map. You might be able to cast it directly aswell.

wet breach
wet breach
flint coyote
# wet breach I think the issue was that they believed they understood and really didnt and th...

I only followed the last ~10-20% of that conversation. And there they said that you are probably not understanding each other which was right in this case.
Both of you probably thought the other side does not understand the problem/solution. It was a misunderstanding and that's a common thing. I really feel like both of you did nothing wrong. Besides that your solution required quite deep knowledge - which isn't always a problem.

wet breach
#

One of these days i will make educational videos

hybrid spoke
#

do spigot tutorials

lethal coral
#

is it static abuse if it's a utility class

#

🚎

flint coyote
#

Not if you also have a private constructor and therefore make it a "real" utility class that does not hold a state

echo basalt
#

.

lethal coral
#

😡

hybrid spoke
#

he's trying to be funny

echo basalt
#

when in doubt

lethal coral
#

I just forgot the private constructor

flint coyote
#

It's basically a glorified map

#

I wasn't sure about that anymore which is why I said might

tardy delta
#

reflections 🙏

lethal coral
#

shouldn't the utility class throw an exception in the private constructor

#

and in the singleton as well if it's not null

#

no I'm saying for A singleton

#

in their example code

flint coyote
#

And then we end up with the same problems as the SimpleDateFormat

echo basalt
#

I do throw it in the constructor

#

for the singleton

#

for utility class it's whatever

lethal coral
#

oh the getInstance being on top of the constructor was throwing me off

#

I'm blind

flint coyote
#

Therefore if avoidable at any cost don't make a static (especially utility) class have a state :/

#

Why would a static utility class have a usable constructor?

#

You said it doesn't have to be private

lethal coral
#

the world also doesn't need mosquitos

#

but here we are

flint coyote
#

Yeah sure but what's the point?
You could also name your classes MY_CLASS_FOR_COMMANDS because you SHOULD go with conventions

#

Oh that's not how my sentence was meant. I just wanted to be clear that there should be no state and a private constructor. Not that the private constructor makes it stateless

#

Yeah I see why

#

Also birds eat them, too

lethal coral
#

guys come on

#

mosquitos suck rocks

flint coyote
#

I still hate ticks more than mosquitos

lethal coral
#

replace em with something that doesn't suck blood and make us itch

#

😬

flint coyote
#

No open air concerts in the evening for you ig

#

🤷‍♂️ nobody asking for help atm

#

And I can't work either because I have to wait for 800 integration tests to run

hybrid spoke
flint coyote
#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

flint coyote
#

jk

undone axleBOT
#

antm#7677 definitely regrets to for the most part inform you that unfortunately, they essentially are unable to definitely assist with definitely your enquiry, which essentially is fairly significant. Please simply really ask again later or possibly kind of ask someone else about this enquiry, demonstrating that the person that ran this command generally regrets to kind of inform you that unfortunately, they for the most part are unable to generally assist with actually your enquiry in a subtle way. Thank you very sort of much for kind of your time and the person that ran this command specifically wishes you a really good day, so the person that ran this command really regrets to actually inform you that unfortunately, they literally are unable to definitely assist with very your enquiry, or so they particularly thought.

flint coyote
#

To get this back to something programming related:
Do you guys actually write unit/integration tests for your plugins? I can't be the only lazy one

tardy delta
#

nah

hybrid spoke
#

never

#

let your customers test it

tardy delta
#

i just fix it if smth doesnt seem to work 💀

flint coyote
#

Not even my biggest plugins have a single test

tardy delta
#

no tests needed

hybrid spoke
#

wouldnt test spigot logic anyways

tardy delta
#

imagine finding spigot bugs while testing

flint coyote
#

sounds like what I would get when I asked chatgpt to write the most unreadable explanation of a simple term

flint coyote
tardy delta
#

facts

#

i let chatgpt write half of my testcases

flint coyote
#

Tests make sense when multiple people work on a single project and there's no "single-point-of-truth" as in someone who's fully aware of all code reviewing everything

hybrid spoke
undone axleBOT
#

Luzifer#0666 definitely regrets to for the most part inform you that unfortunately, they essentially are unable to definitely assist with definitely your enquiry, which essentially is fairly significant. Please simply really ask again later or possibly kind of ask someone else about this enquiry, demonstrating that the person that ran this command generally regrets to kind of inform you that unfortunately, they for the most part are unable to generally assist with actually your enquiry in a subtle way. Thank you very sort of much for kind of your time and the person that ran this command specifically wishes you a really good day, so the person that ran this command really regrets to actually inform you that unfortunately, they literally are unable to definitely assist with very your enquiry, or so they particularly thought.

flint coyote
#

Wait you are God and the Devil at the same time

#

That's confusing

hybrid spoke
#

thats mythology

tardy delta
#

god luzifer

hybrid spoke
#

im the better ending of the series lucifer

flint coyote
#

Lucifer was decent

#

Also may I suggest we move to #general for more offtopic?

sour folio
hybrid spoke
#

already told you to elaborate more since we dont know what you are trying to do

flint coyote
tardy delta
#

more like devil

hybrid spoke
sour folio
#

I didnt know abt that when i started making the plugin

flint coyote
# hybrid spoke sin

My only sin is using way to long stream.filter expressions to push things into one line

#

well I still split the line. But one expression

agile anvil
#

Streams are so sexy we have to admit

flint coyote
agile anvil
#

Yeah, there is a limit 🤣

flint coyote
#

I told you that's my sin 😅

tardy delta
#

join rust where streams compile to the same machinecode as normal loops

native ruin
#

i am using an example i found online to change the metadata of a player (using protcollib )


            ProtocolManager pm = ProtocolLibrary.getProtocolManager();
            PacketContainer packet = pm.createPacket(PacketType.Play.Server.ENTITY_METADATA);
            packet.getIntegers().write(0, player.getEntityId());
            WrappedDataWatcher watcher = new WrappedDataWatcher();
            WrappedDataWatcher.Serializer serializer = WrappedDataWatcher.Registry.get(Byte.class); 
            watcher.setEntity(player);
            watcher.setObject(0, serializer, (byte) (0x40)); 
            packet.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects());
            pm.broadcastServerPacket(packet);

when executing i am getting kicked from the server and get this errormessage in the console
class net.minecraft.network.syncher.DataWatcher$Item cannot be cast to class net.minecraft.network.syncher.DataWatcher$b
i assume this has something to do with the serializer, but don't know

#

wdym?

#

how do i use a datacontainer here

echo basalt
#

do you not know what entity metadata is

#

well

#

you do not

native ruin
#

i think this example makes the player glow
but i won't be using it for storage

echo basalt
#

By entity metadata I'm not talking about bukkit's shitty metadata api

#

entity metadata in nms is like

#

All the data that the server needs to communicate to the client such as like

native ruin
#

maybe i should have made that clearer mb

echo basalt
#

how much health, if it is on fire, what items it has equiped

echo basalt
wet breach
echo basalt
#

Here zacken

#

That's entity metadata in the context of packets and nms

tardy delta
echo basalt
#

updating protocollib

#

Just to be sure

native ruin
echo basalt
#

5.1.0 is in snapshot

native ruin
#

can i just change the verison in pom and reload it?

echo basalt
#

No, it's what's on the server that matters

native ruin
#

ok server got it

echo basalt
#

why the fuck would you shade protocollib

#

🤦

flint coyote
#

😅

echo basalt
#

I don't want to sound like a moron but there's still some learning for you to do

#

And don't worry we're all going through this at one stage

wet breach
#

You cant shade protocollib as it wont work properly even if you relocate. Its one of few plugins/libs that simply cant be and will run into a lot of problems if you do

flint coyote
#

he never said he is shading it though. He might just have scope provided

echo basalt
#

There was like a time period back in 2020 where I stopped everything I was doing to fuck around with packets

native ruin
#

where can i find the snapshot versions? i can only find the 5.0.0

wet breach
#

Dont be rude now

echo basalt
#

Just go with the latest dev build

#

I honestly don't remember where I saw 5.1.0

#

Not always the case, ProtocolLib doesn't change much across versions

#

It's way too popular to afford splitting its community

wet breach
echo basalt
#

That's protocollib's job to handle, updating the pom won't change how you're writing data into the container

#

If you were using the packet wrappers, sure

#

But plib just wraps stuff and updating the pom on your plugin won't change how it serializes stuff

#

this is a stupid argument

wet breach
echo basalt
#

And it won't for a good time

wet breach
#

If it does lots of people would be coming here to complain too 😂

echo basalt
#

Because the only way that changing the pom would actually change how the underlying code would work is if you were shading it

native ruin
#

how can i specify the 645 build in the pom?

echo basalt
#

You don't need to

wet breach
#

They do when it id necessary because the protocol somehwhere changed that forced it

#

But most of the time this isnt the case

native ruin
#

then changing the versions didn't help, even deleted the protocollib server folder

echo basalt
#

They change versions when the protocol changes, meaning they need to add new wrappers and more reflection

#

jfc it's disappointing we still arguing over something this minor

#

I'm gonna look for a solution, y'all 2 can bicker

#

fml

native ruin
#

so anyone an idea on how the error occurs and maybe knows a solution?

native ruin
#

19.4

wet breach
#

I dont really see the issue other then potentially building against a version that isnt for whatever mc version

echo basalt
#

only thing I can think of

#

which I did on my packet wrapper

#

was like

#

boxing primitives

#

but I'm pretty sure that's just with getting the serializer rather than actually writing the data

#

okay yeah I can replicate

native ruin
#

hmm i got no idea how to continue this so i am willing to try everything at this point

#

the code is a few years old so i assume something has changed over time

echo basalt
#

yeah they changed something

#

I think protocollib genuinely broke this packet

#

think this packet uses WrappedDataWatcherObject now

#

@native ruin Found a solution!

native ruin
#

fr?

echo basalt
#

had to investigate some github issues back from december

#

but this works

native ruin
#

yooooooo

#

amazing ty

tardy delta
#

isnt Player#setGlowing a thing?

flint coyote
#

Since Player is an Entity, yes

quiet ice
#

Though the issue most likely is that it does not work on a per-player basis