#help-development

1 messages · Page 787 of 1

wet breach
#

states can have their own textures is what it comes down to

upper hazel
#

As I understand it, you need to change its state to the desired one during placement so that the texture of the block changes?

wet breach
#

states are like changes, and with changes means a way to convey that visually. Not all states are visually represented

#

therefore you can make use of them, even more so when there is unused states to be used 🙂

upper hazel
#

hm this cool i gess

#

but I guess the states are strictly limited

#

spawnerBlock with an entity, is it just a block or also an entity?

#

I heard ItemAdder uses them

#

for textures

wet breach
#

but also an item if its in the eventory

grim hound
#

So

#

AsyncPreLoginEvent

#

Can have more than one thread invoking it?

wet breach
#

you mean listening to it?

#

or you mean when its thrown?

#

its async because netty threads you know

grim hound
#

So it's invoked from the netty threads?

grim hound
eternal night
#

yes

#

the event is called from a network thread not the games main thread

#

hence your logic in your listeners for AsyncPreLoginEvent is invoked on the respective network thread too

grim hound
#

I just asked whether it was one or many threads

eternal night
#

implementation detail

#

for most server implementations, multiple threads are used tho

#

you can block the pre login event just fine if that is what you are asking

#

other players should be able to connect just fine

wet breach
#

so you can in theory have that event fire at the same time 4 times

#

but its one of the few events as lynx said that actually happens outside of the game loop

grim hound
eternal night
#

Given that there is a main game thread and at least one netty thread, yes

grim hound
#

I already got the answer

eternal night
#

perfect

grim hound
#

Thank you

#

Btw

#

Is a thread equal to another in terms of computational power?

eternal night
#

"yes"

grim hound
#

If I recall correctly they aren't only if comparing user to virtual threads

eternal night
#

virtual threads aren't really a thing in the JVM yet, iirc they are still in preview ?

#

oh wait no

#

they were finalised in 21

grim hound
#

What

#

Wait

#

Then how come

#

A server have like 52 java threads

#

With only having like 16 physical ones

eternal night
#

what

#

platform threads can exceed the core count ?

#

its just that the OS scheduler deals with them

#

instead of the JVM itself (which is the case for virtual threads)

grim hound
eternal night
#

(not that plain java threads are typical OS threads, more of a JVM implementation detail as to what it ends up being)

lost matrix
# grim hound I really don't know whether you're asking or being annoyed

The OS has a scheduling strategy which lets the pyhsical threads work on any OS threads + the OS itself.
Sometimes this means the physical thread actually jumps between two os threads every few micros/nanos for just
one or two instructions (At least in real time operating systems). Each windows, linux and mac have different strategies.

But you could in theory start 100 threads in java which are all handled by a single physical core if your OS and/or jvm impl suck.

glossy venture
#

the reason its still advantagious to create multiple threads in that case is because of blocking operations which halt the thread meaning it isnt scheduled so other threads have more resources to do their work

eternal night
#

gasps

slender elbow
#

with all the plugins you have doing blocking IO in that event that would massively increase the ping of 1/n of your player base lol

#

n being the number of Netty threads

eternal night
#

I mean it isn't run on a netty thread...

#

The auth threads are still network threads

#

stop the flame

slender elbow
#

the server thread is also a network thread if I perform network ops on it

eternal night
#

There you go

slender elbow
#

:yesyes:

eternal night
#

now you think correctly

#

phew

#

auth threads are just network threads to the mojang services weSmart

grim hound
rotund ravine
slender elbow
#

your thread not running because something else is is also surprisingly inefficient

#

it wildly depends on the kernel every how many cycles it switches processes

#

and what strategy etc

#

even for Linux they seem to use a new scheduler every few versions lmao

eternal night
#

something has to support my e-cores NODDERS

storm crystal
#

how can I use interact entities?

eternal oxide
#

interact entities?

young knoll
#

What do you want to use them for

spare hazel
#

how can i detect armor breaking?

#

or any tools

rotund ravine
#

There is an event iirc

spare hazel
#

found it

storm crystal
young knoll
#

You spawn, move, and remove them just like any other entity

#

As for reading what's inside them, you can use entity.getBoundingBox with world.getNearbyEntities

storm crystal
young knoll
#

BoundingBox

storm crystal
#

yeah but how do I extract entities inside that bounding box?

eternal night
storm crystal
#

but that gets nearby entities in world

young knoll
#

Yes

eternal night
#

it has a BoundingBox overload

young knoll
#

And one of the options you can pass to it is a bounding box

eternal night
#

so it gets the "nearby entities in the world" that are insidethe bounding box

storm crystal
eternal night
#

hm ?

#

are you asking what an overload is ?

storm crystal
#

yes

eternal night
#

Method overloading in java is a feature that allows a class to have more than one method with the same name, but with different parameters.

storm crystal
#

first time im hearing it

summer scroll
#

Is it possible to get others minecraft server data like player count maybe? For example I know a server with ip play.minecraft.net and I wanted to get the player count of that server, is that possible?

rotund ravine
#

Yeah

eternal night
#

there should be a couple of libs out there that do pings for you

rotund ravine
summer scroll
rotund ravine
#

Probably?

young knoll
#

All you need to do is send a query packet to the server and read the response

#

Could make a quick api for that ig, But I assume one exists already

slender elbow
#

yeah I mean there's a million

#

