#help-development

1 messages · Page 932 of 1

lost matrix
#

Because you check if the clicked inventory is your custom inventory.
But if the player clicks in his own inventory, then this condition wont be true ofc.

peak jetty
#

oh yeah, how do i fix that?

lost matrix
#

Check if the primary inventory of this event is your custom inventory, regardless of which inventory is clicked.

#
Inventory primary = event.getInventory();
peak jetty
#

thanks that fixed it!

#

appreciate the help

lost matrix
# peak jetty appreciate the help

You might want to think about using a GUI library btw.
The current setup might work for now, but using a lib lets you focus on creating actual content
instead of fiddling with your gui logic.

cinder abyss
#

Hello, when I try to get the foliage color using net.minecraft.world.level.biome.Biome.getFoliageColor, sometimes it returns 0, how can I fix that?

peak jetty
lost matrix
lost matrix
cinder abyss
lost matrix
cinder abyss
#

yeah it's the problem

young knoll
#

I think a value of 0 means it uses whatever colormap the client has

cinder abyss
#

is there a way to get the default colormap?

young knoll
#

Download it and use the vanilla maths

#

Or hardcode the vanilla biomes I guess

cinder abyss
#

humm okay thanks

cinder abyss
# young knoll

So, I have thisjava public static Object getFoliageDefaultColor(Block block){ double AdjTemp = Math.clamp(FallingLeaves.leavesColorImpl.getTemperature(block.getLocation()), 0.0, 1.0); double AdjDownfall = Math.clamp(FallingLeaves.leavesColorImpl.getDownFall(block.getLocation()), 0.0, 1.0 ) * AdjTemp; return null; }
But how can I select the good color from that?

#

I imported Foliage.png in resources

proud badge
#

is InventoryCloseEvent fired when the player leaves before closing the inventory?

lost matrix
proud badge
#

Ok nice

cinder abyss
lost matrix
#

What makes a color "good"?

cinder abyss
#

Pinking the good color for a plain not the one for a mangrove if I'm in a plain

lost matrix
cinder abyss
#

Okay I'll try to understand

wary harness
#

hey is it possible to spawn arrow entity which is attached to specific part on player entity

#

like when u get shot by skeleton

#

but I would like to spawn arrow on player

inner mulch
#

how can i have code run when an object is collected by the garbage collector?

#

basically the opposite of a constructor?

chrome beacon
#

finalize

#

But don't do that

inner mulch
#

its deprecated

chrome beacon
#

yeah

#

exactly

inner mulch
#

what do i do instead?

chrome beacon
#

why do you need to do that

inner mulch
#

i have an object that you can modify at the and you need to call a method to commit the changes and i want to throw an error if you dont commit the changes and the object was collected

slender elbow
#

cleaner api

#

but be very careful to not reference the object from your runnable

#

or it will never be GCd since it's reachable

worthy yarrow
#

So I’ve got a project I’m working on, pets system. Issue is that I need the items model’s to be integrated through a pre-existing resource pack, I’ve never worked with them before so I have no idea how to go about this.

#

Them being resource packs

rare rover
#

No

chrome beacon
#

Show the entire code

cinder abyss
# lost matrix Ah, you just write some code to pick the color from the png. Just as described i...

something like that?```java
public static byte getFoliageDefaultColor(FallingLeaves plugin, Block block) throws IOException {
double AdjTemp = Math.clamp(FallingLeaves.leavesColorImpl.getTemperature(block.getLocation()), 0.0, 1.0);
double AdjDownfall = Math.clamp(FallingLeaves.leavesColorImpl.getDownFall(block.getLocation()), 0.0, 1.0 ) * AdjTemp;
BufferedImage in = ImageIO.read(plugin.getResource("Foliage.png"));

BufferedImage newImage = new BufferedImage(in.getWidth(), in.getHeight(), BufferedImage.TYPE_INT_RGB);
byte[] pixels = ((DataBufferByte) newImage.getRaster().getDataBuffer()).getData();
return pixels[(int) (pixels.length*AdjDownfall)];

}```

worthy yarrow
#

?paste

undone axleBOT
inner mulch
#

When using hibernate, is there a method to retrieve a value or insert one and return it if not existing alr?

wary harness
#

would it be possible to spawn arrow at specific part of body?

#

my pc lagging with 100k arrows from some reason

tawdry monolith
#

does anyone have a tutorial on using Firebase?

chrome beacon
#

Google does have good documentation

icy beacon
#

Google's documentation on anything always throws me off

#

They have like 30 steps to authenticate anything for their API (any, not just firebase) and then turns out the doc page I'm reading is deprecated and the new API requires 40 steps, but the API in itself is deprecated and the new auth method requires a different account overall, and then when I finally authenticate, the methods and classes I need are the least documented

lost matrix
#

Looks like this should work. Btw you should follow java naming conventions.
How do you determine if this works or not?

cinder abyss
#

@lost matrix I edited my code but it returns me -113:```java
public static byte getDefaultFoliageColor(FallingLeaves plugin, Location location) throws IOException {
double AdjTemp = Math.clamp(FallingLeaves.leavesColorImpl.getTemperature(location), 0.0, 1.0);
double AdjDownfall = Math.clamp(FallingLeaves.leavesColorImpl.getDownFall(location), 0.0, 1.0 ) * AdjTemp;
BufferedImage in = ImageIO.read(plugin.getResource("Foliage.png"));

    byte[] pixels = ((DataBufferByte) in.getRaster().getDataBuffer()).getData();
    return pixels[(byte) (pixels.length*AdjDownfall)];
}```
#

(in a jungle)

#

and -1 in a forest

#

but how can I convert it to a hexadecimal then?

lost matrix
#

Didnt read the wiki entry

echo basalt
#

reading a buffered image every time seems a bit uh

#

wasteful

cinder abyss
#

multiplying by 256?

cinder abyss
lost matrix
proud badge
#

if I do ArrayList.set(60, someValue) when the array list is empty rn, does the arraylist size become 60?

proud badge
#

Does it become 1?

lost matrix
#

Wait

#

What are you trying to do?

proud badge
#

im making vaults rn
0-9
List<ItemStack[]>

#

so the first vault is 0 in the list, 2nd is 1 etc etc

cinder abyss
proud badge
lost matrix
cinder abyss
#

@lost matrix java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!

return new Color(in.getRGB((int) (AdjTemp*256), (int) (AdjDownfall*256)), true);```
#

Do you know?

#

Should I remove new Color ?

lost matrix
cinder abyss
#

but the image is 256x256

#

and It's clamped so..

lost matrix
#

Tell me the index of the very first pixel and the index of the very last pixel.
Maybe this helps.

cinder abyss
#

humm

#

list.indexOf(0) and list.indexOf(list.length) ?

lost matrix
#

The first pixel is at (0 : 0) and the last is at (255 : 255)

cinder abyss
#

sooo 255*255 ?

#

wait

#

255?

#

so I shouldn't do *256 but *255?

lost matrix
#

No idea. Depends on how your code looks like rn.

cinder abyss
#
public static int getDefaultFoliageColor(FallingLeaves plugin, Location location) throws IOException {
        double AdjTemp = Math.clamp(FallingLeaves.leavesColorImpl.getTemperature(location), 0.0, 1.0);
        double AdjDownfall = Math.clamp(FallingLeaves.leavesColorImpl.getDownFall(location), 0.0, 1.0 ) * AdjTemp;
        BufferedImage in = ImageIO.read(plugin.getResource("Foliage.png"));

        //byte[] pixels = ((DataBufferByte) in.getRaster().getDataBuffer()).getData();
        return in.getRGB((int) (AdjTemp*256), (int) (AdjDownfall*256)); //pixels[(int) (pixels.length*AdjDownfall)];
    }```
