#help-development

1 messages ยท Page 2177 of 1

quaint mantle
#

@limber owl I want to make it change colors so why isnt it working:

                Color[] colors = {Color.RED, Color.ORANGE, Color.YELLOW, Color.GREEN, Color.BLUE, Color.PURPLE};
                int index;

                @Override
                public void run() {
                    if (index >= colors.length) index = 0;
                    Color color = colors[index];
                    index++;
                    leatherArmorMeta.setColor(color);
                    e.getItem().getItemStack().setItemMeta(meta);
                }
            }.runTaskTimer(plugin,20,20);```
limber owl
#

then do you want help or not?

subtle folio
#

a*

ivory flume
#

don't have to be so rude, I just want to know how long it should take to be considered "performing good"

distant fern
#

No progress

    public void onClick(InventoryClickEvent e) {

        ItemStack clicked = e.getCurrentItem();

        if (clicked.getType().equals(Material.DIAMOND_HOE)) {
            Bukkit.broadcastMessage("1");
            if (e.getCurrentItem().containsEnchantment(Enchantment.MENDING)) {
                e.getCursor().setType(Material.AIR);
                e.getCurrentItem().setType(Material.AIR);
                Bukkit.broadcastMessage("2");
            }
        }
    }
limber owl
ivory flume
#

my laptop takes ~30 ms to run it, according to my tests.

tardy delta
#

if you dont show what you're doing i cant advise you

ivory flume
#

i hope thats not too long

tardy delta
#

to run what

quaint mantle
#

30ms?

#

honestly not that much time but still, that's a bit long?

ivory flume
#

it does have mutliple SQL queries

chrome beacon
#

SQL should be done async

tardy delta
#

do them in the async pre login event

#

after you checked if the player is allowed to join

quaint mantle
#

Bukkit#getScheduler#runTaskAsynchronously

#

or that yeah

green prism
#
    public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
            String[] args = event.getMessage().split(" ");
            if(args.length == 2) {
                if(args[0].equals("/creditcardconfirm")) {
                    event.setCancelled(true);
                    Player player = event.getPlayer();
                    CardConfigStep configStep = plugin.getCardConfigStep().getOrDefault(args[1], null);
                    new CardConfigStepTask(configStep, args[1], player, plugin);

                }
            }
        }
    }```


Doesn't works for hide command-log from console
ivory flume
#

well if I try to get stuff async won't that not update it in the main thread?

limber owl
# quaint mantle <@932615769194397716> I want to make it change colors so why isnt it working: ``...

do it like this

long task1 = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new BukkitRunnable() {
            Color[] colors = {Color.RED, Color.ORANGE, Color.YELLOW, Color.GREEN, Color.BLUE, Color.PURPLE};
            int index;
            @Override
            public void run() {
                if (index >= colors.length) index = 0;
                Color color = colors[index];
                index++;
                leatherArmorMeta.setColor(color);
                e.getItem().getItemStack().setItemMeta(meta);
            }
        }, 0, 20);
grim oak
#

Hi so im making a custom GUI, and i want to make it so that when the user exists the gui (uses a chest gui) it returns the items they put in there back to their inventory, how would i do that?

limber owl
#

?spoon

undone axleBOT
#

Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.

green prism
quaint mantle
#

nice

limber owl
quaint mantle
chrome beacon
quaint mantle
chrome beacon
#

?scheduling

undone axleBOT
chrome beacon
#

Read this ^^

quaint mantle
#

ok

quaint mantle
#

Reason it's deprecated is because spigot recommends to use "Runnable" instead of their own "BukkitRunnable" @quaint mantle

limber owl
quaint mantle
#

So, basically you want to use Runnable instead of BukkitRunnable

limber owl
#

@quaint mantle

quaint mantle
#

ok I got it

green prism
chrome beacon
#

You can use the BukkitRunnable directly that's fine

quaint mantle
#

ok

green prism
limber owl
#

put Bukkit.getLogger().log(Level.INFO, "if statement working");
to the if statement

green prism
#

with some checks

limber owl
#

and see if it works

quaint mantle
limber owl
#

because i suspect that the / in the equals is unnecessary

limber owl
#

show us the whole log

quaint mantle
#

stacktrace

chrome beacon
#

Unchecked cast going by things posted earlier

green prism
limber owl
#

i see

green prism
#

kydoky

limber owl
#

does the command work?

green prism
#

yep

#

[20:58:34 INFO]: Jaamin issued server command: /creditcardconfirm aZIQ8h4RMy
[20:58:34 INFO]: if statement working

limber owl
#

but if the command does the code you made

green prism
#

yep

limber owl
#

what does it do

green prism
#

starts the task
at the moment, it sends a message: "Jaamin you don't have enough money in your account"

limber owl
#

okay

green prism
#

?paste

undone axleBOT
green prism
limber owl
#

i dont need this, paste a listener class

#

that you use

#

especially the part with that event

green prism
limber owl
green prism
#

huhuh

#

guess

limber owl
#

move Bukkit.getLogger().log(Level.INFO, "if statement working"); to the 33 line

ripe owl
#

can i ask 1.8 minecraft dev question?

limber owl
green prism
#

sure

ripe owl
#

paper community don't allow 1.8 question

#

ah

#

ok

#

i have some problem: players are damaged when spam blockhitting, they keep their sword blocking state so every damage they have reduced by sword blocking though they are not sword blocking state (no holding right click)
bukkit versions: 1.8.9

limber owl
#

try doing the event.setCancelled(true); at the start on line 25, that should show us if it shows any command in console

limber owl
ripe owl
#

ok

#

so is there any way to set player's sword blocking state?

limber owl
#

if you need help with code, come back and we can help but I'm not sure how to help with this

limber owl
limber owl
green prism
#

[21:07:58 INFO]: Jaamin issued server command: /creditcardconfirm aZIQ8h4RMy
[21:07:58 INFO]: if statement working

green prism
#

cool

limber owl
#

try doing event.setMessage("");

#

and remove event.setCancelled(true);

green prism
#

java.lang.IllegalArgumentException: Command cannot be empty

limber owl
green prism
#

yep

#

I had already imagined

#

xd

limber owl
#

okay, do this, add the event.setMessage("/creditcardconfirm"); after the new credit card something and add the event.setCancelled(true); before creating that

#

wait

#

let me show you

#
    @EventHandler
    public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
        String[] args = event.getMessage().split(" ");
        if(args.length == 2) {
            if(args[0].equals("/creditcardconfirm")) {
                Bukkit.getLogger().log(Level.INFO, "if statement working");
                Player player = event.getPlayer();
                event.setCancelled(true);
                CardConfigStep configStep = plugin.getCardConfigStep().getOrDefault(args[1], null);
                new CardConfigStepTask(configStep, args[1], player, plugin);
                event.setMessage("/creditcardconfirm");
            }
        }
    }
#

like this

green prism
#

[21:14:05 INFO]: Jaamin issued server command: /creditcardconfirm aZIQ8h4RMy
[21:14:05 INFO]: if statement working

limber owl
#

remove the event set cancelled

#

or add the event set cancelled after the set message

green prism
#

that's beautiful

#

Unknown command + Command Works

#

[21:15:06 INFO]: Jaamin issued server command: /creditcardconfirm oAesqbNrgv

#

and obv

limber owl
#

frick

quaint mantle
#

pretty sure that only sets the command you execute

#

Not sure if it's possible without hooking into packets

limber owl
#

on spigot someone said: AuthMe hides login from console. It's open source, so you can check how they did it.

#

try looking deeper into that, but this is what they use:

