#help-development
1 messages Β· Page 748 of 1
or break the law and use paper with the dsable watchdog flag and keep alive timout
uh... i meant the mod that'd remove the timeout thing from the client
so yea, then you'd need a mod
server has this 'dont timeout' thing iirc
i mean this m ight work https://www.curseforge.com/minecraft/mc-mods/timeoutout-fabric
i wish there was a way to have a run config on all projects, its not hard to make the debug config i just wish i didnt have to
and i could make the debug button go to a specific task
nice
Could you give me a hand with my sendUsage() method of my command system. I have complications with recursion, since my commands are going to be of hierarchical types and where a command can have many arguments and/or sub commands associated with it.
In my case I would like the help to look like this, in case of executing a root command it will only show me the name of the arguments andr sub commands associated to it.
In case of executing a root command without arguments it would be something like this. Where %command% represents the name of the initial command and %argument%, represents the name of the argument and/or sub command associated to it.
%command% Help:
/%command% %argument% %usage% - %description%.
On the other hand, in case a root sub command is executed, the help should show only the names of arguments and sub commands associated to it. Very similar to the detail above, thus obtaining a complete example of how it would be:
Example:
Running /faction would return in the help the names list (argument) and points (sub command).
In case of executing /faction points it would return in the help, the names of arguments and/or sub commands associated to it.
I don't know if I am making myself clear with respect to the sendUsage command
Unfortunately, your recent report has been rejected: Resource Update in 'Buildings' - No text description
i don't understand :/
They deleted the plugin when they sent me that
Contact an staff they can help you in this case and give an answer
which is the contact?
?support
Epic, are you busy? I would to ask you small questions
go for it
i will link to it
.
If its not well explained just ping me and i answer in the momment. Thanks because in struggling with recurstion
if it has a map, just keySet() if it needs more you just have to beable to query the sub commands
I have this command structure
Command - interface level with common methods
SingleCommand - a command with no implicit arguments
ParentCommand - This one handle all the logic for sub commands containing a List<Command>
Just struggling around the help part, because so far i didnt it appear the help in this way following a simple faction structure
Faction help
/faction list
/faction points add <player> <amount>
/faction points remove <player> <amount>
When it should only appear, when just running /faction
/faction list
/faction points
When running /faction points, then yes it should appear like this:
/faction points add <player> <amount>
/faction points remove <player> <amount>
youd have to loop over the command list and get the arg name
Do i explain more or less to what i refer?
Yes i know that but struggling round what i mention
Do i explain?
Is the BlockBreakEvent fired, when a door is broken on one half and the other half still drops a door?
So far im testing around this code i just finished:
public void sendUsage(Sender<?> sender, Command command) {
List<Command> children = getArguments().stream().filter(arg -> isAuthorized(sender) || arg.isAuthorized(sender)).collect(Collectors.toList());
if (children.isEmpty()) return;
StringBuilder builder = new StringBuilder(command.getName() + " help \n \n");
for (Command argument : children) {
// struggling at this part, because it sends all the command availaible
}
sender.sendMessage(builder.toString());
}
First half will fire the break event, second half will not
would other half send block drop item event event
damn, how do i prevent the second half from dropping then?
Sounds like a job for BlockPhysicsEvent
Called when a block drops an item :p
wouldn't that be the right event then?
I don't know. Is that what you want?
I'm still working on that key system with PDC + CustomBlockData-API
I want to check if the broken block has CBD and then cancel the drop event and drop a custom item
Oh, then yeah, probably that then
what means CBD?
custom block data, presumably
Just for curious haha
it still drops tho :/
right thanks
Choco could you read my text? i need some help too
I know they too much text but they fully detailed what issue i having and how i would like to fix it
okay it just got a lot weirder.
i changed the condition for cancelling the event and now both halves drop the right item....
but upon breaking one, the other won't break, what
hah that remeber me tonight when i was having a compile maven error, which must be first marked by the IDE while coding but wasnt it. But when i compiling it started to appear that eror
Those type of things make us strugglig asf
nvm, got it lmao
ok i fucking give up
for some reason commands, even vanilla ones are case sensitive
type ./gamemode the server and ./gAmemode
they're case sensitive by default
would I look in here for potential developers?
what do you need?
you could ig? idk the server rules that in depth
well like I'm not really well versed in code and I got a plugin made as the main part of my server but the dev delivered it like half completed so now I'm looking for someone to either fix and add to it or just created a whole new one, its pretty big tho is the issue\
what exactly does "main part of my server" mean?
also how big we talking?
like what kinda functionality does it provide?
wellll its like a magic based plugin with unlockable spells so like rn it has 4 different magic abilities with like 4-5 spells each. But later on im looking to add more abilities, a level up mechanic, a death ban and revival mechanic, a couple custom items, and some changes to fighting
what would be the simplest aproach for a map reset system
anyone got maybe a github repo or something i can look at?
that's fairly big tbh, yes and for now out of my capacity sadly. but here are some good devs so u'll find someone
(depending on how your wallet looks)
I'm pretty flush rn, I also have like $200 in fiverr balance after the guy scammed me
you mean like resetting a map for a minigame?
like bedwars or something?
damn. does fiverr not have some kind of protection for scam?
well it sort of does, the scam went though bc the guy delivered me a totally broken plugin but then I appealed it and got the money back. Wasted a whole month tho
i mean at least u got ur money
yeah
yeah i have no idea how the coding market works yet. for now it's a hobby lol
can't really complain
and as far as i'm concerned there's not a huge market for minecraft plugins anymore sadly lmao
BlockPhysicsEvent is the correct one btw fsr. don't quite get that but as long as it works
something like that yh
ive seen people just create a copy of the world and load it again every time but that doesnt work for me
i dont want to remove the players from the map while reseting it
I know its possible to just yeet the chunks files and put in new ones with desired data
but that does imply the players should be somewhere else
Like tping them away at least, and making sure nothing gets in the way
i mean easiest way for that would be bungeecord tbh
having a seperate server -> players can't be there
No not really, not if its just one server
This being a key requirement
ArmorTrim?
yes pls create one
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/meta/trim/ArmorTrim.html#<init>(org.bukkit.inventory.meta.trim.TrimMaterial,org.bukkit.inventory.meta.trim.TrimPattern)
do u know how to create an object
declaration: package: org.bukkit.inventory.meta.trim, class: ArmorTrim
which one
Those are the ones in game
Just pick a material and pattern
new ArmorTrim(TrimMaterial.GOLD, TrimPattern.VEX)
If you want a random material or pattern, use the registry to get one
how far is somewhere else
just in a different chunk?
Yes, thatβs a bit more problematic
ik
If they have to be in touch closely to the regeneration
is .hashcode() safe to use for uniquely identifiying Inventories? (Need it to identify chests in the world)
no
and hashCode() should never be used to identify anything uniquely
use equals()
if equals() is true then it implies hashCode() is true
but the converse is not always true
I use hashcode to identify my ints

