#help-development

1 messages Β· Page 1709 of 1

ivory sleet
#

Just expose setters of the field?

analog ore
#

but it adds OOP messiness

#

oh

ivory sleet
#

No need to have that container thing?

drowsy helm
#

would be a bit faster, but you are saving so much space not attributing all the variables just for one field

ivory sleet
#

anyways avoid reflection if you can, it can complexify your code very easily

analog ore
#

I could ditch the field wrappers

drowsy helm
#

key, value, defaultVal, timeToLive,loaded, loader, client, connection

#

all just for one variable

analog ore
#

yup

drowsy helm
#

you're saving time but imagine that with like 10k fields

analog ore
#

hm.

ivory sleet
#

Thing is wertik right now your entire memory model is tightly coupled to redis

analog ore
#

sacrificing memory

ivory sleet
#

Maybe you want that but it looks a bit fragile from my pov

analog ore
#

it does

#

i'll rethink the structure

#

but it was intended to run purely with redis

drowsy helm
#

also is the AdderTaker field just a incrementation interface?

ivory sleet
#

Fair Wertik I guess in that case

analog ore
drowsy helm
#

gotcha

analog ore
#

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

ivory sleet
#

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

analog ore
#

yh

#

that feels smoother and more solid

ivory sleet
#

Yeah but I haven’t read your code thoroughly so only you can determine what’s best πŸ˜„

pastel stag
#

@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);
}

}

analog ore
#

it definitely made my think about my approach

#

I knew the OOP was memory inneficient and overkill

drowsy helm
#

also definitely make an interface for your objects you want to be serialized

analog ore
#

yup.

#

didn't need it yet

drowsy helm
#

yeah you're sorta just relying on the person to implement what is needed

ivory sleet
#

But back to your original question, if you have enough ram, definitely directly cache in the jvm short term at least (:

drowsy helm
#

looks good otherwise though

analog ore
#

yeah

#

thanks for you time guys

idle grotto
drowsy helm
#

all good lol

drowsy helm
pastel stag
#

so this is the line that is broken in the main class getServer().getPluginManager().registerEvents(new Join(), this);

drowsy helm
#

new Join(this)

analog ore
#

you need to pass a FriendsHandler instance into the constructor

analog ore
#

based on the naming

drowsy helm
#

ah yeah

pastel stag
#

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); ?

tardy delta
#

should i save locations into Json?

pastel stag
#

then the ide just tells me that constructor Join() is undefined

drowsy helm
#

no need

pastel stag
#

so also add public Join join; ?

drowsy helm
#

or you can just make your own serializer into a single string

ivory sleet
#

Just invoke serialize() and then Gson most likely will know how to handle it

drowsy helm
#

unless you plan on acessing it later

pastel stag
#

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

drowsy helm
#

can i see all your code in Join

pastel stag
#

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);
}

}

analog ore
drowsy helm
#

yep

pastel stag
#

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);
}

}

drowsy helm
#

looks fine to me

#

also lower camel case

#

so "friendsHandler"

#

oh i see

#

you aren't declaring a new friendHandler in your main

ivory sleet
#

Will probably have to create a delegating World -> CraftWorld serializer

pastel stag
#

sooooo this.friendshandler = new FriendsHandler(this);

#

added to main?

drowsy helm
#

yep

pastel stag
#

ok. that works

analog ore
pastel stag
#

but i also have no fucking idea what i did or why it works now

#

lmao

drowsy helm
#

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?

pastel stag
#

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

drowsy helm
#

right

pastel stag
#

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

drowsy helm
#

ah okay

#

so you don't understand the null exception it was giving you right

pastel stag
#

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

drowsy helm
#

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

analog ore
#

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

drowsy helm
#

^ 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

pastel stag
#

so in Join.java in my case the this.friendshandler = friendshandler; creates an 'instance' of the FriendsHandler class?

drowsy helm
#

well the new FriendsHandler(this); creates the instance

#

you are just passing that instance through the constructor

pastel stag
#

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

drowsy helm
#

we all start somewhere man

analog ore
#

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
drowsy helm
#

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

pastel stag
#

So do the instances of classes always need to be created in the Main class as well?

drowsy helm
#

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

pastel stag
#

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

drowsy helm
#

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

pastel stag
#

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

drowsy helm
#

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

pastel stag
drowsy helm
#

