#help-development

1 messages · Page 233 of 1

tardy delta
#

did you delete the file so it could be written again?

twin venture
rotund ravine
#

He is saying if the teleport also caused the damage synchronously a boolean before and after would have worked. But in this case teleport simply moves them

glossy venture
#

yeah

tardy delta
#

gimme the whole location adapter lol

rotund ravine
#

Oh ur talking to that guy

twin venture
#

the same one i sent to you in dm

tardy delta
#

man if you keep sending snippets imma have a mental breakdown

#

does that extend TypeAdapter<T> tho or what does it extend?

#

dunno about that method

twin venture
#

ok so i changed my whole methods to Location

trim creek
#

How do I even start anything lol

rotund ravine
#

?learn

#

What’s the commands fuck

trim creek
#

thats not the idea

#

I can do plugins

#

I just can't start a new in IntelliJ

twin venture
trim creek
#

I switched from Eclipse today ;-;

twin venture
#

but now for some reason , it stop registering the gson ..

river oracle
#

this worked thank you

rotund ravine
twin venture
#

no errors tho or anything

tardy delta
#

man if you keep sending snippets imma have a mental breakdown

twin venture
opal juniper
rotund ravine
#

He’s hiding his code so u won’t steal it obviously /s

tardy delta
#

im just seeing random code

opal juniper
#

i will sue you if you steal my code

rotund ravine
#

Let’s fight @opal juniper

#

I win i get the code u win i’ll give you a nice cheese

twin venture
rotund ravine
#

@twin venture Usually anything related to the issue is needed to diagnose the issue.

twin venture
tardy delta
#

just send me the damn code to serialize and deserialize

tender shard
tender shard
rotund ravine
twin venture
#

iam using this one ,-,

#

when i use this , and do registerTypeAdapter(Location.class,new LocationAdapter())

#

gson seems to be stop working ,-,

rotund ravine
#

The other day some guy excluded a class where he looped over a set, somehow the set wasn’t present when he accessed it on the bukkit thread. He didn’t tell us he had another class, everything looked fine.

twin venture
#

for some reason , no errors tho

rotund ravine
#

And don’t worry the guys who’ll steal ur code in here is probably some skript kiddies.

tardy delta
rotund ravine
#

Yes

twin venture
tardy delta
#

take a look at ComponentBuilder

#

why creating two files

twin venture
#

what do you mean by creating to files

tardy delta
#

only call file::mkdirs and file::mkdirs when necessary

#

no need to call parent::mkdirs

rotund ravine
#

It’s fine

#

He should probably move it to somewhere else tho

#

That only gets run on plugin start

twin venture
#

i dont think its the reason why its not saving the location to the json file

rotund ravine
#

flush and createNewFile most likely does the same thing. Thought he meant that

tardy delta
#

i was using Files.writeString(file.toPath(), gson::toJson) anyways

rotund ravine
#

A filewriter should work the same with a few more lines.

#

I’m going to bed gnight

twin venture
#

so from what i understand , Location is an Object , and i need to serlize it so gson can read it correctly right ?

tardy delta
#

gn

twin venture
#

Good night .

tardy delta
#

uh ig yes?

#

dunno why your gson instance isnt throwing an exception when coming accross a location object anyway

#

must be smth with that @Expose

twin venture
tardy delta
#

whats the point when you could just not use it and remove the method in your builder

#

just use transient whenever you dont want anything to be serialized

twin venture
#

i will try it thanks

tardy delta
#

like this

twin venture
#

i know .

opal juniper
#

p.spigot().sendMessage

tardy delta
#

whats ((Player)sender).getPlayer() supposed to do lol

#

Player#getPlayer#getPlayer#getPlayer

opal juniper
#

thats a thing? LOL

tardy delta
#

believe so

#

as OfflinePlayer#getPlayer exists

trim creek
#

so SpigotAPI includes BukkitAPI, right?

tardy delta
#

ye iets a thing

#

Bukkit.getOnlinePlayers()

trim creek
#

ahnevermind

#

I just had to manually load maven stuff

#

xd

quiet ice
#

<insert IDE name here> moment

opal juniper
#

netbeans

tardy delta
#

bluej

#

cant be considered an ide but anyways

frail spire
#

Intelij

tender shard
#

if I'd ever write an IDE, it'd be called JuicyJ and it'd have a grape as logo

frail spire
tender shard
#

oh were not in general

vocal cloud
#

Write it as an IDE within an IDE

tender shard
#

java -jar java.jar -jar spigot.jar

#

that would be funny, a JRE packaged as .jar file

tardy delta
#

in disguise

humble tulip
#

I need some maven help

#

actually

#

let me make sure it's mavne

tender shard
#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

humble tulip
#

i was gonna ask but i'm just making sure it's not maven

tender shard
#

if you have a pom.xml file, it's maven 😄
if you have a build.gradle file, it's gradle.
if you have neither, it's neither lol

humble tulip
#

lol

#

i mean if it's maven causing my problem

#

ok i'm not sure what's causing my problem but i dont think it's maven

#
cancel-item:
  type: 'BARRIER'
  name: '&cClose Backpack'

left-arrow-1:
  type: 'PLAYER_HEAD'
  url: 'http://textures.minecraft.net/texture/3866a889e51ca79c5d200ea6b5cfd0a655f32fea38b8138598c72fb200b97b9'
  name: '&aPrevious Page'
  lore:
    - ''
    - '&7Go to the previous page'
    - ''
    - '&7<page>/<num-pages>'

right-arrow-1:
  type: 'PLAYER_HEAD'
  url: 'http://textures.minecraft.net/texture/dfbf1402a04064cebaa96b77d5455ee93b685332e264c80ca36415df992fb46c'
  name: '&aNext Page'
  lore:
    - ''
    - '&7Go to the next page'
    - ''
    - '&7<page>/<num-pages>'

white-glass-decor:
  type: 'WHITE_STAINED_GLASS_PANE'
  name: '&a'

unbought:
  type: 'RED_STAINED_GLASS_PANE'
  name: '&aSlot <slot>'
  lore:
    - ''
    - '&aYou must purchase all slots before this one in order to purchase this.'
    - ''

