#development

1 messages · Page 127 of 1

mint verge
#

Why do u not have a column

shell moon
#

i dont think you get the idea

mint verge
#

x,y,z

dark garnet
mint verge
#

a column for each axis

dark garnet
#

but different worlds

mint verge
#

ok

#

add a world column

shell moon
dark garnet
#

ik i tried that but it was a lot more complicated

shell moon
#

imo its easier

#

as you can save it like float

#

already

#

but well

rose oxide
#

why are you creating a new GetSql every time u make a call yo

shell moon
#

still dont get why you "loop columns"

mint verge
#

You know what the column names are

#

Theres no need to loop

#

through anything

shell moon
mint verge
#

First off

#

u should use sql pools

#

not instantiate a new connection everytime

#

and you know the column names so just use those

shell moon
#

if its for a lock system

#

he probably need to cache on start

mint verge
#

So he loads them on post construct of the plugin class?

#

Then make 1 big query that fetches all of it and u can iterate each row

#

and call the column by their name

#

and not looping

#

Theres no need for a system like that unless you're working with unknown structure

#

@dark garnet If you want help you'll have to give a bit more context to what you're trying to achieve

shell moon
#

few words: lockette

mint verge
#

If you're directly working with sql you should take a look at this too

dark garnet
#

@mint verge did u see this

mint verge
#

Show me a table schem

rose oxide
#

^

west socket
#

I tried using an sql API but it’s better to just either write your own or not use one

rose oxide
#

looks like he wrote his own tbh

mint verge
#

idk I don't use sql with java 🙂 @west socket

west socket
#

I see

west socket
#

The only thing the APIs are decent for is managing the connection

mint verge
#

ye

west socket
#

They’re terrible for making queries

mint verge
#

Which is why u should sql pools

#

bare minimum sql pool api

#

ok

#

so from my understanding

#

you want to loop through the content in the WORLD_XYZ_BLOCK column

rose oxide
#

wth is the table even for

mint verge
#

To get the coordinates right? @dark garnet

dark garnet
#

world + coords + block yea

rose oxide
#

block has a locker right?

mint verge
#

so

#

world_

#

is the name of the world?

rose oxide
#

why do you need the block type if its a locker

#

is there different kinds?

dark garnet
shell moon
#

world name with _ = gg

mint verge
#

okay

#

so

#

U need to split the string

#

Split the string every "_"

dark garnet
#

i do that after

