#help-development

1 messages Β· Page 2151 of 1

urban kernel
#

i cant even use System.out.println

ivory sleet
#

yeah

tardy delta
#

show error

ivory sleet
#

needs to be within a scope

tardy delta
#

i wanted to say that >_<

urban kernel
ivory sleet
#

your ide isnt broken

#

you just cant put System.out.println() everywhere

urban kernel
#

...

ivory sleet
#

or well at least not where you put it, so where did you put it?

urban kernel
#

package me.deveroonie.discord.commands/Discord.java (class)

ivory sleet
#

no

#

which line

#

share the class

#

?paste

undone axleBOT
tardy delta
#

just drop a screen lol

urban kernel
#
package me.deveroonie.discord.commands;

import org.bukkit.configuration.file.FileConfiguration;


public class Discord {
    private final FileConfiguration config;

    public Discord(FileConfiguration config) {
        this.config = config;
    }


    System.out.println(config.getString("discordLink"));
}
ivory sleet
#

yeah exactly

#

in this case you might just wanna move the sysout to inside the constructor scope

urban kernel
#

dont give a shit about the sysout

#

it'll be removed anyway

eternal oxide
#

that code will not even compile

urban kernel
#
package me.deveroonie.discord.commands;

import org.bukkit.configuration.file.FileConfiguration;


public class Discord {
    private final FileConfiguration config;

    public Discord(FileConfiguration config) {
        System.out.println(config.getString("discordLink"));
        this.config = config;
    }

    
}
#

this looks like it will work, it isnt throwing dreaded red line

ivory sleet
#

under the this.config = config;

urban kernel
kindred valley
#
else if(customRes.length() == 7) {
                if (Character.isDigit(customRes.charAt(0)) && Character.isDigit(customRes.charAt(1))&& Character.isDigit(customRes.charAt(2))) {
                    if(customRes.charAt(3) == 'x') {
                        if(Character.isDigit(customRes.charAt(4)) && Character.isDigit(customRes.charAt(5)) && Character.isDigit(customRes.charAt(6))) {
                            System.out.println(customRes);
                            break;
                        }
                    }
                }
                break;
            ```πŸ₯΄
tardy delta
#

aaaa

#

use a for loop

eternal oxide
tardy delta
#

isnt it gettin the config passed as parameter?

urban kernel
#
package me.deveroonie.discord.commands;

import org.bukkit.configuration.file.FileConfiguration;


public class Discord {
    private final FileConfiguration config;

    public Discord(FileConfiguration config) {
       
        this.config = config;
        System.out.println(config.getString("discordLink"));
    }


}
tardy delta
#

yes

sacred prairie
#

are you able to teleport an armorstand while someone is riding it with stand.teleport(loc);

fringe frost
#

Guys, I need to do a votifier plugin. But i dont know how they (server lists) send the data. Do anyone know?

urban kernel
#

have a server list send data to a test server ig

tardy delta
#

what does ig mean

urban kernel
#

i guess

sacred prairie
#

is there any other way to set the posistion of this armorstand, or should i just use an other mob instead

flint coyote
#

You can't teleport entities with passengers. But you can dismount the passenger, tp both and remount

#

or you move it with velocity

small current
#

guys if i send a forward message through bungee messaging channel to ALL server
will it be sent to the sender too ?

ornate heart
#

I've got a skull head item stack with custom texture.

How would I place that down instead of creating an item?

kindred valley
#

?paste

undone axleBOT
restive tangle
#

Is there a pair data type in Java? I made an enchantItem() method which takes (ItemStack, EnchantData...) where EnchantData is a data class I made specifically for storing the Enchantment and an integer value

crimson terrace
#

you mean a HashMap or something of the likes?

lusty cipher
#

Does Files.move block until the file is properly moved?

#

Every second time one of my files is deleted when I try swapping them

#
                    Files.move(backupFile.toPath(), temporarySwapFile.toPath());
                    Files.move(nbtFile.getFile().toPath(), backupFile.toPath());
                    Files.move(temporarySwapFile.toPath(), nbtFile.getFile().toPath());
quaint mantle
#

how can i spawn a silverfish and make them only have one target that they are able to hit?

crimson terrace
#

if you dont wanna use nms I suggest using the EntityTargetEvent

#

and cancel the event for any targets except the one you wanna allow

quaint mantle
#

thanks

#

but i'm making an ability so it spawns like a few silverfish and multiple players can use the ability at once, soo how is that gonna work

crimson terrace
#

edit each silverfish on their PDC. maybe make a namespacedKey which has the players UUID in string form

#

and then you can check that data and decide whether you want it to be targeted

eternal oxide
#

you put the ownign players UUID into the entities PDC. Then in any target event you check for an owning player and cancel if its the owner

quaint mantle
#

what is PDC

eternal oxide
#

?pdc

noble forge
#

Is it possible to force a blockstate client-side? I am currently trying to force the distance blockstate on leaves without any luck

restive tangle
crimson terrace
#

do a forEach

#

and pass in a list of EnchantData

#

alternatively to get closer to what you want, pass in an array and you can put the EnchantData objects into {} as a parameter I believe

restive tangle
#

I already do that, I'm asking if there is a better way

crimson terrace
#

is it not good enough?

#

you could do it with a stream but its unnecessary in this case imo

restive tangle
#

It's alright, just thought it was weird to create a class for a pair

noble forge
#

weird how java doesnt have a builtin tuple type or pair type

restive tangle
#

True

crimson terrace
#

records are the closest thing we have to that atm i believe

noble forge
#

eh

#

those are more like structs I would say tho

quaint mantle
#

how do i get the X amount of stone in a player's inv

crimson terrace
#

how you get the amount of stone a player has in their inv?

quaint mantle
#

ye

crimson terrace
#

loop through the inventory and add all the amounts of itemStacks which are stone together

quaint mantle
#

if i have an event and i have multiple if statements in it, if i add return; at the first one, it won't go through the rest?

rotund pond
#

Hello !
I'm looking for an event where an entity die, so I can get the entity and the killer ...
What's the event ? I'm using the EntityDeathEvent but I can't get the killer 😦

crimson terrace
#

if a return is called the method is basically cancelled

rotund pond
#

NVM, i'm dumb

crimson terrace
#

it works

rotund pond
#

Yeah, I though it was something like event.getKiller but it was event.getEntity().getKiller() xd

crimson terrace
#

just be aware that the killer may not exist if the entity was not damaged by any players

rotund pond
#

What if a snowman kills a zombie so ?

#

(That's an example)

crimson terrace
#

if the entity which dies was never damaged by a player the Killer will be null I believe

rotund pond
#

Okay I see, ty

humble tulip
#

maybe listen to entitydamangebyentityevent

rotund pond
#

ty guys

humble tulip
#

check if the damage will kill the entity and make sure its not cancelled

#

probably have your priority at highest

rotund pond
humble tulip
#

highest

#

lowest is run first

rotund pond
#

Ah yes mb

humble tulip
#

EntityDamageByEntityEvent you mean?

rotund pond
#

Actually I can use EntityDeathEvent, it's all good to me because I need a Player killer ^^
I was just curious, but ty

crimson terrace
#

the Killer is always set to the Player who last hit the entity. If it dies by a block or falldamage the killer is still that player that hit it down the cliff or so

#

in case that helps

rotund pond
#

Ty πŸ‘

rustic pewter
#

Hi, I have a question. I am a complete newbie to minecraft plugin development and fairly new to Java. I have followed a few lessons. I followed a tutorial for event-listeners but it wont recognise. See screenshot: https://imgur.com/a/Ragvwgz

noble forge
#

I dont think thats really how you make a listener

#

Usually you would make a separate class that implements the listener interface along with an eventhandler method

eternal oxide
#

Listener

toxic phoenix
#

try typing capital L

noble forge
#

its really bad practice to do it in the main class tho no?

eternal oxide
#

depends on teh size of the plugin

rustic pewter
#

Oh I dont know. The capital L did work Thanks!

#

I am just trying it out. πŸ™‚

rustic pewter
#

Another problem πŸ™ƒ I am getting this: [20:20:26 WARN]: Nag author(s): '[Ruubbie]' of 'BestPluginEverMade' about their usage of System.out/err.print. Please use your plugin's logger instead (JavaPlugin#getLogger). error when running this: ```@EventHandler
public void onPlayerJoin(){

    Bukkit.broadcastMessage("A player joined the server welcome them!");

}``` piece of code.
civic dagger
#

so how can i get the entity that damaged other entity in EntityDamageEvent? i found ENTITY_ATTACK and ENTITY_SWEEP_ATTACK and some other damage causes that i want to keep track of but idk how to get the entity that actually damaged them

noble forge
rustic pewter
#

Oh, thats also verry possible.

#

Then my broadcast doesnt work

civic dagger
#

lmao i just had to look for other similar events...
thanks :D

noble forge
#

use getDamager() to get the attacker

vestal dome
#

is there a way to set the color of a wool, on bukkit?

#

(1.7 btw πŸ˜‚)

#

u forgor?

#

1.7

#

not 1.17

eternal oxide
#

Wool color in 1.7 is the data/damage value

noble forge
#

before 1.13 color was a blockstate

vestal dome
#

(on 1.8+)

vestal dome
#

dunno

eternal oxide
#

line 46 onwards either delay 1 tick using the scheduler, or cancel the click event

stray flare
quaint mantle
undone axleBOT
quaint mantle
#

ucant find a find the fix as i cant see no errors anywhere

eternal oxide
#

constructor should be public

vestal dome
#

or

#

protected if on the same package.

stray flare
eternal oxide
#

thats all, just pass your instance when you create teh listener

#

new Summon(this)

stray flare
#

The constructor Summon() is undefined

eternal oxide
#

summon(this)

stray flare
#

` @Override
public void onEnable(){

    getServer().getPluginManager().registerEvents(new Summon(), this);
    new Summon(this);
}

@Override
public void onDisable(){
    
}

}`

dusk flicker
#

please for the love of god use three of `

