#help-development

1 messages · Page 1860 of 1

quaint mantle
#

like loc.toVector() or something

chrome beacon
#

You can do loc.toVector

#

It's a thing

quaint mantle
#

wait a minute

#

I had the wrong import

#

dang it

#

srry for wasting time lol

naive loom
#

Anyone? Still getting same issue.

quaint mantle
#

Bruh I cant get it to compile and am too lazy, Can someone compile for me and i will send u like $5, dm

dusk flicker
#

Should just be able to cancel the event

quaint mantle
#

Fr just need to compile exactly whats on it github into a jar

trim surge
#

Just click the spigot link and download?

quaint mantle
quaint mantle
#

I hired someone to make the og plugin and lost his contact, I was able to update API myself as its fr just changing from "V4" to "V6"

low temple
#

You can look up what the bat file should look like

quaint mantle
#

Just need someone who can recompile it for me and will gladly throw you like $5.

trim surge
#

What’s your issue with compiling?

#

Any errors?

quaint mantle
#

I just don't know how to, Don't understand the guide, and am honestly too lazy to 😂

low temple
#

What IDE r u using @quaint mantle

trim surge
#

Is it maven or Gradle?

quaint mantle
#

I just want to honestly have someone compile it for me and i will pay u

trim surge
#

Does it have a pom.xml or a build.Gradle

quaint mantle
#

none

trim surge
quaint mantle
low temple
#

You want someone to give you a fish rather than learn how to fish?

quaint mantle
#

Yep

#

LOL

low temple
#

I would but I’m not home

paper viper
#

You can observe the code and learn from it

quaint mantle
#

Honestly never gonna have to update it for a while, It would still be working right now but they changed the endpoint. No real interest in learning java.

low temple
#

Understandable

#

When I get home I can compile it for you if someone else doesn’t

quaint mantle
#

Bet just shoot me a dm

undone axleBOT
echo basalt
#

How can I make a horse completely uncontrollable?

#

I'm adding custom controlling behavior but it's somewhat conflicting

#

Even after overriding its ControllerMove, it still walks and stops weirdly

wet breach
#

if you don't want the game to control the horse, disable its AI and then use your code to make it move how you want it to?

echo basalt
#

Even after removing all custom and manual control, it still acts weirdly

wet breach
#

then don't let it move

#

cancel its movements

echo basalt
#

That's not entirely easy

#

Horses are entirely weird when a player is on them

wet breach
#

it could be more of a client side thing then a server side thing

echo basalt
#

Odd, I'm using the same exact code to control other entities and it works

wet breach
#

most other entities are not by default ridable either

echo basalt
#

I might have to make a lockable movement controller 🤔

wet breach
#

it could be that the client is sending packets as if its the player making it move but really its not. I would have to look more in the code, but this could be the reason you are having a hard time keeping it from moving

echo basalt
#

movement kinda works but it's really trying not to

#

Seems like it's resisting moving

old elbow
#

heyo, im new to the server and have been really interested in coding plugins. ik u guys probably get annoyed by all the newbies lol, but i have basic java knowledge. i figured hey, why not practice my coding through something that i enjoy playing!

#

ive watched several tutorials, looked through the api, went to the spigot website, but i cant seem to grasp any of it... more of me just looking at a blank project with the spigot library referenced

echo basalt
#

What have you tried so far?

old elbow
#

does anyone have any tutorials for beginners?

old elbow
echo basalt
#

Alright

#

Think of a plugin idea

old elbow
#

I have three

#

block shuffle, i know it already exists, but i would like to make my own version with a few tweaks and stuff

#

then one where if any of the players in a multiplayer world die, all of the players die. like a hardcore thing kinda

#

and the other one was you explode if you're touching grass

echo basalt
#

Alright

#

What's the first one you'd like to do?

old elbow
#

block shuffle

wet breach
old elbow
#

yeah:)

echo basalt
#

I don't entirely remember what block shuffle is

old elbow
#

i can give u a brief description

echo basalt
#

Wasn't it that thing where each block had its own drop?

stone sinew
old elbow
echo basalt
#

ah

#

Yeah that might be a little tougher to make

stone sinew
#

It's gets faster every new block

echo basalt
#

Ideally we want something simple to start with

old elbow
#

would the explosion one be simpler?

stone sinew
#

Simplicity is up to you.

echo basalt
#

Explosion is quite simple to make

#

So where would you start?

old elbow
#

the lag, i assume, would be insane no?

echo basalt
#

Not necessarily

old elbow
#

hmm okay

old elbow
#

where are they standing? on what type of block?

echo basalt
#

Isn't that a bit easier to handle when a player moves across blocks?

#

Doing that on a timer seems wasteful

old elbow
#

that is true'

echo basalt
#

But make sure it only checks when a player moves across blocks

old elbow
#

so every time a player moves, check what new block it's on

echo basalt
#

Otherwise you'll waste performance checking blocks multiple times

old elbow
#

yeah

echo basalt
#

Alright

#

Do you know how to register a listener?

old elbow
#

not necessarily

#

can we vc?

echo basalt
#

Uhh it's like 2am and my mic is acting up

#

Let me try something

old elbow
#

okok

wet breach
#

easiest way to do block shuffle is to first design a way to set the playing field or boundaries of the game. Once you know the boundaries you know all the blocks in said boundary. Then depending on you want to make the game floor, you keep a list of all the approved blocks allowed to create the floor. You would hold this in a map so you can reference it. Then its just a matter of randomly choosing in that list the blocks that players need to stand on or not stand on and then check all players in the field which blocks they are on. As the game goes through you just remove from your map the blocks in the game. All the rest of the code will just be to either add some features or block players from cheating like being able to place a block XD

echo basalt
#

This guy barely knows what a listener is, let's not get into minigames :)

wet breach
#

lol

