#help-development

1 messages ¡ Page 1731 of 1

glossy venture
#

Whats the getarena method

eternal oxide
#

yeash thats not going to work

glossy venture
#

First of all the trailing dot must be removed

#

The arenas. should be arenas

#

Also i recommend loading the arenas into a list and rhen having a reload command to reload it

#

When needed

#

Instead of accessing the config the whole time

#

For performance and code cleanness

proud fiber
#

it worked when i removed the return in all the if statements but now it is applying to player inventories, when i re-add the return it doesn't work anymore

glossy venture
#
Map<String, Arena> arenas = new HashMap<>();

public void reload () {
   arenas = ...; // Convert config section to hash map
}

public Arena getArena(String n) {
   return arenas.get(n);
}
#

Something like that

#

Nice

eternal oxide
#

accessing the config isn't bad, as its already loaded in memory as a Map, but it is slightly slower then using your own list/map

glossy venture
#

True

quaint mantle
glossy venture
#

But its cleaner

eternal oxide
#

yes

#

oh no

#

what have those people let themselves in for.

#

will it blow up their microwave?

bright wind
#

how can i stop runnable? if someone moves

eternal oxide
#

in the move event runnable.cancel()

glossy venture
#

Have it rely on a boolean

glossy venture
#

Nvm

eternal oxide
#

depending on what type of runnable

glossy venture
#

Yeah

#

Sadly not possible

#

Except if u maybe make the leave button invisible using a forced resource pack

#

Its will be condusing

#

Confusing

#

Not impossible tho

#

No yiu could have something working

#

At least make a backup

#

Its seems like youre already pretty far

#

Just some bugs?

#

Really?

#

Nice

#

What joining part

#

Joining a queue or somethinf?

#

Like a minigame queue?

#

We can help tou

#

Your project is just so big already that we need a lot of code

#

To figure out whats going on

#

Not saying that starting over is a bad idea

#

But juwt make a back up

#

Because youre already rhis far

eternal oxide
#

unless you think you can design it better now

glossy venture
#

True

eternal oxide
#

less static would be good 🙂

glossy venture
#

If the core of the system (rhe framework) is bad, yoy should probably start over

#

But it seems like it almost works

#

Just some bugs

#

How does rhe arena storage work

#

Send a part of rhe arena manager

eternal oxide
#

I've not see you load any arenas. Only count them

glossy venture
#

Maybe even dm if ur scared of ppl stealing code

#

And the join code?

quaint mantle
#

hate to break it to ya but nobodys gonna steal this persons code lol

glossy venture
#

Its not that bad qctually

#

Could be improved

eternal oxide
#

um for (int i = 0; i <- (Config.getArenaAmount()-1); i++)

glossy venture
#

Defenitely

quaint mantle
#

also your GameState enum has a typo

glossy venture
#

Thats a compilation error what

quaint mantle
#

fyi

glossy venture
#

Anyways whats the join code

#

Yes

#

No the code

undone axleBOT
glossy venture
#

Behind the join sub command

#

Oh ok yes

proud fiber
#

p u m p

glossy venture
#

Thats not the join code

#

Lmfao

glossy venture
#

Helping this guy

proud fiber
#

oki

glossy venture
#

Ok so getArena(int) returned null

eternal oxide
#

This code is wrong. for (int i = 0; i <- (Config.getArenaAmount()-1); i++)

#

= not -

glossy venture
#

Thats should be a compiler error

eternal oxide
#

it shoudl but it seems its not throwing one

#

it will prevent him creating his arenas though

glossy venture
#

So im assuming its a typo

#

Or something

#

In his discord message

eternal oxide
#

it was a copy/paste so unlikely

glossy venture
#

Because thats not a statement rhe jvm can run

eternal oxide
#

@quaint mantle Show us your manager class again

glossy venture
#

@quaint mantle bro

#

Ur forgetting to return shit

#

In your getArena method

#

Put return arena; in the if statement

#

In getArena(id)

#

Send code to confirm u did it right

#

Of getarena

#

No

#

Wait

#

Bruh

#
package com.hitman.minigame;

import java.util.ArrayList;
import java.util.List;

import org.bukkit.entity.Player;

public class Manager {

    private static ArrayList<Arena> arenas = new ArrayList<>();

    public Manager() {
        for (int i = 0; i <- (Config.getArenaAmount()-1); i++) { 
            arenas.add(new Arena(i));
        }
    }

    public static List<Arena> getArenas() { return arenas; }

    public static boolean isPlaying(Player player) {
        for (Arena arena : arenas) {
            if (arena.getPlayers().contains(player.getUniqueId())) {
                return true;
            }
        }

        return false;
    }
    
    public static Arena getArena(Player player) {
        for (Arena arena : arenas) {
            if (arena.getPlayers().contains(player.getUniqueId())) {
                return arena;
            }
        }
        
        return null;
    }
    
    public static Arena getArena(int id) {
        for (Arena arena : arenas) {
            if (arena.getId() == id) {
                 return arena;
            }
        }
        
        return null;
    }
    
    public static boolean isRecruting(int id) { return getArena(id).getState() == GameState.RECRUTTING; }
    
}
#

Paste that

#

Try it

#

You see the return arena; in the if statement in getArena(int id)?

#

You forgot that

#

It was always returning null

#

I always have that

#

Not necessariky while eating

#

But those stupid mistakes

#

Everyeone makes them

#

Really

#

Oh nice

#

Nice

#

Ur doing pretty well

#

Just work on basic skilks like debugging and reader errors

#

And basic java unspoken rules like proper use of static and stuff

#

Good idea

#

Its not that difficult to learn

#

It has a few parts to it

#

Check if it compiled

#

Otherwise fix the error

#

Actually it might be what elgar said

#

You have a syntax error in your for loop

#

Sorry what

#

Is it a runtime error

#

In the server

#

When you run it

#

Full error?

#

The world ur getting from ur config is null

#

Actually

#

Try to read and understand the error

#

No ur understanding it wrong

#

The world that it returns isnt null

#

The name you are giving it is null

#

It doesnt mean that the server cant find the world

#

It means you cant find the world name

#

Or well your plugin

#

Typo

#

U misspelled arenas

#

