#help-development

1 messages · Page 1948 of 1

warm mica
#

and then simply have each item contain a listener or something

young knoll
#

What

warm mica
#

When done properly, you won't need many lines at the end to create it

young knoll
#

Just map an int to a consumer

#

The int being the slot

warm mica
#

That's what I said

young knoll
#

So what’s this player map

warm mica
#

You surely want it to work on a server with at least two players

young knoll
#

Why not map the view instead of a player

warm mica
#

This doesn't really matter

young knoll
#

Or at least a uuid, you shouldn’t use the entire player object as a key

warm mica
#

A hashmap works by using the hash of a object. It doesn't care whether you're passing a subclass or the exact type.

young knoll
#

Yes but it holds the object

#

Strongly

warm mica
#

And? You're removing it when the inventory gets closed

#

unless an exception occurrs, there's nothing wrong with it

young knoll
#

I suppose the close event should be called on disconnect

warm mica
#

It does

young knoll
warm mica
#

Otherwise it wouldn't be any better whether you're using an uuid or a HumanEntity

#

Especially as the HumanEntity instance is still of the type Player at the end

young knoll
#

I mean

#

Technically the hashcode method of a uuid is faster

warm mica
young knoll
#

But that isn’t really relevant

#

APIs exist for a reason, you should be scared of using them

#

And you can always take the initiative to figure out how they work

warm mica
young knoll
#

Gotta save them cpu cycles

warm mica
warm mica
lost matrix
young knoll
#

If everyone doesn’t have a common lib

#

Then it isn’t common

lost matrix
#

depends on the scope

#

for my plugins it contains common functions. Doesnt matter if others use it or not.

hasty prawn
#

7smile your common lib probably unlocks the secret to the damn universe

#

Mine is "hehe, item builber f_pepe_shy"

lost matrix
young knoll
#

We need one standardized lib to rule them all

#

Wait no there’s an XKCD for that

tall dragon
#

i had have an interesting question:

i have an configuration where you can configure stuff like
Minimal cost
Maximal cost
Max level

then my plugin will autimatically figure out what each level should cost. but i want to add another way you could configure this. this being manually like

Levels:
  1: 100
  2: 200
  3: 300
  etc etc...

how would i best go about doing this so that it would not break everything.

lost matrix
tall dragon
#

hmm thats actually a very interesting idea

young knoll
#

Crunch

tall dragon
young knoll
#

Crunch is meant to be the faster, but I’m sure it doesn’t matter that much

#

Unless you are doing it every tick or soemthing

lost matrix
#

Not if you calculate all costs at startup anyways ^^

young knoll
#

True

tall dragon
#

yea i can calculate all costs at startup

lost matrix
#

Didnt know crunch

warm mica
young knoll
lost matrix
#

Oh its from Redempt?

young knoll
#

Ye

warm mica
# young knoll

This is something different. Nobody will notice it, unless they're working with the code

young knoll
#

Sure but imagine if something already existed and you didn’t need to write one :p

#

Oh well, it’s a chance to learn

warm mica
#

With that thought we'd still be using C++ nowadays

tall dragon
#

wow crunch looks like it can do some interesting stuff

#

with performance in mind

lost matrix
warm mica
next stratus
#

@waxen plinth crunch 🥰

young knoll
#

Redempt makes some neat stuff

#

But he still smells

lost matrix
#

Back in the days we just Nashorned our way through math. expression...

next stratus
#

No!

quaint mantle
#

redempt is pretty cool

next stratus
#

Redempt doesn't smell!

#

Skript smells 🤮

lost matrix
#

Wait... is that too german?
Do you guys know what "Maggi" is?

next stratus
#

No lol

tall dragon
#

i think i do

lost matrix
#

XD fk

young knoll
#

Maggi

#

Isn’t that a name

tall dragon
#

and soup sometimes

lost matrix
tall dragon
#

were close

lost matrix
young knoll
#

Don’t mention nashorn to Choco

lost matrix
waxen plinth
#

Nashorn is so unbelievably slow

tall dragon
tall dragon
waxen plinth
#

I originally wrote crunch because gecko was trying to use nashorn for expression evaluation

#

And it was taking a full 10 seconds to do 2k evaluations

#

Ridiculously slow

young knoll
#

But can crunch do arbitrary exponents

lost matrix
waxen plinth
#

What do you mean

#

You mean like 2^3.1?

#

Or what

lost matrix
#

50 ^ PI

waxen plinth
#

Yes it can do that

young knoll
#

Sure

waxen plinth
#

You could literally just do 50^pi in crunch and it would work fine

young knoll
#

Oh, dangit now I can’t judge

waxen plinth
#

It's a very complete library

young knoll
#

What about arbitrary roots

waxen plinth
#

50^(1/7) lol

young knoll
#

You got me there

waxen plinth
#

And if there's something it doesn't have natively

#

You can define custom functions

lost matrix
#

But can it do complex arithmetic like (11 + 9j) / (4 - 5j)

waxen plinth
#

No it doesn't do complex numbers

#

Also EvalEx uses BigDecimal and Crunch uses doubles for everything

#

Crunch is specifically built to be ridiculously fast

waxen plinth
#

As in what did I do to make it fast?

lost matrix
#

Yes. I thought parsing expression using Dijkstra is as good as it gets.

young knoll
#

But what if I overflow a double

lost matrix
waxen plinth
#

Using dijkstra?

young knoll
#

D:

lost matrix
#

Dont overflow them

waxen plinth
#

Not familiar with that approach honestly

lost matrix
#

shunting yard algorithm

waxen plinth
#

Ah I see

#

Mine works a little differently

#

The first trick is that it uses a prefix tree to tokenize

young knoll
#

He has 100 workers in a foreign country that do the math on request

lost matrix
#

i mean... its basically just unwrapping the exp and working with a stack

waxen plinth
#

A prefix tree is very well-suited to finding any named tokens very quickly

lost matrix
waxen plinth
#

I reimplemented Double#parseDouble which is ~2x as fast as the standard library implementation

young knoll
#

Exactly

waxen plinth
#

And after creating the token list, this is how it reduces it:

#
  1. The token list is a linked list (custom implementation which gives access to the individual nodes)
#
  1. Creates a size 10 array of lists
#
  1. Iterates over the tokens, adding tokens to the list corresponding to their priority
#
  1. Iterates over the array of lists, getting and removing adjacent value tokens for each operator and then combining them into lazy Operation tokens
#

Through that process the entire expression is reduced to a single token

#

And it will also combine operators working only on literal values into just literal value

lost matrix
#

What do you mean by "token"

quaint mantle
waxen plinth
#

So for example it will combine 3+4 into 7

quaint mantle
#

float: 10.1249141491284918941

lost matrix
#

Ah i see

waxen plinth
#

A token represents either an operator or an operand

quaint mantle
waxen plinth
#

It can be a constant, a variable, an operator, a function name, a function argument list, or a lazy variable

