#development
1 messages ยท Page 52 of 1
definitely a skill issue
thats even more verbose lmao
also never done hover and click actions?
i never use custom hexes
i do, my api handles all of it tho
https://github.com/srnyx/annoying-api/wiki/Messages-file#json-components-
Brb imma throw up
HEY
Meanwhile <hover>Hey</hover>
i'll see you the day mojang finally removes the rendering of ยง codes in the client 

that would never happen!!
except for the fact they confirmed they are gonna do it but sure
So you dont like mm but you like that abomination?
i worked hard on it :(
and i dont think i knew about adventure when i first made it idk
Never heard of "work smart not hard"?
adventure's been a thing since, like, 2017
I guess they need to add an alternative, right? Or is that the big ass json 
Tbh I've heard of it for the first time 2y ago iirc - wasnt it named "text" before that?
is it possible to use the legacy color codes in minimessage?
absolutely not
:(
even if you could, they are incompatible formats
^
so no
<b>
pretty sure you could do that with custom tags no?
<green> for green
ik, i just wouldnt like having to write out each color every time
you can do custom tags yeah
but there are reserved ones like <b>, <s>, <i>, etc
b stands for bold btw
unlike kobfuscated, lold, mtrikethrough, nunderline, and otalic
would <green><b>bold green behave the same way as &a&lbold green?
my favorite situation is &a&lA&c&lB&9&lC -> <b><green>A<red>B<blue>C
thats... illegal... !!!!!!!
&5 is dark purple, blue is &1
yeah i couldnt think of the normal blue so i just went with dark ๐
i usually have them all memorized >:(
You know what else you could do
but then if u want &a&lA&cB&d&lC&2D you'd have to do <b><green>A</b><red>B<b><purple>C</b><dark_green>D, escaping each bold
no
public static final String A = "<green>"
Tehnically yes ig, and that means closing, not escaping
wait both of them are getting hard to read ๐ yeah
same thing tbh
no
No is not
not the same thing
ok well i meant the same thing!!
Escape could be \<b>
that'd print <b> right, no conversion?
Idk, probably
the literal text, yes
Make your own enum
NamedTextColor
Except that they are constants, but you can do text("green text", GREEN)
huh
I mean, unlike ChatColor which is an enum, NamedTextColor contains the default colors as constants (public static fields)
not much of a difference but, yeah that is true
wouldnt i still be able to use them like this: NamedTextColor.GREEN + TextDecoration.BOLD + "bold green"
reason it's not an enum was because they needed to implement Comparable which enum makes final compareTo
No
god no
the toString yields debug output
components are pretty clunky i gotta say, its the ideomatic way of doing things though
so then what would i do? i am definitely not using a disgusting builder type thing
i think text() accepts color and decoration, otherwise you can call the method color() and, uh, decoration() (?)
suck it?
minecraft has used components to represent text for almost a decade at this point
apparently you have either not heard of minimessage or dont know proper java patterns
Nothing stops you from using MM if you want hardcoded components with a lot of style
ive heard of minimessage and ive tried it out, was while ago tho, i think the components is what made me stop using it
and probably the 2nd thing too
minimessage. isnt. components.
oh sorry i thought u were saying something else my bad
send messages through morse code & noteblocks
yes
noteblocks??? why not random mob sounds
Obfuscated messages
mob sounds are too long it would be very inefficient
what is mm
btw you don't need to close it lol
well
you do
ah
I see what you did there
It's really nice with static imports
Does this work? <b><green>A</b><red> it's so cursed to open the tag before the next and then close it in the middle lol
<green><b>A</b><red> for sane people
isn't there an <r>?
could make it look a tiny bit better with <green><b>A<r><red>B
spare one char
xD
ah it's <reset>
ChatGPT became op
uh?
op
very
although what became even more OP is the fact that I can just inspect Rectangle class from java awt and check the formula to see if a rectangle intersects another or is inside another
It's not written by an ai. I wrote it. I'm pretty new to java still and if you look at my message I wasn't asking people to check my entire code. it was meant to be a quick proof of concept that was written incorrectly. If you want I can rewrite it, but I did only ask about .setRemainingAir() and .damage()
ignore tony, he is that one guy that every server has, that almost every member dislikes and is likely to get banned for toxicity any time in the future. He's here only to cause problems and to make himself feel superior to others since in real life he's probably no one, so he just goes online to have his "me" time.
ah okay. ๐
np ๐
because saying "learn java" and not providing pointers is very helpful and not condescending
discord isnt stackoverflow kekw
What's the easiest method to check if BlockDropItemEvent actually had a chance of dropping an item (other than just the contents of an inventory)? For some reason I thought it didn't get called if the player used the wrong tool, but it still does and I also need to check for the event being cancelled or if the player is in creative. But then, even if you're in creative, multi-block structures such as torches will still be dropped, just not the original block broken. I was thinking I could just check if event.getItems() is empty, but that doesn't account for breaking containers such as dispensers with items in it using your fist (where the items are still dropped but not the dispenser itself) and would also have a random outcome if you harvested crops. I'm just hoping there's something that checks all this for me.
Block.getDrops(handItemStack)?
Wouldn't that be no different to event.getItems()?
well its just the block, not the blockstate
which means it doesnt account for containers with items in it
or atleast i dont think it does
Oh that's fair, but it still wouldn't account for blocks with randomised drops such as crops, and it wouldn't account for multi-block structures where the items are dropped regardless of the item in the player's hand
i would assume theres a method somewhere that shows the drops and drop chances of an ite.
block
tho im not sure if its nms only
I think that's what LootTables are for, but I've tried playing with LootTables before and it is... painful to say the least. That combined with having to do some sort of check for if the block was directly broken by the player, and if the player is in creative mode, and if the event was cancelled, and if the event is recursive (this one is specific to my implementation, but it's still another thing to add on to the pile of checks)... there must be an easier way ๐
not really, block drops are semi-randomized and based on loot tables stuff yes, there isn't really an easy way to get a weighted list or something like that without, like, running a bajillion generations and creating it yourself
Welp so that's not even really an option
afaik all blocks in the game drop atleast one of each of its possible items
yeah but that's not hardcoded anywhere anyway
Actually ye, just checked the loottables for crops and that seems to be the case, although I have a feeling there's gonna be some strange edge-case
and if there is you will probably end up hitting them at some point and you can fix accordingly
I'm looking through the Spigot patches to see exactly how Spigot itself determines whether to drop anything. It seems like world.captureDrops is supposed to be a temperary store of the items that will be dropped, but I can't find anywhere where this is updated?
https://hub.spigotmc.org/stash/users/i509vcb/repos/adddecorationspopulator-cb/browse/nms-patches/PlayerInteractManager.patch#202-224
it wouldnt be in the spigot source
it would be in net minecraft itself
Oh I didn't see the @@ -228,13 +350,27 @@, I thought all that code I linked to was pure Spigot (well, it is, but it has that missing section)
might have to go dig through the minecraft server code
im sure the Block.getDrops(itemstack) goes somewhere
I'm currently on the 1.7.10 NMS lol. I'm guessing the EULA was updated in 1.8? You can probs find some decomp somewhere, but y'know piracy
Well cos there was that whole CraftBukkit argument, the reason why Spigot has to use patches and the BuildTools in the first place
Sorry, not the EULA, I forget which it is
still what does that have to do with it?
build spigot 1.7.10 with buildtools, change in your pom.xml or gradle build file the spigot depenency to use spigot instead of spigot-api and reload, then look through your external libraries and bobs your uncle you can attempt to find it
Block.getDrops starts at CraftBlock afaik
I just mean cos, at least as far as I understand, CraftBukkit used to decomp Minecraft server and Bukkit/Spigot would just directly modify and redistribute that code, which would be why 1.7.10 is available right on GitHub, but then at some point (I'm guessing 1.8) they were threatened about it by Mojang and they had to switch to using patches, so future versions aren't as easy to obtain anymore
you dont need to use a public decomp when you can decomp it yourself
Fair lol
Well I have already ran BuildTools for 1.19.4 (the version I'm writing my plugin for) so I'll just open that up rq
your probably better off going through 1.7.10 if thats what version your using
it couldve moved
i know for a fact they changed the location of alot of classes
wdym version I'm using? I was only referencing 1.7.10 before because it was the first result on Google for "net minecraft server source code" lmao
well this message got me confused then
i assumed you were doing 1.7.10
Oh right I meant I was "on it" as in I was looking at the source code, not using it for my plugin
so uhh..
I'm guessing I'm looking in the wrong file cos this looks no different to the code on the Spigot stash but I can't find the correct one ๐ BuildTools\CraftBukkit\src\main\java\net\minecraft\server\level\PlayerInteractManager.java
(if you can't tell, I don't really know how Minecraft patches work lol. I do feel like it would be something quite useful to know though)
also can you get rid of eating/e-eye/holding shield speed reduction using plugins and/or potion effects and/or area effect clouds
someone in the comments of this video https://www.youtube.com/watch?v=ufD4eY0mWII said they were using area effect clouds to get rid of the slowdown
Any suggestions for dealing with a circular dependency issue? I have a core plugin that depends on a duels plugin, but the duels plugin depends on the economy of the core for gambling. The only thing I can think of is to make the duels plugin periodically check if the economy is registered with vault or not. Any other ideas?
I have just thought of a case where a destroyed block has a random chance of whether it drops an item- explosions. And I have absolutely no idea how I could go about still handling an exploded block which didn't drop anything
Oh and also leaf decay
That seems odd, why does the core plugin depend on the duels plugin?
to check if players are in duels or not - it uses the duels api for that
Why don't you check that in the duels plugin?
for example, there is a combat logging system in the core. I don't want players in duels to be tagged in combat
it would not be very organized in my opinion to put the duels plugin in charge of that
hmm, ill think about it, thanks for the suggestion
No problem
there is a lot of things that it does though, not just combat log checking
You should make those into API methods then, the core plugin shouldn't rely on the duels plugin at all
an API for the core, that the duels plugin calls?
i feel like i would have to keep adding on to the duels plugin every time a basic feature is added to the core
If it's a core that you're depending on, it should have an API for anything used externally anyways
idk, it seems really messy to me - shouldnt the duels plugin focus strictly on duels, and not have to worry about how the core works?
It's a lot less messy than trying to figure out a circular dependency
If you look at any popular plugin, they call API methods on other plugins to add support, which is basically what you're doing with the duels plugin when you want to cancel combat logging
so say i wanted to make a staff mode command in the core that randomly teleports to players that aren't in duels. As it is now, I'd just have a DuelsApi.IsInMatch(player). But if I dont want the core to depend on the duels plugin, I'd have to add this whole command to the duels plugin
and now duels would be responsible for staff mode - not what i want
I think i'd rather modify the duels plugin so it just waits to enable gambling until vault is hooked
No you don't
You can make something like
public class StaffPreTeleportEvent extends Event {
private final Collection<Player> potentialPlayers;
public void removePlayerIf(Predicate<Player> predicate();
That's just an example of how it would work, not the exact way it should be implemented.
Then, the duels plugin would just remove people in a duel from the potentialPlayers collection
so core fires a custom "preteleport" event, duels listens for it and modifies the parameters, then core handles the "non-pre" teleport event?
Yes
Ahh... then i'd need to update both plugins every time I add any feature like that. I understand it's probably some better design pattern, but it seems a bit much to me. I'm most likely just going to make a DuelsHelper class in the core that wraps the duels API with a check to see if the duels plugin is loaded
Then just put the core as a softdepend in the duels plugin so it loads first
Wouldn't you have to update both anyways?
I dont think so, in the way I described I would just have the core call DuelsHelper to see if the player is in a match. If duels is loaded and they are in a match, it returns true. Duels API doesn't need to know what it's being used for, so it wouldn't need to be updated for this feature to be added. Maybe I'm missing something though
That is still updating both, right? Because if the duels api is returning different values, then the DuelsHelper will have to be modified to fit that, correct?
Hmm, I'm not understanding. If the duels api is changed some time in the future in a way that breaks the helper, then yes ill have to update the DuelsHelper. But that seems unlikely, it just contains very simple methods to check if players are in duels, which kit theyre using, etc.
and i'd still only have to change the helper side of things, not the duels api
no there no libraries for goal/path
Okay you're definitely trolling
can i do this now
trolling what and who did you see what emily suggest and later emily legit said what i told him to do
im glad u made it ๐
You said there are no libraries for pathfinding
there legit no libararies for it
u may try to make the first one lool its a very very different goal every time pointless to make a library
Paper has an API for it
for path library lmao path library is a custom class its lke making library for coding a "plugin" its very general its just utils like math not an library
every mob has its own movement and own path
maybe just library that saves some boilterplate code nohng else.
That's what every library does
Tony when they realize a library adds utility ๐ณ
tony when they state one of the use-cases of a library 
i say it because a library for path finding wont be really a an option
its basically just using some one else path finding code
๐คฆ
dont speak u dont even know how o code it
so please
why u light me up again
fun fact: he does :)
he doesnt know nms
accordiing to wha he said
lmao
so please
why you even answer insttead of him
he has only bukkit api knoweldge
i told the guy what to do that srynx he was like u troll
till someone else told him same
you're spreading misinformation here
he said it yesterday
and what i said is correct
the guy asked how he can make entity follow him and shot also target , emily said get wolf and send packet to discuss the wolf , ii said pathfinder && goals
but there are libraries for stuff like that out there
spesfied goal libraries not what he needs...
for example you need to build a plane you have blueprint for a whole plane without engine blueprints?
you see it wont work like thatt
seems like you don't understand what library means
that guy expects a library to cover him tthe whole thing
now he gonna say he doesnt
seems like you dont understand where library can be used and where not
if there a pathfinding library then you are limited on creativity of pathfinding algorithm
Hi! Someone here has already used Protocollib to change metadata of an Item Display? I want to change the displayed item, but after the packet is sent, the client is disconnected with this error : Internal Exception: io.netty.handler.codec.EncoderException: java.lang.ClassCastException: class net.minecraft.network.syncher.DataWatcher$Item cannot be cast to class net.minecraft.network.syncher.DataWatcher$b (net.minecraft.network.syncher.DataWatcher$Item and net.minecraft.network.syncher.DataWatcher$b are in unnamed module of loader java.net.URLClassLoader @6f2b958e)
It's seem that I send the wrong DataWatcher to the client, but i'm sure that I converted to the good type.
Here is the code to create the packet :
PacketContainer modify = manager.createPacket(PacketType.Play.Server.ENTITY_METADATA);
modify.getIntegers().write(0, entityId);
modify.getWatchableCollectionModifier().write(0, List.of(
new WrappedWatchableObject(new WrappedDataWatcher.WrappedDataWatcherObject(22,
WrappedDataWatcher.Registry.getItemStackSerializer(false)),
BukkitConverters.getItemStackConverter().getGeneric(item))
));
Here is the page about the packet :
https://wiki.vg/Protocol#Set_Entity_Metadata
Here is the page about the entity metadata for an item display
https://wiki.vg/Entity_metadata#Item_Display
Here is the test code from Protocollib that I found to convert Bukkit item to net.minecraft item :
https://github.com/dmulloy2/ProtocolLib/blob/master/src/test/java/com/comphenix/protocol/events/PacketContainerTest.java?plain=1#L837
HI, question, its possible to set the tab completion for command of another plugin?
yes.
anyone knows how to listen when an item gets destroyed by void in bukkit?
EntityDeath doesn't work
ItemDespawn doesn't work
EntityDamage doesn't work
doesn't work = doesn't get fired when item is destroyed by void
hmm can you explan exactly why you want to listen to it?
not sure what event would work never tried it by listen if you have spesific reason that like when item summons that should drop just add it to a list and iterate and get the entity (item) location and once it
so basiically once entity.getlocation.getY is > -??? do something or check if entity is alive
idk what you just said but I wanna listen to it so that I can cancel it and tp item elsewhere
Doing what you just said would cause lag cuz you have to iterate through all items every tick checking it's position and you have to handle chunk loading and stuff.
Hooking into the game where it voids the item would be way faster as you don't have to iterate through items twice and it's already handled in the game's code.
no
not every tick
every 20 ticks
or more
also 0 lags
even if you have 10,000 items falling at same time
I'm asking if there is an event that fires when the game voids an item entity not this shitty workaround.
checking every 20 ticks would be there will be a delay of 1 second then?
plus pushing items into an array would require extra memory.
I do .getType() == Item
its laggy shit
and wtf is .getType() == Item
dont check for ittem check if its in an Instance Of ItemStack entity
i can code it and test if it fires for me
EntityType getEntityType() Gets the EntityType of the Entity involved in this event.
try
also I have a question.
How does protocollib handles packets?
I don't see listener for that.
Does it use @Mixin?
i dont use protocollib its shit
there only one way to handle packets
its via server pipe line
if u send then u dont have to deal with it
what exactly do you think protocollib does
wdym server pipe line. How do I cancel a packet and send one to the client with this "server pipe line"
what packet?
network packets
any packets.
why you do xy problem men common im here to help u
theres no api for packets in spigot so it's not the listener system
what PL does (and really the only way of doing it) is hooking into the internal netty processing pipeline. you can see how its done in com.comphenix.protocol.injector.netty.manager.NetworkManagerInjector
I want to be able to:
- cancel them.
- create them.
- modify them.
k
Brister said correct thing
but you xy problem
wont help u with that ill just quickly see if my event works
wiith void problem
PL can do all of those
Brister please
I see
what
so u tested it right? did it work?
u r the example for non tf2 player
?
for the worst there take tthe aspects from here i wont continue that
how 2 detect when item entity gets voided by void
sec joning game
what are u saying lmao
why do you need packets for that? EntityDeathEvent should work fine
tried this and didn't work.
And the packets question was for a different thing.
men im helping u
just be patient
sec it dont fire Entitty Death event
itemDespawn also dont fire
loop.
and also you can write an idle list
for example correctt managment will be like by priority A < (every 60ticks) B < (every 120tcks)
and a clean lsit.
how to do?
can someone help with installing pterodactyl panel
hey
hi
hi, im trying to include adventure in my library (ive succumb
)
but, if one of my plugins is using paper, i want my library/plugin to use paper's implemented adventure and not my library's
what is the proper way to implement adventure to achieve this functionality?
if paper is already included, you just need to use compileOnly, no need to implement it or shade it
ah wait
well that's tricky, and a good question. Think there is no way to do that really? Besides maybe with paper plugin loaders, but those are latest version only and well, paper only.
since you would have to implement them according to the server software
lol
this would have to be checked at runtime if I am not mistaken
what
if (server is using paper) {
not shade adventure and use papers
} else {
shade adventure and use the plugins adventure
}
if I understood correctly
You should be able to exclude Adventure from paper I think
simply better
skill issue-d
why would you do that?
adventure is provided either way
whether you exclude it in your plugin or not
it's still there, in the server.
Yeah but you're trying to shade Adventure aren't you?
shade >> relocate >> check if exists in original paper package (reflection?) >> if exists in original package - use/else use relocated >> profit?
still weird idea on its own
Why not just always use the shaded if it's shaded anyways?
idk
That's just a bunch of unnecessary work
because then you can not use the paper methods
I mean you don't really need those
Why not?
Yeah but for example, you could do things like ShowItem.of(ItemStack)
Edit: actually Component#setHoverEvent(ItemStack) directly
All the paper adventure methods can just be done through adventure
even stuff like AsyncPlayerChatEvent or whatever?
If you're supporting Spigot you're going to have to use the Spigot chat event anyways
that is not true though, you can just have an if to decide what event to listen to
Yeah but that's kind of pointless
declaration: package: io.papermc.paper.event.player, class: AsyncChatEvent
but again, relocating (or simply shading?) adventure will not let you use the components from paper
yeah, if my library has a method that returns a Component (from it's shaded adventure), i wouldnt be able to use it in any of paper's adventure methods
wait what if i use compileOnlyApi?
Component#toPaperComponent? ๐ฅด
if it comes to it ill just do some excluding magic when declaring my dependencies
but i think this should work
wait no it wouldnt for spigot plugins, i'd have to implement adventure for each of them
i think using compileOnly for adventure in my library and then implementing adventure in my spigot plugins is the only way 
I'm just now getting round to having an attempt at writing the code I discussed yesterday for checking if a BlockDropItemEvent should actually drop items (despite what the name of the event suggests, it gets called in some scenarios where no items should be dropped, such as the player being in creative, the player using the wrong tool and the doTileDrops gamerule being false). I first wanted to deal with the player being in creative, but because the BlockDropItemEvent also gets called for multi-block structures (which is the main reason I'm using that event instead of BlockBreakEvent in the first place) and other blocks in a multi-block structure still drop items if you're in creative, I need to check if the block is the one originally broken by the player. I thought this could be done using a raytrace, but BlockDropItemEvent is called after the block is already broken meaning a raytrace would pass through the block's previous position, so now I'm stuck. It seems like I'm gonna have to do some weird combination of both the BlockBreakEvent and the BlockDropItemEvent to be able to do this, but I'm not sure if I can guarantee that the last BlockBreakEvent is always the one that triggered a BlockDropItemEvent, especially with some server implementations moving towards using more concurrency. Is there a definite way to identify if a BlockDropItemEvent is for the original block broken?
set a UUID in metadata when the block is broken, then read in the drop event perhaps?
I keep forgetting I can store data on loads of Bukkit stuff haha. Don't think I'd even need a UUID- just something that says "this block has been directly broken by a player". This would only not work if there's some way the event can still be cancelled after me receiving it on EventPriority.MONITOR, but I understand the point of that priority being that you can guarantee the event is going to be carried through with so that should work
anyone got a better idea?
Doesn't it have a getSource method?
You can also just manually check if other blocks will be broken by checking connected blocks
No
That would be even more difficult- I don't know how to check if a block is part of a multi-block structure, then I'd also need to check if it can 'repair' itself using other surrounding blocks (e.g: If you break a block behind a torch with another block below it)
What are you trying to do with the plugin?
Brister's method of storing data on the block should work, but I want the plugin to randomise the drops of blocks but I only want to replace the drops if the block is actually supposed to drop anything in the first place and I also don't want there to be a way for player's to get the original drops such as by using water which is what I'm struggling with now. What determines if a block can be broken by water/lava? I'm guessing it's either isBuildable, isPassable or isReplaceable but they seem very similar so not sure which is actually accurate
Canโt you just check if the drops are empty?
No, because that doesn't take into account if the player used the correct tool or if the player is in creative mode or if the doTileDrops gamemode is toggled or if the block is a container
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockDropItem(@NotNull BlockDropItemEvent event) {
if (processingEvent) return;
if (event.getBlockState().hasMetadata(BROKEN_BLOCK_KEY)) return;
if (!isInOngoingGame(event.getPlayer())) return;
if (event.getBlockState().getWorld().getGameRuleValue(GameRule.DO_TILE_DROPS) == Boolean.FALSE) return;
final List<ItemStack> inventoryContents = new ArrayList<>();
if (event.getBlockState() instanceof InventoryHolder) {
final Material type = event.getBlockState().getType();
boolean removedBlockItem = false;
for (Item item : event.getItems()) {
final ItemStack itemStack = item.getItemStack();
if (!removedBlockItem && itemStack.getType() == type) {
removedBlockItem = true;
if (itemStack.getAmount() <= 1) continue;
itemStack.setAmount(itemStack.getAmount()-1);
}
inventoryContents.add(itemStack);
}
}
event.setCancelled(true);
processingEvent = true;
new BlockDropItemEvent(
event.getBlock(),
event.getBlockState(),
event.getPlayer(),
dropItems(event.getBlockState(), inventoryContents)
).callEvent();
processingEvent = false;
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(@NotNull BlockBreakEvent event) {
if (
event.getPlayer().getGameMode() != GameMode.CREATIVE || !(
event.getBlock().getBlockData().requiresCorrectToolForDrops() &&
event.getBlock().isValidTool(event.getPlayer().getInventory().getItemInMainHand())
)
) {
event.getBlock().getState().setMetadata(BROKEN_BLOCK_KEY, new FixedMetadataValue(this, null));
}
}```
And this only handles blocks broken directly by players- there's even more code for handling explosions and I've still got to write the code for leaf decay, pistons and liquid flow ๐ญ
It seems weird that itโs telling you drops for creative mode, I donโt remember that happening to me
Or do you only mean when a secondary block is broken?
It's very counter-intuitive but sadly ye it does ๐
It's for both, which makes it more difficult cos I need to differentiate between them
Just tested the code and it doesn't even work, welp. Just no drops are being replaced anymore ๐
First issue was my creative mode check was inverted, but second issue is that it's saying air isn't a valid tool for dirt which... maybe makes sense??
Fixed that, but next issue is that for some reason BlockState.hasMetaData(BROKEN_BLOCK_KEY) is always true even though I can see that metadata isn't present
I don't think you can store metadata on every blocks state
@tiny dew can you explain more what you mean by items dropping in creative?
I'm trying
@EventHandler
public void onBlockDrop(BlockDropItemEvent event) {
for (Item itemStack : event.getItems()) {
Bukkit.broadcastMessage("Item: " + itemStack.getItemStack().getType().name());
}
}
And nothing is broadcast in creative when breaking, only survival
Oh, I thought event.getItems() still had items even in creative but I suppose not
How were you testing?
Honestly it wasnโt the event.getItems I was testing, I just noticed the event being called at all despite being in creative and assumed the check for creative was done afterwards
ofc
because create doesnt actually break blocks
but delettets them
What?
Creative doesn't break blocks, it deletes them
So I guess it's just Tony adding nothing to the conversation again
Creative does break blocks. You just have to use BlockBreakEvent... BlockDropItemEvent won't run because its not dropping items when you're in creative.
You can use BlockBreakEvent.getBlock().getDrops()
Am pretty new with Tilestate, but want to set some data into a block with tilestate and it seems to lose the data on place?
kinda want some basic data to be there and store the rest in local storage or wahtever
You can use PersistentDataContainer
You might've been using metadata or something similar?
If you're using PDC, then send code
I am, but it seems to get lost straight away.
public void onBlockPlace(BlockPlaceEvent event) {
Block block = event.getBlock();
if (block.getType() == Material.CAMPFIRE) {
Player player = event.getPlayer();
UUID playerUUID = player.getUniqueId();
Campfire campfire = (Campfire) block.getState();
PersistentDataContainer dataContainer = campfire.getPersistentDataContainer();
dataContainer.set(
getNamespacedKey(PLAYER_UUID_KEY),
PersistentDataType.STRING,
playerUUID.toString()
);
campfire.update();
}
}
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
Block block = event.getBlock();
if (block.getType() == Material.CAMPFIRE) {
BlockState blockState = block.getState();
if (blockState instanceof Campfire) {
Campfire campfire = (Campfire) blockState;
PersistentDataContainer dataContainer = campfire.getPersistentDataContainer();
if (dataContainer.has(getNamespacedKey(PLAYER_UUID_KEY), PersistentDataType.STRING)) {
String playerUUIDString = dataContainer.get(getNamespacedKey(PLAYER_UUID_KEY), PersistentDataType.STRING);
UUID playerUUID = UUID.fromString(playerUUIDString);
Player player = event.getPlayer();
if (playerUUID.equals(player.getUniqueId())) {
// Campfire belongs to the player
// Retrieve tile data or perform actions here
// Example: String customData = dataContainer.get(getNamespacedKey("customDataKey"), PersistentDataType.STRING);
player.sendMessage("This campfire belongs to you!");
}
}
}
}
}
event is registered and fires perfectly fine
what about if you try caching the namespaced keys? ๐คท
like storing a NamspacedKey variable isntead of a String variable
probably wouldn't matter but worth a shot? :))
Also try putting some debug logs as well
that's what I wanted to avoid to use less resources by easily just checking if the player mining the campfire is the owner or not
and store more intensive data in cache instead or local database.
but I'll give it a go
wait
im not saying to change anything
I'm just saying to cache the keys instead of making a new one every time (which is what I'm assuming you're doing)
and adding debug logs (System.out.println)
also iirc PDC just involves a Map, so the amount of data shouldn't matter
unless you mean memory, but that would be a lot of data to make an impact
am using them as sort of warp points for the players. sort of like the dark souls games. they can teleport from one to another, and just wanted a basic method of checking if someone breaks it and isn't the owner
anyways can you try this and show new code with debug logs & output?
Yes, I will in a moment!
๐
Have you checked to make sure you're listeners are being called?
Anyone know a logj4 config that displays that data of packets not just what packet and incoming/outgoing?
how is that related to log4j
Cause its a log4j config...
feels like context is missing
the xml config for the logger
yeah... but which packets are you talking about and how are they passed to log4j?
All packets. And because the config I currently have only says which packet and if its in/out
minecraft packets?
yes
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" packages="com.mojang.util">
<Appenders>
<Console name="SysOut" target="SYSTEM_OUT">
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
</Console>
<Queue name="ServerGuiConsole">
<PatternLayout pattern="[%d{HH:mm:ss} %level]: %msg%n" />
</Queue>
<RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz">
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
<Policies>
<TimeBasedTriggeringPolicy />
<OnStartupTriggeringPolicy />
</Policies>
<DefaultRolloverStrategy max="1000"/>
</RollingRandomAccessFile>
</Appenders>
<Loggers>
<Root level="debug">
<filters>
<MarkerFilter marker="NETWORK_PACKETS" onMatch="ACCEPT" onMismatch="DENY" />
</filters>
<AppenderRef ref="SysOut"/>
<AppenderRef ref="File"/>
<AppenderRef ref="ServerGuiConsole"/>
</Root>
</Loggers>
</Configuration>
you can't change in the config what MC passes to the logger
you'd need to change the MC code
Ok. Thanks
Actually... Shouldn't there still be a way to get that data? You can get it from the players connection... and the logger can see which packet and if its incoming/outgoing so I don't see why it can't see said packets data
shut up you ido
idiot
very annoying
the logger doesn't "see" anything, it gets called by the packet decoder with the arguments given in the messages passed to it
๐
and only those arguments can be seen by the logger
Hi,
i don' undesertand how workd this calcul
long minutes = (seconds / 60) % 60;
who can explain to me? (what is %60)
manz first time seing modulo
bruh these guys forgot to type Math.
๐ค
quick tut
it's the remainder of the division
the simplest way to learn imo is:
1 / 10 = 0.1, so the remainder is 1, 1 % 10 = 1
10 / 10 = 0, remainder is 0, 10 % 10 = 0 (same for every n * 10)
15 / 10 = 1.5, the remainder is 5, so 15 % 10 = 5
quick meth
where would one find the info to place in this, so I can update my wiki <dependency> <groupId>com.github.Staartvin</groupId> <artifactId>Autorank-2</artifactId> <version>VersionHere</version> </dependency>
I assume the updated look would be if my URL is https://github.com/Ironic8b498/Autorank <dependency> <groupId>com.github.Ironic8b498</groupId> <artifactId>Autorank</artifactId> <version>VersionHere</version> </dependency>
ah okay is divison but just int
other question, i want make a cooldown message like
h/Min/S
how to do?I've been looking for 4 hours but I can't find how to do it
Hey, I am creating an own ChestShop Plugin and I want to use index 1 of the Sign Line to be the String value of a Material. However if you type in "?" the Sign will automatically change the Line in the index of 1 to the first Item in the Chest. It doesn't work, it always gives me the same Error: "java.lang.IllegalArgumentException: No enum constant org.bukkit.Material.?" How can I prevent this?
Guys I wrote a plugin that makes items dropped from players not despawn but it sometimes produce this weird error and duped the items
[13:27:52 ERROR]: Failed to handle packet net.minecraft.network.protocol.game.PacketPlayInUseEntity@1ee953a, suppressing error>
java.lang.NullPointerException: Cannot invoke "net.minecraft.nbt.NBTBase.d()" because the return value of "java.util.Map$Entry.getValue()" is null
at net.minecraft.nbt.CompoundTag.copy(CompoundTag.java:473) ~[?:?]
at net.minecraft.world.item.ItemStack.copy(ItemStack.java:733) ~[paper-1.20.1.jar:git-Paper-50]
at net.minecraft.world.item.ItemStack.copy(ItemStack.java:721) ~[paper-1.20.1.jar:git-Paper-50]
...
at net.minecraft.server.level.ServerLevel.addEntity(ServerLevel.java:1661) ~[?:?]
at net.minecraft.server.level.ServerLevel.addFreshEntity(ServerLevel.java:1564) ~[?:?]
at org.bukkit.craftbukkit.v1_20_R1.CraftWorld.dropItem(CraftWorld.java:709) ~[paper-1.20.1.jar:git-Paper-50]
at org.bukkit.craftbukkit.v1_20_R1.CraftWorld.dropItem(CraftWorld.java:695) ~[paper-1.20.1.jar:git-Paper-50]
at org.bukkit.craftbukkit.v1_20_R1.event.CraftEventFactory.callPlayerDeathEvent(CraftEventFactory.java:939) ~[paper-1.20.1.jar:git-Paper-50]
at net.minecraft.server.level.ServerPlayer.die(ServerPlayer.java:958) ~[?:?]
Do you mean 99tracheae or me?
i meant tracheae sorry lol
feel free to send your code too mars
I mean it's pretty compact. Didn't know how to simplify it 
just send the relevant parts 
if you're stuck on which parts to send, a good place to start would be all the code surrounding each line referenced by your stack trace
private static double costs;
private static String shop;
@EventHandler
public void onSignChange(SignChangeEvent e) {
Player p = e.getPlayer();
costs = 25;
shop = "ยง8[ยงa" + p.getName() + "ยง8]";
Integer amount = Integer.valueOf(e.getLine(2));
String[] l3 = e.getLine(3).toUpperCase().split(" ");
Chest chest = (Chest) e.getBlock().getRelative(0, -1, 0).getState();
Material m =Material.valueOf(e.getLine(1).toUpperCase());
if(e.getLine(0).equalsIgnoreCase("[shop]")) {
if(chestShopMethods.hasChest(e.getBlock())) {
if(player.getBalance(p) >= costs) {
this is the problem maker -->if(m != null) { ```
I will try it. Other people meant it's better to use valueOf. I will give it a try. Thank you
If you use valueOf you're gonna get an exception if the enum does not match
matching will let you actually null check without having to surround with a try catch
Ahh okay, thank you. That's indeed more useful
You may want to surround the Integer amount line with a try catch NumberFormatException, e.g
Integer amount = 1;
try {
amount = Integer.parseInt(whatever);
} catch (NumberFormatException e) {
// no amount :(
}
because java is stinky and has literally no getIntOrNull function
dont we all
yep
idk, haven't programmed with it yet xd
What's guava?
A general purpose java library bundled with spigot
So you donโt need to add anything to use it
she java my spigot till i guava
โน๏ธ
Hey guys, just a simple question
How do I do this in Javacript?
<img src="https://flagcdn.com/48x36/" + {flight.flightLegs[0].arrivalInformation.airport.country.code} + ".png"/>```
Bit new to JS/react
shouldnโt the whole concatenated string be in {} here
otherwise youโre just writing the +โs as html
src={blah}
Ah oke so like this isn't possible
I know I did something like this in Java
But yeah thats different ofc
Thanks
what no bm just meant you need to do something like this
<img src={"https://flagcdn.com/48x36/" + flight.flightLegs[0].arrivalInformation.airport.country.code + ".png"}/>
what you're writing here would render as <img src="https://flagcdn.com/48x36/" + blah + ".png"/> which obviously isnt valid html
Sorry my English is bad
I meant it not that it isn't possible, I mean that the way I used it is not possible
ah
Yeah true
well, yeah its just incorrect
Thanks for the help : )
np
Thanks 
@EventHandler
public void onEntityDropItem(EntityDeathEvent event) {
@NotNull Entity entity = event.getEntity();
if(entity instanceof Player) {
@NotNull List<ItemStack> itemDrops = event.getDrops();
if(itemDrops.isEmpty())
return;
@NotNull World world = entity.getWorld();
for(ItemStack item : itemDrops) {
Item itemEntity = world.dropItemNaturally(entity.getLocation(), item);
itemEntity.setHealth(Integer.MAX_VALUE);
itemEntity.setUnlimitedLifetime(true);
itemEntity.setWillAge(false);
itemEntity.setPickupDelay(0);
}
itemDrops.clear();
}
}
even better, ```jsx
<img src={https://flagcdn.com/48x36/${flight.flightLegs[0].arrivalInformation.airport.country.code}.png} />

uh does configurate update the file every time something is changed?
how do i broadcast an adventure component?
no it needs to be saved
if you're using paper api then Bukkit.broadcast
otherwise BukkitAudiences#all should do it
what if im not using paper api?
oh
u said otherwise
im so tired ๐
me when i read
is BukkitAudiences#all in adventure-platform-bukkit?
uhhhh yeah totally
how are you even sending any messages without BukkitAudiences or paper api lol
i wasnt, this is me testing to see if adventure works 
hmmm
it work i am so smart

how would it work if I used records?
quick question, I need to create a loader for each config I have right? if so, what would be the most compact and easy way to have several configs?
configurate?
https://github.com/HelpChat/ChatChat/blob/main/plugin/src/main/java/at/helpch/chatchat/config/ConfigFactory.java this is how we do it for chatchat
basically a new loader every time
guys
rate my 1 hour tic tac toe project https://github.com/Ivan8or/TicTacToe
it's got inheritance
0/10 because of inheritance
adventure and minimessage
๐ญ
Ty! I'm trying to add it on a plugin.
me silently stealing the create and loader methods
5$
MIT license 
ehehe
outplayed
holy just noticed, y'all using var
lol
fast to code, but bad for readability
Yeah because one HashMap<Something<Here>, SomethingElse<Here>> is not readable enough ๐คฃ
But yeah, I get what you mean xD sometimes is harder to read the code, especially on git
pov: you're using any language besides C and Java
type inference is a mainstay of the vast majority of languages these days lol
especially where the type is obvious, there's no reason not to use it
eh fair enough I suppose, I always use it though for even faster readability lol
Also, lang or messages?
what suits better?
for context, there is only one file for it, you can download other languages from the cloud if needed.
yup, only if it wasn't so ugly to have a random Object x in the middle of 20 var's 
Types are good for platform calls and unobvious types (for readability)
val age = 1 is pretty clear
val tacos = truncate(45)
Isn't so obvious. Either poor naming, or it could use a type to be more clear.
Does spigot clear memory when shutdown?
I've been starting and stopping a server for awhile now and ran out of memory lol
tf? that's not supposed to happen, to my knowledge it does clear the memory
just like restarting a normal app in your pc does
I thought so too... but I had to restart to get it to clear.
Never had this problem before so hoping it's a one off
how do you stop it?
Just the command. /stop
ah unsure, I usually never use that command lol
quick question why does the ConfigManager set the vars to null exactly?
spigot doesn't do it - the OS does it
how do you restart without /stop?
idk, show me
I didnt write the code
ah it just sets them to null, idk why, but the next methods assign values
ah it's probably cause the methods to assign values only create new values from the factory if the vars are null
yeah
had this problem too. I had a bash script that would restart the jvm if it crashed or whatever.
what I noticed is let's say you have 16 gb, you run the server on 12gb, sometimes it wouldn't clear the memory as fast (to my understanding) and it would try to re-allocate the 12gb for the new jvm, therefore running out of memory
y'all are abusing your operating system's allocators lol
I had that issue too, just disable it
it is not related to configurate
confusion
- wrong channel
- what support?
That's the neat part, you don't
we - helpchat- don't offer 1:1 support, and we are not Discord
Looking for discord support?
HelpChat is a Minecraft plugin and development support server and is not affiliated with discord in any way.
If you require support from discord, we recommend you to visit their official support website at https://support.discord.com
On this website, you can read their FAQs, or open a support ticket if necessary.
Oh
sorry for the inconvenience
Restart my pc.
That's probably what happened.
Odd that it's never happened before though.
how can i do string manipulation to an adventure Component? like String#subString(int), or at least the equivalent ping if reply
this don't reload my config anymore, or might never have ``` public void reloadConfig() {
if (this.languageConfigFile == null) {
this.languageConfigFile = new File(this.plugin.getDataFolder() + "/lang", "lang.yml");
}
this.languageConfig = YamlConfiguration.loadConfiguration(this.languageConfigFile);
}```
That code seems correct, try modifying the lang.yml file and calling the method to see if the value has changed?
How would I check if my signs are in glow ink sack? I'm getting the sign text and making sure it matches to something but the sign text is also in glow ink sack would that effect it?
Ask kyori discord
I wouldn't ask adventure questions here
hello im looking for help from a software developer help is there any like that here
:((((
You can't because that wouldn't make sense
you can do some
Not all components contain a fixed size string
but for ex TranslatableComponent can't
Not substring ttho
There is
Hi
String result = PlaceholderAPI.setPlaceholders(p, "%essentials_is_teleport_enabled%");
if (result.equalsIgnoreCase("yes")) {
return true;
} else {
return false;
}
why i never got true?
If I had to guess it's because result doesn't equal yes.
So either the result is never "yes" or it's never being set to "yes"
upstream I parsed the plceholder and it returns yes
@hoary scarab, does Block#getLocation will load the chunk?
no
Shouldn't. Might need to test that yourself though
You can always just do Block#getX, y, and z
Alright, that's perfect. I'm just paranoid that one of this method load the chunk.
public boolean isChunkLoaded() {
int x = this.block.getX() >> 4;
int z = this.block.getZ() >> 4;
return this.block.getWorld().isChunkLoaded(x, z);
}
this.block
I'm worried about this though
I'm worried about that
Like I said you could always just save the chunk coords when you place/generate the generators
you should be storing the Location, not the Block itself
If you really want to be safe, you should make your own immutable Location / Position class
Dkim
Why the reaction ๐
So right now I saved the location of the block, but when I create the object I do location.getBlock(). I don't know if I explained it clearly.
Just use the location portion when checing if the chunk is loaded.
you shouldn't store it as a field though
Ah alright, so storing Location in the field is the better choice?
ya
and note that Location#getBlock will load the chunk, so ig this method, if you kept it as block, it would load the chunk
Okay, I will change it and hopefully it doesn't break anything
Up
hm
Whats the output from the placeholder? I doubt its "yes"
by default it's "yes"
... why???? xD
is yes
i have try to past it on deluxemenu and i got yes/no
Wait... isn't it "parsePlaceholders"? not set
can you show more of the code?
Hey y'all anyone has any ideas on the Guilds api that would fix this or at least how to get the players properly.
Current method:
Player challengers = (Player) e.getChallenger().getOnlineAsPlayers();
Error:
class java.util.ArrayList cannot be cast to class org.bukkit.entity.Player (java.util.ArrayList is in module java.base of loader 'bootstrap'; org.bukkit.entity.Player is in unnamed module of loader 'app')
String result = PlaceholderAPI.setPlaceholders(p, "%essentials_is_teleport_enabled%");
if (result.equalsIgnoreCase("yes")) {
return true;
} else {
return false;
}
}```
can you change that to ```java
public static boolean essentialstp(Player p) {
String result = PlaceholderAPI.setPlaceholders(p, "%essentials_is_teleport_enabled%");
System.out.println(p.getName() + " TELEPORT: " + result);
if (result.equalsIgnoreCase("yes")) {
return true;
} else {
return false;
}
}
okay i try
my best guess right now is that you don't have the Essentials expansion
if because by pasting the placehodler in deluxe menu it returns yes
it's set
any ideas guys?
don't cast it
[07:26:34] [Server thread/INFO]: TELEPORT:
no value returned
hmmmmm... not what i was expecting
wait
did you remove the player name?
Required type:
Player
Provided:
List
<org.bukkit.entity.Player>
yes
you need to loop it
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
but there ar no placeholder returned, why?
damn i forgot how lmao, lemme go check
I'm not sure
ah
was it foreach something?
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
I would recommend method 1-B @deep panther
ah i have an idea, in my plugin dependaces, i don't have add placeholder in plugin.yml, is that?
do you use either maven or gradle?
maven
but yeah you should add it to plugin.yml too
okay i add it so
List<Player> clist = e.getChallenger().getOnlineAsPlayers();
for(Player variable : clist)
{
// Body of the loop.
// Each element can be accessed using variable.
}
``` like this?
yes
what do I write in the body?
you can use the Player variable
@dapper jackal it seems like it gives a blank string if the player is null
Can you send me the code where you call the essentialstp method?
this?
public static boolean essentialstp(Player p) {
String result = PlaceholderAPI.setPlaceholders(p, "%essentials_is_teleport_enabled%");
if (result.equalsIgnoreCase("yes")) {
return true;
} else {
return false;
}
}
what about the code where you do like essentialstp(epicPlayer)?
@EventHandler
public void onEnd(GuildWarEndEvent e) {
List<Player> clist = e.getChallenger().getOnlineAsPlayers();
List<Player> dlist = e.getDefender().getOnlineAsPlayers();
for(Player player : dlist)
{
player.getInventory().clear();
player.setHealth(20.0);
}
for(Player player : clist)
{
player.getInventory().clear();
player.setHealth(20.0);
}
}
``` looks good?
yep ๐
I'm not sure I understand what you're saying,
but it is this code that retrieves the placeholder
like where do you use the method?
ah, use in a gui if is true print a message else other message
can you show me?
if it's a lot then you can put in https://pastes.dev
if (GetPlaceholders.essentialsmoney(this.player)) {
meta.blabla set title (enable)
else
meta.balbla set titel (disable)
it can't have anything to do with my problem, can it?
hmmm
Try this first ```java
public static boolean essentialstp(Player p) {
String result = PlaceholderAPI.setPlaceholders(p, "%essentials_is_teleport_enabled%");
System.out.println("TELEPORT: " + result + ", is not-null: " + (p != null));
if (result.equalsIgnoreCase("yes")) {
return true;
} else {
return false;
}
}
okay
return no value, and player is false
ok that means your player variable is null
Can you send me the whole class?
of this
here
public GetMenuOptions(Player p) {
this.player = p;
and if (GetPlaceholders.essentialstp(this.player))
private Player player;
I'll need more code if you want me to find out where it's coming from
it's that there are really a lot of them, I'm already going to try to find myself and I'll tell you
alr
oh,
private Player player;
here I should do
private Player player = new Player();? is that why it is null?in any case it is this.player which is null
what?
can you send the whole file in https://pastes.dev
the function registering the this.player
private Inventory gui;
private Player player;
public GetMenuOptions(Player p) {
if (p != null) {
setborderitem();
Inventory gui = Bukkit.createInventory(p, 27, ChatColor.DARK_GREEN + "Options");
setborder(gui);
setButtons(gui);
this.gui = gui;
this.player = p;
}
}```
now where do you create the GetMenuItems instance?
yes, when i make a command, i make getMenuOPtions instance
can you show it
GetMenuOptions getMenuOptions = new GetMenuOptions(p);
can you show me more
p= Player and here the function GetMenuOptions my player is not nul but when i set it in my this.player is null
where do you create the p variable?
Player p = (Player) sender;
but is not null
because Inventory gui = Bukkit.createInventory(p, 27, ChatColor.DARK_GREEN + "Options"); work
https://pastes.dev
Can you send me the entire GetMenuIOptions class and the entire command class?
so far it seems fine
so I'll need the entire files
yes
try removing the if statement at line 26
p shouldn't ever be null anyways
so it's better to catch the error first
okay
InputStream inputStream = test.class.getResourceAsStream("fonts/Comfortaa.ttf");
java.awt.Font font = null;
try {
font = java.awt.Font.createFont(java.awt.Font.TRUETYPE_FONT, inputStream);
} catch (FontFormatException | IOException exception) {
exception.printStackTrace();
}
java.io.IOException: Problem reading font data.
at java.desktop/java.awt.Font.createFont0(Font.java:1208)
at java.desktop/java.awt.Font.createFont(Font.java:1076)
at test.test.main(test.java:17)
https://prnt.sc/AIsFECzUv_kf
why do i receive this exception?
but is not the probleme?
try test.class.getClassLoader().getResourceAsStream
By default, if you just use the class, it'll search in the same package as well
test.class.getClassLoader().getResourceAsStream("fonts/Comfortaa.ttf")
same: java.io.IOException: Problem reading font data.
hmm, can also verify that the fonts/Comfortaa.ttf file exists if you open the JAR up using an extracter program?
when i open the file with winrar i see the class but no ttf files, what is the reason?
ah @dusky harness i think,
when i see the this.player = CraftPlayer{name=delor}
is not Playerobject
CraftPlayer is an implementation of Player
ah
(it uses CraftPlayer "behind-the-scenes")
but it should not be player?
no, since internally it uses CraftPlayer, and Player is just what's shown
If you control-click Player (assuming you're using IntelliJ), you'll notice that Player doesn't actually have any actual code inside the methods
and the problem comes from this?
is strange because
juste before
if (GetPlaceholders.essentialstp(this.player)) {
i systemout the this.player and is not nul
but the if this.player is null, he return true
hmmm
ah no, no null
okay, the player become null when i call this
public static boolean essentialstp(Player p)
so the player become null here
(Player p) {
inteleji
maybe because is static?
public static boolean essentialstp(Player p) {
no
oh wait
yes?
are you running your test server in IntelliJ
no
oh
normal localhost
ah i think
i call the function 2 lines before my this.player = p; so is null when icall it
sorry for the disagrement
oh my ๐คฆ
lol I missed that as well, oops!
no probleme, thanks for your help
๐
Sorry it took 1 hour to fix the issue ๐ฅฒ ๐ฅฒ
debugging is painful
how to waste an hour
How i felt working on my npc lib earlier
๐ฅด
At least you fixed it tho
I've had multiple plugins and features that I had to completely stop developing because I couldn't find out the fix ๐ญ
๐ชฆ Bedwars ๐ชฆ
i love how all my github repos look active bc of renovatebot (dependency updater bot)
๐ฅฒ
kinda messes up my recent repos tho
At least you fixed it tho
Nope xD Gave up and went to bed
oh ๐ ๐ ๐ ๐
Actually I didn't give up. I had to restart cause of the out of memory issue lol
FATAL ERROR in native method: Thread[Render thread,10,main]: No context is current or a function that is not available in the current context was called. The JVM will abort execution.
at org.lwjgl.opengl.GL11.glPushMatrix(Native Method)
https://prnt.sc/SEhzMP7sUwSX
i have now managed to get my font to load correctly but now have a problem with GL11
@dusky harness @hoary scarab thank you for the help, the solution is pretty amazing.
๐
Apparently this method consume 8%+ on spark profiler, this method is called when player break their generator (PlayerInteractEvent with LEFT_CLICK_BLOCK), how can I make it better? There are currently 15k+ active generators and there is 3 second cooldown between breaking generator.
public void unregisterActiveGenerator(Block block) {
// unregister the active block
this.activeGenerators.removeIf(active -> active.getLocation().equals(block.getLocation()));
}
how are you storing the generators?
from this sample it looks like they're just a list that you have to iterate through all of em in order to remove one
Using ArrayList
Are there any alternatives other than Map, maybe the better than Map?
Map is as good as you're gonna get lol
what else would you want?
that way it's indexed by location and you can remove it instantly in O(1) time
I was considering using Map but I'm curious if there are any better alternatives than Map xd
So I should create Map<Location, ActiveGenerator> right?
this scenario is perfect for a map
i'm not 100% on if you can safely use a location as the key
you might need to serialize it into something immutable and thread safe
Maybe parse Location into String?
yeah that was my first idea, can't hurt to try it out
I wish I put UUID on every active generator, but that's too late.
lol
Alright thanks, I'll try it out!
yeah no worries, x/y/z/world location will probably be a fine key
u say u java dev in ur profile descripition
fix it ur self.
tony woke up today and chose violence
some troll probably
isn't that his usual days?
legit never seen tony not being rude/toxic
somebody had to say it
did you create > initialize > set it to current the gl context? ๐ฅด
I am using the CoreProtect API, and I have temporary areas that can be edited, but then rolled back when a block is broken. Currently, I am using this singular line to achieve this: java CoreProtect.getInstance().getAPI().performRollback((int) seconds, null, null, null, null, null, RPGProject.getInstance().getConfig().getInt("campsites.radius"), this.origin);
I need it to rollback an area with a radius of 10 blocks, is that the correct way to do so? Currently, there are no errors, but it doesnt rollback anything, the radius is 10, and the origin is a valid location.
How i can parse a placeholder another plugin in method sendMessage ?
ask in coreprotect discord 
what would be a good approach to conditionally calling a method every N seconds?
I have a game instance that involves two phases; a shop phase and a play phase. the shop phase lasts for 45 seconds and I want to avoid busy waiting while the players interact with stuff async. The play phase doesn't have a time limit but takes a few seconds to run; after the play phase ends I need to stop the cycle if the game is won, or continue it if the game is not over yet.
(not minecraft related fyi)
polling is probably your best bet
just have a thing that checks every second or whatever what the next state of the game should be
if it's shop phase and the timer isn't over, then do nothing
if it's shop phase and the timer is over, move to the play phase
etc.
basically big finite state machine
polling feels icky though
if you think about it, everything is polling!
that's how hardware works, that's how game loops work, etc.
think of this as your game loop, since it basically is
Hello, I need advice
in my plugin i need database system,
At first I was just thinking of doing it this way:
when something needs to be changed -> sql query
but for perfs it's not terrible, what was suggested to me,
create a hashmap which the uid (key) and in value an instance of a class which contains the equivalent of the columns,
then at the start of the server I transfer the database into my hashmap, and all my modifications I make them inside this one, then every 5 minutes I save the hashmap in the database.
Is it a good idea ?
I am not sure what's your goal. Tell me first what are you trying to do?
For Data Management you usually use the config which is saving data in a .yml file, so it stays there permanently unless you change the file
I have a system of options (example: knowing if the player wants to receive messages in the chat)
stored in a database, and I need to access this data from time to time
Yeah, I would really recommend using the config
and i was wondering, would it be best to load all players on start up, or load players 1 by 1 when they join and unload them when they leave?
I use too much data for a config
I would do it one by one
and make a request each time a player joins the server is not too much?
Do a PlayerJoinEvent and check if the Config contains a certain boolean value of the Player.
Do you know how FileConfiguration works? If not, I would really recommend you to watch some videos or read some links. It's very important and I also use configs for everything that refers to permanent data
yes but I would prefer to work with databases
Why? You can simply do that with the config. Here's a helpful link: https://www.spigotmc.org/wiki/config-files/
because I have a very large number of data to store
You would have to use APIs then if you want to use external Databases
yes yes, I already know how to do it, I wonder about the best way to interact with it in an optimized way
Hello! How can we set the player's head as the value for "material:"?
Sorry, I can't help you with that. I would still do it with configs.
For Example:
boolean receiveMessage = Plugin.getConfig().set("Players.(playername).receiveMessage", true)
no because if I have 1500 players who have already played on the server, it will be big to store
oh ok, my bad. Did not know there are so many.. I am sry, then I can't help you
no problem
You want to change the helmet slot to a material or what do you mean?
Another idea might be an array list of the players who accepted them and then check everytime a player joins, if he is in the list. Idk if that's better
yeah that's what i was thinking
I want to put the head of the player who opens the menu
items:
'1':
material: head;%player_name%
but it does not work
then you would have an ItemStack for the head:
Player player = e.getPlayer();
ItemStack playerHead= new ItemStack(Material.PLAYER_HEAD)
SkullMeta sMeta = (SkullMeta) playerHead.getItemMeta();
sMeta.setSkullOwner(player);
playerHead.setItemMeta(sMeta);
Inventory inv = <the Inventroy you have>
inv.setItem(<index>, playerHead);
player.openInventory(<inv>);
Idk if it is that, what you want. English is not my first language, so sometimes its hard to really notice what people want. I apologize for that xD
Uhh nice. Je peux parler francais un petit peu
xd
Wait, I will dm you, so we can get more specific ok? I don't want to spam the help chat here
lol
I have this code, and it all works except for that dropItems doesn't actually spawn an item entity when called by BlockDestroyEvent. So, if I break dirt, it works perfectly. If I break a torch, it works perfectly. However, if I break dirt with a torch on it, the dirt drops an item and I can see in the debugger that dropItemNaturally is called for the drops for the torch, but in-game I don't actually see a dropped item for the torch. It's the exact same function either way, I don't understand why there is any difference at all. Any ideas?```java
private List<Item> dropItems(@NotNull Block block) {
final List<ItemStack> newDroppedItems = game.getNewDropsFor(block.getType());
if (block instanceof InventoryHolder inventoryHolder) addFromInventory(newDroppedItems, inventoryHolder);
game.learn(block.getType());
return newDroppedItems.stream().map(
itemStack -> block.getWorld().dropItemNaturally(block.getLocation(), itemStack)
).toList();
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(@NotNull BlockBreakEvent event) {
if (!isInOngoingGame(event.getPlayer())) return;
if (!event.isDropItems()) return;
if (event.getBlock().getWorld().getGameRuleValue(GameRule.DO_TILE_DROPS) == Boolean.FALSE) return;
if (event.getPlayer().getGameMode() == GameMode.CREATIVE) return;
if (event.getBlock().getBlockData().requiresCorrectToolForDrops() && !event.getBlock().isValidTool(event.getPlayer().getInventory().getItemInMainHand())) return;
event.setDropItems(false);
new BlockDropItemEvent(
event.getBlock(), event.getBlock().getState(), event.getPlayer(), dropItems(event.getBlock())
).callEvent();
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockDestroy(@NotNull BlockDestroyEvent event) {
if (game.isOngoing() && event.willDrop()) {
event.setWillDrop(false);
dropItems(event.getBlock());
}
}```
not every 5 min
no reason for every 5 min
on disable save
on enable load
You should do periodic auto-saves to prevent data loss on server crash. A modern database should easily handle an auto-save every second.
We love data loss
shouldn't writes be written immediately?
ยฏ_(ใ)_/ยฏ
i haven't used databases
i should sometime
Yup
But some people still think that sending several write requests per second to the DB will make it crash or smth like that
I need help with OfflinePlayers inside the config...
I am currently coding a chestShop Plugin and I am struggling with the transaction of a player who wants to buy an item and the player who receives the money, if he's offline...
that's part of the code:
SOLVED --> I can't check if player is not Online if the player is null so I checked if the signPlayer is not null
} else if(!signPlayer.isOnline()) {
chest.getBlockInventory().removeItem(item);
p.getInventory().addItem(item);
player.removeBalance(p.getUniqueId(), costs);
player.addBalance(ofPlayer.getUniqueId(), costs);
p.sendMessage(Citizenship.prefix + "Du hast ยง8" + amount + " ยง8" + material + " ยง7fรผr ยงa" +
costs + Citizenship.suffix + " ยง7ausgegeben.");
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 5, 1);
}
My variables: (they are ofc on the top of the class)
Player p = e.getPlayer();
Player signPlayer = chestShopMethods.getPlayer(e.getClickedBlock());
Sign s = (Sign) e.getClickedBlock().getState();
String[] chain = s.getLine(3).split(" ");
amount = Integer.parseInt(s.getLine(2));
balance = player.getBalance(p.getUniqueId());
Material material = Material.matchMaterial(ChatColor.stripColor(s.getLine(1)));
item = new ItemStack(material);
Chest chest = (Chest) e.getClickedBlock().getRelative(0, -1, 0).getState();
OfflinePlayer ofPlayer = Bukkit.getOfflinePlayer(signPlayer.getUniqueId());
hmmmm depends on scale
also
if it cross server so iit will anyway require to load unload data per user
about crash data?
just restart every 2 hour
its efficent for u and for server
there no reason the go big on the db
just load everytime and unload only at end
on restart
also like dkim said
even on huge scale of datta
u get just get data all the time
if its data that present placeholders like player kills or some shit
then i guess use cache
anyway never save liike anticrash every 5 min
really no reason thing
just make sure u restart server every couple hours
yeah that sounds like a decent idea, if your wanting to use mysql then i believe you will want to use the JDBC api which is built into java. https://docs.oracle.com/javase/tutorial/jdbc/basics/index.html might be quite helpful
This JDBC Java tutorial describes how to use JDBC API to create, insert into, update, and query tables. You will also learn how to use simple and prepared statements, stored procedures and perform transactions
also the config api that spigot has isnt made for massive data storage, if your doing it short term then its not too bad but really you should use a form of database, even sqlite is better then storing your data in yaml files
tho if you really had to go the route of yaml for data storage then single files per player uuid and caching the data in memory using a player object and loading from file is the way to go
i think mysql now supports storing json files aswell so thats also an option if you dont want to go the full row and column way with sql, also i think that most nosql dbs also store everything in json files aswell or atleast i think thats the case with mongodb
That much downtime is not viable for most servers
apparently it's more efficient to restart your server each 2 hours instead of having a per-minute database call
surely 
when i still ran a server i just restarted every 24 hours
yup, that's what most servers do
restart once per day in the least-used time
(usually like 5AM)
What does the Key in the HashMap of the returned Items from the Method addItem() return? By that I mean why is the key an Integer?
addItem? Is this java we're talking about? Because I don't remember HashMaps having that method in java. Unless you're talking about put? which actually returns the previous value associated with that specific key or null if no value was previously associated with that key.
I actually just want to know what's exacty representing the Integer in the HashMap since the value is the ItemStack with the Material and amount it returns. Just for the understanding
I dont think the key has any meaning
Ah okay, thanks
Inventory#addItem returns Map<Integer, ItemStack>
Ah. That makes a lot more sense.
Oh sry, I thought you meant the question ironacially
The returned HashMap contains what it couldn't store, where the key is the index of the parameter, and the value is the ItemStack at that index of the varargs parameter. If all items are stored, it will return an empty HashMap.
ironically*
this is from the spigot api
No. I just misunderstood it.
Oh okay, thanks. Will the map remove it's values automatically once the HashMap contains a different ItemStack?
hm?
Usually the HashMap will keep it's values until they have been removed, no?
yes?
So do I have to remove them, when there's a new ItemStack that couldn't completely add the Items into an Inventory?
the map doesn't update, once it is returned the values are not changing
Ah ok, thank you. And one last question: We don't know the key, so how can we access to the returned Value? (Sry, I don't work a lot with hash maps)
yeah, there's Map#values which returns a Set<ValueType>
ah okay, thank you so much
How i can parse a placeholder another plugin in method sendMessage ?
what?
if you wanna support placeholders in your messages
hook with PlaceholderAPI and use provided methods like PlaceholderAPI.setPlaceholders(p,string)
what kind of placeholder?
placeholder of plugin "bairdrop"
restart take only couple mins...
if not less
but it could be annoying, especially if the player is in the middle of doing something
ex what if hypixel restarted every couple hours?
imagine the amount of games being cut off in the middle of it
and ppl who play skyblock
they would prob do stuff to make sure a game isn't currently running, but for a regular server to do that, they'd have to make custom plugins
which isn't ideal
also my server which loads 4000x4000 world into memory (preloads the whole world without unloading chunks dont ask why) , after wards it spawn 1600 stractures around map loads about more 10,000 things to map... takes just 2 min to load
on server cpu (Epyc 7502)
which is bad for minecraft
2 min can feel like a lot
and so players just go to another server in their server list
nah... my players wait patiently because after restart new mounuments spawn and resources
not everyone does it tho
oh that's because you have an incentive
he can also not cache data and use dattabase directly
not every server has an incentive to wait around
just write a good pool
pool?

