#help-development

1 messages · Page 1977 of 1

quiet ice
#

Why do they want to add so many new types of classes

eternal night
#

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

tender shard
eternal night
#

value and primitive classes

quiet ice
#

Plus we got records recently

tender shard
#

I should google that later today and find out more about it

eternal night
tender shard
#

records are nice but also not really thaaat useful

#

records are nice to have but don't really add new functionality

quiet ice
#

They are just syntactic sugar more or less

quaint mantle
#

records are great. The way of how objects in oop should look like

grim ice
#

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

olive lance
#

if i am creating an array and filling manually with {} how can i only add an element with an if

eternal night
#

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

grim ice
#

Lynx do u have an idea

#

on how to copy an entity without nms

eternal night
#

using paper api

#

that is about it

grim ice
#

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

patent karma
#

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😁 😁 😁

waxen plinth
#
ConfigurationSection section = config.getConfigurationSection("config");
section.getKeys(false); // will return all keys in the section, like value1, value2, value3```
grim ice
#

redempt

#

do u have an idea of a way to copy an entity

#

without paper

#

and without nms

waxen plinth
#

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

grim ice
#

wdym "all manually"

waxen plinth
#

Copying all the properties over one by one

grim ice
#

and just calling new Entity?

#

and overriding

waxen plinth
#

No

brave sparrow
#

Not new entity

waxen plinth
#

Calling World#spawnEntity and copying all the properties over

brave sparrow
#

spawnEntity

#

Yeah

waxen plinth
#

Attributes, health, potion effects, equipment, custom name, inventory contents

grim ice
#

copying it to what

waxen plinth
#

Another entity

grim ice
#

ohhh

#

thats what u mean

brave sparrow
#

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

grim ice
#

I have to do that for every EntityType?

#

as some entities have options other entities dont

tender shard
waxen plinth
#

Not every individual entity type

grim ice
#

I want to copy an entity

waxen plinth
#

You could check stuff like instanceof InventoryHolder

waxen plinth
grim ice
waxen plinth
#

Not instanceof for the endpoint interfaces

grim ice
#

im making a Photocopier

waxen plinth
#

The intermediary ones that compose the properties of it

#

For example, InventoryHolder for inventories, LivingEntity for armor contents and attributes

red sedge
#

Do I have to add a plugin to depend in plugin.yml to work with it?

grim ice
#

thats fucking annoying tbh

waxen plinth
valid solstice
#

Hello, how do i detect if the sword icon that fills up near the crosshair is filled up?

eternal night
#

should be what you want

red sedge
#

java.lang.NoClassDefFoundError: de/tr7zw/changeme/nbtapi/NBTItem
what :

eternal night
#

you will need to shade the NBT-API

red sedge
eternal night
#

because the server does not include it ?

grim ice
#

d o u know how to do the cloning with paper tho@eternal night

#

sorry for pinging

grim ice
#

waittt

#

i have an idea

eternal night
#

the other creates a replica from bytes

grim ice
#

using reflect

#

to edit accessiblity

eternal night
#

wat

grim ice
#

for .clone()

eternal night
#

no

grim ice
#

in entity

#

then doing it

#

:OOOO

#

it will have a duplicate uuid so i can edit it

eternal night
#

I guess run your head into that for the learning journey

grim ice
#

and make it another uuid

#

what do you think will happen tho

grim ice
#

it seems you know it wont work

eternal night
#

you cannot get that entity into the server

grim ice
#

wh

#

why

#

i can just spawn it

eternal night
#

you cannot spawn an existing "entity" instance

grim ice
#

how does it know

#

it exists

eternal night
#

the entity instance is created by the spawn method

grim ice
#

oooooo

eternal night
#

when you call "spawn" internally it creates it in the world

grim ice
#

cant i remove the entity it points to

eternal night
#

what

grim ice
#

like the entity object

#

points to the entity created

eternal night
#

you would have to remove the internal NMS entity representation from the world

#

and spawn in your cloned one

grim ice
#

ffs

eternal night
#

not to mention, cloning afaik is shallow

#

not deep

grim ice
#

yes it is shallow

#

aaaa

hexed hatch
#

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

grim ice
#

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

hexed hatch
#

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

grim ice
#

thats gonna take weeks

hexed hatch
#

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

grim ice
#

i want it to look good

