#help-development

1 messages ยท Page 2046 of 1

tender shard
#

then schedule a new runnable everytime

grim ice
#

um

viral crag
#

changing the delay of a fixed delay ๐Ÿ˜‚

grim ice
#

do

tender shard
#
public void doStuff() {
  doSomeThing();
  getScheduler().schedule(this, () -> doStuff(); someDelay, TimeUnit.SECONDS);
}

then run doStuff once

grim ice
#

hmm

viral crag
#

scheduleSyncDelayedTask is a one off as well

grim ice
#

sir

tender shard
#

probably bc someone asked the same bungee question here 3 times in the last hour

grim ice
#

well not really

tardy delta
#

this::doSomething you nub

grim ice
#

@tender shard btw

#

public void run() {
runOnce();
service.schedule(this::run, random.nextInt(min, max + 1), TimeUnit.MILLISECONDS);
}

#

this uh

#

the random.nextInt(50, 91)

#

the results are really similar

tender shard
#

wdym

viral crag
#

hmm, this is for the random thing? might be a case for ExecutorService if operating outside of spigot anyway ?

tender shard
#

oh my

#

my goat cheese is almost ready

viral crag
#

... - interesting: According to the scheduleAtFixedRate() and scheduleWithFixedDelay() method contracts, period execution of the task will end at the termination of the ExecutorService or if an exception is thrown during task execution.

keen basin
#

why i get this error
19:50:25 [WARNING] Error loading plugin Main java.lang.ClassNotFoundException: me.ag4.bungee.main.Main at net.md_5.bungee.api.plugin.PluginClassloader.loadClass0(PluginClassloader.java:103) at net.md_5.bungee.api.plugin.PluginClassloader.loadClass(PluginClassloader.java:59) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) at net.md_5.bungee.api.plugin.PluginManager.enablePlugin(PluginManager.java:340) at net.md_5.bungee.api.plugin.PluginManager.loadPlugins(PluginManager.java:250) at net.md_5.bungee.BungeeCord.start(BungeeCord.java:271) at net.md_5.bungee.BungeeCordLauncher.main(BungeeCordLauncher.java:67) at net.md_5.bungee.Bootstrap.main(Bootstrap.java:15) 19:50:25 [INFO] Loaded plugin cmd_list version git:cmd_list:1.18-R0.1-SNAPSHOT:a17d8f8:1634 by SpigotMC 19:50:25 [WARNING] Forced host server pvp is not defined 19:50:25 [INFO] Enabled plugin reconnect_yaml version git:reconnect_yaml:1.18-R0.1-SNAPSHOT:a17d8f8:1634 by SpigotMC 19:50:25 [INFO] Enabled plugin cmd_find version git:cmd_find:1.18-R0.1-SNAPSHOT:a17d8f8:1634 by SpigotMC 19:50:25 [INFO] Enabled plugin cmd_server version git:cmd_server:1.18-R0.1-SNAPSHOT:a17d8f8:1634 by SpigotMC 19:50:25 [INFO] Enabled plugin cmd_alert version git:cmd_alert:1.18-R0.1-SNAPSHOT:a17d8f8:1634 by SpigotMC 19:50:25 [INFO] Enabled plugin cmd_send version git:cmd_send:1.18-R0.1-SNAPSHOT:a17d8f8:1634 by SpigotMC 19:50:25 [INFO] Enabled plugin cmd_list version git:cmd_list:1.18-R0.1-SNAPSHOT:a17d8f8:1634 by SpigotMC 19:50:25 [INFO] Listening on /192.168.178.178:25565

buoyant viper
#

?main

dawn hazel
#

is checking for movement like this going to be bad for preformance?

#
@EventHandler
    public void moveEvent(PlayerMoveEvent e) {
        if (HyperFreeze.isFrozen.get(e.getPlayer().getUniqueId())) {
            e.setCancelled(true);
        }
    }```
keen basin
# buoyant viper ?main

and now
19:56:11 [WARNING] Error loading plugin Manager java.lang.NoClassDefFoundError: org/bukkit/plugin/java/JavaPlugin at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150) at net.md_5.bungee.api.plugin.PluginClassloader.findClass(PluginClassloader.java:152) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587) at net.md_5.bungee.api.plugin.PluginClassloader.loadClass0(PluginClassloader.java:66) at net.md_5.bungee.api.plugin.PluginClassloader.loadClass(PluginClassloader.java:59) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) at net.md_5.bungee.api.plugin.PluginManager.enablePlugin(PluginManager.java:340) at net.md_5.bungee.api.plugin.PluginManager.loadPlugins(PluginManager.java:250) at net.md_5.bungee.BungeeCord.start(BungeeCord.java:271) at net.md_5.bungee.BungeeCordLauncher.main(BungeeCordLauncher.java:67) at net.md_5.bungee.Bootstrap.main(Bootstrap.java:15) Caused by: java.lang.ClassNotFoundException: org.bukkit.plugin.java.JavaPlugin at net.md_5.bungee.api.plugin.PluginClassloader.loadClass0(PluginClassloader.java:103) at net.md_5.bungee.api.plugin.PluginClassloader.loadClass(PluginClassloader.java:59) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ... 13 more

hasty prawn
dawn hazel
#

alr

#

thanks

tardy delta
dawn hazel
#

wdym

#

oh you mean like instead of using a hashmap

buoyant viper
#

like a list of players rather than a map

dawn hazel
#

ah a list

hasty prawn
#

Set is better though

buoyant viper
#

well, Set, since ur never gonna have the same player twice

tardy delta
#

are you having a Map<UUID, Boolean>?

dawn hazel
#

yeah

hasty prawn
#

It has to be that or it'd throw an error ๐Ÿ˜›

tardy delta
#

that makes no sense

#

if an user's uuid is not in the map it will throw a npe

#

just save the ones which are actually frozen

grim ice
#

achieving randomness between 60 and 100 ms

#

is really hard

glossy venture
#

how would i make my own command engine that hooks into bukkit with completions/suggestions and execution

#

i want to take the full string excluding the / at the start in

#

unparsed

elfin atlas
#

Is it possible when I get a name of a Item that I clear to color from then name so I mean not on the item only on the string I'm getting

glossy venture
#

ChatColor.stripColor(...)

elfin atlas
#

Thanks

glossy venture
vocal cloud
#

Your question is an XY question. Why do you want to do this?

glossy venture
#

because i wrote my own command system?

#

and i want to use it

vocal cloud
#

What issue does the primary system have that yours solves?

glossy venture
#

what do you consider the "primary system"

#

the bukkit commands?

vocal cloud
#

Yes?

glossy venture
#

i want easy and clean subcommands with automatically parsed parameter types in the middle of the command, that also has tab completion

tender shard
#

obviously that won't work lol

glossy venture
#

lmao

keen basin
tender shard
#

did you actually write any bungeecord plugin?

#

it seems like all you have is a spigot plugin

#

that can and will never run on bungeecord

#

you need to write a plugin for bungeecord

keen basin
keen basin
vocal cloud
#

That's what I needed to do. Add tabcomplete to my auto register thonk

glossy venture
#

oh wait i sorta know what i can do

#

command map

#

shit

#

bruh im gonna have to stitch together the already parsed arguments to make the string, and then re-parse them

#

but differently

desert musk
#

can you execute commands from another plugin in your plugin?

vocal cloud
#

Yes but you usually don't want to

desert musk
#

right i'd imagine

#

but it's just basically a give command

#

i'm trying to give the player a set of items

#

and i'd rather just use a kit plugin to do that

vocal cloud
#

Check if said plugin has an API

quaint mantle
#

How do I do forEach on a json object?

#

Object:

#
private Map<Object, Object> json = PluginFuncs.returnJsonObject(EmeraldsPlugin.tebex.getListing().getData().toString());
vocal cloud
#

Depends,what library is the json object from

smoky oak
#

is there a for(Object o : ObjectArray) that skips all entries that are null?

quaint mantle
# vocal cloud Depends,what library is the json object from
public static <T> Map<T,T> returnJsonObject(String json){
        ObjectMapper objectMapper = new ObjectMapper();
        Map map = null;
        try {
            map = objectMapper.readValue(json, Map.class);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return map;
    }
#

It converts a JSON string to a JsonObject

worn tundra
vocal cloud
#

That's not what I asked. I assume it's jackson due to the objectmapper

quaint mantle
#

@vocal cloud Would I just use a set?

grizzled pollen
tardy delta
#

fancy

dawn hazel
#

this code is giving me a NPE and i cant figure out why

HyperFreeze.isFrozen.add(p.getUniqueId());
        sender.sendMessage(ChatColor.GREEN + "Player has been frozen!");
        return true;```