#
List<String> list = new GetSQL("locked").getValue(new String[]{"WORLD_XYZ_BLOCK"});
if (list != null) for (String key : list) {
    String[] split = key.split(",");```
mint verge
#

well u need to split it

#

_

#

this is your character seperator

dark garnet
#

o i forgot to change the , to _...

mint verge
#

although you should store that string in 3 different columns

#

like you should have a column world, x, y, z, material

#

It's much more efficient than storing varchar

rose oxide
#

CREATE TABLE Locker ( lockerId INT PRIMARY KEY, world VARCHAR(32), x INT, y INT, z INT, type INT);

shell moon
#

TEXT world

#

(ignore, i use sqlite xD)

mint verge
#

use VARCHAR(50) for world name

dark garnet
#

imma explore making each one separate later

#

but i wanna try to get this working first

#

so i at least have something

rose oxide
#

it's more struggle than it's worth bro

west socket
#

I’m confused what he’s trying to do

shell moon
#

he wants to lock blocks

#

so people cannot open or interact

rose oxide
#

hes tryna store all this shit in a varchar and split it to get all this data

dark garnet
dark garnet
west socket
#

Trying to store an entire map in an SQL db?

rose oxide
#

you showed no sql interaction in the method how could we help you with that

dark garnet
shell moon
mint verge
#

You mind showing

#

The GetSql class

dark garnet
shell moon
dark garnet
#

when it gets to the last valid row, the row after it is invalid, so it doesnt add the last valid row

shell moon
#

still, suggestion was

#

do the same as griefpreventions

mint verge
#

You should make your getValue method have a generic

shell moon
#

load all on server start, save on server stop (and interval of time)

shell moon
#

but yeah

#

do that, as normal people would do

#

i mean, why checking database every time someone breaks a block lol

mint verge
#

Wait

#

Does he really do that

dark garnet
#

no

mint verge
#

oh

#

ok

dark garnet
#

well sorta

#

it only checks if the block is lockable

shell moon
#

public void createTable(String[] columns) {

mint verge
#

You should cache the block

rose oxide
#

that is quite literally a query

shell moon
#
    StringBuilder result = new StringBuilder(30);
    for (String value : columns) {
        result.append(value).append(" VARCHAR(100), ");
    }
#

omg

#

isnt it easier to write the string directly?

#

and make it a column per axis?

rose oxide
#

Im also very confused why one would ever need to create a table programmatically, just make a db and host that bitch

mint verge
#

phpmyadmin that shit

#

or

#

mysqlbench that shit

#

much easier to create your infrastructure like that

rose oxide
#

or is this like sqlite or something

shell moon
#

@dark garnet did you write that class?

shell moon
#

that explains a lot

dark garnet
#

oh

shell moon
#

dont get me wrong but

#

it sucks

#

you get confused when using it

#

it's 100times easier

#

to simply write the method you need

#

instead of making it need an array

#

you can easily make a table with world, x, y, z, locker and a random uuid

#

instead of complicating your life making it a string like world_x_y_z_world

mint verge
#

"An idiot admires complexity, a genius admires simplicity. (...) An idiot, anything the more complicated it is, the more he will admire it. If you make something so clusterfucked he can't understand it, he's gonna think you're a god 'cause you made it so complicated nobody can understand it." -Terry A. Davis

shell moon
#

or similar

shell moon
mint verge
#

Terry A Davis has the best quotes

#

he's our lord and saviour

rose oxide
#

+rep for terry davis quote

dark garnet
#

so what do i do

mint verge
#

Scrap it all

#

start over

rose oxide
#

remove getsql

mint verge
#

Remake the sql infrastructure

rose oxide
#

make db and interface it with code instead of creating the whole db programmatically

mint verge
#

Make your Locker Table have a column for each axis, worldname, id of locker, id of placer

rose oxide
#

^

mint verge
#

Then create yourself a method

#

With an interface

#

for example

#

GetAllLockers()

#

Which gets all lockers

#

What you could do is make a Locker class

#

and translate the data each row into a Locker object

#

then put Locker in a cache

#

and when someone breaks a block of type locker check locker cache

shell moon
#

easy, don't use that class and write a new one with only the methods you need

rose oxide
#

@dark garnet you're glowing

shell moon
#

just wondering

#

this.name = Main.config.getString("database.prefix") + table;

#

why?

#

if prefix is [MyPlugin]

#

would table name be [MyPlugin]tablename?

#

why?

dark garnet
#

default database.prefix is v_

shell moon
#

and why?

dark garnet
#

cause the plugin's name is vanadium

shell moon
#

cant you simply use table name configurable?

#

and? lol

dark garnet
#

it starts with a v

shell moon
mint verge
dark garnet
shell moon
#

i usually do

mint verge
#

configure your table names

#

in the config

shell moon
#

Database:
USer etc
Pass etc
Table: "alonsotags"
etc etc

#

why making a prefix AND a table name?

#

dont complicate your life

dark garnet
#
database:
  host: "host"
  port: "3306"
  database: "database"
  username: "username"
  password: "password"
  useSSL: false
  prefix: "v_"```
mint verge
#

Programming is about being lazy

dark garnet
#

thats what the config looks like

shell moon
#

wtf

mint verge
#

not the other way around

shell moon
#

and whats "table" value?

#

thats selected by you

#

in the code?

dark garnet
#

thats set with new GetSQL(table)

shell moon
#

i'm not a huge fan of forcing table name

#

i allow them to pick the one the want

dark garnet
#

ive never seen customizable table names ¯_(ツ)_/¯

shell moon
#

literally

rose oxide
#

just make your table name what you want it to be.

shell moon
#

all of them are

#

if you delete the + table part

#

you are good

dark garnet
#

no...

mint verge
#

y

dark garnet
#

i have multiple tables

shell moon
#

forcing table name

rose oxide
#

Locker table should be Locker

shell moon
#

ew

dark garnet
#

all of them would be called v_

mint verge
#

then

#

call them

#

v_locker

dark garnet
#

thats what i did

mint verge
#

v_users

shell moon
#

i seriously

#

dont get why making it that way

#

someone?

mint verge
#

well don't make the prefix configurable

#

just

#

do

#

getsql("v_locker").getValue...

shell moon
#

if i ever do that, people would complain about it not being configurable lol

rose oxide
#

make your Locker table named Locker not v_locker_alonsotags shit because thats not fun.

shell moon
#

imagine adding a_wahteveryouwant

#

no way, i rather making it configurable

#

going back to the main issue

#

create your sql class and make only necessary methods

shell moon
rose oxide
#

does he have 30,000 other plugins using the same db :V

shell moon
#

even if he had, i dont think he'd need another database

#

unless he gets "max amount of connections" kekW

rose oxide
#

hey man he was glowing hard we had to say something

mint verge
#

He was glowing in the dark

dark garnet
#

wdym im glowing??

shell moon
shell moon
#

prob bc its not my main language

leaden plume
#

Hey @mint verge this is a warning for that latest post of yours! Please rest the rules

mint verge
#

This is who glows in the dark

#

@leaden plume Im explaining

#

why he glows in the dark

lunar sun
#

no fun allowed 😠

mint verge
shell moon
#

fun is allowed, if on topic KEKW

leaden plume
rose oxide
#

the topic is memes now

dark garnet
#

uh oh seb go bye

shell moon
shell moon
#

wtf

#

peppa god

#

so @dark garnet make the class and necessary methods

leaden plume
shell moon
#

and show it

dark garnet
shell moon
dark garnet
#

cause i dont see any benefits from removing the unused ones besides making the class cleaner (or is that the only reason?)

shell moon
#

up 2 u tbh idk

#

i belive writing one is easier

#

¯_(ツ)_/¯

dark garnet
shell moon
#

do it as you want

#

but write the methods you need

#

in an easy way, without utils to make it array or something

#

if you already know there are 3 rows

#

write the code like that

#

not update(String[] values)

#

i mean, whyy?

rose oxide
#

just write the sql queries inline

dark garnet
#

what should be the new things i consider when remaking?

#

besides doing the necessary methods

#

like caching and stuff

rose oxide
#

make the table structure use columns and cache immediately upon start

dark garnet
#

ok dyno

shell moon
dark garnet
shell moon
#

loadLocations() { //on start
get connection, get rows, while next, add to map
}
saveLocations() { //on stop and interval of time
get connection, loop the map, store world, locker, x, y, z, type
}

rose oxide
#
    public boolean contains(String column, String value) {
        try {
            // Statement
            PreparedStatement ps = Main.SQL.getConnection().prepareStatement("SELECT "
                    + column
                    + " FROM "
                    + name);

            // Action
            return ps.executeQuery().toString().contains(value);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return false;
    }
```what is this doing just use .executeQuery that returns resultset
#

then while(set.next()) { String world = set.getString("world"); int x = set.getInt("x"); int y = set.getInt("y"); int z = set.getInt("z"); ..etc }

#

then create the instance of the locker and load it into the hashmap

#

after this all you will need to do is change the data in the map

#

then onDisable you can make all of your inserts/updates

dark garnet
#

imma have 2 tables, so should i just create separate methods for both of them?

rose oxide
#

sure you could have methods to load the maps

dark garnet
#

so should i create another method that does the same thing except for the other table?

shell moon
#

just wondering, why 2 tables

dark garnet
#

trusted players

rose oxide
#

thats not a method/doesnt have to be a method lowkey but yes

dark garnet
#

v_trusted with PLAYER and TRUSTER columns

rose oxide
#

you would just do the same shit

shell moon
#

trusted per block?

#

or per player?

dark garnet
#

player

shell moon
#

i mean, i trust someone to interact with my block

#

or with all my blocks

dark garnet
#

its to trust with all of ur blocks

shell moon
#

ah ok, then it's ok

rose oxide
#
while(set.next()) { 
  UUID uuid = UUID.nameUUIDFromBytes(set.getBytes("uuid"));
}```not rlly sure how to load uuids from resultset but i assume its like this if you want to use the uuid datatype in sql otherwise just store as string
dark garnet
#

does the uuid datatype support hyphens?

shell moon
#

save it as string and UUID#fromString

rose oxide
#

sure

dark garnet
shell moon
#

thats what i've been doing for years

#

haven't found a good way to do it

#

¯_(ツ)_/¯

rose oxide
#

I wonder if that would work

#

sql has the datatype

dark garnet
#

also i just wanted to know the downsides, if any, of using yml storage
and the benefits, if any, of using sql over yml

rose oxide
#

sql wins in speed over yml unless structure is bad

#

plus sql has good querying

#

able to basically write any code to retrieve specific results in sql

shell moon
#

yml can corrupt also, right?

#

and is slow af when too many data

#

dont ever use it

#

seriously

rose oxide
#

other than for like database.yml

#

lol

dark garnet
#

the locking system im using, which i got from a plugin i contribute to, uses yml storage

rose oxide
#

or static data generally

dark garnet
#

and ive been trying to transfer it all into mysql

shell moon
#

yml = slow if too many data

#

so it's not even an option

rose oxide
#

its mostly just interacting with the file system thats slow not rlly about the file type, also every java method to filter results is slower than sql

dark garnet
#

what would be the best option for first plugin?

#

cause this is my first time making a plugin

rose oxide
#

first big plugin or first plugin?

dark garnet
#

first plugin

lyric gyro
#

It’s not that it’s slow…

#

Most of the time fops are much quicker

dark garnet
lyric gyro
#

It depends how you are consuming data

#

As well as adding

#

Not very scalable though

rose oxide
#

idk just use yml if you're not comfortable in java or sql

#

learn java and spigot's api before worrying about data storage imo

leaden sinew
dark garnet
#

whats a good way to store unused code?

#

besides just commenting it out

leaden sinew
#

GitHub

#

You could use Gists

shell moon
dark garnet
#

was gonna make a joke about putin but nevermind rolf
ill just let u imagine what that joke wouldve been

lyric gyro
loud sorrel
#

any1 know what the green light is saying for raspberry pi

#

i got no clue

#

that sound is my fishtank btw

dusky harness
#

then red means its connected to power

#

i think

loud sorrel
#

ive been doing research and diff combos of green flashes mean dif errors

dusky harness
#

O

well for me green always just flashed when it was on, never really googled it before 🤷

#

didn't know it could represent errors o.o

leaden sinew
heavy swan
#

Hello there! im trying to develop a plugin to play with my friends, i called the plugin CommonDamage, it consists in if one player is damaged, all players in the server get damaged too, but i want to implement the DamageCause into it too so if a player falls from a high place, and another one has father falling 4 in his boots, dont get the same damage as the one who fell in the first place. Someone know how can i make this posible?

cerulean birch
#

I need an easy-to-use API for making GUIs in Bukkit for 1.17, well documented etc, anyone have recommendations? everything I've looked at so far is either cringy, confusing, or just not it

neat pierBOT
dense drift
#

@cerulean birch

cerulean birch
#

cheers

median glen
#

Good morning, what does it matter if a commandExecutor's onCommand method returns true or false?
Is the difference only that if I return false, it displays some error message to the sender?

dusty frost
#

Yeah

#

It shows the help message if you return false

median glen
#

Thank you

median glen
#

What is the difference between storing data to PersistentDataContainer and setting metadata? For e.g. a player

sterile hinge
#

one is persistent

median glen
#

When metadata disappears?

sterile hinge
#

I think it's just held by the player object

#

but that's likely documented in javadocs of the related methods

median glen
#

thank you!

median glen
#

Do I have to prefix metadata key? In case of PersistentDataContainer I think it is not necessary, but can't find the code to setmetadata in my IDE so can't check.

#

Also, how can I browse full spigot/paper source code?
(Please use "reply" function to answer to my questions because I have to go afk now)

winged pebble
#

You also don't have to prefix the key

hazy nimbus
dense drift
queen plank
#

How do I create a void world? I found a some information on the wiki but a lot from it is deprecated since MC 1.17 changed so much in the world gen.

terse belfry
#

Use multiverse and void world plugin

#

Then its like /mv create name Normal -g VoidGenerator

#

Or something

queen plank
#

Is there no easy way without dependencies? I want to avoid them as much as possible :>

terse belfry
#

All i know is that way but idk if it works for 1.17

icy shadow
#

you make a ChunkPopulator or something that just returns an empty ChunkData

#

Class names are probably wrong

#

But it's something like that

lyric gyro
#

Change your layers

#

To all air or whatever

hoary scarab
# queen plank How do I create a void world? I found a some information on the wiki but a lot f...
public class VoidChunkGenerator extends ChunkGenerator {
    
    @SuppressWarnings("deprecation")
    public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome) {
        Environment env = world.getEnvironment();
        Biome b = (env == Environment.NORMAL) ? Biome.JUNGLE : (env == Environment.NETHER) ? Biome.NETHER_WASTES : Biome.THE_END;
        for(int c1 = 0; c1 <= 15; c1++)
            for(int c3 = 0; c3 <= 15; c3++)
                biome.setBiome(c1, c3, b);
        return createChunkData(world);
    }
}

// Creation
ConsoleOutput.info(key + " has started generating.");
WorldCreator wc = new WorldCreator(key);
wc.generateStructures(false);
wc.environment(e);
wc.generator(new VoidChunkGenerator());
w = Bukkit.createWorld(wc);

// JavaPlugin class
@Override
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
    String name = ConfiguredSettings.get().worldName;
    if(worldName.equals(name) || worldName.equals(name+"_nether") || worldName.equals(name+"_the_end"))
        return new VoidChunkGenerator();
    else 
        return super.getDefaultWorldGenerator(worldName, id);
}
lyric gyro
#