#

tho

hexed hatch
#

what the fuck does looking good mean

grim ice
#

pretty code

hexed hatch
#

that's a shit goal to be honest

#

and if you think working with nms and reflection is "pretty code"

grim ice
#

i wont use nms

#

and at least i dont wanna

#

do 70 instance of checks

#

thats just too

#

weird

#

there must be another option

hexed hatch
#

use the paper api

#

boom

eternal night
#

:5head:

grim ice
#

paper api wont work with spigot

hexed hatch
#

nope

grim ice
#

actually fuck this

#

im gonna do it

#

with the instance of checks

eternal night
#

👀

hexed hatch
#

have fun

#

that'll be your afternoon

grim ice
#

sigh

#

but first

hexed hatch
#

but once you have it, it should just do the thing as you want it to

grim ice
#

do i just

#

get an entity

#

then

#

spawn an entity

#

but what entity do i spawn

hexed hatch
#

hm?

grim ice
#

and at what location

hexed hatch
#

I mean

#

what is your end goal here

grim ice
#

like when copying to the entity

#

i wanna make a pokemon sort of thing

#

right click something

#

then it gets copied

hexed hatch
#

So right now I think you should worry about copying entities

grim ice
#

I wanna also make it a library

hexed hatch
#

just have a debug command right now that puts it at your feet

grim ice
#

yeah

hexed hatch
#

and you can figure out how to implement it in a pretty way later

grim ice
#

but the entity i copy it to

#

how do i spawn it

#

what entity is it

eternal night
#

using the original entities type ?

grim ice
#

actually

#

ill have to use

#

EntityType

eternal night
#

Yes

hexed hatch
#

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

grim ice
#

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

hexed hatch
#

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

grim ice
#

ic

viral crag
#

most stuff is the same, just template it

grim ice
#

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

viral crag
#

not the greatest idea unless you are going to push it async

grim ice
#

or actually it wont work that good tbh

hexed hatch
#

Seems excessive

grim ice
#

nah dude i was gonna store the method names

#

in a list or some sort

hexed hatch
#

I’d just decide on what generic fields you need for all entities and then throw on the entity type specific fields after that

grim ice
#

but how would i store the data in a player

hexed hatch
#

Again, there’s alot of things that you don’t really need that won’t make a difference

#

PDC

#

or files

grim ice
#

i would need to make some sort of syntax

#

to read the data from

hexed hatch
#

Create a PersistentDataType for this

#

But right now I’d focus on getting this into something you can deserialize and serialize as a string

grim ice
#

i have an idea

hexed hatch
#

Once you get that together, you can worry about where you’re going to store it, whether that’s PDC or a file

grim ice
#

i can probably automate this

#

by

#

looping through every setter method of Entity

hexed hatch
#

I think you really need to buckle down and focus on the actual entity copying part then work out these trivial design choices

grim ice
#

then

eternal night
#

that will definitely work out for things like the entity equipment

grim ice
#

removing set from its name

eternal night
#

yes

#

or paper api

#

or properly create logic

grim ice
#

wdym properly create logic

eternal night
#

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

grim ice
#

i really wanted to make a library for it thoo

#

so using paper api is kinda eh

viral crag
#

make a library after the code works

grim ice
#

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

viral crag
#

is that not the same question for every mod/variant ?

red sedge
#

why not store item-data as a string? thats a bad idea but it is a way to do

eternal night
#

wat

grim ice
#

the problem isnt item data

#

the problem is the whole thing

red sedge
#

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

eternal night
#

perfect data format 🙏

grim ice
#

I can do

red sedge
grim ice
#

(field:value),(field:value);

#

but that wont really solve it will it

viral crag
#

is there a preferred file access method under spigot?

red sedge
#

kind of like how itemsstacks are stored

eternal night
#

no, just java

#

go for whatever way you want to read your file

red sedge
#

it is not the most efficient

#

but it is a way

grim ice
#

this just screamed "no" at ur suggestion

red sedge
#

thats literally just

grim ice
#

some entities have their data

red sedge
#

entity ids...

red sedge
viral crag
#

thats the entities, not the data to make them

grim ice
#

yes but i will have to do it for each of them

eternal night
#

each of those interfaces exposes additional data

#

thats the point of them

viral crag
grim ice
#