```java
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.Set.add(Object)" because "com.woolmc.hyperfreeze.HyperFreeze.isFrozen" is null
        at com.woolmc.hyperfreeze.Commands.FreezeCommand.onCommand(FreezeCommand.java:26) ~[HyperFreeze-1.0.jar:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[purpur-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        ... 21 more```
#

yeah

#

is that bad

#

time to refactor some code

outer pond
#

It's also null, meaning you didn't assign a value to your isFrozen set

tardy delta
dawn hazel
#

wut

tardy delta
#

never make them public

#

and in this case not static

#

wut

quaint mantle
#
INFO java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class com.google.gson.JsonObject (java.util.ArrayList is in module java.base of loader 'bootstrap'; com.google.gson.JsonObject is in unnamed module of loader java.net.URLClassLoader @2e5d6d97)
#

Getting kinda fucking angry

undone axleBOT
quaint mantle
#
public static JsonArray returnJsonList(String json){
        JsonObject array = new JsonObject();
        return array.getAsJsonArray(json);
    }
JsonArray keys = json.get("categories").getAsJsonArray();
        for(JsonElement obj: keys){
            System.out.println(obj);
        }

@sterile token *Im not pasting its small bits of code

#

I dont get WHY my code isnt working however

sterile token
#

Oh allright

#

Wait let see what happening first

quaint mantle
#

The json object just cant parse as an array for some reason

#

for a for loop

sterile token
#

Ah no

#

Nothing forget

#

Can i see your json structure please

quaint mantle
#

Hold on, lettme try returning it as an object again.

#

Cause thats new code.

#

Also, lettme send in a sec..

sterile token
#

Its saying that ArrayList cannot be cast to JsonObject

#

Check that first

quaint mantle
#

alr

sterile token
#

Maybe somewhere you are casting an ArrayList to a JsonObject

sterile token
#

Because if not its imposible to try to understand what happening

quaint mantle
#

@sterile token JSON:

{categories=[{id=2069325, order=1, name=Keys, only_subcategories=false, subcategories=[], packages=[{id=5027337, order=0, name=Common Key x 5, price=1.25, sale={active=false, discount=0}, image=false, gui_item=tripwire_hook}], gui_item=54}]}
sterile token
#

Allright

#

Let me check

quaint mantle
#
Map<JsonObject, JsonObject> json = PluginFuncs.returnJsonObject(EmeraldsPlugin.tebex.getListing().getData().toString());

JsonArray keys = json.get("categories").getAsJsonArray();
for(JsonElement obj: keys){
    System.out.println(obj);
}
``` Updated code 1
#
public static <T> Map<T,T> returnJsonObject(String json){
        ObjectMapper objectMapper = new ObjectMapper();
        Map map = null;
        try {
            map = objectMapper.readValue(json, Map.class);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return map;
    }

Updated code 2

sterile token
#

Wait you are trying to do your own json writer/reader?

#

I have one pretty simply

viral crag
#

JsonObject array = new JsonObject(); what is this supposed to contain?

quaint mantle
quaint mantle
#

its a helpful thing inside it

#

for converting json strings

viral crag
#

but you just created it and then you are asking for a member you are passing to it

sterile token
#

Wait also what are u using gson or jackson?

viral crag
#

i would think it needs to contain the member first ...

quaint mantle
sterile token
#

Alr

viral crag
jovial sparrow
#

I'm trying to parse the Steer Vehicle packet with protocolLib, but I cannot figure out how I am supposed to get the UnsignedByte portion. when using packet.getInt().read(0), and packet.getByte().read(0) I get errors. Anyone know how I can go about this?

tardy delta
#

what errors

#

?paste them

undone axleBOT
viral crag
jovial sparrow
viral crag
#

that looks like it reads the bottom of the int ?

desert musk
#

what isn't working here?
e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING,600, 2));
๐Ÿค”

quaint mantle
#

Hello, could someone help me please? I want to put a map in a itemframe but the image is not placed, I hope you can help me

sterile token
#

Is posible that maven could be dumb?

undone axleBOT
#

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

sterile token
#

Read that please...

desert musk
#

nope

#

it's on a respawn event

#

just simply wanna give them that effect when they respawn...

sterile token
#

Hey people why the fucked maven its looking for evey depedency on remote repo when i already have them on local

viral crag
#

respawn or death?

desert musk
#

respawn

lavish hemlock
#

Maven does shit sometimes

#

That fails to make sense

sterile token
#

And doesnt work}

quaint mantle
#

Image on map

viral crag
tardy delta
#

cancel with one tick

desert musk
#

hm

tardy delta
#

so Bukkit#getScheduler#runTask

desert musk
#

how should i make a delay?

#

oh

tardy delta
#

Bukkit#getScheduler#runTaskLater is for when you want to specify a delay in ticks

desert musk
#

sweet

tardy delta
#

the first one has one tick as delay

desert musk
#

nice

sterile token
tardy delta
#

the only scoreboard lib i know is from jordan osterberg

#

and its weird

viral crag
#

probabliy in mfnalex's - kitchen sink is in there ๐Ÿ˜›

quaint mantle
#

@sterile token Figoure out the issue btw?

desert musk
# tardy delta so ``Bukkit#getScheduler#runTask``

Bukkit.getScheduler().runTask((Plugin) this, new Runnable() { @Override public void run() { e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING,600, 2)); } });

this is how these work right?

#

i'm new to java

forest pagoda
#

Hello, I have a question; Is it possible to use Selectors like @r, @a[r=5] assuming the sender is a CommandBlock or a Player? Is there an API available? If there isn't one is there a library which adds this functionality?

sterile token
tardy delta
#
Bukkit.getScheduler().runTask(this, () -> e.getPlayer().addPotionEffect(/**/));```
sterile token
#

And right now idk why i have 2mb of download

#

So im really stressed

#

lovely shit

viral crag
#

well you did say you deleted your cache

sterile token
#

I invalidated cache more than 20 times

#

I restarted windows, everything

viral crag
#

so it needs to download everything again

sterile token
#

Lol

#

Its saying error

#

On the 2 repos

#

