#help-development

1 messages · Page 2243 of 1

outer wadi
#

thanks

noble lantern
#

ofc

ornate patio
#

k

ivory sleet
#

the last parameter in any function can be a vararg (Java)

dusk shell
#

@noble lantern plss

noble lantern
#

If none of those options work, then HorseAPI seems to just be broken asf and you may need reflections

#

or

ornate patio
#

nope, instantly adult

noble lantern
#

Interact event

-> Cancel it

-> add health manually

-> remove 1 from players in hand item

#

-> and play breed particles (if applicable for that item)

#

Thats probably easiest way now since all that shiz doesnt want to work

ornate patio
#

damn

noble lantern
ornate patio
#

ugh

dusk shell
#

this

ornate patio
#

okay wait

#

i looked at the NBT data of a freshly spawned baby horse

#

i found this

#

lemme try that

worldly ice
#

yeah thats what i was looking at

#

doing /summon with a negative age value summons a baby horse

ornate patio
#

maybe it has to be a specific negative value?

worldly ice
#

the horse is age locked right?

ornate patio
worldly ice
#

yeah idk why that wouldn't work

ornate patio
#

age lock doesnt work for hand feeding though

ornate patio
#

thank god

green prism
#

Player chat event isn't cancelled for the entire server spigot, so others plug-in can use the same one everytime. Help?

compact haven
#

cancelling a chat packet still passes it to other plugins

echo basalt
#

uhh pretty sure cancelling packets doesn't

compact haven
#

meaning logging plugins will still log it, etc

#

ah wait

#

I'm stupid

#

yes if you cancel the incoming packet

#

why was I thinking of outgoing

#

kek

#

I mean.. what's the goal

#

we need more info to tell you what's best

#

using the API is probably the best minus a few circumstances

#

the API lol

#

unless the goal is to prevent any part of the server from even knowing that a player chatted, then use the API

#

otherwise, the only way is to add a handler into the netty pipeline & don't let it pass

ancient plank
#

as a wise man once said: if it exists in the api, you should use it.

quiet ice
#

Unless the API is trash, the lessr wise man said

compact haven
#

just ignore the API & write directly into NMS 😏

echo basalt
#

That's exactly what I do lmao

#

I can't bother doing 20 jumps through the API if I can just call a specific field

compact haven
#

what

#

I'm talking about cloning NMS source into your IDE & coding onto it instead of using spigot

echo basalt
#

Ahhhhhhh

compact haven
#

not using reflection to call a method or get a field

echo basalt
#

Ehh

#

Current job has a spigot fork so I just add whatever I need into it

ornate patio
#

what color do you guys think i should make the age

noble lantern
#

That colors fine imo

#

Huh thats actually cool asf

#

Okay you should make a mobile app for it for shits and giggles

mortal hare
#

today it was my first day i've used yield in switch expressions

noble lantern
#

the fuck

#

is yield?

river oracle
#

wtf is yield

#

I've used it in python

mortal hare
#

java 16

river oracle
#

but I forgor

noble lantern
#

time to google

#

brb

mortal hare
#

lambda switch expressions

#

it basically like a return

#

but for switch expressions

noble lantern
#

omg thats badass

#

earlier today i did some stupid code as a joke

#

and its actually a real thing

#

LMAO

#

lemme find it

mortal hare
#
return switch(type) {
  case TYPE.FOO -> {
    if (this and not that) {
      yield true;
    }
    yield false;
  }
}
#

ofc with more cases and more complicated checks

noble lantern
#

It was actually real all along

#

just instead of if use else

#

thats funny af

opal juniper
severe turret
#

tfw you swap to maven to not have to deal with shadowjar, and now your maven refuses to import mongodb

noble lantern
#

Hence why i was suprised when i saw yield, cause i was like oh they actually have that haha

dull goblet
#

Hey could anyone help me? I want to write a plugin for a leveling system for each player. Player will have different skills which each will have a level. How would I store this data? I was thinking reading and writing to a json file which will work and saving it every five minutes and keeping the Arraylist with playerlevel objects in memory. But won't this eventually take up too much resources since this object will become so large?

lost matrix
mortal hare
noble lantern
mortal hare
#
String string = that == this ? "this" : "that";
#

oh

#

you've just earned another hater then

#

i love ternary operator

noble lantern
#

Hate it

#

xD

#

That shit makes dyslexic people shiver in theyre boots

#

im trying to figure out wether b is d or if d is b and you over here like ?? :: ;; ?? ::

#

xD

grand glade
#

Sometimes it’s more comfortable to use it because that could shorten the code a bit

lost matrix
# dull goblet Hey could anyone help me? I want to write a plugin for a leveling system for eac...
  1. Data exists in 2 states: Live and persisted. Or in other terms: In memory or on disk.
  2. Data has scopes. Usually you would differentiate between application scope and session scope.
    This defines when data should be loaded from disk into memory.
    Application scoped data is loaded when the application starts and saved when the application stops.
    Session scoped data is loaded when a session starts and saved when a session stops.
    Now we just need to define a "session" in minecraft terms:
    A session of a player usually starts when he connects to the server and stops when he quits.
    The same goes for chunks for example. A chunks session starts when the chunk is loaded and stops when the chunk is unloaded again.

Let me explain how to approach player sessions....

mortal hare
#

i use ternary operator almost every day.

#

i just dont nest them

noble lantern
#

boolean hah = otherTernary == true ? anotherTernary : null;

dull goblet
#

This is interesting, thanks for explaining 🙂 I'm listening 🙂

noble lantern
#

Data handling is a lot like baton running ngl

#

Hand baton to one person, baton is held by him for a bit, and eventually it comes back around

#

xD

humble tulip
#

Hm since you're talk abt data, what should I do if a player is online on one server and an admin tries to modify something about said player from another server?

#

Like whwre inventories are synced across a group of servers like skyblock

noble lantern
# dull goblet This is interesting, thanks for explaining 🙂 I'm listening 🙂

I typically:

Project startup:

  1. Keep data and only edit the cached values for said player (Typically you have a HashMap<UUID, PlayerDataClass>) inside of a DataManager class that handles all this loading/saving

  2. Have singleton timer that runs async every x minutes, where it loops through the values of that map, and writes them to file (use the async bukkit timer)

Player join:

  1. Load data on async player join event, make sure to execute a blocking get no async or else the player logs in before data is loaded (This is the only non-async operation you should do, is the GET in an async player join)

  2. On player disconnect, write they're cache to file and remove from cache, repeat

Basically what smile was saying but simpled down to minecraft terms

This is just something basic, you can get more complex the more requirements you need, like with smile said when you need data synced between servers, or servers need to share data

humble tulip
#

Problem i had with loading on async join is of players switch servers, it starts loading their daya before it saves on the prev server

noble lantern
#

just throw his data away it he switches servers

#

its no longer needed, hes not there and he didnt do anything to effect his data if he just instantly switched

#

Besides the player cant leav in async player join anyways

#

the cancel button isnt there, so youll have to alt f4, or modded clients

humble tulip
#

Noo

#

If a player quits after playing

noble lantern
#

Theres a bunch of Statistic issues for spigot ide just handle them myself at this point ngl