never seen it but its a good project

pastel stag
#

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

drowsy helm
#

yo thats actually really impressive for 2 weeks of java lmao

#

database stuff is hard

pastel stag
#

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

drowsy helm
#

and yeah programming is just something that you can never know everything about

#

theres always something to learn

pastel stag
#

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

steady rapids
#

is there anyone who used serialization that can help me for about 10 mins?

drowsy helm
pastel stag
#

@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

steady rapids
#

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;
    }
}
quaint mantle
#

how can i respawn an entity by its uuid (i saved)?

drowsy helm
#

you can just use FileConfiguration.set(path, yourObject)

steady rapids
drowsy helm
#

oh you have to map your serialize method

#

to the actual fields

steady rapids
#

do u have an example?

drowsy helm
#

just create a map and for each variable set it as name, value

steady rapids
#

oh and then FileConfiguration.set and the load will work?

sour fog
#

sus

drowsy helm
#

a lot of people just make a manual methjod that serializes to a string instead

#

can be easier

#

yeah

steady rapids
#

thx

quaint mantle
#

can i somehow serialize and unserialize an entity class? to/from config

drowsy helm
#

also unrelated but if you want to reduce getter/setter methods oyu can use lombok

steady rapids
#

yeah never really used it tho

drowsy helm
#

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

quaint mantle
#

Can i somehow save a whole NBTTagCompound from entity class?

eternal night
#

There are respective methods on the internal entity representation

mystic terrace
#

How I can add Subcommands to the plugin.yml?

eternal night
#

Sub commands are not added to the plugin.yml

mystic terrace
#

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) [?:?]```
hasty jackal
#

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

mystic terrace
#

it is alredy

hasty jackal
#

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

mystic terrace
#

can I send you a paste bin?

trail flume
#

Is there a way to stop Spigot deleting empty config paths?

eternal night
#

?paste

undone axleBOT
hasty jackal
#

I saw your forum post, I've already seen your code. Again, are you sure you're passing in the right string?

mystic terrace
#

I'm just followingn forums, posts and tutorials

mystic terrace
#

And doing exactly what they said and I'm the only one who has this problem πŸ€·β€β™‚οΈ

mystic terrace
#

because I don't know what I'm doing bad

hasty jackal
#

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

quaint mantle
#

null

#

it was null

#

i used if and else if

#

same problem

#

is there any other way to check the server's version ?

mystic terrace
#

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");
            }
        }

    }```
drowsy helm
#

do you ever check for the reload arg

mystic terrace
drowsy helm
#

you are only checking perm

#

where do you check if its the correct argument

mystic terrace
eternal oxide
#

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

mystic terrace
#

how I can fix it then?

eternal oxide
#

what command are you typing and what do you expect it to do?

mystic terrace
#

It's a subcommand (/logintitle reload) and basically it realoads the congif.yml file.

eternal oxide
#

ok

quaint mantle
eternal oxide
#

so the actual command is logintitle the sub command (args) is reload

mystic terrace
#

yup

#

I have help command tho, and it works

eternal oxide
#

so in your executor for logintitle you need to see if args > 0 then check "reload".equalsIgnoreCase(args[0])

mystic terrace
#

the reload one it's the one that doesn't work

eternal oxide
#

is yoru help command /logintitle help ?

mystic terrace
#

yup

eternal oxide
#

then show us your logintitle command executor code

mystic terrace
#

?paste

undone axleBOT
eternal oxide
#

I don't need an essay, just show the code

eternal oxide
#

?paste

undone axleBOT
mystic terrace
#

My bad

eternal oxide
#

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?

mystic terrace
#

it doesn't run

eternal oxide
#

directly?

mystic terrace
#

mb

#

It doesn't run, thts all

eternal oxide
#

ok, there can only be one possible cause. You do not have the permission logintitle.reload,

mystic terrace
#

Lemme check

eternal oxide
#

your code has no issues. Its oddly designed but there are no bugs

mystic terrace
#

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?

eternal oxide
#

yes

#

in plugin.yml you can add a permissions section

#

not a direct command permission, but a full permissions section

mystic terrace
#

doesn't works, I added the permission in Luckperms

#

I think the problem it's this part of the command

eternal oxide
#

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

eternal oxide
#

well spacing

#

String[] args

#

change the name() method to just return a String in the reload command