first-unbought:
  type: 'YELLOW_STAINED_GLASS_PANE'
  name: '&aSlot <slot>'
  lore:
    - ''
    - '&7Price: $<price>'
    - ''
    - '&aClick on this to purchase this slot.'

unobtainable:
  type: 'IRON_BARS'
  name: '&cYou cannot purchase this slot.'
#

this is a file in my ide

tender shard
#

that's a normal yaml config file

#

what's the problem you got?

humble tulip
#

oops

#

that is when it's packaged into the jar

tender shard
#

did you open the .jar file with notepad? o0

humble tulip
#

some files are fine, some have contents missing

#

no one sec

tender shard
#

hm how did you create the .jar?

humble tulip
#

maven

#

wanna see my pom?

tender shard
#

yes pls

#

what did you run to package? mvn package?

humble tulip
#

mvn clean install

#

?paste

undone axleBOT
tender shard
humble tulip
#

btw did u forget me?

tender shard
tender shard
#

in your IDE; does it say "UTF-8" as encoding when you open the yaml file?

humble tulip
#

One sec

tender shard
humble tulip
#

it does

tender shard
#

can you send your .jar file here?

humble tulip
#

uhh can i dm?

humble tulip
#

btw it used to build just fine and all of a sudden it doesnt

trim creek
#

I hate Java...
} else if (!users().get("Players." + event.getPlayer().getUniqueId().toString() + ".Name").equals(event.getPlayer().getName())) {

humble tulip
trim creek
#

that's why I want to check it if its null or not lmao

#

because if not player's name execute reset method lmao

humble tulip
#

u should learn kotlin

trim creek
#

phew

#

nein

#

Java and C# is enough stress for me with school combined

#

no thanks

#

😹

#

and project is set to be java c.c

#

ah wait I got how to fix

tender shard
tender shard
trim creek
#

a simple boolean will do

#

HOPEFULLY

#

Yup, time to fuck Java :)

tender shard
#

java is perfectly fine

tender shard
#

or what yaml are you talking aobut?

trim creek
#

I can't believe this doesn't works...

 public boolean exists(Player player) {
        if (users().get("Players." + player.getUniqueId().toString() + ".Name").equals(player.getName())) {
            return true;
        }
        return false;
    }
humble tulip
#

check the ones in 1.13

humble tulip
#

also the ones in 1.8 are incomplete

tender shard
#
String something = null;
String somethingUppercase = something.toUppercase();
#

this ofc won't work

#

what you want to do is sth like this:

#
String something = null;
String somethingUppercase = null;
if(something != null) {
  somethingUpperCase = something.toUpperCase();
}
trim creek
#

the main problem starts at the point of where I need to check if the player already has been on the server, and if not, then give them their stats, or if yes, but their stats are missing, give it back to them from the default.

tender shard
trim creek
humble tulip
tender shard
# humble tulip

