#help-development

1 messages · Page 2069 of 1

vocal cloud
#

That info is probably in the docs

ornate patio
#

i've googled everywhere i cant find it

#

mainly because its different between versions

#

i need to know for 1.18.1

vocal cloud
#

?jd-s

undone axleBOT
vocal cloud
#

don't use google. Use the docs

ornate patio
#

i've checked the docs too

#

nothing about a character limit

vocal cloud
#

Then just try it and see

ornate patio
#

that'll take forever tho lol

vocal cloud
#

Well how much data are you trying to put in there?

#

And no it wouldnt

ornate patio
#

nevermind i just use the /scoreboard command

#

forgot that was a thing

#

theres no character limit to the point where it can take up the whole screen

vocal cloud
#

Then there is no feasible character limit. Problem solved

wide coyote
#

iirc 32 for older versions, unlimited or 64 for newer versions

kindred valley
#

Can someone tell me pls what is the difference between fileconfiguration and file

late socket
#

how would you work with the crowdin api for translations

#

would you cache them

#

or

hasty wasp
#

yes, on enable just load them

granite burrow
#

Hey this may be a dumb question, but how come I cant access the data in a hashmap from another class? I want to get some data from a PlayerInteractEntityEvent to a InventoryClickEvent

The best way I thought to do this was by setting up a hash map in the PlayerInteractEntityEvent however when I try to access the hashmap from the InventoryClickEvent it doesn't show me any data

Anyone have an idea why

hasty wasp
#

you should use a service or so called manager class to do so

#

you just then create a Singelton instance in your main and access the instance with you main plugin

Something like XYPlugin.getPlugin(XYPlugin.class).getPlayerManager().getGreatHashmap()

granite burrow
#

alright let me try something liek that

#

sick it worked, is there any particular reason why it didnt work in the event class?

chrome beacon
#

What did you do in the event class

#

I hope you didn't create a new instance

granite burrow
#

okay yeah that makes sense now, I feel stupid lmao...

kindred valley
#

Someone tell me the difference between file and fileconfuguration

patent relic
#

im trying to make a plugin that gives each player a ArrayList<Coordinate> where Coordinate is a class that has Location, and name of the location as a string

#

but i cant figure out how to save the data and retrieve the data everytime the server opens and closes

#

I basically used a Hashmap of arraylist<Coordinate>

glass mauve
#

use a database or files to save your data

kindred valley
#

Make methods 'save , load' and call it from main

frigid rock
buoyant viper
ivory sleet
#

Mye it’s pretty much just file location vs file content

kindred valley
noble lantern
#

Okay im having a very odd bug here, i am using Inventory#addItem(ItemStack) to add a item to a players inventory