mystic terrace
#

imagine that was the mistake

eternal oxide
#

that will eliminate any issue with yoru plugin instance

mystic terrace
eternal oxide
#

you have the same space issue in yoru SubCommmand class

eternal oxide
mystic terrace
#

oke, let's test

halcyon mica
#

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

eternal oxide
#

Why extend it? it has every BlockFace you could need

mystic terrace
eternal oxide
mystic terrace
eternal oxide
#

ok

#

and you fixed the spacing in SubCommand and reload?

mystic terrace
eternal oxide
#

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

eternal oxide
#

just check the permission. Don't care about op

mystic terrace
#

nope

#

nothing

#

doesn't works

eternal oxide
#

you get no output at all using /logintitle reload ?

mystic terrace
#

yup

eternal oxide
#

?paste your new reload class with the permission debug in it

undone axleBOT
mystic terrace
#

Oke, i think now I know why it's not working

wide coyote
#

delete the first if statement and see

mystic terrace
#

basically, for no readon the plugin its not creating the config.yml file

#

when i didn't touched that part of the code

halcyon mica
#

I am talking about the BlockPathType

#

Which defines what kind of surface a block is

#

i.e. water border, danger, damage, trapdoor etc

mystic terrace
#

ElgarL i think I found the error

eternal oxide
mystic terrace
#
 createFiles();
 instance=this;
eternal oxide
#

createFiles() is not in the paste you showed of yoru LoginTitle class

#

delete that method

#

just add saveDefaultConfig()

mystic terrace
eternal oxide
#

at teh top of your onEnable

mystic terrace
serene narwhal
#

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

eternal oxide
mystic terrace
eternal oxide
#

Yep, delete line 12 and 21

#

its the only thing left it can possibly be

mystic terrace
#

finally omg

#

thank you so much ^^

eternal oxide
#

now you have to work out why your args is not empty is all

mystic terrace
#

it works 100%

halcyon mica
#

Here's a question, is it even possible to make a entity pathfind with ladders

ivory sleet
#

Hmm doesn’t spiders do that?

#

Or well

#

I guess not ladders

quaint mantle
#

spiders start climbing as soon as they touch one or more blocks on any side

echo basalt
#

write your custom pathfinder

halcyon mica
#

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

solar sable
hollow haven
sick portal
#

Hey everyone, how do you handle players count in a multi-velocity / multi-bungee env ?

tardy delta
#

how the heck can player.getLocation() be null?

hasty prawn
#

If player is null

tardy delta
#

well i'm there

#

it started when i was sitting on a horse

hasty prawn
#

Wdym

tardy delta
#

well maybe then my location changes i dunno

#

from that point i requested my location

#

lemme just restart the server

ivory sleet
#

@quaint mantle

quaint mantle
#

so

ivory sleet
#

create a thread

#

btw

#

πŸ˜„

quaint mantle
#

ok

ember crag
#

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?

solar sable
#

guys how to use json text format in plugin?

tardy delta
#

gson?

vernal pier
#

Text components u talking about ?

quaint mantle
quaint mantle
#

I'd personally recommend the adventure api over the bungeecord components ^

eternal oxide
#

This is Spigot not Paper

quaint mantle
#

adventure works on spigot too

eternal oxide
#

Its not in Spigot though. So recommending it (a competing product) is not appropriate.

quaint mantle
#

you can shade it into your plugin Β―_(ツ)_/Β―

solar sable
#

i mean paper is just basically spigot, but runs smoother

eternal oxide
#

This is spigot though. He asked in a spigot discord about json in chat so I recommend the spigot chat API.

solar sable
#

paper is literally nothing but just to make the server run smooth lol

opal juniper
#

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

quaint mantle
#

it's not "sub api" πŸ™ƒ

opal juniper
#

meh im gonna call it that

#

its made by the same people

quaint mantle
#

eh

opal juniper
#

i was expecting a longer message lol

tardy delta
#

isnt it possible to call the super-super class sonstructor?

opal juniper
#

mmm idk

#

probably not

tardy delta
#

it doesnt work

#

sadly

quaint mantle
opal juniper
#

I mean that is a fair point

#

but im seeing some uncanny similarities lmao

#

dependabot πŸ‘€

tardy delta
#

mwoa

quaint mantle
#

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

tardy delta
#

does anyone knows when static {} is called?