Local and remote :(

viral crag
#

manually check it

sterile token
#

How?

#

I check the errior

viral crag
#

put it in your browser url bar

sterile token
lavish hemlock
#

Sorry but

#

JMethodBasedGlobalScoreboard is a terrible name

sterile token
#

Maow please :>

#

I woudl be really grathefull :D

lavish hemlock
#

Don't know how to help, sorry

viral crag
#

you might just have a bad DNS server

sterile token
#

oh dont worry

viral crag
sterile token
sterile token
#

Which is the correct one?

viral crag
#

you will have a local error if it does not have the code or a version from the remote

sterile token
#

Literally either local or remote doesnt work

#

I will prob just restart the machine via docker command

sterile token
#

Because im so clown that im using a vms over a machine

viral crag
#

run a traceroute

sterile token
#

curl?

#

i will search how to that

viral crag
sterile token
#

And then?

#

which address?

viral crag
#

it will tell you if your reaching the remote or if its stopping somewhere

#

any failed one

sterile token
#

but i run it from intellij?

#

Or other terminal

viral crag
#

not sure it will run in intellij, if your in windows its tracert

sterile token
#

And also hat i have to run im so confuse

#

The link has to much info

viral crag
wary harness
#

is it possible to render other parts of player skin to player_head model

sterile token
viral crag
#

cant you render anything you put in the resource pack?

viral crag
sterile token
viral crag
#

at the ip or with an * ?

#

then its fine - not a route or DNS problem

sterile token
#

So prob intellij problems?

viral crag
#

seems that way

sterile token
#

I will uninstall it

sterile token
#

Oh

#

ihave just clicked on cofirm to uninstall it

#

Hahahha

#

๐Ÿฅบ

viral crag
#

that might remove the bad server.xml file or settings.xml

#

then again that was for maven2 maybe that stuff was fixed

wary harness
#

to models

viral crag
#

mini-player?

wary harness
#

somethig like that

#

this is arm

viral crag
#

wonders if costume works on armor stands

glossy venture
wary harness
#

origin realms does it

#

they render player parts on models of playerhead

#

then use multiple armor stand to make player animations

#

so called gestures

quaint mantle
#

How would I generate a circle, that gets all blocks, set them to air, and drops the item from it?

desert musk
#

i'm bent on bukkit schedulers

#

idfk how this works

quaint mantle
#
Map<JsonObject, JsonObject> json = PluginFuncs.returnJsonObject(EmeraldsPlugin.tebex.getListing().getData().toString());
System.out.println(json);

JsonArray keys = json.get("categories").getAsJsonArray();
for(JsonElement obj: keys){
    System.out.println(obj);
}
desert musk
#

apparently i have to reorganize my main class so i can have a different main class i can pull instances from?

quaint mantle
#

why the hell does this error

#

why is it not allowed

#

to pasrse as an arry

#

*array

hasty prawn
#

Whats the error

hasty prawn
tardy delta
#

there can only be one instance of your main class

north cipher
#

whats the best way to detect when a player activates redstone? BlockRedstoneEvent has way of getting the player that activated it, and PlayerInteractEvent is pretty buggy (constantly callign event when on pressure plate)

forest pagoda
#

Hey question, is there a method like bukkit.selectEntities (or just getting entites based on a Target selector) for mc 1.12.2

quaint mantle
#

@hasty prawn

25.03 20:58:40 [Server] Server thread/ERROR Error occurred while enabling EmeraldsPlugin v1.0.0 (Is it up to date?)
25.03 20:58:40 [Server] INFO java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class com.google.gson.JsonElement (java.util.ArrayList is in module java.base of loader 'bootstrap'; com.google.gson.JsonElement is in unnamed module of loader java.net.URLClassLoader @2e5d6d97)
#

Code:

#
Map<JsonObject, JsonObject> json = PluginFuncs.returnJsonObject(EmeraldsPlugin.tebex.getListing().getData().toString());
        System.out.println(json);

        Iterator x = json.keySet().iterator();
        JsonArray jsonArray = new JsonArray();

        while (x.hasNext()){
            String key = (String) x.next();
            jsonArray.add(json.get(key));
            System.out.println(json.get(key));
        }
quaint mantle
hasty prawn
#

?paste the full thing

undone axleBOT
quaint mantle
hasty prawn
#

Whats line 387 in EmeraldsPlugin

quaint mantle
sterile token
#

Its possible to render models into the game?

hasty prawn
hasty prawn
quaint mantle
#

{categories=[{id=2069325, order=1, name=Keys, only_subcategories=false, subcategories=[], packages=[{id=5027337, order=0, name=Common Key x 5, price=1.25, sale={active=false, discount=0}, image=false, gui_item=tripwire_hook}], gui_item=54}]}

hasty prawn
#

Yeah send it lol

sterile token
hasty prawn
quaint mantle
sterile token
#

Oh i thought you can load a custom 3d player model into an armostand and then manipulate thhe armorstand as you wish

hasty prawn
#

My only guess is that json.get(key) is somehow an ArrayList?

sterile token
grim ice
#

packets

sterile token
grim ice
#

one of the simplest packets tho

desert musk
#

setMaxHealth is deprecated, any alternatives?

hasty prawn
#

Use Attributes

north cipher
hasty prawn
#

What do you mean activates redstone

north cipher
#

for example

#

if a player presses a button or stands on a pressure plate

#

it would elt me know

#

its for a factions plugin, and I need to cancel the event

hasty prawn
#

PlayerInteractEvent is really your best option, atleast as far as I know.

north cipher
#

alr, thank you

desert musk
viral crag
#

opening with { makes it an object does it not? this bracket stuff about json confuses me

desert musk
#

i just installed a plugin that allowed me to change players' max health and i just removed the plugin but its effects still persist how did it achieve that?

viral crag
#

probably changed the players data

smoky oak
#

is there a particle you can dye?

tender shard
#

DustTransition

#

and BLockMarker indirectly by using RED_WOOL etc lol

smoky oak
#

is that visible with decreased particles?

tender shard
smoky oak
#

uh

smoky oak
tender shard
#

and pass it as data to the spawnParticle method

viral crag
#

jsonArray.categories.add(json.get(key)) isnt it, otherwise the key would be the object?

tender shard
#

e.g. ```java
world.spawnParticle(Particle.DUST_COLOR_TRANSITION, 0,64,0,100, new Particle.DustTransition(color1, color2, size));

smoky oak
#

how do you explain to a hard coded number again that it's a float?

smoky oak
#

wait then why is it erroring

#

gime a minute

hasty prawn
#

Your DMs? Yeah, although it's kinda odd that the egg doesn't act as the middle IMO

#

Unless you did that on purpose

#

catyes good start

smoky oak
quaint mantle
#

and if not convert it?

smoky oak
#

actually

#

?

viral crag
hasty prawn
#

I imagine you're just getting where the eggs land and turning nearby blocks into falling blocks with velocity?

viral crag
#

you output looks like you have an array in an obect but try to access it as an array

tender shard
#

yes that's normal

#

I have a method for it so it's not so ugly lol

#

Location getCenter(Block) or sth like that lol

young knoll
#

Should just be as simple as adding 0.5 to xyz

#

I thought we were talking about block coords

#

getBlockX/Y/Z + 0.5

viral crag
#

its not trown unless it lands

#

goofy logic

#

then when you drop it it would be thrown as well

#

its just goofy logic

#

like not being dead in the death event

#

maybe mojang just likes the RPN method?

#

everything happens at the end of an event

#

wouldnt that be at the end?

hasty prawn
#

It's just named badly lol

viral crag
#

shrugs seems logical, but goofy

smoky oak
#

okay I'm gonna need an explanation for this one.
How does this code generate a straight line?

for(int i=0;i<6;i++){
            points[i] = xPos.rotateAroundAxis(new Vector(0,1,0),60*i);}
Particle.DustTransition particle = new Particle.DustTransition(Color.BLUE,Color.AQUA,10.0F);
for(Vector v : points){
  location.getWorld().spawnParticle(Particle.DUST_COLOR_TRANSITION,location.add(v),1000,particle;
}
modest garnet
tender shard
#

yeah it's weird

#

projectilelaunchevent is the one when it's thrown

#

high quality code

    public static class Eggception extends Throwable {

    }

    public static class Egg extends Eggception {

    }

    @EventHandler
    public static void onThrow(PlayerEggThrowEvent event) {
        try {
            throw new Egg();
        } catch (Egg egg) {
            System.out.println("Someone has caught the thrown egg.");
        }
    }
minor garnet
#

I have a question, restarting a thread over and over after updating an object is bad?

vocal cloud
#

If you feel the urge to restart a thread over and over use a scheduled task

ivory sleet
#

restarting a thread?

minor garnet
#

Is a async thread separated from the spigot

ivory sleet
#

calling Thread::start twice yields an exception

#

yes

#

but there's no async thread

minor garnet
#

extends Thread

ivory sleet
#

there are just threads

winged ridge
ivory sleet
#

where server/main thread being the thread where most bukkit related code execution happens on

minor garnet
winged ridge
ivory sleet
#

oh so you launch a new thread every time?

#

thats sth else

#

dont do that

#

its gonna take unnecessary resources

minor garnet
#

I dont know but my thread have a problem updating the players stats..

winged ridge
#

private final Plugin plugin;

ivory sleet
#

vinny7 elaborate a bit

#

perhaps this is solvable in some other way

modest garnet
winged ridge
#

I know

modest garnet
#

ok 1 sec

winged ridge
#

Plugin is something else

ivory sleet
#

though with that being said, testing multithreading and concurrent environments is never easy

grim ice
#

it literally extends JP

young knoll
#

JP extends Plugin

grim ice
#

yeah

winged ridge
#

ah

grim ice
#

u can use JavaPlugin or Plugin or your main class

ivory sleet
#

Plugin is probably better to depend on if you can

winged ridge
#

that's what I do and it works

grim ice
#

but I would do JavaPlugin since its the direct parent of ur main class

ivory sleet
#

yeah, for instance mockability and testability as well as decoupling

grim ice
#

oh ic

#

most people dont do that though lol

ivory sleet
#

well, depends on how far you're willing to go ofc

#

yeah

grim ice
young knoll
#

Just use object

ivory sleet
#

all things considered, there is a lot of things which aren't explicitly needed

#

but the most powerful thing about adopting tests is that you can run those later and still confirm that some class is still behaving correctly even after changing other classes for instance

grim ice
# young knoll Just use object
public static Object Instance = new Main();

public CommandListener implements CommandExecutor {


public boolean onCommand(....) {
Main.Instance.map.put(player, 10);
} }```
why no work
tender shard
grim ice
#

true

tender shard
#

no

#

!false

young knoll
#

if (player.isOnline() == !false)

tender shard
#

instead of "true", let's all say "Double.NaN != Double.NaN" from now on

modest garnet
winged ridge
#

something is fixed at least

#

ima look at your setData()

#

any errors.

#

?

#

did you changed line 28. return YamlConfiguration.loadConfiguration(new File(main.getDataFolder(), filename)); from main to plugin?

grim ice
#
            Field fieldInstance
                = Main.class.getDeclaredField("Instance");
  
            fieldInstance.setAccessible(true);
  
            Object instance = fieldInstance.get(new Main());
tender shard
grim ice
#

why no work

#

:(

#

lier u told it work

winged ridge
vocal cloud
tender shard
grim ice
#

dont mind me its sarcasm

hasty prawn
winged ridge
grim ice
#

anyways gn

tender shard
#

obviously lol

winged ridge
#

ik it can be called whatever

tender shard
#

yeah but it's no difference whether you have MyPluginClass myPlugin = ...;
or
Plugin plugin = ...;

vocal cloud
#

plugin is cleaner uwu

ivory sleet
#

Yea there's a convention for variable names btw

tender shard
winged ridge
#

they doesn't have the error anymore

vocal cloud
#

If you don't have a certain amount of style points the JVM will literally light your house on fire

winged ridge
#

they have another

tender shard
#

if I do Object asd = myPlugin;
or Plugin asd = myPlugin;
and now I call onEnable on that, it'll definitely run the onEnable() from MyPluginClass and not the generic one from JavaPlugin or Plugin

vocal cloud
winged ridge
#

so file does create

tender shard
# winged ridge .

they have changed something else as well then. their error message didn't even match the original code they've sent

ivory sleet
#

like I cannot see the scope its put in so a bit hard to determine

vocal cloud
winged ridge
#

ยฏ_(ใƒ„)_/ยฏ

modest garnet
tender shard
#

in their original code, line 18 (or 28?) was a exception.printStackTrace() statement while their stacktrace showed that they didn't really catch the exception so the whole code they sent never matched the error they've sent

winged ridge
#

you could try to add prints every lines lol

#

that's what i do when idk where something fails

modest garnet
tender shard
winged ridge
#

System.out.println("made it here 1");....

ivory sleet
#

well the convention is, a variables name should be proportionally contextual to the scope its contained within, this means the larger the scope becomes, most likely the longer the name of the variable will be since the context is wider, on the other hand in smaller scopes such as in loops or methods your variable only lives in a small context thus having a long name will just cause illusion.

additionally, methods' names have the polar opposite convention, the larger the scope of the function, the shorter the name will be since it ought to be defined in a higher abstraction. @vocal cloud

tender shard
#

obviously windows simply can't find the specified path but we don't know which one it is since the code doesn't belong to the stacktrace

winged ridge
#

yeah

tender shard
#

so compile your whole stuff again, run it again, then send the new full stacktrace and the exact code that produced it

vocal cloud
#

Jokes aside I just really like long variable names

ivory sleet
#

yeah understandable

#

the convention I just declared isn't faultless

#

so it can be disregarded given proper reasoning

quaint mantle
#

hello guys someone know how to teleport a player in a world?

ivory sleet
#

looks good altho

tender shard
ivory sleet
#

use this if possible, in that way it becomes way more clear what variables and methods are bound to instances (the class scope)

tender shard
#

player.teleport(...)

ivory sleet
#

but yeah very nice

quaint mantle
#

name of the world?

winged ridge
#

read docs

vocal cloud
#

read the docs

#

jinx owe me a coke

tender shard
vocal cloud
#

Ugh now the worst part of writing code is here. Writing the ReadMe.md

ivory sleet
#

kinda becomes more of a dontreadme whenever I write one lol

tender shard
winged ridge
#

and the error did changed

#

at codes.lewi.customyml.customYml.customYmlInitiate(customYml.java:21)

tender shard
tender shard
#

your plugin.getDataFolder(/) does not exist

#

so you can't create a new file inside

modest garnet
#

i mean it does

#

and it creates the file but still gives me the error

#

just doesnt set the data inside

tender shard
#

show your plugin.yml pls

chrome beacon
#

Why are you using packets for particles....

#

Spigot has particle api

tender shard
#

World#spawnParticle

chrome beacon
#

Use it

tender shard
#

packets is for people who haven't updated MC in 10 years

#

as said, people who didn'T update their MC in 10 years

ivory sleet
#

๐Ÿ˜

vocal cloud
#

Why use easy when hard do trick

modest garnet
young knoll
#

I forgot we didn't have particle API at one point

ivory sleet
#

๐Ÿฅฒ

modest garnet
tender shard
sharp bough
#

so I'm working with Jason objects, and I was wondering when is it gonna lag the server when I start adding and moving values, is there a way to check this?

young knoll
#

Do it all in memory

#

And then save async

sharp bough
#

yea it's all in memory

modest garnet
tender shard
sharp bough
#

but I wonder how long it takes to move data arround

vocal cloud
#

Most people here use modern spigot so when you ask for help expect a vast majority of responses to result in up-to-date answers and a lack of knowledge on old outdated methods.

sharp bough
#

it's mostly
json.get value .items
json.remove value .items
json.get otherValue .items add .items from value

#

I hope that's clear enough

young knoll
#

Why is it all json in memory

tender shard
#

anyway, no idea why windows can't find that path

sterile token
#

1h and Intellij still indexing thing

modest garnet
ivory sleet
#

I mean usually when creating the file you wanna do sth like

class CoolYaml {
  Plugin plugin;
  FileConfiguration config;

  CoolYaml(Plugin plugin) {
    this.plugin = plugin;
  }

  void load(String name) {
    var folder = plugin.getDataFolder()
    var file = new File(folder,name+".yml");
    if (!file.exists()) { //check if the file does not exist
      file.getParentFile().mkdirs(); //create the data folder in case it does not exist either
      plugin.saveResource(file.getName(),false); //create the file and load the contents based on the file from your jar
    }
    config = YamlConfiguration.loadConfiguration(file); //load the config from the file and hope the file hasn't been deleted
  }
}```
@modest garnet
sharp bough
#

cuz theres a lot of movement and I don't want to go back to storage 500 times a sec

winged ridge
#

@modest garnet can you try to delete the plugin's folder to see if it actually creates it?

#
if (!file.getParentFile().exists()) {
    file.getParentFile().mkdirs();
}
#

maybe useful

tender shard
# modest garnet honestly, this was improv from a course i brought about a week ago, im extremely...

I don't think you need any wrapper at all. YamlConfiguration.loadCOnfiguration loads an existing Yaml or creates a new config. so just do something like

FileConfiguration dataConfig = YamlConfiguration.loadCOnfiguration(new File(getDataFolder(),"data.yml"));

and that's it. If you have a ton of different configs, just put them into a map, like
"data" -> your "data" config
"somethingElse" -> your "somethingElse" config
etc

winged ridge
#

I'm just comparing your code to mine, and this is missing but idk if it's useful since you don't have child directories inside the plugin's folder

north cipher
#

hey, how could I use Material#data to check if the material type inherits Powerable, since it is only a class I can't use instanceof. any good approach ideas?

desert sedge
#

Powerable.class.equals(material.data) maybe

ivory sleet
#

ayo Gaby ๐Ÿ™Œ

north cipher
#

il try that out, thanks

desert sedge
#

Hey Conclure :D

ivory sleet
#

fingerguns greetings, I rarely see you here tho ๐Ÿฅฒ

north cipher
#

if a player for example shoots a target and gives off a redstone pulse, how could I detect that in a event?

#

I was trying to detect whenever a player activates redstone

#

currently im using PlayerInteractEvent with ```java
private boolean isRedstone(Material type) {
return Powerable.class.equals(type.data) || AnaloguePowerable.class.equals(type.data);
}

#

but it also detects stuf like right clicks which I could probably filter out, but it dosent owrk for redstone pulses, just interactions with fist

desert sedge
quaint mantle
#

any errors?

#

are your particles disabled or something

vocal cloud
tall dragon
#

does any1 here know if redis is viable to cache playerdata among like 5 servers?

ivory sleet
#

if you're disciplined and if the redis db is setup properly then yes

tall dragon
#

i have to be disciplined? is it that much of a pain?

ivory sleet
#

by disciplined I mean, whenever updating a value in the cache, all servers must clear their local cache (such as a Map or sth) and re fetch from the redis cache for instance

tall dragon
#

hmm

ivory sleet
#

not like its painful

tall dragon
#

how would i notify said servers tho

ivory sleet
#

but its going to be crucial no matter what when dealing with data over nodes

#

use redis pub/sub then

eternal night
#

Redis also served-

#

Conclure too fast

ivory sleet
#

๐Ÿ˜…

tall dragon
#

hmm that sounds like a good option indeed

#

but it is viable performance wise?

ivory sleet
#

redis is ridiculously fast

tall dragon
#

because the other way would probably be to fetch from sql everytime the player joins, save on leave

ivory sleet
#

I mean you can use redis as an intermediate cache

tall dragon
#

but redis is not only a cache right?

#

like the data is persistent

ivory sleet
#

nope

eternal night
#

I think you can configure it to be persistent if you want to ?

tall dragon
#

i did a little bit of reading. but i could not really find how it saves that data.

ivory sleet
#

its a in memory db and pub sub among some other stuff mainly, but with the right extensions you can turn it into a persistence database ^

eternal night
#

But by default it's a fancy hashmap with a rest endpoint

ivory sleet
#

^^^

tall dragon
#

like maybe some time after it does not get accessed?

ivory sleet
#

well lets say you restart redis

#

then all the values would be gone

#

but yes expiration is a configuration setting in redis :3

tall dragon
#

hmm

ivory sleet
#

(if thats what you meant)

tall dragon
#

yes

ivory sleet
#

similar to sth like gauva Cache would provide

tall dragon
#

would you go for persistence in redis or just still use a database in the back?

ivory sleet
#

just much more sophisticated Ig

#

I'd use a database

tall dragon
#

and just use redis for caching

ivory sleet
#

or well

#

not redis

#

but sth like postgre or possibly mongo

#

yes

tall dragon
#

alright. thanks for the info & insight :)

ivory sleet
#

no worries :^)

gritty basin
#

Anyone know a way to have structures spawn in a custom map?
we have an earth server and would like there to be villages, ruined portals etc

#

(its being loaded in map tiles)

quaint mantle
#
{"categories":[{"id":2069325,"order":1,"name":"Keys","only_subcategories":false,"subcategories":[],"packages":[{"id":5027337,"order":0,"name":"Common Key x 5","price":"1.25","sale":{"active":false,"discount":0},"image":false,"gui_item":"tripwire_hook"}],"gui_item":"54"}]}

26.03 02:17:05 [Server] INFO Caused by: java.lang.UnsupportedOperationException: JsonObject
26.03 02:17:05 [Server] INFO at com.google.gson.JsonElement.getAsInt(JsonElement.java:231) ~[gson-2.8.8.jar:?]

#

Can anybody explain the issue here?

#

Am I calling this incorrectly? Or

young knoll
#

And it hurts

quaint mantle
#
JsonObject json = EmeraldsPlugin.tebex.getListing().getData();

        assert json != null;
        JsonObject objs = json.getAsJsonObject("categories");
        ArrayList<String> arr = new ArrayList<>();

        System.out.println(json);

        objs.keySet().forEach(keyStr -> {
            Object keyVal = objs.get(keyStr);
            System.out.println("key: " + keyStr + " value: " + keyVal);
            arr.add(objs.get(keyStr + ".name").toString());
        });
#

What the hell am I doing smth wrong or something?

#

any errors

quaint mantle
#
objs.iterator().forEachRemaining((val) -> {
            JsonElement key = objs.iterator().next();
            System.out.println("key: " + key + " value: " + val);
            arr.add(objs.getAsString(key + ".name"));
        });
#

How do I get the key for an itterator?

#

that is an integer?

young knoll
#

Like the index?

quaint mantle
#

im using forEachRemaining for the arrays

young knoll
#

You can just count manually

quaint mantle
#

oh true

quaint mantle
warm light
#

If 2 plugins have same command and a player run it, which will run first?

young knoll
#

Whatever plugin loads last

#

That's why /pluginname:command exists

quaint mantle
#

@waxen plinth

waxen plinth
#

hi

quaint mantle
#

how to open a file inside of another jar file

waxen plinth
#

JarFile & JarEntry

quaint mantle
#

i got the jarentry part down

#

just how to read

quaint mantle
#

noice got it

waxen plinth
#

heh

quaint mantle
#

I was doing json wrong this entire time

#

and just figured out how that works

#

lesson today: research

young knoll
#

Use structure voids when saving

low temple
#

?paste

undone axleBOT
low temple
#

https://paste.md-5.net/codogesupo.java
https://paste.md-5.net/joseqelexe.java
Im having issues with creating a custom item recipe with some custom items. When I try to craft nothing pops up and when I click on the empty space I get kicked with an error in the console saying that the recipe result cannot be of Material type AIR. I checked the recipe result before and after and the material type outputs PAPER as it should. Not sure what im doing wrong here

native siren
#

Hey guys, I'm implementing MySQL into my plugin, but the libraries make my jar go from 350 KB to 10 MB. Is there any way to make the jar smaller?
(pom below)

        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP</artifactId>
            <version>5.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.xerial</groupId>
            <artifactId>sqlite-jdbc</artifactId>
            <version>3.36.0.3</version>
        </dependency>
        <dependency>
            <groupId>org.mariadb.jdbc</groupId>
            <artifactId>mariadb-java-client</artifactId>
            <version>3.0.3</version>
        </dependency>
young knoll
#

sqlite driver is already in spigot iirc

native siren
#

Do you know what the package would be in that case? Unless it is also org.xerial?

young knoll
#

No idea, I just let hikari handle it

hardy swan
#

org.sqlite.JDBC

#

oh xerial

#

ignore me

native siren
native siren
wet breach
#

sure but pointless

young knoll
#

Saves the effort of managing it yourself

wet breach
#

there isn't anything to manage really

native siren
#

Well correct me if I'm wrong but even tho it's overkill bcuz SQLite is a local db, in this specific case wouldn't it eliminate the need for including the SQLite library in maven therefore making the jar smaller?

young knoll
#

I don't include the lib since spigot already has it

native siren
#

Which? HikariCP or SQLite? or both?

wet breach
#

you don't need HikariCP for sqlite

#

you can't have a pool for sqlite

#

it would be no different then you making your own little method to load/access an sqlite db

#

the reason that is true is because SQLite is connectionless, it is a binary db storage

#

you simply write the db file directly, there is no TCP connections just a file handle

#

thus, can't have a pool for a file handle

#

Hikari isn't going to do anything related to queries either as it doesn't touch that stuff

#

so, you make your one method to load the SQLite DB, hold a reference to it in your main class so you can use it everywhere else and then just use sql statements as per usual

#

if all you are going to be using is just SQLite only, then HikariCP isn't needed and can be removed as a dependency

#

as it would serve no purpose

#

or at least you wouldn't be able to use HikariCP for what it was designed for lol

#

as for your question above

#

SQLite is already provided by spigot as its shaded into spigot

#

you can if you want shade your own SQLite if you want to use say a newer version, but then things get a bit tricky since spigot provides it already

#

so not needed to provide it, but you still need to put it in your pom as a dependency though to make the compiler happy ๐Ÿ™‚

#

unless its shaded in the API, don't remember

native siren
#

Well my plugin handles big data so there's 2 options: SQLite or MySQL. I made this SQL library that handles all the statements n stuff, the part I'm having trouble w is 1) sharing the same SQL helper lib but using the appropriate SQL type (SQLite or MySQL) and 2) plugin size bcuz of the aforementioned libraries

