#help-development

1 messages ยท Page 335 of 1

pseudo hazel
#

yeah it says up to 127 should still be mostly supported

quaint mantle
#

how to i turn on piston duping? in my server

pseudo hazel
#

so do you also have like all those other things in there?

dry yacht
pseudo hazel
#

yeah but like what does "this type of inventory" mean

glacial shell
pseudo hazel
#

okay so what made you assume ItemManager.init() wasnt?

glacial shell
#

He was just typing inside of it, so I assumed i needed to add it

pseudo hazel
#

oh well I guess so

#

did you also add the give command?

#

there he also uses the ItemManager

dry yacht
pseudo hazel
#

oh whats this secret minecraft wiki

glacial shell
pseudo hazel
#

well no

#

you dont have to

dry yacht
pseudo hazel
#

its more like if you watched the whole video you would've seen that he added the pickaxe item to the ItemManager

pseudo hazel
#

even though I dont do packets , seems like usefull information to know the background a lil more of some of this stuff

glacial shell
pseudo hazel
#

wel I can spoil it for you right now, all he does it creating like an itemstack that represents the pickaxe

#

you can get away with just omitting ItemManager im pretty sure

glacial shell
#

Okay thx

pseudo hazel
#

since you just care about the rest of the code anyways

livid dove
#

What could cause this error?

rotund ravine
#

Update protcollib / viaversion

#

Or any others using packets

humble tulip
pseudo hazel
#

oh like enchant table slots?

#

i guess that makes sense

#

you would think that wouldnt apply to just the 9x6 inv though

humble tulip
pseudo hazel
#

which is what im tryna use

humble tulip
#

Yh

livid dove
pseudo hazel
#

is the player a developer?

livid dove
#

I am but I fear it might be a server side issue due to the type of error

humble tulip
#

Are they using mods?

#

Nah

#

Wait

#

Is it reproducible?

#

It should be

#

Someone didn't reset the readerIndex

#

@livid dove

livid dove
#

reset the readerindex?

glacial shell
humble tulip
#

And does it happen with no plugins

#

It's likely a plugin reading packets prior to them being decoded to packet objects

#

However, they don't reset the readerindex

dry yacht
humble tulip
#

So mc tries to decode the packet from the end of the data

#

Or that

#

The point is, someone os readong packets

#

And they shouldn't

dry yacht
#

Which again could be due to unresolved version differences between client and server.

dry yacht
# humble tulip The point is, someone os readong packets

Well, the server is constantly doing so, lol. I guess it also doesn't catch everything in the pipe and will throw if there's an error, as these errors should be detectable in production rather than be silenced to any spammy log files.

pseudo hazel
humble tulip
#

But it does so under the assumption that nothing will intercept the packets

dry yacht
#

Sure, but that's just not how the world works with modding. I don't even wanna know how many interceptors got their hands in the packet stream, xD. Could also be some viaversion issue, or a malformed packet, or whatever... Maybe a cosmic ray hit multiple ram cells of the router transmitting the packet and the CRC didn't catch that (LOL).

livid dove
humble tulip
#

You still haven't answered that

livid dove
#

apparently this specific chunk

#

is causing it for this one player

humble tulip
#

No other player?

livid dove
#

about to test

#

not that i know of

#

closest I can think of is plant growth ?

humble tulip
#

Plugin that modifies chunk packets

livid dove
#

no not at all as far as i know

humble tulip
#

So player is kicked

granite burrow
#

How can I tell what plugin a command is handled by?

humble tulip
#

If you can reproduce on another player, try without plugins

humble tulip
undone axleBOT
humble tulip
#

You need to add the nbtapi repo

#

It won't find spigot eother

livid dove
humble tulip
#

Wierd

#

Maybe it's pulling it from your local repo

wet breach
#

not weird

#

when you don't specify a repo maven will look in two places

#

first maven central

#

then your local maven repo

humble tulip
#

ah

#

you probably don't have the same version

humble tulip
livid dove
humble tulip
#

i mean is it cracked?

dry yacht
humble tulip
#

yes

#

in the other project

#

if it's not, it won't be in your local maven repo

wary mountain
#

for some reason i cant get this cmd to work

#

wait

#

why cant i send images i verified

humble tulip
#

try now

wary mountain
#

nope

#

?????

humble tulip
#

idk then

#

use imgur

wary mountain
#

imma restart discord wait

humble tulip
#

just add the repo

granite burrow
wary mountain
humble tulip
#

uhhh

#
<repositories>
...
<!-- CodeMC -->
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
<layout>default</layout>
</repository>
...
</repositories>
wary mountain
#

so this command dosent work

humble tulip
#

oh

dry yacht
humble tulip
#

that's jda?

wary mountain
#

its interprocess between spigot and jda

humble tulip
#

this is spigot lol

wary mountain
#

the bot is run off of a spigot plugin

regal scaffold
#
    LEVEL_1(1, "MinerZombie", "Troll"),

    LEVEL_2(2, "Samurai", "Troll"),

    LEVEL_3(3, "ToxicZombie", "Troll"),

    LEVEL_4(4, "FrozenInhabitant", "Troll");

Currently I can get the String values from this enum using:

        for (MobName mobName : MobName.values()) {
            if (mobName.level == level) {
                return mobName;  <------------------- how can I return a random value between all Strings in each line

Example:

LEVEL_1 either returns "MinerZombie" or "Troll"

humble tulip
#

yeah but i wont go to jda discord for spigot help because the bot runs on a spigot plugin

#

I can't help u sry

wary mountain
#

well the part thats not working is the spigot part

dry yacht
wary mountain
#

not the jda

livid dove
wary mountain
#

the command works, reply works just not the stuff in minecraft

humble tulip
#

you want a random level?

regal scaffold
#

No, I want a random value from each level

#

I think enum is becomming short for this

humble tulip
#

show your constructor

regal scaffold
#

But I still wanna try

#
    MobName(int level, String name, String name2) {
        this.level = level;
        this.name = name;
        this.name2 = name2;
    }
humble tulip
#

also you should not use an enum from the looks of that

#

use String... names

regal scaffold
#

Oh... good point

humble tulip
#

OR String name, String... otherNames

dry yacht
humble tulip
#

and combine both into 1 array

regal scaffold
#
    MobName(int level, String... name) {
        this.level = level;
        this.name = name;
    }
#

Fixed

#

That part

#
String[] name = new String[]{""};
humble tulip
#

huh?

humble tulip
dry yacht
regal scaffold
#

True, alright removed that

#

And added final

#

Now you think I just return name[Math.randomblabla]?

humble tulip
#

yes

regal scaffold
#

Thats kinda dope

dry yacht
#

Thread local random! ;)

regal scaffold
#

Didn't think about it

#

What's thread local random

humble tulip
#

to guarantee that you have atleast one name

dry yacht
#

nextInt(names.length), basically

humble tulip
#

MobName(int level, String name, String... otherNames)

regal scaffold
#

Well the values are actually hardcoded

humble tulip
#

ThreadLocalRandom.current().nextInt(names.length + 1);

regal scaffold
#

User can never add any

humble tulip
#

i know

#

but for safety

dry yacht
# regal scaffold What's thread local random

ThreadLocalRandom.current().nextInt(names.length);

Just don't instantiate a new random for each generation, that would be insanity. This is a pretty good solution which keeps you from managing your own Random instance.

regal scaffold
#

Oh sure I'll do the change anyways

humble tulip
#

if the random int == names.length, return the primary name

#

else return the array index

regal scaffold
#

Gotcha

dry yacht
humble tulip
dry yacht
#

That seems dirty, not gonna lie, xD

regal scaffold
#
    public static String getMobName(int level) {
        for (MobName mobName : MobName.values()) {
            if (mobName.level == level) {
                return mobName.name[ThreadLocalRandom.current().nextInt(mobName.name.length)];
            }
        }
        return null;
    }
humble tulip
#

lol

regal scaffold
#

Technically that works without the default values

dry yacht
#

I just prefer the straight up simplicity of this

regal scaffold
#

That's pretty cool thought wouldn't have thought of it

humble tulip
#

OR

livid dove
regal scaffold
#

Im curious tho

livid dove
#

Should i be concerned considering the kick error

regal scaffold
#

Would then enum EVER be null?

humble tulip
#

no

regal scaffold
#

Like why

dry yacht
humble tulip
regal scaffold
#

I see

dry yacht
regal scaffold
#

I was wondering you you even need the .length == 0

pseudo hazel
#

well in this example the length refers to the amount of names the developer has typed in the enum declaration

#

so yeah, it can be 0

#

since String... is 0 or more

regal scaffold
#

Fair

dry yacht
# regal scaffold I was wondering you you even need the .length == 0

Yes you do, because the variadic argument String... names can be left completely empty and still be valid. To not run into any runtime surprises, I'd catch that at the moment the class is loaded, which is when enum constants are initialized (something like that, geol don't beat me up).

