#help-development
1 messages · Page 1977 of 1
?
Basically a migration issue iirc
e.g. you cannot just make everything fully primitive without breaking old java code
so to get as much improvement in the existing code-base value classes do pretty much as much as possible without breaking it
what other "types of classes" are going to be added?
value and primitive classes
Plus we got records recently
I should google that later today and find out more about it
records are nice but also not really thaaat useful
records are nice to have but don't really add new functionality
They are just syntactic sugar more or less
records are great. The way of how objects in oop should look like
how can I construct an entity
if i wanna construct an entity object from another entity
do i just new Entity, then override the getter methods
with the data i have from another entity
if i am creating an array and filling manually with {} how can i only add an element with an if
you cannot
arrays are fixed size
the only way would be just an else tree with all the initial values and the conditional one
or you just use an array list
can i like
get the entity
spawn it somewhere
and then
access it by unique id
so it actually exists
and i have a copy of it i can use
if i need it i can just teleport
actually thats a very shitty method ill forget that
guys,sorry for interrupting,if I have a config file like this:
config:
value1:
---------
value2:
--------
value3:
how can I get the list of these values😁 😁 😁
ConfigurationSection section = config.getConfigurationSection("config");
section.getKeys(false); // will return all keys in the section, like value1, value2, value3```
You've asked this like 3 times while I've been in the channel
I don't know how you would do that other than just doing it all manually
wdym "all manually"
Copying all the properties over one by one
No
Not new entity
Calling World#spawnEntity and copying all the properties over
Attributes, health, potion effects, equipment, custom name, inventory contents
copying it to what
Another entity
You have an original entity A, you spawn a new one B, and then you copy all the properties from A onto B one by one
I have to do that for every EntityType?
as some entities have options other entities dont
what do you even need it for
Not every individual entity type
I want to copy an entity
You could check stuff like instanceof InventoryHolder
thanks😁
But for what purpose
well
Not instanceof for the endpoint interfaces
im making a Photocopier
The intermediary ones that compose the properties of it
For example, InventoryHolder for inventories, LivingEntity for armor contents and attributes
Do I have to add a plugin to depend in plugin.yml to work with it?
thats fucking annoying tbh
No but you really should
Hello, how do i detect if the sword icon that fills up near the crosshair is filled up?
declaration: package: org.bukkit.entity, interface: HumanEntity
should be what you want
java.lang.NoClassDefFoundError: de/tr7zw/changeme/nbtapi/NBTItem
what :
thanks
you will need to shade the NBT-API
why?
because the server does not include it ?
the other creates a replica from bytes
wat
for .clone()
no
I guess run your head into that for the learning journey
you cannot get that entity into the server
you cannot spawn an existing "entity" instance
the entity instance is created by the spawn method
oooooo
when you call "spawn" internally it creates it in the world
cant i remove the entity it points to
what
you would have to remove the internal NMS entity representation from the world
and spawn in your cloned one
ffs
in the time you spend trying to toil with cloning entities using only the spigot api and nms, you could write a fairly simple universal entity serializer/deserializer with a shit ton of instanceof checks
by just getting all the properties of the entity and creating a new one
wdym instance of checks
so it gets the methods in it
then their return type
then construct the object
thats sort of complicated tho
and no im not using nms
say it's an InventoryHolder, get the contents and save it
if it's instanceof horse, get the horse-specific traits and save them
it's going to be tedious but it's safer
thats gonna take weeks
no it won't, it'll take an afternoon at best and chances are you won't need all of the information that an entity has
what the fuck does looking good mean
pretty code
that's a shit goal to be honest
and if you think working with nms and reflection is "pretty code"
i wont use nms
and at least i dont wanna
do 70 instance of checks
thats just too
weird
there must be another option
:5head:
paper api wont work with spigot
nope
👀
but once you have it, it should just do the thing as you want it to
hm?
and at what location
like when copying to the entity
i wanna make a pokemon sort of thing
right click something
then it gets copied
So right now I think you should worry about copying entities
I wanna also make it a library
just have a debug command right now that puts it at your feet
yeah
and you can figure out how to implement it in a pretty way later
using the original entities type ?
Yes
yeah
that might be an important detail lol
I had a similar project a while back that only dealt with horses, pets, and animals
Looking back at the project, I made it unnecessarily complicated
I mean it can be done automatically
probably with some reflection
but it will take longer with reflection than manually prob
@hexed hatch btw what about some fields
like isDead
and stuff
actually isDead wont make sense
but other stuff that dont have a setter
like isOnGround
you're going to want all the generic shit like health, max health, I'd go ahead and get every attribute it has, name, etc
There's a lot you don't need like whether it's on fire, or is dead, or it's oxygen level
ic
most stuff is the same, just template it
actually
wtf am i doing
the item should store the data
i get the entity from
@hexed hatch i got some good idea
make a loop
to get every single method on entity
that has set in it
not the greatest idea unless you are going to push it async
or actually it wont work that good tbh
Seems excessive
nah I was gonna store the method names
nah dude i was gonna store the method names
in a list or some sort
I’d just decide on what generic fields you need for all entities and then throw on the entity type specific fields after that
but how would i store the data in a player
Again, there’s alot of things that you don’t really need that won’t make a difference
PDC
or files
Create a PersistentDataType for this
But right now I’d focus on getting this into something you can deserialize and serialize as a string
i have an idea
Once you get that together, you can worry about where you’re going to store it, whether that’s PDC or a file
I think you really need to buckle down and focus on the actual entity copying part then work out these trivial design choices
then
that will definitely work out for things like the entity equipment
removing set from its name
aw
do i just
use nms
wdym properly create logic
like, you won't be able to automate this
but you could have some data logic that is responsible for serializing and de-serializing a single properly
make a library after the code works
making a library off 2 lines of code?
if i just use paperapi
whats the point of using my library
since its just using paperapi
is that not the same question for every mod/variant ?
why not store item-data as a string? thats a bad idea but it is a way to do
wat
so like
entity name nbt and other stuff, you can store it as a string
and restore the values from that string
so like
idk
entityname;damage;speed;etc;
as a string
perfect data format 🙏
I can do
as i said, bad idea, but it is a way
is there a preferred file access method under spigot?
kind of like how itemsstacks are stored
i mean just store all the data you need to remake the entity
it is not the most efficient
but it is a way
this just screamed "no" at ur suggestion
thats literally just
some entities have their data
entity ids...
store it as an extra data
thats the entities, not the data to make them
yes but i will have to do it for each of them
only if you wish to punish yourself
tbh im doing it without nms because im way too lazy to build buildtools for each version
sure
i should do it with nms but like
you really need to realize you are one level too low
you asked for a way, i gave you a way
ig
you could make a class for each entity
and setup like a list of extra arguments
and loop through that for the extras
it should be simple enough
ill just build buildtools probably
or wait
cant i just
teleport the entity to somewhere really far in the sky
and put a pdc on it
that identifies the unique item that right clicked it
then when the item is right clicked just teleport it
back
i know chunk will be unloaded
but u can use the unique id
of the mob, right?
I don't think there's much point in saving the entity's unique id if you're just cloning it
then teleport it when he needs it
you need a piece of paper and a pencil
what's stopping you from just putting the entity in a stasis under the world
xy problem moment:
and then teleporting it out
as needed
so cool
if you're just moving an entity around then there's no point in going through all this
Well without the copying part
will moving the entity under the world really be that good of an idea tho
lol pog
not really
like, you will need to load its chunk (and this is spigot sooo, on the main thread)
actually 100%
bruh you will be either teleporting entities with the player to whatever location
or
or you have to chunk load
you'll have to consider the fact that you'll have just a bunch of entities clustered under one spot in the world
which won't be a good thing
or you keep the spawn chunks loaded all the time and mass a shit load of entities there
no
unique id
lol
no
wha
that's not how it works
dosnt it work like armorstands
no
fuck
is there an easy way to store data on 1.8?
armorstand don't work that way either
then i have to keep a chunk loaded what the fuc
perhaps they should just get to the point of either teleporting or cloning an entity first .
wont that suck for performance
yes
Probably at some point
the solution just doesn't scale with larger player basis
even if not performance, framerate of those who enter the region with a clusterfuck of mobs under the world
I guess you could randomly selected a chunk and store the chunk coords on the item
and then load the chunk if needed
I have another out-there potential solution for you
There is a structure api in spigot
LOL
and structures can save entities
wat
omg HAHAHA
yes
actually genius
you create new structures for every single entity
you could save the 2 blocks in which an entity inhabits
or whatever it's bounds are I have no idea how structures work with entities
all I know is that it can in fact save entities
and then just generate the structure at the location with the integrity field as 0 so no blocks are generated
it's absolutely disgusting but I'm like pretty sure that will work out
will it lag
not too bad I guess
less than putting them under the world I'd say
That's how villagers are spawned in villages :) they are a structure piece
This will be the path of least resistance, I can assure you of that lol
better than learning nms
I'm actually a genius
it isn't too bad tho you will be spamming the shit out of your server with files
with a structure per entity
if its really the way you want to do it, you could just do it in another dimension rather than the overworld
s e r i a l i z e it uwu /j
So make sure to ehhh somehow delete them
cant i
make it into a hashmap
but
to save the hashmap
with some smart tomfuckery you could probably group multiple entities in one structure and yank out the one you need
Yea probably
no but they are just namespaced keys
you can tell the server to save them to disk
and load them later using their namespaced key
uh
ok i can just
can i just make some sort of pool
make some amount specified in config
of structures
then
get the first empty one when u need it
but i cant park structures
so uhh
i mean theyre just files and small ones
no but you can register and unregister them as needed I believe
so it wont be that much of a pain for the server
and i can make a library out of this
woo
im gonna credit u if i ever make this :O
JavaPlugin#structureManager should open your eyes a bit to what's possible
I see methods for deleting structures
if I were you, when the entity is spawned, I'd just delete the structure
i would save it for deletion, not delete it
as disgusting as this idea is I'm not entirely sure I want that lol
i would put it in arraylist, if no one needs it anymore in the server
when server disables
ill delete it
if no one needed it again
that would be better than making then deleting
every time someone spawns / despawns
cuz they can spam it
although there will be a cooldown
any guides on structures?
when I was trying to learn it, I found almost nothing on it
But I got it figured out by just reading the docs
can u give some basic info if u want? if ur tired or lazy its fine
I am tired, lazy, and preoccupied with a mountain of school work
hey, I currently have
public static String toPercentage(Double n){
return String.format("%.0f",n*100)+"%";
}
which prints out https://i.imgur.com/BwFxm1N.png but instead of 0-1 I want it to display 0-100. How is this possible?
ask me again on Sunday
Alright
How do I upload a plugin and make it paid? The category premium is grayed out, and I dont see any other options to make it paid.
have you got the required things?
wdym?
there's requirements
You likely don’t meet the requirements
you got 1 of which you uploaded 30 mins ago
ye
when were structers added giz
@waxen plinth Where can I refer people to you for custom plugins
i cant find it in 1.16.5
what do you mean
might've been 1.17
afaik 1.18
Sure
I wrote my structure plugin in 1.17
ok
are you sure ?
Bro
I should just use nms then if its 2 versions
oueuhfuewbfuewufhewfhabF;OJHU
fine
not 1.17 @hexed hatch
1.17.1
aa
ah
thinks you should start at latest and put down some code
why are you clinging to 1.16.5 specifically?
oh yea, one of the last 1.17 additions
This method works fine for me?
Though if you want, you can use NumberFormat.getPercentInstance() instead
Yes, but it only goes up to 1.0% for me not 100%
I'm using a Map of Materials and Doubles if that helps
can i implement structure btw @hexed hatch
the block percentages within the mine
Relative to what? Do you have a % in there for stone? Ideally your number is going to add up to 100%, no?
what?
I think your calculation is flawed in this instance
so i can set the size
because your value is either a percentage or a weight
that is what you have your precision set too ...
I don't get what you're asking
if you're asking if you can create structures with the structure api, I believe the answer is yes
I mean Double goes up to 1 yes?
how do i set a struct size tho
I believe you define two corners
If the value you want is a weight, the percentage is going to be weight/totalWeight. If the value you want is a percentage, the percentage is itself
So if you have your value mapped to 1, but nothing else is in the map, 1/1 is 100%
If you have two values, both mapped to 1, 1/2 = 50%
how tho
But if you are using those as percentages, then the percentage is going to be what you have mapped
Scaling matters here too
but there's no way to make the 1 become 100% instead of 1
You can multiply it by 100 😛
Which you're doing in that method
Which does work, as I've shown above
void
fill(Location corner1, Location corner2, boolean includeEntities)
Fills the structure from an area in a world.```
declaration: package: org.bukkit.structure, interface: Structure
filling?
i dont want it to have anything
plus there is no set location, arent structures virtual
it's weirdly named, almost certain that just gets the shit from the world and puts it in the structure object
You can fill the structure with information from the world, and you can place a structure into the world
actually I am not almost certain
#fill(), #place(), respectively
Who tag me?
Nice to see chocho helping
a clone method for entities teehee
He always try to help
String.format("%f", 100.00);

Probably not
Probably not
alr
It uses the same functionality that structure blocks use
If you're doing any of the IO operations from StructureManager, however, do those async
But it isn’t limited toy 48x48x48
I can't verify that
I wonder if worldedit has an option to save as an NBT structure yet
iirc, that's only with structure blocks
using the api avoids the limit I believe
Yeah, I can't find any restrictions in CraftBukkit so unless they're restricted in the NMS that CB refers to, there is no limit
I think Senmori implemented the structure stuff ages ago and he's not around to answer that question ;p
Oh it wasn't Senmori
Sander Knauff. No clue who that is
lmao all these things
Isn’t the structure stuff new
1.17.1
no clue
Yes
might not even need two though
I assume it’s inclusive
one block might be enough to save the entity
Probably
How can I change it to detect if its a pig who is involved in the event?
@grim ice pull out some structure blocks and mess with saving and spawning an entity from it
Im not sure how to check it
alr
Instanceof Pig
nah ill make a config
Or compare getEntityType
oh!
This should work right?
Yes
amazing
I would use == tho
one less method to call
or entity instanceof Pig?
hmm... java.lang.NullPointerException: Cannot invoke "java.nio.file.Path.toString()" because "PathTest" is null thats interesting
and the second test says I am doing something wrong, lets see if getRootDirectories() will talk to me
Well: [18:59:45 INFO]: [CAdmin] What is Path3: sun.nio.fs.UnixFileSystem$1@476c9ad2 is almost useful
"cmd.getName() returns the name of the command"
so are you actually storing sometihng in nickData?
and those are strings?
the first string defined is a space from what i see
&5SpicyChikn will likely get filtered for being invalid
starts with a symbol
have you tried with a normal username?
converting instants to Date obj 😟
hi, im trying to rotate nms stand im doing it right but i think the packet is wrong, which packet should i send on 1.18
stand.setYBodyRot(entity.getLocation().getYaw());
stand.setYHeadRot(entity.getLocation().getYaw());
stand.setXRot(entity.getLocation().getPitch());
stand.getBukkitEntity().setRotation(entity.getLocation().getYaw(), entity.getLocation().getPitch());
for(Player p : showed){
JeffLib.getNMSHandler().sendPacket(p, new ClientboundSetEntityDataPacket(stand.getId(), stand.getEntityData(), true));
}```
if that is the case you have 50/50 to sort it - remove a test
thats not too bad, i have filesystem security issues atm
the code i am working with , and I suspect it is host related rather than spigot specifically. So i need to ask in a different way
is there or do you have a flag for that?
Not sure if this would work but you could test if the offlineplayer of that person has changed and if not, compare their names
Why not? It’s not bad
String beforeName = ((OfflinePlayer) event.getPlayer()).getName();```
It's not
no it's getting the OfflinePlayer of the joining Player
and gets the name the server has stored
but like I said idk if it's going to be updated already so you should test it first
permissions aren't bad either
Whats the best way to check if a player changed chunks? Currently I was trying to compare x and z variables from both e.getFrom().getChunk() and e.getPlayer().getLocation().getChunk() in the PlayerMoveEvent but it doesn't always trigger it
no, getDisplayName is nicknames
that's a ton of blocks being checked everytime a chunk is loaded
how in the heck are you getting the player from the chunkloadevent
bro idk what black magic is that but my intellij doesnt like that
because you can't cast the event to a player
you should show the code
because the chunkloadevent doesn't even keep track of the player loading chunks
what ?
ChunkLoadEvent should definitely be triggered for chunks loaded by players
ohh
I guess what "player" triggered the chunk load
it doesn't keep track of the player
it does it when the player loads the chunk but doesn't know which player
yeah no just built it and i cannot cast the event to a player object
aint working for that one
Hello there
I got problem player skull not loading
I got gui
which loads 10 players heads
which player before on server
I am getting skins on Heads by player head method
oof i broke intellij
because it is cracked
server
it is strange case it happen on one of
servers in bungee
so what would be a reason
why they don't want to load
how would I do that
set the ownerprofile of the skull meta
or try the sleezy plugin
ask it
simplest is to set a flag in it and poll that flag on login, or you can parse file modification
all those 10 account has skins
and proper name
because they are loaded on server 1.16
at the same machine
how to event get them then
so I can store them
how would I do that if my current
code is not working
your offline stuff probably already tells you what you need to use for player skin support
get the player profile of the person and use that to set the head
my test server is offline and it still gets heads after a second
some1 know how is possible make a vector go trough blocks? else if i spawn inside of blocak
whay do you want to di
a ray trace go trough blocks?
then use ray ratxe
where to store namespacedkeys again
playerdatacontainer
Are you talking about PersistentDataContainer?
yes my bad
ofc you can
a namespacedkey is "basically" just a string in the format "namespace:key"
minecraft:diamond_pickaxe
angelchest:protected_chest
plugin:somestring
1 key can unlock many doors
structure name?
1.17.1 structures
your namespaced key can have whatever string matches the constraints as key
yeah basically [a-z0-9-] IIRC
can a namespacedkey
have a
uuid toString()'d
it prob cant
ok it cant cuz uppercase letters
Namespaces may only contain lowercase alphanumeric characters, periods, underscores, and hyphens.
Keys may only contain lowercase alphanumeric characters, periods, underscores, hyphens, and forward slashes.
uuids are always lowercase letters
o
btw
give me ideas
rn
im storing a struct
in a item pdc
how do i do that
do i make a custom type
or is there a simpler way
you wouldn't store the structure
you just store the namespaced key to the structure
Eh I mean, make a type if you want to
but like, it is just a string in the end
what im struggling with
what do i register
the structure as
like the namespacedkey
what do i name it
it needs to be different for each itemstack
do i just make a number
that increases each time the method is called
and is saved to config on disable
2hex what are you trying to do
storing a struct in an itemstack essentially
oh ok
struct -> namespace of a structure
ah ok
if i use
getManager().registerStructure(new NamespacedKey(getInstance(),
entity.getUniqueId().toString()), struct);
then later
getManager().loadStructure(new NamespacedKey(/* the stuff */))
is it valid
I didnt use a namespacedkey in months
should i run saveStructure
async
(on another thread, since async has another meaning)
is rhis from spigor?
yea
Well the method isn't actively declared safe for off-thread, but eehh might work ?
it uses java io
Ahh makes sense
Yea I don't think it touches any internal state
btw
if i store an entity in a
structure
can i kill the entity
and it will be saved in the structure
no, the structure takes a snapshot
which means you'd have to "refill" the structur
Well it saves it when you call the saveStructure method
i do
so if i save structure
then kill
the entity
will it respawn if i load it
and place
yes
Hello, how can I spawn a specific structure in minecraft? Saving it in a yml file would be okay,
?
But then how would I take every value and spawn a block?
How can I convert that DIAMOND string to a Material? I was using a switch statement for another line in the config and converting it to ChatColor
unless you want to rewrite the wheel, litematica is an option
Material.matchMaterial
I want it in code! Not a mod
palette – The palette index of the structure to use, starting at 0, or -1 to pick a random palette
what the heck is this
How does it work?
thats exactly what 2Hex is trying to figure out how to use as well
yes so what is palette
Hello,
How I can have the Block of the bucket when it is empty ?
I use the PlayerBucketEmptyEvent and it is to creat the plugin of practice.
Excuse me of my english I from French
Please ping me
Thanks you
Palette Represent a variation of a structure.
there is only one i think
specifically: The positions of the returned block states are offsets relative to the structure's position that is provided once the structure is placed into the world.
so when you move a structure or when you port it to another world - would be a basic application of the palette
You shouldn’t have to worry about the pallet
How can I have an offset between two blocks?
For example
I have a block named center
pick it up and move it right 1 space = 1 block offset
And I have an offset of 1 block
How can I get the block in that offset?
And would that count rotation or weird stuff?
Thank you but that’s not what I want and also I’m not that dumb
Would that work using locations and subtracting
?
everything contained is the same as the blockState as it says
Yeah but that’s not my question
If I have a block ad 0,0,0
And an offset of 1
I should have a block at 1,0,0
Get this error from Worldguard because EntityType doesn't have a name in my plugin https://paste.md-5.net/osuduraham.sql
if you can modify it try to debug what the EntitType is and so on, also different versions of plugin/server could be a problem
how do i set where to save the Structures from my plugin
The save method takes a file
Check the method in the docs
Anyone know why when I click my npc this gets executed twice?
event is fired for both hands
How can I stop that, and why?
Because you can click with both hands?
event.getHand() == EquipmentSlot.HAND
i guess
will only run for main hand
^ just use this
- By checking which hand the event fired for
- The client sends 1 use packet for each hand
add OFF_ before HAND so its only for off hand
anyone have experience with making the annotations processor behave in intellij? It is refusing every path I try to give it
Where would I add that?
At the top of the event?
hm
around the same place you get the right click
It says its "Not a statement"
k il figure it out
Myeah
The api is a bit cumbersome
But overall it works just fine
(Using gradle fyi)
Question, how to make text that rapidly changes similar to what happens during the minecraft end credits?
Wdym?
The crazy seizure text?
Yes
Thanks
if("kick".equalsIgnoreCase(args[0])) {
if(args[1] != null) {
if(!(mafias.containsKey(player.getUniqueId().toString()))) {
player.sendMessage(mafiaPrefix + ChatColor.WHITE + "Nie masz jeszcze żadnej mafii");
return true;
}
if(args[1].equalsIgnoreCase(player.getName())) {
player.sendMessage(mafiaPrefix + ChatColor.WHITE + "Nie usunąć siebie z mafii");
return true;
}
if(mafias.get(player.getUniqueId().toString()).members.contains(Bukkit.getServer().getPlayer(args[1]).getUniqueId())) {
player.sendMessage(mafiaPrefix + ChatColor.WHITE + "Gracz został usunięty z mafii");
mafias.get(player.getUniqueId().toString()).members.remove(Bukkit.getServer().getPlayer(args[1]).getUniqueId());
return true;
}
if(Bukkit.getServer().getOnlinePlayers().contains(Bukkit.getServer().getPlayer(args[1]))) {
player.sendMessage(mafiaPrefix + ChatColor.WHITE + "Gracz nie jest członkiem mafii");
return true;
}
player.sendMessage(mafiaPrefix + ChatColor.WHITE+ "Nie znaleziono gracza.");
return true;
}
}
What is wrong with this piece of code? I'm getting basic error. An internal error occurred while attemting to perform this command
Thank you
Share the proper error from console
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
[23:17:29 INFO]: Placek__ issued server command: /mafia kick dsadw
[23:17:29 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'mafia' in plugin PrisonAndPolice v1.0
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.dispatchCommand(CraftServer.java:897) ~[paper-1.18.1.jar:git-Paper-186]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleCommand(ServerGamePacketListenerImpl.java:2293) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2104) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2085) ~[?:?]
at net.minecraft.network.protocol.game.ServerboundChatPacket.handle(ServerboundChatPacket.java:46) ~[?:?]
at net.minecraft.network.protocol.game.ServerboundChatPacket.a(ServerboundChatPacket.java:6) ~[?:?]
at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$1(PacketUtils.java:56) ~[?:?]
at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.18.1.jar:git-Paper-186]
at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:149) ~[?:?]
at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:23) ~[?:?]
that's not the full error
yes
wait
at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1413) ~[paper-1.18.1.jar:git-Paper-186]
at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:189) ~[paper-1.18.1.jar:git-Paper-186]
at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:122) ~[?:?]
at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1391) ~[paper-1.18.1.jar:git-Paper-186]
at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1384) ~[paper-1.18.1.jar:git-Paper-186]
at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:132) ~[?:?]
at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1362) ~[paper-1.18.1.jar:git-Paper-186]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1268) ~[paper-1.18.1.jar:git-Paper-186]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317) ~[paper-1.18.1.jar:git-Paper-186]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.NullPointerException: Cannot invoke "org.bukkit.entity.Player.getUniqueId()" because the return value of "org.bukkit.Server.getPlayer(String)" is null
at me.placek__.prisonandpolice.commands.MafiaCommands.onCommand(MafiaCommands.java:108) ~[PrisonAndPolice.jar:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
... 21 more
the player you are trying to get in line 108 is not online
so Bukkit.getPlayer() returns null
Why is it always an NPE and people just don't read it
Reading hard
Sometimes java stracktrace show lot of lines and you get really confused
It’s at the top
In other hand, its better than C# stracktrace because C# only tell you something explode you need to fix it without knowing why/where its explode
I think you mean C++ stack traces. And even those got ok over the years.
Really annoying are primarily preprocessor exceptions and seg faults.
Yeah C++, i get confuse
Hi, where can I find a working Spigot 1.8 file?
compile it with BuildTools
?bt
Thanks
--rev
using the imports or by using the fully qualified class name
e.g. use org.apache.commons.lang3.StringUtils.reverse("someString") instead of just StringUtils.reverse("someString")
or change the import at the top if you don't need classes from two libs in one class
set up excludes filters on your dependencies
hm they talked about intellij so I guess both are shaded and they want to differentiate it inside the code, not by excluding from one being shaded
because tbh if they don't shade it, they just shouldn't add both libs as dependency
maybe explain your problem a bit further @weary geyser
If I want to access the values in rewards, how can I do this? I want to copy these to a list to do things with them.
List<String> rewards = getConfig().getStringList("Pools.1.rewards");
?
Returned an empty list when I tried that, but I'll copy and try again.
that definitely works unless your config is broken or you had a typo or sth
for (String s : poolSection.getKeys(false)) {
if (plugin.getConfig().getInt("Pools."+s+".FarmLevelMax") >= persistentDataContainer.get(keyLevel, PersistentDataType.INTEGER)) {
rewardsList = plugin.getConfig().getStringList("Pools."+s+"rewards");
player.sendMessage(String.valueOf(rewardsList));
}
}
List<ItemStack> rewardsListItems = new ArrayList<>();
for (String s : rewardsList) {
rewardsListItems.add(new ItemStack(Material.matchMaterial(String.valueOf(s))));
}
This is the code I currently have for the list. Anything wrong with this?
yes
your forget a . in front of "rewards"
you are currently getting the list at "Pools.1rewards"
but you want it to be "Pools.1.rewards"
notice the missing . between 1 and rewards
I see, it is super easy to miss these
Gotta write unit tests 
still wouldnt have explained WHY it returns null though 😛
I assume it would do the same as me uploading it to a local server and testing it
Which would take quite a bit more work to fully emulate with a unit test
Writing a spicy enough error you could. Just make the getstringlist key a string and throw an error with "error " + Key + "does not exist" and voila you'll see the problem
yeah true, but
if getStringList returns null
it's obvious there must be a typo
reading stracktraces is easy no need to do unit tests with a small minecraft plugin
because the getStringList() method works 😛
lol you're funny
how
unit tests are not about "i am too lazy to read a stacktrace"
it's most of the time to check if the results are what you expect
not to check if you get errors
is that your project?
It helps prevent errors before deploying to the server
e.g. imagine you have "complicatedCalculation(int)" and "reverseComplicatedCalculation(int)"
now you can unit test if "reverseComplicatedCalculation(complicatedCalculation(7)) == 7"
it might also return something different without throwing errors
you won't have any stacktrace
unit tests are basically done to check if the methods do what they are supposed to do, not to check whether exceptions etc are thrown (at least not ONLY for that)
Unit tests are fucking great honestly
Sometimes I am rewriting some complicated internal piece of code and I have no idea what it's gonna break
but yeah for many things they are great
And if I didn't have unit tests I would have to go back and test every single possible functionality to make sure it all works
Manually
But with unit tests I just hit a button and it's like "yep good to go"
Well, or it tells me I fucked it up
unit tests are best for things where data is manipulated and you want to ensure what is returned is what it is suppose to return and not some weird thing
Which I often did
yeah exactly
i have never once written a test 😢
Do you have to run the server for unit tests to work or can you do that in intellij
so yeah, unit tests have nothing (or at least not much) to do with stacktraces
I have, but they are generally pointless for plugins most of the time though
there's frameworks like Mockbukkit
they basically emulate a proper server
maven can run them automatically
or gradle
or on your own
I have seen lots of really dumb unit tests though, and some things are very hard to unit test
But for pure functions
Unit test that shit
I'm going to have to learn that for sure
It's very very easy
I hate how some companies write the tests first
couldn't get it to work and gave up after a while 😬
the basic rule is that the coder and the tester should never be the same person
this is quite dumb approach o.O
Not really though
it's quite easy
Popular in the industry
You just make an interface for it that lays out how the abstraction should be interacted with without any actual implementation yet
Then you write tests for that functionality
the person who wrote a method should never be the person who also writes the test for that method
And then you can very easily test everything as you're writing it
It's obviously not really the way you would go about it as an individual developer
But for teams it can often make sense
And it makes it easier to know exactly how far along you are, how close you are to a solution
Which companies obviously care about
if you write the test first, some people might think "I am done" when all tests succeed lol
doesn't really make sense to write tests for everything
Again, depends on the context
If you're an individual developer or small organization with a reasonably-sized codebase then no
But if you're an absolutely massive company you need every piece of code to work 100% of the time because any failure by any part of the code could mean millions of users are affected
I just don't get the advantages of doing unit tests on a smallscale minecraft plugin
for tiny plugins they are useless, sure
Do all of you use mockbukkit to write tests? With Junit I assume
mockbukkit, yes. junit, i dont remember
while true, there are just some methods that make no sense to do tests on because what they return doesn't really matter
In what case are you writing a function whose behavior doesn't matter
if a boolean is returned, its either going to be false or true nothing else