#

Like BREAK_BLOCk statistic not working if the item doesnt drop an item (BlockBreakEvent#setDropsItems(false))

#

Yep

#

If you setDropsItems false on BlockBreakEvent the BREAK_BLOCK statistic breaks and wont increase

#

I reported it on spigot, doc opened a PR but no new news on it yet

#

ohhh i see

humble tulip
noble lantern
lost matrix
# dull goblet This is interesting, thanks for explaining 🙂 I'm listening 🙂

First we need to define our data class.

@Data
public class PlayerData {
  private long firstLogin;
  private ClanUserData clanUserData;
  private JobData jobData;
}

@Data just generates getter, setter, toString, equals and hashCode methods.

Next we define an Interface which has the task to save/load this data. The implementation can be done with Files or whatever.

public interface PlayerPersistenceHandler {
  CompletableFuture<PlayerData> loadDataAsync(UUID playerId);
  void saveDataAsync(UUID playerId, PlayerData playerData);
}

Dont be scared by the CompletableFuture. You can simplify this if you want.
Next we define our manager class that holds the live player data. This is our single entry point for interacting with player data.

@RequiredArgsConstructor
public class PlayerDataManager {

  private final Map<UUID, PlayerData> playerDataMap = new HashMap<>();
  private final PlayerPersistenceHandler playerPersistenceHandler;

  public void loadPlayerData(UUID playerId) {
    PlayerData loadedData = playerPersistenceHandler.loadDataAsync(playerId).join();
    playerDataMap.put(playerId, loadedData);
  }

  public void unloadPlayerData(UUID playerId) {
    PlayerData liveData = playerDataMap.remove(playerId);
    if(liveData == null) {
      return;
    }
    playerPersistenceHandler.saveDataAsync(playerId, liveData);
  }

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

}

At last we are defining our listener. This couples the data with a players session:

@RequiredArgsConstructor
public class PlayerDataListener implements Listener {

  private final PlayerDataManager playerDataManager;

  @EventHandler
  public void onAsyncLogin(AsyncPlayerPreLoginEvent event) {
    playerDataManager.loadPlayerData(event.getUniqueId());
  }

  @EventHandler
  public void onQuit(PlayerQuitEvent event) {
    playerDataManager.unloadPlayerData(event.getPlayer().getUniqueId());
  }

}
noble lantern
#

the player left, save theyre data?

smoky oak
#

is there a spigot mixin tutorial somewhere thats not restricted to the october twenty fifteen version of the game

noble lantern
#

Didnt expect you to go into full code example damn, save it so you dont have to retype it xD

humble tulip
noble lantern
#

Ide just use a Lib or PDT tbh

humble tulip
#

Player quits at 4503ms

#

Data is saved async at 4527ms

noble lantern
humble tulip
#

Yes

noble lantern
#

For that youll need to mark the servers data state as saving with redis

noble lantern
#

and when you receive the callback of completion, mark them as completed in redis

humble tulip
#

Asyncplayerpreloginevent happens really early

lost matrix
# dull goblet This is interesting, thanks for explaining 🙂 I'm listening 🙂

An example usage would look like this:

public final class SpigotSandbox extends JavaPlugin implements Listener {

  private PlayerDataManager playerDataManager;
  private PlayerPersistenceHandler playerPersistenceHandler;

  @Override
  public void onEnable() {
    this.playerPersistenceHandler = new PlayerFilePersistenceHandler();
    this.playerDataManager = new PlayerDataManager(playerPersistenceHandler);
    PlayerDataListener playerDataListener = new PlayerDataListener(playerDataManager);
    Bukkit.getPluginManager().registerEvents(playerDataListener, this);
  }

}

If you need the player data anywhere, then all you have to do is pass the PlayerDataManager instance there.

noble lantern
#

Theres no real reason to re-invent the wheel

and no

#

Thats why i reccomended a lib...

#

Like NBTAPI

#

It uses reflection

worldly ingot
#

Or Bukkit API

lost matrix
worldly ingot
#

PDC has existed since 1.14

noble lantern
#

^^^^^

#

PDC is godsend

#

Youll be reinventing the wheel with nbt unless your using remapped jar

worldly ingot
#

1.13 had another implementation you could use as well

#

Though I'd avoid it

lost matrix
#

Yes of cource. If you want to write custom data into NBT then just use a pdc

worldly ingot
#

Welp

ornate patio
#

bump

noble lantern
#

NBTAPI it is

lost matrix
#

well...

noble lantern
#

supports more than just nbt tags too

dull goblet
#

Thank you very much for your time @lost matrix i'll deffo look into this 🙂 Don't fully understand everything but time to learn!

#

He is isn't he

noble lantern
lost matrix
smoky oak
mortal hare
#

technically as a storage format no, but in order to manipulate NBT data in minecraft you'll require NMS

noble lantern
#

NBT-API has no nms import, only reflection

mortal hare
#

just check the slot

#

if the item is static and cannot be moved

dull goblet
mortal hare
#

then check the slot index

noble lantern
mortal hare
#

items would be unmovable

#

so the slot indexes wouldnt change

noble lantern
#

nbtapi

quaint mantle
#

Hey, if i set the persistent data of a player, would it persist after login and logouts, and server restarts?

mortal hare
#

for these items

lost matrix
#

Just implement the PlayerDataPersistenceHandler

noble lantern
noble lantern
#

idk how i feel about this, thats something new

mortal hare
#

checking index is way computationally faster than lets say a string or some kind of collection which does not provide O(1) random access

quaint mantle
#

I just need an answer really quick

noble lantern
noble lantern
#

meta data is stuff that will never save-

#

BRO WTF

#

BILL GATES HITTING THE DAB 2022 circa (colorized) 🥵 🥵 🥵 🥵

#

he looks like hes trying to make an F though, not a dab

#

he didnt bend his front arm

dull goblet
lost matrix
noble lantern
#

Json you basically just overwrite the data in said file

mortal hare
#
    @Override
    public int getSize() {
        return 5;
    }

noble lantern
#

And have a file for each player

mortal hare
#

player's inventory menu

#

returns 5

noble lantern
#

and the name of the file is theyre UUID

mortal hare
#

of its size

ornate patio
#

i can search for it real fast

noble lantern
ornate patio
#

found the message link

noble lantern
#

Can see a perfect example for saving your data there (Unles your wanting to split it up even further, essentials just shoves all the player data in the one file which may not be ideal if you wanna catagorize the data)

dull goblet
#

Okay thank you for the help you guys!

#

When should you use YAML to store data or when JSON or does it not matter

noble lantern
#

IMO i would never use YAML for storage, mostly everyone else will say the same

#

YAML for configs only

#

JSON read/write and parse is faster than YAML too, not a lot that its gonna make a worlds a difference, buts still faster

severe turret
#

Anyone has any idea why my maven doesn't want to import mongodb 😆

humble tulip
#

Send ur pom

lost matrix
#

?paste

undone axleBOT
lost matrix
#

It uses Gson as the bridge from live object to json

noble lantern
#

That class is built into spigot?

dull goblet
#

Is CompletableFuture a bit comparable with a task in C#

noble lantern
#

How is it used? Is there some type of handler/dispatcher like the commands/events?

lost matrix
#

Wait

#

No Task

#

yes Task is a good comparison

severe turret
lost matrix
lost matrix
noble lantern
severe turret
#

how do i exclude it

humble tulip
#

scope provided

lost matrix
severe turret
#

ah I see

#

and do you know why my mongo import doesnt work

lost matrix
severe turret
#

Well it doesn't

#

oh well

#

guess I have to learn shadowjar

noble lantern
#

Did you reload maven

severe turret
#

I rebuilt

#

reloaded all projects

#

tried different mongo versions

#

nothing

#

I can import it on gradle

#

but I don't know how shadowjar works

noble lantern
#

implementation?

#

shades it right in for me

#

unless your needing some fancy shiz

severe turret
#

wdym

#

I have no idea how to use it so

noble lantern
#

?paste

undone axleBOT
noble lantern
#

sec

#

Compiles fine and runs fine with all libs

severe turret
#

yeah but that's not spigot

noble lantern
#

Ive never needed to use shadowJar unless im wanting like to exclude stuff im not compiling in or whatnot, similar to maven

severe turret
#

I need it to run from the plugin jar

lost matrix
severe turret
#

if i just compile it into a jar i get classnotfound exception

noble lantern
#

What was your old gradle file

lost matrix
noble lantern
#

send it

severe turret
#

idk why it shows ruby lol

ornate patio
#

i'll check it out after i finish this

lost matrix
severe turret
#

I just click run

#

and it compiles into .jar

noble lantern
#

you need to run shadowJar task

#

not the basic build one

severe turret
#

how

lost matrix
noble lantern
#

should show up in the list when you make it

severe turret
#

I swapped my project from gradle to maven

noble lantern
severe turret
#

because I didn't want to deal shading

#

but maven doesn't want to import mongodb for some reason

lost matrix
severe turret
#

yeah

noble lantern
#

yeah mavens definatly one click and go

humble tulip
#

Did u invalidate caches and restart?

noble lantern
#

^

#

not bad idea

severe turret
#

how

noble lantern
#

top left

#

in the File tab

#

its near the bottomish

humble tulip
#

More middle bottom

#

Iirc

hidden kestrel
#

In my custom chunkgenerator, how woulld I go about making the entire world Plains?

severe turret
#

nope

#

doesn't work

#

only thing that gets imported is the bson

#

other stuff doesn't

#

that's why it's so weird

noble lantern
#

wait send the maven file again

#

Or whichever you were just building with that just did that

severe turret
noble lantern
#

Weird its on maven central to hm

severe turret
#

how do I use the shadowjar

noble lantern
#

When you create the task should just be a button like this one

lost matrix
noble lantern
#

The actual shadowJar task seems simple though ive never made one

#

here sec

#
shadowJar {
    archiveBaseName.set('yourarchivename')
}

IIRC it needs the baseName as a minimum

lost matrix
#

Just let another task depend on shadowJar. This way you also have a one click solution

noble lantern
#

That too ^

hidden kestrel
#

But it seems that BiomeGrid is deprecated

severe turret
#

what do you mean by archive

noble lantern
#

archive is just another word for jar in a sense, the finished product

#

you can also

severe turret
#

do i put that at the end of my build

chrome beacon
#

Didn't you switch to maven?

noble lantern
#

not sure about that part ngl, i know gradle is bitchy sometimes about that

chrome beacon
#

Or did you switch from maven

lost matrix
severe turret
#

I switched from gradle to maven because I didn't want to meddle with shading

noble lantern
#

On this project its near the middle so i guess it doesnt matter where the task goes, just needs to be in global scope (Not nested in anything unless somethings depending on it like smile said)

severe turret
#

and then I found out my maven doesn't import mongodb

#

for some reason

#

so I have to use shadowjar

noble lantern
#

Olivo when profile picture 😦

vital ridge
#

Whats up. What would be the best way to load a chunk before player teleports there? I'm creating a random tp plugin and I don't want the player hovering in the void for 3 seconds when teleporting cuz the chunks are loading.

humble tulip
#

Ur chunks take 3 seconds to load 👀

dull goblet
#

Hey is it normal that pdc doesn't go between two plugins?

chrome beacon
humble tulip
noble lantern
humble tulip
#

That's why namespacedkey take your plugin

noble lantern
humble tulip
#

Ah

noble lantern
humble tulip
#

Makes more sense

severe turret
noble lantern
#

you can call generate on existing chunks iirc, it should harm it unless your using the force setting

dull goblet
#

Wait so if I reference the plugin i want to share it between in the namespacedkey it'll work?

severe turret
#

oh!

noble lantern
#

You can create a static instant for both plugins

severe turret
#

now my gradle has

#

shadow in tasks

#

is that good?

noble lantern
#

have one soft depends on it and use ThatMainClass.INSTANCE from both plugins, relativly easy for that part

dull goblet
#

won't it need to hard depend?

noble lantern
#

either or

#

prolly yes hard depend

#

since your gonna be directly using it and its essential for both to be running

dull goblet
#

It's because i'm making an economy system but with physical currency instead of virtual

vital ridge
severe turret
#

think it's working now

dull goblet
#

So i want to make sure the currency is unique

noble lantern
#

Ahh i see then yeah definatly hard depend both plugins

noble lantern
#

99% sure its Chunk

#

1% is my insecurities

vital ridge
#

Neither of those has it.

noble lantern
#

ohhh fuck

#

sec

vital ridge
#

World has regenerateChunk

noble lantern
#

ahh i think

#

its load(true) but

#

i need to check docs

#

2 mins

#

aha

#

yes

vital ridge
#

but that didnt work, iirc someone said in the forums that if there are no players in radius it gets unloaded again.

#

Anyways I tried it and it didn't work.

noble lantern
dull goblet
#

Would a bukkitrunnable be a good way to store the data every 5 minutes?

noble lantern
#

Hence why you hover for a few secs

noble lantern
vital ridge
#

so loadChunk

#

and then wait like 5 sec

#

Currently I'm waiting 3 sec

noble lantern
smoky oak
#

i find that my server can generate and send to a client about thirty chunks per second. I'm unsure if the cpu or the connection is the throttle though. You should be fine waiting three seconds i guess

noble lantern
#

The method is dangerous because if you load shitloads of chunks, those chunks wont clear out

vital ridge
#

Mhm gotchu, I'll make sure the setforceloaded back to false

#

after tping him

noble lantern
noble lantern
#

Just dont use it when searching for a safe location

#

thats the main issue when using it

smoky oak
#

cough accidental dos cough

noble lantern
#

(I learned that the hard way)

vital ridge
#

But should I only load 1 chunk?

humble tulip
#

Yes

noble lantern
#

You could load around yes

#

But the one is fine

humble tulip
#

One is fine no?

noble lantern
#

Yes one is fine, i had nicer effects loading a 3x3 when i made mine though

#

just better TPS performance overall somehow

#

but one was still fine

vital ridge
#

How does it work tho? If you load just one the others will load faster and easier?

#

the others around the one you just loaded

noble lantern
#

i loaded the 3x3 before the player TPd

#

i used a CompletableFuture and called all those methods for the chunks effected

severe turret
#

oh my god

humble tulip
#

The rest will load around them

severe turret
#

it finally works

noble lantern
#

and in the callback, i teleported the player on future completion

severe turret
#

thank you :D

#

god bless gradle

humble tulip
#

Chunks can be loaded async!?

noble lantern
#

nonononoon

#

it was a sync future

#

you can run them on main thread

humble tulip
#

Uhh then why use a future?

noble lantern
#

Just easier because you get the callback from the future

#

so you can easier see the flow of whats executing

smoky oak
#

... 💡
I'm going to make a plugin that loads chunks in front of you if you move exactly north, south, east, or west, and snaps boats on blue ice to cardinal directions

#

nether highways will work so much better

noble lantern
#

IE like this

#

So loadChunksAroundLoc(loc).thenAccept((listOfChunks) -> { // teleport, chunks are all loaded and ready for us to use });

severe turret
#

How do I stop NotNull from shadowing in gradle

severe turret
#

compileOnly?

lost matrix
smoky oak
#

im more doing this because of elytra than boats

hidden kestrel
smoky oak
#

if the chunks arent loaded you get rubberbanded

hidden kestrel
#

This is what I have so far

smoky oak
#

and thats bloody annoying

noble lantern
smoky oak
#

*the chunks you travel through

hidden kestrel
#
public class TerrainGenerator extends ChunkGenerator {
    
    
    private boolean generateStuff;
    
    public TerrainGenerator() {
        generateStuff = true;
    }
    
    @Override
    public void generateNoise(WorldInfo worldInfo, Random random, int chunkX, int chunkZ, ChunkData chunkData) {
        if(chunkX < 2 && chunkZ < 2 && chunkX > -2 && chunkZ > -2) {
            generateStuff = true;
            return;
        } else generateStuff = true;
        for(int y = chunkData.getMinHeight(); y < 61 && y < chunkData.getMaxHeight(); y++) {
            for(int x = 0; x < 16; x++) {
                for(int z = 0; z < 16; z++) {
                    chunkData.setBlock(x, y, z, Material.BEDROCK);
                    chunkData.setBlock(x, y + 1, z, Material.WATER);
                    chunkData.setBlock(x, y + 2, z, Material.WATER);
                }
            }
        }
    }
    
    @Override
    public boolean shouldGenerateNoise() {
        return generateStuff;
    }
    
    @Override
    public boolean shouldGenerateBedrock() {
        return generateStuff;
    }
    
    @Override
    public boolean shouldGenerateSurface() {
        return generateStuff;
    }
}

#

and I'm trying to make it only generate plains biomes, because an ocean biome .. surrounded by water .. is dumb

#

Also if you could let me know if I've done it in a super inefficient way or if this is fine

#

This is the first time I'm really digging into worldgen

smoky oak
#

you can set the biome but that wont change the blocks there

hidden kestrel
#

Crap

#

So I can't force it to only generate plains??

noble lantern
#

it will change grass block looks tho

#

nah not that sadly

#

all thats on you to do

#

world gens are pretty complex ngl

#

people who make those are a different breed

#

they scare me

smoky oak
#

maybe steal the nms code for flatland generation

#

and give it the plains biome

noble lantern
#

superflat should be easy to generate

#

its just generating blocks at a set y axis infinitely

smoky oak
#

actually if you use the plains preset it generates trees, flowers, and small ponds

dull goblet
#
public void saveAllPlayerData() {
        for (Map.Entry<UUID,PlayerData> data :
                playerDataMap.entrySet()) {
            if(data == null) {
                continue;
            }
            playerPersistenceHandler.saveDataAsync(data.getKey(), data.getValue());
        }
    } 

Would this be good to put them all in a different operation or should happen in one async method instead of another per player

noble lantern
#

Ohhhh

smoky oak
#

youre thinking about the normal superflat

noble lantern
#

I mean tbf

#

generating trees wouldnt be too hard

#

flowers maybe

smoky oak
#

eh the one time i tried generation i got a diagonal line of blocks

noble lantern
#

just bc theres so many

smoky oak
#

while trying to do a random distributino

#

so

#

eh

noble lantern
#

hahaha xD

#

well you do a chance per block

hidden kestrel
#

I mean so I guess I should just do custom terrain then right

lost matrix
smoky oak
#

was a structure actually

noble lantern
#

Ohhh

#

structures littlle more complex bc they can go outside the chunk 😠

smoky oak
#

every chunk whose added x and z coord was a specific number generated that

#

i made sure to contain them in the chunk

#

not too big

noble lantern
#

ahh

#

okay thats good

smoky oak
#

but still weird that going north and east sixteen blocks gives you another copy

#

as said

#

supposed to be random

dull goblet
smoky oak
#

i need to take a look at how math random seeds and massive numbers interact

#

cuz i bit shifted the z value by ten i believe then added the x value

noble lantern
#

yeah fuck this

#

im out

#

thats beyond anything i could ever do LMAO

smoky oak
#

hey a vertical ocean

#

aaand thats where i leave

lost matrix
vital ridge
#

So if I just load the chunk it gets unloaded pretty quick

#

I assume

noble lantern
#

NMS maybe

vital ridge
#

CUz when I get there I'm still in the void

noble lantern
#

or reflection

#

Might be able to access that method that way

#

Dont exactly have time to run through something like that rn haha

lost matrix
#

Let me check. Wasnt there an article on how to handle nms block placement?

#

Ok lets see what we can optimize here

vital ridge
#

it saves the chunk on disk

#

what does that mean?

dull goblet
#

@lost matrix i put my project on github and wanna credit you how do you want me to do it? Like what name or something

hidden kestrel
#

This is what I have

#

using the code I posted earlier

hidden kestrel
#

but I'm trying to make it like in 0.30

lost matrix
#

First of all:

            if (blocks.containsKey(chunkKey)) {
                blocks.get(chunkKey).add(new NMSBlock(pos, blockData));
            } else {
                final List<NMSBlock> value = new ArrayList<>();

                value.add(new NMSBlock(pos, blockData));

                blocks.put(chunkKey, value);
            }

Should be

blocks.computeIfAbsent(chunkKey, key -> new ArrayList<>()).add(new NMSBlock(pos, blockData));

It does the same just with some fewer cpu cycles.
@weary geyser

hidden kestrel
# hidden kestrel using the code I posted earlier
public class TerrainGenerator extends ChunkGenerator {
    
    
    private boolean generateStuff;
    
    public TerrainGenerator() {
        generateStuff = true;
    }
    
    @Override
    public void generateNoise(WorldInfo worldInfo, Random random, int chunkX, int chunkZ, ChunkData chunkData) {
        if(chunkX < 2 && chunkZ < 2 && chunkX > -2 && chunkZ > -2) {
            generateStuff = true;
            return;
        } else generateStuff = false;
        for(int y = chunkData.getMinHeight(); y < 61 && y < chunkData.getMaxHeight(); y++) {
            for(int x = 0; x < 16; x++) {
                for(int z = 0; z < 16; z++) {
                    chunkData.setBlock(x, y, z, Material.BEDROCK);
                    chunkData.setBlock(x, y + 1, z, Material.WATER);
                    chunkData.setBlock(x, y + 2, z, Material.WATER);
                }
            }
        }
    }
    
    @Override
    public boolean shouldGenerateNoise() {
        return generateStuff;
    }
    
    @Override
    public boolean shouldGenerateBedrock() {
        return generateStuff;
    }
    
    @Override
    public boolean shouldGenerateSurface() {
        return generateStuff;
    }
#

This one

lost matrix
#

Then this:

final Chunk nmsChunk = ((CraftChunk) this.world.getChunkAt(new Location(this.world, pos.getX(), pos.getY(), pos.getZ()))).getHandle();

Can be improved:

final Chunk nmsChunk = ((CraftChunk) this.world.getChunkAt(pos.getX() << 4, pos.getZ() << 4)).getHandle();`
#

Dont see any other low hanging fruits there

#

Yeah caching the chunks might be a good idea. Not super important tho.

lost matrix
hidden kestrel
lost matrix
#

With a

Map<Long, Chunk>
And computeIfAbsend
#

Or you can group the locations by their chunk id (long)

#

None of those are worth doing

#

Chunks are cached internally anyways.

#

So after the first getChunkAt() call it doesnt really matter

#

You will only play for micros at that point

#

It would be async. So you would have to completely re-write your method

#

And it would be a lot more complicated

noble lantern
#

CompletableFuture isnt too complicated tbh

#
getChunkAtAsync().thenAccept((theChunk) -> {
    // do your SYNC stuff here, main thread here!!
});
lost matrix
#

Does it need to be a bulk method? Because getChunkAtAsync() might spread the placement over
several ticks

noble lantern
#

Doesnt Future have a way to execute multiple futures at once?

#

I know javascripts Promises do

#

CompletableFuture.allOf(. . .)

lost matrix
#

Well... then going for nms stuff is pretty useless. You can easily place hundreds of thousands of blocks
in one seconds with the spigot method by simply spreading it over 20 ticks

noble lantern
#

ouah

#

fawe doesnt even do that in a second i dont think haha

#

maybe 5-10 seconds

lost matrix
#

Well. Whats wrong with using fawe?

noble lantern
#

^ faweapi

#

You can use the normal world edit api with fawe iirc

hybrid spoke
#

edit the file manually dankfingers

lost matrix
#

I can do probably billions per seconds if you give me a good CPU and an NVMe with enough PCIe lanes.
Ill just pump out a gazillion region files with only stone in them.

noble lantern
#

copy paste the same file over and over

#

boom

ornate patio
#

@lost matrix i've implemented the code you sent me to the best of my ability but I don't really see anything happen

#

I'm stepping it 10 times per tick like you said

lost matrix
#

Oh yeah. There is quite a bit more you have to do.
So all this code does is find a suitable block in your surroundings.
You still need to add a simple pathfinder goal and let the entity wander to that block.
(When one is found)

ornate patio
#
public class BlockFinderTask implements LoopingTask<SuperiorHorse> {
    @Override
    public int getIntervalTicks() {
        return 1;
    }

    @Override
    public void runLoopingTask(SuperiorHorse superiorHorse) {
        for (int i = 0; i < 10; i++) {
            superiorHorse.getBlockFinder().step();
        }
    }
}

LoopingTask is an interface that I've created (i'm 100% sure it works i use it everywhere)

ornate patio
lost matrix
#

Just use the nms pathfinder goal

lost matrix
hidden kestrel
#
public class TerrainGenerator extends ChunkGenerator {
    
    
    private boolean generateStuff;
    
    public TerrainGenerator() {
        generateStuff = false;
    }
    
    @Override
    public void generateNoise(WorldInfo worldInfo, Random random, int chunkX, int chunkZ, ChunkData chunkData) {
        if(chunkX < 16 && chunkZ < 16 && chunkX >= -16 && chunkZ >= -16) {
            generateStuff = true;
        } else {
            generateStuff = false;
            
            for(int y = chunkData.getMinHeight(); y < 61 && y < chunkData.getMaxHeight(); y++) {
                for(int x = 0; x < 16; x++) {
                    for(int z = 0; z < 16; z++) {
                        chunkData.setBlock(x, y, z, Material.BEDROCK);
                        chunkData.setBlock(x, y + 1, z, Material.WATER);
                        chunkData.setBlock(x, y + 2, z, Material.WATER);
                    }
                }
            }
        }
    }
    
    @Override
    public boolean shouldGenerateNoise() {
        return generateStuff;
    }
    
    @Override
    public boolean shouldGenerateBedrock() {
        return generateStuff;
    }
    
    @Override
    public boolean shouldGenerateSurface() {
        return generateStuff;
    }
    
    @Override
    public boolean shouldGenerateDecorations() {
        return false;
    }
    
    @Override
    public boolean shouldGenerateCaves() {
        return false;
    }
    
    @Override
    public boolean shouldGenerateMobs() {
        return false;
    }
    
    @Override
    public boolean shouldGenerateStructures() {
        return false;
    }
}```
Does anybody know why it appears insisting on not knowing what chunks are within x 16 and -16 & z 16 and -16?
https://i.imgur.com/fPVz2ju.png
ornate patio
#

with a bunch of other util functions

lost matrix
ornate patio
#

i know its weird but i have a reason

#

i first tried to do everything within the nms horse

#

but it caused spigot to desync with nms

ornate patio
#

for example if i set the horse armor with nms, and then tried to get the horse armor using spigot

#

spigot would say there is none

#

so I basically try to do everything on the bukkit entity, but if I can't then i resort to the NMS entity (such as for pathfinding)

lost matrix
#
public class CoolHorse extends Horse {
  public CoolHorse(EntityType<? extends Horse> var0, Level var1) {
    super(var0, var1);
  }

  public void setArmorThroughBukkit(ItemStack armor) {
    ((CraftHorse) this.getBukkitEntity()).getInventory().setArmor(armor);
  }

}
ornate patio
#

oh

#

lmao damn

lost matrix
#

NMS Horse with bukkit bridge for the armor

ornate patio
#

well too late i already built like my entire plugin based on this system

lost matrix
#

big oof. How do you even keep track of the horses when they are being unloaded then?

ornate patio
#

like, save their data?

#

what do you mean keep track

lost matrix
#

If a horse gets unloaded with a chunk and loaded again later, how do you persist the data?

ornate patio
#

Any changes I make to the SuperiorHorse will automatically update the persistent data container of the horse

ornate patio
#

so that if the server restarts, it basically kills the original horse and replaces it with a new version of the NMS horse

lost matrix
#

Do you extend the nms horse at all?

ornate patio
#

yes

#

i have a SuperiorHorseEntity which extends the nms horse

#

which is contained within SuperiorHorse

pallid forge
#

very quick question, how do you get a world? I want to set a gamerule, and i think i need the world to do that.

iron glade
#

Can someone help me with my english? How would you call it when a player is in lava or water? Player is in liquid? xd

lost matrix
#

Ok. Inside this nms class you need to step the finder algorithm until it found a block or is done and didnt find a block.
If it found a block you need to let the horse have a different AIGoal -> Pathfinding to the found loction.

lost matrix
ornate patio
#

and how would it navigate around obstacles?

lost matrix
ornate patio
#

how lmao

pallid forge
ornate patio
#

would I use getNavigation().moveTo() for a bunch of different block positions?

lost matrix
lost matrix
pallid forge
#

oh lol thats really easy

#

thanks

ornate patio
#

@lost matrix So what I'm getting so far is this:
Override the tick method of the NMS horse, make it step the algorithm 10 times. (with a super call first of course)

Create a pathfinder goal that will start if a target block is found by the block finder, and finish when the horse can no longer reach that block or its hunger/thirst requirement is done.

but how do I get the target block from the block finder, and how would I make the horse navigate around obstacles?

lost matrix
ornate patio
#

with one getNavigation().moveTo()?

lost matrix
#

Actually the StepAlgorithm needs to be adjusted.
step() should return a StepResult instead of a boolean.
[SUCCESS, PROGRESS, FAILURE]

ornate patio
#

is StepResult a custom enum?

lost matrix
#

Yes it should be a custom enum

ornate patio
#

ok done that

tender shard
#

does someone know how I can set the log level per thread in logback?

<configuration>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%level] [%thread] %msg%n</pattern>
        </encoder>
    </appender>

    <root level="debug">
        <appender-ref ref="STDOUT" />
    </root>
</configuration>

My log looks like this:

.....
01:13:25.586 [DEBUG] [JDA MainWS-ReadThread] Setting incomplete count to 1
01:13:25.587 [DEBUG] [JDA MainWS-ReadThread] Starting 75 second timeout for 1 guilds
01:13:25.664 [INFO] [JDA MainWS-ReadThread] Finished Loading!
01:13:25.666 [DEBUG] [JDA MainWS-ReadThread] Finished setup for guild 988732516372480020 firing cached events 0
01:13:25.723 [INFO] [main] Successfully logged in to Discord
01:13:25.732 [DEBUG] [main] Registered command "help" to executor com.jeff_media.quizbot.command.commands.HelpCommand
.....

I'd like to set the log level to debug for my "main" thread, but only to info for the "JDA MainWS-ReadThread" thread

ornate patio
hidden kestrel
ornate patio
#

wait I’m an idiot I didn’t send the actual code 🤦‍♂️

#

there

sterile token
#

Paste url please

#

?copy-paste

#

?copy

delicate lynx
#

?paste

undone axleBOT
sterile token
#

Ohh thanks

valid sorrel
#

I managed to make a plugin that hangs the server without any loogs

iron glade
#

Any idea why this always says the slot's size is 0?

    public void addItemToRandomSlot(Player p, ItemStack item) {

        List<Integer> slots = new ArrayList<>();

        for(int i = 0; i<35; i++) {

            if(!(p.getInventory().getItem(i) == null) && p.getInventory().getItem(i).getType() == Material.AIR) {
                slots.add(i);
            }

        }

        Bukkit.broadcast(Component.text("" + slots.size()));
        Random r = new Random();
        int slot = slots.get(r.nextInt(0, slots.size()));

        p.getInventory().setItem(slot, item);

    }```
```java.lang.IllegalArgumentException: bound must be greater than origin```
valid sorrel
#

is there any way to debug it

eternal night
#

I mean

#

generally indentify what might hang the server

valid sorrel
#

my plugin has a part about reading the log

#

maybe it reads the log and every time it logs

eternal night
#

how do you read the logs

valid sorrel
iron glade
eternal night
#

because iirc getItem(int) on an inventory would return null for an empty slot

eternal night
iron glade
#

Oh so I have to use ```if(p.getInventory().getItem(i) == null || p.getInventory().getItem(i).getType() == Material.AIR) {

eternal night
#

Yea

iron glade
#

Makes sense

#

ty

eternal night
#

should also obviously check if slots is empty

#

else your code errors when someone has a full inventory

valid sorrel
#

hmm

#

so until reading the console it works

#

but then I send it to websocket

#

maybe it logs stuff when I send?

#

but the thing is I don't have any sockets open so it shouldn't send in the first place

outer wadi
#

Is there any library in Java for some "time parser" with a String? Like 3h would give me whatever it could be whatever ms there is in 3h or just a new Date + the 3h

#

Preferably that doesn't require me to pass in a full date string like 0d 3h 0m 0s

iron glade
#

Is there a way to launch a player more than ~60 blocks?

#

Which one for example? Should look smooth

sharp flare
iron glade
#

y axis

sharp flare
#

#setVelocity

iron glade
#

Already doing that, but no matter how high I set the y the player is still not launched more than 60 blocks up

valid sorrel
#

you have to repeatedly launch the player every tick until the player is at the point in which they will be able to reach 60 blocks

iron glade
#

hm okay

quaint mantle
#

anyone can help me please?

dusk flicker
#

just read the exception

#

Somehow cant find the wiki article on it, but understanding basic Java exceptions is a must

ivory sleet
#

getEffectivePermissions

#

and loop that

#

I mean

#

PermissionAttachementInfo encapsulates PermissionAttachment basically

obsidian roost
#

hey I'm new to config stuff, how would I access the encircled objects in an arraylist?

humble tulip
#

U can get it as a set

#

Not arraylist

#

Config#getConfigurationSection("Parkour.1").getKeys(false)

obsidian roost
#

ah ok thanks a ton then

humble tulip
#

That just gets the naems

dusk flicker
#

There is probably a library those already Pvbble, wouldent be surprised lol

#

Check that out on how they did it

#

and then you can make it from that

ivory sleet
#

well if said tournament alr played out

#

why not a binary tree structure

dusk flicker
#

Personally id overcomplicate it

#

Make a good few objects, few enums etc

#

whole constructor to create a tree in real time

iron glade
#

I have an ItemStack being a placable block with a PDC, is there a way to check when this item gets placed?

humble tulip
ornate patio
#

what's a good "happy animal" sound

earnest forum
#

dog whining

ornate patio
#

that would be nice but

#

the animal is a horse in this case

river oracle
#

death sound

ornate patio
#

jesus

iron glade
humble tulip
ornate patio
#

hmm

#

orb pickup actually sounds better to me

#

level up is too dramatic

earnest forum
#

purple advancement sound'

ornate patio
#

mmm

mortal hare
#

i finally made it. After SO MANY ATTEMPTS ITS FULLY SYNCED

#

fully hidden player's inventory contents, you cant interact with player inventory at all

#

and it restores to the previous state after inventory has been closed

ornate patio
#

A library could’ve done for you lmao

quaint mantle
#

hopper gui?

ornate patio
#

inventoryframework

quaint mantle
#

thats simple

mortal hare
#

this is packet based, so no storing of items is done

quaint mantle
#

whats the point of that

mortal hare
#

lemme show you

#

resource pack uis can now overlay the player's inventory

#

by using technique with font bitmaps

#

you can make interactable menus without having items inside the GUI, which can be accidentally moved and due to ping the overlay would wobble in that case

#

with trading gui

quaint mantle
#

😮

#

isnt that already doable tho

mortal hare
#

you can do that but in that case any player's contents will be visible through the overlay

#

but this is mostly for uis that are big

#

for example you cant create item model that can overlay contents

#

bigger than a scale of 4

#

for trading gui scale of 4 isnt enough to properly overlay

river oracle
# mortal hare

you know thats a smart approach now that I think about it

#

just making it look like the item was never put in the inventory

#

by manipulating packets

#

I've been dwelling on how to do something similar.

mortal hare
#

here's the packet handling in action

#

armor slots are not being removed while ui is open

river oracle
#

this is actually a neat concept dude are you going to open source your code?

mortal hare
#

i think so, im working on UI lib rn so

river oracle
#

I'm working on one as well ironically

#

though who isn't working on a UI lib

mortal hare
#

it was a pain in the to make it

river oracle
#

I haven't even gotten to custom textures yet I'm still working on base stuff

mortal hare
#

its very hard since player's inventory is really hardcoded so i needed to inject packet handling and send packets manually to the player to sync it also, i needed to prevent PICKUP_ALL action from collecting items of the invisible player's inventory contents, so i needed to remove literally Slot objects from NMS container menu in order to achieve full sync

river oracle
mortal hare
#

cool

daring egret
#

    public void onMenuClick(InventoryClickEvent e) {

        if (e.getCurrentItem() == null) return;

        if (e.getView().getTitle().equalsIgnoreCase(ChatColor.YELLOW + "Punishment Menu")) {
            if(e.getSlot() == 13) {
                e.setCancelled(true);
                e.getWhoClicked().sendMessage("Stop That");
            }
        }
    }

}```
#

can someone tell me why this is just not registering the click

#

i've tried checking the material, the display name and the lore

river oracle
daring egret
#
        //GUI COMMANDS & GUI EVENTS
        getCommand("punish").setExecutor(new PunishCommand());
        getServer().getPluginManager().registerEvents(new PunishGuiListener(), this);
#

yeah

river oracle
#

did you add debugs to see where it cuts off at

#

oh shit

#

lmfao

#

I'm so stupid

daring egret
#

lol?

river oracle
#

you don't have one

daring egret
#

oops

#

i'm such an idiot lmao

#

thanks man

#

It works now xD

river oracle
#

happens toe veryone

daring egret
#

yo

#

another question'

#

i'm struggling really bad with giving a variable to another class

#

it's breaking a lot

river oracle
#

?di

undone axleBOT
daring egret
#

ooh

#

wat

#

i don't really get it

river oracle
#

Learn more Java before coding a plugin then

daring egret
#

lmao

#

ok

river oracle
#

Di is an industry standard

stone heath
#

How can I implement dialogue as a part of my plugin? As in ask a question, get a response back and then ask another question based on the response(already set responses ofc), etc.?

sweet pike
#

How can I achieve a chat colour gradient like the one below?

short raptor
#

Is there a way to change the max amount of hunger meatsticks similar to how you can change the max amount of hearts?

short raptor
stone heath
sweet pike
stone heath
stone heath
sweet pike
dry marsh
#

hi everyone

#

can i get some help?

undone axleBOT
#

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

dry marsh
#

ok

#

so im trying to make a loot crate

#

where the player right clicks the item

#

and then it subtracts one and then gives them loot

#

i figured out the right click and the subtract but not the loot

#

i have certain items i want to give them but i dont know how you would pick some from those

vocal cloud
#

Store the items in a database and then query them based on chest opened? Use a yml config? I don't understand your exact dilemma.

dry marsh
#

no but i dont want to give them all

#

how do you pick like certain ones

earnest forum
#

basically trying to figure out a random loot system

#

like a loot table

dry marsh
#

here is my current code

earnest forum
#

what is that language

#

asm?

vocal cloud
#

You sent it in java bytecode looking stuff lol

dry marsh
#

so do i need to code a random function?

vocal cloud
#

What did you send us lol

dry marsh
#

LootCrate.asm

vocal cloud
#

Lmfao

#

Yeah if you're doing asm then you'd definitely need to write one yourself there

dry marsh
#

ok, will look into it. so then i just call the random function to give the list of items?

vocal cloud
#

shrug1 Not an asm expert. This is after all a java focused server

dry marsh
#

ah okay ill try to ask on minecraft forum, thanks!

quaint mantle
#

this brotha sent in assembly

#

wtf

#

pretty impressive

humble tulip
#

Wat

#

He's making a plugin in assembly?

quaint mantle
#

that would be something

#

its like the shit that i sent in this server sometimes

#
fn main() {
    println!("Hello, world!");
    let binding = core::iter::Iterator::collect::<Vec<u8>>(core::iter::IntoIterator::into_iter(0u8..=8u8));
    let bytes = Vec::<u8>::as_slice(binding.as_ref());
    println!("{}", usize::from_be_bytes(core::result::Result::<[u8; std::mem::size_of::<usize>()], std::array::TryFromSliceError>::unwrap_or_else(core::convert::TryInto::<[u8; std::mem::size_of::<usize>()]>::try_into(&bytes[1..][..std::mem::size_of::<usize>()]), |err| { std::process::exit(core::iter::Iterator::map(core::iter::IntoIterator::into_iter(String::as_bytes(&ToString::to_string(&err))), |b| *b as i16).sum::<i16>() as i32) })));
}
iron glade
#

Does anyone have an idea how I would check if a player is falling?

earnest forum
#

velocity?

iron glade
#

yeah

#

What I'm currently using is checking #getVelocity().getY() < 0

#

but this is kinda buggy since I found out the main y velocity when standing around is -0.0078

earnest forum
#

maybe make like a threshold

#

some small decimal like -0.05

humble tulip
iron glade
#

Is there a way to calculate like the gravity or smth?

#

currently on my server the main y velocity seems to be -0.0784000015258789 and idk if this can be changed or smth

humble tulip
#

What're you tryina do?

iron glade
#

Checking if a player is falling and as soon as he hits the ground do stuff

#

currently having a runnable firing in the move event

humble tulip
#

That's tough

#

What abt if they fall in water?

iron glade
#

already taken care of that

humble tulip
#

Can't a runnable that checks if the player is on the ground each tick sort that for u?

#

If not on ground and velocity negative falling

#

If on ground, falling stopped

#

^^ if they were previosly falling

iron glade
#

yeah thats all working out the only problem is the event keeps firing like 20 times after im cancelling the task

humble tulip
#

What event?

iron glade
#

MoveEvent

#

seems to be really triggerhappy

humble tulip
#

Well yeah

#

Looking around with ur mouse trigfers moveevent

iron glade
#

I'm spawning a firework as soon as the player lands on the ground and it keeps firing like 20 times

#

can't get it to fire only once

humble tulip
#

Can u send code?

#

When they're falling, put them in a set called falling

#

When they're onnthe ground, if they're in the set, that means that the player fell

#

So you can do whatever and then remove them from the set

iron glade
#

I'll try that give me a sec

humble tulip
#

That way when the runnable checks on tje next tick and sees the player on tje ground, it does nothing since they're not in the set

restive mantle
#

is there a way to get all the structures that exist as a list. Structure manager shows it have none in it

restive mantle
#

Random can return the same value multiple times

smoky oak
#

set the seed to system time in nanoseconds

quaint mantle
#

you're lucky

#

show your code

smoky oak
#

isnt it just that he initialilzes it too fast?

quaint mantle
#

idk]

smoky oak
#

probably is:

Additionally, default-constructed instances do not use a cryptographically random seed unless the system property java.util.secureRandomSeed is set to true.
I think its just using the system time in millis as seed, but i could be wrong

iron glade
#

Not a dev related question but maybe someone can help me out, are there any other MLG types in MC besides water bucket, cobweb and haybale? (ignoring slime blocks)

earnest forum
#

ladder

quaint mantle
#

latter

smoky oak
#

random should have a setseed method. I'm unsure if it works in this instance, but you could check if ThreadLocalRandom#current#setseed#nextInt works

quaint mantle
#

end portal

smoky oak
#

um

#

isnt that the seed

#

ah no its not

quaint mantle
#

you're actually getting the same number every time?

smoky oak
#

its possible that your jvm initializes the same way every time

native nexus
#

What about using SecureRandom ?

iron glade
native nexus
crisp steeple
#

anyone know how to get the windowid of the inventory a player is in? ive tried doing this but it just opens a wrong inventory, and doing some debug on client and server shows the id this returns isnt the same one the client opens

humble tulip
#

use a for loop

smoky oak
#

one layer deep lava doesnt absorb fall damage

humble tulip
#

no like

#

for (int i = 0; i< 1000; i++) {

#

like that

#

and print 1000 random numbers

quaint mantle
humble tulip
#

then something si wrong with your computer

smoky oak
#

why dont you just use math random

native nexus
#

SecureRandom is thread safe

#

It extends random

smoky oak
#

multiply it by your maximum value + one, then cast it tointeger

humble tulip
#

Random random = new SecureRandom();

#

random.nextInt();

native nexus
#

No worries, why do you need to multithread it btw? 😮

shy shadow
#

Hey guys !
Quick question about the docs !

I'm reading this right now : https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/PlayerAdvancementDoneEvent.html

And was wondering, looking at the getAdvancement() method, I see that it returns the completed advancement.
How can I know on which form it returns it ? Like how do I know how to compare it with an existing advancement please ? 😄

humble tulip
#

To compare it you can compare the keys

#

Of the advancement

#

Not sure if there's a better way

#

Advancement#getKey

sweet pike
shy shadow
humble tulip
#

it's made of 2 parts, the namespace and the key

#

hence the name

#

the namespace can be for eg. bukkit or minecraft or your plugin name

#

the key is like the advancement name or whatever

#

just do key.eqauls(otherKey) to compare em

shy shadow
#

Ok I see ! Thanks a lot for the quick course, really helpful ! ❤️

grand hull
#

How to make an array of all players names?

#

thank you

humble tulip
#

Bukkit.getOnlinePlayers().stream().map(HumanEntity::getName).toList().toArray(new String[0]);

#

shorter^^

chrome beacon
#

String[]::new 🙂

humble tulip
#

:o

#

Why does List#toArray require an array

#

And the method that doesn't requires casting

hollow belfry
#

when i try to register login authme with bedrock account in java server there come cheats are not allowed

#

how can i fix it

grand hull
ivory sleet
#

just use toArray directly

humble tulip
ivory sleet
#

nope

humble tulip
#

Really?

hybrid spoke
#

why would you if you already pass in the type

ivory sleet
humble tulip
#

why does it need an IntFunction?

ivory sleet
#

the length

chrome beacon
#

toArray(String[]::new)

quiet ice
#

Or Just use an Array of length 0

#

So .toArray(new String[0])

#

Oh actually that is stream

humble tulip
quiet ice
#

Probably works either way heh

humble tulip
#

this works

#

but not new String[0]

#

that's really dumb

shy shadow
#
@EventHandler
    public void onAdvancement(PlayerAdvancementDoneEvent e){
        Advancement advancement = e.getAdvancement();
        Player p = e.getPlayer();

        if (advancement.getKey().equals(NamespacedKey.minecraft("story/upgrade_tools"))){
            p.sendMessage("action to do here");
        }
    }```

I'm doing something wrong I think, but can't really figure out what 🤔
humble tulip
#

uhh

quiet ice
humble tulip
#

are u sure the upgrade tools namespacedkey is story/upgrade_tools?

hybrid spoke
shy shadow
#

I'm not 100% sure, I didn't really know where to find the info, found on the fr-minecraft.net website that they display the ID of advancements

#

So I assumed it was it xD

humble tulip
#
        String[] names = Bukkit.getOnlinePlayers().stream().map(HumanEntity::getName).toArray(new IntFunction<String[]>() {
            @Override
            public String[] apply(int i) {
                return new String[0];
            }
        });
#

it requires an intfunction just to create an array the size of the stream???

static ingot
#

Just use String[]::new

#

instead of that ugly mess, kek

humble tulip
#

ye ik but like why does it need it in the first place?

static ingot
#

the int is the array size

#

it just initializes an array with the specific size necessary

humble tulip
#

or why does toArray() return an Object[] and not T[]

#

it's just stupid

#

Bukkit.advancementIterator().forEachRemaining(advancement -> System.out.println(advancement.getKey()));
@shy shadow

static ingot
#

the IntFunction also gives it the type so that it can return it as T

humble tulip
#

put that to see all the advancements

static ingot
#

lol

shy shadow
#

p.sendMessage(String.valueOf(advancement.getKey()));

#

Tried to do that on the event xD

humble tulip
#

that's also possible ye

shy shadow
#

It didn't work sadly

#

Will try your 😄

humble tulip
#

why cant it just be a List<Player>

#

if i want it to be a list<Player> i need to cast it

alpine urchin
#

i think its a set and even an array on some older versions

shy shadow
#

omg minion I'm so sorry

#

I've been trying this for 2 hours and just realised I didn't registered the event LOL

humble tulip
#

:/

#

LOL

#

It's alright

#

Happens

quiet ice
shy shadow
#

Hahahaha minion imma go back to sleep

#

I was also connected on the wrong server

#

XD

#

Btw it works perfectly now, thank you very much for your help !

humble tulip
#

Ohh cuz they used ?

vital ridge
#

Iam creating a random teleport plugin. My goal is to load the chunk before teleporting there so the player won't hover in void. I'm on version 1.8.8. How could I achieve that? I can do chunk#load() but I can't set it to be force loaded so it unloads before I get there.

opal juniper
#

if you load the chunk without any reason to keep it loaded it will just be unloaded - you need to update to modern to use plugin tickets

vital ridge
#

So you cannot really achieve that in 1.8.8?

#

What about ChunkUnloadEvent?

#

I could cancel that.

opal juniper
#

no you cant

#

it doesnt implement Cancellable

tender shard
#

oh that's also not available in 1.8 lol

#

I wonder if the 1.8 api has any features at all

hybrid spoke
#

just load it again on unload

vital ridge
tender shard
dawn hazel
#
    @EventHandler
    public void onInteractEvent(PlayerInteractEvent e) {
        //Check if action was right click

        if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
            e.getPlayer().sendMessage("test");
        }
    }```
for whatever reason its sending doubles of the same message and i dont know why
vital ridge
#

I'll give it a try.

tender shard
hybrid spoke
dawn hazel
#

i see

hybrid spoke
opal juniper
#

EW