#help-development
1 messages · Page 382 of 1
It wont slow your server and if an entity despawns then its whole data will ofc be deleted
alr
tysm
how do you get the projectile or arrow entity that was in the air before in an EntityDamageByEntityEvent?
getAttacker()
thats the player right
-> then check if instanceof Projectile
ah
The attacker will be the arrow entity
oh event.getAttacker() is not a thing
Wrong event
hm?
EntityDamageByEntityEvent not EntityDamageEvent
Ah getDamager()
so if I checked before if the cause is damagecause projectile do I still needa check if the damager is instance of projectile
or just getdamager
Yes. Only check with instanceof
alr
so if getdamager is the entity projectile, what is the player that attacked you
or are they the same..
Not sure if this is the right place for this, but I am making a chess plugin, and I am curious how I can go about making a full sized board (8x8). I am using the unicode system for the icons and textures. Does anyone know of a way to allow the player to easily control every piece from the menu, and not external commands?
Where is this chess board located? In an inventory? On Blocks? On a Map? In Chat?
How do you get the player that attacked in an entitydamagebyentity event if getdamager is the projectile?
sorry, I forgot to mention that it is in a inventory. (or at least that is what it is right now, not sure if there is a better way)
Would anyone happen to know how to get a specific light block (eg. light level 12) as an ItemStack?
Unsure if this information is useful but this is the command to give it: /minecraft:give Dav_e_ light{BlockStateTag:{level:"14"}} 1
Well then clicking the figures is the way to go. Properly displaying them is a bit harder.
You can try custom textured heads.
but that doesnt change the issue of the inventory being 9x5 and the chess board being 8x8
Ah i see the problem... Well nothing you can do there.
I know it is possible, I just don't know how. I saw someone use an entire screen worth of space and have everything clickable (no mods, vanilla and a resource pack). They mentioned it involved core shaders.
Some meh ideas:
- make the inventory scrollable
- Use the players inventory as well
Someone managed to make something like this, with the whole thing interactable. Like I said above, this was done with core shaders (which I have no clue how or even what they do)
They act like it took no work at all.
tf..
I can share the link to their discord, there is a bunch of cool things like that on there.
For that you need custom resourcepacks
I mentioned that I am using that
with the unicode system and all
Well you can abstract quite a bit away. Programmatically this is not too much work.
Most of the work lays in drawing the textures.
Well, I just don't understand the actual concept behind it. If I knew how it worked and how it could be replicated, then I could work out the drawing and stuff later.
Well if you use a resourcepack then you can just create a 9x6 inventory, use the players inventory as well (3 rows) and
use a replaced inventory name as a chess board texture. The pieces can be actual ItemStacks.
hmm
Any sources for this?
With just a renamed inventory you can do a lot:
What is the issue then?
I just wanted to know if there was a way to get an interactable gui bigger than a regular inventory, since obviously others have been able to achieve that.
and if I use the player's inventory, then I get the Inventory text and the gap where it isnt interactable, which wouldn't be very pretty in production.
holy pretty
yep
bedrock or java?
Java
Honestly i couldnt figure out how they did this by now. What informations do we have?
nothing. I contacted the guy and all he told me was it was core shaders.
he didnt say anything more, and I didn't feel like being pushy was the right way to go.
they obviously werent directly stating how they were doing things, and that is probably from a business standpoint. If you let your competitors know how your entire business operates, what stops someone with more resources from out pacing you and stealing your marketshare.
Yeah the shader part i understand. Those are just some opengl shaders.
But how are they registering the clicks?
yeah, I got no clue.
oh damn each button is actually its own button and not like a collection of slots?
this would be fire if we could figure it out cause id be able to make everything ive wanted to in terms of ui
Let me take a look at the protocol... Maybe there is some packet which sends screen space locations.
Im making anvil rename gui, how to remove cost of rename? I tried this:
@EventHandler
public void handleMenu(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
AnvilInventory anvilInv = (AnvilInventory) e.getInventory();
anvilInv.setRepairCost(0);
if (e.getSlot() == 2) {
//ItemStack item = e.getCurrentItem();
ItemStack item = anvilInv.getItem(2);
String newName = item.getItemMeta().getDisplayName();
FactionRankUtils.rename(faction, rank, newName);
p.closeInventory();
p.sendMessage(ChatUtils.format("&aÚspešne si premenoval rank &e" + rank + " &ana &e" + newName + "&a."));
return;
}
p.sendMessage("Slot: " + e.getSlot());
}```
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/AnvilInventory.html#setRepairCost(int)
declaration: package: org.bukkit.inventory, interface: AnvilInventory
In the PrepareAnvilEvent
Oh, I cannot do that in InventoryClickEvent? daaam, that's complication 😄 So, chatGPT is dump 😄 I tried that (ChatGPT) to create this GUI, and it suggest me to do that in InventoryClickEvent.
Thank, I will take a look on that
Hmmm, event is not called with custom anvil inventory. But, if I clicked on anvil and start renaming some item is working. Any ideas?
Im using this to create and open inventory, mby thats a issiue?
Inventory inv = Bukkit.createInventory(this, InventoryType.ANVIL, ChatUtils.format(getTitle()));
player.openInventory(inv);
So far every answer on chatgpt I've seen is wrong
It somehow looks correct but something or multiple things are always wrong.
Ye, I just want to try that and save me time on google 😄 but.. better to google thinks
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
❤️ ty habibi
Any ideas why is PrepareAnvilEvent not called with custom inventory?
Bigger in what way?
As in more slots?
We where speaking about how interaction in this is handled:
#help-development message
Why unstackable items get stacked when I use reload
First of all: never use reload. It breaks half the plugins
almost everyone said and its true, but why this happens?
nah ignore me, will be return with more info
Is that entire bottom row interactable? Doesnt appear so
If not then getting the sides to display like that isnt hard if we are not worried about interacting with it
You might have a point. Maybe its just visual
But what about this one
https://cdn.discordapp.com/attachments/1064182580569722981/1066805287459225640/image.png
A chess board has 8x8 tiles. How can this fit in an inventory...
You would use two inventories with custom textures to hide that sliver.
I thought 6x9 inventories arent possible anymore. So there would be a gap between top and bottom inv
The gap is visual only
So you would just use a custom texture to remove the gap
But player inventory and double chest inventory has enough rows and slots for a chess board
This gap doesnt look visual-only to me
This is where the shaders come in. Smoosh the graphic enough and its gone
I know that in earlier versions you could create one more row which would create a seemles big inventory
Never call anything main
Recommended to name it after your plugin or related
You only name it main if its the main class of the entire program
Even then you would go for something like Application
Well i wasnt counting plugins as programs exception being ones that can run standalone in which case application is more fitting
Those are typically called manager classes. But for plugins typically your main class is named after the plugin or a short name variant if its a long name lol
This weekend i will look at the code. It might still be possible to add that extra row just buried or something that it doesnt make it really feasible to have the api do it for you like previously
Been needing to decompile the client anyways as well
AbstractManagerFactorySupplier (/s)
DataFixerUpper.function10
Everything
Sounds good, let me know what you find. I will continue looking into this as well.
Well... Its a decent troll.
if player is in survival -> put him in creative
else -> put him in survival
Thats the short form of your code
This will break console commands
Blindly casing CommandSender to Player
Yes
Sure if it helps you learn then go for it.
Also: You fool nobody with your new name Bettanation 😅
Sure thing
What about a default case?
@Override
public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) {
Player p = (Player) sender;
if (sender instanceof Player) {
if (p.isOp() && cmd.getName().equalsIgnoreCase("/gmswitch")) {
switch (p.getGameMode()) {
case SURVIVAL:
p.setGameMode(GameMode.CREATIVE);
break;
default:
p.setGameMode(GameMode.SURVIVAL);
break;
}
}
}
return true;
}
why are you manually checking the command's name? also it'll never be equal to "/gmswitch" unless the player entered "//gmswitch"
also you should use proper variable names instead of "p"
also why do you have 3 times the same case?
case ADVENTURE:
case CREATIVE:
case SPECTATOR:
p.setGameMode(GameMode.SURVIVAL);
break;
case SURVIVAL:
p.setGameMode(GameMode.CREATIVE);
break;
wouldn't that be much easier?
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
also why are you manually checking whether the player is op instead of just using a properly defined permission in plugin.yml
Permissions are so last year
your mum

this kinda seems overly complicated to me
I like how he just says he's gonna make a resource then just does it
why not just write "yo, add a string PDC tag to your items to identify it"
Ah true... my bad. Let me scrap that.
XD
this indeed looks like an overly complicated approach to me
where's the MyCustomItemFactory that implements Factory<MyCustomItem>
Really? I tried thinking about the most basic approach i did back when i started using custom items.
What critic do you have?
that it is overly complicated. I'd simply attach a string to the ItemMeta, e.g. "my-custom-item-id": "explosion-sword"
yeah and that's it
i dont wanna say that using all this enum stuff is bad, but it's definitely overly complicated, especially if it's written for beginners
Ah i see what you mean. But this is the basis for the next step in the tutorial where i linked functionality directly to the types
But i can see what you mean...
as I said, it's definitely useful, but I still think it's way too complicated to be targetet at "beginners" in spigot plugins
for example I didnt know that enums can have abstract methods
Maybe i should prepend a short section for actual beginners.
that'd be nice :3
intelliJ also really doesnt know about it lol
it only stops complaining when you actually add an enum value (and implement that method inside that) lol
why do you still have 3 same cases?
he means use switch fall through
^
you can make it even shorter using lambdas
but it might become a little harder for most to read
that's going to throw a ClassCastException if console runs it
look at the order you do the cast and instanceof
yep, you cast player before testing
looks fine without any extra flashy syntax sugar
Once you learn this you can move onto bitshifting instead 
?
on modern java you could make it something like
@Override
public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) {
if (sender instanceof Player p) {
if (p.isOp()) {
p.setGameMode(switch (p.getGameMode()) {
case ADVENTURE, CREATIVE, SPECTATOR -> GameMode.SURVIVAL;
case SURVIVAL -> GameMode.CREATIVE;
});
}
}
return true;
}
that is so much more ugly
imho
Joking mostly but game mode is just a bit mask
In the packets and nbt data yes
hm yeah okay lol
Wait, so you can theoretically be in both creative and survival at the same time? lol
You could OR the two bit patterns together and send it in a packet but the client would probably freak out about it and not do what you requested
So yes but also no
I said theoretically for a reason lol
And I answered
ORing bit patterns in general? or what
Nah, gamemodes being a bitmask
I use bit twiddling all the time
It's certainly an interesting design choice.
Minecraft in general is a series of interesting design choices
True
Ah, well that answers that
Yeah i was looking at that to see iv they changed and it seems they have
im inclined to think he meant they're just bit patterns.
0 => 00, 1 => 01, 2 => 10, 3 => 11; so theoretically you can Creative | Adventure => 01 | 10 => 11 which is spectator game mode
but 🤷♂️
(what isn't a bit pattern tho)
011 isn't 3 but 4 or am I stupid
011 is 3
If it were a bitmask, any invalid ones could just default to one of the valid gamemodes. Most likely survival.
11 is 3, 1 + 2
confirmed, I am stupid
No i remembered them being bit masks for values so 2,4,6,8
there i fixed that now
But doesnt surprise me they changed though
Mojang likes changing everything
All well guess no bitshifting for that then lol
6 isn't a power of 2, yeah
Ah maybe it was a grey code
It's 1, 2, 4, 8, 16, 32, etc. Each bit represents a power of 2.
Yeah but why? Makes no sense because we dont have many flags but just a simple enumerated value
You still talking about gamemode being a bitmask, because I think that was already disproven (or at the very least, recently changed)
Im talking about why it would be a bit mask in the first place
Maybe there was plans to mix gamemodes, or gamemodes were setup differently internally. Nobody (but the people who made that system) can say for sure.
it was probably always just 0, 1, 2
Maybe, I don't know. I haven't really looked into how Minecrafts netcode works, when I write my code, I just accept the fact that (in most cases) it does.
In terms of packets and storing wise easy to check and compact. But mojangs view on data seems to be the opposite now. Instead of compact going to store more because everything practically being strings lol
Having a bitmask for a field that isn't used as a bitmask would increase the size of stored data. This is because in a bitmask an entire bit is reserved for a single state, if that were the case with say 4 gamemodes, you are already using 4 bits when you could be using 2 (the numbers 0, 1, 2, and 3 can be stored using only 2 bits.)
well it'd be the same, it's a "byte"
Strings are also useful for networking, since every machine is different strings are probably the safest (if not a little bit expensive) way to send and receive information.
If we are talking about compacting data, that byte can have multiple purposes if not all of its data is used for one purpose.
You want to talk about weird design decisions. Why is it that the player gamemode is stored as an unsigned byte while the previous gamemode is signed? You would think they should be the same.
it could, but mc doesnt do that, never did
It gets converted to binary anyways for packets. And i was talking about when it was a bitmask not talking about what it is now
because it says it could be undefined, for example when they just join
i also wondered about that when I looked through ViaVersion lol
it says it right in the description
I fail to see how that would be the case considering that there is a default gamemode option defined in the server properties.
or if they haven't changed gamemodes before
it looks like a potentially optional field, only used in the debug panel
so if you dont want to share it, just send -1
which is fine
why does it not keep track of yesterday's time, or last week's health, why only previous gamemode
cause that's not shown in the debug panel?
yeah but that exactly is my question
why the heck does the debug panel show my PREVIOUS gamemode
refer to this
that is true
Wait, has the debug menu started showing that information?
I still wonder who thought "ah yes, lets show the PREVIOUS gamemode, that might be useful to some people... yesterday"
who decided that haha
I think minecraft stores previous gamemodes because there is a shortcut key to swap gamemodes back and forth
there is?!
There is and that's what it's used for
there is a key to swap gamemodes? o0
How else would it know to set your game mode to when you come back?
Hold F3 + Tap F4
so it would be -1 when the gamemode has never been changed, which is why it's a signed byte
in that case, the "old" and "new" gamemode would be the same
Not necessarily
make a plugin that collects random animals if you're holding a certain item, then makes them follow you around when you type a certain command i guess 🤷♂️ good practice if nothing else
But anyways we probably shouldnt infer too much when it comes to mojang code because as what simple said they dont always make sense in the why
@tender shard This is what the switcher looks like.
does it need to be useful?
Isn't there another key to switch directly to the previous gamemode though?
I thought there was
is that java edition? o0
Yes, it's in Java
never saw that
It's been in the game for a couple updates now.
AFAIK, there is not one. You'll just have to cycle through all of the gamemodes. Fortunately there is only 4 of them. 😛
Ah, so then that doesn't actually answer why the previous gamemode would need to be stored.
make a plugin that when you send a message like "this is a sentence", it shows it as separate messages per word, like
mfnalex: this
mfnalex: is
mfnalex: a
mfnalex: sentence
Dumb
Just tap the keybind once to switch quickly
The weird thing is that I think it's per server.
So the list re-orders itself based on what the previous gamemode was?
no the list is always the same
No, it just moves the selection cursor to the previous gamemode you had before it will continue to cycle.
F3 + N: Cycle between Spectator mode and the previous gamemode. Switches to Creative mode if there is no previous gamemode. Requires cheats to be enabled.
Cheats for single player
having cheats enabled in single player is sooo stupid
like "oh I need some dirt. well I COULD go back to my base and get it, I'Ll just /give it to myself right now, then remove it from the chest later" said nobody ever
and then one keeps cheating the whole time lol
It has been a long time since ive actually played this game...
Same. Kind of. I have a german stream who has an event every time a new version comes out and im
providing the server/plugins for that. I play in the opening days when we have 50-100 players and then
i get bored
But modded i can stay interested in a bit longer
what is the farthest distance an arrow shot from a bow or crossbow could travel??
At least 5
at most?
A bit more
We need more constraints. Max distance is achieved by a 45° angle.
But if the arrow lands below the height it was shot from then it will fly further.
Are we speaking about a perfectly flat area?
In most cases this will fly outside of loaded chunks
hm
If I check every mob in the world for meta data every tick, will it affect the performance?
Yes
but that depends on how many chunks you set as simulation distance in the world folder.
Interesting math
and there could be other players around.
Sure
that could be loading chunks in that direction.
Significantly?
Just run the test and shoot an arrow
Depends on how the data is stored and how efficient your algorithm is
to be more precise.
just checks for a value in persistent data container
you can run it an async thread.
What are you trying to do?
And just stores it that's it?
to make sure it does not affect performance on the main game thread.
yes
Idk if you could add caching to it
PDC can be a bit expensive at times.
using BukkitRunnable?
using Bukkit.getScheduler().runTaskAsynchronously();.
BukkitRunnable is just a lambda.
you gotta pass that lambda into the function.
What pdc item are you storing? Maybe it doesn't need to be like that
for it to run.
Usually you would separate the lifecycles of your data:
Entity loads -> load from PDC into data structure (Map<UUID, SomeEntityData>)
Entity unloads -> save from data structure back into PDC
Here's something that'll throw a wrench in your problem. Projectile speed is based on how fast the entity is moving, so if a player has speed while shooting a bow, then the arrow will go farther.
this is annoying
lets just assume player is stationary.
anyway, i have this database where i store permissions for the player per chunk.
and i am loading and caching chunks around the player.
i am not sure how much to cache though.
so a player fires an arrow in some random unloaded chunk, there has to be a database query running on the main game thread to check if that row exists.
What are you trying to achieve?
because events cannot be cancelled asynchronously, probably.
I want to each attack add a stack of slowness, up to 3 stacks, but I thought that in my plugin there would be a lot of slowness reasons so to separate them I make attacks add attribute modifier and add a INTEGER tag to PDC, this tag decreases every tick and if it is 0, then I remove attribute modifier
just a plugin with chunk permissions.
More detail pls. You want a permission to prevent an arrow to fly into a chunk which the shooter has no permission for?
something like that, yep.
I would just check for projectile hits and cancel those. Tracking projectiles is a hustle.
But what do you need the max distance for then??
Jeez. I hope you're using blacklist permissions instead of whitelist permissions.
i have a table in the database where i am storing chunks that a player has been trusted to, the data is loaded and cached around a certain distance of the player.
thought that would be more efficient than loading permissions for every loaded chunk for every player online on the server.
that would take up M*N time and space.
eh
too much off a hassle.
i was just thinking about this in terms of edge-case anyway, probably won't be too bad.
I think I can use a manager here like the manager you showed me yesterday, but is it a good idea to create a new manager every time I need to work with the data this way?
This means your data is now player scoped and not chunk scoped. That sounds like a very questionable idea
if you want to protect the chunks and not the players.
Create managers for every major program section you want. But only ever create one instance of your manager. (1 !)
Thanks!
No, the purpose of a manager is for itself to "manage" the instances it'll create. There is hardly a need to create multiple instances of a manager class.
one
/shrug if you ever only will need one instance, might as well make everything static
Just to make sure bc i dont wanna read "why does my map in x not contain the stuff i put in y" again
how would you implement it?
I mean if I need different managers, for example I have a manager to work with individual glow effect, now I need a new manager to work with slowness...
there can be more than one player trusted to a chunk
Yes, but you wouldn't need two instances of that type of manager.
Wait do you have several types of permissions or do you just have a binary value trusted/untrusted
its a bit complicated so, if a player is trusted, it has all the permissions.
Yes, these managers will be completely different types. Maybe I should consider making a manager generator if it is possible...
make it a ManagerFactoryFactory implements Factory<ManagerFactory> and call it a day /scnr
I don't get it. What conditions need to be met in order for the projectile to be removed?
Like, if Player1 and Player2 are trusted to chunk1, chunk2, and chunk3, that means that if the projectile landed in chunk4 that it would be removed for both of them?
"enterprise" java code is usually a big joke
if a player is trusted to that chunk or the global pvp permission for that chunk is enabled, or the chunk is unclaimed, the damage from the projectile is not cancelled.
its a bit complicated to explain in words, i will just show some pictures.
i worked for a software company in my town (INDAL GmbH) and they used FactoryFactories and stuff, and that's just weird
they also used fuzzy logic for EVERYTHING
Oh man. So each chunk has an additional flag that needs to be checked? Are you storing that data or is another plugin handling that?
Its basically:
unclaimed -> fallback
== claimed
== trusted -> allow
== untrusted -> deny
fallback -> global default
claimed (global pvp enabled) -> allow.
is how that is set up.
i mean
its a pretty standard chunk claims plugin.
global permissions.
anyway
That looks like permissions for the claim, not global pvp perms.
i think the server just has to deal with the sql query lag.
yeah, permissions for the claim, globally.
for all players.
that are not trusted to that claim.
Anyways lets go through both approaches.
Lets assume that you give each player a LongSet and simply load all trusted chunks when they join.
On average a player may have 100 chunks assigned to them (which is a lot 1600 x 1600 size)
which means we have to allocate 100 * 64 bit which comes down to 6400 bit = 6.4kBit
A very good server can hold a max of 100 concurrent players which means you need to
Allocate 100 * 6.4kBit = 640kBit which is around 0.6MBit. Add maybe 2MBit for all the
data structure headers and a bit extra which comes down to maybe 3MBit or half a MByte.
So do you think you can spare a few megabytes?
i can do that
I'd just use the chunk's pdc to store "who's the owner of this chunk"
Do you have claim groups? Like owner, member, nonmember?
and that is why i came here to ask
i am not sure about idea of M*N time and space complexity.
This is the agreed standard when it comes to chunk permissions.
Make the data chunk scoped and not player scoped.
loading trusted data for every player.
and no, i dont how many claims players may have
may be 100 or maybe 1000, idk lol, i am not using this plugin.
so i dont wanna load too much stuff.
a max of 100 players? o0
Ok but you need to average that out.
How many trusted players will the average chunk have?
Maybe a bit less in 1.19
wtf
Please, I implore you to setup a server and see it crawl to its knees once 50+ try and join.
I had a tiny Ryzen 5 3600 a year ago, using 1.19.X (whichever version was recent about a year ago) and I got about 30 concurrent players withOUT a pregenerated world, they were flying around with elytras and stuff, with solid 20 TPS. So I doubt that "100" is the limit
what was the render and simulation distance?
12
or 16? definitely NOT below the default limit
I don't remember it but I definitely raised it, or not changed it at all
i currently have an smp and it definitely struggles with more than 11 players.
in terms of TPS.
We used a Ryzen 3600 for our last event and i even pregenerated the whole map. I optimized the jvm params
and limited a lot of the common cpu hogs like entity limit and hopper actions etc. Everything above 65 got us a tick average of 40ms which is a soft limit
are you using a dedicated server?
although it runs fabric with lithium, starlight, ferritecore, and all those sorts of mods.
its a vanilla smp.
well it probably also depends on which plugins people use. I basically only had 4 or 5 plugins running
Only one plugin i wrote myself which was optimized for this. (Didnt even show up in the 1% timings )
instead of chunk scoping it, why not just load chunks in a certain distance of the player?
this way i dont have to load 1000 chunks, in case the player may have that many claims.
anyway, it's definitely possible to have more than 100 players on one server, I've worked for ElderCraft when they still had about 300~ consec players daily, and they also ran everything off one dedicated machine (however that was 1.16/1.17 times)
which is why i asking the maximum distance an arrow can travel.
Sounds error prone to me. Either load all data with the player or load all chunk related data with the chunk.
why would it be error prone?
At minimum 50 blocks because of the achievement. Probably around 4 chunks if you get the right angle.
Then it could go farther if your velocity was somehow increased.
Imagine you have an ender pearl stasis chamber and tp yourself fast enough and inflict some damage before your radial data is loaded
if u cheat, it could possibly be infinite 
yeah i know what you mean, i have optimised for that edge-case
And thats just the first thing i came up with. Players can be vile
when i said i am loading chunks around a player, i am not loading them around the player exclusively
player may have a chunk loader then running a tnt duper
or something like that
which is why i cache them as well.
or something idk, i will get back to working on it
enough procrastination.
Realistically, the farthest a projectile can go is pretty much within the vanilla render distance. You can get around 250 blocks of distance with riptide and speed. However, anything past that is due to variables outside of the vanilla gameplay.
Modern servers have a lot of ram. If you can trade some ram for less cpu usage or more robustness then go for it.
the cpu usage is not affected
actually, it is affected if i am loading M*N chunks where M is the number of players online and N is the number of chunks loaded throughout the server.
Speaking of loading things out of a database on the main thread when a chunk loads: Where is Redempt? Didnt see him recently.
https://github.com/JEFF-Media-GbR/BetterTridents/issues/5 has anyone ever encountered this issue? (snakeyaml complaining about the awareness thing in plugin.yml) o0
[16:21:29] [Server thread/ERROR]: [BetterTridents] [Configuration] An error occured while loading plugin.yml resource for plugin BetterTridents: org.yaml.snakeyaml.constructor.ConstructorException:...
awareness?
it is loaded only if it is not already in the cache.
tf? What does it do?
isnt it a very not necessary and/or deprecated tag
I've never even heard of that tag before so that's why I'm confused.
yeah it is
but it still shouldnt cause problems
when I made that plugin, this tag was still mentioned in the official spigotmc wiki article about plugin.yml
meanwhile, it's not there anymore
but it should still not fail to load, after all yamllint.com tells me it's valid yaml
How long ago? Cause I have never seen it and I've been keeping tabs on stuff since 1.6
Oh wait
Was it that weird flag that was used internally?
Like PluginAwareness.Flags or some shit?
Makes sense
Well it's deprecated in spigot too.
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/plugin/PluginAwareness.Flags.html
yeah it is deprecated
but it's not removed
the whole flag was totally useless anyway, iirc. still it's weird to just remove it
Well if it is functionally useless then I don't see why you should keep it around, but that's just me.
I am also going to remove it, I just wonder why it fails to load in paper
Does paper ever update the snakeyaml dependency?
i don't know what they do
Could be an outdated one trying to read a new format.
Or a new one that dropped that syntax
well it definitely worked in paper when I released that plugin, after all I use paper myself sometimes
if they wouldn't have banned me from their discord, I could ask there, lol
Apparently it shows as null.
Guess its not that surprising since the value starts with an exclamation mark.
it is still valid yaml, isn't it
https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html doesnt look like it
So, either put it in quotes, or don't use it at all.
a list is not a scalar
well, the identifier of the list is, but not the contents of that list, iirc
also I just checked it using paper 1.19.3 and it loads fine for me, very weird. no idea where the dude in the github issue got this exception from
it loads just fine for me lol
Yeaa, I thought it might have been used for data serialization.
Guess it just comes down to the interpreter.
yeah I'll just remove it. I'm still confused about why it errors for them on paper 1.19.3 but not for me on latest paper lol
nvm.
@tender shard It looks like spigot updates the snakeyaml dependency every so often. Version 1.30 was used for 1.18-1.19.2. Version 1.33 is being used for 1.19.3 and onwards for now. Paper probably followed suit. So maybe there was a change somewhere in those versions that had caused that error.
yeah but in that case, it must have been an "in-between" thing because it works fine for me using paper build 420 o0
which is the latest
very weird
why does IntelliJ not support tabs on windows D:
this is so annoying
on mac it's just always one window
YAML docs really are something, trying to look for stuff regarding ! brings me to "tags", idk wtf they r at all, but they show a syntax similar to urs as invalid
tags are also mentioned in snakeyamls error that user reported
have you heard about their "placeholder" stuff?
yaml allows stuff like this: https://github.com/JEFF-Media-GbR/ChestSort/blob/master/src/main/resources/gui.yml
oh woops not alias, anchor https://yaml.org/spec/1.2.2/#rule-c-ns-anchor-property
oh its anchors & and aliases *
ye
might as well have written "portugal" lol
"stop travelling through portugal, mr. trident, you can get to morocco instantly by plane"
instructions unclear, trident was stolen in Detroit
unfortunately, it gets stolen into the nether
Stupid netherlands, always stealing my trident deliveries.
yeah
fuck netherlands
their weed is also much too expensive
but they definitely do know how to properly fry fish (kibbeling)
I'd sell my left leg for some nice kibbeling right now
Is there a way to get a list of only loaded entities? Or world.getEntities() already does so...
that's already returning only loaded entities
I'd sell my right leg to be able to get a list of not loaded entities
Haha thanks!
np
Imagine what magic would be required to get a list of something that technically doesn't exist until it's loaded.
it's called MojangsonParser or similar lol
I use it to get the PDC of offline players for example
It looks like a json serializer/deserializer but for NBT
exactly
There is still the issue of knowing which region files have unloaded entities without looping over all of them.
usually all of them I guess
That's a lotta entities
yeah lol
Are entities really that common? I guess bats, but I don't like the idea of every chunk in a world having at least 1 entity when it's seemingly empty.
Plus, don't entities that aren't persistent get effectively deleted once the chunk unloads?
iirc, hostile or ambient mobs aren't even saved unless they have a custom name or anything
Nice this code takes only 0.005 seconds to run so I can do some unoptimized stuff!
if you run it twice, it probably takes less time
Keep in mind, everything all together (both Minecraft and all plugins) only have 0.05 seconds to finish its processing before your TPS starts dipping below 20.
Yes, thats clear, I will try not to overload my TickTask for too much
just overdrive the ticks so you have more ms to fuck around 
Wouldn't increasing the TPS reduce the available processing time per-tick?
Yes he was joking
but he got a point tho 🤔
just underdrive the ticks so you have more ms to fuck around 
Use reflection to inject more ticks so you can take as much time as you like.
just make /tps return a String "20 20 20" and call it a day
fixed
make your ticks negative so you have infinite ms
isn't there actually a spigot plugin for this?
i remotely recall that there's a spigot plugin that allows you to change the tickrate, but it doesnt work on paper
oh yeah that one
or you can use https://modrinth.com/plugin/limitless-tps

modrinth? for spigot plugins?
That's a Paper plugin
haha
i like the FAQ
I like how paper shot it's own leg by inventing this stupid "paper-plugin.yml" thing
hm how so?
because it makes plugins not be compatible with spigot anymore?
if someone only uses the paper-plugin.yml thing
You can have both a paper yml and a spigot yml
you can, but people won't
😱
they will read exactly one tutorial, and only parts of it, then they'll continue to just provide this paper file, and then they'll be confused about "why it's no workings on spigot uuuuh"
If people want to make spigot plugins they'll just continue to do it like normal
in a perfect world, this would happen
in a perfect world though, paper could just have used the same .yml file to add their additions
or, even better: just contribute upstream
If people misunderstand that the paper-pluign.yml is only for paper then that's not papers fault
they want you to include 2 yml files?
and I said that people will not understand this because nobody ever reads a tutorial completely, and that's why it'll cause problems
Loads of spigot plugins broke on paper bc of their paper-plugin
it's usual for paper to break stuff, e.g. them fixing tnt duping by default is already kinda stupid imho
it should be an OPTION to fix this, not a DEFAULT
oh also the API incompabilities, e.g. remember when AdvencementInfo broke after spigot added that? And then plugins using the existing paper api ofc all broke down because Paper decided they must return a component instead of a string. If they would just contribute upstream, there'd be literally no problems lol
i never understood why everyone's so afraid to sign a tiny cla that only consists of like 2 pages
I also further have to add that paper adds many useful things, like way faster chunk loading and stuff
but the whole idea of "moving away from spigot" is a bit stupid imho
Most don;t like having to provide personal info
we gotta make spigot more performant so people stay with it
why not? why is everyone so afraid of that
personal info handed out to who knows who is nto very safe
my address is Junkerstraße 17 in 48165 Münster, Germany. My phone number is 015174202224. I could continue and tell you my iban. what is anyone going to do with such info?
and as already explained, you only give that info to md_5, not to EVERYONE
impersonate you and open credit in yoru name with enough info
^^
registering with your phone number on some scam site now
Both ConfigurationSection.contains(section, true) and ConfigurationSection.isConfigurationSection(section) appears to be returning true for a field that doesn't exist... Does anybody have an idea as to why this might be happening?
The section exists in the default config.yml but not in the data folder one.
how is anyone supposed to impersonate me just by having my name, address and phone number? o0
- sending you elefant shit to your home
thast the point, You don;t actuall yknow who has access to that information. Everyone assumes it's only md5
anyone can do that already
ever happened?
they can just open "google earth" and scroll to a random place, then check the address
no but I'd love it
so i will be the first
with that info they can use social engineering to get all yrou details from yoru carrier
what do you mean with "all your details"?
there are literally NO details that I am hiding besides my reddit username and my banking pin
any that yoru carrier has. They can also get your phone spoofed
wdym with "spoofed"?
It happens often
Why hide reddit username 
because I only post nudes there
and I dont want spigotmc people to see them
Impersonate ur number from elsewhere
they clone yoru phone and basically get all texts you send/receive
spoofing your phone number to get your reddit username
I dont know how calling works but I am pretty sure that the number you call can see the actual phone number
its very common way of hacking 2fa
idk my ubikeys are safe and sound in a drawer and have never been hacked
yet
We have your address
Thats the thing about personal info, once enough of it gets out there the more you become vulnerable
We just break in and take them
if someone is so stupid and enters his username and password on a website called "wafkwuagfawfawfgawufawfawfawfa.random-chinese-server.com", it's their own fault. doesnt have anything to do with "I am afraid to sign the CLA because the code I provided is actually stolen"
and breakign in becomes quite easy, often with just a fishing rod
if anyone would actually be afraid of their "personal data", they wouldn't use discord
which is erm, quite known to ignore the GDPR and sell data to everywhere
This is why i lock my credit
I gave no personal info to discord
Can I bump this?
lol
however I did sign the cla
nobody can tell me that "randomPaperContrib" doesnt want to sign spigot's CLA because "I'm afraid of giving away personal info" but then continues to talk on their discord server haha
well. im not a fan of publishing my private info but a CLA of a verified longyear-standing project is something else
also, md doesnt even check which data you put into the CLA. you could just enter some random address
you could but it's also on Google servers
what is on google's servers?
as it uses Google to authenticate
?cla
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
when you signed the cla it was via google
As if google didnt already have personal info
yeah that is true
but everyone's data is already on google anyway
I really never understood the idea of everyone now saying "lol I don't want my data being on google"
perhaps perhaps not, it's still a reason people are reluctant to sign it
I had to think twice before I signed
I didnt think twice
i kept the tab for a lil while before i finally signed off on it
You young'uns throwing caution to the wind
Google knows where i live and i am forever in the library of congress
kinda forget now if i signed off with my legal name or my to be legal name
yeah and it's a reason that I do not understand, and also it adds a huge downside to paper:
it might be taken down anytime. someone could just message github and claim "yo that's my code": then they proceed to send a tiny fracture of code that's actually similar. Then github asks the owner of paper's repo "yo, is it true that you stole it?" then they reply:
...
what do you think? spigot could reply
"The dude who pull requested this code promised to me that he wrote it himself, here's the signed PDF:"
paper would have to say:
"erm idk"
Unless the library of congress burns down again
this was a reply to @eternal oxide btw, but I forgot to tag is as reply
How to play an animation for a player with plugin (animation aldready in client's resource pack)
wdym with "animation"
like custom animation for player, can spigot plugin send packet that play an animation in client side?
I still don't know what you mean with "animation"
like run, walk, swing arm etc... you know, player's character's animation
ah ok
for "swing arm", there's api for that, yes
run, walk, i am not sure, but I dont think you can do this using spigot API, you'd probably have to use NMS
anyway, what is the way with "swing arm"
declaration: package: org.bukkit.entity, interface: LivingEntity
swingOffHand() also exists, ofc
Hi, I have a public chat on redis and a guild chat(private) on bungee, someone knows how to block the chat packet when someone write in the bungee chat because right now when you write in the bungee chat the message appears also in the public one 😦 ?
Yes to send the message on every server, its the same of bungee but on redis
yeah I am just confused of you calling it "public"
does everyone know your redis password, or what o0
No, why? 🙂
I asked "why" because you said "public"
I mean the normal chat of minecraft, its public
so you want to do some sort of cloud system where you sync messages across servers via redis or what
I just want to avoid sending the message in both chat when I write in the bungee one
well, how the chat is interpreted depends on the plugins you already use. by default, the proxy only forwards the chat packets to the server where the player (receiver, AND sender) actually is on
if you see the same message twice, you installed some plugins which caused this problem
by default, chats are always "per-server"
bungee has a chat?
no
was about to say
it just forwards the existing packets
if they see messages twice, they already use some plugin
if you'd remove all plugins, I'm sure this wouldn't happen
Yes, the redis one is the chat. When I turn one the guild chat, which send message over bungee to other servers, I see the message in redis and in guild chat
Is not possible to block the packet after sending over bungee?
I really don't understand what you're talking about
if you could explain it again in a bit easier words, maybe I could understand it
you can intercept any packet sent using a custom netty handler (or if you hate yourself, using ProtocolLib)
I would however never recommend ProtocolLib, it's a pain
So, I write in chat and the message is sent over redis to every other server. When I turn on the guild chat it sends the message over bungee but also in the redis
it's the worst library I have ever seen in my entire life, and I have seen stuff like XStream
haha how it works
it promises to be cross-version but actually all it does is like "getIntegers()" and then you still gotta care about "which integer" is "which"
imagine this:
public class MyExamplePacket extends Packet```
Yeah it doesn't do much more than a custom netty handler
and now it adds a new integer parameter into the constructor
how is protocollib gonna handle that? oh right, it doesn't. you are supposed to do this on your own
and that's why I think that protocollib is nothing but a joke
I might be wrong of course, and maybe I simply misunderstood something
yeah that's what I figured. It still doesn't do any X-version compatibility
all it does is to abstract the classes even further. so instead of doing
new PacketExample(1,2,3);
people now do this:
PacketExample ex = new PacketExample();
ex.getIntegers().set(0,1);
ex.getIntegers().set(1,2);
ex.getIntegers().set(2,3);
seems a bit useless to me, but ok
maybe it once was useful, idk
why would anyone want to do this instead of just calling the proper constructor of that packet
Because they dont want to mess with nms and reflection
but they do
they literally say "set the first "int" field in the constructor to 1"
cant get any worse than that imho
this PacketWrapper thing on github was a proper approach but yeah
it died
I am saying for people who use protocollib
that's also what I'm talking about
Well you dont need nms or reflection if you are using protocollib otherwise pretty useless to use the lib
where can i view all code of that method, the website show only the name of method
?stash
i can only see the interface, where should i can find how that method actually work?https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/entity/LivingEntity.java#516
but you still need to code version dependant code
I use BuildTools -> target > decompiled for viewing sourcecode
protocollib is sooo useless in my eyes
Never used it, but I don't think I want to
clone craftbukkit
then check that
nobody wants to use it, it's trash
A Jägermeister a day keeps the doctor away
I'll need some bencodiacepines to survive this day anyway
Oh yes same
rivotril high five
I got holidays this week and got sick on monday yikes
or valium or tavor or whatever
bukkit or craftbukkit, what different
craftbukkit is the implementation of bukkit api for minecraft
Isn't it basicly just nms stuff but in an external library?
it's even worse
I explained it above
well if ur messing with packets, ur already messing with version specific code :V
exactly
unless its a reeaallllyyy generic packet like chat, payload, or maybe player movement
something less likely to change or be removed
You really need some Jäger to not die while porting Version-Dependent stuff
I doubt that, the NMS classes change all the time. and if they really "wouldn't change", then one could easily just provide a wrapper for each class
yes, I'm addicted, not the right place to talk about it though
god yeah
just google "alcohol withdrawahl symptoms" if you care
Ok
i remember trying to port some old ass simple forge mod to a modern version
Ouch
and between mapping changes and literal code changes (ie. Gui handling), it was aids
Forge porting is 10x worse than plugin porting
And plugin porting is already insanely painful
it was like 1.7 mod ported to 1.13 or 1.14
usually one can just use the mojang maps and 99% is fine
Im using mojang mappings nowadays
Imma hope porting gets easier with that from now on
what best app to decompile plugin jar file to view source code
recaf
I am just tired of answering the same questions every day, again and again
like for example "lol how do I make custom heads"
or "uuugh how do I tell maven to output my .jar to C:\MyServer\plugins"
what is multiblocks?
The schematic thingy you know
I knew it? I don't recall that
what should i do, i just clone craftbukkit and open with intellji Could not find artifact org.spigotmc:minecraft-server:jar:1.19.3-R0.1-SNAPSHOT in minecraft-libraries (https://libraries.minecraft.net/)
Nono I mean I know how to fix it
Thing is that the stupid client inits, wipes, inits, wipes the light-chunks everytime
So what I gotta do is init them one time and keep them there by faking like a barrier block so it does not keep wiping it
what actually is "artifact", i see it but i dont understand it
artifact would be like the jar
An artifact is just a piece of software. In the maven context its mostly a compiled jar.
Does anyone have a github-action that when there is a release it publish the artifact even on spigot?
me wondering how people understand how to work with github 😢
Sry but can anyone help me?
I created a list with following command List<PotionEffectType> effects = Arrays.asList(PotionEffectType.values()); and now i try to remove some effects
with following commands ```java
List<PotionEffectType> removeeffects = new ArrayList<>();
removeeffects.add(PotionEffectType.REGENERATION);
removeeffects.add(PotionEffectType.FIRE_RESISTANCE);
removeeffects.add(PotionEffectType.DAMAGE_RESISTANCE);
removeeffects.add(PotionEffectType.INVISIBILITY);
removeeffects.add(PotionEffectType.WITHER);
removeeffects.add(PotionEffectType.INCREASE_DAMAGE);
effects.removeAll(removeeffects); <== ERROR HERE
but i got this error message in the console
Arrays.asList returns an immutable List. Use a normal ArrayList instead.
new ArrayList<>(Arrays.asList(...))
List<PotionEffectType> effects = new ArrayList<>(Arrays.asList(PotionEffectType.values()));
Lists.newArrayList(...) kek
ok Thanks... XD my fault...
Is there a resource that explains how permissions with numeric values work? The problem i have is that something.<number> says the player doesnt have the permission something
something does not equal something.<number>
if you give a permission something.1 they will not have something
how do plugins do it then?
allow everyone access to the command and then check if they have the permission?
you specify child nodes
if you want someone to have something you have to actually give that permission. They don;t get it when you give something.1
a permission does not understand .
wouldnt those go in the wrong direction
thats just another character
ie something.1 is a permission, it is not something and 1
in your plugin.yml you can specify parent/child nodes
i cant just go and say something.1 child something, something.2 child something, something.3 child something
that would defeat the whole purpose of doing it numerically
if you want them to require something to use a command you have to actually grant that node
then you can check for something.x in the command
ig
MapView.Scale doesnt seem to be working for me when i create a Map via server.createMap.
I apply the view via MapMeta toa FILLED_MAP, which works fine, scale just isnt reflected.
Do i need to set anything additionally via the meta? No matter what scaling i set in the MapView it just doesnt seem to work
sender.server.createMap(sender.world).also { mapView ->
mapView.scale = MapView.Scale.FARTHEST
mapView.isLocked = true
mapView.addRenderer(ImageMapRenderer(image.getScaledInstance(2048, 2048, 0)))
ItemStack(Material.FILLED_MAP).also { item ->
item.itemMeta = (item.itemMeta as MapMeta).also { meta ->
meta.mapView = mapView
meta.isScaling = true
}
sender.inventory.addItem(item)
}
sender.sendMap(mapView)
}
The ImageMapRenderer literally just calls canvas.drawImage, not sure if i need to set anything in there additionally
okay so the scale is set right in the Item, but rendering doesnt seem to adjust in the drawImage function
Is there a way to understand if a player is hidden for another player?
Player#canSee iirc
can you test if a string is an integer without using try/catch
like a simple way i dont want to throw a regex at it
loop thro each char
so regex got it
thats not what i said
its essentially the same isnt it?
Thanks!
cant you run regex in like 3 modes
dunno what that means
what
if you want to check if its number with regex just \d*
but tbh idk why wouldn't you use try/catch
its surely faster then regex
what about this one?
if(!new Scanner(strings[1]).hasNextInt()) return false;
int number = Integer.parseInt(strings[1]);
a scanner on a string?
thats how console input works aint it?
there isnt a a constructor that takes a string
https://github.com/apache/commons-lang/blob/master/src/main/java/org/apache/commons/lang3/math/NumberUtils.java#L1622-L1734 this is how apache does it, and according to online benchmark its faster then try/catch
wtf
tbh just use try/catch
https://goksi.tech/ ¯_(ツ)_/¯
im assuming that coreJava is the try catch thing?
yap
are they using pure regex or a pattern in that test btw
Is it possible to have more than 2 world borders in a single world?
i believe with 1.19 world borders are now per-player but still restricted to 1
its like a really recent change
might be in the snapshot im not sure
minecraft borders no. custom borders, yes.
but why would you need 2 borders
what
either per player (whatever moterius said via api) or via packets
Have you played any Skyblock server?
oracle docs:
A compiled representation of a regular expression.
A regular expression, specified as a string, must first be compiled into an instance of this class. The resulting pattern can then be used to create a Matcher object that can match arbitrary character sequences against the regular expression. All of the state involved in performing a match resides in the matcher, so many matchers can share the same pattern.
A typical invocation sequence is thus
Pattern p = Pattern.compile("a*b");
Matcher m = p.matcher("aaaaab");
boolean b = m.matches();
A matches method is defined by this class as a convenience for when a regular expression is used just once. This method compiles an expression and matches an input sequence against it in a single invocation. The statement
boolean b = Pattern.matches("a*b", "aaaaab");
is equivalent to the three statements above, though for repeated matches it is less efficient since it does not allow the compiled pattern to be reused.
Instances of this class are immutable and are safe for use by multiple concurrent threads. Instances of the Matcher class are not safe for such use.
they use different borders for every skyblock island
never really
I would like to make something like that
there are multiple islands in the world, and every island has its world border
oh you mean that many islands are in one world and each player has his own border?
okay yeah, thats just per player
btw cipher? do worlds run all on the same thread? i always forget
not sure, check the api. otherwise https://wiki.vg/Protocol#Initialize_World_Border
i would think so. only the generation is via workers
they used the one showed on top of paghe
k
@tardy delta ur opinion
private boolean hasPermission(final Player player, final int checkValue){
Optional<String> permString = player.getEffectivePermissions().stream()
.map(PermissionAttachmentInfo::getPermission)
.filter(e -> e.toLowerCase(Locale.ENGLISH).startsWith("permission."))
.findFirst();
if(permString.isEmpty()) return false;
try{
int permValue = Integer.parseInt(permString.get().substring(10));
return permValue >= checkValue;
}
catch (NumberFormatException e){
player.sendMessage("Please input a valid number.");
return false;
}
}
also im open to suggestions lol
remove those finals, this is not C++
that aside
no
we both know thats not what i asked
'what would you do differently aside from the final keywords' if you need it spelled out
could use Optional#map but that wont change anything
i mean if people give the same permission with different numbers thats not my problem
but point
ig that loops thro the players permissions and checks for a permission.X with X higher than checkValue?
yuo
*yup
also im checking all perms
cuz of inheritance
thats what im changing rn
assuming you dont fuck up with the permission.X i dont see a reason for that try catch
effective permissions on teh player is ALL perms the player has, excluding wildcard
let the permissions expert help
unless using Vaul#playerHas for permission checks
string to int
people are dumb
id like to not depend on other libraries
Dk if this is the right place to ask this, but where and how could I look for work as a plugin developer. How can I find service kind of places to work, and what evidence of experience, and how much of it would they expect to see, and could it also be more beneficial to just work on my own and publish plugins to Spigot?
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
Thanks
Hey I was about to do that
published?
an account with at least 20 posts
You need a few forum posts to post in the section is all
Can always go yo those who are looking for developers
💀
And contact em
i mean i have like 9000 chat messages here but like 0 forum posts on spigot
just post every day "hello world"
Or be helpful just 20 times 💀
List<String> permList = player.getEffectivePermissions().stream()
.map(PermissionAttachmentInfo::getPermission)
.filter(e -> e.toLowerCase(Locale.ENGLISH).startsWith("permission."))
.map(e -> e.substring(10))
.toList();
if(permList.isEmpty()) return false;
for(String p : permList){
try{
int value = Integer.parseInt(p);
if(value >= checkNumber) return true;
}
catch (NumberFormatException e){
getLogger().warning("Not a number.");
}
}
return false;
opinion?
why streaming and then looping over it?
Where should I look for those people though. BuiltByBit/McMarket seems kind of dead these days
Services
you can put try catch in your map
There is an hiring developer section
can you give an example?
return checkVal - 1 if its not an int or smth, then filter the ones that are lower than checkVal out again
player.getEffectivePermissions().stream().map(p -> p.getPermission().toLowerCase(Locale.ROOT))
.filter(p -> p.startsWith("permission."))
.map(p -> {
try {
return Integer.parseInt(p);
} catch (NumberFormatEx e) { return checkVal - 1; }
})
.filter(num -> num >= checkVal)
.findAny()```
ah
yea i need to make the block around it
what happens with findAny on an empty stream?
does it give an empty Optional ?
you probably want that method that returns if the stream found anything
Does Spigot website provides some Rest API that can I use to update Description of my plugin?
i forgot the name
findfirst?
anyMatch
instead of filter then ig
no anyMatch will return if the stream contains any elements
ye i figured
so you filtered the ones out that are not permission.X and where X is lower than your value
.map(e -> {try{return Integer.parseInt(e);}catch(NumberFormatException ex1){return -1;}})
.anyMatch(e -> e>= vaultNumber);
ah anymatch takes a function?
predicate
🤮
return player.getEffectivePermissions().stream()
.map(PermissionAttachmentInfo::getPermission)
.filter(e -> e.toLowerCase(Locale.ENGLISH).startsWith("permission."))
.map(e -> e.substring(10))//adjust depending on line above
.map(e -> {try{return Integer.parseInt(e);}catch(NumberFormatException ex1){return -1;}})
.anyMatch(e -> e>= vaultNumber);
full code for your viewing pleasure
actually i can remove one of those maps ig
What are you even checking for
ye
permissions, namely numbered ones
in the style of permission.<number>in this example
or rather if the number is equal or higher to the number to check against
Instead of that comment, you could substitute "permissions." with a variable and use length() on that variable instead of the value 10.
public static boolean canMakeMoreKeys(Player p){
if(p.isOp()) return true;
int maxKeys = Integer.parseInt(p.getEffectivePermissions().stream()
.filter(perm -> perm.getPermission().startsWith("restful.count."))
.map(perm -> perm.getPermission().split("\\.")[2]).findFirst().orElse("1"));
return Main.getInstance().getDataContainer().getKeysCount(p) < maxKeys;
}
This is how i done it in my like really old project
ah
i forgot about split
but how do you get around not calling try/catch? saying 'your fault' if someone tried to give restful.count.five?
Someone knows which event is fired when a falling block hits a torch? I know it was something absurd like the BlockPhysics event or something
but im too tiered to go through all the events.
Its for sure not:
- EntityChangeBlockEvent
- EntityDeathEvent