#

It crashes at the return

#

(but I didn't tested using 255)

#

so it's with 256

lost matrix
#

Whats this for?

cinder abyss
#

I'm right?

cinder abyss
#

usingjava byte[] pixels = ((DataBufferByte) in.getRaster().getDataBuffer()).getData();

lost matrix
#

Ah they use the bottom left corner as a base. Ok makes sense.
Yeah now multiply by 255 and check if it works

cinder abyss
#

not working

#

out of bound

#
return in.getRGB((int) (AdjTemp*255), (int) (AdjDownfall*255));```
lost matrix
#

Print out the image dimentions and the coordinates

cinder abyss
#

coordinates?

lost matrix
#

Honestly this is just some basic debugging.

cinder abyss
lost matrix
#

The pixels you want to retrieve

cinder abyss
#

humm

#

no surprises, width : 256, height : 256

proud badge
#

wait is it possible to store things in an inventory holder
like
private int index; and then do
inv.getHolder().getIndex();

cinder abyss
#

@lost matrix do you know?

lost matrix
#

Yes

cinder abyss
#

humm

#

and how can I do that please? 😂

cinder abyss
#

stackoverflow?

#

But then, what should I do with int[][] ?

lost matrix
#

Anything. Doesnt matter. There is probably a Facbook group that has covered this. You can probably
find this in old msn messages. This has been solved millions of times for the past 20 years.
Close your eyes and click on a random link. It will most likely spoon you the answer in 5 different colors.

cinder abyss
#

oh okay

#

@lost matrixjava int[][] pixels = convertTo2DUsingGetRGB(in); // [] x [] y System.out.println(pixels[(int) (AdjTemp*255)][(int) (AdjDownfall*255)]);
Returns me -9395353

lost matrix
#

Sounds good

reef acorn
#

Hey, we are planning to include some kind of auto-updater in our plugins!
This means that we have a folder on our root server (e.g. path /home/autoupdater/), in which we pack configs, for example.
The plugins should then check at startup whether they still have the latest version of the config themselves. If this is not the case, the plugins should automatically download the latest version of the config from this folder.
Now we wanted to ask how we can access a directory that is outside the Minecraft server.
Many thanks in advance.

cinder abyss
lost matrix
young knoll
#

You’d have to hardcode the path

#

Or does java let you traverse backwards above the folder the jar is in

cinder abyss
#

@lost matrix you're a magician, do you know how can I do? 🥹

lost matrix
#
  public static Color getDefaultFoliageColor(Location location) {
    Block block = location.getBlock();

    double temperature = block.getTemperature();
    double downfall = block.getHumidity();

    double adjTemp = Math.clamp(temperature, 0.0, 1.0);
    double adjDownfall = Math.clamp(downfall, 0.0, 1.0) * adjTemp;
    BufferedImage in = ImageIO.read(plugin.getResource("Foliage.png"));

    int xCoord = (int) (adjTemp * (in.getWidth() - 1));
    int yCoord = (int) (adjDownfall * (in.getHeight() - 1));

    int rgb = in.getRGB(xCoord, yCoord);

    return new Color(rgb);
  }
cinder abyss
#

humm

#

I'm trying

#

imagine if it returns a blue color

quaint mantle
#

is anyone able to make movecraft compatible with 1.20.4

#

dm me if can

cinder abyss
#

there isn't any blue color so how in the world can it returns a blue color???

lost matrix
#

Debug it

cinder abyss
#

java.awt.Color coll = LeavesUtil.getDefaultFoliageColor(plugin, location);
System.out.println("r " + coll.getRed());
System.out.println("g " + coll.getBlue());
System.out.println("b " + coll.getGreen());```
#

yeah, it's named coll

#

I forgot to put 1234567 after

#

If i invert blue and green I get a green color

fleet imp
#

How do i add a method to a class, outside of a class

#

hey, thats the bungeecord dude

lost matrix
fleet imp
#

poop

#

specifically, can i add an eventlistener to a lister class, outside the listener

lost matrix
#

Im sensing an xy problem

#

What are you trying to do?

quaint mantle
#

how do i make movecraft compatible with 1.20.4 version of MC

fleet imp
# lost matrix What are you trying to do?

Make a class + methods to make inventories and guis easier to work with. Specifically, my class had a listener nested in it, and i want to be able to add eventlisteners after the class is instantiated

cinder abyss
#

It's weird

lost matrix
#

Debug it

cinder abyss
#

In 4 years of programmation, I never used a debugger, only print in console...

#

But I'll try this tomorrow, thanks really much for your help

lost matrix
#

Im seeing plenty of blue on this png to be honest

fleet imp
cinder abyss
#

That's weird

cinder abyss
#

Goodbye 👋

lost matrix
#

Im no regex expert, but this exception looks very questionable

young knoll
#

Yeah that looks fine

#

Unless “” are part of the key

#

Or there is some weird Unicode character in there

lost matrix
#

I found the problem. It was something cursed in there from serializing the key.
Im doing something that should probably not be done

young knoll
#

Im confused

#

Wat is that

lost matrix
#

Im... not sure. I started implementing a map view for MongoDB

#

And since i had a whole abstraction on top of that, i decided to implement it for Files, SQL and PDCs for some reason

young knoll
#

But PDC is already a map

lost matrix
#

Yes, but it has a bunch of serialization and namespacing on its tail

#

Honestly its just an experiment.

#

I like the idea of just having a Map representation for the persistence layer.

#

Imagine all you have to do is

public class PlayerDataManager {

  public static final String DB_NAME = "playerdata";

  private final Map<UUID, PlayerData> liveMap;
  private final MongoMap<UUID, PlayerData> mongoMap;

  public PlayerDataManager(Ambrosia<MongoDatabase, MongoMap<?, ?>> ambrosia) {
    this.liveMap = new ConcurrentHashMap<>();
    this.mongoMap = ambrosia.createMapView(DB_NAME, UUID.class, PlayerData.class);
  }

  public void loadPlayerData(UUID playerId) {
    PlayerData mPlayerData = this.mongoMap.computeIfAbsent(playerId, PlayerData::new);
    this.liveMap.put(playerId, mPlayerData);
  }

  public void savePlayerData(UUID playerId) {
    PlayerData playerData = this.liveMap.remove(playerId);
    this.mongoMap.fastPut(playerId, playerData);
  }

  public PlayerData getPlayerData(UUID playerId) {
    return this.liveMap.get(playerId);
  }

}

To load and save your data

rare rover
#

why cant the JVM find the class?

#

can i not use top level variables inside another plugin?

#

trying to use that variable

#

i've tried shading my dependant plugin, and tried it without

#

neither worked

drowsy helm
#

is the InvoiceCore plugin loaded properly?

young knoll
#

The child plugin should have depend: otherplugin in the plugin.yml

rare rover
#

i am doing that

#

and i tripled checked that the core is being loaded before the child plugin

#

which it is

lost matrix
#

NoClassDefFoundError can be caused by an exception in a static initializer block.
Its thrown during classloading and doesnt show up in the logs. The classloader simply discards this class.
Try lazily initializing your fields.

rare rover
#

how would i do that?

lost matrix
#

This looks extremely dangerous

rare rover
#

how? I was also thinking that was a bad practice

#

i just didn't know what else to do

#

ig could put it as static inside the main class

drowsy helm
#

just initialise it like a normal plugin

#

spigot class loader will handle plugin loading priority if you set the depend in config

#

technically the block hasnt changed yet

#

getBlockData()

#

for the block that it iwll be changed to

lost matrix
#

getBlock() returns the current state of the block before its changed

rare rover
#

yeah maybe mccoroutine messing it up

#

let me just try normal and move those variables to static instead

inner mulch
#

Im using Hibernate and when i delete a field it doesnt delete the column in the database? is there a config setting i need to apply?

inner mulch
#

why is it a mess tho?

#

oh yeah this one

#

im not doing any transctions

#

im just deleting fiels

#

fields

#

in the entity

#

yes im editing the class

#

no this is just for when updating values

#

i dont think it drops columns

#

i have it set to update, update only adds columns but doesnt drop them

umbral ridge
wet breach
#

lol

quaint mantle
#

it's returning air though

#

it should be sand?

#

because it's sand turning into air

#

(falling sand)

lost matrix
#

Ah wait

#

You are speaking about when the Block starts falling?

quaint mantle
#

yea i'm trying to grab it after the first state change

#

yeee

#

so uh

#

my goal is

#

basically

#

to keep block gravity but simulate it in a way that doesn't involve any entities

#

so when a block is falling, the entity doesn't spawn and instead it calculates the first physical block under that block

#

then removes the block, and replaces it one above the block it found

#

simulating block gravity

young knoll
#

I wonder if the downwards iteration would actually be that much more efficient than entities

quaint mantle
#

everything works except for the replacing of the block

lost matrix
#

In that case the EntitySpawnEvent might be more suitable

quaint mantle
quaint mantle
#

even if it did, would I be able to get the block state before it's turned into an entity?

lost matrix
#

You would get the BlockData

#

Hm, does that event really not trigger for falling blocks?

quaint mantle
#

i'll double check rq

#

oh nevermind it does trigger

#

"CraftFallingBlock"

young knoll
#

So wait what’s wrong with the EntityChangeBlockEvent

quaint mantle
lost matrix
#

I mean you still have the FallinBlock entity and could your BlockData from it

young knoll
#

^

#

Also can despawn it

lost matrix
#

Cancelling the EntitySpawnEvent might be more efficient if the EntityChangeBlockEvent is fired after already spawning the entity to the world

quaint mantle
#

managed to get it working with EntitySpawnEvent

#

thank you vm

#

is it possible to run it all asynchronously? not sure if it's because the server is waiting for the processing or it's just running out of mem (i'm self hosting off of my pc rn so it might be that)

lost matrix
#

I mean you can run it async but not on a different thread

hybrid spoke
#

its one method you need to call

#

literally one

obsidian plinth
#

No the path finding itself wasn’t what I was looking for

#

So I just made my own

hybrid spoke
#

fair

obsidian plinth
#

Also it’s like 3 methods

hybrid spoke
#

one to make it work, two to get your pathfinder, three to do the math

obsidian plinth
#

Yea not literally one lol

#

It also loved the randomly fly up a block on walking setting

#

Custom is also better just was try’s be lazy

hybrid spoke
#

i should have read your entire sentence first

I couldn't get it to function at all

#

anyways, at least you could find a solution that fits you the best

obsidian plinth
#

Took a while to get it to work with what I was doing

hybrid spoke
#

maybe there are things to improve, always glad about feedback

grave laurel
#

Hey, quick question

#

Is it possible to give a player an item from another mod via a spigot plugin?

lost matrix
grave laurel
#

I am using Mohist 1.20.1

quiet ice
#

Prepare for the mandatory disclaimer lol

grave laurel
#

Yeah, I am only using Mohist because I need to use plugins and want to add a mod pack to my Server.. So is there a way to use or rather give a player an item from a different mod?

lost matrix
lost matrix
inner mulch
#

Im using hibernate and the Auto schema only adds columns is there a setting for also dropping columns?

lost matrix
inner mulch
#

:(

icy beacon
#

I will be looking into it 🙂

#

Incredible job haha

lost matrix
wanton oak
#

Hlo

chrome beacon
#

Hi :)

lost matrix
#

Hy

wanton oak
#

Can anyone give me anticheat plugin

#

For my server

#

I. Need this plugins

wanton oak
#

Item adder essentialx essential x chat footage buzz anticheat world edit world guard multiverse core multiverse inventorys Happy Hyd Eco Pets And Job Bas Yeh Sab

#

I need this plugins

#

How to download

#

Not showing me download option

chrome beacon
#

Some of those are paid plugins

#

Login and buy them

lost matrix
wanton oak
#

I can't send photo

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

wanton oak
#

I do verify why I am not verified

chrome beacon
wanton oak
#

Early supporter badge what is early supporter

#

@chrome beacon

chrome beacon
#

Buying nitro before 2018

wanton oak
#

He give nitro ?

chrome beacon
#

?

wanton oak
#

To anyone

chrome beacon
#

You're not talking about the discord badge?

#

Why would they give you nitro?

lost matrix
#

Olivo you always give free Nitro to people.
Give one the Epic_Mayank as well.

chrome beacon
#

._.

wet breach
#

o.o

chrome beacon
#

no that's your job uwu

wet breach
#

lol, idk who that person is

#

they are not even verified XD

quiet ice
#

Why would you even need nitro

tender shard
#

to annoy people with huge code blocks instead of using ?paste

lost matrix
#

Wait you can paste bigger codeblocks with nitro? lmt

tender shard
#

well the message limit is higher in general

#

I think it's twice the normal one

#

let's test

#
class ArgumentPath<T : CommandContext>(
    val senderArgument: SenderType<*>,
    val arguments: List<Pair<String, CommandArgument<*>>>,
    val permission: List<Permission> = emptyList(),
    private val contextBuilder: (Map<String, Any?>) -> T,
    val ownExecutor: CommandContextExecutor<T>? = null,
) {

    fun matches(
        sender: CommandSender,
        args: List<String>,
    ): Either<PathMatchResult, Pair<Double, List<Message>>> {
        val greedyArg = arguments.indexOfFirst { it.second.greedy }
        var firstErrorIndex = -1.0

        val errors = mutableListOf<Message>()
        arguments.indices.forEach { index ->

            if (index >= args.size) {
                return@forEach
            }

            val currentArg = currentArgResult.leftOrNull()!!

            val parsed = argument.parse(sender, currentArg)

            if (parsed == null) {
                val error = argument.errorMessage(sender, currentArg)
                firstErrorIndex = if (firstErrorIndex == -1.0) index.toDouble() else min(firstErrorIndex, index.toDouble())
                errors.add(error)
            }
        }

        if (errors.isNotEmpty()) return Either.Right(firstErrorIndex to errors)

        if (greedyArg == -1) {
            if (args.size > arguments.sumOf { it.second.length }) {
                return Either.Right(
                    arguments.size.toDouble() to listOf(Basics.messages.tooManyArguments),
                )
            }
        }

        if (!senderArgument.requiredType.isInstance(sender)) return Either.Left(PathMatchResult.YES_BUT_NOT_FROM_CONSOLE)
        if (!hasPermission(sender)) return Either.Left(PathMatchResult.YES_BUT_NO_PERMISSION)
        return Either.Left(PathMatchResult.YES)
    }

    fun accumulateArguments0(
        argIndex: Int,
        givenArgs: List<String>,
        commandArguments: List<CommandArgument<*>>,
        greedyPosition: Int,
    ): Either<String, Int> {
        var myStartIndex = commandArguments.subList(0, argIndex).sumOf { it.length }
        val mySupposedLength = commandArguments[argIndex].length
        val myEndIndex = myStartIndex + mySupposedLength
        var missingArguments = mySupposedLength - (givenArgs.size - myStartIndex)

        if (myEndIndex > givenArgs.size) {
            return Either.Right(missingArguments) // TODO: Is this correct?
        }

        val expectedLengthWithoutGreedy = commandArguments.filter { !it.greedy }.sumOf { it.length }

        if (greedyPosition == -1 || argIndex < greedyPosition) {
            return Either.Left(givenArgs.subList(myStartIndex, myEndIndex).joinToString(" "))
        }

        val greedyArgumentSize = givenArgs.size - expectedLengthWithoutGreedy
        val extraArgs = givenArgs.subList(greedyPosition, greedyPosition + greedyArgumentSize)

        if (argIndex == greedyPosition) {
            return Either.Left(extraArgs.joinToString(" "))
        }

        val lengthAfterMe = commandArguments.subList(argIndex + 1, commandArguments.size).sumOf { it.length }
        myStartIndex = givenArgs.size - lengthAfterMe - 1

        missingArguments = mySupposedLength - (givenArgs.size - myStartIndex)

        if (myStartIndex + 1 > givenArgs.size) {
            return Either.Right(missingArguments)
        }

        return Either.Left(givenArgs.subList(myStartIndex, givenArgs.size).joinToString(" "))
    }
}
#

weird, 3950 chars is too much for nitro

#

but 3306 works

lost matrix
#

Meh thats half the class at best

tender shard
#

the class had 14k chars, I deleted stuff until it fit

tardy delta
#

thanks for the free code

tender shard
#

I thought the limit is 4k chars but apparently its 3500 or sth

lost matrix
#

I swear Either and Pair are so Pythonesque.

tender shard
lost matrix
#

XD

tardy delta
#

coding at 3am moment

drowsy helm
#

Tuple?

lost matrix
#

An actual object 🙂

#

Pair is maybe ok for very internal usage

tardy delta
#

should have tagged unions like in rust

wet breach
#

or a map

#

pair unfortunately only exists in javafx

shadow night
#

What's javafx

valid burrow
shadow night
#

Ah that

pseudo hazel
#

wtf is Either

#

is that like a union?

tardy delta
#

i guess so

mortal hare
#

why does c# love pyramids of hell

lost matrix
#

properties distilldowo

#

Hate them

mortal hare
#

i just dont like how they nest things up

tardy delta
#

early return on IsUploadJob

slate surge
#

?

fallen lily
slate surge
#

why it showing errors?

lost matrix
#

?1.8

undone axleBOT
small current
#

im trying to access a file in the plugins folder from a plugin that is not loaded
File dataFile = new File("plugins/SomePlugin/data.yml");

will this work? or should i find the server's directory

lost matrix
#

Did you add the spigot repository to your pom?

slate surge
fallen lily
slate surge
fallen lily
small current
hazy parrot
fallen lily
#

Ah yes my apologies

#

Well

#

val pluginsRoot = File(yourPlugin.dataFolder).resolve("../")

#

if you really need to know the path

#

resolve might be part of the paths api

#

Yeah part of NIO, kotlin should have extensions for that though

lost matrix
#

What do you mean by task? And how would you "execute tasks through the command" when you are in an inventory GUI?

fallen lily
#

🧌

inner mulch
tender shard
inner mulch
#

?

fallen lily
#

read the room bro

pseudo hazel
#

well its hard to tell if its a joke

#

the only suggestion to a joke is that orc

#

otherwise it seems like advice on how to make such a thing

ivory sleet
quaint mantle
tardy delta
#

is the format messed up?

quaint mantle
#

Possibly convert to a format, such as dd-MM-YYYYY or whatever you wanna use

fallen lily
#

?

ivory sleet
#

?kick @fallen lily put off the attitude

undone axleBOT
#

Done. That felt good.

fallen lily
#

No need for that thanks

#

Besides if YOU as the moderating body read the room yourself you would have noticed that the person originally asking for help with their poor approach realised that it didn’t make sense

#

Shocker, I know right

slender elbow
#

take a chill pill, victim

ivory sleet
fallen lily
#

“Rude” gif 😭

ivory sleet
#

You don’t see a problem, do you?

fallen lily
#

Man are you like

#

10 or smt

fallen lily
sand spire
#

Does anyone know how to display this kind of preview using a list of itemstacks while hovering over an item of choice

smoky anchor
#

This "preview" is limited only to the bundle item

native ruin
#

Would it be possible to extend / implement from bundle?

sand spire
smoky anchor
smoky anchor
echo basalt
#

You might be able to pull off some hacky resourcepack wizardry

sand spire
echo basalt
#

By emulating every item

#

And using like 8 fonts

sullen canyon
#

if I want to create a copy of some world when a player joins the server, teleport him there and then remove it once he leaves the server, would it be overkill if there are 500 players joining in one moment? Ig yes, then the question how would I be able to handle that

hybrid spoke
#

placeholderapi exists

glass inlet
smoky anchor
echo basalt
#

But ideally you have like 5 servers

#

And some services and shit to track everything

smoky anchor
inner mulch
glass inlet
inner mulch
pallid oxide
pallid oxide
#

ye just noticed it has new pages

sullen canyon
echo basalt
#

Uh you're looking at an old build for that version

sullen canyon
echo basalt
#

I'd keep it at 100/server

hybrid spoke
#

there was a command as well to it

#

?workload

echo basalt
#

?workdistro

inner mulch
sullen canyon
# echo basalt I'd keep it at 100/server

hm, I am making that system for one guy, so I'd say he expects like 1000 players joining at once and he does not want to have more than 1 server, so there is really no way with this system to handle that amount of players on 1 server?

hybrid spoke
#

who tf called it workdistro

sullen canyon
icy beacon
#

not a bad abbr for workload distribution

pallid oxide
#

ye

echo basalt
#

by 1 server do you mean 1 machine or 1 instance

hybrid spoke
sullen canyon
echo basalt
#

because you really really really really really want multiple instances for 1k+

#

IIRC at akuma we did hold 1500 players on prison but everything was packet-based and the main thread tps wasn't great

hybrid spoke
#

yeah you wanna have a cloud for that one

icy beacon
jagged bobcat
#

Made a prison server using packets? Wow

hybrid spoke
#

imagine a skyblock server with only one island for every player but everything is packet based

#

so they each have "their own"

echo basalt
#

you have to do A LOT of tracking and emulating but you can do it all off the main thread

#

And maybe a custom spigot would help

#

it's really just not realistic

inner mulch
pallid oxide
icy beacon
#

Zoltus.

#

Zoltus.

sullen canyon
echo basalt
#

Let's say you have a single "island-world"

#

And you know its default state

#

And you can replicate it with "packet blocks"

#

Everyone's on the same world but no one can see each other

#

When a player breaks a block, you listen to the packets sent, track the block and send it as "broken" and replicate all of the logic

#

You'd need to make a hacked version of every entity in nms so it collides with the right blocks

#

Simulate water physics, all of that

#

When the player leaves, they go to another world like usual

#

When a player rejoins their island, you need to build up the right chunk packets

#

Basically rewriting all the logic from scratch

sullen canyon
#

ahh I see, that would have been much nicer

echo basalt
#

The cool part is that you can do all that tracking async

#

The not so cool part is that you need to rewrite everything from scratch

#

In theory you can have the island server be on minestom

#

And maybe just maybe hold a lot more players

#

But that means writing all your custom logic from scratch because minestom doesn't run your usual bukkit plugins

inner mulch
#

when having objects that can have an impl of something but dont need to, how do i handle such situations? do i need to spam instanceof's to check if an interface is present?

echo basalt
#

uH no

#

Give an example

inner mulch
#

I have a Data object which can have a onload a onunload or neither or both

echo basalt
#

Default empty methods that you call regardless?

#

And if you want to impl them you override

inner mulch
#

i guess, wouldnt that mean dead code tho?

echo basalt
#

Isn't dead code just code that isn't linked anywhere

#

You can make it mandatory to override and just // No-OP it

inner mulch
#

okay

hybrid spoke
#

as long as it gets called its never dead ¯_(ツ)_/¯

rapid vigil
#

Hello, I am trying to get a join message from config but its not working, here is my code:

@EventHandler
public void onJoin(PlayerJoinEvent e) {
  Player p = e.getPlayer();
  e.setJoinMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getInt("join-message").replace("{player}", p.getName())));
}
``` I did it before and it worked now it doesnt
inner mulch
#

are there any errors?

#

and wdym by "not working"?

rapid vigil
#

The code in the IDE is errored

inner mulch
#

okay so red underlines?

rapid vigil
#

yes

inner mulch
#

and what do they tell you

rapid vigil
#

Let me check

echo basalt
#

getInt 🤔

#

Read over the code you wrote and let me know what's wrong

rapid vigil
#

i need to find the erorr

inner mulch
#

its probably because you are trying to edit a int with a string or something

rapid vigil
#

Oh there is a solve thing it said "Put in String.valueOf" and i clicked on it then it worked

inner mulch
#

ok

echo basalt
#

Well, yes and no

native ruin
#

I don't think that's right

echo basalt
#

Do you know what an int is?

rapid vigil
echo basalt
#

Half-right

#

It's a number

native ruin
#

Is your join messenge a number?

echo basalt
#

But 22M is completely wrong :)

#

It's closer to 2.7B

rapid vigil
#

i once saw you can set the value from a specific million to another

echo basalt
#

Now, do you know what a String is?

rapid vigil
#

Its text

echo basalt
#

Cool

rapid vigil
#

Like String string = "Hi"

echo basalt
#

Now, is a message a String or an int?

rapid vigil
#

Its String because a message is usually text

echo basalt
#

Alright

rapid vigil
#

unless you send someone a message saying "1234"

echo basalt
#

And what are you trying to fetch from your config?

rapid vigil
#

But why are you asking me all that

#

it worked

rapid vigil
echo basalt
#

(Wrapping in String.valueOf is the wrong solution to your problem)

echo basalt
rapid vigil
echo basalt
#

Let's start by clarifying that you can have numerical strings

#

"123" is a string whose content is just numbers

#

Now, the final question

#

Why are you calling getInt and not getString then disappointment

rapid vigil
#

i checked now there is getString not getInt but why if String.valueOf() works

echo basalt
#

String.valueOf converts an int to a String

#

So String.valueOf(123) -> "123"

rapid vigil
#

Oh what if it already is a string

echo basalt
#

It compiles, but it's not the right solution

echo basalt
#

String.valueOf("hey") -> "hey"

rapid vigil
#

Oh then its not made for this purpose so i should use getString because its made for this purpose

echo basalt
#

Correct

rapid vigil
#

thanks so much :D

rare rover
#

wtf is a LinkageError?

#

cant seem to fix it (

eternal oxide
#

depends on context

rare rover
#

one sec

#

Caused by: java.lang.LinkageError: loader constraint violation for class me.outspending.invoice.mining.pmines.data.PmineDataManager: when selecting overriding method 'java.lang.Object me.outspending.invoice.mining.pmines.data.PmineDataManager.loadData(java.lang.Object, kotlin.coroutines.Continuation)' the class loader 'InvoiceMining.jar' @4c33cb51 of the selected method's type me.outspending.invoice.mining.pmines.data.PmineDataManager, and the class loader 'InvoiceCore.jar' @1a7ae251 for its super type me.outspending.invoice.core.data.DataManager have different Class objects for the type kotlin.coroutines.Continuation used in the signature (me.outspending.invoice.mining.pmines.data.PmineDataManager is in unnamed module of loader 'InvoiceMining.jar' @4c33cb51, parent loader java.net.URLClassLoader @4e515669; me.outspending.invoice.core.data.DataManager is in unnamed module of loader 'InvoiceCore.jar' @1a7ae251, parent loader java.net.URLClassLoader @4e515669)

#

sob

#

never had this happen before

eternal oxide
#

Kotlin, so no clue

rare rover
#

wouldn't it be the same either way?

#

both use the same exception?

eternal oxide
#

You could be shading something you should not as it refers to a different loader for the objects.

rare rover
#

well both plugins have somewhat the same dependencies cuz it errors if it cannot find the correct dependency

#

i can send both of my build.gradle

chrome beacon
#

My guess would be that you've loaded the Kotlin library twice

rare rover
#

that might be it, but i have too? Or it errors

chrome beacon
#

so Java doesn't know which one the code is refering to

rare rover
#

both basically have the same dependencies but if i dont it wont let me use some of the methods

remote swallow
#

beta version of kotlin eyes_sus

rare rover
#

yeah its always worked fine for me

#

been using it for a while

#

99% sure its something to do with mccoroutine cuz of this Class objects for the type kotlin.coroutines.Continuation

#

i've also tried to compileOnly instead

#

which didn't work

#

with the dependencies that are used in Core

chrome beacon
#

How are you loading the Kotlin library

rare rover
#

it does it for me? wdym, intellij just adds it to the dependencies then it works fine

#

once i compile

chrome beacon
#

So you're shading it?

wet breach
chrome beacon
#

Code that doesn't exist cannot run so you're providing it somewhere

rare rover
#

i ain't specifically shading it but one sec

#

it seems to do it for me:

#

decompiled jar ^

chrome beacon
#

Try relocating it

rare rover
chrome beacon
#

so you avoid loading it twice under the same namespace

rare rover
#

what if i just compileOnly the sdk?

chrome beacon
#

Code that doesn't exist cannot run

wet breach
chrome beacon
#

You need to provide it at runtime

rare rover
#

sad

wet breach
#

I assume you are shading both of those and are those jars yours?

chrome beacon
rare rover
chrome beacon
rare rover
#

ah oki

chrome beacon
#

causing the kotlin classes to be loaded twice

chrome beacon
#

So my guess here is correct

wet breach
#

if both of those jars are yours, then restructure your projects where you are not doing that

rare rover
#

although its coroutine dependent? different Class objects for the type kotlin.coroutines.Continuation

#

or is it kotlin itself

wet breach
#

if they are going to be shaded into a project, it makes no sense to shade anything into those jars

#

and let the last project do the shading

rare rover
#

cuz coroutines are a seperate thing

chrome beacon
rare rover
#

ah

chrome beacon
#

So it has no idea what to do

rare rover
#

so i have to relocate it somewhere?

wet breach
#

when this happens, the class is treated as being different

#

between the two loaders

wet breach
#

so even though you have Object1 loaded, Object1 in the other class is not the same

#

but the JVM can't distinguish this

#

not automatically anyways

rare rover
#

do something like this?

wet breach
#

you don't need to relocate if these jars are being shaded in

rare rover
#

okay...

#

so what would i do then?

#

💀

wet breach
#

don't shade anything into those two jars, the final project which is where you are at, shade everything

rare rover
#

well i dont have a final project doe, they are all seperate plugins

#

just easier to manage

#

imo

wet breach
#

then where are you shading those jars into?

#

there has to be a third project

rare rover
#

oof

#

sad

remote swallow
#

implementation + shadow

chrome beacon
#

Just relocate

#

should fix the problem

rare rover
wet breach
remote swallow
#

its 2 projects so should get different paths

wet breach
#

well if the second project is shading the same thing

#

then one of them doesn't need to shade that one thing

chrome beacon
wet breach
#

if for some reason you need both jars to shade that thing, then instead of relocating, use a filter to exclude from shading then

chrome beacon
#

well you could create a third lib plugin

rare rover
#

which one is better to manage? I can relocate kotlin

#

but

wet breach
#

goal here is not to end up with duplicated classes, which is what relocating will cause to happen

#

so the best thing to use, is exclusions

rare rover
#

well since kotlin has the same path in both plugins

#

couldn't i just compileOnly kotlin's SDK?

wet breach
#

you can target specific artifiacts with exclusions

rare rover
#

since they will both point to the same package

chrome beacon
rare rover
#

well the child plugin depends on core

chrome beacon
#

or can they run separate

rare rover
#

but noth the other way around

#

not*

chrome beacon
#

Then shade kotlin in to core (relocated)

eternal oxide
#

then only include kotlin in teh core

chrome beacon
#

and exclude it from the child

wet breach
#

basically what some of us said in the beginning >>

rare rover
#

i said that so long ago 😭

#

oki

#

tysm for all the help, i was clueless

wet breach
#

fortunately there is people here who know the error you were getting and how to resolve it 😛

rare rover
#

hmm, still doing the same thing

#

compileOnly(kotlin("stdlib-jdk8"))

#

just did dat

#

and all of these are compileOnly because Core already has them:

gilded lily
#

how can i get this text?

rare rover
#

gotta use NMS iirc

chrome beacon
rare rover
#

honestly pretty goofy that bukkit doesn't allow you to grab that string

chrome beacon
#

Feel free to add it yourself

#

?contribute

young knoll
#

It does

#

But you can't open a proper anvil GUI with the api

remote swallow
#

yet

slender elbow
#

@y2k

remote swallow
#

he left

young knoll
#

wat

slender elbow
#

no chance what

icy beacon
#

@miles_dev

#

Wtf

umbral ridge
#

@frostalf

#

omg frostalf left

icy beacon
#

ok no fr y2k left

umbral ridge
#

XD

icy beacon
remote swallow
slender elbow
#

lmao

echo basalt
#

Or we can ban marco instead of having half the community leave

slender elbow
#

block button fr

remote swallow
#

block button no help

#

blocking cmarco doesnt stop seeing everyone else still interacting with them causing more stuff

slender elbow
#

xd

umbral ridge
#

if only we would find anti cmarco guy who would be a total opposite of cmarco

#

then there would be some action

slender elbow
#

I think the most opposite of cmarco is cmarco

remote swallow
#

cmarco is secretly suffering of multiple personality disorder and hasnt had his real personality in 3 years

icy beacon
#

imagine leguernic and cmarco in 1 convo

smoky anchor
#

What is everyones beef with cmarco ?

umbral ridge
wet breach
umbral ridge
#

YOU ARE back

wet breach
#

i never left

empty comet
#

Hi, quick question, kinda lost on the doc with this one, i'm trying to get the itemstacks from a smithingrecipes, it give you a recipechoice but i'm not sure if i can just cast it to Itemstack or not without causing problems :/

#

when i'm creating the craft i can just use the .exactchoice / .materialchoice but when i want to retrieve it the .getitemstack is deprecated

young knoll
#

Check and cast

chrome beacon
#

1.8,3 💀

#

Just use 1.8.8

#

There's no reason to older

rapid vigil
jagged bobcat
#

Use the build tools

chrome beacon
rapid vigil
jagged bobcat
chrome beacon
jagged bobcat
#

1.8.8 ofc

#

1.8.3 is useless now

rapid vigil
#

they run 1.8.8 at the least

chrome beacon
#

Also many vulnerabilities are in the client

rapid vigil
#

is there even spigot for older than 1.8.8

chrome beacon
#

yes

rapid vigil
#

oh

chrome beacon
#

Don't use 1.8.3

#

and depend on Spigot

jagged bobcat
#

Using the build tools and using spigot instead of spigot-api

rapid vigil
#

i think there is a command in the discord here that tells u not to use 1.8 🤣

#

forgot what it was

jagged bobcat
#

It's ?1.8

rapid vigil
#

ooh ye

jagged bobcat
#

I enjoy 1.8 servers too as it has the classy nostalgic feel for me as I started at those times

rapid vigil
#

dont Hypixel which is the most popular mc server write their plugins in 1.8

icy beacon
#

?1.8

undone axleBOT
icy beacon
#

1.8 is only good for pvp realistically

#

the docs for 1.8 api are terrible

rapid vigil
jagged bobcat
#

Bruv just use 1.8.8 and not 1.8.3

icy beacon
rapid vigil
#

it lacks a lot of useful features in the API 2

icy beacon
#

v1_8_R3 is 1.8.8 iirc

#

run buildtools for 1.8.8

jagged bobcat
#

I added adventure chat apis to 1.8.8 myself and lost the patches

#

I cant find it and I spent so long adding the patches so awesome time lost

chrome beacon
#

Just use the adapter

jagged bobcat
#

I want to backport my plugins to 1.8.8 easier so I'm just adding Audience to the player entity

chrome beacon
#

Rerun BuildTools in a clean folder

icy beacon
#

What is the directory you run BuildTools from? It's probably not the reason for your error, but try to make sure it only contains alphanumeric characters and no spaces

chrome beacon
#

folders with spaces do work fine

icy beacon
#

In that case idrk

#

I'll run bt myself and see if I get the same error

#

Wouldn't be surprised tbh 1.8 is old

#

Oh mine's even better lol

chrome beacon
#

right didn't Mojang remove that download

icy beacon
#

One sec I'll download latest bt

#

Mine is quite old

remote swallow
#

use the gui smh

icy beacon
#

Yeah mine is from 27.07.2022 it does not have a gui lol

#

I downloaded latest and the gui is loading rn

#

This is taking its sweet time

remote swallow
#

yeah that happens on slow internet

icy beacon
#

VPN 🥲

remote swallow
#

oh difflib stuff, im out

chrome beacon
#

What did you change

willow fern
#

I got a question how does hypixel skyblocks private island system work, like do hypixel have like 200 different servers for each players private island or is it another system cause I know that whenever traveling from the hub to your private island you get sent into another server

rapid vigil
#

maybe they have 5 players per server and they hide them from each other

willow fern
#

wait but I know that each player can set the time for their island

#

wouldnt that have influence on the other players island aswell?

young knoll
#

It's per world

rapid vigil
#

there's Player#setTime or a method called something similar, it only changes the time for the player and if they relog itll be reset to the normal time

willow fern
#

ah aight

willow fern
jagged bobcat
#

Likely and multiple servers

willow fern
#

Thats gonna take alot of power tho

#

u need some good servers

young knoll
#

Yeah it's multiple servers with multiple worlds per server

jagged bobcat
#

It's hypixel they get 50k+ players

willow fern
#

fax

#

aight ty for the help guys

young knoll
#

Technically

#

Multiple machines with multiple servers with multiple worlds

proud badge
#

Whats the best way to save an ItemStack, byte array?

proud badge
#

wait you can do that?

rapid vigil
#

yes

young knoll
#

Depends

proud badge
#

this makes things so much easier

young knoll
#

Do you want readable or compact

proud badge
#

I wont be reading it while its stored

twin venture
#

what do you mean by compact?

#

like pvp?

proud badge
#

storage compact

twin venture
#

i see

proud badge
rapid vigil
sterile flicker
#
public List<CraftHusk> getZombiesInWorldChunk(World world, int chunkX, int chunkZ) {
        List<CraftHusk> list = new ArrayList<>();
        for (CraftHusk zombie : zombieMap) {
            int chunkXZombie = (int) zombie.getLocation().getX() >> 4;
            int chunkZZombie = (int) zombie.getLocation().getZ() >> 4;

            if (chunkXZombie == chunkX && chunkZZombie == chunkZ && zombie.getWorld().equals(world)) {
                list.add(zombie);
            }
        }
        return list;
    }``` the chunkX variable is the value of the PacketPlayOutMapChunk variable "a" and chunkZ is variable "b". zombie is my custom entity entityzombiehusk, but for some reason, when adding it to the array, I cannot track its position and determine whether the player is in the same chunk