tall dragon
#

when the class is loaded by JVM

solar sable
#

do anyone know how to do a hover event on onPlayerJoin event?

quaint mantle
tardy delta
#

oh

solar sable
quaint mantle
tardy delta
quaint mantle
solar sable
tardy delta
#

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?

solar sable
#

maybe

#

scheduler?

tardy delta
#

yea that

solar sable
#

oh

eternal oxide
#

?scheduling

undone axleBOT
solar sable
#

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

trail flume
#

Is there a way to stop Spigot deleting empty config paths?

quaint mantle
#

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 ?

glass sparrow
#

Has anyone ever used Jython inside a Java program? If you have please let me know

vague oracle
paper viper
#

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

glass sparrow
#

Yeah, I was wondering how to compile a python function and then run it later in my java code

glass sparrow
quaint mantle
vague oracle
#

πŸ™‚

hollow haven
#

Saving custom block to a json

quaint mantle
#
public static HashMap<Player, List<Integer>> hololist = new HashMap<>(); 

will this work if i get the list, modify it and set it ?

young knoll
#

You don't need to set it

quaint mantle
#

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 ?

young knoll
#

You don't even need to set it

quaint mantle
#

so what

young knoll
#

Just get the list and modify it

gritty urchin
#

What is the maximum amount of block updates I can send to a client a second

eternal oxide
#

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

gritty urchin
#

So would 20 - 30 block updates be possible for one block position?

hollow bluff
#

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?

gritty urchin
#

If sent async

gritty urchin
#

What is the plugin

hollow bluff
#

?paste

undone axleBOT
hollow bluff
#

That's the error that comes for when I start the server for the first time, but it all works fine after /rl?

eternal oxide
#

WorldLocationUtility.java:166

hollow bluff
#
Location loc = (Location) arenaConfiguration.getArenaConfig().get(getSelected() + ".traitorTester.testerSpawn");```
eternal oxide
#

one of those is null

hollow bluff
#

But why would it work fine after /rl and not other?

eternal oxide
#

arenaConfiguration or getArenaConfig() or there is no entry in that config for getSelected() + ".traitorTester.testerSpawn"

#

you initialize it at some point

#

what is getSelected()?

hollow bluff
#

the getSelected() thing is used in a method that is in the enable thing

eternal oxide
#

lots of things, tells me nothing

hollow bluff
#

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

eternal oxide
#

yeah none of that tells me specifically what getSelected() does

hollow bluff
#
public String getSelected() {
        String result = "";
        return result = String.join("", selectedMap);
    }```
eternal oxide
#

ok

hollow bluff
#

like everything does work after /rl but not when first started

#

doesnt really make sense to me

eternal oxide
#

what is selectedMap?

hollow bluff
#

public List<String> selectedMap = new ArrayList<>();

eternal oxide
#

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

hollow bluff
#

not sure how to fix that tho

eternal oxide
#

that means the world is not yet loaded

quaint mantle
#

can we edit an entity by the id ?

#

for example EntityArmorStand

opal juniper
#

I meean you can use the UUID

#

World#getEntity(UUID) iirc

quaint mantle
opal juniper
#

oh

quaint mantle
#

nms

#

modify

#

an existing entity

opal juniper
#

Modify what

quaint mantle
#

for example updating it's display name

#

armorstand

hollow bluff
# eternal oxide that means the world is not yet loaded

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)); }

eternal oxide
#

it takes time for a world to load

#

its not instant

quaint mantle
pallid tiger
#

Hi, have a small problem :/ So, maven cannot resolve spigot dependency for 1.17.1, any thoughts?

hollow bluff
#

its 1.17 I think

eternal oxide
#

spigot or spigot-api?

pallid tiger
#

spigot-api

eternal oxide
#

show your pom

#

?paste

undone axleBOT
pallid tiger
eternal oxide
#

looks fine, other than your source/target

#

1.7?

opal juniper
#

bit weird

#

old

pallid tiger
#

lemme check

opal juniper
#

and random

eternal oxide
#

InteliJ or eclipse?

pallid tiger
#

vscode

eternal oxide
#

ah

#

good luck

pallid tiger
#

hah, thanks ❀️

eternal oxide
#

However, nothing wrong with your pom. Can't help you with vs though

pallid tiger
#

np

quaint mantle
#

