#help-development

1 messages Β· Page 902 of 1

proud badge
#

Is there something like a "JsonElementArray" (i cant find one with that name) in GSON? I have a set of objects that I need to adapt to json

river oracle
#

Clear the caches

quaint mantle
#

I see "common" as a popular module name, but should I do the same in my packages for a non modular project

hazy parrot
#

You are probably referring to JsonArray ^

proud badge
river oracle
hazy parrot
proud badge
#

ok thanks then

quaint mantle
#

np

proud badge
#

I thought JsonArray was a list of JsonObjects not JsonElements

quaint mantle
#

Nah

#

Everything is a JsonElement

slender elbow
#

it's an array of any json element

#

could be an object

#

could be another array

#

could be a mixture of many element kinds, it doesn't have to be of one type

quaint mantle
#

It could be another list with an object

crimson comet
#

hi guys

fervent robin
crimson comet
#

im trying to create a server using the build tools but i keep getting a SocketExceptions message

#

can somebody help me?

river oracle
#

?paste

undone axleBOT
proud badge
#

Ok now how would I add the JsonArray I made to a json object

crimson comet
#

cant send ss

river oracle
#

Delete it

#

Use a paste please

#

?paste

undone axleBOT
sand spire
#

Does anyone know how to go to a new line after every line of lore when using a variable that isn't a fixed amount of lines? When using \n the next line just doesn't show

I tried finding the solution in this discord & with chatgpt, below is everything I tried but I don't think I understood it right so nothing worked.

            List<String> loreList = new ArrayList<>();
            //logic to add lines of lore

            //what I tried
            List<String> loreLines = Arrays.asList(loreList.toString().split("\n"));
            meta.setLore(Arrays.asList(loreLines.toString()));
            item.setItemMeta(meta);
            
            //also tried this
            StringBuilder stringBuilder = new StringBuilder();
            for (String loreLine : loreList) {
                stringBuilder.append(loreLine).append("\n");
            }
            meta.setLore(Arrays.asList(stringBuilder.toString()));
            item.setItemMeta(meta);```
quaint mantle
#

Read the parameter types

proud badge
tardy delta
#

chatgpt πŸ’€

crimson comet
#

?paste

undone axleBOT
slender elbow
quaint mantle
proud badge
#

Ok thx

fluid river
#

ok

crimson comet
#

?paste

undone axleBOT
river oracle
#

bruh press the save button then copy the link in your address bar

fluid river
bleak eagle
quaint mantle
crimson comet
zinc moat
#

bro coded the whole plugin for me πŸ’€

bleak eagle
river oracle
proud badge
bleak eagle
#

nah it has none

#

it's pretty simple

river oracle
granite owl
#

was looking at oracles documentation for naming conventions to get how member variables are to be named and found a doc of 11 pages

proud badge
#

I know a guy who once backdoored a server by injecting malicious code in the gradle-wrapper.jar

#

And it worked

bleak eagle
#

i knew a guuuuuy who got his haaair cut shoooort

crimson comet
bleak eagle
zinc moat
#

@bleak eagle how do i fix this again?

river oracle
eternal night
#

repair ide

bleak eagle
#

it's for reading

river oracle
crimson comet
#

that could be

#

thanks

zinc moat
#

ohh

#

alr

bleak eagle
#

i didn't include a pom.xml or anything

#

so your ide doesn;t even know it's supposed to be a spigot plugin

#

read the code and implement it inside your own plugin

#

we could've done some really fancy stuff with enumconverters and shit instead of defining the particle types you want by brute force but again i left it out for simplicity

#

once you understand the code you can implement it so that any particle type works without you having to have a huge switch statement

quaint mantle
#

.valueOf(String)

zinc moat
#

alrigth

inner mulch
#

can i somehow implement tab completion for chat in general?

#

no command?

river oracle
#

?jd-s

undone axleBOT
inner mulch
fervent robin
#

is it possible to make another entity invisible? even on the forums some people are saying with nms its still impossible

inner mulch
river oracle
fervent robin
#

its a nametag

fervent robin
inner mulch
sand spire
# tardy delta add ""

I assume like one of these, both doesn't work unfortunately πŸ˜”

            stringBuilder.append(loreLine).append("");```
river oracle
wet breach
#

not sure why you would need nms for that

river oracle
#

1.8

#

8 year old verison 8 year old problems

bleak eagle
wet breach
#

oh, well that is what you get with old software

#

if you like making it harder on yourself then so be it I guess

fervent robin
river oracle
#

I feel even less incentivised to help you

slender elbow
#

I want 10%

wet breach
bleak eagle
#

i want a cut too, for being a good listener

river oracle
#

#1 thing to say to NOT get free help from people online

#

"yeah I'm getting paid tho"

fervent robin
#

πŸ€·β€β™‚οΈ

wet breach
#

getting paid to make something they don't know how to make on outdated software

#

sounds legit

fervent robin
#

i knew how to do it but i am following a diff way that 7smile7 suggested

tardy delta
sand spire
tardy delta
#

dont use a stringbuilder, append to your list instead

#

listOf("line", "another one", "woo", "", "ooh")

sand spire
#

yeah, i know how to get different lines of lore underneath eachother, but the problem is that my lore is within a variable that isn't of a fixed size, and I need to make splits within that variable, so I tried \n everytime I add something to that variable but that doesn't work

remote swallow
#

theres some form of a pageinator buit in somewhere

#

its like ChatPaginator or smth

tawny pine
#

hey guys, i'm trying to import the citizens api into my plugin, but i'm struggling. i've followed the tutorial on the citizens wiki, any idea what might go wrong?

rough ibex
#

It would be nice to see some code

#

or see anything actually

#

also, what exactly is going wrong

tardy delta
tawny pine
remote swallow
#

?psate

#

?paste

undone axleBOT
kind hatch
tawny pine
rough ibex
#

did you add the repository

#

and sync

tender shard
#

did you reload maven?

tawny pine
#

does that link work or no?

tender shard
#

yes

  1. did you reload maven?
  2. the scope of citizens should be "provided" not "compile"
tawny pine
#

thanks πŸ™‚

tender shard
quaint mantle
#

How can I add a dependency to a lib jar?

tender shard
#

and why do you have com.github.nbbrd.java-io-util like 20 times in your pom?

sand spire
tender shard
tawny pine
#

yeah sorry it looks rly bad atm

sand spire
remote swallow
#

dont use a string builder

tawny pine
#