#

the code is supposed to behave like so:

Database db = new Database(host, 3306, "db", "user", etc...); // mysql```
young knoll
native siren
#

so that's the further context of my issue. To make the code I'm showing work (which uses DataSource, not DriverManager, which according to my research is outdated and shouldn't be used) I'm trying to see where I can optimize my libraries (some of which are seemingly already included via spigot) but also making it work with the helper sql lib

wet breach
#

thing with SQLite is you won't be able to have multiple things accessing it

#

so if the data being stored needs to be accessible by other servers, then you are going to want to use MySQL

#

MySQL is quite capable of handling large data

#

so much so, you probably are not anywhere close to hitting its limit to warrant any drastic optimizations lol

native siren
#

right. But some ppl that use my plugin want cross server support

#

which means mysql

wet breach
#

what many people fail to do however, is configure their MySQL server appropriately which is the key to handling data you are wanting it to

#

hikariCP will help with MySQL by having connection pools, but even then in most cases you don't even need that either

native siren
#

tbh what it comes down to at least for my plugin is 1) sqlite if you don't want cross server support 2) mysql if you want cross server support
The way I want to make it tho is that the difference between (1) and (2) is like 30 lines of code, where the sql helper lib handles the statements the same regardless of sqlite or mysql

wet breach
#