lost matrix
#

How do you evaluate the priority?

waxen plinth
#

It puts them in the list in the array with the index being their priority

#

Then when you iterate they're already in order based on priority

#

I guess it's basically radixsort in that regard

#

But since it keeps references to the linked list nodes containing the operators rather than the operators themselves

young knoll
#

What if you have over 10 priorities

waxen plinth
#

It can get the adjacent value tokens from the linked list node, then remove them and set the token there to be the lazily-evaluated one

#

This is one of the very few use cases a linked list is well suited for

waxen plinth
lost matrix
#

Why do you combine value tokens into lazy operations instead of evaluating them on the spot?

young knoll
#

Wouldn’t deeply nested () qualify

waxen plinth
#

Because this is for compiling expressions

#

For example

#

1+x

#

You don't want to have to recompile this from a string every single time

lost matrix
#

Ah makes sense

#

yes yes

waxen plinth
#

You can evaluate the expression just once after it is compiled

#

But it's a hell of a lot faster to just hold onto the compiled expression and re-evaluate it

lost matrix
#

If you have different values for x. Get it

quaint mantle
#

be proud of me

waxen plinth
#

Good job

lost matrix
young knoll
#

I challenge you to make crunch faster in some aspect

#

By any degree

waxen plinth
#

I can do that

quaint mantle
#

use rust ^

waxen plinth
#

At this point I feel like the speed gains will be very minimal unless I use JNI or something

young knoll
#

Do it no balls

waxen plinth
#

Ok

young knoll
#

Mmm excellent now my stupid library can become even faster

#

And yet I still haven’t released anything with it

waxen plinth
#

What are you making with it

#

Like what's your library

young knoll
#

It’s for parsing effects and conditions for config files

waxen plinth
#

Ah nice

#

That's a good use case for it

young knoll
#

AdvancedEnchants style

lost matrix
waxen plinth
#

I kind of doubt it honestly

#

I really don't think expressions would ever get long enough for the overhead of parallelization to be worth it

#

And if they are then people are insane

lost matrix
#

Yeah

waxen plinth
#

And the other thing with that is that you would need to figure out what the two parenthesized expressions are first

#

At least, where they begin and end

young knoll
#

Idk this one is pretty big

#

%y% < 63

waxen plinth
#

So you would iterate over the string twice at least

#

And in doing so waste a lot of time that you could have just spent tokenizing

#

It might be possible to parallelize compiling the tokens after the string is tokenized but it would be very hard to avoid race conditions and the overhead would still probably not be worth it

lost matrix
waxen plinth
#

Yes

#

I use tabs

#

Deal with it

young knoll
#

Cancelled

lost matrix
#

Uh EvaluationEnvironment is stateful. Means Crunch is not thread safe on default because of the DEFAULT_EVALUATION_ENVIRONMENT.

young knoll
#

The only real way to do indentation is with /* indent */

lost matrix
#

Hm you could always just pass a new one i guess

waxen plinth
#

It literally says this in the readme lol

lost matrix
waxen plinth
#

And EvaluationEnvironment should only ever be modified prior to compiling any expressions

#

You could make copies and whatnot but there isn't really a better solution other than copy on write

#

Which I wouldn't want because speeeeeeeeed

lost matrix
#

I like this. Consider it stolen added to my useful libraries.

waxen plinth
#

:)

young knoll
#

Is it better to have one evaluation environment with a bunch of variables, or multiple smaller ones per use case

waxen plinth
#

Well any variables defined in the evaluation environment must be passed to the expression each time you call evaluate

young knoll
#

Ah okay

#

That answers that

waxen plinth
#

If you have a lot of them you should either use lazy variables or wrap the compiled expression with something that can supply only the variables that are needed

#

Lazy variables are kind of ideal for it though

waxen plinth
#

Yeah definitely use lazy variables for that

#

In one EvaluationEnvironment that has all of the variables you need as lazy variables

ancient jackal
waxen plinth
#

I did create a github gist that lets you use PlaceholderAPI placeholders in crunch expressions

lost matrix
#
    static {
        ENV.setVariableNames("%food%");
    }

I would rather extend EvaluationEnvironment with a class that takes a varargs parameter in its constructor.

#

And what is up with tabs and leaving out bodies?

        if (!(entity instanceof Player player))
            return false;

Google code style is dead 😦

waxen plinth
#

You shouldn't really be using an EvaluationEnvironment for this anyways

#

You especially should not be using a different one for every variable

#

That defeats the purpose

#

This is a good use case for lazy variables

#

You can define them like

#
env.addLazyVariable("%food%", () -> someMethodToGetFood())```
young knoll
waxen plinth
#

If you're gonna skip the braces you should inline the return in my opinion

#

But I still prefer leaving the braces

#

It should be this:

#
if (!condition) {
  return;
}```
#

But if you must leave the braces out then

#
if (!condition) return;```
young knoll
#

But so many extra bytes :p

#

What would be the method to do this without an evaluation environment

lost matrix
#

Hm im actually also writing conditions at the moment...

@Data
@EqualsAndHashCode(callSuper = true)
public class HeightCondition extends PlayerCondition {

  private int height = 100;
  private NumericComparison comparison = NumericComparison.AT_LEAST;
  ...

Maybe i should consider using crunch instead.

young knoll
#

What I’m currently doing

waxen plinth
#

Oh

waxen plinth
#

You'd just make it have a getter for its name and a DoubleSupplier

waxen plinth
#

This is a bit of a workaround to allow it to work for a given player, it's stateful and not thread-safe

#

But you probably don't really need it to be thread-safe

#

So this should work fine

#

Or an approach similar to it

#

Hell, you could just use PAPI instead of your own system

#

And do %player_hunger%

waxen plinth
#

Though it just evaluates to 0.0 or 1.0 since crunch only uses doubles

lost matrix
waxen plinth
#

How much faster could it be

#

Once compiled, crunch expressions are pretty insanely fast

olive lance
#

trying to remove a hashmap entry , check if it was null(existed) , and also get the value only thing I can think of is temporary variables

lost matrix
waxen plinth
#

Yeah just keep the value in a variable

lost matrix
#

Oh i see an error there

waxen plinth
# lost matrix

Oh so you mean the benefit is that it doesn't wrap them in lambdas?

#

I guess that would be a smidge faster

#

But the overhead of a method call is pretty miniscule

olive lance
#

How do you get a scheduled task by its id?

#

all results are getting id of the task

waxen plinth
#

Sounds like an xy problem

lost matrix
lost matrix
waxen plinth
#

^

#

lol

lost matrix
#

XD

olive lance
#

wait

#

public void cancelTask(int taskId);

#

this is ok to use?

waxen plinth
#

Why would it not be

olive lance
#

well idk

#

said it was a design issue

#

i mean youre prob not wrong

waxen plinth
#

If you need to get a task by ID then that's probably a design issue

#

If you need to cancel one by ID that makes sense

olive lance
#

ok yeah thats what i was doing it for

#

didnt realize that was a thing

waxen plinth
#

Yeah that's why you should always ask for help with your overall goal rather than your attempted solution at it

#

?xy

undone axleBOT
olive lance
#

you can tell me if theres a design issue pretty short

#

basically adding delays to teleports

waxen plinth
#

WHY are people still using BukkitRunnable

#

🌚

olive lance
#

all the forum posts urge people to use it

waxen plinth
#
Bukkit.getScheduler().runTaskLater(plugin, () -> {
  // Do stuff
}, ticks);```
#

