#development

1 messages ยท Page 136 of 1

rigid mountain
lyric gyro
#

Oh boy it's time to teach dependency injection

#

Are you familiar with what a constructor is?

#

Anyway, you want to get rid of all that static, all of it. static is evil, you want to do basically this from the examples ๐Ÿ‘‡ but with your classes

neat pierBOT
rigid mountain
#

Ok, so i shouldnt use a Main instance, instead pass in main into the constructor?

lyric gyro
#

correct

rigid mountain
#

Ok, let me change that rq

lyric gyro
#

That looks much better except that it doesn't compile lol
that new GuildData(this) shouldn't be needed, and you need to pass this when calling new PlayerEvents ๐Ÿ˜„

rigid mountain
#

yeah i noticed that after i copied it lol

#

let me try this and see

#

Still getting the same error

#

idk where it is coming from

lyric gyro
#

hm, how are you building your plugin?

rigid mountain
#

With maven

lyric gyro
#

ah, you need to put <scope>provided</scope> for the guilds dep too, you're probably shading it (bundling it inside your own jar) and it's doing pretty nasty things

rigid mountain
#

Ok, let me try that

#

Same error even if i add that

winged pebble
#

And it's in the plugins folder?

rigid mountain
#

the guilds plugin?

#

yep and all dependencies

rigid mountain
#

Any ideas?

night ice
dense galleon
#

What's the directory holding the enchantment glyphs?

rigid mountain
night ice
#

U might be adding realocation on dependency plugin

rigid mountain
mint trail
#

help with deluxe tags for some reason when i use rgb and mutliple colors and things like that
for example &#c745ff&lN&#ff15e8&la&#c745ff&lm&7
it isnt just "nam" in colors
it look like this "&n&a&m" with colors and it really fucked even tho when i type the same thing in chat normaly without it using the plugin is look fine
and i have no idea what to do

night ice
rigid mountain
#

Im still getting the same error

night ice
#

btw, how are you building your plugin?

dense galleon
#

can I sort a Map based on the return value of a method of the items present in the keyset of the map?

sterile hinge
#

what

dense galleon
#

Say I got a map Map<Enchantment, Integer>, and the Enchantment class has a method getWeight() which returns an integer

I want to sort the map based on what each object in the map returns using that method

#

enchantMap.keySet().stream().sorted(Comparator.comparingInt(o -> o.getWeight())).forEach(enchantment -> System.out.println(enchantment.getDescriptionId())); I tried doing this

sterile hinge
#

use a TreeMap with a custom comparator

dense galleon
#

But it didn't do much

#

When I tried using a TreeMap it complained to me saying that Enchantment is not a comparable item

sterile hinge
#

note that a tree map has other asymptotic characteristics

sterile hinge
dense galleon
#

How would I make a custom comparator..?

sterile hinge
#

something like new TreeMap<>(Comparator.comparintInt(Enchantment::getWeight)); should do the trick iirc

dense galleon
#

Oh wow okay I didn't even think of that

warm wing
#

anyone know how I could access a variable from another class?

dense galleon
#

I gotta do the whole keyset().stream().sorted() thing

sterile hinge
#

it should keep the map sorted the whole time

night ice
dense galleon
#

Well, it doesn't seem to be sorted ๐Ÿ˜…

sterile hinge
#

(as long as the weight does not change)

dense galleon
#

or maybe it is hold on

#

I'm dum, gotta double check

queen plank
#

I try to copy a section of blocks, WE-like. However, I can't figure out how to copy double chests. Regular ones are fine, but since there are two blocks idk how to get the other one for a Block instance. I know there is a getLeftSide and getRightSide but how do I know which one is which?

dense galleon
#

If there's like 5 items with the same getWeight() value, it should sort based on another value

#

It's another int

sterile hinge
#

.thenComparing[Int/Double/etc](...) or something like that on your comparator

dense galleon
#

Oh that's cool

#

uhm something's up

#

When adding the thenComparing, for some reason o is no longer of type Enchantment according to my IDE

sterile hinge
#

yeah type infering isn't strong enough there, you can write it as .<Enchantment>thenComparing though

dense galleon
#

Ahhhh I was so close to figuring that out

#

Alright

rigid mountain
lyric gyro
#

hey where do i place the command: so it would work
left/right click

viral star
#

@graceful hedge smells

graceful hedge
#

nah

rigid mountain
#

Still having this issue if anyone has any ideas

sharp cove
#

When i am changing my minecraft plugin to 1.18 i get this error when i try compiling:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project Kingdom: Compilation failure An unknown compilation problem occurred
https://www.toptal.com/developers/hastebin/ihohuyihes.xml <-- My pom.xml

winged pebble
#

First thing you should change is don't include spigot twice

#

You only need to include spigot if you already have that then you don't need spigot-api

sharp cove
#

Oke thank you

winged pebble
#

You also don't need the online repo if you have it installed locally (which you probably do if you have the spigot artifact)

sharp cove
#

Yeah but i only want to solve my error tho

winged pebble
#

What else does it say?

sharp cove
#

Thats the only thing

#

Thats the weird thing too haha

#

Maybe changing the java version

#

But how?

winged pebble
#

Your version in the pom is set to 8 rn

#

But I feel like if that was the issue, it'd give you a better error message

rigid mountain
#

Question, im trying to make some quests, but im wondering how i should track the progress of each quest?

rigid mountain
#

Nvm, i figured out a way, but now i have an optimization question.

So the quests are configureable so im loading them from config, and currently i do it like so:

            QuestType type = QuestType.valueOf(config.getString("blacksmith." + key + ".type"));
            int amount = config.getInt("blacksmith." + key + ".amount");
            String m = (config.isSet("blacksmith." + key + ".id") ? (config.getString("blacksmith." + key + ".id")) : null);
            int karma = config.getInt("blacksmith." + key + ".karma");
            String name = config.getString("blacksmith." + key + ".name");
            List<String> lore = Utils.color(config.getStringList("blacksmith." + key + ".lore"));
            List<String> commands = config.getStringList("blacksmith." + key + ".commands");
            String area = config.getString("blacksmith." + key + ".area");

            Quest q = new Quest("blacksmith", type, amount, m, karma, name, lore, commands, area);
            blacksmith.add(q);
            allQuest.add(q);
        });```

While this works, if i were to do this for **every** player i have a feeling it will get intensive. So once i create these objects, and store them in a list is there any way to basically duplicate that list, but with different object ids? Duplicated each object? or is there a better way of doing this?
dusky harness
#

How do I delete a plugin after the server stops?
deleteOnExit doesn't seem to work ๐Ÿ˜•

I remember seeing a plugin auto updating itself and deleting the old version... but I don't remember the name of the plugin D:

If I add a shutdown hook (to unload the plugins that I want to delete after they unloaded), then I get this error: IllegalStateException: zip file closed
although the code inside (I added a print to test) works

lyric gyro
#

put the new file inside the ./plugins/update folder

#

the server will replace it on startup

dusky harness
#

waaaaaaaaaaaaaaait what

lyric gyro
#

update or updates, hold on

#

yes, that's a thing

dusky harness
#

๐Ÿ˜ฎ ๐Ÿ˜ฎ ๐Ÿ˜ฎ i never knew

#

wait

#

so spigot automatically removes the old jar?

#

oh wait no

lyric gyro
#

there's an "update-folder" setting or whatever inside bukkit.yml, check that

dusky harness
#

Lightbulb.png Note: Ensure the name of the .jar in the update directory is the same as the name of the .jar in the plugins directory for the same plugin.
hm

lyric gyro
#

that's where you put the new file

lyric gyro
lyric gyro
#

yes

dusky harness
#

๐Ÿ˜ฎ

#

oh is it only 1.18

#

Hmmm

#

not that i use other versions

#

but if other people use it

#

its limited to 1.18

#

ยฏ_(ใƒ„)_/ยฏ

lyric gyro
#

then uh.. save the new file with the same name as "this" file?

#

idk lol

#

but yeah that's actually a really neat feature very few people know about

dusky harness
#

ty

#

although for solving the issue without requiring the same file name, maybe I could disable & unload the plugins... manually in onDisable? ๐Ÿ‘€

#

hmm

lyric gyro
#

uh

#

why...? the server is already unloading

dusky harness
#

on windows

#

the disablePlugin method has a check to see if it's enabled

#

so I think that disabling other plugins in onDisable shouldn't cause any issues

lyric gyro
#

uh.. and how does that solve anything?

#

you're unloading other plugins

dusky harness
#

(after running some code that plugman uses)

#

(or plugwoman)

lyric gyro
#

deleting your own file
after disabling other plugins
from code that is inside your file
currently open and running?

wintry grove
#

wack

dusky harness
#

deleting other plugins files

#

but once i disable

#

it shouldn't be running anymore

#

i think

lyric gyro
#

on newer versions their class loader is closed when disabling it, that isn't the case in older versions
unless you're using paper

dusky harness
#

close the classloader

#

noo why 1.13+

#

plugwoman

#

ah well

#

plugmanx supports 1.8

#

ยฏ_(ใƒ„)_/ยฏ

lyric gyro
dusky harness
#

will that unlock the file?

#

in windows

lyric gyro
#

dunno

#

oh and in newer vesions the library loader class loader isn't closed so uh

#

basically you're in for a ride

dusky harness
#

library loader?

#

๐Ÿ‘€

lyric gyro
#

yes, the libraries thing in the plugin.yml to download libraries on startup form central instead of shading everything

dusky harness
#

oh

#

aaaaaa

#

wait

#

well that will be in the server classloader

#

wouldn't it?

lyric gyro
#

no, it's a separate one

dusky harness
#

but that would mean it's separate from the plugin fingerguns

#

i think

lyric gyro
#

it is, but those libraries could contain references to classes from your file

dusky harness
#

True

#

hmm

#

ill just make it so that if the file deletion errors out, then it'll just skip it until I find a solution ๐Ÿฅด

lyric gyro
#

just put the file in the updates folder lol

dusky harness
#

oh i could do that

#

ill make the backup solution

#

๐Ÿ™ƒ

lyric gyro
dusky harness
#

(since i want to support older versions)

#

(and the paper thing is only 1.18)

lyric gyro
#

it's just that good

dusky harness
#

deleteOnExit does indeed work ๐Ÿ˜ƒ

dusky harness
#

all the other plugins work tho

limber hedge
#

How do I get CraftItem to work on 1.18?

#
final CraftItem craftItem = null;```