stray flare
eternal oxide
#

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

stray flare
#

Works perfect. thank you very much @eternal oxide

ancient plank
dusk flicker
#

good idea

#

lmao

rough drift
#

How can you create a Content object? net.md_5.bungee.api.chat.hover.content.Content

tardy delta
#

imagine not escaping your emotes

#

\πŸ˜‚

opal juniper
#

spigot

#

no need for unecessary abstraction

rotund ravine
#

That’s not spigot

#

Newer versions of the API has more utilities

#

You’re using 1.8 yah?

tardy delta
#

?pdc

tardy delta
#

aight

rotund pond
#

Hey !

Is there an easy way to check if a block mined is a crop ?
I mean, another thing than

Material blockMaterial = event.getBlock().getType();

if(blockMaterial == Material.CARROT || ...)
  return;
#

Just change his drop on death

#

What's the question exactly ?

golden turret
#

if i create a listener and a class that extends it, will the listeners from the parent be registered too?

noble forge
#

How can I prevent a block from ticking?

#

I want to prevent the pp update of leaves

tall dragon
#

you want to stop the decay?

noble forge
#

leaves calculate and update their blockstate distance to the nearest log

#

I want to prevent them from updating their blockstate distance

tall dragon
#

because?

noble forge
#

because I want to use them for custom (translucent) blocks

tall dragon
#

so you want to stop them decaying then.

noble forge
#

no

#

distance is in a range of 1-7

#

you can assign a custom model to each blockstate

tall dragon
#

ah

#

i see where ur going with that

noble forge
#

if I reimplement the decay logic with a plugin and use 1 blockstate I free up 6

#

however

#

when I set the blockstate it just returns back to its original value rn

tall dragon
#

im not rlly aware of a way to stop blocks from ticking

noble forge
#

I couldnt really find anything on the forums either

tall dragon
#

you could look into BlockPhysicsEvent but im not sure you can use that eiher in the way you want.

noble forge
#

im not sure if that fires tho

tall dragon
#

yh no idea either

noble forge
#

I will test

#

At least u have given me a path to go onto

#

thank you

tall dragon
#

?stash

undone axleBOT
tall dragon
# noble forge I will test

else you might benefit from just looking into mc code how they are being ticked & see if its possible to do somethn with reflection.

noble forge
#

yeah that was my 2nd idea

#

I already downloaded the build tools

#

but lets hope this works first

#

thank u either way!

tall dragon
#

πŸ‘

noble forge
# tall dragon πŸ‘

It seems I may have struck gold as my pc is burning down and my terminal is filling up with numbers I'd like to see

sacred prairie
#

How do i teleport/move an armor stands wich has a passanger?

noble forge
#

catching the event worked

#

thank you again!

rotund pond
noble forge
#

what I did for leaves was just have a set of all the leaf types and check if the current material was inside of that set

rotund pond
#

Oh I didn't know about this block data, ty

civic dagger
#

why EntityInteractEvent is not triggering? i tried player interact event and it worked perfectly now i just replaced it with entity and its not even triggering

#

or is it for something else?

#

no

#

trigger a event when a skeleton tries to shoot with a bow

#

or similar things

#

this works for players

#

also not when shoots

#

when tries to shoot

#

in another saying i want to block it

potent quest
#

other than the standard block place/break/destroy & player interact events, is there any other events i should listen for and run location based checks for an antigrief?

noble forge
#

what would be the best way to change the blocktype of newly generated trees? Preferably I want to add on logic/code when a tree is generating its leaves. Would anyone know to point me in the right direction please?

tall dragon
#

when it comes to trees being generated from sapplings. you can use StructureGrowEvent

noble forge
#

oo I see

#

and is there any more performant way of setting blocks other than setType?

tall dragon
#

if that doesnt help. you can also make a custom tree generator i believe

noble forge
#

I see

noble forge
#

thank you. I will check if using this event is performant enough for me and otherwise will use custom tree gen

tall dragon
noble forge
#

thank you will take a look

#

I am processing multiple chunks and setting blocks in each of those most of the time and I was wondering if doing it multithreaded would improve anything?

tall dragon
#

uh u can only change blocks from the main thread tho

#

you could probably divide the load tho. and proccess over time.

noble forge
#

oo

#

so instead of multithreaded, async?

pulsar vessel
#

can any devs volenteer to help me with this problem
i need it fixed quick
pls dm me