@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
    public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
        String cmd = event.getMessage().split(" ")[0].toLowerCase();
        if (settings.getProperty(HooksSettings.USE_ESSENTIALS_MOTD) && "/motd".equals(cmd)) {
            return;
        }
        if (settings.getProperty(RestrictionSettings.ALLOW_COMMANDS).contains(cmd)) {
            return;
        }
        final Player player = event.getPlayer();
        if (!quickCommandsProtectionManager.isAllowed(player.getName())) {
            event.setCancelled(true);
            player.kickPlayer(messages.retrieveSingle(player, MessageKey.QUICK_COMMAND_PROTECTION_KICK));
            return;
        }
        if (listenerService.shouldCancelEvent(player)) {
            event.setCancelled(true);
            messages.send(player, MessageKey.DENIED_COMMAND);
        }
    }
slate mortar
#

why isn't the Forward message going to like any server?

        Bukkit.getMessenger().registerOutgoingPluginChannel(this, "test:some_test_channel");
        Bukkit.getMessenger().registerIncomingPluginChannel(this, "test:some_test_channel", new de.cxlina.locallobby.Listener());
            ByteArrayDataOutput out = ByteStreams.newDataOutput();
            out.writeUTF("Forward");
            out.writeUTF("ALL");
            out.writeUTF("test:some_test_channel");
            ByteArrayOutputStream msgbytes = new ByteArrayOutputStream();
            DataOutputStream msgout = new DataOutputStream(msgbytes);
            try {
                msgout.writeUTF("Some kind of data here");
                msgout.writeShort(123);
            } catch (IOException exception) {
                exception.printStackTrace();
            }
            out.writeShort(msgbytes.toByteArray().length);
            out.write(msgbytes.toByteArray());
            e.getPlayer().sendPluginMessage(this, "test:some_test_channel", out.toByteArray());
            System.out.println("Sent Plugin Message.");

tried every combination of channels, server-names/types, even tried BungeeCord itself, nothing is apparently received on the second server.

#

and yes, there is a player on each server online

quaint mantle
#

@green prism @limber owl

#

how do i save an inventory into a config file?

tardy delta
#

that code looks meh

#

save the contents

tardy delta
#

an itemstack is (de)serializable

tender shard
slate mortar
#

if so, i like seeing Zombie_striker lying to us :(

thorny dawn
#

Getting IllegalArgumentException: location.world on the "sender.teleport()" method. Could it be because the world has not been created yet? (I am duplicating a world file before teleporting the player)

slate mortar
#

oh god, my eyes lmfao

#

again

thorny dawn
#

LOL

slate mortar
#

why you do this to me again

#

IVE DONE NOTHING TO YOU

thorny dawn
#

im evil

tardy delta
#

aa kotlin

slate mortar
#

:(

thorny dawn
#

kotlin is for the real chads

#

java is for the weak

tardy delta
#

kotlin is a very funny language

slate mortar
#

LIES EVERYWHERE

thorny dawn
#

NAH

slate mortar
#

kotlin is ugly af imo

#

my eyes are bleeding rn

thorny dawn
#

"public static main void(String[] args)" ๐Ÿค“

ivory sleet
#

I mean kotlin kinda sucks but at the same time, its splendid

ivory sleet
#

I mean verbosity isnt necessarily bad

green prism
thorny dawn
#

well

ivory sleet
#

for enterprise, verbosity has been proven quite effective

green prism
#

that's the only reason

thorny dawn
#

u get away from javas boilerplate with kotlin

tardy delta
#

what does verbosity mean?

ivory sleet
#

many words

tardy delta
#

๐Ÿ‘‰๐Ÿ‘ˆ

ivory sleet
#

Like classes named AbstractObserverVisitor or sth

#

yk

ivory sleet
thorny dawn
#

not looking at @slate mortar

slate mortar
#

ofc not

#

my eyes are still bleeding

ivory sleet
#

this has minimal boilerplate public static main void(String[] args) unless we're talking in terms of functional programming

thorny dawn
#

sorry next time ill convert it to java so u can see

humble tulip
ivory sleet
#

the only paradigm that still allows for one letter variable names

slate mortar
ivory sleet
#

ceryth still

slate mortar
#

the bottom of the message

thorny dawn
#

well

#

ive done some android development before

#

so it was easier for me to adopt with kotlin

ivory sleet
#

I think we told you already about the issue

thorny dawn
#

wait where

ivory sleet
#

oh im not complaining about kotlin

thorny dawn
#

im confused

#

๐Ÿ˜ญ

twilit pulsar
green prism
# limber owl try looking deeper into that, but this is what they use: ```java @EventHandler(i...

I've tried like that but nothing

    public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
        String[] args = event.getMessage().split(" ");
        if (args.length == 2) {
            if (args[0].equals("/creditcardconfirm")) {
                event.setCancelled(true);
                Bukkit.getLogger().log(Level.INFO, "if statement working");
                Player player = event.getPlayer();
                CardConfigStep configStep = plugin.getCardConfigStep().getOrDefault(args[1], null);
                new CardConfigStepTask(configStep, args[1], player, plugin);
            }
        }
    }```
ivory sleet
#

the world is null

twilit pulsar
#

here

ancient plank
#

kekw

slate mortar
#

i honestly have no idea if i want to even answer this

thorny dawn
ancient plank
#

red things in intellij (base theme) are errors, fun fact

ivory sleet
#

ceryth what does GetWorldToQueue().getWorld() do?

slate mortar
ancient plank
slate mortar
#

._.

#

imagine

twilit pulsar
ivory sleet
#

feels like you could make that into a companion object and put the function inside the companion, but besides that what world name does it yield?

#

like if you were to debug/print

slate mortar
twilit pulsar
#

its not a joke

slate mortar
#

in that case please

#

?learnjava

undone axleBOT
humble tulip
#

?java

thorny dawn
tardy delta
#

same thing as if list.remove() {}

slate mortar
#
      private void Flymethod(Player player){
          if (sender instanceof Player){

where do you expect to get the sender from

tardy delta
#

from the matrix

slate mortar
#

i feel like this channel slowly gets worse every day

#

idk

ancient plank
#

I like how nobody's mentioned the

if(player.hasPermission("permission"));
thorny dawn
#

with posting kotlin code

slate mortar
#

i'm the main issue
for not beeing funny enough

#

i'm sorry people

#

i'm trying to be better the next times

tardy delta
#

๐Ÿ˜ž

echo basalt
iron glade
twilit pulsar
#

Im sorry

#

eminem.

iron glade
#
if(player.hasPermission("netcore.fly"));``` What's up with this
twilit pulsar
#

whats wrong?

iron glade
#

;

iron glade
#

why is there ; at the end

#

and no {

twilit pulsar
#

cause im better.

tender shard
#

it's valid syntax but it makes absolutely no sense lol

twilit pulsar
#

the plugin works fine tho?

iron glade
#

Just cause it works doesn't mean there's no room for improvement

tender shard
#

    public NamespacedKey getKey(String name) {
        boolean $$ = true;
        if($$);
        if(false);
        else;;;
        {{{{{ return KEYS.computeIfAbsent(name, __ -> new NamespacedKey(this, name)); }}}}}
    }

I like this

twilit pulsar
lethal python
#

guys if you had an item which had an ID number in its lore which do you think would look better:
โ„–39
#39

#

which character looks better

iron glade
#

-> #

ivory sleet
#

or some key tag like ID: 678

tender shard
#

I'd use a full sentence like
"The item to which this lore belongs to has an ID of 39. Have a nice day."

tardy delta
#

does Class::isAnnotationPresent checks all the variables and fields for the annotation or only the class declaration?

ivory sleet
#

only latter

tender shard
#

you'd have to loop over all declared fields and methods if you want to know whether that annotations appears SOMEWHERE in the class

tardy delta
#

ah

tender shard
#

sth like this

    public static boolean doesContainAnnotation(Class<?> clazz, Class<? extends Annotation> annotation) {
        if(clazz.isAnnotationPresent(annotation)) return true;
        for(Field field : clazz.getDeclaredFields()) {
            if(field.isAnnotationPresent(annotation)) return true;
        }
        for(Method method : clazz.getDeclaredMethods()) {
            if(method.isAnnotationPresent(annotation)) return true;
        }
        return false;
    }

although I wonder why someone would need that

tardy delta
#

vewy important

lethal python
#

they are

tardy delta
#

ah i get it

ivory sleet
#

remember the annot needs to be set to runtime retention

quaint mantle
#

How do I fix this:

                Color[] colors = {Color.RED, Color.ORANGE, Color.YELLOW, Color.GREEN, Color.BLUE, Color.PURPLE};
                int index;
                @Override
                public void run() {
                    p.sendMessage("hhh");
                    if (index >= colors.length) index = 0;
                    Color color = colors[index];
                    index++;
                    leatherArmorMeta.setColor(color);
                    e.getItem().getItemStack().setItemMeta(meta);
                }
            }, 0L, 20L);```
its sending (hhh), bu its not chaning the color of the item
ivory sleet
#

yep

#

because p.sendMessage("hhh");

silent topaz
#

fax

hybrid spoke
thorny dawn
#

@ivory sleet figured out the issue i had to do Bukkit.createWorld(WorldCreator($worldname))

#

cause the world wasnt loaded

humble tulip
#

Lol

ivory sleet
#

ye

#

makes sense

echo basalt
tardy delta
#

why are they doing this to me

#

newt time its going to be UwU i swear

ivory flume
#

whats the fastest way to check if a player is online

tender shard
#

by what? by their player object? by their name? UUID? ...

ivory flume
#

their name

tender shard
#

Bukkit.getOnlinePlayer("name")

#

it will be null when they are not online

tardy delta
#

.isOnline

echo basalt
#

ยฏ_(ใƒ„)_/ยฏ

tender shard
#

erm

#

just getPlayer

#

not getOnlinePlayer

tender shard
echo basalt
#

it internally loops through all players anyways

tardy delta
#

wait my bad

#

thought you had a player obj

hybrid spoke
#

mission failed successful

tender shard
#

btw better use Bukkit.getPlayerExact

#

otherwise e.g. "mfn" would return the "mfnalex" player even though you wanted to look for "mfn"

tardy delta
#

i always forget ๐Ÿฅบ

ivory flume
thorny dawn
#

how do i detect when a player changes worlds?

echo basalt
#

PlayerWorldChangeEvent

#

or EntityWorldChangeEvent

thorny dawn
#

when does it fire?

echo basalt
#

seems like the actual one

#

when an entity changes the world...

thorny dawn
#

before or after world change?

echo basalt
#

pretty sure it's pre-world change

thorny dawn
#

oh

#

is there a way to get the destination world?

echo basalt
#

I'd need to look at the nms internals for that

echo basalt
tender shard
#

`jd-s

