#development

1 messages · Page 68 of 1

dusky harness
#

so as long as you modify the blockstate copy without updating, it won't actually change the type, even server-side

hoary scarab
#

👍

stuck canopy
#

but its not actually changing the type of the Block

hoary scarab
#

👍

stuck canopy
#

what does that mean

dusky harness
#

understood

hoary scarab
#

I can't think of a better response lmao

dusky harness
#

🥲

#

👍

stuck canopy
#

👍

hoary scarab
#

👍

forest jay
#

👍

hoary scarab
#

Material.isBlock()
Material.createBlockState().getBlock().getDrops() @stuck canopy

dusky harness
#

ooo

minor summit
#

that getBlock call is going to fail

#

the state is not attached to any position in a world

#

you can just do BlockState#getDrops, but drops are entirely loot-table driven so it can (and depending on the item, it will) return different things on separate calls

stuck canopy
junior shard
#

What would be the best way to store data such as a string which is the player's callsign, that is bound to their UUID?

Should I use a string list in the config and make the player's uuid the keys or should I go for a hashmap<UUID, String> and somehow save the hashmap to the config.yml so that the data carries over through server restarts?

torpid raft
#

although you probably don't want to use the default config.yml to store all your data

junior shard
#

Yeah I would make a callsignsData.yml

torpid raft
#

yee

junior shard
#

How do I go across saving the hashmap to the data file?

torpid raft
#

i think the general pattern you'd follow is loading the entire file once on startup, and putting all the contents into the hashmap

#

and then whenever a callsign is added or changed, you push the update to both the hashmap and the data file

#

you should never have to write the entire hashmap to your data file at once

#

(unless you end up having to change all / a ton of players' callsigns at the same time, but that seems unlikely)

#

you can also consider using a SQLite database instead of a yaml file, to make it easier on yourself for if/when you eventually want to add multi server support

spiral prairie
#

Or just use PDC

junior shard
junior shard
river solstice
#

database?? for data storing???

#

crazy wid it

junior shard
#

so I just asked

junior shard
#

very

cyan siren
#

I am loosing my marbles and have tried so many different things to get this to work. I keep getting null errors when trying to register a command, I've parsed the plugin.ml and made sure that it has the command name in it and formatted correctly, and am now at my wits end.

PlotManager.java:

package net.boredman.plotmanager;

import net.boredman.plotmanager.commands.*;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public final class PlotManager extends JavaPlugin {

    @Override
    public void onEnable() {
        getLogger().info("PlotManager has been enabled!");
        getCommand("plotallowance").setExecutor(new PlotAllowanceCommand());
    }

    @Override
    public void onDisable() {
        getLogger().info("PlotManager has been disabled!");
    }
}
#

PlotAllowanceCommand.java:

package net.boredman.plotmanager.commands;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import static org.bukkit.Bukkit.getLogger;

public class PlotAllowanceCommand implements CommandExecutor {
    
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        getLogger().info("Command executed!");
        if (command.getName().equalsIgnoreCase("plotallowance")) {
            if (args.length == 1) {
                String playerName = args[0];
                Player targetPlayer = Bukkit.getPlayer(playerName);

                if (targetPlayer != null) {
                    // Assuming the permission node is in the format plot.plots.x
                    String permissionNode = "plot.plots";

                    // Get the player's plot allowance
                    int plotAllowance = targetPlayer.hasPermission(permissionNode) ?
                            Integer.parseInt(targetPlayer.getEffectivePermissions().stream()
                                    .filter(perm -> perm.getPermission().startsWith(permissionNode))
                                    .findFirst().orElse(null)
                                    .getPermission()
                                    .replace(permissionNode + ".", ""))
                            : 0;


                    sender.sendMessage(targetPlayer.getName() + "'s plot allowance is: " + plotAllowance);
                    return true;
                } else {
                    sender.sendMessage("Player not found!");
                    return true;
                }
            } else {
                sender.sendMessage("Usage: /plotallowance <player>");
                return true;
            }
        }
        return false;
    }
}
#

plugin.yml:

name: PlotManager
version: '${project.version}'
main: net.boredman.plotmanager.PlotManager
api-version: '1.20'
prefix: [PLOTMGR]
authors: [BoredManCodes]

commands:
  plotallowance:
    usage: /plotallowance <player>
    description: Checks the allowance of a player.
#

And finally, the error that is making me drink:

[ERROR] Error occurred while enabling PlotManager v1.0-SNAPSHOT (Is it up to date?)
[Server] java.lang.NullPointerExceptionCannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "net.boredman.plotmanager.PlotManager.getCommand(String)" is null
#

Any help is greatly appreciated, please feel free to ping me

#

Full trace:

[07.12 06:25:08] [Server]     at net.boredman.plotmanager.PlotManager.onEnable(PlotManager.java:20) ~[PlotManager-1.0-SNAPSHOT.jar:?]
[07.12 06:25:08] [Server]     at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:281) ~[paper-api-1.20.2-R0.1-SNAPSHOT.jar:?]
[07.12 06:25:08] [Server]     at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:190) ~[paper-1.20.2.jar:git-Paper-318]
[07.12 06:25:08] [Server]     at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:104) ~[paper-1.20.2.jar:git-Paper-318]
[07.12 06:25:08] [Server]     at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:507) ~[paper-api-1.20.2-R0.1-SNAPSHOT.jar:?]
[07.12 06:25:08] [Server]     at org.bukkit.craftbukkit.v1_20_R2.CraftServer.enablePlugin(CraftServer.java:646) ~[paper-1.20.2.jar:git-Paper-318]
[07.12 06:25:08] [Server]     at org.bukkit.craftbukkit.v1_20_R2.CraftServer.enablePlugins(CraftServer.java:557) ~[paper-1.20.2.jar:git-Paper-318]
[07.12 06:25:08] [Server]     at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:627) ~[paper-1.20.2.jar:git-Paper-318]
[07.12 06:25:08] [Server]     at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:424) ~[paper-1.20.2.jar:git-Paper-318]
[07.12 06:25:08] [Server]     at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:308) ~[paper-1.20.2.jar:git-Paper-318]
[07.12 06:25:08] [Server]     at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1086) ~[paper-1.20.2.jar:git-Paper-318]
[07.12 06:25:08] [Server]     at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315) ~[paper-1.20.2.jar:git-Paper-318]
[07.12 06:25:08] [Server]     at java.lang.Thread.run(Thread.java:833) ~[?:?]
dusky harness
#

To verify

cyan siren
#

I have :)

hoary scarab
#

at net.boredman.plotmanager.PlotManager.onEnable(PlotManager.java:20)
Doesn't match the code you sent.

cyan siren
#

How so?

hoary scarab
#

line 20 isn't in onEnable

cyan siren
#

oh I deleted a bunch of comments where I was bitching about it not working 😅

#
[07.12 06:53:07] [Server]     at net.boredman.plotmanager.PlotManager.onEnable(PlotManager.java:15) ~[PlotManager-1.0-SNAPSHOT.jar:?]
[07.12 06:53:07] [Server]     at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:281) ~[paper-api-1.20.2-R0.1-SNAPSHOT.jar:?]
[07.12 06:53:07] [Server]     at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:190) ~[paper-1.20.2.jar:git-Paper-318]
[07.12 06:53:07] [Server]     at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:104) ~[paper-1.20.2.jar:git-Paper-318]
[07.12 06:53:07] [Server]     at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:507) ~[paper-api-1.20.2-R0.1-SNAPSHOT.jar:?]
[07.12 06:53:07] [Server]     at org.bukkit.craftbukkit.v1_20_R2.CraftServer.enablePlugin(CraftServer.java:646) ~[paper-1.20.2.jar:git-Paper-318]
[07.12 06:53:07] [Server]     at org.bukkit.craftbukkit.v1_20_R2.CraftServer.enablePlugins(CraftServer.java:557) ~[paper-1.20.2.jar:git-Paper-318]
[07.12 06:53:07] [Server]     at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:627) ~[paper-1.20.2.jar:git-Paper-318]
[07.12 06:53:07] [Server]     at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:424) ~[paper-1.20.2.jar:git-Paper-318]
[07.12 06:53:07] [Server]     at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:308) ~[paper-1.20.2.jar:git-Paper-318]
[07.12 06:53:07] [Server]     at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1086) ~[paper-1.20.2.jar:git-Paper-318]
[07.12 06:53:07] [Server]     at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315) ~[paper-1.20.2.jar:git-Paper-318]
[07.12 06:53:07] [Server]     at java.lang.Thread.run(Thread.java:833) ~[?:?]
#

Sorry about that

dusky harness
#

in the jar

cyan siren
#

Sure did

dusky harness
#

wait paper-plugin.yml

cyan siren
#

Didn't send it here to avoid spamming too much

dusky harness
#

plugin.yml gets ignored if you have paper-plugin.yml, no?

#

show your paper-plugin.yml

cyan siren
#

They are clones of each other

#
name: PlotManager
version: '${project.version}'
main: net.boredman.plotmanager.PlotManager
api-version: '1.20'
prefix: [PLOTMGR]
authors: [BoredManCodes]
description: A Simple helper plugin to handle adding and removing player's plot allowances.
website: https://boredman.net

commands:
  plotallowance:
    usage: /plotallowance <player>
    description: Checks the allowance of a player.

dusky harness
#

hm

#

that should fix it ^

#

also I would recommend removing the plugin.yml to avoid confusion

hoary scarab
#

Debug and try changing plotallowance.
I don't use paper so can't help much with that side of things.

dusky harness
junior shard
#

I am trying to save the keys and values from a hashmap to my data.yml file when the plugin disables, however every time I add things to the hashmap through my command, and restart the server / reload the plugin, it doesn't save into my "data.yml". Im not really sure what I am doing wrong

Main: https://pastebin.com/gBMbFjAw
DataFile: https://pastebin.com/NTT1g8Le

