#help-development
1 messages · Page 953 of 1
@young knoll Im pulling my hair out. Doesnt matter what i try, my work directory refuses to include moj mapped files for this class.
I've meticulously read the contribution section in stash because i havent PRd nms changes for a while. And im literally unable to find out the workflow.
do you know how i can modify this number to add the player here?
question: why
Modify the outgoing ping response packet
Everything that maps from X to Y should have a dedicated class which handles this relation.
And managers are a simple solution for that.
We can meet in voice sometime in the next hour.
Yeah, need to get home anyway and probably buy some food for the weekend
did someone say dog
show dog
Guys I wrote the plugin, everything works just fine but it doesn’t show any info I edited (with the comman /hoveredit Egitto)
?paste
Here’s the code
I tested it, but it doesn’t show the info I edited
In chat “Hover Chat Plugin”
how do i update it now?
public PacketContainer changeOnlinePlayersAmount(int onlinePlayers) {
PacketContainer packet = new PacketContainer(PacketType.Status.Server.SERVER_INFO);
WrappedServerPing ping = packet.getServerPings().read(0);
ping.setPlayersOnline(onlinePlayers);
return packet;
}```
agreed
you would need to listen for the server list ping packet
and of course set your MOTD, maxplayers and version
oh is there no way to modify only the playercount?
that would leave you with an otherwise empty packet
which might give you an exception or crash client, idk
paper has an event for that where you can directly modify stuff, just saying ^^
oh whats the event called?
PaperServerListPingEvent
https://jd.papermc.io/paper/1.20/com/destroystokyo/paper/event/server/PaperServerListPingEvent.html but reminder that this is the spigot discord
declaration: package: com.destroystokyo.paper.event.server, class: PaperServerListPingEvent
awwww
I SEE DOG
how can I repeat code 16 times and wait 200 ticks before the next code block repeat?
?scheduling
thanks
does anyone know how the plugin “model engine” does what it does, with allowing like extra textures in game without overwriting some?
Having some difficulties with damage types and events...
I've canceled the entity explode event:
@EventHandler
public void onEntityExplodeEvent(EntityExplodeEvent event) {
event.setCancelled(true);
}
but I am still somehow able to damage myself with ENTITY_EXPLOSION. Could anybody help me? Thanks!
protocollib
are you talking about the damage reason?
you would need to cancel an EntityDamageEvent if that's the reason
is this code good tho?
public PacketContainer changeOnlinePlayersAmount(int onlinePlayers) {
PacketContainer packet = new PacketContainer(PacketType.Status.Server.SERVER_INFO);
WrappedServerPing ping = packet.getServerPings().read(0);
ping.setPlayersOnline(onlinePlayers);
return packet;
}```
as I said, you need to add in the other fields as well
Well, yes but I wanted to cancel the origin by itself, which would, in term, prevent the damage...
i'm pretty sure the explosion doesn't deal the damage itself, could be wrong tho....
Does anyone know why the stand breaks? if it says stand.setInvulnerable(true);
final ArmorStand stand = (ArmorStand) this.location.getWorld().spawnEntity(this.location, EntityType.ARMOR_STAND);
stand.setMetadata("NPC", new FixedMetadataValue(Anarchy.getInstance(), this.npcId));
stand.setInvulnerable(true);
what are the other feilds called?
check the variable
your IDE should tell you what other fields are there
Hmmm... In that case do you have any idea what other things can cause it? As in events or something...
Last case scenario, I do as you said and cancle entity explosion damage
Why does it break it shouldn't break (
Pretty sure it does
I do remember making fake explosions to track damage
would be my only explanation ¯_(ツ)_/¯
interesting
ill check for damager first
Eh
Any recommendations for looking through remapped jar? I was using jd-gui but I can't figure out the search function.
will this work?
public PacketContainer createFakeTablistPacket(String name, String displayName, UUID uuid, int ping) {
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
WrappedGameProfile profile = new WrappedGameProfile(uuid, name);
EnumWrappers.NativeGameMode gameMode = EnumWrappers.NativeGameMode.SURVIVAL;
WrappedChatComponent wrappedName = WrappedChatComponent.fromText(displayName);
PlayerInfoData playerInfoData = new PlayerInfoData(profile, ping, gameMode, wrappedName, null);
Set<EnumWrappers.PlayerInfoAction> actions = EnumSet.of(
EnumWrappers.PlayerInfoAction.ADD_PLAYER,
EnumWrappers.PlayerInfoAction.UPDATE_DISPLAY_NAME,
EnumWrappers.PlayerInfoAction.UPDATE_LATENCY,
EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE,
EnumWrappers.PlayerInfoAction.UPDATE_LISTED
);
packet.getPlayerInfoActions().write(0, actions);
packet.getPlayerInfoDataLists().write(1, List.of(playerInfoData));
PacketContainer onlinePlayers = new PacketContainer(PacketType.Status.Server.SERVER_INFO);
WrappedServerPing serverPing = onlinePlayers.getServerPings().read(0);
serverPing.setPlayersOnline(getServer().getOnlinePlayers().size() + 1);
return packet;
}```
try it and see bro
?tryandsee
lifesaver
nope it didnt work
why does this not increase the player count by 1?
@EventHandler
public void onServerListPing(ServerListPingEvent event) {
int realPlayers = getServer().getOnlinePlayers().size();
changeOnlinePlayersAmount(realPlayers);
}
public PacketContainer changeOnlinePlayersAmount(int onlinePlayers) {
PacketContainer packet = new PacketContainer(PacketType.Status.Server.SERVER_INFO);
WrappedServerPing ping = packet.getServerPings().read(0);
ping.setPlayersOnline(onlinePlayers + 1);
return packet;
}```
Maybe because you dont write the ping back into the packet?
oh like this? packet.getServerPings().write(0, ping);
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
/pee is crazy 😭
i added this:
public PacketContainer changeOnlinePlayersAmount(int onlinePlayers) {
PacketContainer packet = new PacketContainer(PacketType.Status.Server.SERVER_INFO);
WrappedServerPing ping = packet.getServerPings().read(0);
ping.setPlayersOnline(onlinePlayers + 1);
packet.getServerPings().write(0, ping);
return packet;
}```
but it still doesnt work
o_o
How are you sending this?
like this:
@EventHandler
public void onServerListPing(ServerListPingEvent event) {
int realPlayers = getServer().getOnlinePlayers().size();
changeOnlinePlayersAmount(realPlayers);
}```
So you are creating a packet and then throwing it right in the trash without doing anything with it
🤔
How do you expect anyone to receive a packet if you send it to literally nobody.
Its like writing a letter, throwing it in your bin, and then wondering why nobody got this letter.
PandaSpigot o_o
oh how do i send it to the person who pinged?
Looks like they use an outdated gson instance?
Or you are shading in an old version of gson which is then used instead.
You listen for outgoing packets of that type and then modify them instead of sending a completely new packet.
hi
hi
the wiki shows every entity type along with its id, but these ids do not match up with the ones provided by the bukkit EntityTypes. where can i find the correct entity ids
What's interesting that the plugin I am trying to run works on the first server but on the second server it break at this point, not really sure why, I have this dependency on my Core
Update the version and make sure to relocate it
uh no wait, I used the same code on two different plugins* On one plugin it works fine on another it breaks, thou those two plugins use the dependency from my Core
relocate gson in your core
how?
Making now a grief alert plugin, but I actually don’t get alerts
ProtocolLib
using a PacketListener?
Can anyone check this code and tell me why I don’t get grief alerts?
Did you register the listener?
Opsie, nop
how do i get the person i need to send the packet too, like event.get___
?
You dont. Just modify the outgoing packet.
is that using protocolManager?
please read the docs 🙏
What is even OpListEntry
thou I am only interacting with strings, ints and bukkit Locations
like this?
@EventHandler
public void onServerListPing(ServerListPingEvent event) {
int realPlayers = getServer().getOnlinePlayers().size();
changeOnlinePlayersAmount(realPlayers);
// Censor
protocolManager.addPacketListener(new PacketAdapter(
this,
ListenerPriority.NORMAL,
PacketType.Status.Server.SERVER_INFO
) {
@Override
public void onPacketReceiving(PacketEvent event) {
PacketContainer packet = event.getPacket();
WrappedServerPing ping = packet.getServerPings().read(0);;
ping.setPlayersOnline(realPlayers + 1);
packet.getServerPings().write(0, ping);
}
});
}```
no
you can't use ServerListPingEvent
just put that packet listener in your onEnable
Every time someone pings your server, you are registering a new packet listener.
This will crash your server in no time.
unfortunately in ServerListPingEvent, you can't change the numPlayers, in PaperServerListPingEvent that's a thing
The send method in PlayerConnection implements ServerCommonPacketListenerImpl. I was wondering whether I should be getting the ServerCommonPacketListenerImpl to use the send method or using PlayerConnection. Very new to this so I might be approaching this wrong.
Send:
connection.getClass().getMethod("send", getNMSClass("network.protocol.Packet")).invoke(connection, packet);
Error:
java.lang.NoSuchMethodException: net.minecraft.server.network.PlayerConnection.send(net.minecraft.network.protocol.Packet)
is there a way for me to use PaperServerListPingEvent while still being able to use remapped spigot?
When using reflections you need to use the obfuscated names.
Might be worth using ProtocolLib instead. What do you need packets for?
so i cant use both?
?fork
SpigotMC maintains the Spigot server. If you are using a fork of Spigot (such as Paper, Airplane, Purpur, or other derivative works), you should seek support in the appropriate Discord servers.
Using the sign editor ui to take inputs, I'd rather not use protocollib.
^^
Then i hope you are caching reflections for your servers sake
And you should probably use MethodHandles instead of the old reflect Method invocations
so with that would it be like this?
@EventHandler
public void onPaperServerListPing(PaperServerListPingEvent event) {
int realPlayers = getServer().getOnlinePlayers().size();
event.setNumPlayers(realPlayers + 1);
}```
how do i get the internal registry id of an entitytype?
bukkit used to have this defined but it has since been deprecated
Isnt EntityType Keyed?
what do you need it for
used for protocol and stuff
well no
That was always an internal magic number
If you're using ProtocolLib or nms you pass the entity type
yeah but shouldnt bukkit have some kind of registry
Only way you don't is if you have your own server impl
to access this
In which case you should have every registry already anyways
There's no need to, that's the thing
If you're messing with packets you either have a couple native bukkit methods or you're crossing into nms territory
I also cant think of a use case for the API
is it somehow related to me trying to serialize bukkit location?
Yeah
If you want to for example, spawn a fake entity
THere's the virtual entity api now IIRC
But also the entity type field in the spawn packet is of.. an entity type
Not the type id
So even if you're using ProtocolLib you just pass the bukkit type, not the type id
Unless you're dealing with like.. 1.8?