Much cleaner

olive lance
#

Yeah it is but it hurts my brain to read

waxen plinth
#

Why

olive lance
#

idk the arrow just makes no sense and the empty parenthesis

waxen plinth
#

Then read up on lambdas

#

They are pretty simple and extremely useful

olive lance
#

Yeah probably are

young knoll
#

So basically I just want a single evaluation environment with a bunch of lazy variables

waxen plinth
#

Right

young knoll
#

Makes sense, also means I can condense all my numeric conditions into one

olive lance
#

does getScheduler need to be called by the main class

young knoll
#

I could technically do the other ones too, but users might get confused by something like %on_ground% = 1

olive lance
#

Ok coo appreciate it

waxen plinth
young knoll
#

Oh right

#

Crunch accepts true and false

waxen plinth
#

If %on_ground% is already either a 0 or a 1 then they wouldn't have to

young knoll
#

That too

#

Shhh

waxen plinth
#

Well true and false are just constants mapped to 1 and 0

young knoll
#

I can Boolean I swear

waxen plinth
#

So now your booleans can be 64 bits wide instead of 8 😁

olive lance
young knoll
#

Yeah this means I can just use a single condition, so users could do something like %on_ground% & %y% < 63

waxen plinth
#

Yep

young knoll
#

I wish someone told me that before I wrote them all :p

#

Oh well

#

Oh lazy variables didn’t exist when I made this

waxen plinth
#

Yeah lol

young knoll
#

That also makes sense

waxen plinth
#

They are a very new addition

#

I noticed that a lot of people were trying to do this sort of thing

#

And regular variables are not really good for that

#

So I added lazy variables

#

I mean they're essentially just zero-arg functions that don't require the () to be called in the expression but they're really useful

#

%on_ground% & %y% < 63 is much cleaner than %on_ground%() & %y%() < 63

young knoll
#

Yeah

#

And with that snipped you posted I can also support papi variables

waxen plinth
#

👌

young knoll
#

I’ll probably still do some basic ones myself though, no sense requiring papi if I just want to use %health%

waxen plinth
#

Yeah and papi will almost definitely be much slower

#

Because it has to fetch it as a string and then parse the string to a double

young knoll
#

Also only applies to players

#

Although that means I probably shouldn’t use %xxx% for mine to avoid clashing with papi ones

waxen plinth
#

You could always do something like $on_ground

young knoll
#

Yeah that seems good

lost matrix
#

Does the Value class retain whitespaces?

waxen plinth
#

No, why would it?

#

Whitespace is discarded when the expression is compiled

#

I mean, you could define a variable, function, or lazy variable with a space in its name and that would be valid

#

But otherwise it's ignored

lost matrix
#

Sure. But i would like to present the user with "x < 100 & x > 50" if he wrote it that way. So i need to keep track of the original String myself.

young knoll
#

Will a Boolean expression always evaluate to exactly 0.0 or 1.0 or is it subject to precision jank

waxen plinth
#

CompiledExpressions have a toString() implementation that will spit out a string that you can use to compile the same expression again, but it's not particularly readable

waxen plinth
young knoll
#

👍

waxen plinth
#

You guys should join my support discord and ask for help there to make it less dead lol

lethal coral
#

How can I get access to a private method within a class that's within a class?

young knoll
#

Inner class?

lethal coral
#

indeed

lost matrix
young knoll
#

I assumed they meant reflection

lethal coral
lost matrix
#

Is the class static? Is the class private?

lethal coral
#

the class is private

#

and the method is protected

lost matrix
#

Is it static?

lethal coral
#

no

lost matrix
#

What? Why would someone use protected in an inner class?

lethal coral
#

I'm trying to make an evoker cast a spell

#

this is from nms

young knoll
#

Could you get the class with Class.forName?

lost matrix
lethal coral
#

no

#

there's only one static thing in the entityevoker class

young knoll
#

The API has a setSpell method

lethal coral
#

that is not the same thing

young knoll
#

No idea if that causes it to fire instantly though

lethal coral
#

that sets its active spell

#

meaning the one that will be triggered next

young knoll
#

Ah, it doesn’t trigger it though

lethal coral
#

nope

#

but I found the method

#

it's just... hard to get to

young knoll
#

I mean

#

Maybe the API could expose this

lethal coral
#

wdym

young knoll
#

Something like Spellcaster#castSpell

lethal coral
#

would be nice

#

I kinda need to do it now though 🚎

young knoll
#

I can look at it sometime

#

Until then idk, my only idea is to get the inner class using Class.forName and then go from there

lethal coral
#

well

#

I'm like 40% sure that I have it, the problem is that the method I'm using doesn't use the object I have for the evoker, it just uses the class itself so it obviously won't be able to cast from that evoker

young knoll
#

What does the code look like

lethal coral
#
            EntityEvoker entityEvoker = (EntityEvoker) evoker.getSingle(event);
            entityEvoker.setSpell(spel);

            Class<?> innerClass = EntityEvoker.class.getDeclaredClasses()[0];
            Constructor<?> constructor = innerClass.getDeclaredConstructors()[1];
            constructor.setAccessible(true);
            try {
                Method m = innerClass.getDeclaredMethod("j");
                m.setAccessible(true);
                m.invoke(null);
            } catch (Exception e) {
                e.printStackTrace();
            }
#

I feel like that's wrong in every way possible

#

🚎

young knoll
#

You gotta replace that null with an instance of said class

#

Which I assume you can somehow get from the evoker

waxen plinth
#

You can do Class#getDeclaredClasses

#

Which will get all internal classes of a given class

quaint mantle
#

Who know how to get advancement type on 1.18.1?

waxen plinth
#

Oh you already are lol

waxen plinth
lethal coral
waxen plinth
#

Oh

#

m.invoke(null) invokes the method in a static context

#

To invoke it on a specific object you have to pass that object

lethal coral
#

so it would be m.invoke(entityEvoker)

young knoll
#

What’s the inner class here

lethal coral
waxen plinth
#

Well if you're invoking a method on the inner class

young knoll
#

Yeah AI goal

waxen plinth
#

Then presumably it would need an instance of the inner class

lethal coral
young knoll
#

So you need to get the instance of that goal from the evoker

lethal coral
#

this is hurting my brain