dusky harness
junior shard
#

in the CallsignCommand class?

dusky harness
#

yes

#

when you run saveDataFile(), you don't apply the hashmap into the file either

#

you only do data.yml -> hashmap

#

not hashmap -> data.yml

junior shard
#

does ```java
for (UUID uuid : classDataFile.getCallsignMap().keySet()) {
String key = uuid.toString();
String cs = classDataFile.getCallsignMap().get(uuid);

        DataFile.getDataFile().createSection("callsigns." + key);
        ConfigurationSection configSec = DataFile.getDataFile().getConfigurationSection("callsigns." + key);
        configSec.set("cs", cs);

        DataFile.saveDataFile();
    }
not go through all the keys of the hashmap and set it in the data file as

callsigns:
<playerUUID>:
cs: '<cs>'

cyan siren
proud pebble
#

also something else is that you can just always return true and then you can send your own message if the usage is wrong since how its formatted by default isnt the best in terms of design personally

cyan siren
#

Thanks for the insight ☺️

azure sky
#

Hey,
I made a datapack that gives you a knowledge book, and then a enchanted bow.

It works perfectly fine in survival, but on my server after crafting the knowledge book, nothing happens. if i right click it, it just dissappears

pleaseee help.

azure sky
hexed locust
#

You should also probably save after you're done loading in all the data instead of every single instance of you creating a section for a UUID.

junior shard
#

am I doing something wrong with putting the values into the hashmap in the first place?

graceful hedge
# junior shard

Aren’t you creating a new DataFile instance for each command execution?

#

Which in that case, the values are being populated into the map, but since you create a new map every time they’re not really saved across a single command execution. If that makes sense to you :>

river solstice
#

unless you have a static instance of the map

dusky harness
hoary scarab
sterile hinge
#

Code? Any proper measuring?

hoary scarab
#

Not full code but here is an example.```java
List<Entity> nearbyItems = getEntity().getNearbyEntities(radius, radius, radius).stream()
.filter(e -> e instanceof Item)
.collect(Collectors.toList());

Location minionLocation = getLocation();
nearbyItems.forEach(e -> {
Location loc = e.getLocation();
if(loc.distance(minionLocation) < .8)
return;

e.teleport(minionLocation);

});

#

https://i.imgur.com/221LrEk.mp4

List<Entity> nearbyItems = getEntity().getNearbyEntities(radius, radius, radius).stream()
        .filter(e -> e instanceof Item)
        .collect(Collectors.toList());

Location minionLocation = getLocation();
nearbyItems.forEach(e -> {
    Location loc = e.getLocation();
    if(loc.distance(minionLocation) < .8)
        return;

    Item item = (Item) e;
    e.remove();

    Item i = minionLocation.getWorld().dropItem(minionLocation, item.getItemStack());
    i.setVelocity(i.getVelocity().multiply(0));
});
graceful hedge
#

Yeah that’d be my theory as well, due to the little distance the entities have to travel minecraft code maybe just ends up applying some velocity to the entities instead, tho with that being said streams and using just distance could probably be optimized space wise and speed wise if wanted x)

hoary scarab
sterile hinge
#

Ah items might not be ticked every tick, but even then it looks long…

hoary scarab
#

Let me test on 1.8 real quick

#

I guess I'll stick to removing/respawning the items then.

#

Actually that might cause issues when it starts getting into the thousands of items lol

hoary scarab
#

🤦```java
if(!spawnEvent.isCancelled())
if(amount-canFit > 0)
leftOver.put(item, amount-canFit);
else
leftOver.put(item, amount);

stuck canopy
#

F

icy shadow
#

thats why we always add brackets to if/else

hoary scarab
#
if(spawnEvent.isCancelled())
    leftOver.put(item, amount);
else if(amount-canFit > 0)
    leftOver.put(item, amount-canFit);
```This functions correctly though lol
stuck canopy
#

why do you hate using brackets

hoary scarab
#

I don't hate using brackets... Just looks cleaner to me when 1 liners like these don't have them... If its multi line I enclose in brackets.

stuck canopy
#

👍

hoary scarab
#

This has been a bitch the past few days. Essentially recoding all my minions to work with blocks that aren't chests to add support for another plugin.
Haven't even started on 1.20.3 support.

unborn condor
#

Hy

hoary scarab
#

👋

graceful hedge
#

Maybe some more scopes just to emphasize: if ( x ) {{{ blah(); }}}

river solstice
#

even more real

azure sky
#

hey, i want to make a datapack, with a custom crafting helmet,
I dont know what i have to do to make the helmet look like the helmet i made, and not just the item helmet that you hold in your hand*

pleaseee helpieeee

signal grove
#

im trying to update a string list in a plugin config, yet this doesn't work. Any ideas?

List<String> rtpLocations = getConfig().getStringList("random-tp-locations");
rtpLocations.add(rtpString);
getConfig().set("random-tp-locations", rtpLocations);
saveConfig()
#

the config changes in memory, but it does not write to the file, and therefore is not persistent across restarts

#

Every other datatype seems to work fine, but string list is having troubles

hexed locust
signal grove
#

I can show more code, but i think the fact that i can access the updated values with getConfig().getStringList("random-tp-locations") in other scopes imply it's set correctly, so the issue is with saveConfig somehow

#

im using paper 1.8.8, if that makes a difference

graceful hedge
hoary scarab
#
private Field field = null;

private static Class instance = new Class();
public static Class instance() {
    if(instance.field == null)
        instance.field = Object;

    return instance;
}
```Any idea why this would be returning an `NPE` saying `instance` is null?
sterile hinge
#

It‘s a terrible idea to strip code when you don’t understand what’s happening

#

Especially when it‘s most likely related to initialization order

hoary scarab
#

It‘s a terrible idea to strip code
?

#

I have this same method in another class but it only errors in 1 of them.

#

🤦 the field and method are named the same and it becomes a stackoverflow

sterile hinge
#

The names don’t matter there

hoary scarab
#

Well I moved the null check to another method and it errored with stackoverflow

#

sigh still same error.

sterile hinge
#

Guess we can’t help you then

hoary scarab
#

🤷 You haven't even answered my second question lol

sterile hinge
#

What‘s the question? You didn’t share the actual code causing the error, and neither did you share the error/stacktrace

hoary scarab
#
private VoidChestAPI api = null;

private static VoidChestsHook instance = new VoidChestsHook();
public static VoidChestsHook get() {
    if(HookManager.instance().isEnabled("VoidChest") && instance.api == null) {
        instance.api = VoidChestAPI.getInstance();
        instance.storageManager = instance.api.voidStorageManager();
    }

    return instance;
}
#

Same code

#

instance.api is throwing NPE

sterile hinge
#

Where is this code in? Where is the exception message?

hoary scarab
#

In the class VoidChestsHook... In my server logs xD

spiral prairie
#

Yapper really wants to provide as little information as possible xD

hoary scarab
#

I'm providing what he's asking for lol
"Where is the code in"... "a class" What other answer can be provided?
"Where is the exception message"... "instance.api is throwing NPE"

#

Found the stackoverflow 🤦

#

private ChestMethods chestMethods = ChestMethods.get(); chestMethods runs VoidChestsHook.get() in its get method.

sterile hinge
#

It would be helpful if you just give the information the computer gives you instead of trying to translate it, because that step is lossy

hoary scarab
#

Welp solved now. Thanks for the help.

drowsy kite
#

im using rightclickswordlistener.ProjectileTypes to access a hashmap public HashMap<UUID, String> ProjectileTypes; in my rightclickswordlistener class from another class but it doesnt work does anyone know why?

drowsy kite
hoary scarab
drowsy kite
dusky harness
#

yeah I'd combine it

drowsy kite
#

alright thanks

hoary scarab
#

Thats prob the better option.

tulip anvil
#

does anyone know how i can apply a potion effect without it resetting? like for example: if i want to apply health boost, and if i re-apply it, the health goes back to 20 HP and the health boost hearts are empty even if they were regenerated

atomic trail
#

How can I look through a yaml config using Configurate?

someEvent:
  time: "0 0 16 * * *"
otherEvent:
  time: "0 0 16 * * *"
blah:
  time: "0 0 16 * * *"
blahBlah:
  time: "0 0 16 * * *"

Basically I want to do this for (String entry : configurationSection.getKeys(false))

#

Is it just ```java
for (CommentedConfigurationNode node : root.getChildrenList()) {

    }
?
molten venture
atomic trail
#

What's the difference between the key and the note?

molten venture
atomic trail
#

Makes sense, so the key in my case would be someEvent otherEvent etc.

#

Right?

#

How would I then get the time?

molten venture
molten venture
# atomic trail How would I then get the time?
for (Map.Entry<Object, ? extends CommentedConfigurationNode> kvp : root.getChildrenMap().entrySet()) {
    String key = kvp.getKey().toString();
    CommentedConfigurationNode node = kvp.getValue();

    // Get the time value for this key
    String time = node.getNode("time").getString();

    // Now you can work with the key and time
}
atomic trail
#

So it would be done like this?

        for (Map.Entry<Object, ? extends CommentedConfigurationNode> kvp : root.getChildrenMap().entrySet()) {
            String eventName = kvp.getKey().toString();
            CommentedConfigurationNode node = kvp.getValue();

            CommentedConfigurationNode timeNode = node.getNode("time");
            String time = timeNode.getString();
        }
#

Ah yeah nice

#

Thank you!

molten venture
#

Np😊

dense drift
#

With configurate you can use objects and deserialize them, but ig it depends on your config layout

shell moon
#

Any way to provide an ItemHook for DeluxeMenus using a plugin? (similar ti dbh- texture- etc)

dense drift
#

No

shell moon
#

Will there be any way?

#

