#development

1 messages ยท Page 52 of 1

dark garnet
#

ive never done that before tho FLOOSH

minor summit
#

definitely a skill issue

icy shadow
#

thats even more verbose lmao

minor summit
#

also never done hover and click actions?

dark garnet
minor summit
#

oh boy

#

components

#

!!!

#

jesus christ that is hideous

dense drift
#

Brb imma throw up

dark garnet
dense drift
#

Meanwhile <hover>Hey</hover>

minor summit
#

i'll see you the day mojang finally removes the rendering of ยง codes in the client pepelaugh

dense drift
minor summit
#

except for the fact they confirmed they are gonna do it but sure

dense drift
#

So you dont like mm but you like that abomination?

dark garnet
#

and i dont think i knew about adventure when i first made it idk

dense drift
#

Never heard of "work smart not hard"?

minor summit
#

adventure's been a thing since, like, 2017

dense drift
minor summit
#

json is the "alternative"

#

it's just how minecraft represents text

dense drift
dark garnet
#

is it possible to use the legacy color codes in minimessage?

minor summit
#

absolutely not

dark garnet
#

:(

minor summit
#

even if you could, they are incompatible formats

dense drift
#

^

minor summit
#

so no

dark garnet
#

no i mean

#

<l> for bold, <a> for green

dense drift
#

<b>

minor summit
#

<b> for bold

#

no

icy shadow
#

pretty sure you could do that with custom tags no?

dense drift
#

<green> for green

dark garnet
minor summit
#

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

dark garnet
#

would <green><b>bold green behave the same way as &a&lbold green?

minor summit
#

sure

#

you know what also works? <b><green>bold green ๐Ÿคฏ

dense drift
#

my favorite situation is &a&lA&c&lB&9&lC -> <b><green>A<red>B<blue>C

dark garnet
dark garnet
dense drift
#

Is been a while

#

1 is dark blue

#

See, very easy to remind

dark garnet
#

yeah i couldnt think of the normal blue so i just went with dark ๐Ÿ’€

#

i usually have them all memorized >:(

leaden sinew
#

You know what else you could do

dark garnet
minor summit
#

no

leaden sinew
#
public static final String A = "<green>"
dense drift
minor summit
#

wait both of them are getting hard to read ๐Ÿ’€ yeah

dark garnet
minor summit
#

no

dense drift
#

No is not

minor summit
#

not the same thing

dark garnet
#

ok well i meant the same thing!!

dense drift
#

Escape could be \<b>

dark garnet
dense drift
#

Idk, probably

minor summit
#

the literal text, yes

dark garnet
#

ok ok well what about the ChatColor enum

#

does adventure have an equivalent?

leaden sinew
#

Make your own enum

minor summit
#

NamedTextColor

dense drift
#

Except that they are constants, but you can do text("green text", GREEN)

minor summit
#

huh

dense drift
#

I mean, unlike ChatColor which is an enum, NamedTextColor contains the default colors as constants (public static fields)

minor summit
#

not much of a difference but, yeah that is true

dark garnet
minor summit
#

reason it's not an enum was because they needed to implement Comparable which enum makes final compareTo

dense drift
#

No

minor summit
#

the toString yields debug output

spiral prairie
#

components are pretty clunky i gotta say, its the ideomatic way of doing things though

dark garnet
#

so then what would i do? i am definitely not using a disgusting builder type thing

dense drift
#

i think text() accepts color and decoration, otherwise you can call the method color() and, uh, decoration() (?)

minor summit
#

minecraft has used components to represent text for almost a decade at this point

spiral prairie
dense drift
#

Nothing stops you from using MM if you want hardcoded components with a lot of style

icy shadow
#

yeah literally just use MM

#

easiest way by far

dark garnet
spiral prairie
#

minimessage. isnt. components.

leaden sinew
#

You should just switch to audio

#

Then you don't need colors at all

dark garnet
icy shadow
#

send messages through morse code & noteblocks

spiral prairie
#

yes

dark garnet
dense drift
#

Obfuscated messages

icy shadow
neon bear
#

what is mm

minor summit
#

what is dn

#

minimessage

icy shadow
#

its gone TOO far

worn jasper
#

well

#

you do

#

ah

#

I see what you did there

dusky harness
pulsar ferry
#

<green><b>A</b><red> for sane people

worn jasper
#

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>

spiral prairie
#

ChatGPT became op

worn jasper
spiral prairie
worn jasper
#

op

spiral prairie
#

very

worn jasper
#

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

versed carbon
#

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()

worn jasper
#

so me not have to learn those for the test tmr

#

lol

worn jasper
worn jasper
#

np ๐Ÿ™‚

minor summit
#

because saying "learn java" and not providing pointers is very helpful and not condescending

proud pebble
#

discord isnt stackoverflow kekw

tiny dew
#

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.

proud pebble
tiny dew
#

Wouldn't that be no different to event.getItems()?

proud pebble
#

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

tiny dew
#

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

proud pebble
#

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

tiny dew
#

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 ๐Ÿ˜–

minor summit
#

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

tiny dew
#

Welp so that's not even really an option

proud pebble
#

afaik all blocks in the game drop atleast one of each of its possible items

minor summit
#

yeah but that's not hardcoded anywhere anyway

tiny dew
#

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

proud pebble
tiny dew
proud pebble
#

it would be in net minecraft itself

tiny dew
#

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)

proud pebble
#

might have to go dig through the minecraft server code

#

im sure the Block.getDrops(itemstack) goes somewhere

tiny dew
#

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

proud pebble
#

updated how?

#

what would eula have to do with it

tiny dew
#

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

proud pebble
#

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

tiny dew
#

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

proud pebble
#

you dont need to use a public decomp when you can decomp it yourself

tiny dew
#

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

proud pebble
#

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

tiny dew
#

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

proud pebble
#

i assumed you were doing 1.7.10

tiny dew
#

Oh right I meant I was "on it" as in I was looking at the source code, not using it for my plugin

neon bear
#

so uhh..

tiny dew
#

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)

