#help-development

1 messages · Page 618 of 1

vast ledge
#

Chest chest = location. getBlock()

#

the get inv of chest

chrome beacon
#

Why not use the block state?

tender shard
#

no

tender shard
vast ledge
#

yes

small current
chrome beacon
#

?

tender shard
#

wtf is going on here, everyone drunk today

small current
#

2.8%

vast ledge
#

you can't just write usage

#

and expect us to read ur mind

small current
#

you are right

#

my bad

chrome beacon
#

I assume you mean it's slow

small current
#

yeah

#

is there an NMS way to get the chest?

#

and inventory

chrome beacon
#

ofc there is

vast ledge
#

why

chrome beacon
#

You just need to find it

vast ledge
#

would you need nms just use blockstate

tender shard
#

how is it slow? are you calling it 3 million times per tick?

vast ledge
#

idk

#

he no speak ingles

small current
tender shard
#

getting a container's inventory is not slow

vast ledge
#

why are you calling it 3m times per tick

small current
#

is

#

block.getState()

tender shard
#

hm not really

small current
smoky anchor
#

oh no

echo basalt
#

mhm I wouldn't advise doing this shit

small current
#

settings blocks are also very slow but i managed to fix it

smoky anchor
#

I really wanna see the code for that
please share

vast ledge
#

yea

small current
vast ledge
#

I need background to wtf you mean

#

So you have a large amount of items tacks?

echo basalt
#

I should honestly just make a full set of utilities around multi-threaded block manipulation

#

Including tile states n shit

tender shard
#

why do you need the blockstate to get a container in the first place?

small current
#

the maximum is 1500 blocks being broken at the same time

#

i used multi threaded

#

yes

small current
#

but adding the item to the inventory

vast ledge
#

oh

echo basalt
#

adding items to inventories can be done async

tender shard
#

You don't need the blockstate at all

smoky anchor
echo basalt
#

But it can also cause some problems

buoyant viper
vast ledge
#

you can't even add 1.5k

#

wait

#

you can

#

but that shouldn't cause lag

tender shard
#

then you dont have to get the blockstates of all other blocks

small current
#

Everything crashed

#

Normal linux behaviour

vast ledge
#

ehy

#

why

#

any errors

small current
#

@tender shard i have location of the chest

vast ledge
#

then just get the inventory

small current
#

Bruuuh i found out tf is happenin

#

Nvm

#

Shitcode

tender shard
#

dude you are talking about only one single chest?

vast ledge
#

ig

small current
#

Also why tf im adding the items in a for loop

#

Hell naw

#

Was i drunk coding this shit

smoky anchor
#

well now I really wanna see that
come on, don't be shy
show us some code :)

tender shard
#

wow i'm out, i have no clue what kind of weird things you guys are doing, but I could easily get that chest's inventory a hundred times per tick and add a ton of random items every time without ayone complainin about it being slow or anything. literally no reason at all to use slughorn/nms for this

vast ledge
#

yea

small current
#

@smoky anchor i will explain
I will get the inventory of the chest for every single block

tender shard
#

i thought you were scanning like a 3x3 chunk area for containers and that's why you wanted to avoid getting each block's blockstate,....

#

one single chest, lmao

#

what a waste of time to even think about it

small current
#

One single chest 1600 times

small current
#

Lol

#

W8

#

Yeah

#

That

smoky anchor
#

Drink some water, sober up
And fucking rewrite that shit

vast ledge
#

Holy shit

small current
#

I will also use a queue to add the items

vast ledge
#

you need another bottle

#

then it should be fine

small current
#

What in the shitcode was that

vast ledge
#

just use
while(true) {
chestInv.add(item);
}

tender shard
#

I always code great stuff when drunk, like MorePersistentDataTypes lol

#

Or CustomBlockData

smoky anchor
#

Aren't those like actually good ?
don't you even have a ? command for morepdc ? XD

tender shard
#

?morepdc

undone axleBOT
tender shard
#

?customblockdata

#

?blockdata

#

?cbd

#

Hm

#

There was a command for cbd too

#

?customblock

#

?blockpdc

undone axleBOT
smoky anchor
#

imagine forgetting a command for your own plugin
smh

quaint mantle
#

hi

smoky anchor
#

Paper

#

?whereami

tender shard
#

what's Dayzz line 706?

quaint mantle
# quaint mantle

Could someone please help? The plugin works correctly on craftbukkit and there is an error on spigot, I do not understand what is the matter, since in this case there should be no error

smoky anchor
#

what in the name of all that is holy

quaint mantle
tender shard
#

lastMessage is an empty string

quaint mantle
smoky anchor
chrome beacon
#

It can do RGB yes

quaint mantle
#

okey, thanks

chilly hearth
#
package me.airforce.excavation.Listensers;

import org.bukkit.block.Block;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;

public class BlockBreak implements Listener {