Ive used isEmpty() on that hashmap returned from the method, its empty so its 100% added to the players inventory (I have a handler if the list is not empty the item im trying to add to a player's inventory, and each and every time my debug log is not fired and that method isnt called so i know 100% its being added somewhere)

My issue here, is the item simply is not being added to the players inventory (Ive tried calling p.updateInventory(), not difference here the item is not added)

Now: The item being added is a Main hand item, there is a system where

if player gets hit -> get the ItemStack in the items hand, and store it using a clone() method -> set main hand to AIR -> give player cloned ItemStack

The behavior here is the item is simply just banished to the shadow realm, never to be seen again

chrome beacon
#

Could you show your code?

#

?paste

undone axleBOT
noble lantern
#

I can but give me a few as i need to change a few things from it

neon nymph
#

Hello guys,

The render method of a Renderer class gets called like every quarter second, right? How would I manually call and update a map instantly rather than wait for the next "bus" to pick my renderer changes up?

chrome beacon
#

Call the render method yourself?

neon nymph
#

I try, but the method requires a MapCanvas parameter and idk where to get it

neon nymph
#

Cast from what?

#

There's the map itemstack itself, mapmeta, and mapview. I dunno where to get canvas from

#

Got it, basically saved the canvas to a field var after the first render call, now I can use that whenever I want to call it myself. Kinda hacky lol

#

If any of you got a better solution, please share ! 😄

chrome beacon
#

hm doesn't sound optimal but I'm not aware of another way

#

Maybe take a look at some other map plugins and see how they work

neon nymph
#

True, plus I still don't know what the drawbacks of doing this method is. I'll just use this until I find a better way

chrome beacon
#

Make sure to store a weak reference so you don't start wasting memory

noble lantern
#

Okay i actually managed to figure out what was wrong, my bad i had my main hand set as the first slot like so, and when it did the steps i did above it was just re-adding it into that one singular slot with another method i try

I ended up adding a method that gets a empty AIR slot and it will instead add it to that specific slot, and makes sure that slot isnt the held item slot

granite owl
#

i guess i just dont understand its implementation correctly but if i access the primary command map using this method

#
try 
        {   
            final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
            bukkitCommandMap.setAccessible(true);
            bukkitCmds = (CommandMap) bukkitCommandMap.get(Bukkit.getServer());
        } 
        catch(Exception e) 
        { 
            e.printStackTrace();    
        }
#

i get a list of all commands

#

but can only unregister plugin added commands?

ivory sleet
kindred valley
# ivory sleet Elaborate

For example, I want to create a custom config file. Should I define it as File or File configuration?

dawn arch
#

Hello,
I am trying to run a function from another plugins main class that returns its instance but it keeps returning null.

    public static JustAnimations INSTANCE;

    private final Map<String, BlockAnimation> animations = new HashMap<>();

    public JustAnimations() {
        INSTANCE = this;
    }```
^^^ the plugin main class

when i run `JustAnimations.INSTANCE` from my other plugin (the animation plugin is a dependency) it returns null
neon nymph
#

That means your other plugin is ran before JustAnimations

lavish hemlock
#

w o w n o w a y , h o w c o u l d t h a t b e ?

dawn arch
#

but my plugin has justanimations set as a dependency & starts after it in console?

granite owl
#

how can i unregister vanilla commands? apparently the knownCommands field has been renamed and reflection is anoying to reverse engineer

#

so i hoped someone already knows what the field is named now

#
[10:59:22] [Server thread/WARN]: java.lang.NoSuchFieldException: knownCommands
``` using this ```java
try 
{
  final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("knownCommands");
}
catch (NoSuchFieldException | SecurityException e)
{
  e.printStackTrace();
}
#

so hows the field named now? i need it

maiden thicket
#

oh

#

commandmap isnt nms

#

if u have the commandmap as a class just ctrl click it

#

like if u write CommandMap and import it

frigid rock
#

hello, how can i get the color of a terracotta block? I need a String variable with the color prefix

granite owl
#

i want to remove vanilla commands, so that they're unaccessable

#

and for that i need the knownCommands field

#

thing is that its name is deprecated as it seems to have been changed

frigid rock
#

i need to get a prefix from the material, not to get the material from a string

#

but how can i just get the "RED_" prefix?

frigid rock
granite owl
#

the problem is

#

that i want to override the /op command

#

with my own logic

#

so i want to unregister the vanilla command

#

and register my custom one

frigid rock
frigid rock
#

if it's a vanilla command you cancel it, otherwise you just return

granite owl
#

i dont want to cancel it

#

those are redundant tasks which will eat away processing power which i already need for really resource intensive tasks

grim ice
#

just replace the "terracota"

#

part

#

oh u alr got t

grim ice
#

sir machines are way faster than what you think

#

cancelling an event which occurs not that often

#

will not take any resources for the most part

#

a few nanoseconds wont matter

#

Premature optimization bad

granite owl
#

mhm

#

fine ill reverse it myself

#

okay then how exactly do i override the /op command and replace it

#

using the PlayerCommandPreprocessEvent

#

and then execute it from the console?

tender shard
#

is there a better way to turn a byte[] into a String than using new String(char[]) ?

dawn arch
#

it is depended in plugin.yml & same issue when shaded

glossy venture
#

i think

tender shard
tender shard
glossy venture
#

you said how to turn a byte[] into a String

#

but ok

tender shard
#

whoops

#

I meant a char[]

#

sorry

glossy venture
#

ah

dawn arch
glossy venture
#

why not use new String(chars) though

tender shard
tender shard
glossy venture
#

isnt there a loadafter tag

dawn arch
#

it soft depends world edit?

tender shard
#

there's loadbefore

glossy venture
#

oh

dawn arch
#

yes

tender shard
#

open your .jar with winrar or whatever and check if the included plugin.yml really contains the depend section

#

I know

#

but sometimes when you forget mvn clean I've had weird results of some changes not being added to the .jar

#

so can't hurt to check it

tender shard
#

then all I can think of is one thing:

#

one of your plugins has cyclic dependencies. this causes the server to load all plugins in an arbitrary order

#

e.g. two plugins softdepend on each other

#

try with only your plugin and your dependency and no other plugins

tender shard
#

?paste your latest.log pls

undone axleBOT
dawn arch
#
            <groupId>com.github.JustDoom</groupId>
            <artifactId>JustAnimations</artifactId>
            <version>d6e3227a0c</version>
        </dependency>```
like this?
tender shard
#

huh

#

what are you talking

#

wait

#

I mean

#

the loading order is correct

#
  1. JustAnimations gets loaded
  2. your plugin gets loaded
  3. JustAnimations gets enabled
  4. your plugin gets enabled
#

everything's fine

#

if he has the shade-plugin enabled, then yes

dawn arch
#

i dont think im shading it?

tender shard
#

but they were talking about wrong loading order, which isn't true

tender shard
dawn arch
#

it makes 2 versions one normal one with -shaded at the end (i've been using the one without -shaded)

tender shard
#

so you are shading it

#

add <scope>provided</scope> to the JustANimations dependency

#

also I am confused why you kept saying that your plugin gets enabled BEFORE JustAnimations, the log cleary shows that's not the case 😛

#

you are accessing the JustAnimations.INSTANCE of the version you have shaded into your plugin, obviously that never created any instance

tender shard
dawn arch
#

the jar is tiny now

#

it works aswell

#

thanks!

tender shard
#

btw am I the only one who always keeps accidently typing into their IDE instead of discord lol

#

F

#

so it softdepends

glossy venture
#

why light theme

tall dragon
#

i type in discord instead of my ide :/

tender shard
glossy venture
#

no way guys

tender shard
glossy venture
tall dragon
#

is there an error?

#

is it not behaving like you want?

#

its not looping?

rough drift
#

happens to me

#

always

#

you're never calling timer()

#

print al

tall dragon
rough drift
#

rather than printing "b"

#

print al

#

it should display like

#

[something, something, something]

#

to see if there is data in it

#

if there is no data it will display as []

#

hm

#

try using a list

#

an array list

#

i wanna see if it works then

#

Also why are you doing this?

#

ohk

#

eeeeeeeeeh

grim ice
#

ew abbrievations

#

still

#

making testing harder

tender shard
#

can I somehow force YamlConfiguration to use quotes for strings?

#

right now it saves it without quotes unless absolutely needed

#

that'd confuse admins as they'll think they can just insert color codes and it'll work

vocal cloud
#

I gave up when I tried with my translib and couldn't make it work. It only seems to do it when necessary

tender shard
#

hm I see one dirty possible workaround

#

insert a weird string into every line before saving, after that remove it manually again lol

#

that'd at least work

#

like inserting &x_dirty_hack_&x in every line

vocal cloud
#

Idk. Maybe it's time to open a PR lol

tender shard
#

yeah that would be nice

#

I'll use my dirty hack

#

I'll prepend &x___&x to every string, then remove it during saving the file

vocal cloud
eternal night
#

A pr might be better 👀

#

especially concerning how easy that PR is

grim ice
#

free pr

tender shard
#

totally readable

#

very good for admins

#

it happens when you add some utf8 symbols e.g. the bell \u0007

#

does anyone know what characters are needed to make YamlConfiguration use double quotes?

#

I can only force it to use single quotes

quaint mantle
#

is there an event for "player took damage"? i can't really find anything applicable for that

quaint mantle
#

I don't see a way to get the player from that

hybrid spoke
#

check if the entity is a player

#

then cast

quaint mantle
#

ohh, okay

#

ty

tender shard
#

@vocal cloud

#

I found out how to do it

#
    private static void hackDumperOptions(YamlConfiguration savedFile) {
        try {
            Field field = YamlConfiguration.class.getDeclaredField("yamlDumperOptions");
            field.setAccessible(true);
            DumperOptions options = (DumperOptions) field.get(savedFile);
            options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
#

where's the problem?

#

I think you must add the kotlin-gradle-plugin to your buildscript {}

#

but not sure

quaint mantle
#

what does it mean [plugin name] attempted to register an invalid EventHandler method signature?
here is my code:

@EventHandler
public void onEntityDamage(Entity entity, EntityDamageEvent.DamageCause cause, double damage) {
    if (entity instanceof Player p) {
        System.out.println(String.format("%s took damage", p.getName()));
    }
}
#

i just copy-pasted the signature from javadoc

dire marsh
#

double damage

tender shard
quaint mantle
#

oh

tender shard
#

you can't just randomly add new parameters and expect the event handler to know what to pass there

dire marsh
#

get the entity and damage and cause from the event param

quaint mantle
#

lol i tried using the event constructor signature as the event handler signature. im dumb

tender shard
quaint mantle
#

yea lol

tender shard
eternal night
#

that would work ^

#

well partially

#

the problem is that the Yaml class internally copies that on constructor call

#

e.g. you are too late

#

another issue is the fact that the keys would be affected by this too

tender shard
#

it'll only work for scalars

#

I need it to work for regular strings

#

I have now decided to use my dirty hack that just adds something like {{&x__&x}} to the beginning of every string, then remove it again when saving it

#

although that way I only get single quotes

#

but I guess that's fine

glossy venture
#

what are you trying to do

tender shard
#

force a yaml file to quote all strings

#

it's for translations and messages

#

so admins would break the config all the time by adding color codes at the beginning if it wouldn't be quoted in the default config

eternal night
#
final var yamlConfiguration = new YamlConfiguration();
try {
    final Field yamlField = YamlConfiguration.class.getDeclaredField("yaml");
    yamlField.setAccessible(true);
    final Yaml innerYaml = (Yaml) yamlField.get(yamlConfiguration);
    final Field representerField = Yaml.class.getDeclaredField("representer");
    representerField.setAccessible(true);

    final Representer representer = (Representer) representerField.get(innerYaml);
    representer.setDefaultScalarStyle(DumperOptions.ScalarStyle.SINGLE_QUOTED);
} catch (final ReflectiveOperationException exception) {
    throw new RuntimeException("Something bad happened", exception);
}
#

this works

#

however that enforces quotes on keys as well

tender shard
#

hmm on keys too

eternal night
#

Yea kind of ugly

#

and nothing you really get to do about that 😅

tender shard
#

well I could manually remove them again 😄 as long as it'd allow me to use double quotes

eternal night
#

Yea you could just switch to double quoted

tender shard
#

I can be 100% sure that all my saved files will always either be in the format
"key": "string"
or

  - "string"

so I could just manually remove the quotes from keys

eternal night
#

yea you should be able to just match ".*":

tender shard
#

yeah

#

thanks, i'll try

quaint mantle
#

Can i open the player's crafting inventory with armor, shield and 4(5) slots for craft?

tender shard
#
- "my text: whatever"
#

I think this should do

^\s*"(.+?)":
eternal night
#

oh ye

tender shard
#
line = line.replaceFirst("^\\s*\"(.+?)\":","$1");

jesus wish me luck

#

yaaay it works, I only forgot the colon 🙂

Thanks @eternal night !

eternal night
#

nice 🙏

tender shard
#

well and the spacing

#

but yeah that's no problem

tender shard
granite owl
#

can i override the executor of vanilla commands?

#

or is their execution hardcoded

tender shard
granite owl
#

that aint no problem

#

i just need to know the field names

tender shard
#

lol

#

it's just to test my message library 😄

#

and thank got I used the "ß"

#

it still has troubles with UTF8

#

otherwise I wouldn't have noticed

hybrid spoke
#

WHATß

granite owl
#
try 
{   
  final Field f = Bukkit.getServer().getClass().getDeclaredField("commandMap");
  f.setAccessible(true);
  CommandMap bukkitCmds = (CommandMap) f.get(Bukkit.getServer());
            
  Command cmd = bukkitCmds.getCommand("op");
  if (cmd != null)
  {
    Bukkit.getServer().getPlayer("TheTimeee").sendMessage("Command found");
                
    cmd.unregister(bukkitCmds);
                
    f.set(org.bukkit.craftbukkit.v1_18_R1.command.VanillaCommandWrapper, cmd);
  }
  else
  {
    Bukkit.getServer().getPlayer("TheTimeee").sendMessage("Command not found");
  }
} 
catch(Exception e) 
{ 
  e.printStackTrace();    
}
``` kinda here but that obv doesnt apply the change
pliant oyster
#

Uhh I got a console error, lemmie send rq

#

?paste

undone axleBOT
pliant oyster
#

that's the error

#

basically I'm creating an item with a custom craft and it's giving me the error and idk what's wrong

#
public class ItemManager {

    public static ItemStack heart;
    public static void init(){

        createHeart();

    }

    public static void createHeart(){

        // Heart Iem
        ItemStack heartItem = new ItemStack(Material.RED_DYE);
        ItemMeta heartItemMeta = heartItem.getItemMeta();
        heartItemMeta.setDisplayName(ChatColor.RED + "" + ChatColor.BOLD + "Heart");
        ArrayList<String> heartItemLore = new ArrayList<>();
        heartItemMeta.addEnchant(Enchantment.DURABILITY, 255, true);
        heartItemLore.add("+1 Heart");
        heartItemLore.add(ChatColor.GREEN + "Right click to redeem heart!");
        heartItemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
        heartItemMeta.setLore(heartItemLore);
        heartItem.setItemMeta(heartItemMeta);
        heart = heartItem;

        // Recipe
        ShapedRecipe shapedRecipe = new ShapedRecipe(NamespacedKey.minecraft("heartitem"), heartItem);
        shapedRecipe.shape("ABA",
                           "BCB",
                           "ABA");
        shapedRecipe.setIngredient('A', Material.IRON_BLOCK);
        shapedRecipe.setIngredient('B', Material.DIAMOND);
        shapedRecipe.setIngredient('C', Material.REDSTONE_BLOCK);
        Bukkit.getServer().addRecipe(shapedRecipe);

    }

}```
tender shard
pliant oyster
#

wdym

#

I don't register two

#

will calling createHeart() create a different one?

#

oh yeah

#

everytime I call that it will create a new shape recipe

#

well I thought I have to create it every time the plugin starts

river oracle
#

But your using the same namespaced key

pliant oyster
#

yeah

eternal oxide
#

The NamespacedKey is a Unique identifier

pliant oyster
#

yeah but when do I recreate it?

#

when I call the method?

tender shard
#

I fixed my UTF8 issue

#

fucking FileWriter doesnt take a Charset in java 8

#

so I replaced FileWriter with OutputStreamWriter(FileOutputStream)

eternal oxide
#

Yes you create it every time your plugin starts

#

why are you using the minecraft namespace?

kind hatch
#

Someone correct me if wrong, but I though that you needed to register your recipes on enable every time because custom recipes were cleared from the recipe map on shutdown?

pliant oyster
eternal oxide
#

your plugin new NamespacedKey(plugin, "heartitem")

kind hatch
#

Your own plugin.

pliant oyster
#

ohh

pliant oyster
eternal oxide
#

Its just a key

#

your recipe defines the item

pliant oyster
#

do u want me to show u the parameters

#

oh wait

#

nvm

#

i'm doing it wrong lmfao

#

so something like this right?

#

new ShapedRecipe(new NamespacedKey(CreeperLS.getInstance(), "heartitem"), heartItem);

eternal oxide
#

yes

pliant oyster
#

I see, thanks

granite owl
#

so any help on how to override vanilla command executors?

tender shard
#

the proper solution would be to simply not give permission to the vanilla commands

granite owl
#

and deop

#

and i want the console to also be able

#

to use the modified version

#

so i want to redirect the execution onto my plugins method

tender shard
#

oh okay. easiest solution is to use the PlayerCommandPreprocessEvent

#

simply get the first word, and if it contains a :, split it by the : and get the right part of it

#

if it's op or deop, replace it with your command

#

that's definitely the easiest way and doesn't require any NMS

granite owl
#

thats what ive done

tender shard
#

and where's the problem?

granite owl
#

but that doesnt override vanilla behavior for console executed commands

tender shard
#

that is true, but how is that a problem?

noble lantern
#

Is there a way to make Player#spigot()#respawn() not force open the pause menu, or is this just a bug on my end on my client?

tender shard
#

someone with access to the console can basically do anything they like anyway

granite owl
#

yes but my point being to be uniform

#

i dont want to solve it any possible way

noble lantern
#

I have my secondary client open on my pause menu, and it doesnt open until that method is called hmm

granite owl
#

if theres a better

granite owl
#

and it didnt satisfy

#

thats why i ask here

noble lantern
tender shard
#
    @EventHandler
    public void onDeath(PlayerDeathEvent event) {
        Bukkit.getScheduler().runTask(this, () -> event.getEntity().spigot().respawn());
    }
noble lantern
#

1 tick after the player is considered dead

tender shard
#

this works for me without any escape menu

#

the first video is the one with runTask

#

the second video is calling it immediately

noble lantern
#

sec ill show my video

granite owl
#

well i guess ill have to disassemble the whole spigot server then

#

cu in 2 weeks xD

noble lantern
wide coyote
tender shard
#

aah

#

that's because you don't have the window in focus

#

it's because your chat closes

#

when you die

noble lantern
#

Okay so with 2 actual players, i shouldnt need to worry about this?

tender shard
#

nope

noble lantern
#

Thanks!

tender shard
#

should work fine

#

you do use runTask() though right?

noble lantern
#

i run it in a BukkitRunnable

tender shard
#

haven't tried that but should be the same

noble lantern
#

Yeah more or less basically same thing

tender shard
#

you don't need runTaskLater and 1 tick

#

you can just do runTask

noble lantern
#

ah good point ty

tender shard
#

at least that worked for me 🙂

noble lantern
#

Yeah should basically be the same way, weird how bukkit has so many ways to handle runnables lmao, thanks for the help alex

granite owl
#

@tender shard so u dunno?

tender shard
#

as said, I think it's totally unneccessary

#

people with access to console can do anything anyway

#

they could also just edit ops.json

#

if they want to use minecraft:op, so be it

#

imho you shouldn't mess with that command at all

#

I understand it for other commands but not for op

granite owl
#

im going to do it anyway

#

itll just take longer if no one can help me tho xD

glossy venture
#

you own the account Dalton?

#

burchard

quaint mantle
#

hey, Player#setAllowFlight doesn't seem to be doing anything, I just have a join event that calls p.getPlayer().setAllowFlight(true);

#

is there something I'm missing?

tender shard
#
throw new IllegalStateException("Could neither load the given language file, nor the saved default language file, nor the included default language file!");

is this more an illegalstate or an illegalargument exception?

#

since it always falls back to the included default file, I guess it's more an illegal state than an illegal argument right?

pliant oyster
#

uhh, when an item is stacked the server thinks they're 2 different items cuz they're 2 different item stacks, how can I make it do the same thing even if it's stacked

summer scroll
tender shard
#

isSimilar is basically equals() while ignoring the amount

quaint mantle
#

i'm new to plugin dev, is there a builtin function for execute something on next tick?

undone axleBOT
summer scroll
tender shard
#

basically this:

Bukkit.getScheduler().runTask(myPlugin, () -> {
  // your code
});
#

however it should work fine without delaying it

#

are you sure your event handler is even called?

quaint mantle
#

yes, other stuff before the setAllowFlight works correctly

#

i'm going to try to move the setAllowFlight before the other stuff and see if it still gets called

tender shard
#

@quaint mantle

#
    @EventHandler
    public void onJoin(PlayerJoinEvent event) {
        event.getPlayer().setAllowFlight(true);
    }
#

this works 100%

#

you're doing sth wrong

#

i just tried it

quaint mantle
#

🤔

quasi flint
#

that should work absolutely fine

quaint mantle
#

here is my code

@EventHandler
fun onJoin(p: PlayerJoinEvent) {
    p.getPlayer().setAllowFlight(true);
    var addr = p.getPlayer().getAddress().toString().substring(1).split(":")[0];
    p.setJoinMessage(String.format("%s%s has joined, welcome!", ChatColor.ITALIC, addr));
    p.getPlayer().setInvulnerable(true);
}
#

ignore the uh

#

but the chat message gets sent correctly

quasi flint
#

kotlin ;7

#

u are setting him invulnurable xd

#

not flying

quaint mantle
#

you're looking at the wrong line

#

i set as invulnerable at the beginning of the function

quaint mantle
#

uh i just copy pasted some example code

quasi flint
#

ouch

tender shard
#

that's a funny name for an event

quasi flint
#

maybe .setFlying too

#

dunno if there is a method for that

tender shard
#

yeah setALlowFLight still requires them to double-tap space

quaint mantle
#

i am double tapping space, lol

#

it doesn't set as flying

tender shard
#

then you have other pugins that disallow flying on join

quasi flint
#

^^

quaint mantle
#

oh

#

you are right

quasi flint
#

neuron activation happened

glossy venture
#

what is PlayerCommandPreprocessEvent used for?

#

is there also a command suggestion event and/or command execution event

quasi flint
tender shard
glossy venture
#

ah

quasi flint
#

java docs always help

glossy venture
#

is there a way to set the caption above the text box

#

like what brigadier does

#

in an event like that

#

(tab complete)

tender shard
#

when you hate code inspection

granite owl
#

how can i create a craftbukkit shaded jar?

tender shard
#

why do you need one

granite owl
#

to access vanilla methods to write to the field

tender shard
#

why don't you just use spigot instead of craftbukkit?

granite owl
#

i do

#

but spigots shaded jar does not contain vanilla methods

tender shard
#

but to get craftbukkit:

java17 -jar BuildTools.jar --rev 1.18.2 --compile craftbukkit
tender shard
granite owl
#

yea i did that

tender shard
#

?bootstrap

undone axleBOT
#

Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.

Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163

tender shard
#

the mentioned shaded .jar only has the API, you should take the one from the spigot folder use maven instead

granite owl
#

i did

#

spigot api

#

shaded jar 5kb

tender shard
#

just use maven and everything will magically work

eternal oxide
#

"vanilla" methods would be NMS

tender shard
#

yes, they are all included in the spigot artifact from the local maven repo

granite owl
#

and cant use maven in eclipse

#

jeez

eternal oxide
#

yes you can

tender shard
eternal oxide
#

maven plugin is included in Eclipse

#

just start a Maven project or convert to Maven

tender shard
#

it's just a pain in the ass to get it working when you already have a non-maven project in eclipse

#

eclipse always starts breaking when it founds both, eclipse files and a pom.xml

#

so be sure to delete your eclipse project files when you convert to maven

#

eclipse sucks anyway

exotic jetty
#
Could not load spigot.yml, please correct your syntax errors
org.bukkit.configuration.InvalidConfigurationException: unacceptable code point ' ' (0x0) special characters are not allowed
in "'string'", position 0
        at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:59) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
        at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguration.java:160) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
        at org.bukkit.configuration.file.FileConfiguration.load(FileConfiguration.java:128) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
        at org.spigotmc.SpigotConfig.init(SpigotConfig.java:59) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
        at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:187) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:928) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:273) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_301]