glass mauve
#

dontasktoask

tall dragon
noble forge
#

oo I see

tall dragon
#

thats how i make big block operations lagg free at least

noble forge
#

wait so how does async work then?

tall dragon
#

u cant change blocks async

noble forge
#

I mean doing the processing part

unkempt peak
pulsar vessel
#

dm

noble forge
#

I was thinking perhaps I could process it all async and then add to a queue and then on main thread go through the queue

unkempt peak
noble forge
#

or would that be worse for performance?

glass mauve
tall dragon
# noble forge I was thinking perhaps I could process it all async and then add to a queue and ...
noble forge
#

thank you! Youve probably noticed already but im a bit inexperienced πŸ˜…

tall dragon
#

@lost matrix im pluggin ur stuff cPES_Wink

chrome beacon
noble forge
#

:)

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!

quaint mantle
#

Why doesn't this just update the team prefix value ?

lost matrix
quaint mantle
#

there were more

#

but i cleaned it

#

good that u mentioned it

#

The thing is, it sets it when a player join, but then, doesn't change it.

lost matrix
quaint mantle
#

Yeap.

#

no idea why it doesn't work

shut field
#

I still have no clue what to do

lost matrix
lost matrix
shut field
wary harness
#

anyone could tell me is this bad approach

shut field
#

so I think that I need to import smth, using maven or depending on it? and even after reading this I still don't know how to

last sleet
#

Is serializing data (like custom enchantments) into PDC's with, strings, for example better or should I make a plugin file that records item stacks and associates enchantments with them

waxen plinth
wary harness
#

so I need some spacing

vale cradle
#

and help other ones read yours more comfortable ;P

vale cradle
wary harness
#

So I am spawning mobs with PDC from custom spawner.
Now question is about performance is it good idea to check does entity has specific PDC key on every single damage event?

#

Other idea would be to add UUID of entities to HashSet

#

on there spawn

vale cradle
#

If you're already using PDC why don't keep using it then?

wary harness
eternal night
#

I mean PDC is rather close to a plain hashmap

vale cradle
#

I actually don't know how different the PDC API is compared to the NBTApi, but I don't think there would be hardly any noticeable different so you're probably fine with either

eternal night
#

you have a bit of overhead

wary harness
vale cradle
#

One is a HashMap the other one is Reflection based and I believe it has to constantly parse the NBT string back and forth

eternal night
#

^^ PDC basically converts to nbt when you call set

#

no IO or anything but object conversion

vale cradle
#

They're basically the same, I'd say one has a higher Memory footprint while the other one is more CPU intensive

#

I think you're fine with either tbh

wary harness
#

Thanks for info

vale cradle
#

If you see any lag, I don't think it's related to using PDC API or NBTApi, imo ;P

tepid ore
#

How do I make a pattern that has a certain start and end string but unknown mids? Like this <<Hello>> and <<Something>> are valid as they start with << and end with >>

tepid ore
#

Yeah

#

I know you can do this [a-fA-F0-9]{6} but I have no clue of how to set the characters to an unknown amount

vale cradle
#

<<(\w+)>>

vale cradle
tepid ore
#

Omg I'm stupid, I tried googling it but for some unknown reason my brain thought a matcher and a pattern is the same. Which I know they are not lol

tepid ore
vale cradle
#

you can always go to a regex tester, they are very helpful

tepid ore
#

That is very helpful indeed, thanks!

tepid ore
#

Thanks πŸ™‚ I think Imma stick with <<(\w+)>> tho, as it's easier to read imo :>

waxen plinth
#

They are different

vale cradle
#

^^

#

the other one takes all of the characters, including whitespaces

waxen plinth
#

That one will only match alphanumeric characters + underscore

#

Mine accepts all characters

waxen plinth
#

Mine also will only work if the << is at the beginning of the string and the >> is at the end

vale cradle
#

I also just realize you used from a to f

tepid ore
#

Doesn't <<(\w+)>> require << and >> at the start and end tho?

waxen plinth
#

It will match anything surrounded by those

#

So abc <<something>> def would match

#

But only the middle part there

#

If you want it to have to be the entire string you need ^$

tepid ore
#

Ahh, I see. I only use it for placeholder-ish type of stuff. So it should be allowed anywhere in a string

waxen plinth
#

Alright

tepid ore
#

Really good to know though

humble tulip
#

https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/#forward
I am reading through this wiki page, specifically the Forward section. I want to know if i NEED to specify a subchannel. I would like my plugin to communicate with other servers with the same "server name" which is set in the config. so i registered the outgoing and incoming channels as pluginname_servername. I feel as though this is better than just registering the channel as pluginname and having a subchannel for servername as messages will only be sent where they need to go to

#

thoughts^?

ivory sleet
#

I mean it’s probably for the best if you write a sub channel

#

Assuming you use the default channel

#

Else it’s pretty much not needed

humble tulip
#

" so i registered the outgoing and incoming channels as pluginname_servername"

#

i registered my own channel

ivory sleet
#

Yeah you probably don’t need a specific sub channel, but like it’s convenient for let’s say format identification

lethal python
#

i saw someone on a forum say they could send players custom notifications using the tip gui, like the one which tells you you have new crafting recipes i think

#

how do you do that with spigot, i couldn't find anything in the docs

#

Here is the post where someone declares they can send notifications using the tips window, but they don't provide any proof of it

ivory flume
#

What's good practice when saving an inventory to a database like mysql

#

whats a good way to do it

wet breach
#

you could serialize it and then store it as a blob

#

how you choose to serialize is up to you, I recommend just serializing to binary though

#

then you can just unserialize easily

crisp steeple
#

yeah, only minor problem is that it makes a web api for viewing inventories pretty much impossible

#

its surprisingly difficult to serialize any other way though besides yml (or binary), which yml isnt really supported to save to sql

crisp steeple
#

how?

#

i wasnt able to find any good way of doing it

humble tulip
#

I'm having a problem with plugin messaging. I've set it up as shown in the Wiki but it doesnt seem to work.

wet breach
#

because php is capable of deserializing the information? just because you use a different language doesn't mean you can't deserialize the same way you serialized

humble tulip
#

omg

#

i wanna put a new line

crisp steeple
wet breach
#

wasn't talking about using bukkit methods to serialize

#

but you can implement the bukkit method into php easily though

crisp steeple
#

well i was using java

#

i was storing it in a database as binary with bukkitobjectoutputstream, tried using json but it wasnt able to deserialze on the server

#

im not too sure what other way to deserialize a bukkitobjectoutputstream would be, seeing as it uses methods that require a minecraft server being run

humble tulip
crisp steeple
#

it uses configurationserializable, the problem is will deserialize it to an item, and making an itemstack without a server running causes many issues

wet breach
#

especially the way I am talking about

crisp steeple
#

which way are you talking about?

#

im not sure what other way there would be to serialize to binary without using object output streams

wet breach
#

don't serialize the object

#

just serialize the data

crisp steeple
#

?

#

its very difficult to serialize the data of an item

dusk flicker
#

not really

crisp steeple
#

what way do you have?

dusk flicker
#

most of them are strings, just pass it through json

#