stone sinew
#
@EventHandler
public void onMove(PlayerMoveEvent e) {
    if(e.getTo().getBlockX() == e.getFrom().getBlockX() && e.getTo().getBlockZ() == e.getFrom().getBlockZ()) return; // if the player hasn't moved from the block it won't run the code below.
    Player p = e.getPlayer();
    Location l = p.getLocation();
    
    if(l.clone().subtract(0,1,0).getBlock().getType() == Material.GRASS_BLOCK) {
       // l.getWorld().spawnExplosion()
    }
}
```written on my phone, pseudo code.
fleet imp
#

how do i get the dimention a player is in

old elbow
echo basalt
#

Yapper, we're trying to help someone, not spoonfeed

wet breach
fleet imp
#

oh thx

wet breach
#

or Player.getLocation().getWorld();

#

one of those two or both should work 😛

stone sinew
old elbow
echo basalt
#

also your code doesn't account for falling into grass

old elbow
#

so i'd unfortunately be copy pasting

echo basalt
#

But still

wet breach
#

while you want to be helpful in that way @stone sinew it is probably first best that we get them on a path to learning the basics/fundamentals first before showing code like that since they are new, very new.

stone sinew
echo basalt
#

Have a read, let me know if you don't understand anything in specific

stone sinew
# old elbow thanks, but honestly i have no idea what im looking at lol

Method name and what event is being accessed. PlayerMoveEvent

Checking if the player has moved to a different block via x and z coords. You can add y coord too but others will just complain that it's missing instead of just adding it lol

Setting variables for player and their location

Checking the block below the player if it's a grass block.

Spawn an explosion.

fleet imp
echo basalt
stone sinew
fleet imp
#

ok thx

wet breach
#

getName() is if you need the name of the world, getWorld() if you need that world's object

#

?jd

wet breach
#

if you need to look at some java docs where you can search

lusty cipher
#
        if (nbtFile != null && backupNbtFile != null && temporarySwapFile != null) {
            temporarySwapFile.delete();
            backupNbtFile.save();
            if (!backupNbtFile.getFile().renameTo(temporarySwapFile)) {
                throw new IOException("Failed to rename backup NBT file.");
            }

            if (!nbtFile.getFile().renameTo(backupNbtFile.getFile())) {
                throw new IOException("Failed to rename base file to backup file.");
            }

            if (!temporarySwapFile.renameTo(nbtFile.getFile())) {
                throw new IOException("Failed to rename temporary file to base file.");
            }

            temporarySwapFile.delete();
        }

Is this a good way to swap two files? I've had issues that nbtFile can get corrupted, and I think this way swapping the two files should fix that. Or is this bad?

wet breach
#

NBTFiles depending which ones can become corrupted when you assume it is not being used

old elbow
old elbow
#

@echo basalt so i read it through, makes sense

#

this is what im thinking.

#

set up the listener for PlayerMoveEvent()

wet breach
#

this way, if something goes wrong and needs to be corrected outside of the application, the files are there to do so

old elbow
#

nvm not sure haha

wet breach
#

you will need that event for sure

#

but there will be others you need too. You can put multiple event methods into a single listener just fyi however you can also have multiple listener classes to organize code easily 🙂

sonic osprey
#

Which web-hosting application for Ubuntu would be recommended?
...Apache2, NGINX, or a better alternative to the both?

dusk flicker
#

i prefer NGINX

wet breach
#

Apache2 or Nginx. Either or is fine just mainly down to preference unless there is something very specific you need from one or the other

dusk flicker
#

but apache is easier to start with imo

old elbow
lusty cipher
wet breach
#

More annoying when the application needs to create said files, but it is the thing failing XD

#

if this is just a personal project, I mean do whatever but if its a public plugin or something intended for others then probably best you look into that

lusty cipher
#

Yeah sure, I know what you mean

#

I was more or less just trying to replicate what minecraft does with its level.dat

#

it also only has level.dat and level.dat_old

#

and iirc it also just has a temp file it deletes

#

I think this should fix the file corruption issue anyway, even if it's not 100% the best solution

old elbow
#

can any of u vc? i feel like i can learn a lot better like that

#

i have no idea what i can do in return, maybe i could cashapp u like 20 bucks? idk

gentle oriole
#

I made a plugin with Spigot API 1.18.1 will it support 1.18 as well as older versions?

quaint mantle
#

Hello I am trying to add bstats into my plugin. Just a question, should the name of the plugin i give in bstats.org and the name in my plugin.yml be same?

valid sorrel
#

I had made a plugin for spigot that disables the "Illegal characters in chat" message, now it's saying "illegal characters in chat (charcode)," is the latter from bungeecord?

dusk flicker
#

are you running a bungee server?

valid sorrel
#

the only difference is installing bungeecord

#

before and after

dusk flicker
#

If it worked prior to installing bungee its gonna be on bungee's end then

valid sorrel
#

ok then

dusk flicker
#

dont have to be

#

should be your plugins name tho

quaint mantle
#

Thanks no wonder why its not updating

dusk flicker
#

Should just have to define it in the metrics class (whatever id it is)

steady herald
#

I have a null pointer in here and I cant seem to find it

public class OneRingUse implements Listener {
    @EventHandler
    public void RingPickup(PlayerInteractEvent event) {
        Player player = event.getPlayer();
        if (event.getAction() != Action.LEFT_CLICK_AIR & event.getAction() != Action.LEFT_CLICK_BLOCK & event.getAction() == Action.RIGHT_CLICK_AIR) {
            if (player.getItemInHand().hasItemMeta() & player.getItemInHand().getItemMeta().hasLore() & event.getPlayer().getItemInHand().getItemMeta().getLore().contains(ChatColor.WHITE + "The Precious")) {
                player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 25*20, 0));
            }
        }
    }
}
dusk flicker
#

well the npe will tell you the line

#

if I had to guess getItemInHand is null, only one I can guess that

steady herald
#

I thought getItemINhand couldnt be bull since it would return air?

#

oh wait thats type

#

nvm

dusk flicker
#

well check the NPE for the line

#

and that will answer your question

quaint mantle
#

One more question. Should i always code in the latest spigot api?

drowsy bramble
#

does what jre you use matter?

#

jdk rather

gentle oriole
#

how do I know what minecraft versions my plugin supports

eternal pawn
#

Not sure if this is the right place to ask but I'll preface this with I am pretty new to Java and spigot coding but i've been leaning over the last year how this all works. I'm working on upgrading an old plugin to work with 1.18 but it uses alot of NBT reflection methods instead of NMS directly and so alot of console errors are occurring. It was originally coded for 1.13 if that helps. Also, would it matter if I am coding in Java 16 in intelliJ or should I force it to use java 17 to compile? I already had to change an async task to a main thread task since getEntities won't work on an async task anymore. DM me if you can help 🙂 Thanks.

quaint mantle
#

good luck

#

🙂

naive loom
#

Does anyone know why this issue is happening? The key set inside of the log file is XXX because it's my gpg private key.

quaint mantle
#

?paste

undone axleBOT
quaint mantle
#

i dun like to download those lol

naive loom
quaint mantle
#

why would you build 1.8 lol

naive loom
#

to get the nms

lost matrix
drowsy bramble
quaint mantle
#

the latest jdk includes more stuff than say 1.8

#

like the String#repeat method

#

i like the most

#

records

#

so basically there is no downside to using the latest jdk besides a small size increase

young knoll
#

But that also probably comes with a small performance increase

quaint mantle
#

^

lost matrix
#

*when running the server
For development there is not much of a benefit.
Unless you are speaking about compiler optimizations

young knoll
#

I assume the compiler has also gotten smarter

quaint mantle
#

string + string + string wasnt optimized pre 1.7

worn flax
#
try {
                    ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
                    String command = "setlevel "+k.getName()+" "+level;
                    Bukkit.getServer().dispatchCommand(console, command);
                }catch (NullPointerException exception){
                    System.out.println(Bukkit.getConsoleSender());
                    System.out.println("setLevel "+k.getName()+" "+level);
                }```

This (every time), is printing out 

```org.bukkit.craftbukkit.v1_8_R3.command.ColouredConsoleSender@199de05a
02.01 15:30:02 [Server] INFO setLevel Yoursole 24```

instead of running the command.  This is because FOR SOME REASON it is throwing a nullpointerexception, but like - as you can see im printing out both components and neither are null.
#

this is the error if it isnt caught:

02.01 15:34:00 [Server] INFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:152) ~[patched.jar:git-PaperSpigot-"4c7641d19"]
02.01 15:34:00 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:666) ~[patched.jar:git-PaperSpigot-"4c7641d19"]
02.01 15:34:03 [Server] INFO at me.yoursole.kitpvp.Kits.Archer.entityDamageEntity(Archer.java:274) ~[?:?]
02.01 15:34:03 [Server] INFO at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_292]
02.01 15:34:03 [Server] INFO at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_292]
02.01 15:34:03 [Server] INFO at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_292]
02.01 15:34:03 [Server] INFO at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_292]
02.01 15:34:03 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:300) ~[patched.jar:git-PaperSpigot-"4c7641d19"]
02.01 15:34:03 [Server] INFO ... 23 more```
#

line 274 where it says the error is is this line:

young knoll
#

Not spigot, also 1.8

worn flax
#
                    Bukkit.getServer().dispatchCommand(console, command); ```