    public void onBlockBreak(BlockBreakEvent e) {

        Block block = e.getBlock();
        {


        }


    }
} ```
#

how do i make it so if thye block gets broken blocks in 3x3 raduis will also get broken ?

pseudo hazel
#

use 3 for loops

smoky anchor
#

3x3 or 3x3x3 ?

pseudo hazel
#

assuming you want it to be 3 dimensional

chilly hearth
#

3x3

smoky anchor
#

wait what do you mean by 3x3 radius ?

#

like
OOO
OXO
OOO
?

echo basalt
#

Let's start by addressing 2 things, maybe 3

#

For starters you need to annotate your listener with @EventHandler

chilly hearth
#

like excavation enchant

hazy parrot
#

just destroy blocks same way you would print matrix ig

echo basalt
#

Second, no point in opening random code blocks for no reason

pseudo hazel
#

and make sure these blocks dont call the blockbreakevent..

echo basalt
#

I'd refer to this but I honestly doubt you'll be able to understand it

smoky anchor
pseudo hazel
#

okay, well you never know 🤷

chilly hearth
#

bro so what i need to do ?

echo basalt
#

research

chilly hearth
#

bruh tell me a way man

pseudo hazel
#

no

smoky anchor
#

?spoon

undone axleBOT
#

Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.

echo basalt
#

You can't even break down your problem into steps

pseudo hazel
#

because then youll be back with the next question

chilly hearth
#

hmmmm

echo basalt
#

And you're just asking to be spoon-fed

flint coyote
# pseudo hazel okay, well you never know 🤷

In fact he wants to fire a blockbreakevent to not break plugins like worldguard and logblock. He can just extend the block break event and fire that custom event so he can ignore it in his listener

chilly hearth
echo basalt
#

Might be a little harsh but we want you to be able to understand how to solve issues by yourself

chilly hearth
#

tell a simple method isnt called spoonfeeding

ivory sleet
#

It might be

echo basalt
#

Just breaking down the problem for you is spoon-feeding

ivory sleet
#

The problem with spoonfeeding is the mindset you get from it

echo basalt
#

Well not exactly but it's something so basic

chilly hearth
#

breaking down problems and lit tell a method

#

they arent the same but whatever

echo basalt
#

Yeah but you don't learn anything from this if I just do all the work for you

#

But fuck it let's walk over the steps

#

Define 3x3

chilly hearth
#

bro

echo basalt
#

Does it include height?

chilly hearth
#

i understand it

#

yes ig

pseudo hazel
#

wdym i guess

chilly hearth
#

i mean yes

#

3x3 ofc includes hiehgt

echo basalt
#

Okay so 3x3, in relative positioning

chilly hearth
#

height*

echo basalt
#

It's -1, 0, 1 in all axis

pseudo hazel
#

okay so its a cube of blocks around the broken block

echo basalt
#

AKA a cube where your origin is your center and it expands by 1 in all axis

echo basalt
#

So let's start with what you have

flint coyote
#

Please use a variable for the size so you can easily increase it in case you want/need to

echo basalt
#

Which is a "start" X Y and Z

#

And a sort of "diameter" which is 3

chilly hearth
#

make sense

echo basalt
#

Remove 1 as it's your center, and divide by 2 to have your radius

#

So if it's 5x5, the radius is 2

chilly hearth
#

ok

twilit roost
#

bungeecord
is there some way to check if some server went offline or online?

echo basalt
#

Now you want to loop through all axis

#

Starting at -radius and ending at radius

#

I'll do it for a single radius

chilly hearth
#

alr the the ridaius 2 and -2 ?

echo basalt
#
int centerX = ..:
int centerY = ...;
int centerZ = ...;

int diameter = 5; // 5x5
int radius = (diameter - 1) / 2; // 2

for(int x = -radius; x <= radius; x++) {

}
#

So this will loop through
-2, -1, 0, 1, 2

#

Think of those as "relative" positions

pseudo hazel
#

(you dont technically have to do diameter - 1 but it make it more clear I think)

echo basalt
#

Give me an answer

chilly hearth
#

what will be my x y z ?

echo basalt
#

The initial centerX, y, z?

#

They're the position of the block you broke

chilly hearth
#

ok

echo basalt
#

Anyways you still haven't answered

chilly hearth
#
        int centerX = block.getX();
        int centerY = block.getY();
        int centerZ = block.getZ();
#

it give me those options

zenith gate
#

when retrieving an inventory name, if its colored, does that get retrieved as well? If i need to compare it, do i need the color?

chrome beacon
#

Don't use inventory names to detect inventories

#

That's a bad idea

warm mica
#

I love how it says modern but that's how it was done since always

#

Apart from having lambdas

eternal night
#

really wasn't 😅

#

too many people used like, item stack comparison

#

or I guess inventory holders (tho you can't say that too loud or md_5 is gonna come for you)

warm mica
#

The correct adjective would be properly not modern, that's what I am trying to say

#

It's not making use of anything special that I'd call modern as it only exists in newer versions

wet breach
#

Which was equally bad as using holder

onyx fjord
#

does SimpleDateFormat use some standard?

#

what is it called

eternal night
#

for what part of it ? xD

onyx fjord
#

like what the letters give as output

#

is it standarized?

eternal night
#

what method

#

.toString() ?

onyx fjord
#

nah i mean like

#

iso standard or whatever

#

that languages follow to create formatters

eternal night
#

I mean, 8601 is the ISO standard for that

onyx fjord
#

gotcha

wet breach
fervent cobalt
#

I made a plugin for 1.18.2 with Java 8, which should support other versions. But it doesn't. How to add support for other minecraft versions?

chrome beacon
#

Start by targetting the lowest version you want to support

#

Set api-version in the plugin.yml to 1.13 and then add submodule for each version of nms/version where new api got added and code that part there

#

shade it all together and only load code supported on the current version

#

That's the basics of it ^

fervent cobalt
#

Thanks

#

What versions of minecraft support what version of java?

chrome beacon
#

Lower than 1.17 uses Java 8
1.17 uses Java 16
1.18+ uses Java 17

fervent cobalt
#

But latest versions still support older java versions, right?

smoky anchor
#

no

#

you can't run 1.20 on java 8

fervent cobalt
#

I mean in terms of plugin development

#

So theoretically any version of minecraft supports a plugin that was made for Java 8

chrome beacon
#

1.8+ at least

fervent cobalt
#

Ok, thank you!

chrome beacon
#

If you start going lower than that you will have even older Java versions

eternal oxide
#

?paste for me

undone axleBOT
fervent cobalt
umbral ridge
#

nice XD

#

Didn't know that existed

upper hazel
#

is it possible to change without using reflection
max stack potion?

eternal oxide
#

no

upper hazel
#

demm(

smoky anchor
#

I believe it is but in inventory it would be "laggy" for the player
Like you can listen to interaction events and do math to set the stack size

eternal oxide
#

far too complex to handle manually

#

and you could only reduce size

upper hazel
#

and through reflection without lags will be?

eternal oxide
#

even using reflection its buggy

smoky anchor
#

yes
client still thinks the max stack size is 1

#

and you can't change what client thinks without modifying it
which is impossible via just server
||if you were in the past tho you could have used the log4j vulnerability tho XD||

upper hazel
#

Does this apply to all items?

smoky anchor
#

yes

lilac dagger
#

how do i make it so intellij won't warn about methods annotated with EventHandler?

tawdry monolith
#

Hey guys, how do I add hex color codes to a TextComponent? I need a custom colored clickable link

upper hazel
#

who knows what the variable is called responsible for this

smoky anchor
#

or the method that shows the warning

lilac dagger
#

oh wow

#

thank you

lilac dagger
#

this is so clean now

smoky anchor
# zenith gate bump.

#1 read what was said below
#2 yes, it gives you the color as well, yes you need to compare it with the color

smoky anchor
lilac dagger
#

does this mean that the itemstack is not null huh?

#

i assume it's just the array itself that is not null, not the items in the array

vestal pewter
#

Hi,

I'm trying to work with scoreboards,

If I use this code :


    @EventHandler
    public void onPlayerLogin(PlayerJoinEvent event) {

        score.playerScores.put(event.getPlayer().getUniqueId(), 0);


        ScoreboardManager manager = Bukkit.getScoreboardManager();
        Scoreboard scoreboard = manager.getNewScoreboard();

        Objective objective = scoreboard.registerNewObjective("Test", Criteria.create("dummy"), Component.text("Test"));
        objective.setDisplaySlot(DisplaySlot.SIDEBAR);

        Team team = scoreboard.registerNewTeam("ol");
        team.addEntry(" score");
        team.prefix(Component.text(score.playerScores.get(event.getPlayer().getUniqueId())));
        objective.getScore(" score").setScore(1);
        event.getPlayer().setScoreboard(scoreboard);
    }

Will my teams be shared between all the players or not ?

eternal oxide
#

no

young knoll
earnest plinth
#

how can i download java 16 on ubuntu 22.04 for 1.16 minecraft server?

twilit roost
#

how should one make an editor simillar to LuckPerms?

fervent cobalt
#

I was using MiniMessage to parse text in my plugin, but now I'm adding support for older versions and I can't send Component in chat directly anymore. Any way out?

young knoll
#

Sounds like ur using paper

#

Talk to them

fervent cobalt
#

Just adventure

#
<dependency>
    <groupId>net.kyori</groupId>
    <artifactId>adventure-api</artifactId>
    <version>4.14.0</version>
</dependency>
<dependency>
    <groupId>net.kyori</groupId>
    <artifactId>adventure-text-minimessage</artifactId>
    <version>4.14.0</version>
</dependency>
young knoll
#

Probably best to talk to adventure then

#

I’m not sure anyone here knows

fervent cobalt
#

I don't think they have support, do they?

eternal night
#

They have a discord

#

however, if you are on spigot you'd also need the bukkit bridge

fervent cobalt
#

I found the server, thank you

eternal night
#

like, how are you sending components

#

gl 😅

upper hazel
#

how obaut this ReflectionUtils

#

this api how i undestand

opal juniper
eternal night
manic furnace
#

I try to make my own argument type for brigadier. I registered it via reflections and it is loaded with no errors. But when I try to type the command, the argument input is all red and there are no suggestions. It actually calls the pars method from the type, but still the command fails

smoky anchor
#

wait I think I know this one
'cause I tried it years ago
You have to somehow register that I believe BUT those are somehow synched to client and if the client does not recognize it it throws an error
try looking into the clients console

manic furnace
#

Ill try that. I have already registered them in ArgumentTypInfos

silent steeple
#

Any good command frameworks?

fervent cobalt
#

So I made a simple plugin. In this context, all it does is reply to a command with some text. Originally it was made for 1.18.2, but since it is so simple I decided to add support from 1.12 and up. I set the API version to 1.12 in plugin.yml and downgraded all dependecies to 1.12, but when I try to load it in newer versions of minecraft I get: org.bukkit.plugin.InvalidPluginException: Unsupported API version 1.12

#

Also it uses java 8

smoky anchor
#

the argument was added in 1.13
So just put 1.13
It should work on lower versions regardless

fervent cobalt
#

I will try that, thank you

silent steeple
#

Maybe wrap it in “”

smoky anchor
#

ye no
those characters NEVER work with ANYTHING programming related

smoky anchor
fervent cobalt
#

Now the plugin supports ANY minecraft version *insert evil laugh*

#

I was wondering, is there like some sort of a list of what minecraft versions use what java version?

#

Couldn't find that

smoky anchor
#

Literally first result when googling "minecraft java java versions"

#

tho it is not full actually

fervent cobalt
#

Yes

#

I need the full list

#

That's why I asked

manic furnace
grizzled oasis
#

something with math I'm trying to do,
if a player sets the config every 1000 blocks are 1 level of exp, how can I calculate exp correctly to then every 1000 blocks give a level?
(this doesn't not depends on Minecraft level experience every 200000 exp is equal to some level but it's forced but should show correctly inside the bar if I have 200 blocks remaining it should show like it)

fervent cobalt
#

I found this but not sure

smoky anchor
chrome beacon
smoky anchor
quiet ice
fervent cobalt
quiet ice
#

The recommended one is always the lowest java version though - unless you don't care about the userbase

fervent cobalt
quiet ice
#

if you want to run a server you should use the highest version in the list though

#

And ideally use a fork that supports newer java versions

manic furnace
#

(They are dynamically generated)

smoky anchor
#

I don't think I quite understand
can you show a picture of an example or something ?

manic furnace
#

Like that you type: /test and then the plugin suggests n number of options. But you can only use these options. Otherwise it will be red

smoky anchor
manic furnace
#

Ok thx

reef flower
#

Hello, I'm having problems with the encoding of my plugin / server. When I write "¨" in the chat, "¿" this appears in the console instead!

smoky anchor
quiet ice
#

Are you calling new String() anywhere?

#

(or String#getBytes) - if not then it is probably that your client and your console are using different codepages

reef flower
reef flower
quiet ice
#

Yes, but how do you obtain that message?

smoky anchor
reef flower
#

Yes

quiet ice
#

If you pass it through any kind of input stream (and thus somehow calling new String(...) with a byte-array) then chances are this happens as intended

quiet ice
reef flower
quiet ice
#

And when explicitly saving with ANSI?

silent steeple
#

Any good command frameworks where you can register commands using annotations

brazen oriole
#

What is the order of events that get called when a player joins a server? I was wondering if there is an event that happens after PlayerJoinEvent. I'm trying to send a PluginMessage packet to a player when they join, but it seems that the messaging channel isn't registered for the Player's connection until a bit after the PlayerJoinEvent happens.

reef flower
quiet ice
#

Yeah in that case there is something wrong within the server

#

What exactly IDK

reef flower
reef flower
fervent cobalt
#

How to make the plugin jar smaller? Mine is giant, like 5MB, while the code is super simple.

smoky anchor
quiet ice
flint coyote
fervent cobalt
#

"provided"

brazen oriole
eternal night
#

I mean, if you are shading all of adventure, that is a lot

fervent cobalt
#

Maven

quiet ice
#

Could you show the pom just so we are sure?

reef flower
reef flower
reef flower
quiet ice
# reef flower gradle

not relevant for you as I already said it is a logic problem. You are somewhere converting from java.lang.String to byte[] to java.lang.String

reef flower
fervent cobalt
eternal night
#

that defauls to compile scope

#

so

#

yes

quiet ice
#

Yes - depending on the dependency it should be provided

fervent cobalt
#

Ok, I will try that, thanks

eternal night
#

obviously only those dependencies you do not need to shade

fervent cobalt
#

10KB! This is like magic!

#

Thank you guys A LOT

quiet ice
#

Yeah, no - something will break

flint coyote
#

most likely

eternal night
#

kekw cannot wait for you to have set adventure platform to provided

#

and getting runtime clapped

fervent cobalt
#

idek what shading is ¯_(ツ)_/¯

eternal night
#

including the dependency in your output jar

#

which is needed if the depdency is not provided by the server itself

#

which would be the case for adventure and the likes on spigot

quiet ice
#

(or by another plugin)

fervent cobalt
#

Ohhhhh

reef flower
# eternal night obviously only those dependencies you do not need to shade

my build.gradle loogs like : ```gradle
plugins {
id 'com.github.johnrengelman.shadow' version '7.0.0'
id 'java'
}