yeah i barely ever use dependencies bc i find them rly frustrating but now i have to so thanks for trynna help me guys πŸ™‚ hope it works, just syncing now

#

oh my god i'm an idiot

#

wow im so stupid

#

ive been trying to add dependencies but i havent been reloading maven and syncing

#

ive literally spent like 10 or 20 hours overall trynna do this stuff

#

@tender shard @rough ibex thanks guys sorry i was being stupid but my code works now πŸ™‚ tysm

tender shard
#

np lol

sand spire
remote swallow
#

a list

#

StringBuilder will generate 1 String, not multiple

tender shard
#

your current lore looks like this

"line1",
"line2"
"line3\nline4"
"line5\nline6"

sand spire
#

I had a list before but that didn't work so I changed it to a builder but I will change it back

remote swallow
#

ItemStack stack = new ItemStack(Material.BARRIER);
ItemMeta meta = stack.getItemMeta();
List<String> lore = new ArrayList<>();
lore.add("Line 1");
lore.add("Line 2");
meta.setLore(lore);
stack.setItemMeta(meta);
``` and you send up with 

Barrier
minecraft:barrier
Line 1
Line 2
grim hound
#

A user of a plugin of mine tried to change the plugin's messages to cyryllic.

#

But it shows up like that

#

Does anyone know why?

tender shard
#

is the file saved as UTF8? How do you load the file?

grim hound
#

I don't do anything funny with it

grim hound
#

readLine

tender shard
#

then you have to specify a charset

grim hound
#

Is there a universal one?

grim hound
tender shard
#

show your code to load the file

tender shard
#

import java.nio.charset.StandardCharsets;

  //...
  try (FileInputStream fis = new FileInputStream(file);
       InputStreamReader isr = new InputStreamReader(fis, StandardCharsets.UTF_8);
       BufferedReader reader = new BufferedReader(isr)
  ) {

      String str;
      while ((str = reader.readLine()) != null) {
          System.out.println(str);
      }

  } catch (IOException e) {
      e.printStackTrace();
  }

for example like this ^

grim hound
#

I don't specify it

#

In the InputStreamReader

grim hound
remote swallow
#

yeah

slender elbow
#

Files.newBufferedReader ftw

#

utf8 by default api 🀀

grim hound
#

Tis how I do it

slender elbow
#

but even better is utf8 aware system by default 🀀

grim hound
#

But if utf8 supports all chars

#

Then wtf is utf16

wet breach
#

utf8 does not support all characters

tender shard
grim hound
#

It's an old piece of code

grim hound
#

So

#

How do I make it read what's actually there?

wet breach
# grim hound But if utf8 supports all chars

in utf8, characters take 1,2,3,4 bytes(8,16,24,32 bits) to encode a character. With UTF-16 its either 2 or 4 bytes. (16, 32 bits) and utf32 always uses 32bits to encode a character

grim hound
#

So I should use utf32

#

That doesn't seem to be a standard charset tho

wet breach
#

only if you know that the characters you are going to use will always take 32bits, IE chinese characters for example always do

#

and I think some emojis

wet breach
#

the number after UTF is how many bits minimum it uses

grim hound
slender elbow
#

just use utf8

eternal night
#

just use utf8

slender elbow
#

lmao

eternal night
slender elbow
wet breach
#

yeah what the two above said

grim hound
#

And since it's for messages it could be any

grim hound
eternal night
#

no

quaint mantle
#
if (Bukkit.getServer().getPluginManager().getPlugin("CoreLib") == null) {
     System.out.println(ChatColor.RED + "CoreLib dependency not found");
     return;
}

So I what to add a dependency to my plugin with a jar, that code will able to check if the jar is in the plugins folder but, on the maven project how can I set the dependency on the pom.xml???

remote swallow
tall dragon
#

does any1 here know of good software to make a few hundred bots join my server?

#

for testing obviously

remote swallow
#

mine flayer

chrome beacon
#

^^

eternal night
remote swallow
tall dragon
#

appreciate that

#

thanks

grim hound
#

Mc bots

eternal night
#

but OS's tend to do funny things

#

so do people

grim hound
#

And mcstorm

eternal night
#

specify it actively and be happy

grim hound
#

You can use my AlixSystem antibot if you want

quaint mantle
remote swallow
#

the project, im guessing both use maven

quaint mantle
#

yes

remote swallow
#

just run the mvn install task and it will handle all the info

quaint mantle
#

let me try

remote swallow
#

no

#

in the maven tab on the right

#

open lifecycles

#

and run install

bleak eagle
#

top right it's like a little m

quaint mantle
#

yeah ik

#

but that just made me the target/out things

remote swallow
#

it adds it to maven local as well

quaint mantle
#

but is not a dependecy for the other project i mean

#

idk

remote swallow
#

you have to add that

quaint mantle
#

I mean those a 3 separated maven projects but at the same folder

remote swallow
#

read the info at the top of the pom and add it to a dep

quaint mantle
#

Each time I update the lib I need to change the dependency?

wet breach
#

hmmm

#

it is interesting that suddenly recently people have issues with using maven

#

you would think by now there is plenty of info out there in using it

wet breach
#

technically yes they are separate maven projects on their own

#

but if you use the parent pom, it should pull all of them up

#

or you can compile all of them using the parent pom

quaint mantle
spare mason
#

why block displays location isn't in it's center?

inner mulch
#

is it possible to cancel all the player events at once for one player or do i really neeed to go through every event and cacnel it for them?

zinc moat
#

is there any populair particle api?

grim hound
#

so update

#

I did this

bleak eagle
#

it exists in bukkit

grim hound
zinc moat
#

i know

bleak eagle
#

KISS, use as little external dependencies as you can

#

i'm sure there is some 'particle api' out there but there are many reasons as to why you shouldn't use dependencies for very simple things like that

#

you're counting on some random guy outside of your code maintaining it

grim hound
#

you can use like PacketEvents

#

for the ease of coding

quaint mantle
grim hound
remote swallow
grim hound
quaint mantle
remote swallow
#

maven

quaint mantle
#

You mean maven

#

yeah

remote swallow
#

?paste the 2 poms

undone axleBOT
grim hound
remote swallow
#

we love type erasure

inner mulch
#

whats that, and how do i get a capture of ?

inner mulch
remote swallow
remote swallow
quaint mantle
#

goal pass correctly

sage patio
#

can i teleport a player on PlayerQuitEvent?

#

the event is triggered before the quit or after it?

quaint mantle
#

thanks

sage patio
eternal night
bleak eagle
eternal night
#

It only defaults to utf 8 if file.encoding isn't set

#

Which, your os might very well do

eternal night
#

So if people run their shit with that set to anything but utf 8, Welp, explodr

sage patio
#

thanks, i've a teleport code on my PlayerQuitEvent, it works sometimes

#

otherwise gives an error (i don't have any logs & erros rn)

bleak eagle
#

it worked every single time for me

#

i'm pretty sure you can be certain it executes before

#
    @EventHandler
    public void onPlayerLeave(PlayerQuitEvent event) {
        Player player = event.getPlayer();
        player.teleport(player.getWorld().getSpawnLocation());
    }

this is the handler i used

sage patio
#

thanks

echo basalt
#

hm is there a way to force a player to place a block

#

fuck it imma call bukkit events

#

im feeling angy

worldly ingot
#

There is not a way to force this, no

worldly ingot
#

I've considered it a few times but I think there was a reason why it wasn't possible

grim hound
#

But you can't really physically force him

echo basalt
#

well

#

not necessarily force but call all the right events n stuff

#

or like get the block state, create a context n call the thing

#

but creatin a context is annoying as shit

grim hound
echo basalt
#

I think imma just call BlockPlaceEvent with a hacky injected block

echo basalt
grim hound
#

Tf is that

echo basalt
#

hm CraftBlock is not a final class

#

I think I've made a hacked craftblock before

worldly ingot
#

Oh dear

#

I don't see why you would ever need to do that though? PandaThink A block is literally nothing more than a set of coordinates and a world

#

It's a glorified Location object

echo basalt
#

to call a BlockPlaceEvent and see if things worky

#

basically this idiot customer configured her "custom block" as a feather and feathers can't be placed

#

and they can't change it from a feather because stuff breaks idk im not an expert

#

so imma hack something in so they can place a feather

#

it's just hacking in a new block, calling the event for region checks n placing it

#

no big deal

#

just a pain in the ass

#

I wonder if Location is final think3d

#

what if I extended the location class so location.getBlock returned the hacked block

#

it's not final let's go

river oracle
#

That means a block is just 3 numbers the truth is scary

kind hatch
#

Tmw you realize everything is just math.

river oracle
#

I'm watching this series of a guy remaking a voxel game in an optimized way

#

It's very interesting

kind hatch
#

Is that the one by FinalForEach?

river oracle
#

he's awesome can't wait to see what he does

hot reef
#

hi, so I'm trying to make a task that runs basically every single living instant of a plugin, but anyways im trying to assign it to a variable known as scoreScheduler, now upon looking at the bukkit classfiles, it appears that this should work but it doesn't... can someone explain what im doing wrong?
https://imgur.com/a/XpWcJmK

eternal night
#

the runTaskTimer variant that takes a Consumer yields void

#

as seen in your screenshot

#

replace task -> with () ->

hot reef
bleak eagle
#

it's fairly simple - find their address, pull up to their house and hold them at gunpoint telling them to place the block

young knoll
#

Sadly no

bleak eagle
#

it's not as fun though??

#

fun is subjective

lost matrix
echo basalt
#

yeah I figured

#

I'll test this later

#

just passed the 10 hour mark

junior anvil
#

for some reason working with remapped-mojang brings errors as soon as i try out commands and working without it makes my plugins work correctly

eternal night
#

Are you remapping your jar ^

junior anvil
river oracle
#

?paste

undone axleBOT
river oracle
#

PASTE YOUR POMMMMMMM Party

lost matrix
#

Show your pom.xml

junior anvil
#

oh okay

river oracle
#

in the link above please ^^^^^^^^^^^^

lost matrix
#

And tell us what steps you take in order to compile while you are at it

junior anvil
lost matrix
#

You are not using the special sources plugin which is needed to remap your jar

junior anvil
#

makes sense

#

how do i add it

river oracle
#

?nmss

#

?nms

junior anvil
#

that's handy

#

aaaand the version is red

granite owl
#

i just wanted server independent communication and ended up writing my whole ass own api... ```java
public class DataPackage implements Serializable
{
private static final long serialVersionUID = -5167300204896740582L;

protected PublicKey responseKey = null;
protected byte[] dataKey = null;

protected byte[] data = null;

<T> DataPackage(RSAEncrypter rsa, AESEncrypter aes, Serializer serializer, T data) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException
{
    this.responseKey = rsa.getPublicKey();
    this.dataKey = rsa.encrypt(serializer.serializeToBytes(aes.getSecretKey()));
    this.data = aes.encrypt(serializer.serializeToBytes(data));
}

PublicKey getResponseKey()
{
    return this.responseKey;
}

byte[] getDataKey()
{
    return this.dataKey;
}

byte[] getData()
{
    return this.data;
}

}