(I counted them all/

#

it's a fun quick project

young knoll
#

Ah then I could be 1,000,001

#

How exciting

summer scroll
#

I could just use PlaceholderAPI Pinger placeholders smh.

#

Thanks for the help anyway guys!

upper hazel
#

i try find note block texture but i have just 1 texture

#

but how i undestand note block has 800+ textures

grim hound
#

Is there a way to change max players at runtime?

eternal oxide
#

in your resource pack. you add them

#

every change to teh NotBlock Meta makes it a different block, as far as your resource pack knows

upper hazel
eternal oxide
#

They are still just Noteblocks

#

look at teh resource pack I linked you

upper hazel
#

were

eternal oxide
#

if you place a noteblock and change it's values you geta different texture

upper hazel
#

but when you change the itemStack it stops stacking with the main itemStack and if noteBlock works like that it shouldn’t stack when dropped

eternal oxide
#

you change when you place

young knoll
#

Wait I have a sample

upper hazel
#

does this mean there will be 800+ note Blocks in the inventory?

young knoll
#

no

#

There is always only 1 item for a given block

upper hazel
#

i mean if you click and break block

#

you will have 1 state

young knoll
upper hazel
#

2 state

#

3

#

e t c

young knoll
#

Any state will drop the same item when broken

#

By default anyway

upper hazel
#

ah i see now

#

default drop?

young knoll
#

what?

upper hazel
#

I'm confused when you put a block it doesn't store information inside itself. And that means the drop will be normal standrard item

eternal oxide
#

when you break a block you get back it's default block

upper hazel
#

yea

eternal oxide
#

no matter if you changed it when placing

upper hazel
#

I forgot that the block does not store information (

young knoll
#

I mean, the states are the information in this case

upper hazel
#

although it would be great if this was added

shadow night
#

What if BlockBreakEvent -> if brokenBlock.getMetadata()... -> blockItem.getItemStack()...

young knoll
#

You could but metadata isn't persistent

#

There is block PDC, but in this case you can just use the states to identify the block

shadow night
#

I know command blocks can store nbt while in the inventory

rotund ravine
#

?customdata

#

I know there was some util using the chunk pdc

shadow night
#

?blockpdc

undone axleBOT
shadow night
#

That one?

rotund ravine
#

Probably idk

upper hazel
# rotund ravine ?customdata

By the way, persistentDataContainer is not persistent, right? This means that the data from the chunk pdc must be stored somewhere

eternal night
#

persistentDataContainer is not persistent, right?

shadow night
#

It literally says persistent

#

How much of what did you smoke

upper hazel
#

ah yes i bad speak eng 👍

#

didn't read the literal translation

young knoll
#

Idk why you don't just use the state as a unique identifier

upper hazel
#

the library from that link about customBlock must store data somewhere, but how does it do this if the data is not constant

rotund ravine
#

It is

young knoll
#

It stores it in chunk pdc

shadow night
#

PDC (Persistent Data Container) is persistent, it just stores stuff in the chunk pdc, as chunks, worlds, entities (including block/tile entities) and items can have pdc

rotund ravine
#

It stores it as nbt data

upper hazel
#

oh

#

so is "persistent" ahh

#

I'm already confused about these translators

shadow night
#

Metadata = not persistent
Pdc = persistent

rotund ravine
#

Pdc = persistant data container

#

Persistent*

shadow night
#

Yes

#

The only case where storing stuff in metadata is acceptable is when you don't need it to persist

young knoll
#

As long as you clean it up

#

Otherwise yay memory leaks

rotund ravine
#

He’s nonnative it seems

upper hazel
#

i not eng

grim hound
#

I under stand

upper hazel
#

how much here eng?

shadow night
#

Do you mean much

upper hazel
#

yes

rotund ravine
#

I am not english, but i did have english at high levels in school

shadow night
#

I am not english, but I accidentally learnt it once

rotund ravine
#

Happens to the best of us

#

English is a plague

shadow night
#

Worse than french?

rotund ravine
#

French is also a plague

valid burrow
valid burrow
#

english is so easy

rotund ravine
#

Still a plague

storm crystal
slender elbow
#

erm 🤓 old German, actually, not Latin

hushed spindle
#

i smelled drugs

#

whats going on here

rotund ravine
#

Drugs are good for you

#

When doctors prescribe them properly

blazing ocean
#

hiya, im currently using this code:

        fun createFakePlayer(name: String, displayName: Component, uuid: UUID): Player? {
            val packet = PacketContainer(PacketType.Play.Server.PLAYER_INFO)

            // Set the parameters
            packet.modifier.writeDefaults()
            val profile = WrappedGameProfile(uuid, name)
            packet.playerInfoDataLists.write( // error is appearing here
                0,
                listOf(
                    PlayerInfoData(
                        profile,
                        0,
                        EnumWrappers.NativeGameMode.SPECTATOR,
                        WrappedChatComponent.fromText(name)
                    )
                )
            )

            packet.playerInfoAction.write(0, EnumWrappers.PlayerInfoAction.ADD_PLAYER)

            // Send the packet to all players
            for (player in Bukkit.getOnlinePlayers()) {
                MCInfinite.protocolManager!!.sendServerPacket(player, packet)
            }

            // Get the player
            val player = Bukkit.getPlayer(uuid)
            player?.displayName(displayName)

            return player
        }```

and getting this error: ```
Caused by: java.lang.ClassCastException: Cannot cast java.util.ArrayList to java.util.EnumSet
    at java.lang.Class.cast(Class.java:3889) ~[?:?]
    at com.comphenix.protocol.reflect.accessors.DefaultFieldAccessor.set(DefaultFieldAccessor.java:41) ~[ProtocolLib.jar:?]
    ... 23 more```
#

(protocollib)

hushed spindle
river oracle
#

is there any way to specifically disallow comments passing a certain character limit in IntelliJ, currently I hard wrap at 120 characters for code, but I want it to be shorter for comments

slate tinsel
#

Hi, if I want to teleport a player to the nearest safe place within maybe 9x9 blocks and if that example is slabs, stairs, etc. then the player should be teleported to the nearest place correctly how can I do it?

lost matrix
slate tinsel
blazing ocean
#

ok so packet.playerInfoAction.write(0, EnumSet.of(EnumWrappers.PlayerInfoAction.ADD_PLAYER)) doesn't work because it needs an int and a EnumWrappers.PlayerInfoAction

lost matrix
# blazing ocean hiya, im currently using this code: ```kotlin fun createFakePlayer(name:...
    PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);

    Set<EnumWrappers.PlayerInfoAction> actions = EnumSet.of(
        EnumWrappers.PlayerInfoAction.ADD_PLAYER,
        EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE,
        EnumWrappers.PlayerInfoAction.UPDATE_LATENCY,
        EnumWrappers.PlayerInfoAction.UPDATE_DISPLAY_NAME
    );

    packet.getPlayerInfoActions().write(0, actions);

    // You got this part already
    WrappedGameProfile profile = new WrappedGameProfile(UUID.randomUUID(), "Bob");

    List<PlayerInfoData> playerInfoDataList = List.of(
        new PlayerInfoData(profile, 0, EnumWrappers.NativeGameMode.SURVIVAL, null)
    );
    
    packet.getPlayerInfoDataLists().write(0, playerInfoDataList);
blazing ocean
#

ill try

blazing ocean
#

error occurs in this line: packet.playerInfoDataLists.write(0, playerInfoDataList)

lost matrix
blazing ocean
#

v5.1.0

lost matrix
#

Server version?

blazing ocean
#

1.20.1

lost matrix
#

Weird

#

Try writing the actions first and check if its throws an exception

blazing ocean
#

so not writing the playerinfo?

lost matrix
#

Write the info after writing the actions

blazing ocean
vital vortex
blazing ocean
#

somebody delete that

blazing ocean
lost matrix
lost matrix
blazing ocean
#

this is so frustrating

haughty granite
#

hi, has anyone here already configured Plan Analytics on an https domain name with nginx?

scenic onyx
#

how i can add an attribute "String" in an item?

chrome beacon
#

If you want to save a string on an item you can use pdc

#

?pdc

scenic onyx
#
 private static String getRomanNumeral(int number) {
        if (number <= 0 || number > 3999) {
            throw new IllegalArgumentException("Il numero deve essere compreso tra 1 e 3999");
        }

        String[] romanSymbols = {"I", "IV", "V", "IX", "X", "XL", "L", "XC", "C", "CD", "D", "CM", "M"};
        int[] arabicValues = {1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000};

        StringBuilder result = new StringBuilder();
        int i = arabicValues.length - 1;

        while (number > 0) {
            if (number >= arabicValues[i]) {
                result.append(romanSymbols[i]);
                number -= arabicValues[i];
            } else {
                i--;
            }
        }

        return result.toString();
    }

how i can optimize it?

glad prawn
#

cache your romanSymbols 🤓

#

and the one below it too 🤓

compact haven
#

(by cache he means make it a constant)

heavy mural
#

My display entity seems to remove it's render before the chunk that it is positioned on is out of render distance. View range (from display entity) and simulation distance (from server properties) and Entity-tracking-range (from spigot.yml) all seem to not fix the issue.

Is there any other setting I am missing?

stone cosmos
#

Oh did not know that, thought it would use packets so it could track stuff off the main thread, that explains the higher performance costs of it compared to others.

rustic hamlet
#

is anyone here familiar with bungeecord messaging because for some reason mine stopped working after migrating my server

drifting viper
#

I even think they didn't fixed the 3+ block vanilla Step yet

stone cosmos
#

Yeah, I know, I had, well not the best experience with it, I switched to smth else already, but it's still surprising me that he does not use packets.

rustic hamlet
# scenic onyx ```java private static String getRomanNumeral(int number) { if (number ...
public class IntegerToRoman {

    public static void main(String[] args) {
        int number = 1000;
        String romanNumeral = intToRoman(number);
        System.out.println(number + " in Roman numerals is " + romanNumeral);
    }

    public static String intToRoman(int number) {
        String[] romanNumerals = {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};
        int[] values = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
        String romanNumeral = "";
        for (int i = 0; i < values.length; i++) {
            while (number >= values[i]) {
                romanNumeral += romanNumerals[i];
                number -= values[i];
            }
        }
        return romanNumeral;
    }
}
drifting viper
rustic hamlet
#

yea

#

is anyone here familiar with bungeecord messaging because for some reason mine stopped working after migrating my server

stone cosmos
drifting viper
#

I actaully don't know, I think Minecraft Anti-Cheats can be very profitable because there are not Many Good Solutions but a high demand, Many Server Owners don't know what they should do

drifting viper
rustic hamlet
#

wait i might be onto the solution

#

stand by

rustic hamlet
#

now for some reason bungee messages not getting through

stone cosmos
drifting viper
valid burrow
rustic hamlet
valid burrow
#

i mean not even servers like hypixel have a working one

#

3 year old clients still bypass it

drifting viper
#

Im working on a own Anti-Cheat but don't have really time for that :C

shadow night
valid burrow
#

if you manage to make a good one

#

you will make hella bank

#

good luck man

drifting viper
grand flint
#

what event runs when u middle click a block in creative

young knoll
#

InventoryCreativeEvent

grand flint
#

thx

#

it returns the block clicked too right?

#

with its properties?

severe hinge
warped shell
#

any ideas on how to minimize tps drops from hoppers/tileentities?

warped shell
#

ye i alr have it

#

lol

valid burrow
#

not much more you can do i believe

warped shell
#

ye thats why im asking around

#

i dont know anything else

#

ty though

valid burrow
#

most servers jusr limit hoppers peer player

#

or redstone in general

warped shell
#

well id rather not have to do that but I see the point

#

I alr added a tile entity limit for like 1k per chunk

#

its a last resort for somone actually trying to lag the server

#

but some farms need hoppers

valid burrow
#

well then the only thing you can do is

#

upgrade server

#

maybe

warped shell
#

ye i plan on it really soon

valid burrow
#

use the block feature ad soon as it drops below 15tps

warped shell
#

ye

#

i alr completely stopped entity spawning

#

below 15 tps

valid burrow
#

mhm

#

good

#

could also lower chunk loading

warped shell
#

ye i also made entities no spawn in new chunks for 30 seconds

#

that really helped

rotund ravine
#

Isn’t there a tick limiter for hoppers

warped shell
#

hm

#

maybe i could just stop all hoppers

#

below 15 tps

rotund ravine
#

Also. Don’t crosspost in 4 places wtf

warped shell
#

lmao

#

no one answers in paper somtimes

valid burrow
warped shell
#

lol

valid burrow
#

my server with 60 members answers faster

rotund ravine
#

I am gonna block every single person who crossposts from now on

warped shell
#

lmao

#

ig im blocked

#

for asking a question

#

rip

dry hazel
#

reasonable

warped shell
#

fr

blazing ocean
storm crystal
#

if I want to spawn Interaction entity in x,y,z location and set it to be 1x1x2 rectangle, would it's length be equally distributed in that center?

#

or would it count the length from a corner like that?

eternal oxide
#

Entities spawn by corners

storm crystal
#

alright

#

how can I change their dimensions?

eternal oxide
storm crystal
#

oh okay I forgot to cast Interaction

#

thats why I didnt see it

young knoll
#

Shouldn't have to cast if you use the fancy spawn method

river oracle
mental crystal
#

Hello, i have made a plugin long time ago with some friends and now tried to use it again, tho when starting it i get this error:

#
java.lang.NoClassDefFoundError: de/tr7zw/nbtapi/NBTItem
        at de.xxxxxxxxx.xxxxx.Main.onEnable(Main.java:88) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:266) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_20_R2.CraftServer.enablePlugin(CraftServer.java:548) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3936-Spigot-dba3cdc-5a2d905]
        at org.bukkit.craftbukkit.v1_20_R2.CraftServer.enablePlugins(CraftServer.java:462) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3936-Spigot-dba3cdc-5a2d905]
        at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:577) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3936-Spigot-dba3cdc-5a2d905]
        at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:400) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3936-Spigot-dba3cdc-5a2d905]
        at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:250) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3936-Spigot-dba3cdc-5a2d905]
        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:954) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3936-Spigot-dba3cdc-5a2d905]
        at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:298) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3936-Spigot-dba3cdc-5a2d905]
        at java.lang.Thread.run(Thread.java:840) ~[?:?]