ancient jackal
#

first time using a hashmap and no clue why it's returning null

So HashMap<UUID, Long> hm is a private static in my main, with a getter and setter

I have 2 listeners, one for players joining and one for players quitting
On join, it gets the hashmap getHm(), puts the UUID as key and the current system time millis as Long. Then it sets the hm setHm(newHm) with the added key and value
On leave, it uses the player's UUID to get system time millis for getting the session playtime then removes the key and value

why would it return null if the player's UUID doesn't change?

The code specifically looks like this
On join:

        HashMap<UUID, Long> hm = TrackPlaytime.getHm();
        Long joinTime = System.currentTimeMillis();
        hm.put(event.getPlayer().getUniqueId(), joinTime);
        TrackPlaytime.setHm(hm);```
On leave:
```java
        HashMap<UUID, Long> hm = TrackPlaytime.getHm();
        long timeJoined = hm.get(player.getUniqueId());
        long sessionTime = System.currentTimeMillis() - timeJoined;
        ptd.addPlaytime(sessionTime);
        db.addToDatabase(ptd);
        hm.remove(player.getUniqueId());```
The getter and setter:
```java
    public static HashMap<UUID, Long> getHm() {
        return hm;
    }

    public static void setHm(HashMap<UUID, Long> hashy) {
        hm = hashy;
    }```
I did read the documentation and #get(K) is supposed to return the value of the key
sly trout
#

Is there a channel for advertising our server ?

quaint mantle
#

Who know how to get advancement type on 1.18.1? 😶

lethal coral
sly trout
#

K

young knoll
quaint mantle
#

Yes

young knoll
#

What do you mean by type

quaint mantle
#

(Normal,goal,challenge)

young knoll
#

Ah

#

It does not appear the API exposes that

#

So you may be looking at NMS

quaint mantle
#

Bruh, ok

sly trout
#

Lol

young knoll
#

I can look at adding that to the API

quaint mantle
#

Ok

lethal coral
#

does this look right

young knoll
#

That’s not the inner class

#

But yes

lethal coral
#

yes I know

#

hence the name outerClass

young knoll
#

You already have an EntityEvoker instance

#

Can’t you just use getClass on that

lethal coral
#

I could

#

👍

lethal coral
#

Here's my updated code:

            EntityEvoker entityEvoker = (EntityEvoker) evoker.getSingle(event);
            entityEvoker.setSpell(spel);

            Class<?> outerClass = entityEvoker.getClass();
            Class<?> innerclass = outerClass.getDeclaredClasses()[1];
            try {
                Method m = innerclass.getMethod("j");
                m.setAccessible(true);
                m.in
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            }
waxen plinth
young knoll
lethal coral
#

yes

#

😩

quaint mantle
#

um how to add net.minecraft.server? it says not found

lethal coral
quaint mantle
#

this is what?

lethal coral
quaint mantle
#

oh thx

#

?bt

undone axleBOT
minor otter
#

Dealing with tripwires, how would I stop breaking a tripwire from changing the state of tripwires near it/connected to it

quaint mantle
#

?learnjava

undone axleBOT
ancient jackal
#

I did read the documentation and #get(K) is supposed to return the value of the key

#

I set a joining player's UUID as a key with long system time in millis as value, and when they leave the server it uses their UUID to get the time they joined

#

getting the value with their UUID key returns null

eternal oxide
#

Then you didn;t add the K/V or you are referencing a different map instance

ancient jackal
#

I used a getter to get a static hashmap holding all of the keys and values of players and when they joined respectively, and a setter to set the hashmap to that but with another k/v put into it when someone joins

#

the code segments are there

lethal coral
#

Nvm, he didn't have a target set

eternal oxide
#

My guess, you are replacing teh map when a player joins so it only ever holds one player

ancient jackal
#

this is what happens when a palyer joins java HashMap<UUID, Long> hm = TrackPlaytime.getHm(); Long joinTime = System.currentTimeMillis(); hm.put(event.getPlayer().getUniqueId(), joinTime); TrackPlaytime.setHm(hm);

eternal oxide
#

yes, you are replacing the map instance

quaint mantle
#

lol

eternal oxide
#

Your Map is STATIC so just get values, don;t get teh whole Map

quaint mantle
#

if your map is static

#

you can access it from anywhere

#

why bother making a getter

ancient jackal
#

it's 12 am and I'm very tired, I knew that

#

mb

#

thanks

quaint mantle
#

?sleep

#

conclure should have add that command

ancient jackal
#

yes goodnight

quaint mantle
#

😴

#

goodnight

#

actually mine right now is like 10pm or so

ancient jackal
#

you should sleep soon too

quaint mantle
#

yeah thanks for reminding

#

i should finish the readme first

#

then ill just gonna go and sleep for 2 hours

ancient jackal
#

me too

#

just one more...

quaint mantle
#

bruh nms so big maybe it has some docs? 😶

eternal oxide
#

no

quaint mantle
#

uh

quaint mantle
ancient jackal
#

so I figured out the problem why the hashmap was always null

#

2 hours later at 1 am

#

I never registered the playerJoin event

summer scroll
#

How can I check If an entity is out of player's render/view distance?

granite burrow
#

Hey, how can I prevent a mob from despawning?

ancient jackal
summer scroll
#

getNearbyEntities method is not really good If I use it every second for example and to all players, correct?

golden kelp
#

how to build a structure from a schematic file?

blazing scarab
manic furnace
#

When i want to make my plugin work from like 1.13-1.18, which API-version do I have to set?

spiral light
#

lowest

manic furnace
#

ok thanks

limber dust
#

anyone know a fix? been at this for hours

visual tide
#

?paste the code where the error occurs

undone axleBOT
limber dust
#

for better example

visual tide
#

well

summer scroll
visual tide
#

i gotta implement hte methods

#

alt+enter with cursor on pig and click "implement methods"

#

and

#

please

limber dust
#

theres nothing to implement

visual tide
#

dont name youre classes lowercase

limber dust
#

oh i know how to name my classes

#

i'm just done with this one

#

it implements nothing

#

its that the class i need to implement clashes however i can't find any resolution to this issue

#

as it is with EntityInsentient and EntityLiving having both methods called x()

#

remapping the jar changes x() to getLeash

summer scroll
#

Alright, thanks for that.

hollow bluff
summer scroll
# blazing scarab yes

Basically I want to do something If an entity goes out of player's perspective or unloaded from player's perspective, so what would you suggest on how I do that?

quaint mantle
#

raytrace

#

😃

ancient jackal
summer scroll
# ancient jackal The way you do it really depends on what you’re doing

I want to destroy an armor stand that was spawned with packets, so my problem right now Is I have an armor stand that rides player, and when the other player who have armor stand goes out of vision (unloaded) from another players, the armor stand will be dismounted only on the another players perspective.

#

Let's say P1 and P2, P1 has armor stand that rides him and P2 can see the armor stand mounting on P1, and P1 goes out of P2 vision (unloaded) and the armor stand is dismounted on P2 perspective but not on P1 perspeective.

ancient jackal
summer scroll
#

It looked dismounted on P2.

#

There are several ways, whether mounted it back on P2 or destroy the armor stand and equip it on P2 perspective.

#

Left P1, Right P2

ancient jackal
#

Well you can check for nearby entities that isn’t the player it’s mounted on and if any other player entity is there then do nothing yet

summer scroll
#

What do you mean? I don't understand.

ancient jackal
#

#getNearbyEntities()

summer scroll
ancient jackal
#

You might be looking at NMS

summer scroll
#

I'm using NMS

#

As I say I spawned the armor stand using packets

summer scroll
#

@ancient jackal can you tell me how to get the exact distance with the maximum view distance?

#

For the getNearbyEntities method.

golden kelp
#

How can I spawn 12 villagers which ride each other (like stacked)

slim shell
#

so I am trying to broadcast this

Bukkit.broadcast(Component.text("updating angles with aspose to " + Math.toDegrees(armorStandPose.x).toFloat() + Math.toDegrees(armorStandPose.y).toFloat() + Math.toDegrees(armorStandPose.z).toFloat()))

I am not getting any syntax errors. But on build I am getting these errors:

Type mismatch: inferred type is TextComponent but String was expected
No value passed for parameter 'p1'
eternal night
#

are you compiling against paper api ?

#

is your server also running paper ?

#

spigot does not offer first-level support for adventure

dusk flicker
#

Don't you need to use broadcastMessage

#

Iirc broadcast requires a perm node

golden kelp
#

can u make an entity ride another entity ( i want to make a villager ride another villager )

golden kelp
#

ty

#

how to spawn 8 entities around the player? like 1 in each direction

sacred mountain
#

hey i can't find why my plugin isnt loading, it may be because of the new config system im trying.

java.lang.NullPointerException: null
        at com.clonkc.vlands.kitpvp.Fireball.FireballMain.<init>(FireballMain.java:28) ~[?:?]
        at com.clonkc.vlands.kitpvp.Main.registerListeners(Main.java:32) ~[?:?]
        at com.clonkc.vlands.kitpvp.Main.onEnable(Main.java:19) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot.jar:git-Spigot-21fe707-741a1bd]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [spigot.jar:git-Spigot-21fe707-741a1bd]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot.jar:git-Spigot-21fe707-741a1bd]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [spigot.jar:git-Spigot-21fe707-741a1bd]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [spigot.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:414) [spigot.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:378) [spigot.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:333) [spigot.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:263) [spigot.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:525) [spigot.jar:git-Spigot-21fe707-741a1bd]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_311] ```