group 'fr.toutcourt.plugin'
version '1.0-SNAPSHOT'

repositories {
mavenCentral()
mavenLocal()
}

dependencies {
implementation 'net.dv8tion:JDA:5.0.0-beta.10'
implementation 'org.reflections:reflections:0.10.2'
compileOnly 'org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT'
}

shadowJar {
destinationDirectory = file("../../Minecraft Server/survival/plugins")
compileJava.options.encoding='UTF-8'
}

sourceCompatibility = targetCompatibility = '17'
compileJava.options.encoding = 'UTF-8'

eternal night
#

okay ?

#

have you checked in the output jar ?

#

if the classes are there

fervent cobalt
#

I have these

<dependencies>
    <dependency>
        <groupId>org.spigotmc</groupId>
        <artifactId>spigot-api</artifactId>
        <version>1.12-R0.1-SNAPSHOT</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.theokanning.openai-gpt3-java</groupId>
        <artifactId>service</artifactId>
        <version>0.12.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>net.kyori</groupId>
        <artifactId>adventure-api</artifactId>
        <version>4.14.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>net.kyori</groupId>
        <artifactId>adventure-text-minimessage</artifactId>
        <version>4.14.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>net.kyori</groupId>
        <artifactId>adventure-platform-bukkit</artifactId>
        <version>4.3.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