#

?jd-s

undone axleBOT
tender shard
#

oh wait

#

yeah it's weird

#

it fires AFTER the player changed the world

green prism
tender shard
#

so player.getWorld is the new world

#

and event.getFrom is the old world

thorny dawn
#

๐Ÿ‘

echo basalt
tender shard
#

but

thorny dawn
#

this is odd

#

its not logging out when the event fires

tender shard
#

you could probably just cancel it or change the world in playerteleportevent

thorny dawn
#

wdym?

#

i want the event to fire

#

but for some odd reason it isnt

#

and yes ive registered it

tender shard
#

I wasn't replying to your screenshot

thorny dawn
#

oh okay

tender shard
#

what's "send"?

thorny dawn
#

oh its just a quick custom logger ive made

ivory sleet
#

unless you're registering a custom event executor

#

but doubtful thats the case

tender shard
#

lol I didn't check the annotation because they said "and yes ive registered it"

thorny dawn
#

lmao

#

i forgot ab it

#

well its 3am my brain isnt braining rn

sterile token
#

If i dont use it them they are not listened

tender shard
#

I#m thinking about what's the best way to store custom enchantments. Maybe just a Map<String.Integer> as PDC on the itemmeta?

I came up with this: https://paste.jeff-media.com/?cb11c58a4343be68#CWhrbazAKv7SMMDEobrwM6Q8MsoXcjpADPRmYGPxh8KE

Of course I could replace the String key with a CustomEnchantment object but that's not important right now. I just wonder if there's any better way?

sterile token
#

Jeff

ivory sleet
#

did you even read the entire convo verano

sterile token
#

Im not convo

tender shard
#

bruh

ivory sleet
#

convo - conversation

sterile token
#

ohh ok

#

Sounds badly on my lang

ivory sleet
#

myea figured you might not know the abbreviation

#

anyway

sterile token
#

As usual

#

Conclure do you remember my menu lib?

ivory sleet
#

nope

sterile token
#

The one we dicuss more than 1h

#

In fact with the help of redempt i finally fixed it

ivory sleet
#

ye

warm saddle
#

How would I got about making a dropper inventory?

tender shard
#

Bukkit.createInventory(..., InventoryType.DROPPER)

warm saddle
#

thank you :)

tender shard
#

np

grim oak
#

If i have a chest inventory GUI is there a way i can check 2 slots for inputs and produce an output in another slot for all things that can be combined in an anvil. idk if i explained that very well

tall dragon
grim oak
#

yep pretty much

river oracle
#

you can it'd just be a tad hacky

tall dragon
#

or u can take the long way

#

and see how mc did it

grim oak
river oracle
#

just some if checks and stuff

#

recipe handlers etc

#

I trust you can figure it out

grim oak
#

aight

humble tulip
tall dragon
#

it will probably be much more clean and easier to add stuff to yea.

humble tulip
#

Yeah just copy paste the mc code

grim oak
#

where would i find the mc code for an anvil

humble tulip
#

In the server.jar

#

In mns

grim oak
#

aight thanks

humble tulip
#

Or however you get nms code now

tender shard
#

in net.minecraft.world.inventory.AnvilMenu

#

and in ItemCombinerMenu

#

(same package)

#

good luck in "copy pasting" that though lmao

humble tulip
#

Is it obfuscated?

atomic flax
#

Hello ! I'm trying to create a scheduled task like this :

Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(Plugin plugin, new BukkitRunnable() {
            public void run() {
                getLogger().info("Managed Task !");
            }
        }, 0L, 400L);

but the "Plugin plugin" appears in red and I don't know how to solve it... Otherwise, I can't find how to get a scoreboard value from a player who is not one like the players: Red for the number of remaining lives.

Thanks to you !

humble tulip
#

Lol

#

U cant define plugin there

tender shard
tall dragon
humble tulip
#

Why does mojang still obfuscate the server.jar?

tall dragon
#

i have no idea. they obfusate it

#

then release an deobfuscate map

tender shard
#

you can't just "copy paste" the whole NMS anvil logic into a bukkit plugin lol. no matter whether it's obfuscated or not

clever musk
#

Do spigot nms mappings change with each major update, or minor update?

humble tulip
tender shard
clever musk
#

Do spigot names stay?

river oracle
#

of-course

tender shard
#

there aren't really spigot names anymore, just the obfuscated ones. and yes, they obviously change everytime

clever musk
#

Rip

#

Ok

tender shard
#

why rip? that's what mojang mappings are for ๐Ÿ˜„

#

there is no reason, EVER, to NOT use mojang mappings

clever musk
#

I'm backporting my plugin and want to know if I need 6 modules for 1.16

#

For 1.16.0-5

tender shard
#

no, 3

#

1_16R1, 1_16R2 and 1_16R3

clever musk
#

Oohhh I see

#

Okay

tender shard
#

although tbh who the heck uses 1.16.1 or 1.16.2?

#

I'd only care about 1.16.5