#

do u need my class

#

i can send it in paste bin

spiral light
golden kelp
sacred mountain
#

why does everyone have to comment on that

#

i have my reasons and i need help with this

quiet ice
#

Because it has smart NPEs, it'll tell you exactly what is null absolutely no need to ask anyone about it

sacred mountain
#

well, thats useful

full elbow
#

wait

sacred mountain
#

but i still need to know

full elbow
#

what is the best coding website?

golden kelp
#

depends on what u are coding

sacred mountain
#

get an IDE

quiet ice
#

Well, what is com.clonkc.vlands.kitpvp.Fireball.FireballMain.<init>(FireballMain.java:28) ~[?:?]?

full elbow
#

i already

quiet ice
midnight shore
#

Guys how can i get a Base64 custom head in an ItemStack?

#

I want to use this code: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzhmZjQ3M2JkNTJiNGRiMmMwNmYxYWM4N2ZlMTM2N2JjZTc1NzRmYWMzMzBmZmFjNzk1NjIyOWY4MmVmYmExIn19fQ==

naive bolt
#

anyone know where i can get a json list of every 1.8 sound in minecraft so i can pick a random one when a block is broken

young knoll
#

Get a random entry from the sounds enum

naive bolt
#

how do i do that

#

i want it to be version dependent because obvs cant run a 1.18 sound on a 1.15 server

young knoll
#

Sound.values will get you an array

#

Then just get a random array element

limber dust
#

anyone know of a way to assign a passive mob the ATTACK_DAMAGE attribute, using the getAttribute() method will return null as a passive mob doesn't naturally have the attack attribute but any other way of assigning one?

young knoll
#

NMS

limber dust
#

im using nms

young knoll
#

Probably have to add the attribute to them

limber dust
#

easier said then done

young knoll
#

Exactly

young knoll
#

You are using nms, you’re kinda on your own

limber dust
#

i know

young knoll
#

See if the forums have anything

limber dust
#

already checked

young knoll
limber dust
#

i ask here last if i can't find anything anywhere

#

there are methods for older versions like 1.16 and 15 but all those methods that i've tested don't work on 1.18

midnight shore
ivory sleet
midnight shore
#

oh ok

tardy delta
#

👀

midnight shore
#

I can't access the createPlayerProfile method... What server do i need? I tried Bukkit# and Server# but nothing shows up

young knoll
#

Latest

midnight shore
quaint mantle
#

playerprofile is for 1.18

#

at least it was added in 1.18

young knoll
#

Latest 1.18 at that

midnight shore
#

I'm in 1.17

quaint mantle
#

well

#

nms momento

young knoll
#

Then you don’t have it

sacred mountain
#

anyone know why this is happening? i ran it through a yaml validator and its fine

org.bukkit.configuration.InvalidConfigurationException: mapping values are not allowed here
 in 'string', line 3, column 12:
    goldenheads:```

my config:

```goldenheads:
  cooldown-msg: "&cGolden Heads are on cooldown for &6%timeleft% &cseconds"
  effects:
    - "ABSORPTION:3:120"
    - "REGENERATION:3:8"
  item-lore:
    - "first line"
    - "second line"
    - "third line"
  item-name: "&bHello"
  wrong-usage-msg: "&aUse &e&lRIGHT_CLICK &ato consume!"
throwablefireballs:
  blast-radius: 4
  cooldown-msg: "&cFireballs are on cooldown for &6%timeleft% &cseconds"
  damage-multiplier: 1
  fireball-speed-multiplier: 1
  item-lore:
    - "first line"
    - "second line"
    - "third-line"
  item-name: "&bWorld"
  wrong-usage-msg: "&aUse &e&lRIGHT_CLICK &ato throw!"
quaint mantle
#

?paste

undone axleBOT
sacred mountain
quaint mantle
#

it is valid as it seems

sacred mountain
#

yea so i have no clue why

quaint mantle
#

might be snakeyaml error

sturdy ivy
#

Is there a way to get material ID in 1.18?

quaint mantle
#

xseries

#

if you wanna say that id is the numbers

tardy delta
#

maybe the : ? "ABSORPTION:3:120"

sacred mountain
#

its a string placeholder

tardy delta
#

it should be a string