#

i feel like this is a crime

junior anvil
#

didn't help much, i'm getting pretty much the same problem

lost matrix
#

How are you compiling?

junior anvil
#

with intellij i go to project structure, artifacts and there i put my jar output dir
then i build the project

river oracle
#

if you compile with intellij it simply ignores your pom.xml configuration

junior anvil
#

OOOOOH

lost matrix
#

Alright, this will result in the pom to be completely ignored because you arent using maven.
When using maven you can only compile through the maven goals.
And never manually add any jars to your project when using maven. If you did -> remove them again.

After that: Click on your maven pannel and run package

#

You can sporadically run clean before package

quaint mantle
#

does snake yaml support comments above objects

#

like this works, but it's because the comments are attached to the value node

#

not the actual key node "hi"

wet breach
junior anvil
#

im getting 4 jar outputs, which one should i use

river oracle
#

the one without any suffixes*

deep herald
#
Bukkit will attempt to fix it this time for you, but may not be able to do this every time.
If you see this message after typing a command from a plugin, please report this to the plugin developer, they should use the api instead of relying on reflection (and doing it the wrong way).```anyone know why im getting this
slender elbow
#

use the PlayerProfile API

deep herald
#
    public static ItemStack getSkull(String url) {
        ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1, (short) 3);
        if (url.isEmpty()) {
            return head;
        }

        SkullMeta headMeta = (SkullMeta) head.getItemMeta();
        GameProfile profile = new GameProfile(UUID.randomUUID(), "");
        profile.getProperties().put("textures", new Property("textures", url));
        Field profileField;
        try {
            profileField = headMeta.getClass().getDeclaredField("profile");
            profileField.setAccessible(true);
            profileField.set(headMeta, profile);
        } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException ignored) {

        }
        head.setItemMeta(headMeta);
        return head;
    }
}```thats what i use
slender elbow
#