it will take time to do it manually but not that much time

crisp steeple
#

but theres item nbt as well

dusk flicker
#

well how is that stored

#

"having data" isnt the issue, its how its stored

crisp steeple
#

its stored in a json-like format, but using something like gson doesnt work for storing the nbt tag

dusk flicker
#

you can EASILY put data from Java to json or other stuff

crisp steeple
#

ik

#

i tried serializing the nbt of an item to json, however youll get problems when you try to deserialize it because it doesnt know the type of the nbt compound

dusk flicker
#

I feel like you are spending more times making excuses on why it wont work rather than figuring out how it will work

crisp steeple
#

spent a couple hours working on it over here πŸ™ƒ

#

you can read through the messages if you want more detail on the things i tried

#

still never resolved the issue, finding a solution would be great

round agate
#

make a custom deserializer

wet breach
#

I think there is php libs already for NBT

round agate
#

Is this what you want deotime?

crisp steeple
#

first of all, im not using php for anything

round agate
#
class MyItemStackDeserializer implements JsonDeserializer<ItemStack>
{
  // ...
}
crisp steeple
#

secondly, the problem wasnt making the itemstack, it was deserializing it again on the server

crisp steeple
round agate
#

maybe look at some nbt open source library, then work your way there.

crisp steeple
#

i looked through a few

round agate
#

I mean

crisp steeple
#

like i said, the main problem wasnt serializing and deserializing the item

round agate
#

if you're using CraftItemStack.asNMSCopy(item), why not use the nms directly?

crisp steeple
#

it was making it compatable with a web api

humble tulip
#

What problem do you have making it compatible?

wet breach
crisp steeple
#

*web api

#

i used java spring for it, not php

wet breach
#

therefore there is no issues then

crisp steeple
#

...

wet breach
crisp steeple
#

look

#

reading the nbt is not a problem

#

i do that just fine by serializing the item to binary

round agate
#

can you show us what's your itemstack json structure file looks like?

crisp steeple
#

sure

#

ill find an item somewhere one sec

wet breach
#

somewhere you are having an issue that none of us experience

crisp steeple
#

i sort of think we are one two different pages here

wet breach
#

I have serialized MC data before and have displayed it on the web without issues as well as transferred that data to other applications

crisp steeple
#

great, could i ask how?

wet breach
#

the method in how you serialize your data is what is important. You have multiple ways of doing it to include using base64

#

which base64 works the same regardless of application or it is suppose to anyways

crisp steeple
#

yea, used base64

#

but the problem is just getting it into a json format

wet breach
#

if its serialized to base64 then all you have is just a string

#

but it depends on how you decided to serialize everything, whether you serialized it all together as well as if you took out the info you actually needed

crisp steeple
wet breach
#

not sure why you are using NMS for this

crisp steeple
#

im not?

#

it was just something i tried

wet breach
#

you might not be able to deserialize back directly into an item

#

instead you might have to manually create the item again using the data you have

quaint mantle
wet breach
#

so you would deserialize the data and then go through the data reconstructing the item using the API methods

crisp steeple
#

here is the current code i have right now: https://paste.md-5.net/heyesocufe.java
this works fine for saving items in a database, and loading them back again when neccessary. however, its not possible to deserialize this on a server (the api) that does not have essential things setup such as the itemfactory

wet breach
#

plugging in as you go the pieces of the data

#

yeah because you keep using bukkit object output

#

after I told you not to

#

if you don't know how to make your own serialization methods, then this is probably beyond your abilities to make

crisp steeple
#

i know perfectly well how to serialize things

#

its just that it is not able to properly serialze the nbt without causing a multitude of issues

wet breach
#

it is, because almost everyone here has done it

humble tulip
#

This is in my main class.

        Bukkit.getMessenger().registerOutgoingPluginChannel(this, this.channelName);
        Bukkit.getMessenger().registerIncomingPluginChannel(this, this.channelName, this.playerManager);

https://paste.md-5.net/uhedofokat.java
In my PlayerManagerClass

I call sendMessage on playerinteract event to debug

#

I have 2 servers on bungee, server and lobby with one player online in each. I see "Sending plugin message" on the server that's sending but nothing on the server that's supposed to receive it

humble tulip
#

o

#

my bad

#

?paste

undone axleBOT
humble tulip
#

editted it

crisp steeple
wet breach
round agate
#

I don't know deotime.
But here is what I'm thinking, I think you're trying to make your code as elegant as possible.
If you're serialize thing your way.
Then you have to deserialize it your way too.
Including deserialize NBT in your way. I don't think you can expect NBT to work as you like

wet breach
#

hence why I linked JNBT, allows writing and reading NBT data without needing NMS

#

that is called implementing

golden turret
#

why nit use BukkitObjectOutputStream?

wet breach
crisp steeple
golden turret
#

so why are you wanting gson

crisp steeple
#

so that it can function on a web api

wet breach
#

objects can be transferred between applications but only if the object is also valid in the other application as well

crisp steeple
#

at some point i was thinking of just making two different storages, one for the api and the other for the actual server loading, although that would be horribly inefficient

wet breach
#

well you are just over thinking this

#

since we are using Java, the only thing you really need is just the data that describes the item

crisp steeple
#

correct

wet breach
#

if you serialize to base64

#

it is just a string

wet breach
#

and not sure how you are not able to get a valid json object from a string

crisp steeple
#

i dont really think im up to making an entire json api thats as good as one created by google

wet breach
#

well, it is up to you. the point I was making is whatever way you decide has to be done in reverse exactly how you did it to serialize regardless of the application

#

hence you might need to pick out the data you want serialized instead of serializing the whole thing

#

web api might not know what the heck an itemstack is for example

crisp steeple
wet breach
#

getting the information using API methods isn't different then getting the raw information via NBT

#

but if you want the NBT raw data then go with that, but don't combine NMS NBT with API methods

crisp steeple
#

dont think i ever did that

wet breach
#

however, since you have an issue with NBT compounds somewhere, I linked you a library that will allow you to arbitrarily create them

crisp steeple
#

i switched a lot between bukkitobjectoutputstreams and json, trying to find something that would work, but never used both of them simultaneously

#

anyways ill think ill just be done here

#

not even sure how a 1 month old issue for a server thats pretty much dead now even got brought up again lol

wet breach
#

idk you talked about having issues with serializing

#

which so far as you explained shouldn't be that difficult

#

here is a link in how easy it is to create a json object

#

I used json simple for that

#

not super elegant or whatever, but it gets the job done lol

crisp steeple
#

yes, serializing it is very simple

#

the combinations of things that worked at some point:

bukkitobjectoutputstream:

serializing: βœ…
deserializing: βœ…
api compatable: ❌ (not able to deserialze on a server not running minecraft)


json (using the gson library):

serializing: βœ…
deserializing: ❌ (gson doesnt save types of jsonobjects, nbt tag gets converted into a treemap and doesnt work)
api compatable: βœ…

#

if i ever come back to this, what ill probably do is just make some method to convert json types into nbt compound types

wet breach
#

to avoid breakage like the last bit where nbt tags get converted to something you don't want converted to

crisp steeple
golden turret
#

i would create a wrapper from scratch

rigid bridge
#