mysql can handle millions of connections and queries, a connection pool just helps re-use connections so you are not always opening and closing connections which there isn't anything bad in doing that except the overhead in doing so and possibly slowing your querying down which is that is the bad part lol

native siren
#

I'm using player stats which are often updated and being fetched, so hikari would be recommended in that case right?

#

or is hikari overkill and I just do it vanilla?

#

From my research it just seemed easier bcuz I don't have to worry ab managing connections, bcuz hikari handles it, which I like

wet breach
#

connection pools are always recommended regardless. But it all depends how often in your code you are storing and retrieving really. If neither of those are being done constantly, then you could easily get away with not using a connection pool

#

Even more so if you have the ability to cache the data from the DB

native siren
#

I mean yeah I do cache stats stuff so it isn't crazy inefficient or anything

wet breach
#

Anyways, for which should you use, that is up to you. Just use HikariCP if you are using mysql, it isn't overly difficult to use it, and then sqlite you will have to handle yourself again not overly difficult

#

but I think that pretty much answers your questions though in regards to those things lol

native siren
#

Agreed lol. my last issue tho is with packaging ig?
Like if you look at the snippet I sent is there any way I can swap out those classes for others that are already present in spigot? I'm a bit confused on how to do that

#

that probably doesn't make any sense

wet breach
#