tbh im doing it without nms because im way too lazy to build buildtools for each version

red sedge
#

sure

grim ice
#

i should do it with nms but like

viral crag
#

you really need to realize you are one level too low

red sedge
grim ice
#

ig

red sedge
#

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

grim ice
#

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?

hexed hatch
#

I don't think there's much point in saving the entity's unique id if you're just cloning it

grim ice
#

i wont clone it

#

just hide it

hexed hatch
#

you'll have to generate a new entity for the cloned version anyways

#

what

grim ice
#

then teleport it when he needs it

viral crag
#

you need a piece of paper and a pencil

hexed hatch
#

hold on

#

what is your end goal

#

so no entity is being copied?

grim ice
#

im making a sort of "pokemon"

#

plugin

hexed hatch
#

what's stopping you from just putting the entity in a stasis under the world

grim ice
#

xy problem moment:

hexed hatch
#

and then teleporting it out

grim ice
#

oh right i can make it invincible

#

and do that

hexed hatch
#

as needed

grim ice
#

thats a cool idea

#

just got xy'd

hexed hatch
#

it's lazy, and it'd be better to serialize it probably

#

but like

grim ice
#

so cool

hexed hatch
#

if you're just moving an entity around then there's no point in going through all this

eternal night
#

Well without the copying part

#

will moving the entity under the world really be that good of an idea tho

grim ice
#

lol pog

grim ice
#

prob better performance

eternal night
#

like, you will need to load its chunk (and this is spigot sooo, on the main thread)

grim ice
#

actually 100%

eternal night
#

bruh you will be either teleporting entities with the player to whatever location

grim ice
#

or

eternal night
#

or you have to chunk load

hexed hatch
#

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

eternal night
#

or you keep the spawn chunks loaded all the time and mass a shit load of entities there

grim ice
#

but liek

#

even if chunk is unloaded

#

i can get the mob by its id

eternal night
#

no

grim ice
#

unique id

eternal night
#

lol

hexed hatch
#

no

grim ice
#

wha

hexed hatch
#

that's not how it works

grim ice
#

dosnt it work like armorstands

eternal night
#

no

grim ice
#

fuck

mighty pier
#

is there an easy way to store data on 1.8?

eternal night
#

armorstand don't work that way either

grim ice
#

then i have to keep a chunk loaded what the fuc

viral crag
#

perhaps they should just get to the point of either teleporting or cloning an entity first .

grim ice
#

wont that suck for performance

eternal night
#

yes

grim ice
#

oh no

#

will it suck performance a lot

hexed hatch
#

Probably at some point

eternal night
#

the solution just doesn't scale with larger player basis

hexed hatch
#

even if not performance, framerate of those who enter the region with a clusterfuck of mobs under the world

grim ice
#

Lmfao

#

right

eternal night
#

I guess you could randomly selected a chunk and store the chunk coords on the item

#

and then load the chunk if needed

hexed hatch
#

I have another out-there potential solution for you

eternal night
#

kind of spread the entities

#

don't say it omg

hexed hatch
#

There is a structure api in spigot

eternal night
#

LOL

hexed hatch
#

and structures can save entities

grim ice
#

wat

eternal night
#

omg HAHAHA

#

yes

#

actually genius

#

you create new structures for every single entity

hexed hatch
#

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

grim ice
#

will it lag

eternal night
#

not too bad I guess

hexed hatch
#

less than putting them under the world I'd say

chrome beacon
#

That's how villagers are spawned in villages :) they are a structure piece

hexed hatch
#

This will be the path of least resistance, I can assure you of that lol

grim ice
#

alright bad thing is i dont know a single shit

#

about structures

hexed hatch
#

now you get to learn the structure api

#

took me about one afternoon to figure it out

grim ice
#

better than learning nms

hexed hatch
#

I'm actually a genius

eternal night
#

it isn't too bad tho you will be spamming the shit out of your server with files

#

with a structure per entity

grim ice
#

cant i

#

uhh

viral crag
#

if its really the way you want to do it, you could just do it in another dimension rather than the overworld

grim ice
#

s e r i a l i z e it uwu /j

eternal night
#

So make sure to ehhh somehow delete them

grim ice
#

make it into a hashmap

#

but

#

to save the hashmap

hexed hatch
grim ice
#

i wil have to serialize it

#

and Structure cant be serialized