neon bear
#

also can you get rid of eating/e-eye/holding shield speed reduction using plugins and/or potion effects and/or area effect clouds

signal grove
#

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?

tiny dew
#

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

leaden sinew
signal grove
#

to check if players are in duels or not - it uses the duels api for that

leaden sinew
#

Why don't you check that in the duels plugin?

signal grove
#

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

leaden sinew
#

You can call an event like CombatLogEvent

#

Then cancel it in the duels plugin

signal grove
#

hmm, ill think about it, thanks for the suggestion

leaden sinew
#

No problem

signal grove
#

there is a lot of things that it does though, not just combat log checking

leaden sinew
#

You should make those into API methods then, the core plugin shouldn't rely on the duels plugin at all

signal grove
#

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

leaden sinew
#

If it's a core that you're depending on, it should have an API for anything used externally anyways

signal grove
#

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?

leaden sinew
#

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

signal grove
#

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

leaden sinew
#

No you don't

leaden sinew
signal grove
#

so core fires a custom "preteleport" event, duels listens for it and modifies the parameters, then core handles the "non-pre" teleport event?

leaden sinew
#

Yes

signal grove
#

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

leaden sinew
signal grove
#

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

forest jay
signal grove
#

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

sonic nebula
#

no there no libraries for goal/path

leaden sinew
#

Okay you're definitely trolling

neon bear
#

can i do this now

sonic nebula
sonic nebula
leaden sinew
#

You said there are no libraries for pathfinding

sonic nebula
#

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

leaden sinew
#

Paper has an API for it

sonic nebula
#

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.

leaden sinew
#

That's what every library does

stuck hearth
#

Tony when they realize a library adds utility ๐Ÿ˜ณ

dark garnet
sonic nebula
#

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

leaden sinew
#

๐Ÿคฆ

sonic nebula
#

so please

#

why u light me up again

graceful hedge
sonic nebula
#

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

sterile hinge
sonic nebula
#

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

sterile hinge
#

but there are libraries for stuff like that out there

sonic nebula
#

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

sterile hinge
#

seems like you don't understand what library means

sonic nebula
#

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

void crypt
#

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