I'd recommend using a proper IDE like IntellIJ or Eclipse

quaint mantle
#

i also would like to say that IntelliJ is superior for features, customization and syntax highlighting

#

but eclipse is faster if you care

young knoll
#

?jd

dire marsh
#

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.

shadow pulsar
#

What to Use Instead of Static

dire marsh
#

that just sets the url

#

and brings up the "recommends" screen

young knoll
#

Correct

#

You can’t force them to accept it

dire marsh
#

you can tho

#

if you monitor the resourcepack status event

#

I want to show this from the API

young knoll
#

Not sure if you can do that without setting the option in server.properties

dire marsh
#

sad

quaint mantle
#

Paper has API for this

dire marsh
#

kekw

quaint mantle
#

Pretty sure you can't do it with API in Spigot

dire marsh
#

paper strikes again

#

guess I'll have to add a paper check and only enable it on paper servers (otherwise fallback to spigot api)

grand bronze
#

I'm really having trouble creating 3 nested loops over X,Y, and Z any tips?

dire marsh
#

you trying to get blocks in a radius?

grand bronze
#

yes

quaint mantle
#

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
grand bronze
#

trying to make neighboring blocks do the same thing as the first block

quaint mantle
#

also should be allowedEntities according to naming conventions

#

also should be a getter

dire marsh
#

@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 } } }

grand bronze
#

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

quaint mantle
#

add +

#

between the ChatColors

opal juniper
#

ChatColor1 + "" + ChatColor2

digital kettle
quaint mantle
#

Or you could you do ChatColor.translateAlternateColorCodes('&', "Message")

opal juniper
#

you need to add a whitespace

digital kettle
#

i suggest you to use translateAlternateColorCodes or Β§

#

"Β§cHello"

opal juniper
#

DONT USE THIS

quaint mantle
hasty prawn
#

Definitely use translateAlternateColorCodes

young knoll
#

I mean you should be using the enum constants

hasty prawn
#

I'd use them if they weren't so terrible to work with

quaint mantle
#

in plugin.yml, add aliases: [ youraliashere ] to the command

#

Add a aliases: [aliasCommand] to the command in plugin.yml

robust jolt
#

Hello, how i can check if block placed is a tnt?

#

I use this event: BlockMultiPlaceEvent

young knoll
#

BlockPlaceEvent

formal dome
#

hey guys, what is a commandsender?

young knoll
#

A sender of a command

glossy barn
#

Since MultiBlockPlaceEvent inherits from BlockPlaceEvent, you can call getBlockPlaced() without having to modify your existing code

young knoll
#

I don't think the multiplace event will fire for tnt

robust jolt
young knoll
#

Get the material and compare it to Material.TNT

formal dome
#

when does BroadcastMessageEvent trigger?

#

nvm nvm

#

i'm not dumb i can read docs xD

quaint mantle
#

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?

carmine nacelle
#

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

burnt rapids
#

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)

unreal quartz
unreal quartz
quaint mantle
carmine nacelle
#

Would I need to make all of my methods static in my dependency plugin?

ivory sleet
#

No dont do that

carmine nacelle
#

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);

unreal quartz
#

not.. entirely sure what you're trying to do?

carmine nacelle
#

I need to use Plugin A as a dependency for plugin B

#

and be able to get the methods from A in B

unreal quartz
#

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

carmine nacelle
#

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)

unreal quartz
#

compile it and add that as a dependency

carmine nacelle
#

Yeah, it already is one

#

do I gotta remove and readd?

#

using it as a jar dependency right now

unreal quartz
#

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

sullen marlin
#

lame

carmine nacelle
#

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.

grand bronze
#

how would I specify what blocks I want to affect within a loop

quaint mantle
#

add them to an enumset

grand bronze
#

alright time to figure out what the fuck that is

quaint mantle
#
Set<Material> allowBlocks = EnumSet.of(Material$1, Material$2...);