eternal night
#

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

hexed hatch
#

you can also save the structures in your own directory

#

instead of in the world file

grim ice
#

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

hexed hatch
#

no but you can register and unregister them as needed I believe

grim ice
#

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

hexed hatch
#

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

grim ice
#

i would save it for deletion, not delete it

hexed hatch
grim ice
#

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?

hexed hatch
#

when I was trying to learn it, I found almost nothing on it

#

But I got it figured out by just reading the docs

grim ice
#

can u give some basic info if u want? if ur tired or lazy its fine

hexed hatch
#

I am tired, lazy, and preoccupied with a mountain of school work

next stratus
#

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?

hexed hatch
#

ask me again on Sunday

grim ice
#

Alright

twilit wharf
#

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.

next stratus
twilit wharf
#

wdym?

next stratus
#

there's requirements

eternal night
kind hatch
#

You likely don’t meet the requirements

twilit wharf
#

ah

#

I dont have the 3 free plugins

next stratus
#

you got 1 of which you uploaded 30 mins ago

twilit wharf
#

ye

grim ice
#

when were structers added giz

olive lance
#

@waxen plinth Where can I refer people to you for custom plugins

grim ice
#

i cant find it in 1.16.5

hexed hatch
#

might've been 1.17

olive lance
#

someone wants a custom plugin

#

can i just give them your discord

eternal night
#

afaik 1.18

waxen plinth
#

Sure

hexed hatch
#

I wrote my structure plugin in 1.17

olive lance
#

ok

eternal night
#

are you sure ?

hexed hatch
#

so I'm certain it existed then

#

yes

grim ice
#

Bro

#

I should just use nms then if its 2 versions

#

oueuhfuewbfuewufhewfhabF;OJHU

#

fine

#

not 1.17 @hexed hatch

#

1.17.1

#

aa

hexed hatch
#

ah

viral crag
#

thinks you should start at latest and put down some code

hexed hatch
#

why are you clinging to 1.16.5 specifically?

eternal night
#

oh yea, one of the last 1.17 additions

worldly ingot
#

Though if you want, you can use NumberFormat.getPercentInstance() instead

next stratus
#

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

grim ice
#

can i implement structure btw @hexed hatch

worldly ingot
#

Not sure I understand

#

What are the doubles?

next stratus
#

the block percentages within the mine

worldly ingot
#

Relative to what? Do you have a % in there for stone? Ideally your number is going to add up to 100%, no?

worldly ingot
#

I think your calculation is flawed in this instance

grim ice
#

so i can set the size

worldly ingot
#

because your value is either a percentage or a weight

grim ice
#

of the struct

#

and other info

viral crag
hexed hatch
#

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

next stratus
#

I mean Double goes up to 1 yes?

worldly ingot
#

Double can exceed 1

#

It's just a decimal

grim ice
#

how do i set a struct size tho

hexed hatch
#

I believe you define two corners

worldly ingot
#

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%

grim ice
#

how tho

worldly ingot
#

But if you are using those as percentages, then the percentage is going to be what you have mapped

#

Scaling matters here too

next stratus
#

but there's no way to make the 1 become 100% instead of 1

worldly ingot
#

You can multiply it by 100 😛

#

Which you're doing in that method

#

Which does work, as I've shown above