People don’t know you can just do it in single player I guess lmao?

hoary scarab
lyric gyro
#

Why need code when you can just go make a single player workd

#

But okay

#

It’s already coded

hoary scarab
#

If you used a single player world when new chunks are loaded they will be loaded by the default worldgenerator and not the void generator.

lyric gyro
#

No it’s all void

#

Go try it yourself

hoary scarab
#

I have lol

lyric gyro
#

I’m not arguing with you when you haven’t

#

Or else you wouldn’t be speaking out of your ass

hoary scarab
#

And also this is the development channel. So he asked for code to do it. (With no dependencies.)

lyric gyro
#

Here’s the code for what single player already made

graceful hedge
#

I mean creating a simple void world is sure easier by just doing it in single player, altho there are some benefits in regards to doing it programmatically with a plugin I presume

lyric gyro
#

Like what @graceful hedge ?

hoary scarab
#

Setting biomes for one.

graceful hedge
#

Yeah

#

Altho it’s pretty pointless to set biomes in a void world

hoary scarab
graceful hedge
#

Not really visible all that much, and if you do need it for certain chunks world edit can be used

graceful hedge
#

shrug Idk what the original dude was looking for specifically tbf

lyric gyro
#

You can set biomes still 100%

graceful hedge
#

Yeah

lyric gyro
#

If you make a single player void world

#

Multiverse will make a void then like 1000 blocks away it’s just terrain

hoary scarab
lyric gyro
#

I assumed it wasn’t from multiverse cause there void worlds suck

sterile hinge
#

ah yes, @SuppressWarnings("deprecation")

spiral prairie
#

xD

hoary scarab
sterile hinge
#

it makes me sad

spiral prairie
#

it really does

hoary scarab
#

Well if they didn't deprecate useful methods without adding methods to replace them it wouldn't be necessary. (At least in the plugin that code is from cause thats a latest version plugin.)

sterile hinge
#

so you just will continue using the methods after they were removed?

hoary scarab
spiral prairie
spiral prairie
#

thats what deprecation says afaik

hoary scarab
lyric gyro
#

with the exception that the old worldgen API is confirmed by maintainers to be removed in a near-future update

dense drift
#

Md5 likes the @Deprecated method 🤡

sterile hinge
lyric gyro
#

"deprecate useful methods"
"without adding methods to replace them"
chooses to ignore the completely new and fine-tuned worldgen api

spiral prairie
dense drift
#

Imo, some methods are deprecated to somehow make the people use the other methods more, for example getPlayer(String) and getPlayer(UUID) or getOfflinePlayer

lyric gyro
#

no, that's yapperyaps rolypolyclown

hoary scarab
lyric gyro
#

'?'?

broken elbow
#

but what if owner can be something else than just player?

spiral prairie
#

setOwner takes String and setOwningPlayer takes an offline player

kind granite
#

github is down yet again smiling_face_with_3_tears

broken elbow
#

is it?

graceful hedge
#

works fine for me thonk

spiral prairie
#

isnt for me

broken elbow
#

seems fine for me.

hoary scarab
spiral prairie
#

you just have shitty internet

kind granite
#

oops

lyric gyro
#

skull

kind granite
#

that is not the screenshot

#

that is

graceful hedge
spiral prairie
kind granite
#

i get 500s when i try to log in

lyric gyro
#

then don't

hoary scarab
lyric gyro
# hoary scarab ?

in case you weren't aware, there is a new worldgen api the better reflects how minecraft world gen stages work

#

as very well outlined by the javadoc

hoary scarab
lyric gyro
#

idk 1.17 probably?

#

or late 1.16.5

spiral prairie
#

1.17

#

in preparation for 1.18

#

afaik

sterile hinge
lyric gyro
#

the name tho !!!

spiral prairie
#

!!!!! kekw

pulsar ferry
#

Actually I think it was before that, 1.15 or something

spiral prairie
#

really?

pulsar ferry
#

I think so, I remember using it before 1.17 at least

lyric gyro
#

checked, it's 1.17+

hoary scarab
lyric gyro
#

javadoc?

#

lol

hoary scarab
#

Is it the methods in worldcreator you're talking about?

lyric gyro
#

and the class javadoc mentions them too

pulsar ferry
#