yeah so, not that

#

check the methods in SkullMeta for working with PlayerProfile, Bukkit.creatrProfile etc

#

textures in the profile, properties and such

deep herald
#

i didnt even make this system so

granite owl
#

okay so after working it out abit more, im aware that serializing class instances and transmitting them via the internet is generally considered a vulnerability for arbitrary code execution, is this still a major concern when the serialized object is transmitted encrypted like this: ```java
public class DataPackage implements Serializable
{
private static final long serialVersionUID = -6766450200075478944L;

protected PublicKey responseKey = null;
protected byte[] dataKey = null;

protected byte[] data = null;
protected byte[] hash = null;

<T> DataPackage(RSAEncrypter rsa, AESEncrypter aes, Serializer serializer, T data) throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException
{
    this.responseKey = rsa.getPublicKey();
    this.dataKey = rsa.encrypt(serializer.serializeToBytes(aes.getSecretKey()));
    this.data = aes.encrypt(serializer.serializeToBytes(data));
    this.hash = MessageDigest.getInstance("SHA-512").digest(serializer.serializeToBytes(data));
}

PublicKey getResponseKey()
{
    return this.responseKey;
}

byte[] getDataKey()
{
    return this.dataKey;
}

byte[] getData()
{
    return this.data;
}

byte[] getHash()
{
    return this.hash;
}

}

#

altough the package itself is not encrypted?

junior anvil
#

thank you guys very much btw @lost matrix @river oracle

lilac palm
#

Can I replace all villager pathfinders with my own in NMS or no?

rough ibex
#

is there a reason you need to use PLib?

#

i'm sorry?

#

by its UUID?

#

Why are you using Plib?

#

are we having an XY problem

drowsy helm
#

is it just a packet entity?

#

if so you can't

#

you have to keep track of it on the server

rough ibex
#

then you will need to keep track of it

quaint mantle
#

and I can't seem to attach a comment to a key

wraith apex
#

How does one implement vanilla-like enchants in 1.20+ ? I've seen other plugins are able to add vanilla-like enchants to minecraft and have them appear in the enchant table and work fine with the anvil.

river oracle
#

have them appear in the anvil??

#

that's not even possible

#

@young knoll the lang files for enchantments are hard coded right I'm not going insane here?

wraith apex
#

as if they were just another enchantment

river oracle
#

work in the anvil would include displaying the lang files in my mind

vital sandal
#

I want to do something like this :l

wet breach
#

There is a method for inline comments too

vital sandal
#

is there any existed way for it

river oracle
young knoll
#

The lang files are not hard coded

#

But enchantments are sent over the network by numeric id

river oracle
young knoll
#

Sure but you can still change the names of enchantments

river oracle
#

since the registries aren't synced it has no clue what your enchantment even is on the client regardless of the numeric ID system

bright pelican
#

what would be the class name for a strength or like health tipped arrow?

river oracle
wraith apex
#

Can I just intercept the packet then? and change the name of the enchant?

river oracle
#

no

#

the client doesn't even know your enchantments exist

#

it can't interpret them in any capacity

bright pelican
#

can someone help me?

river oracle
#

still the only way to add them is to use the vanilla registry, unfeeze it and register your enchantment

river oracle
young knoll
#

Or use PDC and events for the table and anvil

bright pelican
#

ok

river oracle
wraith apex
young knoll
#

Yes

river oracle
wraith apex
young knoll
#

You can just manually add it to lore

#

But if it gets picked as the hint in an enchantment table it’ll just appear blank

wraith apex
#

aye aye but then you need to restructure the lore

#

if lore already exists

young knoll
#

Just add it to the start of the list

river oracle
wraith apex
#

So in otherwords, adding an enchant to the registry is only good as a method for identifying the enchant on it

#

it's basically useless at displaying itself?

#

oh and adding the glow effect

river oracle
#

yeppers πŸ‘

wraith apex
#

christ on a stick, alright. Guess I'll have to get gud with the manual handling of anvil logic.

#

Thanks for the help o/

dusk moth
#

Guys, could you tell me how to make a lobby teleporting system in gui?

#

With spigot world loading api?

river oracle
#

when in reality its just a potioneffect lol

young knoll
#

Yeah all tipped arrow items have PotionMeta and all the entities are just arrow

minor junco
red trout
#

Hello everyone! I am currently building a server with Mohist Bukkit and creating plugins.
When I modify the plugin, build it, and reload it, an error occurs. How should I resolve this?

dapper scarab
#

where r the logs?

red trout
#

here

dapper scarab
#

well

#

maybe

#

the build task was failed

#

try to rebuild the plugin

red trout
#

Furthermore, my plugin operates normally again after I turn off and restart the server.

dapper scarab
#

Cannot find main class `org.server.silvergabi.Main'

#

well is that Main Class Path in plugin.yml correct?

red trout
#

yap

#

wait

#
# plugin.yml

name: SilverGabi
version: '${version}'
main: org.server.silvergabi.Main
api-version: '1.16'
commands:
  ν˜Έκ°λ„:
    description: "ν˜Έκ°λ„ κ΄€λ ¨ λͺ…λ Ήμ–΄μž…λ‹ˆλ‹€." # sorry not english
depend:
  - ItemsAdder
dapper scarab
#

holy shit

#

well

#

try to stop the server

#

and start it again

undone axleBOT
#

SpigotMC maintains the Spigot server. If you are using a fork of Spigot (such as Paper, Airplane, Purpur, or other derivative works), you should seek support in the appropriate Discord servers.

dapper scarab
#

instead of reload the plugin by PlugMan

river oracle
#

Mohist isn't support

#

Nor Is reloading

#

You can't expect stuff to work if you're using unsupported software and an unsupported feature

red trout
#

Oh, I See!

river oracle
#

Unfortunately time travel hasn't been invented yet

#

So we are stuck with /reload and whatever jank ass plugins people use to reload now adays

slender elbow
#

I know you're a time traveller

#

"y2k" pft

dapper scarab
#

🀣

river oracle
dapper scarab
#

lock your door this nightπŸ•΅οΈβ€β™‚οΈ

red trout
remote swallow
river oracle
#

I'd never hurt anyone

#

That's fucked up

remote swallow
#

you would definately beat me up

river oracle
#

You think my scrawny ass could beat you up? Smh epic

#

I weigh less than a feather πŸͺΆ

remote swallow
#

ive been told im built like a paper clip

dapper scarab
#

