#help-development
1 messages ยท Page 2046 of 1
um
changing the delay of a fixed delay ๐
public void doStuff() {
doSomeThing();
getScheduler().schedule(this, () -> doStuff(); someDelay, TimeUnit.SECONDS);
}
then run doStuff once
hmm
scheduleSyncDelayedTask is a one off as well
sir
btw this is for bungee, I don't know why I thought someone was tlaking about bungee
probably bc someone asked the same bungee question here 3 times in the last hour
well not really
this::doSomething you nub
@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
wdym
hmm, this is for the random thing? might be a case for ExecutorService if operating outside of spigot anyway ?
... - 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.
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
?main
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);
}
}```
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
Nah should be fine
you should have a Set<UUID> with frozen people
like a list of players rather than a map
ah a list
Set is better though
well, Set, since ur never gonna have the same player twice
are you having a Map<UUID, Boolean>?
yeah
It has to be that or it'd throw an error ๐
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
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
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
ChatColor.stripColor(...)
Thanks
i tried using events but i dont think that can accomplish what im trying to do here
Your question is an XY question. Why do you want to do this?
What issue does the primary system have that yours solves?
Yes?
i want easy and clean subcommands with automatically parsed parameter types in the middle of the command, that also has tab completion
you are trying to load your spigot plugin on the bungee server
obviously that won't work lol
lmao
Oh I'm sorry but I don't know how to do this
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
ok 1m
ok now i have a PostLoginEvent class for bungeecord
That's what I needed to do. Add tabcomplete to my auto register 
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
can you execute commands from another plugin in your plugin?
Yes but you usually don't want to
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
Check if said plugin has an API
How do I do forEach on a json object?
Object:
private Map<Object, Object> json = PluginFuncs.returnJsonObject(EmeraldsPlugin.tebex.getListing().getData().toString());
Depends,what library is the json object from
is there a for(Object o : ObjectArray) that skips all entries that are null?
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
for (Object o : ...) {
if (o == null) {
continue;
}
// Object isn't null
}
That's not what I asked. I assume it's jackson due to the objectmapper
Yes
@vocal cloud Would I just use a set?
fancy
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
It's also null, meaning you didn't assign a value to your isFrozen set
do not expose collections please
wut
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
Send full code
?paste
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
Wait it looks like a loading problem
Ah no
Nothing forget
Can i see your json structure please
Hold on, lettme try returning it as an object again.
Cause thats new code.
Also, lettme send in a sec..
alr
Maybe somewhere you are casting an ArrayList to a JsonObject
And also send full errors please
Because if not its imposible to try to understand what happening
alright
@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}]}
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
JsonObject array = new JsonObject(); what is this supposed to contain?
Im attempting to get a list of all the catagories, so I can retrieve the key names.
com.fasterxml.jackson.core:jackson-databind:2.13.0
research on the dependancy
its a helpful thing inside it
for converting json strings
but you just created it and then you are asking for a member you are passing to it
Thats how it works?
Wait also what are u using gson or jackson?
i would think it needs to contain the member first ...
jackson in this case
Alr
thinking you might want to check for null based on this example for jackson : https://gist.github.com/arjunKumbakkara/ff4edad7e50617d8f53f5266dc0a283c
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?
choose a method you want to use? https://programming.guide/java/unsigned-byte.html mostly you have to decide how you want to deal with the unsigned
Apparently packet.getModifier().read(3); works.
that looks like it reads the bottom of the int ?
what isn't working here?
e.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING,600, 2));
๐ค
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
Is posible that maven could be dumb?
?ask
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!
Read that please...
player offline?
nope
it's on a respawn event
just simply wanna give them that effect when they respawn...
Hey people why the fucked maven its looking for evey depedency on remote repo when i already have them on local
respawn or death?
respawn
Its so dumb maven today
I have invalidated cache 20 times
And doesnt work}
Image on map
hmm, you might need to use a delay until the respawn exits if it clears effects
cancel with one tick
hm
so Bukkit#getScheduler#runTask
Bukkit#getScheduler#runTaskLater is for when you want to specify a delay in ticks
sweet
the first one has one tick as delay
nice
Do you know any scoreoard lib simplier?
the only scoreboard lib i know is from jordan osterberg
and its weird
The Spigot Scoreboard API can be incredibly complicated to learn, especially because it isn't designed for how most people use it. I made a new Scoreboard API that you can use that should help you out quite a bit! I hope you enjoy :]
JScoreboards: https://github.com/JordanOsterberg/JScoreboards
Patreon: https://www.patreon.com/jordanosterberg
...
probabliy in mfnalex's - kitchen sink is in there ๐
@sterile token Figoure out the issue btw?
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
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?
ok apparently not lol
No sorry im annoyed with my maven repo since its fucked = i cannot help because i cannot test
roll it back?
Bukkit.getScheduler().runTask(this, () -> e.getPlayer().addPotionEffect(/**/));```
They are 200gb
And right now idk why i have 2mb of download
So im really stressed
Lmao
lovely shit
well you did say you deleted your cache
so it needs to download everything again
manually check it
put it in your browser url bar
God, this API looks like a piece of shit.
Sorry but
JMethodBasedGlobalScoreboard is a terrible name
Don't know how to help, sorry
you might just have a bad DNS server
oh dont worry
https://repo.maven.apache.org/maven2/ is valid for me
maybe, but why saying error still on local repo ? That its literally a system route?
Lol
Which is the correct one?
you will have a local error if it does not have the code or a version from the remote
Literally either local or remote doesnt work
I will prob just restart the machine via docker command
oh your cmd
Because im so clown that im using a vms over a machine
run a traceroute
it will tell you if your reaching the remote or if its stopping somewhere
any failed one
not sure it will run in intellij, if your in windows its tracert
rking>tracert repo.maven.apache.org
Tracing route to maven.map.fastly.net [151.101.52.215]
over a maximum of 30 hops:
1 2 ms 1 ms 2 ms
is it possible to render other parts of player skin to player_head model
Its sending a list that start on 1 and cotninues
cant you render anything you put in the resource pack?
as long as it ends valid then its intellij/maven
So prob intellij problems?
seems that way
I will uninstall it
https://stackoverflow.com/questions/28725195/maven-clean-install-fails-with-connection-timed-outconnect-error curious old solutions for the issue
that might remove the bad server.xml file or settings.xml
then again that was for maven2 maybe that stuff was fixed
plan it is to render player skin
to models
mini-player?
wonders if costume works on armor stands
is that possible?
it is
origin realms does it
they render player parts on models of playerhead
then use multiple armor stand to make player animations
so called gestures
How would I generate a circle, that gets all blocks, set them to air, and drops the item from it?
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);
}
apparently i have to reorganize my main class so i can have a different main class i can pull instances from?
why the hell does this error
why is it not allowed
to pasrse as an arry
*array
Whats the error
No, you can just use DI or Singleton to get your Main class instance.
there can only be one instance of your main class
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)
Hey question, is there a method like bukkit.selectEntities (or just getting entites based on a Target selector) for mc 1.12.2
@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));
}
Is that the full error?
no
?paste the full thing
@hasty prawn https://paste.md-5.net/yumiruyuri.apache
Whats line 387 in EmeraldsPlugin
jsonArray.add(json.get(key));
Its possible to render models into the game?
Okay, and what does the System.out.println(json); print?
Kinda, you can put an item with a model on an ArmorStand's head.
the json string
{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}]}
Yeah send it lol
But you can render a 3d model into the game parsing them as armorstand?
Nono, use CustomModelData to make the item have a specific model and texture and then just put that item onto an armorstand.
thats what it prints
Oh i thought you can load a custom 3d player model into an armostand and then manipulate thhe armorstand as you wish
My only guess is that json.get(key) is somehow an ArrayList?
Yeah what i have said 1h before. Somewhere he is parsing an ArrayList as JsonObject
packets
Another solution its possible? because packets abussing can be a mess
one of the simplest packets tho
setMaxHealth is deprecated, any alternatives?
Use Attributes
does anyone know a good approach ?
What do you mean activates redstone
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
PlayerInteractEvent is really your best option, atleast as far as I know.
alr, thank you
e.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(2);
this fails to work
you sure that is correct? shouldn't it open with a square brace ?
opening with { makes it an object does it not? this bracket stuff about json confuses me
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?
probably changed the players data
is there a particle you can dye?
is that visible with decreased particles?
no idea
uh
how do i initiallize/create such a particle?
create an instance of this https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Particle.DustTransition.html
declaration: package: org.bukkit, enum: Particle, class: DustTransition
and pass it as data to the spawnParticle method
jsonArray.categories.add(json.get(key)) isnt it, otherwise the key would be the object?
e.g. ```java
world.spawnParticle(Particle.DUST_COLOR_TRANSITION, 0,64,0,100, new Particle.DustTransition(color1, color2, size));
how do you explain to a hard coded number again that it's a float?
1f
or (float) 1
Your DMs? Yeah, although it's kinda odd that the egg doesn't act as the middle IMO
Unless you did that on purpose
good start
nevermind i swapped particle and number
in my limited understanding of json it has to do with your brackets
I imagine you're just getting where the eggs land and turning nearby blocks into falling blocks with velocity?
you output looks like you have an array in an obect but try to access it as an array
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
Should just be as simple as adding 0.5 to xyz
I thought we were talking about block coords
getBlockX/Y/Z + 0.5
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?
It's just named badly lol
shrugs seems logical, but goofy
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;
}
Hey, ive tried to make my own customyml file manager however i run into an error when starting my server.
ERROR = https://paste.md-5.net/xogekevixa.md
Manager = https://paste.md-5.net/simojaqina.java
Main = https://paste.md-5.net/paqucavote.java
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.");
}
}
I have a question, restarting a thread over and over after updating an object is bad?
If you feel the urge to restart a thread over and over use a scheduled task
restarting a thread?
Is a async thread separated from the spigot
extends Thread
there are just threads
You could try```java
public class customYml {
private final Plugin plugin;
public customYml (Plugin plugin) {
this.plugin = plugin;
}
public void customYmlInitiate(String name) {
File file = new File(plugin.getDataFolder(), name);
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
where server/main thread being the thread where most bukkit related code execution happens on
I ill kill the thread and start other
private final Plugin plugin;
instead of
private Main main;
oh so you launch a new thread every time?
thats sth else
dont do that
its gonna take unnecessary resources
I dont know but my thread have a problem updating the players stats..
exactly what i have?
private final Plugin plugin;
main is my main class
I know
ok 1 sec
Plugin is something else
though with that being said, testing multithreading and concurrent environments is never easy
JP extends Plugin
yeah
ah
u can use JavaPlugin or Plugin or your main class
Plugin is probably better to depend on if you can
that's what I do and it works
I see people doing that
but I would do JavaPlugin since its the direct parent of ur main class
yeah, for instance mockability and testability as well as decoupling
ive never seen a scenario when you need those in spigot
Just use object
define the requirements for "need"
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
public static Object Instance = new Main();
public CommandListener implements CommandExecutor {
public boolean onCommand(....) {
Main.Instance.map.put(player, 10);
} }```
why no work
you have to make Instance private and access it with reflection
true
if (player.isOnline() == !false)
instead of "true", let's all say "Double.NaN != Double.NaN" from now on
i mean this has somehow cause the file to be created however i still receive the same error and my setData() method will not work
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?
Field fieldInstance
= Main.class.getDeclaredField("Instance");
fieldInstance.setAccessible(true);
Object instance = fieldInstance.get(new Main());
that will not change anything
the variable was renamed to plugin so it will
What are you trying to do
why would it matter how a variable is called? you could also name it "jerry" and it'll behave the same as before
dont mind me its sarcasm
ur fired
if the wrong variable is called, it won't work
anyways gn
obviously lol
ik it can be called whatever
yeah but it's no difference whether you have MyPluginClass myPlugin = ...;
or
Plugin plugin = ...;
plugin is cleaner 
apparently there is
Yea there's a convention for variable names btw
there is not
they doesn't have the error anymore
If you don't have a certain amount of style points the JVM will literally light your house on fire
they have another
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
.
Do you like my variable names 
so file does create
they have changed something else as well then. their error message didn't even match the original code they've sent
idk might be a bit too lengthy
like I cannot see the scope its put in so a bit hard to determine
i can't tell you that
Mmmm you're right needs a set at the end
ยฏ_(ใ)_/ยฏ
the file is now in the data folder but i cannot setData() and i still get the same error i was originally getting idk
?
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
you could try to add prints every lines lol
that's what i do when idk where something fails
yes
It says "CustomYaml line 19" while that line is just the try { part, that can't throw any exception. it makes no sense to send code that's not exactly the same as the one that throw the exception
System.out.println("made it here 1");....
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
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
yeah
I gotchu
so compile your whole stuff again, run it again, then send the new full stacktrace and the exact code that produced it
ok 1 sec
Jokes aside I just really like long variable names
yeah understandable
the convention I just declared isn't faultless
so it can be disregarded given proper reasoning
https://github.com/MikeTheShadow/AutoRegisterHelper/blob/master/src/main/java/com/miketheshadow/autoregister/api/AutoRegister.java#L102 It should be a lot lot shorter but it's already in a whirlpool of gross so 
hello guys someone know how to teleport a player in a world?
looks good altho
what is a "new" world?
use this if possible, in that way it becomes way more clear what variables and methods are bound to instances (the class scope)
player.teleport(...)
but yeah very nice
read docs
?jd
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Entity.html#teleport(org.bukkit.Location)
declaration: package: org.bukkit.entity, interface: Entity
kinda becomes more of a dontreadme whenever I write one lol
now send your customYml and Main class again
and the error did changed
at codes.lewi.customyml.customYml.customYmlInitiate(customYml.java:21)
of course, he added try/catch blocks and is now printing the exception themselves
Main = https://paste.md-5.net/zehaqileyo.java
customYml = https://paste.md-5.net/owunetodod.java
i mean it does
and it creates the file but still gives me the error
just doesnt set the data inside
show your plugin.yml pls
World#spawnParticle
Use it
packets is for people who haven't updated MC in 10 years
as said, people who didn'T update their MC in 10 years
๐
Why use easy when hard do trick
name: CustomYML
version: '${project.version}'
main: codes.lewi.customyml.Main
api-version: 1.16
I forgot we didn't have particle API at one point
๐ฅฒ
print out file.getABsolutePath() before trying to create the file
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?
yea it's all in memory
C:\Users\Lewi2\Desktop\Test Server\plugins\CustomYML\data.yml
tbh your whole CustomYml class is extremyl bad. first of all your method names are weird, you're not using proper OOP and also, worst of all, you load the file from disk every time you want to get data from it? why don't you just store a Map of loaded YamlConfigurations? Why do you need to load them every time again?
but I wonder how long it takes to move data arround
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.
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
Why is it all json in memory
anyway, no idea why windows can't find that path
1h and Intellij still indexing thing
honestly, this was improv from a course i brought about a week ago, im extremely new to all this i just couldnt fix these errors, how would u suggest i redo it?
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
cuz theres a lot of movement and I don't want to go back to storage 500 times a sec
@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
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
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
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?
Powerable.class.equals(material.data) maybe
ayo Gaby ๐
il try that out, thanks
Hey Conclure :D
greetings, I rarely see you here tho ๐ฅฒ
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
Yeah, I dont use it too often ๐ฅฒ
https://paste.md-5.net/lubarunayo.cpp
if this better?

does any1 here know if redis is viable to cache playerdata among like 5 servers?
if you're disciplined and if the redis db is setup properly then yes
i have to be disciplined? is it that much of a pain?
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
hmm
not like its painful
how would i notify said servers tho
but its going to be crucial no matter what when dealing with data over nodes
use redis pub/sub then
๐
redis is ridiculously fast
because the other way would probably be to fetch from sql everytime the player joins, save on leave
I mean you can use redis as an intermediate cache
nope
I think you can configure it to be persistent if you want to ?
i did a little bit of reading. but i could not really find how it saves that data.
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 ^
But by default it's a fancy hashmap with a rest endpoint
^^^
like maybe some time after it does not get accessed?
well lets say you restart redis
then all the values would be gone
but yes expiration is a configuration setting in redis :3
hmm
(if thats what you meant)
yes
similar to sth like gauva Cache would provide
would you go for persistence in redis or just still use a database in the back?
and just use redis for caching
alright. thanks for the info & insight :)
no worries :^)
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)
{"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
I've recently learned that these earth maps don't have structures
And it hurts
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
no, but i figured it out, but i need help again
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?
Like the index?
You can just count manually
oh true
So I THINK its grabbing the array correctly, but its not actually "getting it" per say
If 2 plugins have same command and a player run it, which will run first?
@waxen plinth
hi
how to open a file inside of another jar file
JarFile & JarEntry
noice got it
heh
I was doing json wrong this entire time
and just figured out how that works
lesson today: research
Use structure voids when saving
?paste
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
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>
sqlite driver is already in spigot iirc
Do you know what the package would be in that case? Unless it is also org.xerial?
No idea, I just let hikari handle it
normal package
org.sqlite.JDBC
oh xerial
ignore me
I'm not an expert in SQL. What's the difference?
Hikari can work with SQLite?
sure but pointless
Saves the effort of managing it yourself
there isn't anything to manage really
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?
I don't include the lib since spigot already has it
Which? HikariCP or SQLite? or both?
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
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
to describe what I mean for (1), look at these lines (https://github.com/cervinakuy/KitPvP/blob/ea930bf1b16b7d573543c9d8b1da833971e212ba/src/main/java/com/planetgallium/database/Database.java#L20-L54) from my code and you can probably get a feel for what I mean
the code is supposed to behave like so:
Database db = new Database(host, 3306, "db", "user", etc...); // mysql```
SQLite
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
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
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
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
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
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
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
I mean yeah I do cache stats stuff so it isn't crazy inefficient or anything
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
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
well what spigot provides is the SQLite and MySQL drivers
How do I use the libraries present in spigot vs using the ones I import myself
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
I saw everywhere at least in the spigot space that ppl recommend mariaDB. is that necessary?
you add them to your dependency in maven but don't shade them, when your plugin loads it should find those drivers automatically
You should know how to check/load drivers for DB's
if you don't its really easy to find examples via google ๐
MariaDB is MySQL but better. I don't recommend using MariaDB driver in your plugin without first getting everything working
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
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
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
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 ๐
lol ok fair enough
is bungee
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();
}
}```
No such file or directory
PlayerDates.yml vs PlayersDates.yml
PlayersDates.yml
hmm ๐
.
BLOCK_ENDER_CHEST_OPEN sound added on 1.13?
most likely
but you can always check the spigot 1.12 javadocs?
hm how should I name a listener whose only purpose is to listen to some events to turn them into another event?
my plugin was not working when I add api-version: 1.18 but without that, it work on all version lol
erm well
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
okay
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?
.
show the full error message
thats the full error message
then you catched the exception somehow?
well after that last line it just sent messages about other plugins starting up
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"
so what changes do I have to make to the code
like dis?
the first two lines look good, but the third? it makes absolutely zero sense to save your config directly after reading it
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;
}
}
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
you are still passing "config.yml" as string to the ConfigurationProvider
show the code again pls
try {
File file = new File(getDataFolder(), "config.yml");
Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
}
catch (IOException e) {
e.printStackTrace();
}
show your config.yml
the one in your plugin's data folder, NOT the one in your .jar's resources folder
no, the one that's actually on your server in plugins/YourPlugin/
same file
show VillagerPark line 52
as I said, you might wanna have something like this in your main class, then store your loaded configuration. it's a very bad idea to load your config more than once in different places
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
yeah that's what I figured too from looking at the code
maybe tell us what you're actually trying to do
Blocks don't have any Metadata anyway
ONLY entities do
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
the third line of code is line 73
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
if you need to store information "inside blocks", take a look my lib: https://github.com/JEFF-Media-GbR/CustomBlockData
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
finally the plugin has successfully started up
Does someone know what this error is about? https://paste.md-5.net/difurajugo.php
I'm suspecting this area of code is the cause https://paste.md-5.net/devipurifa.cpp
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
It's a bit confusing since I didn't even know where the error is on the code.
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
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
?jd-bc
I code on 3 different versions, 1.16 - 1.18, and that error only exist in 1.18 even tho the code is similiar.
show your myCOmmand class
yeah protocollib isn'T really useful at all
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?
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
https://paste.md-5.net/cevuvijohu.cpp
It's PacketPlayOutPlayerInfo and PacketPlayOutGameStateChange, and I don't think the packet constructor need any string.
hm I wonder what's the proper mojang name for that lol
It's ClientboundPlayerInfoPacket
that is the code for the command @tender shard
okay, that packet takes a PlayerUpdate object, which in turn needs
- a GameProfile
- the ping
- the gamemode
- the tablist displayname (a string)
well not a string but a component
but it's probably then sent as string
IChatBaseComponent
"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
Well, in the server I don't have skin because I set online-mode to false a while ago.
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
So I need to add a skin to the GameProfile?
I guess that this would fix it, yes
in 1.18.2 there's API to change PLayerProfiles
declaration: package: org.bukkit.profile, interface: PlayerTextures
Alright, imma try that.
lol I guess it's because it supports nullable stuff ๐
I'm just gonna grab random skin from google lmao
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
That only exist in 1.18.2?
Yeah I'm gonna use GameProfile instead.
What's new on 1.18.2 anyway?
For plugin development
dont know if it is documented somewhere; always nice to see what they added here: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/pull-requests
first one is what may come in the future and second link is what they added*
oh my bad, PlayerProfile was added in 1.18.1, not 1.18.2
He wont biye
Bite
UnlimitedLifetime item, interesting...
Still don't know what's the use-case with that
all i want to read is that "Change Enums to classes to easier handle none standart minecraft values" is in /commits
holograms using items
items on ground wont despawn after the specific time
I bet in a few days there'll be a plugin that makes all items unlimited lifetime and it'll crash all servers
Add isJohnny / setJohnny for Vindicator who the hell is Johnny
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());
Man, they should've picked a better method names xd
nah, its fine to have same names like mojang uses ... devs should find the methods easy with that
Light mode is a life savor when the weather is too good
How's minecraft demo screen looks like?
did you try to cover your window instead xD?
I like good weather
also I'm smoking so the door has to be open lol
Ah that's indeed will be useful when combined with resource pack.
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.
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/InventoryClickEvent.html#<init>(org.bukkit.inventory.InventoryView,org.bukkit.event.inventory.InventoryType.SlotType,int,org.bukkit.event.inventory.ClickType,org.bukkit.event.inventory.InventoryAction,int) does anyone know what the "int key" parameter is?
declaration: package: org.bukkit.event.inventory, class: InventoryClickEvent
ah I found out, it's the hotbar slot
It's still giving me errors btw, I'm confused now.
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!
you cannot create another instance of your main class.
Don't initialize the "main" class.
Instead pass it to the other classes.
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
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.
That's called singleton pattern.
Oh yeah, I'm not talking about dependency injection.
Well you can either use dependency injection or singleton pattern, but I highly suggest using dependency injection.
never ever try to instantiate your main class twice
or this.
it makes no sense anyway
He's probably new to java. We all start from somewhere
And cant anyways
nice username @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);
}```
Lol, thanks!
yes, sure
one second
this is something someone from this discord made:
https://github.com/MikeTheShadow/AutoRegisterLib/blob/aba5e0eb7459e65a6291038af198394c53a75cb8/src/main/java/com/miketheshadow/autoregister/util/ReflectionBase.java#L40
This can be used to have a custom command loader, right?
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
you probably want to do exactly the same as this, right? https://github.com/MikeTheShadow/AutoRegisterLib/tree/aba5e0eb7459e65a6291038af198394c53a75cb8
Is your class named transferEco?
yes
you should definitely give your classes proper names
ClassesShouldHaveUpperCamelCaseNames
notLowerCamelCase
OkIWillFixThatButTheOtherIssueNeedsToBeDealtWithRightNow
you can't access "this.plugin" because you don't have any "this" yet
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
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
sometimes too friendly he becomes lovely :)
Set the potion duration overtime perhaps?
it will not run out "eventually" if you use the highest possible value
but friendly again since he got friendzoned
Oh, I thought the highest was 99999 which runs out after 40 minutes or so
the highest value is Integer.MAX_VALUE which is about 2.7 billion
that's more than 4 years
Ok cool thanks
I guess that should be enough in most cases lol
Yeah lol
Correct.
Btw @tender shard after I set the skin property on GameProfile, I still receive the same error.
I don't think it's a good idea though
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
And apparently now I found out that 1.16 and 1.17 has the same error.
have you tried manually sending the packet without ProtocolLib?
I'm not using ProtocolLib.
oh I thught you were
but