#help-development
1 messages Β· Page 327 of 1
Yes but it's a path down classes
public interface CmdImplement {
Plugin plugin = JavaPlugin.getPlugin(Plugin.class);
ChatManager chatManager = plugin.getChatManager();
default void register(Object object) {
plugin.getCommandFramework().registerCommands(object);
}
static void registerCommands() {
new AdminCommands();
new PlayerCommands();
}
}
I could pass it straight down i guess
Not sure if it's the best practice tho
i wouldn't call that good practice for interface lmao
Wat tf
you are still converting it. instead of storing it in the database as a long equivalent, you are storing it as an int equivalent. regardless of which you use in the database, you would still need to convert it to either long or Instant, regardless of which of the two you want to use in code. I've included how to get long because that's what you wanted, although am not a fan of it
Maybe only for POC kind of plugin
That's not good practice tho
Why does the omterface have amything to do woth the implementations
that kind of interface you made is not interface
Interface*
It automatically registers every command in any file I give it
Without having to add it to plugin.yml
Including permissions, cooldown, etc
Alright but that wasn't the question at hand
But I understand
public class MyClass {
{
register(this);
}
public PlayerCommands(CooldownManager cooldownManager) {
register(this);
this.cooldownManager = cooldownManager;
}
}
Is that gonna call twice?
So no bueno?
why are you using init block ?
Because that's how the framework works?...
Alright guess that means remove the init and keep the construcvtor
Thanks
What do you mean by "framework"?
yeah im also confused by this
@Command(
name = "spawn",
permission = "br.player",
senderType = Command.SenderType.PLAYER
)
public void spawnCommand(CommandArguments arguments) {}
No plugin.yml needed
1 line to register the file and all commands get registered
Like if you ask about good code practice use constructor or method instead init block because later your code will be easier to deal with in unit tests
Alright I appreciate that advise. Much better than what I got before\
I will start doing that from now on
The whole point of avoiding static stuff is mostly motivated making code that is easy to mock in unit tests
does anyone know why this happens
[17:50:55 ERROR]: Could not pass event ProjectileHitEvent to Plugin v1.0.0
java.lang.ExceptionInInitializerError: null
at me.fury.plugin.MushroomBowEvents.onProjectileHit
if you decide to use them
I hope soon or later every project will use them
imagine writing tests, just see how program behaves in production
also depending on what you are doing, it is more of a hassle to set it up then it would be to toss in a server
this is actually not accurate
the point of avoiding static is so you are not holding objects in heap that don't need to be there. Static objects, methods, classes do not get GC'ed and will exist through the entire time using up resources whether its being used or not
also, statics always point to the same instance
so if the instance were needed to change, that isn't going to happen
Not saying you should never use them, but you shouldn't be using them everywhere either lol
I might have misinterpreted something that was said previously and responded with that. What I meant by that was I already have existing interface methods that use long as a parameter. I don't want to have to change them to both input and return ints. Most of the time methods in java use longs.
I feel like I'm not getting my point across and might just have to make an example to explain what I mean.
could cast
Oh good to know don't know about that
But why do that when I can just use the proper datatype?
If I make a custom event variation @Eventhandler will still have to be the event I'm extending my custom event right?
but times that by like a million
and its a considerable difference lol
up to you, if you have the storage space for it then I guess it doesn't matter
you dont need to change it
the code I gave you already gives you the column as a long
Sure, but this makes me curious. How much data is this table going to take up? Is there a way to calculate that?
2nd code block, last line..
and idk what u mean by proper datatype, if you mean long then it's not
mysql can't give you the unix milliseconds, so saving it as a long is meaningless
the proper data type is either DATETIME, TIMESTAMP, or INT
BIGINT if you want millisecond precision, but then the client needs to provide that
Right, but what if I don't care about MySQL giving me that info? What if I just want to store it as is?
then do whatever you want
If I make a custom event variation @Eventhandler will still have to be the event I'm extending my custom event right?
because I'm frankly done with debating how to store a time
just know I'm not updating that sql or the examples anymore to reflect that specific change
Like if I make a PlayerDamageByPlayerEvent I need to call my event from inside the EntityDamageToEntityEvent right?
lmao
Nice, thanks for the help
@regal scaffold no
if PlayerDamageByPlayerEvent extends EntityDamageToEntityEvent
then you do not need to call PlayerDamageByPlayerEvent from an EntityDamageToEntityEvent, because @EventHandler will work on subclasses
Ok so what I said lol
but you can listen to EntityDamageToEntityEvent and PlayerDamageByPlayerEvent will trigger that
Rip
lmfao
yeah yeah lol was in the middle of doing that tohught I was saved
That means all the checks should be done before calling MyCustoMEvent
I was so happy
When is that getting added :/
never
how else would it know how to construct your custom event
that makes no sense
yes I know
Didn't even think it rhough lol