#

You know when you load your plugin, instead of after you shipped it. Big difference.

regal scaffold
#

Now guys I have a little question hehehe

#

Get ready btrw

humble tulip
#
public class Level {

    public static final Level ONE = new Level("One", "1", "First");

    private String[] names;

    public Level(String name, String... otherNames) {
        List<String> namesList = Arrays.asList(otherNames);
        namesList.add(0, name);
        this.names = namesList.toArray(new String[0]);
    }


}
dry yacht
humble tulip
#

can also use a class for that

regal scaffold
#

What if for each level not only do I want random strings of mobs but I also want a % for each. And then the random actually gets called using that %

humble tulip
#

ah

regal scaffold
#

lmao

humble tulip
#

weighted randomness

humble tulip
#

lmao i couldn't think of a better way to increase array size by 1 but have the previous items copied to the tail end

humble tulip
regal scaffold
#

No I don't

#

So dw about that

#

I don't mind recompiling the plugin once a change. It's still in development

dry yacht
humble tulip
#

not really

#

it doesnt have to add to 100

#

if you assign 1 to Steve and 1 to alex, it is a 50/50% chance

regal scaffold
#

Bro can you guys like agree on something, plz

dry yacht
humble tulip
#

if you want percent, it must add to 100 but checking that it adds to 100 is hard

regal scaffold
#

Don't care about %

#

Weight is fine

humble tulip
#

great

regal scaffold
#

But I don't think enums gonna cut it anymore

humble tulip
#

lol

#

duh

#

?paste

undone axleBOT
humble tulip
dry yacht
# humble tulip not really

It has, if it's done the way I wrote about it. Like have A take 20% and B 30% and C 50% would be

A [0;0.2] B [0.2;0.5] and C [0.5;1]. Maybe I also screwed this up, it has been a long time since I needed it and I haven't thought about it ever since.

humble tulip
#

WeightedRandomGenerator class

regal scaffold
#

Oh god...

#

And I need to make my enum into that

humble tulip
#

no

dry yacht
regal scaffold
#

LMAO

#

I mean yeah

#

I just don't know where to really start

#

First i gotta switch out of enums

humble tulip
#

What are you doing?

dry yacht
humble tulip
#

you want to store mob names?

regal scaffold
#

So I'm thinking each level needs a map

#

Well yeah

#

I want to store a mobname / weight

#

As many per level

#

And then getRandom() uses the weight per random

humble tulip
#

right so each level needs a weightedrandomgenerator

#

the only change you'll have to make is you can no longer accept String...

regal scaffold
#

Isn't this too much just to get a randomthing

#

What if I make a map and just if lmao

humble tulip
#

well sure

regal scaffold
#

I mean it sounds cool for sure

#

I would like to try it tbh

humble tulip
#

what works isnt what's best

regal scaffold
#

If you feel like guiding me through the steps I'll give it a try

humble tulip
#

sure

#

send ur current code

#

?paste

undone axleBOT
humble tulip
#

lemme just have a look

regal scaffold
humble tulip
#

why ""?

regal scaffold
#

MobName.getMobName(currentLevel).toString()

#

Cause I was editing stuff

#

They'll be full,

humble tulip
#

ah ok

#

String.toString?

regal scaffold
#

toString() uncesseary

humble tulip
#

ye

regal scaffold
#

Before it was returning MobName

humble tulip
#

ok anyhow

regal scaffold
#

Cause was only 1

#

Wait before we do this

#

Is calling this in a bukkittask

humble tulip
#

yeah?

regal scaffold
#

Gonna cause issues

humble tulip
#

calling what?

#

and no it won't

regal scaffold
#

getRandomName doing all the stuff about random and that

humble tulip
#

if it's the enum

#

nah it wont

regal scaffold
#

Alright

humble tulip
#

i'm thinking 1 sec

regal scaffold
#

Yeah no issue I got time lol

humble tulip
#

You can have a class like this

public class Weighted<E> {

    private final E object;
    private final double weight;

    public Weighted(E object, double weight) {
        this.object = object;
        this.weight = weight;
    }

    public double getWeight() {
        return weight;
    }

    public E getObject() {
        return object;
    }
}
#
public class WeightedString extends Weighted<String> {
    public WeightedString(String object, double weight) {
        super(object, weight);
    }
}
#

and this

#

so now, you can replace String with WeightedString

regal scaffold
#

ooooooooooooooooooooooo

humble tulip
#

in your Enum Cnostructor

regal scaffold
#

I see what you're doing

#

Holy sht

#

Ok yeah, so far so good

#

Am I still doing array of WeightedString?

#

According to what I see, I say no

rotund ravine
humble tulip
rotund ravine
#

No lol

humble tulip
#

you can just use that tho

regal scaffold
humble tulip
humble tulip
regal scaffold
#

Well, if I want to have multiple names and weights

#

I kinda have to, right?

humble tulip
#

it's the same

regal scaffold
#

WeightedString[]?

#

Cause unless I'm full lost WeightedString isn't actually a collection of any sort

rotund ravine
#

No?

#

It's just a bad implementation of the generic.

regal scaffold
#

What would you do then

humble tulip
#

Ok well scrap using WeightedString

#

just use Weighted<String>...

regal scaffold
#
    final Weighted<String>[] names;

    MobName(int level, Weighted<String>... names) {
        this.level = level;
        this.names = names;
    }
humble tulip
#

yeah

#

now we need to load the weights into the WeightedRandomGenerator

#

private WeightedRandomGenerator<String> randomGenerator = new WeightedRandomGenerator<>();

regal scaffold
#

Oh I actually need that entire class, alright

humble tulip
#

yes

regal scaffold
#

Alright

valid basin
#

Does anyone have a good way or util to shrink/expand world borders smoothly?

humble tulip
#
    private final int level;
    private WeightedRandomGenerator<String> randomGenerator = new WeightedRandomGenerator<>();


    @SafeVarargs
    MobName(int level, Weighted<String>... names) {
        this.level = level;
        for (Weighted<String> name : names) {
            randomGenerator.addItem(name.getObject(), name.getWeight());
        }
    }

    public String getRandomName() {
        return randomGenerator.generateRandom();
    }

    public static String getMobName(int level) {

        for (MobName mobName : MobName.values()) {
            if (mobName.level == level) {
                mobName.getRandomName();
            }
        }
        return null;
    }
regal scaffold
#

Ok great

valid basin
#

Does anyone have a good way or util to shrink/expand world borders smoothly?

worldly ingot
#

WorldBorder#setSize(size, seconds)

regal scaffold
#

And then in each level how should I be adding it exactly

#
    LEVEL_1(1, new Weighted<>("MinerZombie",3)),
valid basin
humble tulip
#

yes

worldly ingot
#

If world borders exist in 1.8 then yes

regal scaffold
#

Thta's sick

worldly ingot
#

but you should really update. 1.8 is like 8 years old

regal scaffold
#

Now the weights I assume is with the total of each level

valid basin
#

Alright, thank you

regal scaffold
#

If both are 50/50 then it'll be 50%

humble tulip
#

weights are like fractions ye

regal scaffold
#

Perfect

#

That's so fking sick