What should I do? I made them all provided just now

eternal night
#

beyond the first one

#

all others need to be set to compile

quiet ice
#

Again, this is probably not a build system problem but if you insist I can make it one

reef flower
quiet ice
#

"Hello, my car doesn't start, but you may not look at it"

#

"Pls fix"

eternal night
#

compileJava.options.encoding='UTF-8' is also wrong there

#

that does not go into the shadowJar configuration

quiet ice
#

Java 17 is UTF-8 by default anyways iirc

fervent cobalt
quiet ice
#

(Or was it Java 18? Whatever.)

eternal night
#

you don't

#

you are shipping a large amount of code

#

you can try to ask maven to minimize it

fervent cobalt
#

Can I shade only the relevant parts?

fervent cobalt
quiet ice
eternal night
fervent cobalt
eternal night
#

That is what that attempts to accomplish

#

the minimizeJar part

reef flower
eternal night
#

don't expact a magical solution tho

fervent cobalt
#

Ok, thanks

quiet ice
#

If you were to give me the jar I could quickly check thanks to recaf my beloved

#

(would also catch improper buildscript configs while we are at it)

reef flower
quiet ice
#

DM me I guess

#

If it is too large for DMs any generic uploading site should also work

fervent cobalt
#

It worked a little bit. Now it is half a MB smaller than before. Maybe now SpigotMC will accept it. Huge thanks to everybody here

flint coyote
#

spigotmc has a 5MB limit?

fervent cobalt
#

Nope. Still too big. Guess I'll have to use somthing external

fervent cobalt
kind hatch
#

Last time I checked
4MB limit for normal resources.
4.5MB for premium resources.

flint coyote
#

well, should be enough for 95%

eternal night
#

if you are only going down to 1.16.5, you can use the library loader

#

that thing basically downloads dependencies on the servers for you

#

so you don't have to shade them

fervent cobalt
#

since the plugin is so simple, I added support for all minecraft versions that support Java 8

#

It's fine, I'll just post a release on github

eternal night
#

yea ¯_(ツ)_/¯

echo basalt
#

Given your dependencies are in mavenCentral

echo basalt
#

Depends on what your plugin does and what the errors are about

#

Read the exceptions then

#

That looks fine

#

We can't do much if we don't know what the error is

#

Show full code

#

?paste

undone axleBOT
echo basalt
#

I asked for full code not for 2 classes and an exception

#

Just a copypaste of the class

#

But I see an issue

#

And it's called static abuse

#

Which in this case will cause you issues if you ever /reload

#

If you're unfamiliar with static read this

#

Or in short

#

?di

undone axleBOT
echo basalt
#

And no, this is not an issue due to a custom spigot jar

#

Passing your map around with DI certainly helps

#

But ideally you'd change your get to a getOrDefault and pass false as your second param

#

Just for additional safety

#

That's what dependency injection is for

tender shard
#

I mean wtf you don't need more than 2 sentences to explain it lol

umbral ridge
#

hey,

itemMeta1.getDisplayName().equals(itemMeta2.getDisplayName())

would be an equavilent to this?

Objects.equals(itemMeta1.getDisplayName(), itemMeta2.getDisplayName());
#

could I also use getEnchants() and getLore() on 2nd function?

tender shard
#

no, that's not the same

#

first one would throw NPE if itemMeta1 is null, Objects.equals() will not

umbral ridge
#

Objects.equals() will return false instead?

tender shard
#

no

#

it returns false if they are not equal lol

#

if both are null it's true ofc

umbral ridge
#

whatif one is null and other one isnt

#

that's still false

tender shard
#

then they are obviously not equal

umbral ridge
#

of course, that's what im saying lmfao

#

thanks!

tender shard
#

I'd always use Objects.equals in case one could be null

umbral ridge
#

Yeah, 🤓

timid hedge
#

Im trying to fix my pyramide with if statements but i am getting these errors: Suspicious indentation after 'if' statement should i just ignore them or have i done it wrong?

    @EventHandler
    public void onPlayerDamage(EntityDamageByEntityEvent e) {
        Entity victim = e.getEntity();
        Entity attacker = e.getDamager();
        if (!(victim.getLastDamageCause() != null)) return;
            if (!(victim instanceof Player && attacker instanceof Player)) return;
            if (!(victim.hasPermission("Vagt"))) return;
                victim.sendMessage("§3§lVAGT §f§lSYSTEM §8» §7Du blev slået af §a" + e.getDamager().getName());
                if (!(attacker.hasPermission("Vagt")))  return;
                attacker.sendMessage("§3§lVAGT §f§lSYSTEM §8» §7Du slog §a" + victim.getName());
                if(!(((Player) victim).getHealth() <= 20)) return;
                List<Player> players = new ArrayList<>();
                Bukkit.getOnlinePlayers().stream()
                .filter(p -> p.hasPermission("vagt"))
                .forEach(p -> sendActionbar(p, "hej"));
        }
smoky anchor
#

It's warning you that you may have written something incorrectly based on the indentation
You can ignore it, but instead you should fix the indentation so: you get rid of the error, don't accidentally cause emotional damage to whoever reads the code

