#help-development
1 messages · Page 1686 of 1
Ok then yeah use a set
I mean, just look at the exception
It tells you exactly what is going wrong and where
works, thanks
@EventHandler
public void useItemInHand(PlayerInteractEvent event)
{
if (event.getHand() == EquipmentSlot.HAND) {
if (event.getPlayer().getItemInHand().getType().equals(Material.FIREWORK_ROCKET))
{
if (CoreMethods.isPlayerGliding(event.getPlayer()))
{
ItemStack chestplate = event.getPlayer().getInventory().getChestplate();
if (chestplate.getType().equals(Material.ELYTRA))
{
chestplate.setDurability((short) (chestplate.getDurability() + 2));
}
}
}
}
}```
Is anyone able to explain why this is getting called twice? I know it's related to the `OFF_HAND` but I can't figure out how to solve it
Should only make it past that first if once
I'm losing 4 durability on the Elytra when it should only be 2 though?
You don’t like staircases?
You don't even need to check the hand of the event because fireworks can be used from either hand
I do not like arrow code, no
if (e.getAction() != Action.RIGHT_CLICK_AIR || e.getItem() == null || !e.getPlayer().isGliding()) {
return;
}
ItemStack item = e.getItem();
if (item.getType() != Material.FIREWORK_ROCKET) {
return;
}
ItemStack chest = e.getPlayer().getInventory().getChestplate();
if (chest.getType() != Material.ELYTRA) {
return;
}
chest.setDurability((short) Math.min(chest.getType().getMaxDurability(), chest.getDurability() + 2));
e.getPlayer().getInventory().setChestplate(chest);```
Something like this would be a whole lot better
In that it works no matter which hand the firework is in, and it won't end up with negative durability if their elytra is already broken
You also don't need a separate utility to check if a player is gliding
It's an existing method of Player
You may also be able to do this on ProjectileLaunchEvent, which I would imagine is fired if they boost with a firework midair
But it's worth noting that the level of unbreaking on the item also affects the damage it takes when using a firework
Assuming you're trying to recreate the snapshot behavior
Didn’t spigot fix negative durability at some point
Not to my knowledge
Or was that stack sizes of 0 when using setAmount
Hey thanks for the input there!
Just gave it a try and I think the durability removal is broken as it completely breaks a new elytra
Oh sorry it should be Math.min not Math.max
Sorry, used to doing Math.max to prevent things going negative but forgot durability is reversed, higher = less durability (for some reason)
Yes! Absolute legend! Thank you so much!
In the future
Avoid indenting your code with nested if statements
It makes it hard to follow and hard to keep onscreen
Use early-return, exit the method early when you hit a fail condition rather than nesting if statements
Alright thanks, will do! I've always used nested statements
Nested if should be avoided at all costs
And if-else should be avoided in general as well
hey there yall, me again
Hi
getting an Access is denied error while trying to access the world folder of my server
Access it how?
I know windows is weird about letting you use files that are in use by other programs
try {
FileReader file = new FileReader(player.getWorld().getWorldFolder());
player.sendMessage(file.toString());
} catch (FileNotFoundException e) {
e.printStackTrace();
}```
that's the code im using
Can I see the full exception
java.io.FileNotFoundException: .\world (Access is denied)
at java.base/java.io.FileInputStream.open0(Native Method)
at java.base/java.io.FileInputStream.open(FileInputStream.java:211)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:153)
at java.base/java.io.FileReader.<init>(FileReader.java:75)
at me.omaknight.lootTableViewCommands.lootTableView.onCommand(lootTableView.java:53)
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45)
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149)
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.dispatchCommand(CraftServer.java:776)
at net.minecraft.server.network.PlayerConnection.handleCommand(PlayerConnection.java:1931)
at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1770)
at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1751)
at net.minecraft.network.protocol.game.PacketPlayInChat.a(PacketPlayInChat.java:46)
at net.minecraft.network.protocol.game.PacketPlayInChat.a(PacketPlayInChat.java:1)
at net.minecraft.network.protocol.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:30)
at net.minecraft.server.TickTask.run(SourceFile:18)
at net.minecraft.util.thread.IAsyncTaskHandler.executeTask(SourceFile:151)
at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23)
at net.minecraft.util.thread.IAsyncTaskHandler.executeNext(SourceFile:125)
at net.minecraft.server.MinecraftServer.bf(MinecraftServer.java:1148)
at net.minecraft.server.MinecraftServer.executeNext(MinecraftServer.java:1141)
at net.minecraft.util.thread.IAsyncTaskHandler.awaitTasks(SourceFile:134)
at net.minecraft.server.MinecraftServer.sleepForTick(MinecraftServer.java:1125)
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1054)
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:305)
at java.base/java.lang.Thread.run(Thread.java:831)```
Interesting
Not sure what would cause that other than windows file handles being weird
i'm gonna try just calling the actual file name and see if that works
yeah no it cant find the file
Q: how can i mkae a command alias thats "ars help" i have one for "ars" as we have 2 plugins that use /rs just tring to reformat om=nes help output {there is no lang or messages file and the GH for it is 404}
commands.yml
let me reprase,
we have 2 plugins that use /rs as their prefix,
we are tring to redo one of them so we can have /ars
we need to reformat /rs help to display /ars as /rs will not work, sadly the plugins GitHub is 404'ed so i cant just recompile it {would need to as it has no lan or messages.yml}, ive gone in commands.yml however /ars help will not work however using /ars to run advancedredstone:rs $1 $2 works
Oh
You can't really just modify the command's help messages without editing their code
You'd need to decompile, edit, and recompile it
thats why i was wondering if i could override it with /ars
would just decompileing the jar work?
Should
It's a pain but it should work
You'll need to manually sort out any dependencies it has
i assume just using 7zip would not work correct?
It would not
That would still leave you with compiled source code
You need something like procyon or fernflower
ill try those, hopefully will be simpler than eclipse
Well... you could always take a "sneak peak" at the plugin.yml inside the jar ans change the alias if its defined there
i found it, tried to recompile and well, failed horrably
its in org.dragonet.remoteredstone > rs > RSCommand.class
Yeah it needs the classpath to compile
do you by chance know how id do that in eclipse?
You know what? Just send me the jar, I'll do it
You don't even technically need to decompile and recompile
i have the decompiled java if you want it, and thats very kind of you
should i dm you?
what plugin is he working on?
You should be able to do this with Statistics
I am creating a plugin that loads three new world: 1 new overworld, 1 new nether world and 1 new end world. But when i enter a portal it takes me to normal world, nether, end. How can i change the world in which the portal will get created (simply link custom nether to custom world). Ive tried with PlayerPortalEvent but I can just change the location the player will be teleported, not the world a portal is created. Ive read, that travelagent has done that but it was removed.
bump
what lol
it wants a short/byte
not an int
my material is stained clay
my int amount is 1
and my short/byte is t.getWoolColour()
in the playerTeleport event, why is this making me face directly north east south or west, depending on what's closer instead of making me face the direction i was already facing?
event.getTo().setDirection(player.getFacing().getDirection());```
hey i been looking into local Maven repository. And i cant see remapped-obf
any help please
Jave you used the buildtools flag?
Anyone that could help?
well idk which block faces getFacing returns
it could just be the ones on North, South, East & West
Hello, i try to get the book author for a specific Element. At this point, i only get the Author names of all Books but i only want the Author names of a specific book.
https://hastebin.com/zewaduyufi.php
My XML:
https://ibb.co/ZfXFT95
?ban @ripe lagoon
Done. That felt good.
Wow someone took action
Intercept the packets
I recommend using Protocollib. Note that not all particles can be hidden by the server
Hi, is it possible to get all regions in WorldGuard API? If anyone has experience with it. Looked through documentation but got confused :c
(and preferably do a for loop through them)
There's things like
region.contains(BlockVector3.at(20, 0, 30));
But I need to get all 400 regions on server that I have
not only at specific location
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionManager regions = container.get(world);
regions.getRegions().values().forEach(region -> ...);
Just by looking at https://worldguard.enginehub.org/en/latest/developer/regions/managers/
Oh thanks.. I was just thinking of that but im way too slow.. 😄
Can u guys help me? It writes me "failed to verify username"
What to do? :C
You can hide particles when giving an effect
How would I go about registering default entity attributes for my custom nms entity
i know
But I mean if a lot of players have particles and I want to hide the particles I just don't want to see it
you can turn off particles in your game settings
particles can still be forced by the server
Creating an item framework to easily make new items
Oh no.. my jar file is 1kb and only has my yml file 😦 what am I doing wrong? Intelij IDEA.. 😄
how do i get the amount of sleeping players?
public long getSleepingPlayerCount() {
return Bukkit.getOnlinePlayers().stream().filter(LivingEntity::isSleeping).count();
}
Or
public long getSleepingPlayerCount() {
int count = 0;
for (final Player player : Bukkit.getOnlinePlayers()) {
if (player.isSleeping()) {
count++;
}
}
return count;
}
The second instantiates less objects ftr.
Simple approach to filter a specific packet type for a group of players:
public class ParticleFilter extends PacketAdapter {
public ParticleFilter(final Plugin plugin) {
super(plugin, Server.WORLD_PARTICLES);
}
private final Set<Player> filteredPlayers = new HashSet<>();
public void addPlayer(final Player player) {
this.filteredPlayers.add(player);
}
public void removePlayer(final Player player) {
this.filteredPlayers.remove(player);
}
@Override
public void onPacketSending(final PacketEvent event) {
if (this.filteredPlayers.contains(event.getPlayer())) {
event.setCancelled(true);
}
}
}
(Using ProtocolLib)
Just make sure to remove them when they log out.
damn that's clean
ProtocolLib epic
why does paper says my plugin is legacy if its not?
What api-version did you specify in your plugin.yml?
i didn't?
I think I know the cause but... what am I supposed to do here lol
These are random modules registered in my IDE
- Do you use maven?
- How do you compile
Yes. I think I figured it out, I reset maven configuration and restarted, seems to work now
Although now .jar is 3.5mb 😄
still testing
how do i do something in bed enter event only when the player is really sleeping
declaration: package: org.bukkit.event.player, class: PlayerBedEnterEvent
._.
why do i still take dmg after skeleton's death
when player clicks on the bed it executes the code even on day thats what i'm talking about 🤦
declaration: package: org.bukkit.event.player, class: PlayerBedEnterEvent
so why do i take damage even after my custom boss is dead
You start a scheduler and never stop it
So I can‘t replace a NMS Entity's attributes in the constructor because of my entity because the super contructors rely on it and nullpoint immediately, and I can't modify the default attribute registry anymore because java 16 removed the field modifiers hack
So what am I supposed to do now
So you want to introduce complete custom attributes? Or just change the value of current attributes like generic.max_health
There are several ways.
Its called if
Well, as you know I created a completely unique nms entity. But the default attribute registry, which is used to fetch the attributes, is a private static final immutable map of hardcoded entity types
And since my entity type is not part of that map, it fails to fetch the attributes and nullpointers during the constructor
I have set up a reflection way to replace the attributes with a valid one, but since it nullpointers in the constructor I cannot replace it in time
And thanks to Java 16's new reflection handling, replacing the default registry map is effectively impossible
One example on a self cancelling task. Although i dont recommend
having a ton of tasks. Just use one single task that maintains a collection of tickables.
final UUID playerID = player.getUniqueId();
new BukkitRunnable() {
@Override
public void run() {
final Player onlinePlayer = Bukkit.getPlayer(playerID);
if (onlinePlayer == null) {
this.cancel();
} else {
onlinePlayer.sendMessage("Hi");
}
}
}.runTaskTimer(plugin, 10, 10);
so this can function as a DPS for a boss?
Fking mojang
Because the runnable never stops
well ofc changeing the stuff, but this should fix it?
Hm. And the custom type you pass in the constructor is used as a key to fetch the attributes from the map?
By the super constructor
Ill have to take a look at that...
AttributeDefaults. This class looks like bad design.
(Mojmap btw)
Tried to implement a hashCode method that matches one of the types currently in the map?
Hm
I don't think I can do that, because the key is the entity type
Which I can't realisticially extend
Ah i see...
maybe I can overwrite the entity type after the fact, and pass a valid one as placeholder
If that works
how can i set an id for a task that isnt in main class
The id is specified by the BukkitScheduler.
how can i get it
You get it when scheduling the task
int taskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, task, 10, 10);
replace taskId with int?
final BukkitTask bukkitTask = Bukkit.getScheduler().runTaskTimer(this.plugin, task, 10, 10);
bukkitTask.cancel();
This is more than enough info
i see
one last question, not really about code
do i have to put this in the main class?
When I create a offline player with a uuid, and use getPlayer to get the abstracted player, will it become a valid craftplayer and return true for isOnline when the player comes on?
I have a Item-Builder and created a FIREWORK_CHARGE, how can I change the color of it?
Search for a base64 serializer and store every particle in the database under base64 https://gist.github.com/graywolf336/8153678 something like this
```language
code
```
k ty
hey there yall
trying to read a file as return it as a string, having a bit of an issue
try {
FileReader file = new FileReader("world/datapacks/Test Datapack/data/testpack/loot_tables/entities/custom.json");
while(file.read() != -1) {
testString += file.read();
}
file.close();
player.sendMessage(testString);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}```
this is returning a large string of numbers, which i guess is to be expected of .read(). what else should I be using?
why do you have 2 catches?
auto generated, not necessarily sure if i need both though
doing /reload is bad
when i pass in the location, wether or not i actually stand on the block it always returns false
woops
You'd have to use resource packs for the model and then probably send a packet to each player for whatever you wanted to show them
or make a mod
Yeah or do that
how do i enable the PlayerBedEnterEvent only when the player really sleeps (not just clicks)
Can someone for the sanity of my soul say, why this spwes out air as the block
if(location.clone().subtract(location.getX(), 0.501, location.getZ()).getBlock().getType() != Material.AIR) {
System.out.println(location.clone().getBlock().getType());
return true;
}
it is not supposed to do such a thing
Check isCancelled() maybe?
Because you're not subtracting 0.5 from the printed value.
You're not subtracting anything from the printed value for that matter
not?
i only want the block 0.501 below him
and i do that
or am i completly dumb?
Yeah the if check is probably fine, youre just printing a different block.
now its workin
removed the clone()
well that was not good XD
now its printing me oak_leaves when jumping on stone
Don't subtract location.getX and location.getZ
That makes it always 0, Y, 0 instead of you location
like dis
if(location.clone().subtract(0, 0.501,0).getBlock().getType() != Material.AIR) {
Yes
good thing
now lets see if it works
wow this escallated
when tryin to jump now i get flagged to death
What does that mean
its detecting me as an nofall hacker woops
but i know how to fix that
probably
Infact no
I could not fix it
is new Example().doSomething() the same as Example e = new Example; e.doSomething() in a private method?
ok
The 2nd one you just can’t access the same instance again
Becuase it’s not declared a variable
yea i know
Just remember if doSomething() is private you can't call it outside of the Example class.
I think you mean first one? 
ofcourse 😼
You said private so I was just making sure you knew 
yea inside a private method i make the object
Ah, yeah that doesn't really matter as long as Example and doSomething can be accessed from that method.
It's modifier doesn't matter for calling other methods
My only guess would be is that is says something as them
@ VectorExperts
Looking for some vector help. I'm trying to understand the axis' a bit better. I'm using 2 locations and creating a vector between them, I then normalize because I'm only interested in the direction of the vector. Now I want to turn the vector 90 to the left, now the 2 locations initially may not be at the same height level so when rotating the vector the vector may increase/decrease in height as it is rotated on the horizontal axis... This is my understanding. Im looking to modify the vector so the arrow will be parrallel to the ground, I believe this would be pitch? Therefore setting the vectors pitch to 0 would make the base of the vector and the end of the vector at the same height correct? Then I would be able to rotate the vector to the left and right with the vectors height staying the same at the base as well as the end of the vector. My last question is to rotate a vector to left or right I would rotate around the y axis correct? Therefore rotating the Y axis 90 degrees would turn to the right and -90 would turn to the left?
Vector vectorFromAToB = ...
Vector vectorFromAToBParrallelToGround = new Vector(vectorFromAToB.getX(), 0, vectorFromAToB.getZ());
0 in y = no modification to Y = parallel to ground
does it answer your question or did I read too quickly ?
It answers getting the vector parralel to the ground. Thank you. Now in order to rotate the vector left/right i would rotate around the y axis correct?
yeah indead. if you want to only change the x/z parameters the rotation has to be around the Y axis
Okay Ill give it a go thanks!
good luck !
how do i make the command permission none, so everyone can use it?
If its a command your writing yourself, dont do any permission checks
Is there a simple way to spawn particles in game to help visualize vectors
Hi guys. Strange bug :
I have to use the unusual method to register my listener:
Bukkit.getPluginManager().registerEvent(
this.eventClass,
this.listener,
EventPriority.LOW,
(listener1, previousEvent) -> {
//...
},
plugin,
false);
In the callback I use some instance able to transform an event A (let's say EntityDamageByEntityEvent) into a custom event B (let's say ItemLeftClickEvent).
since this class is generic, it contains a cast at some point:
eventClass.cast(event);
This cast throws an exception :
java.lang.ClassCastException: Cannot cast org.bukkit.event.entity.EntityDamageEvent to org.bukkit.event.entity.EntityDamageByEntityEvent
I used debugger to verify that "this.eventClass" is indeed a EntityDamageByEntityEvent (and not a EntityDamageEvent) when calling PluginManager#registerEvent method and I did not see any issue there.
How is it possible that my event handler retrieve a EntityDamageEvent and not an EntityDamageByEntityEvent ?
In short no. You have to build functions to show a line.
public void showLine(Location locA, Location locB, double distanceBetweenPoint)
ok
Awesome
Hmm I found it back but it will not help you:
- It's in order to show some cuboid edges (and one of its diagonals)
- It's built upon my own NMSManager
https://gitlab.com/lasersenigma/lasersenigma/-/blob/master/core/src/main/java/eu/lasersenigma/areas/AArea.java#L667
Sorry ^^
you will have to do it yourself ^^
Okay no worries Ill take a look and maybe get some ideas
What are these random teams? Whenever I try to access them it says they do not exist.
I am trying to find out because I want to make nametags invisible but all available teams have this option on never and I can still see them.
Why the fuck am I retrieving a EntityDamageEvent when Listening an EntityDamageByEntityEvent ?
Is it a spigot issue ?
Or did I do something wrong :/
for some reason my resourcepack doesnt show up in the list
bruh
What theme is this ?
I can't use a simple listener in my case.
I don't do this for fun... just for advanced modular features ^^
Material Theme > Darker Theme
why
how do i get server tps?
./tps
nms
Oh
MinecraftServer#recentTicksPerSecond i think
i'm talking about development not commands
Because I dynamically build and register event listeners according to modifiable data saved in json.
i worked with that these days
But that does not change the fact that I should receive a EntityDamageByEntityEvent and not an EntityDamageEvent (that, in addition, can't be casted to an EntityDamageByEntityEvent).
MinecraftServer#recentTps
I think it's a spigot bug related to the lact of the static HandlerList within this particular event (that may explain why I retrieve its parent).
((CraftServer) Bukkit.getServer()).getServer().recentTps
you could simply create a global listener
and call sublisteners
you can't listen to abstract event. Moreover that would be highly inefficient.
wtf is CraftServer
public void onDamage(EntityDamageByEntityEvent event) {
for (SubListener listener : listeners)
if (listener.canListen(event))
listener.listen(event);
}```
pseudocode
is from nms
actually is from org.bukkit.craftbukkit
i don't have that
?buildtools
fuk]
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
/buildtools
So this is not a global listener: If I have 30 events that can be specified in json, I have to do that 30 times ^^
anyone?
That's why I prefer registerEvent ^^
if you use registerEvent the bukkit will do the same thing
¯_(ツ)_/¯
Anyone know of a plugin like this to display custom titles under the players names
I think there is a difference. And I think that exactly because of the issue I found.
If you use the usual Listener you will only retrieve EntityDamageByEntityEvent because a cast check is probably done beforehand.
If you use registerEvent you may receive a EntityDamageEvent because this cast check is not done and because EntityDamageByEntityEvent does not have its own HandlerList (I suppose that's the reason of this spigot api bug).
here is about development
search for name tags plugin
I will just add the check ^^
if you want a plugin, idk
if you want how to do it, armorstands mounting players
pretty sure plugins fall under development lol, thank you Wizarldy!
This channel is for developing plugins, #help-server is generally for finding them.
What was it
(not very important but still very annoying)
maybe there is an \n?
nah...
Send the code where you're sending that. You probably have a blank sout or a \n somewhere.
I'll show you
well
ChatColor.DARK_GRAY + "[" + ChatColor.GRAY + "CastleSiege" + ChatColor.DARK_GRAY + "] " + ChatColor.RESET```
there ya go
happens on another plugin as well
an idea ?
Does it do it if you remove ChatColor.RESET
well
how do i get server uptime?
how can i check if the EntityType im hitting is a player
if(entitywhatever instanceof Player)
i want to send a message to the damager to see how much hp the damaged player has
well, already answered ?
yeah but how do i get the targets health
if( event.getDamagedEntity instanceof Player)
I mean, something like that
I don't know all ways of doing it
by the way
to get back on my issue
well
removed all jdk
and reinstall jdk 12 and the "runtime environment" thing
To be honest
java versions compatibility sucks
which spigot version are you running
use jdk 8
welcome to windows
WHY DO YOU NEED TO LOG IN
just specify the full path to the specific jdk in the other servers
use adoptopenjdk
You can tell Windows to use a specific version of Java for a specific task.
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
oh yea I already searched
understandable but
somehow my pc just doesn't want to act the way this guy's ants
xznts
wanrs
wanrs
wants
god damn
hope i helped
just build OpenJDK yourself
absolute gamer moment
WHY DID
oh aaa
THANKS
I SAID
WINDOWS LAUNCH THIS SLDKFJSDLKJF MESSAGE
now my wifif keeps disconnecting
for 2 months now
anyway
U'kk cgecj tgat
I'll check that
hmmf
guess NOW I can code peacefully
thanksssssssssssssssssssss
I will leave it like this!
you can use Math#round
or google
math.round helped
is there a way to determine if an entity is a passenger? From what I've found you can only see if a entity has passengers
how can i make it so that when i hit a mob, it dings for me
I think there is player.isInsideVehicle()
with a bow
in my case it would be for non player entities
oh lol yapperyapss ye
player.playSound(player.getEyeLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1F, 1F);
Player extends living entity
yeah but what if i want to do it with a bow
more specifically jockey mobs like skeletons, zombies, etc
oh you're saying .isInsideVehicle is part of the Entity interface?
EntitiyDamageByEntityEvent
if attacker instanceof Projectile
ProjectileSource from Projectile
if ProjectileSource instanceof Player
play ping to source
oh makes sense thanks!
Anyone have any tutorials or starter points for making a plugin framework?
E.g. framework for custom items, mobs etc.
some shiz wrong?
it said Line 16 is wrong which is:
ProjectileSource source = ( (Projectile) event.getEntity() ).getShooter();
Your checking damage event. You need to test if the entity causing the damage is a projectile
public void onDamage(EntityDamageByEntityEvent event) {
if(!(event.getDamager() instanceof Projectile)) return;
// world.playSound()
}
How would i run a task async but get the variable outside?
as i cant run the world async
why is world red for me, it doesnt recommend me to import stuff also
run the operation back on the main thread inside the async task
ah
CompleteableFuture
thanks
thanks
I didn't find it
Yeah, looks like thats only for dropped Items
I need to prohibit the use of an experience bubble with the name
What do you mean experience bubble?
yo dumb question
but i cant seem to be able to define the world
ik that the first half is World world
World world = event.getDamager().getWorld()
This doesnt look like it needs to be done async. Im almost certain that spawning a new thread has
practically the same overhead on the main thread.
fuck i hate asking for help, but i have to, it is also very basic probably,
Declaration not allowed here
It's telling that to:
World world = event.getDamager().getWorld();
wait dont answer yet
Show your code
oh
i put it in the if statement
oh
lmfao
i fixed it
just need to move my 2 brain cells
👍
how would i optimise this? As i cant do chunk loading off the main thread, i dont think there is much i can do for this
Not much. But if you remove the airdrop later anyways then you can just add a plugin ticket to the chunk
and keep the chunk loaded as long as the airdrop exists. This way the chunk wont constantly unload.
oh thanks
exp bottle
What exactly do you want to prevent? Throwing the bottle, exp spawning when the bottle pops
or picking up the experience afterwards.
Throwing the bottle
this still doesnt work smh. I have tried to get a resolver, which tells what source the arrow comes from, still no ding on Mob hit
ah thats completely different
Have you tried just cancelling the PlayerInteractEvent?
what is the probleme here
there are many problems
list them
well, one
look at this
i want it so that when i hit a mob with arrow, it dings
or lets take it simply, play a sound
I only need to cancel an exp bottle with a specific name
@solid cargo
if (event.getDamager() instanceof Projectile) {
//dont forget to get the projectile sender
}```
That also works if a shulker hits u tho
i can get the projectile sender by
ProjectileSource source = ((Projectile) event.getEntity()).getShooter();
right?
for this reason i said to check the shooter
yes
check if the source is a player
if yes
gg
if not
sad
@EventHandler
public void onHit(EntityDamageByEntityEvent event) {
Entity attacker = event.getDamager();
// If attacker is not a Projectile then do nothing
if (!(attacker instanceof Projectile)) {
return;
}
Projectile projectile = (Projectile) attacker;
ProjectileSource source = projectile.getShooter();
// If ProjectileSource is not a Player then do nothing
if (!(source instanceof Player)) {
return;
}
Player shooter = (Player) source;
}
tysm, been trying to fix this for an hour, hopefully this works
i hate that in java if ur code even makes sense, it might not run
no
If your code makes sense then it will run perfectly fine.
yes
If code misbehaves then its 99.9% the fault of whom write it.
ok that was a bold claim
Idk how to fix this, so kinda wanna ask for help here so im gonna ask i hope im not bothering anyone's help session,
So im having this issue where when i click in this menu ive created it doesnt run the command for one of the items but for the other it does. And both of them have commands in them.
So i am wondering if someone can look into it and help me find out the problem.
Show some code pls.
do a simple item callback system
https://pastebin.com/7jvP2uw3 <- The entire class file.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
If he was able to write this then he would prob not ask for help XD
maybe he simply dont know about that
Did you literally write one big fat JavaPlugin class?
Thats horrible
Dont do that. Bat habits die hard.
do it before and save yourself the hassle
eh, well ill do it after this gets resolved then
i would do that with something like this https://github.com/WizardlyBump17/WLib/tree/main/core/src/main/java/com/wizardlybump17/wlib/inventory
would save a lot of time
- Refactor all your single letter variables.
- Dont identify the click action by the ItemStack that was clicked but the slotID.
Much more reliable for now.
@manic crater
yes
ah ok, so is that basically the key to my answer? xD
and make a simply system for to make an inventory based in a string
like
#########
1
#########
the # is black glass
the 1 is your item
This should do it for now. Just check the clicked slot ID instead of the clicked item.
much faster too
alright hold up let me quickly make an example and see if im on the right track.
Why not just make it with cmd blocks? Its much easier
bc cmd blocks can lag out ur server if multiple ppl open the menu.
Ah yes, why not use commands in the plugin?
Your UpdatableHolder#update() method could use some refactoring...
wdym im using commands...
Do you merge PRs?
Like use commands in the plugin (something like plugin.executeCommand("/replaceitem..."))
if it be a good pr
No. Im gonna break everything and leave a mess.
sad
Then force push to master
:C
Anyway sorry for long time trying to figure out something but
is this right?
if(e.getSlot() == 1)
agh i need to figure out better code block stuff i stg. xD
like do u think that would work by any chance or nah
This gonna take a while. Who supports 1.8 in 2021 anyways...
and i want to add all versions above 1.8
Ew
if ur using 1.8 ur plugin auto supports higher versions then 1.8 till some features start to break past 1.13.
i did a simple copy of xseries
at least for items
@lost matrix never got ur feedback yet on this but this does seam right in a sense yes?
What is "XSeries"?
ah ok
but still why dont u use 1.17???
1.17 has better stable support + its not broken like 1.8
ppl only play on 1.8 to play on hypixel without lag back issues and bugs.
- hypixel's developers develop plugins in 1.17....
Looks good to me
ight ok good, so i am on the right track, God bless your soul. <3
and i will be splitting up my entire plugin now so i dont have to hear like 500000 wtf's from ppl lmao
Well. 1.8 needs java 8 and i dont keep ancient software on my pc. Not gonna happen then.
lists of all minecraft servers updated 2021:
hypixel
hypixel
hypixel
hypixel
hypixel
hypixel
never. never type that EVER again like that.
it looks so spam like and takes up literally 1000000% of this chat.
java 8 and 1.8 are bs
Issue: Same issue still ocuring ;-;
well, i want that wlib have compatiblity with all 1.8+ versions and these versions are very used
mainly in brazil
1.8 is like 8% or something
if a normal brazillian tries to run 1.17 his pc will explode
Like idk why but only the message happens every other bit of code i put doesnt work for some reason in the gui.....
i mean at least a lot of ppl are using like some what NEAR the latest versions.
almost sure that this is of servers only
It is, but its the most accurate metric we have
for servers
i would say that if a community metric about minecraft version happen, 1.8 will have more than 8%
I doubt it
wont say that this is the most popular but relevant
Would this work for a fireball?
velocity.multiply(2);
entity.setVelocity(velocity);```
the 8% is hypixel ( bc they have like what 10k Servers. ) then is mineplex , the hive etc.
hypixel is not on 1.8
they are
dont see why not
the only thing they dont have thats 1.8 is the Hypixel SMP features.
almost sure that they are in the latest
They are not. I'm told they are on 1.12 custom for pretty much everything
No? Cause then 1.8 users would have tons of lag back.
viaversion, viabackwards
The hive shut down its java network
k, I was just asking because in minecraft the velocity is in x, y, and z, so I didn't know if I needed a single axis thing
Ik
i would say that 2 is a very big number for that
try and see
if(e.getSlot() == 11) {
p.performCommand("server skyblock");
p.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("sending-to-skyblock")));
return;
}
if(e.getSlot() == 15) {
p.performCommand("server Clicker");
p.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("sending-to-clicker")));
return;
}
For some reasonly only the SkyBlock one works and yet the clicker one doesnt. i dont understand the logic....
velocity is a pain
k
you arent clicking the right slot then
hope i helped
use rawSlot then
and I swear every time I export my plugin it says it cant find the main so I have to click f5 like ten times
Tried that..
bruh
getDirection() returns a unit vector which has a length of 1. That corresponds to 1 block per tick. Multiply for yoru desired speed
p.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("sending-to-clicker"))); runs? @manic crater
yes.
yes it is, i have used it many times.
k so two blocks a tick works fine for tnt so I think it will be fine for a fireball
so like a sudo thing but for an armor stand? I got no clue
getting an entity to perform a command.... well for starters i thought u said " Is it even possible to do this. "
And idk, but what i do know is, Citizens is all entity based, so decompile it and give it a look through.
Entities don;t perform commands
Yes they do, Citizens specifically has it execute a command if u add it to it.
Entity#performCommand afaik
no
Only Players can perform commands
yeah but citizens, its entity based. not player based.
nothing
they use the interact event
yeah, but its still linked with in the entity.
look the only way that we will know what does what is if we asked the owner of citizens. 😆
any code can issue a console command but its better to use available APIs if you can
if(e.getSlot() == 11) {
p.performCommand("server skyblock");
p.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("sending-to-skyblock")));
return;
}
if(e.getSlot() == 15) {
p.performCommand("server Clicker");
p.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("sending-to-clicker")));
return;
}
Back to this issue pls???
Cuz for some reason i cant get it to make the user execute the cmd, but yet for skyblock it runs fine.
and clicker it doesnt run the cmd or any other code besides the msg.
how do you make the explosion size larger, in minecraft its an nbt tag. explosionPower:1b
(for a fireball)
How can i put a hyperlink in the desription of a resource?
wtf is a hyperlink
wrong chat
a link, you obviously don't use HTML
if it shows the message its running your command. try using lower case in the server name?
yeah
im assuming you mean the spigotmc page?
Yes
My bad, it's Server#dispatchCommand, you pass the entity as the commandsender
uh idk if you can
Still doesnt work @eternal oxide :/
^
This Minecraft tutorial explains the NBT tags (formerly called data tags) that you can use for a fireball in Minecraft Java Edition (PC/Mac) 1.16. In Minecraft Java Edition 1.16, the entity value for a fireball is fireball. The fireball entity has a unique set of data tags that can be used in Minecraft commands such as: /summon and /data.
if you got the message for sending to clicker then its yoru command that is at issue
Awesome.
or the server is offline
Cast to TNTPrimed iirc
there are methods there
???
hm, idk..... :/ gotta look into it
what does that mean
wait.. i wanna see something rq.......
yeah
@shadow tide i literally sent u how to make a fireball explosion bigger...
and I don't know what you mean by "Cast to"
like i literally sent u the LINK for NBT Tags for FIREBALLS
I mean in a plugin
ahh
Fireball#setYield()
so for a fireball how do I make the explosion larger or even better set NBT Tags
this
yea?
NBT shit is stupid and you should avoid it if there are better ways
k
thats not what i said
then idk what you mean
Its not a method of Entity
what is it'
its a method of Fireball
which extends Projectile which in turn extends Entity
hmm
actually
are you spawning the fireballs in your plugin?
yes
Well World#spawnEntity returns the entity object
Entity entity = player.getWorld().spawnEntity(player.getLocation(), EntityType.FIREBALL);
Vector velocity = player.getEyeLocation().getDirection();
velocity.multiply(2);
entity.setVelocity(velocity);```
((Fireball) entity).setYield(x)
I have no idea what you are talking about, sorry I just started developing plugins so can you just tell me the line of code I need to write and if you want, explain it
ElgarL did...
uh
We'll let you work out that part
(it needs to go in a method)
in an entity. method? don't tell me the answer but give me hints
Which entity do you think it would affect?
this one Entity entity = player.getWorld().spawnEntity(player.getLocation(), EntityType.FIREBALL);
Looks promising
soo Entity entity = player.getWorld().spawnEntity(player.getLocation(), EntityType.FIREBALL, ((Fireball) entity).setYield(x));?
Anyone has any good conversation API tutorials which are easy to understand?
no
uhh
put it on its own line
and replace x with whatever size you want
ik
Entity entity = player.getWorld().spawnEntity(player.getLocation(), EntityType.FIREBALL);
((Fireball) entity).setYield(10);```
Excuse me, is there a way to have autocomplete options for bungee commands i add?
I'm trying to check if a player clicks a GUI,
Did some digging and ended up writing this. It should work,
But it constantly thinks i'm clicking the default player inventory
What can i do, is there any other way to check if a GUI is clicked instead of player inventory?
package com.plugin.TabCompleters.Utils;
import com.plugin.Main;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
public class GUIUtils implements InventoryHolder {
private Main main;
private Player player;
private Inventory GUI;
public GUIUtils (Player player) {
this.player = player;
this.GUI = Bukkit.createInventory(player, 36, ChatColor.AQUA + "Odyssey GUI");
}
public void setGui() {
this.player.openInventory(GUI);
}
@Override
public Inventory getInventory() {
return this.GUI;
}
}
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
GUIUtils guiUtils = new GUIUtils(player);
if (!(event.getInventory().equals(guiUtils.getInventory()))) {
player.sendMessage(ChatColor.GREEN + "Clicked GUI");
} else {
player.sendMessage(ChatColor.RED + "Clicked player inventory");
}
}
you gave in lol
Yep. It was too painful
so explain
What doesn;t make sense about it?
when you spawn an Entity you are returned the Entity you spawned, but not as the type you asked for. Just a generic Entity
from the fact that the GUIUtils implements InventoryHolder it seems weird that you set the inventory holder to be the player
So entity only behaves as a generic Entity. If you want to access the Fireball methods, you have to turn it into a Fireball
how does that explain it starting with (
why can a line not start with a (
You need to learn about java type casting
yep
?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.
Casting is like changing the data type of a variable
doesn't help
look at the second example
int myInt = (int) myDouble; // Manual casting: double to int
Also, every time they click you are making a new GUIUtils object, you should just set the holder to this when you make the inventory and then check with an instanceof check in the listener
that is casting a double to an int
ok
and ((Fireball) entity).setYield(10); is a type cast?
Yep
got it
teh (...) are simply surrounding elements to control what order things happen
So first it casts the entity object into a Fireball, then you have access to teh fireball methods for setYield
ctrl + s, F5x20, export
Why does it not save the locations?
define "it not save the locations"
what doesn't work
also - you can just call Location#serialize()
and then Location.deserialise
If I type /setspawn the config.yml doesn't get updatet. So it still looks like this after sending the command:
spawnX:
spawnY:
spawnZ:
spawnYaw:
spawnPitch:```
you need to save the config
LobbySystem.getPlugin(LobbySystem.class).getConfig().save("plugin/LobbySystem/config.yml");
} catch (IOException e) {
e.printStackTrace();```
Doesn't this save the config?
quick question how do I make a command only available for ops
I need an answer fast pls
set it to ops in the plugin.yml
?plugin-yml also works 😄
eww what an ugly command

I guess it might make it memorable
alright I get the permission part in YML but what is the op permission? like minecraft.op or minecraft.operator
idk what it is
ahh
if you want to command to only ever be available to ops, just don;t set a permission nor a default
wtf is that
that is the most ugly emoji i've ever seen
what happens if p.closeInventory() is called when the inventory is already closed?
Try it and see
your server explodes and the universe ends
was just about to xd i've been having an issue with it but im gonna try now
yo does any of you know how mc's NbtAccounter works?
the values passed to it don't make sense to me
e.g. for an EndTag
doesn't store any data and the tag id is stored in a byte (=8bits) so I don't understand where the 64 bits is coming from
This code snippet only outputs something for mobs except for the ender dragon, why?
@EventHandler
public void onEnderDragonDeath(EntityDeathEvent e) {
Bukkit.broadcastMessage(String.valueOf(e.getEntity()));
if (e.getEntity() instanceof EnderDragon) {
System.out.println("test");
}
}
how do I check if the player has an open inventory? such as a chest or a GUI?
is it getOpenInventory or getInventory?
?jd
rtfm
k
hello it's saying title doesnt match even on the onMove event, although it's only implemented in the onClose event and the title also matches so why is it displaying this??
@EventHandler
public void onClose(InventoryCloseEvent e) {
Player p = (Player) e.getPlayer();
if(FreezeExecutor.frozen.contains(p.getName())) {
if(p.getOpenInventory().getTitle().equalsIgnoreCase("YOU HAVE BEEN FROZEN")) {
FreezeMenu menu = new FreezeMenu(p);
p.openInventory(menu.getInv());
}
else {
Chat.INFO.send(p, "title doesnt match");
}
}
}
@EventHandler
public void onPlayerMove(PlayerMoveEvent e) {
Player p = e.getPlayer();
if (FreezeExecutor.frozen.contains(p.getName())) {
e.setTo(e.getFrom());
FreezeMenu menu = new FreezeMenu(p);
p.openInventory(menu.getInv());
Chat.FAIL.send(p, "You can't move while frozen.");
}
}
I did and I usually like documentations but spigot's is messy and that's why I resort to asking discord
what is itemmeta thing for damage 🤨
this throws an error meta.addAttributeModifier(GENERIC_ATTACK_DAMAGE, 1)
Show me the error and I will teach you how to read it
I mean that isn’t the format for that method
it didn't actually throw an error. its just underlined red. I need to know the format for that method
I know how to read errors
underlined in read = method does not exist
Look at teh method definition in teh javadoc
hello
GENERIC_ATTACK_DAMAGE was underlined in red. so its the wrong thing to put in the method
GENERIC_ATTACK_DAMAGE, 1, AttributeModifier.Operation I don't know what that last one means
I'm reading the spigot documentation
read teh link I gave you
addAttributeModifier
boolean addAttributeModifier(@NotNull Attribute attribute, @NotNull AttributeModifier modifier)
Add an Attribute and it's Modifier. AttributeModifiers```
ok, new AttributeModifier(...)
Listen, this documentation is super out of my comfort zone
Yes, you need to learn more java to be comfortable
teh documentation is really good, once you know java
I guess I'm just used to w3schools and python's documentation
This documentation is standard for all Java
ok
you need to provide the modifier
AttributeModifier.Operation.ADD_NUMBER or any of the three
Without writing it for you (which you will learn nothing) I'm not sure I can dumb it down further.
You understand what a constructor is?
Look at the javadoc and see the objects constructors https://hub.spigotmc.org/javadocs/spigot/org/bukkit/attribute/AttributeModifier.html
elgar you know anything about plugin messaging ?
when you use new Object you are creating an instance of the object, using its constructor
Description
AttributeModifier(String name, double amount, AttributeModifier.Operation operation)
AttributeModifier(UUID uuid, String name, double amount, AttributeModifier.Operation operation)
AttributeModifier(UUID uuid, String name, double amount, AttributeModifier.Operation operation, EquipmentSlot slot)
``` this?
ok
it tells you what you have to provide as arguments to create a new object
so if you were using the top one, String, double, AttributeModifier.Operation
ElgarL teaches Cj stuff
hello it's saying title doesnt match even on the onMove event, although it's only implemented in the onClose event and the title also matches so why is it displaying this??
@EventHandler
public void onClose(InventoryCloseEvent e) {
Player p = (Player) e.getPlayer();
if(FreezeExecutor.frozen.contains(p.getName())) {
if(p.getOpenInventory().getTitle().equalsIgnoreCase("YOU HAVE BEEN FROZEN")) {
FreezeMenu menu = new FreezeMenu(p);
p.openInventory(menu.getInv());
}
else {
Chat.INFO.send(p, "title doesnt match");
}
}
}
@EventHandler
public void onPlayerMove(PlayerMoveEvent e) {
Player p = e.getPlayer();
if (FreezeExecutor.frozen.contains(p.getName())) {
e.setTo(e.getFrom());
FreezeMenu menu = new FreezeMenu(p);
p.openInventory(menu.getInv());
Chat.FAIL.send(p, "You can't move while frozen.");
}
}
why are you using p.getOpenInventory()?
If you open an inv when the player freezes then there is no need to check the inv name.
Just cancel the close event regardles.
Btw i hope frozen is not a List.
Also -> dont make collections public and dont pass them to other classes via a getter.
They should have strong encapsulation. Your FreezeExecutor should have a method
public boolean isFrozen(Player) and public void freeze(Player) instead.
its a collection
What type of collection?
string
Not the generic type... What collection implementation.
- Dont compare players by their name
- Dont use lists if you call contains rly often
You should use a
private final Set<UUID>
instead
ok i will change it but how can I open the inventory after they closed it?
Cancel the InventoryCloseEvent
But you dont have to check the inventory name.
Just check if they are frozen.
It’s not cancellable
Its not?
Nope
Ah i see... then just reopen the inv again i guess.
that's what im doing
why is https://pastebin.com/irTyYZSC giving me this error: https://pastebin.com/KB7DpPpe
well trying to do *
You cant cast a ConfigurationSection to a List
so would it be a set?
plugin.getConfig().getList() instead
ah ok thanks 😄
im getting this error now https://pastebin.com/bK4auzZh i dont see anything thats wrong though
what are yall thoughts about vavr?
Show the updated code
can u help or nah
Never heard of it but it looks interesting. They Lazy<T> for example.
Yeah
There is a getStringList() method iirc
Btw
List<String> keys = (List<String>) plugin.getConfig().getKeys(false);
Do you even check the return types of your methods?
getKeys returns a Set<String>
yeah?
ayo
you here?
compare enums
e.getEntityType() == EntityType.ENDER_DRAGON
Uhm-
hey can someone help me?
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Create a thread in case the help channel you are using is already in use!
bluu freesze
quick question, how could i get the keys of a file created using File f = new File("plugins/Test/" + args[0] + ".yml");
File pluginsDirectory = plugin.getDataFolder().getParentFile();
File testFileConfig = new File(pluginsDirectory.getAbsolutePath() + "/Test/" + args[0] + ".yml");
so that would get the keys or just the file itself?
just the file
The Configuration API is a set of tools to help developers quickly parse and emit configuration files that are human readable and editable. Despite the name, the API can easily be used to store plugin data in addition to plugin configuration. Presently only YAML configurations can be used. The API however was designed to be extensible and allow ...