humble tulip
#

add all the wights that's the denominator

#

and the individual weight / total weights is the probability

regal scaffold
#

Thanks a lot for the lesson

#

Now I'm a bit worried about running all this in a tasktimer so I'm just gonna add some period to it and should be safe

wary mountain
#

"asynchronous entity add"

wary mountain
humble tulip
#

if you're async(another thread) you need to schdule the entity to be added on the main thread

#

?scheduling

undone axleBOT
regal scaffold
#
 new BukkitRunnable() {
            @Override
            public void run() {
                    mythicMob = MythicBukkit.inst().getMobManager().getMythicMob(MobName.getMobName(currentLevel)).orElse(null);  <------ enum
                    Location location = locations.getRandomLocation();
                    mythicMob.spawn(BukkitAdapter.adapt(location), 1);
        }.runTaskTimer(plugin, 1, 10);
    }
wary mountain
#

oh

regal scaffold
#

I wonder if it's an issue doing so many calls so quickly

cunning bane
#

Hey I Need a Developer for Mods and Plugins pls let me know DM

tender shard
#

?services

undone axleBOT
tender shard
#

if it works, don't worry about it

dry yacht
regal scaffold
#

60 at any given time

dry yacht
#

Oh, okay, that wasn't obvious from the excerpt alone.

regal scaffold
#

Yeah for sure lol I did actually infinitely spawn entities once

#

Then I fixed the limit hehehe

#

I was confused when my frames went to 20

#

@tender shard The cirrus dev still hasn't answered my messages in his cord about his stuff not working

tender shard
#

maybe use another lib then

regal scaffold
#

Yeah unlucky I really wanted that intelliJ plugin

#

@tender shard When is jefflib getting a intelliJ plugin O.o

tender shard
#

I tried to write an intelliJ plugin, but it was so complicated that I nearly died and then I never touched it again

regal scaffold
#

lmaoooo

tender shard
#

kotlin iirc

dry yacht
tender shard
#

yeah exactly lol

dry yacht
#

Screw IntelliJ, maybe gonna write a vim plugin instead some day, haha

#

rather for the lsp, I guess

regal scaffold
#

@dry yacht Have you seen the resource we're talking about?

dry yacht
regal scaffold
#

Cause the dev has a shitton in his repos and it's not even usable

#

But the plugin looks cool

dry yacht
#

GUI lib? I bet it's a clusterfuck

#

I'd just roll my own minimal implementation

regal scaffold
#

Nah prob but the intelliJ plugin is what made it look interesting

regal scaffold
dry yacht
dry yacht
#

I actually have something laying around, xD

regal scaffold
#

I

#

I'll be waiting

#

btw his github repo doesn't seem to have his final version. that is here

#

Even alex tried helping me try to build it. impossible

dry yacht
#

Not trying to be mean, but that's the single most useless thing I've ever seen, haha

dry yacht
regal scaffold
#

I mean I assume he his framework converts that config file into a gui to edit in code

regal scaffold
#

I don't think I'm at the level yet wher emy implementation is better than mostframeworks tho. No amtter how bad those cna be

dry yacht
tender shard
#

(InventoryFramework)

#

i never used it, so no clue whether its good or not

dry yacht
regal scaffold
pseudo hazel
#

expression parser ๐Ÿค”

#

IF is good once you are used to it

dry yacht
pseudo hazel
#

I use my own thing though

#

just because I like the challenge of makin it

dry yacht
regal scaffold
#

Man everyone here uses their own thing

pseudo hazel
#

what kinda expressions though

dry yacht
regal scaffold
#

I don't think I have the knowledge to make my own lib just yet

pseudo hazel
#

well because there are a billion options of what to do/preferences/etc

regal scaffold
#

I've only been coding java for like 2 weeks now

dry yacht
pseudo hazel
#

well I dont know how to make a "lib" I just write code based on what spigot lets me do with inventories using google xD

dry yacht
pseudo hazel
#

wtf are you opening pandora's box or something

#

just looking at your example

#

looks pretty nice

#

I mostly have some base gui , an a few things like some banner based keyboard menu, paginated item picker, stuff like that

#

but its all inside of 9x6's for now haha

regal scaffold
#

One day

pseudo hazel
#

and submenuUI which I recently did, which is basically just a node in a gui tree

regal scaffold
#

I'll make such a good lib you guys will both switch for it

#

Just remember

pseudo hazel
#

ill remember that

dry yacht
dry yacht
pseudo hazel
#

yeah same for me

regal scaffold
#

You got no idea how committed I am to something when i set my mind onto it

#

I put 20 hours a day until I master it

pseudo hazel
#

also now that I have already started putting time in my guis,I see less reason to switch to anything else

regal scaffold
#

It was a joke steaf lol. I'm actually going after jefflib

#

so dw

pseudo hazel
#

because of how limited minecraft plugin guis can get, I feel like every sort of menu is a few lines of code away at this point

dry yacht
regal scaffold
#

Good

#

Work hard or go home

dry yacht
# pseudo hazel looks pretty nice

Btw, don't know if that's obvious, but I'm also no longer interacting with a plain config. I'm automatically mapping these sections to objects, with automatic expression support.

dry yacht
regal scaffold
#

Like it might not sound very good to you guys and the code is definately not refined but in a week I made a chunk collector which works as an infinite chest better than all the options rn at elast on spigot forums. In 2 days I made and finished my first game

#

Like I said it's defo not refined code, it's honestly pretty bad, but that's from a week of doing stuff

dry yacht
pseudo hazel
#

yes thats cool

regal scaffold
#

I am. Today someone tought me about like, idk what they're called exactly like MyClass<>

dry yacht
regal scaffold
#

So now need to use that more and more

regal scaffold
#

If you compare my inf storage to my game it looks like it's built by someone else

#

It's still bad but not as bad lol

#

And as I cope my hate for cmi and songoda grow so

dry yacht
dry yacht
#

"298+ Commands/Insane Kits/Portals/Essentials/Economy/MySQL & SqLite/Much More!" ๐Ÿคฎ

regal scaffold
#

And the songoda team also make terrible massive massive plugins

dry yacht
#

Jack of all traits but master of none, huh, xD

regal scaffold
#

I don't think a single dev likes CMI

#

Support is ass

#

Compatibility is ass

#

Performance is ass

#

If it was free I still wouldn't use it

dry yacht
#

I actually don't understand how people can work on such giant projects, that just has to be immensely cumbersome.

hasty prawn
#

Make it modular and then you shouldn't get overwhelmed too bad since you focus on sections at a time

tender shard
#

can gradle init meanwhile properly handle maven plugins like maven-shade-plugin and also submodules? or do I have to rewrite this shit again D:

tender shard
dry yacht
tender shard
#

pin*

#

angelchest is such a feature creep, not even the translations fit onto one screenshot D:

dry yacht
regal scaffold
#

gg bad dev

#

Angelchest new cmi

tender shard
regal scaffold
#

I'm wondering right

tender shard
regal scaffold
#

How long does it actually take to develop something so big as cmi

#

Or Mythicmobs

dry yacht
tender shard
regal scaffold
#

But like we talking years?

#

Cause they are absolutely massive plugins

tender shard
#

I'd say "a few hundred hours"

dry yacht
dry yacht
tender shard
#

remember it has to keep comments and stuff

dry yacht
# tender shard well how'd you do it?

Probably diffs from each version, some sort of migration scheme. No idea tbh, haven't had to think about it. But if your logic works well, you should be able to extrapolate that to nested keys as well, I think. Maybe I'm overlooking something.

dry yacht
tender shard
#

yeah unfortunately it's only in 1.17+ IIRC D:

#

I still gotta support 1.16 for all these shitty hybrid forks

regal scaffold
#

Is the way that viaversion works complicated?

#

Like I don't see any other similar ones

tender shard
regal scaffold
#

Oh what for? lol

tender shard
#

the general idea is not very complicated

#

but it's a lot of effort mapping all these different versions

#

e.g. saying "oh, a 1.8 user sees netherite, hm let's show them diamond ore instead"