I see, my brain fails me one more time

hoary scarab
lyric gyro
#

yes because

ChunkData are now directly provided
in all the new non-deprecated methods that replaced the old ones you should be using instead

hoary scarab
# lyric gyro yes because >ChunkData are now directly provided in all the new non-deprecated m...
public class VoidChunkGenerator extends ChunkGenerator {
    
    @Override
    public BiomeProvider getDefaultBiomeProvider(WorldInfo worldInfo) { return new VoidBiomeProvider(); }
    @Override
    public boolean shouldGenerateNoise() { return false; }
    @Override
    public boolean shouldGenerateSurface() { return false; }
    @Override
    public boolean shouldGenerateBedrock() { return false; }
    @Override
    public boolean shouldGenerateCaves() { return false; }
    @Override
    public boolean shouldGenerateStructures() { return false; }
    @Override
    public Location getFixedSpawnLocation(World world, Random random) { return new Location(world, 0, 70, 0); }
    
}

public class VoidBiomeProvider extends BiomeProvider {

    @Override
    public Biome getBiome(WorldInfo worldInfo, int x, int y, int z) {
        Environment env = worldInfo.getEnvironment();
        return (env == Environment.NORMAL) ? Biome.JUNGLE : (env == Environment.NETHER) ? Biome.NETHER_WASTES : Biome.THE_END;
    }

    @Override
    public List<Biome> getBiomes(WorldInfo worldInfo) {
        Environment env = worldInfo.getEnvironment();
        return (env == Environment.NORMAL) ? Arrays.asList(Biome.JUNGLE) : 
                    (env == Environment.NETHER) ? Arrays.asList(Biome.NETHER_WASTES) : Arrays.asList(Biome.THE_END);
    }

}
sterile hinge
#

YES

#

and now use switch expressions instead of those ternary expressions please

hoary scarab
#

I gotta switch that plugins workspace to java 17

spiral prairie
#

switches are in java 8

#

duh

sterile hinge
sterile hinge
spiral prairie
#

yes

hoary scarab
spiral prairie
#

?

hoary scarab
#

Thats a switch expression

spiral prairie
#

i know

#

you can still use switches

hoary scarab
#

Its not in java 8

spiral prairie
#

yes?

#

never said that

hoary scarab
dense drift
#

Put the return inside the case

spiral prairie
surreal lynx
#

Is there a simple method you can check if a number is incrementing in order:

Example:

1, 2, 3, 4, 5
(correct)

Using spoilers to demonstrate the numbers that should be there, but aren't:
1, 2, ||3,|| 4, ||5,|| 6, ||7,|| ||8,|| ||9,|| 10
(bad)

icy shadow
#
for each number
  if number != previous + 1
    it's bad
surreal lynx
#

Thank you

hoary scarab
#

The issue is the more numbers you have the more it has to loop through

dense drift
#

the issue?

broken elbow
#

how'd you fix this so called issue?

#

make the list smaller? :))

hoary scarab
dense drift
#

ok aaaand?

#

and no, he won't have that many

icy shadow
#

i dont think it's possible to do in anything better than O(n)

hoary scarab
dense drift
#

I'm saying that because I know what he's doing, cmon yapp, some common sense

#

obv int ids can go higher, the limit is 2.7b xD

broken elbow
#

I mean I want to hear what he'd do instead.

#

I'm intrigued

hoary scarab
queen plank
lyric gyro
#

Do it in single player man

queen plank
#

Well the thing is I need a void world to be made for my plugin. If there isn't one on the server, the plugin should make one. And I can't really jump on every server and make one myself

median glen
# dense drift Nah, it will have your plugins name appended, `plugin:dataKey: value`

I got curious and looked it up, and the answer is not exactly this.
In case of getting metadata, you get back the list of stored values of that given key, and the list contains values for all plugins.
So, in case of common names, when getting stored metadata, you would have to filter for plugins after getting values.
But if you prefix your key with some unique thing (like plugin name), the chance for key coincidence is minimized.
Same thing for hasMetadata too.
So I would recommend everyone to prefix keys with something unique.
If you are curious for the code, here it is:
https://pastes.dev/fBMM97KTEM

lyric gyro
#

the metadata api sucks ass

#

partly because it's never actually used for its intended purpose, which was a horrible idea even

median glen
#

well I have a player action which has two stages: player selects something, then something else.
For this (to store some state between the two parts), metadata api is great I think.

lyric gyro
median glen
lyric gyro
#

Bear in mind that metadata api is leaky as fuck because nothing is removed (unload of chunks/worlds/entities) ever unless you do

median glen
lyric gyro
#

The original idea of it was to provide an easy means for plugins to communicate between each other

#

But like, nobody uses it for that and it was never actually promoted

#

so it was left there to rot lol

median glen
lyric gyro
#

yeah

median glen
#

There are other better ways for that I suppose

lyric gyro
#

but reality is, any self-respectable plugin will provide an API of their own of sorts

#

(because passing shit between a giant ass Map is a horrible idea and constrained to types already provided by the existing libraries only)

queen plank
# hoary scarab What version is your server?

Nvm, I'm to tired for this. I sat here for 2-3 hrs trying to figure out why it did not work. And did not once notice that I exported my plugin to the wrong destination lol. So thank you! The world gen works great!

median glen
#

Oh btw just a random fact that if you want a paste service that is serverless (data is stored inside the URL), check this out. I think it's awesome for smaller pastes.
https://github.com/topaz/paste

hoary scarab
lyric gyro
#

topaz cringe 👎

queen plank
#

Yeah, I just recently changed the output dir. So I thought it exported correctly, but it just went to the old folder lol. Thanks again :))

lyric gyro
median glen
surreal lynx
#

Does anyone know why the second if statement isn't getting called?

        for (String currentEntry : OraxenItems.getItemNames()) {

            Material material = OraxenItems.getItemById(currentEntry).build().getType();
            int currentModelData = OraxenItems.getItemById(currentEntry).getOraxenMeta().getCustomModelData();
            int previousModelData = currentModelData - 1;
            
            if (material == null) {
                Logs.logWarning("Material is null! Cancelling debug system.");
                return;
            }
            if (currentModelData == previousModelData + 1) {
                Logs.logInfo("Model Data Match: " + material.name() + " ModelData: " + currentModelData);
            } else {
                Logs.logInfo("Model Data Mismatch: " + material.name() + " ModelData: " + currentModelData);
            }
        }

