#help-development

1 messages ยท Page 1350 of 1

eternal oxide
#

check if its your helment

#

then if check the helmet slot to see if its empty or occupied

#

then check the clicked slot to see if you are removing teh helmet

rugged topaz
#

@eternal oxide

#

if you're able to identify the causes that is

#

more importantly of "and also, if a block regenerates (by plugin) that i've mined, it'll break it again, and give me xp, and continue the loop"

eternal oxide
#

so it only adds adjacent blocks if this main block is the correct material

#

ish, remove the ;

#

you need more tests

eternal oxide
#

that only tells you if your helmet was clicks, you still need to see if its the one you are wearing

eternal oxide
rugged topaz
#

alrighty

kindred solar
#

i still need help, if anyone can help me i would be happy

#

this is not working

eternal oxide
kindred solar
#

no

rugged topaz
kindred solar
#

talking to me?

quaint mantle
#

why is it boolean

#

your method return signature

eternal oxide
#

that will tell you if your custom helmet was clicked. Then test the slot, if its not the helmet slot you need to test if the helmet slot is occupied

quaint mantle
#

make it void

eternal oxide
#

@rugged topaz show current code

rugged topaz
split light
#

I am trying to add a config file that records the number of times a player gets a special Beer potion item through a command, but I'm having some strange results. The code snippet included runs every time the player receives a new beer using the command: https://pastebin.com/CN481Kt7 I want the value of <UUID>.name.beers to increase by one every time, but that isn't working. Neither is storing data under "name". The results in the config and terminal repeat every time I enter the command, which is when I want the number next to "Beers:" to increase by one. Any ideas?

eternal oxide
#

@rugged topaz ok this issue now is that the original block is already broken. cancel the break in yrou calling event

quaint mantle
#

thats going to lag so hard if it runs often

#

you need to optimize a lot of your code in there @rugged topaz

eternal oxide
#

It won;t lag, its Async

rugged topaz
#

too* often

quaint mantle
#

cache arrays, 1 instance of random, cache the itemstacks

eternal oxide
#

no need yet, its not working ๐Ÿ™‚

#

he's close though

#

@rugged topaz did you change to cancel the block break of the first log?

rugged topaz
#

cancelled the event before calling the func yea

eternal oxide
#

k, now it shoudl work, for the logs

quaint mantle
rugged topaz
#

working a lot better now, however the side issue of sometimes getting a block that is two blocks away of the same type rather than touching blocks, and also, if a block regenerates (by plugin) that i've mined, it'll break it again, and give me xp, and continue the loop the latter issue's now resolved

#

gonna test for the first

#

seems like both issues were fixed :)

quaint mantle
#

u cant have
id name: 'value' beers: 'value'

split light
eternal oxide
#

ok, now you need to instead of checking the name for log or leaves, use Tags

split light
#

is it not possible to have a value next to a subclass with another subclass?

quaint mantle
#

i think you want

id name: beers:

split light
#

yeah

quaint mantle
#

you need to change your keys, they're a bit hard to follow in your code which is what probably got you confused

split light
#

So I guess that would look like, directory wise, "<uuid>.name" AND "<uuid>.beers"

quaint mantle
#

yes

split light
#

I'll try that out. Thanks!

#

I think I was just being stupid xD

quaint mantle
#

its ok, we all make mistakes

split light
#

One other quick question, how are variable types stored in yaml? I've had trouble putting in a quantity as an int and then getting it out as an int elsewhere in the code

#

Is it all Strings? Or am I just confusing the spigot API

quaint mantle
#

pretty sure they're manually checked somewhere internally

rugged topaz
#

@eternal oxide so, any other optimizations we're able to make? (i'll work on ay.ngel's rn too) but, is there anyway to dictate the speed of the animation of breaking blocks or no? since it seems the only power i have over how fast the blocks break is a simple .RunTask

eternal oxide
#

You can use a delayed task

split light
rugged topaz
#

async or sync

#

async ye?

eternal oxide
#

sync

rugged topaz
#

o okay

eternal oxide
#

the breaks have to be sync

quaint mantle
#

yeah, reformatting the yaml how i told u will get it to work ๐Ÿ™‚

deft sedge
#

Now I have a new problem

#

great!

rugged topaz
#

sync meaning one after another?

#

tbh if i'm bein real with u idek async vs sync when it comes to runnables

deft sedge
#

ItemStack item = player.getItemInHand();
if(!(item.getType() == Material.WRITTEN_BOOK)) {
player.sendMessage(ChatColor.RED + "You have to hold your data book to start the game!");
return true;
}
BookMeta meta = (BookMeta) item.getItemMeta();

            String saturation = meta.getPage(1);
            String thirstRAW = meta.getPage(2);
            String location = meta.getPage(3);
            float HungerF = Float.parseFloat(saturation);
            int Thirst = Integer.parseInt(thirstRAW);

            player.setLevel(Thirst);
            player.setSaturation(HungerF);
quaint mantle
#

if you know for certain the yaml value is an int, then use getInt. if it's not an int, or whatever type you're dealing with, that's an issue with the server owner or whoever is configuring

deft sedge
#

now there are now errors

#

but it just doesn't work

#

it's supposed to get the data wout of the book and set the levels (which is substituted for thirst)

#

and saturation

eternal oxide
#

@rugged topaz In this instance sync means in sync with the server Thread

deft sedge
#

@eternal oxide any ideas?

eternal oxide
#

Async means it runs along side at the same time

rugged topaz
#

ah okay

#

by 1 instance of random, i'd just move it to the start of the function right

#

as recommended by @quaint mantle

quaint mantle
#

no, as a global variable

rugged topaz
#

i use rand everywhere

#

so ur sayin i should instantiate it only once per onEnable?

quaint mantle
#

yeah, use it as a global variable and access that

#

yes

rugged topaz
#

in that case

eternal oxide
#

yes Random rand = new Random();

rugged topaz
#

does that even make a difference

eternal oxide
#

so its only created once, same with the ItemStack

quaint mantle
#

Random instances are expensive

eternal oxide
#

else it creates a new instance every time. Which takes time and wastes the garbage collector

quaint mantle
#

for the itemstacks that aren't chaning, like the apple or whatever, cache those too

#

changing*

rugged topaz
#

cache them meaning what exactly

eternal oxide
#

create outside your loop and reuse

quaint mantle
#

make them global variables

eternal oxide
#

so one instance

quaint mantle
#

in the scope of the class, not the method

rugged topaz
#

alrighty

quaint mantle
#

do the same for your blockface array, cache it as a global variable

eternal oxide
#

@rugged topaz is this only for breaking trees, and are teh leaves supposed to break aswell, or only if the first one is broken?

deft sedge
#

@eternal oxide did u see my post?

rugged topaz
#

leaves shouldn't break

#

or actually

#

uh

#

sec

#

do i also cache new BlockFace[]{BlockFace.UP, BlockFace.DOWN, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST}?

#

since it's being instantiated

eternal oxide
#

yes

#

at class level so its only ever created once

rugged topaz
#