Isnt working anymore, it worked on 1.17
sterile hinge
#

Itโ€™s not part of the API

broken elbow
broken elbow
#

oh turns out I can use numbers with decimals. that's helpful

dense galleon
#

Noob question incoming

#

Does a tree data type exist in Java? When looking it up online, I see most people create their own implementation of Trees

solemn ocean
#

anyone knows why if I do
player.damage(60);
i get 60 dmg but if I do
player.damage(60,entityDamager);
where entitydamager is a entity reference it deals only 31.0?

wheat carbon
dense galleon
#

Making a mod which changes the random enchantment system to a tree like enchantment system

#

But I figured it out

hoary scarab
#

Oh IDK if it exists in the minecraft code but it existed in spigot 1.8.8

MaterialData  md = b.getState().getData();
String blockType = (md instanceof Tree) ? ((Tree) md).getSpecies().toString() : ((Leaves) md).getSpecies().toString();
if(blockType != null) {
    switch(blockType) { 
    case "GENERIC": saplingtype = 0; break;
    case "REDWOOD": saplingtype = 1; break;
    case "BIRCH": saplingtype = 2; break;
    case "JUNGLE": saplingtype = 3; break;
    }
}
dense galleon
#

I mean I'm making a fabric mode anyway ๐Ÿ˜‚ ๐Ÿ˜…

wheat carbon
#

yapps theyโ€™re not talking about ingame trees

dense galleon
#

Oh

bitter grove
#

mans linked a minecraft tree

dense galleon
#

I didnt even

#

๐Ÿ˜‚ ๐Ÿ˜‚ ๐Ÿ˜‚

#

I was kinda confused when he said Leaves

hoary scarab
#

Well it is a minecraft server xD

#

Java 14+ contains Tree | getKind(), accept(TreeVisitor<R,D> visitor, D data)
All I could find.

dense galleon
#

Alright I ended up making my own data type kinda

sterile hinge
#

Tree structures are often modeled implicitly

dense galleon
dense galleon
#
            EnchNode[] sharpnessNodes = {
                new EnchNode(root, new EnchantmentInstance(Enchantments.SHARPNESS, 1)),
                new EnchNode(sharpnessNodes[0], new EnchantmentInstance(Enchantments.SHARPNESS, 2)),
                new EnchNode(sharpnessNodes[1], new EnchantmentInstance(Enchantments.SHARPNESS, 3)),
                new EnchNode(sharpnessNodes[2], new EnchantmentInstance(Enchantments.SHARPNESS, 4)),
                new EnchNode(sharpnessNodes[3], new EnchantmentInstance(Enchantments.SHARPNESS, 5))
            };``` 

Is there any way to have this snippet of code work
#

It's annoying to have to create a bunch of variables and store them to use later

dense galleon
sterile hinge
#

well just design it as actual tree structure

#

means an enchantment has n children

dense galleon
#

Which holds EnchNode instances?

#

Or I mean an array of those

sterile hinge
#

just embed it into your Enchantment type

#

no need for an explicit tree structure

dense galleon
#

Can't really embed it in there

#

Or I mean I can, just not sure if it's really worth it

sterile hinge
#

yeah then you need a wrapper

proud pebble
#

what is this for?

queen plank
#

How do I use a particle without it flying away? I have a way to make shapes out of particles and am trying different particle effects. However, some particles (like flame) just fuqs off in mach 2.

barren ore
#

You need the make a repeating task

rigid mountain
#

How can i remove all of the messages Mongo sends on connection?

tacit belfry
#

For some reason with maven whenever i do:

         <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.18.2-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>```
It doesn't work. The latest version it sees is 1.17
#

I understand that 1.18 changed the spigot api?

dusky harness
tacit belfry
#

yeah I want NMS

#

but wait why do I have to run buildtools if its getting it from a repo

tacit belfry
#

oh

dusky harness
#

its getting from local maven repo

#

since you can't host the minecraft jar online (legally)

tacit belfry
#

oop ok

past ibex
#

codemc has an illegal repo

#

although it is illegal so you shouldn't add it to your repositories then use it so that others don't have to use buildtools to compile your plugin

tacit belfry
#

erm why is TPS hard coded..

stuck hearth
#

Likely the max it can be, makes sense it would be set at 20

tacit belfry
#

Is there any way to get the actual server TPS?

hoary scarab
tacit belfry
hoary scarab
#

I don't use paper. And just have a runnable caching the times it runs and calculate if its within 50ms of each other

tacit belfry
#

Ok thanks

tardy cosmos
#

Does anyone know a better regex for converting spigot-style hex codes to #ffffff format? what I have works but it's pretty clunky

public static String decolorize(String string) {
    if (string == null || string.isEmpty())
        return string;
    return string.replace(ChatColor.COLOR_CHAR, '&').replaceAll("&x&([0-9A-Fa-f])&([0-9A-Fa-f])&([0-9A-Fa-f])&([0-9A-Fa-f])&([0-9A-Fa-f])&([0-9A-Fa-f])", "#$1$2$3$4$5$6");
}

I'm not exactly an expert with regex so I don't know if there's a better way to handle the matching groups. I know that &x(&[0-9A-Fa-f]){6} matches the spigot-style hex code properly but then I don't know of a way to transform it to the #ffffff format

hoary scarab
tardy cosmos
#

I'm trying to transform the color codes back to a readable format, not remove them entirely

#

otherwise yes that would have worked

hoary scarab
#

Ah. One sec then

tardy cosmos
#

Basically &x&a&b&c&d&e&f -> #abcdef

hoary scarab
tardy cosmos
#

When you do ChatColor.of() and then toString() on it that's what it transforms into

#

sending that format in a raw string for a chat message sends it as a hex color code lol

#

it's also the format that gets sent with an item's getDisplayName() and getLore() which is what I'm trying to transform

hoary scarab
#

Hmmm... yeah IDK for that then...

tardy cosmos
#

I'll just move the regex to a static final string and call it a day

hoary scarab
#

Kinda odd it would format like that.

tardy cosmos
warm steppe
tardy cosmos
#

no.. you don't?

lyric gyro
#

I used something like that before for a gradient chat plugin. I can send it over here when I get on

tardy cosmos
#

don't feel like using a massive messaging framework like that is necessary for only parsing this small situation, a fair suggestion though

hoary scarab
# tardy cosmos <a:Sparkle:887507928540663928> magic <a:Sparkle:887507928540663928>

So IDK about using regex but you can probs loop through the chars

