#help-development
1 messages · Page 1880 of 1
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.
but libraries can be loaded manually
Wdym
you can load libraries from java code
it's a bit strange operation and made difficult by jave 9 but possible
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.
yea (I can load libary from JDK libary)
Well the problem is that the JDK's code is
- Proprietary (although this depends on what part of the code)
- Platform-dependent
and I'd like to avoid giving arguments
The problem with 2 is that it means your plugin also becomes platform dependent.
oke I can load ASM libary đ correct
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.
which is true, but I don't like making .jar files that are too big
I prefer ClassLoader
This is incredibly small.
like so, but it accumulates
You still haven't explained why you need ASM.
although I thought it was smaller đ
oke
I am afraid of another discussion on this topic
disable phycics gravel, sand etc
Use Google
This is highly reminiscent of the
?xy
Asking about your attempted solution rather than your actual problem
I saw it about a year ago
but
EntityChangeBlockEvent don't work perfect
Well I can't help any further đ€·ââïž
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
erm
why is this nullable
declaration: package: org.bukkit.event.player, class: PlayerBucketEvent
wouldn't it always return an empty bucket?
It's not nullable?
How do you turn a String[] args, itno a regular String?
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.
Youâd have to join them all
String.join
Read the docs
how would i wait for a task to finish before proceeding?
This is what I have so far: https://pastebin.com/vaGWWgtD
This is the timer class https://pastebin.com/sZLP95dB
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
Add a consumer to the class that gets called at the end of the timer
Would you give me an example without spoonfeeding?
what does the .setRemainingAir method do of the Chicken class? đź
RTMFD
LivingEntity#setRemainingAir(int ticks)- Sets the amount of air that the living entity has remaining, in ticks.
amount of time before drowning I believe
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?
PlayerItemConsumeEvent sucks hard
you have to use something else
I don't remember what it is
but you can't just grab it as a File
looks like we had the same idea
I would use getResourceAsStream @fervent robin
Then you can pass that in the scanner constructor
is your file included in your .jar?
did you check with winrar / winzip / etc?
is it at the root folder of your .jar?
We answered their question i think?
you can't just use new File() if it's inside your .jar
Yes⊠weâve said this
kk
what error do you get
does the net.minecraft.world.item.ItemStack class not have a getTag() or a hasTag() method anymore in 1.18?
I believe PDC is the replacement for that?
what version of java
java 8?
ig
whats the file structure of this again
pdc?
You might need to do /me/name/mypackage/blockedwords.txt
PersistentDataContainer
PersistentDataContainer
ah
and how would i go about grabbing the entire nbt structure of an item from its pdc
is he trying to get a resource from src/main/resources?
The PDC is an additional layer not an NBT replacement.
no
just a resource in a package
then how would i get the nbt of an itemstack now if getTag() is removed for nms itemstacks?
why tho, use the maven generated resource folder
thats not the question theyre asking
that's a better practice
What do you need it for? There might be an alternative way to achieve what you want, depending.
trying to create a bungeecord Item from an itemstacks nbt data to display in chat as a HoverEvent
incheresting
it never had. only materials have tags
oh wait
you talk about NBT kinda tags?
would itemstack.serialize help?
do you need it to be in the same package as the class itself or just need it in the packaged jar
You know, I thought I saw something similar to your issue and the result was just to use ItemMeta and put it in a TextComponent.
alright
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?
i think i tried that and it didnt work but ill try that again just in case im remembering wrong
they already have one
okay pur your file in there
Using ShapedRecipe().setIngredient() in the ingredient, what is the char
The char is a placeholder. You will use it to mark the spot in the grid.
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());
}
why do you do your stuff so complicated
me?
everyone here trying to read the file from the .jar
that's what he wanted
I am lost, idk how that would help me. after looking up youtube videos and tutorials on this, it ends up iterating through the Util.getCommands(). Either that or I am doing it wrong. code i came up with https://pastebin.com/aZzSmSPn
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;
}
Creating a HoverEvent with an item to display takes an ItemTag, and an ItemTag requires a string version of nbt
ItemMeta does not have a toString() method
okay mr regex maniac, ||wish I knew regular expressions cries||
It's actually a good approach
Yea, but I meant using the inner methods, like getDisplayName() and getLore(). It would require some more variables, but you would have everything about that item right there.
you realize that 90% of it is something else right?
to read a file all you need is this:
InputStream input = getResource("regex/" + name + ".txt");
try(InputStream input = getResource(fileName);
BufferedReader reader = new BufferedReader(new InputStreamReader(input))) {
reader.lines() // <-- Stream<String>
}```
so id have to manually construct a string of nbt?
do you know of any resources for what an itemstacks nbt looks like?
reader.lines() is now a stream of strings. to turn it into a string list, you can easily do this:
try(InputStream input = getResource(fileName);
BufferedReader reader = new BufferedReader(new InputStreamReader(input))) {
List<String> linesInFile = reader.lines().collect(Collectors.toList());
}
+1
otherwise
ClassLoader classLoader = getClass().getClassLoader();
InputStream inputStream = classLoader.getResourceAsStream(fileName);
Not necessarily. Your end goal is a chat message correct? You would just need a text component and put the necessary information in it. You can use newlines in TextComponents, so for example, your first line would be the item name, second line would be item lore, third line would be enchantments, etc etc.
That would be for your hover, your main message would be the item name.
just updated my library to include it like this https://github.com/JEFF-Media-GbR/JeffLib/blob/492cd6457f09d2c8b3838f18e771a7a40c869d49/core/src/main/java/de/jeff_media/jefflib/FileUtils.java#L85
ouou import lombok.SneakyThrows need to try lombok sometime
well ill try that and see how it goes
This way you donât have to have to worry about any reflection or deal with weird workarounds.
lombok is awesome đ
for many things, not for everything
sneakythrows must be used carefully
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
otherwise you'll be in hell for some hours trying to figure out why something isnt working and where
lmao
ah
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!
oh
you can use that without try/catch
because it only throws a RuntimeException
those do not have to be declared in the method signature
I might need to look into it a bit more
of course you will still get an exception if you use this code. It just removes the need to actually have to wrap your code into try/catch
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 đ
and lombok has a ton of other useful features, for example @ Data is awesome (kinda unnecessary now that record classes exist, but not everyone can use java 16 etc): -> https://blog.jeff-media.com/java-data-classes-using-records-or-lombok/
JEFF Media
Would someone else be willing to help me out?
I don't really understand what you're trying to do
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
you'll want to read your whole string list, then create an async task
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
|| trust me try it without sync scheduled task, trust ||
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 ?
sure it appear in /pl and /plugins
I just told you via DM
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..
getEquipment
declaration: package: org.bukkit.entity, interface: LivingEntity
beat me to it
Yeah most entities donât actually have a proper inventory like players and some tile states, just a container.
thx
My server doesnt like it when i run stuff asynchronously https://i.imgur.com/FwLPuh3.png
May I ask what in the world youâre doing lol
this
That's why I told you to run API stuff in a synced thread
i forgot the sync part
Are there any other wearable items that normally can't be stacked?
^.*_HELMET$
^.*_CHESTPLATE$
^.*_LEGGINGS$
^.*_BOOTS$
^TURTLE_HELMET$
^ELYTRA$
im testing it now
Yeah itâs a really easy fix, simply use runTaskTimer or (runTaskLater, runTask), so not the ones with the Asynchronously suffix
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
no
?
that does not even make sense
Invulnerable = IMMORTAL!
@tender shard YOu could've told me that wayyy earlier! XD
Hmm yeah it sounds like that but that just ainât how itâs done
you could have said that you were testing in creative lol
creative mode changes many things
For the love of god i was thinking all the time its caused by my spigot build
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
bruh
I stop using paper now cuz its ugly u gotta do /rl and then confirm it like wtf?! XD
oh god that format lol
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
Read my damn message potato (:
BedPotato
it works, just not async
1 after another
i got the runtask in there as you can see
Yes but you donât need to async that
you are still using dispatchCommand async
Who wrote this lol
And you donât need to use Thread sleep neither
Does invulnerable work in all gamemodes except creative?
âDoes not workingâ
yes
nice
I wrote it and Conclure changed it a bit đ
It was either me or Alex lol
most people who don't give error messages use kinda RIP english
ok then what do i do? i tried what mfnalex told me to and it yielded same result
produced..
I wrote "It is not working" đ
Oh I think I copied the text from discord
wait i know why it does not work XD
anyway, it's accurate lol
ill remove the runtaskasync as you have said
(:
most people say "why my code not doesn't working"
Yes bed potato and whatâs up with the Thread sleep
this
not doesnât work, lul
that would work fine
no you didnt
and now conclure is telling me to remove it
you used a java Timer
which runs on the same thread
I said to use the bukkit scheduler
That looks like a really nasty way of fucking with bukkit schedulerâs cached thread pool bed potato
to run stuff synced from your async task
i am using a bukkit schedule
can you leash armorstands?
I donât think so
if you would have copied my code it would have worked, but you decided to replace my runTask with a java Timer
The thread?
why don't you just try it
is there a bukkit thread method i can call or is that not what you are referring to
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 đ
is there an event for fallingblocks disappearing by collision?
yes, one sec
of course of course of course
try this https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityChangeBlockEvent.html
declaration: package: org.bukkit.event.entity, class: EntityChangeBlockEvent
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
it does not describe what i'm trying to access..
why? an Entity changes a block
nope
you got it wrong
he's talking about the entity despawning
not the block becoming an entity
yea..
works fine @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
loop over it and check if it still exist
there's no event for that
a fallingblock disappears by colliding to any blocks. that includes a sideways collision.
you could use GenericGameEvent
does not work. I tried for hours to get something like this working a few months ago
and listen for ENTITY_KILLED
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
what's that?
yes
what the bukkit events cant reach or the same
arent shulkers a 1.12 thing
nah
oops
end was 1.8
wasn't end beta 1.8 / release 1.0?
shulkers were 1.9
btw... WHY THE FUCK IS THERE STILL NO VANILLA WAY TO ACQUIRE BUNDLES
because bundles suck
no they are awesome
Do they even exist in the game mfnalex?
they dont solve a problem
yes, since 1.17
you can even access them through spigot without any problems
Damn
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
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
GenericGameEvent is 117
otherwise
declaration: package: org.bukkit.inventory.meta, interface: BundleMeta
Or will it probably stay the same such as others
you need to use Entity.isValid
wait so if the fallingBlock disappeared, however by falling down or disappearing in air, it will return with isValid false right?
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?
yep, it should
and if it is still there (it never disappeared ofc, if its still there), then it will return isValid true?
doesn't work. they are still valid even when they are gone
falling blocks are weird
isValid checks for isDead
more like stupid NMS falling block
Couldnt u just check if the fallingBlock is null?
So that kind of tells if the fallingBlock disappeared
if it would be null, isValid would throw an NPE
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
once you have an entity reference, it will never become null
Player dribbles the system by quitting
we talked about isDead
LMAO XD
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
those are ALL used in the falling block entity class
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
Can i use any of those 2
i am assuming that is what you meant? @tender shard
isValid should cover it
Spigot = Bukkit with more features
spigot is the bukkit continuation
But mfnalex said isValid does still return true although the fallingblock disappeared..
What are you even arguing about
he's claiming isValid doesn't work for falling blocks
About if isValid is working to detect if a fallingblock disappeared lol
im showing evidence it very clearly does
I am too and I'm right
not that I care but
see?
why do you take it THAT personally @glossy scroll
LMFAO XDDDD
because hes telling Proudyy false information lol
Guys stop its funny lol
see my screenshot
xDD
what about it?
U kill me lol
.
isValid checks whether the entity is dead or alive
.
XDD
.
Martoph does not care LOL
xD
girly you gotta ignore method names sometimes and just look at the actual code
those are the spigot mappings too
I really don't get what you are talking about
I said that isValid checks if the entity is dead
you're saying isValid doesn't work for fallingBlocks
how is that wrong
im saying it 100% does
okay, please create a falling block that lives for 20 minutes. I bet you can't
XDDD
it will vanish after 5-10 minutes
Guys
no matter what you do
I want
I want only true informations now
Which method is good to detect if a fallingblock is disappeared?
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?
you can cancel all events, you can set it invulnerable, you can set its despawn ticks or however its called
Tell me
the earth is flat
Thanks
it will be gone after some time, although spigot claims it's still "isValid"
GodCipher understood it
well that'd be a bug, but that's not what @thick gust is trying to detect?
yes that's what he indeed needs, he wants to use falling blocks to create balloons or sth
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
just use an armorstand
NO GODCIPHER
is there a method you're using to incrrease the time it's alive?
Deutsche anschreien wird hier nicht gern gesehen
-.-
Armorstands heads look smaller than steves head
Thats not cool!
It looks shit
I did everything that was possible that I could find... it seemed like NMS just removed it after some time
and bukkit didnt notice it somehow
idk
im asking what did you do to extend its life
I wanted to make some "fake blocks" like walls where you can walk through
I will try isAlive, isRemoved and isValid now...
and the falling block will set itself everywhere once you walk below a block
there is some method to set it's "how long am I alive" ticks
I set it to 0 or 1 every few seconds
I also called all events regarding entity death etc
@tender shard just set it to Integer.MaxValue :kappa:
then it will be dead instantly

xD
just spawn a new one every tick
Yeah i dont boost the server

I am not rich.
yeah that would have worked lol
yea the falling block will despawn after 600 ticks regarldess it looks like
that's 30 seconds
That would cause laags for lots of players
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
You gotta make it as "unlaggy" as possible
what about packets
@tender shard No capslock XD
the falling block doesnt have to exist
sure, that could have worked. I wanted to avoid NMS though. And now I don't care about it anymore anyway ^^
There is no isAlive method for ArmorStands @glossy scroll
falling blocks are never collidable
they are.
isValid
If fallingblocks collide with walls, they disappear.
Okay.
so detect that and send the packet again
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
CraftArmorStand also has no isAlive
I hate packets
your fault
I try avoid those shitty things ._.
@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))
eh but that would describe what you're talking about either...
idk, I just found peace with the idea to ignore my plugin idea, it was a year ago or 2 đ
@thick gust is the one who needs falling blocks to be persistent
things change
it was either 1.16 or 1.17
Does this sentence makes sense?: "Your balloon collided and blew up!"
probably 1.16
I would use ``` @Override
public void setTicksLived(int value) {
super.setTicksLived(value);
// Second field for EntityFallingBlock
getHandle().time = value;
}````
I am bad at grammar lol
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
I did that, after max 5 minutes (roughly) it just went boom
@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?
yes
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.
Black magic stabbed your balloon and threw the remains into a black hole.
Big brain move.
what's isDead?
That's a good one as well XD
A method to check if the falling block of the balloon disappeared.
Cuz getFallingBlock() returns a FallingBlock.
I have to ask again - are there any other damageable, wearable items?
^.*_HELMET$
^.*_CHESTPLATE$
^.*_LEGGINGS$
^.*_BOOTS$
^TURTLE_HELMET$
^ELYTRA$
id just use !isVaild()
@hybrid spoke Good one i will invent such a feature xD
its generally more foolproof
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
should not
nice
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
đ
LMAO
Need to create an explosion at the fallingblocks usual location, u know, where it disappeared.
Then i need to send a message to the player: MAGIC REMOVED YOUR BALLOOOM KABOOM! XD
Balloom lulw
no do the black hole
Balloons look stoopid
then you can do custom balloon skins like these:
Asteroid
Planet
Star
White Dwarf
Photons
A class extending multiple classes? Looks like not possible
a small armorstand with a particle orbit
Correct
interfaces or X extends Y, Z extends X
^chaining
KEKW XD
well
GodCipher is creative in a different way
i like the idea
i am just a god
Multiple class inheritance isnât supported due to problems like the diamond problem
With interfaces i cannot do a method that return smth?
100% Proof that Moe actually has autism, fight me in the comments if you think otherwise!
If you enjoyed, make sure to leave a like and subscibe if you want to see more of my videos! :)
Social Media:
Twitch: https://www.twitch.tv/zalla1
Twitter: https://twitter.com/xZalla7
That's you GodCipher
you can
with parameter default right?
parameter default?
yeah
you mean the default keyword
default void/string
Yeah
yeah
They are called keyboard so?
default is a keyword
Yeah like:
abstract, void, protected, private?
nah i look better
yup
now i have to make a universe balloon plugin with a black hole
Ballons in what way?
Like emoticons/gadgets?
@glossy scroll Well isDead works.
nah like a radius 50 sun sphere
with fancy fire magic
spitting lava
Do you recommend using this as normal class, abstract or interface
exploding into a radius 5 black hole absorbing the world
i would make it an abstract class
Asking about your attempted solution rather than your actual problem
But i have problem that a class cannot extend many class
Btw
Its the same
thats not realyl
what
ok.
you need to eb more specific why you need to extend 2 classes
maybe we can help you with this class structure you're trying to make
we can just guess from here on
becuase "making one an interface" is a solution, but could really be limiting
we may find that it's a good solution, but we dont know for sure
The problems are that interfaces are used for api pupposes
Sorry for bad english
I freaking hate FallingBlocks..
not necessarily ?
hey my drunken friend đ
@sterile token why do you need to extend two classes
hahaha
verano, show us what you have, what you want to be inheritated and why
First of all i wil explain
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
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
Okay
erm that makes no sense at all
Any other idea?
just create a static getter for your main instance
thats even more worse than singleton
just do this
I already have that btww
@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 đ
can even final the instance
no
encapsulation exists
how?
it has to be static. how do you want to make it static and final?
it cannot be final
@hybrid spoke The fuck is that
I bet 20⏠you can't make it final AND static đ and if it's not static, it's worthless
Itâs possible with some hacky shit iirc
how?
a nested class
you got an example?
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
well but then it would be a field of that nested class
or wrap it 
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
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
Yeah as said
Itâs totally possible with some class loading hacks like using a nested class
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.
isn't that the same as doing sth like this?
@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)
Anyone can tell me how the drop chance work in spigot?
what drop chance?
declaration: package: org.bukkit.event.entity, class: EntityUnleashEvent, enum: UnleashReason
Anything. Just asking for how to make chance system
does this trigger by automatic unleash or by player unleash? or both?
I donât think thatâs possible
@tender shard Aight
But yeah almost the same, class loading is a bit magical and thatâs perhaps why it works
it isn't, it throws org.bukkit.plugin.InvalidPluginException: java.lang.ExceptionInInitializerError
but I'd really love to see some code for the nested class hack
just out of interest
I will write it on phone rn
I'll slam it into intellij and test it right away đ
Can you cancel the item drop of the leash when EntityUnleashEvent triggers?
class Bob extends JavaPlugin {
static final Plugin p = Sam.p;
static class Sam{
static final Plugin p = Bob.getPlugin(Bob.class);
}
}
iirc
thx I'll try
Yeah hope it works now so I havenât just been lying
declaration: package: org.bukkit.event.hanging, class: HangingBreakEvent
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? đź
only a leash hitch (on a fence) is a hanging
oh hm
(according to the docs, havnt tried)
yeah but i want to avoid that.
@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..
@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
...
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
Yeah, it sounds illogical
Iâll test it tomorrow and see if I can figure some bizarre way out perhaps lol
i mean you could wrap it and set the instance in the wrapper later. but then the instance would not be final
What are the commands? I just installed it on a server and someones testing it for me
ok đ
so it would be the same as just setting it in the init block, just more complicated^^
but final
didn't you say yourself it would NOT be final?
yeah but not visually
the indirect instance (wrapper) would be final
goal achieved
@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..
yeah probably just like alex said
And EntityUnleashEvent does not have setCancelled Option
have to be on a fence
so dont cancel it, respawn it
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
so just check a tick later for items around material of leash and remove, but thats very hacky and nasty
check EntityDeathEvent
?
when the leash breaks, an entity "dies" lol
the entity does not die..
what do you want to achieve?
wait
make the leash unbreakable?
not sure but a leash could have setInvulnerable
the leash shall not drop when this happens.
not drop, or not get destroyed at all?
the best way to do it would just to use the lazy singleton pattern
this is the right video.
the drop shown in this video shall not happen...
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.
chek EntityDropItemEvent
but the respawn does not cancel the leash drop event
with some shit wrapper
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? đź
there is no LEASH_KNOT entity type
@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
...
ItemSpawnEvent will definitely work
but you'll have to keep track of WHY a leash itemstack spawns
If they store on create the entity I imagine they can just check if it's contained like they already do
ItemSpawnEvent does not have any information about WHY or by who it was spawned
all it has is an item
Hmmm that is problematic.
Can you set it so a lead on break doesn't spawn anything? Modify it before it breaks?
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? đź
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
By the way
that's how my Drop2InventoryPlus plugin works
U truly have a plugin for every shit right
that's an NMS thing
Soon you develop a plugin for deleting a server XD
leash_knot = leash_hatch in nms
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
For fuck says
Which event shall I use now
I was jumping from event to event for like 10 times now
Decide pls..
pay me 50⏠and it'll be done in an hour đ
No ..
I am poor
Iam minus on my bank account
I already paid u 5⏠once per paypal
declaration: package: org.bukkit.event.player, class: PlayerUnleashEntityEvent
Don't be that greedy
- listen to this event
okay then ask someone else for help, I was just about to give a detailled explanation
Nonoonnoo
Pls
Tell me your detailed explanation pls
Dear mfnalex pls
I knee down in front of u
And beg u
Pls
Do that
- save the center location between the player and the other end of the leash in a set
- listen to ItemSpawnEvent
- 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.
gosh so many events
i already used 3 tho
it's like 20 lines in total
Wouldn't you be able to cancel the event and then delete the leash via some other method?
That was my thought @vocal cloud
cancel what event?
This event
I assumed that he already tried that, because in the video he sent the leash was persistent
you didnt even try to cancel PlayerUnleashEntityEvent?!

