#help-development
1 messages · Page 38 of 1
compileOnly means the classes are already provided on runtime. (The server jar includes the spigot api ofc)
implementation means that you copy the classes into your jar so you provide them on runtime
"implementation" and compileOnly are weird terms
"compile" and "provided" makes much more sense imho
compile ur mom
Well I restarted the server and it's good
Bump
hmm is gson::fromJson creating an object by looking thro the public constructors of that class?
You are going to be manually moving each one so fake them would probably be simplest
Okay
Well I have to figure out how to do that then because I have no idea how to start lol
it has the advantage of no stray AS left laying around when you get it wrong. Downside is NMS so version specific
i don’t rlly care about the version specific stuff
It’s just that I don’t know to use fake entities at all lol
well, you don;t want any AI so yours are fairly simple
and purely packet based
means no events and they never really exist
Won’t I be manually moving the fake entities too though?
yes
I need to be teleporting these armor stands on top of players
you'd be doing that real or not
as I think you said earlier you had issues with having them mounted
Yeah
wrong height or something
one armor stand per player being moved is not heavy
Ye
atleast we got another error message now
Recursive infinite loop
it gives an error saying can't be cast
dunno im trying to fix the problem for the whole afternoon now
ah forgot to uncomment smth
Not every BlockData is an instance of Ageable. You need to check before casting.
so were still at the prev error lmfao
BlockExplodeEvent.blockList().remove(Block) doesn't work, how would I fix that?
it doesn't remove the block from the blocklist
Show your code
I love CME
This will throw a concurrent modification exception
it doesnt
it spams REMOVE!! but doesnt affect the actual blockllist
e
This will throw a concurrent modification exception.
If you want to remove all blocks then just call .clear() on the list.
do I have to call e.blockList() every time I want to remove
i was just debugging 💔
that code will throw a CME
so if that code doesn't, it isn't the code that is running
[19:30:09 INFO]: [Gaben123: Set own game mode to Creative Mode]
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 WARN]: Nag author(s): '[Gaben123]' of 'OCMEssentials' about their usage of System.out/err.print. Please use your plugin's logger instead (JavaPlugin#getLogger).
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!
[19:30:19 INFO]: [OCMEssentials] [STDOUT] REMOVE!!```
This example prevents diamond blocks from being destroyed by explosions:
@EventHandler
public void onExplode(EntityExplodeEvent event) {
event.blockList().removeIf(block -> block.getType() == Material.DIAMOND_BLOCK);
}
alr thanks ill use removeIf instead
Use this if you want to have multiple materials:
private static final Set<Material> PROTECTED_BLOCKS = Set.of(
Material.IRON_ORE,
Material.DIAMOND_ORE,
Material.GOLD_ORE
);
@EventHandler
public void onExplode(EntityExplodeEvent event) {
event.blockList().removeIf(block -> PROTECTED_BLOCKS.contains(block.getType()));
}
yeah ik ill just do java e.blockList().removeIf(b -> plugin.checkSpawnProtect(b.getLocation()));
Lets see that checkSpawnProtect method. Could be very expensive depending on the implementation.
whats the difference between a Set<> and a List<>?
a Set can contain any element only once
also you cannot access stuff by their index
What the use for so ?
A Set can not contain duplicates but is generally faster for lookups but has no index access.
A List can contain elements multiple times and has index access.
Thanks
Thanks too
Does anyone have ideas to what could be wrong with the code?
No need to tell me to use OOP, i just wanna fix whatever is wrong with this code, and learn what mistake I made, if there is an easier way to do this sorta "stair-case" configuration management im open to that aswell :)
Looks fine. Use a primitive boolean instead.
pretty new to java, what does primitive even do?
case sensitive
primitives are "built in data types". There are also wrapper objects that you sometimes need, they basically turn a primitive into an object
Ehh what sorry ?
e.g. if you wanna return "true / false / null", you need the object, because primitives cannot be null
Test != test
You mean for the configuration ?
Because i already have case sensitive in the code, just did a quick example for visual, to support the explanation
it would be VOID https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityDamageEvent.DamageCause.html#VOID
declaration: package: org.bukkit.event.entity, class: EntityDamageEvent, enum: DamageCause
uh anyone happen to know if dripstone caves are at a specific depth?
or can they be all over
(which it is always is, anyway, so no real reason to check it)
they are all over!
thanks
same for the lush? it says underground below azalea trees so is that usually at shallow depths?
how can I see if its void specifically
Get the damage event and check the cause ?
get the last damage cause. check if it's null. if not, do getCause() or however its caleld
then check if the given cause == DamageCause.VOID
okay cool iot finally works
Cursed af
Is it against rules if external download link is on curse forge ?
Any help for this issue? And yes in the code it is case sensitive when i set the String path for the config
No
The only issue we have with external links is if it's a pay-per-click link (think adf.ly), if it's getting you to download something that is not the resource being advertised, or if it points to a paid resource
it might be against your country's data privacy laws though if you don't have a proper privacy policy lol
gson is weird and my custom serializer doesnt seem to work
How about a chain of 4 - 6 pay per click links for a 15$ plugin on spigot that points to another marketplace which charges another 15$
You need to add custom serializer for atomics
maybe if i explain my problem...
i'm trying to serialize my KingdomPlayer object and the default serializer threw an exception that it couldnt access the inner value of the atomicref (you prob know that) so i added a serializer to take the value out but that doesnt seem to work
so here are the fields
public class AtomicIntSerializer implements JsonSerializer<AtomicInteger>, JsonDeserializer<AtomicInteger> {
@Override
public AtomicInteger deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
return new AtomicInteger(json.getAsJsonPrimitive().getAsInt());
}
@Override
public JsonElement serialize(AtomicInteger src, Type typeOfSrc, JsonSerializationContext context) {
return new JsonPrimitive(src.get());
}
}
GsonProvider.INSTANCE.registerTypeAdapter(AtomicInteger.class, new AtomicIntSerializer());
For AtomicReference you might need a TypeAdapterFactory which can be quite tricky
Well... maybe not. You could just unwrap the reference.
i currently made this ```java
public static class PlayerDataSerializer implements JsonSerializer<KingdomPlayer> {
private final Gson gson = new GsonBuilder().setPrettyPrinting().create();
@Override
public JsonElement serialize(KingdomPlayer player, Type typeOfSrc, JsonSerializationContext context) {
JsonObject json = new JsonObject();
json.addProperty("uuid", player.getUniqueId().toString());
json.addProperty("playerData", gson.toJson(player.getData(), PlayerData.class));
return json;
}
}```
creating a gson instance inside your json serializer seems meh
mye ik
You should not register a serializer for your KingdomPlayer.
Work your way up. Start with the lowest level and let Gson do the rest.
so i should add one for the playerdata ref?
I have one Gson instance that gets recalculated and has all the type adapters registered you would need
exposing it?
well i was using one cuz the only thing that gson needed to know is what to do with the atomicref, so i passed the playerdata obj to the default serializer after getting it out of there
You should not work with references in data classes at all.
So instead of the player ref you should use the players UUID.
There is also 0 need to make PlayerData an atomic unless you intend to set it a lot from different threads. Which you should avoid. Make it final.
Well yea but that isn't really how you do gson
started with it yesterday hehe
hmye lets remove that atomicref
conclure recommended me that 🤔
Immutability is key here. It automatically makes your data thread safe as well. Only synchronize when you really need to.
Gson can handle immutable classes quite well.
only thing of the kingdomsplayer which is mutable is the whole playerdata class
that why i made a seperate class
Why would you want to swap out the entire PlayerData?
wrapping a mutable type in an atomic ref does not really help
wdym swap out?
Replace it. Use a setter to set the value.
replace what?
it's loaded from the persistent storage and set when creating the player object
the whole playerdata is mutable: https://github.com/FourteenBrush/xKingdoms/blob/master/src/main/java/me/fourteendoggo/xkingdoms/player/PlayerData.java
And the atomic reference tells me that you intended to replace it afterwards
From a different thread
actually i forgot why i did that but conclure told me smth about it lmao 🤔
Just... remove all the references and use final fields.
Then Gson will be able to serialize everything on its own as long as the nested classes are Pojos and you
have type adapters for the bukkit objects.
what about the player field?
If you want a type adapter factory for abstract classes and interfaces just ask me later.
UUID field.
With a method
public Optional<Player> getOnlinePlayer() {
return Optional.ofNullable(Bukkit.getOnlinePlayer(this.playerId));
}
Or without optional if, and only if, the data is never being loaded for an offline player.
the thing is that i wanted to avoid a map lookup cuz the methods that call my getPlayer() method already do a few map lookups and i wanted stuff to be as efficient as possible :/
I mean, can always weak ref the player instace
You can do thousands of lookups on a hashmap every tick and never notice it in your timings. We are speaking of a few micro seconds here.
mmmh
And the overhead of a reference is comparable to a hashmap lookup.
i still got the same error but ig i forgot to remove smth
Yaaaa, but well concurrent writes and reads, proper atomicity becomes especially important, altho think we talked about favoring immutability as well
Havent read your code tho 😅
its on my gh lol
i used to do it at school lol

What error? :0
is there a way i can disable a skeleton from shooting a arrow temporarily
fuck
leaked
Oh
You’re trying to make gson use its reflection shit to serialize/deserialize
yep
its more for testing so i dont have to focus on db impl while testing other stuff lmfao
I mean I hope you mock ur database
whats that supposed to mean
i once had to make a mockup thing at school and i fucked up :(
When you test other parts of your project that rely on the database you subtitute the database implementation with a mock one that you entirely control so we can get the test flow of "Assume everything else works, does this function/module also work?"
We essentially try to only test the stuff we actually want to test
Oh well this is mostly for when u setup auto tests
For the manual ones you probably dont mock stuff
Like some integration test perhaps
Can anyone help me with stopping a player from moving a boat? Currently I am using the VehicleMoveEvent, dismounting the player, teleporting the vehicle, waiting a tick then mounting the player back on. If I do not wait a tick the client thinks the player is not in the vehicle whilst the server does. If I wait a tick that issue is fixed, but it looks like they player is standing up in the boat
My code ^
You know why that is fourteen?
not yet
serialisation should work normally
How does player data look?
and playerdata looks like this, skilldata is basically a map wrapper
You dont use any atomic/weak references?
Try to recompile everything and run again
Sounds like you might have an old cached jar or sth
i just did so shouldnt be possible
Related to this, is there a way I can set the pose of a player? As in put them in the sitting position
lets do again then
Also push everything to gh, Ill read it through rq
what way can i do this mc code:
tag @s add foo
in java basically add a tag to the player
is a tag PDC?
As a command?
it doesnt have to be it can just be in code
Try to repair the ide
like java Player p = (Player)entity; entity.addTag("foo");
just started working lol
Ah nice
I think it was corupted project
I'm working on a plugin for a custom item-type that the player can interact with by left/right clicking the air while holding that specific item. My questions is mostly if it's fine performance wise to have an event listener for this and filter out events where the item is incorrect.
Say the item is diamond, but the eventlistener checks for the player clicking the air with a diamond. Players will always be clicking with lots of random stuff, so will it be a significant impact on performance if it picks up that event and checks if it's a diamond?
I ran a test for the eventlistener, and it would also pick up events where I was clicking blocks, not just nothingness. I assume because there are airblocks everywhere around the player that get clicked as long as you're not interacting with something
still same error lol
You can identify an item by a pdc tag maybe? And then match with a map entry?
Yes so the code right after the event is registered would be something like "If(list.containsItemInHand)"
Does anyone even know of a link to a post on this topic? I'm searching and I can't see anything
Say this would run with 100+ players active at any one time. Essentially I am asking if it would be a noticeable impact on server performance
Yes exactly
100, probably not
But the question is more if listening for an event that common would be an issue
Pretty much no
It depends on what you’re doing in the event
Also what java version
Since newer versions do perform better generally speaking
Yes, Java edition.
No
event.ACTION
Java version, not java edition
oh conclure the only thing that could have a weakref is a location obj
PlayerInteractEvent will trigger on clicking air and blocks
and im saving homes with locations objects
Then thats the culprit
smh
so i'd need another typeadapter for locations :(

this is stupid
Ah, thank you for the clarification
Average gson enjoyer
Filter like so
Is there something you recommend for testing how efficient my code is? Like how much CPU time is spent
You can stress test it, also benchmark it
Could you make a recommendation of how to do that?
Conclure, you got any ideas?
if its a custom tag, use pdc
?pdc
Profiler, jfr and learn how to write benchmarks
if not, you need an nbt api
Thank you
Whatve u tried sofar
I basically said what I've tried there
I also tried making an 'exempt list'
where I add them to the event list before it adds them as a passenger then takes them out after
in case that adding them as a passenger caused another move event?
didn't do anything tho
that has a delay of 1/2 a sec
tabnine is sabotating me
but even with a long delay
still standing up
if I reload the server the player immediately sits down
but even with long delays it doesn't sit the player??
I can just walk off the boat in between times
What if you nullify the velocity ?
Ive only worked with vehicles nms wise so Idk acc
just set the velocity to 0 each tick?
Yeah assuming you can set it before its applied
probably not
I'm listening to a move event after all
I only get the location of where the vehicle is now
and where it was
skills seem to work
ayo, anyone knows how to give a player 3 absorbtion hearts?
the issue is I wait a tick before adding the player back into the boat, but then there is no delay between the event fires again and they get teleported out
so I've just go to switch it around
or maybe not
idfk
aaaahhh
I'm now trying unholy things
the issue comes with having to dismount the rider before teleporting the boat
I think maybe if I send a packet to the client instead of teleporting it might work?
still need that location typeadapter?
Can someone help me with this?
I don't know how to turn those 3 fields into a byte
I have a question. I think this thread https://www.spigotmc.org/threads/premium-resource-guidelines.31667/ is old and I would like to know what have changed. Can someone tell me please?
whats the pourcentage of minecraft basic strenght ? (for 1.8.9)
Google it
i have a question:
- I have a Item Generator Plugin (A plugin that spawns items)
- I want to be an option for players to buy genboosts, so that the gens go faster for like 5-10 minutes.
- Is there a plugin that increases the speed at that moment?
(The Resource I Use:
https://dev.bukkit.org/projects/gorea-item-spawn)
In-game money I hope 
indeed..
cant find it
ok so update on the boat situation
I am now sending a packet to sync the client back up with the server
and it is...
horribly glitchy
what do I have to do to get this to work 😢
does anyone have any ideas?
I just want to stop player from riding a boat
ffs
why is this complicated
dismount?
what about dismount?
p.eject()
how would that help?
Cuz comparing strings with = is wrong
Player will get out of boat
Use .equals
I'm getting this now
how many tps u got?
that error shows sometimes when server is lagging
are you using flyspeed or something addition?
no
what are you even doing?
it's the boat going fucky wucky
trying to stop a player moving a god damn boat
trying to cancel the vehicle move event
Hello, reading about optimization tips I found some tips like cancelling the spawning of bats, salmons and others unusable mobs
So my question is: is there more tips like this? I mean cancelling another events to get more optimization or do something with plugins to get that😳
behold, most cursed code
just remove the boat lol
wdym
try removing boat
why would I remove the boat??
why would you cancel boat move event?
May any op optimization plugin?
just ignore it if it does not cause other bad things
use consolespamfix
idk much
there are most certainly other bad things
I spawn the players in the boats
and want a section where the players can't move the boats, count down, boats can be moved again
and I could do that through other methods
but I though I'd make a general solution which just allows me to stop a player driving any boat
Salmon is useful
useful to stack de ram, yeah
For food
nah there is a lot of salmon on rivers or ocean, really a lot
just for food, but someone really uses a salmon to principal food?
no
And if someone needs a salmon can fishing it
Google your question before asking it:
https://www.google.com/
I can't use citizens and znpcs
for that I ask and I don't find other plugins in google
why cant you use them
citizens is so restrictive and znpcs have malware
then report znpcs
Citizens isn't restrictive wdym?
and ^
Their api is great
I already do that
why do you think it has malware?
they say I need to delete geysermc and I don't want to
@mint oracle why didnt you... report it?
which class is it in source code?
I just decompiled it myself + ran mcantimalware which should flag that
Yes, but if that were true, the creator would not have told me that it did have malware.
Lmfao that code looks so bad
do you have a screenshot of them saying it?
yes
send it please
but is in spanish
thats fine
what he says there would make more sense with what he sends on his support channel, but I'm banned
whats the class location
idk, im not programmer
Ask them that
import ak.znetwork.helmetcosmetics.listeners.PlayerListeners;
Whoever you got it from
.
ZNPCs itsself doesnt have anything- the only ZNetwork under the ZNetworkDev is an empty repo
and even though the Spigot account is ZNetwork, the github is different https://cdn.rackdevelopment.tech/img/voGKHgn08y.png
.-.
i mean bro doxxed himself
Montevideo, Uruguay
doxxed, well
its on his personal website
any know what do that malware?
but yea
it just gives the person permissions it seems
we need to find where that plugin is
but as we said, it isnt in znpcs
whatever any know a npc plugin? (no citizens no znpcs)
seems like he was active in 2017
@mint oracle why not citizens
citizens support say to me "delete geysermc"
And the only UUID ever present in the gist was 2e436714-8dd9-3361-b9e1-7f87536a2e77
and I need geysermc
Citizens is just not ok
ye
citizens is fine they just dont support bedrock which I agree with fir their reasoning
I 100% guarantee they use a lot of packets and Java-specific stuff, they dont want to spend hours redoing stuff from the plugin that will probably only cause more issues
their support is one of the worst
I can agree to that the support sucks lol
Why my item in hand was modified? i want only that items in gui modified
we need serious alternative for citizens
yes the sucks
yeah
I do need to make a npc plugin for my server at some point
maybe that'll be my next project
public project ;D
probably
any ideas ? 😢
What event are you listening to when this code gets called?
BlockLookup() should return a list of string array
it returnes some stranges values, Idk what them are
This is a GUI (custom gui management class)
but when i want take the item in hand, i want not edit this, i want edit just items in the GUI not in my hand
a fonction like clone in php exist in java ?
ItemStack#clone() exists. However, it looks like you are already using a copy.
You may want to have stricter checks on what inventory you are clicking in.
But i want only edit the item in gui (in the for)
not the item in hand
oh .clone work
Then you may want to avoid grabbing the item from the player's inventory if possible. (Unless your system gets the item from their inventory)
I still believe it's an inventory click issue. InventoryView#getTopInventory() should help you with what's being clicked.
i made it spawn a armor stand on the block but why does it spawn in the corner?
the item in hand not modifed with this 🙂 🙂 🙂
the block location is actually .0
Because Minecraft is based on a Vector system. If you want the center, you need to add .5 to any location.
do block.getLocation().add(0.5, 0, 0.5)
I have a feeling of having already seen
thanks
My bad, I meant coordinate system. I'm tired. :PP
But what if it was? vsauce music starts playing
blackholes
No not ok at all
sb much?
Hi does someone know why vault top placeholder like %vault_eco_top_player_1% doesn't work and %vault_eco_balance% works ?
is this a development question?
new Boolean(boolean)

whats wrong with it? Other than the fact Player NPC's arent packet based atm
or is it that
?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.
how can i put a players head on a armor stand ?
or make a itemstack with a players head?
iirc you can just set the equipment slot of the armor stand to a ItemStack of the PLAYER_HEAD material type
ofc
need to set its skin data
create an itemstack of material PLAYER_HEAD. cast the meta to SkullMeta, then set the owning player. set the meta back to the itemstack. then, get the armorstand and set it as helmet using getEquipment
isnt setOwningPlayer deprecated?
no
at least not in 1.19.1 😄
im used to the OfflinePlayer one lol
yes
or UUID, used to be one like that back in the day
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/profile/PlayerProfile.html
@desert frigate this is for the argument of setOwningPlayer
declaration: package: org.bukkit.profile, interface: PlayerProfile
yep
back in the day that was rly nice
one liner solution
how you need hash and uuid and other shit
i think, idfk
like this>
?
the javadocs always tell you what to use instead
i see
thanks
also one more thing, im trying to make the armor stand look at nearby mobs but it is really glitchy for some reason
yeah so basically
you gotta convert yaw and pitch
to Y and X head rotation
ignore the Z axis, you don't need roll
yeah i just set it to 0
also head euler angles are in radians
oh yeah and toFace
a function exist to get the repair cost of item ?
Exemple i want (in code) get the amount of xp need for repair at certain %
any ideas?
Hi, does anyone knows how to manage the teleport priorities between plugins? Say for example, you have 2 plugins that want to teleport you on login, how would you make your plugin the highest priority for that teleportation?
on();
loc.setDirection(player.getLocation().subtract(loc).toVector());
float yaw = loc.getYaw();
float pitch = loc.getPitch();
Util.sendPacket(new ClientboundRotateHeadPacket(entity, (byte) ((yaw%360)*256/360)), player);
Util.sendPacket(new ClientboundMoveEntityPacket.Rot(entity.getId(), (byte)((yaw%360)*256/360), (byte)((pitch%360)*256/360), false), player);
``` I use this for my npc looking maybne it can be applied to armorstands
yes it can
change the event priority
what are you trying to do
and why does it need to be static
static boolean myBoolean = true;
what do you mean register it?
I'd recommend learning a bit of java before hopping into plugin development
JavaPlugin is already a singleton you dont need to create an instance
Which event? I mean, if I do Player#teleport there is no priority
ah, thought you meant onJoin
im still not sure what you are trying to do. can you show your code
Well, even on join. The plugins does Player#teleport on join
so not sure that changing the priority of the join event will change the teleport priority
Well, gonna try anyway
it will
if not try PlayerTEleportEvent possibly?
if(turbodrop) {
turbodrop = true;
will never be true
assuming its false
§c§lT§4§lU§2§lR§a§lB§l§f§lO§4§lD§c§lR§6§lO§e§lP lEgAcY fOrmAt is GreAt
i still dont understand what you are trying to do
running turbodrop = true; only if turbodrop is already true makes no sense
hey guys. ive got plugin 1 which has a method i want to access. in plugin 2 i use Bukkit.getPluginManager().getPlugin("plugin1") and then cast the JavaPlugin to the class of plugin 1.
i then get this error in console: Could not pass event BlockBreakEvent to CrazyEnchantments v1.9.5-SNAPSHOT
java.lang.ClassCastException: class com.gmail.relystuff.EasyDrops.EasyDrops cannot be cast to class com.gmail.relystuff.EasyDrops.EasyDrops (com.gmail.relystuff.EasyDrops.EasyDrops is in unnamed module of loader 'EasyDrops-1.0-SNAPSHOT.jar' @5eac9e04; com.gmail.relystuff.EasyDrops.EasyDrops is in unnamed module of loader 'Crazy-Enchantments-1.18-1.19-v1.9.5-SNAPSHOT.jar' @650ce278)
does anyone have any ideas?
You are probably shading in a plugin. Dont do that.
its gradle 😦
i use maven but this plugin im editing used gradle and its hurting my brain 🤣
then compileOnly() instead of implementation()
anyone have any idea how I'd go about preventing sculk spreading from a sculk catalyst?
not sure which event to use
Have you tried the typical events like BlockFromEvent or BlockSpreadEvent?
}
why can i not use the key.getString() method to get the value
my plan was to create an if statement to see if that key contains the value im looking for
what do you mean "is correct"?
Because the key is a String. String#getString() doesnt really make sense, does it?
doesnt getstring get the attached value?
if the value attached is a string that is
Strings dont have attached values
the Object is String
it has no attachment to config
if its the value, just get the value and compare
idk if oyu can compare NameSpacedKeys though
Check for equality of the namespaced key? No idea what you are trying to do.
wait i might be a little confused. if im searching for a value that should be listed somewhere in the config, how would i go about filtering it?
does anyone know good tutorials on making an API for a plugin?
basically im getting an entities uuid and it should be stored somewhere in the config. my goal is to find what configuration section that key is in which holds the uuid
config.getString(path)
This sounds quite bad. Paths should not be searched.
so search the entire config?
it really doesnt matter
hmm ill look for alternatives then
the whole config is loaded into memory
now, looping through eveyr key is yikes
but it's not the end of the world
Still searching in a config is expensive
yeah your design is probably bad if u need to do this sort of workaround Criv
if the uuid is the key it should be the focal point of your config design
^
You should have a predefined path like
"data.playerdata." + playerId + ".stats.kills"
i think i have an idea for an alternative that should be more optimized as it wont go through the config
sry to post again
Just provide a simple entry point and some events when it makes sense
wdym entry point?
Like a getter for a singleton
oh like getInstance?
blocks dont have a PDC
If you set the PDC of an ItemStack then the placed Block does not contain the PDC of the ItemStack.
You need to transfer the data from your ItemStack to the Block.
Not every Block has a PDC. Only TileState ones. You need to get the BlockState and check if its an
instanceof PersistentDataHolder. (instanceof BrewingStand is fine too)
When you place the block
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/block/BlockPlaceEvent.html#getItemInHand()
declaration: package: org.bukkit.event.block, class: BlockPlaceEvent
Anyone have experience listening for a player leaving a minecart? This is what I tried but none of the sendMessages fired
@EventHandler(priority = EventPriority.LOWEST)
public void onVehicleLeave(VehicleExitEvent e) {
final Entity entity = e.getExited();
final Vehicle vehicle = e.getVehicle();
if (entity == null || vehicle == null) {return;}
if (entity instanceof Player player) {
player.sendMessage("Fired 0");
}
if (entity instanceof Player player && vehicle instanceof Minecart minecart) {
player.sendMessage("Fired 1");
final boolean isRailCar = PersistentDataAPI.getBoolean(minecart, KEY);
if (isRailCar) {
player.sendMessage("Fired 2");
e.setCancelled(true);
}
}
}
Listener registered?