I mean, i noticed the checks are like if starts with, if starts with, etc, which ofc requires the plugin to be updated to add any kind of support for a nnew item provider. Why no just check if it starts with one of the keys from the itemHooks map

dense drift
#

Old code

#

Maybe at some point™️

shell moon
#

Make it open source

dense drift
shell moon
dense drift
#

what packets do I need to modify in order to edit the lore of an item? I need this for custom enchantments & other stuff

dusky harness
#

that's gonna be a lot of packets 🥲

#

I think the best method is to just update the lore whenever an enchantment is modified

dense drift
#

I expect to be like 2-3 packets, but it is probably easier to edit the lore, yeah.

dusky harness
dense drift
#

I only need the packets that show the item to a player ig

molten venture
dense drift
minor summit
stark kraken
#

is there any recommended starting point for getting into the topic of networking? I'm feeling kind of stumped getting started on issues with our proxy and database remote

dusky harness
#

i didn't think of that 🥲

stuck canopy
#

is there a way to add the enchanted glowing effect to a ItemStack without adding any enchant to it?

flint kernel
#

i feel like there's a method in the API for that but I can't remember what/where xD

stuck canopy
#

is there? coz I don't see any methods which do that

flint kernel
#

I think people normally add some non-descript enchant then hide enchants

#

or at least did, last time i looked into it

stuck canopy
#

interesting

flint kernel
hoary scarab
#

Unfortunately an enchant is required. Unless that has been changed in later vrsions.

stuck canopy
#

aight, let me try creating a enchantment which does nothing

flint kernel
stuck canopy
dense drift
#

Nbt lib

shell moon
#

i think its fixed in newer versions (i think)

minor summit
#

jesus

#

1.4

#

the tag name has certainly changed since then lol

signal grove
#

is this channel strictly for mc development, or if i can ask a question about unrelated things like the pandas library in python?

icy shadow
#

the latter

atomic trail
#

Does someone know why the file won't generate in the server directory? Using Configurate

    private void loadConfig() {
        final HoconConfigurationLoader loader = HoconConfigurationLoader.builder()
                .setPath(plugin.getDataDirectory().resolve("events.yml"))
                .build();

        try {
            root = loader.load();
        } catch (IOException e) {
            LOGGER.error("An error occurred while loading the configuration for events.yml", e);
        }
    }

New to using Configurate so yeah

icy shadow
#

what happens?

atomic trail
#

Well no files are loaded into the server directory on startup

#

I thought that this would load the config into the plugins/plugin directory

#

Configurate 3.7.3, idk if that's an issue

#

Using velocity so cant rly change it

icy shadow
#

all that code does is reads a file and loads it

#

you need to copy the file from resources manually if thats what you want

atomic trail
#

Loading the resource into the server directory

icy shadow
#

well no because saveResource isnt a method in velocity

#

but yes in that it's just getting the resource & writing it

atomic trail
#

Wait no I can't, that uses JavaPlugin#getResource()

#

Anyone got an idea how else to do it?

icy shadow
#

ClassLoader#getResource

icy shadow
#

cheeky bit of reverse engineering

atomic trail
icy shadow
#

which is trivial to get

atomic trail
#

I don't think Velocity has class loaders though?

#

Or what

icy shadow
#

classloaders are a fundamental part of java

#

you cant write execute java (on the standard jdk) without them

#

so yes it does

atomic trail
#

Oh, it compiles when I just use Main.getInstance().getClass().getResource() but is that the correct ClassLoader?

#

And no it's not Main but yeah

icy shadow
#

for slightly odd reasons you need to use the CL

#

also you can just do Main.class

atomic trail
#

Oh yeah Main.class.getClassLoader()

#

Ty

#

Using this loader ```java
loader = HoconConfigurationLoader.builder()
.setPath(path)
.build();

icy shadow
#

why are you using HoconConfigurationLoader for a yaml file?

atomic trail
#

Ohhhh I thought it was a version of yaml

#

Dont mind me lol

dense drift
stuck canopy
dense drift
stuck canopy
#

there is nothing such as NBTTagList in the nbt api

#

nvm there is

stuck canopy
#

it looks like in the latest versions they removed Enchantment#registerEnchantment. is there any other method I can use to register custom enchants?

dense drift
#

Spigot is removing stuff now ??

stuck canopy
#

dont know about spigot but papermc definitely did

dusky harness
#

huh
there wasn't even a deprecated annotation

#

although it did say

Generally not to be used from within a plugin.

shell moon
dense drift
#

No more custom enchants or we have to register them though nms now?

red sedge
#

Hello, i would like to know if it is even possible to use relationalplaceholders with offline players instead of online players ?

flint kernel
#

through the registry system

dense drift
#

Yeah idk, the registry is only to get stuff, but I can't find a method to insert. You probably need to expose some method with nms

flint kernel
#

mm true

#
static final class SimpleRegistry<T extends Enum<T> & Keyed> implements Registry<T> {

  private final Map<NamespacedKey, T> map;
  
  protected SimpleRegistry(@NotNull Class<T> type) {
    this(type, Predicates.<T>alwaysTrue());
  }
  
  protected SimpleRegistry(@NotNull Class<T> type, @NotNull Predicate<T> predicate) {
    ImmutableMap.Builder<NamespacedKey, T> builder = ImmutableMap.builder();
    for (T entry : type.getEnumConstants()) {
      if (predicate.test(entry)) {
        builder.put(entry.getKey(), entry);
      }
    }
    map = builder.build();
  }
#

that seems to be what deals with inserting into the registry

minor summit
#

enchantment registry won't be modifiable until Mojang decides to, it is not synced to the client and modifying it isn't really expected by the server either
you can still ofc unfreeze the registry and alter it yourself, but until Mojang supports modifying it (via datapacks), API won't support it, it is still glhf territory as it always has been

#

the registry modification pr plans to align plugins to datapacks in what they can register, such as biomes and dimensions, tags, and more, all these are entirely supported by the server via datapacks

flint kernel
#

Here's a question, what is a datapack

dusty frost
#

it's like a resource pack but for the server

#

adds stuff to the game, like biomes and dimensions, tags, etc.

#

god it's gonna be so nice when that PR comes through, maintaining a separate datapack for stuff is such a pain in the ass

flint kernel
dusty frost
#

on server start, it reads from the datapacks folder, and registers them

#

it doesn't really directly do much, you still have to like add stuff

#

but you can modify drop tables and shit, add new armor trims, etc.

flint kernel
#

i'll pretend i understand half of what you just said

dusty frost
#

it's quite simple lol

flint kernel
#

keep in mind i've only recently started trying modern MC development (been stuck in 1.12 for a while)

dusty frost
#

they added data packs in 1.13 lol

flint kernel
#

exactly, so 1 version above my existence

#

think of it this way: i'm the minecraft equivalent of someone who only worked with Java 7 coming to Java 21

dense drift
dense drift
flint kernel
#

ig, but that'd require customising the server internals NMS]

#

i think

#

unless u screw around with reflection and try to change the value of the map field?

#

but the map still isn't exposed directly either

pure crater
#

It doesn’t have to be exposed, you can still modify it

flint kernel
#

yeah i suppose

dense drift
flint kernel
#

uhhhh u might be right yeah that might be bukkit

#

i dum

#

still point remains

minor summit
dense drift
#

And is there any way to make it mutable without nms?

flint kernel
#

u mean without reflection?

dense drift
#

Nah, nms, if there's a simple field like map that you can setAccessible(true) shrug but any way is fine ig

minor summit
#

i mean sure, you can just use reflection for everything

minor summit
#

but properly, unfreeze the registry and call whatever register method

dense drift
#

How? I was thinking about reassigning the map field with a HashMap value instead of an ImmutableMap - assuming it uses a map like that SimplyRegistry Mitch sent above

minor summit
#

not that easy

#

just unfreeze the registry and call Enchantments.register or w/e

#

(then freeze it again like the good citizen that you are)

dense drift
#

Well, there's no register method anymore, or was it moved to another class than Enchantment?

minor summit
#

i am not talking about api

#

either nms or with reflection which is effectively the same thing

#

not like registering enchantments was ever really api

stuck canopy
#

how do you unfreeze the registry

minor summit
#

you set the frozen field to false

pure crater
#

I like unfreezing my registries and not freezing again, leaving my changed immutablemaps as mutable maps, and doing setAcessible(true) and leaving it like that 🙂

#

And also what's @Inject. The only thing I use is @Overwrite (:

dense drift
#

Isnt it from a DI lib like Guice?

molten venture
#

Goodbye tier 1-9 😂

river solstice
#

yes yes

sonic quartz
#

Why getViewers method doesn't return all players viewing a chest inventory?

                    p.sendMessage(e.getViewers().get(i).getName());
                    Player player = (Player) e.getViewers().get(i);
                    player.closeInventory();
                }```
river solstice
#

maybe they are not looking at it

sonic quartz
#

No, the reason is that I'm an idiot. Solve this issue before you start coding guys!!!!!!!

sonic nebula
#

event when itemstack spawns?

#

from different reasons into world

#

is there such a event?

stuck canopy
#

How do you change the texture of a player head to a custom head on Head Database using PlayerProfile in paper