Caused by: org.yaml.snakeyaml.reader.ReaderException: special characters are not allowed
        at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:211) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
        at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(StreamReader.java:176) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
        at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(StreamReader.java:171) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
        at org.yaml.snakeyaml.reader.StreamReader.peek(StreamReader.java:126) ~[server.jar:3096a-Spigot-9fb885e-af1a232]
        at org.yaml.snakeyaml.scanner.ScannerImpl.scanToNextToken(ScannerImpl.java:1177) ~[server.jar:3096a-Spigot-9fb885e-af1a232]

im so stuck with this error and i dont know what it its?

granite owl
#

different question can i still compile a bundled jar

#

where server and api is in one

tender shard
#

they are always included in the final .jar

#

inside META-INF/libraries

granite owl
#

then why cant i access it

#

from the ide

tender shard
#

because you try to use the bootstrapped .jar

#

instead of the one in your local maven repo

quasi flint
tender shard
#

the proper .jar is at C:\Users\mfnal\.m2\repository\org\spigotmc\spigot\1.18.2-R0.1-SNAPSHOT

#

and you should also use the remapped-mojang jar fie

#

omg intellij shut up

#

how is that a problem

lunar schooner
#

Hey folks, I'm in the land of JNI again, but running into this: Exception in thread "Thread-0" java.lang.NoClassDefFoundError: org/bouncycastle/crypto/AsymmetricCipherKeyPair (wrong name: META-INF/versions/9/org/bouncycastle/crypto/AsymmetricCipherKeyPair), when loading a class, what does this mean? besides that the class couldnt be found, obviously

