#help-development
1 messages Β· Page 1709 of 1
No need to have that container thing?
would be a bit faster, but you are saving so much space not attributing all the variables just for one field
anyways avoid reflection if you can, it can complexify your code very easily
I'm basically doing that, just.. with a bit extra OOP.
I could ditch the field wrappers
key, value, defaultVal, timeToLive,loaded, loader, client, connection
all just for one variable
yup
you're saving time but imagine that with like 10k fields
hm.
Thing is wertik right now your entire memory model is tightly coupled to redis
sacrificing memory
Maybe you want that but it looks a bit fragile from my pov
also is the AdderTaker field just a incrementation interface?
Fair Wertik I guess in that case
it is, but it's there for more complex fields that require more (de)serialization
gotcha
it's true that I could use a setter
but that would make the "driver" less general
I planned on removing the User class from it and using it as a library for more model structures
depending on a setter would remove that possibility wouldn't it
Wertik Iβd recommend handling the invalidatation of fields of the user externally rather than as an implementation detail of the user
So maybe some sort of UserHousekeeper
Then just have pure fields
No generic containers or that
Yeah but I havenβt read your code thoroughly so only you can determine whatβs best π
@idle grotto are you meaning something like this? tbh im completely lost and this also breaks my Main class LOL ```package com.n0grief.WatchBlock.EventHandler;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import com.n0grief.WatchBlock.SQL.FriendsHandler;
public class Join implements Listener {
private final FriendsHandler friendshandler;
public Join(FriendsHandler friendshandler) {
this.friendshandler = friendshandler;
}
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
friendshandler.createPlayer(player);
}
}
it definitely made my think about my approach
I knew the OOP was memory inneficient and overkill
also definitely make an interface for your objects you want to be serialized
yeah you're sorta just relying on the person to implement what is needed
But back to your original question, if you have enough ram, definitely directly cache in the jvm short term at least (:
looks good otherwise though
Exactly. Now in the main class pass the friendshandler in the constructor call
all good lol
try using a different class name like "JoinEventListener" or "JoinListener" etc
so this is the line that is broken in the main class getServer().getPluginManager().registerEvents(new Join(), this);
new Join(this)
you need to pass a FriendsHandler instance into the constructor
ah yeah
soooo if im not a complete idiot then in Main im adding public FriendsHandler friendshandler; and changing the above line to getServer().getPluginManager().registerEvents(new Join(friendshandler), this); ?
should i save locations into Json?
then the ide just tells me that constructor Join() is undefined
locations are serializable by default
no need
so also add public Join join; ?
or you can just make your own serializer into a single string
Just invoke serialize() and then Gson most likely will know how to handle it
in most cases you don't need to declare the listener itself
unless you plan on acessing it later
well with doing all the above changes ive still got the same error "this.friendshandler" is null in EventHandler.Join.onJoin(Join.java:17) which is this line friendshandler.createPlayer(player); in join.java
can i see all your code in Join
ive been stumped for like 3 days on this tbh even tho its probably dumbass simple to solve lol
yeah
this is what it was originally b4 i asked for help ```package com.n0grief.WatchBlock.EventHandler;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import com.n0grief.WatchBlock.SQL.FriendsHandler;
public class Join implements Listener {
public FriendsHandler friendshandler;
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
friendshandler.createPlayer(player);
}
}
there's an issue with the world reference, will prob have to do a (de)serializer
yep
this is what it is now ```package com.n0grief.WatchBlock.EventHandler;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import com.n0grief.WatchBlock.SQL.FriendsHandler;
public class Join implements Listener {
private final FriendsHandler friendshandler;
public Join(FriendsHandler friendshandler) {
this.friendshandler = friendshandler;
}
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
friendshandler.createPlayer(player);
}
}
looks fine to me
also lower camel case
so "friendsHandler"
oh i see
you aren't declaring a new friendHandler in your main
Oh yeah
Will probably have to create a delegating World -> CraftWorld serializer
yep
ok. that works
I always did World <-> name
Try and structure your main like this
public class MyPlugin extends JavaPlugin{
public void onEnable(){
initializeManagers();
initalizeListeners();
}
private void initializeManagers(){
//create managers and handlers
}
private void initializeListeners(){
//create listeners
}
}
okay what bit don't you get?
so like the main thing i don't understand is, i have other methods in another class right, and i can call on those methods in that original Join.java onJoin event that i had without any issues
right
but pulling my createPlayer method from friendshandler didnt work in the same way
aaaand i dont understand why even tho its fixed now, and id like to understand it so next time it happens i can fix it myself lol
yeah like the method is there and its accessible so i totally dont get why it didnt work when, with no other changes i could just change friendshandler.createPlayer(player); to call let's say flatlogcreator.createLog(); and it would work fine
so say I had a two classes:
public class MyClass1{
public void myFunction(){
}
}
public class MyClass2{
private MyClass1 myClass1;
public void onEnable(){
myClass1.myFunction();
}
}```
your problem is similar to this: say friendsHandler was myClass1
you were declaring the variable in the
private MyClass1 myClass1
but not assigning an instance of the class to it
if you think of it as a physical object, you were saying "Here is my machine" but not actually giving a machine to work on
Java is an Object Oriented PRogramming language
so every class/object needs to actually have an instance
class is basically a blueprint on how the object/instance should look like and what properties it should hold
then you construct the object from the class using a constructor
^ thus it allows you to have multiple classes of the same type, with different values
i could have a human class, and 10 different instances of it with different name etc
so in Join.java in my case the this.friendshandler = friendshandler; creates an 'instance' of the FriendsHandler class?
well the new FriendsHandler(this); creates the instance
you are just passing that instance through the constructor
if i say something really dumb it's cause in all honesty my knowledge of java in general is limited to like the last 2 weeks of youtube videos and wiki docs ive been able to look at lol
we all start somewhere man
we've all been there, it's alright
this.friendsHandler = new FriendsHandler(this); // <-- creates an instance from the class and assigns it to the friendsHandler variable
yes exactly
public class Dog{
private String name;
private int age;
public Dog(String name, int age){
this.name = name;
this.age = age;
}
}
Dog dog1 = new Dog("Fido", 10);
Dog dog2 = new Dog("Bob", 2);
so thats an example of how i can use a class multiple times with different values
if i just do
Dog dog;
``` how is my computer supposed to know which dog im referencing
you have to tell it which dog you are referring to
So do the instances of classes always need to be created in the Main class as well?
it doesn't have to be in the main, but for listeners and manager classes yes
Once you learn that Object Oriented Programming is LITERALLY objects, it becomes a whole lot easier lol
ok the listener thing is part of the reason i think why i wasn't able to troubleshoot this issue myself, this is the first time i've used a listener to do anything like this in the plugin
yeah it can be confusing lol
but you only really ever want one instance of a single listener class
like if you have 10 instances of Join classes, it will repeat the code 10 times
Yeah so i mean how i'm structuring the plugin is that everything that is done on join will be in Join.java, probably all inside of that same constructor unless i see there's a reason to split stuff up, although not much is going to be done on join, just a few checks more or less
you can always have multiple listeners of the same type
say i want something to broadcast a message on join, then say spawn a sheep on join
i would usually split that up into separate listeners
Idk if anyone is familiar with this plugin: https://dev.bukkit.org/projects/watchblock-refired - but i am basically attempting to code a plugin from scratch that does the same thing, but in a clean way, and without any prior coding knowledge lol
never seen it but its a good project
i've learned a lot but it feels like a bottomless pit of knowledge sometimes lol, i've managed to get my plugin to create some flatlog files, utilize a config for mysql details, create a method for connecting to and checking connection status of a mysql server, and also creating 2 separate tables w/ formatting in that sql database when it first connects, other than that that's about it though
oh and i've set up a listener for block events like place and remove events that right now just sends a message to the player that did the thing w/ the coords and blocktype, which i plan to later tweak to send it to the mysql server 'blocks' table instead
and yeah programming is just something that you can never know everything about
theres always something to learn
yeah i had a week of vacation off from work and i've found this project kinda fun, was going great, good progress every night till i hit that nullpointerexception problem lmao
is there anyone who used serialization that can help me for about 10 mins?
yeah you start to learn how to read error codes with time, null pointer just means a value is empty
ask away
@drowsy helm well homie thanks so much for the help w/ my side-project homie i really do appreciate it, i'm going to fix a formatting problem w/ that createPlayer() method and then i'm gunna go to bed hope you have a good night
all good dude, gn
how do i make a class serializable? I mean, I know I have to implement ConfigurationSerializable, this makes me add a new method: public Map<String, Object> serialize(){return null} and I should be replacing this return null with a populated map of my serialized class values (i think) like the List of items, the name, posX, posY and posZ. Then what do I do with my class? how do I save its content to a file so I can load it back when needed?
public class RecipeSign implements ConfigurationSerializable {
//list of 10 items: 1-9 are the recipes, 10 is the crafting result
private List<ItemStack> items = new ArrayList<>();
private String name;
private int posX;
private int posY;
private int posZ;
public RecipeSign(int posX, int posY, int posZ) {
this.posX = posX;
this.posY = posY;
this.posZ = posZ;
}
public List<ItemStack> getItems() {
return items;
}
public void setItems(List<ItemStack> items) {
this.items = items;
}
public BlockVector getBlockPost(){
return new BlockVector(posX,posY,posZ);
}
public int getPosX() {
return posX;
}
public void setPosX(int posX) {
this.posX = posX;
}
public int getPosY() {
return posY;
}
public void setPosY(int posY) {
this.posY = posY;
}
public int getPosZ() {
return posZ;
}
public void setPosZ(int posZ) {
this.posZ = posZ;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public Map<String, Object> serialize() {
return null;
}
}
how can i respawn an entity by its uuid (i saved)?
you can just use FileConfiguration.set(path, yourObject)
I tried, and it broke when I tried to load it back :(
do u have an example?
just create a map and for each variable set it as name, value
oh and then FileConfiguration.set and the load will work?
sus
a lot of people just make a manual methjod that serializes to a string instead
can be easier
yeah
thx
can i somehow serialize and unserialize an entity class? to/from config
also unrelated but if you want to reduce getter/setter methods oyu can use lombok
yeah never really used it tho
changes```java
public class Class{
private int number;
public void setNumber(int val){
this.number = val;
}
public void getNumber(){
return this.number;
}
}
to
```java
public class Class{
@Getter
@Setter
private int number;
}```
also has other annotations
Can i somehow save a whole NBTTagCompound from entity class?
There are respective methods on the internal entity representation
How I can add Subcommands to the plugin.yml?
Sub commands are not added to the plugin.yml
I alredy did a Command manager and that stuff for subcommands, in Itellij it doesn't give me an error, but when I put it on the server it gives me this error
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "me.mrstreeet.logintitle.LoginTitle.getCommand(String)" is null
at me.mrstreeet.logintitle.commands.CommandManager.setup(CommandManager.java:27) ~[LoginTitle-1.0-SNAPSHOT.jar:?]
at me.mrstreeet.logintitle.LoginTitle.onEnable(LoginTitle.java:33) ~[LoginTitle-1.0-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[patched_1.17.1.jar:git-Paper-278]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.17.1.jar:git-Paper-278]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.17.1.jar:git-Paper-278]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:535) ~[patched_1.17.1.jar:git-Paper-278]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:449) ~[patched_1.17.1.jar:git-Paper-278]
at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:725) ~[patched_1.17.1.jar:git-Paper-278]
at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:306) ~[patched_1.17.1.jar:git-Paper-278]
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1212) ~[patched_1.17.1.jar:git-Paper-278]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[patched_1.17.1.jar:git-Paper-278]
at java.lang.Thread.run(Thread.java:831) [?:?]```
you're calling getCommand() on a command that does not exist in the plugin.yml - which IDEs obviously don't check. if you're doing getCommand("mycommand") mycommand needs to be registered in the plugin.yml
this is also not a subcommand
are you sure and I mean 100% sure you're passing the right string into the getCommand() call?
given what I just glanced over in your forum post
can I send you a paste bin?
Is there a way to stop Spigot deleting empty config paths?
?paste
I saw your forum post, I've already seen your code. Again, are you sure you're passing in the right string?
I dunno, I'm new coding
I'm just followingn forums, posts and tutorials
wdym
And doing exactly what they said and I'm the only one who has this problem π€·ββοΈ
btw, in the forum you have the plugin.yml and the code, so you can see it.
because I don't know what I'm doing bad
I know what the issue is, I'm trying to get you to see it yourself
check what you're passing into the getCommand call and compare it with the commands you've set up in the plugin.yml
null
it was null
i used if and else if
same problem
is there any other way to check the server's version ?
alredy saw it
omg
reload command doesn't works :c
this one works
but /login title reload doesn't
@Override
public void onCommand(Player player, String [] args) {
if(args.length == 0) {
if (player.hasPermission("logintitle.reload")) {
plugin.reloadConfig();
player.sendMessage(ChatColor.GREEN + "[LoginTitle] " + ChatColor.WHITE + "Plugin reloaded succesfully");
}
}
}```
do you ever check for the reload arg
eh?
that is only going to do anythign if you issue the command with no arguments
From what I've read you seem to be confused over defining and registering commands
how I can fix it then?
what command are you typing and what do you expect it to do?
It's a subcommand (/logintitle reload) and basically it realoads the congif.yml file.
ok
should just put those above the class declaration in this case
so the actual command is logintitle the sub command (args) is reload
so in your executor for logintitle you need to see if args > 0 then check "reload".equalsIgnoreCase(args[0])
the reload one it's the one that doesn't work
is yoru help command /logintitle help ?
then show us your logintitle command executor code
?paste
I don't need an essay, just show the code
Main: https://paste.md-5.net/onowexojaz.java
Command manager: https://paste.md-5.net/tijinukidi.java
SubCommand: https://paste.md-5.net/xocefeqeka.java
Reload command: https://paste.md-5.net/ujutegidip.java
Help command: https://paste.md-5.net/ikuqududez.java
?paste
My bad
k, onme sec while I read
ok do you get an Invalid subCommand message when you try reload?
or teh command just doesn;t run?
it doesn't run
directly?
ok, there can only be one possible cause. You do not have the permission logintitle.reload,
Lemme check
your code has no issues. Its oddly designed but there are no bugs
Im learning, so it's normal if it has an oddly design
Btw, theres a way to put that you need only op in the permission?
yes
in plugin.yml you can add a permissions section
not a direct command permission, but a full permissions section
doesn't works, I added the permission in Luckperms
I think the problem it's this part of the command
there is no other issue with your code. The only possible thing is you are setting your plugin instance in your reload command to read your command name. You don;t do that for help
Nope, nothign wrong with that
well spacing
String[] args
change the name() method to just return a String in the reload command
imagine that was the mistake
that will eliminate any issue with yoru plugin instance
this?
you have the same space issue in yoru SubCommmand class
yes
oke, let's test
So, MC uses a enum to define what a block surface is for pathfinding
So I'll need to extend it
How would I do that
Why extend it? it has every BlockFace you could need
still without working :c
Did you change the name() method to return a string?
ok
then the only thing it can be is a permission issue. add a sysout in your reload command to say if there is no permission
Like this?
just check the permission. Don't care about op
you get no output at all using /logintitle reload ?
yup
?paste your new reload class with the permission debug in it
Oke, i think now I know why it's not working
delete the first if statement and see
basically, for no readon the plugin its not creating the config.yml file
when i didn't touched that part of the code
I am not talking about that
I am talking about the BlockPathType
Which defines what kind of surface a block is
i.e. water border, danger, damage, trapdoor etc
ElgarL i think I found the error
you only need call saveDefaultConfig() in yoru onEnable. It will create the folders and copy the config from yoru jar
createFiles();
instance=this;
createFiles() is not in the paste you showed of yoru LoginTitle class
delete that method
just add saveDefaultConfig()
where exactly?
at teh top of your onEnable
with this works actually, but the command still without working
hi I'm looking for a Minecraft developer whom can program a custom plugin:
I have an issue with Mcmmo and Jobs Reborn... in the server i run i would like to remove the ablity for farms to pay out any xp or currency. (my moderators have stated this is to stop people unfairly grinding levels or inflating market prices)
the issue started with an ender mite ender man farm. and is the primary fix i would like covering but i would like this to cover all living mobs. both good and bad. (and config to change if possible)
this could be best done by targeting mobs that are close together for example mob groups of up to 5. in close proximity.
Of course commission is included and negotiable
PM me
Paste your new reload class
now you have to work out why your args is not empty is all
Here's a question, is it even possible to make a entity pathfind with ladders
spiders start climbing as soon as they touch one or more blocks on any side
write your custom pathfinder
Spiders can climb any surface
Pathfinding is unable to mark certain blocks as climbable
Which would need to be necessairy to pathfind accordingly
Since block node definitions are a enum
Spiders just straight up keep going foward when targeting a position above them
But a climbable pathfinder would need to actively look for nodes marked as climbable
But that is not possible, because nodes cannot be marked as climbable
how to fix?
Hello, I try to load custom blocks from a json and when the plugin load it send an error
The logs: https://hastebin.de/sisaworibe.log
The function: https://hastebin.de/ajugozulaf.java
Hey everyone, how do you handle players count in a multi-velocity / multi-bungee env ?
how the heck can player.getLocation() be null?
If player is null
Wdym
well maybe then my location changes i dunno
from that point i requested my location
lemme just restart the server
@quaint mantle
so
ok
https://prnt.sc/1tu9g7a
hey so im making a plugin which lets you sit on stairs using armor stands, and when i spawn the armor stand and let the player ride it, the legs render off to the side rather than straight down the middle like i want, how do i fix this?
is this a minecraft bug or something to do with the way i set up the entity to ride the armor stand?
gson?
Text components u talking about ?
adventure api
I'd personally recommend the adventure api over the bungeecord components ^
This is Spigot not Paper
adventure works on spigot too
Its not in Spigot though. So recommending it (a competing product) is not appropriate.
you can shade it into your plugin Β―_(γ)_/Β―
i mean paper is just basically spigot, but runs smoother
This is spigot though. He asked in a spigot discord about json in chat so I recommend the spigot chat API.
paper is literally nothing but just to make the server run smooth lol
i already figured it out lol
plus extra API
adventure works on spigot ;)
shill
whilst paper has some cool api additions and speed increases, please refrain from talking about paper(or any of its sub-apis) in spigot
yours truely
oli
lol
it's not "sub api" π
eh
i was expecting a longer message lol
isnt it possible to call the super-super class sonstructor?
was going to say something about how the kyori team isn't exclusively made up of people in the paper team
I mean that is a fair point
but im seeing some uncanny similarities lmao
dependabot π
mwoa
how to use IChatBaseComponent in 1_16_R3 ?
in 1.17.1 was IChatBaseComponent.a(String)
but there is no method in 1.16.5
does anyone knows when static {} is called?
when the class is loaded by JVM
do anyone know how to do a hover event on onPlayerJoin event?
is that the append method?
oh
like player.sendMessage("Test") but with a hover event?
this thing
something like this but not with show command
You probably have to cancel the event and broadcast the component if you're using the spigot api
aah okay
anyways whats the best way to make a countdown timer that says something every minute and when it reaches 1 minute it says somethginh every 10 sec?
yea that
oh
?scheduling
then use scheduler
theres a specific command to start and stop a countdown
lemme give it to you
ah wait my net is bad rn
Is there a way to stop Spigot deleting empty config paths?
so in 1_17_R1 the IChatBaseComponent was easy. a simple IChatBaseComponent.a(String)
but there is no such method in 1_16_R3. what should i do ?
Has anyone ever used Jython inside a Java program? If you have please let me know
new ChatMessage(chatMessage) ?
Yes
However, you cant actually really run like a whole actual python program really inside. It's like the python interpreterer
like the terminal python thing you get
you can call python functions however from your java code
Yeah, I was wondering how to compile a python function and then run it later in my java code
I'm trying to use it as a mini scripting method
thanks
π
Saving custom block to a json
public static HashMap<Player, List<Integer>> hololist = new HashMap<>();
will this work if i get the list, modify it and set it ?
You don't need to set it
for example i want to add an id to the list of integer
so could i get the integer list
add for example 6 to it
and set it ?
You don't even need to set it
so what
Just get the list and modify it
What is the maximum amount of block updates I can send to a client a second
depends on many factors. Their PC horse power, your server horse power, the bandwidth of your connection
There is no way to put an actual number on it
So would 20 - 30 block updates be possible for one block position?
I'm currently having an issue with my plugin. When I start up the server for the first time, some stuff don't work but when I do /rl, it all works fine, why would that even happen?
If sent async
What stuff doesn't work
What is the plugin
?paste
That's the error that comes for when I start the server for the first time, but it all works fine after /rl?
WorldLocationUtility.java:166
Location loc = (Location) arenaConfiguration.getArenaConfig().get(getSelected() + ".traitorTester.testerSpawn");```
one of those is null
But why would it work fine after /rl and not other?
arenaConfiguration or getArenaConfig() or there is no entry in that config for getSelected() + ".traitorTester.testerSpawn"
you initialize it at some point
what is getSelected()?
the getSelected() thing is used in a method that is in the enable thing
lots of things, tells me nothing
gameHandler.IN_LOBBY(); is used in the enable, java public void IN_LOBBY() { StateUtility.setState(StateUtility.IN_LOBBY); new Thread(new EnoughPlayersHandler(this, playerHandler)).start(); worldLocationUtility.run(); } this one is what it is
and run selectes one world from the arenalist in the worldLocationUtility.run()
and then it loads it with java private void load() { String world = arenaConfiguration.getArenaConfig().getConfigurationSection(getSelected()).getString("worldName"); Bukkit.unloadWorld(world, false); Bukkit.createWorld(WorldCreator.name(world)); }
all that is done in the enable basically
yeah none of that tells me specifically what getSelected() does
public String getSelected() {
String result = "";
return result = String.join("", selectedMap);
}```
ok
like everything does work after /rl but not when first started
doesnt really make sense to me
what is selectedMap?
public List<String> selectedMap = new ArrayList<>();
k
can eliminate that as null then
The simplest way to to add some sysouts to see what is null
sysout "arenaConfiguration: " + arenaConfiguration == null
etc
do it for each element of that line, to see what precisely is null
I would imagine this is the issue https://paste.md-5.net/unazifudac.sql
not sure how to fix that tho
that means the world is not yet loaded
i done it with packets
oh
Modify what
it should load with this tho? java private void load() { String world = arenaConfiguration.getArenaConfig().getConfigurationSection(getSelected()).getString("worldName"); Bukkit.unloadWorld(world, false); Bukkit.createWorld(WorldCreator.name(world)); }
i have the id of the armorstand, should i send the meta data again ?
Hi, have a small problem :/ So, maven cannot resolve spigot dependency for 1.17.1, any thoughts?
its 1.17 I think
spigot or spigot-api?
spigot-api
lemme check
and random
InteliJ or eclipse?
vscode
hah, thanks β€οΈ
However, nothing wrong with your pom. Can't help you with vs though
np
I'd recommend using a proper IDE like IntellIJ or Eclipse
i also would like to say that IntelliJ is superior for features, customization and syntax highlighting
but eclipse is faster if you care
?jd
so on 1.17 you can get a "this server requires a custom resourcepack" screen from the normal "recommends" if you set that in the server.properties. How can I achieve this via spigot API? Doesn't seem to be any new setResourcePack methods.
What to Use Instead of Static
you can tho
if you monitor the resourcepack status event
I want to show this from the API
Not sure if you can do that without setting the option in server.properties
sad
Paper has API for this
kekw
Pretty sure you can't do it with API in Spigot
paper strikes again
guess I'll have to add a paper check and only enable it on paper servers (otherwise fallback to spigot api)
I'm really having trouble creating 3 nested loops over X,Y, and Z any tips?
you trying to get blocks in a radius?
yes
Why doesn't this work?
// If the entity isn't a allowed entity, cancel event!
boolean isAllowedEntity = false;
for (EntityType allowedEntities : pokeballMain.getConfigHandler().AllowedEntities) {
if (entity.getType() == allowedEntities) {
System.out.println("&aEntity Type: " + entity.getType() + "&e, AllowedEntity: " + allowedEntities + "&4, Result: true");
isAllowedEntity = true;
break;
} else {
System.out.println("&aEntity Type: " + entity.getType() + "&e, AllowedEntity: " + allowedEntities + "&4, Result: false");
}
}
System.out.println("result:" +isAllowedEntity);
if (isAllowedEntity == false) {
System.out.println("1");
return;
} else {
System.out.println("2");
}
Config:
AllowedEntities:
- COW
- ZOMBIE
Debug:
&aEntity Type: COW&e, AllowedEntity: COW&4, Result: true
[22:05:30] [Server thread/INFO]: result:true
[22:05:30] [Server thread/INFO]: 2
[22:05:30] [Server thread/INFO]: 3
trying to make neighboring blocks do the same thing as the first block
should be pokeballMain.getConfigHandler().AllowedEntities.contains(entity.getType())
also should be allowedEntities according to naming conventions
also should be a getter
@grand bronze for (double x = start.getX() - radius; x <= start.getX() + radius; x++) { for (double y = start.getY() - radius; y <= start.getY() + radius; y++) { for (double z = start.getZ() - radius; z <= start.getZ() + radius; z++) { // do whatever, get location etc } } }
Okay i'll read over this and see if I can make any sense of it I'm very new to java and coding in general so I'm really just here to learn
thank you
ChatColor1 + "" + ChatColor2
Or you could you do ChatColor.translateAlternateColorCodes('&', "Message")
NOOOO
DONT USE THIS
I have this code now, but it doesn't stop the code in the !isAllowedEntity
boolean isAllowedEntity = pokeballMain.getConfigHandler().AllowedEntities.contains(entity.getType());
System.out.println("result:" +isAllowedEntity);
if (!isAllowedEntity) {
System.out.println("Stop");
return;
} else {
System.out.println("pass");
}
Definitely use translateAlternateColorCodes
I mean you should be using the enum constants
I'd use them if they weren't so terrible to work with
or proper chat components Β―_(γ)_/Β―
in plugin.yml, add aliases: [ youraliashere ] to the command
Add a aliases: [aliasCommand] to the command in plugin.yml
Hello, how i can check if block placed is a tnt?
I use this event: BlockMultiPlaceEvent
BlockPlaceEvent
hey guys, what is a commandsender?
A sender of a command
Since MultiBlockPlaceEvent inherits from BlockPlaceEvent, you can call getBlockPlaced() without having to modify your existing code
I don't think the multiplace event will fire for tnt
how i can check if block is tnt?
Get the material and compare it to Material.TNT
Hey. In mysql, if I try to update a value in a row but if the value in that row is equal to the value I've write in the query, will it still be updated? I mean, will the method executeUpdate() return 0 or 1?
How would I use one of my plugins as a dependency for another? like.. I need to be able to get methods from the dependency inside the dependent plugin
How can I get text input from a player using the edit message sign gui (also how can I show the sign gui to the player)
i believe it checks so the changed count should return 0
Ty
mysql docs https://dev.mysql.com/doc/refman/8.0/en/update.html
If you set a column to the value it currently has, MySQL notices this and does not update it.
Thanks man, I ly β€οΈ
Would I need to make all of my methods static in my dependency plugin?
No dont do that
alright...well
it's telling me it can't resolve a method from it
not sure why.
private boolean setupHoloPlugin() {
if(getServer().getPluginManager().getPlugin("CadiaHolos") == null) {
return false;
}
cadiaHolos = (CadiaHolos) getServer().getPluginManager().getPlugin("CadiaHolos");
return false;
}
Got this in the main class of my 2nd plugin, registering the instance of the main one
and trying to get the methods from it
cadiaCore.cadiaHolos.setupHolo(player, hologram);
not.. entirely sure what you're trying to do?
I need to use Plugin A as a dependency for plugin B
and be able to get the methods from A in B
okay, well if your dependency is called CadiaHolos then you're good to access its methods in the above method since you assigned an instance of it to cadiaHolos
in other words cadiaHolos.XXXXXX will work
right thats what I was thinking but
If I add a new method to plugin A, how would I refresh project B so it'll show up?
(intellij)
compile it and add that as a dependency
Yeah, it already is one
do I gotta remove and readd?
using it as a jar dependency right now
if you've used the exact name then yes, intellij will need to rebuild its indexes of it
otherwise it doesn't know it has changed
lame
So, I'm using the CadiaHolos as just a way to display the information, then I want to be able to use it in 2 separate plugins so I plan on adding the interact methods for each dependent plugin inside the dependent plugin itself.
Good idea or naw
then I plan on saving the holograms in files for each plugin, so they would be saved in plugin B's folder instead of plugin A's
idk if thats a smart move or not.
how would I specify what blocks I want to affect within a loop
add them to an enumset
alright time to figure out what the fuck that is
Set<Material> allowBlocks = EnumSet.of(Material$1, Material$2...);
for (...) {
if (!allowBlocks.contains(block.getType()) {
continue;
}
// ...
}
when creating a new event what should i think about when trying to define my set of <CommandSender>'s
?
Why CommandSender
i think i got my thought process wrong.
let me try to explain
i was initially going to create a new broadcastmessagevent that triggers when a broadcast message is sent
π¬
so i could have my discord bot listen for that event and post a message in discord when it comes.
but, i figured there has to be a current broadcastmessage event already in existence that the server throws
is there a way to access that?
Idk
Only if an event callback fails Ig?
But then youβd be prompted with a stacktrace
Anyways
If you just wanna send a message to every player online
Donβt use broadcastMessage lol
nah that's not my goal
my goal is to take broadcasted messages and post them to my discord channel for my server
Oh
Well in that case
Then just listen for the event and send to the discord message channel?
precisley! i just think i'm struggling with understanding the exact syntax of that. i'm using the jda-java api for discord and i've registered a generic eventlistener.
Why
i don't know how to connect the event to the eventlistener
You donβt need any jda event listeners if your only goal is to send a message to a channel with JDA
You dont want a jda listener. You want a bukkit listener. The bot itself just sends messages in a channel.
^
I can get org.bukkit.block.Chest in 1.8.8 but I cant get org.bukkit.block.EnderChest?
How may I get the clicked block?
1.8 support was dropped almost half a decade ago. It has a bunch of bugs that will never get fixed and lacks a ton of API features.
You should move on.
Well... then you have to live with the handicaps an very outdated piece of software comes with π€·
figured it out, I can just do this and it worked java if (event.getClickedBlock().getType().equals(Material.ENDER_CHEST)) {
Do anyone know how to make redstone lamps stay on?
Use == for enums
this enum shit got me re-thinking my life
does anyone know how to set someone balance with the vault api?
Check how much the player has and then add/subtract the delta.
hey! might be a simple question, but, how do you create a repeated task to run every hour?
but i want to set it, not add it
Right. Then check how much a player currently has and add/subtract the delta
There are several ways of approaching this. How precise do you need this to be?
sorry, i dont know how i would do that π is there a documentation or something?
as precise as can be
So a binary interpolation polling approach
i dont see any way to set a balance on there though?
Yeah. You need to get the current balance and then add/subtract the delta. As stated before.
Ill show you a quick example
yes i know, but then i said i dont know how id do that so is there a documentation or something?
i know how to get the balance but not the delta thing
thank youu!
So you want to basically half the time interval every poll until you reached the atomos of your timestep.
ahhh okk tyy
Btw you can also use an external library called Quartz to schedule tasks at specific points in time.
Example:
Trigger trigger = TriggerBuilder.newTrigger()
.withIdentity("myTrigger", "group1")
.startNow()
.withSchedule(SimpleScheduleBuilder.simpleSchedule()
.withIntervalInSeconds(40)
.repeatForever())
.build();
niceee
Unable to make field private java.lang.Object java.lang.ref.Reference.referent accessible: module java.base does not "opens java.lang.ref" to unnamed module @58134517 I am getting this strange error with GSON. Running a server with JAVA 16, Spigot version 1.17.1
https://github.com/PaperMC/Paper/issues/6370#issuecomment-895715541 Found a similar issue on papermc
I have the latest version of spigot via the build tools.
Try shading a newer gson version in your plugin using maven.
π I guess that is the only option yeah..
Is there no way for them to update the GSON version?
There is but it needs extensive testing first.
Btw try starting your server by adding the flag --add-opens java.base/java.lang=ALL-UNNAMED
java.lang.StackOverflowError: null
at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111) ~[spigot-1.17.1.jar:3244-Spigot-6c1c1b2-9aeb46a]
at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553) ~[spigot-1.17.1.jar:3244-Spigot-6c1c1b2-9aeb46a]
This is the error presented
Looks like a recursive serialization is happening
What are you trying to serialize?
Yeah but how do the fields look like?
public void deserialize(Plugin plugin) {
arenas = Json.read(plugin, "arenas", new TypeToken<Set<Arena>>(){}.getType());
if(arenas == null) arenas = new HashSet<>();
}
public static <T> T read(Plugin plugin, String fileName, Type type) {
Path path = Paths.get(plugin.getDataFolder() + "/" + fileName + ".json");
try {
if (!Files.exists(path)) {
Files.createDirectories(path.getParent());
Files.createFile(path);
}
} catch (IOException e) {
e.printStackTrace();
}
try {
BufferedReader bufferedReader = Files.newBufferedReader(path, StandardCharsets.UTF_8);
JsonReader jsonReader = new JsonReader(bufferedReader);
return GSON.fromJson(jsonReader, type);
} catch (IOException e) {
return null;
}
}
``` This is my read function
How dows your Arena class look like?
public class ArenaManager {
private Set<Arena> arenas = new HashSet<>();
public Arena getArena(Player player) {
return arenas.stream().filter(arena -> arena.getPlayers().contains(player.getUniqueId())).findFirst().orElse(null);
}
public Arena getArena(String name) {
return arenas.stream().filter(arena -> arena.getName().equalsIgnoreCase(name)).findFirst().orElse(null);
}
public boolean remove(Player player) {
Arena arena = getArena(player);
if(arena != null) {
arena.remove(player);
return true;
}
return false;
}
public void add(Arena arena) {
arenas.add(arena);
}
public void remove(String name) {
arenas.removeIf(arena -> arena.getName().equalsIgnoreCase(name));
}
public boolean add(Arena arena, Player player) {
Arena playerArena = getArena(player);
if(playerArena != null) return false;
arena.add(player);
return true;
}
public void serialize(Plugin plugin) {
Json.write(plugin, "arenas", arenas);
}
public void deserialize(Plugin plugin) {
arenas = Json.read(plugin, "arenas", new TypeToken<Set<Arena>>(){}.getType());
if(arenas == null) arenas = new HashSet<>();
}
You should def use a Map<String, Arena> here
I did before but changed it
ill revert it back
It is because I wanted to have the name inside the arena class
Arena.class
You can still do that
But also use it as a key mapping
Yeah
Nice to see proper manager classes for once
public class ArenaManager {
private Map<String, Arena> arenas = new HashMap<>();
public Arena getArena(Player player) {
return arenas.values().stream().filter(arena -> arena.getPlayers().contains(player.getUniqueId())).findFirst().orElse(null);
}
public Arena getArena(String name) {
return arenas.get(name);
}
public boolean remove(Player player) {
Arena arena = getArena(player);
if(arena != null) {
arena.remove(player);
return true;
}
return false;
}
public void add(String name, Arena arena) {
arenas.put(name, arena);
}
public void remove(String name) {
arenas.remove(name);
}
public boolean add(Arena arena, Player player) {
Arena playerArena = getArena(player);
if(playerArena != null) return false;
arena.add(player);
return true;
}
public void serialize(Plugin plugin) {
Json.write(plugin, "arenas", arenas);
}
public void deserialize(Plugin plugin) {
arenas = Json.read(plugin, "arenas", new TypeToken<Map<UUID, Arena>>(){}.getType());
if(arenas == null) arenas = new HashMap<>();
}
}``` Ok literally changing it back to a map fixed it
Does it not support sets?
This is weird
It does. Could you pls show your Arena.class or at least the fields
private transient final Set<UUID> players = new HashSet<>();
private final String name;
private ArenaState state;
private Point one, two;
private int minPlayers, maxPlayers;
I don't want it to store a set of players (uuids)
Ok looks fine. I just suspected that you have a non transient ArenaManager class in there which would cause a StackOverflow
Ok nice. Btw take a second look at your TypeToken
Yes (UUID)
Should be name π
(string)
Thank you!
Actually I am getting the same error again hmm
Eh... how does the full stack trace look like?
Btw you could try and serialize/deserialize the whole ArenaManager without a TypeToken for the map. Let gson do the hard lifting.
Json.write(plugin, "arenas", this);
and
this.arenas = Json.read(plugin, "arenas", ArenaManager.class).arenas;
Didn't think of that
lobby = Json.read(plugin, "lobby", Location.class); Let me guess I can't serialize a bukkit location
It holds a reference to a World i think.
Not sure how Gson handles this
I might have to create my own encapsulation class...
Or just write a custom Serializer and register it with Gson
I haven't written one before any documentation on that?
One moment ill give you an example
public class LocationSerializer implements JsonSerializer<Location>, JsonDeserializer<Location> {
@Override
public Location deserialize(
final JsonElement jsonElement,
final Type type,
final JsonDeserializationContext jsonDeserializationContext
) throws JsonParseException {
final JsonObject jsonObject = jsonElement.getAsJsonObject();
final double x = jsonObject.get("x").getAsDouble();
final double y = jsonObject.get("y").getAsDouble();
final double z = jsonObject.get("z").getAsDouble();
final float pitch = jsonObject.get("pitch").getAsFloat();
final float yaw = jsonObject.get("yaw").getAsFloat();
final UUID worldID = UUID.fromString(jsonObject.get("world").getAsString());
final World world = Bukkit.getWorld(worldID);
return world == null ? null : new Location(world, x, y, z, pitch, yaw);
}
@Override
public JsonElement serialize(
final Location location,
final Type type,
final JsonSerializationContext jsonSerializationContext
) {
final JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("x", location.getX());
jsonObject.addProperty("y", location.getY());
jsonObject.addProperty("z", location.getZ());
jsonObject.addProperty("pitch", location.getPitch());
jsonObject.addProperty("yaw", location.getYaw());
jsonObject.addProperty("world", location.getWorld().getUID().toString());
return jsonObject;
}
}
Then later for registration:
final Gson gson = new GsonBuilder()
.disableHtmlEscaping()
.setPrettyPrinting()
.registerTypeAdapter(Location.class, new LocationSerializer())
.create();
use the service manager from bukkit
json
Awesome thank you do much!
Good to see that you are using UUID instead of name
I hardly ever use final keywords like that. Is it a good practice to do so?
When local scoped, it's preference. I never do it personally because I dislike the look of it, but if you're concerned about ever reassigning your variables when you don't expect to, you can do it. It's unlike C++ where you can declare your parameters are constant
Its preference. I always set my IDE up so that it uses them in a bountiful manner.
It makes every variable thread safe by default, qualifies them for usage in lambdas and makes the intention clear that they should not be changed.
Some think its a bit cluttering but i personally prefer it this way.
Alright thank you for the feedback!
using variables in lambda: AtomicReference
or something with a name like this that i forgot
You need an instance of your JavaPlugin class and the PluginManager.
Step by step:
JavaPlugin plugin = ...;
Listener yourListener = new YourListener();
PluginManager pluginManager = Bukkit.getPluginManager();
pluginManager.registerEvents(yourListener, plugin);
Often used like this:
@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents(new SomeListener(), this);
}
oh
okay
was about to say do i need to create an instance of my plugin within the plugin
Nope. This will cause an Exception to be thrown.
You get one single instance of your JavaPlugin class and you need to distribute it to the places which need it.
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Is something wrong with this query?
INSERT INTO acash (name, cash) VALUES (?, ?) ON CONFLICT(name) DO UPDATE SET cash=?
I'm getting this error:
[01:17:35 WARN]: java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (near "ON": syntax error)
I tried this but it seems to throw an exception. Might just use TypeToken
sqlite does not have this
until you get a real solution, try REPLACE INTO
Or ON DUPLICATE KEY if your name is a unique key
Google SQL Upsert. There are many patterns explained.
I did
Tried ignore and on conflict
ok
If it does update it
2 statements, right?
isDirty isDeleted and isInDatabase
and their respective setters
when i load a user from the database
i mark the user as inDatabase
and not dirty
so when i want to update them
i check if they are dirty and if in database
I just let Gson create some Json data and then throw it into mongodb. Since i moved to document based DBs im actually not sure why SQL
is so popular with the spigot community. At the very least i would want to heavily abstract away all those String queries by using something
like QueryDSL.
if (!isDirty() && isInDatabase())
return; //nothing happened
setDirty(false); //they will be clean after that
if (isInDatabase()) {
//update in the database
return;
}
//insert into the database
setInDatabase(true); //in database now :D```
This sounds like you do a bunch of queries which are not necessary. (If isInDatabase() queries the DB for example)
I want to do it in one statement
Ah i see what you mean
Yeah that looks fine. Can also help with batching.
i think that it is beautiful :3
Btw you should check this out:
Get away from those pesky error prone String queries
Is there a repo for wlib?
1.8 π¬ π«
1.8 based but have compatibility with 1.12 1.15.2 1.16.5 and 1.17.1
there is some old code used that i want to refactor
like how i handle nbttags
@lost matrix so now that i have my event listener registered. where do i put my code to handle that event?
try {
final Server server = plugin.getServer();
final Field commandMapField = server.getClass().getDeclaredField("commandMap");
commandMapField.setAccessible(true);
CommandMap commandMap = (CommandMap) commandMapField.get(server);
commandMap.register(getName(), this);
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
``` For those who can't be ***ed adding commands to the plugin.yml
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
i personally like to add the commands in the plugin.yml
Or just use an established command framework like ACF
Not to mention plugin command attribution
I don't like ACF that much
just an addition
i never heard about acf
i use the command system of wlib π
Eh annotations...
Its not everyones cup of tea. It took me forever to learn every little feature and now
i dont feel like switching to anything else.
I just use my own command class.
public abstract class CommandBase extends Command implements Registry {
protected CommandBase(String name, String... aliases) {
super(name);
setAliases(Arrays.asList(aliases));
setPermission("command." + getName());
}
@Override
public boolean execute(@NotNull CommandSender commandSender, String s, String[] strings) {
if (commandSender instanceof Player player) {
if (!player.hasPermission(Objects.requireNonNull(getPermission()))) {
player.sendMessage("You do not seem to have permissions.");
return true;
}
return run(player, strings);
}
return false;
}
public abstract boolean run(Player player, String[] strings);
@Override
public void register(Plugin plugin) {
Registry.super.register(plugin);
try {
final Server server = plugin.getServer();
final Field commandMapField = server.getClass().getDeclaredField("commandMap");
commandMapField.setAccessible(true);
CommandMap commandMap = (CommandMap) commandMapField.get(server);
commandMap.register(getName(), this);
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
}
}
``` I use string arrays for arguments but put them in different functions like ACF has the subcommand methods
nΓhao, wondering how to de-obfusicate classes such as net.minecraft.server, org.craftbukkit, etc.
tried googling, really didnt understand anything it said to do
buildtools?
and about the nms
you cant deobfuscate
I just like having full control over aliases, completions, context resolvers, permissions etc in just a few lines of code:
@CommandPermission("admin")
@CommandAlias("weapons")
public class WeaponCommand extends BaseCommand {
@HelpCommand
public void onDefault(final CommandSender sender) {
Msg.sendInfo(sender, "/weapons melee <Type>");
Msg.sendInfo(sender, "/weapons ranged <Type>");
}
@Subcommand("melee")
@CommandCompletion("@MeleeWeapon")
public void onMelee(final Player player, @Values("@MeleeWeapon") final MeleeWeapon weapon) {
player.getInventory().addItem(weapon.getItem());
Msg.sendInfo(player, "Du hast {} erhalten.", weapon);
}
@Subcommand("ranged")
@CommandCompletion("@RangedWeapon")
public void onRanged(final Player player, @Values("@RangedWeapon") final RangedWeapon weapon) {
player.getInventory().addItem(weapon.getItem());
Msg.sendInfo(player, "Du hast {} erhalten.", weapon);
}
}
wlib:
@Command(execution = "command <hello> [world]")
public void command(Player player, String hello, String[] world) {
player.sendMessage(hello);
if (world != null)
player.sendMessage(world);
}
//onEnable
new CommandManager(plugin).registerCommands(commandClass);```
The command completion/context resolvers is quite nice.
You can use mojang mappings. You can read about it here:
https://www.spigotmc.org/threads/spigot-bungeecord-1-17-1-17-1.510208/
I prefer builders over annotations xD
like each class is like a subcommand and stuff
doesn't matter tho
Me too!
for (double x = start.getX() - 5; x <= start.getX() + 10; x++)
how would I actually set a radius with this
First of all: Dont use doubles for that.
int?
doubles in a loop π€‘
Example:
public List<Block> getBlocksAround(final Block center, final int radius) {
final List<Block> blockList = new ArrayList<>();
for (int x = -radius; x <= radius; x++) {
for (int y = -radius; y <= radius; y++) {
for (int z = -radius; z <= radius; z++) {
blockList.add(center.getRelative(x, y, z));
}
}
}
return blockList;
}
@lost matrix does my plugin have to implement listener or do i have to implement listener in a separate class
Btw just for fun. This does the same thing:
public List<Block> getBlocksAround(final Block center, final int radius) {
return IntStream.rangeClosed(-radius, radius)
.mapToObj(x -> IntStream.rangeClosed(-radius, radius)
.mapToObj(y -> IntStream.rangeClosed(-radius, radius)
.mapToObj(z -> center.getRelative(x, y, z))))
.flatMap(Function.identity())
.flatMap(Function.identity())
.collect(Collectors.toList());
}
You implement listener in the same class as where you have your eventhandler method
let me copy that
xD
That is horrible
Yes. And it performs like that too.
i just realized there are two .flatMap calls lmao
Yeah because i first have a stream of stream of streams of blocks that need to be mapped to a stream of stream of blocks which then needs to be mapped to a stream of blocks
seems super inefficient kek
But its technically a one liner. π which is much more important than performance.
yes!
@Override public void onEnable() { getLooger.info("Hello!"); Bukkit.getPluginManager().registerEvents(this, this); }```
o man
Silence, wench
at my screen 3 simple ifs starts to side scroll
getLooger
getLooger
getLooger
heh
any idea for how to auto scaling backend spigot servers for balancing available maps?
I donβt want to use docker or anykind of containerd for latency/performance issue. (if you have any resources for using kubernetes without containerizing it, please tell me.)
anyone familiar with mysql and can clue me into what command i would have to use to attach a rowid to each new row into a database table ive got
prepareStatement("INSERT INTO wb_blocks" + "(NAME,UUID,WORLD,X,Y,Z) VALUES(?,?,?,?,?,?)");
and i would like to have something like
where ROWID is just whatever row number that new data will be on and it just counts upwards by itself never repeating as new data is entered
getLooger
@quaint mantle instructions unclear, dick stuck in blender
please turn on blender for maximum enjoymen. :)
i know it has something to do with @row_number but not sure how to implement it tbh if i have to set the variable when the table is created or what
use insert or set row id to x
or use hashtables and create table named rowid and index it from there.
im using insert already to put new data into the table, but idk how to add in a 'counting' rowid that increases by 1 automatically w/ every new entry if that makes sense
idk or you can use mongoDB, hypixel uses mongoDB.
what are you tring to do?
have you ever seen how coreprotect numbers their block data with a row id?
LMAO i give up
like so
im new
i dont know
im basically trying to do the rowid part of that
um the row id seems to be working alright
the rowid that i linked, i'm trying to accomplish that w/ my own plugin
it just counts, idk if that makes sense lol
before adding row to database, get last lowID. add 1 and insert to DB.
rowid counting?
yeah thats basically wht im needing to do
get the last rowid add 1 to it and insert that number into the preparedstatement w/ the rest of my command i just dont know what sql query commands do that stuff lol
You can set your ID to auto increment
alright. so how close is this to sending my desired message to my discord channel
public class broadcastReader extends JavaPlugin implements Listener {
public JDA jda;
public BroadcastMessageEvent onMessageBroadcast;
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(new broadcastReader(), this);
try {
jda = JDABuilder.createDefault("mybottoken").build();
} catch (LoginException e) {
e.printStackTrace();
}
}
@EventHandler
public void onMessageBroadcast (BroadcastMessageEvent event) {
jda.getGuildById("758813062848708670").getTextChannelById("758813063448363011").sendMessage(event.getMessage());
}
}
Containers would be the way to go here.
But you can also just write java code which copies prototype folders and starts new jvm instances.
getServer().getPluginManager().registerEvents(new broadcastReader(), this);
to
getServer().getPluginManager().registerEvents(this, this);
You are not allowed to create an instance of JavaPlugin classes.
Also right click -> refactor your class and rename it to BroadcastReader
And you def dont want to fetch the guild and channel every time a message is broadcasted. Use fields to store them instead.
alright before compiling and testing.. i already know i'm gonna have some library shading issues... where can i find the syntax for shading in the libraries in plugin.yml
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
making it change map based on how many map are available and balance it to x available maps?
What do you mean by "map"? I thought you wanted server instance load balancing.
map, server, the same thing.
maps and servers are not the same thing but u do u bro
lol
same point, just balancing for availabilit.
The implementation depends on your server model and use case.
Do you need a bunch of smaller servers that host minigames for examples or do you have one
large core which should be instanced but provide effectively the same experience on each instance?
Sure but what is your server model?
each server run around 4 to 8 servers.
Do you host your servers in the cloud (AWS for example)
bare metal, or so called home host.
I dont think bare metal means what you think it means.
Anyways then you dont need dynamic scaling by any means. Kubernetes or not.
You have fixed constraints.
i have fixed hardware, and i want it to balance for available software.
Ok then you probably want nginx with a reverse proxy setup that leverages the load
between your bungee proxies using a round robin distribution.
One moment
two momentβ¦
three momentβ¦
In this scenario the bungee proxies have the responsibility of distributing the load between the running mc instances.
Based on the player count.
The Nginx proxy has the responsibility to distribute the connection load between the bungee proxies because one instance can handle ~200 players at once max
(If you do a lot of packet magic then even as low as 150)
ok, you come to hypixel and play bedwars. the server available for bedwars games are 100 servers at 16 per. and skywars have 50 server/16. there are 1600 players playing bedwars while 400 playing skywars, the unused skywars server how wants to change it self to bedwars so more players can join.
balancing players and queue are not the sameβ¦
Thats why i asked for a server model...
pretty much the same.
This above would work for something like Wynncraft
there is a mastercontrol that handles queue, party, /msgβ¦
Quick question
So
If I have a YAML File then I save it, will it continue to be loaded after I have saved it or would I have to load it again?
Then go for Kubernetes and Containers.
docker or other container have 5% to 15% performance decreas. and adds 20ms of ping to database requests or client.
It stays in memory. So as long as you have a reference to your YamlConfiguration it will be kept in memory.
Thank you so much, I thought I was gonna get a rude response.
I dont know where you get those numbers from but they are not true. I wrote a whitepaper last year about the performance overhead of docker.
If you are on a Linux machine then there is almost no performance overhead (Unless you are on Windows)
IBM Research Report
https://course.ece.cmu.edu/~ece845/sp18/docs/containers.pdf
and a lot of other resources i found.
This report is from 2014
Yeah i know this paper. Its from 2014 and pretty much proves my point. Docker is even faster than kvms.
Technology has changed a lot since then
what is your whitepaperβs link?
I cant publicly share it because it contains confidential information but i can give you a truncated version.
dm me
First of all this is the repository for the JMH benchmarks:
https://github.com/Flo0/JMHSandbox/tree/master/src/main/java/com/gestankbratwurst/jmhbenchmark
404
Should be public now
alright
Also mandelbrot π
Oh right... its in german. π€¦ββοΈ
Anyways the conclusion is that a jvm ran in docker has practically no overhead.
If you use generated native code (GraalVM, Quarkus) then it even outperforms a normally run JVM
:D
Yeah i use mandelbrot whenever i learn a new language as its a pretty good measurement for
how well a lang handles nested loops and math in the imaginary number space.
Btw listed from slowest to fastest so far:
Ruby, Python, Lua, JavaScript, C#, Java, Rust, C++, C
If Python uses C libraries for the math then its on par with JavaScript.
I have done mandelbrot in C++ before with using SDL2
And ooooh interesting!
I remember when I made windows applications with C and I had to write so many switch statements π
Ah i have yet to write a mandelbrot evaluation which utilizes the GPU.
Yes I recommend utilizing the GPU omg
But i got a curse for KUDA and Shader programming coming up π
My friend and I while we were at university made procedural terrain generation with compute shaders for our game.
Shader Programming is π π
Open simplex noise?
wait what ?
org.bukkit.plugin.InvalidDescriptionException: libraries are of wrong type
at org.bukkit.plugin.PluginDescriptionFile.loadMap(PluginDescriptionFile.java:1160) ~[spigot-1.17.1.jar:3244-Spigot-6c1c1b2-9aeb46a]
at org.bukkit.plugin.PluginDescriptionFile.<init>(PluginDescriptionFile.java:259) ~[spigot-1.17.1.jar:3244-Spigot-6c1c1b2-9aeb46a]
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:175) ~[spigot-1.17.1.jar:3244-Spigot-6c1c1b2-9aeb46a]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:144) ~[spigot-1.17.1.jar:3244-Spigot-6c1c1b2-9aeb46a]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.loadPlugins(CraftServer.java:403) ~[spigot-1.17.1.jar:3244-Spigot-6c1c1b2-9aeb46a]
at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:233) ~[spigot-1.17.1.jar:3244-Spigot-6c1c1b2-9aeb46a]
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1010) ~[spigot-1.17.1.jar:3244-Spigot-6c1c1b2-9aeb46a]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:305) ~[spigot-1.17.1.jar:3244-Spigot-6c1c1b2-9aeb46a]
at java.lang.Thread.run(Thread.java:831) [?:?]
Caused by: java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Iterable (java.lang.String and java.lang.Iterable are in module java.base of loader 'bootstrap')
at org.bukkit.plugin.PluginDescriptionFile.loadMap(PluginDescriptionFile.java:1156) ~[spigot-1.17.1.jar:3244-Spigot-6c1c1b2-9aeb46a]
... 8 more
a it's something with my plugin.yml. b: its something with the way i passed strings to my JDA
Show your plugin.yml
No we did Perlin noise
main: com.craftinc747.discord.logReader
name: LogReader
version: 1.0.0
libraries:
-net.dv8tion:JDA:4.3.0_324
-
database: true```
i didn't actually finish it lol
Almost the same π
wasn't sure which libs i needed in there tbh
Yeah pretty much π
Anyways im out for now. BB
Cya
peace
im so confused right now..I moved some stuff around in my plugin and now my gui clicks are registering twice. sending two messages, etc.
its not registered twice
It might be because it is registering left and right click/
There is a fix for that but I can't remember
I have it checking if its left only, still fires twice
Have you restarted the server
it shouldnt fire twice though cause left/right is separate in that
yes
what's super weird is.. the green message sends twice while the yellow only sends once
I would expect both to send twice if that was the issue
oh..
ok im just retarded.
setupProtocolLib();
registerClassInstances();
loadConfigs();
registerListeners();
registerCommandExecutor();
registerListeners();