#help-development

1 messages · Page 1307 of 1

wraith delta
#

i dont want the mess in tab complete tho

#

i want the command they use in game to be the same as the plugin name tho

#

figured it out, you can remove it in PlayerCommandSendEvent

lethal knoll
#

Hi, is there a built in way already to support hex color coding?

#

This seems to be the new standard, but it's been a while

lilac dagger
#

Yes

#

&x&a&a&b&b&c&c

lethal knoll
#

Yes, but I mean in regards to how I implement this support for my plugins

#

I see some Regex stuff but it can't be that complicated anymore right?

slate surge
#

is there a way to write llbit's nbt api into buffers? (which bungeecord natively provides like others inside DefinedPacket)

ivory sleet
lethal knoll
ivory sleet
#

yea so ChatColor is from bungee chat thingy thing, as freestyler said, users may use aforementioned format. But if you wanna provide a custom format then thats on you. I should say there are a good set of libraries that do this for you more or less, for example you could utilize minimessage.

lethal knoll
#

Alright, I'll have a look. Thanks for looking into it!

ivory sleet
#

best of luck :)

lethal knoll
#

Thanks 🙂

woeful sleet
#

Guys how to fix this

lethal knoll
#

On the top right, there should be a small import icon ↪️

#

update indexes*

woeful sleet
#

where?

lethal knoll
#

try restarting inteliJ maybe

#

Also, you are sure hte version you are using actually exists?

woeful sleet
#

I did several times

lethal knoll
#
<!-- https://mvnrepository.com/artifact/com.ticxo.modelengine/api -->
<dependency>
    <groupId>com.ticxo.modelengine</groupId>
    <artifactId>api</artifactId>
    <version>R3.2.0</version>
</dependency>
pine forge
#

How do i get the minecraft version in format 1.MAJOR.MINOR?

#

and why is there no simple function for that yet

mortal vortex
#

does getBukkitVersion not exist in ur fantasy land?

pine forge
#

literally returns the bukkit version and not the minecraft version

mortal vortex
#

i cant wember

sly topaz
#

Bukkit#getVersion returns the version but with the following format: (MC: <version>)

#

so you'd have to parse the version out of that

mortal vortex
#

(do note, Javier has a Ko-Fi link in his bio, support is not free, please donate)

sly topaz
#

I've only ever gotten a few donations out of that but thanks for the shoutout lol

pine forge
#

getServer().getBukkitVersion().split("-")[0]
been using this but not sure that works for everywhere

mortal vortex
#

yeah it should

#

and if it doesnt...

#

then

#

idk

pine forge
sly topaz
#

you can parse it with regex, or with apache commons' StringUtils: StringUtils.substringBetween(Bukkit.getVersion(), "(MC: ", ")");

pine forge
#

alright

chrome beacon
#

getBukkitVersion has exsited since 2011

#

so you're fine using that

pine forge
#

okay thanks

agile lodge
#

Spigot has a custom classloader or something like that right? I'm trying to load Javalin and it's saying class not found but I've checked the dependencies and I'm pretty sure it's there

mortal vortex
#

r u using softdepend or anything of the sorts

agile lodge
#

not sure

#

I have the dependency build.gradle.kts as an implementation dependency. I have the dependency jar downloaded and it's being included in the build as far as I'm aware

#

Pretty sure I ran into this issue before and I had to switch classloaders or something but I don't quite remember

thorn isle
#

how are you trying to load it

agile lodge
#

just importing the class and running functions from the class

thorn isle
#

confirm that the classes are actually in the jar

#

like unzip the jar with winrar or whatever and physically look inside

agile lodge
#

hmm weird

#

they aren't

young knoll
#

How are you building

#

Maven/gradle?

agile lodge
#

gradle

#

in intellj idea

young knoll
#

Make sure you are actually running the grade build and not IntelliJ’s default build

#

And that you have something like shadowJar to bundle the dependency

agile lodge
#

im running gradlew build

#

whats shadow jar and do I add that somewhere in build.gradle.kts

young knoll
#

Yes

agile lodge
#

So how does shadowjar affect like the plugin entry point

#

I'm a bit confused (I'm new to java)

thorn isle
#

shadowjar just includes the dependencies you want to include in your jar

#

so the classes will be available at runtime

#

some dependencies are provided by the runtime, like the spigot api; other dependencies you need to bundle into your plugin itself, creating a "fat jar" of application + dependencies

agile lodge
#

So I added it to the plugin block of build.gradle

#

but I seem to still be missing steps

wet breach
thorn isle
#

run minimize to trim that extra fat

wet breach
#

lol

mortal vortex
#

has anyone actually asked the JAR what he feels? If he is comfortable in his skin, I don’t see a problem.

thorn isle
#

have you ever seen a jar over 100mb live past 30?

agile lodge
#

my jar is trying to bulk up and it still needs help

thorn isle
#

i don't quite remember how to set it up with gradle, something something tasks { } somewhere

#

best look up a guide or wait for one of the kotlin/gradle/di enthusiast pinknames to answer

agile lodge
#

got it. well I have a direction for this at least

thorn isle
#

another option, if your dependency is on maven central, is the spigot library loader

#

in your plugin.yml you can define a list of dependencies for the server to download at runtime and provide to your classloader

#

this keeps your jars lightweight, but iirc only maven central is currently supported for getting the dependencies from

#

i also vaguely remember it having some kind of issues with kotlin, but "issues with kotlin" has a simple fix of not using kotlin

rare ether
#

Hi. I need to use StructureGrowEvent to prevent tree growth in certain situations and to do that I need to find the location of the original block (sapling) from which the tree grew, the event however provides only getLocation() and getBlocks() methods with the first method's description stating Gets the location of the structure. which is non-informative. Do you guys know whether getLocation() points to the block at which the sapling once was or if the first block returned by getBlocks() is the one?

thorn isle
#

try it and see

#

i'm fairly sure it points at the sapling, i remember doing something tree growth related before and having to test this out

#

specifically it's the sapling that triggered the growth, so for e.g. huge spruce trees it's the one sapling among the 4 that gets bonemealed or procs growth naturally

rare ether
#

Okay, tyms<3

brazen ether
#

Hey, do u know how to dont have commands like this cmd:cmd ?
i search on internet but idk how to have only /jobs command and not /jobs:jobs

#

this is my plugin.yml

fresh coral
#

HELP

#

PLEASE

#

DEVS

plush sluice
fresh coral
#

I BAUGHT VULCAN AND FORGOT TO LOGIN PAYPAL IDK WHERE TO DOWNLOAD

brazen ether
chrome beacon
brazen ether
chrome beacon
#

yes

brazen ether
#

i tought it was a plugin side config, thanks for helping

pseudo hazel
#

contact plugin dev or support

#

?support

undone axleBOT
orchid furnace
tawny osprey
#

Hello all, I have a java related question related to upcasting. What is the point of upcasting, I dont see how its useful when a subclass' objects already inherit that of the superclass.

orchid furnace
#

Does anyone know how I can check if any command, even like non plugin related commands has been executed?
PlayerCommandPreprocessEvent

thorn isle
#

i don't remember the last time i've upcast anything

pseudo hazel
#

probably some generic type stuff requires upcasting

smoky anchor
#

What in the unholy hell

chrome beacon
#

is there a reason why you're using gson directly instead of just using the yml api that spigot provides

thorn isle
#

and doesn't gson accept a typetoken directly, without having to call getType on it

#

to be fair gson is quite a bit nicer than the bukkit config api for serialization

chrome beacon
#

Never liked gson

#

Jackson >>

smoky anchor
#

DFU Codecs 😊

mortal hare
#

i've survived on linux for three weeks now without hopping

#

decided to stay with gnome though

#

i like its fast file search

#

plasma search seem to suck

#

modded a top bar a bit with dash to dock to mimmic workflow i've had with startallback on windows 11

mortal hare
#

honestly i dont know any plugin which uses .json apart from very old versions of factions plugin

#

with massivecore

lime mauve
young knoll
#

Works for both if you want

thorn isle
#

yaml is a superset of json, so valid json is valid yaml

#

though i do find parsing json with the bukkit config api a bit silly

lime mauve
#

Isn’t json faster

thorn isle
#

you shouldn't be doing disk io on the main thread anyway, and off the main thread the difference is negligible

lime mauve
#

Oh

#

And yml is easier to work with in the api right

young knoll
#

I still don’t understand how valid json is valid yml

#

yaml does not like the {}

thorn isle
#

{} and [] are used to define inline dicts and arrays

#

e.g.

map:
 list: ["of", "strings"]