Caused by: java.lang.ClassNotFoundException: de.tr7zw.nbtapi.NBTItem
        at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:160) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:112) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
        at ....
#

Does someone maybe have an idea on why this is not working?

eternal oxide
#

Missing/outdated NBTapi

quaint mantle
#

hi is there a way to set a specific line of a text display

#

i have a lot of characters to put into a text display but if i do it all at once the client disconnects

mental crystal
rotund ravine
#

Add the plugin to plugins

storm crystal
#

what kind of problem is that?

#

first time im seeing it

chrome beacon
#

You casted Interaction to LivingEntity

#

Which won't work since Interaction isn't a LivingEntity

storm crystal
#

but im getting interaction

chrome beacon
#

Not all entities are living entities

storm crystal
#

okay I get it

#

how can I make armorstand's rotation same as player's?

eternal oxide
#

setDirection

mental crystal
river oracle
#

How big can a minecraft world be? I'm kinda of curious right now if its plausible to use an Int2Object map in my situation by instead of having a 1d array with 3 entries I could pack all of the coordinates together using bit shifting and use that as the map key otherwise I'll prob just go with the array

tall dragon
#

isnt it pretty much unlimited?

#

as far as your hardware takes you i guess

river oracle
tall dragon
#

yea

tall dragon
#