#
        profile.getProperties().put("textures", new com.mojang.authlib.properties.Property("textures", head));
        try {
            Field profileField = meta.getClass().getDeclaredField("profile");
            profileField.setAccessible(true);
            profileField.set(meta, profile);
        } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException exp) {
            return;
        }```
#

This is what I am currently using

sonic nebula
#

if itt works

stuck canopy
#

well the issue is that paper tells me to do this through the PlayerProfile api instead of reflection

sonic nebula
#

without reflection how u want to support multi versions

stuck canopy
#

huh?

sonic nebula
#

paper also dont like when people use System.out.println

stuck canopy
#

I am pretty sure theres a way to do this without reflection

stuck canopy
sonic nebula
#

well its usually reason why people use reflection ;/ , in my opinion there no reason to reinvent the wheel good luck with ur mission ❤️

stuck canopy
#

well that doesn't help

stuck canopy
#

doesn't make any sense

#

I would rather use PlayerProfile api than have my console spammed by
[20:09:07] [Server thread/WARN]: Found inconsistent skull meta, this should normally not happen and is not a Bukkit / Spigot issue, but one from a plugin you are using.
Bukkit will attempt to fix it this time for you, but may not be able to do this every time.
If you see this message after typing a command from a plugin, please report this to the plugin developer, they should use the api instead of relying on reflection (and doing it the wrong way).

hoary scarab
stuck canopy
#
        item.setType(getMaterial("PLAYER_HEAD"));
        SkullMeta meta = (SkullMeta) item.getItemMeta();
        GameProfile profile = new GameProfile(UUID.randomUUID(), "Player Head");
        profile.getProperties().put("textures", new com.mojang.authlib.properties.Property("textures", head));
        try {
            Field profileField = meta.getClass().getDeclaredField("profile");
            profileField.setAccessible(true);
            profileField.set(meta, profile);
        } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException exp) {
            return;
        }
        item.setItemMeta(meta);```
hoary scarab
#

What string are you using for head?

stuck canopy
hoary scarab
# stuck canopy

Hmm yeah odd might be specific to paper then.

Look into what gaby posted for paper I guess.

stuck canopy
dense drift
#

And the code below is for the base64 string

#

The url is the value below the rectangle in your picture

stuck canopy
#

oh you mean this?

hoary scarab
dense drift
#

and you can also get it from the bas64 string if you decode it, it is a simple json

dense drift
stuck canopy
#

anyways, I can give it another try maybe I did smth wrong before

#

yea, I was using this method

        item.setType(getMaterial("PLAYER_HEAD"));
        SkullMeta meta = (SkullMeta) item.getItemMeta();
        try {
            PlayerProfile profile = Bukkit.createProfile(UUID.randomUUID());
            profile.getTextures().setSkin(new URL("https://textures.minecraft.net/texture/" + head));
            meta.setPlayerProfile(profile);
        }catch (MalformedURLException exp) {
            throw new RuntimeException(exp);
        }
        item.setItemMeta(meta);
    }```
dense drift
#

Pass an empty string to the createProfile method

#

And make sure you use the right value as "head"

stuck canopy
#

yea the Minecraft URL

#

its giving me a head with default skins

#

fixed

dusky harness
uneven needle
#

successful id say

sonic nebula
#

any shit

#

stop lying

#

why i always see those clowns keep pretending to be programming what r u mentally insane see a psychiatrist instead

uneven needle
#

what?

stuck canopy
#

forgot to use that method

sonic nebula
#

eh scammers try hard

#

ill report that discord acc

#

lmao

#

oh no

#

;/

dusky harness
junior shard
#

Anyone know if luckperms has minimessage support?

#

I am working on a chat formatting plugin for my server and before I go through and seralize the messages with minimessage, I wanted to make sure luckperms actually supports it, or if it even matters

#

Actually now that I am thinking, If I just put <rainbow>Member as the prefix, it should just format it with my formatting plugin, yeah?

dusky harness
#

LP doesn't do any formatting on its own

junior shard
#

got it

junior shard
#

Anyone able to help me figure out where I went wrong that is causing this bug?

Velocity:

@Subscribe
    public void onPluginMessageFromPlayer(PluginMessageEvent event) {
        if (!(event.getSource() instanceof Player)) {
            return;
        }
        if (event.getIdentifier() != IDENTIFIER) return;

        Player player = (Player) event.getSource();
        ByteArrayDataInput in = ByteStreams.newDataInput(event.getData());
        String msg = in.readUTF();

        ByteArrayDataOutput out = ByteStreams.newDataOutput();
        out.writeUTF(msg);

        player.sendPluginMessage(IDENTIFIER, out.toByteArray());
    }

Paper Plugin Command: https://pastebin.com/3APaYNDz


The plugin is currently sending a message for each player that is online (ref the images), however when there is only 1 player online it works fine. (For example if both my accounts are on the same server it sends the message twice, I assume 3,4,5 times depending on how many other players are on. If I am connected to a seperate server on the proxy with just me online, and my alt being the only one online in a different proxy connected server, it only sends 1.

sonic nebula
#

I got weird homeless error

#

Gonna share tommrow

#

🙏🙏🙏

#

Meowowowowowowww I can’t do it anymore

junior shard
#

an update on my last message, I got the duplicate messages to stop, however now it looks like the text isnt getting serialized out of its json format

#

Command ran in game was /global testing 1 2 3 and was intended to return “testing 1 2 3”

flint kernel
#

I think it's because that is what you're sending

#

I'm not certain how adventure and minimessages' serialisation methods word but from what I can see, it looks like you're converting the minimessage to a component, using adventures serialisation stuff to convert it to JSON then sending that, except it seems you're doing the same thing on both ends

You're converting the already converted message back through as if you hadn't already done all that

iron merlin
#

Hello im trying to use the default config 1.20.2 it worked very well with only saving one thing but now it seems to not work and i dont know whats wrong with it

#
Random rand = new Random();
                int randomWarNumber = rand.nextInt(10000) + 1;
                FileConfiguration config = Warteams.plugin.getConfig();
                Team senderteam = Team.getTeam(player);
                Team enemyteam = Team.getTeam(Bukkit.getServer().getPlayerExact(args[0]));
                Bukkit.broadcastMessage(senderteam.getName() + "Team start a war with " + enemyteam.getName());
                long currentTimeInSeconds = System.currentTimeMillis() / 1000;
                LocalDateTime currentDateTime = LocalDateTime.ofEpochSecond(currentTimeInSeconds, 0, ZoneOffset.UTC);
                String texttosave = "wars." + randomWarNumber;
                config.set(texttosave,randomWarNumber);
                Warteams.plugin.saveConfig();
                config.set(texttosave + ".timecur",System.currentTimeMillis() / 1000);
                config.set(texttosave + ".timend", currentDateTime.plusMinutes(Long.parseLong(args[1])).toEpochSecond(ZoneOffset.UTC)) ;
                config.set(texttosave + ".who",senderteam.getName());
                config.set(texttosave + ".to",enemyteam.getName());
                config.set(texttosave +".text",senderteam.getName() + " start a war with " + enemyteam.getName());
                Warteams.plugin.saveConfig();
#

it didnt work with only one save.config also

#

Hello sorry guys it was my problem

junior shard
#

Why is my plugin sending the cooldown message on the first message sent by a player after a plugin reload / restart?
Command Class https://pastebin.com/aptxUxaa

#

After the first time, it works fine. Not a huge issue, but its just a bug that will continue to bother me

warm steppe
#

you can just probably store the time when player sent a message and then just check if they sent another one faster than allowed

#

ur just making ur life cancer for no reason

#

oh wait nvm, i have it

#

try clearing cooldown list in #onDisable() in your plugins main class

junior shard
#

Ah, let me try in 15m when I’m home

junior shard
warm steppe
junior shard
#

Ah

junior shard
#

Don't hashmaps already clear themselves on plugin disable by default? Since they're stored in memory and not a file?

#

Oh my god nevermind

#

it was a missing return statement in if (!cooldown.containsKey(player.getUniqueId())) {...

sonic nebula
#

changing itemstack on pickup

#

hmmm

#

should i modify the item or kill it and add item to player inventory?

junior shard
#

Can someone help me figure out why this is happening? I’m a little confused

@Override
    public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] bytes) {
        if (channel.equals("mccity:staff")) {
            ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
            Component msg = GsonComponentSerializer.gson().deserialize(in.readUTF());

            if (player.hasPermission("mccity.staffchat")) {
                player.sendMessage(msg);
            }
            return;
        }
…
#

I think it has to do with the hasPermission check. That code is just a copy paste of my global command (which works) but adds a permission check before sending the message to the player, and for some reason only one player receives any message, but anybody else with the permission can send but not receive

#

Should I use a for loop to loop through each player on the proxy and then do the permission check and send message instead?

molten venture
# junior shard Can someone help me figure out why this is happening? I’m a little confused ```...
@Override
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] bytes) {
    if (channel.equals("mccity:staff")) {
        ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
        Component msg = GsonComponentSerializer.gson().deserialize(in.readUTF());

        for (Player p : getServer().getOnlinePlayers()) {
            if (p.hasPermission("mccity.staffchat")) {
                p.sendMessage(msg);
            }
        }
        return;
    }
    // ...
}
junior shard
flint kernel
#

is that player the one who sent the message?

junior shard
#

The code that does that is exactly what he sent

proud pebble
#

that doesnt really make sense

junior shard
#

I tried adding the permission check and message send into a for loop, Player pl : getServer()GetOnlinePlayers

proud pebble
#

that code from what i can tell would send a message to all players

junior shard
#

Exactly my thought process…

junior shard
#

Alright one second, gotta log in to the pc

proud pebble
#

tho we shall find out when you post ur code again

junior shard
#

well instead of p like in his code, mine was pl

#

whereas the onPluginMessageRecieved method's player is player

#
if (channel.equals("mccity:staff")) {
            ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
            Component msg = GsonComponentSerializer.gson().deserialize(in.readUTF());

            for (Player pl : this.getServer().getOnlinePlayers()) {
                if (pl.hasPermission("mccity.staffchat")) {
                    player.sendMessage(msg);
                }
            }

            return;
        }
#

if I do player.sendMessage(msg), it works fine as long as all the receiving players are on the same server

#

however if I do pl.sendMessage(msg), it sends multiple messages to only one player @proud pebble

#

on the same server

#

on different server

flint kernel
#

if (pl.hasPermission("mccity.staffchat")) {
player.sendMessage(msg);
}

#

exactly what Luna was saying