that would be the first thing I would have tried ffs
I thought all this discussion started because that didnt work
then do what I said
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 đ
I'd test it myself but
How does that work?
WHAT THE FUCK IS THAT XDDD
That's something you really don't want to do
just save the player's location for now
Better performance i assume đ
If canceling the event doesn't work then you're going to have to figure something else out
Isn't a set like a collection, and an arraylist or a regular list?
You got the add, contains and remove method.
But here u said that I have to save 2 locations in a set. I don't get that, because such a thing would only work in a hashmap, map or dictionary using a key and a value..
a set is like a list without order
No shit sherlock XD đ”ïžââïž
So I'm confused to as if canceling it works or not
@tender shard So how would I save 2 locations in a set just like u described it in ur second step of ur super-detailed explaination?
why would you have to save 2 locations?
Cuz you said that in your second step!
"2. save the center location between the player and the other end of the leash in a set"
the center location is only one location
Save nanana location AND the other end of the leash in a set
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);
}
}
You want me to loop through each location of the set?
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?
yes
I still don't get why we're trying to use a set...
no, and even if, how many leads do you think will break per tick?
That makes less sense than using a hashmap/map/dictionary
what else would you use? a set is the fastest collection
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?
you want to check if the distance is SMALLER than 20
No shame in being small around here
Distance doesn't matter /j
@thick gust I got it to work with like 20 lines of code
?ban @quaint mantle discord nitro scam link
Done. That felt good.
Damn speedy with the bans
@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
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;
}
}
}
lole
of course you have to check in onUnleash whether it's a normal lead or one of your ballong things
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
it should work at least
How do I initialize a Set?
New HashSet
Thanks mike
Well protocallib means packets so if you want to do it manually then you need to learn packets.
Or NMS
LULW
Then you should be able to do it if youre pro what?
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);
}
}
}
}
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;
}
}
}
https://wiki.vg/Protocol#Player_Info idk probably this one. I imagine there's more than just this one though.
Either copy my code or add debug statements to see what code actually runs
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
U SAID USE PLAYERUNLEASHEVENT..
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
if (loc.distance(event.getLocation()) < 20) {
event.setCancelled(true);
locations.remove(loc);
}
THis is where i tested it
In the lowest event called onLeashSpawn of my piece of code i just sent u
all I can say is that when you copy/paste my code, it'll work
btw why was the "free nitro" dude banned?
And build my own code