there does seem to be one at 30m blocks

#

but it can be removed

#

if one would like that

#

i see no reason the world coulnt be bigger than that

rotund ravine
#

Oh u difn’t mean size?

river oracle
#

mainly need to know as I'm making a plugin that relies on world coordinates for keeping track of certain structures and this is a super rare edge case, but I gotta know

rotund ravine
#

I think it can be infinite

#

But past a certain point it becomes broken

tall dragon
#

yea

river oracle
river oracle
quaint mantle
#

yes i can

#

but ill have over 300 textdisplays

river oracle
#

time to replan I think then

storm crystal
#

how can I check if a certain entity UUID is already stored in this ArrayList?

tall dragon
#

#containsKey

slender elbow
quaint mantle
#

yes but i went from 300 to 10 fps after a few

#

server was running 20 tps

storm crystal
tall dragon
#

yea

#

that will return either true or false if it contains it as key

quaint mantle
#
playerHitEnemies.get(uuid) != null
#

:)

storm crystal
#

I want to see if it has THAT particular entity UUID in here

tall dragon
#

i mean, if you are going to end up getting that list. its the same

#

else, contains is fine

quaint mantle
storm crystal
#

problem is that entity is added to ArrayList despite me saying in code that if it's been added it shouldnt be added 2nd time

hazy parrot
#

computeIfAbsent is redudant here

young knoll
#

You are checking if the map has the entity as a key

#

Not the list

#

Also, you could use a set to avoid duplicates

storm crystal
#

I was told to use it like that

hazy parrot
#

mb

storm crystal
#

first value is player UUID

#

second value is ArrayList of entitiy UUIDs

#

I want to check if ArrayList of that specific player contains that entity UUID already

#

but idk how to work in nested lists

hazy parrot
#

map.get(playerUUID).contains(entityUUID)

#

as coll suggested you probably want to use Set there

#

instead of list

storm crystal
#

why

pseudo hazel
#

since there is no point in having duplicates

#

and if you arent gonna have duplicates, sets are the way to go

fiery blade
#

Hello, is there any way to spawn a lightning and not affect the player who spawned it (I explain?), I have a code that spawns a lightning and affects nearby entities in a limit, but I have already tried several alternatives and still doing damage, the code is as follows:

player.getWorld().strikeLightning(player.getTargetBlock(null, 100).getLocation());

                    int radius = Main.getInstance().skills.getInt("lightning.radius");
                    double damage = Main.getInstance().skills.getDouble("lightning.damage");

                    player.getWorld().getNearbyEntities(player.getLocation(), radius, radius, radius)
                            .stream()
                            .forEach(entity -> {
                                        if (entity instanceof Player && entity != player) {
                                            ChatUtil.console("PLAYER DAMAGED BY A LIGHTNING: " + ((Player) entity).getName());
                                            ((Player) entity).damage(damage);
                                            ((Player) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 200, 2));
                                        }

                                    }
                            );
young knoll
#

strikeLightningEffect

storm crystal
#

so Set cant store duplicates by default?

hazy parrot
orchid trout
#

bro plzzz help my es ku el no work'
myeskuel

pseudo hazel
#

ur what

river oracle
#

mysql

orchid trout
#

my es ku el

river oracle
#

don 't ask how tf I figured that out

#

just say MySQL bro

storm crystal
#

if I had a set

river oracle
#

dont' try to confuse the people helping you kinda idiotic

storm crystal
#

cuz no duplicates

pseudo hazel
#

?

#

yeah true

#

you just put it in

#

thats the whole point of a set

orchid trout
pseudo hazel
#

they are talking to crackma im pretty sure

fiery blade
storm crystal
#

wait how do I add one Entity UUID to Set in to this kind of Map

pseudo hazel
#

playerHitEntities.get(playerUUID).insert(uuid)

#

or add I mean

dry hazel
#

well you need to computeIfAbsent it, since there won't be a set entry for that uuid

rotund ravine
#

Why do you use a concurrenthashmap

pseudo hazel
river oracle
#

since Entities can't really be accessed via asynchronous threads

storm crystal
#

xdddddddddddd

river oracle
#

please know the data structures you are using

tall dragon
#

do u know what they are for

river oracle
#

but it works worse for your case

pseudo hazel
#

then they just need a better server 🤷

storm crystal
#

how do I compute if absent with list

pseudo hazel
#

its a map

#

you dont have a list?

storm crystal
#

uh its map<uuid, set<uuid>>

#

so how do I compute if absent it

pseudo hazel
#

yeah

storm crystal
#

with set

#

yeah not list, set

pseudo hazel
#

wdym

hazy parrot
#

same as u did with list ?

dry hazel
#

literally the same thing but with a set implementation

#

i.e. HashSet

storm crystal
#

like its -> with ArrayList

pseudo hazel
#

wait so why do you need computeifabsent

storm crystal
#

someone told me I need it

#

lol

pseudo hazel
#

thats not a good enough reason to add it

pseudo hazel
#

I dont even know how you want to add stuff to your sets

storm crystal
pseudo hazel
#

yeah they were talking about when you dont have a player id in the map yet

storm crystal
#

yeah and I dont have them

pseudo hazel
#

okay then use computeIfAbsent on the map

#

not on the set

storm crystal
#

eh

#

its like that for ArrayList

#

how is it for Set

#

how to do it for Set

#

its what I am asking for

#

not how to computeifabsent for set

dry hazel
#

dude please learn basic java data structures

#

HashSet instead of ArrayList

pseudo hazel
#

or a concurrentHasSet if you like those 😛

stone cosmos
#

Just curios

orchid gazelle
#

For resource pack dev, how tf do I center my model in blockbench so that the arrow is accurately on the position I want it to be?

pseudo hazel
#

what arrow

orchid gazelle
#

I use displayentities to simulate projectiles

#

when spawning it without resourcepack, it's centered on the vector where I want it to be

#

when I use the resourcepack, the model is off in position

pseudo hazel
#

oh, idk sorry

orchid gazelle
stone cosmos
pseudo hazel
#

a plugin probably

hazy parrot
#

yeah i would also assume they are making a plugin

storm crystal
grim hound
#

It ain't wrong if you're sure that's how it should be done