for (...) {
    if (!allowBlocks.contains(block.getType()) {
        continue;
    }
    // ...
}
formal dome
#

when creating a new event what should i think about when trying to define my set of <CommandSender>'s

quaint mantle
#

?

ivory sleet
#

Why CommandSender

formal dome
#

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

ivory sleet
#

😬

formal dome
#

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?

ivory sleet
#

Idk

#

Only if an event callback fails Ig?

#

But then you’d be prompted with a stacktrace

formal dome
#

hmmm

#

time to dive deeper into the docs

ivory sleet
#

Anyways

#

If you just wanna send a message to every player online

#

Don’t use broadcastMessage lol

formal dome
#

nah that's not my goal

#

my goal is to take broadcasted messages and post them to my discord channel for my server

ivory sleet
#

Oh

#

Well in that case

#

Then just listen for the event and send to the discord message channel?

formal dome
ivory sleet
#

Why

formal dome
#

i don't know how to connect the event to the eventlistener

ivory sleet
#

You don’t need any jda event listeners if your only goal is to send a message to a channel with JDA

lost matrix
ivory sleet
#

^

formal dome
#

.ohhh

#

yeah that makes sense i think

hollow bluff
#

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?

lost matrix
hollow bluff
#

nah

#

1.8 is kinda better tbh

#

for what I need

lost matrix
# hollow bluff nah

Well... then you have to live with the handicaps an very outdated piece of software comes with 🀷

hollow bluff
#

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?

young knoll
#

Use == for enums

grand bronze
#

this enum shit got me re-thinking my life

trail remnant
#

does anyone know how to set someone balance with the vault api?

lost matrix
austere bone
#

hey! might be a simple question, but, how do you create a repeated task to run every hour?

trail remnant
lost matrix
lost matrix
trail remnant
#

sorry, i dont know how i would do that πŸ˜… is there a documentation or something?

lost matrix
trail remnant
#

i dont see any way to set a balance on there though?

lost matrix
lost matrix
trail remnant
#

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

austere bone
lost matrix
austere bone
#

ahhh okk tyy

lost matrix
#

Example:

Trigger trigger = TriggerBuilder.newTrigger()
  .withIdentity("myTrigger", "group1")
  .startNow()
  .withSchedule(SimpleScheduleBuilder.simpleSchedule()
    .withIntervalInSeconds(40)
    .repeatForever())
  .build();
austere bone
#

niceee

native nexus
#

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

#

I have the latest version of spigot via the build tools.

lost matrix
native nexus
#

Is there no way for them to update the GSON version?

lost matrix
#

There is but it needs extensive testing first.

lost matrix
native nexus
#
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

lost matrix
#

What are you trying to serialize?

native nexus
#

I think I know what the issue is

#

I am trying to deserialize arenas into a manager

lost matrix
#

Yeah but how do the fields look like?

native nexus
#
    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
lost matrix
#

How dows your Arena class look like?

native nexus
#
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<>();
    }
lost matrix
native nexus
#

I did before but changed it

#

ill revert it back

#

It is because I wanted to have the name inside the arena class

lost matrix
#

Arena.class

lost matrix
#

But also use it as a key mapping

native nexus
#

Yeah

lost matrix
#

Nice to see proper manager classes for once

native nexus
#
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

lost matrix
#

It does. Could you pls show your Arena.class or at least the fields

native nexus
#
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)

lost matrix
#

Ok looks fine. I just suspected that you have a non transient ArenaManager class in there which would cause a StackOverflow

native nexus
#

Oh haha no way

#

Changing it from a Set to a Map fixed it

#

Really bizarre...

lost matrix
#

Ok nice. Btw take a second look at your TypeToken

native nexus
#

Yes (UUID)

#

Should be name πŸ˜›

#

(string)

#

Thank you!

#

Actually I am getting the same error again hmm

lost matrix
#

Eh... how does the full stack trace look like?

native nexus
#

Wait no this is a new error

#

This is in the SpleefManager class

lost matrix
#

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;

native nexus
#

Didn't think of that

#

lobby = Json.read(plugin, "lobby", Location.class); Let me guess I can't serialize a bukkit location

lost matrix
#

It holds a reference to a World i think.

native nexus
#

Yeah it does

#

Are references transient?

#

It doesn't look like it.

lost matrix
#

Not sure how Gson handles this

native nexus
#

I might have to create my own encapsulation class...

lost matrix
#

Or just write a custom Serializer and register it with Gson

native nexus
#

I haven't written one before any documentation on that?

lost matrix
#

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();
golden turret
#

json

native nexus
#

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?

worldly ingot
#

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

formal dome
#

how do i register a plugin with spigot?

#

oops

#

i mean eventlistener

lost matrix
formal dome
#

with the current instance of spigot

#