young knoll
#

😬

worn flax
#

what

#

this is spigot

#

and yes its 1.8 spigot

young knoll
#

That’s paper

worn flax
#

class is the same tho

#

the ConsoleCommandSender

#

which is what im having an issue with

#

its the same class with the same implementation

young knoll
#

?paste the error

undone axleBOT
worn flax
#

pasted

worn flax
young knoll
#

What line is Archer.java 274

worn flax
#

Bukkit.getServer().dispatchCommand(console, command);

#

and like i said

#

neither console or command are null

#

because

#

this```java

try {
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
String command = "setlevel "+k.getName()+" "+level;
Bukkit.getServer().dispatchCommand(console, command);
}catch (NullPointerException exception){
System.out.println(Bukkit.getConsoleSender());
System.out.println("setLevel "+k.getName()+" "+level);
}```

#

prints

#
02.01 15:30:02 [Server] INFO setLevel Yoursole 24```
#

which shows both are certainly not null

#

lmao

#

@young knoll

young knoll
#

Can 1.8 run on java 15+?

#

I don’t remember

worn flax
#

yea

#

its working perfectly fine

#

for everything else

#

also it wouldnt throw null would it?

young knoll
#

Then run it on modern java to get the better stacktrace

#

Which will actually tell you what’s null

#

I assume setlevel is a registered command

worn flax
#

no

#

it might not be

#

its a command my friend make with skript

young knoll
#

That may be it

worn flax
#

alr

#

ill try that

quaint berry
#

Does anyone here know how the hell permission nodes work? (Creating them)

young knoll
#

Explain

quaint berry
#

If you have a certain permission nopde then you can type a certain command

#

If you don't have the permission node then you can't

dim bronze
#

what’s the best way to continuously perform a task if a player is not within a specific region of a block. There could potentially be many of these blocks. This also integrates with world guard regions if that makes things easier (I am currently using flag changes but I don’t want to create lots of regions)

young knoll
#

All permission stuff is there

kind hatch
#

Does minecraft support RGBA for color codes? Or is it strictly RGB.

quaint mantle
#

does anyone have a resource for understanding how .spawnParticle works

#

in terms of the parameters and their meaning

#

hello how can i do so if an event is triggered in one class it calls an event in another class

wet breach
#

?di

undone axleBOT
quaint mantle
#

its like

#

i want to make an implosion effect

#

so i guess have particles travel in from a point

#

and then i have a method to create a circle of particles, but i want them to shoot out from their starting point

#

is there a way to spawn them with vectors or something with the offset?

quaint mantle
#

i feel like if theres a way to manipulate the offsets then i can do it

kind hatch
# young knoll RGB

Thought so, but just wanted to make sure. Do you know of a way to get a darker or lighter value from RGB while still maintaining the original color? Or if there is a simple way to calculate it?

kind hatch
quaint mantle
#

whats vibration even

kind hatch
gentle oriole
#

is there player inventory update event?

#

fires when made changes to player inventory? pickup/drop/get item in chest/commands

gentle oriole
kind hatch
gentle oriole
#

/give yadda yadda

#

and creative inventory

kind hatch
gentle oriole
#

checking player inventory every tick works just fine, who needs efficiency anyways...

quaint mantle
#

wait

#

wasnt the correct? you deleted it

gentle oriole
#

@quaint mantle I thought you wanted to call a method. I misread

#

why do you want to call an event in another class?

#

if i were you i'd create a method and put the code there, and if one of the events called, run the said method

wet breach
#

well the first two are similar, the last one is different

#

the first two, one takes a Runnable as an argument the other takes a Consumer

gentle oriole
#

nvm im so dumb

quaint berry
#

Thank you, I made the permission nodes work but when someone who doesn't have permission to the command tries to type it it show up as white like you can type it, (The command won't actually work tho) How would I change this?

young knoll
#

Did you set the commands permission in the plugin.yml

quaint berry
#

Yes

young knoll
#

Because iirc that should stop players from seeing it as well

quaint berry
#

Oh

#

hmmm

#

What would that look like?

young knoll
#

If not you can remove it in the PlayerCommandSendEvent

quaint berry
#

Could I do this in LuckPerms?

young knoll
#

Do what

#

It does state “This permission node can be used to determine if a user should be able to see this command.”

stone apex
#

Does anyone here unload and delete minigame worlds? I get these errors and afaik spigot doesn't have a way (at least rn) to tell minecraft to stop trying to save these deleted worlds

#

My next step is making like worlds that never really get deleted until shutdown of the server. Which would be annoying and I'd basically have a huge amount of files creating over time

young knoll
#

Bukkit#unloadWorld

wet breach
#

some minigames require modifying the terrain, easy way to allow that and reset easily is to have a master world that gets copied, loaded and then ultimately deleted afterwards 🙂

stone apex
analog prairie
#

How can I reload my plugin,Not all server

quaint mantle
#

Whats wrong with this code -

    // triggers when a player vanishes and is online
    public void onVanish(PlayerHideEvent event) {
        Bukkit.getPluginManager().callEvent(onPlayerLeave());
    }```

I'm getting this error -

```'onPlayerLeave(org.bukkit.event.player.PlayerQuitEvent)' in 'com.beans.simplejoinmessages.events.joinEvent' cannot be applied to '()'```

and idk what that means. help pls
analog prairie
#

I can't found reload in PluginManger

zinc spire
analog prairie
quaint mantle
zinc spire
analog prairie
zinc spire
#

Yes, the plugin will be disabled if the enable cause error

quaint berry
valid sorrel
#

why is javadoc broken

gentle oriole
#

?jd

wet breach
#

as long as you handle stuff appropriately in onEnable to initialize properly it shouldn't be an issue doing it this way o.o

analog prairie
#

I can't use this in Apart from main class

#

How can I solve this problem?

#
package command;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

public class command implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        this.getPluginLoader().disablePlugin(this);
        this.getPluginLoader().enablePlugin(this);
        return false;
    }
}
dense phoenix
#

How to change /login password without being logged in on the UserLogin Plugin

kind hatch
dense phoenix
#

Im not the owner

#

Im a member

kind hatch
dense phoenix
#

I forgot my password

#

And idk how to change jt

kind hatch
# dense phoenix Im not the owner

You'll probably have to contact the owner of the server. I doubt that the plugin creator would leave a way for members to reset their password without being logged in.

analog prairie
dense phoenix
#

Yep i pinged the ownrr

#

and how to fix illegal-access=permit

analog prairie
kind hatch
analog prairie
#

so I can use any command with space?

kind hatch
dense phoenix
#

@kind hatch

#

How to fix illegal-access=permit in server.jar

kind hatch
dense phoenix
#

Its in the server.jar

#

It crashed my server a billion times

quaint mantle
analog prairie
kind hatch
# dense phoenix Its in the server.jar

From what I can find it's a flag used in your startup script. I have no clue what it's purpose is or the functionality it provides. Could you explain why you need it?

analog prairie
kind hatch
#

What do you mean in your last post? I was confused interpreting it.

analog prairie
#

I am new to java,Sorry

kind hatch
#

Again, wdym by server options? Are you referring to the tab completions? Or something else?

analog prairie
#

It's error without main class

kind hatch
#

Oh

#

You need to pass an instance of your main class (that extends JavaPlugin) as the parameter for #enablePlugin().
You can pass an instance with Dependency Injection.

#

Your code is trying to enable the plugin with a command class instead of your main class which extends JavaPlugin.