public String decolorHex(String string) {
    Set<String> hexCodes = new HashSet<>();
    for(int i = 0; i < string.getLength(); i++) {
        if(string.subString(i).equals("&") && string.subString(i+1).equals("x")) {
            hexCodes.add(string.subString(i, i+6))
            i = i+6;
        }
    }

    String edit = string;
    for(String code : hexCodes)
        edit = edit.replace(code, code.replace("&", ""))
    return edit;
}
```Pesudo code just wrote it up.
dense drift
#

You cant use a normal set for that though, you care about the order

hoary scarab
dense drift
#

Ah, I read it wrong

hoary scarab
#
private Pattern mcFormattedHex = Pattern.compile("&x&([A-Fa-f0-9]){6}");
public String decolorHex(String s) {
    Matcher matcher = mcFormattedHex.matcher(s);
    return matcher.replaceAll(color -> color.replace("&", ""));
}
```This might work....
dense drift
#

Well you can still use a regex for that and remove the section symbol

hoary scarab
# hoary scarab ```java private Pattern mcFormattedHex = Pattern.compile("&x&([A-Fa-f0-9]){6}");...

Ok finally got the pattern right.
Try this @tardy cosmos

String hexString = "&6Hex Colors | #ffa800H#ff9c00e#ff8f00x #ff8200C#ff7400o#ff6500l#ff5400o#ff4000r#ff2400s";

public String removeColor(String s) {
    return s.replace("ยง", "&");
}

private Pattern mcFormattedHex = Pattern.compile("&x([A-Fa-f0-9&]){12}");
public String decolorHex(String s) {
    Matcher matcher = mcFormattedHex.matcher(s);
    return matcher.replaceAll(color -> color.group().replaceAll("&", "").replaceFirst("x", "#"));
}
tardy cosmos
#

I guess that's sort of one way to get around the matcher groups, it would match for things like &x&&&&&&&&&&&& though which I guess isn't horrible but the solution I had for it now might just be easier to do at this point

hoary scarab
#

๐Ÿ‘

tardy cosmos
#

Thanks for the attempts

hoary scarab
#

np. Knew I was getting close xD

worn jasper
#

MiniMessage couldโ€™ve fixed this xd

lyric gyro
#

Yeaaah that's what I suggested

warm steppe
#

mf-msg

#

?mf

neat pierBOT
night ice
#

Someone needs to update those linksโ€ฆThis leads to the old docs right?

pulsar ferry
#

Those are still the current docs, the new ones are very incomplete

pulsar ferry
# warm steppe mf-msg

Use Minimessage instead for most things
Plus you still need adventure for it as well

night ice
pulsar ferry
#

Well only for commands, because the old docs don't have anything for the rewrite, but since the rewrite is still not fully done I don't want to change it yet

proud pebble
#

cus i assumed there was a getter but there isnt.

#

this requires nms unless theres some other way to get it without requiring a certain version

tacit belfry
proud pebble
pine flax
#

Could depend on spark and use their api

plush robin
#

Hello, API for Heroes doesn't work for me, can someone help?

quaint skiff
#

does someone know how to make Tablist Prefixes in Bungeecord plugins (I tried everything i could think of but it never worked (the names just stayed white))

grim oasis
#

?help

neat pierBOT
#
FAQ Answer:
ยป Give the helpers some details
ยป Ask suitable questions
ยป Be polite
ยป Wait

Source

grim oasis
#

classes, what you've tried, what Heroes is, etc.

plush robin
#

Okay, I downloaded Heroes-expansion then reloaded papi, then tried %heroes_main_class_name%, %heroes_class_name% etc... in TabList and SimpleScore, both doesn't work

grim oasis
#

lmao

plush robin
#

Okay

#

xd

rigid mountain
#

How can i remove all the jumble from Mongo https://i.imgur.com/1PxgfDb.png as well as the messages when i use saveResource() saying could not save fileLocation because name already exists?

dense drift
#

for saveResource, check if the file exists before saving it

crimson fox
#

Hey everyone!

#

I'm honestly really keen in learning how to code minecraft plugins. Do any of you have any suggestions on what sort of tutorials to learn from?

#

Like YT videos or anything honestly.

neat pierBOT
#
FAQ Answer:

Online Courses:
Online courses are also great for learning java. Some websites that offer them are:

  • Coursera - Free unless you want a certificate
  • PluralSight - Great courses from what I've seen. Mostly Paid
  • Udemy - Never used them myself but they seem to all or at least most be paid.
    My first ever course was one from Coursera. - I can say it was pretty good at introducing me to the programming world as a whole not just java.

