#help-development
1 messages · Page 1612 of 1
that would be nice if it was an actual event
hmm okay
Not so
we should just use interact event for everything
Egg throw is actually when the egg hits the ground and decides if it will hatch
brilliant
Projectile is for all projectiles
hey how do i get all armour stands and kill them
i just for(Entity e : world.getEntities())
if e.getType() ==
etc.?
Hmm, didn't work the first time I tried it. It only seemed to trigger for arrows but I can give it another shot
ok well this doesnt actually remove the armour stands
worlds:
unexisting_world:
1:
x: -123
z: -766
2:
x: 648
z: 478
another_unexisting_world:
1:
x: -3577
z: -1364
2:
x: 3135
z: 2642
var worlds = (Map<String, Map<Integer, Map<String, Integer>>>) config.get("worlds");
java.lang.ClassCastException: class org.bukkit.configuration.MemorySection cannot be cast to class java.util.Map (org.bukkit.configuration.MemorySection is in unnamed module of loader 'app'; java.util.Map is in module java.base of loader 'bootstrap')
it worked before, i think
and how do i convert that memory section into a Map<String, Map<Integer, Map<String, Integer>>>?
you'll call getConfigurationSection to get a ConfigurationSection
and then call .values on it which will give you a Map<String, Object>
i'm not sure if the second level maps are going to be memorysections or maps, but probably maps
working with configurations directly is ass
you're supposed to do the serialization outside of your main code
that means there is an indirect way...?
you could create a class named ConfiguredWorld and make it ConfigurationSerializable
and then call config.getSerializable("worlds." + worldname, ConfiguredWorld.class)
the deserializer you'd write in the new class would take care of all the config bullshit
how is that
it's still cancer, but pretty similar to working with maps
a configurationsection is just a sort of map, anyway
can u give me a little example, having 3 nested maps confuses me a bit
ConfigurationSection worlds = config.getConfigurationSection("worlds");
for (String worldName : worlds.getKeys(false)) {
ConfigurationSection world = worlds.getConfigurationSection(worldName);
for (String pointName : world.getKeys(false)) {
ConfigurationSection point = worldSection.getConfigurationSection(pointName);
int x = point.getInt(x);
int z = point.getInt(z);
as you can see, it's not fun
w
ok so what could i possibly be doing wrong
because the entities im triyng to kill...
their customname is NOT null
consider calling remove() instead of damaging them
i don't know if armorstands work properly with damage
beyond that, throw some sysouts at it and see why the if condition is failing
ahhhh
or if the loop is even running in the first place
armorstands are fucking batshit
yeah
they are treated as living entities
so they will drown underwater
and other brilliant shit like that
yeah so the loop isnt actually running
it could be because i have it on the ServerLoadEvent ?
the world is probably not loaded by that point yes
though the server's worlds exist way before this event is called iirc
listen to the WorldLoadEvent or something maybe
well the ServerLoadEvent is the final loading event
yeah
Hey @eternal oxide, I've got some bad news. The PlayerInteractEvent is not event called when I left click on the itemframe
it is called if I click at the bottom of its block
but not on it directly
the entity damage event is probably called instead
entity interact event should be caught by the regular interact listener
if i remember the class hierarchy right
let me check
yeah apparently not
isn't that only for right clicks though
make your plugin load on startup as opposed to postworld
unless you've set load: startup in plugin.yml, the load phase defaults to postworld
which is after the main worlds have loaded
and thus your listener won't be registered in time to hear them to load
ok so but heres the thing @valid crag
i have
a for(
that gets the worlds
to set their gamerules
in the serverloadvenvet
assuming that is on the main thread, yes, that is laggy and stupid
it's doing file IO on the main thread
No one per chunk per plugin
on the fucking block break event
yeah, figured
i guess I have to manage duplicate tickets myself
It doesn;t matter how many you place, so long as you remove once
yeah but the thing is that I have multiple areas that I want to load chunks on a certain condition
if multiple areas occupy the same chunk, I want the ticket to be removed once all areas fail the condition
ah, so one may remove the ticket of another
so i'm probably going to tally the present areas in a Map<ChunkKey, Set<Area>> or something
yep
i have an issue with the nbt api,
for some reason it doesnt seem to be saving,
i run this code:
NBTEntity p = new NBTEntity(event.getPlayer());
p.setBoolean("GeneratedSkills", Boolean.TRUE);
p.setInteger("SkillTreeAvailablePoints", 69);
p.setInteger("SkillTreeAgilityLevel", 12);
p.setInteger("SkillTreeAgilityPoints", 2);
p.setInteger("SkillTreeMiningLevel", 9);
p.setInteger("SkillTreeMiningPoints", 4);
p.setInteger("SkillTreeFlyingLevel", 14);
p.setInteger("SkillTreeFlyingPoints", 8);
``` and later when I run this code:
```java
NBTEntity p = new NBTEntity(player);
availablePoints = p.getInteger("SkillTreeAvailablePoints");
agilityLvl = p.getInteger("SkillTreeAgilityLevel");
agilityPoints = p.getInteger("SkillTreeAgilityPoints");
miningLvl = p.getInteger("SkillTreeMiningLevel");
miningPoints = p.getInteger("SkillTreeMiningPoints");
flyingLvl = p.getInteger("SkillTreeFlyingLevel");
flyingPoints = p.getInteger("SkillTreeFlyingPoints");
System.out.println(availablePoints);
System.out.println(agilityLvl);
System.out.println(agilityPoints);
System.out.println(miningLvl);
System.out.println(miningPoints);
System.out.println(flyingLvl);
System.out.println(flyingPoints);
``` and it just doesn't work, it just returns 0
and i supposed to run some sort of saving code?
use the pdc
ik, its just so much easier to look at with this
could always write a wrpper that makes the pdc look nice as well
wait, i think i figured it out
i this i needed to use the variable "nbt" as in:
NBTCompound nbt = p.getPersistentDataContainer().getOrCreateCompound("SkillTree");
``` instead of variable "p"
yep
that worked
task.runTaskTimer(null, 0, 0); il faut mettre quoi dans null (plugin plugin) si on est pas dans la class principal ?
c'est bon j'ai mit n'importe quoi ça marche
i did this to summon random anvils with fawe api but the anvils staying in air how to fix it?
try (EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorld("Anvilmayhem")), -1)) {
RandomPattern pat = new RandomPattern();
BlockState air = BukkitAdapter.adapt(Material.AIR.createBlockData());
BlockState anvil = BukkitAdapter.adapt(Material.ANVIL.createBlockData());
pat.add(air, 1.0-percents);
pat.add(anvil, percents);
editSession.setBlocks(region, pat);
}```
String b = event.getInventory().getTitle();
if (b == "OneBlock Menu") {
} //
it is exactly the same value for a name even if I print it, but the comparison always comes out false
1.8.8
you cant == strings
String b = event.getInventory().getTitle();
if (b.equalsIgnoreCase("oneblock menu") {
} //```
Don't compare title names for Guis man
can someone help me?
why
What event?
InventoryClickEvent
sorry I'm a C ++ programmer usually
k then like md said. Can't use ==. Duck santa provided an example.
Use event.getClickedInventory()
you cant == strings in c++ either
Unreal Engine
getMaxStackSize is 64 for a chest inventory, and changes with the inventory type, right?
Depends on the material
i mean Inventory#getMaxStackSize
Yeah idk. It says for itemstack but doesn't allow any params
how would I make method to wait fro another method to finish loading player balance
CompletableFuture
thing is galistener is trying to run command and add amount to player balance
and balance is not loaded yet
"GAListener" the voting thing right? Why not just add a delay to the command?
well expalin that
to my plugin users xd
they just want it to work
and balance is loaded from mysql
so it takes sometime
and galistener is running command
on join xd
Well I haven't used voting listeners in a few years but I always added a 5 second delay to the commands ran by it.
the balance plugin is trash then
the player isn't supposed to be let in until their data is properly retrieved and loaded
hey there im getting a ClassNotFoundException on this line private mainMenuGUI mainMenuGUI = new mainMenuGUI();
in this class
public class OpenGUI implements CommandExecutor {
private mainMenuGUI mainMenuGUI = new mainMenuGUI();
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player p = (Player) sender;
if (p.hasPermission("EUNetwork.parkour.openGUI") || p.isOp()) {
if (command.getName().equalsIgnoreCase("parkour-gui")) {
mainMenuGUI.getCounter();
mainMenuGUI.OpenMainMenuInventory(p);
}
}
return true;
}
}
i have no idea why im getting this error
probably a static initializer failing somewhere
wdym
something is doing something that tries to load a class
which runs the static code of that class
which fails
and so the class can't be initialized
throwing a class not found
also
don't cast sender to player blindly
and get rid of the isOp check
make the permission default true for ops if you want ops to have perms to the command by default
alright
is there an enderman place block event
because idk how to disable that
without turning off mob griefing
AKA disabling villager breeding, and other stuff
@quaint mantle https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityChangeBlockEvent.html
declaration: package: org.bukkit.event.entity, class: EntityChangeBlockEvent
😭
?
thank you
idk why i didnt google that
or search rather*
i looked for "EndermanBlockPlaceEvent"
too specific to be a bukkit event
bukkit events must be vaguely named and difficult to guess at what they actually represent
Batman
imajin
if my plugin, recoded works 1st try you owe me 5 dollars
i may consider sending an ok_hand emoticon
i am grateful for the consideration
what is the plugin supposed to do
shop plugin
because that's never been done before
right
what kind of shop plugin
GUI shop
surprised you arent shitting on me
it didnt work
make me a crates plugin
no
it needs to be not shit
arent you like the best programmer here
maybe
but i have many projects i'm working on
i don't feel like working on something as gay and uninspired as a crates plugin
ok so now that we osrted that
idk what to really do for this
so i have a custom shitty Holograms method, right? it works its done its whatever
but idk why i cant remove them
you know
i loop entities on "ServerLoadEvent"
i really fucking hate optionals
they're so redundant and dumb
literally just nullable variables with extra steps
sometimes they're useful
type over issues with unnecessary conversation
bro
keep typing
ok
so
the only use case is like chaining lambda conditionals or something
for everything else it's literally a nullable variable
and people make the fucking argument that they avoid npe's
or it does and they somehow fail the conds?
well gee now I have no such element exceptions
or whatever empty optionals throw
"you'll probably forget to nullcheck"
yeah you're probably going to forget to check isPresent
such absolute bullshit
var nullable = Optional.ofNullable(otherNullable).orElse(defaultValue)
// var nullable = otherNullable;
// nullable = nullable == null ? defaultValue : nullable;
// if (nullable == null) nullable = defaultValue;
@valid crag
its cleaner imo
ok
so
can you help me pls
yeah be patient
because idk why its not workin
are you sure its being called?
oh does he have an actual issue
yes
the original for(getworlds whatever)
is being called
the code in that loop is also being ran, as my gamerules are being set
yeah the chaining with the conditionals and ifPresent and whatever are the only real use cases
they're situationally nice
Optionals are stupid
but like, use kotlin
armorstand isnt a livingentity
lmao the orange cube agrees with me for once
aaaa
i've also tried getEntities()
i'll try getEntities again
but that was my 2nd try for that
pretty sure armorstand is a living entity
they apparently also drown if left underwater
yeah
idk tbh
i'll try getEntities() again
but as far as i know that doesnt work either
yeah that didnt work
is the custom name visible?
yep
there is one case where I did use an optional
a nullable optional
the value could either be present, an empty optional, or null
infact heres the hologram code, i know its shitty but it does work fairly well
mcMsgFrom just translate colour codes and some HEX stuff
i agree
more reliable
im not sure if minecraft defaults to \n but use System.lineSeperator
hd does it through the protocol layer so it's less fragile
because why use more plugins for something that i onily need a few line sfor
HolographicDisplays also is just.. annoying tbh
i want stuff to be customizable, and easy to edit/use
i dont want a ton of extra commands and files for something i dont actually need
noo i have to include an extra jar in the runtime
one that the environment would probably have anyway
the horror
i'm sure you can find a decent library you could shade in instead of depending on hd
¯_(ツ)_/¯
i might just make a getHolograms() List
you should definitely track your holograms yes and probably abstract them away from being armorstands
¯_(ツ)_/¯
worst comes to worst i could just enable their marker
idek what the Marker does
yeah
just a smaller hitbox?
so
May be a dumb question
But i can only use the paper API if the plugin is run on a paper server correct?
you can use spigot too
Ok, but if i use the paper api in my plugin and run it on a spigot server it breaks everything?
It makes sense that it would
Imma try it
Cause the paper api is just a replacement for spigot they say its better
it is better
whats better about it? only thing i know is that theres a onJump event
if you use paper specific parts of the paper api, the implementations of those parts do not exist on spigot servers
it has a lot more features for stuff, its fast
and thus the plugin will explode
it has a little bit better server-related stuff
https://papermc.io/ for more info @somber hull
thanks, thats what i thought
thank you
it's better and more comprehensive in almost every way and there is little reason beyond maintaining spigot compat to not use it over spigot
of course it's still based on bukkit so it isn't just dancing on roses either
So should i use spigot or paper
depends
Oh
hm if I get a shallow copy of a livingentity location and it then gets removed, does the location become null or does it keep the last known location in storage?
wut
location = livingEntity.getLocation();
livingEntity.remove();
30 minutes later
location == null ?
learn java
this isn't a java issue
no
you need to clone the location right?
the location might get nulled depending on how locations were implemented
you do not null a Location
you do not null an object
you null a reference
you null a field
you null a variable
yeah I called that field location, that's why we're saying location
what you are asking is whether the contents of your "location" variable are assigned to null
which, how could it be?
what would set it to null?
removing the entity
the entity doesn't know about your variable
that is the question
the server doesn't know about your variable
only your code knows about your variable
how could they null it?'
location is a shallow copy of the entity's field
unless you clone it
so they all do know about it
@torn shuttle try sending a message with the location.getX() before and after removing it
if they both error then it has nothing to do with removing the entity
batman you should really learn java ya know
the entity knows about the object
the underlying Location object referenced by your location variable
it does not know about your variable
the location variable is something that only the class that declares it knows about
unless something comes and sets it to null, it won't be set to null
I will if no one tells me it specifically won't work
it's just I can't really test it right now because I'm in the middle of a big rewrite
a location is 3 doubles
and a world
which is an identity element and cannot be cloned
you cannot clone it deeply, you cannot clone it shallowly
you can only clone it
locations can be cloned, what are you on about
yes, my point is that the distinction of "shallow" which you're going on about doesn't exist for locations
I said shallow copy not shallow clone
that is the same thing
no, a shallow copy specifically wouldn't be a clone
I'm just creating my own field that links to the entity's field
a deep copy would have to be a clone of the location
the entity's field is 100% irrelevant
you aren't pointing at the field
you are pointing at the object
get it through your skull
the object that is in the field
this is genuinely just semantics
what happens with the entity's field is none of your business
it won't have an effect on anything in your code
I think you're just mad because you made a fool out of yourself a few minutes ago
are you genuinely daft or are you pulling my strings
🥱 just get along
so specifically if the object I was referencing gets nulled because that's how mc or spigot or anything in between decided to do things I will have to handle that in my code, which is the question I had to start with
Objects do not get nulled
Variables get nulled
The distinction is key to understanding why your question is stupid
so you're saying the field might get reassigned to null but the location object won't
the field will be reassigned to null if something reassigns it to null
let me reiterate
you are not pointing at the field on the entity
you are taking the object from the entity's field
and then you are referencing that object in your own field
no matter what happens to that other field, or any other field in the world, your own field will still hold that reference
I understand what you mean, now i am just wondering if entity teleportation might create a new location object under specific conditions which would mess me up
it will hold that reference until you tell it to stop holding that reference
specifically things like going through portals
the location object retrieved from the entity is always a clone
you seem to have a definition of clone that is not compatible with the cloneable interface's nomenclature
Location::clone gives a clone of the location
yeah
sure, except I'm not cloning the object
am I not pointing to the same object lol
that is what cloning means yes
you are creating a new object with the same contents
or more technically, the same state
what are some cool things I can do with the event handler
events
thanks but really though
I made a player join and leave message but that was the only thing I could think of
you see how it gets confusing when you have a definition of cloning that just points to one object and then another different but equally named definition of cloning that takes an object and does a deep copy right
well, like I explained, the distinction between deep and shallow does not exist for Location
this is why the clone wars sucked
so whether the copy or clone or whatever you want to call it is deep or shallow or anything in between doesn't matter
what matters is that the clone operation takes an object
and produces a new, identical object
it has the exact same values
but it is not the same object
changes made to the original will not be reflected in the clone
and vice versa
cloning never "points to one object"
cloning always creates a new object, a copy, of the original
copy and clone are effectively interchangeable
are you claiming that getting a location and getting a location and cloning it are exactly the same thing ?
are you getting the location from an entity?
yes
Locations are mutable
you never want to pass mutable objects out of getters
because then the person who received that object can mutate it
and only you should be allowed to mutate your objects
for this reason, all bukkit entities return a clone, a copy, of their location
instead of the location itself
otherwise, if you did entity.getLocation().add(100,100,100)
the next person calling getLocation would get the location moved by 100s
this is also why you shouldn't return collections or maps or whatever directly in your getters
the moment you expose something mutable to the world, you lose all control of what happens to it
that mutable map gets passed around like a whore and suddenly your supposedly "private" map is full of aids and STDs
I was nearly absolutely certain that the getLocation object passed was mutable
it isn't; very few things returned by anything are mutable
my life is a lie
you can modify it, but doing that won't touch the original
which is what we care about
I fucking knew it
man you are actually gaslighting me into having an existential crisis
we don't want the original to be modified by you and be infected by your noob aids
so in conclusion
the Location you're getting is a clone
so you cloning it makes no difference
because it's already a clone
toxic masculinity in a nutshell
except it makes a difference because one is mutable and the other one isn't
if you clone a location it is only mutable insofar as you personally modify it
I mean
none of the fields of Location are final
hence Location is mutable; able to be mutated
and no your google definition doesn't apply
i'm talking about the programming term
the literal of which would probably be "mutatable" or "modifiable" or whatever
the point is that one is in sync (hopefully) with the actual location and the other one is a snapshot of when you cloned it
anyway, the object you're getting is already a clone
there is no point in cloning it a second time
no more than there is any point in cloning it a third time
or a fourth
unless you want a snapshot of where it was a specific point... or want to do operations based on locations....
yes, well, obviously
but what you said makes it sound like you're doing getLocation().clone()
which I do when I need to be certain it's a very specific location
at a specific time
getLocation moves around over time even if you don't touch it
yes... but that doesn't mean that the returned Location does
getLocation() returns different values over time because the entity's underlying Location object is modified/changed
since the returned Location is a clone, those modifications/changes will not apply to the clone
are you saying that every time you do getLocation you get a different instance of the object in the location field
just as you cannot modify the underlying location, neither can it modify yours
yes, that is what clone means
like I've been trying to explain for like 20 minutes now
you get a new object with the same initial values
you get a Location that has the same values but is not the same object
I'm going to have to test it because up until now I was pretty certain it was returning one object no matter when you queried it
@Override
public Location getLocation() {
return new Location(getWorld(), entity.locX(), entity.locY(), entity.locZ(), entity.getBukkitYaw(), entity.pitch);
}
this is the implementation of getLocation for CraftEntity
I guess that settles it then
I was lied to in like 2017 lol
why it would be specifically strange if it didn't do this
batman never wrong
do you remember when I said Location is mutable
I know the issues it being mutable can cause, I've dealt with them several times when running operations on locations
so you should know that it would be very strange for bukkit to return the actual original location
as any changed made to it would be reflected on the entity itself
without any possibility of control on the entity's part
yeah, I thought it was strange years back but I went with the answer provided back then
right
and never really thought to look it up
next, to dismantle the nullable objects issue
i don't know what possessed you to think of things that way but that is not how anything works
objects don't just turn null at random for no reason
objects don't turn null at all
you know how worlds can be null in locations? I thought it might be possible to make the entire thing null
would've required every field to support it though which they don't
it isn't a state of being that an object supports
even if you null every part of an object, the object itself still exists
you can null the contents of an object; its fields
but the object itself still exists, and is not, and can not, be null
i'm going to go get some donuts
the utter and complete disappointment is too bitter without any sweets
Someone know why the head rotation using packet doesn't work when I use 1.16.5 and it works on 1.17.1, it has the same method. Basically I want to make the armor stand head, rotate the same as player head rotation (yaw).
I have a question I made a /spawn command but I changed the command name to /hub in the plugin.yml but it is still commandtps:tps
and my player join message is also not sending anymore, it was sending yesterday but since I restarted the server it is not
@quaint mantle code?
wait I fixed it nvm
but thanks for trying to help
Packets don't have the same names and/or value in 1.17 and 1.16. Send your packet code.
Anyone know how I could put all NPC config numbers retrieved with this in a list or something so I can check them against the args the user gave and tell them if it's an available NPC or not? It might just be because it's 9:30, but I can't think of how I would. I tried and a ArrayList a few mins ago and it either wouldn't work, or I did it wrong.
file.getConfigurationSection("data").getKeys(false).forEach(npc -> {});
1.16
@Override
public void setHeadRotation(Player player, float yaw) {
if(!armorStandMap.containsKey(player)) return;
NMSBackpack backpack = armorStandMap.get(player);
sendPacket(new PacketPlayOutEntityHeadRotation(backpack.getArmorStand(), ((byte) yaw)), null);
}
1.17
@Override
public void setHeadRotation(Player player, float yaw) {
if(!armorStandMap.containsKey(player)) return;
NMSBackpack backpack = armorStandMap.get(player);
sendPacket(new PacketPlayOutEntityHeadRotation(backpack.getArmorStand(), ((byte) yaw)), null);
}
If you're attempting to check if the configuration section contains an npc or what ever ID just use contains...
file.getConfigurationSection("data").getKeys(false).contains(<npc path>)
How are you sending a packet without getting the connection?
sendPacket method.
Point still stands
private void sendPacket(Packet packet, Player player){
if(player == null){
Bukkit.getOnlinePlayers().forEach(online -> ((CraftPlayer) online).getHandle().b.sendPacket(packet));
return;
}
((CraftPlayer) player).getHandle().b.sendPacket(packet);
}
Oh, I'm stupid
you set player as null in the above code
sendPacket(new PacketPlayOutEntityHeadRotation(backpack.getArmorStand(), ((byte) yaw)), null //Player object is set as null here);
?
if player null, send packet to online players
Oh missed that lol
it's not required
sendPacket(new PacketPlayOutEntityHeadRotation(npc, (byte) yaw));
I'm pretty sure b is a 1.17 thing
yes, it's on different class
i have 2 sendpacket method basically
So you can't use it in 1.16
i know
there is a method for 1.16.5 and 1.17.1
i have 2 send packet method for 1.17, and 1.16
What's your 1.16 method?
just change b to playerConnection
What is your issue exactly?
The head rotation doesn't work on 1.16
doesn't follow the player head like what does it 1.17
Have you debugged it? Made sure the sendPacket method is actually running?
Yup, it is run each tick.
can you pastebin the full code? Off those methods it should function correctly. As long as on 1.16 you're using the right field names.
Hmmm... Yeah just based off those classes it should display the head rotation properly.
Is it possible to send a video of the difference (Whats occurring on 1.16 then 1.17)?
Sure, one second, launching mc and everything.
sorry for butting in, but is there a way to remove a score from a scoreboard or change a score's Entry name? i cant seem to find one and the other option would be to create a new objective every time and delete the old one, which seems unideal
code?
and are you talking about making a nonflickering scoreboard?
So IDK if this would solve anything but https://www.spigotmc.org/threads/how-to-create-and-modify-npcs.400753/ says under the how to rotate
To rotate an NPC you will need to turn the angle of yaw and pitch (not delta) into bytes (-128 to 128). To do this multiply them by 256 and divide the product with 360.
So maybe try(byte)(yaw * 256 / 360)If this isn't the bug you're talking about just ignore this message.
basically i want to create a dummy objective and then have lines with text that updates (similar to hypixel's sidebar) but I cant find any methods to change the names of scores. I havent started coding this part yet
so you create the scoreboard for the player once on login
then create teams for each entry you want to be updated (non-updated entries can be scores)
set the team prefix to the desired initial text
then on update you get the players scoreboard
then get the team and setPrefix()
ok i kind of get it
ok tysm
would this work for the main scoreboard as well?
wdym
lemme find it
the one returned by getMainScoreboard() thats shown by default to everyone
do you already have a scoreboard shown when on the server?
no
i dont think so
its just listed here so i assumed it already exists or something https://hub.spigotmc.org/javadocs/spigot/org/bukkit/scoreboard/ScoreboardManager.html
Can anyone explain bukkit runnabel to me?
What do you need to know?
no you are fine
How to make a runnable that switches a boolean var on and off
I'm a bit confused between the differences between different player connection events in BungeeCord- PlayerHandshakeEvent, LoginEvent and ClientConnectEvent. When should I use which one?
new BukkitRunnable() {
public void run() {
updateBoolean();
}
}.runTaskTimer(plugin, delay, interval)```
its your main class that extends JavaPlugin
?
oh ok
plugin is where your onEnable and onDisable are
ok i think i get it now, thank you so much
no problem!
Tbh that looks like a client issue... I could be wrong though.
Try debugging the yaw you're setting and the yaw after the packet is sent
all items?
yes
for loop?
PlayerMoveEvent
I need a all sound for tabcomplete
making a list of all the manual sounds would be horrible.
for(Sound sound : Sound.values()) {
String soundName = sound.name();
}```
@quaint mantle ^
oh
thanks
return Arrays.asList(Sound.values());
It doesn't detect the direct that the player is moving in
make sure to cache it
Do plugins built with jdk 8 work with servers running java 16?
Yes I believe so
?
why not?
private boolean playerMoved(Location to, Location from) {
return to.getX() != from.getX()
|| to.getZ() != from.getZ();
}
Ok 👍 thanks guys
: )
@EventHandler
public void onPlayerMove(PlayerMoveEvent e) {
if (!this.playerMoved(e.getTo(), e.getFrom()) {
return;
}
// Your code here
}
well this still doesn't detect the direction that the player are moving in
Oh ok
you can do that by comparing the values
but what if a player is looking east as opposed to west?
yeah that is my issue as well
declaration: package: org.bukkit.util, class: Vector
alr tyu
Ignoring that this has nothing to do with helping you, that's cool, is it a custom resourcepack?
it's normal minecraft?
looks like it uses an armorstand
it is
Yes, custom resource pack.
A 3D version of an axolotl in a bucket isn't normal Minecraft 🤔
woke up roof is missin
ice
lemonade my neck is drippin
i'm just gonna log off for the night 😢
So you put the item stack with custom model data in armor stand helmet and make the armor stand rides you.
Yeah, I saw the armor stand part before, was just wondering if it was with a resourcepack
what kind of var is location?
what happens if I print it?
its just a location
hmmm
declaration: package: org.bukkit, class: Location
burning question here
what is the purpose of this protected abstract class constructor, who even calls it
protected JavaPlugin(@NotNull final JavaPluginLoader loader, @NotNull final PluginDescriptionFile description, @NotNull final File dataFolder, @NotNull final File file)
I've debug that also, and the yaw is the same.
How to check args is a sound?
PluginClassLoader
If not it, then the parent loader
yea that I know, but the implementing class do not normally use this constructor, isn't it?
No
then wouldn't the public abstract constructor without args always be called instead of this?
Im about to punch a baby
does extending an itemstack remove ALL of its equals functionality?
who asked that lol
oh, no
does putting it in a map destroy it's equals functionality?
destroy?
map uses equals
how can map function if equals is destroyed? or idk what you mean

anyone know how to fix intellij freezing?
How to check args is a sound?
I tried using trycatch but it keeps giving the error on the console.
try {
Sound sound = Sound.valueOf(string);
} catch (IllegalArgumentException e) {
}
I make a function for check is a sound
i try IllegalArgumentException
and NullPointerException
but
are you sure you compiled and updated the plugin? restarted server and got this error?
it doesn't matter, he should have caught the exception nonetheless
isSound and args1 are not the same method
ah oops im blind
My god, I was doing the wrong job and I only noticed now.
I apologize for the stupidity.
and thanks for the help
dont name you method arg1 pls
I couldn't even tell it was a method at first glance XD
i knew it
extending an itemstack breaks functionality through #equals
even when cloned
watchu mean by break functionality
says A extends ItemStack
😂
but you can override the superclass equals method
this man
it is not "destroyed" XD
i didnt ask for your help
;-;
:(
wait a minute
By using List#add(index, something) method, will it replace the item with that index or adding it?
add
add(int index, E element): inserts the element at the given index. The elements from the given index is shifted towards right of the list. The method throws IndexOutOfBoundsException if the given index is out of range.
so if you had [A, E, U] and do vowels.add(0, "I") itll be [I, A, E, U]
When I try to spawn a player it returns this error.
code?
However I did a try catch to return null
When I type random letters, it returns the correct message.
Is there a better way to do something every hour on the hour in Bungeecord? Something's telling me this method is probably bad and I don't know why```java
public void startHourLoop() {
LocalDateTime now = LocalDateTime.now();
plugin.getProxy().getScheduler().schedule(plugin, this::everyHour,
Duration.between(now,now.plusHours(1).truncatedTo(ChronoUnit.HOURS)).getSeconds(), TimeUnit.SECONDS);
}
public void everyHour() {
System.out.println("It is now on the hour");
plugin.getProxy().getScheduler().schedule(plugin, this::everyHour, 1, TimeUnit.HOURS);
}```
I'm not creating an npc system
It's just a simple spawn mobs command
However, when the PLAYER option appears, it gives an error.
public void startHourLoop() {
getProxy().getScheduler().schedule(this, new Runnable() {
public void run() {
//Do code?
}
}, 0, 1, TimeUnit.HOURS);
}```
then block the type of player
if(input.equalsIgnoreCase(EntityType.PLAYER.name())){
//say no
}```
boolean isEntity(String string) {
try {
return EntityType.valueOf(string.toUpperCase(Locale.ROOT)) != EntityType.PLAYER;
} catch (IllegalArgumentException | NullPointerException e) {
return false;
}
}
🥄
or that
Oh I didn't realise Bungeecord's .schedule() could have an interval, I assumed that would be a different method like in Bukkit. Guess my suspicions were correct! Thanks 😄
no problem
not working for me
I wanted to make a list of entities that give an error to return null.
Isn't Enum#valueOf annotated as Nullable?
or it will throws IllegalArgumentException instead if the enum is invalid.
boolean isEntity(String string) {
try {
EntityType entityType = EntityType.valueOf(string.toUpperCase(Locale.ROOT));
if(entityType.equals(EntityType.PLAYER) {
return false;
}
} catch (IllegalArgumentException | NullPointerException e) {
return false;
}
return true;
}
boys, only 93 compile time errors left on my big rewrite
I'm throwing a party once it's done
Hello good evening.
I have a problem with a Bukkit Runnable I hope you can help me.
The thing is, I'm using a multiplayer Bukki Runnable. all using hashmaps, but what I don't know is how to make the hashmaps (player) arguments individual for each player. because currently I give the value to the variable Player player; from the constructor and the player I use it in the run (), the problem is that it interferes with the other tasks of the players. thank you I hope you have given me to understand and can help me. I attach a bit of the code:
private final Player player;
public TaskAR(Bar bar, Player player, AR plugin){
this.bar = bar;
this.player = player;
this.playerHash.put(player, player);
timeRelog = plugin.getConfig().getInt("Anti-relog.Time");
this.progressHash.put(player, 1.0);
this.timeHash.put(player, 1.0 /(30 * 20));
}
@Override
public void run() {
//player.sendMessage("tas loco tio");
if (player != null) { bar.getplayerBossBar().get(player).setProgress(getProgressHash().get(player));
bar.getplayerBossBar().get(player).setTitle(Bar.format("&6Anti-Relog (" + Math.round((getProgressHash().get(player) - getTimeHash().get(player)) * 30) + ")"));
getProgressHash().put(player, getProgressHash().get(player) - getTimeHash().get(player));
if (getProgressHash().get(player) <= 0) {
bar.getplayerBossBar().get(player).removePlayer(player);
bar.getplayerBossBar().get(player).setVisible(false);
bar.getHashPlayers().put(player, false);
this.cancel();
bar.getPlayerTask().remove(player);
bar.sendedMsg.put(player, false);
}
if (player.isDead()) {
bar.getplayerBossBar().get(player).removePlayer(player);
bar.getplayerBossBar().get(player).setVisible(false);
bar.getHashPlayers().put(player, false);
this.cancel();
bar.getPlayerTask().remove(player);
bar.sendedMsg.put(player, false);
}
}
}
is your issue that every player is getting the same bar?
nop i cover that with the getPlayerBossBar that return a bossbar hashmap
he problem is that that class i called by 2 players at the same time
and the variable player interferes
that all the code in run uses player
i was thinkink to do a foreach but idk if i works
stacking all the players who call the class in a hashmap and then in run do the foreach of the hashmap players
That's fine though, many entities give the error.
this is genuinely hard to read
I thought about that
I'm still not sure what the issue is based on your description
The problem is that the player variable cannot store more than 2 players so it interferes with the entire run () method.
run() its ok but i need to execute run() for 2 players in the same time
ok so yeah you want to either have one run() per player or have run() go through every player
Let the method run for any player regardless of whether other players are already running it
have each player create their own instance of run when it should start
You can be more specific
ty :3
I've used an armorstand marker to make the armorstand hitbox smaller, but the name of the armorstand has gone down. Instead, has anyone ever solved this problem, can you help me?
---> picture: https://www.img.in.th/image/OJW5xw
how are you running your run() method
move the armorstand up
also I thought armorstands with marker tags specifically couldn't be hit at all
I want the name on top of the armorstand
it is on top of the armorstand
that is your problem
with a:
TaskAR task = new TaskAR(this, player, plugin);
public class TaskAR extends BukkitRunnable {
@Override
run()
}
ok how are you calling the thing on top
and also I guess it might be important to say how you're creating your bossbar
how do i check if a player is sleeping
my current code isnt running
oh
well that isnt all the code
but its just the standard PlayerEnterBedEvent
if (getConfig().getBoolean("Anti-relog.Defender-Timer")) {
bar.castPlayer((Player) e.getEntity());
}
if (getConfig().getBoolean("Anti-relog.Attack-Timer")) {
bar.castPlayer((Player) e.getDamager());
}
public void castPlayer(Player player){
if (sendedMsg.get(player) == null || !sendedMsg.get(player)){
List<String> castMessage = plugin.getConfig().getStringList("Anti-relog.Anti-Relog-Message");
for(String messages : castMessage) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', messages));
}
sendedMsg.put(player, true);
}
getHashPlayers().put(player, false);
if (getHashPlayers().get(player)){
getPlayerTask().get(player).cancel();
getHashPlayers().put(player, false);
getPlayerTask().remove(player);
}
getplayerBossBar().get(player).addPlayer(player);
getplayerBossBar().get(player).setVisible(true);
getHashPlayers().put(player, true);
TaskAR task = new TaskAR(this, player, plugin);
getPlayerTask().put(player, task);
getPlayerTask().get(player).runTaskTimer(plugin, 0, 0);
}
This is the method castplayer
are you passing the same bar object to all run() tasks?
excepting the player variable
that i put there
where are you creating the bar
HashMap<Player, Boolean> castedPlayers = new HashMap<>();
HashMap<Player, BossBar> playerBossBar = new HashMap<>();
HashMap<Player, TaskAR > playerTask = new HashMap<>();
HashMap<Player, Boolean > sendedMsg = new HashMap<>();
these are the hashmaps
on playerJoin
@EventHandler
public void onJoin (PlayerJoinEvent e){
if (getConfig().getBoolean("Anti-relog.Enable")) {
Player player = e.getPlayer();
if (!bar.getplayerBossBar().containsKey(player)) {
bar.createBar(player);
}
}
}
public void createBar(Player player){
BossBar bossBar = Bukkit.createBossBar(format("&6Anti-Relog"), BarColor.RED, BarStyle.SOLID);
getplayerBossBar().put(player, bossBar);
}
if ((float) farmingXP / xpRequiredToNextLvl(farmingXP) < 0.05) {
fillFarming = "&f--------------------";
}
if ((float) farmingXP / xpRequiredToNextLvl(farmingXP) >= 0.05) {
fillFarming = "&2-&f-------------------";
}
if ((float) farmingXP / xpRequiredToNextLvl(farmingXP) >= 0.1) {
fillFarming = "&2--&f------------------";
}
is anyone able to help me convert this into a function that deals with a StringBuilder as i cant get my mind across how to do that, rather than occupy 250+ lines of code with this nonsense
and what is your issue, exactly? something about wanting to run something multiple times?
The program creates a bar for each player, that is activated when he hits or receives hits, the problem is that as the task is global and is called by constructor, it interferes with the other tasks
https://www.geeksforgeeks.org/stringbuilder-class-in-java-with-examples/
stringbuilder isn't going to fix the core issue which is you not doing this in segments
interferes how
when the player hits again the same player, the time of the progressbar is not reset because the player variable contains another player
the progressbar shown is reset but the time of the task continue and cancel he task with he first hit
yeah you might have a structure issue here
it's not that complex but the way you structured it is starting to sound like it's not going to work
there cast 2 players in the same time, but if i leave only i cast its ok
probably i have to do the same structure to the other player
but i want to this work with only 1 method
who is the person who gets the bar, the person hitting or the person getting hit?
e.getEntity() is the player that recives the hit
and e.getDamager() is the player that do the hit
the 2
the 2 with the same event and same methods
ok so this entire thing should only take 1 hashmap to make
class CombatTag{
int timeRemaining;
Player player;
BossBar bossBar;
CombatTag(Player player){
boolean isDisplaying = false;
this.player = player
ListenerClass.players.put(player, this);
}
public startDisplay(){
isDisplaying = true;
//start a repeating task here that will repeat showing the tag until the time remaining == 0 , once it is make isDisplaying = false;
}
}
class ListenerClass implements Listener{
HashMap<Player, CombatTag> players = new HashMap<>();
@EventHandler
public void whatevr(damageevent damageevent){
CombatTag combatTag = players.get(damageevent.getplayer());
if (combatTag == null){
combatTag = new CombatTag(player);
combatTag.timeRemaining = X;
}
}
}
obviously it's pseudocode
and there's a better way to do the listener but I can't be bothered to use the hashmap specific mehtods for pseudocode
@hardy pivot ^
oh yeah and make sure to use the boolean to make it start the display again if it is set to false
de nada
don't forget to tip your staff
JAJJA
@torn shuttle Hey
I realised that i already have this implemented in my code
the problem was this
Always giving false xD. what a headache
the whole program its ok
btw thanks for your helping and he patience
my me from another night did that and did not remember
yeah
Is there any list of minecraft particles with their values from spigot API, or i need to make one myself?
hey bro, how to clear dead named entity log
Unname entity on its death
like this, how to clear it
hmmm, i think it work
I know that it works, i use this in my own plugin
okay, i will try it
i hate pebblehost :(
wait, how to unname named entity, name it ""?
or null
idk why
I won't get an error right?
now
multicraft panel, shotty machines
terrible support group
idk why i wouldnt hate it lol
XD
I hate any hosting that has a panel
XD
LOL
rAtelImIt
just use Pterodactyl
or your own panel tbh
...Im just using ssh
ssh is for pros
thanks
right XD
ur salty
i think
idk
LOL
On hypixel skyblock theres a sound if you hit a double, triple etc hit
Relaxing sounds to fall asleep to
Subscribe if you want to see more content :)
Join my discord! https://discord.gg/hY2DXNHkNW
this
how do i find out what its called?
kinda sounds like a spider
oh bro, its steel has a name. how you setname when entity die.
EntityDeathEvent?...
question
yes, i set it
question
i have a question
is GeyserMC & floodgate safe to use
like, is Player#getName() still functional
Probably
okay
Can I add maven modules to my project? Like include the module, right now I only know how to create a module but in separate project and shaded the module into my project.
Okay, what should I do first? I have my project right here.
Defining all the <module>
how to setname when entity die.
It’s dead????
or how to clear named entity on log
like this #help-development message
bro i dont think he even knows what hes saying
okay so, i have this wrapper https://github.com/aglerr/BackpackWrapper and I want to move all of them to my current project.
Pebblehost 👀
I think you need to ask in #help-server @indigo crypt
Because it's in different project, and to use them I need to run maven install and shaded it into my project, which take a lot of time honestly.
I mean using gradle could increase performance in terms of time if you’re interested in that
just clear log on named entity, its game problem, not a server
Gradle shill arrives
Smh
I mean to update the wrapper and use it on my project I need to run maven install and compile my project again.
And now it's giving NoSuchMethodError for some reason.
Do you shade in the right stuff into your final jar?
yes, i shaded it
Did you shade it or did you include the jar in ur jar
shade or relocated
Open it with like 7zip or sommin
Which module is responsible for building your jar?