#help-development

1 messages · Page 1880 of 1

main dew
#

.

lavish hemlock
#

Well: Static instrumentation is just the generic jvmagent method, which is problematic as it requires server owners to do additional setup to configure the plugin (which is only important if your plugin is public).

#

Dynamic instrumentation allows you to instrument after classes have loaded and without jvmagent, but requires server owners to have a full JDK installed as opposed to a JRE (and a lot of them don't, since most of them download from Oracle)

#

So if your plugin isn't public, just do it the static way.

main dew
lavish hemlock
#

Wdym

main dew
#

you can load libraries from java code

#

it's a bit strange operation and made difficult by jave 9 but possible

lavish hemlock
#

Well yeah but that's for classes that haven't been loaded yet

#

And primarily uses ClassLoader

#

You'd also either have to use URLClassLoader (which is prone to error because of Java 9) or your own implementation.

main dew
#

yea (I can load libary from JDK libary)

lavish hemlock
#

Well the problem is that the JDK's code is

  1. Proprietary (although this depends on what part of the code)
  2. Platform-dependent
main dew
#

and I'd like to avoid giving arguments

lavish hemlock
#

The problem with 2 is that it means your plugin also becomes platform dependent.

main dew
#

oke I can load ASM libary 😅 correct

lavish hemlock
#

I mean yes but that's because ASM is made in Java and has 0 native code.

#

You don't need to load it either, you can just add it to your dependencies in a buildsystem like Maven or Gradle.

#

With the JDK, that's not possible.

#

The JDK has multiple platform implementations (Mac, Windows, and Linux), and you'd have to distribute all of them, which would spike your plugin's code size up to hundreds of megabytes, possibly even multiple gigabytes, and be IMPOSSIBLE to manage.

main dew
lavish hemlock
#

ASM is...

#

one second

#

ASM is only 119 KB.

main dew
#

I prefer ClassLoader

lavish hemlock
main dew
lavish hemlock
#

You still haven't explained why you need ASM.

main dew
main dew
#

I am afraid of another discussion on this topic

#

disable phycics gravel, sand etc

lavish hemlock
#

Use Google

#

This is highly reminiscent of the

#

?xy

undone axleBOT
main dew
#

but

#

EntityChangeBlockEvent don't work perfect

lavish hemlock
#

Well I can't help any further đŸ€·â€â™‚ïž

main dew
#

on moment summon faliing block set in this place air latter remove falling block and set block again

#

I was looking for a long time, I did not find a properly working method for it

tender shard
#

erm

#

why is this nullable

#

wouldn't it always return an empty bucket?

chrome beacon
#

It's not nullable?

quaint mantle
#

How do you turn a String[] args, itno a regular String?

left swift
#

I am creating my own entity which consists of several armorstands. They have items on them. Is it possible to use EntityComplexPart for this? Ender dragon uses it. I can use it for my own entity or rather that's not possible.

young knoll
#

String.join

#

Read the docs

quaint mantle
#

done

#

String.join(" ", args);

young knoll
#

Not sure why you want to join all the command args

#

Broadcast/msg command I guess

tender shard
#

I meant getItemStack

#

that's nullable

young knoll
#

Huh

#

Yeah idk when it’d be null

drifting vault
#

I am wanting to check if the list of commands in config contains a %timer_x% and then run that first and then proceed to the next commands. x being time in seconds

young knoll
#

Add a consumer to the class that gets called at the end of the timer

drifting vault
#

Would you give me an example without spoonfeeding?

thick gust
#

what does the .setRemainingAir method do of the Chicken class? 😼

charred echo
#

RTMFD

#

LivingEntity#setRemainingAir(int ticks) - Sets the amount of air that the living entity has remaining, in ticks.

hexed hatch
#

I don't think a file name will suffice

#

I believe instantiating a file requires a path

#

yeah

#

it's gotta have a path

#

well

#

Oh, so this is in your jar?

tender shard
#

PlayerItemConsumeEvent sucks hard

hexed hatch
#

you have to use something else

#

I don't remember what it is

#

but you can't just grab it as a File

glossy scroll
hexed hatch
#

looks like we had the same idea

glossy scroll
#

I would use getResourceAsStream @fervent robin

#

Then you can pass that in the scanner constructor

tender shard
#

is your file included in your .jar?

#

did you check with winrar / winzip / etc?

#

is it at the root folder of your .jar?

glossy scroll
#

We answered their question i think?

tender shard
#

you can't just use new File() if it's inside your .jar

glossy scroll
tender shard
#

kk

glossy scroll
#

what error do you get

upper niche
#

does the net.minecraft.world.item.ItemStack class not have a getTag() or a hasTag() method anymore in 1.18?

glossy scroll
#

I believe PDC is the replacement for that?

#

what version of java

#

java 8?

#

ig

#

whats the file structure of this again

upper niche
glossy scroll
#

You might need to do /me/name/mypackage/blockedwords.txt

kind hatch
#

PersistentDataContainer

charred echo
#

PersistentDataContainer

upper niche
#

ah
and how would i go about grabbing the entire nbt structure of an item from its pdc

glossy scroll
#

yes

#

Spigot does not have an NBT api

#

you would need to use NMS I believe

charred echo
#

is he trying to get a resource from src/main/resources?

kind hatch
glossy scroll
#

just a resource in a package

upper niche
#

then how would i get the nbt of an itemstack now if getTag() is removed for nms itemstacks?

charred echo
#

why tho, use the maven generated resource folder

glossy scroll
charred echo
#

that's a better practice

kind hatch
upper niche
#

trying to create a bungeecord Item from an itemstacks nbt data to display in chat as a HoverEvent

glossy scroll
#

incheresting

tender shard
#

oh wait

#

you talk about NBT kinda tags?

glossy scroll
#

would itemstack.serialize help?

charred echo
#

do you need it to be in the same package as the class itself or just need it in the packaged jar

kind hatch
charred echo
#

alright

glossy scroll
#

yea at this point i'd just recommend dehys approach

#

i believe you might need a maven compile plugin to put your resources in the jar?

upper niche
charred echo
#

create a new folder where main is and call it resources

#

you already got it

glossy scroll
#

they already have one

charred echo
#

okay pur your file in there

fleet imp
#

Using ShapedRecipe().setIngredient() in the ingredient, what is the char

kind hatch
#

The char is a placeholder. You will use it to mark the spot in the grid.

charred echo
#

now use getResourcesAsStream("path/to/file")

#

but in this instance it would just be

#

"filename.extension"

#

if you got your file in resources directory only

#

and not in any sub directories

#
URL resource = getClass().getClassLoader().getResource("file.txt");
if (resource == null) {
      throw new IllegalArgumentException("file not found!");
  } else {
      return new File(resource.toURI());
  }
tender shard
#

why do you do your stuff so complicated

charred echo
#

me?

tender shard
#

everyone here trying to read the file from the .jar

charred echo
#

that's what he wanted

drifting vault
tender shard
#

this is how I read files from a .jar

    public Set<Material> loadRegexList(String name) {
        Set<Material> set = new HashSet<>();
        try(InputStream input = getResource("regex/" + name + ".txt");
            BufferedReader reader = new BufferedReader(new InputStreamReader(input))) {
            reader.lines().forEach(regex -> {
                Pattern pattern = Pattern.compile(regex);
                Arrays.stream(Material.values()).forEach(mat -> {
                    if(pattern.matcher(mat.name()).matches()) {
                        set.add(mat);
                    }
                });
            });
        } catch (IOException exception) {
            exception.printStackTrace();
        }
        return set;
    }
upper niche
charred echo
#

It's actually a good approach

kind hatch
tender shard
#

you realize that 90% of it is something else right?

#

to read a file all you need is this:

charred echo
#

InputStream input = getResource("regex/" + name + ".txt");

tender shard
#
try(InputStream input = getResource(fileName);
    BufferedReader reader = new BufferedReader(new InputStreamReader(input))) {
      reader.lines() // <-- Stream<String>
}```
upper niche
tender shard
charred echo
#

prob should have something more dynamic like this

#

nvm.

tender shard
#

it's a method of JavaPlugin

#

so yourMainClass.getResource

charred echo
#

otherwise

ClassLoader classLoader = getClass().getClassLoader();
InputStream inputStream = classLoader.getResourceAsStream(fileName);
kind hatch
upper niche
#

hm

#

ill have to play with that but that seems like an idea

kind hatch
# upper niche hm

That would be for your hover, your main message would be the item name.

charred echo
#

ouou import lombok.SneakyThrows need to try lombok sometime

upper niche
#

well ill try that and see how it goes

kind hatch
tender shard
#

for many things, not for everything

#

sneakythrows must be used carefully

charred echo
#

using it what are your thoughts

#

I mean some pro's and con's

tender shard
#

e.g. SneakyThrows makes sense if you do something like

if(file.exists()) {
  // ...
}

We can be sure that no FileNotFoundException will be thrown, so try/catch is totally useless. Just @ SneakyThrows, and go ahead

#

basically if you KNOW the exception can't be thrown, you can wrap it in sneaky throws

charred echo
#

otherwise you'll be in hell for some hours trying to figure out why something isnt working and where

#

lmao

tender shard
#

no no

#

it will still throw an exception

charred echo
#

ah

tender shard
#

it's just that you don't have to declare it

#

it behaves like runtime exceptions

#

e.g. if you do this:

#
int myNumber = Integer.parseInt("asdasd");
#

it does not declare any exception!

charred echo
#

oh

tender shard
#

you can use that without try/catch

#

because it only throws a RuntimeException

#

those do not have to be declared in the method signature

charred echo
#

I might need to look into it a bit more

tender shard
#

so tl;dr: you can use SneakyThrows if you KNOW something won't go wrong. e.g. if you read a file included in your .jar, it will always work, unless someone removed it from the .jar. in that case, it's their fault, so not your problem 🙂

unreal quartz
#

JEFF Media

tender shard
#

that's me

#

(and some other jerks)

drifting vault
tender shard
drifting vault
#

Iterate through a list of strings and if it contains a specific string such as “%timer_10%” then run a task then wait for it to finish then proceed to the next string

#

I don’t know how else to explain it

#

Basically a timer variable in config. When the timer finishes, the next string is read

#

An example of this usage would be:

PermissionCommands:
  flight:
    node: essentials.fly
    commands:
    - '%timer_5% msg %player% you have %timeLeft% seconds to land.'
    - msg %player% Hey
    - fly %player% disable

A 5 second timer would display telling the player they have 5 seconds to land. after the 5 seconds, the other commands would be ran

tender shard
#

that loops through the strings and do whatever you like

#

once it encounters one of your %timer_% things, just Thread.sleep for that long

#

if you do call Bukkit API however, you have to do so in a new sync scheduled task

#

I'll send an example

charred echo
#

|| trust me try it without sync scheduled task, trust ||

tender shard
#
Bukkit.getScheduler().runTaskAsynchronously(this, () -> {
            System.out.println("Printing something, then waiting 5 seconds...");
            Thread.sleep(5000);
            System.out.println("Now, we call the Bukkit API - we must do so on a synced thread.");
            Bukkit.getScheduler().runTask(this, () -> {
                player.teleport(...);
            };
        });
#

btw

#

since when is it possible to right-click while having armor in your hand to equip it?
and is any event called for that besides PlayerInteract ?

night patrol
#

sure it appear in /pl and /plugins

thick gust
#

how can u change the head of an armorstand?

#

setHelmet is deprecated.

tender shard
#

I just told you via DM

thick gust
#

you said getInventory()

#

And it's not available for ArmorStand class...

#

-.-

#

and you did not further reply to me when i told u that

#

so i went to this channel to ask other peeps u know..

glossy scroll
#

getEquipment

tender shard
glossy scroll
#

beat me to it

ivory sleet
#

Yeah most entities don’t actually have a proper inventory like players and some tile states, just a container.

thick gust
#

thx

drifting vault
ivory sleet
#

May I ask what in the world you’re doing lol

tender shard
drifting vault
#

i forgot the sync part

tender shard
#

Are there any other wearable items that normally can't be stacked?

^.*_HELMET$
^.*_CHESTPLATE$
^.*_LEGGINGS$
^.*_BOOTS$
^TURTLE_HELMET$
^ELYTRA$
drifting vault
#

im testing it now

ivory sleet
#

Yeah it’s a really easy fix, simply use runTaskTimer or (runTaskLater, runTask), so not the ones with the Asynchronously suffix

thick gust
#

why the heck are my entities not invulnerable although i used setInvulnerable(true) AND I'm using the current paper build to test my plugin

#

the fuck is going on

ivory sleet
#

Well

#

It doesn’t prevent damage by players in creative mode iirc

thick gust
#

w8..

#

it does not?

#

why

tender shard
#

no

thick gust
#

?

#

that does not even make sense

#

Invulnerable = IMMORTAL!

#

@tender shard YOu could've told me that wayyy earlier! XD

ivory sleet
#

Hmm yeah it sounds like that but that just ain’t how it’s done

tender shard
#

creative mode changes many things

thick gust
#

For the love of god i was thinking all the time its caused by my spigot build

drifting vault
#
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
                        if (matcher.find()) {
                            int dur = Integer.parseInt(matcher.group(1).replace("%timer_", "").replace("%", ""));
                            new Timer(dur, plugin) {
                                @Override
                                public void count(int current) {
                                    String command = cmd.replaceAll("%timer_\\d+%", "").replaceAll("%player%", player.getName()).replace("%timeLeft%", current + "");
                                    this.plugin.getServer().dispatchCommand(this.plugin.getServer().getConsoleSender(), command);
                                }
                            }.start();
                            try {
                                Thread.sleep(dur * 1000L);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                        }
                        Bukkit.getScheduler().runTask(plugin, () -> {
                            String command = cmd.replaceAll("%player%", player.getName());
                            this.plugin.getServer().dispatchCommand(this.plugin.getServer().getConsoleSender(), command);
                        });
                    });
``` still not working lol
ivory sleet
#

bruh

thick gust
#

I stop using paper now cuz its ugly u gotta do /rl and then confirm it like wtf?! XD

drifting vault
#

oh god that format lol

tender shard
#

?notworking

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

ivory sleet
#

Read my damn message potato (:

drifting vault
#

it works, just not async

#

1 after another

#

i got the runtask in there as you can see

ivory sleet
#

Yes but you don’t need to async that

tender shard
ivory sleet
#

And you don’t need to use Thread sleep neither

thick gust
#

Does invulnerable work in all gamemodes except creative?

unreal quartz
#

“Does not working”

thick gust
#

nice

tender shard
thick gust
#

armorStand.getEquipment().setHelmet(itemStack);

#

does not work

#

?

ivory sleet
#

It was either me or Alex lol

tender shard
#

most people who don't give error messages use kinda RIP english

drifting vault
#

ok then what do i do? i tried what mfnalex told me to and it yielded same result

thick gust
#

yielded KEKW

drifting vault
#

produced..

tender shard
ivory sleet
#

Oh I think I copied the text from discord

thick gust
#

wait i know why it does not work XD

ivory sleet
#

Idk

#

Hmm I can change that later lol

tender shard
drifting vault
#

ill remove the runtaskasync as you have said

ivory sleet
#

(:

tender shard
#

most people say "why my code not doesn't working"

ivory sleet
#

Yes bed potato and what’s up with the Thread sleep

ivory sleet
tender shard
drifting vault
#

alex provided an example

#

i followed it

tender shard
#

no you didnt

drifting vault
#

and now conclure is telling me to remove it

tender shard
#

you used a java Timer

#

which runs on the same thread

#

I said to use the bukkit scheduler

ivory sleet
#

That looks like a really nasty way of fucking with bukkit scheduler’s cached thread pool bed potato

tender shard
#

to run stuff synced from your async task

drifting vault
#

i am using a bukkit schedule

thick gust
#

can you leash armorstands?

ivory sleet
#

I don’t think so

tender shard
drifting vault
#

The thread?

tender shard
drifting vault
#

is there a bukkit thread method i can call or is that not what you are referring to

tender shard
# drifting vault The thread?

Thread.sleep does of course work when you run it in an async task. of course you have to wrap it inside try / catch

#

it's not the best solution of course, it was just an example. just wanted to say it would have worked 😛

thick gust
#

is there an event for fallingblocks disappearing by collision?

hybrid spoke
thick gust
#

w8...

#

the event name is confusing

#

...

drifting vault
#

i am just not grasping what you are trying to tell me. i tried the example you gave me and i get called an idiot

thick gust
#

it does not describe what i'm trying to access..

tender shard
glossy scroll
#

nope

#

you got it wrong

#

he's talking about the entity despawning

#

not the block becoming an entity

thick gust
#

yea..

tender shard
thick gust
#

welll...

#

what if the fallingblock despawns right in the air

#

and does not change into an actual block?

#

cuz that's the case sometimes for me

hybrid spoke
#

loop over it and check if it still exist

tender shard
#

there's no event for that

thick gust
#

a fallingblock disappears by colliding to any blocks. that includes a sideways collision.

glossy scroll
#

you could use GenericGameEvent

tender shard
glossy scroll
#

and listen for ENTITY_KILLED

thick gust
#

GenericGamEvent? XD

#

That sounds hella funny LUL

tender shard
#

somehow falling blocks are strange and sometimes they are just gone, even though Entity#isValid still returns true

#

I gave up after a few hours

tender shard
hybrid spoke
#

a generic game event

#

for mojang actions

glossy scroll
#

yes

hybrid spoke
#

what the bukkit events cant reach or the same

tender shard
#

whoa is that new

#

never heard of that

glossy scroll
#

since shulkers

#

i believe 1.17

hybrid spoke
#

arent shulkers a 1.12 thing

tender shard
#

nah

glossy scroll
#

oops

tender shard
#

end was 1.8

glossy scroll
#

i meant skulk

#

skulkers

tender shard
#

wasn't end beta 1.8 / release 1.0?

glossy scroll
#

shulkers were 1.9

tender shard
#

btw... WHY THE FUCK IS THERE STILL NO VANILLA WAY TO ACQUIRE BUNDLES

glossy scroll
#

because bundles suck

hybrid spoke
#

shulker since 1.9

#

yeah

tender shard
#

no they are awesome

ivory sleet
#

Do they even exist in the game mfnalex?

glossy scroll
#

they dont solve a problem

tender shard
#

you can even access them through spigot without any problems

ivory sleet
#

Wait

#

Ugh

#

Fr

tender shard
#

yes

#

fr

ivory sleet
#

Damn

glossy scroll
#

mojang wanted to address inventory management, budles are just another wacky item that causes the workflow to be more confusing and time consuming

#

not to mention

#

uses rabbit hide... people get shulkers before they get rabbit hide

thick gust
#

so does the event changes in a newer version? I mean it's name?

#

I don't want to change in each new minecraft version that event name lol

glossy scroll
#

otherwise

thick gust
#

Or will it probably stay the same such as others

glossy scroll
#

you need to use Entity.isValid

ivory sleet
#

what the fuck

#

I’m transfixed

thick gust
#

wait so if the fallingBlock disappeared, however by falling down or disappearing in air, it will return with isValid false right?

upper niche
#

so im looping through enchantment names
when using toString() for an enchantment, it prints Enchantment[minecraft:<game name>, <enum name thats half accurate>]
is there a way to get the displayed name of an enchantment from an Enchantment object? i cant just parse the toString() string because of name discrepancies
sharpness reads as [minecraft:sharpness, DAMAGE_ALL]
but sweeping edge reads as [minecraft:sweeping, SWEEPING_EDGE]
sharpness would only be valid from the former half whereas sweeping edge the latter
any way to get the displayed ingame name from the enchantment?

thick gust
#

and if it is still there (it never disappeared ofc, if its still there), then it will return isValid true?

tender shard
thick gust
#

Aight then I'll use that to detect it, thanks.

#

Wait what the fckkk

tender shard
#

falling blocks are weird

thick gust
#

why should spigot keep it like that?

#

Is there isDead?

tender shard
#

isValid checks for isDead

thick gust
#

Some classes had such a method

#

-.-

#

Stupid isValid

tender shard
#

more like stupid NMS falling block

thick gust
#

Couldnt u just check if the fallingBlock is null?

#

So that kind of tells if the fallingBlock disappeared

tender shard
#

if it would be null, isValid would throw an NPE

thick gust
#

So that does not work as well? XD

#

But somehow u gotta detect something like that

#

For the love of god pls fix such stuff Spigot lol

tender shard
#

once you have an entity reference, it will never become null

hybrid spoke
#

Player dribbles the system by quitting

glossy scroll
#

@tender shard youre literally incorrect

tender shard
thick gust
#

LMAO XD

glossy scroll
drifting vault
#

I have come up with this https://pastebin.com/M5B3aPMN
for the runTaskLater() towards the bottom, i put 5 instead of time, for testing. it is 0 when i put time in its place

glossy scroll
#

those are ALL used in the falling block entity class

thick gust
#

So wait FallingBlock got also the isAlive and isRemoved method right?

#

So i can use any of those 2 to check if it disappeared?

#

Okay thx

glossy scroll
#

thats nms

#

you need to use bukkit

thick gust
#

Can i use any of those 2

drifting vault
#

i am assuming that is what you meant? @tender shard

glossy scroll
#

isValid should cover it

thick gust
#

Spigot = Bukkit with more features

glossy scroll
hybrid spoke
#

spigot is the bukkit continuation

thick gust
#

But mfnalex said isValid does still return true although the fallingblock disappeared..

glossy scroll
#

mfnalex

#

im literally in the code rn

thick gust
#

I like the discussions here XD

#

I am lmao atm

hasty prawn
#

What are you even arguing about

glossy scroll
#

he's claiming isValid doesn't work for falling blocks

thick gust
#

About if isValid is working to detect if a fallingblock disappeared lol

glossy scroll
#

im showing evidence it very clearly does

thick gust
#

LMAO XD

#

Martoph wants to make things clear

#

LUL

tender shard
#

not that I care but

#

see?

hybrid spoke
#

why do you take it THAT personally @glossy scroll

thick gust
#

LMFAO XDDDD

glossy scroll
#

because hes telling Proudyy false information lol

thick gust
#

Guys stop its funny lol

tender shard
thick gust
#

xDD

glossy scroll
#

what about it?

thick gust
#

U kill me lol

glossy scroll
tender shard
#

isValid checks whether the entity is dead or alive

glossy scroll
thick gust
#

XDD

glossy scroll
thick gust
hybrid spoke
#

xD

thick gust
#

And mfnalex does not care

#

LMAO XD

glossy scroll
#

girly you gotta ignore method names sometimes and just look at the actual code

drifting vault
glossy scroll
#

those are the spigot mappings too

tender shard
#

I really don't get what you are talking about

#

I said that isValid checks if the entity is dead

glossy scroll
#

you're saying isValid doesn't work for fallingBlocks

tender shard
#

how is that wrong

glossy scroll
#

im saying it 100% does

tender shard
thick gust
#

XDDD

tender shard
#

it will vanish after 5-10 minutes

thick gust
#

Guys

tender shard
#

no matter what you do

thick gust
#

I want

#

I want only true informations now

#

Which method is good to detect if a fallingblock is disappeared?

ivory sleet
#

looks like isValid checks if it’s alive rather than dead but I presume some where deep in code it may inherently check for dead state?

tender shard
#

you can cancel all events, you can set it invulnerable, you can set its despawn ticks or however its called

thick gust
#

Tell me

hybrid spoke
thick gust
tender shard
#

it will be gone after some time, although spigot claims it's still "isValid"

thick gust
#

GodCipher understood it

tender shard
#

but its gone

#

just try it

thick gust
#

What i want

#

The word earth is flat cuz he was not using any uppercase.

#

LUL

glossy scroll
tender shard
#

and yeah it's a bug, I think that too

#

I spent hours trying to get it to work

#

somehow the blocks always disappeared but I still had a "isValid" Entity object

#

it was really strange

#

I gave up after some hours

hybrid spoke
#

just use an armorstand

thick gust
#

NO GODCIPHER

glossy scroll
#

is there a method you're using to incrrease the time it's alive?

tender shard
thick gust
#

-.-

#

Armorstands heads look smaller than steves head

#

Thats not cool!

#

It looks shit

tender shard
#

and bukkit didnt notice it somehow

#

idk

glossy scroll
#

im asking what did you do to extend its life

tender shard
#

I wanted to make some "fake blocks" like walls where you can walk through

thick gust
#

I will try isAlive, isRemoved and isValid now...

hybrid spoke
tender shard
#

I set it to 0 or 1 every few seconds

#

I also called all events regarding entity death etc

thick gust
#

@tender shard just set it to Integer.MaxValue :kappa:

tender shard
#

then it will be dead instantly

thick gust
#

Consider the kappa emote

#

I was kidding

#

I know that ofc

tender shard
thick gust
#

xD

hybrid spoke
#

just spawn a new one every tick

thick gust
#

Yeah i dont boost the server

hasty prawn
thick gust
#

I am not rich.

tender shard
glossy scroll
#

yea the falling block will despawn after 600 ticks regarldess it looks like

thick gust
#

But that would be ineffecient

#

Spawning a falling block every tick

glossy scroll
#

that's 30 seconds

thick gust
#

That would cause laags for lots of players

tender shard
#

I managed to get it to work to exist a random amount of time, from 30 seconds up to sometimes 5 minutes

#

but at SOME POINT it was always just gone

thick gust
#

You gotta make it as "unlaggy" as possible

hybrid spoke
#

what about packets

thick gust
#

@tender shard No capslock XD

hybrid spoke
#

the falling block doesnt have to exist

thick gust
#

BigBrain GodCipher

#

XD

tender shard
glossy scroll
#

Packets will still mean collidable

#

he wants blocks that arent collidable

thick gust
#

There is no isAlive method for ArmorStands @glossy scroll

tender shard
#

falling blocks are never collidable

thick gust
#

they are.

thick gust
#

If fallingblocks collide with walls, they disappear.

glossy scroll
#

not isAlive

#

isAlive is NMS

thick gust
#

Okay.

hybrid spoke
thick gust
#

If they collide with ground, they occur a spawning block. and disappear ofc lol

#

I dont wanna work with packets

#

I want it to be uncomplicated

tender shard
thick gust
#

I hate packets

hybrid spoke
thick gust
#

I try avoid those shitty things ._.

glossy scroll
#

@tender shard this is likely what is causing it to despawn

#

if (!this.level.isClientSide && (this.time > 100 && (blockposition.getY() <= this.level.getMinBuildHeight() || blockposition.getY() > this.level.getMaxBuildHeight()) || this.time > 600))

thick gust
#

Shaddup godcipher

#

xD

glossy scroll
#

eh but that would describe what you're talking about either...

tender shard
glossy scroll
#

....

#

that was 1.15

#

we're on 1.18 now silly

tender shard
#

@thick gust is the one who needs falling blocks to be persistent

glossy scroll
#

things change

tender shard
#

it was either 1.16 or 1.17

thick gust
#

Does this sentence makes sense?: "Your balloon collided and blew up!"

tender shard
#

probably 1.16

glossy scroll
#

I would use ``` @Override
public void setTicksLived(int value) {
super.setTicksLived(value);

    // Second field for EntityFallingBlock
    getHandle().time = value;
}````
thick gust
#

I am bad at grammar lol

hybrid spoke
#

so the mechanism would be the same. spawn again after dead. now your choice if you wanna impact the servers performance or just kill the computers of the players

tender shard
glossy scroll
#

right but that was on an outdated version

#

you've not tested this in 1.18

thick gust
#

@tender shard Call nasa, they will use ur amount of code * 5 xD

#

Guys does this sentence makes sense: Your balloon collided and blew up!

#

It does, does it?

tender shard
#

yes

thick gust
#

Aight

#

Thx

#
    @EventHandler
    public void onPlayerMove(PlayerMoveEvent event) {
        Player player = event.getPlayer();
        if(hasBalloon(player)) {
            if(getBalloon(player).getFallingBlock().isDead()) {
                removeBalloon(player);
                player.sendMessage(ChatColor.RED + "Your balloon collided and blew up!");
                return;
            }
            getBalloon(player).getEntity().teleport(player.getLocation().add(0, getBalloon(player).getHeight(), 0));
        }
    }
#

Easy peasy.

#

Don't judge my methods.

hybrid spoke
#

Black magic stabbed your balloon and threw the remains into a black hole.

thick gust
#

Big brain move.

glossy scroll
#

what's isDead?

thick gust
thick gust
hybrid spoke
#

make a premium feature

#

where a black hole spawns

thick gust
#

Cuz getFallingBlock() returns a FallingBlock.

tender shard
#

I have to ask again - are there any other damageable, wearable items?

^.*_HELMET$
^.*_CHESTPLATE$
^.*_LEGGINGS$
^.*_BOOTS$
^TURTLE_HELMET$
^ELYTRA$
glossy scroll
thick gust
#

@hybrid spoke Good one i will invent such a feature xD

glossy scroll
#

its generally more foolproof

thick gust
#

Aight i try that one and if it does not work i will try isDed 😛

#

@hybrid spoke Any suggestion on how to simulate a black hole? KEKW XD

tender shard
thick gust
#

I just won't sleep now. I gotta stand up at 7 am to get ready for the school but idgaf

#

I just keep code plugins

#

😉

thick gust
#

LMAO

#

Need to create an explosion at the fallingblocks usual location, u know, where it disappeared.

hybrid spoke
thick gust
#

Then i need to send a message to the player: MAGIC REMOVED YOUR BALLOOOM KABOOM! XD

#

Balloom lulw

hybrid spoke
#

no do the black hole

thick gust
#

Balloons look stoopid

hybrid spoke
#

then you can do custom balloon skins like these:
Asteroid
Planet
Star
White Dwarf
Photons

glossy scroll
#

photon wtf

#

what would that even look like lmfao

sterile token
#

A class extending multiple classes? Looks like not possible

hybrid spoke
hybrid spoke
#

^chaining

thick gust
#

KEKW XD

hybrid spoke
#

well

thick gust
#

GodCipher is creative in a different way

hybrid spoke
#

i like the idea

thick gust
#

U have autism

#

Like yassuo

hybrid spoke
#

i am just a god

ivory sleet
sterile token
thick gust
#

That's you GodCipher

sterile token
hybrid spoke
#

parameter default?

sterile token
#

yeah

hybrid spoke
#

you mean the default keyword

sterile token
#

default void/string

sterile token
hybrid spoke
#

yeah

sterile token
#

They are called keyboard so?

hybrid spoke
#

default is a keyword

sterile token
#

Yeah like:

abstract, void, protected, private?

hybrid spoke
hybrid spoke
#

now i have to make a universe balloon plugin with a black hole

sterile token
#

Like emoticons/gadgets?

thick gust
#

@glossy scroll Well isDead works.

hybrid spoke
#

with fancy fire magic

#

spitting lava

sterile token
hybrid spoke
#

exploding into a radius 5 black hole absorbing the world

hybrid spoke
glossy scroll
#

I think this is an

#

?xy

undone axleBOT
sterile token
#

Btw

#

Its the same

hybrid spoke
#

chain it

#

or make the other ones interfaces

glossy scroll
#

thats not realyl

#

what

#

ok.

#

you need to eb more specific why you need to extend 2 classes

hybrid spoke
#

^

#

we dont know your goal

glossy scroll
#

maybe we can help you with this class structure you're trying to make

hybrid spoke
#

we can just guess from here on

glossy scroll
#

becuase "making one an interface" is a solution, but could really be limiting

hybrid spoke
#

also IS-A is not always a good solution

#

(always) try to go for the HAS-A

glossy scroll
#

we may find that it's a good solution, but we dont know for sure

sterile token
#

Sorry for bad english

thick gust
#

I freaking hate FallingBlocks..

glossy scroll
#

not necessarily ?

tender shard
glossy scroll
#

@sterile token why do you need to extend two classes

sterile token
hybrid spoke
#

verano, show us what you have, what you want to be inheritated and why

sterile token
tender shard
#

it's simply not possible to extend two classes. you could just create an interface for your two "super classes", make class A impement interface IA and B implement interface IB, then your third class implements both, IA and IB

sterile token
#

I have created that class with methods for enable/disable and then for getting main class instaead. Of doing MainClass#getPlugin() on every class. Im planing to extend that class on every class

hybrid spoke
#

yeah well no

#

dont do that

sterile token
#

Okay

tender shard
#

erm that makes no sense at all

sterile token
#

Any other idea?

tender shard
#

just create a static getter for your main instance

hybrid spoke
#

thats even more worse than singleton

tender shard
#

just do this

sterile token
thick gust
#

@tender shard Just make ur instance variable public instead of private, and u can save those 3 lower lines.

#

@tender shard As easy as that 😛

hybrid spoke
tender shard
tender shard
#

how?

#

it has to be static. how do you want to make it static and final?

#

it cannot be final

thick gust
#

@hybrid spoke The fuck is that

tender shard
#

I bet 20€ you can't make it final AND static 😛 and if it's not static, it's worthless

ivory sleet
#

It’s possible with some hacky shit iirc

tender shard
#

how?

ivory sleet
#

a nested class

tender shard
#

you got an example?

ivory sleet
#

And then in that nested class you could use JavaPlugin::getPlugin statically

#

and then you let the enclosing java plugin derivative just reference that static variable from the nested class

#

I think

thick gust
#

Lmfao xD

#

You bet money on that

#

Less goo oxD

tender shard
#

well but then it would be a field of that nested class

hybrid spoke
#

or wrap it 5Head

ivory sleet
#

Yea well point is, it’s actually possible to have a static final field pointing to your plugin instance (in plugin derivative ofc) altho it gets ugly

tender shard
#

yeah sure, I have private static final myPLugin fields in many classes, but the bet was to make THIS variable static final 😄

#

the one that actually belongs to the main class

ivory sleet
#

Yeah as said

#

It’s totally possible with some class loading hacks like using a nested class

thick gust
#

Guys, can you cancel a leash drop, when an entity gets automatically unleashed just by being too far away from a player?

#

Cuz as far as I know, the PlayerUnleashEntityEvent only gets triggered, if the player unleashes the entity, not if it gets unleashed automatically cuz of the distance between the player and the entity.

tender shard
#

@thick gust

#

really ffs check the java docs

#

I know the answer and you could easily do so too within 30 seconds

#

google the event you mentioned

#

(I am being a bit unfriendly because he told me in DMs that always asks BEFORE checking the java docs because he says it's faster to ask than to check the docs)

warm light
#

Anyone can tell me how the drop chance work in spigot?

tender shard
warm light
#

Anything. Just asking for how to make chance system

thick gust
#

does this trigger by automatic unleash or by player unleash? or both?

ivory sleet
tender shard
thick gust
#

@tender shard Aight

ivory sleet
#

But yeah almost the same, class loading is a bit magical and that’s perhaps why it works

tender shard
#

but I'd really love to see some code for the nested class hack

#

just out of interest

ivory sleet
#

I will write it on phone rn

tender shard
#

I'll slam it into intellij and test it right away 🙂

thick gust
#

Can you cancel the item drop of the leash when EntityUnleashEvent triggers?

ivory sleet
#

class Bob extends JavaPlugin {
static final Plugin p = Sam.p;
static class Sam{
static final Plugin p = Bob.getPlugin(Bob.class);
}
}

thick gust
ivory sleet
#

iirc

ivory sleet
#

Yeah hope it works now so I haven’t just been lying

thick gust
#

Just cancel the event when the distance of the events entity to the player is higher than 10?

#

So that will cancel the leash drop? 😼

hybrid spoke
#

thats how a leash works

tender shard
hybrid spoke
tender shard
#

(according to the docs, havnt tried)

thick gust
#

@hybrid spoke somehow it's not because of the leash, cuz if the fallingblock disappears, and there's only the chicken left being leashed to the player, then the teleport works just fine (WITH THE LEASH STILL!)

#

That's the weird thing i do not understand..

tender shard
#

@ivory sleet

public class Test extends JavaPlugin {

    private static final Test instance = Hack.p;

    static class Hack {
        static final Test p = Test.getPlugin(Test.class);
    }
}
[03:33:49 INFO]: Loaded 7 recipes
[03:33:50 ERROR]: Could not load 'plugins\Test.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: java.lang.ExceptionInInitializerError
...
ivory sleet
#

Hmm

#

I’m sure there was some way

tender shard
#

hm no idea 😄

#

I highly doubt it tbh

#

it's just not logical

#

all static things get inited before there is an instance

#

and it needs an instance

ivory sleet
#

Yeah, it sounds illogical

#

I’ll test it tomorrow and see if I can figure some bizarre way out perhaps lol

hybrid spoke
#

i mean you could wrap it and set the instance in the wrapper later. but then the instance would not be final

narrow pewter
#

What are the commands? I just installed it on a server and someones testing it for me

tender shard
hybrid spoke
#

but final

tender shard
#

didn't you say yourself it would NOT be final?

hybrid spoke
#

yeah but not visually

#

the indirect instance (wrapper) would be final

#

goal achieved

thick gust
#
    @EventHandler
    public void onUnleash(HangingBreakEvent event) {
        if(balloons.containsValue(event.getEntity())) {
            event.setCancelled(true);
        }
    }

@hybrid spoke this does not work, and I added the entity into the hashmap called balloons before the event actually triggers at all, including the player in the hashmap ofc, but the player does not matter in this case cuz the HangingBreakEvent does not even save the player (doesn't have a getPlayer() method)

#

The leash still gets dropped..

hybrid spoke
#

yeah probably just like alex said

thick gust
#

And EntityUnleashEvent does not have setCancelled Option

hybrid spoke
#

have to be on a fence

hybrid spoke
thick gust
#

Can't you cancel it in any other way

#

You dont understand

#

If the enemy is far enough away from the player the leash gets dropped automatically

#

I can respawn it as often as i want

#

It does not cancel the leash drop lol

hybrid spoke
#

so just check a tick later for items around material of leash and remove, but thats very hacky and nasty

tender shard
#

check EntityDeathEvent

thick gust
#

?

tender shard
#

when the leash breaks, an entity "dies" lol

thick gust
#

the entity does not die..

tender shard
#

what do you want to achieve?

thick gust
#

wait

tender shard
#

make the leash unbreakable?

hybrid spoke
#

not sure but a leash could have setInvulnerable

thick gust
#

the leash shall not drop when this happens.

tender shard
thick gust
#

wait wrong video

#

xD

faint sage
thick gust
#

this is the right video.

thick gust
#

the balloon gets respawned cuz when the player moves, i check if the entity (the chicken) is unleashed.

#

in this case it was unleashed many times, so the balloon got respawned many times.

tender shard
#

chek EntityDropItemEvent

thick gust
#

but the respawn does not cancel the leash drop event

faint sage
thick gust
#

entitydropitemevent will only consider items which actually the enemy held in his hand doesn't it?

#

I am unsure if it covers the leash as well...

#

I just give it a try..

#

gotta drink a coffee very soon, i'm getting tired xD

#

whats EntityType.LEASH_HITCH and EntityType.LEASH_KNOT

#

respectively what's the difference between those 2 EntityTypes? 😼

tender shard
#

there is no LEASH_KNOT entity type

thick gust
#
    @EventHandler
    public void onEntityDropLeash(EntityDropItemEvent event) {
        if(balloons.containsValue(event.getEntity())) {
            event.setCancelled(true);
        }
    }
#

Does not work...

#

What else shall I try*

#

I was already searching through an entire library to get so far.

#

Creating balloons in minecraft is so annoying without making a mod lol

#

...

tender shard
#

ItemSpawnEvent will definitely work

#

but you'll have to keep track of WHY a leash itemstack spawns

vocal cloud
#

If they store on create the entity I imagine they can just check if it's contained like they already do

tender shard
#

all it has is an item

vocal cloud
#

Hmmm that is problematic.

#

Can you set it so a lead on break doesn't spawn anything? Modify it before it breaks?

thick gust
#

I don't want to try out 10 different events unless I know what they actually do

#

So how can I get this done using the ItemSpawnEvent? 😼

tender shard
#

when a leash dies, add the location to a set. when itemspawnevent triggers, check if it's roughly (+/- 20 blocks) inside the location of your set. if yes, cancel itemspawnevent. then remove the location from your set

thick gust
tender shard
#

that's how my Drop2InventoryPlus plugin works

thick gust
#

U truly have a plugin for every shit right

tender shard
thick gust
#

Soon you develop a plugin for deleting a server XD

tender shard
#

leash_knot = leash_hatch in nms

thick gust
#

Aight

#

So leash_knot is what i'm looking for?

#

A regular leash?

tender shard
#

no, nothing of those

#

leashes are no entities

#

they are "nothing"

#

they actually don't exist

#

they only become real when they drop

#

so with "when a leash dies" i meant the leash disappear event, forgot how its called

#

the one with the DISTANCE enum

thick gust
#

For fuck says

#

Which event shall I use now

#

I was jumping from event to event for like 10 times now

#

Decide pls..

tender shard
#

pay me 50€ and it'll be done in an hour 😛

thick gust
#

No ..

#

I am poor

#

Iam minus on my bank account

#

I already paid u 5€ once per paypal

tender shard
thick gust
#

Don't be that greedy

tender shard
#
  1. listen to this event
thick gust
#

I ALREADY HAD THAT SHIT

#

I DONT BEAT IT WITH THAT...

tender shard
#

okay then ask someone else for help, I was just about to give a detailled explanation

thick gust
#

Nonoonnoo

#

Pls

#

Tell me your detailed explanation pls

#

Dear mfnalex pls

#

I knee down in front of u

#

And beg u

#

Pls

#

Do that

tender shard
#
  1. save the center location between the player and the other end of the leash in a set
#
  1. listen to ItemSpawnEvent
#
  1. check your set of locations. if the location of new spawned item is within +/- 20 blocks of one location in your set, cancel the event.
thick gust
#

gosh so many events

tender shard
#
  1. remove the location from your set
#

it's two events bruh

thick gust
#

i already used 3 tho

tender shard
#

it's like 20 lines in total

thick gust
#

gotta removeall of them and only use 2 now

#

..

vocal cloud
#

Wouldn't you be able to cancel the event and then delete the leash via some other method?

thick gust
#

That was my thought @vocal cloud

thick gust
#

cancel which event*

#

đŸ€“

tender shard
#

I assumed that he already tried that, because in the video he sent the leash was persistent

thick gust
#

tried wut

#

I thought that wouldnt work

tender shard
#

you didnt even try to cancel PlayerUnleashEntityEvent?!

thick gust
#

no no i did XD

#

LKMAO XD

vocal cloud
tender shard
#

that would be the first thing I would have tried ffs

thick gust
#

I try that out real quick hold on

#

lol

#

xDD

tender shard
#

I thought all this discussion started because that didnt work

thick gust
#

I just tried it

#

It does not work.

#

No things to worry about

tender shard
#

then do what I said

thick gust
#

That was a thing of 2 minutes

#

I will, great master alex.

#

Just gotta scroll all the way up to ur 5 mui importanto steps

#

hold on 😛

vocal cloud
#

I'd test it myself but

thick gust
vocal cloud
#

That's something you really don't want to do

thick gust
#

Ryzen 7 2700X POG

#

I got i5-10400f

tender shard
thick gust
#

Better performance i assume 😄

vocal cloud
#

If canceling the event doesn't work then you're going to have to figure something else out

thick gust
#

Isn't a set like a collection, and an arraylist or a regular list?

#

You got the add, contains and remove method.

thick gust
tender shard
thick gust
vocal cloud
#

So I'm confused to as if canceling it works or not

thick gust
tender shard
thick gust
tender shard
#

the center location is only one location

thick gust
#

Save nanana location AND the other end of the leash in a set

tender shard
#

A ------ center ------- B

#

just save the player location for now

thick gust
#

I am confused as fuck

#

I did.

#
    @EventHandler
    public void onUnleash(PlayerUnleashEntityEvent event) {
        if(balloons.containsKey(event.getPlayer())
                || balloons.containsValue(event.getEntity())) {
            locations.add(event.getPlayer().getLocation());
        }
    }

    @EventHandler
    public void onLeashSpawn(ItemSpawnEvent event) {
        if (event.getLocation().distance(locations.)) {
            event.setCancelled(true);
        }
    }
thick gust
#

Wouldn't a map with the player and a location be more efficient?

#

Cuz u could instantly get that location instead of looping through all other false locations u get what i mean?

thick gust
#

I still don't get why we're trying to use a set...

tender shard
thick gust
#

That makes less sense than using a hashmap/map/dictionary

tender shard
thick gust
#

Okay we will use a set then i guess..

#
    @EventHandler
    public void onUnleash(PlayerUnleashEntityEvent event) {
        if(hasBalloon(event.getPlayer())) {
            locations.add(event.getPlayer().getLocation());
        }
    }

    @EventHandler
    public void onLeashSpawn(ItemSpawnEvent event) {
        for(Location loc : locations) {
            if (loc.distance(event.getLocation()) > 20) {
                event.setCancelled(true);
            }
        }
    }
#

Correct?

tender shard
#

you want to check if the distance is SMALLER than 20

unreal quartz
#

No shame in being small around here

lavish hemlock
#

Distance doesn't matter /j

tender shard
#

@thick gust I got it to work with like 20 lines of code

ivory sleet
#

?ban @quaint mantle discord nitro scam link

undone axleBOT
#

Done. That felt good.

vocal cloud
#

Damn speedy with the bans

thick gust
# tender shard <@!272454873512017931> I got it to work with like 20 lines of code
    @EventHandler
    public void onUnleash(PlayerUnleashEntityEvent event) {
        if(hasBalloon(event.getPlayer())) {
            locations.add(event.getPlayer().getLocation());
        }
    }

    @EventHandler
    public void onLeashSpawn(ItemSpawnEvent event) {
        for(Location loc : locations) {
            if (loc.distance(event.getLocation()) < 20) {
                event.setCancelled(true);
            }
        }
    }

this is what i got so far..

#

time to test dat shit

#

with a bunch of chewy chocolate chip cookies đŸȘ

#

i bet it works

tender shard
#

haven't tested but

#

this should do it

#
package de.jeff_media.test;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityUnleashEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.HashSet;
import java.util.Set;

public class Test extends JavaPlugin implements Listener {

    private final Set<Location> brokenLeads = new HashSet<>();
    private static final int maxDistance = 20;

    @Override
    public void onEnable() {
        Bukkit.getPluginManager().registerEvents(this, this);
    }

    @EventHandler
    public void onUnleash(EntityUnleashEvent event) {
        if(event.getReason() != EntityUnleashEvent.UnleashReason.DISTANCE) return;
        brokenLeads.add(event.getEntity().getLocation());
        Bukkit.getScheduler().runTaskLater(this, () -> brokenLeads.remove(event.getEntity().getLocation()),1L);
    }

    @EventHandler
    public void onLeadSpawn(ItemSpawnEvent event) {
        if(event.getEntity().getItemStack().getType() != Material.LEAD) return;
        for(Location loc : brokenLeads) {
            if(!loc.getWorld().equals(event.getLocation()).getWorld()) continue;
            if(loc.distanceSquared(event.getLocation()) >= maxDistance*maxDistance) continue;
            event.setCancelled(true);
            return;
        }
    }

}

buoyant viper
#

lole

tender shard
#

of course you have to check in onUnleash whether it's a normal lead or one of your ballong things

thick gust
#

No one. Literally no one.
mfnalex: "Here a bunch of code I just wrote spontaneous. I haven't tested it yet, but it has to work, cuz I wrote it. B)"

#

xD

tender shard
#

it should work at least

thick gust
#

How do I initialize a Set?

vocal cloud
#

New HashSet

thick gust
#

Thanks mike

vocal cloud
#

Well protocallib means packets so if you want to do it manually then you need to learn packets.

#

Or NMS

thick gust
#

LULW

vocal cloud
#

Then you should be able to do it if youre pro what?

thick gust
#

What the fuck am I missing?

#

I am doing something wrong but what is it..

#
public class BalloonManager implements Listener {

    private static HashMap<Player, Balloon> balloons;
    private static Set<Location> locations;
    public BalloonManager() {
        balloons = new HashMap<>(); locations = new HashSet<>();
    }

    public static void createBalloon(Player holder, ItemStack itemStack, double height) {
        Balloon balloon = new Balloon(holder, itemStack, height);
        balloons.put(holder, balloon);
    }
    public static void removeBalloon(Player holder) {
        if(hasBalloon(holder)) { balloons.get(holder).remove(); balloons.remove(holder); }
    }
    public static boolean hasBalloon(Player holder) { return balloons.containsKey(holder); }
    public static Balloon getBalloon(Player holder) { return balloons.get(holder); }

    public static void recreateBalloon(Player holder) {
        ItemStack stack = getBalloon(holder).getBlock();
        locations.add(holder.getLocation());
        removeBalloon(holder);
        createBalloon(holder, stack, 5.8);
    }

    @EventHandler
    public void onPlayerMove(PlayerMoveEvent event) {
        Player player = event.getPlayer();
        if(hasBalloon(player)) {
            if(getBalloon(player).getFallingBlock().isDead()
                    || !getBalloon(player).getEntity().isLeashed()) {
                recreateBalloon(player);
                return;
            }
            getBalloon(player).getEntity().teleport(player.getLocation()
                    .add(0, getBalloon(player).getHeight(), 0));
        }
    }

    @EventHandler
    public void onUnleash(PlayerUnleashEntityEvent event) {
        if(hasBalloon(event.getPlayer())) {
            locations.add(event.getPlayer().getLocation());
        }
    }

    @EventHandler
    public void onLeashSpawn(ItemSpawnEvent event) {
        for(Location loc : locations) {
            if (loc.distance(event.getLocation()) < 20) {
                event.setCancelled(true);
                locations.remove(loc);
            }
        }
    }
}
tender shard
#

it's working fine for me, just tested it

#
public class Test extends JavaPlugin implements Listener {

    private final Set<Location> brokenLeads = new HashSet<>();
    private static final int maxDistance = 40;

    @Override
    public void onEnable() {
        Bukkit.getPluginManager().registerEvents(this, this);
    }

    @EventHandler
    public void onUnleash(EntityUnleashEvent event) {
        if(event.getReason() != EntityUnleashEvent.UnleashReason.DISTANCE) return;
        brokenLeads.add(event.getEntity().getLocation());
        Bukkit.broadcastMessage("UnleashEvent");
        Bukkit.getScheduler().runTaskLater(this, () -> brokenLeads.remove(event.getEntity().getLocation()),1L);
    }

    @EventHandler
    public void onLeadSpawn(ItemSpawnEvent event) {
        Bukkit.broadcastMessage("SpawnEvent");
        if(event.getEntity().getItemStack().getType() != Material.LEAD) {
            Bukkit.broadcastMessage("Not a lead");
            return;
        }
        for(Location loc : brokenLeads) {
            Bukkit.broadcastMessage("Checking broken lead Location: " + loc);
            if(!loc.getWorld().equals(event.getLocation().getWorld())) continue;
            Bukkit.broadcastMessage("Distance: " + loc.distanceSquared(event.getLocation()));
            if(loc.distanceSquared(event.getLocation()) >= maxDistance*maxDistance) {
                Bukkit.broadcastMessage("Distance too large!");
                continue;
            }
            Bukkit.broadcastMessage("Cancelled");
            event.setCancelled(true);
            return;
        }
    }

}

vocal cloud
tender shard
#

I just notice I am using EntityUnleashEvent, not PlayerUnleashEntityEvent @thick gust

#

maybe that's the problem

#

anyway you HAVE to add a check for the distance thing, otherwise you get a ton of errors when leads break in other worlds

thick gust
#

U SAID USE PLAYERUNLEASHEVENT..

tender shard
#

also you want to use distanceSquared instead of distance to avoid calculating square roots

#

I have no idea whether that makes a difference, I just entered LeashEvent and used the first thing intellij suggested to me

thick gust
#

if (loc.distance(event.getLocation()) < 20) {
event.setCancelled(true);
locations.remove(loc);
}

#

THis is where i tested it

thick gust
tender shard
#

all I can say is that when you copy/paste my code, it'll work

thick gust
#

wow.. xD

#

I don't want to skid

#

U know

#

I wanna learn something from that

tender shard
#

btw why was the "free nitro" dude banned?

thick gust
#

And build my own code