Try to not rush it

#

Cuz ur gonna make typos

#

Lmao

#

Yes

#

Coding is fun

#

When you get the hang of somethinf you can do whatever you want

#

Its so powerful

#

Can be frustrating though

#

Ok

#

Cya

#

Does it work though

#

Lmao

#

Nice

formal dome
#

dang there's already a java 17

#

i'm gonna go ahead and assume that spigot still uses 16

#

is that correct?

proud fiber
#

p u m p

chrome beacon
#

Spigot probably won't update until mojang does

formal dome
#

feels like 16 came out yesterday

plain helm
#

I can’t imagine how many pings “even” has

glossy venture
#

Didnt u fix it?

#

Is the event being called?

#

Ping when u need me

proud fiber
glossy venture
#

Send the code

proud fiber
#

Ok

undone axleBOT
glossy venture
#

Use that for big chunks

proud fiber
#

Okay

glossy venture
#

Holy shit

#

OpenJDK?

formal dome
#

not sure

ivory sleet
#

Yes open

glossy venture
#

Would make sense

formal dome
#

i was just trying to make a spring jar and it said 17 not 16 lol

ivory sleet
#

And it’s stable enough

glossy venture
#

Wow

#

Epic

formal dome
#

oracle's on fire

glossy venture
#

Open source projects are so good

glossy venture
ivory sleet
#

Cant wait for jdk 18 honestly lol

formal dome
#

why

glossy venture
#

But contributors also help a lot i think

paper viper
glossy venture
#

@proud fiber

formal dome
#

java 17 just came out and he's asking for java 18

#

why

ivory sleet
#

Vector API third incubator

paper viper
#

Actually

glossy venture
#

New version of java is always exciting

paper viper
#

And also

ivory sleet
#

And utf will be defaulted

paper viper
#

Sealed types

ivory sleet
#

Which is very nice

proud fiber
paper viper
#

Sexy instanceof checks

proud fiber
#

I am reopening it

glossy venture
formal dome
#

bruh i'm gonna die

ivory sleet
#

Since specifying StandardCharsets.UTF_8 is annoying

formal dome
#

so many messages

glossy venture
#

I just wanted to cehck if u still needed help

#

Bruhhh

proud fiber
#

yes I need pls :-)

glossy venture
#

Ok

#

Is it throwing an error?

proud fiber
#

No

#

there

glossy venture
#

Did u try to debug it using println

proud fiber
#

yep

#

it worked before if statements

#

but when i try in if statements it doesn't work

#

i removed the return and it worked, however it worked in every gui possible

muted sand
#

maven related question, but how do i output my plugin directly into my plugins folder in my server dir?
google didn't help

glossy venture
#

What if statements?

#

The ones at the start of the method?

#

Like the ones checking for null?

proud fiber
glossy venture
#

Do you know exactly which one fails?

#

Which if statement

proud fiber
#

it's probably the first one

#

not sure

#

but like 99% it's the first one

glossy venture
#

Try using print

proud fiber
#

ok

glossy venture
#

Put like "if statement # passed"

proud fiber
#

in first one?

#

ok

glossy venture
#

After each one

#

And see how many it passes

proud fiber
#

but

#

i'll get unreachable code error

#

because of the returns

glossy venture
#

No because it doesnt always return

#

As long as it doesnt give a compiler error ur fine

#

Put it after the if statements

#

Not in them

#

Like the next line

#

Not after the return

proud fiber
#

ok nvm it doesnt give unreachable code

glossy venture
#

Yeah

#

Its not after the return

#

Now test

proud fiber
#

only 1st one

#

it's not passing it

glossy venture
#

Did yoy place it qfter or before rhe first one

proud fiber
glossy venture
#

The event.getinventory doesnt return rhe clicked inventory i think

#

You will have to check the inventory views name

proud fiber
#

wdym?