umbral ridge
#

XD I read the indentation in your code is correct, which is causing the errors

iron crow
#

Basically, don't nest your code, it'll look a bit ugly, try using early returns.

#
  • Each ( must end with ), there cannot be 2 starts and 3 ends.
smoky anchor
iron crow
#
  • Don't use victim.getLastDamageCause(), use e.getDamageCause()
timid hedge
#

Oh, it was because i should use e.getDamager().getLastDamageCause()

#

Thanks for the help

timid hedge
manic furnace
#

@smoky anchor sadly I didn't find a argument type the matches my requirements

smoky anchor
#

ok, I'll try to go through my old plugin

timid hedge
#

How do i get ride of this warning? Condition 'attacker instanceof Player' is redundant and can be replaced with a null check'
I have tried many thing but i am still getting this warning
if(!(victim instanceof Player && attacker instanceof Player)) return;

    @EventHandler
    public void onPlayerDeath(EntityDeathEvent e) {
        Entity victim = e.getEntity();
        Entity attacker = e.getEntity().getKiller();
        if (!(e.getEntity().getLastDamageCause() == null)) return;

        if(!(victim instanceof Player && attacker instanceof Player)) return;
        if (victim.hasPermission("vagt")) {
            victim.sendMessage("You killed " + attacker);
        }
    }
}
jagged quail
wet breach
smoky anchor
wet breach
#

But there is a playerdeathevent too

river oracle
#

I was today days old when I learned about PlayerDeathEvent

timid hedge
#

How do i get the player that damaged the last time? so if a player died to fall damaged it sends in the that the player died to the last that hit the player

wet breach
#

Probably need to listen for playerinteractentity event

#

Use a global object that can be set so when the player dies you can check if they were a few ticks ago hit by a player and then can attribute their death to such

timid hedge
#

I dont know if this is correct but its kind of this right?
String killer = e.getEntity().getKiller().getPlayer().getName();

orchid trout
#

i think most mobs can have armor on

#

just do instanceof player

torn shuttle
#

I feel scammed, I've been working out for something like 2 years now and I still get DOMS bad enough that it hurts to even program

undone axleBOT
torn shuttle
#

anyone familiar with the remapped nms code? is #canReach actually whether it has already reached the target?

#

hm... actually I wonder if moveTo is returning whether the objective can be reached

#

looks like it might be

umbral ridge
#

How do you make a player "lay down" when they die? (for a few seconds)

#

What's the best to achieve this? packets?

timid hedge
#

Can someone help?

umbral ridge
#

Does that happen too, if you restart the server?

timid hedge
#

Yeah

remote swallow
#

you have an invald .env path, and the file doesnt exist

umbral ridge
#

I don't know much about this but .env is a file for variables I believe

#

I use it for completely different thing, vue.js, js framework

timid hedge
remote swallow
#

pretty sure thats not have env files work

tender shard
#

you have two filles with a different name and none called .env

timid hedge
#

I have, i have 2, 1 named files.env and another one named info.env

tender shard
#

yes

#

you have two files that are not named .env

#

and you have 0 files that are named .env

#

while you should have one file that's called .env

timid hedge
#

But when its .env it dosent work, that was the problem yesterday

tender shard
#

?notworking

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

timid hedge
#

So if i have 1 named .env and 1 named test.env it should work?

tender shard
#

i dont even know what you're trying to do

#

so no clue what you mean with "it should work"

timid hedge
#

So im not getting the error in the console

tender shard
#

all I know is that yesterday you sent a stacktrace where dotenv couldnt find a file called .env

compact haven
#

the file has to be named literally ".env"

#

the only time you have "<anything>.env" is when you are running a different .env for prod/staging

#

and that has to be configured with dotenv, you don't just magically have three files ending in .env and they all load

torn shuttle
#

why the hecking heck are my entities absolutely crawling with this movement speed...

timid hedge
#

So when i have one file named ".env" what should i call the other one "info.env" or ".env.info"?

remote swallow
#

why are you even using env files in the first place

torn shuttle
#

oh there we go now they're moving normally

glad prawn
#

He doesn't know what he has to do 😭

obtuse meadow
#

Does anyone know how to create a protocollib packet SCOREBOARD_TEAM that shows invisible players for the members? Thansk

chrome beacon
#

You don't need Protocollib for that though

#

You can just use the Scoreboard API

lavish hemlock
#

What's a more efficient idea?

  • Creating a listener per inventory.
  • Creating a listener per plugin that delegates to different inventories.
    I've been a bit mixed on how to implement GUIs in a way that could easily scale while having a nice API.
ivory sleet
#

Less committed to the spigot api is a benefit imo

lavish hemlock
#

Figured. This is meant to be platform-agnostic so registering events could get slower when working with something like Paper.

ivory sleet
#

Yeah

lavish hemlock
#

For one, I dislike Spigot's API. For two, I need to abstract if I want to support a wider range of platforms.

ivory sleet
#

Yeah right, much nicer to have ur own event bus for ur other modules and eventual api users

lavish hemlock
#

My main rationale is that I'm going to be having clients of different server architectures.
Most people'll use Spigot or a fork, of course, but there's always exceptions.

#

I'm in the process of abstracting away the plugin loading mechanism.

lavish hemlock
#

Possibly even a spork.

torn shuttle
#

I love the mineblox spork that allows me to run spigot plugins in robolox

ivory sleet
lavish hemlock
#

Oh that was what I was considering doing

ivory sleet
lavish hemlock
#

I've done classloader hacking in the past to do stuff like runtime class modification

ivory sleet
#

Ah yeah

#

Well I do it a jar in a jar fashioned way like luckperms

brisk estuary
#

hey, is this the correct way to check if it's the first time the villager get trades? I mean, when it gets the first 2 trades

#
@EventHandler
    public void onVillagerGetTrade(VillagerAcquireTradeEvent e) {
        AbstractVillager villager = e.getEntity();
        List<MerchantRecipe> trades = villager.getRecipes();
        if (trades.isEmpty() || trades == null) {
            // insert new trade
        }
    }
lavish hemlock
#

This code would produce an NPE

#

You check if the value is null after calling a method on it

brisk estuary
#

yea ur right, i just have to invert it

vivid tangle
#

Hello everyone. Some body have a todo list to check for start use Spigot with the wiki, i know java basement.

brisk estuary
#

but is it the correct way to check if it's the first time the villager get trades?

ocean hollow
#

how can i create custom enchant? it gives my that

lavish hemlock
brisk estuary
#

1.19

lavish hemlock
#

Okay well getRecipes is marked as @NonNull so the null check is redundant

#

Just check if it's empty, that might work.

brisk estuary
#

oh, I didn't notice that, thank you

