#development
1 messages · Page 68 of 1
👍
but its not actually changing the type of the Block
👍
what does that mean
understood
I can't think of a better response lmao
👍
👍
👍
Material.isBlock()
Material.createBlockState().getBlock().getDrops() @stuck canopy
ooo
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
yea I have tried that before but got an error
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?
I would probably opt for a hashmap that is synced to a persistent storage like you said
although you probably don't want to use the default config.yml to store all your data
Yeah I would make a callsignsData.yml
yee
How do I go across saving the hashmap to the data file?
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
Or just use PDC
PDC?
shoot I didnt even think of a db
LOL yeah but I sat here thinking which way to do it for 2 hours that I continued to overthink the simple
so I just asked
very
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) ~[?:?]
Try opening up the jar
To verify
I have :)
at net.boredman.plotmanager.PlotManager.onEnable(PlotManager.java:20)
Doesn't match the code you sent.
line 20 isn't in onEnable
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
did you open the plugin.yml too?
in the jar
Sure did
wait paper-plugin.yml
Didn't send it here to avoid spamming too much
plugin.yml gets ignored if you have paper-plugin.yml, no?
show your paper-plugin.yml
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.
hm
that should fix it ^
also I would recommend removing the plugin.yml to avoid confusion
Debug and try changing plotallowance.
I don't use paper so can't help much with that side of things.
the issue is that paper-plugins.yml doesn't support commands
Not exactly sure why, but 🤷
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
I am setting the hashmap stuff in my callsign command https://pastebin.com/TcBVb772
in line 51 here, you never actually save the hashmap
in the CallsignCommand class?
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
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>'
Thanks for the help guys!
https://i.imgur.com/YNBN4Fa.png
I can hopefully fgure out the rest myself now :)
since its a seperate command class, you should beable to drop the command.getname... thingy
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
Thanks for the insight ☺️
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.
if i give myself the bow with command, the texture is there, if i move it from hotbar into my inv or just move it generally, it has the normal bow texture again :c
Could be that your main class @ line 12 and 13, you're saving before checking the section and also not checking if the section exists or not. You shouldn't have to create a section every instance if you're copying the contents every instance.
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.
I just made a test command that should help me figure out if the values are even being put into the hashmap in the first place, and it looks like they arent
Callsign Set/Remove Command: https://pastebin.com/DQnjRPzu
Callsign Test (Debug) Command: https://pastebin.com/aipsJMqK
am I doing something wrong with putting the values into the hashmap in the first place?
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 :>
well it depends on your implementation of DataFile, but that seems to be wrong, basically what Conclube said
unless you have a static instance of the map
Btw spigot will automatically create a configurations extinct for you
Why does Entity.teleport(Location) take so long? Didn't it use to be instant?
https://i.imgur.com/2ZXjd24.mp4
Code? Any proper measuring?
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));
});
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)
Yeah its just testing at this point. I'll do the optimizing later.
Ah items might not be ticked every tick, but even then it looks long…
Let me test on 1.8 real quick
Hmmm... https://i.imgur.com/jnCKZcR.mp4
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
🤦```java
if(!spawnEvent.isCancelled())
if(amount-canFit > 0)
leftOver.put(item, amount-canFit);
else
leftOver.put(item, amount);
F
thats why we always add brackets to if/else
if(spawnEvent.isCancelled())
leftOver.put(item, amount);
else if(amount-canFit > 0)
leftOver.put(item, amount-canFit);
```This functions correctly though lol
why do you hate using brackets
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.
👍
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.
Hy
👋
if(x) { blah() }
real
Maybe some more scopes just to emphasize: if ( x ) {{{ blah(); }}}
even more real
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
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
Probably better to show more code
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
Got more code? And nah, the config code has stayed relatively same from 1.8 to 1.20 in bukkit/paper etc :)
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?
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
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
The names don’t matter there
Well I moved the null check to another method and it errored with stackoverflow
sigh still same error.
Guess we can’t help you then
🤷 You haven't even answered my second question lol
What‘s the question? You didn’t share the actual code causing the error, and neither did you share the error/stacktrace
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
Where is this code in? Where is the exception message?
In the class VoidChestsHook... In my server logs xD
Yapper really wants to provide as little information as possible xD
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.
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
Welp solved now. Thanks for the help.
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?
wdym 'it doesn't work'?
it gets a red underline in intelij and when i try to make it into a jar i get the error cannot find symbol
Its not static... You need a reference of the class to access it
should i just merge my two listeners since they are for the same thing? one shoots the arrow other one checks when it lands
yeah I'd combine it
alright thanks
Thats prob the better option.
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
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()) {
}
?
for (Map.Entry<Object, ? extends CommentedConfigurationNode> kvp : root.getChildrenMap().entrySet()) {
String key = kvp.getKey().toString();
CommentedConfigurationNode node = kvp.getValue();
// Now you can work with the key and node
}
What's the difference between the key and the note?
key is the identifier for a piece of data, and node is the actual data at that key, which could be a value or another configuration section.
Makes sense, so the key in my case would be someEvent otherEvent etc.
Right?
How would I then get the time?
Exactly
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
}
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!
Np😊
With configurate you can use objects and deserialize them, but ig it depends on your config layout
omg crontab my beloved
Any way to provide an ItemHook for DeluxeMenus using a plugin? (similar ti dbh- texture- etc)
No
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