warm saddle
#

are inventories indexed from 0 or 1?

river oracle
#

0

undone axleBOT
chrome beacon
#

Also plugin is a reference to your main plugin class that extends JavaPlugin

warm saddle
#

is there a way to get custom player heads other than using HeadDatabaseAPI?

chrome beacon
#

Yes

tender shard
river oracle
tall dragon
river oracle
#

take a look at mfnalex skull utils

tender shard
#

Create a new ItemStack. Cast the Meta to SkullMeta. use "setOwnerProfile" or "setOwningPlayer". A PlayerProfile can contain custom Textures

fierce salmon
#

does anyone know of any way to use both JDK and Spigot inside of one class

river oracle
#

what

river oracle
#

^

fierce salmon
#

For example, I want to be able to have a discord bot do something when a minecraft event takes place

river oracle
#

you mean

#

JDA

tall dragon
#

lol yea

#

jda

fierce salmon
#

oh

#

LMAO

river oracle
#

very different from the java JDK lol

tall dragon
#

well ye thats possible

#

a plugin is still a java program

fierce salmon
#

how can I implement both jda and bukkit listener to one class

tender shard
#

that sounds like pretty stupid choice

#

anyway, where's the problem? make your class extend the JDA listener class thingy and implement Bukkit's Listener interface

#

no problem at all

#

just plain stupid

fierce salmon
#

alright

tender shard
#

you should definitely have separate classes for those

fierce salmon
#

Like how do I make the minecraft server issue a command once this event takes place

tender shard
#

simply call Bukkit.broadcastMessage or whatever you want to call from inside your JDA listener

tardy delta
#

listen for the jda event and dispatch a command using the spigot api

tender shard
#

for example

@Override
    public void onMessageReceived(@NotNull MessageReceivedEvent event) {
        if(event.getAuthor().isBot()) return;
        Bukkit.broadcastMessage(event.getMessage().getContentRaw());
    }
fickle crater
#

can someone help me with a simple question?

#

I am currently trying to spawn an npc, and my code so far is this:

MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
        WorldServer world = ((CraftWorld) Bukkit.getWorld(player.getWorld().getName())).getHandle();
        GameProfile gameProfile = new GameProfile(UUID.randomUUID(), ChatColor.GOLD + "" + ChatColor.BOLD + "Soldier");
        EntityPlayer npc = new EntityPlayer(server, world, gameProfile);```
And i am trying to set its location, but when i type npc.setLocation nothing shows up. What am i doing wrong?
lethal python
#

when my plugin teleports a player it says they moved too fast will this cause problems

fierce salmon
lethal python
#

epic

tall dragon
#

i suspect it also does not happen everytime

#

does it?

lethal python
#

it do b happening every time i think

tall dragon
#

server version?

tawdry finch
#

anyone know how i can like do a command that makes a custom world that i have as a file?

lethal python
#

paper somethin something

#

idk

#

i don't mind atm

#

i've got a location with a yaw/pitch and i want to translate that location 1 block along the view axis

#

how do i do that

tall dragon
#

anyway pretty sure u can just ignore that message

lethal python
#

how do i move a position's xyz 1 block along the location's view vector

tall dragon
#

soo u want to teleport the player forward 1 block?

lethal python
#

i just want to get the location of the block immediately in front of another location

tender shard
humble tulip
lethal python
#

thanks minion

tender shard
lethal python
#

why 1.5?

tawdry finch
humble tulip
#

enough to reach the next block but not enought to reach the block past that

lethal python
#

ok thanks

violet mauve
humble tulip
#

actually make it 1.8

#

because sqrt(3) is 1.73

#

@lethal python

tawdry finch
#

so i have a custom world and i want to run a command that like makes it load and kinda like multiverce the world gets added into the server

#

then another command that can tp ppl into that world!

#

if that makes sense

fierce salmon
humble tulip
#

if u dont have it as a file

#

u want the plugin to tell u that?

violet mauve
tawdry finch
#

so

#

in my plugin

#

i want to have a world that you can "load" in then once its loaded it works like anyother world

#

does that makes sense?

humble tulip
tawdry finch
#

im not trying to make a new world

#

im trying to make the plugin load a world that is a file

humble tulip
#

This loads one itnit exists as well

#

U can check if there is afolder woth the world name

tawdry finch
#

ahh okay

#

wait so how lol

humble tulip
#

And check if there is a level.dat file

#
tawdry finch
#

okay so

#

WorldCreator wc = new WorldCreator("world name"); << where "world name" is do i need to like add the look for file code there?

tender shard
#

you can simply put your world into the server directory. e.g. C:\MyServer\myCustomWorld

#

then just do Bukkit.createWorld("myCustomWorld")

#

then it loads your existing world or creates a new one if there is no folder called "myCustomWorld"

tawdry finch
#

ahh then it sees it as that

#

sweet

tender shard
#

exactly :3

tawdry finch
#

tysm!

tender shard
#

np

tardy delta
#

:o

humble tulip
#

Ur in the future man

tender shard
#

yay my vacation starts in 1 month and 30 minutes

uneven fiber
fierce salmon
#

how can I register a jda event inside of the main javaplugin file?

#

the jda event is from another class

river oracle
#

if it extends you can't

#

if it implements idk how touse JDA

crimson scarab
#

how can i make it possible for full hunger player to be able to eat

fierce salmon
#

eat what?

#

I think you need a mod for that

#

but idk

tender shard
#

jda.addEventListener(YourListenerInstance)

fierce salmon
#
[15:13:41] [Server thread/ERROR]: Error occurred while enabling DiscSpigot v1 (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "net.dv8tion.jda.api.JDA.addEventListener(Object[])" because "this.jda" is null
        at me.elim.discspigot.Main.onEnable(Main.java:23) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-api-1.18.2-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.18.2-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-api-1.18.2-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugin(CraftServer.java:518) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3491-Spigot-b081915-95d233d]
        at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugins(CraftServer.java:432) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3491-Spigot-b081915-95d233d]
        at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:612) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3491-Spigot-b081915-95d233d]
        at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:414) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3491-Spigot-b081915-95d233d]
        at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:263) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3491-Spigot-b081915-95d233d]
        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1007) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3491-Spigot-b081915-95d233d]
        at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.18.2-R0.1-SNAPSHOT.jar:3491-Spigot-b081915-95d233d]
        at java.lang.Thread.run(Thread.java:833) [?:?]
tender shard
#

bro

#

it tells you exactly the problem

#

your jda field is null because you never created any JDA instance

#

it literally says that

"this.jda" is null

#

with a stream or a regular for loop?

#
List<Player> players = getConfig().getStringList("players").stream().map(Bukkit::getPlayerExact).collect(Collectors.toList());
#

the list will contain "null" for every player who's not online

tender shard
#

no, that will a create a list like this

- CraftPlayer{name=mfnalex}
#

well depends what you want to store in the list lol

#

if you want to store their names, then yes, using getName() would be helpful lol

#

well what do you need it for? sometimes a name is better, sometimes a UUID. it depends on what you're trying to do at all

#

I have no idea what that is but it sounds like UUIDs are better for this

#

what is a tnt tag event?

ivory flume
#

Hello, i am trying to do this using NMS
Field field = Class.forName("net.minecraft.world.item.WrittenBookItem").getDeclaredField("MAX_PAGES");
but it says the class doesn't exist
java.lang.ClassNotFoundException: net.minecraft.world.item.WrittenBookItem
when it clearly does

tawdry finch
#

can someone point me in the right direction, Im trying to run a command that then spawns a portal ( neather portal ) That then tps a player into a custom world

tender shard
#

the server doesn't use the mojang mappings

#

you should do WrittenBookItem.class, then the specialsource plugin translates it to the proper class name

ivory flume
#

so how would I go about doing it correctly then

#

and what about the field?

tender shard
#

you'll have to check the obfuscation map for that

ivory flume
#

won't that also cause some mapping error

tender shard
#

one second

eternal oxide
#

specialsource plugin for maven

tender shard
#

also wait whut

#

MAX_PAGES is a public field

#

no need to use reflection at all

ivory flume
#

i uh

#

want to change it

tender shard
#

oh okay

#

well two possibilities. both are dirty

ivory flume
#

no matter ๐Ÿ™‚

tender shard
#

first:
WrittenBookItem.class.getDeclaredFields, loop over it until you found a field that's int and has a value of 100

#

that's your field

#

second way: hardcode the obfuscated field name and change it for every NMS version

ivory flume
#

the first one sounds better, thank you

tender shard
#
    public static Field getMaxPagesField() throws IllegalAccessException {
        for(Field field : WrittenBookItem.class.getDeclaredFields()) {
            if (field.getType().equals(Integer.TYPE) && ((int) field.get(null)) == 100) return field;
        }
        return null;
    }

Something like this. Haven't tested @ivory flume

#

alternatively you could get the field by it's index

#

it probably won't change anytime soon

#
public static Field getMaxPagesField() throws IllegalAccessException {
        return WrittenBookItem.class.getDeclaredFields()[4];
    }
#

this probably works too but it could break between updates. however the first method will break when the value isn't 100 anymore because you e.g. changed it yourself. so I'd get simply cache the result of the first method

crude cobalt
#

Give please advice. What is the best way to implement such a scale so that the colors change sequentially. Red - reduction of the scale, yellow - the normal state of the scale, green increase the scale. The scale depends on the value of the variable. I think it can be implemented with if , if else and server threads. Are there other options?

https://www.veed.io/view/db05a626-5479-40db-a93d-c7431f50313a?sharingWidget=true

tender shard
# ivory flume oh wow thank you

I'd probably do it like this

    private static final Field MAX_PAGES_FIELD;

    static {
        Field tmp = null;
        try {
            for(Field field : WrittenBookItem.class.getDeclaredFields()) {
                if (field.getType().equals(Integer.TYPE) && ((int) field.get(null)) == 100) {
                    tmp = field;
                    break;
                }
            }
        } catch (IllegalAccessException ex) {
            Bukkit.getLogger().warning("Couldn't get WrittenBook's MAX_PAGES field");
        }
        MAX_PAGES_FIELD = tmp;
    }
#

is there anyway to find out the <Class> of a Supplier<?> without actually calling get() on the supplier? I doubt there is

#

I basically want to get rid of the part I marked in red

tawdry finch
#
 Objects.requireNonNull(getCommand("Loadusd")).setExecutor(new Loadusd(this));``` Why does this give me a NPE error?