dapper jackal
#

HI, question, its possible to set the tab completion for command of another plugin?

worthy basalt
#

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

sonic nebula
#

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

worthy basalt
#

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.

sonic nebula
#

no

#

not every tick

#

every 20 ticks

#

or more

#

also 0 lags

#

even if you have 10,000 items falling at same time

worthy basalt
#

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?

sonic nebula
#

the events u said

#

entity dies

worthy basalt
#

plus pushing items into an array would require extra memory.

sonic nebula
#

it kills the enitty

#

not much memory

#

very little

worthy basalt
#

it doesn't get fired

#

it doesn't get fired when the item dies by void

sonic nebula
#

did u do instanceOf?

#

try debug if itt fiires dont try in an instance

worthy basalt
#

I do .getType() == Item

sonic nebula
#

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

worthy basalt
#
EntityType   getEntityType()    Gets the EntityType of the Entity involved in this event.
worthy basalt
#

also I have a question.
How does protocollib handles packets?
I don't see listener for that.
Does it use @Mixin?

sonic nebula
#

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

icy shadow
worthy basalt
#

wdym server pipe line. How do I cancel a packet and send one to the client with this "server pipe line"

worthy basalt
#

network packets

sonic nebula
#

what packet exactly

#

what you want to do

worthy basalt
#

any packets.

sonic nebula
#

why you do xy problem men common im here to help u

icy shadow
worthy basalt
#

I want to be able to:

  1. cancel them.
  2. create them.
  3. modify them.
sonic nebula
#

Brister said correct thing

#

but you xy problem

#

wont help u with that ill just quickly see if my event works

#

wiith void problem

icy shadow
sonic nebula
#

Brister please

worthy basalt
#

I see

icy shadow
worthy basalt
sonic nebula
#

u r the example for non tf2 player

icy shadow
#

?

sonic nebula
#

for the worst there take tthe aspects from here i wont continue that

worthy basalt
#

how 2 detect when item entity gets voided by void

sonic nebula
icy shadow
#

what are u saying lmao

icy shadow
worthy basalt
sonic nebula
#

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.

dapper jackal
weary galleon
#

can someone help with installing pterodactyl panel

surreal pollen
#

hey

minor summit
#

hi

dark garnet
#

hi, im trying to include adventure in my library (ive succumb Sadge)
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?

worn jasper
#

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

worn jasper
# river solstice what
if (server is using paper) {
    not shade adventure and use papers
} else {
    shade adventure and use the plugins adventure
}
#

if I understood correctly

river solstice
leaden sinew
#

You should be able to exclude Adventure from paper I think

worn jasper
river solstice
#

skill issue-d

worn jasper
#

adventure is provided either way

#

whether you exclude it in your plugin or not

#

it's still there, in the server.

leaden sinew
#

Yeah but you're trying to shade Adventure aren't you?

river solstice
#

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

leaden sinew
#

Why not just always use the shaded if it's shaded anyways?

river solstice
#

idk

leaden sinew
#

That's just a bunch of unnecessary work

river solstice
#

man has his reasons

#

(maybe)

dense drift
leaden sinew
#

I mean you don't really need those

dense drift
#

Why not?

icy shadow
#

hes not wrong, the deprecated ones still work

#

theyre just annoying to use

dense drift
#

Yeah but for example, you could do things like ShowItem.of(ItemStack)
Edit: actually Component#setHoverEvent(ItemStack) directly

leaden sinew
#

All the paper adventure methods can just be done through adventure

dark garnet
leaden sinew
#

If you're supporting Spigot you're going to have to use the Spigot chat event anyways

dense drift
#

that is not true though, you can just have an if to decide what event to listen to

leaden sinew
#

Yeah but that's kind of pointless

dense drift
#

but again, relocating (or simply shading?) adventure will not let you use the components from paper

dark garnet
#

wait what if i use compileOnlyApi?

river solstice
#

Component#toPaperComponent? ๐Ÿฅด

dark garnet
dark garnet
#

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 Sadge

tiny dew
#

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?

icy shadow
#

set a UUID in metadata when the block is broken, then read in the drop event perhaps?