hexed hatch
#
void
fill(Location corner1, Location corner2, boolean includeEntities)
Fills the structure from an area in a world.```
grim ice
#

filling?

#

i dont want it to have anything

#

plus there is no set location, arent structures virtual

hexed hatch
#

it's weirdly named, almost certain that just gets the shit from the world and puts it in the structure object

worldly ingot
#

You can fill the structure with information from the world, and you can place a structure into the world

hexed hatch
#

actually I am not almost certain

worldly ingot
#

#fill(), #place(), respectively

sterile token
#

Who tag me?

hexed hatch
#

Okay now I am certain thank you choco

#

choco you know what would be like super cute

sterile token
#

Nice to see chocho helping

hexed hatch
#

a clone method for entities teehee

sterile token
#

He always try to help

viral crag
#

String.format("%f", 100.00);

worldly ingot
grim ice
#

ACTUALLY

#

will calling createStructure

#

lag

worldly ingot
#

Probably not

grim ice
#

is it worth distributing

#

over several ticks

worldly ingot
#

Probably not

grim ice
#

alr

worldly ingot
#

It uses the same functionality that structure blocks use

#

If you're doing any of the IO operations from StructureManager, however, do those async

young knoll
#

But it isn’t limited toy 48x48x48

worldly ingot
#

I can't verify that

young knoll
#

I wonder if worldedit has an option to save as an NBT structure yet

young knoll
#

That’s an arbitrary limit

hexed hatch
#

using the api avoids the limit I believe

worldly ingot
#

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

tardy delta
#

lmao all these things

young knoll
#

Isn’t the structure stuff new

grim ice
#

entity.getLocation(), entity.getLocation().add(0,2,0)

#

that would be

hexed hatch
#

1.17.1

grim ice
#

2 blocks height

#

right?

hexed hatch
#

no clue

young knoll
#

Yes

hexed hatch
#

might not even need two though

young knoll
#

I assume it’s inclusive

hexed hatch
#

one block might be enough to save the entity

young knoll
#

Probably

fossil lily
#

How can I change it to detect if its a pig who is involved in the event?

hexed hatch
#

@grim ice pull out some structure blocks and mess with saving and spawning an entity from it

fossil lily
#

Im not sure how to check it

grim ice
#

alr

young knoll
#

Instanceof Pig

grim ice
#

nah ill make a config

young knoll
#

Or compare getEntityType

fossil lily
#

oh!

grim ice
#

for the int

#

to make it easier

fossil lily
#

This should work right?

young knoll
#

Yes

fossil lily
#

amazing

young knoll
#

I would use == tho

fossil lily
#

thanks

#

is there any difference?

eternal night
#

one less method to call

tardy delta
#

or entity instanceof Pig?

viral crag
#

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

tender shard
#

lol SpickyChicken

#

sounds like something you can order from KFC

viral crag
#

&5SpicyChikn will likely get filtered for being invalid

#

starts with a symbol

#

have you tried with a normal username?

maiden thicket
#

converting instants to Date obj 😟

west bone
#

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));
        }```
viral crag
#

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?

ancient jackal
#

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

somber sequoia
#

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

ancient jackal
#

no, getDisplayName is nicknames

#

that's a ton of blocks being checked everytime a chunk is loaded

somber sequoia
#

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

ancient jackal
#

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

eternal night
#

what ?

somber sequoia
#

yeah i think im just gonna use a hashmap

#

finna be easier

eternal night
#

ChunkLoadEvent should definitely be triggered for chunks loaded by players

#

ohh

#

I guess what "player" triggered the chunk load

ancient jackal
#

it doesn't keep track of the player

#

it does it when the player loads the chunk but doesn't know which player

somber sequoia
#

yeah no just built it and i cannot cast the event to a player object

somber sequoia
#

aint working for that one

wary harness
#

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

viral crag
#

oof i broke intellij

wary harness
#

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

ancient jackal
#

set the ownerprofile of the skull meta

viral crag
#

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

wary harness
#

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

viral crag
#

your offline stuff probably already tells you what you need to use for player skin support

ancient jackal
#

my test server is offline and it still gets heads after a second

minor garnet
#

some1 know how is possible make a vector go trough blocks? else if i spawn inside of blocak

minor garnet
#

a ray trace go trough blocks?

golden turret
#

then use ray ratxe

grim ice
#

where to store namespacedkeys again

unkempt peak
#

What are you doing?

ancient jackal
#

playerdatacontainer

unkempt peak
ancient jackal
#

yes my bad

grim ice
#

actually

#

can i use one namespacedkey for many persistent data containers

young knoll
#

Yes

#

As long as they aren’t on the same holder

tender shard
#

a namespacedkey is "basically" just a string in the format "namespace:key"

#

minecraft:diamond_pickaxe
angelchest:protected_chest
plugin:somestring

ancient jackal
#

1 key can unlock many doors

grim ice
#

can I use

#

a player uuid

#

as a structure name

tender shard
#

structure name?

grim ice
#

1.17.1 structures

eternal night
#

your namespaced key can have whatever string matches the constraints as key

grim ice
#

actually

#

not a name

#

ok

tender shard
#

yeah basically [a-z0-9-] IIRC

grim ice
#

can a namespacedkey

#

have a

#

uuid toString()'d

#

it prob cant

#

ok it cant cuz uppercase letters