#

That's why it would work in your Main class, but not any other.

#

Because the this keyword refers to the class command. (In that context)

#

Also your class names should be UpperCamelCase.

analog prairie
#

How to solve it

analog prairie
#
package command;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import  Spigot_ExpTech_whes1015.*;

public class command implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        this.getPluginLoader().disablePlugin(this);
        this.getPluginLoader().enablePlugin(this);

        return false;
    }
}
kind hatch
quaint mantle
#

Just di

eternal oxide
#

?di

undone axleBOT
kind hatch
#

Dependency Injection is the way to go for commands, but if you have enums or something that can't take in constructor parameters, you could use JavaPlugin#getPlugin(Class<T> clazz)

quaint mantle
#

you shouldnt use plugin in enums or any other static context 🙂

analog prairie
#

I don't understand at all😢

#

I am new to java

kind hatch
# quaint mantle you shouldnt use plugin in enums or any other static context 🙂

Really? Cause I do that so I can replace variables in my configs. For instance, I have a Messages enum that contains all the message paths in my lang file. Once I get the path, I replace things like %prefix% and return the fixed string. This way I don't have to repeat myself constantly. This isn't possible without that instance though.

analog prairie
#

Is there any example?

eternal oxide
#

?di

undone axleBOT
kind hatch
#

?java

#

?learn

#

Tf is the command lmao

eternal oxide
#

?learnjava

undone axleBOT
quaint mantle
# kind hatch Really? Cause I do that so I can replace variables in my configs. For instance, ...

Yes. Enums for configs is not a good idea. At the first place, enums should not have any mutable state. At the second place, enums are in static context, while plugins and configurations arent. I would recommend you to separate responsibilities - make your enum to just hold keys and create a config class.
Config config = new Config(plugin, file);
String value = config.getString(MyEnum.PREFIX);

analog prairie
#

[16:40:12] [Server thread/ERROR]: Error occurred while enabling Spigot-ExpTech v22w01-pre1 (Is it up to date?)
java.lang.IllegalArgumentException: Plugin already initialized!

#
package command;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;

public class command extends JavaPlugin implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        console(ChatColor.RED+" "+sender);
        console(ChatColor.RED+" "+command);
        console(ChatColor.RED+" "+label);
        console(ChatColor.RED+" "+args);
        this.getPluginLoader().disablePlugin(this);
        this.getPluginLoader().enablePlugin(this);
        return false;
    }

    public  void console(String data){
        Bukkit.getConsoleSender().sendMessage(data);
    }
}
eternal oxide
#

Only ONE class can extend JavaPlugin

quaint mantle
#

Please learn java

eternal oxide
#

read the di link you've been given multiple times

quaint mantle
#

!learnjava

#

How was it

kind hatch
#

?learnjava

undone axleBOT
gentle oriole
#

how do I know how many hunger food gives

spiral light
#

i think nms has all those values ^^

gentle oriole
#

nms?

spiral light
#

net.minecraft(.server)

turbid crest
#

Hey 🙂 I have trouble using the onLoad method...

#

I tried ` @Override
public void onLoad(){

}`
#

But it seems to not work

sage patio
#

public void onEnable()

spiral light
#

you want to use this method for what ?

turbid crest
#

I'm using the NBT Api

#

And I need to inject it on onLoad method

#

But I'm gonna try with onEnable

sage patio
#

u mean on plugin startup?

wet breach
#

onLoad() happens before onEnable() and there is some things unavailable from the onLoad() depending when that happens. Most of the time that happens during server startup. Generally you are fine and will want to use onEnable().

turbid crest
#

"Please enable it during onLoad with NBTInjector.inject(); if you are using it!"

#

That's what the plugin says

sage patio
turbid crest
#

And it looks like it's not working on the onEnable method

sage patio
spiral light
#

any errors in log ?

turbid crest
#

de.tr7zw.nbtapi.NbtApiException: The NBTInjector has not been enabled!
You need to call 'NBTInjector.inject()' during the Method 'onLoad' of your Plugin! Check the Wiki/Pluginpage for more information!

spiral light
#

did you add a depend in plugin-yml ?

turbid crest
#

Yes, only the NBTAPI

spiral light
#

right version ?

turbid crest
#

Yes sir

spiral light
#

if you use inject onLoad ... can you send your log ?

turbid crest
#

Have you ever used onLoad?

#

The thing is that I don't know how to use onLoad ahah

lapis lark
quiet ice
#

onLoad is onEnable but running earlier

lapis lark
#

Override it

wet breach
quiet ice
#

just note that it might be running when no worlds are loaded

wet breach
#

just you can't make use of everything in onLoad() typically. If you need to use it, then do so lol

spiral light
#

there is nothing special with onLoad --- it just gets called before onEnable

quiet ice
#

Well there are a few critical timing differences, so you can't substitute it

turbid crest
#

It's not working, I still have the error in console

#

@Override public void onLoad(){ NBTInjector.inject(); }

spiral light
#

error ?

turbid crest
#

de.tr7zw.nbtapi.NbtApiException: The NBTInjector has not been enabled! You need to call 'NBTInjector.inject()' during the Method 'onLoad' of your Plugin! Check the Wiki/Pluginpage for more information!

quiet ice
#

I'd check their API docs honestly

spiral light
#

you could debug the onLoad (with System.out) and check if gets called

quiet ice
#

It does get called, otherwise no exception would happen

#

Oh I see

spiral light
#

depends on what he did ... if he has 2 JavaPlugin extended ^^ xD

quiet ice
#

Yeah, but honestly it not getting called is unlikely except if the old revision is still there

turbid crest
#

Oh I feel stupid

#