glossy venture
#
if (event.getView().getTitle().equals(inventory.getTitle())
proud fiber
#

hm let me try

glossy venture
#

Or you can use

if (event.getView().getTopInventory() == inventory)

(I think, havent tested it)

#

I recommend this qctually

#

For when you change the title

proud fiber
glossy venture
#

Oh yeah

#

Forgot

#

The class field

#

That holds rhe inventory

#

In your code

proud fiber
#

let me try that

#

works but it still works in any gui

glossy venture
#

Did u put in the return statement?

proud fiber
#

mhm

glossy venture
#

Whattt

#

Try the title based one

proud fiber
#

ok

glossy venture
#

Otherwise idk

#

I gtg in a sec

proud fiber
glossy venture
#

I have no fucking clue

#

Sorry

#

Watch a tutorial

proud fiber
#

np thanks for helping me

#

I'll just recode the whole thing ig

#

pretty sure i fucked up a line or 2

quaint mantle
#

worth a shot since updates are happening so fast now lol

dusty kindle
#

Hello so i am making chat messages for my plugin and idk how to add prefixes

#

public class ChatMessages implements Listener {

    public ChatMessages(AquaEssentials plugin){
        plugin.getServer().getPluginManager().registerEvents(this, plugin);
    }

    @EventHandler
    public void onChat(AsyncPlayerChatEvent event){
        Player p = event.getPlayer();
        event.setFormat("PREFIX " +ChatColor.of(new Color(255, 178, 0))+ "%s " + ChatColor.of(new Color(255, 255, 255))+ "%s ");
    }
}
crude charm
#

Eclipse 🤮

crude charm
#

Pretty sure thats the issue

brave trellis
#

Is there an alternative to the getNearbyEntites but can run async and not only sync

#

or looping through all the entites in a world async

quaint mantle
#

How can I make my code run on Buckminsterfullurene atomic usage for my plugin?

vague oracle
brave trellis
#

doesn't matter if it has to be done with some sketchy methods

vague oracle
#

well whats the problem using the above method?

brave trellis
#

what?

vague oracle
#

what is the problem with using getNearbyEntites

brave trellis
#

it runs every time a movement packet is sent with the plugin im making

vague oracle
#

doesn't sound like the best way to go about what ever you are doing

quaint mantle
#

doesnt sound very performant

brave trellis
#

or somehow an alternative way

vague oracle
#

async will always be wrong, you making some sort of anit cheat?

brave trellis
#

yes

#

all im trying to do is somehow find a boat nearby a player

vague oracle
#

its probably better of to do random checks

#

rather than 1 every movement

quaint mantle
#

movements are called thousands of times per second

brave trellis
#

no they aren't

quaint mantle
#

they are

brave trellis
#

per packet?

#

PacketPlayInFlying

quaint mantle
#

try it

brave trellis
#

I have

quaint mantle
#

flying?

vague oracle
#

Isn't it the entityteleport packet for moving

brave trellis
#

no?

#

everytime a PacketPlayInFlying is received from the client

#

it runs

vague oracle
#

Doesn't really matter what packet you listen to, still the same result, as in needing to use another method to check movement

#

is it a speed check or a wall check or a fly check or a fall check

brave trellis
#

jesus

#

fluid walk cheat

dry forum
#

how could i get text between percentage signs

quaint mantle
#
private final Pattern placeholderPattern = Pattern.compile("%(.+)%");
dry forum
#

thanks

vague oracle
#

I might be being dumb, but why do you need nearby entities for a jesus check

brave trellis
#

boats

#

or standing on a boat on open water

#

mainly the later

vague oracle
#

does your Y value change whilst running over a boat?

brave trellis
#

no

#

no and yes

#

it fluctuates sometimes

#

For example, sometimes a player would be in that "glitch" spot if you stand on a boat, it makes you hard to move on it, and the y axis bounces

#

otherwise the Y axis is the same

#

the checks are all made, the AC is done, just trying to optimize it in a way where it doesn't kill the server

#

and the only thing left is that getNearbyEntities problem

vague oracle
#

Unfortunately, I don't know much but my best guess would be there is way around not having to check for boats

brave trellis
#

yeah thats what i was thinking too, but couldn't think of a way

#

well thanks though

barren nacelle
#

?paste

undone axleBOT
barren nacelle
#

So I was trying to make a hologram called "001" when I placed a block I know its messy but does anyone know why its not working when I place a block https://paste.md-5.net/otekiqapop.java

quaint mantle
#

great.

#

what caused it to broke?

#

you punch it or what

outer sorrel
#

are there any api library things for spigot in php?

valid solstice
#
if(!(sender.hasPermission("etp.use"))){
            player.sendMessage("§l§e(!)§r§c You are missing the required permission: §retp.use§r§c to use this command!");
            return true;
        }
``` this is what i wrote to check for the perms
young knoll
#

What’s the issue? Perms or the command

valid solstice
#

its giving me true for if(!(sender.hasPermission("etp.use")))

#

which should be false because i have the permission "etp.use"

young knoll
#

What permission system is that

valid solstice
#

i just typed it out in permissions.yml

#

i dont have any plugins managing permissions

young knoll
#

Ah, I’ve never used that so ¯_(ツ)_/¯

paper viper
#

You aint op right

#

lol

valid solstice
#

yes im not op

#

but i specifically put the permission under my name

paper viper
#

Is that Pex?

#

You should use LuckPerms instead because Pex is outdated

#

But did you list the permission in your plugin.yml or somewhere at least too?

valid solstice
#

i just typed out my name and the permission under my name

#

thats it

#

it should recognize that i have the permission right?

valid solstice
paper viper
#

Ah I see

valid solstice
#

...so it should work right?

paper viper
#

I never tried it

#

so im not sure

#

i always used like luckperms

valid solstice
#

hmm... so its not possible managing permissions without luckperms?

worldly ingot
#

permissions.yml is really not meant to be a proper permissions management system

#

It was a poor mans attempt at it in early Bukkit inspired by WEPIF. You're most definitely better off using LuckPerms to handle permissions in almost every situation

sharp kelp
#

Will

event.getDrops().clear();

Work for remove drops of the entity that died in entity death event?

worldly ingot
#

Yes. It's mutable

#

Can add to, remove from, or clear the list as you see fit

muted sand
#

If i were to access a hashmap (or any other collection) inside an asynctask, should i use the synchronized keyword?

#

or is a nono for spigot

#

I am creating the collection inside the async task, so i presume it would be fine as other events wouldn't be able to access / modify it?

paper viper
#

If multiple threads are using the HashMap, use a concurrenthashmap

#

Otherwise, if it’s just the same thread, it’s fine

spare marsh
#

I want to make a plugin that listens to when you move items around an inventory so that it can make the same changes to other invenotr

#

inventory

#

what is the best even to use for this

#

Example if you click on slot 20 to drag the stack around, the item in slot 20 on the other will disappear to and be placed where it was placed on inventory 1

paper viper
#

Inventory#setContents

#

Then listen to inventory events

#

And use the method

quaint mantle
#

use ChatColor.translateAlternateColorCode()

valid solstice
quaint mantle
#

its a bad practice in general and for future compatibility

valid solstice
#

oh ok

young knoll
#

Technically the ChatColor enum is the preferred way

#

But it is quite annoying

subtle kite
#

how should I get if a event in a time period.

#

if x happens x amount of time.

quaint mantle
#

use a int

#

then each time the event occur just increase by one

#
@eventhandler
public void onsomething(somethingcool e) {
i++
}```
subtle kite
#

ok I have ideas what to do. thanks

quaint mantle
#

just save it to the config

#

and change int i; to int i = plugin.getConfig.getInt(paht);

#

when the config start (or create) for the first time

#

just add the path is 0

cursive summit
#

heya

#

i need some help please

#

I need help for a project, please can someone help me build some things for my map? ... so I don't know much of English actually and if anyone can help me I would thank you very much

cursive summit
#

thanks😅

quasi shoal
#

hey! has anyone tried developing plugins with kotlin? is it a viable idea, and how hard is it to set up a spigot kotlin project?

white thicket
#

Hey, so I have coded a bot which sends discord message to minecraft which is perfectly fine just that it is sending it 3 times even if someone types a message once
Code

    @Override
    public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) {
        super.onGuildMessageReceived(event);
        if (botEnabled) {
            if (event.getChannel().getId().equals(plugin.getConfig().getString("chatIntegrationChannelID"))) {
                if (!Objects.requireNonNull(event.getMember()).getUser().isBot()) {
                    String format = plugin.getConfig().getString("DiscordToMinecraftFormat");
                    assert format != null;
                    format = format.replace("{user}", Objects.requireNonNull(event.getMember()).getUser().getName());
                    format = format.replace("{message}", event.getMessage().getContentRaw());
                    Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', format));
                }
            }
        }
    }