what packets do I need to modify in order to edit the lore of an item? I need this for custom enchantments & other stuff
that's gonna be a lot of packets 🥲
I think the best method is to just update the lore whenever an enchantment is modified
I expect to be like 2-3 packets, but it is probably easier to edit the lore, yeah.
maybe
There's at least Set Container Content, Set Container Slot, and whatever packets are used for item drop entity
Maybe some for armorstand as well, etc
I think it's just safer to edit the lore
I only need the packets that show the item to a player ig
PacketPlayOutSetSlot
The problem with this is that I can't modify items created with other plugins like essentials, only when the enchantment is added with my command or other ways like custom books
there are more than just that
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
hmm
i didn't think of that 🥲
is there a way to add the enchanted glowing effect to a ItemStack without adding any enchant to it?
i feel like there's a method in the API for that but I can't remember what/where xD
is there? coz I don't see any methods which do that
I think people normally add some non-descript enchant then hide enchants
or at least did, last time i looked into it
interesting
I found this, which involves creating a new enchantment and using that:
https://bukkit.org/threads/how-to-create-glowing-items-without-actually-enchanting-them-1-14.479311/
Unfortunately an enchant is required. Unless that has been changed in later vrsions.
aight, let me try creating a enchantment which does nothing
https://gist.github.com/aadnk/4580362
No idea if this [still] works, though I could see why it might, since it puts the ench/Enchantments flag on the item, which might be enough for the client to say "ah that has enchantments, better make it glow"?
is this possible without using nms?
Nbt lib
i think its fixed in newer versions (i think)
is this channel strictly for mc development, or if i can ask a question about unrelated things like the pandas library in python?
the latter
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
what happens?
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
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
Yeah that's what I meant, is it still done the same way as usually?
Loading the resource into the server directory
well no because saveResource isnt a method in velocity
but yes in that it's just getting the resource & writing it
Can't I just copy the method spigot uses though? I don't see why it would be different
Wait no I can't, that uses JavaPlugin#getResource()
Anyone got an idea how else to do it?
ClassLoader#getResource
or even better, look at the source of this & figure it out from that
cheeky bit of reverse engineering
Then I also need the ClassLoader so yeah
which is trivial to get
classloaders are a fundamental part of java
you cant write execute java (on the standard jdk) without them
so yes it does
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
getClass() returns a Class, not a ClassLoader, so no
for slightly odd reasons you need to use the CL
also you can just do Main.class
Oh yeah Main.class.getClassLoader()
Ty
Got an idea what's wrong with this?
guess-number:
time: "0 0 16 * * *"
description: "whatever"
Using this loader ```java
loader = HoconConfigurationLoader.builder()
.setPath(path)
.build();
why are you using HoconConfigurationLoader for a yaml file?
Something I've tried that seems to work so far https://paste.helpch.at/vafadohagi.java
The idea is to store the original lore and add the enchantments underneath
how so?
This is what I usually use https://modrinth.com/plugin/nbtapi, this takes care of NMS for you
it looks like in the latest versions they removed Enchantment#registerEnchantment. is there any other method I can use to register custom enchants?
Spigot is removing stuff now ??
or maybe papermc doesn't have it
dont know about spigot but papermc definitely did
declaration: package: org.bukkit.enchantments, class: Enchantment
declaration: package: org.bukkit.enchantments, class: Enchantment
huh
there wasn't even a deprecated annotation
although it did say
Generally not to be used from within a plugin.

No more custom enchants or we have to register them though nms now?
Hello, i would like to know if it is even possible to use relationalplaceholders with offline players instead of online players ?
It seems you can still do it through the API, i might be smoking something tho
through the registry system
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
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
Paper seems to be working on something related to this:
#1179518554702348319 message
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
Here's a question, what is a datapack
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
howtf that work
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.
i'll pretend i understand half of what you just said
keep in mind i've only recently started trying modern MC development (been stuck in 1.12 for a while)
they added data packs in 1.13 lol
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
I mean, custom enchants were not displayed to clients anyways, it was just a way for plugins to use your enchants 
That's cool
So we can simply replace the map with a HashMap
?
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
It doesn’t have to be exposed, you can still modify it
yeah i suppose
Isnt this from the Registry class?
Nvm: for enchants they use Bukkit.getRegistry which idk what it does
it pulls it from the internal registry
And is there any way to make it mutable without nms?
u mean without reflection?
Nah, nms, if there's a simple field like map that you can setAccessible(true)
but any way is fine ig
i mean sure, you can just use reflection for everything
but properly, unfreeze the registry and call whatever register method
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
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)
Well, there's no register method anymore, or was it moved to another class than Enchantment?
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
how do you unfreeze the registry
you set the frozen field to false
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 (:
Isnt it from a DI lib like Guice?
Goodbye tier 1-9 😂
yes yes
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();
}```
maybe they are not looking at it
No, the reason is that I'm an idiot. Solve this issue before you start coding guys!!!!!!!
event when itemstack spawns?
from different reasons into world
is there such a event?
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
so whats the problem
if itt works
well the issue is that paper tells me to do this through the PlayerProfile api instead of reflection
without reflection how u want to support multi versions
huh?
paper also dont like when people use System.out.println
I am pretty sure theres a way to do this without reflection
I didn't mention multi version support
well its usually reason why people use reflection ;/ , in my opinion there no reason to reinvent the wheel good luck with ur mission ❤️
well that doesn't help
why tf would I need to use reflection to texture a player head for multi version support when PlayerProfile api is there from like 1.13
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).
I haven't had issues just adding a name to the game profile.
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);```
I am using a custom head texture from (https://minecraft-heads.com)
What string are you using for head?
Hmm yeah odd might be specific to paper then.
Look into what gaby posted for paper I guess.
where can I get the urls from?
And the code below is for the base64 string
The url is the value below the rectangle in your picture
oh you mean this?
From the base64
and you can also get it from the bas64 string if you decode it, it is a simple json
Yeah it is https://textures.minecraft.net/texture/<id> I think
I think I tried this yesterday
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);
}```
Pass an empty string to the createProfile method
And make sure you use the right value as "head"
What was the solution?
ive been coding this stuff for 3 years to this date i have no clue how any of this works
successful id say
u dont code
any shit
stop lying
why i always see those clowns keep pretending to be programming what r u mentally insane see a psychiatrist instead
what?
damn 😂 😂
u can report the message directly
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?
yes
LP doesn't do any formatting on its own
got it
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.
I got weird homeless error
Gonna share tommrow
🙏🙏🙏
Meowowowowowowww I can’t do it anymore
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
Paper Plugin Main Class https://pastebin.com/CYS9Uzvm
Paper Plugin Command Class https://pastebin.com/wwvhHHSh
Velocity Plugin Main Class https://pastebin.com/c65J11A1
Command ran in game was /global testing 1 2 3 and was intended to return “testing 1 2 3”
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
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
Ah yeah.. didn't realize I never deserialized the minimessage
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
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
Ah, let me try in 15m when I’m home
Are you referencing to the math crap in there for checking the time? Lmao
i didnt look in to it when i typed it
Ah
Clearing the hashmap didnt seem to change anything
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())) {...

changing itemstack on pickup
hmmm
should i modify the item or kill it and add item to player inventory?
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?
@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;
}
// ...
}
I tried this exact code last night and the issue with for loops is that one of the players gets multiple messages (1 for each online)
is that player the one who sent the message?
send the code that does that
The code that does that is exactly what he sent
that doesnt really make sense
I tried adding the permission check and message send into a for loop, Player pl : getServer()GetOnlinePlayers
that code from what i can tell would send a message to all players
Exactly my thought process…
just post what youve put
Alright one second, gotta log in to the pc
this sounds like instead of putting the variable name of the player object of the loop, in the case of asyncchunk's code which is just p, youve put player instead
tho we shall find out when you post ur code again
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
if (pl.hasPermission("mccity.staffchat")) {
player.sendMessage(msg);
}
exactly what Luna was saying
If I do
if (pl.hasPermission("mccity.staffchat")) {
pl.sendMessage(msg);
}
``` this is what happens
so you/the sender see the message twice?
Yeah
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
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
you're never sending it to yourself in the actual command?
Nope
hence why I have been confused as hell on this all night
Real question I think tho is, why are you doing this as a server-proxy plugin instead of proxy-only?
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
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
If I just make it proxy sided I guess that should be a lot easier
Yeah
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
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
Right
All my permissions are synced across the proxy and all servers through a luckperms db anyways,
Alright I will give this a try
why are you doing player.sendPluginMessage?
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?
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
where is that ran?
the server what runs it
cus idk if thats a velocity,bungee or spigot method
That is ran on the server plugin under the onPluginMessageRecieved event
@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
just cancel the chat event if typing in staff chat
The problem maybe is onPluginMessageReceived
they run a command, they dont actually send a chat message
that makes no sense as if your looping through the player list and then only calling player, it would send many messages to the origin player and no one else
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
Bukkit.broadcastMessage("String", "Permission.Node");
Yeah, that is exactly how I understood it. However both of those don't work as expected
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
does the same thing :/
if (channel.equals("mccity:staff")) {
ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
Component msg = GsonComponentSerializer.gson().deserialize(in.readUTF());
Bukkit.broadcast(msg, "mccity.staffchat");
}
are you sending a plugin mesage to each player?
if so, I would only send 1 plugin message to each server
^
and if that doesn't work properly, debug or do the loop and debug that if needed
Does player.sendPluginMessage() send it to each online player?
Or does it send a plugin message from the player
can you show the code where you send
I'm not entirely sure since I haven't used plugin messages much
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());
}
}
shouldnt do
event.getIdentifier() == STAFFIDENTIFIER
this is very questionable
wdym
what is the type of getIdentifier()?
MinecraftChannelIdentifier
wait why are you sending another plugin message on PluginMessageEvent?
ye
yeah this is weird code
This is from the velocity side plugin
connection.ifPresent(serverConnection -> serverConnection.sendPluginMessage(STAFFIDENTIFIER, out.toByteArray()));
player.sendPluginMessage(STAFFIDENTIFIER, out.toByteArray());
you're effectively sending the same message twice here
Velocity and Paper plugin
we already know its not
I don't think you would need paper plugin for this tho
since you can send/receive messages via velocity api i think
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
if you use plugin messaging, you should either have PluginMessageEvent in velocity or spigot - not both
im pretty sure
or alternatively use velocity only
scroll up mate
oh
smh
whenever u edit ur message it makes me look dumb 😦
lmfaooo
I just added the last part
yeah and that changed the meaning
to clarify 🥲
there are 2 real options here, you're currently doing both at once:
- velocity plugin only where you do the player loop on the proxy and just send each player the message directly through the proxy
- velocity + paper, just send a single message to each server, and let the server plugin handle the loop
pros and cons to both really, though i think i'd favour the first
you wouldn't need velocity plugin for 2nd tho, right?
uhh
Well velocity in the 2nd one would handling sending the plugin message out
so
yes
i think dkim's right
I have never made a velocity plugin before so idk
although i cant remember very well
Does velocity have that ability?
I know you can use the BungeeCord pluginmessaage in velocity which would do that
I would assume so in order to keep compatibility, but #development message
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
Well, as for making a single velocity plugin which would handle the network-wide chat commands, I was reading into this https://docs.papermc.io/velocity/dev/command-api
Im just a little stumped on the SimpleCommand, I can't get it to work on the servers
wait are you trying to do bm's 1 or 2
since the original post seemed like 2, but now it seems like 1
"work" how?
If I remember when I tested it, running the command would just send nothing
Originially what I sent was me trying to use Plugin Messaging using a Velocity Plugin connected with a Paper Plugin, but realistically the better option would just be to make the commands that send messages to all servers be just on the velocity plugin
idk if that was english, I have a headache
if velocity api lets you send messages to players directly, I wouldn't recommend using plugin messages at all
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
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
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 ;/
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
its different textures should be applied for both
u make all textures for load and etc
tho
no thank you
here downloaod that
look how it was made
replicate
we call it reverse enginerrring lol
bump
I actually did exactly that, that only made it more confusing
I tried exaaactly that with exactly this datapack
Texture pack i mean*
yeea but it doesnt work x.x
String luckpermsPrimaryGroupName = PlaceholderAPI.setPlaceholders(Player, "%luckperms_primary_group_name%");
Player Player = getServer().getPlayer(UUID.fromString());
"Illegal forward refrence" ...?
The Player in .setPlaceholders(Player, "%...%");
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
the IDE might not like that it has the same name as the class
So player Player = ... ?
Player player
Ah
Could this just be .getPlayer(UUID()); then?
No.
Try to read some java tutorials for beginners to get used with the syntax.
I’m pretty sure the luckperm docs say how to do this
Is there any alternative of PersistentDataContainer for 1.13
not directly, you could add nbt tags yourself using some additional API
how does CreatureSpawner check for a spawnable location?
It is for an open source project, not sure about if project owner is cool with using NBTAPI
NBTAPI is open source and the license is highly permissive
I fail to see the problem
Lol dude, you are more than fine to use NBT API
oh waiit, so nbtapi is easier way to handle pdc ?
i just looked it up and it seems so fine
Pdc is just the nbt implementation of spigot
You should use pdc if you are on 1.14+ and it fits your needs 
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.
don't use hikari for sqlite
just use a regular sql connection
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
If I don't relocate it, will that not cause more issues with conflicting driver versions?
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
Fair enough, thank you. I forgot spigot already includes it, works fine now I'm not shading + relocating it.
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
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
@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);
}
is there a way to check if a ArmorStand is rotating?
store the rotation of it at x time and check if its the same as y time
Exactly
probably doable with js extension also, not the right channel... use #general-plugins
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?
It seems to be an ImmutableMap now, which obviously you can't put into an ImmutableMap, it's immutable
Probably related to the whole registries thing, Paper has a proposal for making those a lot better to use iirc
Hm, ok, all I did was use it for messages actually, kinda weird ik but it worked well. I'm rusty with bukkit rn so if you can point me in the right direction to do this that'd be great. Here is a pic of what I mean: https://imgur.com/a/DsV9eOx
the top right message is what im trying to do
I am honestly not sure, iirc you can define them with datapacks or something similar? Not 100% on using them as like toasts, I did find this which could maybe be helpful? https://github.com/frengor/UltimateAdvancementAPI
Seems to be updated recently
thanks i'll look into this, unfortunately all I need is literally the message part since I liked how it looked for messaging a user while in a GUI lol
It does mention toasts in the spigot description, so maybe you could look at how they do their code for inspiration?
ah ok cool ty
Use https://paste.helpch.at/ for errors, logs and configs. So we don't spam the discord.
?
https://paste.helpch.at/caconeyaqa.rb it gave me this error at first but after fixing that it doesnt not apear in the tab bar
I never really worked with packets so i dont know whats going on
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);
}
anyone know if deluxemenus have an api?
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?
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
@waxen escarp dont copy random chatgpt text
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
Wrong channel. #general-plugins
oops sorry
... Would still be looping through all the blocks in the 64x64x64
its just concept
64x64x64 dont really present much
but u get what i mean
im pretty sure
You need to get the min and max of each coordinate otherwise this will break in some cases...
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
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.
then u chunk if the chunk is effected chunk
and only then u loop
but he loops for everyone
heavy check
I'm still not understanding your explanation.
Maybe write up some code that does what you're saying...
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
u see what i mean
Yeap
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
the thing i suggested to that guy
who his code look like he just uses glue and puts things together
that seems to be something completely different
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
not sure if you understood what they want to do
and your vomit is your code?
u can define it that way
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.
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
second option he look for spoon feed which is #1180022345071599697
maybe im just ret@rd not sure
more like #1180022347063906395
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
What in the frick is going on here?
tony falk is going on
SirYwell my g friend lets go to off-topic chat? got to share some crazy info about today
classic tonyfalk schizo rant activities
@river solstice oh so the usual?
somewhat, yes
@sonic nebula try not to spam smh
sorry gabe just u know its like somethings come to ur mind afterwards but i already send what i think before and i need to complete the sentence best regards tony falk!
Well, think more before sending the message 
more like yap
shush u waffler xoxo
😢
ly xoxo
Yes?
my fault
Who is from US?
I need some help.
Please DM.
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
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?
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.

i understand, unless i compare the distanceSquared with (radius*radius)?
Finding the square root is a rather expensive operation, though it might not really matter much
So calculating the distance when you can do your stuff with the squared distance just isn’t needed and adds some overhead
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)??
If you square both sides, the math is the same yeah
(Given there is no semantics behind negative values)
I mean, unless you're doing 10k's of calls every second, the sqrt call wont kill your server
Why not just use the #getNearbyPlayers method
(unsure if its 100% called that)
I think getNearbyEntities do a lot more stuff than distanceSquared
I would assume built in methods are the most optimized ways... or should...
I mean it depends on what you want to achieve
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
```?????
If you want all players in a certain distance, getNearbyPlayers might be better than going through all players
well it's faster to only go through the entities of the relevant chunks than through all chunks