tiny dew
#

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

leaden sinew
#

You can also just manually check if other blocks will be broken by checking connected blocks

tiny dew
tiny dew
leaden sinew
#

What are you trying to do with the plugin?

tiny dew
#

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

leaden sinew
#

Canโ€™t you just check if the drops are empty?

tiny dew
#

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

leaden sinew
#

Can you send the code you are using?

#

To check the drops

tiny dew
#
@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 ๐Ÿ˜ญ

leaden sinew
#

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?

tiny dew
#

It's very counter-intuitive but sadly ye it does ๐Ÿ˜…

tiny dew
tiny dew
#

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

leaden sinew
#

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

tiny dew
#

Oh, I thought event.getItems() still had items even in creative but I suppose not

leaden sinew
#

How were you testing?

tiny dew
#

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

sonic nebula
#

because create doesnt actually break blocks

#

but delettets them

leaden sinew
stuck hearth
#

Creative doesn't break blocks, it deletes them

leaden sinew
#

So I guess it's just Tony adding nothing to the conversation again

hoary scarab
#

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()

spiral mural
#

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

dusky harness
spiral mural
#

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

dusky harness
spiral mural
#

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

dusky harness
#

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

spiral mural
#

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

dusky harness
spiral mural
#

Yes, I will in a moment!

dusky harness
#

๐Ÿ‘

leaden sinew
spiral mural
#

it works now, incorrect import

#

was the issue

hoary scarab
#

Anyone know a logj4 config that displays that data of packets not just what packet and incoming/outgoing?

sterile hinge
#

how is that related to log4j

hoary scarab
#

Cause its a log4j config...

sterile hinge
#

feels like context is missing

hoary scarab
#

the xml config for the logger

sterile hinge
#

yeah... but which packets are you talking about and how are they passed to log4j?

hoary scarab
sterile hinge
#

minecraft packets?

hoary scarab
#

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>
sterile hinge
#

you can't change in the config what MC passes to the logger

#

you'd need to change the MC code

hoary scarab
#

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

sonic nebula
#

idiot

#

very annoying

sterile hinge
sterile hinge
#

and only those arguments can be seen by the logger

dapper jackal
#

Hi,

i don' undesertand how workd this calcul
long minutes = (seconds / 60) % 60;
who can explain to me? (what is %60)

sterile hinge
river solstice
#

manz first time seing modulo

warm steppe
#

bruh these guys forgot to type Math.

icy shadow
#

๐Ÿค“

river solstice
#

quick meth

icy shadow
#

um

#

that only works when you're dividing by 10 lol

#

1 / 5 = 0.2
1 % 5 = 1, not 2

river solstice
#

ah true

#

meth aint mething today

trail burrow
#

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>

dapper jackal
#

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

river solstice
#

By magic

#

Of code

dapper jackal
#

yes^^

#

but how

river solstice
#

by

#

converting time when started subtracted now

#

to specific time units

nova minnow
#

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?

worthy basalt
#

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) ~[?:?]
torpid raft
#

huh

#

can you show your code

nova minnow
#

Do you mean 99tracheae or me?

torpid raft
#

i meant tracheae sorry lol

tight junco
#

feel free to send your code too mars

nova minnow
#

I mean it's pretty compact. Didn't know how to simplify it BorpaStare

tight junco
#

just send the relevant parts Shruge