dry yacht
tender shard
#

also true

regal scaffold
#

Ummm sorry 1 question, What's the bar that shows above the hotbar with text? Can one customize it? What's it called

tender shard
#

but then I'd be at 4MB and poeple would then give 1 star ratings "when I bought this plugin it was 1MB, now it's 4MB, I am upset ugh ugh ugh" lol

regal scaffold
#

Thankss

tender shard
#

somePlayer.spigot().sendMessage(ChatMessageType.ACTION_BAR, yourText);

regal scaffold
#

Great!

tender shard
#

it requires component though IIRC

regal scaffold
#

...

tender shard
#

e.g. TextComponent.of("My text")

regal scaffold
#

Oh god not this already

#

Oh that

tender shard
#

or sth similar

dry yacht
dry yacht
tender shard
opaque scarab
#

So Iโ€™m working on a plugin and I want to make an armorstand that is constantly moving and posing, creating an animation. There is one armorstand per player. Iโ€™m pretty new to spigot, and so I was wondering what is more efficient. Should I create a new runnable instance per player and animate each armorstand in that, or should I have one central runnable and iterate through all armorstands in a list?

tender shard
dry yacht
tender shard
#

and then I'd use a Map<UUID,ArmorStand> or sth like that

#

YAML is nice

#

JSON is a bad joke

dry yacht
tender shard
#

json was never made to be human cofigurable

#

forget one comma? whole file "dies"

#

json = nice for internal storage. YAML = nice for human editable things

#

that's at least my opinion

dry yacht
#

I don't even know what to say rn, :-:

tender shard
#

two options: you could say "I agree", or you could start to explain about which things you disagree ๐Ÿ˜›

tender shard
#

I can only speak for myself, but if docker-compose would use .json files instead of .yml, then I'd sure as hell be quite annoyed

tender shard
#

still, no reason to have 1000 runnables if you could just use one

dry yacht
#

Like, I respect your opinion, but I don't know if you're actually aware of how bad yaml is. If you actually forget such a stupid comma, you at least get the exact parser cursor location of where an unexpected token occurred, while yaml can fuck your whole config over and maybe even pass parsing. Look at the yaml parser. It's an immensely complicated state machine which is only so complicated because the spec has been written by maniacs with feature-creep syndrome and because the language is indentation-based. I can write a proper json parser in like a few Ks. Yaml brings nothing to the table and makes debugging way way worse. Json is so easy that I can explain it to a five year old, while Yaml has so many stupid possible ways to mess it up...

tender shard
regal scaffold
#

Ummm alex

#

How long does this sendtext action bar last

tender shard
regal scaffold
#

oh

#

ok

#

ty

dry yacht
tender shard
#

oh I get what you mean

#

they probably did message: &cRED TEXT

#

instead of using quotes

opaque scarab
tender shard
tender shard
dry yacht
tender shard
#

the server doesnt really care about having to run 1000 runnables every tick, however it'd still be a nice idea not to spam the scheduler with a shit ton of new runnables

dry yacht
tender shard
tender shard
#

just do not add random " or ' or & chars into your configs without escaping them, and you're fine

dry yacht
# tender shard I don't really see why that's any reason to hate YAML. People are ofc excpected ...

Because you gain a bit of readability for the disadvantage of a far more complex parsing algorithm as well as far less bullet-proof grammar. It's not at all worth the tradeoff, judged from an objective standpoint.

I think you just don't care about that because it "just works" for you. You never had these horrible parser failures, and you never tried to write a yaml parser. It's not even closely comparable to a json parser, and again - it doesn't bring enough to the table to justify that.

tender shard
#

I mean tbh pls be honest, which is easier to read and edit for humans?

{
  "name": "mfnalex",
  "age": 27,
  "friends": [
    {
      "uuid": 1234
    },
    {
      "uuid": 3456
    }
  ],
  "address": {
    "street": "JunkerstraรŸe 17",
    "city": "Mรผnster",
    "zip": 48165,
    "country": "DE"
  }
}

or

name: mfnalex
age: 27
friends:
  - uuid: 1234
  - uuid: 3456
address:
  street: JunkerstraรŸe 17
  city: Mรผnster
  zip: 48165
  country: DE
#

I think YAML is way easier to edit

tender shard
dry yacht
#

Nobody argues that it's easier to read and edit, that's not my point

tender shard
#

I know exactly that if plugins would use json instead of yaml, I'd get like 100 support tickets per day

#

that I could avoid by making people using YAML instead

dry yacht
dry yacht
tender shard
#

50% of my support tickets are like "ugh why does the disabled-world options not work" and then they send a config that looks like this:

disabled-worlds:
- world1
- world2

disabled-worlds:
#

if people don't even understand why this doesn't work, then I highly doubt that they would be smart enough to edit json files without breaking everything

dry yacht
#

We're just coming at this from two completely different angles. You're about use and how it's going to be accepted on the market while I'm about the implementation details and about how obscure it's specification actually is.

I guess that's fine tho, but when users are just too stupid to learn json, then they shouldn't be cocky about you shading the latest snakeyaml into your plugins to make it even easier for them (because size was the initial concern, iirc).

tender shard
#

yeah but I dont understand why I should care about the implementation, when snakeyaml already does it in a way that works well for everyone

#

I guess that's fine tho, but when users are just too stupid to learn json, then they shouldn't be cocky about you shading the latest snakeyaml into your plugins to make it even easier for them (because size was the initial concern, iirc).
I 100% do support this statement though

dry yacht
#

As I've said, you just don't care about technology in a way that I do, and I respect that! :). People have different motivations to be in this field, that's just how diversity works.

tender shard
#

yeah I just wanna sell my stuff and stop having to answer tickets because people do not understand how to edit the config files

#

as long as SnakeYAML works, I dont see any reason not to use it

dry yacht
# tender shard yeah I just wanna sell my stuff and stop having to answer tickets because people...

I get that. And I just want the world of computing to become a better place where we don't write immensely complex parsers to compensate for the ignorance and straight up disinterest of bukkit server owners against technology. JSON is more than easy enough to read and understand. It has a few more control characters, but it's not like I make them write assembly, populate system registers and perform syscalls. It's json, my lord.

snow ember
#

can someone help me shade my own classes into a jar file (also edit one of the .class files to actually run the shaded in classes)

dry yacht
quaint mantle
#

hi

tender shard
tender shard
quaint mantle
#
        try {
            ResultSet resultSet = chunksTable.getChunk(chunkCoordX, chunkCoordZ);
            if (resultSet.next()) {
                this.owner_uuid = resultSet.getString("owner_uuid");
            }
            else {
                this.owner_uuid = null;
            }
        } catch (Exception e) {
            ChunkClaimsPlugin.logWarn(e.getMessage());
        }```
quaint mantle
#

so, i am storing chunk data in a sqlite database

tender shard
#

what kinda chunk data?

quaint mantle
#

then whenever a chunk gets loaded the ChunkLoadEvent gets fired, i load the chunkdata from my sqlite database into server memory

snow ember
# dry yacht Are you talking about shading another project of yours into your current project...

No, I have a plugin .jar file. It's obfuscated and I want to add my own features to it. I can easily add my own classes by just unzipping the jar, adding them, and rezipping it, but I need to call them. To do that, I have to edit the main file, and all attempts at editing the bytecode don't work. I even created a clone of the decompiled version of it, and then added stubs until I was able to get it to compile, but that threw errors in console and didn't actually make the function run

snow ember
quaint mantle
#

but it seems incosistent

quaint mantle
#

so owner uuid is null

snow ember
#

That's not what I'm trying to do

quaint mantle
#

even though i see the owner uuid in database

snow ember
#

I'm trying to edit the jar file

tender shard
#

huh

snow ember
#

So I guess "shading" isn't the best terminology

tender shard
#

I dont really understand

#

can you try to explain it again

snow ember
#

I want to edit the main class of a jar file

dry yacht
snow ember
#

Yeah

#

Ik

#

I've tried this for days on end

#

nothing seems to work

#

I was able to get my injected code to work, but the downside is the actual plugin itself didn't load properly

sterile token
#

Imagine still using SQL ๐Ÿ’€

quaint mantle
#

i am using sqlite

tender shard
#

verano you on crack cocaine again?

quaint mantle
#

i just need the single file convinience

sterile token
quaint mantle
#

otherwise i would use a nosql database like mongodb but that aside

river oracle
#

he is on crack again

tender shard
#

obv

#

yeah

quaint mantle
#

Json?

river oracle
#

๐Ÿ‘€ wtf

quaint mantle
#

do you even know what json is?

tender shard
#

verano you should go to sleep

dry yacht
# snow ember I was able to get my injected code to work, but the downside is the actual plugi...

Could you give me an example of what you're actually trying to achieve? Is it just to add function calls to methods or do you actually want to patch out methods? Wouldn't it be easier to just change the main entry point of the obfuscated plugin's yaml file and then bootstrap the obfuscated code yourself rather than having to do it the other way around? You could just inherit and override some methods then, I guess.

tender shard
#

your name's Alex

dry yacht
#

Oh, I thought you're the yamler

quaint mantle
#

ok i have an actual problem that i am trying to solve please dont make awful jokes.

tender shard
#

welcome to spigotmc discord

quaint mantle
#

this problem is causing me a headache

snow ember
quaint mantle
#
        this.executeStatement("CREATE TABLE IF NOT EXISTS Chunkclaims (" +
                "owner_uuid text NOT NULL," +
                "coordX int NOT NULL," +
                "coordZ int NOT NULL," +
                "FOREIGN KEY (owner_uuid) REFERENCES Players(uuid)" +
                ");" +
                "");```