lavish hemlock
#

Additionally if you're inserting trades, don't do it with the list returned by getRecipes

#

Docs say it's immutable, so modifying it would cause an error

brisk estuary
#

yea, there's a method to insert trades

lavish hemlock
#

A'ight.

lavish hemlock
#

It's not a good idea to live reload Bukkit plugins but if I'm not relying on Bukkit's plugin mechanism then it's no big deal

#

Only issue is that you can't unload classes in Java

#

Well actually I think you can.

#

But only through instrumentation or JVM TI?

ivory sleet
#

Mye

#

Or if u’re lucky with class loading

lavish hemlock
#

Supposedly it is possible to unload a class as long as the classloader is garbage-collected.

ivory sleet
#

Yeah

lavish hemlock
#

Not too difficult if that's the case.

ivory sleet
#

By far not reliable but I mean hey it’s there

lavish hemlock
#

Yeah but thankfully this is a me-only feature

ivory sleet
#

🙏

lavish hemlock
#

I dislike restarting the server over and over to test

#

A long time ago I wrote a Gradle plugin that let you build and start a server but I abandoned that project because it was too hard to maintain

ivory sleet
#

Oh have u tried running debug mode with the jvm thingy that allows for better debug

lavish hemlock
#

You mean uhh

ivory sleet
#

Yea paper has good stuff now

lavish hemlock
#

I think I've heard of it, let me find it

#

DCEVM?

ivory sleet
#

yeah

#

Always forget the name

#

But it’s pretty neat although unsure how up to date it is

lavish hemlock
#

I tried to use that once but it just wouldn't start up, lol

ivory sleet
#

🥲

lavish hemlock
#

Stuff like this is why I stopped writing Java

#

But uh, Spigot is a profitable market so I'm back at it, I guess

lavish hemlock
ivory sleet
#

Oo yeah if (almost) everything was in rust we would line in peace 100%

lavish hemlock
#

I agree from the standpoint of someone who hates writing C and C++.

#

I don't actually dislike the languages all that much.

#

Just the build tools :)

#

Swear to god, GNU software makes me want to game end myself

ivory sleet
#

Lol understandable

ocean hollow
#

Now I need to enter NameSpacedKey, what should I enter?

paper cosmos
#

can I play a sound when deciding which one to use from IJ because there are a lot of sounds and I dont know what many of them sound like?

lavish hemlock
#

I believe there's a page on the wiki.

#

It'll probably be a pain in the ass to find the specific sound event IDs for each but you can also look at the game files

onyx fjord
#

how do i set player's bed using the api?

#

oh i got it

warm light
#

is this the corrent way to check if custom event is cancelled?

tender shard
#

gobbledegook

warm light
#

how can I do it then?

tender shard
#
Cancellable myEvent = new MyEvent(...);
// Now call the event
getServer().getPluginManager().callEvent(myEvent);

// Now check if it was cancelled
if(myEvent.isCancelled()) {
  // My Event was cancelled
}
warm light
#

ow. thanks

#

I need to cast it as event?

remote swallow
#

HeadDropEvent headDropEvent = new HeadDropEvent

tender shard
#

erm no?

#

no need to cast anything