#

specificially the second part

granite owl
#

@tender shard whats the best maven template to use if i want as little other dependencies as possible?

tender shard
#

you don't need any templates

lunar schooner
lunar schooner
#

Rust 😄

tender shard
#

ooh

#

ok

lunar schooner
#

I will not touch PHP with a 10ft pole

#

😂

tender shard
#

I wouldn't touch imperial units with a 3.33m pole 😛

lunar schooner
#

:true:

tender shard
#

you mean... !Boolean.FALSE

lunar schooner
#

I'll take a JValue::Bool(0) today :"D

hybrid spoke
tender shard
#
YamlConfiguration yaml = new YamlConfiguration().load("{}");
boolean bool = !yaml.getBoolean("asd");
hybrid spoke
#

well that would be false

tender shard
#

corrected

quaint mantle
#
function count(tbl, v)
    table.sort(tbl)
    local count = 0
    for i = 1, table.getn(tbl) do
        if tbl[i] == v then
            count = count+1
        elseif tbl[i] > v then
            break
        end
    end
    return count
end
#

lua is way cooler

#

Kappa

lunar schooner
hybrid spoke
#

boolean

tender shard
#

but my favorite way of getting true is still
Double.NaN != Double.NaN

hybrid spoke
#

does the negation auto-unbox a Boolean btw?