(new to java, sorry if it's something very simple)

hoary scarab
#
int previousModelData = 0;
for (String currentEntry : OraxenItems.getItemNames()) {

    Material material = OraxenItems.getItemById(currentEntry).build().getType();
    int currentModelData = OraxenItems.getItemById(currentEntry).getOraxenMeta().getCustomModelData();
            
    if (material == null) {
        Logs.logWarning("Material is null! Cancelling debug system.");
        return;
    }
    if (currentModelData == previousModelData + 1) {
        Logs.logInfo("Model Data Match: " + material.name() + " ModelData: " + currentModelData);
    } else {
        Logs.logInfo("Model Data Mismatch: " + material.name() + " ModelData: " + currentModelData);
    }
    previousModelData = currentModelData;
}
```Should work.
surreal lynx
#

Oh, I see the issue

#

Thank you

hoary scarab
#

👍

sage kettle
#

Hello i would like to display custom text above players names

I tried theses:

  • Scoreboards (Below_Name) (bukkit api and NMS) problem: one '0' is displayed before text

  • AmorStand moving with the player (event handler or scheduler) problem: bugged and expensive for server calculations

  • ArmorStand on passenger on the player (Player#addPassenger(ArmorStand))
    problem: player name will not display anymore + cannot change offset between player and armorstand

  • Other entities for Player#addPassenger
    problem: same of armorstand + customName of riding entity is not displayed if entity is invisible

Does someone know why this doesn't work / other methods ?

lyric gyro
#

IBlockData isn't a mojmapped name, it's a Spigot deobf one

hoary scarab
#

I use both so how can I get them to work like they use too?

#

Would prefer to not have to use reflection for all future minecraft versions lol

lyric gyro
#

For when using mojang mappings just use them normally but also add the.. whatever special-source-plugin md5 provides, it remaps your jar so it works with the reobfed server used at runtime

hoary scarab
lyric gyro
#

"proper classes"?

hoary scarab
#

IBlockData, BlockData, WorldServer etc...

lyric gyro
#

your source code for 1.17/1.18 won't have those names

#

it would have the mojang names

hoary scarab
#

For example with WorldServer it wants me to use ServerWorld and that causes errors

lyric gyro
#

causes errors when or where?

hoary scarab
#

in the code. It won't let CraftWorld be casted

lyric gyro
#

CraftWorld is CraftWorld, not ServerLevel ?

#

can you actually show what you're trying to do? I'm having a hard time understanding the situation

hoary scarab
#

I have code that works with the 1.17 jar. That code no longer works with the 1.18 jar (Any of them) I need it to work.

I have used the maven depends (all of them), used the maven config from the 1.18 release. Nothing will let the code work on a 1.18 server.

#

Its hard to show because I would have to show the whole project and I am not sending that many pictures lol

formal crane
#

How do i open a book for a player (one that is not in the inventory) ?

formal crane
#

alright

wise steeple
#

hoe to open a book fir a player spigot

#

I’m bad at spelling

#

On Mobile

formal crane
wise steeple
#

Well

#

You would have to use packets

#

Nvm lol

#

@formal crane

#

Lemme get the link

#

👍

formal crane
#

i am gonna try that

#

ty

wise steeple
#

No

#

Np

junior shard
#
List<String> payMsg = CityRPPaycheck.plugin.getConfig().getStringList("Message");

                            if (!payMsg.contains("%a%")) {

                                EconomyResponse r = econ.depositPlayer(player, amt);

                                for (int i = 0; i <= payMsg.size(); i++) {
                                    player.sendMessage(ChatColor.translateAlternateColorCodes('&', payMsg.get(i)));
                                }
                                return;

                            } else {

                                List<String> plhPayMsg = new ArrayList<>();

                                EconomyResponse r = econ.depositPlayer(player, amt);

                                for (String s : payMsg) {
                                    if (s.contains("%a%")) {
                                        String newStr = s.replaceAll("%a%", amt.toString());
                                        plhPayMsg.add(newStr);
                                    } else {
                                        plhPayMsg.add(s);
                                    }
                                }

                                for (int i = 0; i <= plhPayMsg.size(); i++) {
                                    player.sendMessage(ChatColor.translateAlternateColorCodes('&', plhPayMsg.get(i)));
                                }
                                return;

                            }
#

Im trying to figure out why it is not replacing the placeholder %a% with the amount

west socket
#

Are you trying to use PAPI?

wise steeple
#

No

junior shard
#

No, its just a local placeholder so that people can place the amount of their paycheck anywhere in the message

west socket
#

Oh I see

#

Have you tested to see if it’s getting past the contains check?

west socket
#

Hmm

junior shard
#
if (!payMsg.contains("%a%")) {
                                player.sendMessage("Debug: Passed contains check");
lyric gyro
#

you are checking if the list contains a string "%a%"
not if a string in the list contains %a%

junior shard
#

but it isn't passing the placeholder replace

junior shard
lyric gyro
#

yeah basically just stick with what's inside the else case

junior shard
#

Just just put what's in my else { into the if player#hasPermission, yeah?

lyric gyro
#

what?

#

there's no hasPermission check in there

junior shard
#

oh

#

I didn't include it in the paste

#

all of that code I pasted is contained within if (player.hasPermission(perm)) {

lyric gyro
#

from what you showed, just use what's in the else block

junior shard
#
if (player.hasPermission(perm)) {

  player.sendMessage("Debug: Passed perm check");

  List<String> payMsg = CityRPPaycheck.plugin.getConfig().getStringList("Message");

  player.sendMessage("Debug: Placeholder replace");

  List<String> plhPayMsg = new ArrayList<>();

  EconomyResponse r = econ.depositPlayer(player, amt);

  for (String s : payMsg) {
    if (s.contains("%a%")) {
    String newStr = s.replaceAll("%a%", amt.toString());
    plhPayMsg.add(newStr);
  } else {
    plhPayMsg.add(s);
    }
  }

  for (int i = 0; i <= plhPayMsg.size(); i++) {
    player.sendMessage(ChatColor.translateAlternateColorCodes('&', plhPayMsg.get(i)));
  }
  return;                        
}
tight junco
#

what is this tabbing

junior shard
#

its just because I didn't copy the spaces before the hasPerm check lol

junior shard
tight junco
#

that emoji has british teeth

#

what is up with that

junior shard
#

lolol

#

@lyric gyro worked, ty

#

Guess I was just over complicating it

queen plank
#

Isn't this how you get potion effects, PotionEffectType.getByKey(new NamespacedKey(plugin, "slowness"))?

lyric gyro
#

yes except the effect isn't "yours" (the key namespace isn't your plugin), you'd use NamespacedKey.minecraft("slowness")

queen plank
#

Ahh, I see. Thank you!

hoary scarab
#

So even after switching all spigots deobf classes to their mojang mapped counter parts I still get the same errors I did with the old code.

#

Caused by: java.lang.ClassNotFoundException: org.bukkit.craftbukkit.v1_18_R1.CraftWorld

dense drift
#

would be possible to create a mariadb table and add default data?

#
CREATE TABLE IF NOT EXISTS `USER_ROLES`
(
    id   INT PRIMARY KEY,
    name VARCHAR(25) NOT NULL
);```

I have this table and id like to add two roles `(1, 'professor')` and `(2, 'student')`
hoary scarab
dense drift
#
INSERT IGNORE INTO `USER_ROLES` (id, name)
VALUES (1, 'professor'),
       (2, 'student');```
I guess this will do it
formal crane
hoary scarab
#

@lyric gyro I got it to work. Thanks for the help.

icy path
#

can anyone help me with an error?
can't really understand on where to look

#

me when can't send messages

#

dm me if you can help ig

shell moon
lyric gyro
#

sends messages
"me when can't send messages"
mfw
bruhrie

icy path
#

lmao

formal crane
#

How would i run code when a player clicks on a textcomponent in a book?

formal crane
#

I know how to like make it do something but its limited to this (see picture below) and i am trying to open a diffrent book instead of one of those actions

proud pebble
#

what event is that?>

formal crane
#

wdym?

queen plank
formal crane
queen plank
#

Not to my knowledge, you will have to sudo the player.

#

But the player won't see that the command is ran, only the console

formal crane
queen plank
#

Probably not

formal crane
#

oh

queen plank
#

They have a heavily modified version of minecraft. It is all custom made

#

So they have access to different tools than us

proud pebble
# formal crane wdym?

exactly what i just asked, what event is that, i cant find an even relating to book gui clicking

queen plank
#

You have to make a text component in a book

#

And add a click event to it

proud pebble
#

ahh ok

queen plank
#

It's not an event

formal crane
#

TextComponent chatAbuseScam = new TextComponent("○ Chat Abuse/Scam");
chatAbuseScam.setClickEvent(new ClickEvent(ClickEvent.Action.idkaeventyouchose));

proud pebble
#

i didnt know that.

formal crane
#

like this

queen plank
#

Yeah, like that

#

Well now you do :))

proud pebble
#

well given the limited options i would suggest creating a command that opens the new book.

queen plank
#

Yeah, that is the only way I think

formal crane
#

yea probably but i don't want te player to be able to execute the command without clicking in the book

proud pebble
#

not much else you could do unless you are able to figure out the packet thats sent when you click the book and use protocol lib or smth

#

if there is a packet thats sent that is

formal crane
#

prob just gonna give the player a perm and remove it after orsm (to execute the cmd from the clicked text)

queen plank
#

I have a similar system in my plugin. I use a clickable chat conversation but it works the same. When a player starts a conversation, they are added to a set. And the command listener returns immediately if the player sending the command is not in said set, and then removed from it once the conversation is over. It prevents what you want

proud pebble
#

yeah that can work

#

actually the second one would probably work best.

#

its what i do for when i want a value input

queen plank
#

The time changes correctly in the world, but the gamerules do not save. Any idea why this is happening?```java
World world = Bukkit.getWorld(worldName);
if (world == null) {
WorldCreator w = new WorldCreator(worldName);
w.generateStructures(false);
w.environment(Environment.NORMAL);
w.generator(new VoidWorld());
w.type(WorldType.NORMAL);
dataWorld = Bukkit.createWorld(w);
} else
dataWorld = world;

dataWorld.setTime(0);
dataWorld.setDifficulty(Difficulty.EASY);
dataWorld.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false);
dataWorld.setGameRule(GameRule.DO_WEATHER_CYCLE, false);
dataWorld.setGameRule(GameRule.DO_MOB_SPAWNING, false);
dataWorld.setGameRule(GameRule.MAX_ENTITY_CRAMMING, Integer.MAX_VALUE);