sacred mountain
#

and im not doing anything with it yet

sturdy ivy
quaint mantle
#

how could it affect the yaml

#

it couldnt

sacred mountain
#

yea it wont

young knoll
#

A utility to deal with legacy materials

quaint mantle
#

i saw multiple plugins done it

quaint mantle
young knoll
#

Numeric IDs are dead, don’t use them

midnight shore
#

IT WORKS! TY

quaint mantle
#

gg

#

but what did you ask

sacred mountain
#

anyone know why my yaml is invalid then?

quaint mantle
sacred mountain
#

not sure what u mean

#

how would i fix that

young knoll
#

Your error says goldenheads is line 3

tardy delta
#

have you tried turning it off and back on again?

young knoll
#

What are lines 1 and 2

quaint mantle
#

wait

sacred mountain
quaint mantle
#

post all of ur yaml

#

it might not help but just want to make sure

sacred mountain
#

i updated it, ill send the new one

  cooldown-msg: "&cGolden Heads are on cooldown for &6%timeleft% &cseconds"
  effects:
    - ABSORPTION:3:120
    - REGENERATION:3:8
  item-lore:
    - "first line"
    - "second line"
    - "third line"
  item-name: "&bHello"
  wrong-usage-msg: "&aUse &e&lRIGHT_CLICK &ato consume!"

throwablefireballs:
  blast-radius: 4
  cooldown-msg: "&cFireballs are on cooldown for &6%timeleft% &cseconds"
  damage-multiplier: 1
  fireball-speed-multiplier: 1
  item-lore:
    - "first line"
    - "second line"
    - "third-line"
  item-name: "&bWorld"
  wrong-usage-msg: "&aUse &e&lRIGHT_CLICK &ato throw!"
#

tjats it currerntly

quaint mantle
#

okay

#

then check if it still throws the error

young knoll
#

Make sure the file in your server is up to date

sacred mountain
quaint mantle
#

wait i think server.pro and other host is kinda "illegal" right

#

cause we can download the spigot jar/minecraft jar through their files

#

lol

sturdy ivy
#

But how I get material ID in 1.18 of 1.8 material?

quaint mantle
#

use xseries

tardy delta
quaint mantle
#

or use multiple module

#

to handle multi ver

young knoll
#

Or stop supporting legacy

#

:3

quaint mantle
sacred mountain
#

i know why, my default config was different from the one stored in the server files. It doesnt regenerate if it its invalid

#

i might make a util for that

quaint mantle
#

imagine you didnt know that 😒

sacred mountain
quaint mantle
#

you can use the update config

sacred mountain
#

o oka

quaint mantle
#

from @tender shard

#

alex go give him the link

#

im too lazy to find it

#

lol

sacred mountain
#

lol ok

young knoll
#

But does it heck comments

quaint mantle
#

basically how they work was that they have the config-ver or something in their config, and each startup they check if the config-ver is the same as the config-ver they have

#

if they arent

#

they will rename the file to old_config.yml

#

then generate new one

tardy delta
#

could use that for my lang file

quaint mantle
#

instead of removing that old config then generate new one

tardy delta
#

however it just loops through the values so i wont need it

quaint mantle
#

renaming it to oldconfig to help server owners to transfer any important values from the old config to the new config if they need to

#

@sacred mountain

sacred mountain
#

mk

young knoll
#

I think redlib handles it without yeeting the old one

quaint mantle
#

redlib op but no toml support

#

sadge

tiny mural
#

How to cancel player login?

sacred mountain
#

whitelist the server

tiny mural
#

Isn't there an event for such things?

sacred mountain
#

i have a weird problem where knockback lags from the damage

#

idk how to explain

#

the entities take damage first, and then take kb a short bit later

#

and i have no idea why

#

anyone?

#

import com.clonkc.vlands.kitpvp.Main;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.plugin.Plugin;

public class DamageHandler implements Listener {

    Plugin plugin = Main.getPlugin(Main.class);

    public DamageHandler(Main main) {

    }

    int explosionmultiplier = plugin.getConfig().getInt("throwablefireballs.damage-multiplier");
    double localradius = plugin.getConfig().getInt("throwablefireballs.blast-radius");

    @EventHandler (priority = EventPriority.HIGHEST)
    public void onExplode(EntityDamageByEntityEvent e) {
        if (e.getDamager().getType().equals(EntityType.FIREBALL) && e.getEntityType().equals(EntityType.PLAYER)) {
            double d = e.getEntity().getLocation().distanceSquared(e.getDamager().getLocation());
            if (d <= 2.0D) {
                e.setDamage(16.0D);
            } else {
                e.setDamage(12.0D);
            }

            for (Entity entity : e.getEntity().getNearbyEntities(this.localradius, this.localradius, this.localradius)) {
                if (entity instanceof LivingEntity) {
                    LivingEntity le = (LivingEntity) entity;
                    double dist = e.getEntity().getLocation().distanceSquared(le.getLocation());
                    if (dist <= 2.0D) {
                        e.setDamage(18.0D * explosionmultiplier);
                    } else {
                        e.setDamage(14.0D * explosionmultiplier);
                    }
                }
            }
        }

    }
}
quaint mantle
#

lag

#

it just lag

sacred mountain
#

no its not lag

quaint mantle
#

pure server lag

sacred mountain
#

the server is fine

quaint mantle
#

you are lag

sacred mountain
#

its legit running on my pc

#

bruh

quaint mantle
#

well

sacred mountain
#

i have 1 ping

quaint mantle
#

if they are running on your pc

#

most of the times that is lag

#

i wont write a wall of text here to explain why it lag

#

but basically

sturdy ivy
#