#
public class HeadDropEvent extends Event implements Cancellable {
#

seems like your event class does not extend Event

onyx fjord
#

what event triggers this (bed)

remote swallow
#

above

#

Cancellable ... = new HeadDropEvent

tender shard
#

oh yeah

flint coyote
tender shard
#

i assumed Event was an interface that Cancellable extends

mossy dock
#
@Override
public void belowPrefix(Player player, int score, Component content) {
    Scoreboard scoreboard = player.getScoreboard();

    Objective objective = scoreboard.registerNewObjective("BelowNames", Criteria.DUMMY, content);

    objective.setDisplaySlot(DisplaySlot.BELOW_NAME);

    player.setScoreboard(scoreboard);
}

Any idea how i could change the score 0 to the score var?

onyx fjord
reef flower
#

Hi ! i have a problem, i'm using some custom configFile but when i try to know if the config file exist,

file.getAbsoluteFile().exists()

always return false... can someone help me ?

remote swallow
#

just do file.exists

flint coyote
onyx fjord
#

btw when i set Player#setBedSpawnLocation player still gets message when right clicks the exact same bed

reef flower
ivory sleet
flint coyote
ivory sleet
#

U sure u use the same file for everything thats related?

reef flower
ivory sleet
#

Clearly not

#

Maybe some other file

#

But not that file

reef flower
ivory sleet
#

Send code

#

Easiest that way to sniff out what u did wrong

reef flower
#
        if (!this.file.getAbsoluteFile().exists()) {
            this.plugin.saveResource(template_file_name, true);
        }
ivory sleet
#

More than that will be needed

reef flower
#

Wait i break the code cause discord sayed too much char

ivory sleet
#

?paste

undone axleBOT
tender shard
#

what is "file"?

reef flower
reef flower
reef flower
tender shard
#

print out the path of file

reef flower
#

absolute or not ?

tender shard
#

doesnt matter

#

anyway, your path is wrong

onyx fjord
#

i guess this will work

reef flower
#

C:\Users\natha\Desktop\Java\Minecraft Server\survival\plugins\lang.yml

onyx fjord
#

for the message

tender shard
#

i doubt you want to save your file in plugins/

warm light
tender shard
#

it's because you add this weird "parent + /" to your file's path

reef flower
#

Oh yeah my bad !

tender shard
#

also why aren't you just using getDataFolder() ?

reef flower
#

idk

tender shard
#

getDataFolder returns your plugin's folder, e.g. plugins/MyPlugin/

#

you can create files inside that like new File(plugin.getDataFolder(), "lang.yml");

reef flower
#

yeah i know but idk why i dont use this !

quaint mantle
#

hey i got a quick question how would i disable a wither not taking arrow damage below 50%?

cold tartan
#

What is the difference between rayTrace, rayTraceEntities, & rayTraceBlocks?

tender shard
quaint needle
tender shard
quaint needle
#

not sure

remote swallow
cold tartan
tender shard
quaint mantle
#

also can i force a wither to go lower, ik if a wither is below 50% hp to hover's lower

cold tartan
warm light
#

here my code. so the event get called before the drop adding
I have cancled the event in 2nd class. so its not modifying the drops.
but in 3rd class, I did a task on that event. and that didn't got cancelled :/

tender shard
#

wdym "I did a task on that event"?

pseudo hazel
#

not like instantly

#

but gradually

remote swallow
quaint mantle
#

yes but can i force it if its not at 50%

pseudo hazel
#

not that I know

remote swallow
#

the event should have the new drop included, then if it isnt cancelled you drop it on the floor

warm light
quaint mantle
# pseudo hazel not that I know

i tried looking at EntityWither and it calls a method .cm() which is a boolean, tried overriding it and damageEntity but it just recursively calls

gusty jungle
#

Guys, can you create a plugin that has items with custom textures?

quaint mantle
#

and a texture pack

tender shard
gusty jungle
#

Does it overwrite textures or add new items in this case?

tender shard
#

add new ones

cold tartan
tender shard
#

it doesnt really add new items, it just makes you able to use different textures for already existing items without changing the default item look

gusty jungle
#

Can you explain to me how I can do it?

chrome beacon
#

The Minecraft wiki has all the information you need

tender shard
warm light
gusty jungle
#

Ty

tender shard
gusty jungle
#

Can I also use them in a custom craft?

quaint mantle
#

yes

#

its a normal item

gusty jungle
#

Ty

quaint mantle
#

it can do all the things a normal item can it just gets rendered differently client side

gusty jungle
#

Ok

remote swallow
#

send the message if the event isnt cancelled

gusty jungle
#

So I have to create a custom model data pack?

#

But if I use items from other plugins in the craft, is that a problem?

quaint mantle
#

no

#

just add the checks for those items

#

but those items wont have the custom model data (so no custom textures) unless the author or you sets it

orchid trout
#

whats the purpose of implementing an interface once

ocean hollow
#

how to register Enchantment when server is enabling, it gives me IllegalStateExeption

tender shard
#

however there is really no reason to do it unless you wanna create a fake glow enchantment

ocean hollow
#

and why not register, I need it to be just like a real one, appear in the enchantment table, for example

chrome beacon
#

For example the client won't be able to see the name

#

So you need to listen to a bunch of events and add lore

ocean hollow
#

I only need the appearance in the table of enchantments, trade with the inhabitants, everything else itself.

chrome beacon
#

Yeah

#

And you won't be able to get it to display the name when hovering the enchantment buttons

ocean hollow
#

but why it has Rarity and can be Traded?

chrome beacon
#

So you can check the rarity and if you can trade for it

ocean hollow
#

oh, okay 😦

#

but the enchantment tag is stored inside it?

chrome beacon
#

?

mossy nimbus
#

Is there a way to avoid nbt stuff from Being able to place/use?

chrome beacon
#

Cancel if it has the information

pseudo hazel
#

how instant will a task timer set to 0 be completed once its started?

#

like the next tick?

ivory sleet
#

wdym?

eternal oxide
#

probably but no guarantee

pseudo hazel
#

hmm

#

its probably a bug in my timer, nvm

ivory sleet
#

Im still confused about the question

pseudo hazel
#

okay so lets start from the beginning

#

I am creating a plugin where I want to divide some players from a list into teams, I am currently getting a concurrentmod exception when removing from my list, likely because I am ending the timer too soon

#

I have a timer which when it goes of should start the game

#

the timer start when enough players have joined

#

but in teh config you can set the timer to 0 seconds

#

so my timer is going off probably before I added the player to the team

#

and while the timer is timing out, and messing with the list, I am trying to add a player to said list

lavish hemlock
pseudo hazel
#

no

#

I am explicitly using iterators to avoid that

#

but

#

it can still be modified from the outside

#

because if I just change the timer to be 1 second, I have no issues

#

hence why I thik its actually because I am adding to the list

#

hmm

#

nvm

#

seems like I will have to do more debugging on the actual feature

nova notch
#
for (NamespacedKey key : player.getPersistentDataContainer().getKeys()) {
            player.sendMessage(key.toString() + " VALUE");
        }```
how do i iterate over the keys and get their values?
pseudo hazel
#

player.getPersistentDataContainer().get(key)

nova notch
#

but it says it needs a type

#

and idk how to do the thing when the type is unknown

rain cypress
#

Is there an event that's triggered when a suspicious block changes state from a player using a brush?

pseudo hazel
rare rover
#

not badd

#

46ms to load my plugin

pseudo hazel
#

idk what kinda monster plugin you would have to have to make it super long

nova notch
#

like idk a message and a kill count

#

actually i guess i dont need to do that cus i can just remove the stuff i dont want to keep since it saves itself

#

but i still wanna figure it out

pseudo hazel
#

yeah the whole point of pdc is that you dont need to save it somewhere else

nova notch
#

maybe i want to make backups idk

young knoll
#

If you backup the world like you should, that will also backup PDC

nova notch
#

fine ill do it the lame manual way

pseudo hazel
#

it seems like pdc wasnt made for what you wanna do

nova notch
#

wait so when is pdc actually saved to the file

#

every few min or on server shutdown or what

ivory sleet
#

Sort of

#

It saves when it most

#

Like chunk load/save

nova notch
#

...it saves when it most??

eternal night
#

it saves with the parent

#

on a chunk, it saves when the chunk is saved

#

on an item, it is saved when an item is saved

nova notch
#

oh

icy bone
#

I got a question, i made this part to send a player a message the moment the players is standing to long on the same block (not coords, same block):

    @EventHandler
    public void onPlayerMove(PlayerMoveEvent e) throws IOException {

        Player player = e.getPlayer();

        if(isStandingOnSameBlock(player))
        {
            Bukkit.getScheduler().runTaskLater(plugin, () -> {
                if(isStandingOnSameBlock(player))
                {
                    player.sendMessage("You have transformed!");
                }
            }, 60L);
        }```
But i got a question, does the task keep the player that triggerd it or is it possible if multiple players are online that the message will go to the wrong player?
#

Cuz im not sure if im standing still for example and right before the task runs (after 3 sec) another player moves and the message will be send to that player

eternal night
#

this would be fine

icy bone
#

Ah okay so no multiplayer issues here

eternal night
#

the player variable is method local

#

this would be an issue if the variable is defined e.g. on the class

icy bone
#

Ahh okay awesome, thank you!

tender shard
#

what does isStandingOnSameBlock do?

remote swallow
#

io ig

hushed spindle
#

how would one avoid a ClassNotFoundException if a class in my code exists and it references a class from a future version that doesn't exist on the one i'm playing, even if that code is never ran because of a version check?

#

like i got a custom recipe class that references SmithingTransformRecipe, but this doesn't exist in 1.19 versions so it throws that error, even though the code will never get to that point

ivory sleet
#

its an exception from a reflective call

#

NoClassDefFoundError is if the class doesnt exist tho

hushed spindle
#

yeah obviously

#

thats not the point

#

i want my plugin to support a range of versions but this 1.20 class doesnt exist in other versions, but i still need to work with it

#

how would i avoid that in a preferably nice way, because i know i can just put that referenced class in a different class and have it do its thing that way

tender shard
hushed spindle
#

thats what im doing yeah

#

still the exception is thrown

tender shard
#

then you're doing sth wrong

#

?paste the whole class

undone axleBOT
hushed spindle
#

i could have sworn it used to do that before but im pretty sure because i persist and load this object with gson it does it anyway

tender shard
#

and the whole stacktrace

hushed spindle
#

pretty sure its just because of gson that it throws the exception regardless

#

i dont even have any custom smithing recipes made right now so the bit of code that's meant to generate the recipe never runs either

#

just the reference alone causes the exception

ivory sleet
#

yes its gson

#

cuz gson uses reflection (sometimes)

#

and u happen to be getting cnfe

#

which is impossible to get if u dont use reflection

hushed spindle
#

is there some workaround i can use to avoid it

ivory sleet
#

how exactly do u use gson rn?

hushed spindle
#

like can i make a fake SmithingTransformRecipe to trick gson lol

tender shard
#

put your gson deserialization into a try/catch

hushed spindle
#

i guess yeah

#

i dont think im doing anything special with gson, besides registering some type adapters for my abstract classes and interfaces

#

its not even allowing me to catch CNFE because it thinks it's never thrown

tender shard
#

Isnt the CNFE caused by NoClassDefFoundError?

#

Or sth

#

Worst case, catch Throwable and rethrow anything thats not NoClassStuff

hushed spindle
#

oh you right mb

#

mistook CNFE for NCDFE

tender shard
#

you cannot detect that reliably

#

listen to incoming ServerboundCustomPayloadPacket

#

idk how exactly the data looks, but that's the one where forge MIGHT send a list of mods

#

you can easily disable that with another mod though

#

sooo it's not reliable at all

#

to listen to that?

#

you either need to inject a custom netty listener, or use sth like ProtocolLib or PacketEvents

#

i'd suggest ProtocolLib because then you don't need to update for every new NMS version

#

PacketEvents requires to be shaded, and yeah NMS you also gotta recompile for every new versino

#

who? ProtoclLib?

#

it is

#

one sec

river oracle
#

was there even many changes in 1.20 for protocol

tender shard
#

hmmm

#

weird, idk then

#

one sec

#

oh yeah you're right, I thought I was running ProtoclLib but I'm not

#

hmm then I'd use a custom netty listener

#

?nms

tender shard
tender shard
#

PacketEvents would also work if it's on 1.20, idk

#

never used it

river oracle
#

PacketEvents is 1.8+

#

afaik

#

idk try it out

novel kite
#

Heyo, I've got a few questions about sending custom events as I've never used it before.