does getLineOfSight() return a block as a string?

crisp steeple
#

why would it do that lol

vocal cloud
#

Docs will tell you what it returns

quaint mantle
#

has anyone got rideable entity NMS code for 1.18

#

i lost mine

glossy venture
#

only problem is having some serialization/deserialization system for objects

#

i made something similar

#

only problem is that the client deserialization doesnt work

#

but if the data isnt sent to the client it works fine i think

#

it also stays as a runtime object in memory until it is serialozed

high ridge
#

Um is there any recommendations for libraries that make menu guis eaiser.

#

I haven't touched bukkit since the very early days of minecraft.

golden kelp
#

Yes

#

that suggests some libs

half bone
#

Player velocity reduction on attack

golden kelp
#

what version of Java should i use for 1.15.2?

#

14

summer scroll
hardy raven
#

How should I use "nms"?

#

I downloaded buildtools and ran it in Desktop/NMS (created NMS folder)

golden kelp
golden kelp
#

which IDE r u using?

hardy raven
#

IntelliJ

eternal oxide
#

?bootstrap read the full post

undone axleBOT
#

Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.

Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163

hardy raven
#

How do I depend on jar file?

eternal oxide
#

if you read teh linked post it tells you all about it

hardy raven
#

Oh thanks

golden kelp
eternal oxide
#

no

hardy raven
#

The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar (download), or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.

#

How do I use maven to do this? I don't know the repository link (like

<repository>
            <id>papermc-repo</id>
            <url>https://papermc.io/repo/repository/maven-public/</url>
        </repository>

)

#
        <repository>
            <id>spigotmc-repo</id>
            <url>https://hub.spigotmc.org/stash/projects/SPIGOT/repos/spigot</url>
        </repository>

did not let me use spigot dependency

eternal oxide
#

you are wanting to use NMS. You clearly have not read the link that was posted

golden kelp
#

Is there a way I can increase the intensity of a lantern using nms or smth

#

i want to create a glowing effect around a player

#

and also make the light follow the player

ivory sleet
crimson terrace
#

?paste

undone axleBOT
crimson terrace
#

I'm having trouble making objects out of config sections. Ive been troubleshooting and I found out that the map I pass into the deserializer doesn't contain the keys at all. https://paste.md-5.net/rahusucori.cs Here is my relevant code and config, This is the first time I'm trying to parse objects like this from the config, so beginner mistakes are possible

lost matrix
#

Does CustomCreatureData implement ConfigurationSerializable?

crimson terrace
#

yes

lost matrix
#

Because the config does not look like its saving ConfigurationSerializables at all.

crimson terrace
#

what do you mean?

lost matrix
#

If you use ConfigurationSerializable then you can no longer write your configs by hand

eternal oxide
#

that config just has a data set. theres no serialized data in there at all

lost matrix
blazing rune
#

How do I save a double or int to a config.yml halp plz

lost matrix
lost matrix
crimson terrace
#

will do! Thanks πŸ˜„

golden kelp
#

Is there a way I can increase the intensity of a lantern using nms or smth
i want to create a glowing effect around a player
and also make the light follow the player

blazing rune
#

?config

#

tf?

lost matrix
# blazing rune tf?

Whatever. Its FileConfiguration#set(String, Object)
This means you can just use any java object.

blazing rune
#

getConfig().set("Coins." + e.getPlayer().getName() + "coins", 1000);

golden kelp
#

I am using 1.15.2 unfortunately

#

and i m using lantern so i can change the colour of the light

lost matrix
golden kelp
#

I dont think that supports lanterns

#

As I want to change colours (Red/Aqua, the two lanterns)

golden kelp
golden kelp
#
<repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>com.github.BeYkeRYkt</groupId>
            <artifactId>lightapi-bukkit-common</artifactId>
            <version>5.1.0</version>
        </dependency>
    </dependencies>
#
Cannot resolve authentication failed for https://jitpack.io/com/github/BeYkeRYkt/lightapi-bukkit-common/master-SNAPSHOT/lightapi-bukkit-common-master-SNAPSHOT.pom, status: 401 Unauthorized
ivory flume
#

If I encode an Inventory to base64, how long could the string get?

#

i need to make sure i have a datatype in mysql database long enough for them

#

i do plan on not allowing books into the inventory

crisp steeple
#

text should be good enough

#

haven’t had any issues when encoding inventories in base64

ivory flume
#

i feel like that is kinda long

#

64kb for one player?

#

i want a smaller one but idk which one to choose, unless 64kb is recommended for the entire inventory

#

this is a 9x6 inventory btw

hybrid spoke
ivory flume
#

No, I use a task scheduler to repeat every few ticks a message

ivory flume
#

is mysql

hybrid spoke
#

yes, obv. how long the base64 string could get, what we cant tell you.

ivory flume
#

right, ima have to test soon

hybrid spoke
#

but if base64 is too long for you, you could dodge to another way to store it

#

like json

#

but i dont think that you will save much there

ivory flume
#

i think ill be fine

#

one million players taking up that mucb space would be about 65 gb

#

not a lot

#

would VARCHAR(65,535) be good? i dont want to use a fixed length as thatll take space

#

base64’s output will be different lengths right

#

thats big

#

not what i want

#

i can create a filter

#

to block books

hybrid spoke
#

item with big lores go brrr

ivory flume
#

medium text is 16,777,215 characters

#

thats way longer than 65535 characters

#

πŸ‘€

#

all right

#

first time dealing with databases πŸ˜“

#

thank you

cobalt dew
#

how'd I create a switch statement with pex to check the group?

quaint mantle
#

Hm

#

There is Maven and...?

vocal cloud
#

Gradle

quaint mantle
#

Ah ty

#

What do I need to change in an IntelliJ project to change Maven to Gradle and the other way?

ivory sleet
#

You can use the gradle wrapper if it’s from maven to gradle at least

golden turret
quaint mantle
glass mauve
ivory flume
golden turret
#

nop

#

it is returning a list

glass mauve
#

nvm didnt saw the pic that is 1 px above lmao

crisp steeple
#

idk that’s pretty weird

#

maybe just try casting it

patent horizon
#

is java 17 compatible with plugin development?

ivory sleet
#

for newer versions yes

summer scroll
patent horizon
#

ah alr

ivory sleet
#

belive there are some libs older versions use that make j17 incompatible with them

golden turret
#

1.18: java 17
1.17: java 16
1.16 and below: java 8 (and java 11, but im not sure)

golden turret
#

but when i do for, it thinks it is Object i guess

crisp steeple
#

ik, it’s weird that it would want object

ivory sleet
#

I mean is your class that has the getBestPlayers method on your compile classpath?

golden turret
#

of course

#

im using that inside a listener

#

and everyone is on the same module

ivory sleet
#

yeah certainly a bit weird

#

might wanna reinvalidate caches

golden turret
granite owl
#

does unLoadWorld() work properly? i mean since unloading worlds is iirc not known to the vanilla server

golden turret
ivory sleet
#

and no class is protected / packpriv such that it by definition is inaccessible to that other class of yours?

golden turret
#

wdym

#

the getBestPlayers is public

#

like

#

the problem is with List<GamePlayer>

#