I asked this question before too at that time I was asked to check if my bot was running 3 times but it is not the case, the bot is only running by the plugin

undone axleBOT
glossy venture
#

this a good place to find people who can help you

#

with building

#

and stuff

glossy venture
#

or your bot is running three times

white thicket
glossy venture
#

then try removing super.onGuildMessageReceived

#

how did u check it

#

im assuming ur using JDA

#

ive used it to make a bot once

white thicket
#

I mean it is in my plugin so ofc it will be in JDA

glossy venture
#

theres another java discord lib

#

discord4j i think

white thicket
#

ik but JDA is the most used once

glossy venture
#

yeah

#

but how did u check it

white thicket
#

It is easy,
1st I checked if the bot is running by some other plugin or anything, I stopped my server to check if bot is still online if not then it is not being used by some other stuff
2nd It is my bot so ik I haven't used it elsewhere
3rd I also have a system where it sends in game message to discord and if bot was running 3 times then it should've sent the same message three times on discord too

glossy venture
#

ok

#

try removing the super.onGuildMessageReceived

#

do you have multiple listeners registered

#

or multiple instances of the same one

#

which could explain it

white thicket
#

I do have multiple listeners registered but not of the same one

glossy venture
#

do any other listeners listen to this event

white thicket
#

I don't think so but let me recheck because I was doing some stuff with that class

#

And also this thing was working fine before

glossy venture
#

what

white thicket
#

Then I did something idk what and it started sending 3 messages

glossy venture
#

you probably made it register 3 instances of the listener

#

accidentally

white thicket
#

hmm let me check

#

wait

#

could it be because I am trying to register 3 different listeners in 1 try catch statement?

glossy venture
#

can you send the code where you register it

undone axleBOT
white thicket
#

oh wait let me try something

glossy venture
#

why are your variable names camel case

#

why do they start with capital letter

#

change them first of all could mess with types

#

as cthey are also camel case

white thicket
#

yes ik ;-; I will change them

glossy venture
#

also those register statements dont throw a LoginException

white thicket
#

Done changed

glossy venture
#

can you send me your whole Discord class

#

thats the discord listener right

#

al least the constructor, declaration and event handler method

white thicket
#

eh IntelliJ IDE suggest it 😂

#

the try was only for Discord

#

No the others yes

glossy venture
#

I recommend changing it to DiscordListener

white thicket
#

forgot

glossy venture
#

but can you send me the code

#

behind the Discord class

white thicket
#

Fixed it too

glossy venture
#

can be through dms

#

if ur scared of people stealing ur code or something

#

i dont think they will though

white thicket
#

I will send you the whole Discord class in your DMs 😛

#

No one would like to steal messy code anyways

glossy venture
#

ok

#

?paste

undone axleBOT
glossy venture
#

better idea to use that

#

no character limit

#

dude

#

you are adding the event listener three times

#

because you are doing it in ur constructor

#

so you are creating an instance, then you are creating another instance and registering it

quaint mantle
#

uhhh

#

maybe that guy need an example of that

#

i used constructor all the time

zinc monolith
#
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  8.415 s
[INFO] Finished at: 2021-10-14T16:46:24+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project bungeecord-chat: There are test failures.
[ERROR]
[ERROR] Please refer to /home/camar/repos/BungeeCord/chat/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project bungeecord-chat: There are test failures.

Please refer to /home/camar/repos/BungeeCord/chat/target/surefire-reports for the individual test results.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject``` any idea what causes this error?
#

when building bungeecord

chrome beacon
#

Tests failed

#

Why are you building bungeecord?

zinc monolith
#

im trying to edit the source

chrome beacon
#

Look at test report and see what failed

quasi shoal
#

i didn't get an answer before, so im asking again
hey! has anyone tried developing plugins with kotlin? is it a viable idea, and how hard is it to set up a spigot kotlin project, and how would i do that?

glossy venture
#

i think bukkit has built in support for java and scala, but not for kotlin

#

youre probably going to need to use antoher plugin that implements kotlin support

#

to build it on top of

quasi shoal
#

i see

glossy venture
#

i dont use scala or kotlin so idk how you would do that

tacit drift
ivory sleet
ivory sleet
#

And all three compile to jvm bytecode

verbal nymph
#

Are there any best practices / must-follow conventions for NamespacedKeys?
I'm adding custom crafting recipes from a config file in a loop.
Can I just give them NamespacedKeys like custom_recipe_1 custom_recipe_2 or custom_recipe_randomString ?

#

Or is it essential that recipes get the same NamespacedKey again after a server reboot / changes to the config?

drowsy helm
#

Well i don't think theres any definite naming convention, but since namespacedKeys are plugin dependent its really up to you. I don't think it matters all that much

ivory sleet
#

Which you must follow

#

I’d avoid numbers also

pastel stag
#

how does one utilitze Bukkit.getScheduler().scheduleSyncRepeatingTask(); to run scheduledTasks.SQLAutoCheck() once every 5 minutes?

#

does anyone know what the formatting is? im just finding what looks to be a lot of wrong info from deprecated usages/methods

eternal night
pastel stag
#

this will also work w/ repeating tasks?

#

not just a 1 time use delayed task

eternal night
#

the page also describes repeating tasks

valid solstice
#

is it a good way to store coords in a yaml (including the world object) and get it later from the yaml file?

#
World dest_w = (World) locations.get(dest_name+".w");
                Double dest_x = (Double) locations.get(dest_name+".x");
                Double dest_y = (Double) locations.get(dest_name+".y");
                Double dest_z = (Double) locations.get(dest_name+".z");
``` Im doing something like this
#

and FileConfiguration locations = YamlConfiguration.loadConfiguration(file);

eternal oxide
#

So long as yoru world is loaded just store teh full Location

#

its already serializable