Any thoughts?

        Caused by: java.util.NoSuchElementException: No value present
        at java.util.Optional.get(Optional.java:143) ~[?:?]
        at com.modnmetl.virtualrealty.commands.test.TestCommand.onCommand(TestCommand.java:35) ~[virtualrealty-2.0.0.jar:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        ... 21 more

Input: /test 2:0

XMaterial.matchXMaterial(Integer.parseInt(args[0].split(":")[0]), Byte.parseByte(args[0].split(":")[1])).get().parseMaterial()
quaint mantle
#

your pc are not good enough to run a server, even though it is 20 tps, it still lag

quaint mantle
#

go use some real servers to run servers

#

less ram = lag

#

but more ram != less lag

sacred mountain
#

i know as in

#

it usually runs fine

#

and ghast fireballs work

#

like from the ghasts

#

this is pretty much the same thing so idk why its happening

quaint mantle
#

wait

#

send me your cpu

tardy delta
visual tide
tardy delta
#

^^

sturdy ivy
#

But why It can't find one? Its grass

#

lol

visual tide
#

¯_(ツ)_/¯

#

matchXMaterial's fault

quaint mantle
#

what are you trying to get

#

grass block or what

quiet ice
quaint mantle
#

geol is typing

sacred mountain
#

took a while to find it

#

its just me online

#

and its a flat world

quaint mantle
#

well i guess i7 should be enough to handle at least 1 player then

sturdy ivy
quaint mantle
#

go use grass block

#

instead of grass

#

iirc

quiet ice
#

yeah, that is a common beginner error

sturdy ivy
sacred mountain
quaint mantle
#

no i did not

quaint mantle
sacred mountain
#

setting the damage of an explosion shouldnt take a long time right

sturdy ivy
#

I want to get it thorugh material ID

sturdy ivy
#

But I don't want to..

quiet ice
#

Since when does parseByte return an Optional?

quaint mantle
#

they are still gonna work

quiet ice
#

ah nvm, confused some stuff

sturdy ivy
tardy delta
#

xd

sturdy ivy
#

I dont have choice

tardy delta
#

looks weird too that method that call

quaint mantle
#

hey

#

may i ask

#

what are you trying to do

#

because i suspect an x y problem

quiet ice
#

Would it be possible to simply trigger legacy mode?

quaint mantle
#

cant even read

sturdy ivy
#

On the bottom

hollow bluff
#

?paste it bro

undone axleBOT
sturdy ivy
quaint mantle
#

wait

#

you have nitro

#

noooooo

sturdy ivy
#

?

quaint mantle
#

nah dont mind it

sacred mountain
#

im really confused now

#

so basically

#

i added some code comments and compiled the plugin

#

and now it works

#

huh

quaint mantle
#

well

#

uhhhh

sacred mountain
#

like i legit changed nothing

quaint mantle
#

idk

#

did you

sacred mountain
#

well at least it works now

quaint mantle
#

use anything

#

while running the server

sacred mountain
#

wym by use anything

quaint mantle
#

like only the server with mc or something else too?

sacred mountain
#

nope, i didnt change anything

quiet ice
#

(i. e. accidental dos)

quaint mantle
#

well thats could just be temporary lag

#

by something

sacred mountain
#

yeah well thanks anyways :) at least its fixed now

red sedge
#

how can i get the latest accessible inventory slot

tardy delta
#

can i cast a Object[] to String[]?
like this

#

and if only one arg is passed in will it be a new String[1]

sacred mountain
#

anyone know how to print colors to the console?

tardy delta
#

Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "yes")

#

ChatColor#translateAlternateColors is smth too

#

it works on the windows commandprompt

chilly haven
#

player.sendMessage("You can't enable your pvptimer for another " + (10000 - (System.currentTimeMillis() - cooldown.get(player.getUniqueId()))) + " seconds!");
Is there anyway to convert this to seconds

sacred mountain
#

would this work


import org.bukkit.Bukkit;

public class Logger {
    public static void log(String msg) {
        msg = ColorUtil.translateColorCodes("&6[LOG]&r " + msg);
        Bukkit.getConsoleSender().sendMessage(msg);
    }

    public static void debug(String msg) {
        log("&6[DEBUG]&r" + msg);
    }
}```
quiet ice
sacred mountain
#

just want to make a quick util so ican use it everywhere

chilly haven
#

math is hard

quiet ice
#

I s = 1000 ms

red sedge
#

thats like... 6th grade math...

#

if you stretch it

quiet ice
#

Nah, that is 3rd grade math

#

Okay perhaps not as these are pretty large numbers, but the basics behind it are 3rd grade

red sedge
#

yeah idk how america does stuff so i just went with what would be expected from america

dusk flicker
#

we arent that stupid

quaint mantle
#

without syntax highlight i cant even see the code

dusk flicker
#

well some are

red sedge
dusk flicker
#

not most

#

SOME

tardy delta
dusk flicker
#

personally asia is my favorite country /j

red sedge
#

asia mm

#

amazing country am I right

tardy delta
#

is asia a country?

#

🤔

quiet ice
#

No, but paris is one

tardy delta
#

ah yes

quiet ice
#

There's paris and the rest of france

#

Idk what asia is though

quaint mantle
spare prism
#

Why?

java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class net.md_5.bungee.config.Configuration (java.util.ArrayList is in module java.base of loader 'bootstrap'; net.md_5.bungee.config.Configuration is in unnamed module of loader 'app')```

`dataConfig.set("PlayerData." + uuid + ".Punishments.Ban.Initiator", banPunishment.getInitiator());`

PlayerData:
71cd065e-3980-4f06-8da6-769311af1132:
Punishments:
Mute: []
Ban: []
UltraBan: []
IPBan: []
Warns: []

red sedge
red sedge
dusk flicker
#

tf is an ultra ban

#

but the error basically tells you exactly what yo uneed to know

red sedge
red sedge
#

triple ban

spare prism
#

I don't cast anything there

quiet ice
#

it do be interesting that it is doing an implicit cast

#

What is the whole stacktrace?

undone axleBOT
spare prism
#

?paste

quiet ice
#

And what is the datatype of .getInitiator()?

spare prism
quiet ice
#

Ah

#

?stash

undone axleBOT
quiet ice
#

I think I know why it is happening, but I cannot really put it in words

spare prism
#

It's BungeeCord btw

quaint mantle
#

wtf is the convention

#

i cant read it

#

the fu-

quiet ice
#

Ah, ban is a list

dusk flicker
#

oh dear fuck

quiet ice
#

but it must be a configuration section

#

Which it isn't

spare prism
#

how can I

#

using Bungee API

quiet ice
#

Declare it is a config section and not as an array

#

I.e. instead of

PlayerData:
  71cd065e-3980-4f06-8da6-769311af1132:
    Punishments:
      Mute: []
      Ban: []
      UltraBan: []
      IPBan: []
      Warns: []

you'd have

PlayerData:
  71cd065e-3980-4f06-8da6-769311af1132:
    Punishments:
      Mute: []
      Ban:
      UltraBan: []
      IPBan: []
      Warns: []
spare prism
#

I tried this

#
    @Override
    public void registerPlayer(ProxiedPlayer proxiedPlayer) {
        UUID uuid = proxiedPlayer.getUniqueId();

        dataConfig.set("PlayerData." + uuid.toString() + ".Punishments.Mute", new Configuration[0]);
        dataConfig.set("PlayerData." + uuid.toString() + ".Punishments.Ban", new Configuration[0]);
        dataConfig.set("PlayerData." + uuid.toString() + ".Punishments.UltraBan", new Configuration[0]);
        dataConfig.set("PlayerData." + uuid.toString() + ".Punishments.IPBan", new Configuration[0]);
        dataConfig.set("PlayerData." + uuid.toString() + ".Punishments.Warns", new Configuration[0]);
        saveConfigFiles();
    }
quiet ice
#

Basically remove dataConfig.set("PlayerData." + uuid.toString() + ".Punishments.Ban", new Configuration[0]);

#

That declares it as an array, not as a section

spare prism
#

How can I declare that as an empty config section?

quiet ice
#