i ll steal your snacks, and all soda in the freezer...

remote swallow
remote swallow
#

joshwa

#

i think i found the use of config type

#

is it for maps

young knoll
#

It’s for anything with generics

river oracle
#

And has not been corrupted by the type erasure

remote swallow
#

yeah i didnt get a chance to do anything on it today so im still having some fun

delicate obsidian
#

does anyone know if it is possible to make beacons able to use other materials to activate them? Like quartz or something

echo basalt
#

I believe that's client-sided

delicate obsidian
#

yea that's what I was thinking

#

just wanted to confirm

shadow night
#

Maybe you could packet spoof that in some way, idk

lost matrix
torn shuttle
#

does anyone happen to know which packet updates the armorstand head post rotation on a client?

#

isn't it supposed to be ClientboundSetEntityDataPacket?

echo basalt
#

Rotation is part of EntityData, yes

lost matrix
#

Its this hybrid pos+rot packet

lost matrix
echo basalt
#

pos+rot is yaw/pitch

torn shuttle
echo basalt
#

euler angles are in entity data

lost matrix
#

Ah he means specifically for the AS component

echo basalt
#

same for transformations on display entities

#

p sure you can use yaw+pitch on top of the quaternions

torn shuttle
#
        entity.setHeadPose(new Rotations((float) eulerAngle.getX(), (float) eulerAngle.getY(), (float) eulerAngle.getZ()));
        sendPacket(createEntityDataPacket());

this snippet should be about right, right?

echo basalt
#

looks fine

torn shuttle
#

hrm

echo basalt
#

bro just copied my code

torn shuttle
#

nah man I added some sick methods

echo basalt
lost matrix
torn shuttle
#

I changed the homework

echo basalt
#

light theme woeisme

torn shuttle
#

ok so why is this not updating hten

echo basalt
#

well

#

are you calling it

torn shuttle
#

yep

lost matrix
#

Did you send the packet πŸ™‚

torn shuttle
#

yep

#

I need to check what the rot value is I guess

echo basalt
#

uhH

#

you're not negating it with -yaw right

lost matrix
#

Then send some coderino

torn shuttle
#

nope

wet breach
#

Maybe some kind of entity update packet needs sent or chunk update? Pretty sure some update packet needs sent.

echo basalt
#

uHh

echo basalt
#

just like

#

debug stuff idk

lost matrix
#

There are a ton of things that could go wrong. For example: Is the entity ID correct

torn shuttle
#

was just making sure I was addressing the right packet in the first place

echo basalt
#

I'm crashing from a 60 hour work week I really can't bother staring at code

echo basalt
#

Maybe with the new registry stuff we'll be able to change beacon items

lost matrix
echo basalt
#

but feel free to prove me wrong

torn shuttle
#

scammed

lost matrix
torn shuttle
#

absolute scam

echo basalt
#

fuck it time to hook protocollib

torn shuttle
#

that's not officially updated to 1.20

lost matrix
torn shuttle
#

I am going to

echo basalt
#

cool I don't have a test server with protocollib

torn shuttle
#

next

#

I am doing both

echo basalt
#

actually

#

πŸ€”

torn shuttle
#

am I tripping or something

lost matrix
#

No, bad illusion. Dont use prod for testing your stuff

echo basalt
#

I have a minigame network

#

where the prod servers are running plib

#

what if I spammed the console for a bit

#

joenoeyebrow wtf was I testing

wet breach
torn shuttle
#

man is this packet even getting sent or something

#

what the heck

wet breach
torn shuttle
#

not on this setup

#

they're all mine and this is the first time I'm doing stuff with packets

echo basalt
#

look at this fool

#

prob only crashed his client like twice

torn shuttle
#

it looks like the packet is getting sent

#

I actually crashed my client exactly 3 times today

lost matrix
echo basalt
#

the answer is no, I can't place and the packet doesn't get sent unless the button is actually clickable

#

Now, let's see if any inventory events fire

#

cool the inv click event fires

torn shuttle
#

not going to lie this is the least fun way of developing this

echo basalt
#

now let's do a pro gamer move

torn shuttle
#

all nms and packets are doing in a library that gets shaded in

#

so I have to clean and restart everything every time

#

wait... radian to degrees maybe?

echo basalt
#

maybe

#

the angles I was setting are in radians

torn shuttle
#

I am pretty sure I'm using radian but

#

I think this might be requiring degrees

echo basalt
#

Cool my entire pc froze

#

And windows is gonna update fuck

torn shuttle
#

classic radian vs degree fuckup

#

it's working

echo basalt
#

noob

torn shuttle
#

ayo boys

#

it's full async

#

and packet-based

#

so stop asking me to add that

#

now just missing using display entities

echo basalt
#

cool so @delicate obsidian @lost matrix Done some testing. While the slot is restricted in vanilla, it still fires the InventoryClickEvent

#

Unfortunately, if the item's not in the list, the button won't be marked as available

#

And it won't fire any confirm packets

#

I might be an idiot and need a bunch of iron blocks though

#

Ok yeah with iron blocks this works

#

cool

#

You'll still need to emulate all the slot functionality with the inventory click event

#

This is really cursed but achieves your goal so whatever

#

I might make a plugin for this think3d

lost matrix
echo basalt
#

go away

#

shoo off

#

hm should I make this really enterprisy

#

fuck it

torn shuttle
#

bedrock has display entities right

echo basalt
#

hah

#

doubt

torn shuttle
#

oh shit

#

it does not

#

does meg4 have a fallback for that?

echo basalt
#

it does

#

it's called

#

not supporting bedrock

#

help I'm overengineering stuff again

lost matrix
echo basalt
#

Β―_(ツ)_/Β―

#

imma open source it

#

flex quality on cmarco or sumn idk

#

im just bored

smoky anchor
#

Illusion is bored, quick, give him Spigot PR ideas!
I would like uhhh
You know the Events vanilla added, for sound and stuff ?
Ye that plz kthx

echo basalt
#

I don't do spigot forks

smoky anchor
#

I said PR to spigot
(am I not understanding something here actually ?)

echo basalt
#

Not signing the CLA, not doing the whole patch process

#

Basically go bother someone else for spigot stuff

smoky anchor
#

Aaah okok
Gotcha, sry :D

echo basalt
#

oo 8am sun is rising

#

yipee made a useless interface

remote swallow
echo basalt
#

still

#

just a pain in the ass

#

tbh so is all the patching i'm doing but whatev

inner mulch
echo basalt
#