lunar schooner
#

Then thisll hold JValue::Bool(0) 😂 otherwhise it'd be Object::new_boolean_object(env, false)?.into_inner().into(), which is uglier

tender shard
tender shard
#

Condition '!Boolean.TRUE' is always 'false'

#

but I couldn't really check since this all returns java.lang.Boolean

        Object Bool = Boolean.TRUE;
        Object bool = true;
        Object negatedBool = !Boolean.TRUE;
        System.out.println(Bool.getClass());
        System.out.println(bool.getClass());
        System.out.println(negatedBool.getClass());
#

which makes sense, I put it into an Object

#

so no idea

#

lol

visual tide
#

new Boolean(new Boolean(new Boolean(new Boolean(new Boolean(false)))))

tender shard
hybrid spoke
#

i need to take care of the performance youknow

tender shard
#

I just read, it always get unboxed

#

which makes sense

#

there is no !Object

hybrid spoke
#

so no negation on a Boolean anymore

tender shard
#

not if it's nullable

hybrid spoke
#

ohh, maybe because of that sonarlint always wants me to do Boolean.FALSE.equals(myBool)

tender shard
#
    public static void main(String... args) {
        Boolean bool = null;
        System.out.println(!bool);
    }
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.lang.Boolean.booleanValue()" because "bool" is null
    at GlobalGson.main(GlobalGson.java:11)
granite owl
#

@tender shard so ive setup a simple maven project it compiled the server accepted the implementations and it executes

#

but ive got a warning that my JRE compiliance does not match

#

where do i set this now because i couldnt set it at the start

#

xD

tender shard
#

what java version do you want to compile for?

granite owl
#

17

#

and the compiliance is set to 1.8

tender shard
#

do you have <java.version> set to 17?

granite owl
#

ive found it

#

xD

tender shard
#
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.10.0</version>
                <configuration>
                    <target>${java.version}</target>
                    <source>${java.version}</source>
                </configuration>
            </plugin>
#

this belongs into <build><plugins>

granite owl
#

no ive set it in the project properties

#

under build path

#

was able to change it there

tender shard
#

you should also set it in the pom

#

in case you compile it without intellij from command line etc

granite owl
#

hm kk

#

ive created an empty maven project btw

#

that correct?

#

pom looks like this

tender shard
granite owl
#
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>SystemControl</groupId>
  <artifactId>SystemControl</artifactId>
  <version>1.0.0</version>
  <name>SystemControl</name>

  <repositories>
    <!-- This adds the Spigot Maven repository to the build -->
    <repository>
      <id>spigot-repo</id>
      <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
    </repository>
  </repositories>

  <dependencies>
    <!--This adds the Spigot API artifact to the build -->
    <dependency>
      <groupId>org.spigotmc</groupId>
      <artifactId>spigot-api</artifactId>
      <version>1.18.2-R0.1-SNAPSHOT</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
</project>
#

sorry to bother but i really didnt wanna use it

#

i only rush trough it because im apparently forced to use it now xD

tender shard
granite owl
#

k

tender shard
#

also setting the project encoding to UTF8 is always advised

granite owl
#

k

#

well time to adapt my plugins

#

to maven yay

tender shard
#

:3

granite owl
#

and now i have full access to all methods?

tender shard
#

no no no

#

you did only add spigot-api

#

you need spigot to access NMS methods

#

I sent you a blog post

#

one sec I'll send it again