#

is equivalent to

map:
  list:
  - "of"
  - "strings"
#

and is also equivalent to ```yaml
map: { list: ["of", "strings"] }

lime mauve
#

So should I use yml

thorn isle
#

and is also equivalent by quoting the dict keys to

"map":{"list":["of","strings"]}
#

which is now json

young knoll
#

Oh it does work

#

It must have been the other way around I tried

thorn isle
#

yes, valid yaml isn't necessarily valid json, json is very strict while in yaml there are 100 ways to do any given thing

young knoll
#

As long as it doesn’t involve tabs

sullen marlin
#

No comments in json 💀

young knoll
#

“_comment”: “kek”

pseudo hazel
#

☠️

mortal hare
pseudo hazel
#

^ software world if javascript didnt exist

fresh coral
#

@orchid furnace

orchid furnace
#

wdym yes

orchid furnace
mortal hare
#

you can shit on javascript as much as people on karl marx until they realize that before socialism, such things as minimum wage didnt exist

sullen marlin
#

wow we went from 0-socialism in record time

pseudo hazel
#

I mean I guess, they would probably invent something just as annoying if js wasnt there

mortal vortex
#

Just because something happens at the same time as something, doesnt mean its related.

#

Both ice cream sales, and drowning incidents, increase during the warmer seasons. Doesnt mean they are related.

mortal hare
#

well there were labour protests and activism prior to this that made this happen. Sure karl marx didnt got involved in this ofc lol, but those things are related to socialism, since socialism is a policy which take priority of the workers and people over conglomerates. The outcome of this kind of socialism were drastically different when comparing west to east, with west favouring socialdemocratism and east being more radical than west. saying this that karl marx didnt inspire this kind of activism would be an understatement. He didnt had involvement, but his ideas were carried on in 20th century, especially after great depression

#

i'll stop here, since i dont want to get banned by almighty md_5 for politics

mortal vortex
#

too late, submitted the report from 10 of my alt accounts

#

you're gone pal

mortal hare
#

😭

nova notch
#

dude what the fuck are you on about

left jay
#

hey question, how do i get this listener to not trigger again when cancelling this event?

@EventHandler
    public void onUseAbility(PlayerItemHeldEvent event) {
        int newSlot = event.getNewSlot();
        ItemStack abilityItem = event.getPlayer().getInventory().getItem(newSlot);
        ItemStack weapon = event.getPlayer().getInventory().getItem(event.getPreviousSlot());
        event.getPlayer().sendMessage("playeritemheldevent triggered");

        if (AbilityItemTemplate.isImmovable(abilityItem)) {
            event.setCancelled(true);

            Bukkit.getPluginManager().callEvent(new UseAbilityEvent(event.getPlayer(), weapon, abilityItem));

            if (AbilityItemTemplate.getCooldown(abilityItem) != -1) { // if the item has a cooldown timer
                event.getPlayer().getInventory().setItem(newSlot, cooldownItem);

                Bukkit.getScheduler().runTaskLater(instance, () -> {
                    event.getPlayer().getInventory().setItem(newSlot, abilityItem);
                }, 20L * AbilityItemTemplate.getCooldown(abilityItem)); // 20L = 1s
            }
        }
    }```
mortal vortex
#

or store the item, check if item was same as last

left jay
#

oh yeah decent idea

left jay
#

yeah a version of that worked, thanks

mortal vortex
lime mauve
#

Language.

wet breach
tacit haven
#

Dependency 'com.sk89q:worldedit:6.0.0-SNAPSHOT' not found Dependency 'com.sk89q:worldedit:6.0.0-SNAPSHOT' not found Dependency 'com.sk89q:worldedit:6.0.0-SNAPSHOT' not found

Anyone knows how to fix this I installed a plugin from github and im trying to compile it and no matter what i change in the dependency nothing seems to work.

<dependency> <groupId>com.sk89q</groupId> <artifactId>worldedit</artifactId> <version>6.0.0-SNAPSHOT</version> <scope>provided</scope> </dependency>

mortal vortex
#

or is it a local repo

#

if its local, youll need the jar locally

tacit haven
#

<!-- WORLDEDIT --> <dependency> <groupId>com.fastasyncworldedit</groupId> <artifactId>FastAsyncWorldEdit-Bukkit</artifactId> <version>2.6.1</version> <scope>system</scope> <systemPath>${basedir}/lib/FAWE.jar</systemPath> </dependency> <dependency> <groupId>com.sk89q</groupId> <artifactId>worldedit</artifactId> <version>6.0.0-SNAPSHOT</version> <scope>provided</scope> </dependency> this is the whole dependency

wet breach
mortal vortex
#

🤦‍♂️ get it and then add it.

tacit haven
tacit haven
mortal vortex
#

What’s the plugins name

tacit haven
#

I figured out how to do it thanks i was just stupid bruh 😭

mortal vortex
#

I think someone’s trying to skid a plugin 🤔🤔

mortal vortex
tacit haven
lean pumice
#

heyy, one question, Bukkit#getPlayer, get the player in a list, or load something sync?

mortal vortex
#

getOfflinePlayer is what loads from disk.

lean pumice
#

okok tnx

wet breach
mortal vortex
#

Pretty sure that’s obvious given the word Offline

thorn isle
#

the usercache is in memory and getting offline player by uuid/name checks that first

#

you hit the disk only if the player's not been online for around a month so their usercache entry is expired, or, if getting by name, network io

pure elbow
#

Hey i don't know where to ask, but i'm currently making a resource pack for my minecraft server in 1.21.4 there i have a custom model which loads but has no texture, the model is just black and i can't get the texture of the model working thats what's currently in the texture slot in the model json