Which means that key-value mappings can be specified

spare prism
#

maybe to put there an empty map?

#

cause in Bukkit API I do it by new ConfigurationSection[0]

quiet ice
#

That shouldn't work either

#

It is probably best to just not declare it at all

tardy delta
#

unnessecary toString ._.

quiet ice
#

can be useful for nullabillity assertions

tardy delta
#

hmm ._.

spare prism
#

it works

#

@quiet ice, ily

#

(no homo)

#

tysm

quiet ice
#

Does anyone have any negative experiences with Locale#getISO3Language (specifically it's performance)? I do not quite like it's implementation but it also appears to be the only sane way of indexing languages as the others seem to be built on not well defined standards where as getISO3Language is very direct in which implementation it uses

tribal holly
#

Hi i have a java question: I have a class named CustomEnchant extanding Enchant (Enchant from bukkit method). When i try to call CustomEnchant::canEnchantItem() it call Enchant::canEnchantItem(). And when i try to cast my call i have an error about : Cannot casting CustomEnchant with CustomEnchant
I there some way to call the good class method ?

tardy delta
#

is there a better way lol?

quiet ice
#

System.arrayCopy

#

so

String[] a = new String[args.length];
System.arraycopy(args, 0, a, 0, args.length);
sacred mountain
#

hey my config cant currently be changed when you edit the file, how do i fxi this?

quiet ice
#

Though if you want to invoke .toString on all the objects, You'd need to iterate over the array

sacred mountain
#

plugin.reloadConfig(); isnt working for me

tardy delta
#

alright

dusk flicker
#

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

maiden briar
#

java.sql.SQLException: Invalid utf8mb4 character string: 'ACED00'
On

public Rating getStoredRating(UUID player)
{
return getFirstValue("SELECT * FROM {table} WHERE player_uuid = ?", player);
}
tardy delta
#

why {table}

maiden briar
#

That is replaced

quaint mantle
tardy delta
#

why not just "SELECT * FROM " + tableName?

maiden briar
#

This is more easy

tardy delta
#

lol

#

public variables are easy too

maiden briar
#

I know, but any answer for my error?

quaint mantle
#

Just keeping the name of your table is easy too 🙂

quaint mantle
maiden briar
#

Java's UUID class

#

VARCHAR(36)

tardy delta
#

show where you do the replace

maiden briar
#
public T getFirstValue(final String query, Object... values)
    {
        List<T> data = get(query, values);

        if(data.isEmpty())
            return null;
        else
            return data.get(0);
    }

    public List<T> get(final String query, Object... values)
    {
        PreparedStatement preparedStatement = this.database.prepareStatement(query.replace("{table}", getName()));

.....
dusk flicker
#

I feel like that introduces a bigger failure point then just hardcoding the name would be

quaint mantle
#

Have you tried yhis on other databases?

quiet ice
maiden briar
#

Printed to console: com.mysql.cj.jdbc.ClientPreparedStatement: SELECT * FROM pastseasonratings WHERE player_uuid = ** STREAM DATA **

#

** STREAM DATA **????

tardy delta
#

and where does getName() comes from?

maiden briar
#

That works, that is just a public field with the name of the table

#

That one is correct in this query

sacred mountain
#

anyone know why my plugin doesnt enable?

[13:19:20 ERROR]: Error occurred while enabling VLandsUtils v1.3.0-CONFIGUTILTEST (Is it up to date?)
java.lang.NullPointerException: null
        at com.clonkc.vlands.kitpvp.Fireball.FireballMain.<init>(FireballMain.java:25) ~[?:?]
        at com.clonkc.vlands.kitpvp.Main.registerListeners(Main.java:30) ~[?:?]
        at com.clonkc.vlands.kitpvp.Main.onEnable(Main.java:16) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot.jar:git-Spigot-21fe707-741a1bd]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [spigot.jar:git-Spigot-21fe707-741a1bd]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot.jar:git-Spigot-21fe707-741a1bd]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [spigot.jar:git-Spigot-21fe707-741a1bd]
        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [spigot.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:414) [spigot.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:378) [spigot.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:333) [spigot.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:263) [spigot.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:525) [spigot.jar:git-Spigot-21fe707-741a1bd]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_311]```
maiden briar
#

java.lang.NullPointerException: null at com.clonkc.vlands.kitpvp.Fireball.FireballMain.<init>(FireballMain.java:25)

sacred mountain
#

i can see that. i just dont know whats wrong

spiral light
#

at com.clonkc.vlands.kitpvp.Fireball.FireballMain.<init>(FireballMain.java:25) ~[?:?]
whats the code ?

maiden briar
#

A null value is used

tardy delta
#

whats in your FireballMain file line 25?

spiral light
#

what version is the plugin and the server ?

quaint mantle
sacred mountain
maiden briar
#

Configuration.get() or .getInt("throwablefireballs.blast-radius") is null

dusk flicker
#

yikes

#

use a paste

#

?paste

undone axleBOT
tardy delta
#

Configuration.get() is null i guess

maiden briar
tardy delta
#

getInt cant return null

sacred mountain
#

hm

maiden briar
tardy delta
#

what does that return?

quaint mantle
#

Have you tried explicitly calling toString on uuid?

maiden briar
maiden briar
tardy delta
#

i would do WHERE player_uuid=? instead of using the spaces idk if that would be something

sacred mountain
#

Returns:
Requested int.

tardy delta
#

what does Configuration.get() returns?

maiden briar
sacred mountain
#

@Contract(pure = true)
public static FileConfiguration get()
Inferred annotations:
@org.jetbrains.annotations.Contract(pure = true)

thast when i hover over it

tardy delta
#

oh was just wonderinf if that was the problem

quaint mantle
maiden briar
#
for(int i = 1; i <= values.length; i++)
    preparedStatement.setObject(i, values[i - 1]);
tardy delta
#

setString probably

quaint mantle
#

that makes sense

sacred mountain
quaint mantle
#

you set directly an uuid, not the string representation

maiden briar
maiden briar
quaint mantle
#

And it probably has some custom adapter

maiden briar
#

instanceof UUID ?

quaint mantle
#

Ugly

#

One Word: JDBI

maiden briar
#

And that means?

tardy delta
#

before calling get()

#

so it is null

#

and static mehh

quaint mantle
#

A modern fluent java sql library

maiden briar
#

No need for right now, still thanks for helping me out

sacred mountain
#

does it have to be called in all classes using configuration.get?

tardy delta
#

no

quaint mantle
#

Just don't use singletones

tardy delta
#

or dojava FIleCOnfi get() { if (customfile == null) reload() return customfile }

sacred mountain
#
public void onEnable() {
        this.registerListeners();
        this.registerCommands();

        //Setup config
        getConfig().options().copyDefaults();
        saveDefaultConfig();

        Configuration.setup();
        Configuration.get().options().copyDefaults(true);
        Configuration.save();

    }```