torpid raft
nova minnow
#
    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) { ```
tight junco
#

Use Material#matchMaterial

#

or whatever iti s

nova minnow
#

I will try it. Other people meant it's better to use valueOf. I will give it a try. Thank you

tight junco
#

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

nova minnow
#

Ahh okay, thank you. That's indeed more useful

tight junco
#

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

nova minnow
#

I hate Java sitt

#

But thank you

tight junco
#

dont we all

nova minnow
#

yep

tight junco
#

the small areas where kotlin is preferable

#

just functions for everything

nova minnow
#

idk, haven't programmed with it yet xd

icy shadow
#

Guava has Ints.tryParse

#

which does this

nova minnow
#

What's guava?

icy shadow
#

A general purpose java library bundled with spigot

#

So you donโ€™t need to add anything to use it

torpid raft
#

she java my spigot till i guava

icy shadow
#

โ˜น๏ธ

sharp cove
#

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

icy shadow
#

shouldnโ€™t the whole concatenated string be in {} here

#

otherwise youโ€™re just writing the +โ€™s as html

#

src={blah}

sharp cove
#

Ah oke so like this isn't possible

#

I know I did something like this in Java

#

But yeah thats different ofc

#

Thanks

torpid raft
#

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"}/>
icy shadow
#

I didnโ€™t say itโ€™s not possible lol

#

dunno what gave that impression

#

^^

sharp cove
#

Yess

#

I know

icy shadow
sharp cove
#

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

icy shadow
#

ah

icy shadow
#

well, yeah its just incorrect

sharp cove
#

Thanks for the help : )

icy shadow
#

np

worthy basalt
# torpid raft can you show your code
@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();
        }
    }
dusty frost
icy shadow
worn jasper
#

uh does configurate update the file every time something is changed?

dark garnet
#

how do i broadcast an adventure component?

dark garnet
icy shadow
#

otherwise BukkitAudiences#all should do it

dark garnet
#

oh

#

u said otherwise

#

im so tired ๐Ÿ™ƒ

icy shadow
#

me when i read

dark garnet
#

is BukkitAudiences#all in adventure-platform-bukkit?

icy shadow
#

yes

#

which i assume you're using already

dark garnet
#

uhhhh yeah totally

icy shadow
#

how are you even sending any messages without BukkitAudiences or paper api lol

dark garnet
#

i wasnt, this is me testing to see if adventure works rolf

icy shadow
#

hmmm

dark garnet
#

how do i get an instance of BukkitAudiences?

#

o nvm

dark garnet
#

it work i am so smart

nova minnow
worn jasper
worn jasper
#

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?

dense drift
#

configurate?

worn jasper
#

forgot to specify that

dense drift
#

basically a new loader every time

torpid raft
#

guys

#

it's got inheritance

icy shadow
#

0/10 because of inheritance

high needle
#

Does anyone know a good colorapi?

#

Or is it better to code colors / hex / gradients?

dense drift
#

adventure and minimessage

torpid raft
high needle
worn jasper
dense drift
#

5$

minor summit
#

MIT license prayga

worn jasper
#

ehehe

#

outplayed

#

holy just noticed, y'all using var

#

lol

#

fast to code, but bad for readability

dense drift
#

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

dusty frost
#

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

worn jasper
#

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.

dense drift
stuck hearth
#

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.

hoary scarab
#

Does spigot clear memory when shutdown?
I've been starting and stopping a server for awhile now and ran out of memory lol

worn jasper
#

just like restarting a normal app in your pc does

hoary scarab
#

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

worn jasper
#

how do you stop it?

hoary scarab
#

Just the command. /stop

worn jasper
worn jasper
dusky harness
dusky harness
dense drift
#

I didnt write the code

#

ah it just sets them to null, idk why, but the next methods assign values

worn jasper
#

ah it's probably cause the methods to assign values only create new values from the factory if the vars are null

dense drift
#

yeah

river solstice
dusty frost
#

y'all are abusing your operating system's allocators lol

spiral prairie
dense drift
#

it is not related to configurate

worn jasper
#

confusion

normal garden
#

How can I contact support via a private chat or voice

#

ุŸ

dense drift
#
  1. wrong channel
  2. what support?
pulsar ferry
#

That's the neat part, you don't

dense drift
#

we - helpchat- don't offer 1:1 support, and we are not Discord

neat pierBOT
#
FAQ Answer:

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.

normal garden
#

Oh
sorry for the inconvenience

hoary scarab
hoary scarab
#

Odd that it's never happened before though.

dark garnet
#

how can i do string manipulation to an adventure Component? like String#subString(int), or at least the equivalent ping if reply

trail burrow
#

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);
}```
fading kettle
#

That code seems correct, try modifying the lang.yml file and calling the method to see if the value has changed?

lyric gyro
#

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?

dusky harness
#

I wouldn't ask adventure questions here

grave yacht
#

hello im looking for help from a software developer help is there any like that here

dark garnet
tired olive
dusky harness
#

you can do some

tired olive
#

Not all components contain a fixed size string

dusky harness
#

but for ex TranslatableComponent can't

tired olive
dusky harness
#

ye

#

but i think theres like a replace function

#

but im not sure

tired olive
#

There is

dusky harness
#

:))