junior shard
#

If I do

if (pl.hasPermission("mccity.staffchat")) {
                    pl.sendMessage(msg);
                }
``` this is what happens
flint kernel
#

so you/the sender see the message twice?

junior shard
#

Yeah

flint kernel
#

Would that be because... you're sending the message to yourself when you run the command

#

meaning it's being sent twice, once there and once more with the messaging

junior shard
#

I mean I dont think player.sendPluginMessage(McCityChat.plugin, "mccity:staff", out.toByteArray()); sends directly to the player right?

#

This should just send the plugin message from the player

flint kernel
#

you're never sending it to yourself in the actual command?

junior shard
#

Nope

flint kernel
#

interesting

#

not a damn clue then

junior shard
junior shard
flint kernel
#

Real question I think tho is, why are you doing this as a server-proxy plugin instead of proxy-only?

junior shard
#

Well I guess the cross-server message commands could just be through a proxy command

#

but this plugin also handles local server chat as well

#

such as normal chat gets cancelled and turned into a formatted proximity based chat, and there will be commands such as /whisper /yell which will also not be cross-server and be proximity based as well

flint kernel
#

I'd imagine there might be other inter-server staff-related stuff, no?

#

could be worth just having a dedicated staff proxy plugin that handles everything at the proxy level

#

centralises permissions handling for that part too

junior shard
#

If I just make it proxy sided I guess that should be a lot easier

flint kernel
#

Yeah

junior shard
#

For the commands, the class code is basically the same but without sending the plugin message, and in my @subscribe I would just register it using the CommandManager and CommandMeta stuff, yeah?

#

oh wow that pinged someone

flint kernel
#

Not sure how Velocity's command system works, but probably

#

The two solutions that come to mind are:

  • make it proxy sided only, cus you can handle everything there then
  • keep the dual system, but still check permissions and handle relaying to all required players at the proxy level

both of which end up with needing to assign proxy-level permissions, so may as well just avoid the added complexity of sending and receiving plugin messages and just handle it at the proxy level

junior shard
#

Right

#

All my permissions are synced across the proxy and all servers through a luckperms db anyways,

#

Alright I will give this a try

proud pebble
#

isnt there a generic sendpluginmessage?

#

actually lemme think

#

uhh

#

its possible that when you send a plugin message that it ends up sending it back to itself aswell as other servers?

junior shard
#

What it is doing is sending to the proxy, then the proxy sends it back to itself + the other servers, yes

#

but the pluginmessage isnt being sent twice

#

It goes from server1 --> proxy --> server1, server2, server3
so the onPluginMessageRecieved should only be called once

proud pebble
#

the server what runs it

#

cus idk if thats a velocity,bungee or spigot method

junior shard
molten venture
# junior shard I tried this exact code last night and the issue with for loops is that one of t...
@Override
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] bytes) {
    if (channel.equals("mccity:staff")) {
        ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
        Component msg = GsonComponentSerializer.gson().deserialize(in.readUTF());

        if (player.equals(getServer().getPlayer(player.getName()))) {
            for (Player p : getServer().getOnlinePlayers()) {
                if (p.hasPermission("mccity.staffchat")) {
                    p.sendMessage(msg);
                }
            }
        }
        return;
    }```
#

Idk really know

warm steppe
#

just cancel the chat event if typing in staff chat

molten venture
#

The problem maybe is onPluginMessageReceived

proud pebble
proud pebble
#
for (Player pl : this.getServer().getOnlinePlayers()) {
  if (pl.hasPermission("mccity.staffchat")) {
    player.sendMessage(msg); //player variable specified in the onPluginMessageReceived method args, is the origin player of the message
  }
}

^^^ this would go through the online player list and send a message to the origin player for as many players are currently online, 5 players online with the permission would mean 5 messages to the origin player and no one else.

for (Player pl : this.getServer().getOnlinePlayers()) {
  if (pl.hasPermission("mccity.staffchat")) {
    pl.sendMessage(msg);
  }
}

^^^ this would go through the online player list and send a message to everyone currently online on that server with the permission, this would include the origin player if they are online on that server just cus they are in the list

#

but the code youve provided and how its described doesnt line up with whats actually expected from the code

#

are you making sure that both servers are actually on the same version of the plugin?

#

tbh the funky behaviour can only really been explained by different versions of the plugin, one running fixed code one running the old not working properly code

#

tbh id add a random uuid onto the end of the message to see if its actually being duplicated or not or if its deciding to be late sending the messages

#

generate it during the command's oncommand, add it onto the end of the message before you use player.sendpluginmessage and also send the uuid to the player thats running the command

#

just to be sure

hoary scarab
#

Bukkit.broadcastMessage("String", "Permission.Node");

junior shard
#

player sends the message to the origin player once for each player thats online

#

pl isnt even sending it to the origin player, its just sending it to the first one of the player list

#

since aDrew1 is higher than aDrew02, its only sending the messages to aDrew1 and not aDrew02

#

It genuinely makes no sense

junior shard
#
if (channel.equals("mccity:staff")) {
            ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
            Component msg = GsonComponentSerializer.gson().deserialize(in.readUTF());

            Bukkit.broadcast(msg, "mccity.staffchat");
        }
dusky harness
#

if so, I would only send 1 plugin message to each server

icy shadow
#

^

dusky harness
#

and if that doesn't work properly, debug or do the loop and debug that if needed

junior shard
#

Does player.sendPluginMessage() send it to each online player?

#

Or does it send a plugin message from the player

dusky harness
#

can you show the code where you send

#

I'm not entirely sure since I haven't used plugin messages much

junior shard
#

yes

#

This is the code from the velocity plugin

in ```java
@Subscribe
public void onPluginMessageFromPlayer(PluginMessageEvent event)

--
```java
if (event.getIdentifier() == STAFFIDENTIFIER) {
            for (Player player : proxy.getAllPlayers()) {
                ByteArrayDataInput in = ByteStreams.newDataInput(event.getData());
                ByteArrayDataOutput out = ByteStreams.newDataOutput();
                out.writeUTF(in.readUTF());

                Optional<ServerConnection> connection = player.getCurrentServer();
                connection.ifPresent(serverConnection -> serverConnection.sendPluginMessage(STAFFIDENTIFIER, out.toByteArray()));

                player.sendPluginMessage(STAFFIDENTIFIER, out.toByteArray());
            }
        }
icy shadow
#

event.getIdentifier() == STAFFIDENTIFIER
this is very questionable

junior shard
#

wdym

icy shadow
#

what is the type of getIdentifier()?

junior shard
#

MinecraftChannelIdentifier

icy shadow
#

oh velocity

#

ic

dusky harness
#

wait why are you sending another plugin message on PluginMessageEvent?

junior shard
#

ye

dusky harness
#

oh

#

is this not spigot api

icy shadow
#

yeah this is weird code

junior shard
#

This is from the velocity side plugin

icy shadow
#

connection.ifPresent(serverConnection -> serverConnection.sendPluginMessage(STAFFIDENTIFIER, out.toByteArray()));

            player.sendPluginMessage(STAFFIDENTIFIER, out.toByteArray());

you're effectively sending the same message twice here

dusky harness
#

is this a velocity and velocity only plugin?

#

oh wait nevermind

junior shard
#

Velocity and Paper plugin

icy shadow
#

we already know its not

dusky harness
#

I don't think you would need paper plugin for this tho

#

since you can send/receive messages via velocity api i think

junior shard
#

No I just recently learned I could just make the commands directly in the velocity plugin

#

But I am also still figuring the SimpleCommand stuff out in velocity

dusky harness
#

if you use plugin messaging, you should either have PluginMessageEvent in velocity or spigot - not both

#

im pretty sure

#

or alternatively use velocity only

icy shadow
#

oh

#

smh

#

whenever u edit ur message it makes me look dumb 😦

junior shard
#

lmfaooo

dusky harness
#

I just added the last part

icy shadow
#

yeah and that changed the meaning

dusky harness
#

to clarify 🥲

icy shadow
#

pros and cons to both really, though i think i'd favour the first

dusky harness
#

you wouldn't need velocity plugin for 2nd tho, right?

icy shadow
#

uhh

junior shard
#

Well velocity in the 2nd one would handling sending the plugin message out

#

so

#

yes

dusky harness
#

but shouldn't it handle it automatically?

#

bungee does at least

icy shadow
#

i think dkim's right

dusky harness
#

I have never made a velocity plugin before so idk

icy shadow
#

although i cant remember very well

junior shard
#

Does velocity have that ability?

#

I know you can use the BungeeCord pluginmessaage in velocity which would do that

dusky harness
icy shadow
#

honestly it's fairly easy to find out and fairly easy to fix if it's not what you/we expected

#

so just try it and see

junior shard
#

Im just a little stumped on the SimpleCommand, I can't get it to work on the servers

dusky harness
#

wait are you trying to do bm's 1 or 2
since the original post seemed like 2, but now it seems like 1

icy shadow
#

"work" how?

junior shard
junior shard
#

idk if that was english, I have a headache

dusky harness
#

if velocity api lets you send messages to players directly, I wouldn't recommend using plugin messages at all

junior shard
#

It should, considering the API has the ability to create commands that are supposed to be "injected" on all connected servers

#

I just gotta learn SimpleCommand in the velocityAPI now lmao

tepid wagon
#

Hi, I am trying to make 'drivable' pigs, I want to disable the AI of the pig, and when I do that it no longer lets me set velo, I have tried to tp the pig but it won't tp until I get off of the pig. I am using protocol lib to read WASD inputs, but i'm just struggling to figure this out for some reason. spigot 1.20.2

sonic nebula
#

how to change itemstack

#

on pickup

#

without looping thru player inventory and deleting the entity from floor

#