well what spigot provides is the SQLite and MySQL drivers

native siren
#

How do I use the libraries present in spigot vs using the ones I import myself

wet breach
#

so that you don't have to put them in your plugin jar

#

as for everything else you will have to include yourself, like HikariCP for example

native siren
#

I saw everywhere at least in the spigot space that ppl recommend mariaDB. is that necessary?

wet breach
#

You should know how to check/load drivers for DB's

#

if you don't its really easy to find examples via google ๐Ÿ˜›

wet breach
#

the reason for this is if you include the MariaDB driver which is one that spigot doesn't provide

#

it will conflict with the one Spigot has

#

and there is some trickery you have to do to get the MariaDB driver to load

#

MariaDB and MySQL drivers conflict with each other, since they are both essentially the same thing. One is just better then the other but still MySQL

dreamy light
#

I'm fairly new to developing with spigot and I can't figure out how to get the remapped-mojang working for nms for 1.16.5

wet breach
#

good news however

#

MySQL driver works for those that use MariaDB

native siren
#

ah bruh
This driver shit sucks lmao.
Is there any easier way of doing this? I'm literally just tryna use MySQL or SQLite based on a boolean value from a config and I've done all the statement code
I don't need any optimizations from what you've told me and my research

wet breach
#

so you don't necessarily need to worry about your code using MySQL driver only

#

MariaDB server is happy to accept connections from MySQL driver ๐Ÿ™‚

#

so don't worry too much on it

#

until later down the road ๐Ÿ˜‰

#

just giving you info before you decide to shade the MariaDB driver and then come back because nothing is working ๐Ÿ˜›

native siren
#

lol ok fair enough

misty ingot
desert tinsel
#

Why i have that error: Failed to load PlayerDates.yml [05:18:56] [Server thread/WARN]: java.io.FileNotFoundException: plugins/VoteTheTime/PlayersDates.yml (No such file or directory)

#

my code for load this file is