#

this is the sqlite database table.

snow ember
#

every time

tender shard
#

what data do you need to store? @quaint mantle

#

because you could usually just use the chunk's PDC

quaint mantle
tender shard
#

usually there is no reason to use an external DB

quaint mantle
#

i know i can use the spigot persistent data api

#

but i wanna be able to use this elsewhere as well

tender shard
quaint mantle
#

so i am storing this in a separate file

dry yacht
quaint mantle
#

so the problem is

#

so i have this command called /claim.

snow ember
#

how am I supposed to inherit a class that isn't abstract or an interface?

quaint mantle
#

a player claims a chunk and if a chunk is claimed, it cannot be claimed again

sterile token
quaint mantle
#
        this.executeStatement("CREATE TABLE IF NOT EXISTS Chunkclaims (" +
                "owner_uuid text NOT NULL," +
                "coordX int NOT NULL," +
                "coordZ int NOT NULL," +
                "FOREIGN KEY (owner_uuid) REFERENCES Players(uuid)" +
                ");" +
                "");```
snow ember
dry yacht
snow ember
#

tysm this might work

#

I'll get back to you

quaint mantle
#
getChunk = db.createPreparedStatement("SELECT * FROM Chunkclaims WHERE (coordX=? AND coordZ=?);");```
sterile token
dry yacht
quaint mantle
#
    public ResultSet getChunk (int chunkCoordX, int chunkCoordZ) throws SQLException {
        getChunk.setInt(1, chunkCoordX);
        getChunk.setInt(2, chunkCoordZ);
        return getChunk.executeQuery();
    }```
#
        try {
            ResultSet resultSet = chunksTable.getChunk(chunkCoordX, chunkCoordZ);
            if (resultSet.next()) {
                this.owner_uuid = resultSet.getString("owner_uuid");
            }
            else {
                this.owner_uuid = null;
            }
        } catch (Exception e) {
            ChunkClaimsPlugin.logWarn(e.getMessage());
        }

        if (this.owner_uuid != null) {
            this.chunkOwner = Bukkit.getPlayer(UUID.fromString(this.owner_uuid));
        }```
#

i am using jdbc to do this.

#

and here is how i get the result set

#

private String owner_uuid = "loading";

#

owner_uuid is "loading"

#

once it loads

sterile token
#

okay, so you are asigining each player a chunk?

quaint mantle
#

it is null if the database row was not found

quaint mantle
#

but it has been inconsistent

#

i keep going to a chunk

#

and i have been able to claim it several times

#
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player)) {
            return false;
        }

        Player player = (Player) sender;

        Bukkit.getScheduler().runTaskAsynchronously(ChunkClaimsPlugin.getThisPlugin(), () -> {
            try {
                ChunkData.claimChunk(player, player.getLocation().getChunk());
                player.sendMessage("You have now claimed this chunk.");
            } catch (Exception e) {
                player.sendMessage(e.getMessage());
            }
        });

        return true;
    }```
sterile token
#

Are you doing a claim system?

quaint mantle
#

yes

#

do you know what the problem is?

sterile token
#

So what your issue?

quaint mantle
#

i do /claim on a chunk that is already claimed

sterile token
#

You are not finding the player?

quaint mantle
#

has a row in the database table

#

but i keep being able to do /claim and claim it over and over

sterile token
#

right, please i want to see your user and your claims table strucutre

quaint mantle
#

here is what the database structure looks like

#

and that is the chunk claims database table.

sterile token
#

Oh the uri is not allowed in my country

quaint mantle
#

lol where do you live its just imgur

#

i am only posting an image.

sterile token
#

So youri ssue is that your players can claim many chunks?

quaint mantle
#

no, the same chunk over and over

sterile token
#

oh right

#

Hmn i never worked with Chunks, i use a cuboid based system

quaint mantle
#

there are two rows containing the same chunk coordinates in the database table.

sterile token
#

oh ok

tender shard
kind hatch
#

Yall want the images?

tender shard
#

Cant hurt

kind hatch
#

Pasted in order.

tender shard
#

Thx

#

Well the db obv contains your data, the issue must be how youre reading it

#

Looks like a typical problem where you forgot to do next() on the resultset

quaint mantle
#

there should only be one row

#

with a certain combination of chunkCoordX and chunkCoordZ

tender shard
#

You still gotta call next() to get the first result

quaint mantle
#
private static HashMap<Chunk, ChunkData> chunkDataStore = new HashMap<Chunk, ChunkData>();
public ChunkData (Chunk chunk) {
        this.initialisations(chunk);
    }

    private void initialisations (Chunk chunk) {
        chunkDataStore.put(chunk, this);

        try {
            if (!initialised) {
                chunksTable = new ChunksTable();
                initialised = true;
            }
        } catch (Exception e) {
            ChunkClaimsPlugin.logWarn(e.getMessage());
        }

        this.chunk = chunk;

        int chunkCoordX = chunk.getX();
        int chunkCoordZ = chunk.getZ();

        try {
            ResultSet resultSet = chunksTable.getChunk(chunkCoordX, chunkCoordZ);
            if (resultSet.next()) {
                this.owner_uuid = resultSet.getString("owner_uuid");
            }
            else {
                this.owner_uuid = null;
            }
        } catch (Exception e) {
            ChunkClaimsPlugin.logWarn(e.getMessage());
        }

        if (this.owner_uuid != null) {
            this.chunkOwner = Bukkit.getPlayer(UUID.fromString(this.owner_uuid));
        }
    }```
kind hatch
#

This sounds like something composite keys might fix.