dapper jackal
#

Hi

        String result = PlaceholderAPI.setPlaceholders(p, "%essentials_is_teleport_enabled%");
        if (result.equalsIgnoreCase("yes")) {
            return true;
        } else {
            return false;
        }

why i never got true?

stuck hearth
#

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"

dapper jackal
#

upstream I parsed the plceholder and it returns yes

prisma briar
#

@hoary scarab, does Block#getLocation will load the chunk?

dusky harness
#

no

hoary scarab
leaden sinew
#

You can always just do Block#getX, y, and z

prisma briar
#

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);
    }
dusky harness
#

this.block
I'm worried about this though

leaden sinew
#

I'm worried about that

hoary scarab
dusky harness
#

you should be storing the Location, not the Block itself

leaden sinew
#

If you really want to be safe, you should make your own immutable Location / Position class

#

Dkim

#

Why the reaction ๐Ÿ™

prisma briar
#

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.

hoary scarab
dusky harness
prisma briar
#

Ah alright, so storing Location in the field is the better choice?

dusky harness
prisma briar
#

Okay, I will change it and hopefully it doesn't break anything

dusky harness
#

hm

hoary scarab
hoary scarab
dapper jackal
#

i have try to past it on deluxemenu and i got yes/no

hoary scarab
#

Wait... isn't it "parsePlaceholders"? not set

dusky harness
deep panther
#

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')

dapper jackal
dusky harness
#

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;
}
}

dapper jackal
#

okay i try

dusky harness
#

my best guess right now is that you don't have the Essentials expansion

dapper jackal
#

if because by pasting the placehodler in deluxe menu it returns yes

dusky harness
#

it's set

dapper jackal
dusky harness
#

wait

#

did you remove the player name?

deep panther
dapper jackal
dusky harness
dusky harness
#

hmmm odd

dapper jackal
#

but there ar no placeholder returned, why?

deep panther
dusky harness
dapper jackal
#

ah

deep panther
#

was it foreach something?

dusky harness
dusky harness
dapper jackal
#

ah i have an idea, in my plugin dependaces, i don't have add placeholder in plugin.yml, is that?

dusky harness
dapper jackal
#

maven

dusky harness
#

but yeah you should add it to plugin.yml too

dapper jackal
#

okay i add it so

deep panther
#
        List<Player> clist = e.getChallenger().getOnlineAsPlayers();

        for(Player variable : clist)
        {
            // Body of the loop.
            // Each element can be accessed using variable.
        }
``` like this?
deep panther
#

what do I write in the body?

dusky harness
deep panther
#

ah right

#

sorry lmao im too old

dusky harness
#

@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?

dapper jackal
dusky harness
deep panther
#
    @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?
dusky harness
#

yep ๐Ÿ‘

dapper jackal
dusky harness
dapper jackal
dusky harness
#

can you show me?

dapper jackal
#

it can't have anything to do with my problem, can it?

dusky harness
dapper jackal
#

okay

dapper jackal
dusky harness
dapper jackal
dusky harness
#

somewhere this.player is likely null

#

that's why it's returning false

dapper jackal
#

private Player player;

dusky harness
#

I'll need more code if you want me to find out where it's coming from

dapper jackal
#

it's that there are really a lot of them, I'm already going to try to find myself and I'll tell you

dusky harness
#

alr

dapper jackal
# dusky harness 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

dusky harness
#

don't make a new Player

#

wait what

#

how is that even compiling?

dapper jackal
dusky harness
dapper jackal
# dusky harness 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;
        }

    }```
dusky harness
#

now where do you create the GetMenuItems instance?

dapper jackal
#

yes, when i make a command, i make getMenuOPtions instance