Are custom events even that powerufl then?
of course they are, but they arent meant for your own code
my fucking god nbtapi
custom events are meant for APIs
ohhhh I see
for example in a permission plugin PermissionAddedEvent might exist
Oh I see that makes sense
no internal code would listen for that event, but it would dispatch it for other plugins to use
ok im idiot
wait yeah that's what I meant
if my api has CustomEvent
My actual plugin can listen to customevent
and then other plugins can use that event
only because alex told you about better item config
Fair enough
im holding air
are u sure it's calling .write
and u arent talking about the line that uses getConfig().set
will do
guys how to fix this
Caused by: java.lang.ClassNotFoundException: com.github.shynixn.structureblocklib.bukkit.Main
how do I fix this not preventing some clicks?
its the dropping thats causing an npe
you need to listen and cancel the drag event too
is there a way to check if its the top inventory? That they are dragging in item into in InventoryDragEvent ?
Ummm so, I followed this guide to making a custom event https://www.spigotmc.org/threads/why-arent-there-playerdamagebyplayerevent-bowshootevent-etc.532429/
But I'm wondering what the guy that posted means when he said "now you can handle the PlayerDamageByPlayerEvent". What would be different than just using the default event
i love when ij dies if i crtl+Z something that has Material. anything in it
or vice versa, I forget
this would work right
if (event.view == event.view.topInventory) return
kotlin code moment
ohhh wait I just realized that xD
The drag event can return multiple slots. You compare the slot to raw slot, if they are the same it's the top inventory, if different it's bottom. Or the other way around, he needs to test
https://paste.md-5.net/qomowerinu.cs
for some reason when i run the command /k create <kingdomName>, it will say <kingdom> was disbanded. why is this?
how the fuck is the Material AIR
epic can you try to explain what I asked plz π
give it more resources
whats ur issue
its got as much as i can give it
there is a file that IJ uses for settings
The difference is you can directly call event.getPlayer() @regal scaffold
also use some JVM arguments with it too
Oh so that makes me believe that in my use case itβs not needed
https://paste.md-5.net/qomowerinu.cs
for some reason when i run the command /k create <kingdomName>, it will say <kingdom> was disbanded. why is this?
it also doesnt save the permissions of the player to be able to disband the kingdom anytime i reload the server
custom events are only useful if something implements it to fire it
if nothing implements it to fire it, then nothing can listen for the event
now you could have the event purely in api for the sake other plugins are supposed to implement it instead
and your plugin listens for it
which is a bit backwards but still works lol
Well I don't think I personally have a use in my situation. Cause all I really need is to check when a player hits another player and interact with both player objects
Kingdom create command will say "<kingdom> was disbanded" even though its not supposed to
@wet breach finally found a way to do it π holy shit
this game me a huge headache
like several "crashes"(not crashes but huge lag) cause threads were lagging sever so much
99x99 chunks in just 1 minute πΏ π· without lagging server at all
async is fun
ty for the help
Is there any way to interact with mob drops on death
Only evet I see is EntityDeathEvent
You mean change mob drops?
Well if that's a side effect so be it but I wanna get the drops and how many it dropped. the itemstacks
declaration: package: org.bukkit.event.entity, class: EntityDeathEvent
there's a getDrops methods
I tried the same method for BlockBreak and it wouldn't give the amount
I'll try for mobs
declaration: package: org.bukkit.event.entity, class: EntityDeathEvent
Yes but the itemstacks don't contain the amount
Let me actually try this time
brb
event.getDrops() is a list
you can iterate the list and use drops.get(i).getAmount
also there's this event to set what a block drops
declaration: package: org.bukkit.event.block, class: BlockDropItemEvent
Yes I had to use that instead of blockbreakevent
Because getdrops doesn't get the amount
But I'll try and show you
oh for the blockbreakevent?
Yessir
hey everyone, im trying to detect block collision with an item that has a set velocity. anyone have any idea how to solve this?
That's why I thought same would happen for mobdeath
the drops aren't determined until after blockbreakevent is called and it's not cancelled by any plugin
nah
Just get the position, and raytrace using the velocity as direction, the magnitude of the velocity as the distance
see if u hit any blocks
How would you know if there are any checks you need to do to the entity so no errors come?
none
no checks needed
because you're just modifying drops right?
if there are no drops, it'll be empty but not null
np
Man copilot is so nice
Once you start you can never go back
Now 1 more question @humble tulip
What if
what if?
a mob drops 2 different items
it's a list
Can I cancel the drop for 1 of them
remove it from the list
yes
So sick
you can clear drops by clearing the list
what do you mean?
here's how bukkit events work
well most of them (cancellable ones)
some thing is about to happen -> event get's called -> all listeners process them. (LOWEST process first, MONITOR is processed last) -> if not cancelled, server processes what happened
so all listeners get's called before the server processes anything
np
Now there is a issue
[22:03:50 ERROR]: Could not pass event EntityDeathEvent to DeepStorage v1.0-SNAPSHOT
java.util.ConcurrentModificationException: null
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1013) ~[?:?]
at java.util.ArrayList$Itr.next(ArrayList.java:967) ~[?:?]
at me.tomisanhues2.deepstorage.events1.ChestEvents.onMobDeath(ChestEvents.java:160) ~[deepstorage-1.0-SNAPSHOT.jar:?]
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor1677.execute(Unknown Source) ~[?:?]
at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:77) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:git-Paper-381]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:672) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
at com.bgsoftware.wildstacker.utils.entity.logic.DeathSimulation.lambda$null$3(DeathSimulation.java:148) ~[WildStacker-2022.6-b414.jar:?]
at org.bukkit.craftbukkit.v1_19_R2.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.19.3.jar:git-Paper-381]
at org.bukkit.craftbukkit.v1_19_R2.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483) ~[paper-1.19.3.jar:git-Paper-381]
at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1473) ~[paper-1.19.3.jar:git-Paper-381]
at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:440) ~[paper-1.19.3.jar:git-Paper-381]
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1397) ~[paper-1.19.3.jar:git-Paper-381]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1173) ~[paper-1.19.3.jar:git-Paper-381]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:316) ~[paper-1.19.3.jar:git-Paper-381]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Something is null
you're removing in the for loop aren't you?
store the stuff to remove in a set or something and remove it after
use an iterator to remove
Is it cause threads?
oh yeah do this
Ummm
you can use iterator.remove();
Alright gotta read on it
nah not threads
How would I use a iterator for that
pretend you're reading a word doc and someone is typing/deleting stuff, it can get confusing
I'm reading on what they are
Iterator<ItemStack> itreator = event.getDrops.iterator();
Section 3.1 https://www.baeldung.com/java-iterate-list
while (iterator.hasNext()) {
ItemStack item = iterator.next();
if (item.whatever) {
iterator.remove();
}
}
like this @regal scaffold
Readomg right now
And ok I understand now
you could also iterate backwards
Easy enough
Thanks a lot!
Ummm
Isn't it bad practice
To do ItemStack item inside a loop
Declare outside
no
I actually don't remember but a while ago
Is it not better
or is it the same
or worse
you shouldn't be declaring stuff out of scope
Cause it could end up null?
yeah that's one reason
I mean if you declare outside scope just add a null check after no?
Oh nvm "one reason" lol
if you wanted to find a specific item from the loop and do something after, you can totally decalre item outside the loop
you can also follow that logic and declare item outside the method
Does it automatically know which obnject im currently on
Cause of iterator.next()
yes
Damn iterators are sick
think of the iterator having an internal counter to know the next index
Minion
yes?
With your help I've finally added mobfarm autocollect, mine autocollect to my infinite storage plugin
s
nice
And auto furnace smelt collect too, forgot
god that lore colour hurts my eyes
infinite π max amount
wait until you find out about paper and their per player mob caps
and that i have 3 accounts
and as much time as i want
wym
Oh
Papar has no cap?
paper has per player mob cap
I see I see
i could make 3 insane mob farms
Now you can autocollect them with my plugin π xd
ez items
middle mouse click to collect all
just a bit of lag for 5 minutes
Fair, all ivnentory slots
All that lets for my plugin is to finish adding the gui features and fully done
This is what I have, but stuff like this is still happening
// projectile collided with block
RayTraceResult pathRayTrace = item.getWorld().rayTraceBlocks(item.getLocation(), item.getVelocity(), getVectorMagnitude(item.getVelocity()));
if (pathRayTrace != null) {
Bukkit.getLogger().info("projectile collided with block");
item.remove();
return;
}
public static Double getVectorMagnitude(Vector vector) {
return Math.sqrt(Math.pow(vector.getX(), 2) + Math.pow(vector.getY(), 2) + Math.pow(vector.getZ(), 2));
}
was kinda hoping that would upload correctly... lol one sec
can also do vector.length lol
true
@humble tulip Is the iterator usage the same for blockdropitemevent
event.getItems() returns an item instead of a otemstack
Iterator<Item> iterator = event.getItems().iterator();
while (iterator.hasNext()) {
ItemStack item = iterator.next().getItemStack();
``` that would be same thing tho?
might need casting but probably
you don't need an iterator to loop over stuff
you could do this instead
for(ItemStack items : event.getItems()) {
//do stuff with the items
items
}
I do need an iterator cause 1 lower
I remove it from a getDrops list
Working perfectly now
Now the knowledge question. How would I know that I need a iterator there
well be careful with the while loops
they will block the main thread
if it takes too long for it to complete
or worse case you set a condition that will never return XD
the loop I gave, uses an interator behind the scenes just fyi
a traditional loop is good for indices
you could replace what I have
and put an interator in there too
for (Iterator<ItemStack> it = list.iterator(); it.hasNext();) {
ItemStack items = it.next();
}
if the iterator supports it, you can remove items as you loop
so that would be one reason you need an iterator
the difference between the for loop above I gave and the one I just gave just now is readability as well as preventing certain bugs
now a traditional for loop is like so
for (int i = 0; i <10; i++;) {
//do something like access array indexes using i
}
but this for loop you won't be able to remove as you loop
yes
Any thoughts on this
So that everytime you build a jar you can run a command on server and not have to drag and drop
you could just modify your maven pom to do that for you
you could use deploy for remote uploads etc
can also directly have a goal to run a test server
am using that for my current project, lets me run directly from a run configuration & attach a debugger
super neat
I assume that's what allows me to maven remotely
Ah
maven deploy plugin, but you also need to configure your server you are uploading to as well
you could use maven deploy plugin, to use ssh to upload file
and put it where you want it
obviously lol
anything prefixed with maven- has been made by the Apache maven team
or at least, it was meant to
Not really obvious could be a spigot plugin implementation for it
you can use what ever it is your comfortable with using
Do you set breakpoints?
Yeah
Ok yeah that's ot
don't worry about it being better, worry about if it works for you π
for non config testing stuff i just use winscp, keep remove directories upto date and my server on alex's ptero
and then just a button in game
it works as expected
does what i need
For testing stuff, whatever works works
So
For this maven deploy
I assume I want project deployment?
Or do I straight up just use file deployment
I'll wait for frost
Don't really understand what half of the words mean in this page and it's english...
Yeah full lost on this
How tf could I possibly get a built jar into my servers plugin folder lmao
Oh that's easy
One sec
Clarification:
Remote
Either using sftp or something
Actually I just thought about something, could make a python plugin that does that
Always running, check folder for changes, use sftp to upload
wym
and add a runafter in intellij
I see there's a script tab there
Yes
Ok so the script should
If Im gonna run it from intelliJ
maven package spefically
wait wait
?
working directory ntohing matters right
nah
All that is in the script
huh
Ok great
did you select script?
yEP
add a before launch to the bottom
and run the maven package configuration before launch
or run maven goal
Ok yes
both would work technically
ya both work
Oh didn't know there were kinda the same
well the configuration runs a maven goal lol
Ah that makes sense
do you have the script setup?
I selected the maven yes
no i mean the script in a file
Do I just copy paste from the generated?
When is #hasItemMeta() going to be false, and #getItemMeta() going to be null?
air maybe
yes but you need to ad your commands
so select script
Yeah I see it says add here
ur gonna cd to ur directory
& "C:\Users\Saif Mohammed\AppData\Local\Programs\WinSCP\WinSCP.com" `
/log="C:\writable\path\to\log\WinSCP.log" /ini=nul `
/command `
"open sftp://login here`"`"" `
"cd /home/server/plugins" `
"put target/Plugin.jar" `
"exit"
$winscpResult = $LastExitCode
if ($winscpResult -eq 0)
{
Write-Host "Success"
}
else
{
Write-Host "Error"
}
exit $winscpResult
like that
wait
wait wait
you may need the absolute path
why am I cding to my own plugin
put (Your buidl folder)
will getItemMeta() also clone the PersistentDataContainer? as in, do I need to call setItemMeta after modifying the PDC?
you may need an absolute path for put
yes
Gotcha
it returns a deep clone iirc
wait
?
My build folder as in remote again?
no
Ok local
build folder will be local
u can read more herehttps://winscp.net/eng/docs/scripting#generating_script
WinSCP is a free SFTP, SCP, Amazon S3, WebDAV, and FTP client for Windows.
Does it have to be alone in the folder?
in which folder?
yes
actually no
if getItemMeta is null, how are you gonna add meta
"put C:\Users\Random123\Desktop\Spigotmc\plugins\BorderRealm-1.0-SNAPSHOT.jar" `
I think that would work
Ye
I'm trying to spawn a particle 2D square but just the outline of the square, currently I can get the full square, how can I achieve it?
public List<Block> getBlocksInRadius(int radius) {
List<Block> blocks = new ArrayList<>();
for (int x = (this.location.getBlockX() - radius); x <= (this.location.getBlockX() + radius); x++) {
for (int z = (this.location.getBlockZ() - radius); z <= (this.location.getBlockZ() + radius); z++) {
blocks.add(new Location(this.location.getWorld(), x, this.location.getY(), z).getBlock());
}
}
return blocks;
}
That's crazy cool
cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
lmao
Gotta fix that
Lmao
Testing
Holy crap
Error
But almost lool
I'll sort it out
Nice error description tho
What's the error?
Hm so it built and then?
Oh yeah I see i messed it up
Lol
Imagine not knwoing powershel scripting language
Oh wait nvm
Still broke
I had /plugins/
Weird
Not sure
It's using sftp too
Should work
How can I debug 3 lines
Bro how can powershell ju8st say error, with no actual error
Alr 1 sec
Or u can configure the intellij terminal to not use powershell
Is WinSCPnet.dll something I need to download?
And use a sh file
I rarely do remote testing before
But when i worked for a server a while bacl that's how it was setup
lmao
Well u have the blocks so you just get the location of each block and spawn a particle there
how do i post one of my plugins on spigot?
thanks
that doesnt com up for me
are you signed in
yep
Not verified? Upload screenshots here: https://prnt.sc/
?premium @haughty tendon
I'm trying to use CountDownLatch in BukkitRunnable but it always throws serious error
In the first place is it possible to use CountDownLatch in anonymous async BukkitRunnable?
does anyone know which packet to use in ProtocolLib for block breaking? I want to send a player a packet of a block breaking when in reality that block isnt broken
you can use the api for that
declaration: package: org.bukkit.entity, interface: Player

luckily, less and less things
like nothing afaik xD
does printf seriously not work in the bukkit console output
can't even do System.out.printf or something
either that or my check is failing which I seriously doubt
yeah calling println(format(...)) works
stupid
I want to get all classes that includes βMainβ in class name.
I tried reflection, and Package#getPackages().
But NullPointerException returned.. π’
Thanks for helping! 
Why do you need to do that?
In your jarfile?
Is this a plugin?
need to run (extends) implemented subplugin registration method in static block.
yes
Ohh
So you're not looking for main?
Anyhow
In this class there's FindLocaleResources
It's a method
It gets all files inside a jarfile
You can do this, get all class files and cjeck them for a main method
Or main in tje class name
is it possible to make players not collide with entities? excluding players
i think both the entity and player need to be on the same team with the collision rule set to off, but I need to test if you can just add the entity to a team only and have it work with collision rule never
Iβve been fixed it with annotation!
thx for all
Does anyone know how to use CountDownLatch in BukkitRunnable?
Hey there! I have had some issues compiling whilst using 1.19.2 NMS
Somehow my compiler cannot access any of the NMS classes during compile-time
"cannot access net.minecraft.network.protocol.game.PacketPlayOutPosition"
per example
Anyone knows what's going on?
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
Make sure you're using Java 17
Oh, right
yikes, why aren't you using mojang mappings
Is there a way I can check for the protection value of an item? Say, I want to check the prot value for an iron chestplate
you mean the enchantment?
nope, the armour points they give
No clue we had those tbh
I haven't been up-to-date with all the stuffz going on here
since 1.12 release
?nms
Oh, cool
Hello, I'm doing a little project, and when I right click with an iron hoe I want a message in the chat. The problem is that when I right-click with the hoe on a block, the message appears twice, how can I fix this please ? Thanks in advance π
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html
Check the event description
declaration: package: org.bukkit.event.player, class: PlayerInteractEvent
As far as I know, you get it twice because the event is being called for every hand (mainhand and offhand)
You can check if the main hand click is executed by getting the getEquipmentSlot() equipment enum
I added e.getHand()==EquipmentSlot.HAND
in the if statement
Welp, it works perfect, ty ! π
Np
The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.
For example, only executing code if the main hand was used:
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
return; // do not progress past this point |
}
// provide functionality
}
does spigot have a page list of projectiles?
declaration: package: org.bukkit, interface: Tag
declaration: package: org.bukkit.entity, interface: Projectile
se subinterfaces on the second one
AbstractArrow, Arrow, DragonFireball, Egg, EnderPearl, Fireball, Firework, FishHook, LargeFireball, LingeringPotion, LlamaSpit, ShulkerBullet, SizedFireball, SmallFireball, Snowball, SpectralArrow, SplashPotion, ThrowableProjectile, ThrownExpBottle, ThrownPotion, TippedArrow, Trident, WitherSkull
thx
how can i check after x amount of time enderpearl landed or not? (projectilelaunchevent)
can i equal it to null? (entity) will it work?
how can we make "bundles inventory" for other items on the inventory?
like, when u put mouse hover it opens a small custom inventory on top
π€ is there any thread about this?
well, they are out for any version in 1.19 already
so i was guessing this "was discovered" already with packets
i believe i saw a plugin doing it
how does he do it then? π€ it looks a bit different than bundles
can I maybe "force" a BundleMeta on a different itemstack not a bundle?
currently I am using this way to register command(JDA). is it possible to get the instance & register all commands on the instance?
yes
I am making a spigot plugin. thats why asked here :)
to prove that, I keep the upper code :)
well but you're using JDA and using DiscordSRV API
it's not a spigot api question π€
so here is the full code. & I want to register more one command with checking of another plugin.
that chunk should work on both if DiscordSRV enable & disable. idk how to do that. so I think if there is something like a command instance, I can register it individually
or any other way to do that
this one :)
I'm not against you asking it, just you said "im coding a spigot plugin" doesnt mean it's a question directly about spigot api.
Question, using an external .JAR for my plugin (a mysql helper) - but no matter how I add it to IntelliJ the build fails because it can't find the package. It's already marked as a dependency with the "build" mode selected. The exported classes from the jar work perfectly fine in the editor, but on build it doesn't work.
what do you use maven or gradle
maven
then add the dependency there
it's not in a repo?
wdym
it's just a jarfile I have locally
you can use system scope
well otherwise its a pain if someone else needs to build it
like this? <dependency> <groupId>GROUP_ID</groupId> <artifactId>artifact_id</artifactId> <version>1.0</version> <scope>system</scope> <systemPath>${project.basedir}/src/main/resources/JARFILE.jar</systemPath> </dependency>
just jar but intellj can read it
probably, im not rly a maven user
where did you find it?
System path is deprecated
since when?
If you only have the jar use the maven install command
ill ask vagdedes
and what did he say
decompiled code != original code
fernflowβ’οΈ
no
Not sure. It's been as far as I can remember
or rather doubt
because i used at least 6 different decompilers for past two months
and
its not cool to reverse engineer and publish something with no license
.
I think that this is the most cursed code I've ever written java @EventHandler public void shootBowEvent(ProjectileLaunchEvent event) { Projectile proj = event.getEntity(); float offX = ((random.nextFloat()) - 0.5f); float offY = ((random.nextFloat()) - 0.5f); float offZ = ((random.nextFloat()) - 0.5f); proj.setVelocity(proj.getVelocity().add(new Vector(offX, offY, offZ))); }
found it in an old project called "CursedPlugin"
public void shootBowEvent(ProjectileLaunchEvent event)
{
this is the most cursed part
rip
its something like this
@EventHandler
public void shootBowEvent( ProjectileLaunchEvent event )
{
Projectile proj = event.getEntity();
float offX = ( (random.nextFloat()) - 0.5f );
float offY = ( (random.nextFloat()) - 0.5f );
float offZ = ( (random.nextFloat()) - 0.5f );
proj.setVelocity(proj.getVelocity().add( new Vector( offX, offY, offZ ) ));
}
man
The only thing wrong with that is that the name of the method sucks Lol
{ <-- this should be on the same line
nah
Oh I didn't look at the original I looked at yours
I agree it should be on the same line yes
even discord FIXES it
wym nah
how is that readable if its on the same line
normally lol?
do you also do that with stuff like if statements?
if you see public you already know it starts
Yes??
IntelliJs default is to format braces on the same line too
yeah cuz its java not C#
It's preference yes, but the convention in Java is the same line
I more used to like any c language i guess
just like not naming your methods Like_This is preference but not conventional.
their conventions are weird af
then my plugin breaks that convention happily

naming your methods like that is just pure evil though
My JS professor does that for his functions
It makes me sad
Though, he's not consistent with it. I've seen updateAll and Paint_Scene
there are only 2 naming conventions I can approve of, that being java and pythons styles
how can python have any form of conventions
snake case ig
the same way java does
but yeah python uses a lot of snake case
which is still better then Cursed_Case
iPreferThis
caterpillar case :)
im suprised this shit has names
this looks like a bit like my phone address book.
person x, person x old, perosn x old old, ...
lmao
my phone book is like 2-3 pizzerias
and a family member or two
I don't have my parents on my contacts
thats a shame
can someone please help?
https://paste.md-5.net/lajagorega.pl
does this happen in onDisable?
how do you structure a config when you want like a list of config sections
items:
item1:
-type:
item2:
-type:
item1 and 2 would be config sections
config section is really arbitrary as well, basically you could consider anything a config section as long as it has data below it
and items, too
you have to have the itemx keys though?
a config section is basically just a map
no
no was just an example
but basically a config section object, has data below it that can be mapped, it doesn't have to contain anything specifically
so i guess my question is then, with the config i gave, how would you iterate through the items
for(Map<String,Object> map : (List<Map<String,Object>>) getConfig().getList("items"))```
and then you can do map.get("type"), map.get("amount"), etc
alternatively you could use getMapList
you could also do it the old fashion way too
where you would put configsection in a for loop
and then have another loop to get your Lists
if you wanted say an array of lists
β€οΈ
ty
Hey! how can I prevent natural mob spawning but still allow spawners
listen to EntitySpawnEvent, check if its instanceof SpawnerSpawnEvent. If no, cancel the event
EntitySpawnEvent or CreatureSpawnEvent
wdym?
There's a creatureSpawnEvent too
SpawnerSpawnEvent extends EntitySpawnEvent
Gotcha gotcha
so listen to the EntitySpawnEvent and check if its instanceof SpawnerSPawnEvent
Hi,
is there a way to make the body and the head of an NPC player look in the same direction? At the moment I turn the head 45 degrees further and then back again, but this is error-prone and costs time.
I have List of Players and I want to split it in half.
Put half into Key and the second one as Value for those Keys
This is my current attempt || results in NullPointerException ||
if (event instanceof SpawnerSpawnEvent) return; I have a feeling this is not how to do it
that's correct
like this
as I said
it's correct
oh no
It's correct as it I said it wasn;t
I meant it's correct like you're doing it
Well i think it didn't work
Is this right?
nvm we good
shouldnt u use getLogger.info instead of system printin?
How do I align NPC player head and body identically with NMS?
cause server gives warning about it and ever since i changed
ah ok, good to know
IJ's quickfixes suck. Instead of suggesting me to set the language level to java 16, it should rather suggest to use .collect(Collectors.toList())
then start using eclipse 
right? haha
surely
suuureely
How can I prevent mobs from dropping exp if they die by anything other than a player
@EventHandler(priority = EventPriority.HIGHEST)
public void EntityDeathEvent(EntityDeathEvent event) {
if (!event.getEntity().getWorld().equals(Utils.ISLAND_WORLD)) return;
if (!(event.getEntity() instanceof Player)) return;
if ((event.getEntity().getKiller() instanceof Player)) return;
//Remove exp drops
}
Ignore just read the docs one more time
?jd-s
var size = list.size();
if(size == 0) {
return;
}
var half = size / 2;
var left = list.subList(0, half);
var right = list.subList(half, size);
Looks kinda like kotlin haha
Wait you're telling me I can just var and stop using types
You can't in fields/params
but ye
public void someMethod(YouNeedA typeHere);
private final Some type;
I literally only use var in for loops xD
ofc
though if there is an easy enough way to figure out what it is it's fine
For example var scoreboard = this.getServer().getScoreboardManager().getNewScoreboard();
The only time I used var was when I got stuck in generic hell when modding
I couldn't figure out how to get the variable right and Intellij wouldn't help
well u can also just write '.var' after specifying it
and it will generate the correct one
very usefull
as it also prompts you to replace any other usages by that variable right away
var sucks
with var you have to look on the right side what type sth is. when declaring it normally, all the types are directly below each other
true. but this does not suck
this is probably one of the nicest things from intellij imo
im smart
yea haha
no
Let's forget that bukkit is 99% built on interface where that is theoretically possible
where?
sounds like ur more lazy than me π
well I'm on the latest version of IJ ultimate and there it doesnt suggest it
how do you see if your plugin is causing memory issues
like is there some sort of profiler
run spark
Alternatively, perform heapdumps en masse
https://www.spigotmc.org/resources/spark.57242/ install this, use ur plugin
then memory dump
or what geol said
However it is very unlikely that either solutions would bring up any non-obvious issues
Most common obvious issue is infinite loop, other one is autoboxing
Everything else is rather hard to detect
and im not good enough with java to make memory leaks myself
Patience is key there
not sure if spark will actually inform you of potential memory leaks. Typically need a GC profiler to see such things
oh it's easier than you think
no it will not. but you can see if your objects are not being gc'd
You will see high amounts of allocs and whatever, but yeah not the fine details
i thought java was like a memory managed languages or whatever xD
it is
you can still fuck it up
there is always a way haha
but anyways, users of my plugin are reporting high ram usage, like full server capacity
you could e.g. add player objects to a list everytime they join, then never clear it
then you have a huge list of dead player objects
which I was wondering if there is a way to see what the issue could be
they wont get garbage collected because you keep them in a list
Hey ummm
and im pretty sure that prevents stuff like the world they logged out in from unloading too