(hashmaps btw do use .equals, inventories do hence work as map keys if that is what you are asking)
I needto identify ItemStack[] in a map (the chest contents are saved and compared in the future to contents of the same chest). I need to somehow identify the chest/inventory but also save the contents as a clone
what is the xy in the end here ?
is the ItemStack[] the key? (if I so may ask)
No that would be the value as it changes
?
Like, what is the end goal
what is the key type then????????
I am confused by the data structure you are describing
where do we put feature requests?
for the spigot API ?
issue tracker
cuz events are dumb
Ah: I want to have it so that if you open a chest again after loot generation and nothing is changed then it regenerates the loot. So right now Im saving the Inventory StorageContents when a LootGenerateEvent happens and then on an IvnentoryOpen i want to check if that same inventory is opened again and if all the contents are still the same
mate im resorting to THIS
That's what Im trying to figure out and hashcode would have been nice
Yea, but properly implementing an after event entry point is less of a "feature" request and more of a "rewrite of the event calls"
to annotate what exactly
yea, that wowuld be one of the largest redos of the entire codebase 
if even possible
sure, open an issue for it
but like
Β―_(γ)_/Β―
all i learned those last 2 days is that the spigot base is dumb :kekw:
for (int i = 0; i < 10; ++i) or for (int i = 0; i < 10; i++) π€
what is your xy here
basically
HashMap<K,V>:
stores an array
uses K::hashCode
calculates index with the hashCode (with modulo or whatever uwna call it)
if the index is already populated it resorts to equals
if equals if false it will use a backing linked list
running events before isn't dumb. How else are oyu supposed to cancel the event if the event runs after the actual thing takes place
that I need to obtain the state of the player as-is after the event concluded to apply the code I'm writing, and having the event code run once simulated and once real sounds even worse
so its highly problematic now if you'd use hashCode as K type
or well Integer more or less
++i is one or two cycles faster
I mean, scheduling things a tick after an event is not really uncommon practice
dafuq why
So yea I guess
because ++ first copies the value to another register so that it can be retrieved after adding
?issues
because
?jora :P
?jira
shouldnt something as simple as that be compiled to the faster version anyways
System.out.println(i++); is 0 if i is 0, meaning that 0 got copied
System.out.println(++i); is 1 if i is 0, meaning that 0 didn't get copied
they have different functionality
don't expect a universal "post event" entry point to be implemented any remotely time soon
MD_5 would prob be like PR it if anything
π‘
granted it can be replaced in cases where it doesn't matter
PlayerPostMoveEvent π
yeah spigot doesnt rly have a clear notion of post and pre in the api
given how much fucking changes that would be
can't we just make an annotation that wraps the entire method into a BukkitRunnable.runTaskLater(this,0)
how do annotations work exactly?
oh god
PostEvent which has an Event
and that runs after
ez
true
just metadata u equip on stuff
and reflection
and allow listening to Event goddammit
Thats how it works right? So does that mean that its a valid key option to use the Inventory.hashCode()
cant annotations change how stuff compiles
no ;-;
did you just read what I said in that message
I mean yeah if you make a compiler plugin for that
no
a compiler plugin can pick up on the annotations
since jvm does care about certain annots
but the annotations themselves do nothing
Annotations by themselves don't do shit, you need a processor
anyone got a tutorial on how to make such a plugin
bleh
its a not fun process tho
given that you literally just have to write a single util method to schedule a task for you
and pass it a runnable
I don't see the usage here
i mean GPT3.5 got faster lately
it's a) faster b) can be used by more than this one plugin
Yea, but GPT needs a competent developer to check its work
I know the concept of hashmaps I only need to know if hashcode() is ok to use...if its incredibly unlikely to overlap then its fine
it really isn't faster
to type
it really isn't faster to type
how would u pass what is functionally a method to a runnable then
it compiles down to the same bytecode when used in the loop like that
its not
i already said it
π
actually is BRunnable#runTask and BRunnable#runTaskLater(plugin,0) different in timing?
no afaik pretty sure runTask auto queues for the next tick
runTask just invokes runTaskLater with 0
ask 2 people get 2 answers lol
so which one is it
what
or does 0 just translate to 1 anyways
both answers are equivalent
you literally got the same answer
eh
0 does not exist, it it scheduled for the next scheduler heartbeat
*ah
it runs on the next tick or when a tick happens if you run this async
yeah moterius they do the exact thing, like they're quite literally identical
just that one consumes more braincells to read I suppose
Is posible to know when player touch the water?
but after the event has been processed
you can't do that though not with the API atleast
doesnt entity have a isWet method or smth
declaration: package: org.bukkit.entity, interface: Entity
right really thank
So got specific situation and now got two options to solve a problem.
I got shop item restocking each item has there custom restock time set in shop file for example after last piece is sold item should restock in 6h and etc
now solton options:
- to have runnable and go thru all items in multiple shops check if item has restocking and should it be restocked
2.run code when player opens gui shop to check only items which are in that shop section so no need for runnables
What do you think what would be better aproch
Plus there is 2 type of restocks type per: player/server
number 2
personally - I dont know if this is a good solution - I'd store a global timer for 'most recent server refresh', and store when a shop's been used last
Then, on shop open:
If that timer is older than the refresh, refresh shop 'globally'.
do something similar for player.
Your first solution is guaranteed to be worse than the second, because it iterates through everything, for all items, which is very likely to never be necessary in it's entirety
just dont do a discord oopsie and store time in seconds, what kinda nonsense timestamp is that lol
<t:1>
depends if you want timers in ticks or in real time
The standard for pretty much all time based code? The unix epoch?
It's time in seconds since January 1st, 1970
how do people
unix time is in millis tho?
use timestamps like this
Java's System.currentTimeMillis() is based on the unix epoch as well
Yeah, Discord, a chat messaging program, doesn't really need millisecond precision lol
@smoky oak I asked a spigot fork developer by the way and they said the only way to bypass it was to print to System.console(), but this didn't print out anything. System console may also be null in certain terminals, so it wouldn't have been the best option either.
The other solution he provided was editing the log4j.xml file in the server jar, which obviously wasn't the intended way to achieve this.
So I guess there's not really a workaround for it if the runtime exception method doesn't work.
tried that, no result lol. got the suggestion to use the console thingy directly
whats it called again
something something five capital letters
So in that case, what would you recommend me to do. Partially use the bukkit logger and send anything above level info as an info message?
SLF4J?
ye
cant really say without knowing your usecase. I've been messing a bit with runtimeExceptions tho, which gets rid of the stamps but adds a single line of text above the message you print to it
Bruh, this is basic java knowledge - you shouldn't forget the name of SLF4J!
if i print to console I#ve lost all hope geol
That is like developing a web application without knowing what HTML stands for!
Mainly just wanted to print fine finer finest as debug for my plugin
Preferably in a blue color
can i cancel duping items in gmc
But also keep a consistent theme, so I'll probably keep them white if the prefix is already white too
its possible to injectively change format or whatever, dont remember what I used to do but dont get ur hopes down bloedarend
Could you give me any leads? It has already gotten fairly complicated and I'm not sure where to look
Is mod development similar to plugin development?
in my opinion no
for me is more complex forge than spigot
Can i get some sort of help fixing this issue
faction appears double in points usage, should be only /faction points
right
sorry i will send it
public void sendUsage(Sender<?> sender, Command command) {
List<Command> children = getArguments().stream().filter(arg -> isAuthorized(sender) || arg.isAuthorized(sender)).collect(Collectors.toList());
if (children.isEmpty()) return;
StringBuilder builder = new StringBuilder(command.getName() + " help \n \n");
for (Command argument : children) {
if (argument instanceof SingleCommand) {
builder.append(String.format("- /%s %s %s - %s \n \n", command.getName(), argument.getName(), argument.getUsage(), argument.getDescription()));
continue;
}
builder.append(String.format("- /%s %s %s %s - %s \n \n", command.getName(), this.name, argument.getName(), argument.getUsage(), argument.getDescription()));
}
sender.sendMessage(builder.toString());
}
let send full code ok?
Its better
?paste
Also i get this output running /faction points (a faction sub command), if yo usee carefully it doesnt appear the sub command name. Just appear the root command name (faction)
basically is a coding skill hehe
@quaint mantle https://paste.md-5.net/oxekaqewoc.java there we go. I also put there the parser and the class causing the issue itself
To clarify structure is next
faction - ParentCommand
faction list -> SingleCommand of faction
faction points -> ParentCommand of faction
faction points add -> SingleCommand of points
but this.name should be returning points, shouldnt it?
Recurstion its a mess i struggle a lot with it
its necesary to use recursion in this really?
thought it was like something that'll be used in some specific cases
not even near to minecraft
oh right, i will try that thanks zacken. If i dont fix i will come hehe
In m ycase yes, because a ParentCommand represents a collection of SingleCommand and ParentCommand, but a ParentCommand can be associated to other parents. Like creating a chain of things
Yeah its a mess i struggle a lot with them haha
Because you get confused too easly
yeah this is the first version, can you give me recommendations
yes i know but i dont like third parties impl, they use weird annotations which im not a custom to them
right, but the one who dont use they are a mess
Mines is exactly the same as Luckperms, the idea of the command api structure was taken from their one
just maven being maven (to clarify i havent toch anything related to dependency-reduced)
its creates a reduce pom named "false" and with no extension π
@quaint mantle one part is fixed, now is missing the part of the sub command helping where doesnt appear the sub command name
yeah i know, but how do i do it? Im nightmare around the recursition
but why? its really simple the Parent is just a collection of more parents and/or single commands. I dont see it really messy or confusing
oh right that the problem
I will add some sort of parent field to parent object
yo is it possible to make entities invulnerable (not getting removed by /kill and so on too) or do I have to save them and load->check them with my plugin?
No you can just make it invulnerable, I am not sure the method though wait for someone
Alternative would be "serialize to file, deserialize on boot, check for entity-existance somehow and spawn it if needed"
It makes it unkillable by stuff like lava and cactus, I'm not sure about kill and ClearLag, probably not for ClearLag as it does not check for it, plus ClearLag is hot garbage
I don't use clearlag, just wanted to see how "powerful" it is
Imma probably go for the hard way then I guess
Well, if you want a clearlag plugin, you could probably just check if the entity is invulnerable or not
Which clearlag probably should do already, and if it doesn't that's just stupid by them
Im a beginner and need help.
technically yes, but you would have to recreate the entity. Only way you could make it invulnerable is if you changed how the kill command works to check if its something of yours or not.
Interesting
its like trying to stop the server from being stopped, ultimately you won't prevent it
because eventually your plugin would be viewed as malicious
Yeaah fair
So imma go with the thing on boot I guess
How would I check for existance of the entity?
on boot
Does it have some UUID I can serialize to my Entity-Database-File and then look for?
Can save the Location for sure
Entities have a uuid
location so you know you need to load the chunk to check if its still there, UUID to identify it
Yes
So basically
I make a hook on ChunkLoad
And if the chunk loads, I check if it contains any entity I need
And then load in from db
that is one way to do it
Entities donβt load with the chunk anymore
Thereβs EntitiesLoad event or something
Ohhh
Wait EntitiesLoad at ChunkLoads or what?
In other words, when is the time I gotta check for the targetted entities
Ah ok
So I need the LoadEntities event which fires for a specific chunk right?
And have a Map of which Entities are associated with which chunk
Yes
Great, thanks a lot!
The entities load event will contain which chunk itβs for
Ah yes ok
Is there a way to predict craftbukkit package version through version number or is it arbitrary
You talking about the RO.1 RO.2 naming?
yeah
It's arbitrary.
π
Sadly
I was scripting up for auto-updating my NMS
It's up to mojang when they want to bump the number. :p
sigh is there some way I could scrape that data somehow :P
Post update?
yeah
Does the bukkit method not return the full string?
it basically just reflects protocol changes p sure
Yea, Server#getBukkitVersion() should give you the full string. (Example: 1.20.2-R0.1-SNAPSHOT)
unfortuantely its not that easy for me :(
No access to spigot api here
Well, I'm making a script to automatically update my NMS version and notify me of conflicts or methods that moved if that happened
the latter part is easy the hard part would be determining the version
seeing as the Release number is arbitrary I can't confidently bump it
Im annoyed that you gotta change package names for nms
Every update the nms package names go brrr
that is also annoying
You mean craftbukkit packages?
Probably
yeah
How?
Yes plz
Is there a reason it even exists as is
When no more cb package names with versions??? When????
wait real talk then how would we know what version the plugin runs on I've always used regex lol;
Good question.
Bukkit#getServerVersion just bump it each version?
Ayooo, a reason to add @since tags??
Ye
When?
No idea
Just not relocate craftbukkit anymore
I haven't touched CB, so I wouldn't know the process or why that's necessary. Please explain.
What would the import path look like then?
org.craftbukkit.entity.CraftPlayer
instead of
org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer
ye
Iβm sure thereβs a reason itβs done, but itβs in no way required for things to work
Yes
bug choco see if he knows
10000x better
I would assume it's relocated because of the constant changes between versions. There's tons of methods that get obfuscated to other methods depending on the version used. How would that be accounted for if it wasn't version specific?
How would what be accounted for
Lets say CraftPlayer#a() points to one method in 1.20
Let's also say CraftPlayer#a() points to a different method or field in 1.19
How would that work across versions?
Just leave as is and let the devs deal with the problems?
Or....
Craftbukkit classes donβt have obfuscated methods
true
Don't they get obfuscated though?
No
Is that because of the mojmaps? I know they help us devs, but I thought everything had be be obfuscated back once compiled?
CraftBukkit is code written by Mr 5
Method arguments and fields will get obfuscated if they use NMS types
But no method names or field names will
Hmmm, I guess I just don't fully grasp how this works.
I always forget Mojang owns Craftbukkit so weird
they don't even help us maintain it π
what are they busy making a game or something
If you take the method CraftPlayer.whatever(Player NMSplayer)
After all compiling and reobfuscation you will have
CraftPlayer.whatever(a NMSplayer)
Obviously a isnβt the obfuscated name for player but you get the idea
Ok, I understand that part of it.
Am I thinking of how it was done previously? Where spigot methods being obfuscated would not equate to the same method across versions?
Wait, nevermind. I think I'm misremembering part of this.
Spigot and craftbukkit methods have never been obfuscated
If I target experimental branch for the thing I'm testing out with craftbukkit that will include the registry changes right?
whats the difference between asyncchatevent and chatevent
is async just a replacement for normal
ideally
is it only me or itemstack[].clone() doesnt work
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
You are trying to call clone() on array?
yes
ItemStack[] originalArmor = player.getArmorContents();
ItemStack[] newArmor = originalArmor.clone();
// <modify enchants to newArmor>
player.setArmorContents(newArmor);
// <does stuffs for 10 seconds>
player.setArmorContents(originalArmor);
Cloning an array is a shallow copy
You're only cloning the array not the ItemStacks in the array
meaning if you modify a item stack in originalArmor it will change the item stack in newArmor
since they're the same item stack
how do i get over this
is there a way to do it
properly
instead of just keeping track of everything in originalArmor?
getItemMeta does return a copy
So you can just store that if you're only modifying enchantments
ItemStack is cloneable as well. You can just clone each element.
But this looks like you should write more classes for this. Something like TemporaryEquipment which uses the PersistentDataContainer of
the Player to make sure he gets his items back when he disconnects and doesnt drop his new armor etc.
Hi I have a discussion with a fellow developer and wanted to ask your opinion on the topic.
Which of the following implementations is more of a kill to the Server ?
- To run a one second timer which loops throw a list with 10.000 elements and subtracts from a variable one if it reaches zero it executes a method
- To add the 10.000 elements to the BukkitSheduler as a AsyncTask
Edit: Every element has a different time when it reaches the point where its method should be executed
There is a tremendously better approach using a PriorityQueue.
Anyways, could you explain what 2 actually means? Do you just iterate like
in 1 but with an async task?
Or are you speaking about adding 10k async tasks to the scheduler
In 2. I just schedule the task to when the method should be executed. 1 and 2 executes the same method
For example it should be executed in 2 min.
- Would cont from 120 down to 0 before executing the Task
- Would execute it after 120 seconds passed
Yeah adding 10k tasks to the scheduler is a pretty bad idea.
But so is iterating over a list and decrementing a timer in each one.
what are you doing in the first place to have such a problem π
Let me write you a mock impl which outperforms both by a mile. One sec.
taking the breaking of blocks in a region and replace them after a certain time
decay?
no - it sets the block back to its original state before it was broken
So if you break a Stone it will be there again after a certain time
sound like you're doing some kind of prison mining system, did i guessed correct ? π
is the variable that you're talking about subtraction, is it per element based (integer per block), or is there one for the region?
per region and block
Here. This outperforms both approaches by a landslide.
public abstract class TimedExecutable implements Comparable<TimedExecutable>, Runnable {
private final int executionTime;
public TimedExecutable(int executionTime) {
this.executionTime = executionTime;
}
public int getExecutionTime() {
return executionTime;
}
@Override
public int compareTo(TimedExecutable other) {
return Integer.compare(this.executionTime, other.executionTime);
}
// Its abstract and implements Runnable
}
public class TimedExecutionManager {
private int currentTime = 0;
private final PriorityQueue<TimedExecutable> executables = new PriorityQueue<>();
public int getCurrentTime() {
return this.currentTime;
}
// Insertion is O(log(n))
public void addExecutable(TimedExecutable executable) {
this.executables.add(executable);
}
// Run this every tick with a single task
public void tick() {
currentTime++;
while (true) {
TimedExecutable next = executables.peek();
if(next == null || next.getExecutionTime() > this.currentTime) {
break;
}
next.run();
executables.poll();
}
}
}
thanks
Wait there is a flaw. It needs to peek for the first element
how is it better if it runs every tick rather than a second, sure its in fine granularity, but im pretty sure it doesnt improve the performance, since it still iterates through the collection of data
No it doesnt
The queue is sorted by the time to execute. And it only polls the elements from the queue until it reaches one that is not
due for execution, which makes all 9999 elements before that also not due, meaning we can just break very early.
yea, that i've just realised before you typed that
i mean yea its better, since you poll like only 20% (my rough estimation) of data instead of iterating them all
i like it
im gonna use it probably by myself π€ \
What would be the difference to execute it every tick and second
tick runs every 1/20th second
Run it every tick if you need a more precise time scale. Otherwise you can run it every second.
Depends on how you define your time scale.
But performance wise there is no difference. Maybe a few nanos each tick.
you have more precise time in that case, but for blocks that are returning to the previous state its not really advantageous to have it in such small scale
unless its some kind of competitive disadvantage
okay thanks fore the greate help and info π
Btw if you dont look for timed scheduling but throughput optimization each tick then i have a guide for that:
https://www.spigotmc.org/threads/guide-on-workload-distribution-or-how-to-handle-heavy-splittable-tasks.409003/
is there any way to run code in the minecraft main thread instantly, without waiting for a tick, after running the code in the separate thread?
ik some NMS methods have some methods to do this afaik, but is there any api calls to support that
why
I dont see how that would be possible as you cant just interrupt the code flow. You could maybe append something to the end of a tick
if the executor service looks into the tickables afterwards again. But then you are pretty much on par with running it next tick.
I've got a var a = switch { ...
piece of code. One of the cases requires logic inside it. How can i make the result of the switch differ depending on a bool?
return var says its returning out of the method
Plz elaborate a bit more, I don't exactly understand the question
ah yield keyword
var time = switch (material) {
case OAK_LOG -> {
if(this.boostActive) {
yield 20;
} else {
yield 10;
}
}
default -> 0;
};
bc inventory might be null at that point
yes it can if you click outside
If you click outside of an inventory
ah
*PS The inventory can only be null in old garbage versions
Ah getClickedInventory, not getInventory
Well. You didnt use any build tools. So you need to manually add your dependencies to the IDE.
Use maven or gradle, then you wont have this problem and any IDE can open your project.
i was think eliscape has maven
but how i see
this not have
how demm this eliscape work
why plugin.yml not in resurces

Eclipse supports maven just fine
whgat?
config.yml and plugin.yml in scr
Because you dont have a resources forlder
this not eliscape system?
i just not have derictory??
i mean were gradle or maven exists in eliscape project
i not see it
what is eliscape π
Hes either not english or using a phone or bad keyboard
i rus
hmm is it worth it to trade object allocation for less null checking in the end?
i mean memory is tad bit cheaper than cpu power
especially in spigot i would trade ram for a bit more free cpu time any day. Most machines have plenty of ram nowadays.
because in 1.18 get error?
what does the error say
i havent used bungee's chat components for a while (adventure api ftw)
Wrong import
it literally doesn't matter, that's like nanoseconds if not picoseconds (depending on the cpu), a single minecraft tick lasts (ideally) 50 million times more than a nanosecond
Okay but whatβs the overhead on using optionals
the memory overhead is larger than the cpu overhead
negligible
and it is negligible in modern jvms
neigillibleble
.
import
if you have to worry about stuff like that you should probably switch languages

but im not sure
ok
Thats included in spigot i believe
But they are just a worse option than null checking in pretty much every case
eh, it depends on your project structure really
they are not apt for every use case
idk im just suggesting things since i havent used spigot's components for a while, adventure api suits my needs better
Boo
yooo
get always the error
I wrote a micro service once where everything that came in was wrapped in optionals and
everything that got out was unwrapped again. Internally null was not allowed. Was kinda nice
but also a bit exhausting.
tell spigot to add more api
I mean
Just change your import my guy...
The component PR is still there
merg merge :whip:
Optionals should be fake classes which get compiled by the compiler into raw null checks
there isnt an import
valhalla goes brrrrr
What do you mean by that? You need to import the right package.
Didnβt adventure use to have a serializer for bungee components
But they dropped it
pretty sure that still exists
i have resolved
Ah, maybe the issue is just that bungee components donβt work in most places yet
New mc block coming in 1.21 π
yea
They could also just give us the tools to add blocks via resourcepacks.
Same for proper UIs and entities. Then they dont need many more updates.
its so good
bedrock have proper ui's iirc
I think they are coming soon tbh
The configuration phase is interesting
yea tbh minecraft update by update is being more and more configurable
Slowly but surely
Tis why we need to figure out a spigot api for datapack content soon
custom dimensions, sky colors, biome colors, fonts, client entities
these are all possible to do nowadays, which was unimaginable in 1.8 without hacks
this would be cool. bedrock already has something like this
Idk if itβs possible to move plugin loading before server loading without fooking everything
What about a premain class in plugin.yml
no lol
Kek
this wouldnt make sense
I mean, a certain spigot fork does it
Not moving the current method calls
but why
i mean if that would be case, mixins would probably be the best solution for this, like some kind of fabric loader
not that mixins would help there either beyond being glorified reflections. You don't need to change logic for your registries
you just need to be early enough to mutate them

I need to look at what parts of CraftServer actually need the backing server
does anyone know of a way to add more item drops to BlockDropItemEvent#getItems(). in spigot it's illegal to add more things to it which i think is dumb, but could i force this using reflection or something
^
Unfortunately it does not
how so
Adding drops means other listeners would see them
i mean its not legal for a reason
thats what i want yes
(I actually have no idea why it's not allowed)
why not trigger another block drop item event
md5 doesnt even know either
lol
and its legal on paper and purpur
so it seems to me like it just might be a relic of the past
try it and see then ig
wdym lol ive already tried it
did it not work
it throws an illegalstateexception on spigot and its fine on paper and forks if you add drops to the list
then sounds like its not legal
πΏ
It's documented on spigot that you can't add to it
i know thats not my question lol
But there isn't really a documented reason why
hi
hello
i wish you could draw skins
Hmm
wdym, you can draw skins
i would prefer if other plugins could see those drops
I do see one issue adding would cause
It's expected that the items aren't spawned in the world yet
There is no way with the spigot api to create an item that isn't spawned in the world yet
right
seems a bit weird for them to be using item entities to begin with
instead of itemstacks
True
But it does let you modify the entities which is nice
Mmm yeah it looks like it would be fine to add new stuff to it
though it seems rather inconsistent to then allow the removal of items even though they're already meant to exist
if removing an item also removes the entity, how come adding an item doesnt simply add an entity
It could
The problem is there's no way to add an unspawned entity
Since you can't make an unspawned entity with the api
*yet
then i dont get how getItems() already contains a collection of item entities lol
internals can offer you those entities
Because the api doesn't make them
you can but implement 50000 method :(
When the api creates an entity, it has to be added to the world
ah
NMS does not have such requirements
nms πͺ
However there is currently a PR in progress to add such functionality
this is #help-development
so?
That's something that would be better in a modding discord
i don't really understand
Spigot doesn't touch any client stuff
the anticheat?
yes?
nor edit them
i dont want edit it, only get
the brandname?
Or anything server side
How do anticheat get it?
they usually dont
iirc
hacked clients can simply choose not to
But obvsiouly a cheat client isn't gonna tell the server they are using a cheat client
its like a child asking entrace into a pub saying they're 20 years old and the bouncer is blind so they just believe em, you can just be dishonest with the server about what you're using
If life was that easy we would have 100% effective anticheats
I didn't understand why anything I'm not English but still you're a poet
Or just don't tell
you have better chance to ask the player "hey are you cheating?" π
server cant know hacked client is hacked
Unless the hacked client is very dumb
is the best mode
the player, with stacks of netherite in 10 minutes, "no"
Feels like you've been watching the world from my perspective in the past couple of months. π₯²
luckily the average cheater is pretty damn dumb
yeah im just randomly tunnelling and finding diamonds at every corner man idk what to tell you πΏ
why
tunnel
I won lottery today so thats why
my dad works at microsoft and told me where the diamonds were
No
He configured the server if you ban me mojang will block the server and you won't be able to play anymore
of?
also give me op thanks
a bukkit itemstack?
"its just a resourcepack"
same with griefers who do all of their griefing the moment they go on the server
they grief for like an hour and then coreprotect be like mmmm yeah cool story
all your hard work gone in 3 seconds
So if youβre using protocol lib it should have a getItems() or getItemStacks() method to modify
Which would use Bukkit ItemStacks
im not actually
imo i would say no
but probbaly yes
depends how much obfuscation u need
but a sane person should use protocol
is there like some downside to it maybe in terms of performance to not use it in projects
or just if you dont want your plugin to have that extra dependency
in performance? if i were to do a guess doing nms yourself is better
not forcing your userbase to use protocollib
but you need to keep it updated yourself then
but nowadays nearly every server has it
cuz people are noobπ
but protocollib does practically the same under the hood as you would do with nms
i just dont like the api
but its the best you can go for
how do i make a custom mob ignore one player but stay hostile to the rest?
i'm making a custom warden inspired by jujutsu kaisen and i want it to not attack the person who summoned it but still go for every other player
public class Mahoraga extends Warden {
public Mahoraga(Location location, Player player) {
super(EntityType.WARDEN, ((CraftWorld) location.getWorld()).getHandle());
this.setPos(location.getX(), location.getY(), location.getZ());
this.setCustomName(Component.literal(Common.colorize("&lMahoraga")));
this.setCustomNameVisible(true);
this.setHealth(60f);
}
@Override
protected boolean shouldDropLoot() {
return false;
}
}
use the attack nearest entity
goal something
it has predicate
entity target event π¬
GROSS
oh i can't send pic
Modifier Constructor
public (Mob mob, Class<T> targetClass, boolean checkVisibility)
public (Mob mob, Class<T> targetClass, boolean checkVisibility, Predicate<LivingEntity> targetPredicate)
public (Mob mob, Class<T> targetClass, boolean checkVisibility, boolean checkCanNavigate)
public (Mob mob, Class<T> targetClass, int reciprocalChance, boolean checkVisibility, boolean checkCanNavigate, Predicate<LivingEntity> targetPredicate)
π
Yea NMS is way easier maybe if you're too lazy to update yourself you use protocol lib but otherwise nms is easier IMHO. With the mojmaps I see 0 reason to ever use something like protocol lib unless your uncomfortable with multi module projects
hahaa
i haven't touched that method
but i imagine it sucks
ah i remember how i tried to add custom items to craft on 1.12.2 api
using reflection and hashmap instead of map on java 8
Never a better method to learn
NMS been never been easier to use NMS
don't you basically have to make a new project for each version
module
thats why i linked this
Yeah it takes like 1 minutes to update if nothings changed which a lot of times it doesn't tbh unless you use nms a ton
lol
i included multiple spigot api's when been on eclipse
Hell I'm making a script to update for me atm
Bungee is multi module afaik
oh maybe i got confused with using paperweight maven multi module
If you use paper you gotta use gradle modules
yeah
public static Object getHandle(Player player)
Method getHandle = player.getClass().getMethod("getHandle");
return getHandle.invoke(player);
}
π no multi module :)
You still need multi module with reflection
Because the obfuscated fields change every version
Idk why anyone would ever use reflection its just harder
Ig you could make a pack for each version in one module but that's just harder
Also it'd be better to use MethodHandle here
multi module def better
but i haven't used it for javaplugins
what's the difference between paperweight and spigot's (i don remember the name)
one is a gradle plugin the other a maven plugin ?
paperweight offers you papers NMS, spigots spigots NMS
Spigots is objectively better(not biased)
?nms
Some instructions on how to setup mojmaps here
minecraft doesn't support java21
It came out a few days ago innit
one month ago
gradle doesnt support java 21
too
sad
so....?
21 wont be lts anytime soon
They're working on it
21 is LTS
oh
it sure does
java 8 is not bad, but some companies still use java 1.5 and 1.6 even today
its not that bad, but compared to 17 or 21 with virtual threads, its a bit heart breaking
minecraft client does support java 21
client and server support it lol
you tell me, i can
then what was the question!
you can, but tools like gradle doesnt support java 21 yet due to some issues with kotlin, so its tad bit difficult to either use maven or other build system
oh just use maven
theres gradle 8.4
it doesnt support running gradle
Yeah but you can't run it with Java 21
only compiling java
I love gradle when I need to use it, but maven is just easier for my poor eyes
its quite opposite for me
gradle is easier imo
when i see so much noise with xml my eyes are bleeding
apache vs nginx π€£
xml might make spelling mistake or mis tab
after all XML wasnt designed for such tasks
eks em el
in my native language i would pronounce : iks mmm le
icks em el
weirddd
I have an InventoryCLickEvent and want to check if the clicked Player is taking any kind of damage or is falling. Is there an easy way to do it or do I have to check the corresponding events and update a bool or smth like that?
You would have to make your own booleans for isFalling and such
so based
no gradle is good
hi ```@EventHandler
public void ItemInteractEvent(PlayerInteractEvent event) {
Player player = event.getPlayer();
UUID playerId = player.getUniqueId();
ItemStack OffhandItem = player.getInventory().getItemInOffHand();
if (isOnCooldown(playerId)) {
return;
}
if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) {
// Check if the player is not eating or performing other right-click actions with a different item in the offhand
if (!player.isHandRaised() && OffhandItem.hasItemMeta() && OffhandItem.isSimilar(createSpeedGemLVL3())) {
if (!player.hasPotionEffect(PotionEffectType.FAST_DIGGING)) {
player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, HASTE_DURATION * 20, 1));
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 200, 4));
setCooldown(playerId, COOLDOWN_SECONDS * 1000);
startHotbarCooldown(playerId);
spawnWhiteParticlesAroundPlayer(player);
player.getWorld().playSound(player.getLocation(), Sound.UI_TOAST_CHALLENGE_COMPLETE, SoundCategory.PLAYERS, 1.0F, 1.0F);
player.sendMessage(ChatColor.GREEN + "You Gained Speed 5 and Haste 2 for 10 Seconds!");
}
}
}
}``` i have made a right click ability to activate on right click but it is aslo activating whenever i eat food or open chests etc can anyone help
What about getNoDamageTicks or is that smth else and getFallDistance ?
Hmm, try seeing if whilst taking damage the damage ticks are like -1 or 0. Not sure if this is expected output
getFallDistance isn't accurate for what you want to do.
check if a player has taken damage in an inventory click event
But getFallDistance seems to work when clicken and falling π€
And getNoDamageTicks gives some numbers if there is damage and 0 if there is none at least thats what my quick testing shows
Its a Teleporter Inventory and I want to prevent teleporting while falling and damage
well what do you want to define as "is taking damage"?
like do you want to close the inventory when a player takes damage or what
you need to do that with events
Nah I just dont want to teleport the player in the InventoryCLickEvent when he clicks a head of a diff player
ok but whats with the "is taking damage" part
do you want to have somekinda "is in combat" feature where the player cant teleport while in combat
@smoky oak I've settled with this. This way I still get colored messages for severe and warning, and for all other messages it shows the level as like a prefix.
/**
* Send the logging message if the level is below the logger's level.
* @param message The message to send.
* @param level The level of the logging message.
*/
private fun send(message: String, level: Level) {
if (this.level.intValue() > level.intValue()) return
val string = "$name${level.name}: $message"
when (level) {
Level.SEVERE -> Bukkit.getLogger().severe(string)
Level.WARNING -> Bukkit.getLogger().warning(string)
else -> Bukkit.getLogger().info(string)
}
}
Yeah but just very basic (fire damage or player hit) but not like a whole system for it just very basic to prevent most cases
right
so you listen to a damage event, can filter out what you do and dont want or whatever
have the class have a map with a uuid key and long value
when the player takes damage, put the current system time plus, say, 5000ms
then in your click event check if the current time is under that, if so, they're in combat
Yeah good idea but isn't noDamageTicks fine for my case?
otherwise go ahead
nodamageticks can be modified by other plugins and will in most cases be 0.5 seconds
OK I think it will work for me then thx π
who worked with eliscape, is maven needed there? They keep throwing me a project without Maven wth
How i can get Client Brand Name?
Needed no
Recommended Yes
i mean someone use jar for it lol?
BukkitAPI jar lool
?
if dev not use maven or gradle how he load api? Use jar?
You add it to the project manually
should be a tab for that somewhere
Haven't used Eclipse in 5 years so π€·ββοΈ
Though maven would make maintaining the plugin easier
jar yes?
And you wouldn't have to push libraries to version control
you either add it to ide, or specify all the .java files with javac
yea but this old practic
its still used till this day, its just that your IDE does it for you
If you want modern practice use maven or gradle
I guess that means eliscape Dev users are 60 years old lol
and there are no zero cost abstractions, riiighttt???
no
You can use maven and gradle with Eclipse
ant!!
I looked at ide and it seems very inconvenient to me
Eclipse IDE is not bad, but its plugin management is the worst
yes but why devs use this ide
Because they like it π€·ββοΈ
half of the links on the plugin store, are literally dead
Because its a middleground between text editors and heavyweight ide's like intellij
well eclipse isnt bad, there are just better variants out there
its fast, uses less resources

