#help-development
1 messages · Page 847 of 1
also I think that list contains blocks that will be destroyed, not all blocks hit by the explosion
thats the answer to check if the player is in circle
So, I've got a hell lot of positions (i think around 50), which are always 2x3 (2 high, 3 wide) where the player can place blocks and I want to know on which of these 2x3 positions they've placed the block and it shouldn't matter on what of the 6 blocks it was placed. I had the idea of creating a two-dimensional array for storing the positions, but that would be pretty annoying to do (the positions are also all on the same y-axis). In my idea the array stores the offset from the middle point of the 'board' (where all the positions are). Anyone got another, simpler idea on how to do this?
wait wait
use distance() not distanceSquared()
also might need to make it absolute idk
ok i will change it , im not good at math lol
I created a custom biome class that doesn’t use any api. I could send it if you’d like?
absolute is to make any negative value into a positive one. -2 = 2; 3 = 3
It is obviously harder to use than an api, but I try to step away from relying on others apis
i mean i know that but generally not that good at math lmao
yes, i would really apreatiate it
Ok, I’ll send it soon then.
It’s for 1.20.2, but probably will work on 1.20.4
mine doesn't use an external API but
mines all nms
@quaint mantle sorry for ping ```
double return location.distance(center); <= radius;``` but do you think this is ok?
1.20.2 is R2 and 1.20.4 is R3 so it wont
You’re right, but it wouldn’t probably take much to change right?
josh
how were you able to do custom biomes with nms?
i tried for several hours but i couldn't figure it out
@quaint mantle really sorry but that didnt work entities few blocks outside are still taking damage ;-;
double return?
oh i included double as mistake return location.distance(center) <= radius;
but i used this
in my code
now
Are you sure that radius is just not really big?
radius is 15.0
with counting? like do it in game
Yes
ok wait few sec
wait by counting in game radius is actually quite smaller than 15
Draco
well not alot butlike few blocks less than 15
yo I'm trying to hook Vault into my plugin but it keeps saying no dependency found, i tried adding depend Vault and also vault, but it doesn't seem to work, I also have it installed in my server and it works fine, its also in my plugin pom.xml
i thought the radius was exactly 15 blocks
https://github.com/MilkBowl/VaultAPI make sure you added the repo
add it where
in the pom?
to your build file
Ive never done that, how so?
add this with the other repos
But I do have it?
check the dependency is correct then
hM?
reload maven then
I mean I did when I installed it lol
reload it again and say if you still get the error
ok
yeah still no dependency found
where is the error appearing
console
?paste the error
what
you have nothing providing the economy, vault is just an api
does it need to have a use for it to load?
I'm still using the chat and permissions of vault
Do you need vault for economy?
for future yes, but rn i havent done anything in economy specifically
Then dont check for an economy provider if you dont need one
aight
public void onEntityExplode(EntityExplodeEvent event) {
if (event.getEntity().getType() == EntityType.PRIMED_TNT) {
String list = "OBSIDIAN";
List destroyed = event.blockList();
Iterator it = destroyed.iterator();
while (it.hasNext()) {
Block block = (Block)it.next();
String name = block.getType().toString();
if (list.contains(name))
it.remove();
}
}
}```
why it explode all the other blocks but not the obsidian? i want to make explode only the obsidian
so if any1 here has played bedwars in it when a player has invisibility it is completely invisible except footsteps, so what if I send a "lie" packet to other clients that the player removed his armour and give the player invisibilty?
Why do you use the material name, and why are you using a raw list?
Also you have to remove everything that‘s NOT obsidian
And obsidian doesnt break from explosions, you have to manually destroy them
It‘ll never be in the list in vanilla
how can i get all the obsidian block in the explosion range?
with a nested for loop that loops over x,y,z coordinates in a certain radius
how would i break client side blocks in survival? I can't find a forum or anything talking about this
i can break client side blocks in creative
but not survival
Is there a way to set a World variable to the overworld without detecting the world from a player?
wdym with "set a world variable to the overworld"?
you want to get the default world, you mean?
yes
Bukkit.getWorlds().get(0) is the default world
I've got a hell lot of positions (i think around 50), which are always 2x3 (2 high, 3 wide) where the player can place blocks and I want to know on which of these 2x3 positions they've placed the block and it shouldn't matter on what of the 6 blocks it was placed. I had the idea of creating a two-dimensional array for storing the positions, but that would be pretty annoying to do (the positions are also all on the same y-axis). In my idea the array stores the offset from the middle point of the 'board' (where all the positions are). Anyone got another, simpler idea on how to do this?
What do you mean exactly? Are you talking about breaking client side blocks with packets?
well, i have client side blocks. But if i try to break one in survival it just doesn't do anything
so yes packets
if i need to do that
50 isn't much at all
A while back I made a system to manage custom block break durations. I’m sure that code would relate. I’ll take a look at it and see if I can help
i'd just create a custom class, e.g. PlaceableLocation or sth, that has a method to return the list of blocks it contains, and/or a static method that turns a block into a PlaceableLocation, or return null if it's outside of any allowed locations
but 300 is
it's 300 blocks
just 50 locations of each 6 blocks
awesome, thanks
300 is still not much. I'd just create a list of your 50 custom locations (or e.g. a list of boundingboxes, or whatever)
If you have a thousands of positions, you could use subdivision of space (a la https://github.com/Geolykt/Presence/blob/main/src/main/java/de/geolykt/presence/common/util/RegionatedIntIntToObjectMap.java) for that I guess.
But for 300 positions you might just as well use some kind of fuzzy search in an array
Especially if your positions are sorted you can use binary search (once you migrate the position to a long)
So basically you check if there are any of your positions in a given region, and if there are you perform your binary search on a long array to obtain the index which you can use to obtain the origin of your position
If the positions change frequently it becomes a bit more tricky as you need to use a TreeMap<Long, MyObject>, but that is also achievable
You just need to remember to add all 6 corresponding longs to the map for every position you add
@rare rover almost done
I'm trying to make it so if you do not provide the amount of ticks for this command, it returns false with a message. However, whenever I run the ocmmand without providing the amount of ticks, it causing an internal server error, with an error at line 31, which is line 2 here.
if (!args[1].isEmpty()) {
delay = Integer.parseInt(args[1]);
sender.sendMessage(ChatColor.GREEN.toString() + "Delay time set to " + delay + " ticks.");
} else {
sender.sendMessage(ChatColor.RED.toString() + "You did not provide the amount of ticks!");
return false;
}
} ```
How can I fix this?
it seems you have to change the packet?
if i am correct
so if (args.length < 2) {?
That if statement would run when the arguments are less than 2. But since you want more, use 3 instead.
= min
Yes. My method uses a Channel Duplex Handler. It checks for an incoming ServerboundPlayerActionPacket. It then gets the action and sees if it meets criteria. What you could do is create such a handler, and look for a packet from the client that indicates a block left click. Then send a packet breaking the block.
The following code should do this (keep in mind this is within an extention class of the ChannelDuplexHandler). I have to send it as a text file do to size.
This isn't tested, so hopefully it'll work. Somewhat rushed coding this on the fly
Just be a bit careful with adding ChannelDuplexHandlers. If there are other plugins on the server also doing that, you can get fun conflicts, so I wouldn't really recommend doing it for public plugins
Perfectly fine for a private plugin though
Definitely agree! My server uses pretty much entirely proprietary plugins, so it’s fine for us, but if you’ll use this alongside many other plugins from other devs, it might cause issues
@rare rover I doubt this, but an interaction event might be called even if the block doesn’t exist server side. I have a feeling this is only works on creative players though. If so, intercepting packets is the only way I see for survival
@rare rover greetings. josh.
what happened to zweaty palms
This is being looped in my command using runTaskTimer. Is there a more effecient way to do this?
while (zloops <= 96) {
blocation.getBlock().setType(Material.LAVA);
zloops = zloops + 1;
delz = delz + 1;
blocation = new Location(world, delx, voidlvl, delz);
}
xloops = xloops + 1;
zloops = 1;
delx = delx + 1;
}
delx = 850;
delz = -48;
xloops = 1;
zloops = 1;
voidlvlv = voidlvlv + 1```
Currently it only sets the z "strips" to lava, but I need it to set the entire square to lava.
No kidding, i somehow forgot one of the most important lines. Here's it fixed
which works but everytime i interact with a block it reset's all the other client side blocks i broke
just changed it to this:
@Override
public void channelRead(ChannelHandlerContext channelHandlerContext, Object packet) throws Exception { //this will trigger when the client sends a packet to the server
if (packet instanceof ServerboundPlayerActionPacket actionPacket) {
recieveAction(actionPacket);
return;
} else if (packet instanceof ServerboundUseItemOnPacket) {
return;
}
super.channelRead(channelHandlerContext, packet);
}```
So you break a block, and the last reappears even though it does not exist server side? Or is it you break the block on the client, but the server believes it exists?
thats what I have so far
no, it breaks but whenever i interact with a client side block it resets them all
Now I’m starting to remember having this issue too. I’ll check how I solved it
Why does permission-message not work and gets overriden by the Unknown command when using a command with insufficient permissions?
sweat
Because commands without permission don't exist to the client
which is also why they don't show up in tab complete
Very odd way, but breaking the block server side (even if it's air) might fix this. BlockPos pos = actionPacket.getPos(); ClientboundBlockDestructionPacket breakPacket = new ClientboundBlockDestructionPacket(player.getEntityId(), pos, -1); sendBreakPacket(connection, breakPacket); player.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()).breakNaturally();
nah its the same
@lone jacinth do you recall your motivation for CraftLimitedRegion#saveEntities clearing the entities in the chunk? Or more generally, loading the entities into fields instead of loading them each call?
How do some plugins hide the commands and have an error message at the same time?
Try this. Noticed my code runs the following tick Bukkit.getScheduler().runTask( <plugin instance here> , () -> { sendBreakPacket(connection, breakPacket); player.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()).breakNaturally(); });
IDK if it’ll make a difference, but worth a shot
i'll try iut
it seems to work for my friend
how he does it
just he did it in kotlin
i still got no clue why its resetting them
If a world is deleted, but a player's location is still set to that world, will the game hash it out and just send the player to another available world?
i want to have a seperate world for farming/gathering and want it to automatically reset itself to a new world every week
When blocks are mined, the block break is actually handled on the client. It sets a timer for when the block should break (if not interrupted). The BlockDestructionPacket is usually there to show other players (not mining the block) the progress from afar. The client sends a packet to the server once the timer completes, updating the world.
If I remember correctly, this block break packet sent goes to the server, and the server sends a packet to nearby players updating the world. When the client begins breaking a block, but does not complete it, a “break fail” occurs. The packet is sent to the server, and the server sends a packet to all other players that basically says “undo the break animation” This is why the block reappear when you release your click.
The purpose of doing block#breakNaturally is to prevent this. When the block breaks, the server sends a packet to all players that updates the state. This tells the client the break is successful, and a “break fail” event shouldn’t respawn that block.
it looks like i have to call Player#sendBlockChange()?
ig
but i'm not sure where to put it?
since there is no location or blockdata
in the duplex
you may need to listen for break packet instead of break event
i am listening for the break packet
not quite sure if spigot check the block is valid or doesnt care if its clientsided or not
why not add sendblockchange to there then?
there must be a location
is there a way to convert BlockPos to Location?
Yes, use getPos
I dont actually understand what you are trying to achieve here
if you are gonna let every client know about the block break and place
what is the point of clientsided blocks
cuz i can set blocks async
Awesome!
and its just easier for me to do it this way
good thing i'm using all custom plugins
still, there isnt many ways to check the type of that block using bukkit api
doesnt worth the headache imo
There really isn’t any other way other than getting the packets directly
why not just use minestom if you are using packets and all custom plugins?
exactly
But it works LOL, and there are thousands of plugins that use duplex handlers on default spigot
is apache commons still good for simple file io or is there something better thats more recent
Anyone know if getNoiseBiome takes world coordinates?
whats getNoiseBiome
It does
Thanks
LevelChunk#getNoiseBiome() gets the nms biome of a world at specific coordinates
What? 🤔
biomes are 4x4x4
getNoiseBiome(int x, int y, int z, Sampler arg3)
well #1, that's not the method they said
LevelChunk#getNoiseBiome
also, trusting parameter names is not a good idea
looking at the implementation in ChunkAccess#getNoiseBiome, it looks to me they are biome coords
Alright so 4x4x4 then?
can somebody explain this
The last bits of the 64 are: 22 for x, 22 for z, 20 for y
that's 64 bits not 128
how can i check if a block was place in the last period??
Which should mean x = (pos >> (64-22))&0x16
0xF
I mean the & 0xF
long pos = 0;
pos |= (chunkY & 0xFFFFF);
pos |= (chunkZ & 0x3FFFFF) << 20;
pos |= (chunkX & 0x3FFFFF) << 42;
sumn like that
damn i've never seen this before
Yes that looks right
y >> 4
It's called bit shifting, you are basically squeezing 3 smaller numbers into larger one. 1 long is more space and memory efficient than 3 ints
you are taking advantage of the fact that a chunk has 16 blocks, which is 2^4
It's the chunk section y. Similar how blocks gets bundled with chunks, the same is happening with chunk sections on the y axis
its hex representation of number
that number meaning the maximum value you can fit with the amount of bits
Basically we grab the number and strip the bits we need
Then we grab those bits and toss them in ther dedicated area
how can i convert a long into a varlong
would i have to store the types of block inside a list
(client side)
I'm sending client side block updates to the client and i need to get the block type from that location
would i have to store it in a map or smth
Yes
The efficiency depends. In most cases yes this is true however do note you cant perform more then a single bitshift operation at a time. So breaking a long for example into 3 ints can be more efficient to process then just one long long 
thats what I have so far
You could avoid constructing a Location instance every time and use a scheduler to avoid tps drops
Location is mutable, so you don’t need to make a new instance each time
Also
?workdistro
Should I use a BiMap for this? Like EnumHashBiMap<Material, Location> for the performance overhead?
Nvm that wouldn't work
It would have to be Map<Location, Material>?
You can remove the world and go down to just a vector
And then handle the world separately
just for curiosity (ik i can use bukkit api for this and i can explain why/how i got here), but does anyone know how to use protocollib's NBT API to custom enchant an item?
ask him to send you the error and how he produced it
ask him what other plugins he uses what version which world
then how does he know
its ur plugin doing it
lol
what
did he just randomly assume
its ur plugin
tell them its not the plugin then
idk what u want us to do
be specific or tell them its not ur plugin
well by info
i mean
what ur plugin even is
what happend to ur user
what ur code is
and such
well it depends how u change the tool
so it could possibly be ur plugin, we would need code though
what 💀
then its probs that
?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.
i figured out from https://minecraft.wiki/w/Player.dat_format#Item_structure that enchants are stored as a list of compounds, but protocollib's NbtList implementation only allows .add() to be called with a NbtBase<T> (where T is the generic type of the list, which from my understanding should be NbtCompound). NbtFactory doesnt allow for the creation of neither NbtBase<NbtCompound> nor generic NbtBase<T>, so idrk what the proper way to create it would be. Im also confused as to what NbtBase is even supposed to be/accomplish
<player>.dat files are used by servers to store the state of individual players. The format is also used within level.dat files to store the state of the singleplayer player, which overrides any <player>.dat files with the same name as the singleplayer player. These files are in NBT format.
nvm figured out how to do it after i realised how NbtCompound was related to NbtBase, if anyone for whatever obscure reason faces the same problem here's how I did it
NbtCompound tag = NbtFactory.asCompound(NbtFactory.fromItemTag(item));
NbtList<Map<String, NbtBase<?>>> enchants = NbtFactory.ofList("Enchantments");
NbtCompound enchant = NbtFactory.ofCompound("");
enchant.put("a", "b");
enchant.put("b", 1);
enchants.add(enchant);
tag.put(enchants);
so unintuitive to have to figure out i didnt have to make a list of nbtcompounds but a list of maps of strings to any base nbt (which is what essentially makes a nbtcompound, just not wrapped in nbtbase)
well you'd really have to register your enchantment with a Vanilla registry
just adding it as an NBT tag doesn't do much I wonder if it would even stay like that
no, it won't not if it runs through CraftMetaItem which happens on most inventory clicks/drags
Well if it’s on the packet level it should already be past that
yeah, if the enchantment is only going to exist on the packet-side of things, then it will stay. But it will break in creative mode
any creative mode interaction could remove it or will make it a server-side enchant which can then be removed by CraftMetaItem conversion
It is easier then trying to track which entity gets changed by a plugin. And parsing the entity each time would result in multiple entity instances flowting around and worse performance
ok, I get the second part. I don't think I'm following the first part relating to clearing the entities in the chunk
when you add an entity, it just gets added to that list, not added to the underlying nms region
Do you mean like if a plugin discards/removes an entity, its easier to just not add it back?
There is any event that register when a player has more than 100 ms?
it doesnt , but that was intented
inv click makes it stay
drag doesnt
Am I remembering correctly that you can't check if Chunk == Chunk?
have to check coords right?
Yes, a new entity gets first added to the list and later into the chunk. The entities only get cleared from the chunk, if a plugin uses a method which uses getNMSEntities(). Since now a plugin could have modified an entity which was added in earlier generation steps. And ther it is easier to discard the ones in the chunk and replace them. Then trying to track the changes.
yeah, that sounds right. drag is very common tho, all it takes is a single pixel change between mousedown and mouseup for it to happen
No?
i need help, i have made a sphere of particles of radius 15 and i want to damage entities in that radius but some entities aprox 5-6 blocks outside the sphere are also taking damage. here is my code https://pastebin.com/w59pnKMw
i will be very gratefull if someone help me, i am trying to figure out this problem for days
still didnt able to fix it
Why are you checking if it isn't a player and then if it is a player?
also you're damaging in a radius around the particle not the center of the sphere
ignore that im kinda dumb i have already removed that
so how i damage entities inside the sphere
wait lemme cook
ima try
yoooooo thanks!
it works, my dumbass was using particle location as centre thanks alot!
yea will do
Should getting stuff from a ResultSet be done async, or only the actual part where I access the database?
also should I make this async?
?paste
ConcurrentModificationException
You're modifying the list while looping it
hi im sorry but i need help with one more thing. i am kinda lost, how do i prevent players from putting certain items in containers
is it possible?
Listen to the InventoryClick and Drag events
not a big fan of the spigot inventory api
how i can resolve it? i am not modification it
so do see if the player clicks the certain item and drags it to chest?
You are modifying it somewhere
@chrome beacon
pretty much
hmm that makes sense lets see if it works
the click event fires when a player clicks an item to move it to cursor, shift click it or using the arrow keys
drag event fires when dragging items across multiple slots (so it places more than one slot at once)
hey
when i build the jar file with this
the code isnt updated in the jar file
why?
(maven)
how
did i manage to do that
xd
nvm decompiler bug
thanks it worked
it was named "jar" and i thought.................
Is your code that bad? Xd
it looks fine
Well, compile is named compile too, yet it only generates the classes
Which makes sense, amazingly
I wonder if compile, then jar generates a proper jar 🤔
Bukkit.getLogger().log(Level.ALL, targetLoc.toString());
why am i getting error on this
targetLoc null?
Location targetLoc = plugin.arenasConfig.getLocation("arenas.arena."+arena.getID()+".pos1");
Hmmmmmmm 🤔
ill try to debug the arena.getID()
oh i have already done that
but why isnt it printing anything
🤔
tried using the INFO level?
no
so use what instead
it gives a warning with sysoutprint
Imagine using System.out.println
?
Also, don't use Bukkit.getLogger, use Plugin.getLogger
its printing this now
ok but why
Well you want your logs to belong to your plugin, not Bukkit
It's not like you are debugging Bukkit lol
Lol
ah
If there is a Bukkit class, is there a CraftBukkit class?
why
If anyone is experienced with Android, is it a bad practice to do oauth with Google? Their docs give this warning, but after reading the Credential Manager docs, I do not have any understanding of how to do Google auth with it, so I'm kind of in two minds here
I wanted to send this in the android dev server but my account isn't phone verified so I can't lol
verify it then lol
I cannot unfortunately
My account is phone verified
"Unable to send sms message"
Bruh
use someone elses phone? report it to discord?
Long story short, my account was phone verified but I couldn't join some servers for some reason, then I decided to unlink it and link it back again; unlinking helped and I could join servers again, but now I'm unable to link the number back. Contacted Discord and they said that if it says "unable to send sms message" the number cannot be used for verification and I have to use another, which I currently can't
The only bad thing is if you didn't have some way to invalidate a session
Hmm
basically the premise is bad apps stealing the token
?
Oauth is cool and decreases the odds that somebody is gonna deinstall your app when they are faced a login screen
but with oauth, the token can only be stolen after authentication
Oh, I've been reading this lol https://developer.android.com/training/sign-in/passkeys it's what they linked in that warning
I'll take a look at that ty
Fair enough
Yep, I want to do Google oauth exactly for that reason, much easier to have one account rule them all
just pointing out while although that is what they are trying to prevent, to steal an oauth token is just not easy because the token is only present after authenticating lol
also google wants to track more
can't really do that the way they want with oauth
so in otherwords as long as you are aware of some things that you need to be aware about, OAuth is actually pretty secure and works 🙂
I'm sorry but this is getting confusing for me lol, are you supporting the older oauth means or discouraging the use? xD
I am informing why Google is trying to discourage it and that there is a valid point to what they say but at the same time not valid and hidden agenda
not everything is perfect
Gotcha
the only flaw with OAuth is if you save the token to a file or something
but as long as you don't do that and invalidate sessions periodically the odds of someone actually doing something nefarious is like almost 0
I see, thanks for the tips 🙂
or add a guest mode
My app can be used without authentication, but some features are only available to authenticated users
How can I check if the console has executed any (valid) command
so not /aiujwddwon or /notacommand
but /op, /say, /tp etc.
declaration: package: org.bukkit.event.server, class: ServerCommandEvent
thanks
Fun fact there's no way to detect if a commandsender is forced to execute a command through performCommand
unless you inject a custom command map
public void onInventoryDrag(InventoryDragEvent event) {
HumanEntity humanEntity = event.getWhoClicked();
if (humanEntity instanceof Player && isContainerInventoryType(event.getInventory().getType())) {
Player player = (Player) humanEntity;
for (Map.Entry<Integer, ItemStack> entry : event.getNewItems().entrySet()) {
if (isForbiddenItem(entry.getValue())) {
event.setCancelled(true);
break;
}
}
}
}``` @chrome beacon sorry for ping, but i made it work so that the certain items can not be put in the container but when i shift click and place it, the items are still getting placed in the container. i tried something but it isnt working
As I said shift clicking fires the InventoryClickEvent
How can I check if the command being executed is an actual command and not just a typo or something
public void onInventoryClick(InventoryClickEvent event) {
HumanEntity humanEntity = event.getWhoClicked();
if (humanEntity instanceof Player && isContainerInventoryType(event.getClickedInventory().getType())) {
Player player = (Player) humanEntity;
if (event.getAction() == InventoryAction.PLACE_ALL || event.getAction() == InventoryAction.PLACE_ONE || event.getAction() == InventoryAction.PLACE_SOME) {
ItemStack clickedItem = event.getCursor();
if (isForbiddenItem(clickedItem)) {
event.setCancelled(true);
}
}
}
}``` this is my inv click event, can you guide on how to incorporate shift click check in this method
this works when i try to normally place items in a container
um hi
olivo
do you know how can i maybe do this
Check if someone is shift clicking or using the number keys
How can I check if a command requires op to execute
Where would I use this, I can't use onCommand (can I?) since it will only execute for my plugin's commands
im sorry what you mean by yours? or do you mean the item that is not supposed to go in he container
Yeah I mean the item you want to block
Find what command is being ran and use that to check the permission node
I'm using PlayerCommandPreprocessEvent, so would I have to check where the first space is in the string (where to command name stops)
yeah
And then, how do I convert this new name to a command
So what exactly is the goal here
I want to save all commands executed by an op to a file, but only if the command itself requires op in the first place
no if I can't make it faster, I need it fixed. it only sets the z "strips". to lava, not the entire square.
but again commands have permission nodes so keep that in mind
huh, is there no way to convert a name to a minecraft command?
getCommand exists but that won't work for aliases as far as I'm aware
so you need to look up the command name first
public void onInventoryClick(InventoryClickEvent event) {
HumanEntity humanEntity = event.getWhoClicked();
// Check if the event involves a player and a container
if (humanEntity instanceof Player && isContainerInventoryType(event.getClickedInventory().getType())) {
Player player = (Player) humanEntity;
// Check if the event is a shift-click
if (event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY && event.isShiftClick()) {
ItemStack clickedItem = event.getCurrentItem();
handleForbiddenItem(player, clickedItem, event);
}
// Check if the event is a click
if (event.getAction() == InventoryAction.PLACE_ALL || event.getAction() == InventoryAction.PLACE_ONE || event.getAction() == InventoryAction.PLACE_SOME) {
ItemStack clickedItem = event.getCursor();
handleForbiddenItem(player, clickedItem, event);}
}
private void handleForbiddenItem(Player player, ItemStack clickedItem, InventoryClickEvent event) {
// Check if the clicked item is forbidden
if (clickedItem != null && isForbiddenItem(clickedItem)) {
event.setCancelled(true);
player.sendMessage("You cannot interact with this item in containers!");
}
}``` i tried what you said but i can still shift click items in containers but it cancles the shift click to drag items in inventory instead
do default commands have aliases?
oh yea tp and teleport
I don't quite understand what you mean
also you could probably just check the action
like i can still put that specified item with the shift click in the container
um what?
i am checking the action am i not?
ok iil try
Does the HumanEntity#setCooldown(material, ticks) method set the cooldown to be applied everytime the material is used?
no it just triggers the cooldown animation once
Okay, thank you 😄
Gets the command with the given name, specific to this plugin. Commands need to be registered in the PluginDescriptionFile to exist at runtime.
Do you mean getPlugin().getCommand(commandName);?, that's what I'm using
I also need to check normal commands such as tp and op
Use the CommandMap
Where? What functions is this?
It's not easily accessible and they way you grab it can be version dependent
It should be a field in CraftServer (the implementation of the Server interface)
You can access it with reflection
i lost you with that
How do I access CraftServer
You mean CraftServer server = (CraftServer) Bukkit.getServer();
you can use annotation based commands
They're not trying to register commands
let me handle this
yes boss
CraftServer doesn't seem to be a... thing I can use/import?
That cast would work but you don't need it
Oh ok
because it's part of the implementation rather than the api
oh ok great, how do I access it
yea, ok, but I don't know where the commandMap field is
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
what
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
bukkitCommandMap.setAccessible(true);
CommandMap commandMap = (CommandMap) bukkitCommandMap.get(Bukkit.getServer());
Probably immutable
why doesn't this one work
https://github.com/Sweattypalms/skyblock-remake/blob/master/src/main/java/com/sweattypalms/skyblock/commands/CommandRegistry.java#L62
Here's how I inject commands into the Bukkit command map
Hypixel skyblock remake. Contribute to Sweattypalms/skyblock-remake development by creating an account on GitHub.
no I don't want to add commands or change stuff?
Mm, some useful info here
just retrieve info
yeah use the command map instance and call getCommand on it
Regarding what?
oh ok
but the command map instance, do you mean this thing
^
yeah
Think this'll work for "parsing" the command name?
String commandName = (event.getMessage().split("\s+")[0]).substring(1);
Like you don't inlude the / surely?
yeah skip the /
You can log the entire map and do some debugging
Ah this works great, thanks Olivo!!
String commandName = (event.getMessage().split("\\s+")[0]).substring(1);
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
bukkitCommandMap.setAccessible(true);
CommandMap commandMap = (CommandMap) bukkitCommandMap.get(Bukkit.getServer());
if(commandMap.getCommand(commandName) != null){
event.getPlayer().sendMessage("YAY! " + commandName + " is a real command!");
}
nah that's just for testing
What I really want to do is this:
//If the player has op
if(commandMap.getCommand(commandName) != null){
if(commandMap.getCommand(commandName).getPermission() == "op"){
//Log this command to the file, as it requires op to even execute
}
}
so you didn't have to look up the alias?
oh \
lets see
ah finally, spigot is on my side
it seems aliases are included
so no :>
I advice early returns for cleaner code
Not where they want to do it 
how?
Let me just say the full thing that I want:
Check if the OP player has executed a command, and if the command is a real thing, and requires op to execute, log it
They wanted it in the preprocess event
What I just put it there because it couldn't be in the onCommand event right?
btw there isn't a hard requirement for op
wdym?
Commands have permission nodes
Don't permissions have a default, like, true, op, not op, false
I lost you? Surely tp must always require an op permission?
oh yea
But I'm checking if the player itself if an op
as well
Bukkit.broadcastMessage("the objective: "+score.getObjective().getName()+" the Entry: "+score.getEntry()+" the score: "+score.getScore());```
gives me this:
whole code
public static int process(List<String> sub,Entity targetEntity){
for (String e:sub){
Bukkit.broadcastMessage(e);
}
Bukkit.broadcastMessage(targetEntity.getName());
if (sub.get(0).contains("scoreboard")){
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
Objective objective = scoreboard.getObjective(sub.get(2));
Score score = objective.getScore(targetEntity.getName());
Bukkit.broadcastMessage("the objective: "+score.getObjective().getName()+" the Entry: "+score.getEntry()+" the score: "+score.getScore());
return score.getScore();
}Bukkit.broadcastMessage("jcrois que ta commande $ existe pas");
throw new IllegalArgumentException("Error: truc qui ne marche pas");
}
oh getPermission doesn't work
how can I check if the command requires the op permission to execute
getDefault() == OP
if you want to check if the permission is given to op by default
You mean?
command.getPermission().getDefault()
yes
Oh ok thanks
score is defined as not set:
java if (score.isScoreSet()) {Bukkit.broadcastMessage("the objective: " + score.getObjective().getName() + " the Entry: " + score.getEntry() + " the score: " + score.getScore());}
dont send anything, but on the screen above (the reply) you can see that it's set, so i guess i'm doing something wrong
Hey so I'm a bit of a dumbass, I made a plugin that gets whether or not a player has an action bar toggled (using the plugin supplied command) and displays an action bar. It checks this every 40 or so ticks... per player... and now my servers having lag issues.
I would like to provide an image but I can't
How do i stop there from being 33,099 instances of org.bukkit.craftbukkit.v1_20_R1.presistence.CraftPersistentDataAdapterContext#...
Fix: Do not create them
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
can't you just use a listener?
For what?
to actively show the action bar or the command?
Not sure why that would be any more efficient
the action bar is created in the plugin
the same plugin
the variable i'm talking about is what controls the action bar
not repetitly looking for creation
Use DB instead of pdc
and make it async
that shouldn't cause any issues whatsoever
show a spark report. the code you sent shouldn't cause any lag
Yea I get that by DB you mean database if so how?
Where would I upload the spark report?
it does that automatically
It does?
Yes. The sqlite
Link
a database to store a simple boolean per player? why? that'll only cause I/O issues while the PDC is already loaded anyway
Where would I find it since this is an older upload
just do /spark profiler stopand it should give you a link or sth
Its an older upload as in from a while back
Because I never got around to checking it.
Either way I have the spark profile and it is causing problems
considering there is 33 thousand instances of it open...
how do you know that it's 33k instances
Because it tells me...
who tells you?
what does the red dot mean in front of the class names?
because usually that should all just get garbage collected
Idk I'm using visualvm
If you would not be opposed I can upload the full .hprof to a google drive and share it.
Will take some time though.
How much is a projectile affected by water, ie the force?
Istg the credentialmanager docs are so fucking confusing
Where the fuck do I get the requestJson value
I mean not much difference
There is some bullshit related to JSON above but I do not see how that could be related to this
https://w3c.github.io/webauthn/#dictdef-publickeycredentialrequestoptionsjson are they talking about webauthn json thingy?
Ok I think I can just not allow for the passkeys thing lol
Honestly I don't know, I've read through the docs multiple times and I still don't know
Google documentation always makes me feel like a fucking idiot because they say so much but say so little
Is runTaskTimer optimized?
whats ur definition of optimized
it uses a thread pool and it automatically shuts down tasks when your plugin gets disabled, so it's at least more convenient than just creating a thread yourself
it does not use a thread pool
how can i get the content of a scoreboard in a plugin to use its values
hm i thought it does
then someone once lied to me
ah ok
otherwise its correct ^^
I think I understand how to authenticate with Credential Manager, now the question is how the hell do I fetch the email from this
is it google?
Yeah google oauth with credentialmanager for android
This whole thing is melting my brain
yea their lib apis r huge lol
The documentation is not only overwhelming but also all over the place lmao
And there's no mention of the word "mail" at all on this page
androidx.credentials.exceptions.GetCredentialProviderConfigurationException: getCredentialAsync no provider dependencies found - please ensure the desired provider dependencies are added What the fuck is this supposed to mean 🙂
Google is not telling me anything about this
how to developer mode, I am developer
I'm rolling out my own account system fuck this
what is developermode
I don't wanna spend more of my time on this siht
Is there anyway to guarantee a Chunk's PDC is stored and updated whenever it is set?
I'm trying to store some info associated with chunks, but it seems like the PDC only saves and updates when the server is stopped and world is saved.
lol
going to be hilarious when you learn down the road that its probably like just a few lines of code you needed
but never managed to get that far because the documents are too difficult to read/understand
nevermind I have the IQ of an ant
This happened because I was on the spawn chunks
what
Yeahh... That's gonna be fun lol
Well they should've made their docs more clear 😛
I've got no idea what the hell is this error
ChatEvent(super=TargetedEvent(sender=SivannGaming, receiver=net.md_5.bungee.ServerConnection@6e692724), cancelled=false, message=.) @ net.md_5.bungee.event.EventBus:-1
on BungeeCord
nah
in general i think its just stored on load / unload
but thats good, since it does io and stuff
How can I get the directory of the latest.log file?
Is there a way to add enchant higher than maxLevel?
new File("logs")
nah I need the actual latest.log file directory
addUnsafeEnchant on itemStack or the last Boolean arg when enchanting with ItemMeta
Ah I can do:
String dir = getServer().getWorldContainer().getAbsolutePath()+"/logs/latest.log";
File file = new File(dir);
thanks
uhh, from my testing it stores when the chunk is unloaded
Sorry I went somewhere after that but I didn't get what you meant by just action
Like remove the isShiftClick part and just try move_to_other_inventory right?
Lemme try this
public void onInventoryClick(InventoryClickEvent event) {
HumanEntity humanEntity = event.getWhoClicked();
// Check if the event involves a player and a container
if (humanEntity instanceof Player && isContainerInventoryType(event.getClickedInventory().getType())) {
Player player = (Player) humanEntity;
// Check if the event is a shift-click
if (event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) {
ItemStack clickedItem = event.getCurrentItem();
handleForbiddenItem(player, clickedItem, event);
}
// Check if the event is a click
if (event.getAction() == InventoryAction.PLACE_ALL || event.getAction() == InventoryAction.PLACE_ONE || event.getAction() == InventoryAction.PLACE_SOME) {
ItemStack clickedItem = event.getCursor();
handleForbiddenItem(player, clickedItem, event);
}
}
}``` i removed the shift click check from the method but i can still place the item with shift clicking in the chest
what should i do..
yeah
certain commands may also store it
like force store it
iirc
Is there a way to change "Too Expensive!" in anvil, to the real cost?
I wanna make a command without registering it or generally having it in my plugin.yml, how would I?
Sounds like a pain, how do I do that?
Class scanners and annotations
Hmm
How the hell do I invalidate a jwt token when a password is updated lol
Do I need to store the password salted hash inside the token and verify it every time i authorize a user
Don't say that, reflection is super fun
So it works, but not visual
Especially when suddenly your classes don't exist
maybe
best use a command framework
Build your own command framework
already did
I've seen servers limit the price at 30, maybe that's why
I've been wanting to do that for so long lol
ordinate has you covered https://github.com/boxbeam/Ordinate
A command framework would be so overkill lol
I really wanna build my own annotation based framework because I am tired of getting an enormous overhead from acf
Yeah the text is clearly client-side because if you make max cost lower than 40 there is no text
I much prefer the dsl
I prefer building my own stuff 🙂 I might try yours out but there are so many pros of building stuff yourselves, such as experience and high maintability
don't gotta tell me
Haha
building stuff yourself is always the way to go if you have the motivation
you learn so much more
Yep
ordinate is the 4th rewrite
and I originally wrote it as a rewrite of someone else's project too lol
I will 100% do a command framework after I'm done with the 2 projects I'm already doing lmao
xD
Just 2 projects? Man you're lucky
public void onInventoryClick(InventoryClickEvent event) {
HumanEntity humanEntity = event.getWhoClicked();
// Check if the event involves a player and a container
if (humanEntity instanceof Player && isContainerInventoryType(event.getClickedInventory().getType())) {
Player player = (Player) humanEntity;
//SHIFT CLICK-
if (event.getClick().isShiftClick()) {
Inventory clicked = event.getClickedInventory();
if (clicked == event.getWhoClicked().getInventory()) {
ItemStack clickedOn = event.getCurrentItem();
if (clickedOn != null && clickedOn.isSimilar(createFireGemLVL3()) || clickedOn.isSimilar(createFireGemLVL2()) || clickedOn.isSimilar(createFireGemLVL1()) || clickedOn.isSimilar(HEALING_WAND)) {
event.setCancelled(true);
player.sendMessage("You cannot put this item in containers!");
}
}
}
//NORMAL CLICK
if (event.getAction() == InventoryAction.PLACE_ALL || event.getAction() == InventoryAction.PLACE_ONE || event.getAction() == InventoryAction.PLACE_SOME) {
ItemStack clickedItem = event.getCursor();
handleForbiddenItem(player, clickedItem, event);
}
}
}``` can some one help me, the block of code which has shift click comment on it is not working as intented, i want to prevent players from shift clicking items from their inventory to a container https://paste.md-5.net/oxazodihuh.cs
I mean I wanna be working on 1 but since I'm also working on a school project (that's getting bigger by the fucking day) I am working on 2 instead
?paste
Text wall
I wanna be working on one but can't even find the motivation
can someone help me 🥲
yo how do i make my plugin size smaller
how big is it
the general idea is less code = smaller file
and don't shade things that don't need to be shaded
Shade spigot
wdym by shade
37kb 💀
37kb sounds fine to me
my configs are already bigger than that
lol
37kb is almost nothing
i mean like thing is its a pretty simple plugin and there are other more complex plugins that is only 4-6kb of size
nvm i misread those "4-6kb"
its actually mb
ig 37kb is fine
Whats the best way to pass information from one plugin to another?
size doesn't matter
would an api be hard to make?
you just create a public method?
if you don't know java well yeah
yeah an api seems resonable
ig this is a more of a understanding maven though xD
I thought a public method is only accessible inside of the plugin
it's accessible by anything that has your class(es) on the classpath
so other plugins can just add your plugin as maven dependency (or gradle) and then you can get the plugin instance from the bukkit plugin manager, cast it to your plugin instance, and then use those methods
so I could do import com.yes.myplugin.blablabla.MyClass.myMethod to obtain that method in a different plugin?
or something like this
import com.yes.myplugin.blablabla.MyClass
…
You don't import methods
ok
💀
Reverse em
lmao
If buildtools fails again I am blaming @river oracle
shut
blame @kind hatch
I get I cleaned up the code, but that doesn't make it my faultr
Yes it does
I also blame you for requiring me to use BUKKIT:PR rather than just PR
whats the approach to a global chat between servers, like how do i call a chatevent across all servers?
static bad?
but static is sometimes better??
imagine if invokestatic killed TPS
fr
that'd be some wild shit
I always make my variable/method public static if I need to access it in another class
tbf invokedynamic is 
I'ma invoke you
🤣