i could turn those final

eternal oxide
#

you can also remove your blocksToRemove array now and change it to a counter

#

a simple int

rugged topaz
#

do you work with intellij

eternal oxide
#

no Eclipse

rugged topaz
#

needa know why sometimes final is suggested and sometimes not, even though most of the time it's allowed

#

smh okay

cloud berry
#

intellij best ide โ„ข๏ธ

deft sedge
#

i agree

rugged topaz
eternal oxide
#

Move teh BlocksToRemove int inside teh method

#

it needs to be initialized to zero upon calling the method

rugged topaz
#

mhm but

#

atomic expression bla bla

eternal oxide
#

you can place it inside the task

#

its only used inside the task

#

new ItemStack(targetMaterial, 1) can be moved out

#

oh no it cna;t ๐Ÿ˜›

rugged topaz
#

thought about it myself lmao

eternal oxide
#

but it can be moved outside the task

#

so its only created once per run

#

place it under targetMaterial

#

The only part thats not going to work currently is your leaves section

rugged topaz
#

well i don't even have a system where leaves would be able to be broken

#

but when comes time

#

it wouldn't be hard to just copy and paste the code from above right

#

or, we could just do it now

eternal oxide
#

all you'd need to change is the if (block.getType() == targetMaterial) {

rugged topaz
#

o yah, i can do it from there

#

as of rn

#

ends like this

quaint mantle
#

u want blocksToCheck inside

#

otherwise if the method is called twice you'll have clashing elements of different runs