storm crystal
#

it makes playerUUID and adds this EntityUUID to list

stone cosmos
storm crystal
#

and then just adds them if PlayerUUID exists

#

I guess

#

it works like that at least

grim hound
#

But the creation only takes places for when it's absent

pseudo hazel
#

which makes sense

grim hound
#

Otherwise it just returns the existing list

grim hound
storm crystal
#

yeah

#

thats literally

#

what I need

grim hound
#

But you understand why that works, right?

pseudo hazel
#

but yeah I do agree with sirbro that it would be beter to create a class for a player that has these sets and stuff rather than creating a bunch of maps

#

how many of these maps do you have

storm crystal
#

why when doing abilityStand.getLocation().setDirection(player.getLocation().getDirection()); armorstands are always on one specific direction?

#

even when I switch my looking direction

pseudo hazel
#

well what does getDirection return

storm crystal
#

direction?

grim hound
#

Locations work

#

They just return a separate object/a snapshot

#

Of the entity's position

#

ArmorStand#teleport

eternal oxide
#

player location holds teh bodys location/facing

grim hound
#

Is how you actually modify it

#

So do

eternal oxide
#

player getEyeLocation returns the head location/facing

pseudo hazel
grim hound
#

Location loc = armorStand.loc

#

loc.setDir(player.dir)

#

ArmorStand#teleport(loc)

eternal oxide
#

yep use teleport

#

setDirection will only adjust teh Location object which is a clone

grim hound
#

Location is always a snapshot that does not change the original holder's location

storm crystal
#

cant I just

#

abilityStand.teleport(abilityStand.getLocation());

grim hound
#

Because as I'm saying

storm crystal
#

why?

pseudo hazel
#

you cna but nothing changes xD

storm crystal
#

its literally same thing

eternal oxide
#

its not the same

grim hound
#

new Location

eternal oxide
#

armorstand.getLocation returns a clone, so modifying it will not affect teh stand

grim hound
eternal oxide
#

getLocation, setDirection, then teleport the stand to the modified location

grim hound
#

Anyways I'm going to sleep

#

Gn

pseudo hazel
storm crystal
#

so stupid

pseudo hazel
#

🤷

pseudo hazel
#

yeah

#

3 is too many to repeat

stone cosmos
#

Cloning is not stupid, is necessary in an API, since Java passes by reference except of primitives, you would end up in hell, passing references via API.

pseudo hazel
#

when you have repeated something like 3+ times, its time to approach it differently

storm crystal
#

it works

pseudo hazel
#

its annoying and the code gets bloated

#

sure it works

storm crystal
#

annoying for who exactly

chrome beacon
#

you

storm crystal
#

I dont feel annoyed

pseudo hazel
#

tahts because you dont know any better

storm crystal
#

what do you suggest then, if you know better

stone cosmos
# storm crystal it works

Because 3x map or list lookups, resizes etc. operations will consume a lot more time/load than just creating one class object what holds the data structure in a single map or list, as I said

#

But what do I know

storm crystal
#

so whats the difference

pseudo hazel
#

you only have to get your "player" object once

stone cosmos
#

The difference is, that one list or map holding the data class's object is more performant than x lists or maps just holding a part of it and also cleaner code.

pseudo hazel
#

because it would just be a List<PlayerLists> for a lack of a better name

#

which also means it will scale better when you decide to add more maps

tough parcel
#

how can you use a config.yml file to change different attributes of a gui (rows, lore, items, etc.)

#

i'm new to java its quite confusing

pseudo hazel
#

well those are 2 seperate things

storm crystal
#

so like what

#

I can just make

pseudo hazel
#

first one being how don you read from a config file

#

and the second part being how do I change attributes of a gui

#

by which I assume you mean some way to create a gui from a config file

storm crystal
#

List<playerUUID, ListOfLists<List1, List2, List3...>>?

pseudo hazel
#

yes essentially

tough parcel
#

fuck

#

wrong person

#

anyway

storm crystal
# pseudo hazel yes essentially

I just want it to store spawned Armor Stands, Interactions (that I use as hitboxes) and Enemies standing in those Interactions

#

ArmorStands for animation purposes

#

Interactions for mechanics

#

which works like that rn

#

and it just works fine

#

anyone thats in it gets damage as long as they are living entity and not armorstand

pseudo hazel
#

if those are the only 3 lists youll ever need its probably fine

pseudo hazel
storm crystal
#

idk if those are the only 3

#

like

#

I want to make those 3 by each ability separately

#

so that they wouldnt get mashed together

tough parcel
#

oh

pseudo hazel
#

you said its confusing

tough parcel
#

nvm i think ill find some way

#

sooner or later

storm crystal
#

like 3 lists for this ability, 3 for that etc.

tough parcel
#

thank you for volunteering ig

storm crystal
#

so that I wouldnt remove armorstands / interactions / use hit enemies by something else by accident

pseudo hazel
#

I would reccomend to start out creating a menu hardcoding it into a class

stone cosmos
pseudo hazel
#

and then devise some kind of format that would work for creating a menu on the fly

storm crystal
#

I already made several manager classes

#

lol

#

I just wanted to see how to use interactions properly

#

I didnt think that Id need 3 separate lists

#

so I should make a class that would create, remove and edit such playeruuid nested lists?

lament slate
#

I am trying to figure out how to make it so that everyone in a server says a random number from 0-9 or gets messaged a random number either or I am confused though how I would do that would I make a for loop and grab all the players then for each player it goes through the loop? Im still newish to coding so sorry if its a easy solution - I did the random number generator already

grim hound
lament slate
#

Thanks

grim hound
#

Just make a variable for that Random

quaint mantle
#
    var friendlyByteBuf = new PacketDataSerializer(Unpooled.buffer());

    friendlyByteBuf.c(id);
    friendlyByteBuf.writeDouble(loc.getX());
    friendlyByteBuf.writeDouble(loc.getY());
    friendlyByteBuf.writeDouble(loc.getZ());
    friendlyByteBuf.writeFloat(loc.getYaw());
    friendlyByteBuf.writeFloat(loc.getPitch());

    var EntityTeleport = new PacketPlayOutEntityTeleport(friendlyByteBuf);
    // send packet

am i missing something obvious?

dry hazel
#

I mean, look at how the constructor reads the bytebuf

storm crystal
#

wait so what should I use instead of this CocurrentHashMap?

dry hazel
#

HashMap lol

smoky oak
storm crystal
dry hazel
#

CHM can work in concurrent environments

#

with a slight overhead

#

i.e. you can use it from multiple threads at a time

stone cosmos
storm crystal
#

im not using any apis tho

quiet ice
#

CMH is also useful if you modify it while iterating

dry hazel
dry hazel
stone cosmos
quiet ice
#

Wha?

quaint mantle
quiet ice
quiet ice
dry hazel
#