{
    "format_version": "1.9.0",
    "credit": "...........",
    "textures": {
        "texture": "uv_map/taser_loaded"
    },
    "elements": [

and i have the taser_loaded.png file everywhere in my texturepack already because nothign works

#

it usally should search for assets/minecraft/textures/uv_map/taser_loaded.png but there is that file but still theres no texture

smoky anchor
#

Open logs and send the error

smoky anchor
#

Oh no ok, I remember now
Did you add the uv_map directory to the block atlas @pure elbow

pure elbow
#

what is block atlas?

smoky anchor
#

You need to have this file in your RP and add one entry with your directory

#

you don't copy all of it, just add one entry

#

Otherwise minecraft will not load any textures from your directory

pure elbow
smoky anchor
#

well if you moved the texture to a vanilla directory, then it would work, yes

pure elbow
#

yeah i just use the minecraft folder in my RP

smoky anchor
#

-# which btw I despise lul

sick oracle
#

Hey where can I request custom plugins i can pay

smoky anchor
undone axleBOT
thorn isle
#

give me all of your money

grand flint
pseudo hazel
#

lol

tender shard
#

just remove systemPath and replace <scope>system with <scope>provided and add the proper FAWE repo and then it'll just work

hardy garnet
#

Do you guys have a custom logging class for debugging?

lilac dagger
#

i do not

#

i use system out println

hardy garnet
#

I just thought it would be nice to be able to disable certain classes from printing for the purposes of turning on certain classes to print when debugging

thorn isle
#

i go into the class in question and do replaceall from //system.out.print to system.out.print

#

they double as comments about what the code is doing when commented out 🤡

hardy garnet
#

Lmao, yea nah

#

I might do it just for fun

slender elbow
#

log levels

thorn isle
#

that + per-class/feature/module loggers to adjust the levels on is probably the way to go

#

having one logger doesn't help in a big project because when you bump it up to the debug level you get a wall of text from 25 modules and your logfile becomes 50 megabytes instantly

echo basalt
#

😔

smoky anchor
#

Hi, does anybody here know of a place where I can steal code for Bezier Spline ?

echo basalt
#

I remember having code for that

smoky anchor
#

🙏

echo basalt
#

apparently it's on my "goofyahhlaunchpads" project

#

took a while to find

smoky anchor
#

That's certainly a name :D

echo basalt
smoky anchor
#

Thank you

echo basalt
#

pretty sure I stole this off somewhere

#

or used AI to write it

#

dunno it's been years

rare ether
#

Hi. Is there a way to listen to all block events? I tried doing that by listening to BlockEvent but it's abstract and doesnt have handlers list

vocal cloud
#

The question would be: why

hardy garnet
#

What exactly is MinecraftKey and is it related to NamespacedKey?

#

is it basically just namespacedkey but only for the minecraft namespace?

sullen marlin
#

It's just NMS naming

#

They're the name thing, one is just API

hardy garnet
#

I didn't want to do NMS, but it is seeming I need to for one specific thing

#

which is item cooldowns (like, on the visual item in your hotbar)

#

Honestly its kind of weird spigot api doesnt have a setItemGroupOnCooldown method or something

chrome beacon
#

Item group?

young knoll
#

Yeah there’s a cooldown component now

#

That allows you to specify a namespace key for a group, all items with that same key will share a cooldown

chrome beacon
#

Oh that's neat

hardy garnet
#

Ugh I spent a bunch of time looking for it and couldnt find it

#

alas

#

Honestly idk how i missed it

#

Yep that was a pointless sidequest lmao

pseudo hazel
#

but sadly it doesnt show the cooldown animation

hardy garnet
#

I replaced my nms code with the setCooldown function and it shows the animation just fine

pseudo hazel
#

hmm then maybe I messed something up inflatable

hardy garnet
#

Is your item in its own namespace group?

#

or is it just a cooldown on the stick item (for example)

pseudo hazel
#

its a cooldown group

#

but ill figure it out some other time

echo basalt
#

you gotta use nms for cooldown groups

#

@pseudo hazel

pseudo hazel
#

hmm okay

hardy garnet
#

The docs could just be wrong, I havent seen that with spigot yet though

young knoll
#

Smh

#

It was specifically modified to affect cooldown groups not too long ago

#

By someone with this same issue

echo basalt
#

It didn't when I wrote this 2 months ago

sly topaz
young knoll
#

Nah even the overload didn’t work with the component at first

slender elbow
sly topaz
young knoll
#

I see

#

I swear I told someone to try it and it didn’t work

lime mauve
echo basalt
#

why rely on names to begin with

lime mauve
#

Yea I know but it’s a little weird to just let players do that

#

I use UUIDs

left jay
#

question, how would i go about making a player invunerable without losing a mob's aggro?

wet breach
# lime mauve

Parse their name, set it to whatever you want it to be

left jay
#

neato, ill try that
thanks

lime mauve
#

To find the right name

echo basalt
wet breach
#

if they are on the server, you should have their name. If you are just wanting to fix casing in the names its not hard to do, but you do need to parse their name to figure out which letters need to be fixed

lime mauve
#

Oh

hearty hornet
left jay
sly topaz
#

because they shouldn't be able to dupe items like that

hearty hornet
sly topaz
#

or do you mean just generating ghost items, because that's a non-issue

hearty hornet
#

So its like that. Basically by clicking items into their inventory and perfectly disconecting their router it messes with the packet timings between client and server

#

allowing them to dupe

echo basalt
#

well

#

the server has total control besides creative mode

#

so one of your guis is waiting a tick or something

#

and that introduces issues and race conditions

#

I've seen it in other ways where they have a sell button that gives you drops

#

and you can click on it like 5 times and fire them all at once

#

and there's nothing stopping that

hearty hornet
#

Im telling you whats happening

#

All I know is packet delay client allows duping...other devs have suggested I put in cancel events that check to make sure client matches server

echo basalt
#

joeshrug I've been deep into menu internals for the past few months

hearty hornet
#

I can provide the plugin src its open source and you can take a look if thats posssible

echo basalt
#

Throw the link in here I'd rather procrastinate and check this out

hearty hornet
#

mkay. little more info also
This is networks a addon to a larger plugin called Slimefun4. In networks theres 3 items with this dupe glitch. Network Monitor, Grabber, and Pusher. When placed these blocks show you all the blocks around it. Then you select which block the machine interacts with. Because the data is saved in this button menu, if a player takes items out and desyncs packets (to my knowlage) they can obtain the items over and over again. Here is the open source srcs
Slimefun4 https://github.com/Slimefun/Slimefun4
Networks (the problem comes from here) https://github.com/Sc268245/Networks

echo basalt
#

I'd blame slimefun / not using synchronized tickers for this

#

dunno enough about slimefun and this is insanely abstracted

#

with a pretty derp menu system too wow

hearty hornet
#

any fix no matter how bootleg

wet breach
#

seems you are going to have a lot of fun

hearty hornet
#

jesus why 😭

wet breach
#

I think the easiest solution is to record inventories when interacting with inventories

#

and if they disconnect, just put it in a DB to apply that inventory to them when they reconnect

#

should solve the duping problem with those things until you find a more appropriate fix like changing the entire code possibly lol

sly topaz
#

time would be better spent just figuring out a way to easily reproduce the dupe

wet breach
#

pretty easy to develop such a fix I proposed which leaves them more time to figure out where its going wrong

sly topaz
#

I mean, the dupe is pretty specific, they could just not save the inventory if they send too many packets at once like those hacked clients are doing by delaying packets

#

but either way, I do not believe it is that hard to trace this issue even if it comes from slimefun, unless it is actually a vanilla issue which in that case then one would be deep in the sauce

wet breach
#

I am not familiar with the stuff they linked nor looked at it so couldn't really say how hard or difficult it would be

fresh coral
#

who can modify vulcan for me dm me

thorn isle
#

Har Har Har another slimefun/networks dupe

#

The solution is not to use networks

#

It's almost surely some form of threading issue since the networks motto is "everything is async"

rare ether
#

Guys is this a bug? ```java
@EventHandler(priority = EventPriority.HIGHEST)
public void onProjectileHit(ProjectileHitEvent event) {
Bukkit.broadcastMessage("1");
Plot affectedPlot = null;

    Block hitBlock = event.getHitBlock();
    Entity hitEntity = event.getHitEntity();
    if(hitBlock != null) affectedPlot = PlotManager.getInstance().getPlot(hitBlock);
    else if(hitEntity != null) affectedPlot = PlotManager.getInstance().getPlot(hitEntity);

    Bukkit.broadcastMessage("2");
    if(affectedPlot == null) return;
    Bukkit.broadcastMessage("3");

    Projectile projectile = event.getEntity();
    if (projectile.getShooter() instanceof Player player) {
        Bukkit.broadcastMessage("4");
        if(ProtectionUtil.canPlayerAffect(player, affectedPlot)) return;
    } else if (projectile.getShooter() instanceof Entity entity) {
        Bukkit.broadcastMessage("5");
        Plot entityPlot = PlotManager.getInstance().getPlot(entity);
        if(ProtectionUtil.canPlotAffectPlot(entityPlot, affectedPlot)) return;
    }
    Bukkit.broadcastMessage("6");
    event.setCancelled(true);
}```
#

I thought I can bypass it but it doesn't seem to work, the block still gets activated: java projectile.remove(); event.setCancelled(true);

chrome beacon
#

What exactly is the problem

rare ether
# chrome beacon What exactly is the problem

As shown on the photo, the whole logic is sound and when a player is not permitted event is set to be cancelled, however as you can see on the attached screenshot the arrow still actually activates the pressure plate

rare ether
eternal oxide
#

are you certain it is actually triggering. It might be a client predictive rendering]

rare ether
#

yes, i've checked with a piston and the block actually moves on two clients

thorn isle
#

listen to whatever event fires when the pressure plate is pushed and dump the stack trace and see which code path is reaching that

rare ether
#

good idea, i'll do that and get back to you

thorn isle
#

there are a bunch of different arrow related events, so it might be that you have to cancel a different one

#

could also be a bug; we'll see

thorn isle
#

seems reasonable

chrome beacon
#

Yeah that's it

rare ether
rare ether
#

I honestly don't see anything useful in that stack trace, but I'm probably just inexperienced

thorn isle
#

it's not useful by itself, but it lets you pinpoint what's going on in nms and then step back/forward from that and find which events happen before/after

#

using obfuscated/spigot mapped server makes it quite a bit more ass

#

but eyeballing from the fact that the event triggers under Entity rather than anything arrow related, i'd guesstimate that the entity interact event is right

#
    @Override
    protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) {
        if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent
        if (!level.isClientSide) {
            int signalForState = this.getSignalForState(state);
            if (signalForState == 0) {
                this.checkPressed(entity, level, pos, state, signalForState);
            }
        }
    }

i may have bad news

young knoll
#

I wonder if removing the entity in the hit event would work

#

Or if it would still trigger for a tick

thorn isle
#

iirc they tried that already and it seems to trigger for a tick

rare ether
thorn isle
#

odd, i don't see that being fired anywhere, but good that it works

rare ether
#

I wonder what's actually getting cancelled when ProjectileHitEvent is cancelled. Maybe it works on entites?

young knoll
#

Probably

rare ether
#

I'll make an issue on github, let some smart people give it a thought. edit : nvm haha

thorn isle
#

the conditions for hitting things and triggering the pressure plate are a bit different

thorn isle
#