Important note regarding Tiles/Entities Starting with 1.14+ you can use the getPersistentDataContainer() (for NBT(Tile)-Entity's) to save custom tags. This replaces the now mentioned NBT-Injector.

vale ember
#

how can i take as paramter only objects that are instance of class with specific annotation present?

spiral light
#

for what do you need this ?

quiet ice
#

public void method(@NotNull Object o) is the de-facto standard way, but it is not enforced by javac and is also not enforced by the JVM

gentle oriole
#
scheduler.scheduleSyncRepeatingTask(plugin, () -> {
            Collection<? extends Player> onlinePlayers = plugin.getServer().getOnlinePlayers();
            for (Player player : onlinePlayers) {
                System.out.println(player.getPlayerListName());
            }
        }, 20L, 0L);
```smh instead of this running every second, it runs every tick...
quiet ice
#

As far as I know there is no real way of knowing whether an object is annotated, except if you know that the class the object comes from is annotated

spiral light
#

you should use 0 for delay and 20 for time between run

gentle oriole
#

oh ok

quiet ice
#

?jd

quiet ice
#

The javadocs are your friend

gentle oriole
#

yes, ive read them, but I thought it was delay after running each task

#

and period i have no idea what its for

quiet ice
#
delay the ticks to wait before running the task for the first time
period the ticks to wait between runs
gentle oriole
#

ofcourse im blind

tardy delta
#

me writing javadocs goes brr

quiet ice
#

I stopped writing javadocs for my own projects after realising that noone is going to use them and that I spend far too much time with them

tardy delta
#

code which javadocs can look so big while there is actually not much code

spiral light
#

i hate writing explanations at all ... xD

tardy delta
#

👀

#

is HashSet#contains about the same efficienty as HashMap#containsKey?

quiet ice
#

And sometimes there is no code attached at all:

    /**
     * Obtains the name of the color-independent texture.
     *<br/>
     * This method used to return a {@link NotNull} value, however
     * this was an error as the only class implementing this interface can indeed return null values here.
     * A null value should be treated as no no-col texture, but this does not mean that {@link #getTextureName()}
     * is not applicable.
     *
     * @return The texture name that is independent of color
     */
    public @Nullable String getColorlessTextureName();

Well, actually it is most of the time. I only really bother writing javadocs in interfaces as I always expose the API via interfaces

tardy delta
#

bruh

quiet ice
tardy delta
#

i just saw that

quiet ice
#

A HashSet is a glorified HashMap

quaint mantle
#

yes. Contains Key is fast enough

tardy delta
#

and can a hashmap contains duplicated key value pairs?

#

ah it cant

#

i was looking for a boolean method like HashSet#add

#

but in a hashmap

spiral light
#

if you need something to store a Key with more then 1 value you kan use a MultiMap

north trench
quiet ice
#

I prefer my Map<K, List<V>> instead

quiet ice
#

?stash

undone axleBOT
tardy delta
#

ehh does Map#put returns the old value if there is one and overwrites it?

#

or null if nothing was mapped to that key

quiet ice
#

yes

#

That is the API contract. If you do not want to overwrite, you can use #putIfAbsent

tardy delta
#

so i could check for presence with put(key, value) != null?

quiet ice
#

yes, though beware that it overwrites the old value

#

Though if you allow for null values things might change by a bit

frigid rock
#

i get this error when i load the plugin, can anyone help?

#
public class RankExpireEvent implements Listener {

    private TWCore TWCore;

    public RankExpireEvent(TWCore TWCore, LuckPerms api) {
        this.TWCore = TWCore;

        EventBus eventBus = api.getEventBus();
        eventBus.subscribe(this, NodeRemoveEvent.class, this::onUserExpire);
    }


    private void onUserExpire(NodeRemoveEvent e){
        String name = e.getTarget().getFriendlyName() + " ";
        String rankName = e.getNode().getKey() + " ";
        Player p = (Player) e.getTarget();

        p.sendMessage(TWCore.prefix + ChatColor.LIGHT_PURPLE + name + ChatColor.GRAY + "the rank" + ChatColor.AQUA + rankName + ChatColor.GRAY + "expired.");
    }



}``` this is the code
#

tried asking on the luckperms ds server but no one answered lol

quiet ice
#

Try eventBus.subscribe(TWCore, NodeRemoveEvent.class, this::onUserExpire); instead

#

Also, you really shouldn't name your variables like classes

#

So TWCore becomes tWCore at worst

delicate cargo
#

Does e.getEntity() (e is an EntityDamageEvent) get the victim?

quiet ice
#

that method cannot know that RankExpireEvent exists

#

let alone have an instance of it

frigid rock
#

wait now it works

quiet ice
#

Read the API docs next time, I feel like you can easily avoid this problem

vapid needle
#

How can I fix this

frigid rock
#

i get another error, but thank you!

quiet ice
# north trench yes

How do you build the plugin? Via mvn package or gradlew build or something else entirely?

north trench
#

gradle

quiet ice
#

So you don't use CLI at all?

#

that means that the plugin.yml is invalid, show the rest of the error then

visual tide
quiet ice
north trench
#

i am a noob btw

quiet ice
vapid needle
visual tide
#

send your plugin.yml then

quiet ice
#

Makes sense given that the code that throws the exception is


            jar = new JarFile(file);
            JarEntry entry = jar.getJarEntry("plugin.yml");

            if (entry == null) {
                throw new InvalidDescriptionException(new FileNotFoundException("Jar does not contain plugin.yml"));
            }
visual tide
#

?paste i mean

undone axleBOT
quiet ice
#

so this time spigot does not lie, there really is no plugin.yml

#

Which means that the way you are building the plugin is incorrect

#

(could also point to a nonstandard build.gradle)

quiet ice
delicate cargo
#

Trying to make custom damage system, what is wrong here? (No error is logged, but the event isn't run)```java
public class EntityDamage implements Listener {

public void onEntityDamage(EntityDamageByEntityEvent e) {
    if (!(e.getDamager() instanceof Player) || e.getEntity() instanceof Player || !(e.getEntity() instanceof LivingEntity)) {
        return;
    }
    e.setCancelled(true);
    Player player = (Player) e.getDamager();
    LivingEntity reciever = (LivingEntity) e.getEntity();
    
    PlayerStats stats = Main.instance.playersStats.get(player);
    float unroundedDamage = stats.totalStrength/5;
    int damage = Math.round(unroundedDamage);
    reciever.damage(damage);
}

}

north trench
# visual tide send your plugin.yml then

name: NewItemplugin
version: 1.0
main: newitemplugin.newitemplugin.NewItemplugin
api-version: 1.17
commands:
givewand:
description: Gives our custom item to the player.
usage: /<command>

quiet ice
#

That miencraft-server artifactId is a bit sus

quiet ice
#

But I do not know enough 1.18 NMS to know a bit more

spiral light
# vapid needle

spigot-api with 1.14 but minecraft-server? and 1.17 then ?

quiet ice
#

As I said before, the plugin.yml literally does not exist. which means that something is excluding it in the build

quiet ice
#

^ this should do the job

north trench
quiet ice
#

Unzip your plugin jar

visual tide
#

are you using maven or gradle?

quiet ice
#

gradle

north trench
north trench
quiet ice
#

Then check if the plugin.yml is present, that should narrow it down a bit more

visual tide
#

any gradle stuff/plugins that could be excluding the plugin.yml fomr the jar?

quiet ice
#

Or just send the build.gradle file

#

You cannot

north trench
visual tide
quiet ice
#

okay, then you are not using gradle and you are using the builtin intelliJ build feature (or JDT)

#

Which would explain it

north trench
# visual tide in your project root dir

plugins {
id 'java'
}

group = 'NewItemplugin'
version = '1.0-SNAPSHOT'

repositories {
mavenCentral()
maven {
name = 'spigotmc-repo'
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
}
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public/'
}
}

dependencies {
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
}

def targetJavaVersion = 16
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
}

tasks.withType(JavaCompile).configureEach {
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
options.release = targetJavaVersion
}
}

processResources {
def props = [version: version]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
}

#

so?

vapid needle
quiet ice
#

that won't work

#

at least I do not think so

vapid needle
#

You are talking to me or?

quiet ice
#

yes, mojang mappings are a relatively new thing and it's only really since 1.17 that they are employed

vapid needle
#

so 1.14.4 won't work with it?

north trench
#

What do I do?

quiet ice
#

correct, though you will have the god forsaken spigot mappings at your disposal then

vapid needle
quiet ice
#

just some preemptive assumptions that ended up being wrong

north trench
vapid needle
#

wait maybe I found a solution but another problem appeared

quiet ice
#

You cannot have interop between 1.14 spigot mapped spigot and the 1.17 mojang mapped vanilla server

worldly steppe
#

How do i optimeze my spigot server?

#

Without clearlagg

tardy delta
#

check your plugins

#

mob limits

#

make sure it has enough ram

#

etc

north trench
#

Can someone help me

quiet ice
#

I sadly have not enough gradle knowledge to address your issue, removing the processResources task might help, but that would be a bodge

young knoll
#

Do you have the file in the right spot

north trench
#

Do I make it maven?

quiet ice
#

all roads go to maven

north trench
quiet ice
#

in the end you will get fed up with gradle and just move to maven because there if something works, it tends to work for a long time

north trench
#

Btw I made it maven but it had the same error

quiet ice
#

that is highly interesting