plain helm
eternal oxide
#
Location loc = player.getLocation();
config.set("spawns.1", loc);
config.save();
loc = config.getLocation("spawns.1");```
valid solstice
#

AHH

#

i see what you mean now

#

i dont know why i didn't think about that, i instead get every x, y, z and planned to make a new location class

#

thanks for the help!!!!

full holly
#

how can I update a score in spigot 1.17? (scoreboard)

crude sleet
#

Is it possible to tell a particle to go immediately? It just looks completely stupid if you have wings made of particle and then move around

glossy venture
#

But i rhought there was some kind of special kotlin based api u needed

#

But thats optional

#

As ive just learned

tardy delta
#

what's the best way of getting messages? storing them in a map or something?

shrewd hemlock
#

is there a way to set instead of the ping in the tablist a custom value?

ivory sleet
alpine urchin
#

with packets

#

idk if possible with bukkit

compact cape
#

Does anyone know which one is which?

paper viper
#

you arent supposed to post NMS code here

#

but

#

you can compare 1.16 nms

#

to 1.17

alpine urchin
paper viper
#

iirc

#

b is SYSTEM

alpine urchin
#

chat

#

system

#

game info

paper viper
#

Yep

alpine urchin
#

its the setting in ur client

#

chat setting

compact cape
#

why they changed it to abc 😦

alpine urchin
#

obfuscated

paper viper
#

Yeah

arctic delta
#

Hey guys how can i set inventory contents before running the command? e.g. i use a tool to open the inventory 🙂

compact cape
#

It's almost impossible to work with them now

alpine urchin
#

use mappings then

paper viper
#

i just compare nms 1.16 and 1.17

#

cause like 90% of the time its the same

ivory sleet
compact cape
compact cape
ivory sleet
#

Wym

paper viper
#

because mojang

alpine urchin
#

use mappings

hasty prawn
#

Yeah if you're doing extensive work with NMS you should use Mojmaps

alpine urchin
#

my god

#

xd

#

now he will ask how to use mappings

compact cape
#

I like the "MojMaps"

alpine urchin
#

what

#

tf

#

even worse

#

what are mappings he will ask

compact cape
#

😅

alpine urchin
#

its not maps

#

XD

glossy venture
#

mapping is like using a map (aka a dictionary, you can also see it as a dictionary)
you bind something to a value, like a key value pair
in the case of code mappings you bind the obfuscated symbols to the real names to make it much easier to work with them

alpine urchin
#

you basically get access to unobfuscated source

glossy venture
#

its like a dictionary actually

ChatMessageType.a
    ChatMessageType.CHAT
compact cape
#

I know the mapping 😂 My profession is with Python and Python is all about mapping and dictionaries

alpine urchin
#

nice

shrewd hemlock
alpine urchin
#

use mojang mappings

alpine urchin
#

just eating rn

#

xd

shrewd hemlock
#

ok

alpine urchin
#

you can change ping in tablist

#

the bars

#

can be changed

shrewd hemlock
#

yes this will be enough

alpine urchin
#

remove??

#

why

#

he wants to change it

#

its ok my son

shrewd hemlock
#

adding something next to it will be enough

#

but how?

tardy delta
paper viper
#

a locale is a class full of only chat components/messages

#

For example

#

LuckPerms has the same format too

glossy venture
#

you can then import different translations through a config file

#

into the locale class

paper viper
#

you'd have to use manually encoded Strings

#

like getLocaleKey("ERR_MESSAGE")

#

rather than

#

Locale.ERR_MESSAGE

#

But if you have a ton of messages

glossy venture
#

yeah

paper viper
#

its probably better

glossy venture
#

but you can configure your own tab complete helper right

paper viper
#

However, there is another issue too tho

#

with arguments

glossy venture
#

for commands its really easy

paper viper
#

if you are formatting arguments

#

that would be a bit more complex

#

cause you need to apply string#format

tardy delta
#

i was thinking about an enum with all my messages and a default message

paper viper
#

and some stuff

#

yea

glossy venture
#

i would keep commands one translation yeah

paper viper
glossy venture
#

otherwise it would be way too complex

tardy delta
#

but why an interface as it are only colored strings?

paper viper
#

for example

#

my component can accept an argument

#

and add it into the component

#
  UniComponent<Sender, String> STARTING_VIDEO = (mrl) -> format(
      text("Starting Video on MRL %s".formatted(mrl), GOLD));
#

I pass the mrl inside

#

and it can build the component with it

tardy delta
#

can you show an example how to use it?

#

whoa

undone axleBOT
paper viper
#

where mrl is a String

#

and it can build the component and display message

#

with the mrl inside the messsage

#

For example, if I have a command /video set color BLUE

tardy delta
#

hmm interesting

paper viper
#

and you want the user to get a message

#

You set the color to [COLOR]

#

which is blue in this case

#

you can pass in BLUE

#

and customize the component

#

Core, i recommend creating a new thread

regal moat
#

There

tardy delta
unique meteor
shrewd hemlock
#

so how?

paper viper
#

you can put whatever in there, I just added it just in case if i wanted to support other platforms or smthing

quaint mantle
#
PacketPlayOutEntityMetadata metadataPacket = new PacketPlayOutEntityMetadata(a.getId(), a.getDataWatcher(), true);
                    ^^^^

what is that true at the end of code
what will change if it is false

fickle helm
#

hello, with my plugin I'm listening to https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/PlayerDeathEvent.html#getDeathMessage()
then replacing the mob's name with something else then updating it with https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/PlayerDeathEvent.html#setDeathMessage(java.lang.String)
a person who's on a russian server says this is causing all the death messages to be in english instead of russian.
Does calling setDeathMessage somehow override the language it would've normally used?

#

without my plugin

#

with it:

alpine urchin
#

um

#

bukkit won’t translate your death message

fickle helm
#

thing is all i'm doing is a string replace from zombie to lvl 25 | zombie for example

#

not sure why it changes the russian version of was slain by and others

alpine urchin
#

can be some other plugin

#

on his server

fickle helm
#

he claims removing my plugin fixes it

alpine urchin
#

that modifies your message

regal dew
# regal moat bump

The error tells you what's wrong, you're trying to access coordinates -144 within a chunk; while the chunk only has a domain of [0, 15]

#

java.lang.IllegalArgumentException: x out of range (expected 0-15, got -144)

regal moat
#

ah

#

so are my for loops wrong?

regal dew
#

yes, what are you trying to do in the loop?

#

iterate through the full chunk?

quaint mantle
alpine urchin
#

is the boolean not used?

#

let me check

regal moat
regal dew
#

Then your loops should look like this (1.17 with support for the extended world height):

World world = chunk.getWorld();
int maxY = Math.abs(world.getMinHeight()) + world.getMaxHeight();
for (int x = 0; x < 16; x++) {
    for (int y = 0; y < maxY; y++) {
        for (int z = 0; z < 16; z++) {
            Block block = chunk.getBlock(x, y, z);
            ...
        }
    }
}
alpine urchin
#

but what i know is its not irrelevant

#

sorry for not being much of a help

regal dew
#

@alpine urchin @quaint mantle the boolean indicated whether the data should be force updated

#

you likely want this to be set to true.

quaint mantle
#

?

regal dew
#

flush everything or only dirty data

quaint mantle
#

wait

#

i dont get it

#

what do you mean force updated

#

update ?

#

changing for example metadata

#

?

regal dew
#

just set it to true

glossy venture
#

in the for loop

#

._.

quaint mantle
#

performance issues ?

regal dew
glossy venture
#

in 1.18 they wont be anymore :p

regal dew
#

They do ^^

glossy venture
#

u added support for the world height in your maxY equation

#

but that would cause an overflow

regal dew
#

chunk sections start from 0 -> ((minBuildHeight + maxBuildHeight)/16)

#

thats currently in 1.17

#

in 1.18, this might be different

glossy venture
#

also

int maxY = Math.abs(world.getMinHeight()) + world.getMaxHeight(); // will cause an out of bounds error, replace with
int maxY = world.getMaxHeight();
#

1.18 i mean

tawny talon
#

Hello, I'm trying to make a gamemode command but I have a problem, I want to make that /gmc puts you directly in creative mode but I have to do /gamemode gmc, can someone help me in that?

opal juniper
#

register gmc in your plugin.yml

#

then just add a command executor

tawny talon
#

if (label.equals("gmc")) {
p.getPlayer().setGameMode(GameMode.CREATIVE);
p.sendMessage(PrefixUtil.prefix + "Setted game mode creative");

#

i made that in this way

#

and i registered gmc as an aliases of /gamemode

minor garnet
#

where you get this ascii image

clear blade
#

yo real quick, on Entity.getUniqueID(), does it return a UUID that looks like cbf8d615-b440-49cc-90de-9e66d7c8ac53 or does it not contain the -s?

ivory sleet
#

It’s just stored in bytes iirc

#

Whether it uses - or no - depends on the format you want to use when stringifying it

#

But iirc by default the - is included in toString

quaint mantle
#

UUID#toString contains dashes ^

indigo cave
#

hello! how can i get the distance between two blocks?

quaint mantle
#

Location#distance

#

(or the much faster Location#distanceSquared)

alpine urchin
#

distance is basically sqrt(distanceSquared)

#

so it might be heavy cause of the square root

quaint mantle
#

my listeners aren't activating at all this is my main class: ```java
public class Main extends JavaPlugin {

public void onEnable() {
    getCommand("flystick").setExecutor(new FlyStickCommand());
    Bukkit.getPluginManager().registerEvents(new FlyStickCommand(), this);
}

}```

#

this is my listener ```java
@EventHandler
public void onInteract(PlayerInteractEvent e) {
Player player = e.getPlayer();
if((e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) && e.getItem().equals(Material.STICK) && e.getItem().containsEnchantment(Enchantment.KNOCKBACK)) {
Vector v = new Vector(player.getEyeLocation().getX(), player.getEyeLocation().getY(), player.getEyeLocation().getZ());
player.setVelocity(v);

    } else {
        return;
    }
}```
#

can someone help me?

eternal oxide
#

player.getEyeLocation().toVector()

alpine urchin
#

how do you know its not activating

quaint mantle
#

because when I right click my stick it won't do anything

eternal night
#

That is not how you compare materials tho

#

You'll need to actually get the items type

#

Your ide should be yelling at you anyway

quaint mantle
#

it isn't tho

eternal night
#

Sounds like a bad ide/disabled warnings

quaint mantle
#

umm not bad ide and I didn't disable warnings

#

the ide is Eclipse

alpine urchin
#

Lol

eternal night
#

XD

#

Anyway, fix your material comparison

quaint mantle
#

how

#

==?

eternal night
#

getItem returns an item stack

alpine urchin
#

getItem().getType() returns a Material

quaint mantle
#

oh k

eternal night
#

Call getTyp3

#

Ywa

#

Besides that your vector is pretty likely not what you want

quaint mantle
#

how?

#

I want to fling myself in the air when I rightclick the stick

eternal night
#

Constructing it using the X y and z of the players head location makes no sense

quaint mantle
#

where the player is looking

eternal night
#

E.g if the player is at 0,0,0 with their head this would give you 0 velocity

quaint mantle
#

that fine you have to look up to be able to fly

alpine urchin
#

helpful guide

eternal night
#

Probably look at Location#getDirection

alpine urchin
#

can help you achieve your goal

quaint mantle
eternal night
#

Yea

quaint mantle
#

k

#

also is there anything wrong with main class?

eternal night
#

Also give the tutorial a read as you don't seem to know much about vectors yet

quaint mantle
#
Bukkit.getPluginManager().registerEvents(new Command(), this);```
eternal night
#