because every for with that is giving me errors

ivory sleet
#

is GamePlayer public?

golden turret
#

yes

river oracle
#

Are you deserializing GamePlayer

golden turret
#

wdym

river oracle
#

Oh are you importing the correct class?

cobalt dew
golden turret
summer scroll
vocal cloud
#

Utils.getidentifier and not just the players UUID?

ivory flume
summer scroll
ivory flume
#

what if they change names

#

you want to save by uuid internally

#

then you cna build that data with stuff like Bukkit#getOfflinePlayer

summer scroll
crisp steeple
summer scroll
#

placeholders like what?

crisp steeple
#

? (placeholder symbol)

#

then prepStatment.setString(1, iidentifier)

summer scroll
#

Ah right

#

PreparedStatement

crisp steeple
#

yea

summer scroll
#

it starts with 0 right?

worldly ingot
#

Indices for statements start at 1

#

I'm not so sure about that implementation though

#

I don't even think it will work as you expect because it's just going to return the default user every time, defeating the entire purpose of a CF

#

If you insist on going that route,

    public CompletableFuture<User> loadUser(String identifier) {
        CompletableFuture<User> future = new CompletableFuture<>();
        Bukkit.getScheduler().runTaskAsync(plugin, () -> {
            // Obviously rewrite this to use PreparedStatements. I'm too lazy
            String query = "SELECT * FROM `" + SQLDatabaseInitializer.USER_TABLE + "` " +
                    "WHERE name=\"" + identifier + "\";";

            SQLHelper.executeQuery(query, result -> {
                if (result.next()) {
                    double coins = result.getDouble("coins");
                    future.complete(new User(identifier, coins));
                }
            });
        });
        return future;
    }```
#

Though in an ideal world, your SQLHelper would also return a CompletableFuture against which you can call chained CF methods to map it to a User

#

You then call that method and call upon its future

whateverInstance.loadUser("2008Choco").whenComplete((user, e) -> { // or thenRun() if you don't care about handling the exception
    user.doSomething();
});```
#

Yeah

summer scroll
#

I use hikari right now

worldly ingot
#

There you go, even better

summer scroll
#

Thank you for the explanation Choco, I'll try it.

worldly ingot
#

tbqh, depending on how your SQLHelper is implemented, the scheduler probably isn't necessary.

#

It might already be done async. idk

#

You can return the default user if that user doesn't exist though. But ye, returning the default user every time like you were doing before would just never work ;p

summer scroll
#

Would return null if the user doesn't exist on the database is fine?

crisp steeple
#

personally i would make it return an optional instead of null, but it shouldn’t make too much of a difference

lost matrix
summer scroll
#

My main idea is to create something like that too.

lost matrix
#

After writing some stuff in Kotlin and Rust i find handling null values quite cumbersome. So i either wrap them in optionals
or dont allow null values anywhere (which is a bit harder to enforce on compile time in java)

golden turret
summer scroll
#

So If I want to create the loadOrCreateUser method, should I use AtomicReference or what?

crisp steeple
# golden turret heeelp

maybe just try casting it in the loop and seeing if it works? i’m really not sure why it would be giving that error, maybe it’s something with intellij somehow and not the actual compiler?

golden turret
#

idk

#

i invalidated the cache

#

but it did not work

hushed spindle
#

question

#

i somehow made my plugin able to crash a persons client but not the server itself

#

how

golden turret
#

the Game had a type

#

Game<M>

#

the classes that were using it, wasnt using atype

#

i added a <?>

#

and worked

hushed spindle
#

i implemented a kind of bleed mechanic thing and whenever something dies of said bleed the client shits itself and the cpu usage jumps to 100%

tardy delta
hushed spindle
#

nope

#

the server doesnt care

#

only the client dies

tardy delta
#

and what does 'the client shits itself' means?

hushed spindle
#

im honestly amazed like i didnt know plugins were capable of that

#

crashing the server sure but not the client

#

not responding + 100% cpu usage

#

gotta shut it down

tardy delta
#

you gotta be doing something in order to make that happen?

hushed spindle
#

i mean obviously

#

i just dont get what could be causing the client alone to crash

#

i just know it happens when an entity dies of my bleed damage

vocal cloud
#

Check the client log?

tardy delta
#

it has to do with the impl of your bleeding stuff then

hushed spindle
#

well, yes

tardy delta
#

figure out what you are doing wrong then or paste the code

hushed spindle
#

the log doesnt go any further beyond saying what entity died

#

i mean thats the thing i dont know what is going wrong, im just assuming it must be some kind of bug with minecraft i exploited

crisp steeple
#

are you using any mods?

hushed spindle
#

how else could it make sense that the client alone suffers from it

#

only optifine

#

oh wait i think i know, sec

#

i think its because i made the amount of bleed particles scale off the damage dealt and i have a custom damage system that has to cause entities to die manually if custom damage were to be fatal to them

#

so it deals about 10 billion damage to them

#

πŸ—Ώ

vocal cloud
#

Why not set health to 0 instead of dealing billions of damage Thonk

hushed spindle
#

because then the death message becomes "entity died" instead of naming their cause

#

didnt want that

#

making a custom damage system sucks, too damn hacky, but you gotta do what you gotta do

vocal cloud
#

Set a custom death message? Idk lol

hushed spindle
#

i mean thats just a big workaround

#

i could also set their health to something really really low so its basically guaranteed the usual damage would kill them

quaint mantle
#

can i check motion Y player?

hushed spindle
#

sure, just get their velocity

#

do keep in mind velocity in the Y direction is always a bit negative due to falling

glossy scroll
#

Is there a way to override the default world that is created on startup?

hushed spindle
#

so even when standing on the ground Y motion will be negative

hushed spindle
#

you might be able to use getFallDistance as well but i havent tried

#

but obviously this would only work if moving downwards

quaint mantle
#

?

#

or getY

hushed spindle
#

getY

#

thats their Y motion

#

add the falling negative velocity and you approximately got your true relative velocity

sacred mountain
#

any ideas on why i cant summon a mob on my server at all?

#

no console errors