#
java.lang.NullPointerException: null
        at java.util.Objects.requireNonNull(Objects.java:208) ~[?:?]
        at me.main.strangerthings.Main.onEnable(Main.java:19) ~[StrangerThings-1.0-SNAPSHOT.jar:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]```
tender shard
#

because getCommand("Loadusd") is null

tawdry finch
#

it shouldnt be tho

#

how can i correct it?

tender shard
#

add that command to your plugin.yml

tawdry finch
#

it is lol

tender shard
#

?paste your plugin.yml pls

undone axleBOT
tawdry finch
tender shard
#

okay then you're either editing the wrong plugin.yml or something

#

open your plugin .jar file with winrar and check the included plugin.yml

tawdry finch
#

nvm it works now

#

thats so weird

#

LOL

tender shard
#

what was the problem?

tawdry finch
#

honestly dont know

#

i just restarted the server

#

strange

tender shard
#

ยฏ_(ใƒ„)_/ยฏ

#

huh isn't TypeToken part of Guava?

#
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>31.0.1-jre</version>
        </dependency>
#

the only TypeTokens I find are from gson

tawdry finch
#

?paste

undone axleBOT
tawdry finch
#

can anyone tell me what this means lmao

#

ive been reading over it for like 5 mins now

tender shard
#

the player isn't online

#

you do something like Bukkit.getPlayer("notonline").teleport(...)

#

so Bukkit.getPlayer(...) returns null so you can't call teleport on it

tawdry finch
#

AHH

#

boolean p = Bukkit.getPlayer("notonline").teleport(loc); --- smtn like this lmao

delicate lynx
#

only teleport if getPlayer doesn't return null

paper viper
#

and if it isnt just teleport

tawdry finch
#

errrrrr

#

so

#

i get what you mean

tender shard
#

Task:

Write a generic method to count the number of elements in a collection that have a specific property (for example, odd integers, prime numbers, palindromes).

Am I stupid or is the solution this simple? Am I misunderstanding the question?

    private static <T> int task1(Collection<T> collection, Predicate<T> predicate) {
        return (int) collection.stream().filter(predicate).count();
    }
paper viper
#

That should work

#

After all filter takes whatever is in the predicate and that is the property part ig

#

and you just count all the occurrences

tender shard
#

yeah of course, I mean, is that really all that is to the question? ๐Ÿ˜„

#

it seems way too easy

paper viper
#

Wheres the question from

#

lol

tawdry finch
#
        if () {
            p = p.isOnline() = false;
        } else {
            
        }```
#

not sure this is right LMAO

paper viper
tender shard
#

seems like all those questions are that easy

paper viper
#
Player player = Bukkit.getPlayer(...);
if (player == null) { // player isn't online 
...
}
#

If the player returned is null, the player is not online

tawdry finch
#
        if (p == null) {
            sender.sendMessage(ChatColor.RED + "PLAYER OFFLINE");
        }
        else {
            
        }```
crisp steeple
# tender shard I basically want to get rid of the part I marked in red

did some testing, turns out you can but only if the supplier isnt a lambda
example:

public static void main(String[] args) {
        
        Supplier<String> sup1 = new Supplier<String>() {
            @Override
            public String get() {
                return "hello";
            }
        };

        Supplier<String> sup2 = () -> "test";
        
        System.out.println("Supplier 1: " + getClassOfSupplier(sup1)); // java.lang.String
        System.out.println("Supplier 2: " + getClassOfSupplier(sup2)); // java.lang.Object
    }

getClassOfSupplier method:

public static Class<?> getClassOfSupplier(Supplier<?> supplier) {
        try {
            Method supplyMethod = supplier.getClass().getMethod("get");
            return supplyMethod.getReturnType();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
            return null;
        }
    }
#

kind of odd

#

intellij is a liar

tender shard
tawdry finch
#

ugh still getting that error lol

#
        if (p == null) {
            sender.sendMessage(ChatColor.RED + "PLAYER OFFLINE");
        }
        else {
          p.teleport(loc);
        }```
crisp steeple
tender shard
crude cobalt
tender shard
#

I can't decide on what generic names to use. opinions?

public class MapDataType<M extends Map<K, V>, K, V> implements PersistentDataType<PersistentDataContainer, M> {
    // ...
}

public class MapDataType<MapT extends Map<KeyT, ValueT>, KeyT, ValueT> implements PersistentDataType<PersistentDataContainer, MapT> {
    // ...
}

public class MapDataType<MapType extends Map<KeyType, ValueType>, KeyType, ValueType> implements PersistentDataType<PersistentDataContainer, MapType> {
    // ...
}

Here I actually like the K,V thing most since you see that in lists all the time. But what about collections then? Just call those C,T?

public class CollectionDataType<C extends Collection<T>, T>  implements PersistentDataType<PersistentDataContainer, C> { ... }
#

it feels weird to call it C

tall dragon
#

C seems fine to me tbh

tender shard
#

C,T sounds like hospital lol

#

but yeah probably better than those overly verbose names

ivory sleet
#

by convention the first one looks best, but the last one is fine as well altho not conventional