Interesting name for a listener class

quaint mantle
#

just made it up

#

actually it is a ComandExecutor

#

thats where the listener is located

eternal night
#

Yea looks good

quaint mantle
#

k thx I am gonna make fixes and test now

tardy delta
#

does an enum constructor has an access modifier?

eternal night
#

Isn't it implicitly private ?

#

Tho I am not too sure

lean gull
#

heyo, does anyone have an idea for a good clickable / hoverable text thing? i know that was a bad explaination but i mean like Skript, where you can do "tooltip:hihello<reset>" and then if you hover over on hello you will get a tooltip saying hi

eternal night
#

Look into Mini-Message and the adventure platform maybe ?

lean gull
#

what are those?

eternal night
#

Mini-Message has a similar style

quaint mantle
#

yes

eternal night
#

Yea

quaint mantle
#

smh my head

lean gull
#

i don't really understand the usage example

#

do you know how to just make the skript one? it's very easy to use

eternal night
lean gull
#

does anyone know how to do it? pls i need help i am big nub

quaint mantle
tardy delta
#

smh how is this valid
Class<?>[]... a

eternal oxide
#

an array of classes

lusty oyster
#

hi
how can i add latest mongodb driver
to spigot plugin

quaint mantle
#

anyone know how to change the anti cheat in the spigot server?