neon wren
graceful juniper
#

How does one go by setting the player's hp via attributes? (Using setHealth has its limits and for some reason i cant edit it in the spigot.yml).
I've tried this: this.player.getAttribute(Attribute.GENERIC_MAX_HEALTH).addModifier(new AttributeModifier(UUID.randomUUID(), Attribute.GENERIC_MAX_HEALTH.getKey().getKey(), playerHealth, AttributeModifier.Operation.ADD_NUMBER));
but all that does is add the health as you can tell, but i want to set, there isnt an operation to set and I can't seem to find another way of doing so.
I am using Spigot 1.16.5 for this

tight junco
#

d;spigot Damageable#setHealth

uneven lanternBOT
#
void setHealth(double health)
throws IllegalArgumentException```
Description:

Sets the entity's health from 0 to getMaxHealth(), where 0 is dead.

Parameters:

health - New health represented from 0 to max

Throws:

IllegalArgumentException - Thrown if the health is < 0 or > getMaxHealth()

graceful juniper
#

How does one go by setting the player's hp via attributes? (Using setHealth has its limits and for some reason i cant edit it in the spigot.yml).

queen plank
edgy lintel
#

anyone have experience using atomic variables
it just doesnt work for me
when im trying to update it which is static in the main class
in other async threads

#

am using the set get method of the atomic variable
no manual increment or anything like tehat

lyric gyro
#

Show, and what does “it doesent work for me” mean lmao

graceful hedge
#

well

#

usually you want to use updateAndGet or getAndUpdate (if the new value is dependent on the old value)

#

just the mere volatile/wrapping with AtomicReference does not inherently fix all concurrency update problems

#

also btw static state to some extent is terrible for multi threading

sterile hinge
#

also btw static state to some extent is terrible for multi threading
FTFY

lyric gyro
#

static 👎

#

uncool, dude

#

-rep

broken elbow
sterile hinge
#

as a Map itself doesn't even expose any concept of indexes, yes, you need to use a for loop if you need one specific position

broken elbow
#

but to loop, I'd have to use Map#entrySet. Couldn't that mess up the order?

sterile hinge
#

that's not further specified, but I guess order is kept there

sterile hinge
#

and as it is an implementation detail, you should not rely on that :)

solar lake
lyric gyro
#

Sets don't guarantee ordering either, the ordering of the array will depend on the ordering of the map entries

icy shadow
#

"it's an implementation detail"

lyric gyro
#

okay that's actually pretty funny

#

congratulations

icy shadow
#

when am i not funny?

lyric gyro
#

mondays, tuesdays and thursdays

#

and saturdays when it's raining

icy shadow
#

ok apart from those days

lyric gyro
#

:executing 'apply patches to decompiled jar'

solar lake
lyric gyro
#

correct, and the fact they're using a LHM is an implementation detail in and of itself (unless they're returning it as a LHM rather than a Map which.. they aren't (in other words it's not part of the public contract))

dark garnet
#

why does it make me do this:

int random = new Random().nextInt(9);
String code = String.valueOf(random) + random + random + random;```                                                                             **^**
instead of this:```java
int random = new Random().nextInt(9);
String code = String.valueOf(random + random + random + random);```                                                                                                                                       **^**
if i do it the second way, it only returns 2 integers rather than 4
inner jolt
dark garnet
#

oh lmao

#

thats funny

#

idk how i didnt realize that

inner jolt
#

👍

lyric gyro
#

a joke

neat pierBOT
#
Hey son,

What do you call a bee that lives in America? A USB.

lyric gyro
#

(please laugh)

hushed badge
#

haha

lyric gyro
#

Thank you Kaliber

hushed badge
#

anytime Emily

muted trench
#

Hey! Any ideas on how to detect Fire Extinguish Event?

#

I am trying a Player Interact with the Clicked Block being fire but it doesn't work.

#

Please @ me if you have any ideas!

tight junco
#

PlayerInteractEvent should work

dusky harness
warm steppe
#

java.lang.NullPointerException: Cannot invoke "me.clip.placeholderapi.PlaceholderAPIPlugin.getLocalExpansionManager()" because the return value of "me.clip.placeholderapi.expansion.PlaceholderExpansion.getPlaceholderAPI()" is null

if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
    new PlaceholderAPI(tokenManager).register();
}
#

why

#

i have added papi to depend in plugin.yml

lyric gyro
#

can you show the whole stack trace

warm steppe
#

yeah

dense drift
#

You are shading papi

warm steppe
#

no

#

wait what

lyric gyro
#

me.clip.placeholderapi.expansion.PlaceholderExpansion.register(PlaceholderExpansion.java:139) ~[GTokens-1.0-SNAPSHOT-all.jar:?]
yes lol

warm steppe
#

Adding this to gradle shadowJar task fixed it

dependencies {
    exclude(dependency("me.clip:placeholderapi"))
}
grim oasis
#

anybody know how I can get/print the full raw value of a string without colors, but with the color code?

dusty frost
warm steppe
#

no wtf

dusty frost
#

then you shouldn't need to exclude PAPI

#

send your build.gradle rn

warm steppe
dense drift
#

And you still have that issue?

warm steppe
#

i did the invalidate cache and restart thing and it fixed it

night ice
#

If ur plugin is bungee plugin…ig you can get all the player on the server instance…you don’t need a hashmap