vale ember
#

how do i convert array of strings to array of objects? (no loop)

quiet ice
#

the cast is actually redundant

vale ember
#

it don't work as i want, it still throws array type mismatch exception when i add object of another type

#

i want object array to hold multiple types to invoke method with arguments

quiet ice
#

then you'd need System.arrayCopy

tardy delta
#

will this return true?

eternal oxide
#

no different than return isMuted;

tardy delta
#

or will it only return true if it was able to change ismuted to true?

quiet ice
#

it is also an assignment, so I am not sure if it returns the new value

#

But it could very well return the old value which honestly makes more sense

tardy delta
#

it prints true if it was false before

eternal oxide
#

as yes an assignment

vapid needle
tardy delta
#

two times true

delicate cargo
#

how can i check if a player is mining a block?

north trench
quiet ice
#

Could you send us your jar?

north trench
tardy delta
#

im dying

vapid needle
quiet ice
#

Yeah, you are using IntelliJ / Eclipse JDT to build the jar

#

Use Gradle (./gradlew build or gradlew.bat build) to build the jar

north trench
#

wdym

vapid needle
#

Should I use 1.17 or 1.18?

quiet ice
#

1.17 is EOL on almost all plattforms

delicate cargo
vapid needle
quiet ice
#

Ideally yes

vapid needle
#

ok

quiet ice
#

not sure how well it fares with 0-tick breaking

delicate cargo
#

there's only left-click block, the closest i can think of

quiet ice
vapid needle
#

Should I use a newer one?

quaint mantle
#

Use 17

quiet ice
vapid needle
quiet ice
#

Java 16 is also a favourite of mine

#

but given that 1.18 is J17 only it does not matter

north trench
quaint mantle
#

hi
how to install world edit and world gourd in spigot server

quiet ice
#

./gradlew build on linux or mac and gradlew.bat on windows

quaint mantle
#

intellij has built in gradle / maven support

vapid needle
quaint mantle
#

on right corner

quiet ice
#

The chance is too great that they will use the wrong build feature

delicate cargo
#

geol theres no Player.isMining()

#

or anything

quiet ice
#

PlayerInteractEvent

#

I never pointed you to Player.isMining

delicate cargo
#

that only has LEFT_CLICK_BLOCK and BREAK_BLOCK

#

not BREAKING_BLOCK

quiet ice
#

Ugh, fine

#

?jd

quaint mantle
#

how to install world edit and world gourd in spigot server

quiet ice
quiet ice
#

it would only fire once though

delicate cargo
#

only fires when you lc it

#

yea

#

exactly

quiet ice
#

when exactly does it need to be fired?

quiet ice
#

the ./ are important

delicate cargo
#

it needs to fire multiple times

north trench
quiet ice
#

before, after or while?

delicate cargo
#

while

quiet ice
#

you need to execute it while your pwd is in your project directory

quiet ice
#

There is no event for it though

vapid needle
#

I deleted java 8 and downloaded java 17 also changed the path and it still detects java 8 how

quiet ice
#

you need to replace your environment variables (including, but not limited to java_home)

vapid needle
#

Yeah I did that

quiet ice
#

What's the output of java --version?

young knoll
#

Also make sure you restart cmd prompt

vapid needle
#

Ok got it fixed

quiet ice
#

Basically you need to change your directory (via cd) until you are (as per pwd) in your project directory. I'd just recommend to execute the aforementioned command in the intelliJ terminal

north trench
#

how?

quiet ice
#

Just use IntelliJ's builtin terminal you use the first time, explaining you the cornerstone of MS-DOS is a bit too much

tardy delta
#

took me 15 minutes to make this equation
return isMuted != (isMuted = flag);

#

🥵

#

instead of writing 4 lines..

quiet ice
#

Are you really calling that method that often that it makes sense to have it not branched

tardy delta
#

instead of making a mute and unmute method 🥺

quiet ice
#

As I said beware the ./

quiet ice
tardy delta
#

idk

delicate cargo
#

wait a moment

tardy delta
#

🙄

delicate cargo
#

does LEFT_CLICK_BLOCK fire multiple times when in adv mode and breaking a block?

quiet ice
#

could be, but I doubt it

delicate cargo
#

wait it does

quiet ice
#

the more we know

delicate cargo
#

how can i make a player able to mine blocks with adventure mode?

tardy delta
delicate cargo
quiet ice
#

No, you can't mine blocks you cannot mine

tardy delta
#

oh

delicate cargo
#

adventure is where you have to have a block whitelisted to mine it

tardy delta
#

uhh i dont know about that

quiet ice
#

basically realistic survival mode

tardy delta
#

survival mode when you cant break anything nice

north trench
delicate cargo
quiet ice
north trench
vapid needle
#

The same problem in 1.18

quiet ice
#

get rid of that org.spigotmc:minecraft-server depend if you haven't already

vapid needle
#

How can I do that

quiet ice
#

by removing it from you pom.xml. If you already did that then I cannot really help you further with the information I have right now

tawdry scroll
#

Its only Enderman

vapid needle
#

this is a new project now I have this in pom.xml

tawdry scroll
#

If you are using remapped thing

#

Oh you dont even have nms setup in pom

vapid needle
#

So what can I do

delicate cargo
#

hey does anyone know what the name of the start mining block and stop mining block packets are?

vapid needle
vapid needle
delicate cargo
#

help will come

quaint mantle
#

?jd

delicate cargo
#

now, does anyone have a packets tutorial?

quaint mantle
#

look at codes

#

?nms

#

what

delicate cargo
quaint mantle
#

look at nms codes about packets

#

🇾🇪

delicate cargo
#

uhhh how the hell will that help?

#

i need a tutorial to understand the code

#

does anyone have a packets tutorial?

tardy delta
#

uhh is checking if a user is banned from a chatchannel something to do for the channel or the user?

digital drift
#

what do you mean?

tardy delta
#

is that a responsibility for the user or for the channel?

#

to check if a user is banned

digital drift
#

probably wanna code that on the channel

#

channels are the ones responsible for hooking wit hthe backend db to see who's banned or not

#

i assume you mean what class you want to code this on

restive tangle
#
[13:40:24] [Server thread/ERROR]: Could not load 'plugins/CandyLinks-1.0.0-shaded.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
    at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:186) ~[patched_1.17.1.jar:git-Paper-400]
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:158) ~[patched_1.17.1.jar:git-Paper-400]
    at org.bukkit.craftbukkit.v1_17_R1.CraftServer.loadPlugins(CraftServer.java:419) ~[patched_1.17.1.jar:git-Paper-400]
    at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:287) ~[patched_1.17.1.jar:git-Paper-400]
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1220) ~[patched_1.17.1.jar:git-Paper-400]
    at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[patched_1.17.1.jar:git-Paper-400]
    at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.util.zip.ZipException: zip END header not found
    at java.util.zip.ZipFile$Source.findEND(ZipFile.java:1469) ~[?:?]
    at java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1477) ~[?:?]
    at java.util.zip.ZipFile$Source.<init>(ZipFile.java:1315) ~[?:?]
    at java.util.zip.ZipFile$Source.get(ZipFile.java:1277) ~[?:?]
    at java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:709) ~[?:?]
    at java.util.zip.ZipFile.<init>(ZipFile.java:243) ~[?:?]
    at java.util.zip.ZipFile.<init>(ZipFile.java:172) ~[?:?]
    at java.util.jar.JarFile.<init>(JarFile.java:347) ~[?:?]
    at java.util.jar.JarFile.<init>(JarFile.java:318) ~[?:?]
    at java.util.jar.JarFile.<init>(JarFile.java:284) ~[?:?]
    at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:174) ~[patched_1.17.1.jar:git-Paper-400]
    ... 6 more
