#help-development
1 messages · Page 909 of 1
That way I have fine control over how serialization is made
Same reason I don't just yeet all my stuff into gson and toss it in redis
The byte arrays let me pack stuff in a format that suits it better
Sure it's extra work
Hey, is there a way to redirect player to another bungee server?
[22:56:41 WARN]: [Nerus87] No client connected for pending server!
Yeah just make fallbacks
declaration: package: net.md_5.bungee.api.event, class: ServerConnectEvent
With this code I am trying to check if the (custom) enchantment is compatible with the item, but it doesnt work and still lets uncompatible custom enchantments thru and blocks compatible vanilla enchantments. Why and how to fix?
private Set<Enchantment> getCompatibleEnchantments(ItemStack item, EnchantmentStorageMeta bookMeta) {
Set<Enchantment> compatibleEnchantments = new HashSet<>();
if (bookMeta != null) {
for (Enchantment enchantment : bookMeta.getStoredEnchants().keySet()) {
if (enchantment.canEnchantItem(item) && (customEnchantments.contains(enchantment))) {
compatibleEnchantments.add(enchantment);
}
}
}
return compatibleEnchantments;
}
you sure you're not running old code
I double checked. But still incompatible custom enchantments get put as compatible
xd
how does your custom enchantment's canEnchantItem method look like?
I did some experimenting and with this code it does work sort of, but now vanilla enchants dont go thru:
private Set<Enchantment> getCompatibleEnchantments(ItemStack item, EnchantmentStorageMeta bookMeta) {
Set<Enchantment> compatibleEnchantments = new HashSet<>();
if (bookMeta != null) {
for (Enchantment enchantment : bookMeta.getStoredEnchants().keySet()) {
if (enchantment.canEnchantItem(item) && customEnchantments.contains(enchantment) &&
enchantment.getItemTarget().includes(item.getType())) {
compatibleEnchantments.add(enchantment);
}
}
}
return compatibleEnchantments;
}
I use it for an anvil. Here is that code:
@EventHandler
public void onAnvilPrepare(PrepareAnvilEvent event) {
ItemStack[] contents = event.getInventory().getContents();
if (contents.length < 2) return;
ItemStack slot0 = contents[0];
ItemStack slot1 = contents[1];
if (slot0 != null && slot1 != null) {
if (slot0.getType() == Material.ENCHANTED_BOOK && slot1.getType() == Material.ENCHANTED_BOOK) {
//not important for my problem
System.out.println("ENCHANTED BOOK");
ItemStack result = enchantBook(slot0, slot1);
event.setResult(result);
event.getInventory().setRepairCost(1);
} else if (slot1.getType() == Material.ENCHANTED_BOOK) {
Set<Enchantment> compatibleEnchantments = getCompatibleEnchantments(slot0, (EnchantmentStorageMeta) slot1.getItemMeta());
ItemStack result = applyEnchantments(slot0, compatibleEnchantments);
event.setResult(result);
event.getInventory().setRepairCost(1);
}
}
}
is there a way to make text displays look like the armorstands
without the big background
yeah
https://minecraft.wiki/w/Display check NBT
Display entities are entities useful for map or data pack creators to display various things. There are Block Displays, Item Displays and Text Displays, which are used to display blocks, items and texts respectively. They can be created only with the /summon or /execute summon command.
do as you need
big background? o0
Btw fixed it for people who care. Just created another for loop for vanilla enchantments. based on this
I'm pretty sure there isn't but is there a way to disable full-bright for players? I want to have a gamemode with custom lighting where certain rooms will be brighter and etc. and the darkness of certain rooms will add to the asthetic.
p sure that's client-sided
^^
Apply darkness effect 😈
Apply blindness
or a sus stew with drunk effect
Write core shaders to just make the entire screen black
tell the player they'll get cute anime girlfriend if they dont use fullbright
100% success
Can the client bypass server textures???
I've always wondered
i should make an anticheat using this tactic
Frrrrr
If you have force resource pack set to true they will be kicked if they don’t activate it
But after that there are ways to deactivate it
there are mods to bypass that flag anyway
the client can just tell the server it applied the resource pack when it didn't
I applied the resource pack.
Source: trust me bro
"we trust our client there's no chance anyone would do anything malicious"
I know that the direction of Lily Pad is fixed, but how do I know the direction of Lily Pad at a certain coordinate?
Unfortunately you can't. That's determined by the client
That's what people thought when they invented the internet and its early protocols lol
Probably calculated client side
So you’d have to figure out the math the client does
I believe it's a noise map on the client that determines it
Damn that’s fancy for just lily pad direction
Well it applies to all things that have directional textures. Grass, the stones, sand, etc.
I would have just done some math with the x y z position
It's all randomly rotated
How do you think noise works? 
I mean it could just not be a noise function, given it doesn't really need granularity, but it's calculated on a per-coordinate basis somehow :p
Server just has no reason to know about it
Well, true
I was thinking more just seed a random by combining the XYZ into a long
And then nextInt(4)
Well if we can trust a 3 year old random reddit comment, this is how it's done.
https://www.reddit.com/r/technicalminecraft/comments/l3ub6t/how_is_is_determined_which_direction_a_lily_pad/
Thanks❤️
Aye I was maybe right
did i just waste my time for nothing?
Well no. You can confirm whether it has changed in the past 3 years 
I'd love to, but - https://github.com/ShaneBeeStudios/McDeob/issues/42
where is the decompiled stuff lmao
idk how that works
ah nice. Yeah well the files mentioned in that post don't exist (MathHelper) and I searched for the first number value and that also doesnt occur in the whole .jar (or recaf's search sucks)
probably its the Mth class, let's check that
seems to still be the same
So the search indeed sucks
yes
I like how they just deprecated it but still use it
It's not like they are building a library and have to keep it - they could just replace it.
Instead they kept it and are still using it lol
Yeah it’s interesting that they deprecate things
It’s like they care about us a little bit
not sure if any of these is related to the lilly pads but they definitely use the deprecated method in these classes
I'm sure lily pads are in BedBlock. I love sleeping on lily pads
Custom entities models aren’t that hard
Yet still we don't get support for it
Pfft who needs official support
We have it for items. Why not for entities?
so are those armor stands with specific items equipped that you set a different texture for?
It’s a bunch of display entities
The armor stand is just some visual trickery for the client
Oh so you even modelled the small up and down of their claws?
Like they are moving in itself. Not just walking
I didn’t make the model but yeah
Oh I thought that was you
I see. That's cool though!
Never heard of BlockBench but there are some really cool models lol
Imagine casually mining and when you turn around this guy is behind you lmao
Video Doesnt load for me 😦
https://cdn.discordapp.com/attachments/849481473496580116/1205615381348229230/2024-02-09_15-43-23.mp4?ex=65eb78d2&is=65d903d2&hm=7852a1040d67d9c16aa3579d179aacf8ebba88fc7e6f6e1e74e88371997f3f17&
Does this work for you?
yes thx
damn what kind of creatures are those lol
Crabs
Yeah the unvoted crab
I also have the penguin model
Well, a penguin model
Since the official one was never made
Do you have to animate those models yourself or do they contain animations? No clue how all of that works
They contain them
The screenshot above does have a 3 second video in the website but it does not move at all for me
but maybe this model just doesn't have animations
The crab has walk and idle animations
Death is also supported, still gotta support attack and other ones
and the current animation is kinda ehh too
yeah now
but for years they just ran into you
and "rammed" you to death
Ah
Yeah new mobs have much fancier animations now
I wonder if Mojang will ever update the older ones
I feel like I remember them saying they want to revisit some older mobs
The OG animals and spookies could use some love
I am getting this console error and I need help
This is the GitHub so you can see the classes and their code: https://github.com/Pazore/SpartanHub
?staff
Don't ping staff for development/server help, if you have a question just ask it and someone in the discord will respond when they are capable of helping.
(I'm not staff)
Probably not the case but the usual cause of classloading issues are mostly:
- Replacing the jar while the server is running (classes are only loaded when they need to be loaded, so changing the .jar will cause weird class loading issues)
- Corrupted jar (Probably by uploading before the build finished, just re-build, stop, re-upload and restart)
On a further note, rename your command and listener classes to be a bit more explicit
I tried the 2nd one but didn't work.
Gamemode -> GamemodeCommand type deal
Could changing the plugin name affect that?
yeah ik i am kinda lazu
Your plugin.yml and "main class" name look fine
I'd still suffix it with Plugin (as in SpartanPlugin)
Also another cause for weird issues is shading certian libraries (looking at you, protocollib)
When naming variables, use descriptive, intuitive names
This concept also applies for classes
What do you mean by ProtocolLib?
Like add a dependency & repository? or add the plugin?
ProtocolLib likes to throw class loading issues when you shade it
I don't have ProtocolLib though..
how do I clean package
mvn clean package
in terminal?
or just click the clean and package buttons on your maven tab

?
AWIT
@echo basalt
it worked
I LOVE U SO KMUCHJ
I've spent like all day coding this plguin
or most of it
where the hell did you find that o_o
I was in a call with u when u were coding a minigame plugin for a spanish server
ah
in here
yeah there's been a lot of progress on that network 
Isn't the minigame released now?
it's been like a week no?
minigames
same thing
not really
true
Network released like monday
Minigame != Collection<Minigame>
I've pushed like 2 content updates, cosmetic shop, party system, a whole new game and I'm releasing friends and a new game tomorrow
what is that reaction supposed to mean...
whats the ip
gl
It's whitelisted this weekend so I can actually test stuff without having 100 people nagging on my ear
That’s a weird ip
and also because we're having streamers on monday showcasing the server
nice
Omg is it gonna be dream
and I think monday night I'm gonna have a meeting to develop a new event
mrbreast
I'm starting to feel sick from all the overworking stress and the like 30 minutes of sleep every other day
I’m sure that hasn’t affected code quality at all
sounds like a fan screaming outside jimmy's window
Shame the poor guy is drowning in the ocean
"For the next challenge, we put Frank in a car. But here's the twist: that car is going to be dropped by a crane into this lake."
before you know it Mr Beast will be holding the first official hunger games
Squnger games
squnge
Mr beast should restore o block
So for my plugin I want to have a Interface where when players are creating their empire (team), it displays a minecraft sign that says 'Enter Empire Name:' is there support for anything like that in spigot?
There’s a method to open the sign gui
But I believe it requires an actual sign placed somewhere
just gaslight the client
yeah actually there is a sign placed there and if its asks you just tell it yeah there is a sign there trust me bro
Oh well.
Okay so, I've done some research on my PDC problem and it seems like it's actually coming from itemMeta, here's the post: https://www.spigotmc.org/threads/why-items-with-lots-of-metadata-actually-cause-lag-an-inventoryholder-psa.607711/. So I'm making a prison server and currently getting the itemMeta with its PDC every block, which obviously is a no no. Could I just store the ItemMeta in memory instead then update it every x amount of blocks? What's your thoughts, any opinions on what I should do?
Sorry for the long message 😅
what are you storing in teh PDC that needs to update every block?
Yeah I needa grab values from the PDC and I'm editing one value too
What are you tracking?
Just enchant levels and the blocks broken from the pickaxe
Hey all! Just joined and I am new to the world of plugins and overall minecraft development / commands. I was wondering if there was a plugin that would allow block drops to be 100%. Like if I mine stone with my fist, it will drop the stone etc... If anyone could point me in the right direction that would help me a lot! Thanks
Welcome
Look into listening for the https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/block/BlockBreakEvent.html event
declaration: package: org.bukkit.event.block, class: BlockBreakEvent
" Note: Plugins wanting to simulate a traditional block drop should set the block to air and utilize their own methods for determining what the default drop for the block being broken is and what to do about it, if anything. "
Yeah
Play around with it
I have an idea
Cache it, but update the cache everytime the player swaps or puts on new gear
Okay sweet, I will look into this. Thank you
Yo
How do you guys handle customizable messages via a config file (e.g. warning message to the player) to allow customizable RGB colors?
in the past I've used a new yml key for each phrase, with a string value consiting of (r, g, b) and then parse it
but that just seems so error prone
You can use §x
for legacy text
#RRGGBB is §x§R§R§G§G§B§B
but this is incredibly cumbersome
right so maybe the seperate key isnt such a bad idea
seperate key only allows one color though then again
You may want to look into Adventure's serialization
and simply store your translation values as those
what to do if the event is triggered twice, which leads to an error java public static void injectNetty(final Player player, NPCManager manager) { try { Channel channel = (Channel) channelField .get(((CraftPlayer) player).getHandle().playerConnection.networkManager); if (channel != null) { channel.pipeline().addAfter("decoder", "npc_interact", new MessageToMessageDecoder<Packet>() { @Override protected void decode(ChannelHandlerContext chc, Packet packet, List<Object> out) throws Exception { if (packet instanceof PacketPlayInUseEntity) { PacketPlayInUseEntity usePacket = (PacketPlayInUseEntity) packet; if (usePacket.a() == PacketPlayInUseEntity.EnumEntityUseAction.INTERACT) { int entityId = (int) idField.get(usePacket); if (manager.getNpc(entityId) != null) { Bukkit.getPluginManager() .callEvent(new PlayerInteractNPCEvent(player)); } } } out.add(packet); } }); } } catch (Exception e) { e.printStackTrace(); } }
PacketPlayInUseEntity trigerred twice
that is a lot of indentation
can you maybe use guard clauses
and make this not so illegible thanks
Damn
{ { { { { {
you must have a lisp
.<<.+>>>>>.<<<
terminally ill
And you my friend, are brain fucked
hi how does the distanceSquared work?
if i want to check if there are armorstands in the specfic space
for example 20 block distance
i tried but it does not work ?
so 400?
yep
distance squared is literally distance squared
if you have 2 points (S) you can easily check if P(x,y,z) \in S
I still don't know what this means...
Hi , is there any event for when player fully connected and joined on the server ?
How so
it tells you the formula
It is your job to implement and integrate it
Maybe I wrote the program wrong...but I got different results, I'll check again...I'm currently working on the bamboo offset, will come back later
my code
public static long hashCode(int x, int y, int z) {
long l = (long)(x * 3129871) ^ (long)z * 116129781L ^ (long)y;
l = l * l * 42317861L + l * 11L;
return l >> 16;
}
public static void LilypadFilter(Location location) {
Random random = new Random(hashCode((int) location.getX(), (int) location.getY(), (int) location.getZ()));
Log.info("Type of LilyPad: " + Math.abs(random.nextLong() % 4));
}
I think the last number output should represent its direction, but I found that the output in the same direction outputs different numbers.
What are you trying to do?
nothing this problem was sloved
What did you use?
runtasklater
Sounds like there might be a cleaner solution.
-> What are you trying to do?
nothing i just tried to run a event when after much sec of player joined on the server
When dealing with NMS would there be any differences in using 1.20 vs 1.20.4??
Yes
I don’t understand why though can you help me understand? It seems like there would be no significant change? Is it because when it compiles it compiles the ENTIRE thing?
but i got new problem i am working and testing about Bukkit.dispatchCommand but when i writed Bukkit.dispatchCommand(Bukkit.getConsoleSender(),"whitelist add '"event.getPlayer().getName()+"'"); , i can't get name of player without ' ' for example my name will be 'im_omid' but i don't want this
Well its simple. In 1.20.4 they added code. This means there is a small difference because you have more methods and changed behavior for some methods.
What is your concern? Asking if there is any difference between nms versions sounds like a trivial question, because increasing the version means the game changed.
Do you want to know if nms written for 1.20 is compatible with 1.20.4 ?
Yes! And further, if I want to use Nms code is there anyway I can make it compatible for future use?
Dont dispatch commands. You are a developer. Write code and add players to the whitelist this way.
i know whitelist is a example
and i said this is just testing i want get player name and run a command from other plugins
oh , i sloved
xD , i forgot +
I see. The package structure for nms changed quite a bit and got a lot more consistent. This means that there is a very decent chance that your
1.20 code will run for all versions through 1.20.4
Writing future proof code requires a consistent api layer. This is the main reason why spigot was created -> To write future proof code that will
run for later versions of the game.
There is no way to guarantee nms compatability for future versions because mojang constantly changes their structure and code.
Unbiased opinion please, I’m watching a video that’s 2 years old that said at the time it seemed like devs were trying to make a push to use Mojang mappings rather than spigot because they seemed to be getting better at establishing names for methods, at the current time has there been any change or what should I try first spigot or mojang mappings?
spigot doesn't have mappings for methods (or all class members really) at all anymore, use mojang's
Spigot mappings dont exist anymore (since 1.17 i think)
100% use mojang mappings
Why did spigot stop?
Because mojang released their mappings
Ahhh sweet so it’s easier now?
Yes you now have the original names for classes, methods etc
Reading NMS is quite nice now.
?nms
Thanks bro 😎
Now that that’s established I need to go learn what the word ‘static’ means in Java! (I have no clue what I’m doing)
lul
I would urge you not to touch nms in that case. Working with it can get really complicated and messy, and is often
redundant because the spigot API has grown quite a bit.
Ye but it’s so insightful 😞 I feel like I know why stuffs happening it’s not just spawning out of thin air because spigot said it would
It doesn't??? It does the same thing just at a higher level
No need to use NMS, especially if you don't know java
I dont know which level you are talking about, but its technically a lower level (when speaking about the abstraction layers)
alternative to playerchattabcompleteevent?
Register a tab completer for your command
no i want it in chat
Ah
hey,
How do i add a trim to my armor on craft?
ItemMeta itemMeta = item.getItemMeta();
NamespacedKey key = new NamespacedKey("emeraldtools", "trim");
itemMeta.getPersistentDataContainer().set(
key, // Use the created NamespacedKey
PersistentDataType.STRING,
"{\"material\":\"minecraft:emerald\",\"pattern\":\"minecraft:eye\"}"
);
item.setItemMeta(itemMeta);
this just sets the NBT but doesnt actually add the trim to the armor
google doesnt tell me that much about this tbh
declaration: package: org.bukkit.inventory.meta.trim
declaration: package: org.bukkit.inventory.meta, interface: ArmorMeta
- Get ItemMeta
- Cast to ArmorMeta
- Create an instance of ArmorTrim
- Call ArmorMeta.setTrim(ArmorTrim)
- Apply ItemMeta back on ItemStack
ItemMeta itemMeta = item.getItemMeta();
ArmorTrim ArmorMeta = (ArmorTrim) item.getItemMeta();
ArmorTrim ArmorTrim = new ArmorTrim(TrimMaterial.EMERALD, TrimPattern.EYE);
item.setItemMeta(itemMeta);
but when doing ArmorMeta.setTrim (does not exist)
r u on some old version?
1.20.4
Naming convention pls:
ItemMeta itemMeta = item.getItemMeta();
ArmorMeta armorMeta = (ArmorMeta) item.getItemMeta();
ArmorTrim armorTrim = new ArmorTrim(TrimMaterial.EMERALD, TrimPattern.EYE);
armorMeta.setTrim(armorTrim);
item.setItemMeta(itemMeta);
*You are casting the ItemMeta to ArmorTrim and not ArmorMeta
any ideas (i want to add tabcompletions to ingame chat, not commands)?
I think this completion is client side
it was possible with the event previously :(
adding fake players in tab might work? I'm not sure if there's other ways to do it
tabcompletion is something else than the tab list
The client auto completes with names from the player list. I think that what he is referring to.
Still need help, the solution above doesn't seem right
public static long hashCode(int x, int y, int z) {
long l = (long)(x * 3129871) ^ (long)z * 116129781L ^ (long)y;
l = l * l * 42317861L + l * 11L;
return l >> 16;
}
public static void LilypadFilter(Location location) {
Random random = new Random(hashCode((int) location.getX(), (int) location.getY(), (int) location.getZ()));
Log.info("Type of LilyPad: " + Math.abs(random.nextLong() % 4));
}
afaik tab completion (without commands) is fully client-sided where it gets the completions from the server's player and the only way to modify it is by modifying the tab players adding fake that they'd be added to the tab completion and vice versa
can i add fake players that are invisible in the tab list but still have a name?
You wont get consistent results when generating random numbers like that, even with a seed.
Try printing:
long hash = hashCode(location.getBlockX(), location.getBlockY(), Location.getBlockZ());
int type = Math.abs(hash % 4);
Log.info("Type of LilyPad: " + type);
Thank you, trying it now
Got results that I can't interpret
The number obtained does not match the direction
In that case you need to dig through the client code and check how they render the lily pads
The rotation might also be completely different for some clients
why does stringbuilder always tell me that i can use string instead of the builder, isnt using + on strings bad practice as its much slower than the stringbuilder?
Only if you are constantly allocating new Strings by appending values.
In a loop for example. If you are just building the String directly, then there is no real diff in performance.
im using + 5x, isnt that appending it a lot? or do i misunderstnad what happens internally?
oh i misread, if i create it directly is fine, but if i add it everytime a bit more in a loop it ends up being bad
^
okay thanks
`
i don't think that's possible? to hide fake player you need to remove it from the tab and at the same time you have to keep it for the auto completion
okay
what to do with the situation when an implementation accepts the interface of another implementation but not the implementation itself, this is a hindrance
the interfaces themselves are only needed in the manager class
what
For example craftBukkit objects work with each other but not with their api and therefore it does not affect the api in any way.
A more precise question is what to do with the situation when an implementation with an interface accepts another interface of another implementation, but not the implementation of this interface itself, it interferes with it
interfaces themselves are needed only in the manager class
void addMenuItem(MenuItem menuItem); -
I need to translate this interface into an implementation.
you want to change the parameter to implementation instead of interface?..
yes
public interface MenuItem<T extends MenuItem<T>> {
void doSth(T menuItem);
}
class GuiItem implements MenuItem<GuiItem> {
@Override
public void doSth(GuiItem menuItem) {
// ...
}
}
use generics
+++++++++++++++++++++++++++
I'm using RaidTriggerEvent, RaidFinishEvent and RaidSpawnWaveEvent to track for raids but in all of them, it seems like event.getRaid().getBadOmenLevel() always returns 0 while it shouldn't, is it normal?
It seems that sea pickle also has this problem😓
Hi i'm using spigot 1.17.1 and to kill a entity i use entity,setHealth(0) how can i set a killer to the entity ? because EntityDeathEvent.getEntity().getKiller() is null
without using entity.damage(...) pls
Why tho
because 😉
v
That's not a reason
give a valid reason not to use it
i don't need a reason
because 😉
Then we don't need to help
Then we don;'t waste our time
good luck then
iirc this was taken from the last damage source. Try setting it before killing the mob.
We have?
bro says just answer my question after refusing to answer our question
A reason is actually of high importance because it lets us prevent you from shooting yourself in the knee as we can infer xy problems from your reasoning.
you always need to know why we do this to judge us, I'm not going to explain everything to you about how my plugin works anyway
We don't judge, we just say how to do it better
I had a simple question no need to go further
We can't help you do something if we don't know what you are doing and how you are doing it
Anyways you have an approach. Try that and tell me if it works.
Most of the time questions with conditions like this are an xy problem of somebody doing a thing the wrong way
because i'm not using the minecraft health system for my mob
ok thank
no need for reflection. getkiller() returns the NMS entity's lastHurtByPlayer field, which is public and can be easily changed to any EntityHuman
not to judge but in 99% of cases there's an easier solution when people ask for workarounds instead of their original problem
?xy
Alternatively you can always start tracking the last damage source by adding the damager and a timestamp to the entities PDC.
This only works if you dont rely on other plugins receiving the damager.
Would it work to do this before setting health to 0?
Did you know you can try it and see
setLastDamager? where is that supposed to be from?
or are those obfuscated/spigot mappings/ancient version?
ah
1.20.4 doesnt have such a method
there's only lastHurtByPlayer and lastHurtByMob
ah I've never tried the new versions yet
Hi , how to write api-version that every version will be support ?
1.13
Not exactly, sometimes completions are sent iirc
I don't remember when
In 1.13 it was. But for newer versions there is nothing being sent anymore.
But feel free to bombard the client with this.
I meant more like the client used to send the chat string to the server
I'm so confused right now, I will be able to force a client to connect to another bungeecord server by using my plugin with ServerConnectEvent?
The fallback server is like a lobby server or it can be a bungeecord?
Bungeecord is just a proxy that routes packets around. It actually has not much to do with minecraft itself.
yes, but my question is can I somehow redirect/reconnect (not forward) client to another BC server?
force user to use another BC
Thats not possible. What you can do is cascade bungeecord servers, where one bc server connects to N other bc servers which in their turn connect to M minecraft servers each.
But this structure is almost never viable.
I guess from the BC source code it is possible but needs some implementation on net layer.
So I can only request for this feature.
transfer packet in 1.20.5 
you mean next release can have this feature, but still is only transfer package
I mean that's exactly what you want?
guys, how do you edit a spigot resource? i don't find the option 💀
no no, edit
then bottom of the page
only report i see
nope, my BC#1 is used with TCPShield so client is using tunnel to reach my server.
I'm using it to register clients IPs on my router - whitelist with some timeout (prevent from DDoS attacks and port scanners).
Then client have open port for direct connection, so client needs to be redirected (close current connection and open) to another IP address (DNS name).
are you logged in?
yea
that is indeed weird
lol
you should move your question to #general
and how does the transfer packet not help you there? you're telling it to re-connect to x.y.z instead
Either that or come up with your own solution on top of that, because the client can only go through the login process once, so you can't "just" move it between servers/proxies without shitting the bed
is there a way to catch the time when player gets knockback from a hit? I mean there is an entitydamagebyentity but it calls every time players gets attacked, however he is taking kb less times than being attacked, so it's not really accurate
There’s EntityKnockbackEvent on latest
dont blame me plz 🙏 is there anything similar for 1.8?
Nope
I don't want to move clients with their connection between servers, I wish only to drop the current one and open it to another server and it's fine for me if client is validated again.
I can just force the client to drop the connection with some message: please connect manually to another server, but I wish to do it automatically.
I don’t think you can without transfer packets
You can’t tell the client what to connect to
that is quite literally what the transfer packet does lol
Yeah
but still, the connection will be the same, what do I mean by packages going through BC1 to BC2 to the Spigot server or do I miss the concept?
or it will be just migrate packages, close connection on BC1 and open BC2
Transfer packet is literally "client, close your current server connection and open a new one to this IP/domain"
Cool
so client will be connected from tifferen IP seen by my router
not from tunnel IP but from raw IP
well, the client's IP won't really change, the port will
the client will connect to a different IP
if that changes the final address seen from your router then sure I guess?
to clarify I'm using TCPShield for BC1 so every connection visible on this port is the same for me (all of the clients have the same IP address but different client ports so it's fine), for BC2 you will need to connect to another/different public IP (it will be not from TCPShield endpoint) so In this case I will see real client IP (on router side).
is there any website to see mojang mappings for clientside classes?
makes sense
Compare different mappings with this website: https://mappings.cephx.dev
No just server
No nmc
Is there a reason bukkit still has the weird world formatting other than age
Coll ghosting me truly sad
world formatting?
Meant how theirs a dif folder for every level
Overworld neather
End etc
plugin compatibility? :^)
great thanks guys @slender elbow @lost matrix @young knoll for fats feedback, waiting for new feature, currently clients need to connect manually to the server.
Hi , how to edit my resource on spigot ? i uploaded i want change the direct link
Per world gamerules maybe?
cancel the entitydamage event and make your own knockback
You have to have 2fa enabled
If you do press the edit button it's by the report button
hello
hello
there is any "source code analyzer" that you guys use or suggest ?
to Improve software quality, maintainability, security, and compliance by identifying issues early in development
Static analysis that checks source code detecting bugs, vulnerabilities, complexity, duplication and most importantly unnecessary abstraction, etc
i have SonarQube in my mind but i dont know how it work for spigot and thats why i asked to see what everyone use
Nah that shit is stupid IMHO. If you wanna use it at all just use SonarQube
i mean why not ? maybe analyzer can see something that i can't see, but yeh i probably just gonna use SonarQube
You're code doesn't need to be perfect DRY isn't always necessary if you repeat something once or twice it's fine. The only thing that'd be semi useful is looking for vulnerabilities but you shouldn't be exposing much in an MC plugin that such an analyzer would beable to spot
so im new to plugin development, currently trying to make a simple plugin that removes 2 max hp from a player when they die until they're left with only 2. i seem to be able to build this and the plugin starts normally in the server but the playerdeathevent is never called, am i doing something wrong?
public void onPlayerDeath(PlayerDeathEvent playerDied){
Player player = playerDied.getEntity();
AttributeInstance maxHPAttr = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
if (maxHPAttr != null){
double maxHP = maxHPAttr.getBaseValue();
System.out.println(maxHP + " HP");
if(maxHP > 2){
double newMaxHP = maxHP - 2;
System.out.println(newMaxHP + " HP");
maxHPAttr.setBaseValue(newMaxHP);
if (player.getHealth() > newMaxHP) {
player.setHealth(newMaxHP);
}
}
}
}```
did you register the event?
what does registering an event means in this context
That you registered the Listener that contains the EventHandler method
getServer().getPluginManager().registerEvents(new Listener(), this);
this bassically
@Override
public void onEnable() {
// Plugin startup logic
System.out.println("Dark Rejuvenation Started!");
}
@Override
public void onDisable() {
// Plugin shutdown logic
System.out.println("Dark Rejuvenation Stopped!");
}
@EventHandler
public void onPlayerDeath(PlayerDeathEvent playerDied){
Player player = playerDied.getEntity();
AttributeInstance maxHPAttr = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
if (maxHPAttr != null){
double maxHP = maxHPAttr.getBaseValue();
System.out.println(maxHP + " HP");
if(maxHP > 2){
double newMaxHP = maxHP - 2;
System.out.println(newMaxHP + " HP");
maxHPAttr.setBaseValue(newMaxHP);
if (player.getHealth() > newMaxHP) {
player.setHealth(newMaxHP);
}
}
}
}
}```
So implementing the listener like this is not enough?
i thought main class was automatically registered as listener but i guess not
add this in onenable
since the listener is abstract it cant be instantiated
it gets registered as command executor for all commands, but not as listener
ah right. got those switched up then
Does someone know which Event is used in order to detect if a player hit a Minecart / Boat?
Well yeah you left clicked it
I don't really mind if it is breaking it as long as I can cancel it x)
Ah thank you :)
I think it’s EntityDamageByEntityEvent but I’m not sure it works with boats
and then maybe you can get if the hit entity is instanceof boat/minecart and the damage dealer is a player
Thanks but it seems the event that CMarco mentioned is the correct one as Boats and Minecarts seem to be implementing Vehicle
yeah I found it too now nevermind
VechileDamageEvent is a thing apparently
Yeah I didn't know about that either up until now x)
Hi , anyone can write a code that add a string in list (array) of config.yml ?
i don't know how to write this
i used list.add but didn't work for me
will my command work but didn't add anything on my list
Hey, would it make sense to e.g make my own like format for it so I can basically do:
{
Name: apple
Lore: healthy and tasty
}
Instead of relying on other such
Sorry if I said it bad my English is not the best
I can explain more in detail if needed
W pfp
Looks like a Location with extra steps and sadly not usable as well
to be honest, don't really like that guy. if he's real, he's omnipotently watching my every single move and that's enough to make me very uncomfortable >:(
hello i was trying to make a custom mob, but i get the error "Class 'Bob' must either be declared abstract or implement abstract method 'isBaby()' in 'Zombie'"
public class Bob extends Zombie {
}```
if i implement the methods i get the error: "No interface expected here"
has anyone made custom mobs in 1.20 and know how to fix this?
Which Zombie did you import?
org.bukkit.entity.Zombie
no others show up
This is just an empty hull. You cant create custom mob implementations with Spigot.
You would need to use NMS for that.
oh
What are you trying to do?
trying to add a custom mob entity thing
What about the mob should be customized?
i know i could create a zombie then set its health
and displayname
would be cooler with a class thing

What
I would recommend to use the spigot api and gather some more experience with plugin development.
Custom nms implementations are rarely useful.
i got a little confused i was watching a tutorial
https://pastes.dev/GF1PgS53aK please help me, for a long time I can't figure out how to return the main scoreboard after it was replaced by another one, after the disappearance of the "other" scoreboard, for example, when I entered the mini-game with other scoreboard and quit
return;
}``` in setupScoreboard does not work as expected
That is never going to be true
That's the fun of coding. You get confused and keep trying
what reference?
^, I think you'd have to get the scoreboard created for that minigame, which should already exist by definition of a minigame server, so you should just be able to grab the exisiting one and modify no?
When a player rejoins your logic then should be something like. Player.setScoreboard(game.getScoreboard())
Not to mention, allows you to handle all scoreboards from a single helper method / class (I'd probably use a class since you're doing minigames)
or, as each game has its own scoreboard, just have the game.add method set the players scoreboard
so i can remove p.setScoreboard(board); from setupScoreboard
That would be even simpler tbf
in setupScoreboard, I just need to create an instance?
This is how you'd define any new instance of a scoreboard you'd want
well it doesn't have to be new either
It could already be exisiting as well
Yes, it shoudl do as it's name implies
I'd also better create a hashmap of scoreboards for each player?
why would a player have multiple?
Yeah that sounds like you'll run into issues removing/adding scoreboards... plus only one should be assigned when a minigame starts right?
The scoreboard belongs to teh Game, not the player
well, the scoreboards are different, for example, they have a different position, balance and biome for each player
The scoreboard should relate information based on the minigame, not the player... though I'm sure you can implement some cool stuff with player locations / biomes or wtv
if you are creating a personal scoreboard for each player in teh game, then store them in a Map in teh Game object <UUID, Scoreboard>
im talking about main scoreboard, not minigame scoreboard
what?
Main has nothign to do with the Game
and main is always accessible through getMainScoreboard()
If you want to modify the scoreboard that you consider "main" which I assume is the one for players outside of any minigame correct? Just do so by creating the instance of the "main" scoreboard and modify accordingly
Or that's available so just use that
I don't quite understand what getmainscoreboard does, I thought it gets the player main(current) scoreboard, but then why is it called from the scoreboardmanager and not from the player
no, it gets teh Main Scoreboard. The default one
Players dont own scoreboards. They can be added to scoreboards as a viewer. Multiple players can all have the same scoreboard.
"Scoreboard" is not a player defined object. It's a piece of of the server host if you will, when it comes down to custom scoreboards, you'll have to create a new one or use the default one that comes with the "minigame" server, there's no reason to be creating a new scoreboard then basically masking the default one when you could have just saved time modifying the default one.
default one? that is, an empty scoreboard or I did not understand again
Is there any way to recreate the flinch effect when a player is damaged?
Y2K_ is typing...
I'm cancelling the damage event, but I still want the flinch effect to occur
The Main scoreboard will be empty, if you have not put anything in it
Custom velocity manipulation on player damage event...?
Beyond that, I have no clue lol
if I use getmainscoreboard in setupscoreboard method and compare in updateScoreboard the player's scoreboard with getmainscoreboard, I will compare the player's scoreboard with the scoreboard of the player who defined it in setupScoreboard?
There is ONE Main scoreboard.
There is only ever ONE Main scoreboard
You can create other scoreboards, but they are never the Main
As we keep saying, the scoreboard is not a player defined object
The main scoreboard is what automically gets inplemented for you when you start your server up. If you want to create a new scoreboard then you can though it's unwise when you can just modify the "main" scoreboard and save extra work
For each scoreboard you have, should relate the amount of minigames you have. ie: 5 games : 5 default scoreboards (which you can modify accordingly)
is there any good for debugging plugins
which would print me client branding of the joined client
solved 
clientdetector, hackedserver doesnt seem to work at all with fabric at least
What did you do
I don't think fabric sends the client brand
is it possible to have for example a custom item with the material of a dragon egg but the behavior of a potion you can consume? or are these 2 always linked no matter what
The client decides if the item is suitable for consumption. So you would need a resourcepack for that.
That event is called any time an entity incurs damage
Any cause, any entity
The fact of the matter is that, the entity has to be "damaged"
yea but when player dies of any cause like fall it is considered damage right?
like potion effect cause
just to be clear xd
No worries lol, it's triggered by literally any damage cause on any entity
k thanks
yes
EntityDamageEvent triggers even if the resulting health would be less than 0
k
https://pastes.dev/J24JvEG9WD now my scoreboard is constantly displayed, how can I now give way to other scoreboards
hello
how can i do like an infinite chest?
Like lets say i open a chest, take some items and close it
and when i open it again, the items i took are there but also in my inv?
do i make myself clear?
create a list of the items you want in the chest and when the event for the chest getting opened happens populate the chest with that list
then use pdc or some other identifier to check if people are opening that chest
hmm
like, yeah its possible
but i mean, where does minecraft store this chest info?
like, ItemStack and its name and stuff are in ItemMeta
like, Chest interface has smth?
it doesnt
What would be the event for when an entity in a chunk loads
?jd-s
Ok its
EntitiesLoadEvent
I didnt find it earlier cause I searched with Entity
and not Entities
Also is there a specific event for nametagging a mob or is it just PlayerInteractEvent
if I do p.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard()); to remove the scoreboard for player, I can check that the player does not view any scoreboards if (p.getScoreboard().equals(mainScoreboard)){ ?
in the chunk data
actually it stores it my in my SQL database. Not just the chests for my world either the chests for every minecraft world
how do i get showplayer method working on offline players
or can i still use it on playerquitevent?
this might seem a dumb question
but how does gradle
keep the daemon process running
after finishing a task?
doesnt the program exit afterwards since you can input anything after it?
if it creates new process with a daemon then how does it keep track when to quit the daemon process running
im coding duels plugin and i need it for spectating system
no i dont want to spawn a fake player
im doing something like
/spectate playerwhoisinduel
and im hiding the command executor from playerwhoisinduel
but in case playerwhoisinduel quits the server
i need to unhide the player
have you tested to see if the hidden players stay hidden even when they log back in because I somehow doubt that's how the api did it
how do i check that without testing
You can read the code
but that will take longer than just testing it
where
meh
?stash
CraftPlayer
nvm ill just test it lol
looks about right
why would you have hundreds of public static final fields
that point to the same boolean value
in that case just use a goddamn false
what magic values, how is having 100 lines of the same false boolean variable is worse than one false
no like lets say these constants are passed around
if the value of a constant x is changed, obv u want it changed everywhere, where x is used
so im running this in PlayerJoinEvent but it keeps giving me a normal world. any ideas?
Bukkit.createWorld(new WorldCreator("mine-" + uuid.toString()).generator(new VoidGenerator())
...
public class VoidGenerator extends ChunkGenerator {
@Override
public Location getFixedSpawnLocation(World world, Random random) {
return new Location(world, 0, 100, 0);
}
}
/**
* Shared global constants.
*
* <p><strong>Note:</strong> The majority of the fields within this class are {@code public static final} with constant expressions (constants), and are inlined by the Java compiler at all places which reference these constant fields. Therefore, changing the value of these constant fields will have no effect on already compiled code.</p>
*
* <p>In addition, it is presumed that a large portion of these constant fields (such as those prefixed with {@code DEBUG_} are used as 'flags', for manually toggling code meant for use by Mojang developers in debugging. Therefore, optimizing compilers (which include the Java compiler) may omit the code hidden behind disabled flags, and will result in these flags having no apparent use in the code (when in reality, the optimizing compiler has removed the code which uses them).</p>
*
* @see <a href="https://docs.oracle.com/javase/specs/jls/se16/html/jls-15.html#jls-15.29">The Java® Language Specification, Java SE 16 Edition, § 15.29. "Constant Expressions"</a>
* @see <a href="https://docs.oracle.com/javase/specs/jls/se16/html/jls-14.html#jls-14.22">The Java® Language Specification, Java SE 16 Edition, § 14.22. "Unreachable Statements"</a>
*/
public class SharedConstants {
@mortal hare ^
so these are basically debug mode switches
some are
or well
most of them yes
there is also some readability ones
like
TICKS_PER_SECOND
which I assume they use instead of the magic value (20)
I'm creating a server using resource packs and animated java to replicate things you would usually need mods for, how would i handle things like custom fluids and possibly gases like in Mekanism on the server side, for example i need a block to have an amount of fluid value associated with it
does somebody know how i can create callbacks with redis?
yes when i pub sub something and then i wait for it to pub sub back
and then use the data
yes
i alr have a system that kinda does the same it's really ugly tho
i can give u the general idea tho
for a server
u want to spin up a read thread
that just polls data
and then a write thread probably
that sends the data
and then define a protocol over it
mainly like, server to proxy, proxy to server, server to server etc
i currently have packets, i can send them as whole classes, my current approach needs anonymous classes tho, but kryo doesnt understand how to serialize them
do you know if i can change something so kryo can serialize them properly?
^
I mean I doubt ud wna send over an entire serialized class through redis
i do that and its perfect as the classes are known on the other side and therefore code can be executed in them
redisson 
anonymous classes dont handle well tho
ugh
Yes, you mean callbacks on a topic?
this approach sounds extremely ugly
it is not, its beautiful :)
cant u do it like minecraft
what does minecraft do
Redisson has remote procedure calls (RPCs) btw. Let me get you the link.
have u ever worked w mc packets?
why isnt having the packets as a class cool tho
https://github.com/redisson/redisson/wiki/9.-distributed-services
This is a better alternative to callbacks
if both sides know the code in there
but if both sides know the code in there, there is no need to serialize the entire class and send it over lol
idk know what kryo does
it does its thing i suppose
^
idk what u are really doing either tbh lol
but well
?paste
You mean visuals or implementation details?
anonymous classes did bad stuff to me
i can do visuals with resource pack but what im asking is whats the best way to store additional data in blocks
then i create new classes for every single interaction the server has with another server, that would end in a big unreadable mess
i mean there got to be other ways u can solve the problem without anonymous classes
If they are tile states, then you can use their PDC
Otherwise you need to create custom pdcs
?blockpdc
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
cuz anonymous classes, admittedly, are a big issue in serialization
it works without anonymous classes, but its just not clean
anonymous classes are not clean
i have this weird bug
so you think a ForwardedFindPlayerPacketThenMessagePacket is clean?
sounds better
the teleport code gets executed before duels.spectators.put
cuz then u're giving it a name
why?
and it has a type
it ends up being a big mess with creating classes
let me show u minecrafts packets
in vc?
It cant be executed earlier. Thats physically impossible.
i know, but the FindPlayerPacket and MessagePacket are two that exist, i'd need to combine them tho
for one u get to be able to pass that class to a generic type parameter
and second that class now becomes mockable
the uuids are same
and a visual, explicit component to ur system
moreover, that anonymous class isnt saving u any extra space, its still gonna be its own file at the end of the day pretty much
like once compiled
Looks perfectly fine to me. The code does exactly what i expect it to do.
ah i had to teleport the player first and then put the uuid
man im so fucking dumb
i was trying to figure out why my mixin didnt work
only to realize that i forgot to register it in fabricmod.mixins.json
u dont have the qol plugin?
it yells at u when ur mixin is missing from the mixins.json
is there such in vscode
im using vscodium instead of intellij
just to force myself to use CLI tu build things
with gradle
Is there a way to execute actions on an entity when it is being loaded? I want to remove any ArmorStands with specific scoreboard tags when they are loaded. I know I can simply create an infinite loop to check for each ArmorStand in every loaded world, but that would have a impact on performance
just do it when the plugin is enabled
What if these ArmorStands aren't already loaded at the time your plugin is enabled, yet players encounter them later upon loading their chunks?
yeah that works
alr thank you, i have another question
How can I check if the server has crashed? For example, when enabling a plugin, how can I determine if the last server shutdown was due to a crash or not?
you dont
i know i can just make log for enable and disable but i just wanna know if there is any better way to do it
you cant check if a shutdown was a crash or not
if server crash onDisable method will be called ?
yeah
You may be able to check if worlds were closed correctly
How do you check if there is a block above the player? This is my current code, but it doesnt work:
public boolean isBlockAbove(Player player) {
Location playerLocation = player.getLocation();
Location blockAboveLocation = playerLocation.clone().add(0, 0.2, 0);
Block blockAbove = blockAboveLocation.getBlock();
if (blockAbove.getType().name().endsWith("AIR"))
return false;
return true;
}
what ? are you sure what if power goes down or you just shotdown the computer that server is running on
Location playerLocation = player.getLocation();
Location blockAboveLocation = playerLocation.add(0, 1, 0);
Block blockAbove = blockAboveLocation.getBlock();
return blockAbove.getType() != Material.AIR
}``` that should work
you can check when it shuts down
but u cant check if that shutdown was a crash
a crash meaning server gets too overloaded that it cant handle it anymore and just crashes, if u mean crashes like just shutdown then then you can check the latest log's date in logs
also some crashes have a message at the end of the logs but i dont remember the message, u can check that as well
so there is no scenario where the onDisable method is not called
Well unless something else kills it
I mean if the jvm crashes entirely
that prob wont happen
it only happens when you do it manually
not necessarily ? 🤔
Nope doesnt work.
send full code
yeh and thats exactly why im askin what if power goes down what if vm crash what if that server is running inside docker and that docker instance crash there is infinite possibilities i dont know how you are there is no cenario
oh
its ran on a local pc
then yeah there r some scenarios where it doesnt call onDisable
alright thank you guys, i probably just gonna make a logger for onEnable and onDisable
But how will it know its a crash
that gives me an idea, make onDisable log "Closing.."
/stop calls ondisable
and when the server starts make it check if the latest log contains that specific log
if it doesnt then it crashed
i save every on disable and on enable on a text file and when there is two on enable after each other i know on disable didnt called
sure.
The bug I want to fix is that the player is put into flight mode when trying to double jump with a block above their head
oh wait
?
(The system log keeps saying false. Even with block above head. That was my check)
System.out.println("Block Above Player: " + isBlockAbove(player));```
you're printing isBlockAbove(player) in a !isBlockAbove(player)
so it'll always be false
put the printing outside
Nope. I now made it like this:
System.out.println("Block Above Player: " + isBlockAbove(player));
if (!isBlockAbove(player) || !isOnVineOrLadder(player)) {
And still false
How about you test and print the block instead of a boolean
false false false means nothing
ok
try return !block.isEmpty() && block.getType() != Material.AIR && block.isSold();
this will work
The first two checks are already included within isSolid(), and your first and second check are basically the same thing
Returns air every time
Nope still returns false
Make sure you add api-version to your plugin.yml if you use a modern version
api-version: '1.20'
I use the Minecraft Coding Plugin for intellij so it does it automaticly
Try to add 2 blocks at the y axis instead of 1
Nice
how do i make the plugin build into a specific file
Found another bug. If i stand on the edge it wil be false, but still bump my head :/
Check by 2 edges of the hitbox.
if either edge hits something, player has smth above them.
This can be helpful for that https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/Entity.html#getBoundingBox()
declaration: package: org.bukkit.entity, interface: Entity
pls
In intellij: File -> Project Structure -> Artifacts -> + icon -> JAR> -> From modles with dependencies -> Just press ok -> Change output directory to wehre you want to build too -> apply and ok. Then from build press artifact and then build
oh yeah
im dumb
i want to not have to change the jar every time and just build it then reload the server
Thank you. Fixed it
i know there is a way i just forget how to do it
In intellij: File -> Project Structure -> Artifacts -> + icon -> JAR> -> From modles with dependencies -> Just press ok -> Change output directory to wehre you want to build too -> apply and ok. Then from build press artifact and then build
In this episode of the Spigot series, I show you how to create a new plugin without having to use the Minecraft Development IntelliJ plugin. #minecraft #plugins #tutorial
An easier way: https://www.youtube.com/watch?v=dem7dujCDvg
SpigotAPI Download: https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/
Join th...
And then the building and compiling part
Nice xd
Here is my code. There is a bug that when you jump and right when you are about to hit the ground press double space(double jump) then you get put into fly mode. And i cant figure out why
Hey how do i turn off the built-in reload command. i need to get rid of it so i can use protocoLIB
reload breaks Plib?
Not the last I checked
so what do i do
Use a permission plugin like luckperms and deny the bukkit.command.reload permission
I believe that’s the perm
ty letme try
okay im running the plugin. where do i find the perm. is it in config file? i cant fine it
/lp editor is the easiest way
mvn package is usually what used to compile a maven project to a jar file, but developer must provide a small guide on how to build the plugin on README.md
1.7 paper 
chill
I looked it up lmfao
I can confirm it is not a pvp plugin xD
oh no, thats not good lol
All the best PvP plugins have a MinecraftServer folder
Def
Would you guys recommend a finite state machine approach for minigames
Dude you're a nerd just code the minigame
Like the phases thing
Yeah sounds like a good idea just make sure it doesn't violate ocp
yeah idk how
idk what you mean by this
like