quaint mantle
#
public class ChunkLoadEventHandler implements Listener {
    @EventHandler
    public void onChunkLoadEvent (ChunkLoadEvent event) {
        Chunk chunk = event.getChunk();
        Bukkit.getScheduler().runTaskAsynchronously(ChunkClaimsPlugin.getThisPlugin(), () -> {
            new ChunkData(chunk);
        });
    }
}
#
    public static void claimChunk (Player player, Chunk chunk) throws Exception {
        ChunkData chunkData = chunkDataStore.get(chunk);
        if (chunkData.owner_uuid != null && chunkData.owner_uuid.equals("loading")) {
            throw new Exception("Chunk is still loading.");
        }

        if (chunkData.owner_uuid != null) {
            throw new Exception("This chunk is already claimed by " + chunkData.chunkOwner.getName() + ".");
        }

        chunkData.chunkOwner = player;
        chunkData.owner_uuid = player.getUniqueId().toString();
        chunksTable.addChunk(chunkData.owner_uuid, chunk.getX(), chunk.getZ());
    }```
tender shard
quaint mantle
#

i think the problem is resultset.next().

#

do i have to call resultset.next() to get the first result? if that is it, then i am doing that here.

tender shard
#

Yes

#

Oh ok

quaint mantle
#

but it still sets owner_uuid to null

#

which means

#

resultset.next() is not returning anything

kind hatch
#

There is also ResultSet#first()

tender shard
#

Havent seen that part, sorry, im only on the phone. If you do call next() and its still null, then the issue is sth else

quaint mantle
tender shard
quaint mantle
#

i mean it is returning false

tender shard
#

Then your query is wrong

quaint mantle
#

then it is the query

#

but what is wrong with this query

#

i dont see it

#
getChunk = db.createPreparedStatement("SELECT * FROM Chunkclaims WHERE (coordX=? AND coordZ=?);");```
tender shard
#

Print our your SELECT

quaint mantle
#
this.executeStatement("CREATE TABLE IF NOT EXISTS Chunkclaims (" +
                "owner_uuid text NOT NULL," +
                "coordX int NOT NULL," +
                "coordZ int NOT NULL," +
                "FOREIGN KEY (owner_uuid) REFERENCES Players(uuid)" +
                ");" +
                "");```
tender shard
#

Probably coordX or Z isnt correct

tender shard
quaint mantle
#

what is wrong with that query?

#

i am so confused

tender shard
#

Print it out

quaint mantle
#

print what out?

tender shard
#

The query statement

kind hatch
#

Print out the result of the query.

quaint mantle
#

ok

tender shard
#

Probably you check for โ€žwhere x=0.000โ€œwhile db says x is 0 instead of 0.000 or sth

quaint mantle
#

i am using ints

tender shard
#

Oh ok

#

Anyway, print it out

quaint mantle
#

not sure where decimal digits come from.

tender shard
#

As said, im only on the phone, im in the bathtub rn. All i can do is to suggest what iโ€˜d do, thereโ€˜s no guarantee that any of this will help lol

quaint mantle
#
try {
            ResultSet resultSet = chunksTable.getChunk(chunkCoordX, chunkCoordZ);
            if (resultSet.next()) {
                this.owner_uuid = resultSet.getString("owner_uuid");
                System.out.println(resultSet);
            }
            else {
                this.owner_uuid = null;
            }
        } catch (Exception e) {
            ChunkClaimsPlugin.logWarn(e.getMessage());
        }```
tender shard
#

Just do sth like โ€žSystem.out.println(myQuery)โ€œ where myQuery is sth like โ€žSELECT * FROM โ€ฆโ€œ

#

Then check what it says

quaint mantle
#

do you want me to print the PreparedStatement or ResultSet?

tender shard
#

The statement pla

#

Pls*

quaint mantle
#

ok i am tired for now

#
[11:00:02 INFO]: PulseSapphire joined the game
[11:00:02 INFO]: PulseSapphire[/127.0.0.1:56747] logged in with entity id 91 at ([world]4987.539328703592, 80.0, 5040.021875761163)
[11:00:02 INFO]: org.sqlite.jdbc4.JDBC4ResultSet@7338d078
[11:00:02 WARN]: [Chunkclaimsplugin] ResultSet closed
[11:00:02 INFO]: org.sqlite.jdbc4.JDBC4ResultSet@7338d078
[11:00:02 WARN]: [Chunkclaimsplugin] ResultSet already requested
[11:00:02 WARN]: [Chunkclaimsplugin] [SQLITE_MISUSE]  Library used incorrectly (bad parameter or other API misuse)
[11:00:02 WARN]: [Chunkclaimsplugin] ResultSet already requested
[11:00:02 WARN]: [Chunkclaimsplugin] ResultSet already requested
[11:00:02 WARN]: [Chunkclaimsplugin] ResultSet already requested
[11:00:02 WARN]: [Chunkclaimsplugin] ResultSet already requested
[11:00:02 INFO]: org.sqlite.jdbc4.JDBC4ResultSet@7338d078
[11:00:02 WARN]: [Chunkclaimsplugin] Plugin Chunkclaimsplugin v1.0-SNAPSHOT generated an exception while executing task 1615```
#

now it starts printing this error.

tender shard
#

Oh please do getAsSting() or however its called on the prepared statement before printing it

#

My bad

#

I want to see the exact query

#

The string thats like โ€žSELECT * from whatever etc etcโ€œ

quaint mantle
#
getChunk = db.createPreparedStatement("SELECT * FROM Chunkclaims WHERE (coordX=? AND coordZ=?);");```
tender shard
#

Nooo

quaint mantle
#

this is the exact query.

kind hatch
#

He wants to see the query with the values filled in.

tender shard
#

Print out what the โ€žfilled outโ€œ statement is

quaint mantle
#

oh

tender shard
quaint mantle
#

how do i get that?

tender shard
#

Tbh not sure, just google โ€žjava print out prepared statementโ€œ

#

As said im in the bathtub and using the phone is a pain lol

kind hatch
#

You should just be able to print out the query. System.out.println(query);

tender shard
quaint mantle
#

no i printed the resultset

kind hatch
#

^

tender shard
#

Oooh ok

quaint mantle
#

System.out.println(getChunk.toString());

#

i am printing the preparedstatement here

#
    public ResultSet getChunk (int chunkCoordX, int chunkCoordZ) throws SQLException {
        getChunk.setInt(1, chunkCoordX);
        getChunk.setInt(2, chunkCoordZ);
        System.out.println(getChunk.toString());
        return getChunk.executeQuery();
    }```
tender shard
#

Yeah do that. Then afterwards, do a manual query on your sql server and youโ€˜ll probably see that it indeed doesnt return anything

quaint mantle
#
 parameters=[11, 3]
[11:08:58 INFO]: [Chunkclaimsplugin] [STDOUT] SELECT * FROM Chunkclaims WHERE (coordX=? AND coordZ=?);
 parameters=[-11, 2]
[11:08:58 INFO]: [Chunkclaimsplugin] [STDOUT] SELECT * FROM Chunkclaims WHERE (coordX=? AND coordZ=?);
 parameters=[11, 4]
[11:08:58 INFO]: [Chunkclaimsplugin] [STDOUT] SELECT * FROM Chunkclaims WHERE (coordX=? AND coordZ=?);
 parameters=[11, 4]
[11:08:58 INFO]: [Chunkclaimsplugin] [STDOUT] SELECT * FROM Chunkclaims WHERE (coordX=? AND coordZ=?);
 parameters=[-11, 4]
[11:08:58 INFO]: [Chunkclaimsplugin] [STDOUT] SELECT * FROM Chunkclaims WHERE (coordX=? AND coordZ=?);
 parameters=[-11, 7]
[11:08:58 INFO]: [Chunkclaimsplugin] [STDOUT] SELECT * FROM Chunkclaims WHERE (coordX=? AND coordZ=?);
 parameters=[11, 7]
[11:08:58 INFO]: [Chunkclaimsplugin] [STDOUT] SELECT * FROM Chunkclaims WHERE (coordX=? AND coordZ=?);
 parameters=[-11, 8]
[11:08:58 INFO]: [Chunkclaimsplugin] [STDOUT] SELECT * FROM Chunkclaims WHERE (coordX=? AND coordZ=?);
 parameters=[11, 8]```
#

this is probably the plugin loading the spawn chunks.

#

after server start

tender shard
#

Do a manual โ€žSELECT * from Chunkclaims where coordX = -11 and coordZ=4โ€œ

quaint mantle
#

WTF

tender shard
#

Does that return anything?

quaint mantle
#
parameters=[320, 339]
[11:10:52 INFO]: [Chunkclaimsplugin] [STDOUT] SELECT * FROM Chunkclaims WHERE (coordX=? AND coordZ=?);
 parameters=[320, 339]
