#help-development
1 messages · Page 775 of 1
I just needed something simple to add a clickable element. Don't really care what I use, my main plugin still uses FancyMessage
Hello, I think is not possible to register subbcommand using plugin.yml how to do ? (whithout acf or another framework)
that is because subcommands don't require being registered
only the main command needs to be registered, everything below it is technically just arguments for the main one, how you treat those arguments is up to you
yes, but it still exists? (although we can use arguments) but is there a way to define a subcommand with spigot?
not sure what you mean by define
register subcommand
I already said you can't
so with ctf the annotation @subcommand not create subccommand? (just add (if arg)?)
all a subcommand is, is just an argument of the main command it derives from
/ess give player item
Alright, in this example, ess is the main command, give is the subcommand. It is technically an argument of the main command ess just in code we don't treat it that way.
you can alias /ess give to /give instead as well
and it appears its a main command, but still isn't
so subcommand for server or client doesn't exist it's just a command arg?
wouldn't be a subcommand otherwise if it wasn't under some other command
the handy thing about them is that they don't require being registered since they are not main commands
and its handy in code to not have to register it either 🙂
okay, because with worldedit I had tried to modify the permissions of simple commands by doing getcommand("brush").setpermission("blabla") but it didn't work I was told I had to do get command on a brush subcommand
permissions on sub commands can be set in plugin.yml but the plugin has to support it as well
so its possible to set subcommands permissions?
yes
do you have a small example with that?
https://github.com/frostalf/ServerTutorial/tree/master/ServerTutorial/src/main/java/pw/hwk/tutorial/commands
https://github.com/frostalf/ServerTutorial/blob/master/ServerTutorial/src/main/java/pw/hwk/tutorial/enums/Permissions.java
https://github.com/frostalf/ServerTutorial/blob/master/ServerTutorial/src/main/resources/plugin.yml
as you can see, my defunct plugin here makes use of sub commands and permission for said sub commands. And you can set the default perms of those sub commands in the plugin.yml. However, for the defaults to work in plugin.yml the plugin actually has to check for such perms for the usage of those subcommands
Tell em
if the plugin didn't do that, the perms are meaningless
but permissions aren't really defined on the subcommand, I mean it's in the command's exection logic that it checks the perm so when I do getcommand("x").setPermission("a") shouldn't all this be added by but permissions aren't really defined on the subcommand, I mean it's in the command's exection logic that it checks the perm so when I do getcommand("x").setPermission("a") shouldn't it be added on top of all that??
I really don't like relying on bukkit's command permission system
Just write your own checks and take ownership of code flow
by the mere fact that the plugin uses it in its command logic, is the reason the perm works and you are able to set it in the plugin.yml. The built in permission system is very basic. Plugin.ymls can grant perms with it, and the system will assign it to everyone however it doesn't do anything beyond that and you would have to check within logic for said permission. The checking of the permission is where it makes it work.
if the plugin doesn't care about permissions on the subcommands and only the main command, then the only permission that would work for the plugin is the main one, since the plugin isn't going to check for perms on the sub command
only reason I made use of it, was because my plugin doesn't really require a permission plugin, so to allow players to still be able to go through the tutorials it was necessary for this
but I don't make use of that system beyond this either lol
Also its not like there is a lot of commands either for the players
just like 2 and the rest are for ops really
yes, so a plugin with no "main" permission but with permissions checked in the execution logic, adding a permission to the command as you would in the plugin.yml should block the command call if the executor doesn't have permission? so why does it call the cmd even if I don't have the required permission?
because the command logic has to block the request by checking if you have the permission or not, the built in permission system doesn't do this itself
the built in permission system, just tracks if someone does or doesn't have permission, but it doesn't enforce anything itself
if I call a command for which I don't have the perm, it won't call the execution logic, will it?
Which is why I find it useless
Just give up on command#setPermission
Check the logic on your handler
it depends on the plugin. The plugin is the one responsible to enforce anything, not the built in permission system
but defining a no permission message on the command in plugin.yml doesn't help either?
the way plugins make use of that, is by returning false on a command, again because some logic failed in this case would have to be a permission check failed
i'm doing this to 'cleanly' remove the 'tab completion' command from the client i'm trying to remove permission for cmds world edit but no work
ah okay is return false
yeah onCommand is a boolean
yes i knwo
if it returns true, the command was sucessful even if nothing happened, if its false the system assumes you don't have permission to use it
and therefore returns the message you referred to 🙂
however most people just return true, and return their own messages within the logic
instead
mainly because the message that gets displayed when you return false could be misleading and isn't dynamic either
like someone could have permission, but the failure is because they typed something wrong for example
commands:
letest:
permission: ok
permission-message: no ok
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
System.out.println("ok");
return false;
}
it should return no ok?
and permission in plugin.yml allows the server to know if it is sending the command in completion to the player, but by doing setpermission on worldedit the command was still sent oddly
idk about sending the command in completion, tab completion isn't handled by the permission system rather its handled by brigadier
haven't look at the specifics with brigadier and don't remember if permissions affect what it sends, but if I recall brigadier sends completions regardless of perms
only sends commands for which the player has the perm (apart from worledit)
well, as I said I don't really remember the specifics since I generally don't concern myself with tab completions
I can only tell you about the basic permission system in the server which it really is very basic lol
ok, I understand, and return false should therefore display a message in my case?
the way your code is setup it should print ok and your permission message
since you don't have anything to block the printing
it should but I don't get the message (just print ok)
maybe because your permission would technically be incorrect?
should be letest.ok or just letest
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
name: letest
version: '${project.version}'
main: fr.dylors.test.Test
api-version: '1.20'
commands:
letest:
permission: letest.ok
permission-message: no ok
probably not that
hi , iam having weird error i could not slove it yestrday it was too late ..
so for some reason only the first user who joins the server is being loadded
this is what i use :
what iam doing wrong?
um
yeah
it was working like weeks ago , but now it just stoped working with no error or anything 😦
public class HealthEvent implements Listener {
@EventHandler
public void OnBossDamage(EntityDamageEvent e){
Entity boss = e.getEntity();
if(boss instanceof WitherSkeleton witherSkeleton){
if(witherSkeleton.getScoreboardTags().contains("a")){
witherSkeleton.setCustomName(ChatColor.BLUE + "" + ChatColor.BOLD + "Ancient Wither Skeleton" + ChatColor.WHITE + "| " + ChatColor.RED +"❤ " + Math.round(witherSkeleton.getHealth()));
}
}else if(boss instanceof Zombie zombie){
if(zombie.getScoreboardTags().contains("b")){
zombie.setCustomName(ChatColor.DARK_RED + "" + ChatColor.BOLD + "Reaper Zombie" + ChatColor.WHITE + "| " + ChatColor.RED +"❤ " + Math.round(zombie.getHealth()));
}
} else if (boss instanceof Ravager ravager) {
Bukkit.broadcastMessage("a");
if(ravager.getScoreboardTags().contains("c")){
ravager.setCustomName(ChatColor.RED+ "" + ChatColor.BOLD + "Chaos Ravager" + ChatColor.WHITE + "| " + ChatColor.RED +"❤ " + Math.round(ravager.getHealth()));
}
}else if(boss instanceof Spider spider){
if(spider.getScoreboardTags().contains("d")){
spider.setCustomName(ChatColor.LIGHT_PURPLE + "" + ChatColor.BOLD + "Exotic Spider" + ChatColor.WHITE + "| " + ChatColor.RED +"❤ " + Math.round(spider.getHealth()));
}
}else if(boss instanceof Husk husk){
if (husk.getScoreboardTags().contains("e")){
husk.setCustomName(ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + "Feral Husk" + ChatColor.WHITE + "| " + ChatColor.RED + "❤ " + Math.round(husk.getHealth()));
}
}
}
}
``` all other are working expect of the husk 😦
any idea ?
ok i figured it out , it was because hickariCp for some reason :p
helo ;-;
i mean Zombie will be true in that case
check the Husk inside the Zombie will works ig
?paste
What the hell is this cache method
From what I can see, Map#put would've done the job
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
Does anyone know where i get the .json file for mcp? i have seen a toturial but there isnt a download and i dont know where i should get it
Here is how it looks: https://prnt.sc/RgFjmlPTz4BQ
What should i else use?
What are you trying to do
Just trying to make my own launcher client or what its called
is there a way to use bungeecord command in a npc?
well i tried same , i fixed it by remvoing hickariCP
I want to create a “custom block” with the same minecraft generation logic. Is it a good option to start by inheriting some real class from the bukkit api so that the class is responsible for the “block”
I'm speaking for purely optimization reasons
Hey, do you guys have an idea of how would I get an npc and spawn it?
the npc is made by a mod
(CustomNPCs)
and i want to get the npc itself with spigot, and spawn it
I think that should be possible
since the npc is just an entity? or
You'd have to use a Bungeecord plugin and send a message from the server using the Bungeecord messaging channel
You'd have to ask whatever hybrid server you're using
They implement things differently and are not supported here
they probably dont
but eitherway
mohistmc's server is dead
has any of yall idea whats causing this? https://mclo.gs/c6nLeXq
its so random and rare i have no idea
They 100% do
Spigot doesn't support mods
So they have to implement things differently to force it to work
hm
but its prob just internal stuff
that i dont need to care about
You really do need to care about that though
since you're trying to mess with a modded entity
afaik
the way custom npcs does it
is similar to spigot
cant i just like
get the entity instance and somehow spawn it
i think custom npcs handles the rest
when it notices one of its npcs are spawned
and that entity may or may not break bukkit api contracts
How you'd get the instance depends entirely on what the hybrid has done to make it run
or if you're planning on using nms that'll be even more pain
feels like its worth it since im being paid 1.5 grand
Hybrid also has 0 support
😭
maybe there's a reason you're getting paid so much :p
yeah 💀
Gl
yes
Probably
and just take the npc right from it
and there isnt a github for it
Amazing
oh wait
:O
Then you'd do the classic modding stuff
Reading decompiled code
most of my payment will go to the therapist 💀
someone know why this code is not working?
@EventHandler
public void onPlayerRespawn(PlayerRespawnEvent e) {
Player p = e.getPlayer();
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1, true, false));
p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, Integer.MAX_VALUE, 1, true, false));
p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 1, true, false));
}
i have the same code for the onPlayerJoin event and that one is working
Does anybody know what will happen if you cancel an event with a delay? I presume that it will just not be cancelled but who knows lol
I will test it later anyway but would be good to know in advance
you can;t delay canceling
What if I change any other event values with a delay, like maybe the damage or smth?
Is that possible at all?
you can;t delay anything in an event
if you want to make any change to an event you do it when it fires or not at all
Yeah
Try waiting a tick after trspawn
Thread.sleep 🥴
Sounds good to me 🙂
People will attack you if you use that in an event
In real life
Ur welcome
Ty!!
just fork spigot
for daily events just Thread.sleep in the onEnable for 24 hours 🙂
I don't think people will download my plugin if I ask them to use my version of spigot 😦
just dont tell them and auto download
then the server accidentally crashes
Can I also inject spyware on their personal computers?
and voila its in
Sony did it so I don;t see any issue
you could get their emails and send them cute cat pictures
Oh ok then
Give me your email. Obviously for cat pictures only
nice try but im more of a dog person
I will send you dog photos then, what's the biggie
i dont want photos of yourself
Damn dawg
hi does anyone know how to change the player limit using code with bungee?
declaration: package: org.bukkit, class: Bukkit
hello stupid im souhayl!
hi , i am having really really reallllllllllllllllly weird problem , all commands are notworking
nothings hppanes
tried everything even debugged it
but nothing show
Nice
"Not working" as in doing nothing or showing up as nonexistent (red)? Does your plugin start up? Did you register your commands? Did they work before you introduced some changes? Are there any errors?
Please share more information than "not working"
Does the console allow you to run em
yes it should
ik the codes looks messy , but it was working before idk what happend all commands stoped working
After you run a command, do other commands work? (like /tps)
Well first of all this code is already super error prone
Each of these lines can throw an exception
Did you register your commands? You sure?
yes ofc i did
Double check your onenable
admins commands was down , but i channged it to bukkit way of registering command just to test it out
and its still the same problem
it just broke like 30 minutes ago no warrning nothing
well i know why probbly xD
Yeah...
uhhh ik what's wrong
What is it?
i didn't set any value in the settings file for the lobby-location
that why itwasn't registeringanything ..
Nice
Imagine
it didn't show xD
I feel like
for some reason
You should use the logger
Also don’t not register commands cause of that. Make the commands give some sort of feedback i guess
Absolutely
Event bugs?
yes
Currently I know that inventoryClick needs to be canceled along with InventoryDrag and that it’s better not to use playerInteract again
what
player interact is not for inventory
its for clicking items your hand
not understanding the event is not the same as "bugs"
You are not playing fallout 76, you don't need a goddamn article for all the bugs because there aren't that many. Just check JIRA and see if there are any bugs related to what you're doing
If you cancel inventory click then you dont need to worry about drag
Could you elaborate?
Nvm with that pfp. Dont bother.
Im not. Nothing against palestine. But the person on your picture is a hamas member i assume?
Hello everyone, my friend creates custom models, but how can I interact with them in code, how can I do that on the server?
Tf is isis
How old are you
Young
Okay
There are multiple ways of achieving this. One pre-written solution would be to use the ModelEngine plugin.
Otherwsie you would have to think about writing something yourself. Are we talking about models that show entities
or simply ItemStacks in your hand?
I think both because my friend wants to upgrade my /backpack plugin with a backpack texture so. on the other hand, I would like to make animals or new mobs, but I don't know how to do it at all-
ItemStacks have a property for this, "CustomModelData". It can be any integer and applied through code.
You resourcepack now need to define a predicate for which id to show a different model.
More can be read about this here:
https://minecraft.fandom.com/wiki/Tutorials/Models#Item_predicates
The simple solution would be to use something like ItemsAdder for items and ModelEngine for complex models.
But both plugins are premium. A custom solution is possible but will take some tinkering to get right.
Flashbacks to getting animations right
is this the difficult mobs animals with an AI
I think custom modeled entities with an custom AI is as hard as it gets, when it comes to conventional plugin development.
Myeah but making the animations work like you want to, can be quite difficult.
And making sure your custom brain or goals arent just thrown out the window when
minectaft loads the chunk again is real pain.
We do a little registry hacking
I got the ai down fine, never got the animations to not implode
Exactly. And then at some point you bump into frozen shenanigans
-.-
In what version was Entity#isInWater() added? I can see it was added on this date but I'm not sure about the version
1.15 or 1.16
I would lean towards the latter
Thx
Is there any way to show all the files that were there when a commit was done?
That'd make it easier
It's apparently this commit but I don't know how to see the rest of the files
Uhm you can probably do some gitery to roll back to a certain commit.
Just make a branch and try a rollback to this exact commit.
Hmm
How do I program a scoreboard that updates constantly without flickering
Do you have the commit hash
bcddb7542af9e1e7db07d46495d94e69d0d1cd8b
literally just git checkout ?
Is there any way to do this directly on the website because I really don't wanna go cli mode just to see the version that a commit dates back to
stash can't resolve that revision 🥲
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
its probably going to be 1.16 the method wasn't avliable in 1.15.2
wtf how did it resolve for you
it said the commit didn'te xist for me kms
oh cuz its fucking bukkit
I was looking at cb
O
1.16.4 ZBLL
I was trying to put the hash into the branch field but it wasn't showing up
Guess it's done with url params lol
Thanks Y2K_ and lynxplay 🙂
i have code:java @EventHandler public void modesAction(InventoryClickEvent e) { Player p = (Player) e.getWhoClicked(); if (e.getView().getTitle().equalsIgnoreCase(ChatColor.GRAY + "Wybór trybu")) { ItemStack currentItem = e.getCurrentItem(); if (currentItem != null && currentItem.hasItemMeta()) { ItemMeta itemMeta = currentItem.getItemMeta(); if (itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals("Survival")) { p.sendMessage(ChatColor.YELLOW + "Łączenie z trybem Survival..."); } } } }
and i would to make connection to another bungeecord server
in this event
Plz do not compare inventories by title
and i don't know why
why
I dont think this will suit him but here you go
https://www.spigotmc.org/threads/a-modern-approach-to-inventory-guis.594005/#post-4553427
It just might haha
You mean, you dont know how?
yes
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
This explains how to communicate between Bukkit and Bungeecord
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
ok,thanks
how to prevent block from being destroyed if there are banners attached to it (standing on top or hanging from the side)?
In BlockBreakEvent check the adjacent blocks and see
yeah but how do i check if the adjacent banner is attached to the broken block
p.sendPluginMessage((Plugin) this, "BungeeCord", out.toByteArray());
You cant cast your compassClick.class to Plugin because its not a Plugin class.
Get an instance of your JavaPlugin class and pass it to this method instead.
ok
@EventHandler
public void modesAction(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
if (e.getView().getTitle().equalsIgnoreCase(ChatColor.GRAY + "Wybór trybu")) {
ItemStack currentItem = e.getCurrentItem();
if (currentItem != null && currentItem.hasItemMeta()) {
ItemMeta itemMeta = currentItem.getItemMeta();
if (itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals("Survival")) {
p.sendMessage(ChatColor.YELLOW + "Łączenie z trybem Survival...");
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Connect");
out.writeUTF("survival");
Spawn pluginInstance = Spawn.getInstance();
p.sendPluginMessage(pluginInstance, "BungeeCord", out.toByteArray());
}
}
}
}```
and i get error
spawn code : ```java
package pl.playgroundhc.spawn;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import pl.playgroundhc.spawn.actions.compassClick;
import pl.playgroundhc.spawn.events.joinEvent;
public final class Spawn extends JavaPlugin {
private static Spawn instance;
@Override
public void onEnable() {
instance = this;
getServer().getPluginManager().registerEvents(new joinEvent(),this);
getServer().getPluginManager().registerEvents(new compassClick(),this);
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
public static Spawn getInstance() {
return instance;
}
}
Alright, we just need the error now 🙂
You forgot to register the BungeeCord channel for your plugin
@Override
public void onEnable() {
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
...
}
Ehh, why isn't this working?
I swear I did something like this before
Im on 17
You cant auto unbox like that. short[] != Short[]
So it would need too be Short[]::new instead of short[]::new
thx, it worked
ah yes, when you miss a "(", "!" or even just write a letter in capital, isntead of lowercase :)
To be fair, short and Short are quite differnt :p
One is shorter than the other, I get it
Exactly!
lol
how to get a banner's color and pattern?
ohh alright thanks
Me
What is your gui scale
Yeah it looks awkward but it's fine lol
Registry 😆 REGISTRIES. Maximum customization
And I love all the other GUIs at scale 2
But this one just looks sooo awkward, I don't remember this interface looking so shy in prev versions
Its not too small and its not too big
I always try to make everything in my plugins as customizable as possible. So right now I only have 3 registries, but it might be more before I finish
I need a generator-formation registry still which takes in a 3d array of materials and block data from a json config
and can read it into a structure
I was thinking about using WE schematics for this though instead
nice thing though Is I can move a lot of the stuff I've done after this project. E.g. my StaticRegistry class can just be moved over
same with some other Utilities. like my spacial utilities whic just do stuff with the world and aren't reliant on my project
I actually dedicated an entire library of mine to ONLY using NMS
that's all it does
Wtf
[20:09:09 INFO]: Event type org.bukkit.event.entity.EntityDamageEvent
[20:09:09 INFO]: Expected type com.roughlyunderscore.events.PlayerGotHurtEvent
plugin.server.pluginManager.registerEvent(holder.eventType, object: Listener {}, EventPriority.NORMAL, { _, event ->
println("Event type " + event.javaClass.name)
println("Expected type " + holder.eventType.name)
}
@EventHandler
fun onPlayerGotHurt(event: EntityDamageEvent) {
if (event.entity !is Player) return
val playerGotHurtEvent = PlayerGotHurtEvent(event.entity as Player, event.cause, event.damage)
playerGotHurtEvent.isCancelled = event.isCancelled
println("Got hurt event called")
Bukkit.getPluginManager().callEvent(playerGotHurtEvent)
}
it just interfaces with NMS and provides me API
So I'm registering a listener for my own event that extends EntityDamageEvent
And somehow it gets called every time EntityDamageEvent occurs
Instead of only being called when my event is called
Thats how events work. EntityDamageByEntityEvent will also be passed to EntityDamageEvent listeners
No I'm listening to my PlayerGotHurtEvent
if you're going to call it in EntityDamageEvent you can't extend EntityDamageEvent
Why is the listener getting called when EntityDamageEvent is called
It'd make sense if it was the opposite
But this does not make sense
How is that possible
when you call your listener in a event you extend Bukkit does some very weird stuff
But like
its a symptom of a problem I don't quite understand
EntityDamageEvent cannot be cast to PlayerGotHurtEvent
Did you properly implement all the handler methods/fields in your custom event?
Time for some bit fun :)
Does anyone know an easy (and preferably fast) way too find out how many "1"s are in a given number?
eg.: 248 -> 0000000011111000 -> 5
Yes it can
class PlayerGotHurtEvent(private val victim: Player, cause: DamageCause, damage: Double)
: EntityDamageEvent(victim, cause, damage)
Yes
Should I implement handlers when I extend EntityDamageEvent?
All PlayerGotHurtEvents are EntityDamageEvents
But not all EntityDamageEvents are PlayerGotHurtEvents
you need to add the handler list and stuff too don't forget
Yeah you should have a static and non static handler method
Yeah I thought EntityDamageEvent didn't need handlers haha
Does every event need them?
Afaik yes
I thought it was only for those that are very abstract like PlayerEvent
yes
Doesnt Integer have a util method for that?
If you want it to be listenable
Holy shit
no every event needs a handler list
Did u give it a handlerlist?
I'll check
WIP
int x = 200;
int ones = Integer.bitCount(x);
<3
https://paste.md-5.net/xavuvojome.java cursed :3
O wait maybe not
no you definitely do
I thought children events needed a handler list but I appear to be wrong
every event should have one
what
But it returns it in the twos- compliment; Does that mean I have to do: 32 - Integer.bitCount(x)?
I'm pretty sure you only need handler lists when the event you extend is not listenable by itself
Like PlayerEvent
Probably
But if you're extending a listenable event you don't need one
Ok so if I'm listening to event B, which extends event A, the listener should not be called when event A happens, correct?
if event B doesn't have a handler list but A does, it should
Nvm, I don't have too do anything
Afaik parent event listeners will still catch their child events, but not the other way around
Either B needs to have its own handler list or the eventexecutor perform an instanceof before invoking the listener
Yeah so what I said should be correct
In which case I do not understand why it's not lol
Maybe I'm misusing PluginManager#registerEvent?
Just use a handerlist for ur own event 💪🏻
Maybe
Alrighty I'll just add it
if B doesn't have its own list, the listener will be added to A's handler list
Makes sense if it’s applikable that it will run when its parent runs
so the executor will be invoked for B as well as A
if B has its own list, then the executor won't run for A
it's a horrible system imo, but it's older than some of the members of this discord so what gives
White is also a color
Technically it's a shade
🤓
Yee, legacy support ftw 🤮
I mean the system could be redone without breaking changes
But it works well enough so no one has bothered
I usually go with a library https://github.com/bennidi/mbassador
I'll be forever grateful
Probably won’t be accepted unless proper legacy support
Well yeah ofc
Oh wait u already said that
it wouldn't be hard to keep legacy support with events
I mean the API itself is pretty malleable
yeah but you'd still need to support existing events from plugins with a handler list, so like, the system would need to stay
discord devs in their infinite wisdom allowing for unlimited super reactions
Only on some servers
Y2K_ if you would like to gift me nitro I would not reject the gift 😳
I don't think anyone would :p
frost gvae me nitro, I wouldn't ever buy it for myself
REject it
Idk maybe some people really don't want nitro
See that's the problem,
??
https://discord.gift/C4s8rqDkq3rmxy62 think fast
Ahaha bots
lmfao
bots xD
Yeah bots always grab those
you always DM
rip
Grats to the bot
Rip
How do you change the displayed player amount with spigot
Though thanks for the offer haha
Serverlist ping event
In new versions you can do it without the event
not to mention it stops them from going the advertising route
which is a huge win
declaration: package: org.bukkit, class: Bukkit
Coll
me
Read his question
does that have a method to set the player count, not the max player count
Nah
You'll need the event for it
I'm pretty sure it's not possible though
declaration: package: org.bukkit.event.server, class: ServerListPingEvent
?
Actually
@young knoll review my brand new PR 
I think I had a convo here
The event seems to only have a getter, not a setter
Where I tried to change the amount of the players
But it just was not possible
Read what Choco said
Mmh maybe we can PR that :p
there is still no method to set the player count
im using nms already what is the packet i need to use
You would need a packet listener
And packets might help
something like PacketEvents would work nicely here
PacketEvents, Protocollib, or netty
PacketEvents only
support our retrooper
Wait why only packetevents
I mean what he said was jsut to use reflection
using reflection probably easiest
its a joke cuz retrooper is in here and he made packet events
Yeah but is it possible to change the pinged online count with reflection
Because from what Choco has told me it was not
who knows
Yeah
That's the packet, it's in json format so you'll have to handle that
Gson should work
And this is the allegedly working code with ProtocolLib
Looks reasonable
Stardew Valley is such a relaxing games
I wish my first language wasn't english so I would have an execuse for being so bad at it
Quick question, hopefully...
Does a short, which is 16bits, take up the same space as a long or is storing 4 shorts the same as storing a long?
Context?
a long is 64 bits so its 4x larger than a short
Is the static getHandlerList required for an event, or is overriding getHandlers enough?
Why are there 2 anyway
for magic purposes
Sooo it's required?
yeah
Welp
I'm currently storing an array of 16 shorts, cause it is more convenient than storing 4 longs in an array.
However, I will be storing like up to 800 - 2000 of those 16 short arrays.
So I was wondering if it is more effective too store 800 arrays of 4 longs each.
just ignore Intelij it can scope
I'm having a clash and trying to resolve it
That's the thing
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
that is not something that should happen
Ahh
oof
.@JVMStatic
why is it in a copmanion object? could that be the issue
why isn't your event an object
Objects can't have constructors
what Kotlin Jank
Object is basically a static class
Kotlin automatically makes getters
Ik
Had I named the variable handlerList then I'd understand its complaints
Ok I solved the problem
z.@JVMField no getters
I just had to extend a class that didn't already have handlers
Ah k
Idk, been a while. Usually everything works after a second or two of tinkering
If I understood you correctly I had to do this?
If you reach into the NMS MinecraftServer class and manually set the this.status field (which is private) you could do it with reflection.
But using ProtocolLib is probably the safer route.
I mean probably. Haven’t used custom events in ages
Yeah that didn't help unfortunately
Oh well
I'll just keep extending classes with no default handlers
Yeah it compiles like this, though now I gotta see whether it helped my problem
@river oracle
Here's the context
Its not hard to create custom events
I mean it doesn't really matter its the same amount of memory. Especially if you're using arrays you can keep the memory hot anyways
It in fact is not
But kotlin kinda fucks around
oh using kotlin
😄
@wet breach any advice here I am very limited in my low level knowledge
if you are making a custom event that doesn't exist
just extend Event
if you are wanting to add a more specific custom event, just extend off the one that you want to use
conor yes
If you plan on using them all
Then use a long array, or bitset maybe
which is a long arr lol
what is the advantage of a long array vs a short array
I mean my events were not too niche like PlayerShootBowEvent (just extends EntityShootBowEvent), but when adding handlers to them, a clash was happening because Kotlin automatically adds getters, so I had to extend Event in every case, because the clash was happening due to the fact that the class I was extending already had handlers
Ok adding handlers actually helped resolve my problem yay
Gg
Average HandlerList shenanigans
typically would just override the handlers
😄
That's what I did. I just didn't have my own handlers before and extended EDBEE, but the problem arised when I tried to listen to my own event - firing EDBEE would also fire my listener. So I just extended Event and added handlers
You have the stack model
To abstract myself completely from potentially clashing with an event ever again
Ans things are stored in multiples of 32 bit iirc
where you’d use 2 cells for longs and doubles i believe
So it may be worthwhile if you know you’re going to use it all
really I thought it was 64 for x86x64 processors
well that was the correct thing to do glad you figured it out for yourself 🙂
but its a negligible optimization
Thanks to yall guys haha
You can also just store all shorts in one consecutive short array.
It really depends on the format. If its binary then there is not really any difference to long arrays
but it might be easier to handle
JVM stack model
ahhh
Is the conversation still about what I said?
Yeah, taking into account min/max footprint and if you’d need to resize the arr
I assumed he knows the exact amount of arrays beforehand. If not then this is not viable.
Yeah, as smile said, if its binary or not may also dictate your end choice
Seems I didn't need to impart my knowledge on that lol. Conclube and 7smile7 seem to have it handled 🙂
infinite super reactions so dumb lol but I love it
lol
I'll give a bit more context:
I'm currently trying to implement a greedy meshing algorithm and too make it faster and easier for me, I've stripped away the whole idea of Block.class and am rather just storing an array of shorts, eg short[16] to represent a 16x16 area, ie a "slice" of a chunk.
Since a chunk, in 1.19+, goes from -64 too 319, ie 384 "slices" high, I need too store 6.144 arrays of 16 shorts.
As @ivory sleet pointed out, things are stored in multiples of 32. So I thaugt, that maybe I'd be using up 6.144 memmory addresses too store my data, while only using half of their capacity.
If so, I might change my array type from short too either int or long.
Very important however is, that I'm doing a lot of bitwise operations too work with my bitmap/field, so short is most convenient rn.
So the short contains the relative X and Z coordinates of blocks in your chunk. Im not 100% sold on grouping them in one array per Y coordinate.
What are you meshing out? In my head there is information missing in this structure.
This is a "slice" of a test chunk.
Every "1" represents a block, obviously every "0" therefore just some empty/passable space.
Every block in the X-axis is stored in a single short. And the Z-Axis is the index of the array where the short is stored.
Btw, this is all precomputing. I won't do this on the fly
a 2d array might be better for this
one for the y, the other for x,z bitmask
You mean something like boolean[][]?
But that would make dealing with the bitwise operators annoying, wouldn't it?
Correction*
I missmatched Y and Z. I'm storing X and Z, not X and Y!
Ah ok i understand this now.
So 1 represents a solid block and 0 is a passable block like air.
A chunk slice from above is
0 0 1 0 1 0 1 1 0 1 1 0 0 0 1 1
.
.
.
1 0 0 0 1 0 1 0 1 1 1 1 0 0 1 1
so 16x16 bits, either 1 or 0
use byte[][]
ye
why?
Boolean is 0x01 or 0x00 anyways.
What about bitset
that wouldn't help with y values being larger then 2
boolean and byte arrays would both be less memory efficient on the first glance.
If not optimized then a boolean occupies 32 bit in the beginning
I have never worked with it. I am much more comfortable with primitives
Yes
I think the most memory efficient structure would be a long[] or int[]
Yeah it is
Imagine being efficient
is developing for 1.16.5/17 different than developing for 1.20
Well probably long as it can utilize 64bit platform intrinsics
BitSet is backed by a non negative integer
It's a long[]
Yeah when u index it, its an int
Idk how a single integer would work for something that can have arbitrary size
Yes (but not much), older Java version and outdated API
Not fundamentally. You just have fewer api methods to work with.
If you write a plugin for 1.16 then it should be usable in 1.16 -> 1.20
^
Does anyone know anything about custom tecturepacks? I can't get the server to load it
so a 1.16.5 plugin would work on a 1.20 server?
Well, if you have 384 * 16 * 16 = 98.304 things to store... maybe even multiple of them at the same time... yeah.
It would be 98.304 * 5 ~= 500k bits, ie 500 kBits, 62kB.
Actually... that's nothing XD
^ I would disagree, I have had to update my plugin almost every update because of issues with the chest intrerface changing.
Does anyone know anything about custom tecturepacks? I can't get the server to load it
*If it doesnt use nms or craftbukkit
whats nms
net minecraft server, it refers to Mojangs code which isn't part of the Spigot API
Still have to update my addon for 1.20 (I am a bit lazy) since the scheduler changes between 1.18 and 1.20 (didn't update for 1.19) seem to have broken it.
But you have to decide if you really want space or time efficiency.
If you are doing low level computations on a per-bit basis, then the JIT might have a harder time optimizing your code.
So going for higher level structures might be advisable in an jvm environment.
scheduler changes?
Yea, I was using the older scheduler system back when I wrote it in 1.17 somehow it stopped working properly in 1.20. (Or something with Item lore changed not 100% sure.)
Probably going for time efficiency. However it doesn't have too be SUPER amazing, since everything will be precomputed.
I don't think we changed anything with the scheduler
Well I know it got a new interface to scheduling stuff thru
Any exceptions? What do you mean that your server doesnt load?
no?
can i ask you DM
maybe they are using paper?
Hm, nah not today. Tinkering with resourcepacks is kinda boring.
ah i can t load screenshots her
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
This was Craftbukkit, I have been using scheduleSyncRepeatingTask got all this new BukkitTask stuff that got added sometime after I originally wrote my plugin. Probably the Item Lore related stuff that broke tho.
trying to make a 1.17 plugin with java16, but intellij wont let me select java16 it unless i go 8.2.0-SNAPSHOT or earlier. is this okay?
well your version info seems to be incorrect then between when you wrote your plugin and now
because BukkitTasks have been around for a long time
^^
Doesnt look like a programming problem to me...
Well I wrote this in 1.17 when you had to use just a Runnable.
That hasn't changed
1.17 had BukkitTasks
sorry
Both BukkitRunnable and java Runnable could be used for ages when scheduling tasks
Maybe someone in #help-server can help you 
I have this. What would be a name for the opposite of it?
hi guys
someone can help me with the animation?
with the plugin tab?
i want to do animation with the name too
but i do only the role
how i do with the name?
Spamming that in every channel isn't going to get you an answer faster
I hear it makes people want to help you less
Can you tell me the name of someone who is suitable for 1.16.5? I want it to say 'that bitch mentioned you' on the screen when I write the name of someone suitable for 1.16.5.
Use JOOQ for sql queries.
Spamming that in every channel isn't going to get you an answer faster
Ok
?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!
?help
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous usernames, global display names, and server...
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
i can get data from dataContainer in item in another plugin?
i was try but
this return null
NamespacedKey.fromString("pickaxe") ?
oh this not correct?
you need the plugins name or id too
Well, you should think of a common namespace yea
pluginname:pickaxe
^
thats a bitboard right
or as lynx said use a common namespace that would relate to both
if you have a item plugin you could make them both have the parent key as xyzitems
use NamsepacedKey.fromString for it all and always have a custom key
?selfrole
Syntax: ?selfrole <selfrole>
Server admins must have configured the role as user settable.
NOTE: The role is case sensitive!
list Lists all available selfroles.
Problem with gradle submodule as used dependency by other module
Hello, I have a question, how can I put and establish an item with a .yml file?
Store the item in the config and then use getItemStack(path) to retrieve it
hi I'm working on a plugin that adds souls to the game. Souls can have different types that are registered using Souls.registerSoulType(SoulType soulType) e.g. if I have created LostSoulType then I can use Souls.registerSoulType(new LostSoulType()), and these types can be retrieved using Souls.getSoulTypes().
SoulType is an interface with some methods like spawn(Player) or getSkinData().
Now the problem is that for any soul, I want to get a different instance for each player that I spawn it for. Now this is not possible using my implementation because I will have to change SoulType to Class<SoulType> and then instantiate that class using reflection, which is not ideal.
I can think of one solution, but I'm not sure if it's ideal; I can create a two interfaces called SoulType and SoulEntity. Then I can make SoulType#spawn(Player player) return a SoulEntity, which can be used as the "soul instance" I mentioned earlier.
So my question is very basic; Is there a better approach to doing this?
Ok but how do I specify the slot in which the item will be?
What? You are storing an ItemStack, it doesn't have a slot
Do you perfer base64?
Or you can use just ConfigurationSection#set(key, itemstack) ConfigurationSection#getItemStack(key)
What do you mean?
Basically converts item stack to binary and serialize it to a string
Huh!
^ which is unreadable for the average user configuring
Why would you want to do that?
Well
It’s an easy way to convert it to a string which can be stored most places
Obviously you could also store it as binary if ur storage solution allows that
Is that first I specify the slot in which the item will be and then use that item in an inventory but with a .yml file, do you understand?
I mostly use base64 when i don’t want the user to edit the item after it has been saved
base64 for just storing
How to store using base 64?
Do you need it?
Google: "How to convert itemstack to base64 string spigot"
you can store an ItemStack as-is in bukkit configuration
Inventory#setItem
For the record, #fromString() is intended mostly for user input, not for developers to circumvent deprecation
im not saying to avoid deprecation but to make the key from a common parent, so instead of using chocobot:yes then having to use the plugin name you use staffbots:yes
NamespacedKeys are ideally plugin namespaced
but what if 2 plugins need to access them
Why
idfk
Yeah I'm not sure how that matters :p
yeah probably true
Plugin1 - API
Plguin2 - uses API
If they both need them, they’re probably doing smth along the same lines and it’d be annoying to repeat in plugin 2 so just have plugin 1 expose some methods for use
I know, I mean, first read the number in which the item will be placed and then put it in inventory.
store that data from the key
You can save them under the same key’ish, like item.slot and item.data. It’s a bit hard to say without seeing exactly what ur trying to make
if its invs could also do something like invtype.slotnum
Just create class like 'MyPluginPDCAPI' then do the operations?
Sure
Can someone tell me if this implementation is okay?
Yrs
Ladt part sounds fine
Is it bad that I want to write an addon that lets you place chunkloaders that run on fuel xD
Sounds easy to write as well.
Something like this:
public class MyPDCAPI {
final NameSpacedKey key;
public MyPDCAPI(NameSpacedKey key) { this.key = key; }
public Blah getBlahFrom(ItemStack stack) {
return stack.getMeta().getPersistentDataContainer().get(key, new BlahPDCType());
}
}
how i can add a tnt in head (visible) of player like tnt tag
Suure
Set their helmet to tnt?
yes
Quite literally what i said
how would be a good way to use the same CompletableFuture if I am trying to access the database 2 times with the same key?
?xy
Asking about your attempted solution rather than your actual problem
so?
Bruh literally just set their helmet to tnt
and it is visible?
Yes
lets say I have a DAO#get(String) method. If I use dao.get("aa") two times, I would like to be using the same CompletableFuture
No
Nope you do 2 tasks
Please think of another proper reason.
Just cache the result if it does not change
Cf is instance of task that will be finished in future (or is finished) , it can't be "reinitiated"
I need to use the same CompletableFuture because I have a code that is fetching the database with the same key 2 times with a small delay between it
and it is creating 2 objects
Sure
CompletableFuture does not do that at all
You need to cache it yourself.
This is really an xy problem, you think ur solution is the correct one and is trying to figure out how to do it. Whilst we’re telling you it’s not.
probably should make use of mysql's caching functions then
with mysql's cache function, no matter how many things that need it, it is basically instantly available without doing a requery on that end
That’s cheating
lol
Is there an event for when a player receives an item in their inventory?
By any means*
no
I once made one
There’s a few
theres a few events you would need to listen for yea
you'd only need to listen to pickup events, and inventory move events right?
Gotta make an external lib called XtraEvents or something lol. Add a tonne of useless stuff
I can send you one of my own events
How can I run a website on Spring from a plugin in Minecraft
closest you will come to that is the itempickup event
You would probably need to start up a new thread on the server I to run your Spring webserver (no idea how to use spring, only touched it once for a class in college like 5 years ago)
You can do that by starting a new thread and bootstrapping the application yourself by using the SpringApplication class.
i want to save banner color & pattern to json but my code doesn't work:
Gson gson = new GsonBuilder()
.setPrettyPrinting()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Banner.class, new BannerSerializer())
.create();
private void saveFlags() {
Bukkit.getLogger().info("saving flags");
String flagsJson = gson.toJson(flags); // HashMap<String, Banner> String is banner's faction
try {
File file = new File(getDataFolder().getAbsolutePath() + "/flags.json");
if (!file.getParentFile().exists())
file.getParentFile().mkdirs();
if (!file.exists())
file.createNewFile();
FileWriter fileWriter = new FileWriter(file);
fileWriter.write(flagsJson);
fileWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
import com.google.gson.*;
import org.bukkit.Bukkit;
import org.bukkit.block.Banner;
import org.bukkit.block.banner.Pattern;
import java.lang.reflect.Type;
public class BannerSerializer implements JsonSerializer<Banner> {
@Override
public JsonElement serialize(Banner banner, Type type, JsonSerializationContext jsonSerializationContext) {
Bukkit.getLogger().info("serializing banner");
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("color", banner.getBaseColor().name());
JsonArray jsonPatterns = new JsonArray();
for (Pattern i : banner.getPatterns()) {
jsonPatterns.add((JsonElement) i.serialize());
}
jsonObject.add("patterns", jsonPatterns);
return jsonObject;
}
}
the serializer never gets called. how can i save the banners to json? or is there a simpler way? (i'm new to plugin development and java in general)
Why to json?
i want to save the banner patterns for each faction, json seemed like a good solution
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
ok i'll try yaml, thanks
Weird question. So I got this mc server that has the server resource pack built into the mc client so when you connect to the server it doesn't take time to apply it and load. Does anyone know by chance how to set that up?
That would just be the regular way to do resource packs
The client caches the server resourcepacks so as long as you provide the correct hash it won't redownload it
It would ofc need to apply and load
That's the part I am referring to, they have it set up so it is always applied to your client
If you want to avoid apply and load then you need to tell the users to download the resource pack and apply it themselves
or make a mod that forcibly loads it
What should I do to shoot an arrow with the real force of the arrow wave because the one I'm picking up right now feels like it's lower because the arrow doesn't go as far as a regular bow
declaration: package: org.bukkit.projectiles, interface: ProjectileSource
or use the one without a vector
If the one without a vector doesn't match the speed you want then you can always capture the velocity vector of an arrow and use that
okey 🙂
Do you by chance know of a mod that already does the forced resouce pack?
That would require your users to download a mod
That's fine I plan to make a modpack for the server
Then you could just put the resource pack directly in to the resource pack folder
isn't that what the hash is for?
I tried putting it in the resource pack folder but it still applies the server resource pack and gives you that loading screen
Minecraft still needs to load and apply the resourcepack
you can't just replace 2k texture in a few miliseconds
sure
You can make a simple mod that tells you that they're running the pack and then not send the resource pack again
This is the example I mean, I'm currently in the main menu and the server resouce pack is applied
shot in the dark but does anyone happen to know the velocity function applied on an item when its fished up out of the water
double d = player.getX() - this.getX();
double e = player.getY() - this.getY();
double f = player.getZ() - this.getZ();
double g = 0.1;
itemEntity.setDeltaMovement(d * 0.1, e * 0.1 + Math.sqrt(Math.sqrt(d * d + e * e + f * f)) * 0.08, f * 0.1);
Taken from 1.20.1 Mojmapped
oh sick thanks man
"this" would refer to the Hook
Does anyone know the cause of this error in NMS versions above 1.17?
it's not just with the package net.minecraft.EnumChatFormat.
NMS change between different versions
Modern versions uses the correct mojang package names
how can i fix it?
Update your imports
wait so they just got a dummy variable sitting there for g? lol
or is g used elsewhere
hi guys
someone can help me with the animation?
with the plugin tab?
i want to do animation with the name too
but i do only the role
how i do with the name?
Again this is not the correct channel
what
you understood what they want?
Yeah
Is there a way to monitor all of the packets the server sends?
wow
Could use ProtocolLib or PacketEvents
I don't really understand how to solve this, sorry
https://github.com/Heath123/pakkit is also an option
I wanna do it raw
and I need to monitor all
nms?
yes
does nms even allow that
out of context this is a pretty bad sentence
Just save yourself the trouble and use PacketEvents or ProtocolLib
that's why I'm asking
There's no need to reinvent the wheel
Why not
I have my reasons
interesting reasons you got
You can ofc
