#help-development
1 messages · Page 1912 of 1
I mean help, give, tp etc are also not blocked
^
Wait you want to change the default one?
Just... use the preprocess event then. That even prevents /bukkit:reload
basically
yea that will probably work
what would be the message for /reload? does it include the /?
no they don't. next time i shall read first
even tho... now i have to remember not to reload with console :o
ServerCommandEvent
Sniped
i see. thanks 
to both of you :3
And add a "Dont reload you dum dum" every time you use that command. Just as a reminder.
hehe
This is the actual reload command implementation. Nothing he chose.
for example why the PlayerCommandPreprocessEvent doesnt work, while the ServerCommandEvent does?
I'm doing something incredibly stupid rn but super fun if it works
development in a nutshell
okay
guys
WHY TF
does the PlayerCommandPreprocessEvent include the / but the ServerCommandEvent does not?!? god
that's fucking confusing
Do you use / signs when writing commands into your console?
Wh... how? That wouldnt work.
still... confusing
Still confusing...
gee its pink in here
because good people pay for spigat 
PlayerCommandPreprocessEvent is a subclass of the chat event, so that's probably why
How to set lootTable to empty for spawned mob?
26.01 21:16:57 [Server] Server thread/INFO Enabling SoneBasics v1.0-SNAPSHOT
26.01 21:16:57 [Server] Server thread/INFO SoneBasics has loaded.
26.01 21:16:57 [Server] Server thread/INFO Disabling SoneBasics v1.0-SNAPSHOT
26.01 21:16:57 [Server] Server thread/INFO This plugin was not made for this server, if you wish to use it, contact s0nee#7212 on discord!```
ballin
yea, message says what you have to do
lol all g
🙏
made it to where if the server isnt in the whitelisted ips for the plugin then it auto disables
idk if it's a "private" plugin, but... servers may change ip's
Kinda easy to decompile then remove that line then use the pl again
true
true, though i plan obfuscation, and even then its buried
not just one line
no beginner would be able to just find and remove it
well
ctrl+f entered the chat
It does, but there are still some rule apply with obfuscation
ctrl f will help
plus i could make it rely on that list with a webserver
and if the plugin wasnt on the webserver it dont funtion
nah
that can be removed too
all code
as a newbie
i'd open a decompiler of my choice, search for This plugin was not made for this server and bum, i most likely found it
so truee
if i used plain text
if you are sneaky and try to hide it with ```java
"this plugin " + "was not " + etc
i can easily search for single words
wdym
ik there truly is no way to hide it completely, but there are roadblocks
using a font in the string
well
as someone who wants to re-compile a decompiled plugin
i need to know how my ide of choice works
and if i know that
i can easily search through classes
assuming you don't use 100+ classes
external cmd handler
in case you do, i can still search for package names that seem to contain that shit
yea assumed that
so in that case... i'd go to the onEnable, and search all methods that are called, and methods that are called by called methods
and so on
until i find it
and finding the main-class takes me 10 seconds
main class is a smart way togo
How can I have different textures on the same item?
so
no flex, but i'm an experienced dev
but i'm 99% sure that everyone who knows what methods do, would do exactly the same
hiding such stuff without obfuscation is bascially not possible
obv
It's easily possible
without making your code spaghetti-like for yourself
Just don't share it without anyone 🥲
i like your funny words magic man

If you don't share it with anyone they can't read your stuff
I didn't do that yet, but I saw something about resourcepacks model data, search about that maybe help u
i can hack your server 
obv i won't do that, because i have no idea how hacking works
and it's dumb shit
but i could
theoretically
I heard about setting uhhh durability or something
no
but its possible with item name too
Hm
a block can have 2 texures with 2 names
like
barrier item, name : "Diamond1" = a texure
barrier item, name : "Diamond2" = another texure
is your name a reference to or perhaps directly connected to DevBuckette?
@sullen dome if you can do anti cheat, mind teaching me a few things?
i would never even try to create a real anticheat
?
anticheats are always bypassable. so i'd never even try it
A roblox dev
go for it's fun
There's a way to stop them from cheating with one liner string
I enjoy doing it
"Please stop cheating, thanks!"
^
I enjoy the part of trying to figure how I could detect a type
Mind teaching me a few things?
Well what do you want to learn
Anti fly, kill aura, stuff like that
Auto clicker
Obv wanna start with the simple stuff
and there it starts... good luck
What kind of kill aura check do you want to find?
There is different things you can look for when checking for kill aura
I have no idea, don't know anything about ac
btw always a good idea to tell how you make an anticheat in public chats
how to spawn particle at raytrace
I recommend learning packets before you go into this
lol
Alright
Take a look at this if you don't know where to start https://github.com/Rainnny7/Anticheat-Framework
why is this error coming upo
Type mismatch: inferred type is Boolean? but Boolean was expected
e.setCancelled(true) //Cancel the damages taken
which packet is sent when a player starts pulling a bow?
PacketPlayInBlockDig isnt this one
If anyone has a fix for this or any suggestions I would really appreciate it, it's one of 3 last known bugs to my plugin.
InventoryClickEvent how do you get the item that you had on your cursor and the item that you picked up with ur cursor?
it's like getCurrentItem() or whatever
declaration: package: org.bukkit.event.inventory, class: InventoryClickEvent
ye i just want to know if those are after you clicked or not
if the getCursor is the cursor before you clicked or after
after
I would assume
since when you click, the event fires, you are holding the item
maybe just output to the player to test it
Can I keep having events happen when I click left continuously?
is there a packet sent when the player opens his inventory?
I believe it's client sided
@lost matrix @sullen dome I did it lmfao. Took a while to patch it but it works. 🤡. Unstable? Yes. Works? Also yes.
Yes yes I did
and no I didn't build a custom one this was done as bad as you think it was
?
I mean changing one line is better than doing nothing right? 🚎
System.out.println("Starting...");
try {
ClassPool pool = ClassPool.getDefault();
pool.insertClassPath("spigot.jar");
pool.appendSystemPath();
CtClass cc = pool.get("org.bukkit.command.defaults.ReloadCommand");
CtMethod method = cc.getDeclaredMethod("execute");
method.setBody("""
{
System.out.println("Command disabled by MikeTheShadow!");
}
""");
cc.getClassFile();
cc.writeFile("output");
System.out.println("Writing finished Successfully!");
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Complete!");
First I modified the file and extracted it. Then I inserted it into the spigot jar
If md_5 is here I'm sorry your eyes have to witness this
you're a weirdo
I wanted to do it the worst way possible but hey it works. Reload command no longer works on my server
All modern OS's can function with just tab
Does Bukkit#getWorld(name) get already created but unloaded worlds too, or only loaded worlds?
aight
can i make animal attack player?
LivingEntity#attack(Entity)
no idea tho "how long" it keeps attacking
When a pig just punches the living hell out of you 😂
I'm making a plugin where people can make kits, save them and use them. I think I'm going to use a database to store the kits and when they join load it the player's kits into memory, then if they create a kit add a new Kit instance to their map which is added to database once the player leaves. Is there a better way for me to do this?
1: do you really need a database for this? kit's are most likely only used on one single server
correct me if i'm wrong
hello fellow kids, I come once again asking how I can set the final damage of an entity damaged by entity event
i'm not a kid 
for (EntityDamageEvent.DamageModifier modifier : EntityDamageByEntityEvent.DamageModifier.values())
if (event.getEntityDamageByEntityEvent().isApplicable(modifier))
event.getEntityDamageByEntityEvent().setDamage(modifier, 0);
doesn't work
It's just a fun project I'm doing, I need a way to store the data permanently somewhere
well... use a Configuration File?
this is a bit of a maddening issue for how simple it sounds like it should be
uhhh
EntityDamageEvent#setDamage(int)?
that doesn't set the final damage
should be the final damage
nope
what is it then?
pre-modified damage
That'd work too
actually I wonder if the sequence is messing me up
e.setDamage(EntityDamageEvent.DamageModifier.ABSORPTION, 1);
you could use this to set modifier-related damage
that is what I did
Databases are only needed really if you need to read/write over cross-server
which definitely isnt your case
I know that, Just don't really love yml files since using it as data storage like this is generally not liked by people
the more you avoid them the more you will hate them because the worse you'll be at them
embrace them
they're pretty cool
I think I'll create new yml files when a player first joins and then store their data there
fml alright I finally hit the right sequence
I need to do the thing I did then readd the damage by adding it with the BASE damage modifier
Or do it in one giant one
st.executeQuery("select * from a where b ="+ c);
please just give us a final damage method...
Not a fan on of that idea, though I think that'd be faster
Mongo java driver
if you have to use drivers to make something work without getting a headache, it's not worth it
except it's your gpu
I like it
sql is fine
really after you make a handful of methods you probably don't have to do much else with sql directly
or use a lib I guess, I'm sure there's good ones out there for this
It is a databse, but unlike tables in mySQL it uses documents
I'm still using sqlite, I like the portability
will probably add mysql later but tbh I'll probably always prefer sqlite
or even worse, xml ahhhhhhhh
same
If we have a Component with a Click Event with the action to Copy to Clipboard, as well as a hover event which says something like: "Click to copy".
Is it possible to change this hover event text to copied when the users actually clicks it?
No
SWEEP_ATTACK
Hey guys, I'm creating an inventory which has something like 20 itemstacks in it
Is there a more efficient way than having to write 20 times,
itemstack item = new itemstack
itemmeta meta = item.getitemmeta()
meta.setdisplayname()
etc, etc, etc
Hi guys, actually an error is coming in my plugin
Please help me to solve it.
the command you registered in main class is heal
but in plugin.yml is 2 things
and ffs please make 2 different classes for 2 different commands and not in one class
i never registered 2 commands in one class so idk how it works
make 2 class for 2 commands
and setexecutor it
@surreal valve have you added your command to plugin.yml
Strange
Yes, very strange
wait, i'll try and tell you
Still comes
I'll try the whole code in eclispe
and tell you
oh wait, why do you use a string inside of the setExecutor?
They don’t
Ah ye i see
I did it beacuse (see pic)
yeah I didnt see the commands thing above
Ok
Have you tried making seperate classes for each command?
Have you implemented Command Executor ?!?!? next to the Extend JavaPlugins ?
without that you cant make commands !
He has an extra class ig 😂
JavaPlugin implements command executor
The greetings class has to extend command executor
you made the command in the main class witch is fine but you have to implement Command Executor tho !
Not in the main class you don't
Yes
Yes
yes
It has to implement there
I did it
i have extra class
ohh
Is it a bad idea to use a log4j logger from LogManager rather than the jul logger from JavaPlugin?
I seriously doubt what happened i think my intellij broke 😂
JavaPlugin already implements command executor
Remove label.equals and make bye and hello have two different classes and register them in ur main
Try that, works for me just fine
I have tried that
Show
Wait
The exploit is fixed, tho why not use Bukkit.getlogger
because log4j gives me format strings and jul does not
jul delegates to log4j or whatever logging framework is used anyway
I figured as such, I wasn't sure if there was some magic bukkit does that bypassing it would break

like plugin specific log targets or something idk
Actually Idk, haven’t bothered looking into how deep the rabbit hole goes here
damn, people used to be toxic on dev forums
Done
YOUR MAIN CLASS DOES NOT EXTEND COMMAND EXECUTOR
woops caps lock
sorry
shall nit extend
not
I mean it does either way?
only the classes where command logic is has to implement that
only extend javaplugin
ok
nothing more
ok cooli'll try and tell
You dont need label.equals and when you register, do new Class()
can u explain ?
i mean
what do i have to do
label.equals inside ur cmd class
remove it, you are already setting it when you register
Dont implement commandexecutor in main class
Yes
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Remove the whole line
u have proven little to no real java knowledge
Man show me ur main class
I know a little java
so please first learn basic java syntax
Ok
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
I know
but even if i knew java
i still woudn't be able
to get it
beacuse i am getting no errors and u are not able to solve it also
I am going to write the project from scartch
i will provide no more help to this. good luck
maybe i did some error
ok ur wish
You wouldnt have had that error if you knew the basics, but either way, show me ur main class
replacing a character progrimatically, without the use of texture packs
Well i know a little
I am stilllearning tho
Dont cast commandexecutor, rempve cmd1 and cmd2
ok
Do getCommand("hello").setExecutor(new Class());
Not from what I see in that image
What can i do if i want a command class to execute in game with two commands? like '/store' and '/shop'
add an alias in plugin.yml
Elaborate
thx
https://www.spigotmc.org/threads/custom-chat-prefixes-and-tab-on-origin-realms.484400/ revisiting this thread
How would I actually go about doing this?
Like from start to finish, Im having a hard time understand this concept
How can i get the direction of a block on a blockplace event
Show the command classes and ur plugin.yml
and the place where you register the command executor for each command?
And do you get any errors from this classes u
or removing the usage from the plugin.yml
if onCommand returns false, it prints out the usage from the plugin.yml
^ but the usage is useful no?
It's used in more places than just returning it from the CommandExecutor#onCommand
if (sender instanceof Player) {
try {
Player player = (Player) sender;
saveKit(player);
player.sendMessage("[HUBPVP] Kit saved.");
logger.info("kit saved");
return true;
} catch (IOException e) {
e.printStackTrace();
}
}
}
```
so for some reason this returns false
i always do like ```java
if(args are right){
//do stuff
} else p.sendMessage("Syntax: /whatever <whatever>");
probably just my preference
does it catch an error? @onyx fjord
send the whole method please
well
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("hubpvp") && args[0].equals("savekit")) {
if (sender instanceof Player) {
try {
Player player = (Player) sender;
saveKit(player);
player.sendMessage("[HUBPVP] Kit saved.");
logger.info("kit saved");
return true;
} catch (IOException e) {
e.printStackTrace();
}
}
}
return false;
}```
intellij told me to do it o.o
it would throw the exception
weird
are you sure it's not throwing an IOE
i mean
Did it tho
try a sysout for the return value :o
or did you just implement the method
im sure
yea the usage... from the yml
if (cmd.getName().equalsIgnoreCase("hubpvp") && args[0].equals("savekit")
first of all, why would you check the commandname
it needs to equal /hubpvp savekit
if only
/hubpvp
it return false
that's ur problem
/hubpvp createkit sends hubpvp on chat
does it log the Kit saved?
no at all
if [ yes == yes && no == no] then {
do this
return true
}
return false
well
you are doing that
if (cmd.getName().equalsIgnoreCase("hubpvp") && args[0].equals("savekit")) {
why
if your command is equal to /hubpvp, your arg[0] can't be savekit
cmd is basically the whole command
so these two checks can't both be true at the same time
if the command is /hubpvp savekit it will return true, else if anything else it will return false. And in your case not even run the command logic at all
first of all, please refrain from checking the commandname
why do you do that at all
^
here's a small bit of help how it's supposed to look like
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
if (args.length == 1) {
p.sendMessage(login.login(p.getUniqueId(), args[0]));
} else p.sendMessage("§cWrong Syntax. Please use §7/login <password>");
}
return false;
}```
just took my smallest command
there's never a need of checking command names.
in your onEnable you use getCommand("commandname").setExecutor(executor)
your Executor is ALWAYS using that "commandname" as cmd.getName()
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
switch(args[0]) {
case "savekit" -> savekitlogic
case "deletekit" -> etc... etc...
}
return true;
}
or getPluginCommand()
they changed it in some version, my bad. didnt work for long time on commands
and this too
yeah i got confused
i thought its gonna do stuff in commands different than from my plugin
but i realized that i specify command on register
Would not recommend this for a big plugin tho
I would rather use interfaces
best practise in my opinion
god, deleting a world folder is such a pain in the ass
makes everything so much cleaner
how
rm -rf world/
: )
like.. java always like no no no no no.. want to delete that folder? you can't. because it has still 1 file in it
so i'll throw an exception now
windows? thats ur problem
or even worse, i'll do nothing
linux
oh my I hate emojis so much
uh hmm how are you having problems then
on some linux distros when you wanna do something very destructive you have to write "Yes, I know what I'm doing" which is funny cuz linus tech tips fucked his GUI lmao
i have no idea
either it throws random exceptions, or it does blank nothing
because
code?
If this pathname denotes a directory, then the directory must be empty in order to be deleted.
thats the reason
bullshit imo
void deleteDirectoryRecursion(Path path) throws IOException {
if (Files.isDirectory(path, LinkOption.NOFOLLOW_LINKS)) {
try (DirectoryStream<Path> entries = Files.newDirectoryStream(path)) {
for (Path entry : entries) {
deleteDirectoryRecursion(entry);
}
}
}
Files.delete(path);
}
yea i already have it working
public boolean deleteWorld(File path) {
if (path.exists()) {
File files[] = path.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
deleteWorld(files[i]);
} else {
files[i].delete();
}
}
}
return (path.delete());
}```
if (files[i].isDirectory()) {
deleteWorld(files[i]);
HMMM
WHAT IF
DIRECTORY IS NOT A WORLD
jkjk
well
if (f2.getName().equalsIgnoreCase("level.dat"))```
i'm pretty sure there's no other folders which are having such files
i'm not on an owned system. so i dont have the ability to use any scripts at all
is there not a way to delete a world directory through bukkit?
What's the method to create a potion item with an effect? Since only Material.POTION exists and not something e.g. Material.SPEED_POTION
unload it
thats it?
and then delete the directory with this
public boolean deleteWorld(File path) {
if (path.exists()) {
File files[] = path.listFiles();
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
deleteWorld(files[i]);
} else {
files[i].delete();
}
}
}
return (path.delete());
}```
oops
wrong
my bad
make sure it IS a world folder, and boom
Create a new ItemStack of Material.POTION I believe
and add add effects
not sure tho
There's a potion type class no?
yep
Of , never worked with potions
i'd like to be able to say that myself
If there was, I wouldn't know how to use it lol
same lol
?jd
my world manager command is a big if-else mess
Those things r so confusing lol
but idc tbh
declaration: package: org.bukkit.potion, class: PotionEffectType
me coding my plugins is just me sitting trying new things to "improve sturcture of my code" for 10 hours then going to bed
The more you do the more you learn
I guess
true
Reflection is fun
tell that to school system
but kinda slow
school is like
I've been refactoring a friends project for the past week. I've removed 6k lines of code so far. Been a fun learning experience
then more you learn the less you learn
lmao
Working on an personal annotations library using reflection is fun
but it's hell too at the same time
mixins owo
trying to figure out and plan what does what and how it all works together
I mean it's challenging but fun. First time doing custom java annotations
Mixins?
Noice
i am speed
ItemStack stack = new ItemStack(Material.POTION);
PotionMeta meta = (PotionMeta) stack.getItemMeta();
meta.setBasePotionData(new PotionData(PotionType.INSTANT_HEAL, true, true));
stack.setItemMeta(meta);```
this should do what you want
funny byte code manipulation
fuck you discord i hate you
Huhuhuuh
Thanks lol
I have a ways to go with understanding javadocs
yes make your armour plugin multithreaded, each thread puts on a single piece of armour
Being able to read java docs is the day you're free from needing to ask most questions
god
that would be nice
Truuuue
no
anything
i
please.
overwriting the hell out of methods 😄 https://github.com/mouse0w0/forge-mixin-example/blob/master/src/main/java/com/yourname/modid/mixin/MixinMinecraft.java
shpigout
Can I detect holding left click?

Can I use a texture pack on my server to change the texture of a Swamp Nitwit villagers (Swamp villagers dont spawn & Swamp Nitwits are reallllly rare) and then spawn a swamp nitwit, I want to make a villager look like a lucky block version
why
Why the fuck
Mmmm i prefer using javassist to overwrite the methods.
reposting this
https://www.spigotmc.org/threads/custom-chat-prefixes-and-tab-on-origin-realms.484400/ revisiting this thread
How would I actually go about doing this?
Like from start to finish, Im having a hard time understand this concept****
Im asking for the logic behind it
how does it work
Naw use those really off Unicode characters that no one uses
Yup
ill show u
Since Minecraft 1.13 we have access to custom fonts. Since I have not seen much about it here a little video about it.
I want to show you everything you need to know and provide some ideas how you can use fonts creatively.
Resourcepack: https://dmanager.stevertus.com/pack/stevertus:custom-font
Reddit article: https://www.reddit.com/r/Minecraft...
This video explains it well
ꑕ - unicode 42069
winrar
Ark dosnt seem to wanna read it at all
I'm good
7zip
Just rename it /s
gzip
Bzip
azip
Tar -zxf
Did you stole that resourcepack from sum server
yessir
Yeah there's your problem. Start fresh
well they kindly placed it in my server-resource-packs
No I need to see their structure lmao
who said im taking
laz7077
lmao
Video explains it well
yes it does
Try decompiling the resourcepack with java decompiler
😂
If you must extract it, you need to do it using Java’s ZipFile
I haven’t found any other program that can read the zip
I don't get it. Learn to do it yourself instead of trying to open Pandora's box for 8h and getting confused when you realize reverse engineering it is a lot harder than just making it yourself
are you dumb?
im doing it myself
im literally checking how they did their fonts
chill out
No shit Sherlock but you're doing it the worse possible way
Because there's literal videos explaining in detail everything there is to know yet you're choosing to go the reverse engineering route
Alright.
taco
Or if you really want to reverse engineer it I'm pretty sure the dude just gives the pack away as well so you can look at how he does it. Less bloat as well
🌮
ok.

the decompiler thingy was working
got it working
how so
🌮
somehow 7zip, unzip and other cli tools dont support multipart spanned zip files
i just had to concat all the parts into one big boi
then unzip
pretty dumb lmao

Can I use a texture pack on my server to change the texture of a Swamp Nitwit villagers (Swamp villagers dont spawn & Swamp Nitwits are reallllly rare) and then spawn a swamp nitwit, I want to make a villager look like a lucky block version
declaration: package: org.bukkit.entity, interface: Villager, enum: Type
Then change prof
Okay, thanks

noice
Disgusting isn't it
They do. Just tested it.
At least 7z
I'm trying to remove the thing on potion items that says "Poison (0:45)" but I can't work out if it's even possible. I tried to set a flag to hide attributes and it didn't go away and it's also not considered item lore as far as I can tell (.getLore() is empty)
Is it possible? lol
Thats not in the lore. There should be an ItemFlag for that
Ok I'll see
declaration: package: org.bukkit.inventory, enum: ItemFlag
🤦♂️ I literally looked at that page I'm so dumb
UwU



how do i make a plugin?
By learning java then learning the API
by paying me $500
how does it come i can only change an NPCs skin once?
https://www.spigotmc.org/wiki/intellij-debug-your-plugin/ I'm trying to get option 3 work, but it never adds the plugin
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Is there something I need to add to my build arguments or something
smh just use run-paper plugin
tf is that
gradle 
maven 🥴
maven 🙄
How do I make a hostile mob passive?
cancel entity target event
If you want them to be statues you can setaware as well
hello why i cant set amount of an item stack with feather material
if i change the material it works
item.setAmount()
💀
@Override
public void run() {
count--;
if (count == 0) cancel();
item.setAmount(count);
if (count == 1) {
PlayerData.get(player).setSpeedRecharging(false);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(Utils.RECHARGED_SPEED);
player.setWalkSpeed(0.2F);
}
}
if the material is something like bow
it works
but not feather
How can I get the rotation the block was placed in in a blockplace event
sending a text component to console will just be text right?
???
maybe check for packets
public void onCustomAction(CustomActionEvent ev){}
and call your own event
i want my onCustomEvent to be called after the checks on the actual spigot event
^
is it that simple
ye?
oh ok then
is there a way to check for methods in a class
i want to make it so u can implement EventListener
(a class i make)
and add ur methods
which r ur events
You want your event to fire after an event?
You can just set an event prio to monitor(?) and run your code there
i have a ton of code
its gonna be extremely huge
so i just wanna make my own custom event
that i can listen to
isnt there a nice way to make it
The only reason you really want a custom event is if other people are firing it
You can just create other classes to handle stuff as well
Onevent{subclass.dosomething}
I second that
2Hex are you familiar with the observer design and strategy design pattern?
not but i will learn that if i have to
You have to
oh
Anyhow, doing something like that seems to be what you want to achieve tho tldr
Forge the breakfast of champions
Forge is special
iirc they use classloaders and other stuff to find the annotated event callbacks
the use of the api is t he same
Yeah almost
I personally think firing custom events by yourself using bukkit's plugin manager is fine (Maybe not for forge)
Tho for instance you can annotate a class with sth like @ModEventBus and then all methods will automatically be registered callbacks if they’re annotated
However in Bukkit you have to manually register
I mean with a little reflection you can fix that
Ouch
that thing isnt there yet i think
however that crap is irrelevant to me rn
i need to know the logic
to make it
Well Mike, you’d still have to tell somewhere what class holds the callbacks
In forge there’s just that annotation
I mean basically 2hex you have a collection of strategy objects (like consumer or runnable)
Then on given event you just run each one of them
hm
im thinking about making all classes extending Listener (a class i make)
have their methods regarded as events
Why use a marker super type?
hmm
I know JDA had a method onEvent(Event e) where you basically had to check instanceof
And that was just horrible


actually ill just use normal events
what im doing is checking when a message is sent in chat
then checking its content
and depending on the content i wanna do some code
i would prob name them smth like
DungeonFinishEvent
DungeonStartEvent
Ah
Nice
Sure
Btw if you’re in forge
They do provide an event bus you could use
yes thats how u register ur events
Well you can use it for custom events also
Or well, might have to instantiate your own event bus instance
Idk
I mean
Their event bus is good Ig
idk
Can't you go through each class in a package?
Sure but that’s a rigorous solution
ill jsut do
At that point you’re better of with custom classloading (or maybe not, depends on what experience you got)
Events events = new Events()
if(stuff) and other checks {
events.thatCertainMethod;
} else if (that certain thing and other checks) {
events.otherCertainMethod;
} else if (..etc
it would be a switch statement or smth
thats the stupidest
and simplest way i can do it
It's a bit heavy on the reflection side but if you only do it onenable you'll be fine
ill prob not do that
dunno how to do that
Thing is, classes come and go
they’re not static sadly
You use annotations to mark them same way spigot does it. I had an example somewhere but I think it used googles old reflection stuff
Yeah, but that requires manual registration
Not that manual registration is a big deal
Idk, maybe just a Map<Class<Event>,Consumer<Event>> or sth

so is there a conclusion
is there a good method to do this
the best ig?
something that isnt too hard and isnt too bad
Why does that take so long to load 

what is that
Well that’s a decently engineered event bus
Idk if anyone documented it but you could take some inspiration at least
@ivory sleet
Reflections reflections = new Reflections("com.miketheshadow.criminaljustice.listener");
Set<Class<?>> classes = reflections.getTypesAnnotatedWith(CJListener.class);
for(Class clazz : classes) {
try {
pluginManager.registerEvents((Listener) clazz.newInstance(),this);
getLogger().info("registered custom event: " + clazz.getName());
} catch (Exception e) {
e.printStackTrace();
}
}
feel gross yet?
Tbf that's just nice in terms of decentralization
😦
don't do this though: Class clazz
What about dpendencyes
Do Class<?>
Never use raw-types, it's bad practice even if there's no discernible difference.
How’s it bad?
(Only time you're allowed to use raw-types is when it's necessary to do cursed shit like convert Properties to Map<String, String>)
Yeah intellij has a bunch of complaints with it
It's essentially legacy code
newInstance is also deprecated.
You remove the safe typing of generics
for(Class<?> clazz : classes) {
try {
pluginManager.registerEvents((Listener) clazz.getDeclaredConstructor().newInstance(),this);
getLogger().info("registered custom event: " + clazz.getName());
} catch (Exception e) {
e.printStackTrace();
}
}
No warnings edition
A wildcard is explicitly a "I don't know because there is no type," a raw type is a "I don't know because I wasn't given a type."
do you really have so many listeners
I mean I actually do shit like this in my own codebases
It's fun to get sidetracked
Although I personally implement the scanning myself since I don't like any of the existing options :p
No but when you're bored and someone says reflection is bad I feel legally obligated to do it
Bad practice? Only on my machine 
Reflection isn't that bad
😡
There's a few situations where it's really bad though
Like if you're running reflective operations every frame?
Yeah, that's bad.
Oh wait a minute CraftBukkit does that HEHEHEHEHEHE HAHAAHHAHA
And by "reflection" I'm referring to your standard java.lang.reflect, not java.lang.invoke
Reflect once don't do it ever again
Is there anyone with experience with Spring Boot?
Okay but that guy is also an asshole
I do not listen to the words of Yegor Bugayenko
Especially when THIS was the result of his opinions: https://github.com/cqfn/eo
Reminds me of the "OOP is bad programming and you shouldn't use it" guy
I STILL HATE THIS LANGUAGE
He's basically the opposite
"DSLs/syntactic sugar/FP is bad programming"
One of these clowns https://www.youtube.com/watch?v=QM1iUe6IofM
An explanation of why you should favor procedural programming over Object-Oriented Programming (OOP).
I mean tbf OOP is pretty shit though
Rust and C++ are probably the only langs that have done it well
(and even then, Rust isn't really OOP)
Ironically this compiles to mostly dynamic invocations.
So yeah I don't like yegor256 that much.
He's one of those enterprise devs who doesn't like DSLs or sugary code because
"It's scary"
In my opinion OOP is fine just don't abuse it. OOP dominates the industry for a reason. People like this try to explain that people would be happier without it.
I think Java conventionally abuses OOP
Have you seen most enterprise-grade projects? lol
NamedDomainObjectContainerFactory
What you don't want to have a Class AbstractBeansOfTypeDependsOnDatabaseInitializationDetector
Gotta love my CloudFoundryReactiveHealthEndpointWebExtension
ooooh or
ConcurrentReferenceCachingMetadataReaderFactory
Reflection was invented so java devs could iterate through all the class files in Spring Boot to find the longest class name
Yeah this is why I'm not too big of a fan of Java, just being real with ya
pff
Rust does this nice thing
where inheritance doesn't technically exist
Spring Boot is a beast though. It makes complex API's a breeze
so it's all down to composition