#
PacketPlayOutMapChunk loadChunkPacket = (PacketPlayOutMapChunk) packet;
                        Field xField = loadChunkPacket.getClass().getDeclaredField("a");
                        xField.setAccessible(true);

                        Field zField = loadChunkPacket.getClass().getDeclaredField("b");
                        zField.setAccessible(true);

                        int chunkX = xField.getInt(loadChunkPacket);
                        int chunkZ = zField.getInt(loadChunkPacket);```
blazing ocean
#

hey, im making a custom /enchant command and wondering how i can get the actual vanilla enchantment names, so like minecraft:efficiency instead of Enchantment.DIG_SPEED?

inner mulch
#

so who am i believing at this point?

blazing ocean
#

getItem might be null

rapid vigil
blazing ocean
#

but then again, i dont get it

icy beacon
#

My internet died. Sweet

#

Do you mean the namespaced key of the enchantment?

blazing ocean
#

im pretty sure thats it but i dont entirely know

#

i need all of them as well for autocomplete

willow fern
inner mulch
blazing ocean
cinder abyss
icy beacon
#

Ah missed that msg

young knoll
#

And hope for the best

icy beacon
#

Well try it out ig

blazing ocean
#

how

icy beacon
#

How what

blazing ocean
#

how do i get the keys

#

/ get the value of a key

icy beacon
#

Take the namespaced key of all enchantments and print them out and see if that's what you mean

icy beacon
#

Iirc

blazing ocean
#

deprecated

#

tells me to use the registry

icy beacon
#

Then probably via the registry

willow fern
young knoll
#

I mean you can also do multiple in the same world

#

But it isn't gonna make a huge difference

blazing ocean
#

Bukkit.getRegistry(Enchantment::class.java)!!.toList() is this good

willow fern
#

ye I could but stills gonna take up server storage

blazing ocean
#

or does this just error

willow fern
#

and lag the server

icy beacon
#

Registry.ENCHANTMENT iirc

#

then do map { it.key }

#

after getting all of thjem

blazing ocean
#

alr will try

icy beacon
#

There's an iterator() for them, not sure if there's a way to get all of the values just like that

blazing ocean
#

Registry.ENCHANTMENT.toList().map { it.key.key }

icy beacon
#

You need it.key.value

inner mulch
#

will the loop keep running? or does it stop on error

willow fern
icy beacon
#

NamespacedKey#key is the plugin iirc

#

So in the case of enchantments it'll just be "minecraft"

blazing ocean
#

ah ok

remote swallow
#

people can make custom keys that arent there plugin

icy beacon
#

True

#

But for enchantments it should be "minecraft"

remote swallow
#

yeah

icy beacon
#

To be more precise, the "key" is the "namespace"

#

That's the word

remote swallow
#

unless its a forge/fabric cross over mod and then you can 9 trillion namespaces

icy beacon
#

Lol

blazing ocean
#

swift_sneak, feather_falling, infinity, flame, impaling, protection, knockback, depth_strider, luck_of_the_sea, silk_touch, loyalty, vanishing_curse, fire_protection, channeling, binding_curse, sweeping, quick_charge, bane_of_arthropods, frost_walker, multishot, projectile_protection, aqua_affinity, soul_speed, looting, smite, piercing, lure, riptide, power, blast_protection, mending, fire_aspect, respiration, thorns, punch, sharpness, efficiency, fortune, unbreaking

#

woo

#

can I just say how much I appreciate List#joinToString in kotlin

willow fern
young knoll
#

yep

willow fern
#

that explains it

#

Now I just gotta recreate the system😭

buoyant musk
#

@Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player)) return true;
        Player player = (Player) sender;
        if (command.getName().equalsIgnoreCase("flatworld")){
            World flatworld = Bukkit.getWorld("flatworld");
            player.sendMessage(ChatColor.AQUA + "Cacat!");
            player.teleport(new Location(flatworld , 0 , 0 , 0));
        }
        return true;
    }

#

why doesnt this work

#

i have my world file name flatworld in my server folder

#

for some reason its null

chrome beacon
#

Is the world flatworld loaded

#

Just having the folder won't load it

buoyant musk
#

oh fr?

#

dam

#

lmme see

young knoll
#

You load it with WorldCreator

buoyant musk
#

package testgroup.flatworldhandler;

import org.bukkit.*;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public final class FlatworldHandler extends JavaPlugin implements CommandExecutor {

    World flatWorld;

    @Override
    public void onLoad() {
        flatWorld = new WorldCreator("flatworld").createWorld();
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player)) return true;
        Player player = (Player) sender;
        if (command.getName().equalsIgnoreCase("flatworld")){
            player.teleport(new Location(flatWorld , 0 , 0 , 0));
            player.sendMessage(ChatColor.GREEN + "Welcome to flatworld!");
        }
        return true;
    }
}

#

what da hell

#

ava.lang.IllegalArgumentException: location.world

inner mulch
#

is it faster to create a manager per player when needed and cache the managed data during use for quick access or a manager that accepts the uuid as argument and retrieves the data on every method call (singleton)?

chrome beacon
#

Sounds like you're trying premature optimization again

#

Bad idea, just go for what makes sense (second option)

inner mulch
#

no, im not doing that (optimization) , its just that im unsure whether to use one thing or another, cuz i feel like the first option would be kinda good when methods are used in bulk?

icy beacon
#

Can somebody help me spot concurrent modification in this class? https://paste.md-5.net/avijamupav.java
This is basically a carbon copy of 7smile7's work distro class for evenly distributed workloads that I've written based on my understanding of his code and explanations. When I add 30k+ workloads, it gives me a ConcurrentModificationException at line 65 once but never again, even when I keep readding 30k workloads every now and then.

icy beacon
shrewd dome
#

hey

#

my thing is glitchy

onyx fjord
shrewd dome
#

it says

#

Kicked whilst connecting to lobby: Unnable to authenticate

icy beacon
shrewd dome
#

and when i try to connect

inner mulch
shrewd dome
inner mulch
shrewd dome
#

ty

ocean hollow
#

is it possible to add pdc to ItemStack in the config?

#

and where can I find an example of a serialized item

young knoll
#

Why not just make an itemstack with pdc and then serialize it

#

Bam, you have an example

sterile flicker
#

how can this code be improved so that it can remove NPCs from the tab list in 1.16.5 without the risk that the skin will sometimes disapear ```java
public void showTo(Player player, CraftPlayer npc, int entityID) {
try {
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
PacketPlayOutPlayerInfo info = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc.getHandle());
connection.sendPacket(info);
PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn(npc.getHandle());
Field idField = packet.getClass().getDeclaredField("a");
idField.setAccessible(true);
idField.set(packet, entityID);
connection.sendPacket(packet)

        player.getServer().getScheduler().scheduleSyncDelayedTask(AngryNPC.plugin, () -> new BukkitRunnable() {
            @Override
            public void run() {
                PacketPlayOutPlayerInfo removePlayers = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, npc.getHandle());
                for (Player player : Bukkit.getOnlinePlayers()) {
                    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(removePlayers);
                }
            }
        }.runTaskLater(AngryNPC.plugin, 40));
}```
#

and what could be the reasons that a custom NMS entity sometimes, if you go far away, appears in a suspended state at the player's position and then disappears when moving somewhere (that is, loading another chunk)?

ivory sleet
#

oh wait nvm, ah you’re currying it

sterile flicker
ivory sleet
#

Yea thats fair

#

I mean its a bit weird how u wrap it around 2 tasks

sterile flicker
ivory sleet
#

I think you could just use BukkitRunnable alone

#

Have you read

#

?scheduling

undone axleBOT
sterile flicker
# ivory sleet I think you could just use BukkitRunnable alone

By the way, could you please help me with this problem? custom NMS entity sometimes, if you go far away, appears in a suspended state at the player's position and then disappears when moving somewhere (that is, loading another chunk)? the fact is that I spawn a zombie and replace it with an id for an id npc while the player receives the PacketPlayOutSpawnEntityLiving packet. this way I get an NPC with AI, but if I move away, I sometimes see afterimages of the NPC, it strangely changes its position, maybe I should add handling of the npc unloading event

#
if (packet instanceof PacketPlayOutSpawnEntityLiving) {
                    Field idField = packet.getClass().getDeclaredField("c");
                    idField.setAccessible(true);
                    int id = idField.getInt(packet);
                    Field uidField = packet.getClass().getDeclaredField("b");
                    uidField.setAccessible(true);
                    UUID uuid = (UUID) uidField.get(packet);
                    if (id == 34 && fakeZombies.contains(uuid)) {
                        Field eidField = packet.getClass().getDeclaredField("a");
                        eidField.setAccessible(true);
                        int eid = eidField.getInt(packet);
                        new BukkitRunnable() {
                            @Override
                            public void run() {
                                FakePlayer fakePlayer;
                                try {
                                    fakePlayer = FakePlayer.create("name", "custom_name", player.getWorld(), player.getLocation());
                                } catch (IOException e) {
                                    throw new RuntimeException(e);
                                }
                                System.out.println("SUMMON");
                                manager.showTo(player, fakePlayer.getBukkitEntity(), eid);
                            }
                        }.runTaskLater(plugin, 1);
                        return;
                    }
                }```