[11:10:52 INFO]: [Chunkclaimsplugin] [STDOUT] SELECT * FROM Chunkclaims WHERE (coordX=? AND coordZ=?);
 parameters=[321, 339]
[11:10:52 INFO]: [Chunkclaimsplugin] [STDOUT] SELECT * FROM Chunkclaims WHERE (coordX=? AND coordZ=?);
 parameters=[304, 339]
[11:10:52 INFO]: [Chunkclaimsplugin] [STDOUT] SELECT * FROM Chunkclaims WHERE (coordX=? AND coordZ=?);
 parameters=[299, 339]
[11:10:52 INFO]: [Chunkclaimsplugin] [STDOUT] SELECT * FROM Chunkclaims WHERE (coordX=? AND coordZ=?);
 parameters=[304, 339]
[11:10:52 INFO]: [Chunkclaimsplugin] [STDOUT] SELECT * FROM Chunkclaims WHERE (coordX=? AND coordZ=?);
 parameters=[304, 339]
[11:10:52 INFO]: [Chunkclaimsplugin] [STDOUT] SELECT * FROM Chunkclaims WHERE (coordX=? AND coordZ=?);```
#

i am around (0, 0)

#

and i was flying around

#

my chunk coords in f3 are (0, 0) to (20, 20)

#

why is this as high as 300

#

WTF

#

WHAT THE HECK

#

THIS HAS BEEN THE ISSUE THIS ENTIRE TIME

regal scaffold
#

java.lang.NullPointerException: Cannot invoke "Object.hashCode()" because "key" is null

#

?paste

undone axleBOT
remote swallow
#

?stacktrace

undone axleBOT
regal scaffold
remote swallow
#

He knew

regal scaffold
#

Of course lol

#

Here help me out with this bro :git-Paper-

#

How to fix bro!>!?!?!?!

tender shard
#

so you found the problem? because then I can finally go to sleep ahaha

regal scaffold
#

Now I know this has to do with what I did with....i can't remember his name rn

#

We did this

tender shard
regal scaffold
#
public enum MobName {


    LEVEL_1(1, new Weighted<>("MinerZombie",1)),

    LEVEL_2(2, new Weighted<>("Samurai", 1)),

    LEVEL_3(3, new Weighted<>("ToxicZombie", 1)),

    LEVEL_4(4,  new Weighted<>("FrozenInhabitant", 1));


    private final int level;
    private WeightedRandomGenerator<String> randomGenerator = new WeightedRandomGenerator<>();

    @SafeVarargs
    MobName(int level, Weighted<String>... names) {
        this.level = level;
        for (Weighted<String> name : names) {
            randomGenerator.addItem(name.getObject(), name.getWeight());
        }
    }

    public String getRandomName() {
        return randomGenerator.generateRandom();
    }

    public static String getMobName(int level) {

        for (MobName mobName : MobName.values()) {
            if (mobName.level == level) {
                mobName.getRandomName();
            }
        }
        return null;
    }
}
remote swallow
#

Whats dungeon game ln 183

tender shard
regal scaffold
#

We made a weighted mob enum thing

#

public class Weighted<E> {
    private final E object;
    private final double weight;

    public Weighted(E object, double weight) {
        this.object = object;
        this.weight = weight;
    }

    public double getWeight() {
        return weight;
    }

    public E getObject() {
        return object;
    }
}

tender shard
#

I made a weighted YOUR MOM enum thing

regal scaffold
#

I can't remember his name

remote swallow
#

Im gonna get up for this, ill be on my pc in like 5-10 minutes

tender shard
regal scaffold
#

LMAO

#

Thanks ebic

#

I'll find his name

#

In the meantime

tender shard
#

lets also not forget that imajin sucks

regal scaffold
#

minion325

tender shard
#

who's that

regal scaffold
#

The guy who helped me to what I just sent

#

Im gonna put it all in 1 paste

tender shard
#

oh

regal scaffold
#

There

kind hatch
#

Huh, not all that different from my weighted system. lol

regal scaffold
#

MobName.getMobName(currentLevel) That's what gave the error

#

Well unless your weighted system gives you big errors lol

#

I'm ngl he had to help me understand it so not even sure wtf Object.hashCode() could mean

#

Like in my brain I understand how it works

#

wtf even is that, on a side note

tender shard
#

wdym

regal scaffold
#

"record" but I just looked it up

remote swallow
#

okay im on pc

tender shard
#

records are the most useless invention to java ever

regal scaffold
#

lol

remote swallow
#

time to turn my brain on

tender shard
#

they are like immutable @Data classes

regal scaffold
#

ebic you want context on what we're trying to do?

remote swallow
#

sure

regal scaffold
#
    LEVEL_1(1, new Weighted<>("MinerZombie",1)),

    LEVEL_2(2, new Weighted<>("Samurai", 1)),

    LEVEL_3(3, new Weighted<>("ToxicZombie", 1)),

    LEVEL_4(4,  new Weighted<>("FrozenInhabitant", 1));
#

Each one of the enum entries corresponds to a String of a mobname that is for that level. Levels are in numbers (1, 2, 3, 4) not the "level_1" etc

#

I wanted a system that I could add multiple strings (mobnames) and a weight and with that information doing MobName.getRandom(level) it would return a random mobname for that level

#

You know how weights work so yeah

#

And according to the error and when it happened something went wrong from #getRandom to return

tender shard
#

fix it @remote swallow

regal scaffold
#

LEVEL_1(1, new Weighted<>("MinerZombie",1), new Weighted<>("Mob2",1)) would do 50% random between both. for example

kind hatch
#

There's a difference between weighted systems and percent based ones.

remote swallow
#

add a sys out on the getMobName and getRandomName

regal scaffold
#

wait...

#

Am I looking at the right thing getMobName()

#

Is it never returning the correct thing?

remote swallow
#

oh god

kind hatch
#

Idk, it's hard to tell by the stacktrace. What's line 183 of DungeonGame?

remote swallow
#

i just realised

#

lmfao

regal scaffold
#

LOL

remote swallow
regal scaffold
#

I just did too

remote swallow
#

you never return the string

regal scaffold
#

You could blame me

#

But I blame minion

#

Technically you did fix it

#

If you didn't ask for a sysout in there

remote swallow
#

i looked at it

#

and didnt see anything off

#

you said its never returning the right thing

#

then i saw it

rare rover
#

im trying to connect a database to an external server and its refusing to connect?

#

first time doing this

#

so

#
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Caused by: java.net.ConnectException: Connection refused```
#

code

#
public Connection connection;

    public Connection getConnection() throws SQLException {

        String url = "jdbc:mysql://localhost:3306/embarkkmines";
        String user = "root";
        String password = "";

        Connection connection = DriverManager.getConnection(url, user, password);

        this.connection = connection;
        Bukkit.getLogger().log(Level.INFO, "Connected to database!");
        return connection;
    }```
regal scaffold
#

Do you have jdbc?

rare rover
#

uh, its an external server idk

#

you mean on the plugin or the server?

#

sorry

regal scaffold
#

No worries

remote swallow
kind hatch
rare rover
#

i'll try the dependency rq

regal scaffold
#

np. I would give you more detailed steps but I actually haven't done that in years

#

I'm sure someone else will if you can't do it

rare rover
#

Caused by: java.lang.SecurityException: Invalid signature file digest for Manifest main attributes ๐Ÿค”

#

that's the only error now

regal scaffold
#

Ok out of my area now

rare rover
#

xD

#

thanks tho

regal scaffold
#

Just wait until someone helps you

sullen marlin
#

Post the full error

rare rover
#

oop

#
    at sun.nio.ch.Net.pollConnect(Native Method) ~[?:?]
    at sun.nio.ch.Net.pollConnectNow(Net.java:672) ~[?:?]
    at sun.nio.ch.NioSocketImpl.timedFinishConnect(NioSocketImpl.java:542) ~[?:?]
    at sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:597) ~[?:?]
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:327) ~[?:?]
    at java.net.Socket.connect(Socket.java:633) ~[?:?]
    at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:153) ~[mysql-connector-java-8.0.29.jar:8.0.29]
    at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:63) ~[mysql-connector-java-8.0.29.jar:8.0.29]
    at com.mysql.cj.NativeSession.connect(NativeSession.java:120) ~[mysql-connector-java-8.0.29.jar:8.0.29]
    at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:948) ~[mysql-connector-java-8.0.29.jar:8.0.29]
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:818) ~[mysql-connector-java-8.0.29.jar:8.0.29]
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:448) ~[mysql-connector-java-8.0.29.jar:8.0.29]
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:241) ~[mysql-connector-java-8.0.29.jar:8.0.29]
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198) ~[mysql-connector-java-8.0.29.jar:8.0.29]
    at java.sql.DriverManager.getConnection(DriverManager.java:681) ~[java.sql:?]
    at java.sql.DriverManager.getConnection(DriverManager.java:229) ~[java.sql:?]
    at me.outspending.embarkkmines.API.Database.Database.getConnection(Database.java:20) ~[EmbarkkMines-0.0.1.jar:?]
    at me.outspending.embarkkmines.EmbarkkMines.onEnable(EmbarkkMines.java:15) ~[EmbarkkMines-0.0.1.jar:?]
    ... 26 more```