#
[16:22:57 INFO]: Boncke issued server command: /spawnmob zombieBoncke issued server command: 
/summon zombie ~ ~ ~
[16:23:25 WARN]: Skipping Entity with id zombie
[16:23:25 INFO]: [Boncke: Unable to summon object]```
#

essentialsx spawnmob command btw, so nothing i've made

#

spawn eggs dont work either

#

difficulty is on hard

eternal oxide
#

mobs disabled in server settings?

sacred mountain
#

nope

eternal oxide
#

can you spawn a sheep?

sacred mountain
#

nvm it was a conflicting plugin issue

#

sorry

quaint mantle
#

how can i got Z coords and compare 3 secong after this 2 ints?

crimson terrace
#

Another question about nms, im sure these are loved by now:
If I extend the LivingEntity class how would I make an entity spawn from there? do I just have to call the constructor and call the teleport() method?

dense geyser
#

bump

hushed spindle
#

is there really no way to damage an entity with a specific damage type

#

why is there not a LivingEntity#damage(double, DamageCause)

#

that takes in an EntityDamageEvent but i guess it'll have to do

silver reef
#

Anyone here familiar with EssentialsX and their api? I am trying to listen to one of their events, but for me it doesnt work, if someone else compiles my code, it does work

#

ill dm

limpid bronze
#

Hey, i'm trying to use this util class https://github.com/Sunderia/SunderiaUtils/blob/main/src/main/java/fr/sunderia/sunderiautils/utils/ItemBuilder.java for setting an item in a inventory. I use ItemBuilder like that :

inventory.setItem(index, new ItemBuilder(item).onInteract(event -> event.setCancelled(true)).build())

But when i interact with this item, it's doesn't cancel the event

GitHub

Utility classes. Contribute to Sunderia/SunderiaUtils development by creating an account on GitHub.

silver reef
quiet ice
silver reef
#

tested with spigot 1.18.2

#

ess is v2.19.4

#

In this one I tried 2.19.0

#

Someone told me its more stable for the api

quiet ice
#

?stash

undone axleBOT
quiet ice
#

Either it is an EssX bug or the event rightfully does not fire

#

Test the event with /pay

silver reef
#

I did test it like that

#

it gives no errors, nothing

#

all the events are not triggering

#

(all the essx)

eternal oxide
#

I'd guess you have two ess jars on yoru test server

silver reef
#

wdym?

eternal oxide
#

Your code looks fine and your dependencies look fine too. So I'm going to guess you are listening to the wrong event class

tropic moss
#

is there any way to cancel sand and gravel from falling. I've tried canceling EntityChangeBlockEvent and also with BlockPhysicsEvent and they don't work. I know that there's a way with NMS but I will prefer to do it in a simplier way

eternal oxide
#

If no ess events are triggering for you and ess IS running then you have the wrong references

silver reef
#

i thought of that too, I copy pasta's this from the essentials documentation

#

bottom of the page

waxen plinth
#

@limpid bronze You never call build()

#

You have to call .build() at the end

#

This also isn't something I would use

#

It's going to create a memory leak/performance issues on servers with long uptime

#

It registers a new listener for each item that has a listener, but never unregisters them

#

Meaning that every time you construct one, another register is permanently added

#

So every time the click event is fired it will be slower and slower and take up more and more memory based on how many times you've registered these items

#

It likely won't cause issues until you have a lot of them but it's definitely not going to be insignificant either, at least for a server with a good number of players

glossy scroll
#

anyone else have this issue?

limpid bronze
#

but even with build() event.setCancelled(true) is not working

#

is there a way of unregister when the inventory is closed?

dense geyser
#

does PlayerConnection contain a method for handling every packet?

#

every packetplayin... packet ^

#

it seems to, but im not sure

humble tulip
#

Think it does

tardy delta
#

is FileConfiguration#options#copyDefaults(true) setting defaults for when some path doesnt have a value?

dense geyser
#

yes

dense geyser
tardy delta
#

im lookin for a good way to make a lang file thing

#

i had an enum before which stored paths to where in the config file the entries were saved but that went brr

humble tulip
#

brr

tardy delta
#

maybe java.util.ResourceBundle is something

quiet ice
#

that is my saner way of dealing with it

#

(i.e. the enum thing)

quiet ice
#

My more insane way of dealing with it is


    private static final Map<String, Map<String, String>> TRANSLATIONS = new HashMap<>();
    private static final Map<String, String> EN = new HashMap<>();
    private static final Map<String, String> DE = new HashMap<>();
    private static final Map<String, String> DEFAULT = EN;

    @NotNull
    public static final String WRONG_ARGUMENT_COUNT_CORRECTED_SYNTAX = "wrong-arg-count";
    // [...]

    @NotNull
    public static String translate(@NotNull String key, @NotNull Locale locale) {
        Map<String, String> translationTable = TRANSLATIONS.getOrDefault(locale.getISO3Language(), DEFAULT);
        String value = translationTable.get(key);
        if (value == null) {
            PlayerCurrency.getInstance().getSLF4JLogger().warn("Unable to find value for translation key \"{}\" in language table \"{}\".", key, locale.getISO3Language());
            String s = DEFAULT.getOrDefault(key, key);
            if (s == null) {
                return "";
            }
            return s;
        }
        return value;
    }

    static {
        TRANSLATIONS.put(Locale.ENGLISH.getISO3Language(), EN);
        TRANSLATIONS.put(Locale.GERMAN.getISO3Language(), DE);

        EN.put(WRONG_ARGUMENT_COUNT_CORRECTED_SYNTAX, "Syntax error: Wrong argument count. Correct command syntax: ");
        DE.put(WRONG_ARGUMENT_COUNT_CORRECTED_SYNTAX, "Falsche Anzahl von Befehlsparametern. Richtige syntax: ");
        // [...]
    }
glossy scroll
#

is there a way to disable initial world creation or override it in a plugin?

terse raven
#

how do i register a channel that is marked as reserved / access it

tardy delta
#

aah lol

quiet ice
tardy delta
#

resourcepacks maybe?

quiet ice
#

The client always sends the locale of the user

#

I personally do that (sending messages based on the client locale) in Presence

#

It won't work on older versions of mc however as those do not always send the locale

tardy delta
#

language thing

quiet ice
#

the client's language locale

#

Nothing with geolocation (which would legally be a grey area without consent)

#

That may be illegal

#

Until they consent that is.

#

But ask a more qualified lawyer about this, I am not qualified at all about this. I'd recommend to keep your hands off from geolocation for such non-vital usecases unless you are absolutely sure that data protection laws aren't going to kill you either way however

knotty meteor
#

if (p.getInventory().getItemInMainHand().getType() == Material.INK_SACK) {
How do i check if this is GRAY_DYE?

quaint mantle
#

?

quiet ice
knotty meteor
#

Im using 1.12.2 because i have no choice cause my friends server is 1.12.2 xD

quiet ice
#

But yeah, if you are above that, it is as simple as using GRAY_DYE

quiet ice
knotty meteor
#

Alright thanks! I will try that

quiet ice
#

They are all magic values however and I have no idea how noone came to the conclusion that this system is a bit dum at that time.
Lemme see how canarymod handled those cases

tardy delta
#

check forum post about old stuff

knotty meteor
#

It works!

#

if (p.getInventory().getItemInMainHand().getDurability() == 8) {

quiet ice
tardy delta
#

thats a lot of stuff

quiet ice
#

that is a rewrite of a fork of hmod, quite different from the bukkit we see these days

quaint mantle
#

who thought it was a good idea to use durability to store magic values

tardy delta
#

i thought this should print "null"

visual tide
#

notch

#

dont you ned to reload before you save

visual tide
#

sorry
im too tired to understand jokes rn

midnight shore
#

how could i check if a player is in the nether dimension?

tardy delta
#

lets remove the relaod

#

check their world

midnight shore
tardy delta
#

if it equals (or just the name) Bukkit.getWorlds().get(1)

#

0 is overworld, 1 nether 2 ender stuff and the rest is custom

quiet ice
#

?jd-s this does not seem right

undone axleBOT
noble forge
hasty prawn
#

Pretty sure it's World#getEnvironment()

#

With the type of Nether like geol said

tardy delta
#

oh there are such methods on a world object

#

shouldve checked docs

quiet ice
#

Well, it's the WorldInfo object actually

#

But since World extends WorldInfo, noone will care

hasty prawn
#

Is it? I'm on mobile so I didn't really look that closely

#

Oh smh

tardy delta
#

πŸ‘€

midnight shore
#

would this work?

tardy delta
#

uhm ye

quiet ice
#

Yes

#

Has anyone ever encountered something like

22:08:08.254 INFO: ClassWriter: Position UNKNOWN in type annotation: @org.jetbrains.annotations.NotNull
22:08:08.254 INFO: ClassWriter: Position UNKNOWN in type annotation: @org.jetbrains.annotations.NotNull
22:08:09.458 INFO: ClassWriter: Position UNKNOWN in type annotation: @org.jetbrains.annotations.NotNull
22:08:09.459 INFO: ClassWriter: Position UNKNOWN in type annotation: @org.jetbrains.annotations.NotNull
22:08:09.459 INFO: ClassWriter: Position UNKNOWN in type annotation: @org.jetbrains.annotations.NotNull
22:08:09.459 INFO: ClassWriter: Position UNKNOWN in type annotation: @org.jetbrains.annotations.NotNull

when compiling? If so, does one know how to get rid of those warnings?

tardy delta
#

does instance = this works in a constructor?

tender shard
#

annotations do not need to be shaded

quiet ice
#

I am pretty sure that it is not related to shading given that I would do it "manually" (and even then I do not). It is probably something inside the java compiler API

tender shard
#

can't hurt to ?paste your pom and the full maven log

#

maybe we'll find something

quiet ice
#

You see, I am using a mostly custom toolchain

tender shard
#

but why would you ever need that?

#

sounds like a design failure if you need to do that

#
public class Test {

    private static Test instance;

    public Test() {
        if(instance == this) {
            System.out.println("Why am I doing this check?");
        }
    }

works fine

tardy delta
#

ah

worldly ingot
#

= this, not == this

quiet ice
#

Code such as

        int valueslen = super.values == null ? 0 : super.values.length;
        @NotNull StateActorFactory<?>[] temp = new @NotNull StateActorFactory<?>[valueslen + 1];
        if (valueslen != 0) {
            System.arraycopy(super.values, 0, temp, 0, valueslen);
        }

seems to cause the warn to appear 4 times extra if not uncommented

worldly ingot
#

but yes to both cases lol

tardy delta
#

it looks like all the things im trying are leading to the same thing

tender shard
#

I don't see any reason why someone would think that either of them wouldn't work

dense geyser
#

I made some changes to NMS adding a method, and a class, but when I run it on a server, it tells me that the new method and class don't exist. When I run my plugin through luyten, the class and method are there, which signifies its something to do with the server jar (possibly?), does anyone know how to fix it?

tender shard
dense geyser
#

nono, I made changes to my spigot jar that you maven import into plugins

#

i.e

#

forked spigot

tender shard
#

and did you also use that custom spigot version to run the server?

dense geyser
#

I did not, is that what I need to do lol

tender shard
#

yes ofc

#

you cannot just change a .jar and then expect it to be included in the official spigot

dense geyser
#

big brain

tender shard
#

when you use spigot as dependency in your plugin, it only tells the compiler what methods and classes etc are available at runtime. of course the regular spigot doesn't include the changes you made to your custom spigot version so it cannot work like this

glossy venture
#

just compileOnly your custom jar then

#

or the source

tender shard
#

they made changes to spigot's NMS code. it makes no sense to shade spigot into the plugin because spigot wouldn't use those shaded classes anyway

#

plugins use their own classloader

#

the only proper way to make the spigot server use your custom NMS classes is to actually run the custom spigot version

tardy delta
#

could anyone explain this?

#

i kinda forgot what it means

dire marsh
#

use object... placeholders instead i think

tardy delta
#

it uses that ye

dire marsh
#

in the method parameter i mean

tender shard
#

formatted(String) and formatted(String...)

tardy delta
#

ah right

tender shard
#

it doesn't know which one you are calling

#

if both are the same anyway you can simply ignore it

tardy delta
#

i dont know which one either

#

dont know the length of the args

tender shard
#

try casting to String[], should work fine

#

or be on the safe side and cast it to (Object)

tardy delta
#

ye i did

#

would (String[]) someStr work btw?

tender shard
#

as parameter for your "get" method?

#

pls show your full class, otherwise it makes little sense to guess

tardy delta
#

i meant this but it doesnt work

tender shard
#

no of course not

#

you have to do it like this:

#

String[] arr = new String[] { "sus" };

tardy delta
#

ye so String... converts it to a string array implecitely?

#

dunno how to type that word lol

tender shard
#

if you define something like this:

public void sth(String... asd);

then it's the same as this:

public void sth(String[] asd);
#

there is ONE big difference though

tardy delta
#

ye ik

tender shard
#

using the "..." notation allows you to use both syntaxes:

sth(someArray);
// OR
sth(firstString, secondString, thirdString);
#

in the method, you will however always receive a String[]

tardy delta
#

cuz you can cast varags to a string array does it mean the compiler casts arguments passed to a string array implicitly?

tender shard
#

you never have to cast the String... to a String[]

tardy delta
#

so it compiles to sth(String[] str)

tender shard
#

it automatically is a String[]

tender shard
#

so it allows other classes to also use sth(string1, string2, string3)

tardy delta
#

ah so not really

#

well ye thanks

tender shard
#

the only difference between String[] and String... is that the latter also allows you to pass normal strings "comma separated"

#

however, imagine you have this:

public void sth(String asd);
public void sth(String... asd);

and now you do this somewhere:

String asd = "asd";
sth(asd);

now java doesn't know if you want to use the String... thing with only one element, or if you want to use the method that only takes exactly one string

#

that's why you cast your asd string to either Object or Object[]

tardy delta
#

aah

#

and i guess its not safe to cast a String[] to an Object

tender shard
#

if you have an array, you won't get this problem, then it's obvious you call the varargs method

#

you only get this problem if you have a sth(String) and sth(String...) method

#

my tip is to simply get rid of the sth(String) method

#

you will never need it

tardy delta
#

makes sense ye

latent pelican
#

Hey, is it possible to run a mcfunction on a spigot server?

tardy delta
#

good

tender shard
tardy delta
#

wondering the same lol

latent pelican
#

minecraftfunction

tender shard
#

what is a minecraftfunction?

tardy delta
#

probably a vanilla command?

#

or /function

latent pelican
#

probably yeah

tender shard
#

you can use Bukkit.dispatchCommand to force players to run a command

#

however they need to have permission to use the command

latent pelican
#

I created a random maze and its being stored in a .mcfunction file. However I dont know how to implement this into a spigot server

tender shard
#

as said you can do sth like this

Bukkit.dispatchCommand(somePlayer, "function yourfunctionname");
#

but that requires players to have the minecraft.command.function permission or however its called

#

you could simply give them this permission, dispatch the command, then remove the permission again

#

a bit dirty but I don't see another way to use the function command without allowing players to run ALL functions

tardy delta
#

does Bukkit.getConsoleSender().sendMessage("/function blablabla") also needs permission?

tender shard
#

but wait

#

sendMessage only sends them a message