tender shard
#

Namespaces may only contain lowercase alphanumeric characters, periods, underscores, and hyphens.

Keys may only contain lowercase alphanumeric characters, periods, underscores, hyphens, and forward slashes.

tender shard
grim ice
#

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

eternal night
#

you wouldn't store the structure

#

you just store the namespaced key to the structure

grim ice
#

ik

#

oops i misspelled

eternal night
#

Eh I mean, make a type if you want to

grim ice
#

i meant a key

#

but how

#

to do that

eternal night
#

but like, it is just a string in the end

grim ice
#

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

eternal night
#

I mean

#

the entity uuid ?

quaint mantle
#

2hex what are you trying to do

grim ice
#

storing a struct in an itemstack essentially

grim ice
tender shard
#

what even is a struct

#

i only know structs from c++ lol

eternal night
#

struct -> namespace of a structure

tender shard
#

ah ok

eternal night
#

its the new short form

#

everyone knows

#

smh

young knoll
#

Just like

#

Store the key in the itemstack?

grim ice
#

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

eternal night
#

you'll have to save that structure

#

but yea

quaint mantle
#

Yhh

#

Is this an api ir smth

eternal night
#

manya out here having a stroke

#

damn you spigot discord 😭

grim ice
#

should i run saveStructure

#

async

#

(on another thread, since async has another meaning)

quaint mantle
#

Whaxt isf thr magner

#

manager

grim ice
#

uh

#

StructureManager

#

1.17.1 structures

quaint mantle
#

is rhis from spigor?

grim ice
#

yea

eternal night
#

Well the method isn't actively declared safe for off-thread, but eehh might work ?

quaint mantle
#

Ahh makes sense

grim ice
#

so uhh

#

im kinda doubting the performance

eternal night
#

Yea I don't think it touches any internal state

grim ice
#

but it uses Namespacedkey

#

is that also safe

eternal night
#

Yea

#

namespaced key is just a string pair with a bunch of constraints

grim ice
#

btw

#

if i store an entity in a

#

structure

#

can i kill the entity

#

and it will be saved in the structure

eternal night
#

no, the structure takes a snapshot

#

which means you'd have to "refill" the structur

grim ice
#

so its just copying

#

it does not save it

eternal night
#

Well it saves it when you call the saveStructure method

grim ice
#

i do

#

so if i save structure

#

then kill

#

the entity

#

will it respawn if i load it

#

and place

eternal night
#

yes

midnight shore
#

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?

fervent gate
#

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

viral crag
young knoll
#

Material.matchMaterial

midnight shore
young knoll
#

Use the structure API

#

Or worldedit API

grim ice
#

palette – The palette index of the structure to use, starting at 0, or -1 to pick a random palette

#

what the heck is this

midnight shore
viral crag
#

thats exactly what 2Hex is trying to figure out how to use as well

grim ice
#

yes so what is palette

bitter frigate
#

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

viral crag
grim ice
#

there is only one i think

viral crag
#

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

young knoll
#

You shouldn’t have to worry about the pallet

midnight shore
#

How can I have an offset between two blocks?

#

For example

#

I have a block named center

viral crag
#

pick it up and move it right 1 space = 1 block offset

midnight shore
#

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?

midnight shore
#

Would that work using locations and subtracting

#

?

viral crag
#

everything contained is the same as the blockState as it says

midnight shore
#

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

shrewd sentinel
spiral light
#

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

grim ice
#

how do i set where to save the Structures from my plugin

young knoll
#

The save method takes a file

grim ice
#

what If I dont set where to put it

#

there arent any side effects, right?

young knoll
#

Check the method in the docs

fossil lily
#

Anyone know why when I click my npc this gets executed twice?

lost matrix
fossil lily
#

How can I stop that, and why?

young knoll
#

Because you can click with both hands?

grim ice
#

event.getHand() == EquipmentSlot.HAND

fossil lily
#

i guess

grim ice
#

will only run for main hand

young knoll
lost matrix
#
  1. By checking which hand the event fired for
  2. The client sends 1 use packet for each hand
grim ice
#

add OFF_ before HAND so its only for off hand

viral crag
#

anyone have experience with making the annotations processor behave in intellij? It is refusing every path I try to give it

fossil lily
#

Where would I add that?

young knoll
#