#

sorry for ghost ping ๐Ÿ˜“

regal scaffold
#

I believe connection refused means you put your login information incorrectly

rare rover
#

localhost:(server's port)?

regal scaffold
#

Or the server is not reachable

#

Is that where the server is hosted?

rare rover
#

Minehut

regal scaffold
#

Then no

rare rover
#

;-;

#

sad

regal scaffold
#

I assume the server and sql server are on the same, correct?

rare rover
#

yeah

regal scaffold
#

minehut should give you login credentials when you make a datbase

rare rover
#

i dont see that

#

would sqlite work?

regal scaffold
#

Yes it would, are you making your own plugin or trying to connect another plugin?

rare rover
#

im just trying to store data

#

that's all

regal scaffold
#

sqlite, yml, json

#

all work

rare rover
#

okay, i'll use sqlite

#

thank you kind sir

regal scaffold
#

Let me know if you keep getting issues

#

Search how to start with sqlite and spigot

remote swallow
rare rover
#

i'll just use sqlite

#

no problem there

kind hatch
regal scaffold
#

Hey alright so I just had a major issue here. I thought I had failsafes for mob spawning but I was wrong

#

@kind hatch Wanna give it a look?

kind hatch
#

I suppose

regal scaffold
#
    private void generateLevel() {

        new BukkitRunnable() {
            @Override
            public void run() {
                mythicMob = MythicBukkit.inst().getMobManager().getMythicMob(MobName.getMobName(currentLevel)).orElse(null);
                if (mythicMob == null) {
                    cancel();
                    return;
                }
                if (state == State.BOSS_FIGHT) {
                    cancel();
                    return;
                }
                if (spawnedCount >= 40) {
                    return;
                }
                for (int i = 0; i < 5; i++) {
                    Location location = locations.getRandomLocation();
                    mythicMob.spawn(BukkitAdapter.adapt(location), 1);
                }
            }
        }.runTaskTimer(plugin, 1, 10);
    }
kind hatch
regal scaffold
#

So what I think is happening here is that #generateLevel() is getting called from

#

another taskTimer() and I think it's creating infinite instances of itself

#

Cause at the start it's all g but the longer it goes the more it spams and then 1k mobs

#

But I can't really think of others ways to do this

kind hatch
#

Well, as long as this isn't called multiple times you should be fine. This looks like state management to me and I'm not that great at it. lol

regal scaffold
#

This is the structure

#
        new BukkitRunnable() {
            @Override
            public void run() {
                if (!isEnabled()) {
                    return;
                }
                activateDungeon();  <----------- state manager which then calls generateLevel()
                                         ------- Then generatelevel calls it's own task
            }
        }.runTaskTimer(plugin, 0, 40);
kind hatch
#

Oh, I guess the one thing I would check is the spawnedCount variable. Shouldn't you be incrementing that everytime you spawn the mob?

regal scaffold
#

Well I'm doing that here

#
    @EventHandler
    public void preventMobSpawn(MythicMobSpawnEvent event) {
        if (event.getLocation().getWorld() != world)
            return;
        if (state == State.IN_PROGRESS || state == State.BOSS_FIGHT) {
            event.setCancelled(false);
            spawnedCount++;
            return;
        }
        if (spawnedCount <= 40) {
            event.setCancelled(false);
            return;
        }
        event.setCancelled(true);
    }
#

And then the opposite on DeathEvent

#

But since like I said, starts perfectly then after a bit it floods hard

#

I assume I have a inf loop somewhere

#

Like look at these logs

#
[00:55:01] [Server thread/INFO]: [Dungeonmaster] [STDOUT] MinerZombie
[00:55:01] [Server thread/INFO]: [Dungeonmaster] [STDOUT] MinerZombie
[00:55:01] [Server thread/INFO]: [Dungeonmaster] [STDOUT] MinerZombie
[00:55:01] [Server thread/INFO]: [Dungeonmaster] [STDOUT] MinerZombie
#

4 in one second

#

And if I fast foward

#

lol

#

In the same time

#

@remote swallow you still awake? This gonna make up for the thing before hehe

kind hatch
#

You should attach the taskId to the debug messages if possible.

regal scaffold
#

Sure I'll crash the server again 3 mins

regal scaffold
#

Indeed @kind hatch

#

I was right? I think?

#

Ignore the cooldown

#

Starts off with 1 task

#

Then more

#

I thought this shit was synced

#

Why is it duping itself

kind hatch
#

Looks like you've got some tasks that aren't being killed off. :p

regal scaffold
#

Well ok maybe I'm wrong on how I'm doing this

#

The thing I'm doing which I believe is not the best that my gamestate manager is always running. in a task itself

#

And when the moment comes I'm trying to loop through that generate level until the gatestate changes

remote swallow
#

are those debug messages starting instantly as the server starts or do you trigger it with an event/command

regal scaffold
#

Nah

#

When I play

#

It's this part

regal scaffold
#

As soon as that thing gets activated #generateLevel()

#
[01:13:00 INFO]: [Dungeonmaster] [STDOUT] taskid: 3387 coolDown: 10
[01:13:00 INFO]: [Dungeonmaster] [STDOUT] taskid: 3387 coolDown: 10
[01:13:01 INFO]: [Dungeonmaster] [STDOUT] taskid: 3387 coolDown: 10
[01:13:01 INFO]: [Dungeonmaster] [STDOUT] taskid: 3457 coolDown: 10
[01:13:01 INFO]: [Dungeonmaster] [STDOUT] taskid: 3387 coolDown: 10
[01:13:01 INFO]: [Dungeonmaster] [STDOUT] taskid: 3457 coolDown: 10
[01:13:02 INFO]: [Dungeonmaster] [STDOUT] taskid: 3387 coolDown: 10
[01:13:02 INFO]: [Dungeonmaster] [STDOUT] taskid: 3457 coolDown: 10
[01:13:02 INFO]: [Dungeonmaster] [STDOUT] taskid: 3387 coolDown: 10
[01:13:02 INFO]: [Dungeonmaster] [STDOUT] taskid: 3457 coolDown: 10
#

See how first 4 tasks are the right one

#

I assume it does that after 4 tics because

kind hatch
#

How many times is that method getting called?

regal scaffold
#

1

#

Inside another task lol

kind hatch
#

What's the other task?

regal scaffold
#
            @Override
            public void run() {
                if (!isEnabled()) {
                    return;
                }
                activateDungeon();  <----------- state manager which then calls generateLevel()
                                         ------- Then generatelevel calls it's own task
            }
        }.runTaskTimer(plugin, 0, 40);
#

This

kind hatch
#

Ok, that's why.

regal scaffold
#

Yes but

#

Why would that happen

#

Before I had the task inside activateDungeon

kind hatch
#

Because it runs a task on a timer. Meaning repeat the code inside this block every X ticks.

regal scaffold
#

and sometimes it would go outside of scope