Command -> create armorstand ItemStack -> add pdc key to ItemStack
BlockPlaceEvent -> check if ItemStack to place has pdc key -> transfer pdc key to placed BlockState
totally didnt lmao
classic
Easier for whom? Just program what ive suggested above.
yo smile is this what you mean?
Sure something like that
so essentially just a way of accessing the instanced plugin
Just think about what your plugin can do and provide useful methods for other devs. For example if you are writing a protection plugin then add methods like
public ProtectedRegion createRegion(Location cornerA, Location cornerB, String name)
or
public PortectedRegion getRegionByName(String name)
or
public ProtectedRegion getRegionWithHighestPriorityAt(Location location)
Documentation also goes a long way
yeah ok that makes sense! should the api be separate from the plugin?
There are two approaches. Either write your plugin data driven from the beginning and make everything foolproof so other devs
cant fk up your plugin, or simply create a separate api package and put a useful facade layer in there.
You can take a look at the facade pattern for some inspiration.
ok, so ive watched course and learnt etc. but how do i start to learn all the large projects.
for example a pmine plugin etc. like i wouldnt know where to start. how would i do it?
Gather experience by writing plugins
i understand that but a "hubpvp plugin" is not gunna help me in a pmine plugin. it doesn't help me. it just seems out of reach
I have developed a certain flow and style over 2 years that helps me develop anything really, by simply starting.
I always start with data managers, config managers, setting up databases, defining some data classes and then it
quickly comes together.
For bigger projects i open a trello board
yes
player#getinventory#getiteminmainhand
Isn't there also just an e.getItem()
nope
Yeah e.getItemInHand()
^
Not exactly
If they're placing it from their off hand
And they have a sword in their main hand
Yours would return the wrong item
wanna fight about it?
lul
1v1 me in java
Ill just throw hashmaps at you until you concede. Works every time.
Hashmaps?
They're rarely necessary for clash of code
I abuse streams to the fullest
Oh you are speaking about the site. I only use code wars.
unfortunately 🥲
Wanna try clash of code?
block pdc when
And yes, im always trying to get one liners in there. Doesnt matter how unreadable they become.
if only there was a lib 😭
I cant think of a reason why blocks cant have pdc.
They can with RedLib
They should by default
¯_(ツ)_/¯
I thought it doesn't allow to use actual PDCs?
limitation of minecraft. Mainly the nbt format of chunks.
It can be backed by SQLite or PDC
copycat
Why bother with pdc if you can just query a database on the main thread? 
January
lol
It's actually not an issue
It does a lot of caching
Like it has literally never caused issues
I stand my ground: copycat 😛 june (2021)
Sqlite is fast and it minimizes everything as much as possible
I'll admit pdc is probably better
*As long as you have a decent hard drive that is not used a lot
But I ran it on a server with 100+ players and lots of data blocks and it never caused any lag, I was constantly watching timings
Yeah 7smile you know what else is dependent on your hard drive?
The performance of literally everything else in the server
I dont think that there is a huge difference because the data has still to be loaded sync
Generating and loading and saving chunks, primarily
@waxen plinth I haven't found it - where's the method to get an actual PDC for a block?
World and chunk loading. For the rest its secondary.
PDCBackend
It saves per chunk
Nice
Where exactly does this return a PersistentDataContainer?
It doesn't, it parses the data as json
But you can use it very similarly
And the data is stored in pdc
so you cannot do sth like
PersistentDataContainer blockPdc = ...; ?
because that was what I was looking for
No, I personally find actual pdc kind of tedious
whut
I tried to keep it simpler
hm
Thats the spirit. My approach to pdc is very often just to throw a json string in there.
Makes it compatible with file storage and mongodb in a heartbeat.
It's basically just a property map you can attach to blocks
I think PDC has the perfect balance between easy to use and powerful enough to do everything you need
It's so nice! lol
And I use my own json parser because of course I do 💅
smh
Hey I benchmarked it
I mean how exactly is PDC hard to use?
it's like a Map<String,Object>, where you can define what exactly Object is by using the proper DataType, and String obviously is just a String with a ":" in the middle lol
🤔
"im better at coding than google"
Does it also let me register type adapter factories so i can serialize interfaces and abstract classes?
Nah
Gson isn't built specifically for performance
I set out to specifically make a fast parser
Still not as fast as jackson though
Jackson is on meth
No but it's bundled with a config library that does :)
Gson is the lib which taught me that you dont necessarily need a constructor in order to instanciate a class XD
why is every github service only "normal" and not "nice" or "good"
Unsafe.allocateInstance
Why are you only "normal" and not "nice" or "good", hm?
sun.misc.unsafe is such a dirty place...
But tantalizing
I am not normal
"guys look at me I'm quirky"
it's exactly how it works!
"Publius Sulpicius Quirinius (c. 51 BC – AD 21), also translated as Cyrenius, was a Roman aristocrat."
ok...
i kinda still wonder why stuff like a "8 element tuple" exist at all
like, what's the fucking usecase
Ive never touched anything in the sun package, besides when i forget to add annotations as a dependency.
a Pair<A,B> makes sense, it's like a Map.Entry<K,V>. a Triplet also CAN make sense sometimes. But for anything more, whyyy not just create a specific datatype?
I think pairs and tuples in general are a hacky way coming from
sandbox languages like Python and JavaScript where everything could be anything and nothing you do matters.
I would never use them in Java, Kotlin, C++ etc
we got Table.Cell<R,C,V> :> (guava)
There are so many places I would love to return a tuple but the overhead of the object instantiation makes me hesitant to return a full object
exactly, so useless. as said, for up to three things, okay it can make sense sometimes. But when would you ever need to return an 8 element tuple? like, when?!
Sounds like a design problem to me
But also you can always just Pair<Pair<A, B>, Pair<C, Pair<D, Pair<E, Pair<Pair<F, G>, H>>>>>
sounds like a valhalla issue for me
^
Needing to return multiple things is a design problem?
ragnarök when
Yeah it would be nice to have a super small object with just two references in it
It's literally so useful
Yes
How
It's very frequently used when parsing
Oftentimes you need to return what was parsed along with the number of characters it parsed through so you can jump ahead by that much
There are lots of other such cases
Where the object you're returning can't have that metadata attached to it (or it wouldn't make sense for it to)
You either pass a common context that gets mutated or you return a proper object that encapsulates your returned values.
why would you need to return what was parsed though? I mean, someone who passes sth into a method call knows what they passed into it
Those are both worse in my opinion
Like yes it's not an impossible problem to solve
But the solutions are inelegant
just pass the result as a parameter and mutate it in the method
🙏
C way all the way
My guy
Do you know what a parser IS
I know what a parser IS
Then why are you asking me why someone calling a parsing function needs the parsed value back
I absolutely despise this about C.
Passing pointers as a place for results.
because it makes no sense to me
maybe you could share a small example so I can understand it
I feel like you guys are talking about 2 different things
Exactly, because returning multiple values is often needed, or at least very useful
we should write a minecraft server in assembly
class Array<V> {
private final Object[] inner;
private Array(Object... initial) {
this.inner = initial;
}
public static <T> Array<T> init(int size) {
return new Array<>(new Object[size]);
}
}
what the fuck
Functions can take multiple values, why shouldn't they be able to return multiple values?
You sick fuck
Right, so utterly pointless
You can always make a fixed-size list if that's really what you want
enterprise code
Crazy how java hasnt already implemented this, its literally just like 2 more instructions for loading the values
you should've named it "ArrayFactory"
I mean, it's kind of what records are supposed to be
They literally called them nominal tuples in the jep that added them
The problem is still the overhead of object instantiation
But that's where valhalla comes in
When it comes in, anyways
Ideally you'd be able to make a record into a value type to have it act as an actual tuple
And then return that from your method
It'd be a tuple, just one you have to declare - but you could always just make it something like Pair<A, B> anyways to generify it
that's something totally different from what I thought you wanted to do. What you wrote earlier, I thought you wanted to do something like this
/**
* Returns the original "input" String, and the lower case variant of that String
*/
public String, String toLowerCase(String input)
and obviously that makes no sense. Maybe I misread what you wrote, or you explained it badly, Anyway, this is what I thought you wanted to do, and you probably understand that I thought that this makes no sense, lol
record SmallNumber(boolean isOne, boolean isTwo, boolean isThree, boolean isFour, boolean isFive, boolean isSix, boolean isSeven, boolean isEight, boolean isNine, boolean isTen) {
}
average rust enum user
because here you said "you want to return what was parsed" and I was like "yeah but what you parsed is what you have passed to the method. no need to return that again, since whoever called this method, already has this object", you know, lol
what happens if two of those booleans are true?
or even three 😮
or 7
public enum ByteNumber {
ZERO,
ONE,
TWO,
THREE,
FOUR,
FIVE; // TODO: addm ore
public byte byteValue() {
return ordinal();
}
public boolean isEqual(byte number) {
return ((Byte) byteValue()).equals(number);
}
}
we should rewrite it for a sum of numbers
Superposition
to represent any number
record SmallNumber(boolean one, boolean two, boolean four, boolean eight, boolean sixteen, boolean thirtyTwo)
Will the PlayerRespawnEvent activate in any circumstance besides a player dying?
I don't think so
public void assertValidity() {
if (this.isOne()) {
assert !this.isTwo();
assert !this.isThree();
assert !this.isFour();
assert !this.isFive();
assert !this.isSix();
assert !this.isSeven();
//..
return;
}
throw new UnsupportedOperationException("Hold on, I'm writing more.");
}
sometimes, even copilot is drunk
also sorry, not sorry for that song in the background
I know this band since years but I still cannot write their name
Tafts Beezlebubs
no
Beelzebubs
Tufts Beelzebubs
that one's correct but I also looked at itunes
My internets fucking up
stand.setRotation(toFace.getYaw(), toFace.getPitch());```
why am i getting this error for this simple line of code?
Any ideas?
I guess your pitch is either Double.POSITIVE_INFINITY or Double.NAN
print out the pitch before passing it to whereever you pass it
copilot having a stroke for a minute straight
what type of block is that
grindstone
Wtf XD
@quaint mantle no is anvil
oh
How is that a grindstone 😂
Im not a minecraft pro
lol yeah sometimes it has a stroke. But sometimes it does extremely awesome stuff. For example, it wrote this ENTIRE class (with maybe 2 or 3 lines I had to adjust) and IDK how it knew what I wanted to do.
https://github.com/JEFF-Media-GbR/QuizBot2/blob/master/src/main/java/com/jeff_media/quizbot/data/DefaultNumber.java
Smh
it even wrote the getName method
I remember seeing an enum with like 1000 numbers
how would i knock a mob back like 1 block? basically hitting them with a fist or smth
if you want realistic knockback
I have a util for that
that I need to constantly rewrite because this isn't 1.12 anymore
but it's easy to port
I want get in code the amount of xp needed to repair the item at certain %
Exemple : +10% durability = 3xp level
get the total level
But how?
*= durabilityBonus
just want like a simple 1 block push
then
velocity?? could be wrong
just make a vector in the direction
and call setVelocity
target.setVelocity(target.getLocation().toVector().subtract(new Vector(1,0,1)));
i have no clue how vectors work
uhh no
Vectors are a 3d displacement point relative to any other 3d point
They can be treated as relative to 0,0,0 which makes them effectively an absolute position
You can add, subtract, multiply, divide and normalize these displacements
Normalizing means it grabs the current points and divides them by its length, effectively making a vector with the length of 1
For velocities, it's quite simple
target.setVelocity(new Vector(0, 1, 0)); will set target's velocity to an offset of 1, in the vertical axis
meaning the target will fly up
Ik that creating custom potions is difficult and I was wondering if someone could point me in the direction of some type of tutorial/function/whatever.
So shouldn't I just use (1,0,1)?
orrrred
try it and see
a vector of 1,0,1 will NOT have a length of 1, if that's your question
yeah it did nothing, matter a fact it crashed the server lol
you have some weird server
its a local 1.18 server
thank you copilot
Note that the velocity is blocks per tick
Why does cancelling InventoryClickEvent in the creative PlayerInventory duplicate the item?
setting the cursor to null does nothing aswell
Anyone got some methods to make those item metas animated with colors? flash, blink, etc
u have an int instead of namespacedkey
that looks more like tabnine
damn that screenshot is so small, i can't even read it properly
how would i set a players inventory?
ok well how would i find a solution to do this?
tell us what the problem is before asking for a solution
there is no problem, i get a players inventory and i store it in a Map. then i clear the inventory ("do something") and then i need to set the players inv back to the inventory in the Map
get the contents of the inventory from your map and add them to the player's current inventory
how do i ensure there all in the same slot etc
getContents returns an array
setContents takes such an array
the array indexes match the inventory slot indexes
^ easy as that
Hi i was wondering how Player#getBedLocation works. If it works by server or by world. because im trying to send a player to their bed no matter if it's in another world
ahh for some reason intelij was glitching and i couldnt setcontents
Ok im gonna test it
does special source work with reflection or just with direct references
quick q because I have barely ever dealt with sound: if you are playing a song via resource pack to a player and you want to stop it, is that possible to do immediately?
yeah looks like it's possible
if im using "InventoryCloseEvent", how can i check the contents of a chest gui thats closed for an item
what do i do when i need two types of event listeners?
What's the easiest way to get a specific NBT tag from an entity?
Depends. All the vanilla NBT tags are abstracted out into just simple getters
Alright so you're already in NMS. It should have a getTag() method
When it spawns, im setting a custom nbt tag on it which works fine, however... when the bees exit the hive they are no longer the custom entity but they keep their nbt data
I basically need to check if they SHOULD be a CustomBee so I can cancel CreatureSpawn and spawn my own
Right because vanilla spawns a regular bee
Correct
Nice, thanks chief
Bukkit doesn't expose arbitrary NBT tags (exception to the PersistentDataContainer but that's under a PublicBukkitValues tag, nothing on root)
It's entity#getTags right
It should return an NBTTagCompound (or CompoundNBT depending on the mappings)
getOrCreateTag() iirc
Returns a Set<String>
Yeah those are probably scoreboard tags
@worldly ingot I cant find the import for the nms bee
CraftBee doesnt have getTag
It doesn't, right. You'll have to call getHandle() on it
i only get 3 files im using specialsource-maven-plugin, pom.xml: https://paste.md-5.net/emexokanen.xml
Am I just stupid?
im so lost lmao