or would it be an instance of bukkit

native nexus
#

Alright thank you for the feedback!

golden turret
#

using variables in lambda: AtomicReference

#

or something with a name like this that i forgot

lost matrix
# formal dome with the current instance of spigot

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);
  }
formal dome
#

okay

#

was about to say do i need to create an instance of my plugin within the plugin

lost matrix
#

You get one single instance of your JavaPlugin class and you need to distribute it to the places which need it.

golden turret
#

?di

undone axleBOT
quaint mantle
#

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)
native nexus
quaint mantle
#

Oh 😦

#

Is there another way to do it?

golden turret
#

until you get a real solution, try REPLACE INTO

worldly ingot
#

Or ON DUPLICATE KEY if your name is a unique key

quaint mantle
#

It's

#

I'll try both

#

Ty

golden turret
#

replace into is not performatic

#

but works

lost matrix
quaint mantle
#

Tried ignore and on conflict

golden turret
#

but

#

you want to update their cash, right?

quaint mantle
#

I want to do upsert

#

Insert if not exists

golden turret
#

ok

quaint mantle
#

If it does update it

golden turret
#

got it

#

i personally use a simple system

#

where i call the methods

quaint mantle
#

2 statements, right?

golden turret
#

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

lost matrix
# golden turret where i call the methods

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.

golden turret
#
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```
lost matrix
golden turret
#

no

#

i will send you an example

quaint mantle
golden turret
#

ok

#

and you will

#

only 1 of the 3 queries will be used

lost matrix
#

Yeah that looks fine. Can also help with batching.

golden turret
#

i think that it is beautiful :3

lost matrix
#

Btw you should check this out:

#

Get away from those pesky error prone String queries

golden turret
#

im planning into add something like that in wlib

#

wlib 🀀

native nexus
#

Is there a repo for wlib?

golden turret
#

:3

lost matrix
#

1.8 😬 πŸ”«

golden turret
#

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

formal dome
#

@lost matrix so now that i have my event listener registered. where do i put my code to handle that event?

native nexus
#

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
lost matrix
golden turret
lost matrix
worldly ingot
#

Not to mention plugin command attribution

native nexus
#

I don't like ACF that much

golden turret
#

i never heard about acf

#

i use the command system of wlib 😎

native nexus
#

Eh annotations...

lost matrix
native nexus
#

I just use my own command class.

golden turret
#

or

#

CommandExecutor

native nexus
#
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
quaint mantle
#

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

golden turret
#

and about the nms

#

you cant deobfuscate

quaint mantle
#

w

#

πŸ’€

lost matrix
# native nexus ```JAVA public abstract class CommandBase extends Command implements Registry { ...

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);
  }

}
golden turret
native nexus
#

The command completion/context resolvers is quite nice.

paper viper
#

I prefer builders over annotations xD

#

like each class is like a subcommand and stuff

#

doesn't matter tho

native nexus
#

Me too!

grand bronze
#
  for (double x = start.getX() - 5; x <= start.getX() + 10; x++)
#

how would I actually set a radius with this

lost matrix
grand bronze
#

int?

paper viper
#

doubles in a loop 🀑

grand bronze
#

😦

#

I'm new I apologize

lost matrix
# grand bronze how would I actually set a radius with this

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;
  }
formal dome
#

@lost matrix does my plugin have to implement listener or do i have to implement listener in a separate class

lost matrix
# grand bronze int?

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());
  }
native nexus
#

You implement listener in the same class as where you have your eventhandler method

young knoll
#

That is horrible

lost matrix
paper viper
#

i just realized there are two .flatMap calls lmao

lost matrix
paper viper
#

seems super inefficient kek

lost matrix
#

But its technically a one liner. πŸ˜„ which is much more important than performance.

golden turret
#

yes!