it's just a static method on an interface

#

not a static interface itself

torn shuttle
torn shuttle
#

hey let me copy your homework

#

I promise I'll change a couple of things

echo basalt
#

I already showed you

torn shuttle
#

that one?

#

rotations?

echo basalt
#

yeah

torn shuttle
#

uh

echo basalt
#

rotations are on the transform

torn shuttle
#

oh sit you're right

#

my bad

echo basalt
#

idiot

torn shuttle
#

hey I'm a man of laser focus, I was doing armorstands

#

I'm trying to make it so that the system scans for bedrock player automatically and serves either display entities or armor stand entities depending on that

echo basalt
#

fuck I gotta handle item merging

torn shuttle
#

oh that's blockdata? pretty sure I have to look at itemdisplay for horse leather armor right

#

never used these before

echo basalt
#

the transform

#

you fool

#

but yeah I use block data

torn shuttle
#

what's up with having a left and a right rotation anyway

echo basalt
#

No clue

smoky anchor
#

iirc it allows for something called "shear?"

echo basalt
#

" left rotation is applied before scaling and right rotation after scaling" says reddit

torn shuttle
#

uh

#

ok then

upper hazel
torn shuttle
#

are display entities like armor stands in that it's a different packet to show items on the entity?

echo basalt
#

well armorstands have equipment

torn shuttle
#

uh?

#

I mean

echo basalt
torn shuttle
#

I am using the entity data packet

#

oh what is that even

echo basalt
#

metadata

torn shuttle
#

that's this one right? ClientboundSetEntityDataPacket

echo basalt
#

I'm fucking with beacons rn

#

yea

torn shuttle
#

hm

#

I think I"m putting it incorrectly on the entity then

echo basalt
#

probably

#

you're setting it on the nms entity right

#

with like a craft mirror

#

or whatever

torn shuttle
#

yep

#

oh I'm actually only doing craft for the itemstack, the entity is nms

echo basalt
#

noob

torn shuttle
#
    public void initializeModel(Location location, int modelID) {
        Display.ItemDisplay itemDisplay = entity;
//        itemDisplay.setInterpolationDelay(-1);
//        itemDisplay.setInterpolationDuration(1);
        org.bukkit.inventory.ItemStack itemStack = new org.bukkit.inventory.ItemStack(Material.LEATHER_HORSE_ARMOR);
        LeatherArmorMeta itemMeta = (LeatherArmorMeta) itemStack.getItemMeta();
        itemMeta.setCustomModelData(modelID);
        itemMeta.setColor(Color.WHITE);
        itemStack.setItemMeta(itemMeta);
        leatherHorseArmor = CraftItemStack.asNMSCopy(itemStack);

        itemDisplay.setItemStack( leatherHorseArmor);

        Bukkit.getLogger().info("display item entity initialized");
        //Actually useless, managed by the packet that sends equipment info
    }
echo basalt
#

wtf is that formatting

#

But yeah no you shouldn't use the equipment packet for items

torn shuttle
#

btw fun fact in 1.19.4 the methods commented out give a class missing error but exist in the decompiled code, don't even ask me

echo basalt
#

imports

#

or sumn

#

cool I need to do shift click logic now

#

this is a fucking pain in the ass

torn shuttle
#

there's something busted with this

echo basalt
#

you're prob just sending the wrong packet

torn shuttle
#

basically the same thing runs for armorstands and that one works, all I did was remove the equipment packet

#

(and I tested it with that packet on too)

#

oh the plot thickens

#

I can see it on my test command

echo basalt
#

you're prob just doing something stupid

torn shuttle
#

starting to think it might be the scaling adjustments I was doing for armorstands, going to have to retest that

bleak eagle
#

one question: the formatting in spigot is all over the place
i've seen both

if ( condition )
{
  System.out.println( condition );
}

and (in my opinion better and more standard)

if (condition) {
  System.out.println(condition);
}

which one is actually preferred?

lost matrix
#

The first is primarily used if you have issues and just wanted to show that to everyone

smoky anchor
#