ItemStack itemStack = event.getItem().getItemStack();
if (itemStack.getType() == Material.REDSTONE_BLOCK){
event.getItem().setItemStack(C4);

#

it doesnt change it ;/

azure sky
#

hey, i make a texturepack that changes the crossbow texture when it has a certain custom model data,

somehow the texture of the normal crossbow already has a arrow in it, AND it is the default crossbow with arrow, not mine with arrow :( please help...

#

pleeease help i neeeed it :c

sonic nebula
#

u make all textures for load and etc

#

tho

azure sky
#

mhh yea but no working :c

#

can i send you the texturepack in dm?

sonic nebula
#

no thank you

#

here downloaod that

#

look how it was made

#

replicate

#

we call it reverse enginerrring lol

azure sky
#

I tried exaaactly that with exactly this datapack

#

Texture pack i mean*

sonic nebula
#

so try again

#

ist simple

azure sky
tiny merlin
#
String luckpermsPrimaryGroupName = PlaceholderAPI.setPlaceholders(Player, "%luckperms_primary_group_name%");

Player Player = getServer().getPlayer(UUID.fromString());

"Illegal forward refrence" ...?

dense drift
#

Where are you getting that from?

#

Also, UUID.fromString expects a string argument

tiny merlin
dense drift
#

You need an actual Player object if that's an error you get from your editor.

#

I see you have the Player variable defined after you use it. Also, rename it to player shrug the IDE might not like that it has the same name as the class

tiny merlin
#

So player Player = ... ?

dense drift
#

Player player

tiny merlin
#

Ah

tiny merlin
dense drift
#

No.
Try to read some java tutorials for beginners to get used with the syntax.

junior shard
#

I’m pretty sure the luckperm docs say how to do this

fading stag
#

Is there any alternative of PersistentDataContainer for 1.13

sterile hinge
#

not directly, you could add nbt tags yourself using some additional API

fading stag
#

Oh, pure pain

#

Thanks

shell moon
#

NBTAPI

stuck canopy
#

how does CreatureSpawner check for a spawnable location?

fading stag
# shell moon NBTAPI

It is for an open source project, not sure about if project owner is cool with using NBTAPI

minor summit
#

NBTAPI is open source and the license is highly permissive

#

I fail to see the problem

dense drift
#

Lol dude, you are more than fine to use NBT API

warm steppe
#

oh waiit, so nbtapi is easier way to handle pdc ?

#

i just looked it up and it seems so fine

dense drift
#

Pdc is just the nbt implementation of spigot

#

You should use pdc if you are on 1.14+ and it fits your needs shrug_animated

shell moon
honest spoke
#

Hey, trying to connect to an SQLite db file using Hikari and the org.xerial JDBC driver, but I'm getting this UnsatisfiedLinkError I've never seen before, does anyone know what's happening here?

java.lang.UnsatisfiedLinkError: 'void me.katsumag.example.shaded.xerial.core.NativeDB._open_utf8(byte[], int)'
The driver is shaded and relocated properly, NativeDB exists at that path, and decompiling it inside of IJ shows that exact function does exist.

torpid raft
#

just use a regular sql connection

minor summit
#

sqlite does not like being relocated

#

(don't do it)

#

but also, sqlite with hikaricp is fine really

#

you won't lose anything from using it

honest spoke
minor summit
#

spigot ships the driver already, so unless you need a feature from some specific version (newer or older) then I don't see a reason to shade it

#

otherwise you'll have to get into territory like isolated classloaders to avoid all potential conflicts but still use your driver

#

but you can't relocate it

honest spoke
#

Fair enough, thank you. I forgot spigot already includes it, works fine now I'm not shading + relocating it.

pure crater
#

Yeah for anything that uses native libs relocaating it will cause JNA to not work correctly

#

because the JNA method headers actually use the package names when calling the native methods lol

craggy zealot
#

can someone help me with updating my

#

packets displayname? when I remove and add it back there is a flicker of a defualt minecraft skin that looks really bad and was wondering if there is a fix for that

#
@Override
    public void updateFakePlayer(Player player) {
        new BukkitRunnable() {
            @Override
            public void run() {
                if(!player.isOnline()) {
                    this.cancel();
                }
                //add
                FakePlayer x = new FakePlayer(new FakePlayerUtil().getNextLetter(s), player.getHealth() + "", true);
                x.getTablistAddPacket().sendPacketOnce(player);
                new BukkitRunnable() {
                    @Override
                    public void run() {
                        x.getTablistRemovePacket().sendPacketOnce(player);
                    }
                }.runTaskLater(MafanaNetwork.getInstance(), 20L);
            }
        }.runTaskTimer(MafanaNetwork.getInstance(), 0L, 20L);
    }```
#
protected TabListAddFakePlayerPacket(UUID uuid, String playerName, String displayText) {
        super(uuid, playerName, displayText);
        WrappedGameProfile gameProfile = new WrappedGameProfile(uuid, playerName);
        PacketContainer packet = getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
        setPacket(packet);
        PlayerInfoData data = new PlayerInfoData(FakePlayerPacket.changeGameProfileSkin(gameProfile), 20, EnumWrappers.NativeGameMode.CREATIVE, WrappedChatComponent.fromText(displayText));
        List<PlayerInfoData> infoLists = Collections.singletonList(data);
        if (VersionUtil.isNewTabList()) {
            EnumSet<EnumWrappers.PlayerInfoAction> actions = EnumSet.of(
                    EnumWrappers.PlayerInfoAction.ADD_PLAYER,
                    EnumWrappers.PlayerInfoAction.UPDATE_LATENCY,
                    EnumWrappers.PlayerInfoAction.UPDATE_LISTED, EnumWrappers.PlayerInfoAction.UPDATE_DISPLAY_NAME);
            packet.getPlayerInfoActions().write(0, actions);
            packet.getPlayerInfoDataLists().write(1, infoLists);
            return;
        }
        packet.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.ADD_PLAYER);
        packet.getPlayerInfoDataLists().write(0, infoLists);
    }```
#

let me know if you want to see the remove also

molten venture
# craggy zealot ```java @Override public void updateFakePlayer(Player player) { new ...
@Override
public void updateFakePlayer(Player player) {
    new BukkitRunnable() {
        @Override
        public void run() {
            if(!player.isOnline()) {
                this.cancel();
            }
            //add
            FakePlayer x = new FakePlayer(new FakePlayerUtil().getNextLetter(s), player.getHealth() + "", true);
            x.getTablistUpdatePacket().sendPacketOnce(player); // Update instead of adding or removing
        }
    }.runTaskTimer(MafanaNetwork.getInstance(), 0L, 20L);
}
protected TabListUpdateDisplayNamePacket(UUID uuid, String playerName, String displayText) {
    super(uuid, playerName, displayText);
    WrappedGameProfile gameProfile = new WrappedGameProfile(uuid, playerName);
    PacketContainer packet = getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
    setPacket(packet);
    PlayerInfoData data = new PlayerInfoData(FakePlayerPacket.changeGameProfileSkin(gameProfile), 20, EnumWrappers.NativeGameMode.CREATIVE, WrappedChatComponent.fromText(displayText));
    List<PlayerInfoData> infoLists = Collections.singletonList(data);
    EnumSet<EnumWrappers.PlayerInfoAction> actions = EnumSet.of(EnumWrappers.PlayerInfoAction.UPDATE_DISPLAY_NAME);
    packet.getPlayerInfoActions().write(0, actions);
    packet.getPlayerInfoDataLists().write(0, infoLists);
}
stuck canopy
#

is there a way to check if a ArmorStand is rotating?

worn jasper
worn jasper
#

probably doable with js extension also, not the right channel... use #general-plugins

bronze skiff
#
    at com.google.common.collect.ImmutableMap.put(ImmutableMap.java:781) ~[guava-32.1.2-jre.jar:?]
    at org.bukkit.craftbukkit.v1_20_R2.util.CraftMagicNumbers.loadAdvancement(CraftMagicNumbers.java:264) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3926-Spigot-dba3cdc-ffb1319]
#

niche question but anyone familar with why loadAdvancement is giving an UO exception in 1.20.2+ now?

dusty frost
#

Probably related to the whole registries thing, Paper has a proposal for making those a lot better to use iirc

bronze skiff
#

the top right message is what im trying to do

dusty frost
#

Seems to be updated recently

bronze skiff
dusty frost
#

It does mention toasts in the spigot description, so maybe you could look at how they do their code for inspiration?

bronze skiff
#

not familar with toasts?

#

whats that

dusty frost
#

What you're using it for

#

A little message that pops up and goes away after a bit

bronze skiff
#

ah ok cool ty

neat pierBOT
molten venture
#

?

craggy zealot
#

I never really worked with packets so i dont know whats going on

molten venture
# craggy zealot https://paste.helpch.at/caconeyaqa.rb it gave me this error at first but after f...
protected TabListUpdateDisplayNamePacket(UUID uuid, String playerName, String displayText) {
    super(uuid, playerName, displayText);
    WrappedGameProfile gameProfile = new WrappedGameProfile(uuid, playerName);
    PacketContainer packet = getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
    setPacket(packet);
    PlayerInfoData data = new PlayerInfoData(FakePlayerPacket.changeGameProfileSkin(gameProfile), 20, EnumWrappers.NativeGameMode.CREATIVE, WrappedChatComponent.fromText(displayText));
    List<PlayerInfoData> infoLists = Collections.singletonList(data);

    EnumSet<EnumWrappers.PlayerInfoAction> actions = EnumSet.noneOf(EnumWrappers.PlayerInfoAction.class);

    actions.add(EnumWrappers.PlayerInfoAction.UPDATE_DISPLAY_NAME);

    packet.getPlayerInfoActions().write(0, actions);
    packet.getPlayerInfoDataLists().write(0, infoLists);
}
thin tendon
#

anyone know if deluxemenus have an api?

waxen escarp
#

According to the wiki, DeluxeMenus does not have an official API, but it has some features that allow you to interact with other plugins or commands. For example, you can use commandeventhttps://github.com/HelpChat/DeluxeMenus-Wiki/blob/master/README.md to trigger a command when a player clicks an item, or openguimenuhttps://github.com/HelpChat/DeluxeMenus-Wiki/blob/master/README.md to open another menu from a menu. You can also use placeholders from other plugins in your menus, as long as they are registered with PlaceholderAPI.

#

do u understand?

thin tendon
# waxen escarp do u understand?

Ye, what I need tho is to somehow be able to parse DeluxeMenu config files from my plugin, cause I’m too lazy to code my own system for GUI’s

dense drift
#

@waxen escarp dont copy random chatgpt text

waxen escarp
#

oh

#

yes i'm sorry

sonic nebula
#

bad math

#

instead of blocks in radius poor performance

#

i suggest u to do something in concept of tree

#

instead devide x,y,z into cubes of 64x64x64 and if they contain a safezone do the check

#

really shit performance what u did there

left sigil
red elbow
hoary scarab
sonic nebula
#

64x64x64 dont really present much

#

but u get what i mean

#

im pretty sure

hoary scarab
#

You need to get the min and max of each coordinate otherwise this will break in some cases...

sonic nebula
#

also look

#

how he loops

#

so much performance to garbage

#

no jokes

#

by splitting it into chunks

#

and checking if player in the right chunk

#

lets say chunk will be a x/100 y/100 z/100

#

just x z

#

not y

#

then u get in return a chunk4/3 for example

hoary scarab
#

Use worldguard's API and just add an if to check if a region exists. If you want to go deeper check for specific flags as well.

sonic nebula
#

then u chunk if the chunk is effected chunk

#

and only then u loop

#

but he loops for everyone

#

heavy check

hoary scarab
#

I'm still not understanding your explanation.
Maybe write up some code that does what you're saying...

sonic nebula
#

ok sec just from mobile so if there any weird shit ;l

#
List<String> concept = new Arraylist<>; //we store all near region players
List<Region> regions = new Arraylist<>;
List<Player> incombat = new Arraylist<>; //regions we have
//i wrote it from mobile so may there be some shit problems but its just the concept
//lets imagine is a runnable that runs every 20ticks
void run(){
for(loop for in combat players){ 
 Region region = Region.fromplayer(playerfromshitloop)
 if(regions.contain(region){
double minX = Math.min(pointA.getX(), pointB.getX());
double maxX = Math.max(pointA.getX(), pointB.getX());
double minZ = Math.min(pointA.getZ(), pointB.getZ());
double maxZ = Math.max(pointA.getZ(), pointB.getZ());
double x = Math.max(minX, Math.min(location.getX(), maxX));
double z = Math.max(minZ, Math.min(location.getZ(), maxZ));
if (location.distance(new Location(location.getWorld(), x, location.getY(), z) > 20) {
  async task to send packets of blocks to player! and check if he passes inside teleport out of bounds of region
}
#

just the concept

#

he never needs to even loop via all players

#

cant understand why infirst place he is loops for all players

#

no reason really

#

Region object conttains 2 corners

#

and couple of metthods

#

simple math

hoary scarab
#

Yeap

sonic nebula
#

not sure how to call it exactly suddenly didnt do a CS degree lol

#

ii can compare it to suffix tree

#

some how i dont know

sterile hinge
#

binary tree

#

or what do you mean exactly?

sonic nebula
#

the thing i suggested to that guy

#

who his code look like he just uses glue and puts things together

sterile hinge
#

that seems to be something completely different

sonic nebula
#

search pattern

#

i mean

#

i see something simillar maybe fantasy

#

but in general he asked on how he can improve

#

idk sirYwell i guess its casual tonyfalk activity this is how you call it ;l

sterile hinge
#

not sure if you understood what they want to do

sonic nebula
#

nah i didnt read i just saw that disgusting code

#

and wanted to vomit

sterile hinge
#

and your vomit is your code?

sonic nebula
#

oh

#

check the API

#

never come back here

#

.<

#

XYProblem

sonic nebula
hoary scarab
#

Basically Tony is saying collect regions and players in combat. Loop through that list of players instead of all. Then check the distance between those players and the list of regions and then set the block at the region.

sonic nebula
#

Yapperyapps i only now realized that this mister hotkinky asked something completely different

#

i mean if he is cool with looping all server with that block loop check

#

which is heavy af usually anticheatst only do checks like tha

#

and not in range of 9 blocks lol

#

anyway yeah he asked about worldguard related sh7t

#

so i assume he could not google and think of using worldguard AP

#

API

#

so :l

#

there couple of options first one its language model code i always see them coming here with some bullshit generated code

#

maybe im just ret@rd not sure

river solstice
sonic nebula
#

what r we code slaves here common he works for his own resource

#

i have an guy on discord that ask me to help him with his code and i literally just code for him liike for 1 2 hours a day

#

like it used to be like that

#

till i was like man u didnt learn a sh7t since we started doing tha

#

useless for society

#

also Modi u know what i think acceptable asking for something small and not fixing someone else code made with glue and bullshit generator

#

so i bet u want to help someone and he steal credits and dont leave a singature for u in his plugin

#

because he gonna claim later on i made it by my self there was no modi free help included

jade wave
#

What in the frick is going on here?

sterile hinge
#

tony falk is going on

sonic nebula
#

SirYwell my g friend lets go to off-topic chat? got to share some crazy info about today

river solstice
jade wave
#

@river solstice oh so the usual?

river solstice
#

somewhat, yes

dense drift
#

@sonic nebula try not to spam smh

sonic nebula
dense drift
#

Well, think more before sending the message smh

gilded imp
glacial flower
gilded imp
#

😢

glacial flower
hoary scarab
gilded imp
#

my fault

rapid mist
#

Who is from US?
I need some help.
Please DM.

grave sky
#

can anyone help me with this

i made a credits plugin with a method to get credits of a player and i want to add a placeholder to it via PlaceholderAPI i not familier with either java, placeholder api can anyone help me do it here is the code im trying to do with but it is not working

https://paste.helpch.at/kajebuyecu.typescript

shell moon
#

To check the distance between 2 players (for a chat radius feature), should i use distance or distanceSquared?
Can someone mention the actual diferences? I mean, i know distance calls Math.sqrt(distanceSquared(loc)), but how does that impact in my checks if i want to specify 10 blocks maximum of distance, for example?

river solstice
#

use Location#distance if you need exact distance.
use Location#distanceSquared if you only need the general idea of distance, ex.: for sorting. It won't work correctly for your use case.

shell moon
sterile hinge
#

So calculating the distance when you can do your stuff with the squared distance just isn’t needed and adds some overhead

shell moon
#

i want owners to select the amount of blocks (of distance)

#

can i use distanceSquared and compare it with the amount of blocks (to squared)??

sterile hinge
#

If you square both sides, the math is the same yeah

#

(Given there is no semantics behind negative values)

shell moon
#

thanks fingerguns

#

i'll do that, so i avoid using Math.sqrt

river solstice
#

I mean, unless you're doing 10k's of calls every second, the sqrt call wont kill your server

worn jasper
#

(unsure if its 100% called that)

shell moon
#

I think getNearbyEntities do a lot more stuff than distanceSquared

worn jasper
sterile hinge
#

I mean it depends on what you want to achieve

shell moon
#

Basically, be able to use in chat event

#

for example

e.getRecipients().removeIf(p-> p.getLocation().distance(e.getPlayer().getLocation()) < 10)
``` maybe
```java
e.getRecipients().removeIf(p-> p.getLocation().distanceSquared(e.getPlayer().getLocation()) < (10 ^ 2)) //i mean, use the custom value fromm config
```?????
sterile hinge
#

If you want all players in a certain distance, getNearbyPlayers might be better than going through all players

shell moon
#

btw there is not getNearbyPlayers

#

getNearbyEntities

#

idk tbh

sterile hinge
#

well it's faster to only go through the entities of the relevant chunks than through all chunks

shell moon
shell moon
#
    public CreditsManager(JavaPlugin plugin, FileConfiguration playerData) {
        this.plugin = plugin;
        this.playerData = playerData;
        register(); //<---
    }
shell moon
#

bruh pingWut

worn jasper
# shell moon

then get the nearby entities and filter it by Players?

worn jasper
worn jasper
shell moon
#

ahhh

#

i checked 1.20.4

minor summit
shell moon
hoary scarab
#

Any idea what could be causing this?

Chest chest = (Chest) chestLocation.getBlock().getState();
Inventory chestInventory = chest.getInventory();
Inventory inventory = chestInventory instanceof DoubleChestInventory ? ((DoubleChest) chestInventory.getHolder()).getInventory() : chestInventory;
        
getLogger().info("DEBUG (ChestMethods - Remove) >> "+item.toString());
Map<Integer, ItemStack> leftover = inventory.removeItem(item);
getLogger().info("DEBUG (ChestMethods - Remove) >> Leftover: "+leftover.toString());

DEBUG (ChestMethods - Remove) >> ItemStack{DIAMOND_BLOCK x 10}
DEBUG (ChestMethods - Remove) >> Leftover: {}

signal grove
#

how can i max out enchantments at certain levels

#

(for example, so that sharpness caps out at 3. I want it so players right clicking the enchant table don't even see sharpness 4 as an option)

hoary scarab
#

Probs use reflection to adjust the value of max level from Enchantment.DAMAGE_ALL

signal grove
hoary scarab
#

🤷 method works in other locations but the location Im testing in won't work... If I set the item amount to be 128 it removes the first stack from the chest.

signal grove
#

unrelated, but why do you need to cast it to a DoubleChest then getInventory, if inventory is already instanceof DoubleChestInventory?

hoary scarab
#

Cause if its not casted it returns the chests inventory and not the doublechest inventory.

signal grove
#

weird, you'd think if you store it as a general Inventory, then it'd do that casting for you

hoary scarab
#

🤷 I use to just do chest.getInventory but always had issues with it not taking items from the top or bottom section of doublechests

signal grove
#

does your current issue happen in single chests?

#

or just double

hoary scarab
#

Both

#

And like I said this doesn't happen in other locations of code that use this method... Its really weird.

#
@Override
public int getMaxLevel() {
    return 5;
}
```Welp my way is out xD
You could probably recreate the `DamageEnchantment` (mapped: `EnchantmentWeaponDamage`), or maybe extend it, class and set your own max level then reregister the enchantment with your class.
signal grove
#

bro what

#

hardcoded 5

#

idk, i just looked up a public plugin and im gonna test it now xD

spark skiff
#

Which means your editing the copy of the chest and not the chest thats currently in the world

#

You can fix it by either setting the block state as the copy or getting the inventory directly from the block

signal grove
#

hmm, but it works in some cases

spark skiff
#

It shouldn't work in all cases

hoary scarab
#

Odd. Like I said never had this issue with other locations using this method.
I'll do some testing with updating then and see how that goes. I did test with chest.update() and it just removes the first itemstack every time.

signal grove
#

that means something else is removing itemsfrom it

spark skiff
#

I'm pretty sure another fix is to just add true as a param (getState(true))

#

Which gets the current state of the block and not a copy

hoary scarab
#

Not seeing any boolean parameters

signal grove
#

i want my plugin to obtain info from a Teams plugin api (things like getTeamName, isInTeam, etc), so i have it as a soft dependency. If the teams plugin isnt on the server, I just want to return some default values. Is there a way I can store a Teams plugin instance if the plugin is loaded, and have it null if not? Or do I have to give each of those methods an ugly check for if(Bukkit.getPluginManager.getPlugin("Teams")....) ?

spark skiff
#

You may want to use interfaces for this

hoary scarab
#

getState() doesn't return a copy... Unless getState().copy() is useless lol

signal grove
#

thats what im seeing as well^

signal grove
#

although the docs say that getState is not guaranteed to update

#

meaning its just like, a single point in time

hoary scarab
#

I have tested chest.update() but like I said it removes the entire first stack for some reason.
I've used this method for years now with out issues but moving its location in my code seems to break it in only 1 location so far. Its super weird.

signal grove
#

try removing the items yourself, rather than inventory.removeItem

hoary scarab
#

...

signal grove
#

xD

hoary scarab
#

How do you suppose I remove them?

signal grove
#

what i mean is just to iterate and set items, rather than a single removeItem call

spark skiff
#

Just get the inventory instance from the block

hoary scarab
#

...

spark skiff
#

Dont get it from a snapshot

signal grove
#

you cant cast block to chest

#

you have to getState and cast the state to chest

#

(unless im thinking of something else)

hoary scarab
#

^^^

spark skiff
#

Ok disregard everything I said above

signal grove
#

i made this a while ago and i remember getting casting errors unless i did

player.openInventory(((Chest) attachedBlock.getState()).getInventory());
hoary scarab
#
DEBUG (ChestMethods - Remove) >> ItemStack{BUCKET x 1}
DEBUG (ChestMethods - Remove) >> Leftover: {}
#

Just showing this method does work in other locations of code...

spark skiff
#

Run chest.update() after editing

hoary scarab
spark skiff
#

Are you doing this in an event?

hoary scarab
#

Nope

#

I've also tried chest.getBlockInventory() same issues.

spark skiff
#

Ok now I'm confused

hoary scarab
#

So am I for the past 4 hours xD

spark skiff
#

I'd there a difference in behavior between single chests and double chests?

hoary scarab
#

Nope

signal grove
hoary scarab
#

Well I wish it was consistent with the 128 but sometimes it removes it other times it doesn't

signal grove
#

but in all cases, the hashmap is empty

hoary scarab
#

yeap

signal grove
#

so it successfully thinks it removed the items

hoary scarab
#

Testing with an itemstack of buckets in the location thats having issues.

proud pebble
spark skiff
#

getState(true) doesnt work?

hoary scarab
hoary scarab
proud pebble
#

whats the coordinates of the chests, one that works and one that doesnt

hoary scarab
#

Both don't work

spark skiff
#

Strange

proud pebble
spark skiff
#

getState(boolean) should exist

hoary scarab
signal grove
#

oh paper

proud pebble
#

like the one there

#

with the buckets

#

thats a working one right?

spark skiff
#

Oh spigot

hoary scarab
proud pebble
#

so whats the working code and whats the not working code, side by side

#

theres gotta be some form of differences

hoary scarab
#

Not working: java if(used != 0) { ItemStack clone = block.clone(); clone.setAmount(used); usage.removeItemFromChest(clone, this); } Working ```java
if(usage.removeItemFromChest(remove, this) == null)

spark skiff
#

What's usage?

hoary scarab
#

ChestMethods class

spark skiff
#

Can I see the method code

signal grove
#

guessing block is ItemStack of 128 diamond blocks

proud pebble
#

i hope not

proud pebble
#

cus if it is that makes sense why it doesnt work

#

tho still weird if its just 10

#

should remove 10 from the inventory

hoary scarab
#
public ItemStack[] removeItemFromChest(ItemStack item, Minion minion) {
    Location chestLocation = minion.getLinkedChest("CHEST", true);
    if(chestLocation == null)
        return new ItemStack[] {item};
        
    if(voidchests != null && voidchests.isVoidChest(chestLocation))
        return voidchests.removeItem(item, item.getAmount(), minion);
        
    Chest chest = (Chest) chestLocation.getBlock().getState();
    Inventory chestInventory = chest.getBlockInventory();
    Inventory inventory = chestInventory instanceof DoubleChestInventory ? ((DoubleChest) chestInventory.getHolder()).getInventory() : chestInventory;
        
    getLogger().info("DEBUG (ChestMethods - Remove) >> "+item.toString());
    Map<Integer, ItemStack> leftover = inventory.removeItem(item);
    getLogger().info("DEBUG (ChestMethods - Remove) >> Leftover: "+leftover.toString());
        
    return convertFromMap(leftover);
}
hoary scarab
spark skiff
#

?

#

The entire block is being cloned though

proud pebble
#

personally id just say fuck it and manually loop and modify the inventory instead of using the remove method cus it doesnt like to work

signal grove
#

^

hoary scarab
spark skiff
#

Oh

#

Oh shoot

#

Misread

#

Its 3:00

hoary scarab
proud pebble
#

oof

signal grove
#

you can keep the same methods and just change its implementation

hoary scarab
signal grove
#

yes

#

but inventory method is maybe not working as expected

hoary scarab
#

I get that... but it use to lol And it still does in portions of my code which is why its so frustrating.

signal grove
#

if you test it out with your own iterative remove, and it works, then you will at least know the problem is in removeItems rather than somewhere else

spark skiff
#

Can I see voidchests.removeItem?

signal grove
#

its not voidchests, its Inventory i think

hoary scarab
#

I'm not using voidchests

#

Thats why you can see the debug code lol

#

Also chest.getBlockInventory() only returns the inventory for the left or right of the chest. Which ever you are getting the block from.
Even with my casting of DoubleChest lol

spark skiff
#

I'm pretty sure thats normal

signal grove
#

i've used chest.getInventory() in mine, which returns the whole inv regardless of single of double (at least in all of my testing)

#

otherwise getBlockInventory would be useless

hoary scarab
#

Yeah I've had weird bugs through out the years with getting chest inventories... But atleast the inventory methods worked.

spark skiff
#

Have you tried updating spigot

signal grove
#

btw, the difference may not be in implementations, but in materials. Maybe if you replace the diamond block material with bucket it will show a difference

hoary scarab
spark skiff
#

See if it makes a difference, cause I'm completely confused

hoary scarab
hoary scarab
signal grove
#

nvm

spark skiff
#

What about with paper 1.20.2?

signal grove
#

and therefore it is a broken method that has been lucky

hoary scarab
#

What???? Now I'm hella confused lol
I commented out the portion that removes the used block and added the buckets... it removed the buckets and a stack of diamond blocks.

ItemStack buckets = new ItemStack(Material.BUCKET, 5);
usage.removeItemFromChest(buckets, this);
getLogger().info("DEBUG (Builder) >> Removing: "+buckets);
            
/*if(used != 0) {
    ItemStack clone = block.clone();
    clone.setAmount(used);
    usage.removeItemFromChest(clone, this);
}*/
spark skiff
#

Tf

hoary scarab
#

Yeah IDK maybe I'm too fucking tired and missing something stupid lol

signal grove
#

gonna wake up tomorrow and realize there's just no chest or something xD

hoary scarab
#

Nah just erased it all and started over lol

hoary scarab
#

So... I collect contents from the chest then run it through a sorting method that sorting method places the item stack into a list That list gets turned into an array by combing the amounts from the itemstacks.

Long story short I added .clone() during the sorting and somehow it fucking works.

hoary scarab
sonic nebula
#

difference between WOOD_DOOR and WOODEN_DOOR materials?

torpid raft
#

en

sonic nebula
#

beside it

#

one is the item one is the existing one or?

sonic nebula
#

thanks ^^

#

i was too lazy to the debugging

#

u know its tonyfalk mental problems

#

today i tottaly loost my mind i feel like i want to scream like it will let the bad spirits out of me

#

ivan i text u in offtopic

heady orbit
#

Hi, ive tried to code a system that changes the inventory per world.

Per world there are 2 inventories:
1 build inventory
1 "normal" inventory

Ive tried to make a system that lets the player change that, but ive failed. Currently the inventory only gets deleted when i change them/sometimes they just stay the same

Could someone have a look at my code and help me out?
Thank u

https://pastebin.com/N8y4CLFU

torpid raft