#

Plugin.yml

name: CandyLinks
version: 1.0.0
api-version: 1.16
main: com.candynw.sync.Main
author: Quzack
commands:
  link:
    description: Sync your discord and minecraft
    usage: /<command>
  unlink:
    description: Unlink your discord and minecraft account
    usage: /<command>
digital drift
#

strange, recompile your plugin?

young knoll
#

?paste the full error

undone axleBOT
restive tangle
#

What's wrong with the plugin.yml, it was working fine.

delicate cargo
#

so, does anyone have a packets tutorial?

digital drift
#

recompile your plugin

young knoll
#

Nvm I’m blind

restive tangle
#

Alright.

eternal oxide
#

nm, thats discord formatting

quiet ice
#

Caused by: java.util.zip.ZipException: zip END header not found
would point towards the Jar being corrupted

#

or the classloader being closed, but I doubt that

kind hatch
#

Has anyone worked with 1.18 NMS for advancements? I'm really struggling with it and all I want is to display toast notifications. Here's the code I'm working with.
https://paste.md-5.net/asuhuqicun.java

spiral light
#

where is your problem ?

kind hatch
spiral light
#

hmm your creating an advancementprogress but not set smth ... you just get smth instead

#

you probably need to use "update" first

kind hatch
#

Well that got rid of the NPE, but I'm still not getting the toast.

misty current
#

how can I display a line under an npc's name?

#

i guess by using scoreboard packets but i can't figure it out

quiet ice
#

probs invisible armorstands, idk

misty current
#
Scoreboard scoreboard = ((CraftScoreboard) Bukkit.getScoreboardManager().getMainScoreboard()).getHandle();
PacketUtils.playPacket(new PacketPlayOutScoreboardScore(
        new ScoreboardScore(
                scoreboard,
                new ScoreboardObjective(scoreboard, "health", new ScoreboardBaseCriteria("health")),
                player.getName()
        )
), Bukkit.getOnlinePlayers().toArray(new Player[0]));
``` this was my attempt on a player
tardy delta
#

if (ResultSet#next) will that get the first row if you only call it once?

misty current
#
public static void playPacket(@NotNull Packet<? extends PacketListener> packet, @NotNull Entity... entities) {
        Entity[] var2 = entities;
        int var3 = entities.length;

        for(int var4 = 0; var4 < var3; ++var4) {
            Entity e = var2[var4];
            if (e instanceof Player) {
                Player player = (Player)e;
                EntityPlayer entityPlayer = ((CraftPlayer)player).getHandle();
                entityPlayer.playerConnection.sendPacket(packet);
            }
        }

    }
``` this is the playpacket method i use
misty current
#

also i dont want to spawn extra unneeded entities

tardy delta
#

ah
A ResultSet cursor is initially positioned before the first row;

quiet ice
#

The armorstand can be spawned via packets

lunar schooner
#

You need to figure it out by yourself by looking at the source

zealous osprey
#

Question, how could I get all the bossbars that a player has active ?

Im trying:

for (Iterator<KeyedBossBar> it = Bukkit.getBossBars(); it.hasNext(); ) {
            BossBar bar = it.next();

            bar.removeAll();
        }

But that isnt working.

young knoll
#

That will only work for keyed boss bars

kind hatch
lunar schooner
# delicate cargo so, does anyone have a packets tutorial?

In basics:

Class<?> craftPlayerClass = ReflectionUtil.getBukkitClass("entity.CraftPlayer");
Object entityPlayer = ReflectionUtil.invokeMethod(craftPlayerClass, player, "getHandle");
Object playerConnection = ReflectionUtil.getObject(entityPlayer, "b");
Class<?> packetClass = ReflectionUtil.getMinecraftClass("network.protocol.Packet");
// Construct your packet
ReflectionUtil.invokeMethod(playerConnection, "sendPacket", new Class<?>[] { packetClass }, new Object[] { packetPlayOutPlayerInfoRemovePlayer });
zealous osprey
#

Ah yeah didnt even notice that <KeyBossBar>whoops

young knoll
#

That reflection doesn’t even work anymore

#

Use modules

quaint mantle
#

I have a question, can it be that the spigot remapping is broken? Failed to create remapped artifact, project main artifact does not exist.

lunar schooner
young knoll
#

Well that part will

quaint mantle
#

Relfeciton is a NIGHTMARE

#

Now we have cool mappings

young knoll
#

But all the fields and methods inside entityplayer have changed

quiet ice
#

They want to listen for packets, even worse

young knoll
#

Since they used to be spigot mapped, now they aren’t

lunar schooner
misty current
#

listening for packets is not that bad

#

just copy paste code from someone else

lunar schooner
#

My reflection library has a getMajorVersion(), so I have different implementations for >= 1.18 and =< 1.17, etc

quiet ice
#

I pointed them to Protocollib, should be a lot better for someone with next to no experience

misty current
#

yeah protocollib is nice for listening

#

but i hate sending packets with it

young knoll
#

I can agree with that

zealous osprey
misty current
#

nms very better

quiet ice
#

meh, nms is a hell to include

quaint mantle
#

protocollib code is a NIGHTMARE

young knoll
#

Even better is just adding to the API

quaint mantle
#

i mean, sources

lunar schooner
#

I'm curious, how accepting is the spigot api of this?

misty current
#

i've made a cool class to create packet armor stands in 1.8

lunar schooner
#

like, I'd love to remove all NMS code from my source, and PR it all into Spigot

misty current
#

it works fine after many mental breakdowns

young knoll
#

I’m suddenly tempted to look into writing an advancement API

quaint mantle
#

Packets are not api and they never will be 😘

delicate cargo
#

how can i get the targeted block of a player?

young knoll
#

getTargetBlock

lunar schooner
#

but I'm not sure if it should be

quaint mantle
#

my enchantment is not registering when I craft an item and I have no clue why java ItemStack is = new ItemStack(Material.GOLDEN_HOE); ItemMeta isMeta = is.getItemMeta(); isMeta.setDisplayName(ChatColor.GOLD.toString() + ChatColor.BOLD + "Gun"); is.addUnsafeEnchantment(Enchantment.DURABILITY, 20);

young knoll
#

I know spigot has a very basic advancement API

quaint mantle
#

Paper has player profile api 😎

young knoll
#

That works with raw json strings

lunar schooner
zealous osprey
young knoll
#

Add it to the meta

quaint mantle
#

i hope spigot will die one day

young knoll
#

Could also add support for sending toasts with an advancement API

lunar schooner
#

A library for that certainly would be a nice to have, even better to add it to the Spigot API itself

young knoll
#

That’s the idea

#

Would take some time to create though

quiet ice
#

and thus noone does it

young knoll
#

They do

lunar schooner
#

I'd be more than happy to 🙂

young knoll
#

They just keep it to themselves

lunar schooner
#

I love tinkering with reflection and such

young knoll
#

No reflection

lunar schooner
#

if it'd be part of spigot itself not yeah

#

but as an outside library I'd use reflection to allow backwards compat with e.g 1.17 and 1.16

quaint mantle
young knoll
#

I mean you’re always welcome to make outside APIs

#

It’d be nice if we didn’t have 5000 separate ones thought :p

delicate cargo
#

how can i get the field of a packetevent?

quaint mantle
#

get PacketContainer, pick a structure modifier and read a field with it