At the top of the event?

fossil lily
#

hm

viral crag
#

around the same place you get the right click

fossil lily
#

It says its "Not a statement"

young knoll
#

Well yeah

#

That’s pseudocode

fossil lily
#

k il figure it out

ivory sleet
#

The api is a bit cumbersome

#

But overall it works just fine

#

(Using gradle fyi)

mighty bane
#

Question, how to make text that rapidly changes similar to what happens during the minecraft end credits?

midnight shore
#

Wdym?

young knoll
#

The crazy seizure text?

mighty bane
#

Yes

young knoll
#

&k in legacy codes

#

ChatColor.OBFUSCATED I think?

mighty bane
#

Thanks

young knoll
#

Nope

#

ChatColor.MAGIC

daring lark
#

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

mighty bane
young knoll
tender shard
#

?notworking

undone axleBOT
#

"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.

daring lark
#

[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) ~[?:?]

tender shard
#

that's not the full error

daring lark
#

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

tender shard
#

the player you are trying to get in line 108 is not online

#

so Bukkit.getPlayer() returns null

daring lark
#

thanks

#

i fixed it

waxen plinth
#

Why is it always an NPE and people just don't read it

young knoll
#

Reading hard

sterile token
young knoll
#

It’s at the top

sterile token
#

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

lost matrix
lyric cobalt
#

Hi, where can I find a working Spigot 1.8 file?

lost matrix
#

compile it with BuildTools

lyric cobalt
#

Oh

#

Simple enough

lost matrix
#

?bt

undone axleBOT
lyric cobalt
#

Thanks

lost matrix
#

--rev

tender shard
#

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

young knoll
#

set up excludes filters on your dependencies

tender shard
#

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

fervent gate
#

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.

tender shard
fervent gate
#

Returned an empty list when I tried that, but I'll copy and try again.

tender shard
#

that definitely works unless your config is broken or you had a typo or sth

fervent gate
# tender shard 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?

tender shard
#

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

fervent gate
#

I see, it is super easy to miss these

vocal cloud
#

Gotta write unit tests mmlul

fervent gate
#

I gotta learn to write these

#

have been putting it off for a bit

tender shard
fervent gate
#

Which would take quite a bit more work to fully emulate with a unit test

vocal cloud
tender shard
#

if getStringList returns null

#

it's obvious there must be a typo

river oracle
#

reading stracktraces is easy no need to do unit tests with a small minecraft plugin

tender shard
river oracle
tender shard
#

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

wet breach
#

is that your project?

vocal cloud
#

It helps prevent errors before deploying to the server

tender shard
#

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)

waxen plinth
tender shard
#

yeah it always depends

#

some people write too many stupid tests lol

waxen plinth
#

Sometimes I am rewriting some complicated internal piece of code and I have no idea what it's gonna break

tender shard
#

but yeah for many things they are great

waxen plinth
#

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

wet breach
#

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

waxen plinth
#

Which I often did

opal juniper
#

i have never once written a test 😢

fervent gate
#

Do you have to run the server for unit tests to work or can you do that in intellij

tender shard
# river oracle how

so yeah, unit tests have nothing (or at least not much) to do with stacktraces

wet breach
#

I have, but they are generally pointless for plugins most of the time though

tender shard
#

they basically emulate a proper server

#

maven can run them automatically

#

or gradle

#

or on your own

waxen plinth
#

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

fervent gate
#

I'm going to have to learn that for sure

waxen plinth
#

It's very very easy

vocal cloud
#

I hate how some companies write the tests first

fervent gate
tender shard
wet breach
waxen plinth
#

Not really though

tender shard
vocal cloud
#

Popular in the industry

waxen plinth
#

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

tender shard
#

the person who wrote a method should never be the person who also writes the test for that method

waxen plinth
#

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

tender shard
#

if you write the test first, some people might think "I am done" when all tests succeed lol

wet breach
#

doesn't really make sense to write tests for everything

waxen plinth
#

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

river oracle
#

I just don't get the advantages of doing unit tests on a smallscale minecraft plugin

tender shard
fervent gate
#

Do all of you use mockbukkit to write tests? With Junit I assume

tender shard
wet breach
waxen plinth
#

In what case are you writing a function whose behavior doesn't matter

wet breach
#

if a boolean is returned, its either going to be false or true nothing else