#help-development
1 messages · Page 764 of 1
It's only one I mean
in an asm context, it probably means too new
You can either spawn explosion particles and play a sound, or create an explosion using World#createExplosion() and then listen for the BlockExplodeEvent
So I don't really want to create an explosion except just make it look like the falling blocks kind of explode without destroying any blocks and adding some blocks
?paste
https://paste.md-5.net/ixujanukod.java because Ray#getTargetPlayer If there are blocks in the middle but it's not looking at them why does it return null? like this?
Tha fk is all of this AABB and Ray stuff. Why dont you just use spigots api?
the code I created is more precise (it's just an excuse because I don't know how to use it)
Or do you think I should use BlockExplodeEvent for that?
Bukkit.getScheduler().runTaskTimer(plugin, this::tick, 1L, 1L);
``` this would run something or atleast attempt to every tick right?
You can either spawn explosion particles and play a sound, or create an explosion using World#createExplosion() and then listen for the BlockExplodeEvent
okey
I don't know how to use it
yea
What are you trying to do?
yes
What an answer
what version should i try?
Nice, 👍
11
hahahahahaha
I translated badly
I want to see if the player is seeing the other player's hitboxes
Do you mean if his crosshair is on the hitbox or if the player has a line of sight on the hitbox (regardless if he is looking at him or not)
if his crosshair is on the hitbox
I'm designing a system which ticks basically a task with an ID every tick, would it be better to use UUID or long to ensure there are no overlaps
I know UUID can fail, but so extremely rarely
public Player getTargetPlayer(Player sourcePlayer, double maxDistance) {
Location start = sourcePlayer.getEyeLocation();
Vector direction = start.getDirection();
World world = sourcePlayer.getWorld();
Predicate<Entity> filter = hit -> !hit.equals(sourcePlayer);
RayTraceResult result = world.rayTraceEntities(start, direction, maxDistance, filter);
if (result == null) {
return null;
}
Entity hitEntity = result.getHitEntity();
if(!(hitEntity instanceof Player)) {
return null;
}
return (Player) hitEntity;
}
duplicate uuid is like one in a billion
alright 🤷♂️ good enough for me
tnx
If you started to generate a million UUIDs every hour from now, then there would be a 1% chance for a single duplicate in ~6000 years
shit good thing my plugin won't be running for that long
otherwise I'd get an IllegalArgumentException
The chance is about 1 / three hundred forty undecillion
ah my knowledge might be from another version uuid then
Probably v1 or so
but you can probably rest assured ur not going to get a duplicate
Wait i forgot the bits which are reserved for the timestamp
Yeah, that
Why there is no spigot in intellij minecraft plugin?
There was one for sure
It's in bukkit I think
no
epic you should clone my Inventory API with BuildTools GUI
oh thanks
if (target.getAllowFlight()) {
target.setAllowFlight(false);
target.setFlying(false);
player.sendMessage(Language.FLY_DISABLED.toString()
.replace("<player>", target.getDisplayName()));
} else {
target.setAllowFlight(true);
target.setFlying(true);
player.sendMessage(Language.FLY_ENABLED.toString()
.replace("<player>", target.getDisplayName()));
}
}```
how does this not trigger PlayerFlightToggleEvent
how
https://paste.md-5.net/efeqefiyek.js Why doesnt the casting work and it throws 28.10 20:53:36.951] INFO: [Dev-Server-1] Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_20_R1.block.CraftBed cannot be cast to class org.bukkit.block.data.type.Bed (org.bukkit.craftbukkit.v1_20_R1.block.CraftBed and org.bukkit.block.data.type.Bed are in unnamed module of loader java.net.URLClassLoader @27ce8e37)
have you tried checking what toggles the event?
eg going in creative and flying/stopping to fly
double spacing your keyboard
to turn it off at least
hmm
smell Paper's event
not paper?
isnt it PlayerToggleFlightEvent
im on phone rn
easy
its not paper
oops
smh
oh yeah
ah yes xd
you saw nothing
is there a way to trigger an event yourself?
eg something.triggerEvent
https://paste.md-5.net/efeqefiyek.js Why doesnt the casting work and it throws: INFO: [Dev-Server-1] Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_20_R1.block.CraftBed cannot be cast to class org.bukkit.block.data.type.Bed (org.bukkit.craftbukkit.v1_20_R1.block.CraftBed and org.bukkit.block.data.type.Bed are in unnamed module of loader java.net.URLClassLoader @27ce8e37)
well the deprecated one is the correct one. but you probably are looking for getBlockData instead of getState
then the one you already had would work
thats the thing why?
why isn't it triggered by itself
triggered when, when you construct the event?
i know i can trigger it but i just find it disturbing tbh
you can create your own custom events and call them
namecheap
namecheap good?
yes
this was random but ok
use the event constructor and then use Bukkit.getPluginManager#callEvent
very
il check it out thanks
you said you find it disturbing. like there shouldn't be a way to call an event
great, direct that to @topaz cape
how else would an event be called? You said "why isn't it triggered by itself". what does that mean?
no i said its disturbing that you have to trigger it even though it should trigger automatically
how can I then get what part is is then like bottom or head
im confused tbh
you want an event to be triggered right?
the event description says exactly when it is called. When a player toggles their flying state.
no its not that. i was testing it for 2 hours to find that this is the reason
thats whats annoying me
you can call it yourself if you want to, but event constructors are not API and can change at any time
its not like the api toggles someone else's
well sure it can. The API changing something isn't the player doing that, its some plugin doing it
actually, most of the time the API doesn't
or worldswitch or damage or potion or anything
but there are places where it does, like the teleport event
all of those are called
where
in spigotmc it always does
unleashing an entity doesn't
Pufferfish#setPuffState
oh that one is just a Paper event. but the unleashing isn't.
its gonna take me some time, but I'm confident that most of the time, API method calls don't directly trigger events
but you are 100% correct that some of them do, like the ones you listed
EntityEnterLoveModeEvent isn't fired if you change the love state via the API either
I don't think VillagerCareerChangeEvent is fired when you change a villager's profession either
i have never heared of that event tbh
villagers have profession what
always did
have you never installed citizens on your server
there is a blacksmith, a librarian and alot more
seems like that didn't exist when i played game
point is, it is no where near consistent within itself so its hard to say what is "more correct" really. Making it consistent now is... not really possible without changing a TON of events to either be called more or less often.
uh interesting thing to complain about
aint that getting turned in a value at compile time anyway?
where is my plugin .jar file after building with build.gradle?
build/libs
Yeah, it's convention to have the D, F and L suffixes be uppercase, even though it does not matter
what kind of name is 1l
it's a constant - not a name
ohhh you're casting to a long
it's not really a cast but more of a definition as long
what if I dont have build directiory but it says that build is successful
uh, what is your build.gradle file?
then you stated the build directly somewhere else
id 'java'
}
group = 'kitsudo'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven {
name = "spigotmc-repo"
url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/groups/public/"
}
}
dependencies {
compileOnly "org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT"
}
def targetJavaVersion = 17
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
}
tasks.withType(JavaCompile).configureEach {
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
options.release = targetJavaVersion
}
}
processResources {
def props = [version: version]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
}
and how are you building it
I opened build.gradle and pressed green "play button" in up right corner
I personally recommend executing the gradle wrapper script instead via the command line, but your IDE should provide the necessary tooling too
maybe im missing something blatantly obvious but how can File#createNewFile() throw an IOException saying the system couldn't find the file
you know, the file that i want to create that doesnt exist yet
shouldn't it also create subdirectories if they dont exist
it does not no
how can i make this only recognize comments that start with that word, instead of inside the comment?
its spitting out javadocs
@river oracle you around ?
ugh I have to join paper discord
this is a real chore
I will sit in their muted while I eat my yummy food
@eternal night be kind and move me
Which method says in the chat that the message is a server message, and which method says in the chat that the message may have been edited by the server
every message sent without player input is a server message, if a player message is processed somehow, the 'may have been edited' warning shows
Okay but some servers display player messages as a server message
yea by not sending the player message and re-sending it in the same format it normally would show player messages
So what method is that?
Bukkit.broadcastMessage
this dribbles chat reporting too I think
Which method edits the player message? Like essentialsx does
anyway to use bstats with gradle without manually copying the metrics class?
Yes
That’s how we usually do things
I guess you can use the spigot library loader
shad* plugin
shadn
how would i do that
nvm i fgured it out
I guess that would be a nice command to have
How to chicken?
i feel like there is a better way to do this but i am not sure what it is
Material bootsMaterial = switch (tier) {
case 1 -> Material.CHAINMAIL_BOOTS;
case 2 -> Material.IRON_BOOTS;
case 3 -> Material.DIAMOND_BOOTS;
default -> Material.LEATHER_BOOTS;
};
Material leggingsMaterial = switch (tier) {
case 1 -> Material.CHAINMAIL_LEGGINGS;
case 2 -> Material.IRON_LEGGINGS;
case 3 -> Material.DIAMOND_LEGGINGS;
default -> Material.LEATHER_LEGGINGS;
};```
If it’s any boots or legs?
when talking about minecraft 1.13 up avoid any single memory leak 
Because then you will regret about it
And what with 1.12 and below?
at that point minecraft code is fucked anyways
It was me🐈⬛
jython++#++
You cant make it without NMS, because most of the time you need more precise data which have to be getted from packets
Not sure how to explain this, but i find this useful gists which was sent here before
use an enum
even an array could be sued*
yeah a switch isnt bad anyway wouldnt say any approach is wrong
yeah, agree. But the enum is the best option i totally agree
is jython the jorts of programming
for some reason i cant seem to get the BlockExplodeEvent to work at all,
here is the code for it, the BlockBreakEvent works perfectly fine
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockExplodeEvent;
public class RemoveBlockLootSpawnListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockExplode(BlockExplodeEvent e) {
Bukkit.broadcastMessage("Test 4");
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent e) {
Block block = e.getBlock();
int minX = -100;
int maxX = 100;
int minY = 0;
int maxY = 80;
int minZ = -100;
int maxZ = 100;
Location blockLocation = block.getLocation();
int blockX = blockLocation.getBlockX();
int blockY = blockLocation.getBlockY();
int blockZ = blockLocation.getBlockZ();
Bukkit.broadcastMessage("Test 1");
if (block.getType() == Material.STONE && blockX >= minX && blockX <= maxX && blockY >= minY && blockY <= maxY && blockZ >= minZ && blockZ <= maxZ) {
Bukkit.broadcastMessage("Test 2");
e.setDropItems(false);
}
}
}```
any help is much appreciated
What are you doing to try and trigger it?
BlockExplodeEvent is more for things like beds in the nether
Or a respawn anchor in the overworld
Ye
alright cheers mate
whys it doing htat
Paper has its own support discord
how can i get the server brand name like spigot / paper in plugin
Nms prolly
what do you mean?
i want to know the server is running on which type
well easiest way is to just access version
it will either say git-paper or git-spigot
followed by eaches git commit id
the other way, is to take a look at the meta-inf
neither of those require nms
I think they mean the server name that can be found in the F3 menu.
then they would need to look in the Meta-inf for that
under implementation
that is where version and brand pull the info from
you just need to make use of zip file methods, and read the file
you could also use reflection too to pull that info as well
most likely could just use the java system package I think to get to that info as well
so many ways lol
1.12.2 has no material.*granite*
how can i make a crafting recipe that contains it?
recipe.setIngredient('G', Material.STONE_GRANITE);
will not work
Probably material data / byte value on stone
thats what im currently looking into
why doesnt 1.12.2 just have granite and so on? btw
Cause that’s not how it used to work
incase anyone was wondering
MaterialData md = new MaterialData(Material.STONE, (byte)1);
ShapedRecipe recipe = new ShapedRecipe(key, item);
recipe.shape("GGG", " S ", " S ");
recipe.setIngredient('G', md);
recipe.setIngredient('S', Material.STICK);
I’m old enough to remember the days haha
there is some mc wiki pages if you can find them that has this stuff documented
Search an interactive list of Minecraft blocks, items, mobs, entities, potions, ids and data values.
Good old
I remember smth that looked exactly like this one
yeah there was another one
it covered both blocks and items
would even help you format the in game command too and with spawning entities
I recall
https://minecraftitemids.com looks more modern
A searchable Minecraft ID list, containing all item and block IDs from the latest version of Minecraft (1.18) and lower versions (1.17, 1.16, 1.15, 1.14, 1.13, 1.12, 1.8, etc).
public Player getTargetPlayer(Player sourcePlayer, double maxDistance) {
Location start = sourcePlayer.getEyeLocation();
Vector direction = start.getDirection();
World world = sourcePlayer.getWorld();
Predicate<Entity> filter = hit -> !hit.equals(sourcePlayer);
RayTraceResult result = world.rayTraceEntities(start, direction, maxDistance, filter);
if (result == null) {
return null;
}
Entity hitEntity = result.getHitEntity();
if(!(hitEntity instanceof Player)) {
return null;
}
return (Player) hitEntity;
}
why if i look head return null?
because before lots of blocks like wool and concrete only relied on byte data on original block
this stopped in 1.13
how would i change the pickup range of items
you would need to listen to a few different events involving players and items dropping
and then you just run a task to check further out if there is a valid player
and then either set the items velocity to gravitate to them or instant pickup the item for them
the gravitating might be more difficult to implement then the other way
cause you know accidentally sending items flying away 😛
is there a way to move an entity in mc in a way that does add interpolation but only until the next tick?
teleports do add interpolation but it seems to be about 100ms-ish which is well above 1 tick
the closest I can get it to is by guessing that it takes 2 ticks (usually) to run it but this is not a great way of doing things
I'm guessing getting this to be reliable is basically impossible unless there's some really useful hidden feature somewhere that does exactly this
pretty sure setting entity velocity to a value below 20 blocks/tick just moves it in the way you want, just remove the velocity the next tick and teleport it to it's destination if it got placed wrong
I need to run it continuously and I can't guarantee that it won't break mc speed limitations
so I can't teleport it to adjust because it would teleport every tick which would probably cause it to revert to the delay issue
ProtocoILib Plugin Works In 1.20.2???
also this needs to move through solid blocks with armor stands which I don't think they will do that with velocities
cant u tell armor stands 'u dont have a collision box'?
Does anyone knows how to get the max health the mob can normally have only by knowing the EntityType
ty
how do i check if two instances of ItemStack are of the same itemStack? I don't see a getUniqueID method
.. wdym
why not use #equals
or do you want to ignore amount
if it's the same instance of one itemstack then you can just ==
its not the same instance, but i need to know if it's the same item
use Material
EXACT SAME item stack
clone, set amount to 1, use equals
For itemstack use isSimilar, that will not count amount of items in itemstack
makes a lot of sense
does it check for NBT tags
I should stop being in this channel, the more I'm here the more I want to go develop something new
Yes, just not amount
Aborting charge player as no target was set
Afaik
for (ClayWarsPlayer cwp : getNonEliminatedPlayerList()) {
EnderDragon dragon = getActiveWorld().spawn(new Location(getActiveWorld(), 0, 100, 0), EnderDragon.class);
dragon.setTarget(cwp.getOnlinePlayer());
dragon.setPhase(EnderDragon.Phase.CHARGE_PLAYER);
cwp.getOnlinePlayer().sendTitle(StringUtil.colourize("&c&lSUDDEN DEATH"), "");
cwp.getOnlinePlayer().playSound(cwp.getOnlinePlayer(), Sound.ENTITY_ENDER_DRAGON_GROWL, 2.0f, 0.8f);
}```
surely this would work no?
its setting the target
one way to find out
tho i'm not sure you can make the ender dragon not target 0 0 whenever it switches from charge
nvm
iyou are doing it at 0 0
id prefer getPlayerList() and getEliminatedPlayerList() instead of what you have there
why do breakpoints not work on in-line runnables
hello i coded a gun system. now is my question is it possible if the player shoot the weapon do a animation? i want to move the item under when shoots like a little shoot animation. its like the player drops a item that wheres the DropEvet canceled?
just use a resource pack or something
?
Wasn't there a build tools flag or something something to build/run a PR ?
i got one but how?
Yes, see: https://www.spigotmc.org/wiki/buildtools/#pull-request
Example: java -jar BuildTools.jar --rev 3904 --compile SPIGOT --pr craftbukkit:1271
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Merci
how can i do this animation?
One way would be to have an animated ItemStack and switch it out
you see the gun, i want if the player right clicks that the weapon move under
and then up
maybe in a scheduler
in the first person
Under and then up... I guess you can set the attack cooldown
ahh right!
but how?
code
Here are the javadocs for org.bukkit.Player
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/Player.html
declaration: package: org.bukkit.entity, interface: Player
Search for cooldown or weapon or something similar
Hm i dont see a method to set this cooldown without triggering an attack
Well.. looks like you need to be creative 🙂
Play an animation, let the player swing or attack the air. Let is know how you solved it.
any help
kinda desperate
for (ClayWarsPlayer cwp : getNonEliminatedPlayerList()) {
EnderDragon dragon = getActiveWorld().spawn(new Location(getActiveWorld(), 0, 100, 0), EnderDragon.class);
((CraftEnderDragon) dragon).getHandle().setTarget(((CraftPlayer)cwp.getOnlinePlayer()).getHandle(), EntityTargetEvent.TargetReason.CUSTOM, false);
dragon.setPhase(EnderDragon.Phase.CHARGE_PLAYER);
cwp.getOnlinePlayer().sendTitle(StringUtil.colourize("&c&lSUDDEN DEATH"), "");
cwp.getOnlinePlayer().playSound(cwp.getOnlinePlayer(), Sound.ENTITY_ENDER_DRAGON_GROWL, 2.0f, 0.8f);
}```
i've tried with regular .setTarget() too
My plugin doesn't create the config files folder. Can anyone help me?
You don't need that copyDefaults call
Make sure your config is in your jar
Where are you calling saveDefaultConfig
in the main file
in onEnable function
Are you using the right plugin jar
yep, i build it by gradle
i'm using 1.1
Did you put that jar in to the server
is there no load factor for array list init? I know the exact amoutn of entries it'll have
?
wdym??
What do you need help with mate
for maps and stuff you can declare the load factor
if you know your exact capacity you declare size, 1f
What is a 'load factor'?
Aborting charge player as no target was set
the occupacancy percentage at which it doubles its capacity
What are you coding
minigame
I believe ArrayList just increment the array size by one every time you go over it's limit
You could lerp to player and do custom attack
I didn't know there was .setTarget 💀
wasnt that linkedlist?
wait why tf cant i open the arraylist internals
Just checked array list does that
Not sure about linked list
I've called the connection function before the saveDefaultConfig()
every List does that innit
What is a lerp
Linear Interpolation
not necessarily
yes but not every list expands after each new element
arraylist expands by 50 of its capacity
when its full
50%
yeah no clue how to do that
ideally would want the vanilla way to work
using an array wouldnt work well here, and i iterate the list once for init and once for readout. should i just tell it 'your capacity is size * 2' ?
I did make something similar to that, if you're interested
What is the event called to cancel on water and lava flow?
BlockFromTo
Okay thanks, but how do i check for water? what is water, it isnt a block is it a material?
just cancel if block.isLiquid()
There is also a material for it
yeah
This might be a dumb question but how do i check for the placer? so if the player is op it isnt canceling
bad code??
wdym?
placer of what?
If i place water and i am op i want so it can flow, but if im not op it wont flow
Can you modify if water flows?
I can tell you how to detect placement and if the placer is OP or not
I've never really done water logic stuff
simply in blockplaceevent or interact event check if the clicked block != null and then check if the placer is op event.getPlayer().isOp() or something similar, and cancel event if not
Oh yeah, i could also do it on that way. Thanks
lombok spam
put the getter anno on the class
or just generate the getters with ij and ditch lombok
is there a way to disable dragons' collisions
if they collide with each other they get launched up for some reason
my game needs multiple dragons for a certain portion
lol, yeah I guess every entity just gets flung up when hit by a dragon
Would anyone be able to create a plugin which disables elytra with chestplate swapping
?
wait what
does livingentity not extend entity?
no it does right
through damageable
yes
methinks I may be a bit tired
I keep forgetting the names of my own plugins
well
poop
big turds
I am starting to suspect that there is no 0 interpolation entity movement in mc, that the teleport speed is the fastest speed possible
put @Getter above your class
anyone know how to make an item unstackable?
aight
idk a lot of people like and dont like that
tryna mess around with redis but never tried it before
to make a party system
i was thinking to just store a list of uuids to some sorta key to be some sorta party id
but not sure if thats a decent structure and how to effectively store/fetch that party id
would storing the player uuid and party id for each player in the party be a decentish way of doing that or am i strucuring this badly
anyone got a good guide/tutorial to help me with making plugins
hi, how can i remove respawn death screen and removal of dirt screen in Spigot/Paper 1.8.8 ?
can anyone give me some example from this ?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
like i have to modified PlayerDeathEvent and EntityDamageEvent ?
respawn immediately after death ig?
yes
and i make in 1.8.8
minecraft 1.14.x and the doImmidiateRespawn doesn't existed
so i ask how can i remove death screen with dirt screen
normally when you died and click on respawn button it show dirt screen on it
Hi i have 2 plugins orebfuscator and anty x ray how can i turn on anty x ray??
can you not post it into all channels?
Im sorry but it maches to all
that depends on the antixray plugin
wait ill send
No, it doesn't
no, it doesn't, that's a server administration question
Okay sorry i deleted
help server is okay??
idk
yes
can anyone help this?
hello
hi
runs
sleep
i want to use maven to minimize my jar to keep the final jar size small, but when i do so the plugin's main class isn't added and so the plugin doesnt know how to plugin
ive been trying to add a filter to exclude my core module, but it says its unable to find the artifact
so how the fuck do i use a filter lmao
if my core module's artifactid is core and my plugin is just called "plugin" it should be done like this right?
Just call .respawn() on the player who died
anyone know if the orientation of a block such as an end rod will be retained if i use .setType() for another orientable block
like a chain
it won't
yeah figured that now
also whats the difference between the material glow berries and the cave_vines_plant material
is the berries the item
yes probably
Whats the recommended way to check if a player clicked in a specific custom inventory?
InventoryClickEvent, check if clicked inventory is an instanceof your custom inventory
is there an easy way to replace lava with water, but retain the exact state that the lava was in
like flowing / level / direction
can i just save the blockstate and replace the block and apply the block data
to the new liquid
doess .equals work too?
no
should be possible yes
Sure this will work just fine. Inventory implements equals and hashCode properly.
would i run into any interacting problems if i decided to do it X blocks per tick
okay thats cool
like cobblestone/stone/obsidian stuff
would need to know more context for that
You should probably use a Map<Inventory, CustomHandler> so you can give each bukkit inventory a custom handler for your interactions
replacing a large area of lava, lets say 100x100 blocks
which is quite a lot to do
in 1 tick
and you wanted to do that every tick?
considered using worldedit api?
hmm i'll take a look
https://www.spigotmc.org/threads/a-modern-approach-to-inventory-guis.594005/
If you are a bit more experienced then consider this approach for GUIs
done
it was lava beforehand
to the very same data
i mean it'll work but given you're doing a 100x100 area its probably not gonna be very performance friendly
I wonder if that's multithreadable
i'll use worldedit api if it's getting annoying
A good menu api is triump-gui has everything done
Verano just out of nowhere with his out of context wisdom...
Just dont lost time coding one.
triump-gui has everything for menus, pagination, normal menus, storage menus. Diferent menu types, items actions
Fawe
I have a task that I'm confused about. How to use wolrldguard api to make it so that the owner of the barrel with items can put only in a certain region (for example shop) and then to break this barrel can only the owner of the barrel or the owner of the region shop
there are plenty of barrels like this in the region.
and you can't put someone else's barrel where the barrel is.
region in region i think
region has region were only the owner of the shop region or the owner of a sub-region can lambast the barrel
and p2 can't break the barrel at p1.
but "shop" owner can
Hello.
Is there an event in spigot api for camera movement?
You can do that with region priorities
PlayerMoveEvent I think fires when the head moves
You mean where the player is looking at? If that the case use PlayerMoveEvent
PlayerMoveEvent. But if the client doesnt move his actual character but has a free-cam type of movement then there is nothing you can do
I mean when player moves mouse
i dont think you can
Eee
You cant check mouse moves directly. Only if the client moves his character (looking around)
Yeah you can just know if he moved his head or not
I mean looking around
thanks
Yeah that you can
Just use PlayerMoveEvent
If im not wrong is getHead() or something like that, from player object
Let me check it
getYaw and Pitch or something
I cant really get it to work, do i have to compare it with getClickedInventory, or getInventory or something else?
yes
getInventory() returns the primary inventory in this event. (Which is always the top one if something is open)
So if you have a custom Inventory somewhere, then calling .equals() on this custom inventory and the inventory returned
from .getInventory() then it should return true.
Depending on your java experience, you could create quite a few problems in this implementation that results in .equals() not being true.
*Meaning you should show some code
Wait i believe its because i implemented a custosm inventory holder
custom InventoryHolders are a no no
you've been a bad boy
luckily for you I have some beautiful threads for you to read
https://www.spigotmc.org/threads/a-modern-approach-to-inventory-guis.594005/
https://www.spigotmc.org/threads/why-items-with-lots-of-metadata-actually-cause-lag-an-inventoryholder-psa.607711/
Introduction
The creation of inventory GUIs is a big topic in the spigot developer community and often butchered by inexperienced devs. This is ok...
i know but they work
but im trying to get away from them, thatsss why i assssked
i justs do this.inventory = Bukkit.createInventory(null, 9, "Select Your Class")
and then i do this.inventory.equals(event.getInventory())
This should work fine, as long as you have only one player on your server
well that wont be the case
*Or as long as this GUI has no state
i create a new instance though for every player
I hope that you dont register a listener for every player
its only registered for the instance that i specify in .registerEvents in my onEnable
Then how do you create a new instance for every player? ...
i do new MyCustomInventory().openInventory(player)
and that again calls this
my .equal always returns false though
@lost matrix Yesterday you gave me the code to see if an entity was having the crosshair in the hitbox, it works but sometimes if I look at the player head it returns null
More code
Make the ray a bit bigger i guess
i mean i have this handler class:
public class DominionInventory {
protected final Inventory inventory;
public DominionInventory(Inventory inventory) {
this.inventory = inventory;
}
public void openInventory(HumanEntity entity) {
entity.openInventory(this.inventory);
}
}
and then in my click event:
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
System.out.println("Inventory click grimoire" + this.inventory.equals(event.getClickedInventory()));
if(!this.inventory.equals(event.getClickedInventory()) || event.getCurrentItem() == null) return;
event.setCancelled(true);
if(event.getCurrentItem().getType() != Material.BARRIER) return;
Bukkit.getScheduler().runTask(DominionSMP.getPlugin(), () -> event.getWhoClicked().closeInventory());
}
I have now realized that if you combo a player (so you make him jump from the knkback) aiming for the head he will act as if you are not facing the player because he will have fallen.
Wait, so this.inventory is a DominionInventory´?
no my inventory handlers extend DominionInventory
this.inventory is just inventory as you can see here
Show me the code that opens an inventory for a player
literally here
I mean the usage of this method
.
and MyCustomInventory extends DominionInventory
and in itss constructor i call
super(Bukkit.createInventory(null, 9, "Select Your Class"));
Ah ok. So every time you call new MyCustomInventory(), your constructor creates a completely new instance of
org.bukkit.inventory, making the inventory different from the one in your registered listener.
You now effectively have two inventories. One that is inside the registered listener and one that is used for a player to open.
Yeah, the common approach for most systems is: Write a manager class and put a Map in it that gets managed.
ill just put a static map in DominionInventory
Sure. You can just use the dirty, hacky, shortcut that gets you in a ton of trouble in the future as well 🙂
Its a choice
bruh how iss sthat hacky, dirty and will get me in trouble
public class DominionInventory {
protected final Map<HumanEntity, Inventory> inventories = new HashMap<>();
protected final Inventory inventory;
public DominionInventory(Inventory inventory) {
this.inventory = inventory;
}
public void openInventory(HumanEntity entity) {
this.inventories.put(entity, this.inventory);
entity.openInventory(this.inventory);
}
}
theres the issue, you should have 1 class with a map, not every class gets a map
This wont work
Make it static 
that shouldnt have a map in
public abstract class DominionInventory {
protected static final Map<HumanEntity, Inventory> inventories = new HashMap<>();
protected final Inventory inventory;
public DominionInventory(Inventory inventory) {
this.inventory = inventory;
}
public void openInventory(HumanEntity entity) {
this.inventories.put(entity, this.inventory);
entity.openInventory(this.inventory);
}
}```
better
I was mostly kidding lol
choco was joking with the static
It would work, but I was kidding
i already made it static before he ssaid it
heres an example of the inventory stuff https://github.com/The-Epic/ebiclib/tree/master/ebiclib-core/src/main/java/xyz/epicebic/ebiclib/inventory
why was he joking
There are just better ways to approach it is all
Here are some suggestions you should keep in mind:
- Never use references to game objects (like Player, Entity, Block, World). Always use an identifier like their UUID.
- Never make anything that is mutable, static. Maps, Lists and other collections are generally mutable.
- Never create a getter or setter for any type of collection.
alright why make a reference to the Inventory then?
isnt that a game object?
Why cant i make mutable things stsatic?
im not implementing a getter, im just referencing it by variable, its protected anyways
One of the most important properties of your code is stability. There is one principle which, in my opinion,
helps out this stability the most: Encapsulation
Making mutable objects static, breaks their encapsulation as it is now shared between multiple instances.
This is also true if your object is private.
Okay so wheres the recommended place to put my inventories map
Inventories dont have an identifier (at least not an exposed one), and cant be referenced indirectly.
Managing inventories is the responsibility of the plugin, not the server. The one who creates a resource has the
responsibility to clean this resource again.
the map would be a seperate class, eg https://github.com/The-Epic/ebiclib/blob/master/ebiclib-core/src/main/java/xyz/epicebic/ebiclib/inventory/CustomInventoryManager.java
In some sort of manager. You can name it GUIManager for example.
Managers should always be singletons.
This is gonna hurt the people who only use DI
It's okay though they need to learn
DI?
Wait, you can have singletons and not create a static getter for them right?
I suppose you could
But that's be more ambiguous imho
regardless of singleton pattern and my pointless interjection, the point is you should really only ever use one instance of your manager
who says
Which was synonymous for singleton to me. Let me double check.
Dependency Injection
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
its fancy for use the constructor
Pretty much
personally I think DI is kinda terrible sometimes but lets keep that on the down low
you sound like a static lover
It can be incredibly difficult to enforce, yeah.
But it can also enforce a strict design for your project.
no but if you're passing a manager class into every single class you're doing something wrong
Wait i got an idea XD
wrong with what
my mental state?
okay if i have multiple inventories, do i have multiple maps in the manager or do i mark the inventoriess another way?
if it is my mental state yeah somethings up
public class ManagerRegistry {
private final Map<Class<?>, Object> registeredManagers;
public ManagerRegistry() {
this.registeredManagers = new HashMap<>();
}
@SuppressWarnings("unchecked")
public <T> T getManager(Class<T> managerType) {
return (T) registeredManagers.get(managerType);
}
public <T> void registerManager(T manager) {
if (this.registeredManagers.containsKey(manager.getClass())) {
throw new IllegalStateException("Cant register the same manager type twice.")
}
this.registeredManagers.put(manager.getClass(), manager);
}
}
Just pass this everywhere XD
unrelated, but is this the correct way to double an entity's health?
java vindicator.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(vindicator.getHealth() * 2); vindicator.setHealth(vindicator.getHealth() * 2);
the entity just kinda vanishess after a tick
no error in console though
You should get the health via the current attributes base value
like that?
AttributeInstance attribute = vindicator.getAttribute(Attribute.GENERIC_MAX_HEALTH);
attribute.setBaseValue(attribute.getBaseValue() * 2);
Yes
okay ill try that
.
no i dont recommend that
just add a max health attribute to the entity equal to their base health attribute
you can use the ADD_SCALAR operation of 1 to just add +100% max health
or is that just items i forgor
You mean adding a modifier to the health. But if he wants to change the entities acutal base health then
you dont want a modifier.
that would change the actual base health wouldnt it?
That wouldnt change the health.
it wouldnt change the base health value which i think is less messy, it would double their hp though
but it would change the max health, and then i can set the health to the max health cant it?
wait
You want MULTIPLY_SCALAR_1 i think
if you do multiply scalar 1 you need to put 2 and not 1
add scalar is literally +x%
so +100%
1, AttributeModifier.Operation.MULTIPLY_SCALAR_1
would result in result = base * (1 + 1)
multiply scalar 1 would be just x% so 200%
https://www.spigotmc.org/threads/laser-guardian-and-crystal-beams-1-9-1-20.348901/
[09:50:10] [Server thread/WARN]: at java.base/jdk.internal.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:57)
[09:50:10] [Server thread/WARN]: at java.base/jdk.internal.reflect.UnsafeQualifiedObjectFieldAccessorImpl.get(UnsafeQualifiedObjectFieldAccessorImpl.java:38)
[09:50:10] [Server thread/WARN]: at java.base/java.lang.reflect.Field.get(Field.java:425)
[09:50:10] [Server thread/WARN]: at fr.skytasul.guardianbeam.Laser$Packets.getField(Laser.java:1008)
[09:50:10] [Server thread/WARN]: at fr.skytasul.guardianbeam.Laser$Packets.<clinit>(Laser.java:746)
[09:50:10] [Server thread/WARN]: at fr.skytasul.guardianbeam.Laser.<init>(Laser.java:61)
[09:50:10] [Server thread/WARN]: at fr.skytasul.guardianbeam.Laser$GuardianLaser.<init>(Laser.java:312)```
getting this from the guardian laser resource, i've used it before, but is this the result of the name of the fields changing in 1.20.2?
or can it not easily be fixed
okay ill just try multiply but it probably doesnst matter
Which is double in my books...
Yeah
doess anyone have an answer to this questsion?
i have given an example for the system, https://github.com/The-Epic/ebiclib/blob/master/ebiclib-core/src/main/java/xyz/epicebic/ebiclib/inventory/CustomInventoryManager.java
Who has encountered duping while canceling the inventoryClick event. When while clicking on an item it remained in place but was also picked up by the mouse cursor
Depends on how you want to scale this system.
Usually you just map an inventory to a special handler for this inventory:
Map<Inventory, CustomHandler>
CustomHandler can be abstract and have onClick() onClose() etc.
No if you have an InventoryClickEvent, you ask the Manager which CustomHandler is mapped to this Inventory
Cancel the InventoryDragEvent as well as the InventoryClickEvent. Clicking really fast can sometimes trigger the drag event instead of the click event.
and then i ask the custom handler which player is mapped to it
?
seems to overcomplicate it
the player doesnt get mapped, it uses the view
oh really thenks
okay
Bygoing off the view you already have what you need from the event
doess instanceof work on null?
you shouldnt need to instance check anything
the custsominventory handler
Yes it will be false for that case
okay
in the click event im getting the custom inventory handler from the view and then im checking if its an instance of a sspecific handler to know which inventory they clicked
you know what inv it is from the map
I'm trying to use Jedis but I'm getting java.lang.NoClassDefFoundError: redis/clients/jedis/JedisPool
I'm using Maven and I have shaded Jedis like this:
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>redis.clients.jedis</pattern>
<shadedPattern>online.djsao.event.halloweenplugin.internal.jedis
</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
...
I'm using Kotlin with the JetBrains kotlin-maven-plugin. I don't exactly know what's wrong with this?
you get the view and now have a custom inventory instance
how?
yes but i have to use instanceof to know which cusstsosm inventory it is
no you dont
my s button is broken btw so dont mind
how do i know which of my custsom inventories they clicked on then?
its an isntance of custom inventory
Jedis issue
wait i think were not having the same structure
my cusstosminventories extend one CustomInventory class
do i have to make an example project
um why are you creating a cutom inventory?
This doesnt though for some reason, the vindicator is not spawning
public class consoleMessageEvent extends Event {
private static final consoleMessageListener cml = new consoleMessageListener();
private static final HandlerList HANDLERS = new HandlerList();
private final LogEvent logEvent;
public consoleMessageEvent(LogEvent event){
this.logEvent = event;
}
public Message getMessage(){
return logEvent.getMessage();
}
public Level getLevel(){
return logEvent.getLevel();
}
public String getLoggerName(){
return logEvent.getLoggerName();
}
public Instant getInstant(){
return logEvent.getInstant();
}
public static HandlerList getHandlerList() {
return HANDLERS;
}
@NotNull
@Override
public HandlerList getHandlers() {
return HANDLERS;
}
}
@Plugin(name = "Log4JAppender", category = "Core", elementType = "appender", printObject = true)
class consoleMessageListener extends AbstractAppender {
public consoleMessageListener() {
super("Log4JAppender", null,
PatternLayout.newBuilder()
.withPattern("[%d{HH:mm:ss} %level]: %msg")
.build(), false);
}
@Override
public boolean isStarted() {
return true;
}
@Override
public void append(LogEvent event) {
/*String message = event.getMessage().getFormattedMessage();
Level level = event.getLevel();
JSONObject logData = new JSONObject();
logData.put("message", message);
logData.put("level", level.toString());*/
consoleMessageEvent cme = new consoleMessageEvent(event);
msg.log("calling the event");
Bukkit.getPluginManager().callEvent(cme);
}
}```
Does anybody know why this event isnt being sent ? I have a similar class on another side project (it only listens for the conosle though) and it works alright
hey
if you use getPluginLoader().disablePlugin(..) on onEnable, do you have to put return after it so that it doesn't execute the code afterwards OR does it jump to onDisable right after?
consoleMessageEvent -> ConsoleMessageEvent
🙏
consoleMessageListener -> ConsoleMessageListener
Evening :)
i prefer my camelCase like that
You break ever naming convention of java
ohno
am I just being stupid or why is this.saveDefaultConfig() erroring in my onEnable()?
error: The embedded resource 'config.yml' cannot be found
anyone?
oh no ! 😰
clean and repackage
Vindicator vindicator = (Vindicator) event.getPlayer().getWorld().spawnEntity(event.getPlayer().getLocation(), EntityType.VINDICATOR);
AttributeInstance attribute = vindicator.getAttribute(Attribute.GENERIC_MAX_HEALTH);
attribute.addModifier(new AttributeModifier(UUID.randomUUID(), "Viking Horn", 2, AttributeModifier.Operation.MULTIPLY_SCALAR_1));
vindicator.getPersistentDataContainer().set(DominionSMP.DOMINION_ENTITY_KEY, PersistentDataType.STRING, "VIKING_" + event.getPlayer().getUniqueId());
For some reason this vindicator does not appear in the world
what is that supposed to mean
run mvn clean then run mvn package
You are likely building using artifacts not Maven
also i get this error and i have no idea whats the problem with it
you love kitties dont you
i do
same error
i do have a kitty yes
send pic xD
dm so we dont go off topic
is there like an anvil item rename event?
and also an event for when each character is inputted?
anvil item prepare event or something like that
what
onEnable will continue
It won’t know to stop unless you return
put a return
it won't stop, as that's not how java works
an error would have to be thrown or a thread interrupt in order for the code to stop
it should get called for all item modification in an anvil
I'll try it, thanks
what List (or different collection) implementation should i use if i want to loop over values and remove them after iteration?
After (bulk like removeAll()) or while iterating (iterator.next() -> check something -> iterator.remove())?
while
LinkedList
There is removeIf
random access will be slow right?
theres no condition i would be checking for
A queue
Yes random access is O(n), but removal while iterating is O(1)
its just
iterate
do something
not needed anymore -> trash
But you dont need random access if you just iterate
This is how i like to use LinkedLists in my workload guide
👍 linkedlist is fine
You can also be special and use some other dequeue or smth
LinkedTransferQueue 
Which is a lesser known but actually really cool collection for multithreading
gotta sit down one day and learn em all
I sat down and did a bunch of benchmarks/research for the most used collections
eyo what
java.util.ConcurrentModificationException: null
at java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:970) ~[?:?]
at java.util.LinkedList$ListItr.next(LinkedList.java:892) ~[?:?]
...
You need to use an iterator.
.remove(Object) would be O(n) otherwise and iterates over the whole list again
You can also do this:
linkedList.removeIf(element -> {
element.doSomethingCool();
if(element.isDone()) {
return true;
} else {
return false;
}
});
It iterates over the whole collection, does something with every element and returns true if it should be removed.
Or in short
linkedList.removeIf(element -> {
element.doSomethingCool();
return element.isDone();
});
theres not rly any condition in my code
anyone got a guardian beam api for 1.20.2
I was gonna scold you so hard
ty for fixing

Hello there , iam using :
private ScheduledExecutorService executorService;
but when i want to stop it :
it send me the message :
but the code keep running
also using :
scheduleWithFixedDelay
so it must run every 1 minute and a delay bettwen them is 5 minute
I think shutdown only stops new tasks from being scheduled. Let me check if this changes for a scheduled executor
Yeah looks like you need to interrupt the scheduled tasks if you want to promptly stop a scheduled executor.
You can do that with shutdownNow();
What prevents you from using the bukkit scheduler and an async task?
to much work :-:
executor service is nice cuz you can use CompleteableFuture
?
@twin venture unless your using CompletableFuture api you should really just be wrapping the Bukkit scheduler
you can make it a singleton and intiailize it on startup
then you don't have to worry about passing around your plugin instance
alr thanks for the advice
anyone got particle usage tutorial?
hey, in public boolean onCommand(..) when are you supposed to return true and when false and what is the difference?
is it supposed to be true when something is done successfully?
Returning false shows the usage to the command sender. true means the parameters where correct and the command did something.
Ok awesome thanks!
Yeah exactly.. I handle usage messages myself
Just wanted to know the difference now i do
you can actually get the plugin command using getCommand() and set all the settings using that
I make all messages customizable in config.yml
idk how liberating the actual object is but you usually can just use #setUsage #setDescription etc
including usage messages
can someone explain to me why this breakpoint triggers when spamming right click?
Accidental slip on the left mouse button 🙂
autoclicker time
I tried this and there is not a single click coming through. Doesnt matter if air, entity or block
yea i tried with an autoclicker, didn't happen
but its been reported to me this happened to a bunch of people
so idk
Might be some other code
arent bukkit events only callable server-side?
idk how to answer this
I use the breakpoint to highlight exception lines 
also pretty sure that plugin is the only one running. considering it didnt happen with the autoclicker ur probs right with hitting m1 accidentally, but that doenst explain why so many people reported it happening
- Client sends packet to server
- Server runs some code
- Server detects something happening
- Spigot fires event
- All plugins get event
- Server gets event
- Server does more calculations
- Server sends packet to update all other players on the new state
ah, so u can fire it with either protocollib or nms i assume?
oh on that topic
do you know if you can separate ArmAnimationEvent into left click and right click?
i'm having a problem where PlayerInteractEvent nor EntityDamageByEntityEvent happens when a player looks at a entity at a distance of around 4-5 blocks and presses left/right click
I mean... the PlayerInteractEvent is fired for sure
0.719827 0.952823 are the x/z offsets where if you use water to position an entity in a corner away from you it triggers neither of those events
idk the exact distance unfortunately
but i know for a fact it doesnt trigger
i used a zombie piglin
where should I put this code in my plugin?
survival mode maybe
anywhere
if I want to make it scan for entities when I right click do I just put it in listener?
🤷
no
if there were it would be implemented in fileconfiguration directly
In c++ there are templates for that but what does java have?
If you try to do it all in one method you'll end up with a confusing mess due to type erasure
Ok thanks
Generics. But the types are not present at runtime.
Yeah.. I'll think of something and redesign the class a bit
I mean this can be done with an unsafe cast. It relies on your trust that FileConfiguration has the means to properly serialize the Object in this path
Yeah, how would I do this?
Eh I'll redesign the class I think I'm overcomplicating stuff
@SuppressWarnings("unchecked")
public <T> T getValue(String path) {
return (T) this.fileConfiguration.get(path);
}
Or with type inference
public <T> T getValue(String path, Class<T> type) {
Object value = this.fileConfiguration.get(path);
if(value == null) {
return null;
}
if(!type.isAssignableFrom(value.getClass())) {
return null;
}
return type.cast(value);
}
doesn't FileConfiguration have a getter for that
It does but that's fancier
Oh yeah
public
bro pasted a method inside another method
XD
public
Yeah, what youve done here is no longer java code
Yeah, i can see that.
My current Config class, like a wrapper for FileConfiguration
Copy it into your class and call the method
method inside method
so what's preventing you from just making a getter
Imagine not just delegating using kotlin
fileConfiguration is a variable inside of Config class. I'm trying to create a fancy method get(String configPath) that would retrieve the value (Object) from the config.
If not, I would have to do config.getFileConfiguration().get(.....)
great if you want you can trash talk me further in dms
?learnjava
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.
Let’s fight
Hey I'm really struggling to compare two different colors, does anybody else by chance know how to do this?
The special was fire 🙂
Not really the wrost thing i have seen
I didn't even know you could do that
You can’t
u can
Not really