Oracle Docs:
Oracle docs can help a lot at learning and understanding java:

  • Start with this,
  • Breeze through this (skipping stuff that doesn't seem relevant like bitwise operators),
  • Hit this.
    They're the first three from this larger thing which you should definitely go through overall. But those three should be enough for slightly better understanding of what is happening here without feeling like a huge time sink.
    That one is a small part of this larger site wherein "Essential Java Classes" and "Collections" also have good useful stuff

Other services:
Some other cool services that will help you learn java are:

As you can see there are plenty of good ways to learn as long as you're willing to invest the time. Have fun learning!

dense drift
#

quotes are not always needed for strings, only if they start with certain characters or other situations

broken elbow
#

YAML ๐Ÿ˜ฆ

dense drift
#

you can not force it

haughty parrot
#

What if you escape it

#

โ€œ\โ€hi\โ€โ€

lyric gyro
#

it'll probably write '"hi"' lol

#

because it's part of the contents

dense drift
#

exactly

icy shadow
#

Look into ScalarStyle.SINGLE_QUOTED if you really wanna add / remove it

#

youll probablyu need to do some weird stuff though

hoary scarab
#

getConfig().setString("PATH", "A string");

hoary scarab
#

... all

lyric gyro
#

There is only set, there aren't setThing variants

hoary scarab
#

Ah yeap. Thought there was.

lyric gyro
#

that really sucks tho, but like, bleh

hoary scarab
#

Could try just adding .toString() to the value.

icy shadow
#

String#toString just returns this

#

To be precise, it's an identity function

solemn socket
#

Hey guys im having issues with bungee brigadier

#

can anyone help a bit?

#
Required by:
    project :Bungee

Possible solution:
 - Declare repository providing the artifact, see the documentation at (link here)```
tacit belfry
#

I'm trying to do a clientside glowing effect with PacketPlayOutEntityMetadata but i haven't worked with that packet in a while and am unsure what stuff to mess with.

#

Could anyone help?

lost bluff
#

i made my own server with custom ip , not any server from minehut or aternos, ITS A REAL SERVER. (1.8) Im looking for people to help me make it a pvp server like minemen!
if anyone would like to help me, dm me

high edge
#

How about no

misty carbon
#

lol

#

good luck

slow folio
#

How do you set a custom variables value in custom event from a listener

#

My event

#

I'm trying to set the droppedAmount from a listener

proud pebble
tacit belfry
sharp cove
#

Where is the api usage page for this?

#

On how to implement this in maven?

#

Please @ me

sharp cove
#

Thank u

formal crane
#

if i would create a command /Test in my lobby, is it possible to execute something on a other server connected to the bungeecord?

broken elbow
#

not directly from the lobby. you'd either need a plugin on the other server and a plugin on your proxy to relay the information or some other way to relay the information to the plugin on the other server

wintry grove
#

how do I apply a gradle plugin to other subprojects in kotlin DSL?

#

like i have one on the main build.gradle.kts one

#

a plugin applied

#

and I need to apply it to a module

#

nvm found it

shell moon
#

best way to save items in mysql? (like player inventory, or backpacks, etc)

dusty frost
#

Paper binary serialization

shell moon
#

and with spigot?

lyric gyro
#

cry

dusty frost
#

copy the Paper binary serialization method? lmao

shell moon
#

how exactly would that work?

#

if i want to save a backpack for example

#

respecting empty slots

dusty frost
#
    public static ArrayList<byte[]> serializeInventory(Inventory inventory) {
        var bytes = new ArrayList<byte[]>();

        for (ItemStack itemStack : inventory.getContents()) {
            if (itemStack == null) {
                bytes.add(null);
                continue;
            }
            bytes.add(itemStack.serializeAsBytes());
        }

        return bytes;
    }

    public static ArrayList<ItemStack> deserializeInventory(ArrayList<byte[]> inventory) {
        ArrayList<ItemStack> inventoryHolder = new ArrayList<>();

        for (byte[] itemStack : inventory) {
            if (itemStack == null) {
                inventoryHolder.add(null);
                continue;
            }
            inventoryHolder.add(ItemStack.deserializeBytes(itemStack));
        }

        return inventoryHolder;
    }
#

these are my methods for serializing and deserializing an inventory

lyric gyro
#

null woeisme

dusty frost
#

yeah spigot really gotta do us dirty likc that

lyric gyro
#

it's funny because minecraft doesn't use null items at all

#

and by funny i mean unfunny

shell moon
#

thats available on paper since 1.15 only right?

dusty frost
#

no clue, but use latest and Paper

#

you'll be much happier for it

shell moon
#

yeah, i tend to support 1.8 too

dusty frost
#

๐Ÿ˜‰

shell moon
#

and spigot too

dusty frost
#

oh yikes

#

7% ain't look too good

lyric gyro
#

not even i hate myself that much dude

shell moon
#

another alternative?

dusty frost
#

stop developing plugins for a version of minecraft that is 6 years, 9 months, and 22 days old?

#

and only represents 7% of the market share

shell moon
#

mmm not enough

#

any alternatives?

dusty frost
#

have fun lol

pine flax
shell moon
#

weird, i use a similar thing for backpacks in other plugin

#

was expecting something different, but i guess is the only one approach

#

thanks, wonder how long would a deserialized inv is

#

hope it fits in a db column

lyric gyro
#

well it's definitely not the only approach lol

#

it's your only approach

shell moon
#

for spigot and 1.8+?

dusty frost
#

those are choices you made :)

shell moon
#

yeah, and thats prob the only approach to achieve that

dusty frost
#

funnily enough, even your own plugins would still benefit greatly from not supporting 1.8

#

80% on AlonsoTagsPro

#

and around 80% on AlonsoTags

#

at least 80% Paper

#

and at least 75% Paper

stuck hearth
#

Counter argument, 1.8 just have less bstats diversity

dusty frost
#

wtf is "bstats diversity"

cerulean birch
#

so i need to get all the blocks between a player, and 10 blocks in the direction that the player is looking

the player.rayTraceBlocks doesn't really do what I need b/c it just returns the position where it ends, player.getTargetBlock doesn't really suffice either

any recommendations?

edit: gonna try player.getLineOfSight()

dusty frost
cerulean birch
#

this does indeed sound like exactly I need, I'll take a look at it and try it out, thanks!

winged pebble
#

LivingEntity#getLineOfSight(Set<Material>, int) also seems applicable

cerulean birch
winged pebble
#

It doesn't appear to stop at the first block, it goes the distance you pass in, no?

stuck hearth
dusty frost
#

I mean, we gotta draw the line somewhere

cerulean birch
dusty frost
#

We have these metrics, and this guy has bstats on his actual plugins lol

rugged bane
#

I think for free plug-ins, I wouldnโ€™t put the effort in to support 1.8, unless it required no extra time or effort.

However, with paid / commercial stuff, I can see the benefit supporting older versions. Naturally, you want to take as much market share as possible

sterile hinge
#

I doubt youโ€˜d earn enough from 1.8 to cover the extra work you need to put in to make it work (heavily depending on what the plugin does obviously)

dusty frost
#

yeah the cost-to-benefit ratio is rarely in favor of 1.8 these days, especially with dwindling market share at currently 7%

rugged bane
#

Thatโ€™s crazy how itโ€™s now only 7% though

#

Thatโ€™s dropped so quickly

warm steppe
#

Why would this:

@Path("list")
public static final Property<Map<Integer, Map<String, Object>>> CHAMP = Property.create(
        Map.of(
                1, Map.of(
                        "name", "test1",
                        "name_variations", List.of("tt", "aa"),
                        "skin_urls", List.of("tt", "aa")
                ),
                2, Map.of(
                        "name", "test2",
                        "name_variations", List.of("tt", "aa"),
                        "skin_urls", List.of("tt", "aa")
                )
        )
);

throw: class java.lang.Integer cannot be cast to class java.lang.String?

dense drift
#

How does your config look like?

#

Also, an object would help a lot

dusty frost
#

that is a hell of a generic type specification lmao

hoary scarab
#

It depends on the plugin type too. Which game mode the plugin is mostly used by etc...

For example with my minions plugin it's more beneficial on skyblock but it's also used in prison, factions, survival and I think atleast one towny server.

I don't have the plugin checking stats but users that have requested support usually run the following versions.

Skyblock - 65% 1.8, 25% 1.12, 10% latest.
Factions - 80% 1.8, 15% 1.12, 5% latest.
Survival - 90% latest, 2% 1.8, 5% 1.12, 3% 1.13 - 1.18

It goes on from there. Majority of users of my plugin use skyblock though so even with my newer minions plugin it was beneficial to add backwards compatability.

broken elbow
#

I'm here for you โค๏ธ

warm steppe
#

yeah, i switched from yaml to json

#

and then i figured that out but it was too late

worn jasper
#

any ideas why I am getting this?

java.util.ConcurrentModificationException: null
    at java.util.HashMap$HashIterator.nextNode(HashMap.java:1597) ~[?:?]
    at java.util.HashMap$EntryIterator.next(HashMap.java:1630) ~[?:?]
    at java.util.HashMap$EntryIterator.next(HashMap.java:1628) ~[?:?]
    at java.util.HashMap.putMapEntries(HashMap.java:511) ~[?:?]
    at java.util.HashMap.<init>(HashMap.java:484) ~[?:?]
    at me.mrafonso.acidcore.managers.DropManager.lambda$generateDrops$1(DropManager.java:60) ~[AcidCore-1.0-all (10).jar:?]
    at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftTask.run(CraftTask.java:101) ~[patched_1.17.1.jar:git-Paper-408]
    at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57) ~[patched_1.17.1.jar:git-Paper-408]
    at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[patched_1.17.1.jar:git-Paper-408]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
    at java.lang.Thread.run(Thread.java:833) ~[?:?]```
#

I will try a fix, aka making a list of items I want to remove from gensLocations and removing them all afterwards

hoary scarab
worn jasper
#

yup, that's what I found on stackoverflow

#

thanks anyways!

viral moth
# worn jasper yup, that's what I found on stackoverflow

heres a suggestion, iterating through the list of all generators will not take a lot of time, it is dropping the items via bukkit that takes time. idk if you are even dropping the items since acidgens now just puts it in a storage thing but regardless you dont want to do that stuff async. If you are actually dropping the item, i made a thing to optimize thatwhich would be perfect for you use case, lmk if you want it

worn jasper
viral moth
#

ik, youre running stuff async, thats why that error was thrown

#

im saying that you shouldnt do it async, even if it is just looping through the generators

#

actually

worn jasper
#

uh I already fixed that issue

#

it had nothing to do with that

#

lol

viral moth
#

wack

#

ight lol

worn jasper
#

as I said previously, the issue was that I was looping through a list and modifying it, so I created a list with everything I wanted to remove from the other, and only removed everything afterwards

#

if that makes any sense

#

xd

viral moth
#

yk what

#

that would cause it

broken elbow
#

can you send code here?

viral moth
#

sure, 2 sec

#

i plan to improve it further but this was something i made in like 10m

worn jasper
#

my bet is that you are limiting how many items can be dropped/spawned per tick

#

idk

#

lol

viral moth
#
  public static int STACK_DISTANCE = 9;
  public static int MAX_STACK_SIZE = 64;

    public static void spawnItem(ItemStack i, Location loc, UUID owner) {
        ItemStack item = i.clone();
        for (Item _item : loc.getNearbyEntitiesByType(Item.class, STACK_DISTANCE)) {
            ItemStack itemStack = _item.getItemStack();
            if (itemStack.getAmount() >= MAX_STACK_SIZE) continue;
            ItemStack _itemStack = itemStack.clone();
            _itemStack.setAmount(item.getAmount());
            if (_itemStack.equals(item)) {
                int amountToStack = Math.min(MAX_STACK_SIZE - itemStack.getAmount(), item.getAmount());
                itemStack.setAmount(itemStack.getAmount() + amountToStack);
                item.setAmount(item.getAmount() - amountToStack);
                if (item.getAmount() <= 0) return;
            }
        }
        loc.getWorld().dropItem(loc, item);
    }```
#

no

#

just check if another item is near it and add to that item's count

#

avoids spawning an extra item entirely

worn jasper
#

never thought about that.

viral moth
#

i plan to make my own stacker that goes past 64 however i havent had time to work on this project

worn jasper
#

they will stack anyways, but that avoids spawning another item at all

#

ye

viral moth
#

but it avoids spawning extra items which is that most expensive part

worn jasper
#

ye

#

although in acidgens like you said, that wouldn't be an issue

#

since it's mostly everything digital

#

xd

viral moth
#

yeah, however i dont think that the item spawning was the issue tbh

worn jasper
#

but I will keep that in mind to use next time.

worn jasper
#

but it's still a good tip

viral moth
#

idk why he removed it

worn jasper
#

I mean, the issue was he was using skript

viral moth
#

yeah lol

worn jasper
#

๐Ÿ˜‚

viral moth
#

i told him a long time ago

#

but spawning items makes kids feel like they are making more progress so removing it makes it feel more boring imo

worn jasper
#

this is going a bit offtopic btw

viral moth
#

you right

shell moon
#

when server is stopped, players are kicked before onDisable is called?

broken elbow
#

yeah

#

bcz spigot

#

(I Think. idk I always blame spigot lol)

#

but they are kicked before

warm steppe
#

They are.

shell moon
#

mmm, so basically PlayerQuitEvent is called for each player online

#

when server stops

#

how to know in there if server is being stopped?

warm steppe
#

uhh

shell moon
#

plugin.isEnabled ?

#

or something

broken elbow
#

nah

#

the plugin will be enabled

#

what's the xy here tho?

#

what exactly are you trying to do and why

warm steppe
#

piggy's answer

broken elbow
#

ugh they clearly want to execute something on players. so don't think that will actually help

shell moon
#

data is saved on inventory close event, ofc async, but on server stop you cant (iirc) create tasks, so i wanna know how to "recognize" if server is topping to not use async, but sync

broken elbow
#

unless shut down hooks are called before players are kicked idk

warm steppe
#

save it to a list or smth

broken elbow
#

pretty sure the server waits for async tasks to complete? unless I'm misremembering and its the other way around

warm steppe
#

and then save it all somewhere when onDisable()

broken elbow
#

nitro what are you talking about? xD

shell moon
#

idk either xd

warm steppe
#

he wants to save data

#

wdym

broken elbow
#

he knows how to save data lol

shell moon
#

xd

broken elbow
#

did you read their messages?

#

or the entire message

warm steppe
#

yeah but you can save data when player quits

broken elbow
#

rather

shell moon
#

i dont think so xd

#

why would i use player quit event

#

im not even listening to it

broken elbow
#

when the server is shutting down

shell moon
#

blitz you get the question right?

broken elbow
#

yeah

warm steppe
#

try it?

broken elbow
#

try what lol?

warm steppe
#

does it wait for them to complete

shell moon
#

so, to prevent dups, what would be the best way if i only save data on inventory close event (ofc certain inventories)

shell moon
broken elbow
#

ah yeah. the server won't wait for the async tasks to complete. or maybe it will but throw a warning. I Know it throws the warning just don't remember if it will wait or not

shell moon
broken elbow
#

yeah

#

that is correct

shell moon
#

if so, that means inventory close event and player quit even is thrown for all players

#

and then onDisable is called, correct?

#

that means in onDisable, getOnlinePlayers().length will always be 0 right?

broken elbow
shell moon
#

so, if i wanna decide between using async (as usual when inventory closes) or sync (so server waits until database is saved)

#

how would i check that?

#

there was a serverIsStopping or sth? xd

viral moth
#

if i had to guess the server kicks the players after all plugin's are disabled

#

however i would just test it myself if i were you

broken elbow
#

so yeah @shell moon some googling says that the players get kicked after the plugins are disabled

#

so I guess I Was wrong

#

but yeah. test it

#

just to make sure

shell moon
#

so basically, all plugins that listen to player quit event to save data

#

breaks? xd

broken elbow
#

nah

shell moon
#

if plugin is disabled, how would they work?

broken elbow
#

idk

#

I do know that they're kicked 1 tick before the event is called

#

which is stupid

#

or something like that. I had problems with FrozenJoin

#

unless again I'm misremembering

#

but anyways if you try, I guess you'll find out the answers

shell moon
#

i'll quickly debug the events

#

this driving me crazy

shell moon
#

How to know which version of SQLite is a server running? (i mean, i know latest versions use last version, but i wanna know in case it's 1.8, etc)

proud pebble
#

according to a quick google search

Connection con = yourconnectionmethodhereorwhatever
DatabaseMetaData meta = con.getMetaData();
int majorVersion = meta.getDatabaseMajorVersion();
int minorVersion = meta.getDatabaseMinorVersion();
robust flower
#

what is the easiest way of packing a java application (console or GUI based) as a binary, executable file (exe, flatpak, etc)?

dusty frost
#

Launch4j probs

lyric gyro
#

jlink ๐Ÿฅบ

dusky harness
#

note that it still needs the JRE to be installed

#

either that or u need to make it an installer

lyric gyro
#

the entire point of jlink is to ship a whole runtime image with your application so the jre doesn't need to be installed

dusky harness
#

oh idk about jlink but launch4j requires the JRE iirc

#

or installer

#

either that or i never found a way of how to include the runtime image

#

ยฏ_(ใƒ„)_/ยฏ

forest jay
#

I have a biome provider, and when I set a biome to deep ocean, it sets it in f3, but still generates land there. The land has shipwrecks and ocean monuments on it, yet no water.

past ibex
#

That's how 1.18 generation works

#

Biome is determined by continentalness, weirdness, humidity, and temperature noise

#

the same noise also does world heights and terrain generation

#

setting only biomes does not change terrain generation like it did pre-1.18

cerulean birch
#

trying to spawn in 4 blocks of dripstone (pointing downward) and then having it fall down โ€” instead I'm getting. 4 blocks of dripstone pointing upward that float midair without any physics/logic impacting them sad


        base.getBlock().setType(Material.BARRIER);

        for (int i = 1; i != 5; i++) {

            Location dripstoneLocation = base.clone().add(0, -i, 0);
            dripstoneLocation.getBlock().setType(Material.POINTED_DRIPSTONE);

        }

        Bukkit.getScheduler().runTaskLater(Plugin.getPlugin(), ()-> base.getBlock().breakNaturally(false), 1);```

fixed: fucked around with the blockdata and blockstate and it finally works 20 mins later ![pepeShoot](https://cdn.discordapp.com/emojis/653814268055257101.webp?size=128 "pepeShoot")
rigid mountain
#

Question, so im making a game system and saving it to mongo via GSON, but i keep getting these circular refrencing issues. I swear I have looked over and looked over the code several times and cannot find it. I have even commented out sections to trace where it is coming from. One save it works fine and then the next one it does not. Here are my full classes:

Game.java: https://paste.helpch.at/ekunajabol.java
Arena: https://paste.helpch.at/totakeduzi.cs
lobby: https://paste.helpch.at/ufulohogiw.java
team: https://paste.helpch.at/aranojiqax.java
Lootchest: https://paste.helpch.at/hezubabala.java
MobSpawn: https://paste.helpch.at/abafadodeg.java

Error: https://paste.helpch.at/icekorohev.bash

I feel like I have done a pretty good job seralizing everything and desearilizing it

brittle thunder
#

Give us the exception you get

rigid mountain
#

It doesnt give much detail which is kinda nnoying

stuck hearth
#

Recursion be like ๐Ÿฅด

lyric gyro
#

what object are you trying to serialize?

#

Game?

rigid mountain
#

yes

lyric gyro
#

it's probably trying to serialize the BukkitTask as well, you could try marking it as transient

rigid mountain
#

Ok, let me try that

dark garnet
#

how can i convert a long milliseconds to this: X.YY
X = seconds
YY = 2 decimal places of milliseconds
not sure if im explaining this well enough lmao

dusky harness
dark garnet
#

yea i tried the decimalformat thing

#

i think i had just done it wrong

surreal lynx
#

What's the best way to delay something by a second or so?

dark garnet
#

bukkit runnable, runtasklater

surreal lynx
#

Ok, thank you

#

Is that the only way though?

#

Or is there an alternative

dusky harness
#

well

dark garnet
#

probably but bukkitrunnable is the easiest i think

dusky harness
#

in java itself there is an alternative (outside of bukkit)

but I'd recommend using runTaskLater

hoary scarab
hoary scarab
lyric gyro
#

What the best way for me too make a count down timer as I canโ€™t seem to find anything too help for 1.18

hoary scarab
stuck hearth
#

๐Ÿ’€

indigo plank
#

Hey i wannas k

dark garnet
#
final long timeLeft = TimeUnit.MILLISECONDS.toSeconds(timer.get(tnt) - System.currentTimeMillis());
final BukkitRunnable runnable = new BukkitRunnable() {
    public void run() {
        tnt.setCustomName(ChatColor.RED + "" + ChatColor.BOLD + Math.round(timeLeft / 10.0) / 100.0);
    }
};
runnable.runTaskTimer(Main.plugin, 0, 20);```
dusky harness
#

well you're using TimeUnit to convert to seconds

#

but the issue is that it returns a long

dark garnet
#

oh right

dusky harness
#

not a double

#

just use ```java
double seconds = Math.round((double) milliseconds / 10.0) / 100.0;

winged pebble
#

You also need to move the calculation inside of run, no?

#

If you want it to update

dusky harness
#

oh that too

#

๐Ÿฅฒ

dark garnet
#

alright

#

just realized i cant have the period of the runnable set to 20 lmao

#

or else the milliseconds part is just useless

dusky harness
#

oh wait yea bc thats every second

#

๐Ÿฅด

dark garnet
#

lmfao

#

the flashing

dusky harness
#

instead of #.##

#

not sure if there's another fix

#

wait

#

no thats bc it's switching

#

try this:

dark garnet
# dusky harness I'd just do `#.#`

unrelated, how would i change how many decimals are shown using this method:
Math.round((timer.get(tnt) - System.currentTimeMillis()) / 10.0) / 100.0

#

the / 10.0 part?

#

o wait it would be both divisions right

#

so if i just wanted #.# i'd do Math.round(timer.get(tnt) - System.currentTimeMillis()) / 10.0

dusky harness
# dusky harness try this:
String seconds = String.valueOf(Math.round((double) milliseconds / 10.0) / 100.0);
if (seconds.split("\\.")[1].length() == 1) {
    seconds = seconds + "0"; // if the amount of chars after . is 1, then add an extra 0 after
}
dusky harness
dark garnet
#

alright ill experiment, thank you!

viral moth
#

use BigDecimal.valueOf(0.5).format("#.##"); that will give you 0.50

viral moth
mellow kindle
#

anyone knows any web api that tracks player kills and play time ona server i would like to add that feature on my discord bot

lost bluff
#

Im looking for website devs dm me

tight junco
trail burrow
#

need help on how to get updated code to the original developer github? My github never seems to work using github desktop

hushed badge
#

make a pull request? I'm unsure as to what ur asking here

trail burrow
#

pull request, I just want to send some updated code, I can't seem to figure out how to do it. I can't even update my own github with my setup. It broke I believe when I attempted to do it from two different locations

topaz gust
#

You would need to commit and push the โ€œupdatedโ€ to the git then pull from it wherever else you want it (or whoever)

somber gale
#

Does someone know if Gson will also use any fields defined in an inherited Interface?
Like when I have this:

public class SomeClass implements SomeInterface {
    public String message;

    private static interface SomeInterface {
        boolean error;
    }
}

And the JSON I parse is {"error": true, "message": "Message here"}, would Gson use the error field from the interface or is that completely ignored?

#

From what I tested now does it seem to not work as boolean error; is treated as a final entry

sterile hinge
#

Interfaces donโ€™t have instance fields

icy shadow
#

wtf that is evil

broken elbow
#

everything is

lyric gyro
#

How can i get the location
when the table is like PreparedStatement ps = mySQL.getConnection().prepareStatement ("CREATE TABLE Spawn (" + "ID INT NOT NULL," + "X DOUBLE NULL," + "Y DOUBLE NULL," + "Z DOUBLE NULL," + "YAW FLOAT NULL," + "PITCH FLOAT NULL," + "WorldName VARCHAR(255) NULL," + "PlayerName VARCHAR(255) NULL," + "PlayerUUID VARCHAR(255) NULL," + "Server VARCHAR(255) NULL," + "PRIMARY KEY (ID))");

rugged bane
#

Wdym get the location

#

Read from the DB, pass it as an object

lyric gyro
broken elbow
#

what does "doesn't work" mean? what's the expected output and what's the actual result you get?

lyric gyro
#

So what happens is i do /sp i have to type it 5 times instead of doing a count down then it goes in to the minus so it does reset

#

when i type the command so im trying too figure where my code is wrong

#

as it doing it on the amount of time i type the command in

warm steppe
lyric gyro
#

its so ik what block is what

broken elbow
warm steppe
#

๐Ÿ˜ซ

broken elbow
#

its called Allman or whatever

lyric gyro
#

lol

warm steppe
#

so K&R is the only usable style

lyric gyro
#

what the fuck is gnu and horstmann

#

im off back to try fix my timer ๐Ÿ™‚

broken elbow
#

what you want to use is runTaskTimer

lyric gyro
#

It runs one once per command is done

#

but i can try run TaskTimer

#

What would period be ?

broken elbow
#

well its in ticks

#

so 20

#

for 1 second

lyric gyro
#

and delay is that going to be 1 Tick aswel ?

broken elbow
#

well you want that 20 as well

#

its in ticks yeah

lyric gyro
#

okay ill test that see if that fixes my issue

broken elbow
#

also are you accessing the database every time the command is ran?

#

that sounds like a nice server crash feature xD

lyric gyro
#

For some reason i have to type my command 5 Times for it too take me to spawn instead of 5 seconds

broken elbow
#

even after changing it to runTaskTimer?

#

can you send your current code?

lyric gyro
#

yh

#

here ya go v

broken elbow
#

when you do /spawn it will still just execute runTask

lyric gyro
#

ahh i didnt save it then

#

ill re finish that

#

just gotta fix an ACF problem that idk how to fix

broken elbow
#

maybe we can help?

lyric gyro
#

Thats the error i have recieved

broken elbow
#

you need to shade ACF

lyric gyro
#

i have

broken elbow
#

are you minimizing?

lyric gyro
#

i am not

broken elbow
#

check your jar. open it with winrar or JDGUI or something

#

to make sure its there

lyric gyro
#

im just rebuilding i think i have it now ima give it a quick test

#

issue was resolved it was just a broken bit of code

#

How can i cancel a task correctly

#

as my cancel isnt working correctly

#

but you did fix my other issue thanks Blitz

broken elbow
#

you should be able to cancel the task from within itself. if not you might have to save the task in a variable and cancel it from there

lyric gyro
#

Iโ€™ve got the cancel writhing it sled but it ignores it

#

So Iโ€™m gonna have too turn it into a variable

dusty frost
#

K&R still does Allman for function blocks iirc

#

One True Brace always puts the opening brace on the same line

rugged bane
#

Which is the style where you do
function
{

}

dusty frost
#

Allman

#

it's awful

icy shadow
#

allman is great

pulsar ferry
#

Bad tastes

lyric gyro
#

from now on i'll use a mixture of Whitesmiths and GNU styles

#
void foo ()
        {
        bar ();
        baz ();
        }
rugged bane
#

Iโ€™ve started using Allman more

#

I prefer it because easier to see where the brackets are

#

Vs having it on the same line as functions

dusty frost
#

it's just so much extra whitespace, and if you're using an IDE based on IntelliJ at least, it shows you indents and things really nicely, plus I use rainbow brackets so it makes matching brackets the same color, very nice to use

rugged bane
#

Yeah, I think for me itโ€™s more for visuals, like sometimes Iโ€™ll visit code on GitHub if I donโ€™t want to pull it locally just to check something

dusty frost
#

hmm, I never really had a problem distinguishing where functions start and stuff, maybe it's more of a PHP thing?

#

but honestly, PascalCase and Allman indentation are the biggest reasons I don't like C#/anything .NET

rugged bane
#

I mainly started adopting the style since I primarily using PHP, so could be.

I never saw the appeal of the style before, but then started using, and I find it more readable

#

But naturally all this stuff is preference based

dusty frost
#

yeah, yeah, I suppose it's just what you're used to

#

like I managed to use C# and stuff for a few things for my class, didn't really end up liking it that much

#

the biggest appeal is just the raw features it has over Java, and the integration with like F#

rugged bane
#

I do find it crazy how much languages overlap

#

When I first started programming and heard โ€œonce you know one, the others are a bit easierโ€ I thought that was full of crap

#

But so true

dusty frost
#

the others are a lot easier lol

#

at least, languages in a similar area, like OOP langs

#

I know Java really well, and I can effectively use Ruby, C#, Python, C++, C, Kotlin, JavaScript, Go, PHP, Swift, etc. very quickly

#

just by looking up the syntactic differences and stuff

#

now languages like F#, Clojure, and Haskell, etc. are a bit harder to learn because they are fundamentally different lol

lyric gyro
#

clj pleading_face_with_3_hearts

icy shadow
#

all imperative languages are just reskins of each other

rugged bane
#

Yeah itโ€™s crazy, I think if I were to learn any, Go would be the one to spark me

icy shadow
#

no cap

lyric gyro
#

man I really really want to like properly get into clj

icy shadow
#

so based

lyric gyro
#

but it's so out of my comfort zone

icy shadow
#

good

lyric gyro
#

why good lol

icy shadow
#

idk

#

do it anyway

#

pussy ass

lyric gyro
#

๐Ÿ’€

#

i got one of those yeah OMEGALUL

icy shadow
#

shut up

#

get clojuring

#

now

lyric gyro
#

you started it!

#

at least i know the very very basics outlined in the starter guides

icy shadow
#

i will give you a test

lyric gyro
#

ok

icy shadow
#

what does 3 evaluate to

lyric gyro
#

3

icy shadow
#

well done

#

ok

#

this is a hard one

lyric gyro
#

nice

#

ok

icy shadow
#

(+ 1 2)

#

whats that

lyric gyro
#

a function call

icy shadow
#

yeah but what does it evaluate to

lyric gyro
#

3

icy shadow
#

ok looksing good so far

lyric gyro
#

no i don't sing

icy shadow
#
(defn- make-state
  ([] (make-state nil))
  ([{:keys [:zmq-context]}]
   (let [execute-count    1N
         display-queue    EMPTY-QUEUE
         sess        (-> (his/init-history) his/start-history-session)
         zmq-context    (or zmq-context (zutil/zcontext))
         halt?        false
         comms        (comm-global-state/initial-state)
         cur-ctx    ()]
     (->State execute-count display-queue sess zmq-context halt? comms cur-ctx))))
``` now what does this do?
lyric gyro
#

it makes state

icy shadow
#

well done

#

you understand functional abstraction

lyric gyro
#

yay

icy shadow
#

ok theres nothing more to learn

#

ur an expert

lyric gyro
#

when will we take over the world?

icy shadow
#

tomorrow

#

or the day after

lyric gyro
icy shadow
#

Ha ha

full reef
#

Hey ppl, sorry to interrupt your chat, can you please take a look at #off-topic for a sec

lyric gyro
pine flax
#

can you send your SpawnCommand

night ice
#

Else, it will create memory leaks

lyric gyro
#

okay will do

#

its all been fixed ive recoded it and used a switch statement in stead of an if statement

dark garnet
#

how can i like disable a command from being used?
i wanna make it so no one (including operators) can use /ban-ip

#

ping if reply

teal rapids
#

What's a good video to start on creating plugins myself?

#

hello?

lyric gyro
# night ice Also, close your PreparedStatements and ResultSets

Would this work for closing it public boolean checkTableExists() { try { PreparedStatement ps = coreDatabase.getConnection().prepareStatement("USE Spawn;"); ps.executeUpdate(); DatabaseMetaData dmd = coreDatabase.getConnection().getMetaData(); ResultSet res = dmd.getTables(null, null, "Spawn", null); if (res.next()) { ps.close(); res.close(); return true; } ps.close(); res.close(); } catch (SQLException e) { throw new RuntimeException(e); } return false; }

#

i couldnt remember if it was in the if statement or outside of it

teal rapids
#

How do y all understand coding? It's like how do you know where to put semi colin, or where to put the dashes and brackets? Can someone explain?

#

Please I wanna make my own plugins because I can't find what I want.

torpid raft
#

how do you understand how to write a paragraph? Where do you put nouns or verbs or adjectives? When do you use periods and when do you use commas?

#

both are just a set of syntax rules, and coding even arguably has a much much simpler set of rules than english does

#

A simple way to begin getting used to reading and writing java is to google around for a java tutorial, and visit any one of the hundreds of relevant sites - it honestly does not matter which

#

download a java IDE like IntelliJ / Eclipse / Whatever, and recreate the examples provided in that tutorial

#

from there the world is your oyster

teal rapids
#

English is way easier btw

#

More people know English than coding

#

But how long does it take to get used to coding, like to not look at a sheet woth the place holders and stuff

lyric gyro
#

English is easy only because you know it already

#

It's actually shit

topaz elm
#

for the basics probably a month

#

but you never stop learning

warm steppe
dusty frost
#

yeah the syntax rules of programming languages are much more strict, enforced by a compiler that will make 100% sure, and you can use nice IDEs that will give you generally exact problem spots

#

like in Java, basically every line that doesn't have a {} on it will end in a ;, and for and if are always followed by the expression in ()

past ibex
#

Syntax is easier than logic

torpid raft
#

as far as just memorizing what the keywords mean, it generally doesn't take too long as long as you try using them on your own instead of only following tutorials that spoonfeed you

#

When I took my first programming class in high school, most of the class had a great grasp on the basic java syntax less than halfway into the school year, and that was only with a 45 minute period every weekday + a bit of homework

fresh spade
#

Anyone have any idea why this isn't working? I'm trying to disable dyeing of a leather armor

@EventHandler
public void onLeatherArmorCraft(PrepareItemCraftEvent  e) {
        if(e.getRecipe() == null)
            return;
        
        if(e.getRecipe().getResult().getType() == Material.LEATHER_HELMET ||
                e.getRecipe().getResult().getType() == Material.LEATHER_CHESTPLATE ||
                e.getRecipe().getResult().getType() == Material.LEATHER_LEGGINGS ||
                e.getRecipe().getResult().getType() == Material.LEATHER_BOOTS) {
e.getRecipe().getResult().setType(Material.AIR);
        }
    }
tight junco
#

isnt the event cancellable

#

no uh

#

I think you might want to try CraftItemEvent?

lyric gyro
#

How can i change it from player.getLocation().getWorld().toString() to normal getWorld again

hoary scarab
lyric gyro
#

Thanks I did the bukkoit.getworld

lyric gyro
proud pebble
fresh spade
#

oh yes ur right!

#

thank you for finding that out, I wasn't thinking about that at all

proud pebble
#

id recommend that you put bukkit.getLogger.info(e.getRecipe().getResult().getType());
before your if leather armor statement so you can check if its coming back any type
and also a bukkit.getLogger just before the null check aswell.

#

basically just put some debug outputs to check your logic to see if its doing what you intend

#

if you get no messages then check that the event is registered.

fresh spade
#

Don't worry I already fixed it just forgot I sent a message here xD

#

And yes, I'm always placing some kind of debug outputs when I'm texting my logic

candid arch
#

Hi there is it possible to :

Create a HashMap<String, Object>, (Every Value is a class that extends the Object), putting content inside...
Find the good Value with a String key
Instantiate it with a parameter

I don't want to use Switchcase, this is good for a limited amount of options.
https://pastebin.com/9JEgncbE

(Maybe what i'm asking is unclear or maybe there's a better way to do so)

lyric gyro
#

Anyone know why Hikari Wont check if a table exists or create a table

#

i can send the class it just goes too an SQL Error

leaden sinew
#

Where the function gives the instance of the class

candid arch
# leaden sinew It looks like you might want to do something like Map<String, Function<Territory...

Not really, sorry if I am not understandable. I want to create a map of objectives (every objectives extends Objective but are not instantiated yet).

Then, when devs use my API, they can add their own objectives in the list. (They add possibilities)

Finally, my plugin calls a function that will use a String to find an Objective in the map. If found, I want to instantiate the found Objective, with a parameter.

#

Something that already work on my plugin is this.

                Objective objective = null;
                if (objectiveType.equalsIgnoreCase("KOTH")) {
                    objective = new KingOfTheHill(territory);
                    objective.start();
                } else if (objectiveType.equalsIgnoreCase("STRUGGLE")) {
                    objective = new Struggle(territory);
                    objective.start();
                } else if (objectiveType.equalsIgnoreCase("CONTROL")) {
                    objective = new ControlPoint(territory);
                    objective.start();
                }

But since it is a if/elseif statement (switchcase too), it has limited optionsa dn will not include the objectives created by other devs with the API.

lyric gyro
#

too many caps

night ice
topaz elm
#

switch(objectiveType)

leaden sinew
lyric gyro
leaden sinew
topaz elm
#

ah

#

just smack em all into a list and do List#contains(objectiveType)

candid arch
leaden sinew
#

Yeah

leaden sinew
topaz elm
#

all ur doing is checking if the objective is equal to some constants

#

so you can just smack the constants in a list and make the list changeable at runtime

leaden sinew
#

No they need to create a new instance of the objective

topaz elm
#

ahh

#

just make a Map<String, Class<? extends Objective>>

candid arch
#

Thanks ! ^^

leaden sinew
#

No problem

#

I would like to see how you do it without a map, so if you could send it again and ping me I would appreciate it

candid arch
shell moon
#

is it possible to give an specific creeper a custom texture? (maybe 1.16+ or 1.14+?)

rugged bane
#

Creeper? Oh man

torpid raft
#

!ban

lyric gyro
torpid raft
#

seems like you're doing something silly with your database connections

lyric gyro
#

idk what you mean

#

its just a basic setup

torpid raft
#

no you're right your code is perfectly fine and the server just hates you and that's why it's crashing

#

jk

lyric gyro
#

haha

torpid raft
#

the error you are getting is a result of the main thread being locked up for a long time

#

and the server thinking it died

lyric gyro
#

how would i go about fix that

neon wren
#

your error is with your core database class.

#
Caused by: java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30001ms.
        at com.zaxxer.hikari.pool.HikariPool.createTimeoutException(HikariPool.java:696) ~[Core-0.0.0-DEV.jar:?]
        at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:181) ~[Core-0.0.0-DEV.jar:?]
        at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:146) ~[Core-0.0.0-DEV.jar:?]
        at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) ~[Core-0.0.0-DEV.jar:?]
        at net.devcowsoftware.networkcore.core.spigot.storage.database.connection.CoreDatabase.getConnection(CoreDatabase.java:108) ~[Core-0.0.0-DEV.jar:?]
        ... 11 more
#

This means that your database isn't obtaining connection within 30 seconds (the default connection timeout period).

#

This also means that the network latency, or some of the queries are taking over 30 seconds to execute.

torpid raft
#

chances are you misconfigured your database address ~~/ credentials ~~^

neon wren
#

To help solve this problem, increase your maximum connection timeout to the hikari config.

#

It also could be a connection limit to the database.

#

Could you possibly provide whether the database server location is near the server's location? and also attempt what Ivan mentioned.

torpid raft
#

i've never heard of a server that has a latency of over 30 seconds x.x

lyric gyro
#

Ilbut it will do /spawn the first time and fail on the seconds so it canโ€™t be a creds issue S it can set them as well

torpid raft
#

does your /spawn command rely on the sql database at all

#

if it doesn't it's possible that it never makes the connection in the first place but you just don't notice until later

lyric gyro
#

They are both in the exact same rack

neon wren
#

Is there a reason why you are selecting positions individually?

#

It makes no sense to do 5 selects for one location.

lyric gyro
#

Itโ€™s just massive get to get the location

#

It does it for multiple position across 3 servers

#

Iโ€™ve just been testing

neon wren
#

I'm not sure why you are searching over a server and world name, when it should be the id, as your PRIMARY KEY is the ID.

lyric gyro
#

How would I get the id tho from the database ?

torpid raft
#

kieran

lyric gyro
#

Yh

torpid raft
#

i didnt realize because i didnt see you posted your code but

neon wren
#

I don't understand why you are storing player names with the location either.

torpid raft
#

your issue is almost certainly this

coreDatabase.getConnection().prepareStatement("...");
lyric gyro
#

Yh I posted everything need to help fix it

torpid raft
#

you are never closing the connection from the thread pool

lyric gyro
#

How would I close it

torpid raft
#

by calling close on it lol

lyric gyro
#

Anywhere specific

neon wren
#

You shouldn't close the connection every time.

torpid raft
#

you should

#

that's how thread pools work

neon wren
#

If you are closing the data source connection, you throw away any benefit a connection pool has.

torpid raft
# lyric gyro Anywhere specific

everywhere you have

coreDatabase.getConnection().{...}

make it

Connection conn = coreDatabase.getConnection();
conn.{...};
//other stuff here
conn.close();
lyric gyro
#

twr pleading_face_with_3_hearts

torpid raft
#

first link about it on google

lyric gyro
#

you keep a single data source, and then use and close each connection/statement/resultset/etc

torpid raft
#

^

lyric gyro
#

hikari is smart

#

So too close it would i do something like

    {
        Connection connection = dataSource.getConnection();
        connection.close();
    }```
#

and call that too each of them ?

torpid raft
#

not quite

#

use them as you have been but instead of doing it all in one line like

coreDatabase.getConnection().prepareStatement("...");
#

save the Connection to it's own variable

#

get a prepared statement from it and proceed like usual

#

then after you are done with that query call close() on the connection

neon wren
#

I didn't change COUNT(*) back to *, so you'll need to do that, or switch it to where it'll get the amount from COUNT(*) and check if amount > 0.

#

I recommend possibly passing just the world name of the player, and not the entire player object.

lyric gyro
dark garnet
#

why is command returning null?
PluginCommand command = Bukkit.getPluginCommand("bipreload");

cerulean birch
dark garnet
cerulean birch
neon wren
#

that's a placeholder.

lyric gyro
#

okay np

#

Thanks ill give it a try and see if that fixes my issue ill let you know

shell moon
#

When using

Creeper c = world.spawn(loc,Creeper.class);
//Everything here runs after CreatureSpawnEvent was called and modified by other plugins in all priorities?
//Or it has a delay?

dense drift
#

Does that method even call the event?

topaz elm
#

try it and see

lyric gyro
#

Hello, i couldnt sign in to my old discord because i was activating my 2FA, the problem is I deleted my discord account from my authenticator by mistake, i need back and i tried everything but nothing works

neat pierBOT
#
FAQ Answer:

Looking for discord support?
HelpChat is a Minecraft plugin and development support server and is not affiliated with discord in any way.
If you require support from discord, we recommend you to visit their official support website at https://support.discord.com
On this website, you can read their FAQs, or open a support ticket if necessary.

broken elbow
#

@lyric gyro this anyways. Discord gave you some backup codes when you enabled 2FA. If you don't have those, there's no way to recover your account. That's most likely what they'll tell you as well

lyric gyro
lyric gyro
lyric gyro
neon wren
#

Read the errors, as it clearly mentions what they are.

#

For example UUID of added entity already exists: EntityHorseDonkey['Donkey'/504, uuid='02b7d21a-5d09-4b25-adfc-249e5fc502a2', l='ServerLevel[world]', x=133.15, y=64.00, z=-180.85, cpos=[8, -12], tl=61141, v=false]

lyric gyro
#

thats not the error thats just a spawning error

#

thata somthing do do with my world entitys

#

its te bottom bit i cant figure

neon wren
#

Your database takes way too long to respond.

broken elbow
#

this its blocking the main thread

neon wren
#

Which causes the server to lock up as it thinks its dead.

lyric gyro
#

so how would i go about fixing that its my first time every using HikariCp

neon wren
#

It's definitely not a HikariCp issue, but rather how you do your queries.

#

At some point, one of your connections go null in the pool, or all of them, and the database causes the main thread to be blocked.

lyric gyro
#

can i just check if the connection is null ?

lyric gyro
#

No, you should fix the way you use connections
Closing connections/statements/result sets is one step forward, but because you are (currently) closing them manually, there are places where they aren't closed and are still open, occupying a "connection slot" where it's no longer needed and most likely causing some or another mem leak (see those getX/Y/Z/Yaw etc methods, if the result is found you return immediately without closing the resources)
Thankfully Java can close them "automatically" for you when you return or if an exception is thrown, that's what the "try with resources" is for, the way you're doing it now is like this

try {
  Connection connection = coreDatabase.getConnection();
  PreparedStatement statement = connection.prepareStatement("blah blah");
  // ... set statement arguments
  ResultSet resultSet = statement.executeQuery();
  // use result set

  // oh no! you have a return statement somewhere in here and you're not closing the closeable resources!

  resultSet.close();
  statement.close();
  connection.close();
} catch (SQLException ex) {
  // oh no! perhaps the closeable resources weren't closed!
}

Again, closing them is a step in the right direction, but since you're doing them yourself there are missing spots
The try-with-resources (or just twr for short) will close them for you

try (  // note these parentheses
  Connection connection = coreDatabase.getConnection();
  PreparedStatement statement = connection.prepareStatement("blah blah");
) {
  // set statement arguments
  try (ResultSet resultSet = statement.executeQuery()) {
    // use result set
    // you can safely return here, the twr will close everything for you :)

    // no need to call .close() anywhere!
  }
} catch (SQLException ex) {
  // even if an exception is thrown, everything will be closed and cleaned up for you
}

It can be a little bit tedious to change but it's crucial for connection lifecycling and it's not significantly different in terms of "physical" code changes
@lyric gyro

#

so true

broken elbow
#

LMAO

icy shadow
#

shut up

lyric gyro
#

fuck you

neon wren
#

wow emily copied me.

#

but did more detailed comments.

lyric gyro
#

lol

warped kestrel
lyric gyro
# lyric gyro No, you should fix the way you use connections Closing connections/statements/re...

if i do it in this format would i need to close the connection at all ```try ( // note these parentheses
Connection connection = coreDatabase.getConnection();
PreparedStatement statement = connection.prepareStatement("blah blah");
) {
// set statement arguments
try (ResultSet resultSet = statement.executeQuery()) {
// use result set
// you can safely return here, the twr will close everything for you :)

// no need to call .close() anywhere!

}
} catch (SQLException ex) {
// even if an exception is thrown, everything will be closed and cleaned up for you
}```

#

you don't, java does

#

okay ill switch it all over too that then

warped kestrel
#

Is it possible to make smoking plugin

lyric gyro
#

sure /effect give <player> nausea

warped kestrel
#

That an effect

#

But sure