and the file in resources/1.8/*.yml looks fine in the IDE?

eternal oxide
tender shard
tender shard
trim creek
#

yes I realised lol

tender shard
#

it's an else if

eternal oxide
#

both call setupPlayer(event.getPlayer());

trim creek
humble tulip
tender shard
#
if(a) doSomething();
else if(b) doSomething();

if neither is true, it does not do anything

humble tulip
#

the 1.8/global items.yml is fine

#

same as in the jar

tender shard
#

it's the same as ```java
if(a || b) doSomething();

humble tulip
trim creek
tender shard
humble tulip
#

the 1.8/default is nulls

tender shard
humble tulip
#

im gonna copy the file, delete it and recreate it

#

@tender shard that fixed it

#

who tf knows what went wrong

trim creek
#

no one

#

this is why I hate nulls lol

tender shard
trim creek
#

the software might

#

but the software is not us

#

D:

#

imagine being a software... 🤔

humble tulip
#

intellij did crash on me once so idk if it got curropted or something

tender shard
trim creek
#

whut

#

a full binary

#

of falses

#

lmao

humble tulip
#

NULL NULL NULL NULL NULL NULL NULL NULL

#

lol

trim creek
#

nah

#

falsefalsefalsefalse falsefalsefalsefalse falsefalsefalsefalse falsefalsefalsefalse falsefalsefalsefalse falsefalsefalsefalse

#

this is better lmao

tender shard
trim creek
#

I still don't get why can't we get nulls. It would be MUCH easier if we could detect them lmao

tender shard
#

you can, of course

#

just imagine this:

round finch
#

== null?

tender shard
#
public class Player {
  String getName() { return "mfnalex"; }
}
#

now you can call getName() on every player and it returns mfnalex

#

but if you do not have any player, because your object is null, then on what object should it call getName() on?

#

you cannot call methods or fields on "null" objects

#

it makes no sense

#

imagine I ask you "yo can you tell me the name of this person?" while you point into the void with your finger

#

you cannot tell me the name of that person since there is no person

trim creek
#

getting.. data from a yaml...

#

can't be this serious lmao

tender shard
#

imagine this:

#
people:
  mfnalex:
    name: "Alexander"
  NeonOwlGery:
    name: "Gery (idk)"

Now you can do

String mfnalexName = yaml.getString("people.mfnalex.name"); // this will be "mfnalex"
String neonName = yaml.getString("people.NeonOwlGery.name"); // this will be "Gery (idk)"
String nonExisting = yaml.getString("people.nonexisting.name"); // this will be null
#

isn't that straightforward?

#

And this won't cause an error

trim creek
#

yes but I need to make new data if it doesn't exists lol

tender shard
#

what will throw an error is if you now try to do nonExisting.someMetho()

trim creek
#

like adding a third one

tender shard
trim creek
#
people:
  mfnalex:
    name: "Alexander"
  NeonOwlGery:
    name: "Gergely"
  Yaml_User_NEMTUDOMKIVAGYOKLOL:
    name: "IstilldontknowmynameXD"
tender shard
#

I really have no clue what you're trying to do tbh

#

to set a value in a yaml, you just do myYamlConfiguration.set(node, value)

trim creek
#

This ist users file

#

this file needs users

#

but if they don't exists

#

they need to be created

trim creek
#

otherwise the plugin would not make any sense at all lol

tender shard
#

then you do it like this:

trim creek
#

only new joining players would have data, and all others would just spam the console

tender shard
#
if(yaml.isSet("people.nonExistingUser") {
  // The user exists in the yaml
}
trim creek
#

oooooo

#

I actually never heard of that method XD

tender shard
#

alternatively you could just do it like this:

String name = yaml.getString("people.nonExistingUser.name");
if(name == null) {
  // They do not exist yet
} else {
  // They do exist
}
trim creek
#

the last one actually gets stuck where it gets the player name lol

tender shard
#

no, it would simply set name to null

trim creek
#

and throws.. the f*cking... null error

tender shard
#

no

trim creek
#

it does lol

tender shard
#

it only throws the error if you do name.someMethod() before checking whether name == null

#

if name is null, you must not use name.someMethod()

trim creek
#

🤔

#

so I need to check it in the join method, eh?

#

kind of makes sense

#

but actually no

tender shard
#
onJoin:
  String name = event.getPlayer().getName();
  boolean existsInConfig = getConfig().isSet("people." + name);
  if(existsInConfig) {
    // load date from config
  } else {
    // create default data
  }
#

btw, all the get methods also have a default option

#

for example:

double balance = getConfig().getDouble("mfnalex.balance", 100D);
#

if mfnalex.balance is set in the config, it returns that, if it's not set, it returns 100

#

that's basically the same as this:

boolean doesMfnalexHaveABalance = getConfig().isSet("mfnalex.balance");
double balance = 100D; // default balance for non-existing players
if(doesMfnalexHaveABalance) {
  balance = getConfig().getDouble("mfnalex.balance"); // This player has a balance set, so let's load that instead
}
#

there's also the question mark operator for stuff like this:

double balanceOfMfnalex = getConfig().isSet("mfnalex.balance") ? getConfig().getDouble("mfnalex.balance") : 100D;
#

these three things basically all do the same thing

trim creek
#

boolean user = users().isSet("Players." + event.getPlayer().getUniqueId().toString() + ".Name"); still returns a null...

tender shard
#

imagine that users UUID is 1-2-3-4

#

then your yaml does NOT look like this:

Players:
  1-2-3-4:
    Name: <whatever>
#

if 1-2-3-4 doesn't exist inside Players, then it returns null, as expected

trim creek
tender shard
#

then take a look at your config

trim creek
#

config is empty

tender shard
#

then obviously everything returns null

trim creek
#

UUID remains

#

and plugin stores palyers by UUID

tender shard
#

that's why they use the UUID

trim creek
#

what

tender shard
#

no clue

trim creek
#

the name is already set lol

#

when they run the game

#

lmao

tender shard
#

anyway, if your config is empty, then of course every config.get(...) will return null

#

what else would it return?

trim creek
#

welll xd

#

this is what I want to prevent lmao

#

and to add them

#

to not to be null

#

so next time their stats won't reset

trim creek
#

🤔

tender shard
#

again, let's make it easy. imagine you want to get their money when they join. or 0 when they haven't joined yet

#
double balance = getConfig().getDouble(playerName + ".balance", 0.0D);
#
mfnalex:
  balance: 20
#

now it returns 20

#

if the config is empty, or it doesnt include "mfnalex", then it returns 0

trim creek
#

-braincrash-

tender shard
#

tbh it's extremely straightforward in my eyes

trim creek
#

i bet you have 100 years of Java experience

#

lmao

#

or if not 100

#

over 5

#

well I need to say I don't

#

so I can't imagine the code

#

😫

#

and I am tired af

tender shard
#

but what exactly don'T you understand?

#

maybe you should go to sleep and think about it again tomorrow 😄

trim creek
#

the whole thing 😹

tender shard
#

do you know what a hashmap is?

trim creek
#

yes

#

but I hate it

tender shard
#

well then you didnt understand it

trim creek
#

and stats has to be permanent

tender shard
#

a map is like a phonebook

#

it maps a value to a key

trim creek
#

I could simply just add the temp stats, then set them when player quits

#

but meh

tender shard
#

e.g. in a phone book, the key is the name, and the value is the phone number

trim creek
#

no sense

tender shard
#

mfnalex: 12345
someoneElse: 23456

mfnalex is the key, 12345 is the value

#

now you can do

String numberOfMfnalex = myPhoneBook.get("mfnalex");

now numberOfMfnalex is "12345"

#

this makes sense, right?

trim creek
#

yes

#

except if it returns null lol

tender shard
#

(I changed it to String, otherwise I have to explain what auto unboxing is)

trim creek
#

habááááááááár.... I could set the UUID and the stats as well...

vocal cloud
#

Use getOrDefault then you'll never have nulls

tender shard
#

Now imagine you do this

String numberOfNobody = myPhoneBook.get("person that does not exist");

numberOfNobody is now null, since the phone book doesnt have a number for this person

tender shard
trim creek
#

and now I feel complete shit ;-;

tender shard
#

what does not exist? getOrDefault on your config?

trim creek
tender shard
#

yes, it's just called get(...)

vocal cloud
#

getOrDefault is a HashMap method

tender shard
#
boolean user = users().get("...", false);
trim creek
#

that would return nulla as well

tender shard
tender shard
trim creek
#

I didn't know it can have a false lol

trim creek
tender shard
#
Something something = getConfig().getSomething("mfnalex.something", defaultValue);
trim creek
#

and that's why I feel complete shit ;-;

tender shard
#

you should look at some basic java tutorials maybe 😛

#

?learnjava

undone axleBOT
tender shard
#

no offense

trim creek
#

and now it hurts me what an idiot I am ;-;

tender shard
#

we all started somewhere, but it's really important that you read one of those tutorials

#

otherwise you'll always feel like an idiot

trim creek
#

docs never did really helped me

#

specially the spigot one

tender shard
#

But they explain it perfectly

trim creek
#

only if you understand it ;-;

#

my stupid brain doesn't even understands how to use the docs lol

ivory sleet
#

a good opportunity to learn the spigot javadocs then?

trim creek
#

like ok

river oracle
#

^ This is something I actually learned in school

#

it makes so much sense tho now

trim creek
#

it writes down the methods I can use

#

just does not how

river oracle
#

abnd constructors

#

it explains what they do

#

you should have enough programming fundamental knowledge on how to apply that though

#

if you need use examples specifically look for that

trim creek
#

Gets the requested Object by path, returning a default value if not found.

#

this is what get says

tender shard
#

yes

trim creek
#

meanwhile the plugin still returns null 😹
even tho I added false ;-;

tender shard
#

if you do

String name = getConfig().getString("mfnalex.name", "Alexander");
#

then name is "Alexander" if the config looks like this:

#
mfnalex:
  name: Alexander
#

if "mfnalex.name" is not part of the config, it also returns "Alexander" because you defined that as default value

#

okay bad example

trim creek
#

boolean user = (boolean) users().get("Players." + event.getPlayer().getUniqueId().toString() + ".Name", false);
I probably f*cked up here

#

I think I should not use booleans

tender shard
#

but that makes no sense

#

you do not store a boolean in the "Name" field in your config

trim creek
#

yes

#

I realised

tender shard
#

you would use getString

trim creek
#

somehow booleans sticked to me c.c

tender shard
#

a boolean is always only true/false

#

booleans also can never be null, because they are "primitives"

trim creek
#

eeeh

#

String user = users().get("Players." + event.getPlayer().getUniqueId().toString() + ".Name", event.getPlayer().getName()).toString(); - that should be it... doesn't it...?

#

(.toString() was forced btw xd)

tender shard
#

both toString()s are useless unless maybe you use paper api

#

but they also don't hurt

#

oh you mean the last toString

trim creek
#

yes

tender shard
#

yeah that's because you still use get() instead of getString()

trim creek
#

UUID.toString is needed

tender shard
#

get() returns an Object

trim creek
#

because I don't want stupid looking stings xd

tender shard
#

no, that's also not needed

#

the + operator automatically calls toString()

trim creek
#

lol

tender shard
#
String userName = users().getString("Players." + event.getPlayer().getUniqueId() + ".Name", event.getPlayer().getName());
#

this returns their stored name, or their actual ingame name

trim creek
#

yeeeeah but IDE detects this as an error

tender shard
#

but only if your config looks like this:

Players:
  1-2-3-4:
    Name: "mfnalex"
tender shard
trim creek
tender shard
#
  1. you didnt show the error message
  2. you still use get() instead of getString()
trim creek
#

DAMNXd

#

now it no error

tender shard
#

you should really read a java tutorial if you don't know why you cannot store an Object as a String

trim creek
#

turns out to be still glitched... -.-

tender shard
#
String name = "mfnalex"; // Okay
String name = new Object(); // Not okay, an Object is not a String
#

getString() returns a String, get() returns an Object (could be anything)

trim creek
#

eh

#

so um

#

String user = users().getString("Players." + event.getPlayer().getUniqueId() + ".Name", event.getPlayer().getName()); - this sets the default string if not found

tender shard
#

well it sets your "user" variable to either the saved name, or the actual name

#

but it will never change your actual config.yml file

drowsy helm
#

seems a bit redundant

tender shard
#

why?

drowsy helm
#

wont the user be the name anywa

tender shard
#

not if they have a different name in the config

trim creek
#

but the line still returns a null 😔

#

even tho its set 😫

tender shard
#

it's not set. what does your users() method even do?

trim creek
#

gets the users.yml file

#

to modify it

tender shard
#

and do you ever save it after that again?

#

show your user() code

trim creek
#
public FileConfiguration users() {
        return usersFile;
    }
tender shard
#

yeah okay

trim creek
#

however createPlayer does saves everything

#

after setting them

tender shard
#

and where do you set what usersFile is?

trim creek
#

then reloads just to load it

trim creek
#

inside DataManager

#

its the same as Settings

#

which works

#

so its not the problem of the users method or file

tender shard
#

if one works, and the other doesn't, then it cannot be the same

trim creek
#

its the problem of detecting non-existent players

trim creek
#

-.-

#

file is null

fresh timber
#

I have this code I try to use to kill all of the entities that are an instanceof PiglinBrute in the world "nether" but it does not work:

for (Entity entity : Bukkit.getWorld("nether").getEntities()) {
    if (!(entity instanceof PiglinBrute)) {
        return;
    }

    ((PiglinBrute) entity).setHealth(0.0d);
}

Things I know because I tested: The method does run, the world is named nether, and the entities I want to kill are piglinbrutes. No piglin brutes are killed even though I want to kill all of them. Does anyone know why this does not work or another way I can do this to kill all mobs in a specific world?

trim creek
#

(TRIGGERED)

tender shard
fresh timber
#

ohhh

tender shard
#

if the chunks aren't loaded, you cannot kill them that easily

fresh timber
#

hm

tender shard
#

the server simply has no knowledge about entities in unloaded chunks

fresh timber
#

does the mc cmd /forceload keep them loaded or not?

tender shard
#

i don't know about that command but you can use chunk tickets to force chunks keeping loaded

trim creek
#

I guess keeping an entire world loaded is not a good idea...

fresh timber
#

not the entire world ;-;

#

I know where the mobs are tho

tender shard
#
myChunk.addPluginChunkTicket(myPlugin);
fresh timber
#

they are in like a 20x20 area

tender shard
#

this makes myChunk keep loaded until you remove that "ticket" again

fresh timber
#

is there a way I can get the chunk at certain cords

#

oh wait

tender shard
#

from normal X,Y,Z coordinates or from chunk coordinates?

fresh timber
#

x,y,z

#

also

#

I am standing in the chunks, loading them and its still not working

tender shard
#
Location loc = new Location(myWorld, x, y, z);
Chunk chunk = loc.getChunk();
#

this however will force-load the chunk right now, blocking the main thread

fresh timber
#

I have no idea what that means

tender shard
#

it means that when you do this, the chunk gets loaded RIGHT NOW and the server "hangs" until it actually loaded that chunk

#

this is no problem if you do this during startup, but you should do this while the server is actually running

trim creek
#

good news:

setupFiles();
        String user = users().getString("Players." + event.getPlayer().getUniqueId() + ".Name", event.getPlayer().getName());
        if (!user.equals(event.getPlayer().getName())) {
            setupPlayer(event.getPlayer());
        }

this makes the nulls go away
bad news: file is still empty 😢

#

but I guess I will just struggle thour this

trim creek
fresh timber
sterile token
tender shard
#

you return inside the for loop

#

while you should continue

fresh timber
#

ohh im stupid xd

tender shard
#

you basically quit your whole method as soon as getEntities() returns a non piglin

fresh timber
#

that makes sense

tender shard
#

just use continue instead of return, then it should work

trim creek
#

Guess I am gonna hit Java

#

in its stomacs

fresh timber
#

so liek this

        for (Entity entity : Bukkit.getWorld("nether").getEntities()) {
            if (entity instanceof PiglinBrute) {
                ((PiglinBrute) entity).setHealth(0.0d);
            }
        }
tender shard
#

that works too, sure

fresh timber
#

k

tender shard
#

imma go to head, have a nice day everyone

#

bed*

#

not head

#

lol

fresh timber
#

xd

#

gn

tender shard
#

thx

trim creek
#

good night

#

btw

#

your patience is strong

#

so

#

at the time I wanna thank you and sorry at the same time 😅

desert loom
sterile token
#

Cya mfalex

sterile token
trim creek
#

either the file

sterile token
#

I dont know if his file object is null or what he is getting from config

trim creek
#

or me

#

or idk

#

so

#

temp data is set

#

with getString(izé, defaultdata)

#

but when getting

#

still returns null

#

even tho a default non-found data is set

sterile token
#

Chapter 4, article 4, "Primary Debug" - Advanced Programming and Java Basics Book

#

That is how you should do when something is null

trim creek
#

I ain't advanced guy

sterile token
#

I shall recommend reading about primary debug its really important

desert loom
#

can you show some more code/your config?

round finch
trim creek
#

mfnalex literally told me four times

#

until for the last time

#

I finally udnerstood

#

that adding a second argument

sterile token
#

I dont know why people dont first learn the lang and things were they are coding, to finally learn apis 🤔

trim creek
#

is a temp data, that needs to be found

#

if not

sterile token
#

Temp data is not saved to file

trim creek
#

ik

sterile token
#

That why its temp data

#

🤔

#

So if you are not saving that temp data to file, when sever goes down dow, data goes down tho

trim creek
#

but I am just able to check if temp data is same as something else, don't I? .-.

sterile token
#

You are making me getting stressed

#

💀

trim creek
#

just chill

#

I am more stressed atm

#

and not because of my code

#

?paste

undone axleBOT
sterile token
#

I mean i really get stressed with new ones, because they dont first learn the java lang itself and then do apis stufff 🤦‍♂️ 🤦‍♂️ 🤦‍♂️

trim creek
sterile token
#

Okay some recommendations its really important when you are coding

#

I woudl straightly suggest not mixing logic

round finch
#

did you remember to set your values before getting it...
in the Config?

sterile token
#

I think he never saves them to file, before trying to get them

trim creek
trim creek
#

new players need be saved

trim creek
sterile token
desert loom
round finch
#

or wrong path

desert loom
#

maybe that's the issue.

sterile token
trim creek
#

If you don't notify me I won't notice it

#

fr

#

xd

sterile token
#

Yeah its really weird

#

Also listen bro

trim creek
#

WÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ

sterile token
#

Logic should be divided/splited in different class to have better coding and easier self understanding

round finch
#

Cursed code

trim creek
sterile token
#

I wouldnt learnt good practices without the actual i have

trim creek
#

I either hate statics, or referencing so nothing makes sense imo 🤪

sterile token
#

Also the book its not new, it has like 6y so imagine hahaha

sterile token
#

Seriously have you learnt basis java?

trim creek
#

idk

desert loom
#

also, for things like

        getUsersFile().set("Users." + player.getUniqueId().toString() + ".Name", player.getName());
        getUsersFile().set("Users." + player.getUniqueId().toString() + ".ActiveParticle", "NONE");
        getUsersFile().set("Users." + player.getUniqueId().toString() + ".ActiveGadget", "NONE");
        getUsersFile().set("Users." + player.getUniqueId().toString() + ".ActiveHat", "NONE");

you should prefer using a ConfigurationSection to not repeat yourself and it's less error prone.

round finch
#

Clean, simple and readable

#

good pratices

#

spragetti ain't worth debugging

sterile token
#

The book specified it tho in the main chapter tho

trim creek
#

me no have book

#

no book means no nothing :)

sterile token
#

I know, but internet has thousans of things

trim creek
#

yeaaah... lots of fucking cookies

#

and I hate cookies

#

EW

round finch
#

principles

sterile token
#

I think that this society is full of lazy people who really think they are programmers, but who have never in their lives spent hours and hours studying the language in which they program. I consider that a programmer is the one who really understands what he does and how he does it.

round finch
trim creek
sterile token
sterile token
#

LAW doesnt say who is programmer or not

trim creek
#

It does. 🤷‍♂️

round finch
#

people who have no ide how the languages work or how the code computes

trim creek
#

You can tell how you can programme, unless law didn't verify you, you are not a programmer.

round finch
#

you mean degrees?

sterile token
round finch
#

there is freelancers

sterile token
#

A programmer can be anyone

<"A programmer is a professional who is in charge of writing, debugging and reviewing all the source code of a computer software to make it perform certain tasks, or even to improve it, incorporating new functions to make it a more complete and efficient tool"

  • Taken from the bootcap im taking part
round finch
#

there is jr devs etc

sterile token
#

Yeah but the concept of programmer is that

sterile token
#

Programmer is anyone who can write, debug and review code

round finch
#

varies and skills

sterile token
trim creek
#

I argued

#

She "won" because she knows it better

#

-while she does not even do code anymore lol-

#

and like

#

"many" of her friends told her

#

which you know what does returns?

#

"Life is a piece of shit"

sterile token
#

I dont know what means that argument but okay

#

He must me a child which have lot of things to learn in life

round finch
#

how much different is it really from writting like being an authers?

you can't be author because you're not verified

trim creek
round finch
#

sounds restricting

trim creek
#

bruh anyway if you two want to break my soul do it in another way

round finch
#

?learnjava

undone axleBOT
trim creek
#

-altough its almost broken but you still can break it lmao-

trim creek
round finch
#

😁

#

your code looks like spragetti to me

#

practice design and patterns

trim creek
#

what is a spragetti?

#

🤡

round finch
#

*spaghetti

trim creek
#

that's what we are talking about

round finch
trim creek
#

bruh

round finch
#

you wanted me to be real

#

there you got it

trim creek
#

...

sterile token
#

Studying at a school does not really define you as what you study.
What defines you is the knowledge you actually acquired.
You may have finished your degree but you didn't take it seriously so you don't know anything.

  • From our bootcamp programming instructor
round finch
#

Spaghetti code is a pejorative phrase for unstructured and difficult-to-maintain source code. Spaghetti code can be caused by several factors, such as volatile project requirements, lack of programming style rules, and software engineers with insufficient ability or experience.

trim creek
#

and yes english mine is good very

#

lmao

#

most stuff learned is school is probably unused in life

round finch
#

depends what studies and what you need it for

trim creek
#

oh yes

#

but like

round finch
#

Math is very good!

trim creek
#

why tf would I calculate my sleeping? xd
how tf can I even do that lol

hybrid spoke
#

what is sleep

trim creek
sterile token
hybrid spoke
#

what

round finch
sterile token
trim creek
#

"Programmer doesnt mean what sleep means" - I kinda need to figure out what you wanna say lmao

hybrid spoke
#

we dont sleep

#

we go on standby

trim creek
sterile token
trim creek
#

but not anymore

round finch
trim creek
#

I simply don't have motivation for anything anymore

sterile token
trim creek
#

yes

sterile token
#

In these life only money people have preferences

trim creek
#

like everyone else

#

lmao

round finch
#

wait wait bot still loading

#

😄

trim creek
#

Bot? xd

round finch
#

ye u

#

jokes ofc

trim creek
#

did GodChiper change itself it a bot?

sterile token
#

That's what my parents tell me, "If you don't study you're not going to be anybody in life, just another one of the crowd. That's why you have to be educated or have money to be somebody in this world of lazy people and planeros".

copper scaffold
#

By adding a new recipe can i get from the recepie the water bottles empty back when yes how can i do that?

trim creek
hybrid spoke
trim creek
#

and this is a big no sense imo

#

oh alright

round finch
#

big confusion

#

do you mean emphty water bottle in crafttable?

trim creek
#

MINE WAS ENOUGH

#

STOP IT

#

NOW

#

😠

round finch
#

kid go to sleep

copper scaffold
round finch
#

i'm here to help people

trim creek
sterile token
trim creek
#

RIP

sterile token
#

MEME

trim creek
#

This actually felt good for some reason 🤣🤣

hybrid spoke
trim creek
#

WHYYYYYYYYYYYYYYYYYY?! XDDDDDDD

round finch
copper scaffold
trim creek
#

fhú baszd ki instead of fucking my brain here I am gonna fuck my brain with my code 😆😆

round finch
#

setResult

#

i gotta dip

#

late on sleep

#

work and stuff

sterile token
#

Cyao people have a good night

copper scaffold
#

why is it a interface? is there a difference to do then?

trim creek
#

"programmer doesn't mean what sleep mean"

#

anyway goodnight

sterile token
trim creek
#

nvm

round finch
trim creek
#

who said I am tired? 😐

copper scaffold
hybrid spoke
round finch
fresh timber
#

in 1.19, swords when they hit mobs hit multiple mobs if u have cooldown all the way gone, is there a way to stop this?

trim creek
#

btw I fixed my error lmao

royal monolith
#

Essentials support

zealous glen
#
    private void spawnEntity(Player player, Location location) {
        //https://wiki.vg/Protocol#Spawn_Entity
        PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SPAWN_ENTITY);

        packet.getIntegers().write(0, Integer.MAX_VALUE);
        packet.getUUIDs().write(0, UUID.randomUUID());
        packet.getIntegers().write(1, 51); // magma cube 1.19 id | https://wiki.vg/Entity_metadata#Mobs

        packet.getDoubles()
                .write(0, location.getX() + 0.5)
                .write(1, location.getY() + 0.5)
                .write(2, location.getZ() + 0.5);

        try {
            ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }

Am I missing something why is that code spawning a allay?

#

instead of a magma cube

undone kernel
zealous glen
undone kernel
zealous glen
#

"Magma cube 1.19" If you googled for 1 second you would understand it changed in 1.19

undone kernel
#

put 42 and see what happens

zealous glen
#

You are making yourself look like an idiot right now

undone kernel
#

no i'm not

zealous glen
#

LOOOOL

#

bro just stop typing

#

you have no idea what you are talking about

#

You randomly called me out when your obviously wrong

undone kernel
#

but i'm not

zealous glen
#

@buoyant viper

#

let me help you out again because you don't like to listen to your own advice and "google stuff"

undone kernel
#

no

#

u can't help me

buoyant viper
#

i was also at work so :P didnt have time to look look

zealous glen
undone kernel
#

try flipping them

zealous glen
#

packet.getEntityTypeModifier().write(0, EntityType.MAGMA_CUBE); fixed the issue

zealous glen
#

you didn't do shit lol

faint sage
#

🧌

subtle folio
#

Can anyone help me with this postgresql error? https://paste.md-5.net/upijudenoz.nginx I dont know where I reference "abc" as a column
INSTERT INTO stats (ID, COINS, XP, LEVEL, KILLS, DEATHS, TOP_KS, PRESTIGE, REBIRTH, PLAYTIME, TALENTS, ACHIEVEMENTS) VALUES ('UUID', 0, 0, 0, 0, 0, 0, 0, 0, 0, "abc", "def");

meager lynx
#

lol

#

afaik INSERT just adds a new row to the table

subtle folio
#

that's what I want

subtle folio
#

Kk

meager lynx
#

since double quotes shouldnt be used for values

subtle folio
#

'' will do a TEXT value right?

zealous scroll
#

does anyone know of a good way of de/serializing class subtypes onto an item's persistent data container

#

i have multiple subtypes for one custom item class and, for now, i have to register each subtype in gson for it to recognize all types it should be searching for, but i feel like there's a better way to do it

#

i've looked into type hierarchy and factory adapter's but they don't seem to fix my issue

subtle folio
meager lynx
#

np

undone kernel
fresh timber
#

I have a combat system made by my plugin on my server with named entities that you kill. When you kill them, it spams the heck out of the console. Anyone know how to fix this?

subtle folio
#
java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.String (java.lang.Integer and java.lang.String are in module java.base of loader 'bootstrap')
        at net.tazpvp.tazpvp.utils.data.PlayerData.getInt(PlayerData.java:64) ~[Tazpvp.jar:?]
        at net.tazpvp.tazpvp.utils.data.PlayerData.getInt(PlayerData.java:55) ~[Tazpvp.jar:?]
        at net.tazpvp.tazpvp.utils.functions.ScoreboardFunctions.newLine(ScoreboardFunctions.java:75) ~[Tazpvp.jar:?]
        at net.tazpvp.tazpvp.utils.functions.ScoreboardFunctions.initScoreboard(ScoreboardFunctions.java:56) ~[Tazpvp.jar:?]``` im so confused on what this means?
worldly ice
fresh timber
#

ah ok

worldly ice
#

its called log-named-deaths

fresh timber
#

thx, I found it!

ancient plank
subtle folio
#

integer + “”

ancient plank
#

That's not casting

glad prawn
subtle folio
buoyant viper
ancient plank
vocal cloud
#

Your casteble

buoyant viper
vocal cloud
#

Friend friend = (Friend) person;

#

inb4 cannot cast 'TestClass.Person' to 'TestClass.Friend'

pine island
#
        else if (
                (action == Action.PHYSICAL) || (event.getItem().getType() == Material.GOLDEN_APPLE) 
                && (event.getItem().getItemMeta().getDisplayName().equals(ChatColor.GOLD + "~Angel's Apple~"))
        ) {
#
                        ItemStack item = new ItemStack(Material.GOLDEN_APPLE, 1);
                        ItemMeta itemMeta = item.getItemMeta();
                        itemMeta.setDisplayName(ChatColor.GOLD + "~Angels Apple~");
                        itemMeta.setLore(Collections.singletonList(ChatColor.GRAY + "A Golden Apple that has been blessed by the Angels"));
                        item.setItemMeta(itemMeta);
                        player.getInventory().addItem(item);
rotund ravine
rotund ravine
#

Also show me that you’ve tried debugging it yourself and how you’ve tried for more help

pine island
#

oh.

rotund ravine
pine island
#

wait

#

i copied inspired my code from some forum post, and dint use Action.Right_Click oops

rotund ravine
#

Well there is an “or” there so it didn’t matter much

#

@pine island Tell me is this the same

#

“Angel’s apple” and “Angels apple”

pine island
#

oops

#

its late thats my excuse yeah

rotund ravine
#

😉

pine island
#

aight ill fix it tysm lmao <3

rotund ravine
pine island
#

its concerning if it works first time

#

i tend to check my spelling before i blame myself

summer scroll
#

How do I get the day number from Date? Like fot example, today is 25/11/2022, and I only want to get the 25, how can I do that?

vital yacht
summer scroll
vital yacht
#

No problem

hybrid spoke
somber hull
#

++blame

#

Damn

glossy prawn
#

hi there - anyone have a suggestion for loading a treasure chest in a random location? trying to revive an old plugin of mine, and running into some perf issues. looking for some inspiration 🙂 previously opted for a super naive approach of grabbing a location within a set of X/Y/Z ranges and checking the block above and below (essentially: above = air, below = not air), but this is too slow. wondering about better approaches, maybe someone has an idea

echo basalt
#

then add 1

#

or you can use your approach but make chunksnapshots n all

glossy prawn
# echo basalt just generate a random XZ and get the highest Y at

oh, TIL about that method. super rusty, been out of the game for over a decade 😅 . this seems good, but then it would always spawn on the surface. would be cool if it can spawn underground too. perhaps I can adopt the approach and just start at 0 and add one from there, should be fast enough I suppose

echo basalt
#

you can just make chunksnapshots and multithread it

#

:)

glossy prawn
wet breach
#

if anything, I would clamp the y value to an arbitrary range that most times doesn't contain air

glossy prawn
#

otherwise it could be lodged in random block that would have to be mined at random

wet breach
#

except people not finding it, however this is where I would probably introduce treasure maps that help lead to it

glossy prawn
wet breach
#

but if you really want to just spawn them in caves, I think caves are structures now in the game If I remember correctly

#

if that is true, could just use the structure api and thus will provide the y clamping range 🙂

glossy prawn
#

ah okay thanks I will look into this as well 🙂 between that and the idea of using chunksnapshots, i think one of them will work out nicely. thanks!

tender shard
#

caves are not structures

#

ancient cities, mineshafts, strongholds etc are structures. but normal caves are just created from the normal noise generators and stuff

tender shard
#

and if you don't find any, try another X/Z pair

tender shard
# glossy prawn hi there - anyone have a suggestion for loading a treasure chest in a random loc...

I'd do it like this

    private static final int MIN_X = -1024;
    private static final int MAX_X = 1024;
    private static final int MIN_Z = -1024;
    private static final int MAX_Z = 1024;
    
    private static final int MAX_TRIES = 10000; // After this many tries, give up
    
    public static Block getRandomPossibleChestLocation(World world) {
        List<Block> possibleLocations = new ArrayList<>();
        int tries = 0;
        while(possibleLocations.isEmpty() && tries < MAX_TRIES) {
            int randomX = ThreadLocalRandom.current().nextInt(MIN_X, MAX_X);
            int randomZ = ThreadLocalRandom.current().nextInt(MIN_Z, MAX_Z);
            int highestBlockYAt = world.getHighestBlockYAt(randomX, randomZ);
            int lowestBlock = world.getMinHeight();
            for(int y = lowestBlock; y <= highestBlockYAt; y++) {
                if(isPosibleLocation(world.getBlockAt(randomX, y, randomZ))) {
                    possibleLocations.add(world.getBlockAt(randomX, y, randomZ)));
                }
            }
            tries++;
        }
        return possibleLocations.isEmpty() ? null : possibleLocations.get(ThreadLocalRandom.current().nextInt(0, possibleLocations.size()));
    }

    private static boolean isPosibleLocation(Block block) {
        if(!block.getType().isAir()) return false; // Block above must be air
        if(!block.getRelative(BlockFace.UP).getType().isAir()) return false; // Chest block must be air too
        if(!block.getRelative(BlockFace.DOWN).getType().isSolid()) return false; // Block below must be solid
        return true; // All good
    }
#

except that I'd also fix the typo

hybrid spoke
tender shard
#

yes

#

otherwise the chest would always be at the lowest or highest free space

#

but I guess it should be random

wet breach
#

thanks for clarifying they are still not, but mineshafts however though could work

tender shard
#

I just checked the wiki, I thought maybe those crystal caves were structures

wet breach
#

that is what I was thinking

tender shard
#

but it seems like those also are not structures

#

funny that buried treasures are structures lol

#

I mean, they are only one block lol

wet breach
#

that is....interesting

tender shard
#

the reason is probably so that the maps can "locate" them using the structure finding thing

wet breach
#

yeah, but the structure finding thing is so horribly coded

tender shard
#

idk I havent looked at it lol

wet breach
#

I don't remember who it was but we were looking into how the game finds structures

#

and its very horrible and a source of lag

#

it does a search in a very inefficient manner

#

it has to do with how the game stores structures

tender shard
#

it does look a bit creative

wet breach
#

see the iterating is the part that is actually pointless

#

and where it causes it to bottleneck, and if they had just stored in the chunks the positions of the structure in that chunk, you wouldn't need to iterate

#

game knows ahead of time at generation where a structure is or is not, and can save it appropriately in the chunk file lol

echo granite
#

The eye cancer I got from the first look at this code just increases the longer I'm looking at it

fluid river
#

oh i missed spigotmc anniversary

#

w8 w8 w8 spigot is 21 11 12

ivory sleet
rough drift
#

I ran buildtools, how can I import NMS using maven?

eternal oxide
#

don;t unless there is no alternative

rough drift
#

Why would I use NMS if I didn't need to?

eternal oxide
#

So many do

#

They think it's the proper way to go

rough drift
#

Oh lol

#

Well nah I need it

eternal oxide
#

then depend on spigot not spigot-api

rough drift
#

Oh does it automatically install on my local maven repo?

eternal oxide
#

you will want to use remapped though

#

makes life so much easier

rough drift
#

jeff comes in clutch

#

The requested profiles [remapped] could not be activated or deactivated because they do not exist.

#

How do I even deal with that

hybrid spoke
#

by running buildtools

#

all described in there

rough drift
#

That error comes up when running buildtools

#

java -jar BuildTools.jar --rev latest --remapped

#

?

hybrid spoke
#

what if you try it with setting a version

rough drift
#

same error

eternal oxide
#

does BT continue to run?

rough drift
#

nah

#

it just dies

eternal oxide
#

if so, ignore the error

rough drift
eternal oxide
#

I put my --remapped before the version

rough drift
#

Trying that

#

cfrashes

#

crashes

eternal oxide
#

crash?

rough drift
#

yep

#

--remapped seems to crash

eternal oxide
#

mine %cmd% -jar BuildTools.jar --generate-source --generate-docs --remapped --output-dir .. --rev %Input%

#

simplified java -jar BuildTools.jar --remapped --rev 1.19.2

#

works fine

rough drift
#

doesn't work

eternal oxide
#

your BT old?

rough drift
#

just downloaded it

eternal oxide
#

I just downloaded latest BT and ran it, runs fine

rough drift
#

what java version are you using

#

I am using java 19

eternal oxide
#

jdk-17.0.1.12-hotspot

rough drift
#
java 19.0.1 2022-10-18
Java(TM) SE Runtime Environment (build 19.0.1+10-21)
Java HotSpot(TM) 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)
eternal oxide
#

I don't use 19 so can;t test with it

rough drift
#

downloaded it rn

#

running it

#

maybe I can try with an admin cmd

#

still doesn't work

eternal oxide
#

delete everything and start from scratch

rough drift
#

did

hybrid spoke
#

restart

rough drift
#

my pc?

eternal oxide
#

throw PC out window

hybrid spoke
#

^ that if restart doesnt work

rough drift
#

Nah I just bought it lmfao (well a year ago)

tardy delta
#

instructions unclear, jumped out of the window

hybrid spoke
#

so buy a new one. already too old

rough drift
#

brb restarting

#

back

#

not working

eternal oxide
#

?paste your bt log

undone axleBOT
rough drift
#

kk

#

1s

#

windows cmd is bsing

summer scroll
#

Hey, so I'm creating a playtime rewards system, and in the config you can define on what hour the player will receive the reward, and I'm struggling on how to get the next hour reward that the player can achieve, how can I do that?

hybrid spoke
#

or what exactly do you mean

summer scroll
hybrid spoke
#

for time tracking you would need a timer for every second or so anyways

summer scroll
#
rewards:
  1:
    rewards...
  4:
    rewards...
  and so on..
#

This is the example of the config.

#

Let's say the player just joined the server, how can I get the next available reward for playtime?

#

In this case I want to get the rewards from hour 1.

rough drift
summer scroll
#

Do I need to increment player's playtime by 1 hour till I found the next available reward?

hybrid spoke
#

if you want to frequently look if the player has reached X amount of playhours, you will want to cache the stuff anyways

#

so you probably will store it in a map with the hour as the key

eternal oxide
hybrid spoke
#

then you simply sort the map

#

then you know where the player with his current playtime is and what would be his next

tardy delta
#

TreeMap

summer scroll
#

Okay, that make sense.

hybrid spoke
summer scroll
#

I'll try it out.

#

thanks

tardy delta
#

if stuff only gets inserted when loading the file it doesnt matter anyways

hybrid spoke
#

it does

#

you will probably have to iterate multiple times over it

#

in most cases negligible but still

#

would rather use a linkedmap and sort them in

tardy delta
#

lol

undone kraken
#

does somebody know what this means? class file has wrong version 61.0, should be 52.0

wet breach
#

use the statistic of time played

#

it keeps track of how long they have been playing on the server overall 🙂

#

no need to store it or do anything fancy other then converting it from ticks

#

@summer scroll

#

since this is also relevant to you

vocal cloud
wet breach
undone kraken
#

thanks works now

copper scaffold
#

i make a plugin with Custom minecraft recipes and i have a crafting recipe where i put a water bottle in and then other stuff the water bottle should be after the crafting be empty

rotund ravine
echo granite
#

Hello, as my project is growing I started to suffer from the big constructors annoyance. I do use the builder pattern and adhere to SRP, but sometimes it's impossible as demonstrated by this command: https://pastebin.com/nvtZESCp
Should I use a DI framework to get rid of constructors that need boilerplate dependencies?