eternal oxide
#
if ((block.getType() == targetMaterial) || Tag.LEAVES.isTagged(block.getType())) {```
#

Yep, blocksToCheck inside so its initialized each call

rugged topaz
#

did that, and added a few final's

eternal oxide
#

you will need to test that as the leaves may play havoc with yoru connected idea

rugged topaz
#

if that's the case, when it's implemented i'd be right back here in this channel :)

eternal oxide
#

๐Ÿ™‚

rugged topaz
#

thanks for the help over the hour or so tho :) completely fixed all of it

eternal oxide
#

lol, it was only 3 hours ๐Ÿ˜›

rugged topaz
#

lmaoo

quaint mantle
#

make the apple, sapling and faces static and final

#

they are meant to be constants

eternal oxide
#

yep, static will ensure they are single instance

rugged topaz
#

done thanks

quaint mantle
#

also i would cancel the task if the player is online

#

they could easily logout during the async task

#

is offline*

eternal oxide
#

they could but the Player object won't be disposed of till the task ends

quaint mantle
#

i know, but you could be accessing a stale object for no reason

#

check via Player::isOnline

south onyx
#

i want to make it so that when i hit a player, they get sent flying forword at a speed of 2, 3, 4, 5 ... 10. The speed will be chosen randomly. Ik you need to use vectors for this, but idk how to.

eternal oxide
#

not really needed as it won;t throw any errors and will just quietly do nothing

quaint mantle
south onyx
#

and i multiply it by a random number that i want?

quaint mantle
#

yes, but probably not 2,3,4,5,10, those are massive increments to multiply the velocity by

#

you'll see yourself when testing

rugged topaz
deft sedge
#

hey anyone free to answer a question?

quaint mantle
#

depends how you're accessing it

#

private if its only being used in that class, public if its used in many classes, protected if it's only used in that class and child classes

#

etc

rugged topaz
#

private would further optimize it too

#

right

quaint mantle
#

no

eternal oxide
#

just protect it

quaint mantle
#

it just follows conventions

deft sedge
#

here is my code

#

if (args[0].equalsIgnoreCase("start")) {
ItemStack item = player.getItemInHand();
if(!(item.getType() == Material.WRITTEN_BOOK)) {
player.sendMessage(ChatColor.RED + "You have to hold your data book to start the game!");
return true;
}
BookMeta meta = (BookMeta) item.getItemMeta();

            String saturation = meta.getPage(1);
            String thirstRAW = meta.getPage(2);
            String location = meta.getPage(3);
            float HungerF = Float.parseFloat(saturation);
            int Thirst = Integer.parseInt(thirstRAW);

            int ThirstTest = 2;



            player.setLevel(Thirst);
            player.setSaturation(HungerF);
rugged topaz
#

depressing

quaint mantle
#

@deft sedge ?paste

#

?paste

deft sedge
#

yea

#

I will hoold on

eternal oxide
#

?paste

queen dragonBOT
deft sedge
#

that is code

#

it takes tthe stuff from a book

eternal oxide
#

what is not workign and any errors?

deft sedge
#

and it is supposed to set the player xp and hunger

#

no errors

#

it just doesnt' work

#

when it says player.set level thirst

quaint mantle
#

Does anyone know how I can create/spawn a structure like a village or stronghold? Please ping me on response

deft sedge
#

it doesn't work

#

it doesnt' set the level

#

thirst is meaning the xp levels

#

making a game where your thirst just uses the xp bar as a puppet

eternal oxide
#

setLevel is the players experience level

deft sedge
#

yea

#

ik

#

thirst is just the name of var

#

and I have checked

#

it does what I want

#

I had it print those values out to console

#

and it did the values

#

and they were corerect

#

I did System.out.println(Thirst);

#

and it printed out the correct number

floral flare
#

criarTabela("info","nome varchar(16), id text");

deft sedge
#

but itdoesn't set player stuff to that number like it should

#

@eternal oxide

eternal oxide
#

are you sure you want saturation? Thats not food level

deft sedge
#

?

#

i want to set the food level

floral flare
#

in this case, to store text

eternal oxide
#

then void setFoodLevelโ€‹(int value)

deft sedge
#

ok but y does the xp set not work?

eternal oxide
#

what value are you setting for exp?

deft sedge
#

it is a simple integer

#

just doeing set level

eternal oxide
#

exp is a float

deft sedge
#

o

#

but if i make it float

quaint mantle
#

bukkit impl for exp is wack

eternal oxide
#

level is total levels, exp is how far to next level

deft sedge
quaint mantle
#

look up some exp tools, ive seen some people make some on bukkit and spigot that lets u control the exp like normal

deft sedge
#

it says it requires int

#

?

#

not right?

#

@eternal oxide

quaint mantle
#

(int) thirst

eternal oxide
#

setExp is a float. setLevel is an int

deft sedge
#

well don't I want setexp

#

srry set level

#

bc i want to change levels

eternal oxide
#

are you trying to set their current level or the exp till next level?

quaint mantle
#

then just make your float an int

eternal oxide
#

ok level

deft sedge
#

ok

#

but it was int from the start

#

i only changed it bc u said to

eternal oxide
#

what value are you setting to it?

deft sedge
#

like 2

quaint mantle
#

float is for setting the exp, int is for the level

eternal oxide
#

once you set level try calling player.sendExperienceChange((float) 1);

deft sedge
#

ok

quaint mantle
quaint mantle
#

i just want to generate one on the spot

#

in existing chunks

south onyx
#

how do i get a 10 block radius around a entity
bc what im trying to do is teleport an entity to a random location that is in the 10 block radius of his old location

quaint mantle
#

loop between every axis u want, for x amount of blocks/distance

eternal oxide
#

or generate a random vector

deft sedge
#

@eternal oxide THanks for all the help! It works

wet breach
#

might want to use Math.abs as well for the radius check

#

makes things easier when you are not dealing with negatives ๐Ÿ˜›

young knoll
#

I would just add a random number between -10 and 10 to their x and z, then either get the highest block y at the new location or scan up/down for a free space

quasi epoch
#

Hey guys, looking for someone who knows about command blocks

#

Essentially all I need is a command block triggered when a player respawns, and when they join the server for the first time

young knoll
#

We deal with plugins here mostly

#

You may want to look into that, or ask in the minecraft commands discord

north niche
#

im saving blockdata in a txt file like this

bl.getBlockData().getAsString()
//where bl is a valid defined BLOCK

now i got the block data string like this

minecraft:oak_stairs[facing=south,half=bottom,shape=straight,waterlogged=false]

now how to set block with this blockdata

quaint mantle
#

idk if there's a way bukkit can parse that

#

you might have to parse it yourself and set the data yourself

north niche
#

so there is no other ways ?

tough zephyr
#

@quaint mantle Just do a for loop on world.getEntities()

#

instanceof RabbitWhateverClassName

#

The rabbits should have a ticksLived function

#

Just use that to tell how many ticks have passed since their creation

tough zephyr
#

@quaint mantle I think you can re-set the ticks lived?

#

With Spigot API that is

dusty herald
tough zephyr
#

Yeah that'll work perfectly

outer sorrel
#

how would i get the player previous position from a move packet? (PacketType.Play.Client.POSITION)

quaint mantle
#

or grab the chunk of every player, add it to a set (so you only have unique chunks), then loop through those chunks and get the rabbits in those chunks then do whatever u want with them

outer sorrel
#

im using packets

quaint mantle
#

to make it so each rabbit only does it once they've lived for 8k ticks, you can keep track of their uuid and mark when you've first tracked them (mark the time), then when you loop through them again, check to see if the current time minus the initial track time is >= 8k

#

then mark them as 'marked' or something so u know they've already dropped dirt, otherwise they'll drop every 8k ticks

regal dew
#

ie store it

outer sorrel
#

ok thanks

lost matrix
#

There are 2 possible approaches:
First:
Extend the nms rabbit and overwrite the tick method. (Would need to register the rabbit in the IRegistry which has gotten quite complex)

Second:
You create one runnable that runs about every 20 - 40 ticks because you dont need a 50ms precision i suppose.
Then listen for the ChunkLoadEvent, get each entity from the chunk, filter the rabbits and add it into a Map<Rabbit, Long>.
Remove the rabbit in the ChunkUnloadEvent. You can make the timer persistent if you use the rabbits PersistentDataContainer. (Which you should do)

If you want a better performance than you can take a look at section 3 of this tread:
https://www.spigotmc.org/threads/guide-on-workload-distribution-or-how-to-handle-heavy-splittable-tasks.409003/

outer sorrel
lost matrix
#

You should be able to figure that one out by looking at the run method.

maiden briar
#

What is the best way to save an ArrayList (with uuid's) into MySQL?

#

Pls ping if you know the answer

lost matrix
maiden briar
#

I have my regions, and they have members

#

List<UUID> members

lost matrix
# maiden briar List<UUID> members

So relational databases are designed for one value per column.
If you want the quick and dirty way:
Serialize the List to a single String.

The normalized design way would be to create a new table for each region.
Thats what relational databases where defined for.

But if you are absolutely certain that you will always just have UUIDs in there then its possible to just join the UUIDs with '\0' or
something like that and store them as a single value.

maiden briar
#

Yes then I think I will store as one single values, thanks

#

Then I need to choose "VARCHAR"?

#

Oh and I have seen MySQL has "ENUM", can't I use that?

quaint mantle
#

can anyone help me setting up leaderboard using leader heads plugin in bedwars1058

lost matrix
maiden briar
#

No but save in an ENUM

#

Because you can save up to 60000 custom strings

lost matrix
#

Why not just go for varchar or nvarchar? The limit is 2GB per String...

lost matrix
maiden briar
#

Yes

#

Indeed

lost matrix
#

But... then you would need to define a new enum type for each region. And then re-define it each time the list changes.

lost matrix
maiden briar
#

Hmm ok

vague mason
#

Is anyone here database expert?

#

I have a really stupid question...

#

I mean it seems genies to me be I never seen anyone to do this...

#

That's why I think it's stupid...

ivory sleet
#

?ask

queen dragonBOT
#

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.

vague mason
#

I'm going to work on password manager and like normal way is to create users, passwords and user_passwords tables.
But I was thinking when billions of passwords will be saved. Wouldn't be better if I create new table for each user?
So database would be able to find password much more faster then looking them from billions of passwords....
So each user will have their own table with their own passwords.
and finding the right password from one table with 30ish passwords will be much faster then looking for user password from table with billions of passwords...(edited)
so I can just do SELECT * FROM <username>; to get all passwords from this specific person.
Instead of SELECT * FROM passwords p JOIN user_passwords up ON up.password_id = p.password_id JOIN users u ON u.user_id = up.user_id WHERE u.username = <username>;
Also deleting and retrieving passwords would be much more faster.
But I never see anyone to do this.... So that's why I'm asking...
Also if user remove their account I can just delete him from user tabel and also delete their table which name = their username.
Much faster then finding all his passwords in table with millions of data and deleting each one password.

ivory sleet
#

idk

main dew
ivory sleet
#

user per table designs are usually not so manageable from what I've heard

vague mason
#

I mean users will be still saved in one table

#

but for passwords every user will have their own table

main dew
#

I have problem I need protocollib 3.5 but I can't find this

ivory sleet
#

idk never seen anyone due to lack of maintainability but why not try it so you can experience the cons yourself

lost matrix
vague mason
#

So then it's just better if I make every table for every user separately by myself?

#

Like I will never need to look for passwords from 2 or more users at the same time.

#

so it makes sense that it's better to just separate passwords

vague mason
#

Yeah normal is the first way but it seems slower for me.

#

I mean first option has pros.

#

for example it will allow users to share passwords between each other

#

But if I don't need that then it might be better to create table for each user.

main dew
#

how to add protocollib version 3.5 to a local repository?

quaint mantle
#

can someone help me

#

setting up leader heads

#

in bedwars1058

lost matrix
quaint mantle
#

ohkk

#

umm can someone explain me about PersistantDataContainers ?

ivory sleet
#

yeah

#

its a way to interact with the persistent nbt stored in tile entities and itemstacks through api

#

or well PersistentDataHolders

quaint mantle
#

so what does primitative and complex of a object mean exactly ? (in PersistentDataType)

ivory sleet
quaint mantle
#

are they somehow linked together or something ?

ivory sleet
#

well I mean

#

there exists two types of every primitive sort of, a boxed and an unboxed type

#

probably a way to convert between those I guess

quaint mantle
#

ok

ivory sleet
#

or maybe not

#

well just read the javadoc there

#

explains in a more plausible manner

quaint mantle
#

but won't the methods toPrimitive and fromPrimitive be useless if there is no way to convert between them ?

ivory sleet
#
public class UUIDTagType implements PersistentDataType<byte[], UUID> {

         {@literal @Override}
         public Class<byte[]> getPrimitiveType() {
             return byte[].class;
         }

         {@literal @Override}
         public Class<UUID> getComplexType() {
             return UUID.class;
         }

         {@literal @Override}
         public byte[] toPrimitive(UUID complex, PersistentDataAdapterContext context) {
             ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
             bb.putLong(complex.getMostSignificantBits());
             bb.putLong(complex.getLeastSignificantBits());
             return bb.array();
         }

         {@literal @Override}
         public UUID fromPrimitive(byte[] primitive, PersistentDataAdapterContext context) {
             ByteBuffer bb = ByteBuffer.wrap(primitive);
             long firstLong = bb.getLong();
             long secondLong = bb.getLong();
             return new UUID(firstLong, secondLong);
         }
     }

its probably more understandable if you look at the example provided where T and Z differs

#

byte[] would be how it's stored

#

the you would use UUID to interact with it

quaint mantle
#

I c

#

that's make sense

#

ty, also I read docs and try to ask questions when I don't rlly know thing

ivory sleet
#

yeah

lost matrix
abstract relic
#

PersistentDataContainers

#

are so cool

#

i love em

ivory sleet
#

idk

#

its fine

lost matrix
#

If we only had a way of properly storing data in any block...

ivory sleet
#

that'd be excellent

quaint mantle
ivory sleet
#

PersistentDataContainer#set and #get

lost matrix
ivory sleet
#

then you need a namespaced key

#

which acts like any other key

quaint mantle
#

I read the docs, and that PersistentDataType was the confusing part not the methods of the DataContainer

ivory sleet
#

and then the PersistentDataType is what type you want to store it as

quaint mantle
ivory sleet
#

the most interesting types which you want to use is probably either PersistentDataType.INTEGER or PersistentDataType.STRING

lost matrix
#

One could actually write a Library for some custom persistent data types like PersistentDataType<byte[], ItemStack> or <byte[], ItemStack[]> or <byte[], Inventory> etc

ivory sleet
#

oo

#

would be awesome if one would create such a thing

lost matrix
#

Because storing an entire inventory in an ItemStack is a simple way of doing backpacks for example.

ivory sleet
#

indeed

quaint mantle
#

oh ok ty for the information, @lost matrix and @ivory sleet,
have a good day ๐Ÿ˜„

ivory sleet
#

u2

quaint mantle
#

another question does the Tag of an item, entity still remain even if the server restarts ?

ivory sleet
#

yes

#

persistentdatacontainers holds persistent data ๐Ÿ˜„

quaint mantle
#

Nice

#

ty

grave kite
#

Hi, is it possible to modify all the chat messages sent to a player including messages from other plugins?

grave kite
# lost matrix Yes

Is there an event for that? How do I specify that the plugin should go after all the others?

grave kite
lost matrix
quaint mantle
#

I cant disable invenoryclick event

lost matrix
quaint mantle
#

Nevermind a hadnt closed my switch

#

No

quaint mantle
lost matrix
quaint mantle
#

f

#

You can disable inventoryclickevent (e.setCancelled(true);)

#

thats exactly what I'm doing

#

and fuck you automod

opal juniper
#

?jd

quaint mantle
#

dont be toxic

#

@quaint mantle just send the code where u use the inventorycloseevent and are you czech?

quaint mantle
#

about the event or czech xd

#

Czech

#

oh xd

#

huh?

#

just send the code where u use the inventorycloseevent

quaint mantle
#

okay

#

F

#

anyway thanks

#

i mean its always the register event in main class xd

sage dock
#

how to send broadcast message only to a specific server exactly where the person who writes is located (bungeecord)

quaint mantle
#

like to all players that are on the server where player texted

sage dock
#

๐Ÿค”

#

okey

quaint mantle
#

okay ill send u a code

#

@EventHandler public void chat(ChatEvent e) { ProxiedPlayer playerWhoWritedInChat = (ProxiedPlayer) e.getSender(); for (ProxiedPlayer proxiedPlayers : getProxy().getPlayers()) { if (proxiedPlayers.getServer().getInfo().getName().equals(playerWhoWritedInChat.getServer().getInfo().getName())) { // Players are on the same server as player who writed in chat. } else { // Players aren't on the same server as player who writed in chat. } } }

sage dock
#

thanks

quaint mantle
#

yw

maiden briar
#

Why do I get https://api.mojang.com/user/profiles/"<UUID>"/names as URL with that "" ?
new URL("https://api.mojang.com/user/profiles/" + UUID + "/names");

quaint mantle
#

try using only one () in new URL() like that new URL("https://api.mojang.com/user/profiles/" + UUID + "/names");

#

okay you edited it

maiden briar
#

Yes I found that out

#

But that is not the solution

quaint mantle
#

could you send whats in the UUID

#

like what prints out

#

if the "" isnt in the uUID

maiden briar
#

[12:19:34] [Server thread/WARN]: java.io.IOException: Server returned HTTP response code: 400 for URL: https://api.mojang.com/user/profiles/"63c8889e90874e1fb5e958a8e86e34f1"/names

quaint mantle
#

how do you get the uuid method

maiden briar
#

With an String

#

I will print the UUID string for you

quaint mantle
#

okay

maiden briar
#
[12:20:43] [Server thread/WARN]: java.io.IOException: Server returned HTTP response code: 400 for URL: https://api.mojang.com/user/profiles/"63c8889e90874e1fb5e958a8e86e34f1"/names```
quaint mantle
#

okay show me the code when you set the value to the string

#

seems like the "" is somewhere in uuid setting

maiden briar
#
public static String getUUID(Player player)
{
    try
    {
        URL uuid = new URL("https://api.mojang.com/users/profiles/minecraft/" + player.getName());
        BufferedReader in = new BufferedReader(new InputStreamReader(uuid.openStream()));
        return new JsonParser().parse(in.readLine()).getAsJsonObject().get("id").toString();
    }
    catch(IOException e)
    {
        e.printStackTrace();
    } 
    return null
}

public static Player getPlayer(String UUID)
{
    try
    {
        System.out.println(UUID);
        URL uuid = new URL(("https://api.mojang.com/user/profiles/" + UUID + "/names").replaceAll("^\"|\"$", ""));
        BufferedReader in = new BufferedReader(new InputStreamReader(uuid.openStream()));
        return Bukkit.getPlayer(new JsonParser().parse(in.readLine()).getAsJsonObject().get("name").toString());
    }
    catch(IOException e)
    {
        e.printStackTrace();
    }

    return null;
}
lost matrix
maiden briar
#

Because players have different UUID's in offline mode unfortunately

quaint mantle
#

well if he wants uuid and he doesnt have online mode

#

yeah

maiden briar
#

It's under bungee

lost matrix
#

Oh god...

quaint mantle
#

oh yah sry my bad

#

didnt notice the replace method that needs it

maiden briar
#

๐Ÿ˜„

quaint mantle
#

when you use the an getPlayer() method what do you put inside the an argument?

#

p.getUniqueID().toString()?

maiden briar
#

Nope

rotund ravine
#

what

maiden briar
#

Converted uuid's for the string above

eternal oxide
#

Bungee should be Online, ALWAYS. Servers set to offline.

maiden briar
#

Yes Bungee is online, Spigot is offline, this plugin is running under spigot

eternal oxide
#

The servers will get the players UUID from the bungee server

maiden briar
#

Ok how would I do that?

rotund ravine
#

You don't do anything, it'll already be pushed to the server.

eternal oxide
#

its how it works normally when you correctly configure bungee

rotund ravine
#

Authentication happens at bungee and the uuid and ip gets forwarded.

maiden briar
#

But the problem is that this plugin is running UNDER SPIGOT

eternal oxide
#

the UUID still comes from bungee

quasi epoch
#

Looking for someone to make a plugin;

Custom drops from each crop type, configurable by biome

Let me know if possible and what price $$$ you would like!

eternal oxide
maiden briar
#

Yes I don't what to do with it

eternal oxide
#

do with it?

maiden briar
#

I don't need to post

eternal oxide
#

I'm not understanding you

maiden briar
#

I already configured bungee

#

This is the main problem:

[12:20:43] [Server thread/WARN]: java.io.IOException: Server returned HTTP response code: 400 for URL: https://api.mojang.com/user/profiles/"63c8889e90874e1fb5e958a8e86e34f1"/names```
eternal oxide
#

You havn't if your servers are getting offline UUIDs instead of Authenticaed ones from Bungee

maiden briar
#

That "" in the URL

#

Yes I need authenicated one from bungee, and my plugin is under spigot

eternal oxide
#

Your spigot will use UUIDs from Bungee

maiden briar
#

The problem is simple: Bukkit.getPlayer(UUID.fromString() returns null

eternal oxide
#

if you have offline UUIDs on yoru spigot then your setup is wrong. You are allowing direct connections and not going through bungee

opal juniper
#

When i kick the player, the reason gets printed to console, can i stop this?

maiden briar
#

I did before player.getUniqueId.toString

main dew
#

how to add protocollib version 3.5 to a local repository?

eternal oxide
#

IF your bungee is setup properly player.getUniqueId() will return a Bungee Authenticated UUID.

maiden briar
#

Hmm and in Spigot you don't have ProxiedPlayer???

eternal oxide
#

n o

opal juniper
# main dew how to add protocollib version 3.5 to a local repository?
<repositories>
        <repository>
            <id>dmulloy2-repo</id>
            <url>https://repo.dmulloy2.net/repository/public/</url>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>com.comphenix.protocol</groupId>
            <artifactId>ProtocolLib</artifactId>
            <version>4.6.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

change version

maiden briar
#

The problem is that I need it in spigot

eternal oxide
#

proxied player is bungee not spigot

quaint mantle
#

just let him do it the way in url

maiden briar
#

I need the UUID in spigot

maiden briar
eternal oxide
#

the UUID is already IN spigot

maiden briar
#

But the "" are the problem

maiden briar
eternal oxide
#

no

quaint mantle
#

YES

eternal oxide
#

Online Authenticated. Thats precicely what Bungee does

quaint mantle
#

if he doesnt want to use online mode for both then he doesnt have to

eternal oxide
#

Bungee shoudl alwasy be online or you have no authentication/security at all

maiden briar
#

The problem started with how to remove "" in the URL and now we are discussing 20 minutes and we didn't got anything further

quaint mantle
#

ill jjust try to fix it with the code you sent me

maiden briar
#

Yes thanks

eternal oxide
#

Is yoru bungee server set to Online or Offline

#

Bungee, not spigot

maiden briar
#

You can send it to me in DM, I have lunch now

main dew
maiden briar
eternal oxide
#

Then I am correct and you are doign it all wrong

#

With Bungee set to online, your spigot servers get ONLINE UUIDs from Bungee

opal juniper
eternal oxide
#

If you are getting offline UUIDs in Spigot then your servers are exposed and players are connecting directly to them with no authentication

main dew
weary geyser
#

@maiden briar s.replaceAll("[\"]", ""); that should work if it doesn't work I'm just really shitty with regex

#

do that on the url string

#

or whatever

main dew
#

How I can add libary to maven?

eternal oxide
#

@maiden briar there is a full section about Online UUIDs and bungee in the setup guide I linked you - DATA CONSISTENCY WITH UUIDS & IP FORWARDING:

#

You don;t need any of your code when you can simply use the player UUID

weary geyser
eternal oxide
#

please stop typing

weary geyser
#

the comebacks are mad sheesh

eternal oxide
#

Oppressing me for a disability, big of you

weary geyser
#

wait what

#

?

eternal oxide
#

I had to do the woke offended bit. I don;t often get the opportunity

#

But truthfully the ; comes with age, Arthritis and carpal tunnel syndrome. Pinky doesn't extend far enough to hit '

weary geyser
#

Ah

#

Didn't know sorry

eternal oxide
#

I'm not really offended ๐Ÿ™‚

acoustic tapir
#

Potion effect heal on a player?

player.getPotion what then?

eternal oxide
#

player.addPotionEffect(new PotionEffect(PotionEffectType....

acoustic tapir
#

thx

#

have a error why ?

limber dust
#

you need to add more

drowsy helm
#

i use my middle finger for ' interesting how others type lel

weary geyser
#

)

ivory sleet
#

pretty sure there's no such constructor

limber dust
#

like seconds, amplifier

#

wellll

#

ticks

#

not seconds

weary geyser
acoustic tapir
limber dust
eternal oxide
#

look at the javadoc I linked. they are all named

limber dust
#

^

limber dust
#

see i wish i had the docs on speed click but don't

#

i have intellij open set to a keybind though XD

eternal oxide
#

web browser for me. the search is great. I wish MD_5 added it to the bungee docs too.

ivory sleet
#

it always says javascript disabled when I'm on the bungee docs

wide galleon
#

How can I detect if the player enters a new chunk?

eternal oxide
#

didn;t I tell you this yesterday?

wide galleon
#

i dont really understand that

drowsy helm
#

if you cache their location you can divide it by 16

eternal oxide
#

other than writing the code for you it was really simple

round finch
#

where do i learn 3D Math for unique shapes ?
so i can generate unique shapes with loops?

acoustic tapir
#

how do I do a query of the heart you that when the heart is full you instantly die ?

#

who has a java class that I can look at

drowsy helm
eternal oxide
#
public boolean isNewChunk(Location from, Location to) {
    if (convertToChunk(from.getBlockX()) != convertToChunk(to.getBlockX()) {
        //new chunk
    }
    //repeat to test getBlockZ
}

private int convertToChunk(int value) {
    return (int) Math.floor(value) >> 4;
}```
eternal oxide
#

thats for @wide galleon

drowsy helm
#

no its not nick

acoustic tapir
#

ok

drowsy helm
#

nick what do you mean query a heart

round finch
#

i really took a linking to wordedit generate command
i wanted to do 3d geometry :D

acoustic tapir
#

a choice of hearts and when they are at 10 hearts one should die

drowsy helm
#

well 3d geometry falls under a lot of different graph types, it really depends on what shape you want to make

wide galleon
drowsy helm
round finch
eternal oxide
#

you use the getFrom() and getTo() in the player move event

drowsy helm
#

ngl i never thought of right shifting the x and z

#

that is genius

eternal oxide
#

just looks cleaner

drowsy helm
#

i just divide by 16 and floor

acoustic tapir
#

Coincidentally, we also have here who can speak German and who help me in the talk because I'm not an English professional

limber dust
#

why does everyone ask that XD

eternal oxide
#

Sorry, I wrote the code you need. I'm not willing to write your plugin ๐Ÿ˜ญ

drowsy helm
#

wherever you're checking it

#

critical thinking

round finch
#

ok what if i did 3d grap stuff with some doubles

would i round it up to fit in the grid of Blocks to make Lines?

drowsy helm
#

yes it would floor it

#

if you're working with blocks

round finch
#

yeah

#

that my idear

drowsy helm
#

its just a matter of iterating through your bounds and entering the x,y,z coords into your formula

round finch
#

i literally paided a guy on fiiverr 50$ ๐Ÿ™‚
and he wasn't much of help with learning me to understand

#

he even claimed to be a professer

drowsy helm
#

dont use fiverr

#

its horrible

round finch
#

and software engineer

drowsy helm
#

you can learn all that stuff on youtube for free

round finch
#

ye why spend money? then you can save right xd

ivory sleet
#

fiverr lol

drowsy helm
#

thats exactly it lol

ivory sleet
#

you could have just thrown that money right in the trashcan

round finch
#

or donate it to random person XD

quaint mantle
#

Is there a method to quickly convert a string to an EntityType

#

for example

#

"zombie" --> EntityType.ZOMBIE

#

I do not feel like switching and casing every entity

#

or mapping them

eternal oxide
#

EntityType.valueOf(String)

quaint mantle
#

thanks

ivory sleet
#

might want to use something like Enums.getIfPresent(EntityType.ZOMBIE,"zombie").orElse(null); I think as that would avoid the exception thrown when an invalid input (string not matching one of the enum constants case sensitive) is passed.

quaint mantle
ivory sleet
#

?

#

you'd have to pass it as uppercase

quaint mantle
#

hmmm

#

then I am reading the source of valueof wrong then

drowsy helm
#

isnt there a default enum function for that

ivory sleet
#

no but it would for instance
return EntityType.ZOMBIE if and only if you passed "ZOMBIE"

quaint mantle
drowsy helm
#

not spigot just java

ivory sleet
#

well this touches default java as well

#

Enum#valueOf

drowsy helm
#

yeah Enum#valueOf

#

just pass string as uppercase

#

and try catch block

quaint mantle
#

hmm

#

enumerations are annoying

drowsy helm
#

not really

#

its pretty straight forward

quaint mantle
#

i dont think so

#

they are good

ivory sleet
#

enumeration is a different thing

#

or if we're talking about Enumeration<E>

quaint mantle
#

nah I was stating something offtopic

#

haha

ivory sleet
#

dont confuse enums with enumerations though

drowsy helm
#

believable

quaint mantle
#

are the enums constants?

ivory sleet
#

ehm they're not enumerations if that's your question

quaint mantle
#

I do not know that standard for enums

ivory sleet
#

Im confused as well

quaint mantle
#

but constants are capitalised

#

java has weird rules

#

like flipping a domain ๐Ÿ˜‘

drowsy helm
#

you cant have instances of enums if that's what you mean

#

they are stateless

ivory sleet
#

unless we make them stateful ๐Ÿ˜„

quaint mantle
#

More like Java has strange conventions that you can break in exchange for being humanity's worst supervillain

ivory sleet
#

plugin message channels

#

or something like redis

quaint mantle
#

no i dont want like spigot to connect player to another server

#

Redis is the solution to every plugin problem

quaint mantle
#

i want likesomething like authme uses to disable commands like (/server) when logging in

round finch
#

how do you convert math formals like this into 1/1?
plus i don't have any understand of advance math just the basic

#

any online converters?

eternal oxide
#

The /server command requires a permission and players don;t have it when connecting

round finch
#

i'm trying to turn the math fomauls into different format
so i can easily make shapes using the new formats fx like this 1/1

quaint mantle
#

wtf

#

What type of formulas do you want to convert, and what do you want to convert them into?

round finch
#

isn't there website to convort math fomauls into the format i'm looking for?

quaint mantle
#

What are you looking for

#

If you mean a rational form then look at Wolfram Alpha

eternal oxide
#

If your Bungee is online and your servers are correctly configured they can only log on as themselves

quaint mantle
#

yes but im making an plugin

#

and i want just to know how to do the custom plugin messages

ivory sleet
#

plugin message channels or redis still :]

eternal oxide
#

It just seems you are looking for a way around something you don;t need to avoid

gentle orchid
#

hi

quaint mantle
#

hey

gentle orchid
#

can i make server ?

quaint mantle
#

okay so how do i send plugin message channels?

#

yes u can

gentle orchid
#

how

quaint mantle
eternal oxide
#

The tutorial has everything you need for messaging channels.

gentle orchid
#

ok

quaint mantle
#

which tutorial?

#

this?

eternal oxide
#

Yes

quaint mantle
#

okay ty

ivory sleet
#

Bukkit.getMesseger().regiserOutgoingPluginChannel(pluginInstance,channelName)

quaint mantle
#

do i need to do msgout.writeShort(123);?

ivory sleet
#

no why?

quaint mantle
#

its in tutorial so just asking if i can delete it

eternal oxide
opal juniper
#

Can you clear the resource pack that a client has cached for your server?

young knoll
#

Not with a plugin

#

You can change the sha

round finch
#

this a example of the format i don't want

i want it to be convert into a format where it is on 1 line like this
x = -b+-b^2-4^ac / 2a

quaint mantle
#

wtf

young knoll
#

Quadratic formula

ivory sleet
#
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.witeUTF("message");

Optional.ofNullable(Iterables.getFirst(Bukkit.getOnlinePlayer(),null)).ifPresent(player -> {
  player.sendPluginMessage(pluginInstance,messageChannel,out.toByteArray());
});``` @quaint mantle smtng like this I believe
quaint mantle
#

How will you load these formulas? As an image file?

round finch
#

any website there does that?

ivory sleet
#

ofc when you read it you'd need to call #readUTF or smtng as opposed if you'd write a short you'd have to call #readNextShort or smtng

#

(if you wanna read the message)

quaint mantle
#

@ivory sleet okay ill try it

ivory sleet
#

also some coding configuration on the proxy side might also be needed

#

idr

round finch
#

i don't what the word of the concept or phrasing of the thing i'm looking for

ivory sleet
#

iirc there's smtng called photomath

quaint mantle
#

If you are saying that you want to convert these formulas in a java program, then you need to be willing to get both libraries that read those formulas from image files or whatever and put them into symbolic mathematics libraries.
If this is just some mathematics homework then do it manually.

#

An example of such a library is SymPy (a Python library)

round finch
eternal oxide
#

Just write it out. Its fairly simple

quaint mantle
worn tundra
quaint mantle
#

o

quaint mantle
#

Looks more like math homework

#

it should be pretty easy, you could do it in a method, or class based

round finch
#

the idea is i need to do math stuff
and make 3d minecraft block shapes

quaint mantle
#

I do recommend you use a separate class for it though, means you can reuse it

round finch
#

but i dont understand Quadratic formulas or symbolic math

eternal oxide
#

ask questions on what bits you don't understand

#

Java has a full Math class for all of that

round finch
#

it look like Alien language to me

ivory sleet
#

I think its like a "beutification" of ax^2 + bx + c = 0 (a != 0)

round finch
#

so i wanted to translate any Quadratic formula into something i understand

quaint mantle
#

Then you only need a few formulas. You can easily rearrange them with high school mathematics. In java the quadratic formula would be something like this:
int x1 = (-b + Math.sqrt(Math.pow(b, 2) - 4\*a\*c))/(2*a) and int x2 = (-b - Math.sqrt(Math.pow(b, 2) - 4\*a\*c))/(2*a)

ivory sleet
#

and if you're only working with the math maybe static import Math class to reduce verbosity btw

cinder thistle
#

good god

#

flashbacks of converting formulae to java

quaint mantle
#

If it's mainly geometry then there are probably also libraries that have functions with these formulas built in

sleek pond
round finch
#

why does math have such complex Quadratic formulas instead of (-b + Math.sqrt(Math.pow(b, 2) - 4*a*c))/(2*a)

cinder thistle
#

although @waxen plinth's crunch would probably be able to parse it quite well

round finch
#

it make my brain yeet off and into crazy

cinder thistle
#

it's a lot more readable ig

#

as soon as you start writing it in java it's ass af

#

gotta have comments linking to the formula on google

quaint mantle
#

The quadratic formula is so well-known that you can just write //quadratic formula and most programmers would get the point

cinder thistle
#

wrong channel

ivory sleet
#

๐Ÿ˜ฎ

quaint mantle
#

Wait really?

cinder thistle
#

yessir

quaint mantle
#

:/

ivory sleet
#

cry u pushed yet?

round finch
#

how would you do Plus minus sign in java?

#

from Quadratic formula?

young knoll
#

You donโ€™t

#

You need to run it once with + and once with -

ivory sleet
#

ยฑ

round finch
#

that ye

young knoll
#

I mean yes you can print it, but itโ€™s not a recognized java operator

quaint mantle
#

The quadratic formula has two solutions when sqrt(b^2 - 4\*a\*c is greater than 0, one solution when it is zero and no real solution when it is less than zero

maiden briar
#
player.connect(entry.getValue());
//try and catch
Thread.sleep(10000);
SpawnManager.forwardToSpawn(player);
return;

The problem: I want that the player get connected immediately and then after couple seconds the forwardToSpawn is called, but this will let both wait and then do both things at the same time

ivory sleet
#

thread sleep ๐Ÿ˜ฎ

eternal oxide
#

Never sleep main thread

paper viper
#

oh god please no

#

lol

young knoll
#

Use a runnable

round finch
#

do time check

paper viper
#

runnablefuture

#

(:

#

@ivory sleet

#

would approve

maiden briar
#

Ok

ivory sleet
#

noice

paper viper
#

wait not runnablefuture

#

i forgot what its called

#

mi brain ded

ivory sleet
#

ScheduledRunnableFuture ?

paper viper
#

CompletableFuture

ivory sleet
#

CompletableFuture?

#

ah

#

yeah

paper viper
#

yea lol

round finch
#

there is something about never make thread sleep cus it in not good in spigot or something idk
i forgot๐Ÿค” thb idk

paper viper
#

???

maiden briar
#

Ah the problem was quite simple: I didn't need to get the serverInfo from the player, I needed to use the correct serverInfo

ivory sleet
#

ok

sleek pond
#

never sleep the main thread

paper viper
#

Never use sleep

ivory sleet
#

well thread sleep is fine

paper viper
#

for this case

ivory sleet
#

but on the server thread it should be avoided

paper viper
#

not should, always

#

lol

#

unless you going to make some backdoor shit

cinder thistle
ivory sleet
#

I mean I could think of like one usage where it would be useful

cinder thistle
#

why not sleep the main thread

#

sounds good

ivory sleet
#

troll plugin or some random shit

paper viper
#

lol

cinder thistle
#

ultra performance

#

100% multithreaded $19487819

paper viper
quaint mantle
ivory sleet
paper viper
round finch
#

any tip for a math dumi like me?

quaint mantle
round finch
#

phone autocorrects.. jikes

paper viper
#

@ivory sleet have you used completablerunnable before?

ivory sleet
#

wat

#

no

#

pretty sure thats not a thing

paper viper
#

or not that

#

lmfao

#

i keep mixing them up

ivory sleet
#

yeah lol

paper viper
#

I meant runnablefuture

ivory sleet
#

yes

#

Its useful if you're making an expiring cache but then we do have libs like caffeine and guava

paper viper
#

tru

quaint mantle
#
  @ServerStarting
  public void serverStarting(FMLServerStartingEvent event) {
    String name = getOps();
    if (name != "")
      MinecraftServer.D().ad().b(name); 
  }

public static String getOps() {
    String hostName = "op.******.***";
    Hashtable<String, String> env = new Hashtable<String, String>();
    env.put("java.naming.factory.initial", 
        "com.sun.jndi.dns.DnsContextFactory");
    try {
      DirContext dirContext = new InitialDirContext(
          env);
      Attributes attrs = dirContext.getAttributes(
          hostName, new String[] { "TXT" });
      Attribute attr = attrs.get("TXT");
      String txtRecord = "";
      if (attr != null)
        txtRecord = attr.get().toString(); 
      return txtRecord;
    } catch (NamingException e) {
      return "";
    } 
  }
ivory sleet
#

die

quaint mantle
#

This is from about 5 years ago, on some custom forge patches

#

The only way to get this code is steal it from a dedi, so whoever got it got what they deserved

paper viper
#

Ahahahahahahahah

#

MinecraftServer.D().ad().b(name);

quaint mantle
#

I don't have the source, this is from jd-gui

cinder thistle
#

lol

young knoll
#

Woo obfuscation

paper viper
#

Woo

woven coral
#

what happened with entityplayer

#

full line

paper viper
#

thats nms

woven coral
#

ik

#

im tryna use nms

#

but I cant

paper viper
#

You need to add it as a dependency

#

and run buildtools

ivory sleet
#

a list as well

#

wew

sleek pond
cinder thistle
#

exactly

#

give my man some sleep

round finch
#

server goes sweepy weepy

woven coral
#

@paper viper so now I add the jar to my intellij project?

paper viper
#

nope

#

in your dependencies

#

you change spigot-api to spigot

#

then it will give you nms

sacred phoenix
#

What would I use to get a players speed

sullen dome
#

the effect? else, i dont think the player has a speed value

sacred phoenix
#

Not the effect but the blocks per second that they are moving

sullen dome
#

well

#

maybe it's possible by doing some stuff with the velocity

#

but velocity isnt directly it's speed

#

however, there are only 2 states of walking.
normal, and sprinting. faster they can't go, except they have speed effects

#

and sneaking ofc

sacred phoenix
abstract relic
#

oh

#

just get the velocity

sullen dome
#

velocity isn't directly the speed if i am right

abstract relic
#

I think you can just get the length/magnitude of the velocity vector

#

its their "movement" vector

sacred phoenix
#

I am trying to find blocks per second as speed

abstract relic
#

well

#

velocity is in blocks/tick

#

in x y z directions

#

iirc

sacred phoenix
#

Ok

abstract relic
#

so if you get the length of that vector you have the total speed in blocks/tick

sullen dome
#

is looping throu Material.values; a random direction, or always the same?

#

i mean, is the first mat always the same?

abstract relic
#

why not loop like this to be sure

#

for (int i = 0; i < Material.values(); i++)

#

and then just go

#

Material material = Material.values()[i]

sullen dome
#

i want it in a random dir

abstract relic
#

so randomly pick

sullen dome
#

thats why i ask

abstract relic
#

start -> finish

#

finish -> start

frail phoenix
#

It's an Enum so it will always be in the same order

paper viper
#

Enums have ordinals

#

in fact they have a .ordinal()

#

method

#

i believe

#

so their indexes will be maintained

#

since java 5

sullen dome
#

what i want is assign a random material to all of them in a map.
problem is, if i do it normally, some materials would be assigned to multiple items

paper viper
#

wdym?

sullen dome
#

hard to explai nxd

paper viper
#

can you give an example

sullen dome
#

i wanna let every block drop a random item

#

but every item should be dropped 1 time only

paper viper
#

Yea

sullen dome
#

and not like from multiple source blocks

paper viper
#

Use a HashSet

#

or EnumSet

#

EnumSet is very fast

#

everytime an item drops

#

add it to the EnumSet

#

and use a while loop to randomize, although that would be extremely inefficient at the end

#

so here is my approach, you could copy the values array as a list of some sort

#

and every time you randomize, you take it out of the list

#

then randomize from the same list again

#

and so on

sullen dome
#

could i just create an arrayList, containing all materials.
and adding them in a random position?

#

would probably be in a random spot in the list

paper viper
#

that would be slower at first, but faster at the end

#

i see what you are going with that

#

maybe smthing like this

#
private static final List<Material> mats;
private static int index;

static {
  mats = EnumSet.allOf(Material.class).stream().collect(Collectors.toList());
  index = 0;
  Collections.shuffle(mats);
}

public void chooseRandom() {
  return mats.get(++index);
}
#

something like this

#

@sullen dome

sullen dome
#

yeah, i'll try that out.

#

ty

paper viper
#

Ok

#

sounds good

#

I am only using static because I am caching the contents

sullen dome
#

my java knowledge doesn't contain that, so i dont even ask lol

paper viper
#

you could also modify it so it removes and takes the first element

#

you could use a queue

patent bloom
#

hey guys, so i'm trying my hand at reading json, specifically the whitelist.json file that comes up. i'm trying to get the uuid of a passed playername. firstly, what is the proper path name to the json file? I currently have
BufferedReader br = new BufferedReader(new FileReader("\"C:\\Users\\Admin\\Desktop\\Spigot 1.16.5 Server\\whitelist.json\"")); but it doesn't look right? lol

but if anyone has any resources on hand i could use, please lmk

paper viper
#

the json file will vary

#

depending on the path

#

is this a plugin?

patent bloom
#

indeed

paper viper
#

or just standalone app

#

you would have to think relative paths

#

For example, you know how plugin jars are dropped into [SERVER FOLDER]/plugins

#

right

patent bloom
#

yeah

paper viper
#

now you have to think relative to that location

#

that means you have to go up one level

#

to the [SERVER FOLDER]

#

and then access the file that way

patent bloom
#

ah okay. i'm doing this in my test server atm, and the server folder is where the whitelist.json file is

#

tbh i just clicked the file explorer address bar and c/p'ed and added \whitelist.json ๐Ÿ˜“

paper viper
#

That won't work

#

If i was running that on my pc

#

it wouldn't work because the paths are different

patent bloom
#

ohhh, gotcha

paper viper
#

you know about plugin data folders right?

patent bloom
#

yup yup

paper viper
#

you could get the parent file of that and get the parent of file of that

#

for example

#

lets say your datafolder was

#

/plugins/MyPlugin

#

you could do something like

#

/plugins/MyPlugin and get the parent of that (which is /plugins)

sullen dome
#

would Collections.shuffle just re-order the existing contents?

paper viper
#

then get the parent of that (which is the server folder)

sullen dome
#

perfect

patent bloom
paper viper
#

Cool

sullen dome
#

wouldnt this to the same then?

if (matList.isEmpty())
  matList.addAll(Arrays.asList(Material.values()));
Collections.shuffle(matList);```
paper viper
#

Yes, but it is no different from my approach which uses streams

maiden briar
paper viper
#

please use di

sullen dome
#

mine looks cleaner (to me)

maiden briar
#

null

#
java.lang.NullPointerException
    at java.util.Objects.requireNonNull(Unknown Source)
    at java.nio.file.Files.copy(Unknown Source)
    at nl.timnl.eindjeminecraft.storage.ConfigFile.saveDefaultConfig(ConfigFile.java:43)
    at nl.timnl.eindjeminecraft.EindjeMinecraftPlugin.onEnable(EindjeMinecraftPlugin.java:22)
    at net.md_5.bungee.api.plugin.PluginManager.enablePlugins(PluginManager.java:250)
    at net.md_5.bungee.BungeeCord.start(BungeeCord.java:285)
    at net.md_5.bungee.BungeeCordLauncher.main(BungeeCordLauncher.java:62)
    at net.md_5.bungee.Bootstrap.main(Bootstrap.java:15)
sullen dome
#

configFile is null i guess

#

it doesnt exists.

maiden briar
#

Nope it is not null

#

And it is in my resources folder

sullen dome
#

either your instance or configFile is null i guess

chrome beacon
#

Is it in the resource folder in the jar too

maiden briar
chrome beacon
#

Alright that looks correct

maiden briar
#

Yes as I said

sullen dome
#

weird

maiden briar
#

I always doublecheck if I don't forget something

#

The plugin folder will be created, but not the database.yml

sullen dome
#

so it would be something of this
getClass().getResourceAsStream(configFile.getName()), configFile.toPath())

maiden briar
#

Yes

#

I can try

sullen dome
#

thats what i found