granite owl
#

found it

tender shard
#

yes it's a bit long because it uses remapped mappings

#

but you want to use them

#

that way your NMS fields aren't called "a" "b" "c" but "playerConnection" etc

#

so you have the proper names and not just random garbage

granite owl
#

kk

#

but i guess its okay to create it from a "simple project"

tender shard
#

sure

#

you then just have to add everything you need yourself

#

e.g. if you want to shade dependencies, you have to add the maven-shade-plugin

#

but yeah I always write the pom manually

tender shard
#

Das Gesetz von Demeter (englisch Law of Demeter, kurz LoD) ist eine Entwurfs-Richtlinie in der objektorientierten Softwareentwicklung. Sie besagt im Wesentlichen, dass Objekte nur mit Objekten in ihrer unmittelbaren Umgebung kommunizieren sollen. Dadurch soll die Kopplung (das heißt die Anzahl von Abhängigkeiten) in einem Softwaresystem verringe...

#

they forgot to add the Motor class in the second example

granite owl
#

well im accessing certain methods via reflection and this works at least

#

xD

candid jacinth
#

Guys

#

I am making a plugin

#

i have a command that should open a gui, but when running the command, there are no errors, and no gui opening

river oracle
#

Did you register it? Plugin.yaml etc etc

candid jacinth
#

I did

#

I forgot to put p.openinventory infron tof it

#

Dumb mistake xd

#

But

#

Another error

#

I changed the command

#

In the command class itself, and in the plugin.yml

#

and now it says

#

'org.bukkit.plugin.InvalidPluginException: Cannot find main class `me.whiood.mubblemcislands.Main''

#

it is the right main path tho

river oracle
#

🤷‍♂️ you sure otherwise it wouldn't say that

candid jacinth
#

yes

#

and it used to work

#

but now i just changes the command name

#

and it doesnt

topaz summit
#

guys are there some elegant ways to get the final result(i.e. the item stack in the clicked slot after the event happens) of an InventoryClickEvent?

hybrid spoke
topaz summit
#

<=10 lines code i think?

hybrid spoke
#

you can get the item with a oneliner or what do you mean

topaz summit
#

so is there a one-line solution?

topaz summit
#

🤔let me try

#

unfortunately it doesn't work

#

it returns the item in the clicked slot before the event really happens

hybrid spoke
#

what are you trying to do

hybrid spoke
river oracle
topaz summit
kindred valley
#

why cant i build artifacts

topaz summit
quaint mantle
river oracle
#

It should work fine what's wrong with it

topaz summit
topaz summit
river oracle
#

Your probably way over thinking this

topaz summit
river oracle
#

How? It gets the clicked item

#

If you need a delay use a delay

#

Then get the slot

topaz summit
#

for example, if i put one stack of dirt blocks in an empty slot, e.getCurrentItem will return AIR currently in the slot instead of a stack of dirt

#

it acts just like this

river oracle
#

Then add a slight delay

granite owl
#

@tender shard the websites xml format seems incorrect

topaz summit
summer scroll
#

It will return whatever items is in player cursor, or what items that the player trying to store on the inventory.

topaz summit
noble forge
#

For some reason when I try to teleport an armor stand, the teleport fails (it returns false). Could this be because the armorstand is being ridden or is it something else?

summer scroll
#

Wait, I don't even know what is PLACE_ALL

tender shard
#

PLACE_ALL means you place the whole itemstack into a slot

#

PLACE_ONE e.g. is right clicking a slot while having items on your cursor

#

PLACE_ALL is leftclicking an empty slot with items on your cursor

summer scroll
#

What's the name of the enum?

topaz summit
#

InventoryAction

summer scroll
#

Ah, I thought you meant ClickType

granite owl
#
<plugin>
                <groupId>net.md-5</groupId>
                <artifactId>specialsource-maven-plugin</artifactId>
                <version>1.2.2</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>remap</goal>
                        </goals>
                        <id>remap-obf</id>
                        <configuration>
                            <srgIn>org.spigotmc:minecraft-server:1.18.2-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
                            <reverse>true</reverse>
                            <remappedDependencies>org.spigotmc:spigot:1.18.2-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
                            <remappedArtifactAttached>true</remappedArtifactAttached>
                            <remappedClassifierName>remapped-obf</remappedClassifierName>
                        </configuration>
                    </execution>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>remap</goal>
                        </goals>
                        <id>remap-spigot</id>
                        <configuration>
                            <inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
                            <srgIn>org.spigotmc:minecraft-server:1.18.2-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
                            <remappedDependencies>org.spigotmc:spigot:1.18.2-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
tender shard
#

did you simply forget to click the maven reload button?

granite owl
#

missing parent node

#

also i still have to use these names? new org.bukkit.craftbukkit.v1_18_R2.command.VanillaCommandWrapper(null, null)

#

means that plugins still break across versions i dont really get the benefit of remapping

hasty prawn
#

It gives you the unobfuscated names.

#

If you're not working with NMS then you don't need remapped.

tender shard
tender shard
granite owl
#

kk ty

tender shard
#

in 99% of cases, plugins belong into <build><plugins>

primal stirrup
#

So I would like to stop people from being able to destroy boats as well as make them stop pushing them.
How would this be possible like what event do i need?

kindred valley
#

hey i made a stats system but i think i have something not working

granite owl
#

but i still need to adjust the api versions?

#

in the pom.xml

primal stirrup
#

Tried doesn't work

#

as it is a vechile I am now testing out the VehicleDamageEvent

#

But I want to disable the push event as well

#

how do I do that?

#

Only issue now is that I want to get the player from that event as I am only disabeling this event at spawn

summer scroll
primal stirrup
#

But than the question how do I get the VehicleEntityDamage event and than the player location?

#

never mind I will just use the location of the located Vechile

#

How to get the damager of the VehicleDamageEvent?

tender shard
hasty prawn
#

ninja'd

primal stirrup
#

Yea I checked the spigot docs but that only shows how to get the attacker but how do I than get the player

wheat inlet
#

Hey who do I dm to report mistakes on the spiggot website

eternal night
#

the attacker may be a player ?

#

it may not be

#

you need to instanceOf check it

primal stirrup
#

oke thank you

tender shard
wheat inlet
#

just wanted to notify someone that on the buildtools/#latest part they still say 1.18.1 is the latest stable one and you shouldnt use higher for servers but its 1.18.2 by now

#

not big thing just thought could write a small dm to someone

hasty prawn
#

That's a Wiki page, anyone can edit it.

wheat inlet
#

is it

#

great

#

ty

tender shard
quartz valve
#

How can I use packets to make the client think that a particular player is no longer there, i.e. offline, and how can I undo this?

tender shard
#

why would you need packets for that

tender shard
#

Player#hidePlayer

tender shard
eternal needle
#

an internal error occurred while attempting to perform this command

quartz valve
tender shard
#