what are you guys talking about??
🤔
static isn't bad but you need to know when to use it beginners often abuse it because they lack the understanding of proper design patterns
which is why dependency injection is always reccomended even though everyone really uses Singleton pattern for their plugin
def not me 😔
me dependency injecting my plugin's registries
Singletons are funny
bungee messaging channels likely
you'd have to decompile one / look at source to know for sure though
Welp
java.lang.RuntimeException: Error running command, return status !=0: [C:\WINDOWS\system32\cmd.exe, /D, /C, sh, applyPatches.sh] time to blame y2k smh
Well he can do many things, bungee messaging channels are fine though
have you tried clearing your caches
is it smart to have datamanager plugin that manages the data of all other plugins or should each plugin have it's own data management? (like one big server api)
Yes I ran it in a fresh folder
what PR you trying to build'
[--rev, 1.20.4, --pr, BUKKIT:955, --pr, CRAFTBUKKIT:1327, --compile, SPIGOT]
It can compile cb fine, but not spigot
did y2k break buildtools
watch me build it first try with 0 issues
I cant believe someone rlly thought static use lowers TPS😂😂
no one thought that
I actually giggled
they were asking a question
Idk why patch 25 is failing
i will do it too
I think this is MD_5's fault
I did not touch anything it touches
albeit was a silly question but none the less twas a question
How would i make a tnt explosion with packet?
error: could not build fake ancestor
no fake ancestors
why do we have fake ancestors
ree
what are these 2 prs im building
@young knoll that is so wack
it builds regulat spigot fine
wtf did you do in your PR
well is your PR the same as master's latest?
if not it could cause issues
it needs to be up to date
i got a remote does not have refs
uhh
I may have to merge master
coffescript???
Is there a Non-NMS way to do a Hologram?
Version?
1.20.4
Look at displayentitied
k thanks
spigot does not support pooping of pantaloons
can some1 help me with items adder
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
the dev, probably
wdym by that
what even is your question
i cant figure out how to get the recource pack to work
Ask the developer of that plugin
This channel is for help with coding your own plugins
o
?buildtools
where can i find plugin that will remapp my jar
Maven?
yes
?nms
thx
how do I know which plugin will handle a certain event first
u cant u can use eventhandler priority
/is there a way to force me to handle certain events last or first?
yes priority
Check the handlerlist
in @eventhandler annotation
ah so its in order of teh handlerlist
Yes
what if multiple have lowest
Then it depends which plugin has registered it first
reverse enginere code and u will know
Np. I am 99% sure that what i said is true, if it hasnt changed since 1.16
I see
my goal is to make a world , nether and end with working portals, but I want to make sure it doesnt interfere with multiverse or similar
so I just wanna handle it asap and then cancel the event
if that makes sense
unless there is like a better way to do it
does anyone know why this dependency dosent work for me?
<dependency>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens-main</artifactId>
<version>2.0.30-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
maybe use repository
That worked, thanks
that gives no advantages and only has possible downsides
is there any way for me to refuse a player's connection?
before any packets are sent
and possibly even before the netty channel is implemented
yeah
block their ip
and how can I do that?
something called a firewall
in the plugin
I decide what's possible
ok then go do it
okay maybe not
why do u even need to do that lmao
ok blocked
k
Does anyone know?
As they said a firewall would be the best way
how can i add a custom biome to the overworldgeneration
With datapacks
no if I can't make it faster, I need it fixed. it only sets the z "strips". to lava, not the entire square.
there's no way to do it by plugins?
All the nms
Is there a way to make a config.yml easyer to read?
I have this:
config.addDefault("Chat prefix", ChatColor.translateAlternateColorCodes('&', "§8[ §lCHAT §8]"));
config.addDefault("non-permission", ChatColor.translateAlternateColorCodes('&', "§7Dette har du ikke adgang til."));
But it looks like this:
Chat prefix: "'\xa78[ \xa7f\xa7lCHAT \xa78]'"
non-permission: "'\xa77Dette har du ikke adgang til.'"
Translate at runtime
You seem to not understand what translateAlternateColorCodes do
I though it could be used on this way
Replace that goofy character with &