dusky harness
#

can you show it

dapper jackal
#

GetMenuOptions getMenuOptions = new GetMenuOptions(p);

dusky harness
#

can you show me more

dapper jackal
#

p= Player and here the function GetMenuOptions my player is not nul but when i set it in my this.player is null

dusky harness
#

where do you create the p variable?

dapper jackal
#

Player p = (Player) sender;

#

but is not null

#

because Inventory gui = Bukkit.createInventory(p, 27, ChatColor.DARK_GREEN + "Options"); work

dusky harness
#

so far it seems fine

#

so I'll need the entire files

dapper jackal
#

yes

dusky harness
#

try removing the if statement at line 26

#

p shouldn't ever be null anyways

#

so it's better to catch the error first

dapper jackal
#

okay

unborn perch
#
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?

dapper jackal
dusky harness
unborn perch
#
test.class.getClassLoader().getResourceAsStream("fonts/Comfortaa.ttf")

same: java.io.IOException: Problem reading font data.

dusky harness
unborn perch
#

when i open the file with winrar i see the class but no ttf files, what is the reason?

dapper jackal
#

ah @dusky harness i think,

when i see the this.player = CraftPlayer{name=delor}
is not Playerobject

dusky harness
dapper jackal
#

ah

dusky harness
#

(it uses CraftPlayer "behind-the-scenes")

dapper jackal
#

but it should not be player?

dusky harness
#

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

dapper jackal
#

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

dusky harness
#

hmmm

dapper jackal
#

ah no, no null

#

okay, the player become null when i call this

public static boolean essentialstp(Player p)

dapper jackal
dusky harness
#

that's not possible
what IDE are you using?

#

maybe you could try out debug mode

dapper jackal
dapper jackal
dapper jackal
#

yes?

dusky harness
#

are you running your test server in IntelliJ

dapper jackal
#

no

dusky harness
#

oh

dapper jackal
#

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

dusky harness
dapper jackal
dusky harness
#

debugging is painful

dapper jackal
#

how to waste an hour

hoary scarab
dusky harness
#

๐Ÿฅด
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

hoary scarab
#

At least you fixed it tho
Nope xD Gave up and went to bed

dusky harness
#

oh ๐Ÿ’€ ๐Ÿ’€ ๐Ÿ’€ ๐Ÿ’€

hoary scarab
#

Actually I didn't give up. I had to restart cause of the out of memory issue lol

unborn perch
#
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

prisma briar
#

@dusky harness @hoary scarab thank you for the help, the solution is pretty amazing.

hoary scarab
#

๐Ÿ‘

prisma briar
#

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()));
    }
dusty frost
#

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

prisma briar
#

Using ArrayList

dusty frost
#

ah yeah

#

so you should move to a map of some kind

prisma briar
#

Are there any alternatives other than Map, maybe the better than Map?

dusty frost
#

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

prisma briar
#

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?

dusty frost
#

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

prisma briar
#

Maybe parse Location into String?

dusty frost
#

yeah that was my first idea, can't hurt to try it out

prisma briar
#

I wish I put UUID on every active generator, but that's too late.

dusty frost
#

lol

prisma briar
#

Alright thanks, I'll try it out!

dusty frost
#

yeah no worries, x/y/z/world location will probably be a fine key

sonic nebula
#

fix it ur self.

torpid raft
#

tony woke up today and chose violence

warm steppe
#

some troll probably

worn jasper
#

legit never seen tony not being rude/toxic

river solstice
river solstice
forest jay
#

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.

mortal scaffold
#

How i can parse a placeholder another plugin in method sendMessage ?

torpid raft
#

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)

dusty frost
#

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

torpid raft
#

polling feels icky though

dusty frost
#

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

dapper jackal
#

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 ?

nova minnow
#

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

dapper jackal
#

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

nova minnow
#

Yeah, I would really recommend using the config

dapper jackal
#

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

nova minnow
#

I would do it one by one

dapper jackal
#

and make a request each time a player joins the server is not too much?

nova minnow
#

Do a PlayerJoinEvent and check if the Config contains a certain boolean value of the Player.