you can hide players from other players using Player#hidePlayer. No packets needed for that

tender shard
tender shard
quartz valve
tender shard
#

I didn't say it's not possible

eternal needle
tender shard
#

listen to PlayerInteractEvent and set the block manually

tender shard
#

it's just like one line

#

you completely ignored the stacktrace

eternal needle
hasty prawn
#

Look in your console Blobsky

tender shard
#

?paste

undone axleBOT
tender shard
#

this is how an error looks like

#

the error message you sent is about as useful as this

quartz valve
tender shard
#

spigot still has like 45% "market" share 😄

#

just listen to PlayerInteractEvent

#

check if it's right click bloc kwith a block in main hand

#

then check if there's a player at the clicked block's relative blockface

#

then set the block manually

#

it's maybe 5 lines of code

quartz valve
timid parrot
#

why is this code wrong

#

@EventHandler

    public void onSnowballHit(EntityDamageByEntityEvent e) {
        if ((e.getDamager() instanceof Snowball))
            if ((e.getEntity() instanceof Player)) {
                double damage = 0.01;
                e.setDamage(damage);
                Projectile projectile = (Projectile) e.getEntity();

                Player attacked = (Player) e.getEntity();
                ProjectileSource ps = ((Snowball) e.getDamager()).getShooter();

                if (!(ps instanceof Player)) {
                    return;
                }

                Player shooter = (Player) ps;
                {
                    ArrayList<java.lang.String> lore = new ArrayList<>();
                    lore.add("This balls can freeze a player");
                    if (projectile instanceof Snowball) {
                        if (shooter.getInventory().getItemInMainHand().getItemMeta().getLore().equals(lore)) {
                            attacked.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 60, 20, true));
                            attacked.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 60, 100, true));

                        }
                    }
                }
            }
    }
undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

quartz valve
timid parrot
#

so i would like to that if the player is hitted by a custom snowball the player should get jump effect and slowness effect

#

and it doesnt work i cant freeze somebody

tender shard
#

you click the upper face of the block at 0 100 0

#

now you get the clicked block, it returns the block at 0 100 0

#

now you get the clicked blockface, it returns BlockFace.UP

#

then you do clickedBlock.getRelative(clickedBlockFace)

#

this will the the block at 0 101 0

#

the one where you have to have to place the block

ancient plank
#

whew

quartz valve
#

Ohhhh okay now i know what you mean

tender shard
#

so you can always find out where the block "would have been" placed, then manually place it

tender shard
ancient plank
tender shard
#

lol

#

yeah I really don't get how some people can code plugins but don't understand that sending the actual error is important to get help

ancient plank
#

because they probably don't actually know how to code plugins

quartz valve
ancient plank
#

or java

timid parrot
#

oh ok should i sent the error

tender shard
quartz valve
#

oh

#

yeah...

tender shard
#

check this

#

the dirt block is the "blockPlaceAgainst"

#

erm I mean

#

getBlockAgainst

#

the BlockFace is UP since I clicked the TOP part of the dirt

#

so you do getBlockAgainst.getRelative(BlockFace.UP), that's where the wood would end up

quartz valve
#

Okay thanks

tender shard
#

np

timid parrot
#

pls help

#

[15:38:31 ERROR]: Could not pass event ProjectileHitEvent to Main v${1.0}
java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.meta.ItemMeta.getLore()" because the return value of "org.bukkit.inventory.ItemStack.getItemMeta()" is null
at manhunttwist1.lol.events.SwapEvent.onSnowSwap(SwapEvent.java:39) ~[manhunttwits1.jar:?]
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor9.execute(Unknown Source) ~[?:?]
at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:75) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:git-Paper-259]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:629) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R2.event.CraftEventFactory.callProjectileHitEvent(CraftEventFactory.java:1421) ~[paper-1.18.2.jar:git-Paper-259]
at net.minecraft.world.entity.projectile.Projectile.preOnHit(Projectile.java:169) ~[?:?]

#

at net.minecraft.world.entity.projectile.ThrowableProjectile.tick(ThrowableProjectile.java:79) ~[?:?]
at net.minecraft.server.level.ServerLevel.tickNonPassenger(ServerLevel.java:1134) ~[?:?]
at net.minecraft.world.level.Level.guardEntityTick(Level.java:936) ~[?:?]
at net.minecraft.server.level.ServerLevel.lambda$tick$5(ServerLevel.java:673) ~[?:?]
at net.minecraft.world.level.entity.EntityTickList.forEach(EntityTickList.java:43) ~[paper-1.18.2.jar:git-Paper-259]
at net.minecraft.server.level.ServerLevel.tick(ServerLevel.java:653) ~[?:?]
at
net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1591) ~[paper-1.18.2.jar:git-Paper-259]
at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:483) ~[paper-1.18.2.jar:git-Paper-259]
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1455) ~[paper-1.18.2.jar:git-Paper-259]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1225) ~[paper-1.18.2.jar:git-Paper-259]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315) ~[paper-1.18.2.jar:git-Paper-259]
at java.lang.Thread.run(Thread.java:833) ~[?:?] thats the error

tender shard
#

show SwapEvent line 39

ancient plank
#

use pastes for large errors/code blocks

#

?paste

undone axleBOT
timid parrot
#