north trench
#

how do i sync a texture to my item?

quiet ice
#

what texture?

young knoll
#

ItemMeta#setCustomModelData

#

And then set up a resource pack

delicate cargo
#

so how exactly do i read the field from the packetcontainer?

kind hatch
#

Still need help with advancement NMS. I've got the Advancement showing up in the menu, but for some reason it's not granted to the player. Is it possible that the impossible trigger changed functionality? This code should have automatically granted them this advancement.
https://paste.md-5.net/firugatico.java

young knoll
#

It’s a shame there isn’t just a packet for the toasts

quiet ice
delicate cargo
#

so how do i get a value of a field from a packetcontainer?

quiet ice
#

Probably the wrong place to ask given that BukkitObjectInputStream was last modified in early 2013

manic furnace
#

I try to get a scoreboard from the scoreboard manager, but then it throws a NullPointerException, because the scoreboard manager is null.
Here is the error:

[15:46:43 ERROR]: Could not load 'plugins\Plugin.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: java.lang.ExceptionInInitializerError
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:157) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:414) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:322) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_18_R1.CraftServer.loadPlugins(CraftServer.java:421) ~[paper-1.18.1.jar:git-Paper-71]
        at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:285) ~[paper-1.18.1.jar:git-Paper-71]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1202) ~[paper-1.18.1.jar:git-Paper-71]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317) ~[paper-1.18.1.jar:git-Paper-71]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.ExceptionInInitializerError
        at java.lang.Class.forName0(Native Method) ~[?:?]
        at java.lang.Class.forName(Class.java:467) ~[?:?]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:71) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:153) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        ... 7 more
Caused by: java.lang.NullPointerException: Cannot invoke "org.bukkit.scoreboard.ScoreboardManager.getNewScoreboard()" because "at.theduggy.plugin.Main.scoreboardManager" is null
        at at.theduggy.plugin.Main.<clinit>(Main.java:41) ~[Plugin.jar:?]
        at java.lang.Class.forName0(Native Method) ~[?:?]
        at java.lang.Class.forName(Class.java:467) ~[?:?]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:71) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:153) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        ... 7 more

What should i do?

quaint mantle
ivory sleet
#

Geol yeah that looks weird

quiet ice
young knoll
#

Oh gosh newIOException

#

What a method name

quiet ice
#

So the fact that Bukkit#getScoreboardManager is annotated as @NotNull is a lie under paper

young knoll
#

Surprise surprise

quiet ice
#

spigot correctly annotates it as a @Nullable

#

Which confused me

#

but good to know that the javadocs do not lie

young knoll
#

Now I also have the urge to fix that weird IO Exception stuff

delicate cargo
manic furnace
young knoll
#

onEnable is usually after world load

quiet ice
#

yeah

young knoll
#

Unless you are using load: STARTUP

manic furnace
#

Ok thanks

quiet ice
#

the constructor and the onLoad method are called before world load

young knoll
#

I always forget onLoad exists

quiet ice
#

however it is a bit useless given that you cannot even register event listeners in it

manic furnace
#

I tryed this and became the same error

quiet ice
#

OH

#

You aren't using Bukkit#getScoreboardManager

#

You never set at.theduggy.plugin.Main.scoreboardManager, should be a trivial "initialize the field" stuff

manic furnace
#

Yes i do. I first make a variable scoreboradManager and than i get a new scoreboard from it

tardy delta
#

is getting one row from a db a heavy operation?

young knoll
#

I mean

#

Regardless of number of rows it’s still a database call

#

Which can take an indeterminate amount of time

tardy delta
#

hmm i understand

young knoll
#

Specially if the database isn’t local

manic furnace
quiet ice
#

perhaps you set it too early?

delicate cargo
#

hey, for getting an int from a packet field, do i use container.getIntegers().getValues().get(0);?

manic furnace
quiet ice
#

this is interesting

manic furnace
#

ye, i know

#

the stupid thing is, it worked. But suddenly this happend

delicate cargo
#

@quaint mantle so what would i use for the packet location?

tardy delta
#

why do people use @FunctionalInterface

However, the compiler will treat any interface meeting the definition of a functional interface as a functional interface regardless of whether or not a FunctionalInterface annotation is present on the interface declaration
delicate cargo
kind hatch
#

Ok, so update. I'm dumb and wasn't actually granting the advancement to the player. I got confused and was using the wrong mapping. However, even though I fixed that, I'm still not getting the advancement to go through.

gentle oriole
#

Is there any event that fires if two players walks repeatedly back and forth infront of each other?

kind hatch
#

Highly doubt it. Pretty sure you'd have to make something to detect that.

quiet ice
hardy swan
#

Cuz of lambdas :D

vapid needle
quiet ice
#

I have never used nms really so stop bothering me

kind hatch
#

Change that scope tag to provided.

hardy swan
kind hatch
vapid needle
#

So what do I do

hardy swan
#

Change artifactId to just spigot

vapid needle
#

ok

hardy swan
#

Btw if you have run buildtools

vapid needle
#

ok

tender shard
#

btw

#

you should always use the remapped .jar

#

when accessing NMS

#

otherwise you will get fucked by every update

quaint mantle
#

I am making a plugin where if u right click a specific item it will fire an arrow but so far the arrow is not launching java if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) { Location loc = e.getPlayer().getEyeLocation(); Vector v = loc.toVector(); e.getPlayer().launchProjectile(Arrow.class, v); }

hardy swan
tender shard
hardy swan
#

You will still get fucked every update

tender shard
quaint mantle
#

so don't use craftbukkit lmao

hardy swan
#

To get handles?

tender shard
#

you didnt get my point

quaint mantle
tender shard
#

spigot remapped will save you from getting fucked on every update

#

and spigot also includes craftbukkit

tender shard
quiet ice
#

but cb packages still mutate between versions

hardy swan
#

Ok so even by using the remapped jar

quiet ice
#

because god knows why

hardy swan
#

The obfuscation is still different across versions right

tender shard
quaint mantle
#

only some of the package names

quiet ice
#

yes

tender shard
hardy swan
#

I dun see remapping avoiding anything

#

Just making things readable, maybe that is a restriction of maven

tender shard
#

okay then you probably just don't understand what it does

#

it renames all the methods and classes to the name that mojang themselves use

#

and those of course do NOT change every update

#

they are consistent

hardy swan
#

I know that, but it doesnt help in obfuscation process.

tender shard
#

I have no idea what you are talking about

quaint mantle
tender shard
quaint mantle
#

same lol

tender shard
#

wait

#

Player.getEyeLocation().getDirection()

#

maybe you will also have to normalize() it

quaint mantle
#

ohhhh

#

should I make it the vector?

tender shard
#

yes, that should be used as the vector

quaint mantle
#

ok

hardy swan
tender shard
#

I stil l don't get what you mean

gentle oriole
#

Is there something that when I push to github, it will automatically build and put it into Releases?

quaint mantle
#

so use the special source version for your mc version?

tender shard
#

My library works on all versions between 1.16.0 and 1.18.1, and I am using remapped for both 1.17 and 1.18 without problems

#

only had to change one line between 1.17 and 1.18

#

without remapping, I would have had to change hundreds of lines

hardy swan
#

Ah ok

tender shard
#

oh my bad, I only use 1.18 remapped

#

but yeah you can just have one maven module per NMS version

hardy swan
#

Yea i know

tender shard
#

and every one uses the matching special sauce thingy

quaint mantle
hardy swan
#

I just wasnt sure why you advocate for the use of remapped when it doesnt really matter.