CHM doesn't actually lock a lot, if at all

lament slate
quiet ice
#

Well CHM does lock quite often actually but these locks are not worth speaking about

stone cosmos
quiet ice
#

And they are only required for resizing bucks and stuff

lament slate
#

Nevermind my import was spelt wrong

smoky oak
quiet ice
river oracle
smoky oak
#

eh fair

#

guess im used to replying instantly myself

floral drum
lethal coral
#

how can I send an empty resource pack to the player so it unloads the previous one?

smoky oak
#

le shrug

quiet ice
smoky oak
#

for me the green point means 'repliy ready'

#

guess people dont use it like that

quiet ice
#

For me it generally me "My PC is turned on - if it isn't a thursday it is likely that I will respond soon"

smoky oak
#

thats what the yellow is for tho?

quiet ice
#

Well uh, I don't bother manually setting that flag

dry hazel
#

just set it always to away

quiet ice
#

I have a few people that I know personally that have set their status to always be offline

stone cosmos
quiet ice
#

Which is just pain for me since I cannot really be "well, at this point you probably read it"

cursive falcon
#

what packet lib should I use for 1.20+, since protocollib doesnt support 1.20+

quiet ice
#

Almost no concurrent datastructures will throw CMEs

lament slate
#

is there a way to make a player run a command like sudo or do you just grab there name and make the server run a command for them?

quiet ice
#

That is the point of using them

stone cosmos
#

Why would you care if single thread and clean code, but ok

mental crystal
#

Uhh sory stupid question, i cannot remember what programm to use to access a storage from my hosted server. i got the ip, port, username and password.

lament slate
#

Ok ill look at them rn

#

performCommand
thanks your a lifesaver!

hazy parrot
quiet ice
mental crystal
#

the storage where backups and all the minecraft server files lay

storm crystal
#

what approach should I take if I want to make GUI that would display unlock progress for a player based on what level (not in-game experience level, but just some arbitrary made level mechanic) they practically achieved?

hazy parrot
quiet ice
#

Also, modification while iterating can sometimes be a little more than plain removal of objects - for example what if you need to add or replace objects?

mental crystal
#

AHH yes filezilla was it yesss thanks lol. Just randomly forgot the name of it

quiet ice
#

Isn't that illegal is many countries?

lament slate
#

Question for performCommand - Does the player need to have perms to perform the command or will the server force them to perform it

stone cosmos
smoky oak
#

he in north carolina

#

single state consent

#

only matters to who is recording it

#

i know american law well enough to know hes in the clear

quiet ice
#

So yes, it is illegal.

hazy parrot
quiet ice
#

Probably not considered blackmail, so not completely bad but still.

lament slate
smoky oak
#

fair

lament slate
#

Ill just maybe make the server run the command then and target the player then

quiet ice
#

I was referring that extortion might not be completely fine, which they did by offering a ransom payment

smoky oak
#

welll

#

he took the source code and published it

quiet ice
#

Yeah that blatant act I disregard

smoky oak
#

and now hes like 'pay me to take it down'

slender elbow
shell trench
#

How can I detect when an item is added to the players inventory?
(I know there is a InventoryPickupItemEvent, but this only works for item pick ups, not for item changes if obtained from a chest or /give)

young knoll
#

You’d have to check every tick

#

There is no event that covers all changes to an inventory

lament slate
#

I just downloaded the plugin lombok for intellij and after trying to import it to the project I was previously workong on I get cannt resolve symbol lombok

rotund ravine
#

What build system do you use

lament slate
#

Windows 11

rotund ravine
#

Maven, gradle etc.

lament slate
#

Maven sorry

rotund ravine
#

Did you setup the compiler plugin in there properly?

lament slate
#

I am pretty sure give me a minute

#

All I know is that I have Kotlin and Lumbok which is all I thought I needed to download to use it

#

Do i need t o set something up or get sometihng else?

#

Wait I know what I did wrong

#

I didnt put it in my pom file

green plaza
#

How to set items in the loom?

ivory depot
#

What is the best way to mysql? In plugins

river oracle
green plaza
wet perch
#

Can someone help me with plugin messaging?

river oracle
wet perch
green plaza
river oracle
green plaza
#

Then please

#

Provide me a code

#

When you use setitem

river oracle
#

try InventoryView#setItem

green plaza
#

W8

river oracle
# green plaza Yea

I'm currently working on a PR for bukkit based soley around Inventories and InventoryView's I have been testing it quite frequently and such behavior has been identified as both possible and executable by a plugin

#

I can assure you, with 100% confidence, the loom inventory is not fully client sided and it is possible to set Items within it

green plaza
#

How InventoryView?

        Inventory battleInventory = Bukkit.createInventory(null, InventoryType.LOOM);
        battleInventory.setItem(0, currentBanner);
        battleInventory.setItem(1, dye);

        return battleInventory;
river oracle
#

you can't use that method

green plaza
#

What should i use?

#

@river oracle

river oracle
#

you'll need to use NMS until my PR is merged

river oracle
green plaza
river oracle
lament slate
#

I am having troubles adding project lombok to my pom file(Maven) I can not just copy and paste it because of "multiple root tags" anyone know why

river oracle
green plaza
river oracle
green plaza
#

Should I?

river oracle
#

?nms

river oracle
#

yes mappings are absolutely necessary now adays

#

obfuscated makes this process much harder

green plaza
#

I am used to NMS but i have been using mappings but i have not been coding plugins for a long period of time XD

river oracle
green plaza
#

👍

river oracle
#

okay this might be a second to type out

green plaza
#

I need to use BuildTools

#

Cuz i do not habe 1.17 mappings

river oracle
#

yeah we have a GUI if you would prefer to use that

river oracle
#

its just a GUI vs command line only

green plaza
#

Nah i'll use the full version

golden lava
#

World#rayTraceEntities does not include Displays?

lament slate
#

I have been trying to add Lombok to my project however even after installing the plugins and trying to copy and paste the new pom lines to maven it does not work does anyone know if I am missing a step?

river oracle
#
Player player; // we assume we have a player
CraftPlayer craftPlayer = (CraftPlayer) player;
// Convert to NMS player
ServerPlayer nmsPlayer = craftPlayer.getHandle();
int nextCounter = nmsPlayer.nextContainerCounter(); // this is an ID that can be sent to the client so it knows what is going on
final ContainerLoom loomContianer = MenuType.LOOM.create(nextCounter, nmsPlayer.getInventory()); // this creates our loom
// Bukkit handles a lot of the work for us so our job here is pretty much done
// This gives an InventoryView! remember this can only be created by the player you made that NMS container with, otherwise errors will occur.
InventoryView view = loomContainer.getBukktitView();
// now we can do edits if we want
Inventory inventory = view.getInventory();
inventory.setItem(0, new ItemStack(Material.BLUE_BANNER));
// now we can finally open the view
player.openInventory(view);