if (player.getInventory().getItemInMainHand().getItemMeta().getLore().equals(lore)) {

ancient plank
#

look closely at your error

#

java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.meta.ItemMeta.getLore()" because the return value of "org.bukkit.inventory.ItemStack.getItemMeta()" is null
at manhunttwist1.lol.events.SwapEvent.onSnowSwap(SwapEvent.java:39) ~[manhunttwits1.jar:?]

#

lemme dumb it down a lil, here's the key things you need to look for:

Cannot invoke ItemMeta.getLore() because the return value of ItemStack.getItemMeta() is null
at manhunttwist1.lol.events.SwapEvent.onSnowSwap(SwapEvent.java:39) ~[manhunttwits1.jar:?]

timid parrot
#

but i definied it

#

noo

#

but it works at the other items perfectly fine

#

how i also can give an item a tag so i can definy which item it has to be

quartz valve
timid parrot
#

how to a make event apply to custom items

coral helm
#

Arraylist in listener doesn't update

tender shard
timid parrot
ancient plank
#

patience young padawan

midnight shore
#

HI! How can i check if a player is between two locations?

frigid rock
#

how do i do something like this?

#

i want to check if a normal book is a custom book from a class that i made

#

idk how to explain it well

frigid rock
tender shard
frigid rock
tender shard
#

you have to identify your custom book by PDC tags or similar

frigid rock
#

oh yeah

#

ty

tender shard
#

np

frigid rock
#

u can do that too

granite owl
#

still need to override vanilla commands yet xD

tender shard
#

I've written libraries to PDC myself

#

for example with MorePersistentDataTypes, you can PDC a player

ornate mantle
#

i have an event listener that does some funny requests stuff when a mob is killed

#

but the mob doesnt die until the funny requests stuff is done

#

is there a way to kill the mob

#

then do the funny requests stuff?

viral crag
#

delay or wait until the event is done

ornate mantle
#

good idea

#

how do i do that

#

runnables?

viral crag
#

that is one way

ornate mantle
#

what would be the most efficient way in your opinion

#

an asynchronous task?

viral crag
#

that would do whatever your funny stuff is off the main thread, which may or may not be what you want

halcyon mica
#

Have the events for left and right clicks been merged into the interact event?

ornate mantle
viral crag
#

you have two hands, you need to find out which hand you want

ornate mantle
#

mb low res pic

#
    public void entityKill(EntityDeathEvent event){
        Player player = event.getEntity().getKiller();

        new BukkitRunnable() {
            @Override
            public void run() {
                instance.getCoinsManager().addCoins(player, 10);
                this.cancel();
            }
        }.runTaskAsynchronously(instance);```
#

havent tried this method yet

halcyon mica
viral crag
#

wonders what happend when a mob kills something, do they get money?

ornate mantle
midnight shore
#

why do i get this error? Could not initialize class willocore.willocore.world.Regions

viral crag
halcyon mica
#

That is not what I need regardless

#

I need a consistent way to do a thing when a player left or rightclicks

#

Regardless of entity in front of them, item in hand or whatever

ornate mantle
#

ok so my way for the asynchronous loop works

#

ty espresso guy for making me realise

viral crag
#

yeah, in kill and death events the entity is still alive until the event exit

ornate mantle
#

i realised

tender shard
midnight shore
tender shard
#

can you try to call that from the main thread to get a more useful error msg?

tender shard
# midnight shore

looks like you're doing some bad stuff in a static initializer block

midnight shore
tender shard
#

yes

#

line 12

#

in your Regions class

#

what's that?

#

it's either a static field or a static { } block

#

there's your error

midnight shore
tender shard
#

is that an enum?

midnight shore
#

yes

tender shard
#

what's ServerLocationManager line 40?

#

It seems like you access your enum from the class that's needed to init your enum class in the first place

#

you kinda "self reference" your enum class before it could be initialized

#

I guess

midnight shore
#

this is the actual error, before i was just trying to access a null location but this is the actual problem

tender shard
#

yes

#

show your server location manager line 40 pls

#

I bet you access your Regions enum there

midnight shore
#

nope

tender shard
#

hmmm

#

oh wait

#

yeah now the error is different

midnight shore
#

exactly

tender shard
#

so what's eventhandlers line 178

midnight shore
#

just calling the method

tender shard
#

I see

midnight shore
tender shard
midnight shore
#

yes

tender shard
#

weird

#

I don't know then

midnight shore
#

i think there is some problem with class compiling (?)

tender shard
#

is your code o ngithub or sth?

midnight shore
#

nope

midnight shore
#

the error says it couldn't create the instance of Regions

tender shard
#

can you paste your whole regions class?

midnight shore
#

sure

granite owl
#

am i understanding it right that to accesss the maven repository i still need to run buildtools?

#

with the corrisponding version i want to build for

tender shard
#

does ServerLocationsManager access Regions enum?

midnight shore
#

no, ServerLocationsManager is just for getting Locations based on keys from the plugin configs

tender shard
#

hm then I also don't know

midnight shore
#

the Region enum is never named

#

this is the whole class

tender shard
#

your enum looks suspicous anyway, you shouldn't have to call any stuff in the constructor to get stuff from elsewhere

#

enums are supposed to be like static final constant fields

ancient plank
#

sussy

midnight shore
#

but if we look at the error it says something related to class initializing. NoClassDefFoundError

tender shard
#

yes, the class can't be found because it couldn't be initialized

#

so it doesn't exist for the classloader

#

it tried to init it, but couldn't

#

so it's not present an runtime

#

that's normal

#

doesnt have anything to do with compilation

#

I guess you could easily fix that by not using an enum

#

but instead use public static final fields

midnight shore
#

well, i'll try to recode the whole region system from the start, without enum

kind hatch
#

Wouldn’t it be better to just make that enum it’s own class? It would be a lot more flexible if it was. Probably my wouldn’t be running into the current issue as well.

tender shard
#

one would think this should be an enum

#

but if it was, I couldn't access BY_CHAR in the enum constructor

#

your problems seems to be similar

midnight shore
#

well, tysm i'll try

timid parrot
#

can somebody just help me

kind hatch
#

?ask

undone axleBOT
#

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

tender shard
tall dragon
#

not sure

tender shard
#

oh

#

well check the corresponding item in the event and see if it's yours

midnight shore
#

how can i get a Field without having to hard code for each possible value? Like valueOf() of an Enum?

timid parrot
#

i asked this question

midnight shore
#

what do you mean?

tender shard
#

this is basically just a workaround because enums are weird sometimes

#

well they aren't really weird, it's just that you and me were trying to abuse them

#

if you ever have to call any other methods in your enum constructor, it probably shouldn't be an enum

timid parrot
midnight shore
#

how would i define the stuff in the hashmap?

midnight shore
midnight shore
tender shard
#

this is basically exactly how the builtin chat colors work. also the other things like Enchantment class etc

#

they look like enums from the outside, but actually it's just a normal class with many public static final fields

midnight shore
#

okay!

halcyon mica
#

So is the player interact event not firing on right clicks?

timid parrot
#

i mean how can i add in the event the specific item which can only do the event

tender shard
halcyon mica
#
        clickHandler = Events.listen(PlayerInteractEvent.class, EventPriority.MONITOR, e -> {
           sessions.forEach(s -> {
               if(s.getPlayer().equals(e.getPlayer()) && s.getSelection() != null) {
                   System.out.println("Yes");
                   if(e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK)
                       s.getSelection().executePrimary();
                   else if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK)
                        s.getSelection().executeSecondary();
               }
           });
        });```
#

Doesn't matter

#

But the if block never gets executed on a right click

#

Only a leftclick

tender shard
halcyon mica
#

So then how can I get a consistent event fired whenever the player either presses left click or right click

tender shard
#

for certain items, some events are simply not called

viral crag
#
This event will fire as cancelled if the vanilla behavior is to do nothing (e.g interacting with air). For the purpose of avoiding doubt, this means that the event will only be in the cancelled state if it is fired as a result of some prediction made by the server where no subsequent code will run, rather than when the subsequent interaction activity (e.g. placing a block in an illegal position (BlockCanBuildEvent) will fail. ```
tender shard
#

there's a jira report about that but md_5 closed it because he said it can't be fixed without causing much further trouble

midnight shore
tender shard
timid parrot
#

yeah

tender shard
#

this is just one of many issues related to this

halcyon mica
#

So you're saying there is no way for me to detect a right click