lost matrix
golden turret
#
@Override public void onEnable() { getLooger.info("Hello!"); Bukkit.getPluginManager().registerEvents(this, this); }```
golden turret
golden turret
#

at my screen 3 simple ifs starts to side scroll

young knoll
#

getLooger

quaint mantle
#

getLooger

ancient plank
#

getLooger

pastel stag
#

heh

quaint mantle
#

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.)

pastel stag
#

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

pastel stag
#

@quaint mantle instructions unclear, dick stuck in blender

quaint mantle
pastel stag
#

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

quaint mantle
pastel stag
#

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

quaint mantle
#

idk or you can use mongoDB, hypixel uses mongoDB.

pastel stag
#

have you ever seen how coreprotect numbers their block data with a row id?

quaint mantle
#

LMAO i give up

pastel stag
#

like so

quaint mantle
#

im new

pastel stag
quaint mantle
#

i dont know

pastel stag
#

im basically trying to do the rowid part of that

quaint mantle
#

um the row id seems to be working alright

pastel stag
#

the rowid that i linked, i'm trying to accomplish that w/ my own plugin

#

it just counts, idk if that makes sense lol

quaint mantle
#

before adding row to database, get last lowID. add 1 and insert to DB.

#

rowid counting?

pastel stag
#

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

quaint mantle
#

lol we are all new

#

LOL

#

goodbye

young knoll
#

You can set your ID to auto increment

formal dome
#

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());

    }
}
lost matrix
lost matrix
lost matrix
formal dome
#

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

lost matrix
golden turret
#

it could have something like

#
  • url: url
    somethingiforgot: com.examble:example:1.0.0
quaint mantle
lost matrix
quaint mantle
ancient plank
#

maps and servers are not the same thing but u do u bro

paper viper
#

lol

quaint mantle
#

same point, just balancing for availabilit.

lost matrix
# quaint mantle 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?

quaint mantle
#

a bunch of big separated machines.

#

200 8Core backend, 5 proxy

#

example *

lost matrix
#

Sure but what is your server model?

quaint mantle
#

each server run around 4 to 8 servers.

lost matrix
#

Do you host your servers in the cloud (AWS for example)

quaint mantle
#

bare metal, or so called home host.

lost matrix
#

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.

quaint mantle
#

i have fixed hardware, and i want it to balance for available software.

lost matrix
#

Ok then you probably want nginx with a reverse proxy setup that leverages the load
between your bungee proxies using a round robin distribution.

quaint mantle
#

wwwwwWWwwW???????????

#

im confused

#

wh

lost matrix
#

One moment

quaint mantle
#

i know what you mean, but is not why i came here for.

#

i have reverse proxy setup.

quaint mantle
quaint mantle
lost matrix
#

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)

quaint mantle
#

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…

lost matrix
#

Thats why i asked for a server model...

quaint mantle
lost matrix
#

This above would work for something like Wynncraft

quaint mantle
spare marsh
#

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?

lost matrix
quaint mantle
lost matrix
spare marsh
lost matrix
quaint mantle
#

and a lot of other resources i found.

native nexus
#

This report is from 2014

lost matrix
#

Yeah i know this paper. Its from 2014 and pretty much proves my point. Docker is even faster than kvms.

native nexus
#

Technology has changed a lot since then

quaint mantle
lost matrix
quaint mantle
#

dm me

lost matrix
lost matrix
#

Should be public now

quaint mantle
#

hmm

#

.java files?

native nexus
#

clone it and run it

#

easy peasy

quaint mantle
#

alright

native nexus
#

Also mandelbrot πŸ‘€

lost matrix
#

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

quaint mantle
#

:D

lost matrix
# native nexus Also mandelbrot πŸ‘€

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.

native nexus
#

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 πŸ˜†

lost matrix
native nexus
#

Yes I recommend utilizing the GPU omg

lost matrix
#

But i got a curse for KUDA and Shader programming coming up 😍

native nexus
#

My friend and I while we were at university made procedural terrain generation with compute shaders for our game.

#

Shader Programming is πŸ‘‰ πŸ‘Œ

formal dome
#

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

native nexus
formal dome
#
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

lost matrix
formal dome
#

wasn't sure which libs i needed in there tbh

native nexus
lost matrix
#

Anyways im out for now. BB

native nexus
#

Cya

formal dome
#

peace

carmine nacelle
#

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

native nexus
#

It might be because it is registering left and right click/

#

There is a fix for that but I can't remember

carmine nacelle
#

I have it checking if its left only, still fires twice

young knoll
#

Have you restarted the server

carmine nacelle
#

it shouldnt fire twice though cause left/right is separate in that

#

yes

#

I would expect both to send twice if that was the issue

#

oh..

#

ok im just retarded.

#
        setupProtocolLib();
        registerClassInstances();
        loadConfigs();
        registerListeners();
        registerCommandExecutor();
        registerListeners();