im not using protocollib. it may sound crazy but im directly writing all the stuff using a netty bytebuf
In which case you shouldn't look for help here, but rather on the mirror o_o
through a little wrapper i made
In which case look at how the nms packet serializes it
it uses the internal nms registries
i'd just figure that bukkit would have made a wrapper of it
Can someone make a panel here?
yeah internal registries
Panel for Minecraft server
I wouldn't expect bukkit to make a wrapper for it given it's purely internals
You mean a web interface?
Pterodactyl?
i guess that makes sense
ill have to find some nms way of doing it then
using reflection
A panel for a game, for example: a teacher's panel that expels or joins someone
uH
Just pull out all values into a Map<EntityType, Integer> when the server starts
You can do that through GUIs or through a web interface
I've done that through GUIs before
yeah, that was my plan
Any person can do the plug-in configuration well, send a DM message
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
ye
Something like this?
MethodHandles.Lookup lookup = MethodHandles.lookup();
MethodHandle sendPacket = lookup.findVirtual(connection.getClass(), "send", MethodType.methodType(void.class, getNMSClass("network.protocol.Packet")));
sendPacket.invoke(connection, packet);
?tas
how does model engine work where the plugin has custom mob textures?
it has somewhat custom textures and entities but like they don't override in game ones?
They split the bbmodel into several item models, then emulate bones and joints, and translate it into the minecraft space.
The ingame items are then displayed using ItemModels (in never versions) or ArmorStands wearing ItemStacks (in older versions).
You can basically have millions of custom ingame items by using the customModel tag on ItemStacks which where introduced in minecraft a while ago.
Custom Model tag?
i dont think i've seen that
cool thanks, I found a tutorial on it
Is there a website with minecraft sounds with a button to play the sound and their unique seeds?
nvm found one 💀 https://minecraft.fandom.com/wiki/Category:Sound_effects
nvm x2 this doesn't show the seed...
last time I needed a sound I spent an hour trying to find the right seed
Figured it out, turns out it is b for 1.20.2+
Hi , anyone know how i can send a text display?
A title?
oh
TextDsplay?
you mean like a nametag or is that a entitytype I'm unaware of
Your screenshot tells me you dont
yes , the code was orignaly for 1.8 , i updated but idon't know how 1.20 do it
With mojang mappings you can actually figure it out quite easily because you have actual names to work with
I'm confused don't you need to pass in a Entity
TextDisplay is not an entity?
iam trying to not use armorstand , or entityArmorStand
iam trying to make it correctly for 1.20.4
TextDisplay is in fact an Entity
that does not work
and also iam getting this weird bug with gradle
t
Hey, does anyone know a good way to start plugin development? I know some basic java and have worked with commands and rpacks, but I have no clue how to start or where to begin.
what do you think ?
Speaking of TextDisplays
is their "rotation" dependent on direction?
I was using armorstands before but I never knew about these textdisplays till now
I would start with some videos explaining the basic setup.
Try to get a "Hello World" plugin running and then come back to get some simple plugin ideas from us.
This explains how to create your first blank plugin
welp i was using armorstand , and i was only working with old ver 1.8 , but now i updated and it seem so complicated
thanks, i'll check it out!
nevermind, got it working
You need to find some nieche gradle plugin if you want to use remapped spigot with gradle
oh yeah
can you send me one?
how?
right
yes
the file it gives you is mojang mapped
the point in that plugin is to remap to spigot
i understand , but its not working
keep throwing errors
Could not HEAD 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/com/mojang/authlib/5.0.51/authlib-5.0.51.pom'. Received status code 502 from server: Bad Gateway
You already have the base file though right
yes
Text displays are fun I gotta add some more stuff to my damage holograms
this error looks like you don't have the mojang remapped
but i do 😦
and its in your mavenlocal?
you don't have mavenLocal()
not maven gradle
ik
thats the 1.20 moudle
but where is it...
Did you use buildtools to get a mojang remapped jar?
then did you add it to your local repository (or somewhere)
you need mavenLocal() in your build file
You need that file in mavenLocal()
and to consider mavenLocal() as a repo in your build file
then you can use this tool to remap to spigot, or keep as mojang, up to you
i never used gradle before sorry for my stupid questions
what are you doing anyway? 1.20.4 hologram?
you know they added like display entities and stuff
I've been using armorstands up until this day because I just learned about them
very cool of them to add it though
privite?
sure
Links are fine
my scoreboard registers a new scoreboard and objective on a player joining as I have unique changing values for each player on the scoreboard :
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
PlayerMemory memory=new PlayerMemory();
Scoreboard scoreboard =Bukkit.getScoreboardManager().getNewScoreboard();
Objective scoreboardRight = scoreboard.registerNewObjective("joinSidebar", "dummy");
scoreboardRight.setDisplaySlot(DisplaySlot.SIDEBAR);
<more code>
I don't know how I can change the name above the player's head with rank prefixes. I know I can do this with teams but my code registers a new scoreboard for each individual player and I couldn't manage to do it protocollib. Can anyone help? I've tried googling with no success
is the getPlayer() method in playerdeathevent for attacker or victim
victim
and getEntity() for attacker, right?
you can get attacker by victim.getKiller()
event.getEntity() is still the victim
because PlayerDeathEvent extends EntityDeathEvent
and getEntity is the method of EntityDeathEvent
so both same thing, e.getPlayer() for playerdeath, e.getEntity() for entity death
yeah
ight
thx
how can i set the spawn point of player? or do i have to teleport him
nvm
You can change it by RespawnEvent
i found setRespawnLocation()
that is
that is what
setRespawnLocation() is what you want
oh ok
++
Does anyone know where I can find help for modding using MCP?
eric golde's dc server if it's still available
the only one I know
Can you please send the invite
I think you can find it under one of his videos on youtube, he had series dedicated to mcp918
I am no longer there otherwise I would've sent you the invite
Hi , anyone use hikariConfig.setDataSourceClassName for 1.20?
what is this should be?
i cant say ive ever had to set the driver source
i need i tried..
can i disable the ability to hear the hit sound on entities?
or disable hitting them at all?
apply a weakness effect with 256 levels for the attacker
no
i remember a plugin which change combat system to 1.8
That plugin includes a feature disabling hit sound
hmm
But i forgot its name
Fellas, still clueless...
@EventHandler
public void onProjectileHitEvent(ProjectileHitEvent event) {
if (event.getEntityType() == EntityType.WITHER_SKULL) {
event.setCancelled(true);
if (event.getHitEntity() != null) {
if (event.getHitEntity().getType() == EntityType.PLAYER) return;
}
event.getEntity().remove();
}
}
@EventHandler
public void onEntityExplodeEvent(EntityExplodeEvent event) {
if (event.getEntityType() == EntityType.WITHER_SKULL) {
event.setCancelled(true);
event.getEntity().remove();
}
}
It still damages the player?! It happens when the skull collides with a block, but no actual block damage is produced and the explosion is never created, yet it still harms all entities in a radius. (Wither Skull)
Could anyone help me? Thanks!
Try the damage event
Yes, the damage event returns an ENTITY_EXPLOSION I believe and there is knockback and damage, but no particles or block damage
also I don't want to cancel out ENTITY_EXPLOSION and even if I did, I also don't want the knockback. At this point, the only really viable solution is to go back in time and remove the skull
If I had to guess, it has to do with packets, intercept the sound packet from damage entity event or something and just don’t send it to the player
Check if the damager in the event is a wither skull
in the damage event?
EntityDamageByEntityEvent
Welp it worked, kinda as a bandaid, but it did! I hope that it doesnt come back to bite me in the ass further on, but for now it works. Thanks a lot for all!
Any general info on datawatchers? Trying to send a metadata packet to modify an entity packet i sent earlier. Mainly confused as to how it links to wiki.vg/Protocol as any forum example I've found doesn't link up.
Day Integer.MAX_VALUE of writing cursed code
What version?
Latest
Then it's pretty simple
You don't need data watchers
Although it'd be nice to have entity data
In short, every nms Entity has a "DataWatcher" (whose name is actually SynchedEntityData)
It contains a few fields, which have explicit types and default values
And each entity class (and its parents) define fields
For example the field 0 is of type byte and it's just a bitmask for visibility, glowing etc
Before 1.19 you had to create a whole data watcher (For packet entities this was done by just creating a new entity, assigning values and getting the data watcher) as the packet needed it
After 1.19 it's just a List of data values
If you're using ProtocolLib, it's a List<WrappedDataValue>
These data values are basically just a class that contains
- Their ID (int)
- Their Serializer (basically data type)
- Their value
For ProtocolLib, creating such list is quite trivial:
List<WrappedDataValue> list = List.of(
new WrappedDataValue<>(0, Serializer.Registry.get(Byte.class), (byte) 0x40)
)
With NMS you just get the entity's SynchedEntityData and call either packDirty (Returns a list of every value that has changed since the last packDirty call) or getNonDefaultValues (self explanatory)
That's about it
I'm not using protocolLib, it asks to pass a datawatcher, how would I use that wrappeddatavalue instead
Let me get to PC
This is where I left my code (Sorry if its a bit cramped):
MethodHandles.Lookup lookup = MethodHandles.lookup();
Object worldHandle = lookup.findVirtual(ReflectionUtils.getCraftClass("CraftWorld"), "getHandle", MethodType.methodType(getNMSClass("server.level", "WorldServer"))).invoke(loc.getWorld());
Object textEntity = lookup.findConstructor(getNMSClass("world.entity","Display$TextDisplay"), MethodType.methodType(void.class, getNMSClass("world.entity", "EntityTypes"), getNMSClass("world.level", "World"))).invoke(EntityTypes.aY, worldHandle);
Object convertedEntity = lookup.findVirtual(getNMSClass("world.entity","Display"), "getBukkitEntity", MethodType.methodType(getCraftClass("entity.CraftEntity"))).invoke(textEntity);
Object entityHandle = lookup.findVirtual(ReflectionUtils.getCraftClass("entity.CraftEntity"), "getHandle", MethodType.methodType(getNMSClass("world.entity", "Entity"))).invoke(convertedEntity);
Object dataWatcher = lookup.findVirtual(getNMSClass("world.entity", "Entity"), "an", MethodType.methodType(getNMSClass("network.syncher", "DataWatcher"))).invoke(entityHandle);
And I had planned on using this:
It's this part
yeah found it
If I do the method where I get the datawatcher afterwards and pass that, would I just modify my textEntity?
Also is 0x40 the id for glowing or what is that
I know its 64 but wasn't sure what that linked to
Rephrase
The idea is you call setVisible / setWhatever and then you send the packet with the dirty values
And for new players you send non defualt
?mappings
Compare different mappings with this website: https://mappings.cephx.dev
Yea
I didn't reflect it b/c easier but I'm assuming I would need to
You do that on the nms entity and then send a new packet
yeah
wait so do I get the watcher after I set these values, then send metadata packet?
Yeah
Alright, let me try that out, I'll definitely learn the List method though too
How do I open the ports on my PC for my Minecraft server????
how do i teleport a player to a custom dimention?
wdym by custom dimension?
a world?
Location location = new Location(world, 256, 70, 256);
player.teleport(location);```
maybe like this not sure if it works?
Yeah
if i had to refer to overworld what should i do instead
what?
i dont understand
"world" is the default name for the overworld world
It can be overriden and shouldn't be relied upon
i get it, it checks the name of the folder
Do you have an idea why this class cannot be found?
Code:
Object entityData = lookup.findVirtual(getNMSClass("world.entity", "Entity"), "getEntityData", MethodType.methodType(getNMSClass("network.syncher", "SynchedEntityData"))).invoke(entityHandle);
Error:
java.lang.RuntimeException: java.lang.ClassNotFoundException: net.minecraft.network.syncher.SynchedEntityData
Remappings
Yay mapping
You need to use the obfuscated names for string lookups
Or rely on a way that doesn’t use names
I was using it before, but I eventually got to:
Object dataWatcher = lookup.findVirtual(getNMSClass("world.entity", "Entity"), "an", MethodType.methodType(getNMSClass("network.syncher", "DataWatcher"))).invoke(entityHandle);
Object listValues = lookup.findVirtual(getNMSClass("network.syncher", "DataWatcher"), "b", MethodType.methodType(List.class)).invoke(dataWatcher);
Error:
java.lang.NoSuchMethodException: no such method: net.minecraft.network.syncher.DataWatcher.b()List/invokeVirtual
And now I'm wondering if I f-ed up the type...
I am not certain what the return type is tbh
Oh, figured it out nvm
How do hologram plugins stack each armorstand? What entity do they use
They just use multiple entities
Thanks
You can use setMaxSpeed(), it just might not work on some versions is all
Oh, actually, no, that doesn't even work anymore lol
Is there like a limit to the complexity of which you can make a text display? In other words, what are all the creative features that can be messed with?
Also might anyone have an example of a pdc manager?
EnchantItemEvent
how can i get what an enchant that added to player item? i only can see EnchantmentHint one but it a hint not which player added
oh thank you
How do i set max stack size to my custom item
You dont
You can look at events tho, and look if the player is stacking something higher than you want, and then split the stack moved, to basically achieve what you want
If you want to make an item non stackable, just add a pdc or snth
just wait until 1.20.5 😴
For BungeeCord, is there a way to send colored messages to the console using the logger?
Hello what file is for configure droptiles (Paper, spigot, bukkit )
oh i see
Like if you break a block it spawn on the ground
And you can take it
#help-server this channel is for development
are there any community guidelines or some common policy you must follow when uploading a plugin to spigotmc forums?
Has anyone used the servicemanager before?
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Hello, Is there an event for when an interaction will make the held item lose durability?
how can I there an event
???
Probably this https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/PlayerItemDamageEvent.html
declaration: package: org.bukkit.event.player, class: PlayerItemDamageEvent
yeah ^^
I think I'm more laggy than javascript x)
okay thanks 😄
he just wants to become an event man
yeah 👍
I want to be asked every tick
but how can I cancel a broke block?
?
I want to cancel a block break and the durability use
you want to cancel the PlayerItemDamageEvent?
I want to cancel item damages and the action done with the item
(eg: Cancel sword durability lose and mob attack)
Cancel BlockBreakEvent and EntityDamageByEntityEvent
you might right clicking with a shovel on grass?
yeha
do you think creating a path with a shovel is breaking a block?
no
do you think its interacting with the block
yeah x)
then you got your answer
so I should do specific cases? Because I have done with interact event before and it was just doing a lot of spam and I want to cancel on the cases when it loses durability
cancel PlayerInteractEvent if they're interacting on a grass block with a shovel ig?
whats the best method to add a second name tag (line)
Probably creating a scoreboard with BELOW_NAME as the display slot
im not sure if it will always be a number but in case it is not you could do that, otherwise you need to spawn an entity at eye location and do some code to make it invisible, have the player's data, always there etc
Anyone a take on this? ^^^
why do you have server inside of project folder
yeah xd
but yeah, dont distribute jar on gh
in general just take your server outside our project folder wtf
I work on multiple devices and don‘t want to redownload the server every time. I basically have the eula, the server jar and some start scripts on my repo. The rest is generated on each device seperately. (Also to easily build my jar on different OSs/devices since i then can just use ${project.folder} or sum in my pom.xml.
I just want to know if it‘s only the spigot.jar that‘s not to be destributed. Bc then i‘ll have to .gitignore it once i release the plugin.
Check the license of every jar you keep in that repo
imagine gradle changed their license on the wrapper as an april fools joke
ye
then how to use it
probably atributes its just an entity at the end of the day
okay thanks
Can I cancel event only when player start walking. I used playermoveevent and It cancels every time when player just move his mouse but I need to cancel only on walk.
package milkyland.milkyanimations.events;
import milkyland.milkyanimations.commands.Pee;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
public class PeeOnPlayerMove implements Listener {
@EventHandler
public void onPlayerMove(PlayerMoveEvent e) {
Pee.cancelPee(e.getPlayer());
}
}
Then only cancel if the position of the locations change, but not if the directions changed.
Only living entities have attributes
Yeah I don't think you're going to be able to change the max speed of a boat
Yo can someone help me to install geyser and make it work? When I try it it doesn't work and i use Playit.gg
Would be strange
Hmm, yummy minecraft movement. Remember people straight up flying around in boats without any good fix for that?
There was a popular exploit used by hacked clients which let people fly around in boats
can someone explain to me the differene between placeholderhooks and palceholderexpansions
What even is a placeholderhook? I dont recognize this from PAPI
I believe expension refers to the ones that you can download from the papi ecloud
And hook is whatever placeholder a plugin has added
no thats also expansions
there is a class called placeholderhook
ig it got removed or will be removed
not sure
PlaceholderExpansion is the class you implement and register. What is the purpose of a placeholderhook?
theres also .registerPlaceholderHook but its depricated
thats what im asking
lol
If its deprecated then ignore it
i mean registerPlaceholderExpansion is also deprecated so i assumed maybe theres a new method for "placeholderhook" aswell
why
Because it has tutorials on how to make and register expansions?
why is intellij 2024.1 so ugly
Part of me really does hate new PlaceholderExpansionImplementation().register() though
I absolutely hate having new at the start of a line. It's so gross
Yo can someone help me to install geyser and make it work? When I try it it doesn't work and i use Playit.gg
hi guys, is there a way to get the PersistentDataType of any NamespacedKey, so I don't have an error while casting ?
No because the type can be interpreted as anything you'd like
hm
Just uhh, pull a C# and assign it to _
booleans are just a 1 or a 0 as a byte
I just need to iterate all values of keys in an itemstack
maybe there is another way ?
:kotlin:
Not really. NBT isn't really designed for that sort of behaviour
You should know what you're putting into it and what you expect to get out of it
Otherwise you'd use a list type in the NBT, but even that has to be a list of some type
What do you need this for?
It’s all Object
In ItemsAdder there is /ia tag that just send u all tags in the item, I need to reproduce it
CompoundTag#getAllKeys()?
yes but I need to get values too
Perfect
i know lol
get(...) returns a Tag which has a getType() method -> TagType
not me 7 years ago thinking primitives were deprecated because "it's an OO language"
get from which method ?
CompoundTag
Oh my sweet summer child
I don't have CompoundTag
It’s not summer yet!
7 year old you is going to cry when primitive classes are introduced
Excuse me
then get one. ItemStack#save(new CompoundTag())
Sorry, *value classes
(You need NMS)
or maybe there's an easier way
probably
why do you even need all nbt tags? what's the purpose?
I need to create an admin command to just check up tags and values of an itemstack
Was just going to suggest the same
ohh maybe
ItemMeta#getAsString()
yes I think u right
It will get you everything though, not just the PDC
a million dollars?
god damn
zimbabwe dollars, maybe
should I open an issue
ty !
Just uhh
cry of joy
Alias /data get entity @s SelectedItem
I'll be in my deathbed when that happens
GTA VI releasing before value classes 💀
And skyrim 2
i still remember that from when you told someone to check it
Best command
how do i check the 15th slot on me
Idk
why not
No I’m a plugin dev
no ur a nerd
So are u
ur coedr bro
why does this not work even if both the loggers get logged?
@EventHandler
public void onPaperServerListPing(PaperServerListPingEvent event) {
getLogger().info("event called");
int realPlayers = getServer().getOnlinePlayers().size();
event.setNumPlayers(5);
getLogger().info("player count changed");
}```
How do you test if it works or not?
by refreshing the server list in the multiplayer menu
and if it sets the online players to 5 then it works
What do you mean by that? You told us that it doesnt work.
yeah because it didnt set the online players to 5 it just kept them as 1 (when i had 1 account logged on)
And what does this mean then?
what even is a PaperServerListPingEvent
Check this. Im about to head to the gym...
alright, so i set it to false using this? event.setHidePlayers(false);
works, thanks
how can i get the name gave on the anvil gui when the player click on the item?
AnvilInventory has a getRenameText iirc
how can I get the window id of a player?
wat
Like the internal network id of the inventory/screen they have open? Because that's not exposed
I need to open an inventory for a player
CraftPlayer#activateContainer#windowId
I'd get it with reflection
but it changes names and the last one is an int
so I'm looking for a reliable way
I'd get it by intercepting the outgoing packet after opening an inventory for a player
but that fires an event
which needs to be done sync
ServerPlayer#containerId
Hasn't changed in forever
Why do you even need this though? If you want to open a nee container use ServerPlayer#nextContaineCounter()
new patch just dropped the serverplayer now has current git has on the mapping
?
I don't have such a class
?switchmappings
That's because it's remapped I'm not helping you with obf mappings
Get with the times
didn't ask you to
Does it really range 0-99?
That's what that code seems to imply, yes. It's an internal network id to maintain state so it really doesn't need to go any higher
well but
hmm
I guess it's stored as an int but sent as a byte
appreciate the help
Yeah this only causes problems if you store the reference to the 0th container for so long you've already opened 100 containers
In which case the server and client may experience a bit of desync
I guess it's 1-99
since 0 is the player inventory
I'm trying to store a list of Strings in a PersistentDataContainer but I just cannot get it to work, I even went as far as implementing my own PersistentDataType following this guide (https://www.spigotmc.org/threads/a-guide-to-1-14-persistentdataholder-api.371200/) but I didn't find how to get the values from it 😭
Does everyone know how and even if this is achievable?
how do i make it so that the player which gets added using this:
public static PacketContainer createTablistPacket(String name, String displayName, UUID uuid, int ping) {
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
WrappedGameProfile profile = new WrappedGameProfile(uuid, name);
EnumWrappers.NativeGameMode gameMode = EnumWrappers.NativeGameMode.SURVIVAL;
WrappedChatComponent wrappedName = WrappedChatComponent.fromText(displayName);
PlayerInfoData playerInfoData = new PlayerInfoData(profile, ping, gameMode, wrappedName, null);
Set<EnumWrappers.PlayerInfoAction> actions = EnumSet.of(
EnumWrappers.PlayerInfoAction.ADD_PLAYER,
EnumWrappers.PlayerInfoAction.UPDATE_DISPLAY_NAME,
EnumWrappers.PlayerInfoAction.UPDATE_LATENCY,
EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE,
EnumWrappers.PlayerInfoAction.UPDATE_LISTED
);
packet.getPlayerInfoActions().write(0, actions);
packet.getPlayerInfoDataLists().write(1, List.of(playerInfoData));
return packet;
}```
appears at the bottom of the tablist?
In modern versions there are direct PDC types for lists
Saw that, but it didn't seem to exist somehow, wait
It just says it doesn't know it
What api version are you using
newest for 1.21
time travelling 
there is an api for the anvils? like for the head name getting the string etc? for the 1.20
yes
does someone know how to do this?
tablist is ordered alphanumerically
why dont you use teams to make them at the bottom
how do i do that?
ok i have created a team using:
ScoreboardManager scoreboardManager = Bukkit.getScoreboardManager();
Scoreboard scoreboard = scoreboardManager.getNewScoreboard();
Team team = scoreboard.registerNewTeam("0");```
now how do i add the fakeplayer to that team?
where i can find it?
https://hub.spigotmc.org/javadocs/bukkit/
Top right corner. Type in "anvil" and see what comes up.
oh i didnt know you wanted to add a fake player to it. no idea but you most likely can, ask someone that has experience with fake players the way you're doing it
depends how "fake" your player is
if it's packet only, then you have to send a teams meta packet
i assumed it was something like EntityPlayer
He tells you that he is your friend and then scams your for all your ingame money. So pretty fake.
if you created the player (Bukkit entity) then you can simply add them by name to the team
its just a tablist packet
how do i do that?
Cant you just add the player String to the scoreboard? Might as well work for fake players,#
do you want to fake md_5's presence 😂
it might, but unknwn as Bukkit is likely to validate an added name to a team
I think you can add a player to a scoreboard before he joins, and he will be on it still after joining for the first time.
If thats true, then its nice and easy
like this?
public static PacketContainer createTablistPacket(String name, String displayName, UUID uuid, int ping) {
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
WrappedGameProfile profile = new WrappedGameProfile(uuid, name);
EnumWrappers.NativeGameMode gameMode = EnumWrappers.NativeGameMode.SURVIVAL;
WrappedChatComponent wrappedName = WrappedChatComponent.fromText(displayName);
PlayerInfoData playerInfoData = new PlayerInfoData(profile, ping, gameMode, wrappedName, null);
ScoreboardManager scoreboardManager = Bukkit.getScoreboardManager();
Scoreboard scoreboard = scoreboardManager.getNewScoreboard();
Team team = scoreboard.registerNewTeam("0");
team.addPlayer(Bukkit.getPlayer(uuid));
Set<EnumWrappers.PlayerInfoAction> actions = EnumSet.of(
EnumWrappers.PlayerInfoAction.ADD_PLAYER,
EnumWrappers.PlayerInfoAction.UPDATE_DISPLAY_NAME,
EnumWrappers.PlayerInfoAction.UPDATE_LATENCY,
EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE,
EnumWrappers.PlayerInfoAction.UPDATE_LISTED
);
packet.getPlayerInfoActions().write(0, actions);
packet.getPlayerInfoDataLists().write(1, List.of(playerInfoData));
return packet;
}```
um, you have a Player UUID?
you only sent packets so the player does not exist
Bukkit.getPlayer will have no knowledge of the player and will return null
you add players to teams by name not a Player object
cant you use the name
so just this? team.addPlayer(Bukkit.getPlayer(name));
i think its team.addPlayer(name);
oh so it doesnt take a player name
yeah i was confused as fuck
ive seen it before taking a name
maybe now it doesnt and that was in older versions?
It used to require a Player Object but that was deprecated as teams can have more than Player objects now
so now they are added by player name or object UUID
so this should work then?
public static PacketContainer createTablistPacket(String name, String displayName, UUID uuid, int ping) {
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
WrappedGameProfile profile = new WrappedGameProfile(uuid, name);
EnumWrappers.NativeGameMode gameMode = EnumWrappers.NativeGameMode.SURVIVAL;
WrappedChatComponent wrappedName = WrappedChatComponent.fromText(displayName);
PlayerInfoData playerInfoData = new PlayerInfoData(profile, ping, gameMode, wrappedName, null);
ScoreboardManager scoreboardManager = Bukkit.getScoreboardManager();
Scoreboard scoreboard = scoreboardManager.getNewScoreboard();
Team team = scoreboard.registerNewTeam("0");
team.addPlayer(Bukkit.getPlayer(name));
Set<EnumWrappers.PlayerInfoAction> actions = EnumSet.of(
EnumWrappers.PlayerInfoAction.ADD_PLAYER,
EnumWrappers.PlayerInfoAction.UPDATE_DISPLAY_NAME,
EnumWrappers.PlayerInfoAction.UPDATE_LATENCY,
EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE,
EnumWrappers.PlayerInfoAction.UPDATE_LISTED
);
packet.getPlayerInfoActions().write(0, actions);
packet.getPlayerInfoDataLists().write(1, List.of(playerInfoData));
return packet;
}```
i thought that name was deprecated and UUID is not
?tas
NO! team.addPlayer(Bukkit.getPlayer(name)); Wrong
oh, what should it be instead?
can you do team.addPlayer and show all results
addEntry not addPlayer
wait addEntry takes a player name?
yes
then thats solved ig
player name or stringified UUID of an Entity
ok thanks
lol i like the "stringified"
i ran it but the players stayed at the top of tab, and when i did /team list ingame it said there are no teams
vanilla /teams is probably not going to show any teams as there are no players in that team online
ah ok, but the fake players still show up above
even tho the team is called "0" so it should be at the bottom (at least thats what i saw online)
I'm still of the opinion you are going to have to manually send a teams update packet
oh, how do i do that?
test, put an actual player in the group as well, to see if the group is then shown
Is there something like MaterialCategories so I can know if an Material is for example Wood?
Tag
There are Tags
ok thx
Haven’t touched spigot api since 1.8.9, wtf is up with item metas
ik they’re goofy
Trying to import a dependency in maven using jitpack, but its returning "Could not find artifact"
what dependency are you trying to add
An actionbar API
its showing up in the jitpack website tho
everything shows up on the jitpack website
oh
i did team.addEntry("Gizmo0o"); but the team still doesnt show
Then how would i import this, or is there any alternatives for it?
you need to maven install the release jar then add the info corresponding to what you installed it with
ill grab a doc 1 sec
Sometimes you have a certain .jar file that you need as dependency, but the author of that .jar was too lazy to properly upload it to a public repository. That’s bad, but not a problem. There are two ways to solve this, but only one proper way. The proper way: install the dependency The proper...
Tysm
Has already been made an API for BlockDisplays, ItemDisplays? So I can easier manage rotataion and stuff?
@remote swallow Do you know any other API's which provide actionbar support? This one dosnt seem to work
id just use spigots built in
How would i use it to display a constant actionbar (like in hypixel skyblock)?
use a scheduler or something to send a new action bar every tick or a few ticks
hmm ok
How would i update it tho?
I would create a Buffer. So a String for each player. Then send this buffer every 2 seconds, and when it updates.
So your task just sends whatever is in the buffer, and when the content changes, then you immediately send this update.
There are a few more optimizations you could do, but this should be enough.
Can you provide an example pls? Sry im new to this
That is quite tricky, depending on what transformation you applied to the display.
it should still have a bounding box
Start by writing a manager class which keeps track of your buffers. Let it contain a Map<UUID, String> to keep it simple.
It should map players UUID to their buffered String.
Make sure to make the Map private and final, and dont have a getter or setter for it.
Just methods like
public void addPlayer(UUID playerId)
public void removePlayer(UUID playerId)
public void updatePlayer(UUID playerId, String content)
public void sendBuffer(UUID playerId)
The AABB of block displays is infinitely small iirc
I thought it would be all encompasing, even though it has no collision
doesnt work
Nah the bounding box is size 0
For all 3 display entities
You’d have to create a base vector for each corner and then apply the transformations to them
now i got public List<Location> getBlockCorners(Location location) {
List<Location> corners = new ArrayList<>();
// First
corners.add(location);
// Second
corners.add(location.clone().add(location.getDirection().clone().multiply(1)));
return corners;
}
Again, we need to know what transformations you applied. Otherwise this only works for a very specific case.
i dont know what are talking about but
BlockDisplay blockDisplay = location.getWorld().spawn(location, BlockDisplay.class);
blockDisplay.setBlock(Material.WHITE_WOOL.createBlockData());
Alright so no transformations at all. In that case just get the Location, add (1, 1, 1) to it and span a BoundingBox on those two vectors.
This will give your the corners of your display.
And scaled, and translated.
You can literally create a 100x100 stone block if you wanted to
How can I send message to player when he step into dropped block that were dropped from player by plugin? I have created a pee plugin and I need to send message to player when he step into dropped block like. You have step into player's pee.
I need to create event and in this event check if block has metadata and this material?