ivory sleet
#

Are you using citizens?

sterile flicker
ivory sleet
#

or is this your own stuff?

sterile flicker
ivory sleet
#

Hmm alright and what is it that you’re trying to achieve?

#

Just custom npc nms entities?

sterile flicker
#

also, I am sending packets to the player when loading the chunk ```java
else if (packet instanceof PacketPlayOutMapChunk) {
try {
PacketPlayOutMapChunk loadChunkPacket = (PacketPlayOutMapChunk) packet;
Field xField = loadChunkPacket.getClass().getDeclaredField("a");
xField.setAccessible(true);

                    Field zField = loadChunkPacket.getClass().getDeclaredField("b");
                    zField.setAccessible(true);

                    int chunkX = xField.getInt(loadChunkPacket);
                    int chunkZ = zField.getInt(loadChunkPacket);
                    if (!manager.getZombiesInWorldChunk(player.getWorld(), chunkX, chunkZ).isEmpty()) {
                        new BukkitRunnable() {
                            @Override
                            public void run() {
                                Bukkit.getPluginManager().callEvent(new PlayerChunkLoadEvent(player, chunkX, chunkZ, manager));
                            }
                        }.runTaskLater(plugin, 1);
                        return;
                    }
                } catch(Exception err) {
                    err.printStackTrace();
                }```