public void createPlayers() {
        if (!players.exists()) {
            saveResource("PlayerDates.yml", false);
        }
    }

    public void loadPlayers() {
        try {
            playersC.load(players);
        } catch (IOException | InvalidConfigurationException e) {
            Bukkit.getConsoleSender().sendMessage("Failed to load PlayerDates.yml");
            e.printStackTrace();
        }
    }```
candid galleon
#

No such file or directory

desert tinsel
#

but it is

#

but it doesn't load

candid galleon
#

PlayerDates.yml vs PlayersDates.yml

desert tinsel
candid galleon
#

PlayersDates.yml

desert tinsel
#

hmm ๐Ÿ™‚

misty ingot
warm light
#

BLOCK_ENDER_CHEST_OPEN sound added on 1.13?

abstract sleet
#

but you can always check the spigot 1.12 javadocs?

tender shard
#

hm how should I name a listener whose only purpose is to listen to some events to turn them into another event?

warm light
#

my plugin was not working when I add api-version: 1.18 but without that, it work on all version lol

tender shard
#

that's the idea of "api-version"

#

btw you should set it to at least 1.13

#

otherwise you'll only have legacy material support and other bad stuff

#

if you set it to "1.13" it will still work with all versions

#

that's because 1.12 and below ignore the "api-version" field

warm light
#

okay

tender shard
#

can someone explain the difference between both to me?

#

let's say I have my mouse over slot 2 in the hotbar and press 5, then HOTBAR_SWAP it is, that's obvious.

But if I have my mouse over some slot in my normal inventory, let's say my helmet slot, then I press 5, I guess this now calls the HOTBAR_MOVE_AND_READD thing?

misty ingot
tender shard
#

show the full error message

misty ingot
#

thats the full error message

tender shard
#

then you catched the exception somehow?

misty ingot
#

well after that last line it just sent messages about other plugins starting up

tender shard
#

You are trying to load "config.yml" into a yaml config

#

what you should actually pass though is the content of your actual file

#

you tell bungee
"Yo, pls load the following configuration into a map:
config.yml"

#

What you want to do instead though is to say
"Yo, pls read the following file and load its CONTENTS into a map:
config.yml"

misty ingot
#

so what changes do I have to make to the code

tender shard
#

pass a File object to ConfigurationProvider#load

#

instead of a string

misty ingot
#

like dis?

tender shard
#

the first two lines look good, but the third? it makes absolutely zero sense to save your config directly after reading it

misty ingot
#

ok

#

thanks for the help

tender shard
#

np

#

btw you also have to handle saving the default config yourself

#

you can get your default config as stream, pass that to the ConfigurationProvider too and then let it save it

#

I do it like this in bungee:

    @Getter private static ConfigurationProvider yamlConfigurationProvider = ConfigurationProvider.getProvider(YamlConfiguration.class);
    @Getter private DiscordManager discordManager;

    private Configuration saveDefaultConfig(File file, String fileName) {
        Configuration defaultConfig = yamlConfigurationProvider.load(getResourceAsStream(fileName));
        if(!file.exists()) {
            try {
                file.getParentFile().mkdirs();
                yamlConfigurationProvider.save(defaultConfig, file);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return defaultConfig;
    }

    public Configuration loadConfig(String fileName) {
        File file = new File(getDataFolder(), fileName);
        Configuration defaultConfig = saveDefaultConfig(file, fileName);
        try {
            Configuration config = yamlConfigurationProvider.load(file);
            for(String key : defaultConfig.getKeys()) {
                if(config.contains(key)) {
                    System.out.println("Loaded value: " + fileName + ", " + key + ": " + config.get(key));
                    continue;
                }
                System.out.println(fileName + " doesn't have any value for " + key + ", using default value " + defaultConfig.get(key));
                config.set(key, defaultConfig.get(key));
            }
            return config;
        } catch (IOException e) {
            e.printStackTrace();
            return defaultConfig;
        }
    }
misty ingot
#

hm, same error

#

this time I got more content from console tho

#
26.03 07:40:44 [Server] INFO VillagerParkCore starting up...
26.03 07:40:44 [Server] WARNING Exception encountered when loading plugin: VillagerParkCore
26.03 07:40:44 [Server] INFO Can't construct a java object for tag:yaml.org,2002:java.util.LinkedHashMap; exception=Can't construct a java object for scalar tag:yaml.org,2002:java.util.LinkedHashMap; No String constructor found. Exception=java.util.LinkedHashMap.<init>(java.lang.String)
26.03 07:40:44 [Server] INFO in 'string', line 1, column 1:
26.03 07:40:44 [Server] INFO config.yml
26.03 07:40:44 [Server] INFO ^
26.03 07:40:44 [Server] INFO at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:336)
26.03 07:40:44 [Server] INFO at org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:230)
26.03 07:40:44 [Server] INFO at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:220)
26.03 07:40:44 [Server] INFO at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:174)
26.03 07:40:44 [Server] INFO at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:158)
26.03 07:40:44 [Server] INFO at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:491)
26.03 07:40:44 [Server] INFO at org.yaml.snakeyaml.Yaml.loadAs(Yaml.java:470)
26.03 07:40:44 [Server] INFO at net.md_5.bungee.config.YamlConfiguration.load(YamlConfiguration.java:129)
26.03 07:40:44 [Server] INFO at net.md_5.bungee.config.YamlConfiguration.load(YamlConfiguration.java:122)
26.03 07:40:44 [Server] INFO at com.wonkypigs.villagerpark.VillagerPark.mySqlSetup(VillagerPark.java:52)
26.03 07:40:44 [Server] INFO at com.wonkypigs.villagerpark.VillagerPark.onEnable(VillagerPark.java:31)
26.03 07:40:44 [Server] INFO at net.md_5.bungee.api.plugin.PluginManager.enablePlugins(PluginManager.java:265)
26.03 07:40:44 [Server] INFO at net.md_5.bungee.BungeeCord.start(BungeeCord.java:285)
26.03 07:40:44 [Server] INFO at net.md_5.bungee.BungeeCordLauncher.main(BungeeCordLauncher.java:67)
26.03 07:40:44 [Server] INFO at net.md_5.bungee.Bootstrap.main(Bootstrap.java:15)
26.03 07:40:44 [Server] INFO Caused by: org.yaml.snakeyaml.error.YAMLException: Can't construct a java object for scalar tag:yaml.org,2002:java.util.LinkedHashMap; No String constructor found. Exception=java.util.LinkedHashMap.<init>(java.lang.String)
26.03 07:40:44 [Server] INFO at org.yaml.snakeyaml.constructor.Constructor$ConstructScalar.construct(Constructor.java:410)
26.03 07:40:44 [Server] INFO at org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject.construct(Constructor.java:332)
26.03 07:40:44 [Server] INFO ... 14 more
26.03 07:40:44 [Server] INFO Caused by: java.lang.NoSuchMethodException: java.util.LinkedHashMap.<init>(java.lang.String)
26.03 07:40:44 [Server] INFO at java.base/java.lang.Class.getConstructor0(Class.java:3585)
26.03 07:40:44 [Server] INFO at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2754)
26.03 07:40:44 [Server] INFO at org.yaml.snakeyaml.constructor.Constructor$ConstructScalar.construct(Constructor.java:408)
26.03 07:40:44 [Server] INFO ... 15 more
tender shard
#

you are still passing "config.yml" as string to the ConfigurationProvider

#

show the code again pls

misty ingot
#
        try {
            File file = new File(getDataFolder(), "config.yml");
            Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
        }
        catch (IOException e) {
            e.printStackTrace();
        }
tender shard
#

show your config.yml

#

the one in your plugin's data folder, NOT the one in your .jar's resources folder

misty ingot
#

wait wat

#

not this config.yml?

tender shard
#

no, the one that's actually on your server in plugins/YourPlugin/

misty ingot
#

same file

tender shard
#

show VillagerPark line 52

misty ingot
#

oh I see

#

I didnt change it at a diff place

tender shard
#

PersistentDataCOntainer does NOT store data in blocks

#

Metadatable is only for entities

#

and I think it just uses NBT, just like PDC does too

#

oh wait, it works totally different

#

as far as I can see, Metadata is merely a HashMap and it doesn't even seem to be persistent after a server restart

#

no, it seems to be in memory only

eternal oxide
#

MetaData is not persistent, only PDC is

#

PDC is a wrapper around NBT

tender shard
#

maybe tell us what you're actually trying to do

#

Blocks don't have any Metadata anyway

#

ONLY entities do

misty ingot
#
26.03 08:03:14 [Server] SEVERE java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
26.03 08:03:14 [Server] SEVERE at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
26.03 08:03:14 [Server] SEVERE at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
26.03 08:03:14 [Server] SEVERE at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953)
26.03 08:03:14 [Server] SEVERE at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1098)
26.03 08:03:14 [Server] SEVERE at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1046)
26.03 08:03:14 [Server] SEVERE at com.mysql.cj.jdbc.ClientPreparedStatement.executeLargeUpdate(ClientPreparedStatement.java:1371)
26.03 08:03:14 [Server] SEVERE at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdate(ClientPreparedStatement.java:1031)
26.03 08:03:14 [Server] SEVERE at com.wonkypigs.villagerpark.VillagerPark.mySqlSetup(VillagerPark.java:73)
                Class.forName("com.mysql.cj.jdbc.Driver");
                setConnection(DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password));

                getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS players (UUID varchar(200), NAME varchar(200), ECO int, STREAK int").executeUpdate();
#

whats wrong

#

I dont get it

tender shard
#

oh I see, didn't know that

#

anyway, it's definitely lost on server restart

misty ingot
tender shard
#

you're never closing the bracket

#

@misty ingot

#
(UUID varchar(200), NAME varchar(200), ECO int, STREAK int <-- missing ) bracket
#

also normally you don't use UPPERCASE names for columns, normally in sql you should use lower_case_snake

#

and another thing, you never need 200 chars for a UUID, you need at most 36 characters

#

32 if you get rid of the dashes

#

normal blockstates can only store the data they store anyway in vanilla

#

that's true but as said, blocks can't store arbitrary NBT data

#

sure

#

well structure also has setMetadata and I guess those actually get saved

#

oh lmao

#

didn't know that

#

that must have been added recently

#

in 1.16.5, structure didn't have PDC iirc

misty ingot
#

finally the plugin has successfully started up

summer scroll
eternal oxide
#

NullPointerException: Cannot invoke "String.getBytes(java.nio.charset.Charset)" because "string" is null

#

I've not used PL, but that error is indicating a String in the packet was not set when it should have been

summer scroll
#

It's a bit confusing since I didn't even know where the error is on the code.

eternal oxide
#

I'd guess that you didn't add all the required data. It reached the end of the packet when it expected more data.

#

as such, it returned a null String

misty ingot
#

getProxy().getPluginManager().registerCommand(this, new myCommand());
when I try to use the command in-game in one of the servers connected to the proxy, it says "Unknown command"

#

even when I use it on the bungee proxy itself, it does not work

#

it IS defined in bungee.yml

tender shard
#

?jd-bc

summer scroll
tender shard
#

it's much easier to simply use the actual packet's contstructor

#

you can there easily see what fields are required

#

what's the name of th epacket you want to send?

misty ingot
#

    VillagerPark plugin = new VillagerPark();
    mysqlSetterGetter mysql = new mysqlSetterGetter();

    public giveEco() {
        super("giveeco");
    }

    public String getConfig(String key) {
        String ans = plugin.configuration.getString(key);
        return ChatColor.translateAlternateColorCodes('&', ans);
    }

    @Override
    public void execute(CommandSender sender, String[] args) {
        if (sender.hasPermission("villagerpark.eco.give")) {
            if (args.length == 2) {
                if (ProxyServer.getInstance().getPlayer(args[0]) != null) {
                    ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]);
                    mysql.givePlayerEco(target.getUniqueId(), Integer.parseInt(args[1]));
                    sender.sendMessage(new ComponentBuilder(getConfig("prefix") + "You have given " + target.getName() + " " + args[1] + " emeralds successfully.").create());
                }
                else {
                    sender.sendMessage(new ComponentBuilder(getConfig("prefix") + getConfig("player-not-found")).create());
                }
            }
            else {
                sender.sendMessage(new ComponentBuilder(getConfig("prefix") + "Usage: /giveeco <player> <amount>").create());
            }
        }
        else {
            sender.sendMessage(new ComponentBuilder(getConfig("prefix") + getConfig("no-permission")).create());
        }
    }
#

the code for the command

summer scroll
tender shard
summer scroll
#

It's ClientboundPlayerInfoPacket

misty ingot
tender shard
#

well not a string but a component

#

but it's probably then sent as string

summer scroll
#

IChatBaseComponent

tender shard
#

"Component"

#

this is your problem

#

the gameprofile doesn't have a name

#

or, a bit below, the player doesn't have a skin

#

that's the only things that get written in the write method (which is in your stacktrace) using writeUtf

summer scroll
#

Well, in the server I don't have skin because I set online-mode to false a while ago.

tender shard
#

you probably need to add at least SOME skin to the gameprofile

#

the signature may be missing, the skin must not be missing

#

and it appears as lambda because ADD_PLAYER enum consists of a weird anonymous construct thingy

summer scroll
#

So I need to add a skin to the GameProfile?

tender shard
#

I guess that this would fix it, yes

#

in 1.18.2 there's API to change PLayerProfiles

tardy delta
#

FriendlyByteBuf lol

#

He's friendly

summer scroll
tender shard
summer scroll
#

I'm just gonna grab random skin from google lmao

tender shard
#

you can just pass any URL to PlayerProfile#setSkin

#

well, an URL leading to mojang's textures ofc

#

use this

#

http://textures.minecraft.net/texture/b3fbd454b599df593f57101bfca34e67d292a8861213d2202bb575da7fd091ac

#

that's an example mentioned in the javadocs so if that doesn't work, something is broken lol

summer scroll
#

That only exist in 1.18.2?

tender shard
#

yes

#

in 1.18.1 and below, you have to use GameProfile from com.mojang.authlib

summer scroll
#

Yeah I'm gonna use GameProfile instead.

#

What's new on 1.18.2 anyway?

#

For plugin development

spiral light
#

first one is what may come in the future and second link is what they added*

tender shard
#

oh my bad, PlayerProfile was added in 1.18.1, not 1.18.2

tardy delta
#

Bite

summer scroll
#

UnlimitedLifetime item, interesting...

#

Still don't know what's the use-case with that

spiral light
#

all i want to read is that "Change Enums to classes to easier handle none standart minecraft values" is in /commits

tender shard
spiral light
tender shard
#

I bet in a few days there'll be a plugin that makes all items unlimited lifetime and it'll crash all servers

summer scroll
#

Add isJohnny / setJohnny for Vindicator who the hell is Johnny

tender shard
#

haha wtf

#

A vindicator named Johnny (using a name tag, named spawn egg, etc., or has its Johnny tag set to 1b) is hostile to every mob except baby villagersโ€Œ[Java Edition only], evokers, illusionersโ€Œ[Java Edition only], pillagers, ravagersโ€Œ[Bedrock Edition only], other vindicators, ghasts,[3], and players in Creative or Spectatorโ€Œ[Java Edition only] mode

#
// Toggle Johnny
johnny.setJohnny(!johnny.isJohnny());
summer scroll
#

Man, they should've picked a better method names xd

spiral light
#

nah, its fine to have same names like mojang uses ... devs should find the methods easy with that

tender shard
#

Light mode is a life savor when the weather is too good

summer scroll
#

How's minecraft demo screen looks like?

spiral light
#

did you try to cover your window instead xD?

tender shard
#

also I'm smoking so the door has to be open lol

summer scroll
#

Ah that's indeed will be useful when combined with resource pack.

tender shard
#

or to mess with players

#

every troll plugin has this "feature" lol

summer scroll
#

smh

#

Oh by the way @tender shard, adding skins doesn't solve the issue I still receive the error.

#

Oh I'm dumb, never mind.

summer scroll
#

Probably hotbar?

#

Yeah

tender shard
#

yep

#

@NonNull > @NotNull

#

brb making 3 liters of way too strong coffee

summer scroll
misty ingot
#

how do I use a method from my main class in a different class? When I do the
PluginName plugin = new PluginName(); thing it says in console java.lang.IllegalArgumentException: Plugin already initialized!

quaint mantle
summer scroll
#

Instead pass it to the other classes.

#

?di

undone axleBOT
quaint mantle
#

What I'd do is

ClassName instance;
public void onEnable(){
  instance = this;
}

// In the main class
public static ClassName getInstance(){
  return instance;
}

There are many other ways, this one is one of them, I hope you can understand it.

summer scroll
#

That's called singleton pattern.

quaint mantle
#

Oh yeah, I'm not talking about dependency injection.

summer scroll
#

Well you can either use dependency injection or singleton pattern, but I highly suggest using dependency injection.

tender shard
#

it makes no sense anyway

quaint mantle
desert sedge
#

And cant anyways

tender shard
#

nice username @quaint mantle

quaint mantle
#

I know this is a dumb question, but is there a way to like loop thru all the classes in a package ?
For example:

for(Class class : Package package){
  getCommand(class).setExecutor(new Package);
}```
quaint mantle
quaint mantle
misty ingot
#