For Java it is usually the second one
(Also, I've never seen if ( condition ) with the spaces)

bleak eagle
#

the entire builder class here, for example, has those weird spaces

#

i tried to follow it in my pr and work against my ide which prefers the second one

hybrid spoke
warm mica
bleak eagle
#

yeah same

#

i could do another pr to fix it though it might be deemed as unnecessary by md

warm mica
#

That's likely, it could also break existing prs

#

Bungeecord is similarly formatted if i remember correctly

bleak eagle
#

md himself probably writes that then

#

the funny thing is that Code Requirements in the craftbukkit readme propose sun/oracle coding standards, and those propose the second method without the weird spaces and line breaks

#

i'm assuming (at least that part of) the craftbukkit readme is kind of universal to all the other projects too

bleak eagle
devout pivot
#

is there any event that detects composter being filled?

#

I wanna create a plugin to increase the drop from composter

zinc moat
#

Guys my code is erroing

#

Someone help

bleak eagle
quaint mantle
bleak eagle
#

though you must check if everything is okay before running any code since playerinteractevents will trigger even when clicking on it with an invalid item or empty hand

#

to get the levels of a composter getBlockData() and cast it to Levelled and then getLevel() on that

devout pivot
#

ye alright thanks

candid inlet
drowsy helm
#

feel bad for whatever teacher had to mark that chicken scratch

tender shard
hybrid spoke
#

β΄³β΅£β΅Ÿβ΅‚β΅£β΅β΅–β΅’β΄΅β΅–β΅’β΅‘β΅†β΄Άβ΅ƒβ΅™β΅’β΄Έβ΅Žβ΅‹β΄΄β΅–β΄Ίβ΅™β΅šβ΄Ήβ΅Ÿβ΅€β΅„β΅…β΅β΄³β΅§β΅β΅Ÿβ΅žβ΄΄β΅“β΅•β΅‰β΄³β΄Όβ΅“β΅’β΄³β΅Ÿβ΅œβ΅’β΄·β΅‘β΅†β΅‰β΄Ήβ΅…β΅›β΄Ήβ΅£β΄²β΅™β΄Άβ΅›β΄Ύβ΅β΄°β΅Šβ΄Ώβ΅›β΅‘β΅‹β΅šβ΄Ώβ΅Ÿβ΅β΅β΅Žβ΅Šβ΅„β΄·β΅ˆβ΅œβ΅ˆβ΅™β΅‹β΅„β΅•β΄±β΅‡β΅šβ΅žβ΅…β΅ƒβ΅‘β΅β΅€β΅™β΄±β΅†β΅–β΅β΅€β΅ˆβ΅…β΅žβ΄½β΅‰β΅Œβ΅€β΄Ύβ΅„β΄Έβ΅™β΅–β΄΅β΄²β΅žβ΄΅β΅™β΅†β΅›β΄Ίβ΅€β΅‚β΅Ÿβ΅Žβ΅šβ΅‹β΄΅β΅ˆβ΅‚β΅ˆβ΄»β΅›β΅†β΅’β΅—β΄Έβ΅–β΅šβ΅β΄Έβ΅β΄³β΅‹β΅šβ΄Όβ΅Žβ΅™β΅‰β΄Ίβ΅…β΅‚β΅‚β΄Ώβ΅Ÿβ΅‚β΅–β΄½β΅‚β΅“β΅Šβ΅€β΅€β΄Ίβ΅β΄²β΅‚β΅†

quaint mantle
#

Never that serious

#

Never that deep

bleak eagle
#

hm actually what do you guys think of isCompostable() api for Material

#

yay or nay / useful or useless

#

I could totally implement it in bukkit but I just don't know if it would ever get merged

tender shard
#

it should return the "level up chance" i guess, where 0 is not compostable

gritty current
tender shard
#

because you invoke "org.bukkit.inventory.ItemStack.getType()" although the return value of "org.bukkit.event.inventory.InventoryClickEvent.getCurrentItem()" is null

gritty current
#

it what file

tender shard
#

in line 27 of ReviveInventoryListener

bleak eagle
gritty current
#

what is wrong with the code?

tender shard
rough drift
tender shard
gritty current
#

no i send the code

#

i dont knwo how i can fix it

tender shard
#

you're calling getType() on the return value of event.getCurrentItem() even though event.getCurrentItem() returns null

gritty current
#

how would i then do it?

tender shard
#

check if event.getCurrentItem() returns null and if yes, do not call getType() on it

gritty current
#

ok

#

another problem

tender shard
#
ItemStack currentItem = event.getCurrentItem();
if(currentItem != null) {
  // Now check if currentItem.getType() is a player head
gritty current
#

i have it so people cant take the items from the gui but i makes it so every gui i cant move stuff

bleak eagle
tender shard
#

no he's also doing some else checks

bleak eagle
#

kk

gritty current
tender shard
gritty current
#

but how can i make it so people dont take the items from the gui but can stille from crafting tables and their inv

tender shard
#

by only calling event.setCancelled(true) if the inventory is your GUI

gritty current
#

how?

#

like this ?
if (event.getView().getTitle().equalsIgnoreCase(ChatColor.AQUA + "Revive A Player"))
event.setCancelled(true)

tender shard
#

you should rather identify your inventories by storing them in a set or sth

#

but yeah if you insist on using the title, then move the setCancelled into the if

gritty current
#

how would i make the set

tender shard
#

btw isnt that exactly the same?

tender shard
gritty current
tender shard
#
private Set<Inventory> myGuiInventories = new HashSet<>();

then when you create a GUI inventory, add it to the set. In InventoryCloseEvent, remove the inventories from the set again

#

then in InventoryClickEvent you can just check if the set contains the current inventory

#

if yes, it's your GUI

gritty current
tender shard
#

you create the set only once and store it in a field

bleak eagle
#

@tender shard I can only make a PR in bukkit with a new method on Material, no need for anything craftbukkit, right?

inner mulch
tender shard
gritty current
bleak eagle
#

wouldn't something like that not need any implementation code?

inner mulch
tender shard
gritty current
bleak eagle
#

a big switch statement

#

just like for isBlock() and similar

tender shard
#

that stuff is auto-generated iirc

inner mulch
bleak eagle
#

don't habe the lini either

bleak eagle
#

I can't find any CraftMaterial class or anything in craftbukkit

#

although that might just be because I'm being dumb

inner mulch
#

Okay, good

tender shard
inner mulch
tender shard
#

this is usually how a Material returns a value from NMS, by moving that method to UnsafeValues / CraftMagicNumbers

bleak eagle
#

but for my use I wouldn't need that, unless I were to retrieve the composter chance values from some nms class?

tender shard
#

i doubt it'd get merged if you just hardcode it into bukkit

bleak eagle
#

let's assume I was making a simpler isCompostable method similar to something like isEdible instead of something like getComposterLevelUpChance

#

what would that need to be merged?

#

just for examples sake I might make both

tender shard
#

well I'm not md5, i dont know if he'd accept a hardcoded thingy in Material, but I highly doubt it. IIRC all the values in Material are auto-generated and you should get any values like that from NMS. otherwise imagine the pain if MC gets updated

bleak eagle
#

yeah gotchu

#

do you have any clue on how it's generated? because if I just search the entire craftbukkit repo for isEdible which is similar to what I'm trying to do, the only thing returned is some test. so clearly there isn't a craftbukkit implementation for it, rather it's generated within bukkit (which it is, there is a big switch statement that returns true in case of edible materials and false otherwise)

#

I should maybe just look thru commits myself instead of asking you to do my homework but pointers are appreciated anyways

tender shard
#

@worldly ingot are all the values in Material autogenerated? Eg the huge switch/cases etc?

gritty current
#

in the forum he wrote Inventory.Handler but i can only find Holder

tender shard
#

that's his own class / interface

#

This means we will create an inventory handler object

lost matrix
gritty current
#

ahh ok

#

where do i put it?

tender shard
#

have you fully read his post?

gritty current
gritty current
tender shard
#

it actually explains everything

bleak eagle
#

in either case I was thinking of having an isCompostable AND getComposterLevelUpChance and then put a precondition into getComposterLevelUpChance to check whether the Material isCompostable. basically making it the programmer's duty to check if a Material is compostable before trying to get its level up chance. getComposterLevelUpChance returning 0 for non-compostable Materials implies that those materials are indeed compostable but don't level the composter up at all, and AFAIK there isn't an item like that in the game

tender shard
bleak eagle
#

thank you, that's quite useful

#

I could write some script to do it I guess

tender shard
#

so you could add sth like getCOmpostChance(Material) in CraftMagicNumbers that calls getItem on the material to turn it into an IMaterial and then just throw that into the static COMPOSTABLES map

bleak eagle
#

but then I'm being counted on to maintain those and what if I get a heart attack one day or something

devout pivot
#

how do i use the getLevel() method?

bleak eagle
#

you call it

devout pivot
#

wait i cant send ss

lost matrix
#

?img

undone axleBOT
#

Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.

Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org

devout pivot
#

alright

bleak eagle
#

(750) 471-0936 is its phone number

#

just say you're a plugin developer and want to know the level

lost matrix
#

*But do it async because this is considered IO

bleak eagle
#

xD

tender shard
#

this is all you'd need to PR @bleak eagle

#

oh wait that was suposed to be 3 screenshots

#

is my discord broken?

bleak eagle
#

yup

#

I see three

#

no worries

tender shard
#

ok good

lost matrix
#

I see one

#

Looks like a german problem then

bleak eagle
#

too bad

tender shard
#

Bukkit Material:

    public float getCompostChance() {
        return Bukkit.getUnsafe().getCompostChance(this);
    }

Bukkit UnsafeValues:

    // In UnsafeValues
    float getCompostChance(Material material);

CraftBukkit CraftMagicNUmbers

    @Override
    public float getCompostChance(Material material) {
        IMaterial nmsMaterial = getItem(material);
        return BlockComposter.COMPOSTABLES.getOrDefault(nmsMaterial, -1.0F);
    }
#

that's it

bleak eagle
#

why is UnsafeValues deprecated?

tender shard
#

because plugins are not supposed to use it

lost matrix
#

public Map visible disgust

bleak eagle
#

ahh okay

tender shard
#

internally it's fine to use

shadow night
icy beacon
lost matrix
#

sigh

icy beacon
#

i'm not letting that go

#

anytime soon

bleak eagle
#

can this be done for isCompostable too? like checking in the COMPOSTABLES enum

devout pivot
#

how do I use getLevel() here?

lost matrix
bleak eagle
icy beacon
#

did you make this just now lmao

lost matrix
#

y

icy beacon
#

this is fire

bleak eagle
icy beacon
bleak eagle
#

let me write up an example one sec

devout pivot
devout pivot
tender shard
bleak eagle
#

yeah sorry misphrased

bleak eagle
# devout pivot sure thanks
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
  Block clickedBlock = event.getClickedBlock();

  // not every playerinteractevent has to be about clicked blocks. if no block was clicked, return early
  if (clickedBlock == null) {
    return;
  }

  // we've made sure clickedBlock is not null, so this won't throw errors at us
  BlockData blockData = clickedBlock.getBlockData();

  // we've made sure clickedBlock is not null, but we'll also return early if it's not a composter to keep the code flat
  if (!blockData.getMaterial().equals(Material.COMPOSTER) {
    return;
  }

  Levelled levelledBlockData = (Levelled) blockData;
  int composterLevel = levelledBlockData.getLevel();
  event.getPlayer().sendMessage("the level of the composter you interacted with is " + composterLevel);
}
#

obligatory "this is untested"

devout pivot
#

ohh I see thanks

tender shard
#

@bleak eagle are you going to PR the composter stuff?

bleak eagle
#

probably

#

unless you want to do it better than me because you're more experienced xD

devout pivot
#

whats up with everyone talking about composters today

bleak eagle
#

you started this lol

devout pivot
#

lol

tender shard
bleak eagle
# devout pivot lol

i was talking about implementing an api inside bukkit for checking whether an item is compostable

#

cuz that's not really possible right now

gritty current
bleak eagle
#

rn you need a big list of compostable items in your own code to check if an item is compostable

devout pivot
#

ye u hv to add an array or what not

peak sapphire
#

Hello good, I hope you are all well and are having a nice day, I wanted to ask if you know of any spigot plugin which connects to Twitch, which serves to someone to donate me a X amount of bits can run a command on my server, so is the command of another plugin, I've been looking and have not found, and the few I've found do not have a good wiki or references, if you can help me I would appreciate it very much

lost matrix
gritty current
#

no it gives me an error

lost matrix
#

Show the error then :=

bleak eagle
#

"it gives me an error"
"which error?"
"the error"

tender shard
#

lmao

gritty current
#

never mind

#

fixed it

#

it was bacause i had a lower case "i" XD

peak sapphire
bleak eagle
#

javascript?

hybrid spoke
lost matrix
bleak eagle
# devout pivot ohh I see thanks

casting in java is like converting one type to another. only Levelled types have the getLevel method we need. not all blockdatas are Levelled, so if we've made sure the block is levelled (only some are like crops and a composter, and we've already checked if it's a composter) we can safely cast ("convert") it to Levelled block data with the cast syntax (Levelled) boringNonLevelledBlockData

devout pivot
#

understood thanks

bleak eagle
#

make sure you don't cast if you aren't already 100% sure the BlockData is of a levelled block

#

it will just chuck errors at you

devout pivot
#

ok ill hv to filter out what block is being taken first then

bleak eagle
#

it's already done in the example

devout pivot
#

ye

bleak eagle
#

you just have to check if it's not a levelled block and then return early to stop your code from ever reaching the cast

lost matrix
#

For casting you should check with instanceof in >90% of cases

bleak eagle
#

in this case we only care about composters though

#

so we're checking material

#

not if it's a levelled block in general

lost matrix
#

Sure, but thats still a weak correlation

bleak eagle
#

we can be sure composters are levelled

devout pivot
#

how would i check if a block is levelled block without doing it manually like the example

bleak eagle
#

it's unnecessary adding the instanceof but you can if you'd like to additionally

bleak eagle
#

if (blockData instanceof Levelled)

hybrid spoke
#

just go the right way directly and check with instanceof

peak sapphire
devout pivot
#

ohh i see

bleak eagle
#

but remember that composters aren't the only levelled blocks in the game

hybrid spoke
#

very bad practice to go against the impl

devout pivot
#

ye ik

hybrid spoke
bleak eagle
#

it shouldn't ever lead to any weird behavior in my example, unless mojang randomly decides to make composters non levelled

lost matrix
#
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
  Block clickedBlock = event.getClickedBlock();

  // not every playerinteractevent has to be about clicked blocks. if no block was clicked, return early
  if (clickedBlock == null) {
    return;
  }

  // we've made sure clickedBlock is not null, so this won't throw errors at us
  BlockData blockData = clickedBlock.getBlockData();

  // we've made sure clickedBlock is not null, but we'll also return early if it's not levelled
  if (!(blockData instaceof Levelled levelled)) {
    return;
  }
  
  if(blockData.getType() != Material.COMPOSTER) {
    return;
  }

  int composterLevel = levelled.getLevel();
  event.getPlayer().sendMessage("the level of the composter you interacted with is " + composterLevel);
}

Its one more check but i think its worth it