for pressing the plate, it just needs to be inside its bounds

#

but since it has no collision shape, being inside its bounds doesn't trigger the hit event

rare ether
#

ohh

thorn isle
#

the hit event is triggered when the projectile would, with its current velocity, overlap with the block's collision shape

#

so i think in theory if you angle the arrow right you can trigger the plate without hitting anything

rare ether
#

alright that actually makes sense

#

ill keep the ProjectileHitEvent for the target block

#

Thank you very much for the help guys!

lime mauve
#

How do i stop players from changing the case in their name when logging in

worthy yarrow
#

Why are you using names to begin with? Just use uuids

lime mauve
#

I dont use names but is there any way to stop them from doing that

worthy yarrow
#

Sounds like an offline issue to me

lime mauve
#

They like rewrite the login packet and change some letters to be uppercase

#

No its on online servers

worthy yarrow
#

If you use uuids

lime mauve
#

I guess it doesnt but is there any way to stop it

#

I dont use names

worthy yarrow
#

I didn't know a player was able to do this in an online environment 🤷‍♀️

lime mauve
#

Yea for example you can change poopguy20 to be like POOPGUY20 without actually changing your account name

smoky anchor
#

That is news to me that you can do that

worthy yarrow
#

Hmm weird, anytime I've messed with login packets, I've never been able to pass encryption

#

I guess you could parse their name and just set it to whatever you want

smoky anchor
#

well, the client sends login start packet before any encryption is enabled I guess
so I guess the client can change the name in that packet without it breaking something horribly

worthy yarrow
smoky anchor
#

Aaah

worthy yarrow
#

Also, oddly enough it seems whenever you even just listen to playerPreLoginEvent or whatever it is, prevents all players from connecting

fresh timber
#

anyone know of any tutorials or ways to create book GUIs or just make books w/ pages and stuff to display information with some clickable text

rotund ravine
#

Components exist tho so it’s quite easy

slender elbow
#

I'd say it works quite well

#

poopguy 💀

grand flint
#

lmao

#

who tf is mik

quick jay
#

Is there any way to get the height of the entity without spawning it?

worldly ingot
#

No because the height of an entity depends on its world state

#

i.e. is it sneaking? Is it a marker armour stand? Is it a baby?

quick jay
worldly ingot
#

Mmmm, wonder if the entity snapshots let you do this

#

Eh we don't have any way to create a default entity snapshot though

#

Oh and it doesn't provide you an Entity instance. So no, there isn't. You would have to do this with NMS. You could create an NMS Entity and get it from there

slender elbow
#

you can create an Entity without adding it to the World

worldly ingot
#

2slow

slender elbow
#

I'm talking about API :)

worldly ingot
#

???

#

Which API?

slender elbow
#

the API which lets you create an entity without adding it to the world

worldly ingot
#

Oh there is a World#createEntity() huh

slender elbow
#

although the nms EntityType does expose its default AABB, no?

quick jay
#

im on 1.8

worldly ingot
#

Okay welp

#

lol

slender elbow
#

good luck

quick jay
#

gg

worldly ingot
#

Idk take a look at NMS' EntityType and see if you can spot anything there. Though last I recall, the answer is probably no

#

I'm going based on 10 year old knowledge though

quick jay
#

can i create an entity on nms to get the height on 1.8

potent crescent
quick jay
#

😼

torn shuttle
#

upgrading a pc in 2025 is so damned expensive

#

I just spent 3k euro

#

which if md5 is reading this that's about 3 trillion australian fake currency

#

actually I think it's enough for me to do a decent holiday in australia

echo basalt
torn shuttle
#

no joke I fully maxed it out on what it can do

#

feels like most of my time spent on my pc in the last month had the pc averaging like 80% use

echo basalt
#

I mean most of your money's going towards toying with AI

torn shuttle
#

eh not that much money

#

I'm trying to keep it to 50 euros a month

echo basalt
#

that's most family's disposable income

#

crazy shit

#

what else would you need a 5090 for

#

video editing?

torn shuttle
#

buddy that's what I hear and then I see people dropping more than that in getting drunk and buying collectibles wihtout that being counted towards disposible income

#

been doing a whole lot of video editing and will be doing a lot more of it

#

streaming, had to stop because my pc couldn't cope anymore

#

unity (game engine) since I gave up on godot

#

blender

#

local ai

#

some mass operations on data

#

oh yeah fusion 360 and slicers have also been getting to be a pain

left jay
#

question, can i retroactively edit the delay of a task that has already been fired?

young knoll
#

Don’t think so

sly topaz
#

or you could cancel the previous task and fire a new one

left jay
#

alright then >:T

young knoll
#

You could use a repeating task that counts down a number and does something at zero

#

Then you can edit said number to edit the delay

left jay
#

no i think theres an easier workaround to what im trying to do

#

i was just trying to make it look better

sly topaz
echo basalt
#

that doesn't account for time that has already passed

sly topaz
#

they didn't really specify whether they had to consider that kind of thing

#

but it could be done just by adding another reschedule method which does the math

left jay
#

I just did this with putting item types on a vanilla cool down, it does the same thing anyways

left jay
echo basalt
#

uh

#

why don't you just like

#

use timestamps and stuff

left jay
#

cuz idk what that is

worldly ingot
#

Save time that action successfully occurred, compare against current time, see if the difference exceeds your expected duration

#

now - lastSuccess < cooldown = still on cooldown

echo basalt
#

I did write a crazy little abstraction for abilities at work and it takes into account cooldown reduction and whatever so I can't give a clean example 😔

#

went a lil too cray cray

worldly ingot
#

There's also the vanilla cooldown system if you wanted to be really cool

echo basalt
#

it's useful for some things

#

less useful for others

#

this is how we do those

left jay
#

neato taquito, ill see if i can use this somehow

echo basalt
#

burrito dorito

young knoll
#

?cooldowns

undone axleBOT
young knoll
#

Hmm not what I wanted

#

Oh no wait that is it

#

thought it was a forum post not a wiki

torn shuttle
chrome beacon
#

@tender forge

burnt trench
#

Hi guys! I want to modify Spigot sources and build them then (1.21.5), how?

sullen marlin
#

Run build tools, edit source, build it

sly topaz
burnt trench
sly topaz
#

if you want to modify the spigot-api or spigot-server classes, then you can just clone it with buildtools and then build it with the --dev command flag

burnt trench
sly topaz
#

if you want to modify the actual minecraft classes however you'll have to rebuild patches and maybe add the class with dev-imports.txt

burnt trench
#

Ill just generate 1.21.5 first lol

#

Ill keep you updated guys :D

sly topaz
#

most of that process is explained in the Craftbukkit readme, so once you are done with that then take a look at the Craftbukkit readme

burnt trench
#

Okay

#

Is it legal to post my modified spigot on Spigot and/or Github?

sly topaz
#

as long as you don't acidentally post the minecraft code, it is fine

burnt trench
#

So I can post the jar only?

sly topaz
#

you can post the patches that you made to the minecraft code

burnt trench
burnt trench
#

Ok bet

sly topaz
burnt trench
#

why?

sly topaz
#

because that contains minecraft's code, and that's the illegal part

burnt trench
#

???

#

I dont understand this

sly topaz
#

that's why buildtools exists

burnt trench
#

How do I share my project with the world then?

sly topaz
#

you would have to clone buildtools and make it pull from your repositories or make a bootstrapper system like Paper did long ago

burnt trench
#

I think ill do the buildtools thing

#

Thanks :P

#

Ima tell my friend he cant upload the jar and all

sly topaz
burnt trench
#

Ok ill just make my changes, build it and then just ask smb in this discord for help posting it

#

How to build it btw?

sly topaz
#

java -jar buildtools.jar --rev 1.21.5 for starters, it'll clone all the repositories for you to modify

burnt trench
#

Yes but building

#

once I modified source

sly topaz
#

you can with java -jar buildtools.jar --dev once you've made your changes

#

or running the maven tasks manually, depending on what you're modifying

burnt trench
#

Spigot

#

No api stuff

#

Just some optimizations

burnt trench
#

I thought you can just do java -jar buildtools.exe --dev, right?

sly topaz
#

if you use the exe then you can use the GUI to enable the dev option probably

burnt trench
#

Im stupid

#

prob

sly topaz
#

I am just used to the jar since I've been using it before the GUI existed

burnt trench
#

But its just make changes and use the .exe?

burnt trench
sly topaz
burnt trench
#

Oh yes, I need to make one net.minecraft change I think

#

ok thanks for all the help

sullen marlin
#

What are you changing anyway