It works in the mysqlsettergetter file, but not in the command file

#

I have to have it in the command file to pass it to the settergetter
or else it shows even more errors

desert sedge
#

Is your class named transferEco?

misty ingot
#

yes

tender shard
#

ClassesShouldHaveUpperCamelCaseNames

#

notLowerCamelCase

misty ingot
#

OkIWillFixThatButTheOtherIssueNeedsToBeDealtWithRightNow

tender shard
#

simply use plugin instead of this.plugin in your new mysqlSetterGetter

#

oh wait no

#

that also won't work

#

create your mysqlSetterGetter inside the constructor

#

that'll do

#

but if you're doing it like that you might as well directly go for static getInstance method to avoid making it so messy

short raptor
#

What's the most efficient way to give a player a potion effect permanently? Not like where it says **.** and runs out eventually but more similar to a beacon where as long as you're in range, you have the effect forever

grim ice
summer scroll
#

Set the potion duration overtime perhaps?

tender shard
grim ice
#

but friendly again since he got friendzoned

short raptor
tender shard
#

that's more than 4 years

short raptor
#

Ok cool thanks

tender shard
#

I guess that should be enough in most cases lol

short raptor
#

Yeah lol

summer scroll
#

Btw @tender shard after I set the skin property on GameProfile, I still receive the same error.

tender shard
#

for example if you have a WorldGuard listener, you don't wanna register it without having WorldGuard installed. or if you have a command that uses WorldGuard, the same thing applies

summer scroll
tender shard
summer scroll
#

I'm not using ProtocolLib.

tender shard
#

oh I thught you were

summer scroll
tender shard
#

but