@green plaza hopefully this explains everything if you have errrors lmk

green plaza
#

Thx ❤️

#

I have question but its related to java

#

Why you use final?

river oracle
#

uhm its a small compiler optimization that will usually just get done automatically I just do it out of habit

#

you really don't need to use it in this case

compact haven
#

doing alright lime? been a while

green plaza
#

Ik i don't have to but i am just curious why ppl do that

#

Also heard few times that it boost performance a little bit

river oracle
river oracle
golden lava
green plaza
#

But JDK has to use more bit's to mark that's it's final soo how is that boosting performance XD?

compact haven
golden lava
#
// Paper Method
result = origin.rayTraceEntities(targetBlockDistance, ignoreBlocks)

// Tried Spigot too, always null.
result = origin.getWorld().rayTraceEntities(origin.getEyeLocation(), location.getDirection(), targetBlockDistance, 0.0D, entity -> !entity.equals(origin));

Works fine for a single pixel of an armour stand 120 blocks away. Not a block display right in front of me.

river oracle
floral drum
compact haven
#

@golden lava check if the Display entity is revealed with World#getNearbyEntities
(checking source rn and it seems that ray trace also uses that method)

green plaza
#
    private void getLoomInventory(Player player, ItemStack dye) {
        CraftPlayer craftPlayer = (CraftPlayer) player;
// Convert to NMS player
        ServerPlayer nmsPlayer = craftPlayer.getHandle();
        int nextCounter = nmsPlayer.nextContainerCounter(); // this is an ID that can be sent to the client so it knows what is going on
        final LoomMenu loomContianer = MenuType.LOOM.create(nextCounter, nmsPlayer.getInventory()); // this creates our loom
// Bukkit handles a lot of the work for us so our job here is pretty much done
// This gives an InventoryView! remember this can only be created by the player you made that NMS container with, otherwise errors will occur.
        InventoryView view = loomContianer.getBukkitView();
// now we can do edits if we want
        Inventory inventory = view.getInventory();
        inventory.setItem(0, currentBanner);
        inventory.setItem(1, dye);
// now we can finally open the view
        player.openInventory(view);

    }

Inventory inventory = view.getInventory(); -> here it pokes me for int for method getInventory

#

Does it matter for loom?

river oracle
#

my bhad

green plaza
river oracle
#

please don't 💀

green plaza
#

Haha

river oracle
#

Unless 1.17 changes something that 1.19.4 has with inventories it'll work and that prospect scares me

green plaza
#

I don't think so. Packet implementations are quiet the same

green plaza
#

So i can set this gui a title

river oracle
river oracle
#

or just the normal one

green plaza
#

Custom name

#

new TextCompoentn("text"); Will work?

river oracle
#

don't think so

#

gimme a second

green plaza
#

Okok

river oracle
green plaza
#

Lol it did

#

XD

river oracle
#

this is why we need Inventory PR

green plaza
#

What is inventory pr?

river oracle
#

my pr to add all of this to api <3

green plaza
#

It's just implementation for spigot/paper?

#

Or will have implementation from scratch

young knoll
#

@golden lava display entities have a hitbox size of 0, so the ray can’t hit them

HOWEVER you can use the double argument of the method to increase the size of all hitboxes so you can hit them

river oracle
compact haven
compact haven
#

why shouldn't it? Why would it arbitrarily expand hitboxes unless you're attempting to do something special?

river oracle
young knoll
#

Because by default it shouldn’t expand hitboxes?

golden lava
#

But then it's not including Displays, an Entity.

young knoll
#

Yeah well displays are special and have that 0 size hitbox

#

Mojang basically wanted them to be excluded from ray traces so they don’t block anything

golden lava
#

I would like to recommend changing that default or including that to the JavaDoc of the method.

compact haven
#

definitely don't change the default, but it should be logged in the JavaDoc ngl

young knoll
#

Yeah that can be done

#

Remind me tomorrow or make choco do it :p

compact haven
#

will remind u tomorrow at this time

young knoll
#

Ideally someone can make a jira issue for it

river oracle
#

fr ^

young knoll
#

Gotta be official and all

#

:p

compact haven
#

well im definitely not doing that xd

young knoll
#

This is why we can’t have nice things

river oracle
#

cuz coll messes everything up pepeSobs

green plaza
#

@river oracle i have custom InventoryHolder, any chance to implement this to this loom?

#

This Holder just holds every click event's etc and don't want to implement it manually

river oracle
river oracle
#

e.g. forking spigot

green plaza
#

Something similar to this

#

But more complicated

river oracle
# green plaza

as long as you're not using actual InventoryHolder's you can kind of cheat here lol its gonna be hacky though since you can't do patches

#

just get the Inventory from the InventoryView and store it

storm crystal
#

should I make manager class for custom GUIs made with inventories?

#

or can I get away with making each by hand?

young knoll
#

Some kind of manager is usually good

floral drum
#

Using a class which inherits InventoryHolder is good too :)

storm crystal
#

like making an inventory with X rows filled with certain items as background and custom name set and then changing separate objects by hand based on what I'd want?

storm crystal
green plaza
young knoll
#

Do not use inventory holder to identify inventories

#

The end

young knoll
#

Yeah idk if that’s fired

#

But you can try it

storm crystal
#

I want to make some kind of interactable skill tree / stat upgrade tree within GUI for each player

green plaza
#

Nope as always InventoryClick wave his hand

storm crystal
#

so that it could fill inventory items with visual representation based on readings from player's config

#

like if he's got that upgrade or not etc.

sick ermine
#

I am coding an invitation system, the sent invitation should be deleted after a while. Should I use Bukkit Scheduler or BukkitExecutor or something else?

young knoll
#

Use a scheduler along with timestamps

#

Store a timestamp for when the invite should expire a check them every once in a while using a repeating task

sick ermine
young knoll
#

Why would they not be deleted in time

sick ermine
young knoll
#

Nah you can just use one to check them all

sick ermine
#

In this case, invitations that do not disappear at the right time appear.

wet breach
# sick ermine I am coding an invitation system, the sent invitation should be deleted after a ...

if you are using mysql it can do this for you btw


CREATE EVENT clearExpired
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 2 MINUTES
DO
   UPDATE table SET status=0
    WHERE status <> 0
      AND TIMESTAMPDIFF(SECONDS, NOW(),table.timestamp)>120;

/* OR */

CREATE EVENT clearExpired
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 2 MINUTES
DO
   DELETE FROM table
    WHERE TIMESTAMPDIFF(SECONDS, NOW(),table.timestamp)>120;
#

mysql has events that are handy to use 🙂

#

expiring rows/columns are one of those things

#

so let mysql clean them up for you instead of wasting resources 😛

river oracle
sick ermine
#