sterile flicker
#

Combat NPCs

#

should I hide npc from the entity when its chunk is being unloaded?

lost matrix
sterile flicker
lost matrix
#

I have still no idea why you chose to use reflections when you have nms at your disposal in the first place.
You will trash your servers performance like that.

sterile flicker
#

to be honest, I don't understand how to implement what I need without reflection

rare rover
#

how do i exclude kotlin in gradle?

#

compileOnly doesn't work, also tried shadowJar's exclude

#

decompiled jar ^

tawdry echo
#

When i want to get block and change type chunk needs to be loaded or not?

lost matrix
rare rover
#

no

#

i dont think so

#

my Core has kotlin and is throwing a LinkageError

#

cuz both jars have kotlin

lost matrix
#

Show your build file

rare rover
lost matrix
rare rover
#

i think i figured it out, one of my dependencies was shading the kotlin-stdlib

dawn flower
#

is there something like 'wait' in a BukkitTask?

#

i want to make the task wait afew ticks if a boolean is true

eternal oxide
#

you can "wait" IF async

dawn flower
#

?

lost matrix
dawn flower
#

arent those 2 different things

#

waiting and returning

lost matrix
#

Yes they are indeed very different

dawn flower
#

..

#

then why would i want to return

lost matrix
#

Take a step back and tell us what you are trying to do

dawn flower
#

uh basically an action system and i want a "wait" action

#

if that makes sense

lost matrix
#

Wait for a certain amount of time or until a condition is met?

dawn flower
#

wait a certain amount of time

lost matrix
#

How about BukkitScheduler#runTaskLater(...)?

dawn flower
#

ok

#

how do i get the nearest entity to the player

lost matrix
dawn flower
#

i don't want by distance, i want just in general

#

even if the entity is like 10000 blocks away but it's the nearest

lost matrix
#

In that case you need to get all entities in the same world and check which one has the lowest distanceSq to the player

eternal oxide
#

What are you calling an entity?

#

as dropped items are entities

#

as are Players

#

and mobs

dawn flower
#

all entities