nova minnow
dapper jackal
#

yes but I would prefer to work with databases

nova minnow
dapper jackal
#

because I have a very large number of data to store

nova minnow
#

You would have to use APIs then if you want to use external Databases

dapper jackal
#

yes yes, I already know how to do it, I wonder about the best way to interact with it in an optimized way

soft comet
#

Hello! How can we set the player's head as the value for "material:"?

nova minnow
#

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)

dapper jackal
#

no because if I have 1500 players who have already played on the server, it will be big to store

nova minnow
#

oh ok, my bad. Did not know there are so many.. I am sry, then I can't help you

dapper jackal
#

no problem

nova minnow
nova minnow
# dapper jackal no problem

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

dapper jackal
#

yeah that's what i was thinking

soft comet
#

items:
'1':
material: head;%player_name%

#

but it does not work

nova minnow
#

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

soft comet
#

me to is not my first language O_o

#

i am french

nova minnow
#

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

tiny dew
#

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());
}
}```

sonic nebula
#

no reason for every 5 min

#

on disable save

#

on enable load

hazy nimbus
sterile hinge
#

We love data loss

dusky harness
#

shouldn't writes be written immediately?

#

ยฏ_(ใƒ„)_/ยฏ

#

i haven't used databases

#

i should sometime

hazy nimbus
#

But some people still think that sending several write requests per second to the DB will make it crash or smth like that

nova minnow
#

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());



sonic nebula
#

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

sonic nebula
#

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

proud pebble
# dapper jackal Hello, I need advice in my plugin i need database system, At first I was just ...

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

#

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

leaden sinew
hazy nimbus
#

apparently it's more efficient to restart your server each 2 hours instead of having a per-minute database call

#

surely Aware

proud pebble
#

when i still ran a server i just restarted every 24 hours

hazy nimbus
#

yup, that's what most servers do

#

restart once per day in the least-used time

#

(usually like 5AM)

nova minnow
#

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?

broken elbow
nova minnow
#

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

dense drift
#

I dont think the key has any meaning

nova minnow
#

Ah okay, thanks

dense drift
broken elbow
nova minnow
#

Oh sry, I thought you meant the question ironacially

broken elbow
#

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.

nova minnow
#

ironically*

broken elbow
#

this is from the spigot api

broken elbow
nova minnow
#

Oh okay, thanks. Will the map remove it's values automatically once the HashMap contains a different ItemStack?

dense drift
#

hm?

nova minnow
#

Usually the HashMap will keep it's values until they have been removed, no?

dense drift
#

yes?

nova minnow
#

So do I have to remove them, when there's a new ItemStack that couldn't completely add the Items into an Inventory?

dense drift
#

the map doesn't update, once it is returned the values are not changing

nova minnow
#

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)

dense drift
#

yeah, there's Map#values which returns a Set<ValueType>

nova minnow
#

ah okay, thank you so muchluvv

mortal scaffold
#

How i can parse a placeholder another plugin in method sendMessage ?

shell moon
#

what?

#

if you wanna support placeholders in your messages

#

hook with PlaceholderAPI and use provided methods like PlaceholderAPI.setPlaceholders(p,string)

mortal scaffold
#

what is the string?

#

placeholder?

dusky harness
mortal scaffold
#

placeholder of plugin "bairdrop"

sonic nebula
#

if not less

dusky harness
#

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

sonic nebula
#

they restart every 12h or so

#

100%

dusky harness
#

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

sonic nebula
#

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

dusky harness
#

2 min can feel like a lot

#

and so players just go to another server in their server list

sonic nebula
#

nah... my players wait patiently because after restart new mounuments spawn and resources

dusky harness
#

not everyone does it tho

sonic nebula
#

so they can loot quickly

#

it really depends on his server

dusky harness
#

oh that's because you have an incentive

sonic nebula
#

he can also not cache data and use dattabase directly

dusky harness
#

not every server has an incentive to wait around

sonic nebula
#

just write a good pool

dusky harness
#

pool?

sonic nebula
#

nvm iits off topic

#

anyway i guess saving e veery 5 min the whole map is a bad idea