burnt trench
chrome beacon
#

They already only render when they need to?

burnt trench
#

Only when being looked at

chrome beacon
#

Also rendering is controlled by the client

burnt trench
#

we'll see

chrome beacon
#

There's little reason to hide an entity from the client when they're not directly looking at it

#

Only real reason I can think of is for anticheat purposes

#

And then you really could just use the api

burnt trench
#

Im just trying to save every little CPU % I can

chrome beacon
#

That won't reduce cpu

#

It'll increase it

burnt trench
#

Wait..

#

Your right

#

But it just doesnt do anything with CPU tho

chrome beacon
#

?

burnt trench
#

I only made it just not send to clients

#

Im stuppid

#

Btw it will reduce client-side lag I believe :P

chrome beacon
#

Negligable amounts and will introduce more issues such as entities showing up late due to ping

burnt trench
#
[ERROR] Failed to execute goal on project craftbukkit: Could not resolve dependencies for project org.bukkit:craftbukkit:jar:1.21.5-R0.1-SNAPSHOT: The following artifacts could not be resolved: org.bukkit:bukkit:jar:1.21.5-R0.1-SNAPSHOT (absent): Could not find artifact org.bukkit:bukkit:jar:1.21.5-R0.1-SNAPSHOT in minecraft-libraries (https://libraries.minecraft.net/) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
Exception in thread "main" java.lang.RuntimeException: Error running command, return status !=0: [C:\WINDOWS\system32\cmd.exe, /D, /C, C:\Users\gijs\OneDrive\Documenten\Ember\apache-maven-3.9.6/bin/mvn.cmd, -Dbt.name=dev, -P, development, clean, install]
        at org.spigotmc.builder.Builder.runProcess0(Builder.java:1042)
        at org.spigotmc.builder.Builder.runProcess(Builder.java:967)
        at org.spigotmc.builder.Builder.runMaven0(Builder.java:936)
        at org.spigotmc.builder.Builder.runMavenServer(Builder.java:905)
        at org.spigotmc.builder.Builder.startBuilder(Builder.java:672)
        at org.spigotmc.builder.Bootstrap.main(Bootstrap.java:60)```
chrome beacon
#

Depend on the spigot-api

burnt trench
#

How?

#

I changed like nothing

chrome beacon
#

Oh wait that's BuildTools

burnt trench
#

ye

sullen marlin
#

youre editing craftbukkit without building bukkit first

#

you probably want to edit spigot

rare ether
sly prairie
#

Hii I'm currently solo developping some server plugin, focusing on unique gameplay. Could use some help testing and creating new stuff! Dm me if you interested👀

wooden bay
#

Is it possible to control the color of the sky?

grand flint
#

idk if biomes can

#

but worlds can

undone axleBOT
wooden bay
burnt trench
burnt trench
hardy garnet
#

What is the namespace key format for structures?

#

NamespacedKey.minecraft("structure/igloo") returns null, for example

#

Well, it returns null when running:

#

Structure structure = Bukkit.getStructureManager().getStructure(structureKey);

#

Okay so i've figured out the correct formatting for the key (as an example) is "minecraft:igloo"

#
public static void generateTestStructure(Location location)
{
    NamespacedKey structureKey = NamespacedKey.minecraft("igloo");
    System.out.println(org.bukkit.generator.structure.Structure.IGLOO.getKeyOrNull());
    System.out.println(structureKey);
    Structure structure = Bukkit.getStructureManager().getStructure(structureKey);
    if (structure == null)
    {
        structure = Bukkit.getStructureManager().loadStructure(structureKey);
        if (structure == null)
        {
            System.out.println("Structure does not exist");
            return;
        }
    }
    else
    {
        System.out.println("Structure found");
    }
    generate(structure, location);
}

Okay, so here is the relevent code to the "issue" i'm having. I am trying to load a structure from code manually (for my plugin's datapack that I will be making later, but I wanted to make sure I had the structure code functional first so I am not doing 2 new things at once and making my life more difficult)

Anyway, structureKey and the igloo namespaced key are identical when printed, but when I attempt to get the structure in structuremanager or load it, both return null. Which is weird imo. So, thoughts? Why isnt this working?

#

Also, for sake of completion, I did a test where I did

structureKey = (org.bukkit.generator.structure.Structure.IGLOO.getKeyOrNull());

and it has the same problem

slender elbow
#

the structure manager does not operate with worldgen structures, but with structure files, like the ones with the jigsaw block, think of it like schematics

hardy garnet
#

Ah, I see. That makes sense. So I would need a datapack with custom structures in it to do this

#

are there any structures in vanilla that are structure files? I don't think so right?

worthy yarrow
#

Stash is leading me to believe you can easily get a reference to any structure, custom or not:

slender elbow
#

you can get a reference to a worldgen Structure, yes, but all you can do with them is call World#locateNearbyStructures or something like that

#

you can't "place" them

#

despite the fact that you can with the vanilla /place command lol

hardy garnet
#

hilarious

slender elbow
#

¯_(ツ)_/¯

thorn isle
#

aren't some or most worldgen structures quite similar to the structure files?

#

i haven't really looked into the internals but i was under the impression that mojang uses jigsaws and the same structure system to generate like woodland mansions and basic structures like igloos

worthy yarrow
#

Interesting note

thorn isle
#

well yeah there's no option but to do it that way, since to get a chunk to a certain level it can require adjacent chunks to be at some lower level

worthy yarrow
#

It's just odd how they specify versions and restarts as if there was a case you'd take this long to generate a single chunk

thorn isle
#

if we required all chunks to be at the complete step before shutting down, we'd end up generating an infinite number of chunks as each chunk would require its neighbors to get to a lower step, which would then have to be processed to the complete step

#

the point of the note is that you'll have to account for things like the server version being completely different when a step runs; you can't assume that the previous step was reached under the current environment

worthy yarrow
#

Why can't I assume that? When a vanilla world is generated, it's just using default params anyway

#

I guess I don't understand the case of it taking so long to generate you'd literally be generating chunks of the same world in different versions

hardy garnet
#

I'm pretty sure that was a change made for the deep slate update i forgor its name

thorn isle
#

it's not that it takes long

hardy garnet
#

the one that made world gen deeper and higher

thorn isle
#

it's that the steps aren't all run at once

#

suppose that bob walks into chunk A

#

this means chunk A needs to be fully generated

#

in order for chunk A to be fully generated, it needs some information from some adjacent chunk B, which forces chunk B to be partially generated until the step where that information is available

#

e.g. terrain but no blockpopulators or decorations like trees

#

unless bob walks into chunk B, chunk B is never fully generated

#

it gets saved to disk partially generated

#

5 years later alice logs into the world with minecraft 1.35.1 and goes to chunk B

worthy yarrow
#

Is a partially generated chunk what most people would call a corrupted chunk?

thorn isle
#

no

worthy yarrow
#

Hmm

thorn isle
#

like the note says, chunks are generated in steps

#

e.g. first heightmaps (terrain), then carvers (caves), then blockpopulators (ores, trees, flowers)

worthy yarrow
#

It's quite confusing... how and more so why would a player be able to walk in a partially generated chunk anyway? I would think a "valid" world's chunks are all fully generated before the world is actually handed off to the server

thorn isle
#

anything in the player's view distance and a little farther is fully generated before being sent to the player or drawn on the screen

#

if it isn't, then it is made to generate

worthy yarrow
#

So the steps process is just for efficiency purposes

thorn isle
#

partially, but also because a chunk can need information from adjacent chunks to generate itself

#

e.g. structures

#

look at the graph in the link i sent

worthy yarrow
#

I am

thorn isle
#

you can see that for a chunk to generate to the "complete" level, all of its adjacent chunks need to be at some specific step or higher

#

this is because it needs information from that step to figure out what to do

#

and that adjacent chunk then in turn can need information from some lower-yet step from its adjacent chunks

#

and so on until the step no longer needs any information from adjacent chunks

worthy yarrow
#

I'm relating this to shuffling a deck of cards, the generation follows a proper shuffle as it were, one card on top of the other lol

thorn isle
#

for example, the light step needs to know where light sources are in adjacent chunks to figure out what light levels each block should be

#

so before a chunk can complete the "light" stage, all its adjacent chunks must reach the "initialize light" stage

#

and so if we didn't have generation broken down into steps or stages, we would have an infinite loop or a paradox where, for a chunk to generate (calculate light) it first needs its neighbors to be generated (to find light sources); but the neighbors would require the chunk to be generated first, to do their light calculations; and you have a gridlock

worthy yarrow
#

I see

#

I've been trying to get more knowledgeable about world gen... still need to learn more about perlin, but recently I've been focusing on wfc

rare ether
#

hi guys, do you know which event is triggered when entities such as boats and item frames are destroyed by explosions? because I checked and it isn't EntityDamgeByEntityEvent in the case of TNT Minecarts exploding

hardy garnet
#

and do a check there

rare ether
#

Yeah I though about it but I though I'd ask because if there's an event already firing then I won't have to map two events together (it's not that it's hard, I just don't want to add unnecessary overhead)

hardy garnet
#

Well im pretty sure you'd just need to listen to EntityDeathEvent

#

Check if the entity dying is a boat or item frame, then check the damage source

rare ether
#

no because i have to check whether entity was permitted to explode it so i'd have to map it with EntityExplodeEvent unfortunetaly

hardy garnet
#

for an EntityDeathEvent

#

You can get the causing entity from a DamageSource object

rare ether
#

mn i thought DamageSource is just an enum but it has the causing entity

rare ether
#

im just tweaking im sorry lol

#

thank you for the help ❤️

hardy garnet
#

Np 🙂

rare ether
#

um

#

turn outs EntityDeathEvent isn't Cancellable

grand flint
#

bc its dead already wink

rare ether
#

can i just like set hp to non zero?

rare ether
#

do you know how to detect that along with direct causing entity and cancel it?

hardy garnet
rare ether
#

Doesn't work

#

Doesn't trigger for item frames

#

There's of course HangingBreakEvent but it doesn't work for boats

#

maybe ill have to use this along with VehicleDestroyEvent

#

well yeah so it also doesnt work

#

that's weird honestly

#

I'll try the HangingBreakByEntityEvent at least

#

the HangingBreakByEntityEvent also doesn't trigger

#

and the listener is definitely registered

#

just to be sure ill completely delete the plugin to make sure i ah ve the correct version, however modification date says its already the correct one

#

it's really werid cause HangingBreakByEntity doesn't trigger but HangingBreakEvent does

#

even though i'd say it's an entity cause break because it's tntminecart

#

but alr

#

i can at least work with that

#

but i still have to handle the boats somehow

#

ok so the boat one may have been my fault

#

cause i've made en error in some other code

thorn isle
#

If we're working on a protection plugin, check out the townyadvanced repo for item frames and boats

static quiver
#

Guys, if I do a spigot plugin will it work with paper and vice versa?

thorn isle
#

Getting it right is very finicky

rare ether
#

however you can circumvent that by using paper-only features only when your plugin detects its on a paper server

thorn isle
#

It's a bit more complicated and unreliable now since they hard forked

#

Many major plugins like abovementioned towny have had to drop spigot support altogether

rare ether
rare ether
static quiver
#

I have a problem with this part of the code if (e.getAction() != Action.LEFT_CLICK_BLOCK) return;. I want to be able to use the item to hit the anvil like a blacksmith, but it understands that I'm breaking the anvil when I hold it for more than half a second. I have to click very quickly to prevent this from happening.

How do I solve this?

mortal hare
#

my hot take:
if something is declared in a way that's duplicated across multiple files but is prone to future changes and and can be easily searched and replaced, it shouldn't be abstracted into its own utility static method or field.

by abstracting declarations you lose flexibility which can cause tech debt in long term.
either case if you do extract it under a method you're just moving a problem into another place, by duplicating method names instead of the actual code.

#

worst case is when you extract it and then your code is semantically tied to unrelated behaviour

static quiver
thorn isle
rare ether
mortal hare
#

i would love if paper just contributed patches to NMS via sponge's mixins instead

#

that way you could load it to fabric server

#

i want optimized paper server without bukkit api

static quiver
#
    @EventHandler
    public void onBlockDamage(org.bukkit.event.block.BlockDamageEvent e) {
        Block b = e.getBlock();
        if (b == null) return;

        Material anvil = b.getType();
        if (anvil != Material.ANVIL && anvil != Material.CHIPPED_ANVIL && anvil != Material.DAMAGED_ANVIL) return;

        Player p = e.getPlayer();
        ItemStack inHand = p.getInventory().getItemInMainHand();
        Integer v = inHand.getPersistentDataContainer().get(RepairIT.Keys.REPAIRIT, PersistentDataType.INTEGER);
        boolean isRepairIt = v != null && v == 1;
        if (!isRepairIt) return;

        Location center = b.getLocation().add(0.5, 0.5, 0.5);
        double range = 0.2, bestTool = range * range, bestMat = range * range;
        ItemDisplay toolDisp = null;
        ItemDisplay materialDisp = null;

        for (Entity ent : b.getWorld().getNearbyEntities(center, range, range, range)) {
            if (!(ent instanceof ItemDisplay d)) continue;
            ItemStack s = d.getItemStack();
            if (s == null || s.getType() == Material.AIR) continue;

            double dsq = d.getLocation().distanceSquared(center);
            if (s.getType().getMaxDurability() > 0) {
                if (dsq <= bestTool) {
                    bestTool = dsq;
                    toolDisp = d;
                }
            } else {
                if (dsq <= bestMat) {
                    bestMat = dsq;
                    materialDisp = d;
                }
            }
        }

        if (toolDisp == null) return;

        PersistentDataContainer pdc = toolDisp.getPersistentDataContainer();
        Integer count = pdc.get(RepairIT.Keys.HIT_COUNT, PersistentDataType.INTEGER);
        int next = (count == null ? 0 : count) + 1;
        pdc.set(RepairIT.Keys.HIT_COUNT, PersistentDataType.INTEGER, next);

        b.getWorld().playSound(center, Sound.BLOCK_ANVIL_PLACE, 1.0f, 1.0f);

        int max = inHand.getType().getMaxDurability();
        if (max > 0) {
            Integer cur = inHand.getData(DataComponentTypes.DAMAGE);
            int nex = Math.min(max, (cur == null ? 0 : cur) + 1);
            inHand.setData(DataComponentTypes.DAMAGE, nex);
        }

        if (next >= 5) {
            Material matType = (materialDisp != null && materialDisp.getItemStack() != null)
                    ? materialDisp.getItemStack().getType()
                    : Material.AIR;

            int repairBy = RepairIT.CONFIG.getRepairAmount(matType);

            ItemStack tool = toolDisp.getItemStack();
            ItemMeta meta = tool.getItemMeta();
            if (meta instanceof Damageable dmg) {
                int cur = dmg.getDamage();
                int newDamage = Math.max(0, cur - repairBy);
                dmg.setDamage(newDamage);
                tool.setItemMeta((ItemMeta) dmg);
                toolDisp.setItemStack(tool);
            }

            if (materialDisp != null && !materialDisp.isDead()) {
                materialDisp.remove();
                Location particleLoc = b.getLocation().add(0.5, 1.05, 0.5);
                b.getWorld().spawnParticle(Particle.ELECTRIC_SPARK, particleLoc, 10, 0.1, 0.1, 0.1, 0.0);
            }

            pdc.set(RepairIT.Keys.HIT_COUNT, PersistentDataType.INTEGER, 0);
        }
    }
}```
rare ether
#

that's a long method haha, give me some time to process that

#

@static quiver you don't cancel the event anywhere

static quiver
rare ether
#

well the player starts the mining animation, otherwise called damaging the block, so the BlockDamageEvent is triggered

#

you do your logic and then at some point you decide you want to cancel that animation

#

so you do event.setCancelled(true);

#

and the player stops mining the block

#

i think

static quiver
#

alr thx man

I started learning java less than a week ago

rare ether
#

oh well then that's a pretty decent code for one week actually

static quiver
rare ether
#

@static quiver I'd recommend you get yourself familiar with good coding practices early on, as it will save you very much time unlearning them later on and make your code easier to debug

static quiver
rare ether
#

And I also recommend the book "Clean Code" by Robert C. Martin

#

don't stress about getting it all memorized and all right in your code immidiately after reading, but keep them in mind and gradually you'll see the value of clean code and make the right habits

static quiver
#

Thanks, I'm going on a trip and I wanted to buy some books to study when I'm away from the computer..

rare ether
#

Good luck bro ❤️

grand flint
rare ether
#

nooooo

#

don't do that please :< you're hurting my feelings

static quiver
#
    @EventHandler
    public void onBlockDamage(org.bukkit.event.block.BlockDamageEvent e) {
        Block b = e.getBlock();
        if (b == null) return;

        Material anvil = b.getType();
        if (anvil != Material.ANVIL && anvil != Material.CHIPPED_ANVIL && anvil != Material.DAMAGED_ANVIL) return;

        Player p = e.getPlayer();
        ItemStack inHand = p.getInventory().getItemInMainHand();
        Integer v = inHand.getPersistentDataContainer().get(RepairIT.Keys.REPAIRIT, PersistentDataType.INTEGER);
        boolean isRepairIt = v != null && v == 1;
        if (!isRepairIt) return;
        e.setCancelled(true);
rare ether
#

make `Bukkit.broadcastMessage("numbers in order"); after every conditional and before the first one and see whether you actually get where the event is supposed to be cancelled

lime mauve
#

is there any tutorials for making a custom event bus in java

rare ether
#

maybe you'll find it useful

static quiver
#

Like

#

I understand what's going on

#

but am I supposed to cancel the event after the 5?

rare ether
#

you're supposed to cancel the event wherever you want

#

so if you want to cancel it after you determine isRepairIt is true than do it

#

what these numbers tell you is how far does your logic actually go before it returns

rare ether
#

can you send me that fragment again up to cancellation but with the broadcasts?

static quiver
#
    @EventHandler
    public void onBlockDamage(org.bukkit.event.block.BlockDamageEvent e) {
        Block b = e.getBlock();
        if (b == null) return;
        org.bukkit.Bukkit.broadcastMessage("1");

        Material anvil = b.getType();
        if (anvil != Material.ANVIL && anvil != Material.CHIPPED_ANVIL && anvil != Material.DAMAGED_ANVIL) return;
        org.bukkit.Bukkit.broadcastMessage("2");

        Player p = e.getPlayer();
        ItemStack inHand = p.getInventory().getItemInMainHand();
        Integer v = inHand.getPersistentDataContainer().get(RepairIT.Keys.REPAIRIT, PersistentDataType.INTEGER);
        boolean isRepairIt = v != null && v == 1;
        if (!isRepairIt) return;
        org.bukkit.Bukkit.broadcastMessage("3");

        Location center = b.getLocation().add(0.5, 0.5, 0.5);
        double range = 0.2, bestTool = range * range, bestMat = range * range;
        ItemDisplay toolDisp = null;
        ItemDisplay materialDisp = null;

        for (Entity ent : b.getWorld().getNearbyEntities(center, range, range, range)) {
            if (!(ent instanceof ItemDisplay d)) continue;
            ItemStack s = d.getItemStack();
            if (s == null || s.getType() == Material.AIR) continue;

            double dsq = d.getLocation().distanceSquared(center);
            if (s.getType().getMaxDurability() > 0) {
                if (dsq <= bestTool) {
                    bestTool = dsq;
                    toolDisp = d;
                }
            } else {
                if (dsq <= bestMat) {
                    bestMat = dsq;
                    materialDisp = d;
                }
            }
        }

        if (toolDisp == null) return;
        org.bukkit.Bukkit.broadcastMessage("4");

        PersistentDataContainer pdc = toolDisp.getPersistentDataContainer();
        Integer count = pdc.get(RepairIT.Keys.HIT_COUNT, PersistentDataType.INTEGER);
        int next = (count == null ? 0 : count) + 1;
        pdc.set(RepairIT.Keys.HIT_COUNT, PersistentDataType.INTEGER, next);

        b.getWorld().playSound(center, Sound.BLOCK_ANVIL_PLACE, 1.0f, 1.0f);

        int max = inHand.getType().getMaxDurability();
        if (max > 0) {
            Integer cur = inHand.getData(DataComponentTypes.DAMAGE);
            int nex = Math.min(max, (cur == null ? 0 : cur) + 1);
            inHand.setData(DataComponentTypes.DAMAGE, nex);
            org.bukkit.Bukkit.broadcastMessage("5");
        }

        if (next >= 5) {
            org.bukkit.Bukkit.broadcastMessage("6");

            Material matType = (materialDisp != null && materialDisp.getItemStack() != null)
                    ? materialDisp.getItemStack().getType()
                    : Material.AIR;

            int repairBy = RepairIT.CONFIG.getRepairAmount(matType);

            ItemStack tool = toolDisp.getItemStack();
            ItemMeta meta = tool.getItemMeta();
            if (meta instanceof Damageable dmg) {
                int cur = dmg.getDamage();
                int newDamage = Math.max(0, cur - repairBy);
                dmg.setDamage(newDamage);
                tool.setItemMeta((ItemMeta) dmg);
                toolDisp.setItemStack(tool);
                org.bukkit.Bukkit.broadcastMessage("7");
            }

            if (materialDisp != null && !materialDisp.isDead()) {
                materialDisp.remove();
                Location particleLoc = b.getLocation().add(0.5, 1.05, 0.5);
                b.getWorld().spawnParticle(Particle.ELECTRIC_SPARK, particleLoc, 10, 0.1, 0.1, 0.1, 0.0);
                org.bukkit.Bukkit.broadcastMessage("8");
            }

            pdc.set(RepairIT.Keys.HIT_COUNT, PersistentDataType.INTEGER, 0);
            org.bukkit.Bukkit.broadcastMessage("9");
        }
    }
}
smoky anchor
#

pro tip: split up the method
this is too long

#

also

#

?paste

undone axleBOT
static quiver
rare ether
#

and it does so since it doesnt work the issue is somewhere else

#

for now i'd leave the broadcasts and add the cancelation back

smoky anchor
#

Will cancelling this event prevent the block from breaking ?

static quiver
#

the javadocs says so

smoky anchor
static quiver
#

If this event is cancelled, the block will not be damaged.

static quiver
smoky anchor
#

oh ye I guess it does

static quiver
#

Do u guys have any idea of what i should do?

smoky anchor
#

wait is your issue the fact that the event is ran only once ?

static quiver
#

It runs multiple times, even if i just click

but it runs only one time if i do a super quick click

smoky anchor
#

can't you just do cooldown on the hammer item whenever it hits ?

#

like the ender pearl type cooldown

smoky anchor
#

I don't remember how the thing works

static quiver
#

I hadn't thought of that, I'll try.

#

Here, there's a use cooldown, but I don't think it works for left click

smoky anchor
#

Ok so: give it the duration you want, give it the cooldown group for your custom item (I assume)
And then you can trigger it with API from your event

#

I think

static quiver
#

oooooh

#

ok

#

i'll try

smoky anchor
#

if it doesn't fully stop the left lick, you can just check for the cooldown in that event ig

rare ether
#

@static quiver Just do a separate EventHanlder in the same listener class

#

and let the thing you were using previously handle only the sound and things you want to happen an the beginning

#

and BlockDamageEvent strictly for cancelling the mining

smoky anchor
#

I don't see the need for two separate event listeners here
I'd just do one and create mulitple methods that then handle the things instead

rare ether
#

But why have more logic in a listener that triggers 15 times per second?

#

That's where the logic should be minimal

smoky anchor
#

the other event listener will still triger tho

rare ether
#

yeah but once

smoky anchor
#

just because you cancel it doesn't mean it won't work

rare ether
#

cuz he'll use a different event that detects just the left click

smoky anchor
#

(unless you specify ignore cancelled I GUESS but meh from me)

rare ether
#

these are different events bro

smoky anchor
#

Well you didn't say that, ok sure

smoky anchor
#

you didn't specify different event

#

so I misunderstood as "use 2x BlockDamageEvent"

static quiver
#

The cooldown thing worksss

#
        if (p.hasCooldown(inHand)) return;
        p.setCooldown(inHand, 20);```

That's all I did (and add the cooldown to the mace attributes ofc)
#

That's what my plugin does

thorn isle
#

neat

#

i remember someone making something very similar to this before, but i think it was purely a cosmetic animation that played when you used the "crafting stations" like the anvil or the crafting table, not something you actually interacted with

#

it was also balls deep into nms so it worked for like 2 major versions and was then abandoned

hardy garnet
#

Is there a way to run certain parts of your plugin on startup then do the rest of it postworld?

thorn isle
#

onload maybe, i don't quite remember

#

but you can't do most plugin related things at that point

hardy garnet
#

I'm looking into onload rn

#

Well yea I know that

#

I'm just moving files

echo basalt
#

what the fuck

#

check pins

grand flint
#

no

#

then i wont get fired Pepe_Hearts

echo basalt
#

blocked.

wooden bay
grand flint
#

@echo basalt wait what if i name them small words like

#

me

#

he

#

she

#

i

echo basalt
#

Variable names should be descriptive to minimize the amount of mental gymnastics needed to read code

#

The idea is that you can look at it and immediately understand without prior knowledge that "e" stands for "event" and not "evangelist"

#

that p stands for player, not pizza

#

b can be block, balance, broke

raven wolf
#

It's like you all are talking in another language to me. 😆

echo basalt
#

write clean code

grand flint
#

what if b stood for blocks that are natural in a region

#

is that ok

echo basalt
#

why not just name it "regionBlocks"

raven wolf
#

b should stand for butts

echo basalt
#

or boobs

raven wolf
#

or boners

echo basalt
#

this guy gets it

#

true developers name their variables after marvel characters

grand flint
#

bitches 🙏

#

yk what

#

illusion just for u

echo basalt
#

Player spiderman = avengers.getPlayer()

grand flint
#

im gonna name all my variables after spigot members

raven wolf
#

b for blade

grand flint
#

md, illusion, xpdz

echo basalt
#

beyblade

#

aha

wooden bay
echo basalt
#

spiderman.launchProjectile 💀

wooden bay
#

@echo basalt I have written some code that you may or may not like, wanna see?

echo basalt
#

no

#

wait did the mega thread get archived

#

nvm just got hid

wooden bay
#

It's troll code ngl

echo basalt
#

yeah cba I'm doing other work

wooden bay
#

tf is cba

wet breach
hardy garnet
#

Hmm, anyone here know when datapacks are loaded?

chrome beacon
#

Very early

#

Before plugins

hardy garnet
#

Lol damn

thorn isle
#

paper has some sort of datapack and registry api but it's only for paper-plugins which are kind of different from bukkit plugins and kind of annoying to work with in some respects

sullen marlin
#

you can reload datapacks if needed for some reason

slender elbow
#

not all registries are reloadable however

young knoll
#

Sadly

#

I don’t think any worldgen ones will reload

#

They should make /reload restart the entire server :)

#

At runtime

robust helm
#

how do yall do fancy messages?
i dont want to do "§4§l[§3PR3F1X§4]§7 " + message all the time

#

maybe i could use mixin to inject into the player.sendMessage method, cause im making everything for my own needs and everything myself anyways

#

or a StyleHelper class with static methods to make the messages pretty, but thatd add boilerplate

hardy garnet
#

Jumped down a small rabbit hole to basically allow me to have my datapack im working on for my plugin inside my jar file

young knoll
#

How’d that work out for you

hardy garnet
#

I got it working

#

was it worth it

#

probably now

#

not

young knoll
#

Don’t think it would work for any fancy worldgen stuff

#

Unless you did some registry hacking

hardy garnet
#

Ah, but it does

#

Basically I have it check a custom file I have in the datapack called datapackinfo.json

#

if the version is out of date it overrides the datapack thats in the world for a new one

#

and restarts the server

#

(also if the datapack doesnt exist)

#

so it does work with worldgen

young knoll
#

How does it restart the server

hardy garnet
#

the /restart command

#

as long as restart is configured in spigot.yml its fine

young knoll
#

Except almost no one uses that

hardy garnet
#

Well considering this plugin is for my server only

#

its fine

#

Mostly its just meant to make deving more convenient

#

It took me awhile to get working though so idk if it was worth

smoky oak
#

if i want to display custom graphics in the world, what is my best option to do so? Assume they're pieced together from smaller graphics

young knoll
#

Text displays or item displays

smoky oak
#

can those be transformed properly?

#

oh its probably in the display part

#

oh no math

hardy garnet
#

Hmm, /place structure works for my structure, and bukkit is seemingly able to find the structure (Bukkit.getStructureManager().getStructure(structureKey) is not null)

but, structure.getPalettes() is an empty list

#

weird

hardy garnet
#

Well I figured it out!

#

As it turns out, /place and getStructure reference different things

#

because of course they do why wouldnt they

#

getStructure references the nbt file directly and /place refers to a .json file

#

im tired

young knoll
#

You need to use loadStructure(key)

spiral roost
#

ProtocolLib question, Is there a good way to look up what StructureModifiers go with the data structures listed on the Protocol Wiki page? For instance, how do I read the "Array of changed slots" field for this packet in 1.21.8? https://minecraft.wiki/w/Java_Edition_protocol/Packets#Click_Container

Minecraft Wiki

This article presents a dissection of the current Java Edition protocol for 1.21.8, protocol 772.

echo basalt
#

Look at the nms packet class and then see if you can find a wrapper for it

#

You might not have wrappers for it, in which case IIRC protocollib has an automatic wrapper thingy

#

I'd recommend packetevents atp protocollib has been unreliable since 1.20.5 imo

quaint mantle
#

I'm trying to understand why VSCode says methods are undefined during development

#

I get stuff like "The method getBlock() is undefined for the type BlockBreakEvent Java(67108964)"

#

but other methods on the Spigot API are working fine

chrome beacon
#

VSCode 💀

quaint mantle
#

?

chrome beacon
#

Do make sure you have it set to use Java 21

quaint mantle
#

Yeah of course, I only installed Java 21 because I develop for 1.21.7

chrome beacon
#

Why not .8

quaint mantle
#

The place that I'm working with uses 1.21.7, it's not much different

#

I think I'll probably try running some maven commands, maybe 'mvn clean install' failed. It doesn't seem like a Java issue

chrome beacon
#

.8 is a client hotfix

#

And you will get some server bug fixes

grand flint
#

use minimessage

quaint mantle
quaint mantle
#

If you use p*per you don't have to do all this

knotty zenith
#

💎 Looking for a professional Minecraft server setup?
I specialize in custom server development, plugin configuration, and unique setups tailored to your community. Whether it’s survival, skyblock, minigames, or a completely unique idea – I can bring it to life. 🚀

👉 DM me if you want a polished, lag-free, and fully customized Minecraft experience!

smoky anchor
undone axleBOT
knotty zenith
#

my services are professional stable ms server of any type lifesteal or headsteal or simple it depends on you and also i can make custom plugin for you

smoky anchor
#

Again, this is NOT the place for this

knotty zenith
smoky anchor
#

not discord, forums
as the bot linked

knotty zenith
young knoll
#

Professional stable ms

grand flint
#

LMAO

#

professional ms

robust helm
zealous scroll
#

bit of a necropost from our old conversation, this strategy broke for some reason for me in 1.21.8, specifically with the SET_CURSOR_ITEM packet, as remapping its outgoing item will cause a weird duplication glitch.

what outgoing/incoming packets are you remapping?

robust helm
robust helm
#

like my issue is, that I don't want to obscure my code with all the chat formatting like adding a prefix at every sendMessage using a static variable or sth

chrome beacon
#

Just make a helper method to send your messages

#

You don't need a whole library to avoid one method call

robust helm
#

alrrr

#

ty

lost matrix
zealous scroll
#

Have you tried those in 1.21.8?

smoky oak
#

can someone explain this warning, please?
location of system modules is not set in conjunction with -source 17

echo basalt
#

Creative mode cloning yeah

#

you use PDC to track if an item with client-sided lore was cloned

#

I honestly just do my menus with NMS rather than having to emulate and replicate every vanilla behavior atp

hardy garnet
#

How are you guys feeling about npcs?

wooden bay
#

Feels like a npc ngl

grand flint
#

yeah lowkey an npc

rare ether
#

Hii, do you guys maybe know how to cancel redstone ore lighting up when player stands on it?

thorn isle
#

iirc that's playerinteractevent with the PHYSICAL action type

rare ether
#

okay i see tysm

rare ether
#

ok so im having issues preventing it, i check before with broadcasts and the conditionals pass to the end correctly: ```java
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerInteract(final PlayerInteractEvent event){
switch (event.getAction()){
case PHYSICAL:
handlePhysicalInteraction(event);
break;
case RIGHT_CLICK_BLOCK:
case LEFT_CLICK_BLOCK:
handleBlockClickInteration(event);
break;
}
}

    ...
    
private void handlePhysicalInteraction(final PlayerInteractEvent event) {
    if(!event.hasBlock()) return;

    final Block blockBelow = event.getPlayer().getLocation().getBlock().getRelative(BlockFace.DOWN);
    if(blockBelow.getType() != Material.REDSTONE_ORE) return;

    blockBelow.setBlockData(Bukkit.createBlockData(Material.REDSTONE_ORE));
}```
#

canceling the event also didnt work

#

it may be because the redstone ore gets lit after this event has passed, but there's no event triggered for that in spigot api

#

or it may be because im dumb

chrome beacon
#

Wouldn't the block from the event be the ore

rare ether
#

yeah

#

wait no

chrome beacon
#

the block directly below the players location on the other hand isn't guaranteed

#

to be the ore

rare ether
#

it is but the block from the event only applied to when a block is clicked

#

and in this case its not