anyone?
public CreditsManager(JavaPlugin plugin, FileConfiguration playerData) {
this.plugin = plugin;
this.playerData = playerData;
register(); //<---
}
bruh 
then get the nearby entities and filter it by Players?
wait what version is this?
also, it does exist, in the Location class though: https://jd.papermc.io/paper/1.16/org/bukkit/Location.html#getNearbyPlayers(double)
declaration: package: org.bukkit, class: Location

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: {}
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)
Probs use reflection to adjust the value of max level from Enchantment.DAMAGE_ALL
maybe inventory is not being set back to the chest?
🤷 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.
unrelated, but why do you need to cast it to a DoubleChest then getInventory, if inventory is already instanceof DoubleChestInventory?
Cause if its not casted it returns the chests inventory and not the doublechest inventory.
weird, you'd think if you store it as a general Inventory, then it'd do that casting for you
🤷 I use to just do chest.getInventory but always had issues with it not taking items from the top or bottom section of doublechests
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.
bro what
hardcoded 5
idk, i just looked up a public plugin and im gonna test it now xD
You're using getState, which returns a copy of the chest at that exact time its ran
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
hmm, but it works in some cases
It shouldn't work in all cases
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.
that means something else is removing itemsfrom it
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
Not seeing any boolean parameters
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")....) ?
You may want to use interfaces for this
getState() doesn't return a copy... Unless getState().copy() is useless lol
thats what im seeing as well^
getState is the copy
although the docs say that getState is not guaranteed to update
meaning its just like, a single point in time
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.
try removing the items yourself, rather than inventory.removeItem
...
xD
How do you suppose I remove them?
what i mean is just to iterate and set items, rather than a single removeItem call
Just get the inventory instance from the block
...
Dont get it from a snapshot
you cant cast block to chest
you have to getState and cast the state to chest
(unless im thinking of something else)
^^^
Ok disregard everything I said above
i made this a while ago and i remember getting casting errors unless i did
player.openInventory(((Chest) attachedBlock.getState()).getInventory());
DEBUG (ChestMethods - Remove) >> ItemStack{BUCKET x 1}
DEBUG (ChestMethods - Remove) >> Leftover: {}
Just showing this method does work in other locations of code...
Run chest.update() after editing
Are you doing this in an event?
Ok now I'm confused
So am I for the past 4 hours xD
I'd there a difference in behavior between single chests and double chests?
Nope
i think the inconsistency is here, you remove 10, and nothing happens, but you remove 128 and 64 are removed. right?
Well I wish it was consistent with the 128 but sometimes it removes it other times it doesn't
but in all cases, the hashmap is empty
yeap
so it successfully thinks it removed the items
Testing with an itemstack of buckets in the location thats having issues.
same location but with a double chest?
getState(true) doesnt work?
Doesn't exist
Same issue with double or single
whats the coordinates of the chests, one that works and one that doesnt
Both don't work
Strange
you just said one did
Not on spigot
hmm, im not seeing this anywhere online
oh paper
Oh spigot
Yeah thats in another section of code. I can use that same chest with the other portion of code and it won't work.
so whats the working code and whats the not working code, side by side
theres gotta be some form of differences
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)
What's usage?
ChestMethods class
Can I see the method code
guessing block is ItemStack of 128 diamond blocks
i hope not
Remove block.clone()
cus if it is that makes sense why it doesnt work
tho still weird if its just 10
should remove 10 from the inventory
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);
}
Clones the itemstack being used. I set the clone amount to 10
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
^
Its not the block its an item stack. Its just named block.
I use to but then I'm adding support for VoidChest and its dev is overriding all the methods so to simplify my code I'm using the same methods.
oof
you can keep the same methods and just change its implementation
Then I would be doing exactly the same thing lol (overriding inventory methods)
I get that... but it use to lol And it still does in portions of my code which is why its so frustrating.
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
Can I see voidchests.removeItem?
its not voidchests, its Inventory i think
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
I'm pretty sure thats normal
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
Yeah I've had weird bugs through out the years with getting chest inventories... But atleast the inventory methods worked.
Have you tried updating spigot
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
Running 1.20.2 currently haven't update to 1.20.4 because I was in the middle of a huge recode lol
See if it makes a difference, cause I'm completely confused
Tested with bukets in the same method but above everything sems to work fine... but at the portion I need it to work, it doesnt...
I can't unfortunately. NMS
nvm
What about with paper 1.20.2?
maybe the only reason it works in other sections is because the portion is different
and therefore it is a broken method that has been lucky
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);
}*/
Tf
Yeah IDK maybe I'm too fucking tired and missing something stupid lol
gonna wake up tomorrow and realize there's just no chest or something xD
Nah just erased it all and started over lol
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.
difference between WOOD_DOOR and WOODEN_DOOR materials?
en
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
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
not directly related to your question, but you probably don't want to use the playername to identify the player - use their uuid instead