graceful hedge
#

I mean make a bungee plugin of it, else you'll have to deal with a lot of awkward problems which you'll have to basically duct tape around.

night ice
#

I agree with the above, but if u really want to do it…the logic would be something like this

When someone /msgs add whom he sent that message to, later if you recieve a message from that user u could process it with the data in the map…

but its absolutely better to make it as a bungee plugin

atomic trail
#

Can I somehow add the resources directory to a git? It's not in gitignore, but it isn't being pushed

sterile hinge
#

You can only add files

junior shard
#

Does the scheduler method delay for extra time then set sometimes? Is this a known bug or is it a result of an error or something?

#

It works 90% of the time but occasionally will skip over for one of the people using my plugin. No errors in console

dusty frost
#

the scheduler schedules whenever it can

#

there's no guarantees when it does anything

junior shard
graceful hedge
#

ScheduledExecutorService

#

altho that might be overkill

night ice
junior shard
#

Hmm alright

twilit delta
#
this.saveConfig();
this.reloadConfig();
ConsoleCommandSender console = getServer().getConsoleSender();
String botToken = getConfig().getString("discord-token");
console.sendMessage(botToken);

Is there anything wrong with the way im getting my config? When I update the value it doesnt change.

west tangle
#

Okay, this may be a noob question, but I'm asking it anyways.
I recently asked on another server how to make an easier ChatColor.translateAlternateColorCodes() methot, and I was sent this, but cant figure out how to use it.
I'm a bit new to development, and doesn't undestand methods that well.
How does this work and how do I use it?

public static String replaceColors(String input) {
    return ChatColor.translateAlternateColorCodes('&', message);
}
lyric gyro
#

You can either add in a reload command to your plugin or just restart the server after making changes

#

Oh wait I see the reload, my bad :P

#

What’s the full context then?

twilit delta
#

19.03 17:54:14 [Server] ERROR Error occurred while enabling SnowyRPGPlugin v2.0 (Is it up to date?)
19.03 17:54:14 [Server] INFO java.lang.IllegalStateException: Could not acquire lock in a reasonable timeframe! (10 seconds)

lyric gyro
west tangle
lyric gyro
#

Yeah your method probably doesn’t work

#

The argument you’re passing is called input

west tangle
#

Yes

#

I undestand, but what does message do

lyric gyro
#

And you’re trying to use a variable called message

west tangle
#

When should i declare that variable?

lyric gyro
#

No no, the variable message is wrong here

#

It’s supposed to be ‘input’, since that’s the argument in the method

west tangle
#

Oh yeah

#

Your right

lyric gyro
#

You either make both of them input or both of them message

west tangle
#

I undestand! Thank you for the help :)

#

I learn when you explain things

lyric gyro
#

Glad I could help!

west tangle
#

We need more people like you, everyone tells me to "Learn Java", but I can't learn when I don't undestand

lyric gyro
#

Well how are you trying to learn?

west tangle
#

I learn Java with CodeCademy, but when I'm doing Spigot Development, I mostly Google/ask other people

lyric gyro
#

Yeah so imo you shouldn’t try to code plugins while learning Java both at the same time. You need to get a good understanding of the basics first before thinking about doing anything with APIs like spigot, paper etc

#

You’re basically learning a language, writing your own software, learning someone else’s software and trying to use it all at the same time. You will most likely end up frustrated

west tangle
#

Yeah, I undestand, but I get bored so fast with just learning and get so exited with Spigot development

west tangle
#

Yeah, it's bad

lyric gyro
west tangle
#

Everythings costs money, you know. I don't want to pay for a course

lyric gyro
#

I’d recommend reading Head First Java, very fun book and should give you a great base to work with!

west tangle
#

CodeCademy has small projects in the course, but you need a pro membership

shell moon
#

and learned to code plugins

#

learn java first

west tangle
#

What did you use to learn?

shell moon
#

no excuses like "i have no money"

#

google + youtube + source codes

west tangle
#

I hate learning programming languages from YouTube

#

Hard to do it in your own pace

lyric gyro
#

That’s fine, a lot of people don’t actually learn much from videos, some do but a majority would grasp stuff better by reading

shell moon
#

which leads to "i have no money"

#

= excuse

#

or you learn in the good way

#

or you pay someone to code it for you

#

otherwise you'll be asking over and over how to fix your issues

lyric gyro
west tangle
#

Does it cost to rent books in US?

lyric gyro
#

I dunno, you can probably find the book on kindle or something tho

#

I’m sure it’s somewhere for free if snoop around long enough

west tangle
#

Found a pdf lol

lyric gyro
#

Have fun reading! 😄

west tangle
#

700 pages

#

dam

#

I should probably buy a book instead

#

Can't read 700 pages on a computer

lyric gyro
lyric gyro
#
if (!(npc.getName().contains(PostBE.instance.getConfig().getString("npc.npcname")))) return;

Any1 knows why that doesn't work?

lyric gyro
#

Package name = utils
class name = Format
class information:

import org.bukkit.ChatColor;

public class Format {
    public static String chat(String s) {
        return ChatColor.translateAlternateColorCodes('&', s);
    }
}

usage:

player.sendMessage(Format.chat("&aHey my friends!"));
lyric gyro
neon wren
warm steppe
neon wren
#

As the NPC’s name may contain color you don’t compare the name to the color version

warm steppe
#

usage:

ChatUtils.sendMessage(player, "u are a &6&lpotato");
lyric gyro
#

Oh i could do this right?

if (!(npc.getName().contains(Format.chat("&5" + PostBE.instance.getConfig().getString("npc.npcname"))))) return;
#

and then in the config:

npc:
  npcname: 'PostBE'
neon wren
#

No strip the npc’s name and compare it to the confit

#

config

#

I’d also suggest using dependency injection over a static variable for your instance

#

And possibly a place that your configuration stores the NPC rather than grabbing from config each time

lyric gyro
#

True

neon wren
#

Also possibly remove npc from npcname as it is already under npc

lyric gyro
#

@spiral prairie is typing a whole book

lyric gyro
neon wren
#

That’s your preference though on the last one

lyric gyro
#

beneath*

spiral prairie
#

hello, sorry to interrupt but im having some issues with packetevents and sadly there isnt much activity in their server. it has worked before so i dont have any point to start. i am initializing it correctly and running that method, idek
https://upload.skyslycer.de/idea64_ThCYnl4vVc.png

lyric gyro
spiral prairie
#

welp

random delta
#

hey

#

how can i execute the command /tp ~ ~0.1 ~ as a armour_stand?

#

Hello.???

winged pebble
#

Just do it in code

random delta
#

i dont know code

warm steppe
#

?learn-java

neat pierBOT
#
FAQ Answer:

Online Courses:
Online courses are also great for learning java. Some websites that offer them are:

  • Coursera - Free unless you want a certificate
  • PluralSight - Great courses from what I've seen. Mostly Paid
  • Udemy - Never used them myself but they seem to all or at least most be paid.
    My first ever course was one from Coursera. - I can say it was pretty good at introducing me to the programming world as a whole not just java.