I offer mysql and sqlite support to the user. There is also the possibility of using sqlite. Also, I do not plan to write the invitations to the database, I can keep them in memory, it is not important data, they can be lost when the server is shut down.

wet breach
#

well, options 😉

sick ermine
# young knoll ?

For example, a scheduler ran every 5 minutes and then an invitation was created that had to be deleted after 1 minute. This invitation will be deleted the next time the scheduler runs, that is, after 5 minutes.

wet breach
storm crystal
#

Is it a good idea to store custom experience points and levels like combat experience from hypixel in player configs?

#

Or should I think of other way?

hazy parrot
river oracle
wet breach
river oracle
#

don't worry there are plenty of choices, MongoDB, SQLIte, MySQL, Postgress!!!!
(You should probably just use SQLite)

wet breach
#

so lets say someone wants to use mysql like you said you offer support for, the plugin could run more optimally by not having to store such info in memory when the DB server can do that for them

lament slate
#

i want to make a code for each player online assign them a random number than message them that number any ideas on the for each player online since thats where I am struggling

wet breach
#

as well as handle expiring stuff

#

and then just have your code do the whole in memory scheduling if sqlite is being used since SQLite is just binary file storage

storm crystal
#

So when do I use config and when database

wet breach
storm crystal
#

Which means that majority of my work goes to scrap

wet breach
#

I didn't sell you a half measure o.O

storm crystal
#

What can possibly happen if I use config for that

wet breach
#

you can use a config if you want, but yaml starts to bog down once you start hitting like a few hundred to thousand config options, and if you want to use a yaml like structure still you option would be to move to just storing pure json instead and then from there you would have no choice but to move to binary storage if what you are storing keeps getting larger, and then from binary storage you would need to look at a proper DB server. But DB servers like mysql don't take up much resources so sometimes it might just be best to start with a DB to begin with if you expect to be storing a lot of data and more so if that data needs to persist or is needed elsehwere.

young knoll
#

Comparing time stamps is a cheap operation

lament slate
#

Question I am wondering how would I give everyone a random number then do something with that random number? Would I need a array For Example, 1 = diamonds 2 = dirt and every player gets a 1 or 2

wet breach
#

well why not 0 and 1?

#

then you could use a boolean if you wanted

#

Java has api methods for using Random with a range as well

#

so your range would just be 2

#

and you would check if the random number provided is either a 0 or a 1 🙂

lament slate
#

I know how to use random with range its just how would every player get there numer and ther eitem

#

Just check if all the players have 0 or 1 with a statement and give them the items?

storm crystal
#

And how do I read it

wet breach
#

depends which data base flavor you want

storm crystal
#

?

wet breach
#

most of the time comes down to preference

storm crystal
#

I dont have a preference

wet breach
#

Well just like programming languages, there is different kinds of DB's

storm crystal
#

Idk something that works?

wet breach
#

well they all work of course

storm crystal
#

All my work is now for shit so ill have to start from zero

wet breach
#

however, some have limits while others are tailored to more specific things

storm crystal
#

I want something to store custom enemies, weapons, playerstats etc.

wet breach
#

sometimes you learn what you were doing is just not good enough

storm crystal
#

For which you told me to use configs for

wet breach
#

so you just start again

wet breach
#

since you don't want to learn proper stuff, easier to just direct you to something already provided

#

continuing with not learning proper stuff, using a DB isn't going to make that better and you will in fact make things worse potentially as using DB's are not as forgiving as the API is

storm crystal
#

I dont consider that kind of attitude, namely "heres a half measurement now fuck off" on a help channel apropiate

wet breach
#

well you are not paying

#

so you have no right to say anything about it

storm crystal
#

It doesnt work that way

wet breach
#

the support most receive here as well as the educating would typically cost you a hefty penny for, but we freely do it and we are not paid either nor does anyone pay for this support

storm crystal
#

Since when money determines how important your opinion on a matter is

lament slate
#

would this assign everyone a random number if so there seems to be a error Bukkit.getOnlinePlayers().forEach(new Random().nextInt(10);

wet breach
#

Well, we are not obligated to provide support nor do you have a right to it either. We have no obligations to really do much of anything, but we still provide support because we want to. You are free to not like it, but we are free to not like those wanting support as well. It is a two way street type deal. You refuse consistently to not learn appropriate basics, methods, and conventions to the point it makes it difficult to provide you support on stuff you ask about because you lack the understanding required.

wet breach
#

0-10

lament slate
#

Yes it does however would it give everyone a number or no?

wet breach
#

well 0-9 actually

lament slate
#

true

wet breach
lament slate
#

I am a new coder sorry I am struggling with this XD

wet breach
#

I would create 1 random object, and just call nextInt() every time

#

and then assign a number it provides

lament slate
#

wait so create a integer then make it generate a random number then do 1 player then continue?

wet breach
#

calling new Random() if you have a large enough players would actually lag your server since its a taxing process to generate randoms 😛

lament slate
#

its going to be like 5-10 players

storm crystal
wet breach
wet breach
lament slate
#

I do not no I a mstilll new to coding

#

Do I have to make a array or string?

wet breach
#

I would probably use a hashmap

lament slate
#

Oh god

lament slate
#

The h word

river oracle
floral drum
#

Before I say anything, I would like to request a lawyer

storm crystal
#

Can they be static

floral drum
wet breach
#

Hashmap <UUID, Integer> randomsMap = new HashMap<>(Bukkit.getOnlinePlayers().size())

Random randomNum = new Random();

for (int assignNum : Bukkit.getOnlinePlayers().size()) {
    randomsMap.put((players UUID), randomNum.nextInt());
}
floral drum
#

wottttt

#

frostyyy

lament slate
#

Thank you

wet breach
#

its not complete as you will need to figure out how to get players UUID's and put them in

floral drum
#

hiii

#

how are you bestie

wet breach
#

or just use player names since its only used when they are on anyways

lament slate
#

Frsoty thanks you your very nice and Ima go try to code this now

#

Have a great day/night

wet breach
#

always avoid if you can in making new randoms, its one of few objects that will cause you issues later down the road lmao

lament slate
#

Oks

storm crystal
#

Do i just make connection to db at server enable and keep it like that

floral drum
#

weeeee

storm crystal
#

Whats a pool

wet breach
# storm crystal So what database do I use

There are some things where we can't really tell you because its dependent mainly on you. What you prefer, what you know, what kind of data and how much data, does it need to persist or not etc. If you want a DB for learning purposes either go with sqlite or mysql as there is plenty of resources and tutorials online to guide you in the appropriate direction to learn about this. There is more to DB's then just using them, such as setting the DB tables up properly etc IE their structure and the sorts.

floral drum
# storm crystal Whats a pool

A pool is basically multiple database connections, it basically allows parallel queries to the database without exhausting the single connection

#

not sure if I was correct there

wet breach
#

learning proper DB management is like a whole course in of itself just fyi