cursed questions
That is very important
Why does those logs are scaled smoothly but when it comes to updating their location it is rough?
FluentApi.tasks().taskLater(() ->
{
//Scaling
Transformation transform = display.getTransformation();
transform.getScale().set(0.3f, 0.3f, 0.3f);
display.setTransformation(transform);
}, 20);
FluentApi.tasks().taskTimer(60, (a,b) ->
{
//moving
Transformation transform = display.getTransformation();
transform.getTranslation().add(0.2f, 0, 0);
display.setTransformation(transform);
}).start();
private BlockDisplay createBlockDisplay(Location spawnLoc, Material material) {
BlockDisplay blockDisplay = (BlockDisplay) spawnLoc.getWorld().spawnEntity(spawnLoc, EntityType.BLOCK_DISPLAY);
blockDisplay.setBlock(Material.OAK_LOG.createBlockData());
Vector3f translation = new Vector3f(0, 0, 0);
AxisAngle4f axisAngleRotMat = new AxisAngle4f((float) Math.PI, new Vector3f(0, 1, 0));
Transformation transformation = new Transformation(
translation,
axisAngleRotMat,
new Vector3f(1f, 1f, 1f),
axisAngleRotMat
);
blockDisplay.setInterpolationDuration(25);
blockDisplay.setTransformation(transformation);
blockDisplay.setGlowing(true);
FluentApi.events().onEvent(PluginDisableEvent.class, pluginDisableEvent ->
{
blockDisplay.remove();
});
return blockDisplay;
}
Simplest way would be PlayerMoveEvent and check if the to-location is within this block but the from-location isnt.
bro im not mega ultra senior Fluent Task Manager Transformer
And also i need to parse metadata to check if this block are from plugin?
thoses Fluent things are not relevant
Try setting the interpolation before translating as well
doesn't work :/
IDK, this part is example code from Spigot Forum
Im heading out for a walk now. Try using a teleportation interpolation and teleport the display.
You should be setting the entire transformation at once
Otherwise you’ll override any previous interpolation in progress
to prevent that I've set setInterpolationDuration every 25 ticks and taskTimer every 60 ticks, so it should not override, right?
how do you send a message like this with the hover?
yeah I read through that one already
well it has everything you need
CommandSender#spigot#sendMessage?
is that what you're looking for
Hey
[06.04 19:23:53] [Server] java.lang.RuntimeExceptionUnable to access address of buffer
[06.04 19:23:53] [Server] at io.netty.channel.epoll.Native.read(Native Method) ~[custom352827.jar:git-Spigot-21fe707-e1ebe52]
[06.04 19:23:53] [Server] at io.netty.channel.epoll.EpollSocketChannel$EpollSocketUnsafe.doReadBytes(EpollSocketChannel.java:678) [custom352827.jar:git-Spigot-21fe707-e1ebe52]
[06.04 19:23:53] [Server] at io.netty.channel.epoll.EpollSocketChannel$EpollSocketUnsafe.epollInReady(EpollSocketChannel.java:714) [custom352827.jar:git-Spigot-21fe707-e1ebe52]
[06.04 19:23:53] [Server] at io.netty.channel.epoll.EpollSocketChannel$EpollSocketUnsafe$3.run(EpollSocketChannel.java:755) [custom352827.jar:git-Spigot-21fe707-e1ebe52]
[06.04 19:23:53] [Server] at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:380) [custom352827.jar:git-Spigot-21fe707-e1ebe52]
[06.04 19:23:53] [Server] at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:268) [custom352827.jar:git-Spigot-21fe707-e1ebe52]
[06.04 19:23:53] [Server] at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116) [custom352827.jar:git-Spigot-21fe707-e1ebe52]```
I'm getting this continuely
it's starting normally
And then instanly got a loop
What kind of cursed fork are you running?
How about you ask the maintainer of this sever jar for help...
Looks like they broke spigot.
It’s a funny story or not
They maked me somehow a server jar that run my slimeworldmanager and my spigot
Because they don’t have a functionality for custom startup parameters
id love to know what you are even running
i cant find any of those git hashes in the past few years
oh i think ive found it
all the way back in 2016
so its 1.8.8 that i have a feeling is old old so you should update
1.8.9 does not exist as a server version
1.8.9 is a client only version with protocl compat to 1.8.8 servers
Should i try with 1.8.8?
you are on 1.8.8
But what's the difference
1.8.9 does not exist in spigot
the best advice we can give is update to latest
?1.8 xd
Too old! (Click the link to get the exact time)
I know, it's an old config
That's why
Because i'm sure it will not run the latest version
Because of my plugins are not compatible
with the latest
time to find new plugins then
I still have to add support for 1.8 to some of my plugins because of clients xD
I would tell you to drop em but I know
Some people rate other people's plugins 1 star because they don't support the version they need (1.8 is an example) 💀
fortunately it got less over time
I used api for SQL and lamp api and now plugin size is 13mb and I can't upload what should I do
use the libraries feature in plugin.yml for stuff thats on maven central
- minimize the .jar (both gradle's shadow and maven shade support that)
if that's not enough: - use plugin.yml "libraries" feature if your stuff is on maven central and you're supporting 1.16.5+ only
otherwise - use libby or sth similar
alternatively just upload your plugin to another site (external download)
Good
I also find annoying that bStats require shadowing
tbf it's only like 10kb
10 kb x 100 plugins = 1mb
Though, my main annoyance is that I need to setup the shading plugin every time
1mb is nothing
why would the plugin size matter?
Even if they all were 10mb, who cares
Saving traffic, duh
who doesnt have that on by default
there is not a project that i do not have shadow on
I have some
Where I don't use bStats
The library thing in plugin.yml handles it all
Nah, most of ppl don’t download plugins often I doubt extra MBs for shadow matter.
My server runs on mobile data without a flatrate. Gotta pay per mb :(
You should see how much kids waste TBs of data watching brainrot
Xbox games
NamespacedKey chickenPetKey = new NamespacedKey(CoolPets.getPlugin(CoolPets.class), "chicken_pet_key");
NamespacedKey chickenPetLevelKey = new NamespacedKey(CoolPets.getPlugin(CoolPets.class), "chicken_pet_level_key");
ItemStack chickenPet = new ItemStack(Material.CHICKEN_SPAWN_EGG);
ItemMeta chickenPetMeta = chickenPet.getItemMeta();
chickenPetMeta.getPersistentDataContainer().set(chickenPetKey, PersistentDataType.STRING, getPetId().toString());
chickenPetMeta.getPersistentDataContainer().set(chickenPetLevelKey, PersistentDataType.INTEGER, getPetLevel());
chickenPet.setItemMeta(chickenPetMeta);```
Is this application of pdc correct?
id recommened to cache the keys, and you can use NamespacedKey.fromString("key:value") to make it easier
but the rest looks fine and a correct use of it
flat file prolly fine for that yeah?
by cache the keys i just mean final/static final variable
oh thought you meant like save
its easier to create them in 1 place incase you do ever want to change the key in future
Gotcha
The level however shouldn't be final correct? as I've got a task that'll increment xp every second, level is decided by: (BASE_XP + XP_INCREMENT) * level
Or rather the increment increase per level is decided that way
the values dont matter, just the key
Ah right
I'm dumb
private static final String chickenPetKey = "chicken_pet_key";
private static final String chickenLevelKey = "chicken_pet_level_key";
...
@Override
public ItemStack petItem(){
NamespacedKey chickenKey = new NamespacedKey(CoolPets.getPlugin(CoolPets.class), chickenPetKey);
NamespacedKey levelKey = new NamespacedKey(CoolPets.getPlugin(CoolPets.class), chickenLevelKey);
ItemStack chickenPet = new ItemStack(Material.CHICKEN_SPAWN_EGG);
ItemMeta chickenPetMeta = chickenPet.getItemMeta();
chickenPetMeta.getPersistentDataContainer().set(chickenKey, PersistentDataType.STRING, getPetId().toString());
chickenPetMeta.getPersistentDataContainer().set(levelKey, PersistentDataType.INTEGER, getPetLevel());
chickenPet.setItemMeta(chickenPetMeta);
return chickenPet;
}```
Look fine?
The naming could prolly be better, but if it looks fine that's the goal
why not just store the NamespacedKey?
public static final NamespacedKey CHICKEN_PET_KEY = NamespacedKey.fromString("myplugin:chicken_pet");
Well I thought that too, ig this is just easier
But also it might have been implied and I missed it
Is there a reason you did "myplugin:chicken_pet"?
you can either do "namespace:key_name" (first method) or just use "key_name" and provide the plugin instance (second method)
doesn't really matter
i prefer first one because then you don't need any instance and can just use static final fields without having to dependency inject anything or getting the instance somewhere else
private static final NamespacedKey chickenPetKey = NamespacedKey.fromString("CoolPets:chicken_pet_key");
So this is fine?
Gotcha
hey there, i'm having problem with getPersistentDataContainer method. Basically my ide (Intellij) tells me that this method does not exist for player or itemMeta and refuses to compile the plugin... how can i fix it? i tried changin spigotAPI version in maven file but that didn't really get me anywhere...
this is the code:
public static void WritePlayerPDC(Player player, String key, PersistentDataType type, Object value){
NamespacedKey nKey = new NamespacedKey(MineconomiaCore.getPlugin(MineconomiaCore.class), key);
PersistentDataContainer pdc = player.getPersistentDataContainer();
pdc.set(nKey, type, value);
}
Those are the imports:
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;
The error:
/home/jakub/IdeaProjects/MineconomiaCore/src/main/java/xyz/mineconomia/mineconomiacore/PDC.java:15:49
java: cannot find symbol
symbol: method getPersistentDataContainer()
location: variable player of type org.bukkit.entity.Player
and pom.xml
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
?paste your full pom.xml
my guess is that you're having another dependency that has an old spigot version as transitive dependency which is higher up in your <dependencies>
move your spigot-api to the top of your dependencies
VaultAPI probably comes with an ancient spigot dependency
after that reload maven (the small button in your IJ maven tab)
oh wow that worked! thanks! saved me from a lot of headache. thank for the quick solution
np!
I had a funny instance where my intellij wouldn't recognize maven imports and I thought my maven was corrupted because I moved it around, turns out it was a bug with the intellij version I was using lol. I was contemplating reinstalling everything, so I'm glad I decided to update it.
reminds me of this
eew no
rough
it's an old version of allatori
why is vaultapi even importing spigotapi in the first place?
just vault things
it's a transitive dependency. it's just how maven works. you have two options:
- Move spigot-api up yuorself (as you did)
or - Tell maven that you only need vault, but no transitive dependencies of it (since nobody would use vault without adding spigot-api themselves to pom)
(either using a filter, or simply using <excludes> inside vault's <dependency>
but if you think about it, it only makes sense that adding vault also adds spigot as dependency, how else would you be ever able to use Vault in your project otherwise?
vault could ofc also declare spigot-api to be an <optional> dependency, that'd probably be the best solution
?paste
one of my users is getting the following error and i dont know what to make of it https://paste.md-5.net/yuxebenuqa.txt
for context, they updated from 1.19 to 1.20.4 and then started getting this error
what can cause type to be null during itemstack deserialization
do you use spigots config stuf
it most likely is failing to upgrade the version or smth
well yeah but is there any way i can fix it
or at the least help them remove the error
idk how upgrading works @young knoll might
just updated, let's see now 
I'm encountering a very strange error that I can't solve like..... AT ALL. I'm essentially not being allowed to create any custom events by a null pointer exception that simply doesn't make sense. Everything is instantiated, i've made a dummy function to give my custom event some content (theoretically eliminating any possibility of it being useless and hopefully not 'null')
Error: https://paste.learnspigot.com/epusujapot.php
Custom Event: https://paste.learnspigot.com/asebesaveb.kotlin
Custom Event's Listener: https://paste.learnspigot.com/ucojifewan.kotlin
Main Class: https://paste.learnspigot.com/sexicoreji.kotlin
Does it happen on spigot
Is there a moderetly simple / quick way to switch a project from Paper to Spigot?
