#help-development
1 messages · Page 602 of 1
ok i finally figured out
my own problem
the client drop player's item
the item you see burst out of a player when death
is handled client side
suprise suprise
how the server triggered it
is simple
new PacketPlayOutEntityStatus(entity, (byte)3)
now i can just cancel it
good lord this took me 2 hours to figure out
im so stupid
Question regarding "Respawn point set" message in the game chat when a player interacts with bed - when their bed spawn location updates. Can you modify or remove that message in the chat along with the action bar message? Can either of those be customized or removed or cancelled via packets?
API method(s) used
I've used an override method onPacketSending with a PacketEvent parameter.
In there I am checking for packet type like so: PacketType.Play.Server.<enum>
The enum part is where the enum goes and I've tried even some deprecated ones such as BED, USE_BED, ANIMATION, GAME_STATE_CHANGE, CHAT, BLOCK_ACTION - for which I figured that is for players who send a message to the game chat.
This is the only thing I've tried so far because I can't think of another.
I've tried messing around with the PlayerInteractEvent but that didn't give me an expected result.
I'm looking for a little help and tips in which direction I should be going instead, with the code.
I'm using Minecraft Spigot 1.19.2 with ProtocolLib 5.0.0
Expected behavior
I'm expecting to be able to modify/remove the message in the game chat and action bar.
Code
This is an example code of how I'm handling packet intercepting
public class PacketInterceptor extends PacketAdapter {
public PacketInterceptor(Main main) {
super(main, ListenerPriority.NORMAL, PacketType.Play.Server.BED);
}
@Override
public void onPacketSending(PacketEvent event) {
event.setCancelled(true);
}
}```
@gray talon hey in bukkit api not exists analog metod for speed up update?
the fuck is analog method
my friend say he use bukkit
this mean bukkit api?
just i dont want load another api
for it
Yo @flint coyote mf, looks like ChunkSnapshots are not that thread safe after all. Turns out ChunkSnapshot::getBlockData(...) was what slowed everything down. Executing theses calls in the main thread and caching them for async made everything as fast as sync.

noone knows this?
is there a way to create an item like this
wut
each color represents a separated model
separated .jsons
but they are combined into 1 item
to my knowledge 1 item = 1 model
the client wants like 5 items to be combined into 1
and have a model based on the 5

just make a model with the 5 items
whats the event for tnt ignited ?
TNTPrimeEvent
iam getting a event called TNTPrimed is it the same ?
so is it the same ?
TNTPrimed is the entity
TNTPrimed is not an event
its giveing me an error
like its not recongnizing the event
just giving red
you are not importing the event
package me.airforce.plugin;
import org.bukkit.Material;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
public final class Plugin extends JavaPlugin implements Listener {
@Override
public void onEnable() {
// Plugin startup logic
System.out.println("Plugin is started!");
getServer().getPluginManager().registerEvents(this,this);
}
@EventHandler
public void onTNTExplode(TNTPrimeEvent event) {
}
?
so what should it be ?
I'm like 90% positive you're on a far too old version
how ?
do you have a pom.xml
iam on 1.18.1
yes
it says it exceeds the limit of 2000 characters
what it should be then ?
just import the TNTPrimeEvent if you want to use it
if he was on 1.8 then TNTPrimeEvent doesn't exist, was just trying to help incase he was developing on 1.8 accidentally
ah true
iam not on 1.8
?paste
I'm still curious
TNTPrimeEvent was only added in 1.19.4
ah
anyway if you want when it explodes https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityExplodeEvent.html
well it might not be 1.8 but it's still too old lmfao
if you want an alternative, you can run a schedular from interact -> explode and check for prime then, then fire your own prime event
TNT is a Block. When primed it becomes an Entity
me in 1.7
so listen the explode event for it blowing up
ha what are people talking about
you have to be a fake user
but this will make it explode i just want to prevent that
by cenceling it
what that mean
Real guy just insane
Bro stuck in the past someone froze his clock but tis okay
the thing that kept me from moving is the legacy codebase
if it still works
why touch it
the fact there is a wish copy of the 1.19 warden
in 1.7 server core
no terrain generator tho
Anyone know why ChunkSnapshot#getBlockData(...) is very very slow when running async?
version?
1.20.1
nms implementation
mojang mappings?
idk how 1.20 work but send me the fromData() method
inside CraftBlockData.class
private static final Map<Class<? extends Block>, Function<BlockState, CraftBlockData>> MAP = new HashMap();
tf is Function
send me the declaration of the actual thing
it should not be slow
all of them are jus standard java elements
Here basically:
static {
register(AmethystClusterBlock.class, CraftAmethystCluster::new);
register(BigDripleafBlock.class, CraftBigDripleaf::new);
register(BigDripleafStemBlock.class, CraftBigDripleafStem::new);
register(AnvilBlock.class, CraftAnvil::new);
register(BambooStalkBlock.class, CraftBamboo::new);
...
}
private static void register(Class<? extends Block> nms, Function<BlockState, CraftBlockData> bukkit) {
Preconditions.checkState(MAP.put(nms, bukkit) == null, "Duplicate mapping %s->%s", nms, bukkit);
}
I see alot of casts though, isin't that bad for performance?
nope
o_O
xd
give me yourthe use of this
like
where it is actually used
where did you use it
136 x 36 x 202 region capture of all block data:
running sync, takes 1784 ms = 1.7 sec
running async takes 125011 ms = 125 sec
Executed within commands
for (x in 0 until size.block.x) {
for (y in 0 until size.block.y) {
for (z in 0 until size.block.z) {
val position = Vector(x, y, z)
map[position] = getBlockData(position)
}
}
}
is that kt
yes
the OUTSIDE of it
like
how you used Async
I've tried all of them: Bukkit.getScheduler().runTaskAsynchronously(...), Thread and now I'm on the kotlin one. All same result. When its sync its just running as is
how did you use this
Bukkit.getScheduler().runTaskAsynchronously
where did you put it
In the command execution
?scheduling
Yeah
Nothing, the command ends, well I do send a message to the player saying its done but that is within the lambda async
piece of code around the runtaskasync function?
js?
kotlin
Run it in a completeable future
me: seeing kotlin 
CompletableFuture
yeah you think it will help?
try it and see
Bukkit async isnt always the best
Should I use it like this?
Executors.newCachedThreadPool().submit(() -> {
Thread.sleep(500);
completableFuture.complete("Hello");
return null;
});
He's on a ChunkSnapshot which is made for exactly that Represents a static, thread-safe snapshot of chunk of blocks.
CompletableFuture.supplyAsync
CompletableFuture.supplyAsync(() -> "Hello").get() ?
Get blocks
do a little benchmark
Is this the correct usage though, with the get at the end?
Calling get on an async future forces it to run blocking main
so how do I run it?
You have to use whenComplete or thenAccept
It runs it self
ah ok
the f is that sentence
Which
Me on phone
Still taking forever with completable future
Can you send me the full command? I'll try to execute it on my PC that has better hardware.
I still think your 2 cores being overloaded is an option - therefore resulting in the async thread getting interrupted too often.
?paste for myself
nonono I found the problem its ChunkSnapshot#getBlockData(...) only
If you want some better explanation of cfs read this
And that does not improve when you close your IDE, browser, discord and whatever else you have open and run another test?
No it should not be about that, I do alot of other computations after and those intense computations not calling ChunkSnapshot#getBlockData(...) run exactly the same async or not
Its only when I use ChunkSnapshot#getBlockData(...)
Odd. I'll still run a test
@EventHandler
private void entityChangeBlockEvent(EntityChangeBlockEvent e) {
if (!game_running) {
return;
}
if (e.getBlock().getWorld() != world) {
return;
}
if (e.getBlock().getType() == Material.ANVIL) {
e.getBlock().getDrops().clear();
e.getBlock().setType(Material.AIR);
e.setCancelled(true);
return;
}
if (!e.getEntityType().equals(EntityType.FALLING_BLOCK)) {
return;
}
FallingBlock fb = (FallingBlock) e.getEntity();
if (!fb.getMaterial().equals(Material.ANVIL)) {
return;
}
Location loc = fb.getLocation();
Block block = world.getBlockAt(new Location(world, loc.getX(), loc.getY() - 1, loc.getZ()));
if (block.getType() == Material.QUARTZ_BLOCK) {
block.setType(Material.AIR);
}
}
I have this code I wrote long ago for falling anvils breaking blocks and disappearing (probably inefficent, I don't remember why I did it like this exactly), however when they break the block and disappear, they drop a no texture Anvil item, and some people crash when placing it. (1.8.8) Any idea why this happens or a better way to do this?
Btw world.getChunkAt(x, z).getChunkSnapshot() is the correct way to create a chunk snapshot right?
Is the chunk loaded when you capture that snapshot?
@remote swallow @gray talon CompletableFuture.supplyAsync(() -> ...) still runs very very slow compared to running sync ChunkSnapshot#getBlockData(...) calls
idk, should it matter? I though it loaded itself when calling getChunk just like when calling getBlock().getType()
Try to load them beforehand. Just to be sure.
This line on the docs make me question what's loaded to create a snapshot If the chunk is not yet fully generated and data is requested from the chunk, then the chunk will only be generated as far as it needs to provide the requested data.
I mean it's talking about generation, not loading but I'd still try if I were you
Yeah it is talking about generation. I just tried, they are all loaded
ohh wait!!! I forgot to mention perhaps a crutial part!! @remote swallow @flint coyote I do a position convertion to get the correct chunk block:
private fun getBlockData(position: Vector): BlockData {
val location = position.toLocation(world)
val chunkSnapshot = snapshots[location.chunk.x][location.chunk.z]
val local = (origin + location).run { Location(world, (x).mod(CHUNK_SIZE), y, (z).mod(CHUNK_SIZE)) }
return chunkSnapshot.getBlockData(local.block.x, local.block.y, local.block.z)
}
Is creating a Location object with a world reference not thread safe? I don't access anything, I just use Location for cooredinates x y z
I mean it uses a WeakReference to the world. I'd have to check if those are threadsafe
Doesn’t location.getChunk() force load the chunk?
accesses a Block reference ;-;
It does
So you’re loading the chunk async
I solved my problem
oh, yes that makes sense.
That's why you have all the functions in the snapshot to avoid using sync data
thats true
i managed to paste 4M blocks in 200ms
now correct the lighting 😉
inv.setItem((9 * 3) + 4, createGuiItem(Material.DIAMOND_BLOCK, ChatColor.GREEN + "" + ChatColor.BOLD + "Stat Rewards", List.of("", ChatColor.RED + "Health: +" + skill.getHealthRewards(), ChatColor.AQUA + "Defense: +" + skill.getDefenseRewards(), ChatColor.BLACK + "Damage: +" + skill.getDamageRewards())));
why does this item only contain the first 2 lore lines? the third argument is for the lore
let me turn off the mods
is there an int vector in bukkit/spigot?
a vector is 3 doubles
so no
you convert to int if you need
nother types of vectors or similar?
can you give me the math that you used to calculate the velocity to add to the armor stand for the skyblock hyb jump pads? it looks like you are remaking hypixel skyblock
yes
bump
does anyone by any chance know why that happens?
is the code for you hypixel skyblock plugin open source?
nope
its a project
not a plugin
this isnt a plugin
@eternal oxide i see now
very cool lighting
no i mean the hypixel skyblock core plugin
no way
it doesnt work like drag+drop
but how long did it take to come this far?
bump... again
the lighting is just nuts lmao
yes
What does createGuiItem look like
uhm was that meant to respond to my other message?
yes
then show us the method that Coll asked for, please
the one shown in the article in spigot forums with a .llittle bit of change
paste it here
?paste
protected ItemStack createGuiItem(final Material material, final String name, List<String> lore) {
final ItemStack item = new ItemStack(material, 1);
final ItemMeta meta = item.getItemMeta();
// Set the name of the item
meta.setDisplayName(name);
meta.setLore(lore);
meta.addItemFlags(ItemFlag.HIDE_DYE, ItemFlag.HIDE_DESTROYS, ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_PLACED_ON, ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_DESTROYS);
item.setItemMeta(meta);
return item;
}
that website doesnt work for me
yeah that method looks fine
How would I make a boss bar that I send to a player every second and then remove the last one but change the new one a little. I'm basically doing a second by second timer and I want it to change every time and then remove the last one.
What about it doesn't work
Can you try whether the empty string is a problem that messes with the lore on the client? Try adding a letter instead of "" and check if all three appear
all of it
...
yikes
imagine losing at tictactoe
yea ik
yo
stop flooding chat
use ?paste
?paste
wait... there was an empty line at the end so the prroblem could be the color leme try both @flint coyote's suggestion and mine
yea i got no idea how to do that
I cant create a new bossbar object and i have no idea how to send one
dungeons*
Bukkit.createBossBar()
alr
the other things are easy
how tf is calculating the velocity to add to the player for the jump pad while calculating in air resistance and minecraft physics easy
yes i know that
theres no way that it teleports
if it teleports, then the armor stand would start falling when the player's connection gets laggy
It's not hard calculating the required velocity
it is indeed teleport
hypixel AC doesnt like player velocity
but considering air resistance and everything else is hard
It's just one formula you could google it
I have it at my pc for when I launched other stuff
If you look at tab you will see a special font! Any idea on how to get that?
RGB and some unicode characters
u mean the letters are unicode characters?
Yes
Ok thanks
Could be these, https://www.compart.com/en/unicode/search?q=monospace#characters
Unsure which specific ones they're using
So like how do I actually use this?
https://www.compart.com/en/unicode/decomposition/<font> this might help
So like how do I actually use this?
They're just regular characters
Do I copy the U+????
\u210A for example would be the unicode representation of the char, yeah
ok
If you want to just write out a string and convert each char you can add the first char
e.g.
char monospaceA = '\u1D670' + ('Z' - 'A');
char monospaceE = '\u1D670' + ('Z' - 'E');```
Actually that's wrong lol
There we go. That would probably work for uppercase monospace fonts
Cursed code
It's super general but yeah, a little cursed
char is just weird
You're weird
It's like a string and a number at the same time
Well, no. It's just an integer lol
If you ignore the fact that it can even be represented by a string then it's easier to work with them. Any time you use 'a' it's just treating it as its code point
cringe
Ur cringe
hey Choco, do you mind checking my DM?
I don't really look at DMs unless I'm expecting something. If it's a question you could probably just ask it here. I'm sure someone else could answer it too
Could you answer it right since I'm lucky enough to have you in the chat?
This is it
would anyone know why that happens or a better way to do this?
I can only imagine that message is sent client-sided every time they interact with a bed
fb.setDropItem(false) iirc
Assuming that method exists in 1.ancient
I tried, still dropped these weird no texture anvils
Thank you for that, so that would mean the client itself sends a message to the game chat? I can't really modify it or anything?
@gray talon oddly enough, but the tick start event in practice is slower than the same code with a flow of 0 ticks
You can change it with a resource pack I would bet
or by speed
I'd create it but I can't tell every single player to use a resource pack, it would be a mess, so i'm trying to find an alternative to this, I want players to be able to sleep just without these messages spamming their chat and action bar
Server resource packs exist
But if players are really annoyed by it they should just get a chat filtering mod
They do exist but they're optional to each player, they can choose whether they want to use it or not. So yeah if it would be possible with a plugin, that'd be nice, so far I've managed to modify the action bar message but the chat message is little bit trickier I guess
I've posted the same message on ProtocolLib github but they're not really active that's why I came here
is there anything faster in terms of executing code in a loop than
tickStart event
wtf is a tick start event
not spigot
I mean it's probably your fastest option
I want to put my library in the Github repository. I did everything according to the instructions https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry. No matter how many tokens I create, it's still an error. Help who can) [INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ library --- Uploading to github: https://maven.pkg.github.com/Xemii16/YeLibrary/com/yecraft/library/1.1-SHAPSHOT/library-1.1-SHAPSHOT.jar Uploading to github: https://maven.pkg.github.com/Xemii16/YeLibrary/com/yecraft/library/1.1-SHAPSHOT/library-1.1-SHAPSHOT.pom [IJ]-1-MojoFailed-[IJ]-source=LIFECYCLE-[IJ]-goal=deploy-[IJ]-id=com.yecraft:library:jar:1.1-SHAPSHOT-[IJ]-error=authentication failed for https://maven.pkg.github.com/Xemii16/YeLibrary/com/yecraft/library/1.1-SHAPSHOT/library-1.1-SHAPSHOT.jar, status: 401 Unauthorized [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.208 s [INFO] Finished at: 2023-07-05T15:45:10+03:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project library: Failed to deploy artifacts: Could not transfer artifact com.yecraft:library:jar:1.1-SHAPSHOT from/to github (https://maven.pkg.github.com/Xemii16/YeLibrary): authentication failed for https://maven.pkg.github.com/Xemii16/YeLibrary/com/yecraft/library/1.1-SHAPSHOT/library-1.1-SHAPSHOT.jar, status: 401 Unauthorized -> [Help 1]
is the credentials in the settings.xml
Did you create a personal access token with write access?
what is userhome?
all permissions
What do you mean more speed
what is the exact mvn command you are using to deploy?
How can I make that an item that is given in the inventory can't be moved
windows mac or linux
win
c/users/uruser
I create a bat file in my project to deploy as it shoudl only be called once per release.```bat
@echo off
@echo.
@echo #################################################################
@echo # #
@echo # WARNING - Deploy should only be run once per release. #
@echo # #
@echo #################################################################
@echo.
setlocal
:PROMPT
SET /P AREYOUSURE=Are you sure (Y/[N])?
IF /I "%AREYOUSURE%" NEQ "Y" GOTO END
mvn deploy -Dregistry=https://maven.pkg.github.com/ElgarL -Dtoken=GH_TOKEN
pause
:END
endlocal```Replace ElgarL with your github user name.
How can I make that an item that is given in the inventory can't be moved?????
who?
im trying to iterate through the names of all my resources but am also getting the names of resources ive renamed/deleted, does anyone know why or how to stop this? heres how im doing it (just the relevant chunk):
jar = new JarFile(jarFile);
Enumeration<JarEntry> entries = jar.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
String entryName = entry.getName();
System.out.println("Entry name is " + entryName);
String configPrefix = CONFIGS_DIRECTORY_NAME + "/";
if (!(entryName.startsWith(configPrefix))) {
continue;
}
System.out.println("Entry " + entryName + "starts with " + configPrefix + "!");
}```
and then heres my resources folder and the logs, and obviously the plugin is finding resources which dont exist anymore, which i dont want
and they are also removed in your servers plugin folder?
do aclean build
That's in there temporarily
worked, thank you
As many of you know, you can log to the console in three ways:
/* Way 1 */
System.out.println("Message");
/* Way 2 */
Logger log = Logger.getLogger("Minecraft");
log.info("Message!");
/* Way 3 */
Logger log = Bukkit.getServer().getLogger();
log.info("Message!");```
How do you log to the console? And what is the best way to it?
Is there a mapping viewer for Spigot -> MCP for 1.12?
None of those
I mean the server yells at you when you use the first one
Use your plugins logger, JavaPlugin#getLogger
so that's obviously not it
No it doesn't? What?
paper does
This is not really that easy with the Plugin Messaging Channel as you need a player online to actually receive the data
I'd just do it with redis and maybe an sql database to actually store the player positions
oh
i have a new error: org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT/maven-metadata.xmlfailed to transfer from https://maven.pkg.github.com/xemii16 during a previous attempt. This failure was cached in the local repository and resolution will not be reattempted until the update interval of github has elapsed or updates are forced. Original error: Could not transfer metadata org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT/maven-metadata.xml from/to github (https://maven.pkg.github.com/xemii16): authentication failed for https://maven.pkg.github.com/xemii16/org/spigotmc/spigot-api/1.20.1-R0.1-SNAPSHOT/maven-metadata.xml, status: 401 Unauthorized
Sorry to bother you, but have you had this problem? ⬆️
That's what redis is for
Redis is a database type that basically works like a Map
but there's this thing called Pubsub which allows you to send "messages" on a "channel"
And those messages can just be binary data
Ty!
So in theory you can make a packet system that works with json strings, or in my case dumps a byte[]
And send that to the channel
And subscribe to that packet on the other end and add an entry
Should give you an idea
uuid varchar(36) non null primary key iirc
hey, when i set a result that isnt possible in vanilla, like in the anvil, how to i allow the player to get the result? cause for me it keeps locked
For the brightness in a Display (using NMS), what int should I pass to the method?
The method is: SynchedEntityData.DataValue.create(new EntityDataAccessor<>(15, EntityDataSerializers.INT), <int>
Do I literally have to pass "(block << 4 | sky << 20)" and just replace block and sky with numbers?
:l?
how should I correct it?
remove the primary key(uuid) on the end and add primary key to the uuid at the top
Why are you storing so much?
Also, couldn't you use enums for stuff like "chatcolor" or "rank"?
i add, also error
Correct
this?
no
It wasn't my source :l I'm just edit it
uuid varchar(36) not null primary key,
nick varchar...
YEEEES, I DO THIS, i spend 2 days
paste the sql here rq
create table if not exists Player(
uuid varchar(36) not null primary key,
nick varchar(40) not null,
displaynick varchar(40) not null,
money double not null default 0,
passwd varchar(129) null,
slt varchar(129) null,
chatcolor varchar(120) null,
rank varchar(120) null
);
what version of SQL are you running?
8.0
seems like there might have been an extra space somewhere possibly?
or maybe just have some kind of issue using whatever it is you are using
did you limit the size of types?
idk what your DB setup looks like, but either there was a space in there or some other hidden character
have you tried from the console?
there is a 129 without any error so 120 won't be an issue :l
your issue could be because of the ); being on a separate line and not immediately at the end
then quite possible you already had something in there named rank
idk, I don't recall it being a protected name
again depends on your DB setup so
this is an empty DB :l
the only thing I see in that screenshot which would have a protected name
is passwd, I think its just all the extra spacing at the end
Does anyone know why doing getString() on a FileConfiguration class would cause a NullPointerException?
the config path is empty
no idea :l
but I think I used to have the same issue in the past
Good point, I placed it above where I initalized it 🤦♂️
???
For anyone who wants to know how I have solved it.
look here: https://github.com/dmulloy2/ProtocolLib/issues/2472
I've figured out that the "Respawn point set" message along with the action bar message is sent to the client ONLY when a player interacts with the foot part of an entire bed block (1x2, foot and head).
With that you basically cancel an interact event if player interacts with bed "foot" part and message will not be shown! and you can still manually update the location. So yeah, if player interacts with the "head" part of a bed block, messages suprisingly are not sent (I don't know if this is a bug or a feature?)
@worldly ingot I'm sorry for tagging you, I've solved it :D
a plugin should not really give permissions, unless its for certain commands
but if you have to its a permission attachment on the player
hi guys
You're not allowed
it's possible to hook all events with a function that has @EventHandler?
tried but seems not working java @EventHandler public void onEvent(Event e) { System.out.println(String.format("%sonEvent (%s): %s.", ChatColor.LIGHT_PURPLE, e.getClass(), e.toString())); }
send it in #1100941063058894868
You can only listen to events that have a getHandlerList method
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
xd
I cannot get this function to be called.
@EventHandler
public void FrozenAspect(EnchantItemEvent event) {
event.getEnchanter().sendMessage("Enchanting");
ItemMeta itemMeta = event.getItem().getItemMeta();
PersistentDataContainer itemData = itemMeta.getPersistentDataContainer();
if (itemData.has(new NamespacedKey(ToastsRPG.getPlugin(), "FrozenAspect"), PersistentDataType.INTEGER)) return;
int randomNum = (int) Math.random();
if (randomNum <= 3) { // The chance of getting Frozen Aspect I is 3%
itemData.set(new NamespacedKey(ToastsRPG.getPlugin(), "FrozenAspect"), PersistentDataType.INTEGER, 1);
List<String> lore = itemMeta.getLore();
lore.add(ChatColor.BLUE + "Frozen Aspect I");
itemMeta.setLore(lore);
event.getItem().setItemMeta(itemMeta);
event.getEnchanter().sendMessage(ChatColor.BLUE + "You have received a bonus `Frozen Aspect I` enchantment!");
}
}
the docs say this should be executed when a player has enchanted an item, but it never executes. It is registered.
ew Math.random
Math.random not good?
I'm very confused, why
It's decent and works but
i saw Random as well..
ThreadLocalRandom.current()#randomInt
^
It works, only creates a single instance per thread etc
I've had issues where Math.random() was icky and caused severe slowdowns in multi-threaded environments
Ah okay, welp I just changed it out. its now ThreadLocalRandom
also reuse your namepsaced keys
??
create them in ur main class and use a getter or have a constants class where they're public static final
Okay, I will do that after I figure out why EnchantItemEvent isn't being called.
is the class registered
why is Bukkit.getScheduler().runTaskTimer now depercated?
lol I was using BukkitRunnable instead of normal runnable
I do
I do
but now I created a function getRunnable and I can not use lambda
thanks anyway
java docs say you should use BukkitRunnable.runTaskTimer() instead
?jd-s 
ill be damned, it do
thank you for help!
it shouldnt rly matter which u use id imagine, internally they probably call the same methods
:P
yes but if it is depercated it may be removed and I don't want to change my code rly in the future
tell that to paper and their stupid api lol
you can always remove shit and don't give a shit
anyway how do i make a spigot plugin there can rizz some b ¤%+.... beautiful ladies
@young knoll do i need chatgpt api for this?

Probably
Do they actually remove deprecated methods?
eventually.
which one is better to use AttributeInstance#getValue or AttributeInstance#getBaseValue after changing the value? ( I haven't worked with the newer api so I really don't know which one to use)
^
getValue to get the value with all modifiers applied
setting the base value changes it right?
shout out to lambda
yes
shoutout to lambda until I need to use Atomic values
Hi im combining items in inventory. In creative it works fine but in survival it duplicates the item what should i do?
Not use creative
But in creative it works
make it work in survival only
i dont know how
I need help again. So is there a function in TNTPPRimed that controls how far away the entites in the explosion will be pushed to?
creative is all client side. The server does whatever the client tells it
I'd not use Lombok but thats a personal choice 😉
it does
especially with @Cleanup
java.lang.NullPointerException: Cannot invoke "net.md_5.bungee.config.Configuration.contains(String)" because "this.plugin.config" is null
[Server] INFO at net.multylands.friends.events.JoinListener.onJoin(JoinListener.java:22) ~[?:?]
in which case why are you not using an @allargs constructor?
never knew it existed
hey @eternal oxide, I've used your NPC spawning files but the NPC is despawning after like 15 seconds, any idea why?
Oh my God. I've finally managed to build the server, after a few days of suffering
not a clue
I've not used teh code in a while as I only wrote it to play around. but it worked fine when I did
strange, I'll try some things
Can anyone look into my issue please?
possibly don;t send a remove packet which removes it from tab
functionality may have changed
imo id extend player or block event
so my join listener class looks like this
why is plugin.config null?
show the Friends class
when do you call saveConfigIntoData ?
when editing config
config in your Friends class doesn;t seem to be the same one as used in your listener
Why
in your listener you are using `plugin.config
and?
in your Friends class you are using a class field
is Friends your main plugin class?
yes
ah ok
Whats wrong with my code?
from what you have shown I see no issues
then what was this
no clue you never showed the top of your friends class
I did
see
move all yoru registerListener calls below setting up yoru config
yep
ah
i was starting my proxy when error happened
maybe player tried to join too early
thx
If creating enchantments is thing how can I create a custom enchantment?
you should avoid doing a lot of things the moment a player joins
they are sometimes not fully joined
so, its better to wait a few ticks or so after they join to do stuff
im not doing anything really intensive
also, since you are messing with file related things, you should move those things to their own threads or make use of async tasks
look in the NIO package for thread safe file stuff
how do i do async on bungee?
not sure if bungee provides async tasks, if it doesn't you will just have to do it yourself in making your own threads
anything that doesn't need to be done on the main thread shouldn't be done on the main thread when possible
it doesnt even take 1% cpu or ram to edit config i think...
that isn't the issue
its blocking
when you stop the main thread it causes interruptions everywhere else to include connections
its not about the amount of time
its about whether or not other things can even reliably handle such things
connections are at times tollerent of minor interruptions but not always
and then you have other code that isn't expected to be hung up either
I mean if it works for you now that is awesome, just letting you know you should move any code that doesn't need to be on main thread
off the main thread
this will allow everything to be a lot smoother
also allows you to make better use of your hardware at the same time
if its scheduler is async you can if you want use that as it will make use of a thread pool
or you can just opt to make your own threads, in either case the end goal is the same
how do i use bungee's scheduler?
or right
bungee is on github lol
dont even know what class i need to check
always forget bungee's repo is not on stash 😛
well maybe you might be better off looking at the javadocs
anyways, essentially looking at the code would be looking at the scheduler implementation
if I make a bukkittask and then cancel it later, if I then replace the reference variable I have to it with a new task, does the canceled task get gc'd or does bukkit keep the task hostage
when its marked cancelled it doesn't immediately leave the queue. It will get GC'ed once its that tasks turn to run, the scheduler will see its cancelled and consider it done and then remove it
so if you schedule a new task it will get a new task id
they actually removed whole non-deprecated classes 
that's why any spigot-plugin that is using the AdvancementDisplay class will just throw a NullPointerException on paper servers
yes so then its safe to say that when my only reference to the task gets replaced and I cancel the task it will get gc'd sooner or later
first make sure to cancel it before removing reference. But once you cancel it you don't need to maintain a reference to it, but you never really needed to maintain a reference anyways as long as you have the task id
since you can query the scheduler for tasks it has
How y’all do this coding bs I can’t wrap my head around it
public void onJoin(PostLoginEvent e) {
Runnable task = () -> {
ProxiedPlayer p = e.getPlayer();
String uuid = p.getUniqueId().toString();
if (plugin.config.contains("Data."+uuid)) {
return;
}
plugin.config.set("Data."+uuid+".DoNotDisturb", false);
plugin.config.set("Data."+uuid+".SocialSpy", false);
plugin.config.set("Data."+uuid+".FriendToggle", false);
plugin.config.set("Data."+uuid+".Friends", "");
plugin.saveConfigIntoData();
};
ProxyServer.getInstance().getScheduler().runAsync(plugin, task);
}```
happy now?
Hello, how can I display text below entity's name using nms 1.19 ?
Fym practice u can’t learn anything from yt vids it’s just letters that do stuff how u meant to understand
its not about me being happy lol, just I like to see people know and understand appropriate things is all
if I can tell a few things to make others better at what they are doing why not, whether you choose to use that advice is up to you 😛
Y’all a bunch of nerds
part of the reason a thread is better to have other then it doesn't stop the main thread is that the OS can opt to move it to another cpu core
which as I said earlier is good because it makes better use of hardware 🙂
don't see why not
How do I instantiate a global hashmap so I don't have to remake it every time I check a value against it
More of a Java question than a Spigot question I guess
use ```java
static
If thats what you are going for?
Should I just put it in the root class
I guess yeah
Hmm, I'm not entirely sure how to make a static class
not a static class make it a static field
private static HashMap<Object, Object> hashmap = new HashMap<>();
public class EnchantUtils {
public static HashMap<Enchantment, Integer> MAX_ENCHANT_LEVELS = new HashMap<>();
// Combines all the enchantments of an item, both standard and stored, into a single map
static Map<Enchantment, Integer> getAllEnchantments(ItemStack item) {
if (item == null) {
return null;
}
// Get the standard enchantments of the item
Map<Enchantment, Integer> allEnchantments = new HashMap<>(item.getEnchantments());
// Get the stored enchantments of the item if it is an enchanted book
// (Only enchanted books have an EnchantmentStorageMeta)
ItemMeta meta = item.getItemMeta();
if (meta instanceof EnchantmentStorageMeta) {
EnchantmentStorageMeta enchantmentMeta = (EnchantmentStorageMeta) meta;
// Combine the stored enchantments of the book with its standard enchantments
// Generally books should never have both standard and stored enchantments, but this is here just in case
allEnchantments.putAll(enchantmentMeta.getStoredEnchants());
}
return allEnchantments;
}
...
}
Like this?
yeah
Where do I add all the kv pairs
to the static map if thats what are you doing
set the size of your hashmap
since you know the number of enchantments that can exist, you can presize your hashmap
What is the significance of this
it prevents the hashmap taking up more memory then necessary
default size is going to be larger then what you need from it
public class EnchantUtils {
public static HashMap<Enchantment, Integer> MAX_ENCHANT_LEVELS = new HashMap<>();
MAX_ENCHANT_LEVELS.put(Enchantment.DAMAGE_ALL, 10);
MAX_ENCHANT_LEVELS.put(Enchantment.DAMAGE_UNDEAD, 10);
...
// Combines all the enchantments of an item, both standard and stored, into a single map
static Map<Enchantment, Integer> getAllEnchantments(ItemStack item) {
if (item == null) {
return null;
}
// Get the standard enchantments of the item
Map<Enchantment, Integer> allEnchantments = new HashMap<>(item.getEnchantments());
// Get the stored enchantments of the item if it is an enchanted book
// (Only enchanted books have an EnchantmentStorageMeta)
ItemMeta meta = item.getItemMeta();
if (meta instanceof EnchantmentStorageMeta) {
EnchantmentStorageMeta enchantmentMeta = (EnchantmentStorageMeta) meta;
// Combine the stored enchantments of the book with its standard enchantments
// Generally books should never have both standard and stored enchantments, but this is here just in case
allEnchantments.putAll(enchantmentMeta.getStoredEnchants());
}
return allEnchantments;
}
...
}
This does not work
you set the size when you initialize it on the right
Where do I put the .put calls
in a static block
is it just static {}
yeah
I've not used Java for a long time lol
yeah
Thanks
Can someone tell me what an "no item animation" refer to ?
Context: Container Set Slot packets, with container id = -2
thats what i thought, and hoped for tbh
i'll try
is the armswing related to slot update or equipment HAND update tho?
cuz those are 2 completely different things for the protocol
Hello! How do I use the new Type.PROFILE for the BanList? Type.NAME is deprecated now and I want to update my code to use the former, but the IDE just errors it out when I do Bukkit.getBanList(Type.PROFILE).addBan(Bukkit.createPlayerProfile(uuid), reason, date, source);
Idk
I’m not too sure really
Sorry man can’t help you
I’m pretty sure no one can either
We use eclipse around here bud
I don't even get that type
It's new for the 1.20 api
I am on 1.20 o.o
profile is new
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
You trippin darg
Oh my bad, probs 1.20.1 specifically
oh
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
Hmm, then this should work, right?
Bukkit.getBanList(Type.PROFILE).addBan( Bukkit.getOfflinePlayer(uuid).getPlayerProfile() , reason, date, source)
It's still giving me a The method addBan(String, String, Date, String) in the type BanList<capture#1-of ?> is not applicable for the arguments (PlayerProfile, String, Date, String)
If I use the isBanned method, this'll appear
Bukkit.getBanList(Type.PROFILE).isBanned(Bukkit.getOfflinePlayer(uuid).getPlayerProfile())
The method isBanned(capture#2-of ?) in the type BanList<capture#2-of ?> is not applicable for the arguments (PlayerProfile)
is there a way to disconnect the player from the server using bukkit?
Just kick them I guess
I'm sorry if I don't follow, but isn't that what I'm already doing at the start? Bukkit.getBanList(Type.PROFILE)
alright thanks
So, https://i.imgur.com/s2jFs6M.png
I'm sending slot packets for the player inventory : containerId = 0
It works.
I tried replacing containerId = 0 by containerId = -2, to remove the armswing
Well, it just breaks everything and the setslot packets seem to have become ineffective
Can anyone find an explanation to this ?
You use that returned list to add or remove a ban by profile
And explain me the red part?
be sure you are using a ProfileBanList not a BanList
Well yeah, I tried adding a ban by profile using the Bukkit.getOfflinePlayer(uuid).getPlayerProfile()
Bukkit.getBanList(Type.PROFILE).addBan( Bukkit.getOfflinePlayer(uuid).getPlayerProfile() , reason, date, source)
Should I try casting it to ProfileBanList beforehand? Would that work?
you shouldn;t need to but do it to be sure
Generic types are pretty wacky
Yeah you have to cast because that generic is wack
Oh, it worked!
((ProfileBanList) Bukkit.getBanList(Type.PROFILE)).addBan( Bukkit.getOfflinePlayer(uuid).getPlayerProfile() , reason, date, source);
The error's gone
Though it should work without needing to cast it right? Anyway, thanks for the help 😄
if the generics are properly made you wouldn't need to cast
you will find later on that it is better that you create a system that tracks the bans instead of letting the server do it
mainly because the server uses flat file to store the bans
In that case it won't work without the cast. The generic will be ? if you don't
Yea I do, I use sql to store my bans. I just use the BanEntry since some plugins depend on it to know if a player is banned or not
I'd imagine that's cached so it ain't that bad
Go fix that up king
<T extends BanList<?>>
its not, but just because it is cached doesn't mean it isn't taking up more resources then necessary. The amount of ram you need to hold a file in memory is the size of the file itself
but the entries are an array as well
How large can a file that holds bans be? 5 MB on huge networks?
lmao no
on huge networks it can get quite large
5MB is quite large for just text
have to remember that every entry is on its own line
Well
In YML 5mb takes minutes to load
source: I've had to refactor 5mb+ yml files before due to server hanging on startup
if the bans were stored in binary form with just a character separator, then it would be more optimal because it is making use of space
idk
maybe because sometimes the ban list gets corrupted
and it would be a pain to fix that file
Hypixel probably has like 150mb of bans
without wiping the entire thing
They should have a backup then
hypixel has to store a reason, ban id, player id, as well as all the profile data regardless
also, the banlist only works for that server, when you have a network, typically just easier to use something like mysql to keep track for the entire network 😛
wouldn't wonder. They banned me right after I first joined for 2 minutes and then left again
trying to store and retrieve meta data from a placed block. How do I go about doing this with bukkit api?
Do you want it to persist over restarts
?morepdc
You can create custom persistent data types on your own, or use one of the many libraries available which have implemented those which match your needs. Learn about more persistent data types here: https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/
yeass
?blockpdc
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
Use that
thank you <3
also I think those plugins you refer to mainly depend on the event
which you can throw the event yourself
would be nice if more devs did this lol
How do huge servers like hypixel check bans
Had to ban Notch about 24.000 times with reason "banned by an operator" to reach 5MB on the ban file
They have a database
Like wouldn't their server explode checking 150mb of bans for every join?
That’s what databases are designed for
Still
databases are hella fast
Thats a huge amount of checks
400k entries are nothing for a db
No it isn’t?
You gotta iterate through every single entry
Hmm, I'd imagine they'd use the OfflinePlayer#isBanned() method
no
MySQL is more efficient then you really probably know. Have to remember it came from a time where lots of ram was not feasible and cpu speeds not what they are today lmao
The complexity to find a key on an index is way below O(n)
Internally they have to iterate through every player string to?
should be O(log(n))
depends on the method of storage they use, which there is different ways depending how the DB and tables are setup
also this isn't even factoring in caching on the DB
and caching in the application
I'd guess they have all bans loaded in some redis db to check bans
MySQL has memory only storage too
Like db -> redis on start
you don't need redis for caching
Do nether portals get created when a player teleports into the nether or when they flint and steal the portal?
When they teleport
I know there's more factors to consider. Yet still I'd imagine the lookup without further improvements to be about log(n)
But it's good and faster too?
faster then MySQL? probably not since redis is just an easy to cache any kind of data not data specifically from a DB
MySQL lets you create functions and has functions built in, where you can easily pull information from the DB and have it at the ready ahead of time before anything else
also with appropriate indexes and keys setup its super quick
mysql can easily handle 1mil+ queries to it a second
To understand database lookup data structures you can start at the base of optimization: Understanding binary trees.
Like this:
Do you think they have a backup-db syncing in realtime?
the main reason most people choose to use redis is down to skills. Not many people are DBA's
mysql allows for slaves and does this automatically if you tell it about the slaves
so most likely yes
if you use slaves, you can have a slave DB on every host
and then the master is the only one allowed to alter
and then sends it to the slaves
That's good
this allows each server on a host to always be quick
and then however many hosts you have
is however many DB backups you have
yeah MySQL can do a lot and not just a lot, but do so with not much resources given to it XD
give it 1GB and its good for a long time lmao
Well what I wonder is
Is it worth using something like redis as a cache for single servers since they can just... store in RAM?
but at the same time, network-connecting for the cache takes a long time
well if you don't need a db and just want a caching server or that is all you need for now, then yeah use redis
You'd have like 10ms delay for redis on other hosts
Why not just throw your data in the memory itself
depends if those hosts are in the same DC or not
if they are in the same DC its like 5ms or less
why waste memory on the host that can be used for other things when you already have a host for caching?
Let me reformulate my question: what are the advantages of using a caching-database for a single server running locally
Compared to throwing your data into ram directly
advantage is that if the data being cached comes from the DB anyways, then its faster and would know how to do it better then some outside thing
I mean
I don't know what im doing wrong but:
No legacy enum constant for NETHERITE_BLOCK.
Im using Spigot 1.19.4
the advantage of caching in ram directly is that you have the objects formed using the data from the DB
Software -> Redis -> Software
so its faster in that the objects are already there and don't need to be intialized
Instead of Software -> RAM(example: any string") -> Software
did you forget to specify the api version in your plugin.yml?
are you using the same api version in your plugin build path? 🤓
no?
I mean it vice-versa. Advantage from using redis
Add 'api-version: 1.19' to your plugin
1.19
"api-version: 1.17" 😀
how do i make specific Id's for items to keep track of them
currently i am doing it via a ugly number within the lore (it doesnt really matter what the id is, as long as it is unique and less confusing to the user (best would be not visible at all) )
i tried making a unique sequance of those colors, but that wont work, it will just take the last one as the onlyone
but for that i need an api, is it posible without?
pdc is built in
oh woops, mb
more pdc and block pdc are external
here's a more straightforward exaplanation of PDC btw:
https://blog.jeff-media.com/persistent-data-container-the-better-alternative-to-nbt-tags/
amazing, this makes my job way more easyer
Meh
I just made a class called PersistantTypes that makes it a bit nicer
I also have my custom types in there
why are these T T not K V
yeah that'll only work for the inbuilt array types
T for type
that only allows to use PDC types where primitive and complex are the same class
e.g. byte[] or int[]
but not for e.g. Integer, as that is int, Integer
change PersistentDataType<T,T> to ?,T
oh right. but it won't wor for Boolean, r custom datatypes
just replace the first T with ? and it'll be fine
public class ConfigurationSerializableDataType<S extends ConfigurationSerializable>
implements PersistentDataType<byte[], S> {
this would eg break
mhm wacky
Yeah I don’t think that will ever work out
Internally they are still registered with just the material, spigot just does some filtering for you
ExactChoices only properly work on ShapedRecipes
only fix I know is to use shaped recipes instead
exactchoices work on shapeless ||on paper||
And it’ll never be pushed upstream 😔
can i create a method to use instead of doing hundreds of .replace?
for example:
player.sendMessage("[PLACEHOLDER] [PLACEHOLDER]".doReplacements());
does this:
player.sendMessage("[PLACEHOLDER] [PLACEHOLDER]".replace([PLACEHOLDER]", "Example").replace("[PLACEHOLDER]", "Example"));
I dunno about you, but it at least seems reasonable to me that behavioural changes be made upstream as well
but idk maybe I'm just crazy
Maybeee
Do i need a main class besides onEnable in my plugin?
because i get Could not load 'plugins\hcfcore-1.0-SNAPSHOT.jar' in folder 'plugins' org.bukkit.plugin.InvalidPluginException: Cannot find main class `org.ayple.hcfcore.old.Hcfcore'
does the class name match
just noticed it as soon as you wrote it. forgot to port it over to the new folder, thanks.
That's basically what PlaceholderAPI is for
Is it even hard to make that pr idk how nms handles recipes
what this means?
sir this is spigot
oh sorry
static boolean hasMoreThanOne(Map<Enchantment, Integer> enchantments, Enchantment[] incompatibleEnchantments) {
int count = 0;
for (Enchantment enchantment : incompatibleEnchantments) {
if (enchantments.containsKey(enchantment)) {
count++;
if (count > 1) {
return true;
}
}
}
return false;
}
Is there any stdlib method that basically does this?
Yes, you can do ```java
enchantments.keySet().retainAll(Arrays.asList(incompatibleEnchantments)).size() > 0
Set#retainAll is a destructive intersection with a collection, and then if the intersected set size is > 0 (1 or more), there's at least 1 in both sets.
hey quick question, if im trying to check if player A has any sort of metaData, is there any way to see all of the metaData player A has, or would I have to specify which metaData I want
Just use pdc metadata is pretty archaic
But no you have to know the key to get the value
declaration: package: org.bukkit.metadata, interface: Metadatable
thanks! i didnt realize there is pdc for players
Yeah theres pdc for any entity
enchantments.keySet().stream().filter(e -> e in incompatibleEnchantments).count()
Change e in incompatibleEnchantments to some type of contains call, by converting the array to a Set or some other way
why do that when you can do retainAll
How do I use the singleton pattern on my Plugin instead of DI for util classes containing only static methods
Because that changes the original collection doesn’t it?
The problem is that the AnvilUtils class is not instantiated and I don't want to change all the methods to non-static
Why not just call them statically and pass the plugin instance? Or you can use JavaPlugin.getPlugin(YourPlugin.class)
Because then I need to pass the plugin in a bunch of static methods which is cringe
Because it's really kind of a global variable, it just isn't written that way
public class AnvilUtils {
static double MATERIAL_REPAIR_COST_MULTIPLIER =
JavaPlugin.getPlugin(BetterAnvils.class).getConfig().getDouble("material-repair-cost-multiplier");
Is this acceptable
its in a method, doesnt really matter if it does, even if it does it gets gc'd after the method ends
What does the GC have anything to do with modifying a collection passed as a parameter?
depends on usage
That double seems like something that should be passed as a parameter so that you can implement some type of reload command to reload the value
The GC has nothing to do with it though
And you should really avoid modifying parameters unless that’s explicitly the purpose of the method
if it matters that much just get them to clone the keyset then
Why are you so against using a stream?
im not, its just way more effort than you need
In what way?
no need for you to stream it, when you can just keyset and retain all
It’s more readable
And it’s not more effort
It’s actually the same number of method calls
And then you'll have geol that complains about streams being inherently more expensive
Hi, https://gitlab.com/kodysimpson/menu-manager-spigot/-/tree/master/
The tutorial/template menu by kody simpson is good ?
Why is bad ?
why ain't this working?
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player player = e.getPlayer();
player.setResourcePack("url", "hash");
}```
url and hash are correct
do i need to wait?
inv holders are not the right way, you check by instance. They shouldnt really be exposed to the api but are
follow 7smiles forum post