tender shard
#

yeah I found those "naming schemes" by googling generics naming conventions and seems like every company does it totally different lol

#

google for example uses the second one but I don't like that at all

ivory sleet
#

ye

tender shard
#

I'll just back to the one letter things

ivory sleet
#

but google has weird style inspections

#

like srsly

tender shard
#

no idea, didn't really read anything about ther style things

ivory sleet
#

well for one they prefer 2 space indents to 4

tender shard
#

eew

ivory sleet
#

which is Ig fine, but almost everyone uses 4, thus it gets a bit unorthodox ye

fierce salmon
#

I have a question. I had to make a second main constructor for my jdk stuff inside of my java plugin. How do I register this inside of my onEnable function?

#

I will send code in a second

tender shard
#

jdk stuff?

fierce salmon
#

i was gonna send all of it

tender shard
#

yeah that's a good idea

#

?paste it pls

undone axleBOT
fierce salmon
#

oh yeah

tender shard
#

I only see one constructor though?

#

btw

#

delete that link

#

I don't think the webhook url is supposed to be public?

fierce salmon
#

rly?

tender shard
#

I don't know

fierce salmon
#

oh well i guess ur right

tender shard
#

doesn't knowing that URL allow people to send stuff to your server?

fierce salmon
#

ye

#

its a test server so if they have it, it doesn't matter

tender shard
#

here's the same with link removed

#

okay so what exactly is the problem?

fierce salmon
#

theres the same error before with the this.jdk being null

#

i assume its because the constructor isnt registered or something

tender shard
#

?paste the full stacktrace again

undone axleBOT
fierce salmon
#

hold up

#

i need to start my server again to get the error

tender shard
#

oki

fierce salmon
#

idk why it registered as coffee script

#

but here lol

tender shard
#

nope, can't be. the error isn't from the code you sent, but from another version

#

there is nothing in line 23 in your code

#

the code you sent isn't exactly the one that threw this error

fierce salmon
#

ok lemme upload my latest version and see where it is

tender shard
#

pls use exactly the code that you pasted

fierce salmon
#

i mustve made some changes since the last time i added the plugin to my server

#

?paste

undone axleBOT
fierce salmon
tender shard
#

ah, that's a totally different error

fierce salmon
#

updated error

#

ye

tender shard
#

your error is now in GuildMessageReceived.java

#

send that class pls

fierce salmon
#

yes sir

tender shard
#

okay I guess your JDA is simply missing the proper GatewayIntents

#

it should at least have GatewayIntent.GUILD_MEMBERS

paper viper
#

assert user != null; dont use ide suggestions always pls ๐Ÿ™‚

tender shard
#
        JDABuilder builder = JDABuilder.createDefault(confBotToken.getBotToken());
        builder.enableIntents(GatewayIntent.GUILD_MEMBERS); // Add this
        jda = builder.build();
#

add the GUILD_MEMBERS intent and see if that helps

fierce salmon
#

oh add this to my main?

tender shard
#

yes, where you build your JDA instance

fierce salmon
#

Cannot resolve method 'enableIntents' in 'JDA'

tender shard
#

instead of this: JDA jda = JDABuilder.createDefault("-").build();
do this: JDA jda = JDABuilder.createDefault("-",GatewayIntent.GUILD_MEMBERS).build();

fierce salmon
#

Oh ok

#

is this line still necessary?

tender shard
#

no

fierce salmon
#

ok

tender shard
#

that was an example from my code

fierce salmon
#

oh mb

tender shard
#

I have it on separate lines because my builder is a bit longer

muted sand
#

@tender shard your custom block pdc thing, what if i delete the block and place it somewhere else? Does that block contain the data?
What if I place a new block, does the new block get its own data or does it retain the data of the old block?

fierce salmon
tender shard
muted sand
tender shard
#

np & you're welcome!

#

as said, right now the data is totally indepent of the actual blocks so yeah. block place, block break, block moved by piston, won't affect the data at all

muted sand
#

oh and, as far as i know, tile entities have their own built in pdc correct?

tender shard
#

(and that will of course never change, even in future versions. but I'll add a method like "CustomBlockData.keepTrack()" or something and only then it will automatically take care of this, so it'll always be backwards compatible)

muted sand
tender shard
#

TileEntities, Entities, Chunks, Worlds and ItemMeta all have their own PDC

tender shard
muted sand
#

Ah i see

muted sand
tender shard
#

the TileEntities "dies" and spawns a totally new Item with fresh ItemMeta

#

(although I am not 100% sure on that - you'll have to try it out if you want to be sure ๐Ÿ˜› )

#

I never used any TileEntity's pdc

vocal cloud
#

Some tiles (shulkie bois) keep their data on break but most don't.

tender shard
#

but not the whole PDC data, right?

muted sand
#

onblockbreak
if shulker boi
clear pdc

fierce salmon
#

it says that the constructor that I made for jda isn't used

#

how do i register it in onEnable

tender shard
#

huh you know what? PDC on shulkerboxes doesn't work for me at all

#
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        Block block = ((Player)sender).getTargetBlockExact(20);
        TileState state = (TileState) block.getState();
        PersistentDataContainer pdc = state.getPersistentDataContainer();
        switch (args[0]) {
            case "get":
                if(pdc.has(new NamespacedKey(this, "test"),PersistentDataType.STRING)) {
                    sender.sendMessage("HAS CUSTOM DATA");
                } else {
                    sender.sendMessage("No custom data");
                }
                state.update();
                return true;
            case "set":
                pdc.set(new NamespacedKey(this, "test"), PersistentDataType.STRING, "asd");
                sender.sendMessage("Added custom data to " + state.toString());
                return true;
        }
        return false;
    }

Always prints "No custom data"

#

oh I am stupid

humble tulip
#

Because it behaves just like other tiles

tender shard
#

I updated the state in the wrong case

#