Oracle Docs:
Oracle docs can help a lot at learning and understanding java:

  • Start with this,
  • Breeze through this (skipping stuff that doesn't seem relevant like bitwise operators),
  • Hit this.
    They're the first three from this larger thing which you should definitely go through overall. But those three should be enough for slightly better understanding of what is happening here without feeling like a huge time sink.
    That one is a small part of this larger site wherein "Essential Java Classes" and "Collections" also have good useful stuff

Other services:
Some other cool services that will help you learn java are:

As you can see there are plenty of good ways to learn as long as you're willing to invest the time. Have fun learning!

random delta
#

i aint gonna go though 3 pages of shit

#

all i need is 1 simple command

#

nvm this discord useless

past ibex
#

execute as @e[type=armor_stand] tp ~ ~0.1 ~

#

something like that

lyric gyro
#

Lol

warm steppe
#

zamn

formal crane
#

I tried to make my own dependency for plugins that i use but the problem is that i don't know how to implement it in to my plugin.
This is the repo: https://github.com/RazerStorm/rsLogger
And this is in my build.gradle: implementation 'com.github.RazerStorm:rsLogger:1.0'
(i can't use the implementation because it can't find the dependency)

pulsar ferry
#

Did you publish it?

formal crane
#

i created a release

dusky harness
formal crane
#

Gonna make a release in a sec

#

tysm its working

dense mist
#

Why does the %supervanish_playercount% placeholder sometimes show vanished players too?

sand ermine
dense mist
#

Is there one?

dark garnet
#

hi, im trying to get the number of keys in a yml file that have a specific value in one of their children, how can i do this?
the yml file looks something like this:

WORLD=Z=Y=Z=BLOCK:
  placer: "uuid"
  locker: "uuid"```i wanna get all `WORLD=X=Y=Z=BLOCK` that have `locker` = `value` (`value` being whatever i want it to be)
#

ping if reply

night ice
#

You need to iterate over each keys and check whether the value is what you want

median glen
#

Hey guys I'd like to ask for help with dynamically registering Listener implementations to guice IoC container.
I want to write reflection code which finds all Listener implementations in my code base and registers it.

wheat carbon
#

There's libraries like org.reflections & classgraph which can scan the classpath, they may be of use to you

#

guava also has a classpath scanning util, if you want to use something already in spigot

median glen
#

thank you I will try to understand these

dense drift
#

pig, dont you use that system to read external jars?

wheat carbon
dense drift
#

ah, nice

wheat carbon
#

although that specific implementation wouldn't work for it

#

the papi 3 zis scanner works for both

#

it's just todo with the class loader, the linked impl has it hardcoded, in papi 3 it's given in an argument

wary dust
#

If you have the same listener being registered in multiple classes, would it be worthwhile making an abstract class with that listener in and then the 2+ classes extending that class?
Therefore the actual listener only gets fired once idk like does that save anything at all

#

like if theres 2 PlayerMoveEvents

#

might be a dumb question but

high edge
#

probably helps with organization

sterile hinge
#

uhm the actual listener would still be called for each instance

wary dust
#

I mean yeah I guess you only have to register it once

sterile hinge
#

not sure how you want to accomplish that

wary dust
#

well I coded it and then realised it might not actually be doing anything except just making stuff more organised and preventing registering of listeners a bunch of times

sterile hinge
#

you still need to register each listener

wary dust
#

nah so

high edge
#

You only need to register the abstract one no?

wary dust
#

^^

sterile hinge
#

how would you do that?

wary dust
#

I did it with two classes, the abstract and then the actual class which fires the listeners and also implements listener

#

so the abstract is the one they extend

#

and the handler is the one that fires them

dense drift
#

if you register the subclasses, you will have n listeners

sterile hinge
#

can you show some code? I probably completely misunderstand what you're doing, but from my current understanding, that wouldn't really work

wary dust
#

I mean it is working I'm just wondering if its helping with anything except organisation

#

but sure

#

and then theres multiple classes extending TwistListener and using spawn event

#

also ignore the constructor its kinda a workaround for another plugin

sterile hinge
#

okay, but every of these listeners needs to be registered?

wary dust
#

not independently

#

only "TwistListenerHandler" class needs to be registered

#

idk its probs really pointless

#

its just cus its a big project using repeated listeners

high edge
#

I mean just use it for organization sake

sterile hinge
wary dust
#

those are both the same class ^

#

they arent registered

dense drift
dense drift
# wary dust

the listener is added to a collection, and then they iterate over that collection calling the specific method for each event

sterile hinge
#

Ah lol I see

#

Totally missed that

median glen
#

When I call set on PersistentDataContainer, does it serialize and stuff? So I shouldn't call it often?

high edge
#

pretty efficient call I believe

kind whale
dense drift
#

?

dark garnet
night ice
#

I am currently on phone….i will get u sample code later…

#

You would need need to use getKeys() and iterate through each

dark garnet
#

like this correct? for (String key : Main.locked.getKeys(false))

night ice
#

Yeah

dark garnet
#

then how would i get locker?

tight junco
#

FileConfiguration#getString(key + ".locker")

dark garnet
#

ohh

median glen
#

Hi, what is the recommended way to send config-based messages? Is there a framework for that?
Basically I want to configure from config file every message I send with my plugin

graceful hedge
#

adventure + resource bundles work quite nicely

#

I believe for instance LuckPerms uses this, so might wanna check that out :3

median glen
#

thank you

spiral prairie
broken wave
dusty frost
#

are you shading PAPI?

broken wave
#

What do you mean by shading ?

dusty frost
#

in your build script, Maven or Gradle

broken wave
#

In maven

dusty frost
#

does it have <scope>provided</scope>?

broken wave
#

Yes it does

dusty frost
#

huh

broken wave
#

This error only happens on this version

dusty frost
#

of Minecraft? or of PlaceholderAPI?

#

and are you depending on PAPI in your plugin.yml?

dense drift
#

Show your build script

broken wave
#

Yes i am depending PAPI, and i mean minecraft version

stuck surge
#

Hello, I have also had an error with the PlaceholderAPI

#

And it doesn't happen to me only with one extension, but with 3

dense drift
#

Server software?

dusty frost
stuck surge
#

We use Magma to have mods and plugins, I don't know if that can bring an incompatibility error

dusty frost
#

ah that would probably be it

stuck surge
#

Can't do anything to make it work anyway?

#

I can not do anything?*

dusty frost
#

Weird server mixes like that usually don't work for most stuff

#

Could ask them I suppose

#

ah, someone already has

pulsar ferry
#

Hybrid servers are a nightmare, stay away if you can

broken wave
#

By the build script you mean the output when building the jar file ?

pulsar ferry
#

Buildscript is either pom.xml with maven or build.gradle with gradle

broken wave
#

So you want the whole pom.xml ?

pulsar ferry
#

Yeah

neat pierBOT
#
FAQ Answer:

Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
HelpChat Paste - How To Use

broken wave
#

Okay, no problem

#

Here it is

plucky delta
#

I get an error

#

Caused by: java.lang.NoClassDefFoundError: org/java_websocket/client/WebSocketClient

#
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>me.jayden</groupId>
    <artifactId>voice</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>Voice</name>

    <description>Cool voice plugin</description>
    <properties>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.2</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <createDependencyReducedPom>false</createDependencyReducedPom>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>```
#
    </build>

    <repositories>
        <repository>
            <id>spigotmc-repo</id>
            <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
        </repository>
        <repository>
            <id>sonatype</id>
            <url>https://oss.sonatype.org/content/groups/public/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.12.2-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.java-websocket</groupId>
            <artifactId>Java-WebSocket</artifactId>
            <version>1.5.2</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
</project>
formal crane
azure tapir
#

When you go to set a value in the config it asks for a path

#

How do I make the path the whole file?