#

I have a flying plugin

regal moat
#

Alright, so.
I am trying to randomize every block in a chunk.

#

?paste

undone axleBOT
young knoll
#

You are trying to be place a clock

#

Use Material.isBlock

tardy delta
proud fiber
# glossy venture I have no fucking clue

after like 6 hours i finally did it, it was so frustrating for such small thing.

here is the line of code for the first if statement if u are curious, hope it helps u one day:

        if (!((event.getView()).getTitle().equalsIgnoreCase(ChatColor.RED + "" + ChatColor.BOLD + "Choose the superhero"))) {
full holly
young knoll
#

Please don’t compare inventories by title

#

Use the view returned from openInventory and set.contains

proud fiber
#

I've searched internet

#

Youtube

#

Reddit

#

Spigot

#

Everything

#

And that's the only way i managed to do

paper viper
#

Comparing inventory by titles is a sin

proud fiber
#

Well

paper viper
#

you should be using inventoryview

proud fiber
#

That's easier

regal moat
paper viper
regal moat
#

Here's the updated code: ```java
public static Block[] getAllBlocks(final Chunk chunk) {
World world = chunk.getWorld();
int maxY = Math.abs(world.getMinHeight()) + world.getMaxHeight();

    final Block[] amount = new Block[16*maxY*16];

    for (int x = 0; x < 16; x++) {
        for (int y = 0; y < maxY; y++) {
            for (int z = 0; z < 16; z++) {
                Block block = chunk.getBlock(x, y, z);
                BlockState state = block.getState();
                if (block.getType() != Material.AIR && !(state instanceof TileState)) {
                    amount[y*16*16] = block;
                }
            }
        }
    }
    return amount;
}

@EventHandler
public void onMove(PlayerMoveEvent e){
    if (!(e.getFrom().getChunk().equals(e.getTo().getChunk()))){
        if (!(chunks.containsKey(e.getTo().getChunk()))) {
            chunks.put(e.getTo().getChunk(), true);
            Block[] blocks = getAllBlocks(e.getTo().getChunk());
            for (Block b : blocks) {
                Material random = Material.values()[new Random().nextInt(Material.values().length)];
                if (random.isBlock()){
                    b.setType(random);
                }
            }
        }
    }
}
young knoll
#

Add the view to a set

#

And check set.contains in the event

proud fiber
paper viper
#

Yes, very big difference

#

your method presents a design flaw

#

which will fail

proud fiber
#

When

regal moat
#

Is that suppossed to fix my problem?

paper viper
#

If there is another GUI with the same name, if your GUI names are not correct (comparing GUI names with color codes is very bad)

#

Use reference equality on InventoryView

young knoll
#

Read your error

proud fiber
#

oh I didn't think of that

regal moat
#

Oh

proud fiber
#

How do I do it then

regal moat
#

So there is nothing in the list?

full holly
proud fiber
#

I am heacking confused rn

young knoll
#

No, there is a null in the list

regal moat
#

how did it get there

#

oh i know how

#

thanks

regal moat
# young knoll Read your error

Alright, I updated the code. Now the server just freezes.

    public static Block[] getAllBlocks(final Chunk chunk) {
        World world = chunk.getWorld();
        int maxY = Math.abs(world.getMinHeight()) + world.getMaxHeight();

        final Block[] amount = new Block[16*maxY*16];
        for (int c = 0; c < maxY*16*16; c++){
            for (int x = 0; x < 16; x++) {
                for (int y = 0; y < maxY; y++) {
                    for (int z = 0; z < 16; z++) {
                        Block block = chunk.getBlock(x, y, z);
                        BlockState state = block.getState();
                        if (block.getType() != Material.AIR && !(state instanceof TileState)) {
                            amount[c] = block;
                        }
                    }
                }
            }
        }
        return amount;
    }
tardy delta
#

i'm looking for something in an enum so you can set a boolean in the values and that would mean a method requires parameters

#

but i cant force taking parameters

glossy venture
#

the one with c

#

i think the server freezes because you are trying to run 16*16*16*16*256*256 iterations of a for loop

#

remove the outer loop

#

4,294,967,296 iterations per chunk

opal juniper
#

or do it async

glossy venture
#

why do they have the c loop

#

the outer loop

#

why

opal juniper
glossy venture
#

oooh

#

they are trying to use c as an index

#

yeah thats not how that works

regal moat
glossy venture
#

does it not freeze?

#

anymore

regal moat
#
    public static Block[] getAllBlocks(final Chunk chunk) {
        World world = chunk.getWorld();
        int maxY = Math.abs(world.getMinHeight()) + world.getMaxHeight();
        int c = 0;

        final Block[] amount = new Block[16*maxY*16];
        for (int x = 0; x < 16; x++) {
            for (int y = 0; y < maxY; y++) {
                for (int z = 0; z < 16; z++) {
                    Block block = chunk.getBlock(x, y, z);
                    BlockState state = block.getState();
                    if (block.getType() != Material.AIR && !(state instanceof TileState)) {
                        amount[c] = block;
                        c += 1;
                    }
                }
            }
        }
        return amount;
    }
```No, but it's pretty laggy
opal juniper
#

why not just use a Set

#

and add to it

#

or a list

young knoll
#

Well yeah, you are looping over entire chunks

opal juniper
#

if you need the index

glossy venture
#

try to do some optimizations

young knoll
#

Also lists are faster when doing a lot of insertions iirc

#

Not sure about arrays

regal moat
#

Mmm

glossy venture
#

arrays are the fastest with insertions

regal moat
#

I am confused

glossy venture
#

they just set memory

opal juniper
#

It seems stupid to have a fixed size array

glossy venture
#

nah

full holly
glossy venture
#

it excpects a full array of blocks

regal moat
#

Yep

glossy venture
#

it excpects a full chunk of blocks as return type

#

its on the bukkit developers to improve it

#

or mojang

#

whoever wrote that shit

opal juniper
#

yeah i can see that, meh what i would do is use a list and then just grab a chunk snapshot before hand and run it async

regal moat
#

I am only adding it to the list its not air

regal moat
#

thats why there are some nulls

#

maybe?

glossy venture
#

oh

#

yeah

#

smart

#

what are u using the method for

#

@regal moat

#

the getAllBlocks

tardy delta
#

is there a way to force this method to take a parameter when some value in my enum is true?

opal juniper
#

also the Block#isEmpty() would probably work

glossy venture
#

no way to do it at compile time

tardy delta
#

yea but the user doesnt know if he has to specify an arg

glossy venture
#

what

#

then send an error message

tardy delta
#

if he doesnt it will look like "player {0} not found"

glossy venture
#

instead of throwing an exception

#

well then do that

tardy delta
#

mmm probably have to make a way around

glossy venture
#

???

tardy delta
#

so the user knows he has to specify args

regal moat
# glossy venture the `getAllBlocks`
    @EventHandler
    public void onMove(PlayerMoveEvent e){
        if (!(e.getFrom().getChunk().equals(e.getTo().getChunk()))){
            if (!(chunks.containsKey(e.getTo().getChunk()))) {
                chunks.put(e.getTo().getChunk(), true);
                Block[] blocks = getAllBlocks(e.getTo().getChunk());
                for (Block b : blocks) {
                    Material random = Material.values()[new Random().nextInt(Material.values().length)];
                    if (random.isBlock()){
                        b.setType(random);
                    }
                }
            }
        }
    }```
glossy venture
#

since when are biomes 3d

tardy delta
#

instead of just warning aftet that

glossy venture
#

what are u trying to accomplish

young knoll
#

But it’s not used in the overworld until 1.18

glossy venture
#

oh yeah for nether biomes ofc

#

and end maybe

regal moat
glossy venture
#

oh yeah

#

ok

#

so ur regenerating a chunk every time someone enters it

regal moat
#

Yes

opal juniper
glossy venture
#

lemme look at the chunk class

opal juniper
#

seems very inneficient

regal moat
#

Randomising the chunk

#

Every block of the chunk

#

randomised

#

Well, to not to randomise the same chunk over and over again

#

I am adding the chunk into a hashmap

#

And checking if the chunk was entered before, before running the code

opal juniper
#

please tell me you are not storing the chunk in a hashmap - and are using the chunkkey or sommin

regal moat
#

uh oh

young knoll
#

Why not randomize the chunk on generation

regal moat
#

Maybe because I don't want that

glossy venture
#
    @EventHandler
    public void onMove(PlayerMoveEvent e){
        if (!(e.getFrom().getChunk().equals(e.getTo().getChunk()))){
            if (!(chunks.containsKey(e.getTo().getChunk()))) {
                chunks.put(e.getTo().getChunk(), true);
                regenerate(e.getTo().getChunk(), new Random());
            }
        }
    }

    public static void regenerate(Chunk c, Random r) {
      // get world
      World world = c.getWorld();
      
      // get min and max height
      int mn = world.getMinHeight();
      int mx = world.getMaxHeight();
    
      // get material enum info
      Material[] v = material.values();
      int l = Material.values().length;
      
      // loop over blocks and set them to random material
      for (int x = 0; x < 16; x++) {
        for (int z = 0; z < 16; z++) {
          for (int y = mn; y < mx; y++)
            c.getBlock(x, y, z).setType(v[r.nextInt(l)]);
        }
      }      
    }
glossy venture
#

@regal moat try that

#

the code above

opal juniper
#
    static long getChunkKey(int x, int z) {
        return (long)x & 4294967295L | ((long)z & 4294967295L) << 32;
    }
glossy venture
#

should be more than twice as fast

young knoll
#

Why are you adding the chunk to a map anyway

#

All you need is a set

regal moat
#

Yeah

#

Yeah?

#

Alright

glossy venture
#

hashset preferably

#

so much faster

regal moat
#

orby

#

What if the random material is an item and not a block

glossy venture
#

oh ye

#

check isBlock

#

actually copy the material array

#

in a static block

opal juniper
glossy venture
#

but only the blocks

#

HashSet<Chunk> hasBeenGenerated; should be used

regal moat
#

lets just use the chunk key

#

instead of the whole chunk pls

opal juniper
#

Set<long> hasBeenGenerated = new HashSet<>();

glossy venture
#

doesnt matter when using a hashset

#

it stores hashes

#

and a chunk is a reference

#

same size as a long

#

i think

opal juniper
#

i think != i know

#

so lets use teh key

regal moat
#

?paste

undone axleBOT
regal moat
#

how is this

glossy venture
#
    public HashSet<Long> generated = new HashSet<>();

    static long getChunkKey(int x, int z) {
        return (long)x & 4294967295L | ((long)z & 4294967295L) << 32;
    } // using olijeffersOn's key function
  
    @EventHandler
    public void onMove(PlayerMoveEvent e){
        Chunk chunk = e.getTo().getChunk();
        if (!(e.getFrom().getChunk().equals(chunk))){
            long key = getChunkKey(chunk);
            if (!(generated.contains(key))) {
                chunks.add(key);
                regenerate(chunk, new Random());
            }
        }
    }

    public static void regenerate(Chunk c, Random r) {
      // get world
      World world = c.getWorld();
      
      // get min and max height
      int mn = world.getMinHeight();
      int mx = world.getMaxHeight();
    
      // get material enum info
      Material[] v = material.values();
      int l = Material.values().length;
      
      // loop over blocks and set them to random material
      for (int x = 0; x < 16; x++) {
        for (int z = 0; z < 16; z++) {
          for (int y = mn; y < mx; y++)
            c.getBlock(x, y, z).setType(v[r.nextInt(l)]);
        }
      }      
    }
opal juniper
#

remove the statics

glossy venture
#

ur still using the inefficient getAllBlocks