(I simply used the TileState's PDC, so plain spigot)

muted sand
#

as expected i suppose
else you can't really stack items

tender shard
#

yeah I expected this but wasn't 100% sure

muted sand
#

Thank you for checking though!

tender shard
#

np

ancient plank
#

sometimes I forget if you can break a shulker with your fist and it scares me when I do it

tender shard
#

lol sure you can

#

they are soft and squishy

#

cute little shulker boxes

humble tulip
#

Lol someone loves shulkers

next zinc
#

Anyone know by chance why the mob isn't getting 1000 health?

public void createFireKnight(Location location) {
        MagmaCube fKnight = location.getWorld().spawn(location, MagmaCube.class);
        fKnight.setCustomName(ChatColor.GOLD + "Fire Knight");
        fKnight.setCustomNameVisible(true);
        Attributable knightAI = fKnight;
        AttributeInstance max_health = knightAI.getAttribute(Attribute.GENERIC_MAX_HEALTH);
        Main.createBossBar(fKnight, ChatColor.GOLD + "Fire Knight", BarColor.RED, BarStyle.SOLID);
        max_health.setBaseValue(1000);
        fKnight.setHealth(1000);
        fKnight.setSize(5);
        
        
        
    }
tender shard
#

okay most of you people know my CustomBlockData class. Now I'm adding the function to keep track of data, e.g. automatically remove the data when a block gets broken, etc.

However, I wonder - probably most people do NOT want the custom data to also be added to the block's drop when the block gets broken. So I intented to make this configurable, using something like this:

public static void registerListener(Plugin plugin, CustomBlockDataOption... settings);

So when no options are given, it simply removes the block data on block break or when the block gets replaced with a new one. However, I am now wondering - how could I call the options that basically apply the broken block's data to the dropped item? I can't think of ANY proper name lmao

#

CustomBlockDataOption.APPLY_DATA_FROM_BLOCK_TO_DROP
and
CustomBlockDataOption.APPLY_DATA_FROM_ITEM_TO_PLACED_BLOCK
are both a bit overly verbose lol

elfin tusk
#

Does anyone know if there's a way to get all NamespacedKeys? I tried a few heavily scuffed ways of doing this but none worked which is why I'm wondering.

elfin tusk
#

anything

tender shard
#

no

elfin tusk
#

datapacks, plugins, default

tender shard
#

you can basically create as many as you want

#

everytime, everywhere

#

the question is a bit like "how can I get all the strings"?

#

there are basically unlimited amounts of strings and namespacedkeys

elfin tusk
#

Can't you get the registered ones though?

eternal oxide
#

yes

tender shard
#

namespacedkeys do not get registered

#

what you can do is to get the namespacedkeys of all registered recipes

#

all registered biomes

#

etc etc

elfin tusk
#

So I could technically get a list of all of the advancements or something and get the keys that way?

#

I know the advancement iterator returns all of the advancements disregarding the namespacedkey

tender shard
#

yes

#

for example, for all registered recipes:

    public static List<NamespacedKey> getRecipeKeys() {
        List<NamespacedKey> list = new ArrayList<>();
        Bukkit.recipeIterator().forEachRemaining(recipe -> {
            if(recipe instanceof Keyed) {
                list.add(((Keyed)recipe).getKey());
            }
        });
        return list;
    }
elfin tusk
#

I will try it, thanks so much :D

tender shard
#

np ๐Ÿ™‚

elfin tusk
#

I do not know your CustomBlockData class :(

tender shard
#

it provides a PersistentDataContainer for every block

#

so basically a library to store data in blocks

elfin tusk
#

my ideas are longer than yours ๐Ÿ˜…

tender shard
#

๐Ÿ˜„

elfin tusk
#

Just looked up another way to say sentence generator....

#

apply information from square to drop

#

maybe APPLY_FROM_ITEM and APPLY_FROM_BLOCK?

#

although it is pretty difficult to piece together the message you want to get across

tender shard
#

yeah that's definitely better lol

#
    private static final PersistentDataType<?,?>[] PRIMITIVE_DATA_TYPES = new PersistentDataType<?,?>[] {
            PersistentDataType.BYTE,
            PersistentDataType.SHORT,
            PersistentDataType.INTEGER,
            PersistentDataType.LONG,
            PersistentDataType.FLOAT,
            PersistentDataType.DOUBLE,
            PersistentDataType.STRING,
            PersistentDataType.BYTE_ARRAY,
            PersistentDataType.INTEGER_ARRAY,
            PersistentDataType.LONG_ARRAY,
            PersistentDataType.TAG_CONTAINER_ARRAY,
            PersistentDataType.TAG_CONTAINER
    };

    public static PersistentDataType<?,?> getDataType(PersistentDataContainer pdc, NamespacedKey key) {
        for(PersistentDataType<?,?> dataType : PRIMITIVE_DATA_TYPES) {
            if(pdc.has(key, dataType)) return dataType;
        }
        return null;
    }

This should definitely be builtin to spigot

elfin tusk
#

So I have run into a slight problem with my code. I probably should have been more clear last time, but I am trying to get an advancement and delete it without having to specify its namespace. I have the code that you kindly gave me in order to get the namespacedkeys, but how would I get the advancements from those without going through them one by one?

tender shard
#

I mean you must at least have ONE information about it

elfin tusk
#

I have the key from the code you gave to me which works but I just need to use that key to get the advancement which won't work.

tender shard
#

hm I still don't really understand

#

is there any specific advancement you want to delete?

#

btw I don't think you can remove advancements at all, at least not without NMS

#

Bukkit.advancementIterator returns an UnmodifiableIterator

elfin tusk
#

You can with Bukkit.getUnsafe, although it is depreciated

tender shard
#

oh okay

#

good to know

#

TIL

#

I mean Advancements basically only have a List<String> and a NamespacedKey

elfin tusk
#

I want to delete any advancement from a datapack or something but the keys for each of these advancements would be different. I have the code to get the namespacedkey so I used a for loop in order to go through each of these keys and check which ones have it, but for some reason it doesn't work.

So theoretically could I get a list of all of the advancements and get the value of that advancement in the list then delete it using that?

#

I should probably try it 1 moment

fierce salmon
#

@tender shard how would I register the main constructor I made for jda into the onEnable method of the Java Plugin?

tender shard
# elfin tusk I want to delete any advancement from a datapack or something but the keys for e...

if you only want to delete all non-vanilla advancements, you can simply filter them by namespace. example:

    public static List<NamespacedKey> getAllNonVanillaAdvancements() {
        List<NamespacedKey> list = new ArrayList<>();
        Bukkit.advancementIterator().forEachRemaining(advancement -> list.add(advancement.getKey()));
        return list.stream().filter(key -> !key.getNamespace().equals(NamespacedKey.MINECRAFT)).collect(Collectors.toList());
    }
tender shard
#

JDA has nothing to do with your main class constructor or anything

fierce salmon
#

But it doesn't seem to be running

tender shard
#

yes, your empty Constructor will never be called

#

you shouldn't do it there anyway

#

you should instantiate and build your JDA in your onEnable directly

#

no need to create a new useless constructor

muted sand
#

@tender shard sorry for another mention
But your PDC is for the location of the block right?
I can get the BlockBreakEvent -> event.getBlock() -> pdc stuff -> clear it?

tender shard
#
public class MyPlugin extends JavaPlugin {
  JDA jda;

  public void onEnable() {
    jda = JDABuilder.createDefault(...).build();
   }
}
tender shard
#

although I'm currently working on doing this automatically

muted sand
tender shard
#

it's a pain in the ass though to handle all events lol

elfin tusk
#

So when using NamespacedKey.fromString() do you have to mention the namespacedkey or the actual advancement as well. I am using Bukkit.getAdvancement(NamespacedKey.fromString()) so in fromString() do I put fromString("namespace:advancement/name") or fromString("advancement/name")

tender shard
#

let me check

#

?jd-s

undone axleBOT
tender shard
#

it definitely doesn't hurt to add the namespace

#

you also have to provide it for custom stuff

#

but I think you can omit it for minecraft: stuff

elfin tusk
#

alright thank you

tender shard
#

you HAVE to provide the full name

#

datapack:advancements/someadvancement

#

if you don't, it creates a minecraft default key

elfin tusk
#

ah okay

#

let's hope this works

tender shard
#

ugh

#

took me two minutes to find the actual error

#

quite misleading error message

vocal cloud
#

Nice semi uwu

tender shard
#

yeah fuck intelliJ

#

why didn't it just say " a semicolon doesn't belong there" lol

vocal cloud
#

It looks to me like it thinks you ended the constructor early

worldly ingot
#
    public static List<NamespacedKey> getAllNonVanillaAdvancements() {
        List<NamespacedKey> keys = new ArrayList<>();

        Bukkit.advancementIterator().forEachRemaining(advancement -> {
            NamespacedKey key = advancement.getKey();
            if (key.getNamespace().equals(NamespacedKey.MINECRAFT)) {
                keys.add(key);
            }
        });

        return keys;
    }```
tender shard
#

hm I am confused

#
GitHub

Provides a PersistentDataContainer for every Block location - CustomBlockData/CustomBlockDataListener.java at e199da4cb193fc710eae9a3d858821177ebdfeea ยท JEFF-Media-GbR/CustomBlockData

#
        at com.jeff_media.customblockdata.internal.CustomBlockDataListener.onPiston(CustomBlockDataListener.java:125) ~[Test.jar:?]
        at com.jeff_media.customblockdata.internal.CustomBlockDataListener.onPiston(CustomBlockDataListener.java:125) ~[Test.jar:?]
        at com.jeff_media.customblockdata.internal.CustomBlockDataListener.onPiston(CustomBlockDataListener.java:125) ~[Test.jar:?]
        at com.jeff_media.customblockdata.internal.CustomBlockDataListener.onPiston(CustomBlockDataListener.java:125) ~[Test.jar:?]

tender shard
#

nvm. I forgot that I only recompiled the library, but the plugin used to test it >.<

#

it can be enabled with CustomBlockData.registerListener(plugin);

muted sand
#

Wooo!!!

tender shard
#

:3

#

is there a way to automatically add links to javadocs in intellij?

#

E.g. when I mention "NamespacedKey" in the javadocs, I need a shortcut that automatically turns it into {@link NamespacedKey}

minor vapor
#

No, if your write the documentation correctly using the @link tag, it will make an href to the class you linked

willow gull
#

Anyone know how to fix bootup time for 1.16+, we are making a huge mini game server and we are trying to find someone who can efficiently fix this problem. The CPU usage on my dedi spikes to around 82% when starting a 1.18.2 Paper server, I tried 1.17 and stuff too, it's fine on 1.12.2 and below, just newer versions have issues. The CPU is Ryzen 7 3800X.

tender shard
#

I don't wanna type {@half zephyr all the time

#

sry for ping lol

muted sand
#

"hi"

#

yo wtf 0420 discrim without nitro

tender shard
#

I want IntelliJ to automatically insert the link tags @minor vapor

dense geyser
tender shard
#

kinda lol

minor vapor
tender shard
minor vapor
#

The IDE can't do everything on it's own sweat

tender shard
#

even in this tiny excerpt there's least 4 links missing and I don't wanna go through everything again all the time to add those links ><

ivory flume
minor vapor
#

However, it still requires you to type it at least once

tender shard
hasty prawn
dense geyser
#

Saving files in databases

tender shard
#

I'm smoking too much in front of the PC and then ash goes into the keyboard lol

#

anyway is there any way I can use the parametrized version of PersistentDataType here?

    public static PersistentDataType<?, ?> getDataType(PersistentDataContainer pdc, NamespacedKey key) {
        for (PersistentDataType<?, ?> dataType : PRIMITIVE_DATA_TYPES) {
            if (pdc.has(key, dataType)) return dataType;
        }
        return null;
    }

    public void copyTo(Block block, Plugin plugin) {
        CustomBlockData newCbd = new CustomBlockData(block, plugin);
        getKeys().forEach(key -> {
            PersistentDataType dataType = getDataType(this, key); // <----- HERE
            if (dataType == null) return;
            newCbd.set(key, dataType, get(key, dataType));
        });
    }
#

in the line where I added the comment

#

it works fine like this but yeah it's the raw type

#

when I add <?,?> to the dataType variable, javac isn't happy anymore

#

I basically need something like ?,? but at the same time tell javac that the second ? is definitely the same type as the first ?

quaint mantle
#

I've been trying to setup action bars for my plugin and every thread online says to do something like this but it always tells me Cannot resolve method 'sendMessage(ChatMessageType, TextComponent)'

package com.oneminesraft2;

import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.command.CommandSender;

public class Msg {
    public static void sendActionBar(CommandSender sender, String message) {
        TextComponent text = new TextComponent(message);
        sender.spigot().sendMessage(ChatMessageType.ACTION_BAR, text));
    }
}
#

nevermind i just had to cast sender to a Player class

muted sand
#

If I were to use CompleteableFutures, should I use the async method within them, or still invoke Bukkit's async thread to call the Future method?

humble tulip
#

Honestly I'm not sure

#

I was told here that bukkits asymc tasks can still run oj the main thread

#

So maybe completeAsync is the way to go for especially heavy stuff

muted sand
#

oh-

muted sand
#
    public static CompletableFuture<Boolean> postWebhook(String message) {
        CompletableFuture<Boolean> future = new CompletableFuture<>();
        future.completeAsync(() -> {
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println(message);
            future.complete(true);
            return true;
        });
        return future;
    }

I think I am doing this correctly? Intelij just told me to addd that return true; tho-
i could just return null

kindred valley
#

Is it possible we can create a client and that client will install forge mods automatically?

muted sand
#

doubt the server can access the client's filesystem

humble tulip
#

You don't need to call future.complete

#

Just return the value

ornate patio
#

how can i get NMS to work with Maven?

humble tulip
#

The code in the lambda method thing is what is run async to get your result

humble tulip
#

So just return the result

muted sand
#

im calling it as-

    @EventHandler
    public void onInventoryClick(InventoryClickEvent event) {
        CompletableFuture<Boolean> player1 = postWebhook("aaaaaa");
        event.getWhoClicked().sendMessage(player1.toString());
}
``` (ignore the event im using for this)
humble tulip
#

Yes

#

That's not the way to use it

muted sand
#

oh

#

what would the proper method be then?
and why can't i use it like that?

humble tulip
#

U need to call player1.whencomplete

#

So u can run code when it's finished getting thebvalue

kindred valley
muted sand
ornate patio
humble tulip
#

Code is gonna have to be nested somewhere

muted sand
humble tulip
#

You can have a class that handles all of that though

muted sand
#

oh, alrighty! thank you!!

little panther
#

do anyone know how to use custom items for a recipe?

humble tulip
#

I think nit because you casted?

#

New ExactChoice(IronStick)

harsh totem
#

I tried to do this and nothing happened

    public void SpawnMob(RaidEvent event){
        if (event.getRaid().getBadOmenLevel() >= 5){
            Illusioner mob = (Illusioner) event.getWorld().spawnEntity(event.getRaid().getLocation(), EntityType.ILLUSIONER);
            event.getRaid().getRaiders().add(mob);
        }
    }```
little panther
#

ill try this then

humble tulip
#

Because you passed an itemstack

little panther
humble tulip
#

Ide realized that it wasnt a recipechoice and assumed u were right

#

So it told you to cast

little panther
#

yea

humble tulip
little panther
humble tulip
#

What do u see in console?

#

So i can see which ifs are executed

harsh totem
#

it says this when I reload the server

org.bukkit.plugin.IllegalPluginAccessException: Unable to find handler list for event org.bukkit.event.world.WorldEvent. Static getHandlerList method required!```
humble tulip
#

Wait

harsh totem
#

wdym

humble tulip
#

That's a bukkit event

#

Wtf

harsh totem
#

am

#

how does that even work

humble tulip
#

Idek

harsh totem
#

the IDE doesn't show any error

#

lol

#
org.bukkit.event.EventException: null```
```Caused by: java.lang.UnsupportedOperationException```
sand frost
tardy delta
#

Method names start with a lowercase char

little panther
humble tulip
#

Symbol doesn't appear in shape

#

Let me see your code

little panther
#

can you see what call causes it? Cuz ive changed a few things since last time i tested

humble tulip
#

Let me see the recipe

little panther
#

im guessing its the recipe then

humble tulip
#

You're setting s twice

#

And there is no C

little panther
#

oh right

#

took an old template ๐Ÿ˜„

sand frost
#

Also there is a P

humble tulip
#

Did u replace C with P

#

And remove one setting of S

little panther
#

thats fixed, the plugin is working now

hybrid spoke
#

I C U P

little panther
#

but that event is not starting at all

humble tulip
#

Did u register the listener

little panther
tacit dagger
#

how i can get the circled config?

humble tulip
#

just tes

#

u wanna get like base?

tacit dagger
#

not only "tes"

crimson terrace
#

whats the key you have the list under (if any)

humble tulip
#

Ohh well just do just do getConfig.getKeys(false)

thorny dawn
#

it only displays scores from 3-0 while i have others registered aswell

hybrid spoke
thorny dawn
#

duplicates of what

hybrid spoke
#

scores

thorny dawn
#

score names?

#

oh

#

i didnt know it was a thing