  • When an external plugin depends on my artifact to have the event should it shade my code or use as provided?
  • If shade, if a plugin relocates the artifact would it still be able to use the event as normal?
#

use packetevents 2.0, 1.8.x is outdated

river oracle
#

I sent you the link

#

on github

#

compile it yourself then? though you shouldn't need to

#

its not a plugin

#

its a library

#

just use moj maps then

river oracle
#

you don't even need to use all these libraries just use mojang maps + nms

novel kite
young knoll
#

ProtocolLib and packetevents both work for 1.20.1

novel kite
#

then you gotta compile your own copy

river oracle
#

PacketEvents isn't a plugin no?

young knoll
#

It can be run as one

novel kite
river oracle
#

oh didn't know

#

I thuoght you had to shade it

#

they probably just haven't updated the spigot page yet

young knoll
#

Use the latest dev build

novel kite
#

Looks like you can access it through the CodeMC

icy bone
tender shard
#

why don't you just compare the move event's getFrom and getTo()

eternal night
#

I mean, those locations will always change

tender shard
#

ofc I meant the block

eternal night
#

ah

tender shard
#

basically just check if getFrom().getBlock().equals(getTo().getBlock())

eternal night
#

either you are not depending correctly or you are shading the API

#

yea no scope means it would be shaded

#

ye

undone axleBOT
tender shard
#

onPacketSending is to listen to outgoing packets

#

you have to listen to the incoming packet, not the outgoing

#
public class ProtocolLibTest {
    {
        Plugin plugin = null;
        ProtocolManager manager = ProtocolLibrary.getProtocolManager();
        manager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Client.CUSTOM_PAYLOAD) {
            @Override
            public void onPacketReceiving(PacketEvent event) {
                // Stuff
            }
        });
    }
}

#

works fine for me

#

idk whether the correct type is Client or Server, protocollib's names are ridiculous

#

they should use the proper names, Clientbound and Serverbound

#

simply saying "Client" or "Server" makes absolutely no sense because the packets are alwayws sent between client ADN server lol

#

idk which is the correct one

#

no clue why protocollib fails to use the correct packet names

#

?

#

then client is the correct one

#

and it's out of bounds because that packet doesn't have any strings

#

it only has a byte array or sth

eternal night
#

why are you listening to the custom payload packet skully

#

ehm

#

given how trivial it is to disable that modlist sending

#

not really an effective way

#

I mean, depends on the mod you want to counteract ?

#

anti xray and anti cheat work well

worldly ingot
#

Cheat mods and clients aren't going to announce that they're joining

eternal night
#

yeaaa

worldly ingot
#

They'll present themselves as vanilla

eternal night
#

they are gonna look like vanilla

#

choco typing too fast

worldly ingot
#

lynx typing too slow

eternal night
#

I mean, you can do it this way

#

its a minimal barrier for entry

#

will it block people that know a bit about abusing mods

#

no

nova notch
tender shard
#

what do you not understand?

nova notch
#

anything

tender shard
#

yeah well idk how to explain it then lol

#

imho it's pretty straightforward

#

better dont look at MorePersistentDataTypes then lol

nova notch
#

is this what you mean by has or what am i supposed to be looking for

tender shard
#

yes

#

it loops over all existing primitive PersistentDataTypes, checks if the pdc has(this type) and if yes, returns it

#

the list of native types (NATIVE_PRIMITIVE_PERSISTENT_DATA_TYPES) is set via reflection in the static init block

nova notch
#

so i can use it to get the type of the value?

#

value

tender shard
#

yes

#

I mean, the javadocs explain that

#

Gets the proper {@link org.bukkit.persistence.PersistentDataType} for the given {@link NamespacedKey}

eternal night
#

I'd strongly suggest ordering that

#

the average speedup of first checking STRING, INTEGER, BYTE_ARRAY

#

vs them being in a set

young knoll
#

Shame we don't have a method to just get an object without a type

eternal night
#

I mean

#

You could compute back a PrimitivePersistentDataType

#

idk if that is worth it

#

Issue with that is that people might expect their custom types to be returned, which well, not happening

tender shard
#

tbh 99.9% of people don't even know they can create their own types

#

they do weird stuff like serializing their object to json and then try to save it as string