#development

1 messages Β· Page 98 of 1

icy shadow
#

locks bad

#

yes

graceful hedge
#

No u

icy shadow
#

i know a certain paradigm that multi-threads really easily!

dense galleon
#

assert hUH

graceful hedge
dense galleon
#

const?

leaden sinew
#

What was it used for?

icy shadow
#

nothing

#

ever

#

it's never been implemented

graceful hedge
#

const does nothing

icy shadow
#

goto and const were reserved but never used

pure crater
#

reserved keywords

dense galleon
#

native transient

pure crater
#

XD

dense galleon
#

What the hell

graceful hedge
#

But it might have been used for constants

leaden sinew
#

const is in Java?

pure crater
graceful hedge
#

native is for natively implemented functions

icy shadow
#

barely

pure crater
#

with native

leaden sinew
#

transient is useful

graceful hedge
#

transient is when u want to exclude serializability

pure crater
#

^

#

for example in GSON

graceful hedge
#

assert is with a jvm flag something if you want to assert a boolean expression I believe

#

which if false throws AssertionError

icy shadow
#

useless

pure crater
#

Yeah lol

graceful hedge
#

Yeauh

pure crater
#

final superior

graceful hedge
#

mutable final sadkek

robust flower
dense galleon
#

Ubemubbe

icy shadow
#

imagine having a keyword for variables

dense galleon
#

Yes

#

Why am I not leveling up

graceful hedge
#

Imagine not

leaden sinew
dense galleon
#

so assert is useless

graceful hedge
#

No one uses assert

leaden sinew
#

I've seen it in plugins

dense galleon
#

I have as well

leaden sinew
#

Its suggested by IntelliJ

dense galleon
#

That's why I am asking

graceful hedge
#

If you want to assert stuff use something like Junit maybe

dense galleon
#

🀨

graceful hedge
#

It has a utility class for that shit

leaden sinew
graceful hedge
lyric gyro
#

lol

leaden sinew
#

Yeah lol

#

That's what I mean

lyric gyro
#

because it doesn't do jackshit

thorn cape
#

Does anyone have an example on a websocket server in a spigot plugin? I'm trying to have a discord bot communicate to my server plugin.

leaden sinew
#

That's what I said lol

dusky harness
lyric gyro
#

I personally have used it for debugging and testing but never actually released anything with it

dusky harness
#

why is nullcheck

#

at the bottom

#

;-;

pure crater
#

its so gross that its at top

dusky harness
#

ik D:

pure crater
#

like it should have a suggestion from junit

leaden sinew
#

Its on top because its the most used

pure crater
#

if the dep is there

leaden sinew
#

Dkim uses assert

graceful hedge
#

lol

pure crater
#

lol

dusky harness
#

WAT

leaden sinew
#

Too late

#

You posted proof

pulsar ferry
#

The JDK uses assert all the time

#

It's odd

dusky harness
lyric gyro
dusky harness
#

oh maybe

leaden sinew
#

No definitely not

dusky harness
#

πŸ₯²

leaden sinew
#

Its because Dkim uses assert

lyric gyro
#

also true

dusky harness
#

all because of me

leaden sinew
#

That's the only explanation

graceful hedge
#

πŸ‘€

pure crater
#

Yeah

dusky harness
#

πŸ˜”

pure crater
#

you use assert

#

smh

#

bad programmer

dusky harness
#

i'm sorry

leaden sinew
#

Unbelievable

pure crater
#

go back to coursera

#

or codeacademy

#

or

dusky harness
#

will you forgive me πŸ₯Ί

leaden sinew
dusky harness
#

lol

pure crater
#

?learn-java

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!

pure crater
#

@dusky harness ^

dusky harness
#

☹️

pure crater
#

Yeah you havent seen that for a while eh

#

today is your lucky day

lyric gyro
#

LMAO

dusky harness
#

okay but

lyric gyro
#

REMEMBER???

leaden sinew
lyric gyro
#

dude I forgot we used to spawn that to dkim almost every day xD

icy shadow
#

learnyouahaskell

pure crater
#

i remember trying to teach dkim about generics

#

remember that emily

lyric gyro
#

i don't

dusky harness
#

OOH

lyric gyro
#

lol

dusky harness
#

LOL

leaden sinew
dusky harness
#

also

#

no offense

#

but

lyric gyro
#

offends

dusky harness
#

😌

leaden sinew
#

Wow

pulsar ferry
leaden sinew
#

Something an assert user would do

pure crater
dusky harness
pure crater
icy shadow
#

no cap

pulsar ferry
#

Yeah no cap

pure crater
#

He just turned into stage 1 beginner

pulsar ferry
#

It's true

pure crater
#

/s

#

Lmao

icy shadow
#

dkim haters vs dkim appreciators

pure crater
#

but the assertions tho πŸ‘οΈ

pulsar ferry
#

Also why is :this: a carrot lmao

leaden sinew
#

oooooooooooooooooooooooooooooooooo

ummmmmmmmmmmmm

dusky harness
lyric gyro
#

carrot = caret = this

dusky harness
lyric gyro
#

billed cap

pure crater
#

I cancel you out

lyric gyro
#

billed cap billed cap

dusky harness
lyric gyro
#

tea

dusky harness
#

/tts

pure crater
#

i have a bigger reverse card

leaden sinew
#

I’m getting too much xp from this, I can’t change my name color, bye everyone, Dkim stop using assert.

pure crater
#

size matters 😼

lyric gyro
lyric gyro
#

it does tho

dusky harness
#

aw

dusky harness
#

ig thats discord limit

#

D:

lyric gyro
#

Ender we are trying to have a very serious conversation here

thorn cape
#

pepeW my bad

lyric gyro
#

lmao

dusky harness
lyric gyro
#

soz

dusky harness
#

although i had it where i had proxy as discord bot and servers that connected to it

#

and i didn't use a websocket either

thorn cape
dusky harness
thorn cape
#

so just not that at all them

dusky harness
#

highly recommend++

#

note: u need to port forward the ports for listening

thorn cape
#

I trying to make a team selector for discord. the bot is always running pinging the server because the server can be offline or online

#

Not using a database rn and wanted to look into sockets but I'll look into radio scanner nodders

dusky harness
#

i mean

dense galleon
pure crater
dusky harness
#

πŸ…

pure crater
#

πŸ†

dusky harness
thorn cape
#

i take my leave

pure crater
dusky harness
dense galleon
#

:creeper:

pure crater
#

😏

dense galleon
#

🀨

dusky harness
limber hedge
leaden sinew
limber hedge
#

Thank you

flat cargo
#

Ik how to make a package cuz I copied/pasted decompiled src into a new project in order to update them. That’s how I learn. Tried watching yt vids. Tried reading. They both failed. I learned by starting with existing code, asking questions from those who know, and then doing

dusky harness
#

decompiled 😬

leaden sinew
#

Can I not use Player#attack?

#

I either need to have a player attack an entity, or get the damage that would normally be applied,
and use that with LivingEnttiy#damage

winged pebble
#

What issues are you having with using it?

leaden sinew
#

It doesn't work

#

What's the difference between

ADD_NUMBER
ADD_SCALAR

With AttributeModifier?

#

Nvm

#

I just need to find a way to get how much damage a player would deal to an entity if it had attacked an entity normally

#

I can get the damage with attributes, it doesn't factor in swing cooldown though

leaden sinew
thorn cape
thorn cape
#

you know what I'm proud I figured this out

thorn cape
#

this was the end product btw πŸ™‚

limber hedge
#

I have a PlayerChat event and I want to turn their string into a player to check if that player has been on the server before and has X playtime

#

How would I check if the player has joined the server before?

dense drift
#

d;spigot player#hasplayerbefore

uneven lanternBOT
#
boolean hasPlayedBefore()```
Description:

Checks if this player has played on this server before.

Returns:

True if the player has played before, otherwise false

limber hedge
#

ok thanks

limber hedge
#

Whats the easiest way to get a players next chat input without an API?

prisma briar
dense drift
#

d;spigot conversation

uneven lanternBOT
#
public class Conversation
extends Object```
Conversation has 1 extensions, 15 methods, and  7 fields.
Description:

The Conversation class is responsible for tracking the current state of a conversation, displaying prompts to the user, and dispatching the user's response to the appropriate place. Conversation objects are not typically instantiated directly. Instead a ConversationFactory is used to construct identical conversations on demand.

Conversation flow consists of a directed graph of Prompt objects. Each time a prompt gets input from the user, it must return the next prompt in the graph. Since each Prompt chooses the next Prompt, complex conversation trees can be implemented where the nature of the player's response directs the flow of the conversation.

Each conversation has a ConversationPrefix that prepends all output from the conversation to the...

This description has been shortened as it was too long.

dense drift
#

d;spigot prompt

uneven lanternBOT
#
public interface Prompt
extends Cloneable```
Prompt has 1 super interfaces, 1 extensions, 8 implementing classes, 3 methods, and  1 fields.
Description:

A Prompt is the main constituent of a Conversation. Each prompt displays text to the user and optionally waits for a user's response. Prompts are chained together into a directed graph that represents the conversation flow. To halt a conversation, END_OF_CONVERSATION is returned in liu of another Prompt object.

limber hedge
#

ok thanks ill take a gander

prisma briar
#

oh, didnt know that exist

dense drift
#

it is pretty nice, could be better but yea

limber hedge
#

Is there a simple way to use conversations?

#

Bit confusing

robust flower
#

What in the actual heck is a "Conversation" lmao

dense drift
#

Bukkit api to get input from user

#

You can validate it and such

icy path
lyric gyro
#

is there a way to check plugin message channels that i didnt register yet like so i can list every message channel you can listen to

dusky harness
#

how come ur doing it in js? i thought u had more experience in java πŸ‘€

prisma briar
#

Is it possible to spawn a fake player but consistently spawn a fake player with Steve character model?

limber hedge
#

How do you get the output of an event function in separate function?

#

This is a bad example but yea:```java
public Player getChatInput(AsyncPlayerChatEvent event) {
return Player
}

public getChatter() {
// Get Player from getChatInput()
}```

dusky harness
#

like this?

limber hedge
#

yea ty

fathom kestrel
#

sorry for asking so many questions, but why doesn't this work?

#
    public void PlayerItemConsumeEvent(Player player, ItemStack item) {
        ItemStack glowberry = new ItemStack(Material.GLOW_BERRIES);
        if (item == glowberry) {
            if (item.getEnchantments().containsKey(Enchantment.FIRE_ASPECT)) {
                player.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, 100,1));
            }
        }
    }
prisma briar
#

And register it

lyric gyro
#

That's not event

prisma briar
#

oh true

#

lmao

#

the naming confused me

prisma briar
dusky harness
fathom kestrel
#

    @EventHandler
    public void onEat(PlayerItemConsumeEvent e) {
        ItemStack item = e.getItem();
        Player player = e.getPlayer();
        if (item.getType() == Material.GLOW_BERRIES) {
            if (item.getEnchantments().containsKey(Enchantment.FIRE_ASPECT)) {
                player.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, 100,1));
            }
        }
    }
}```
#

so I changed it to this

dusky harness
#

i think that should work

#

make sure you registered it

fathom kestrel
#



public static onEat onEat;

dusky harness
#

oh wait

fathom kestrel
#

i put those tow lines in the main

dusky harness
#

you need to implement Listener

dusky harness
fathom kestrel
#

theyre in seperate places

dusky harness
#

you don't need the second line
but you have to tell java that your class is a listener by doing this: java public class onEat implements Listener { // code } and to register: ```java
this.getServer().getPluginManager().registerEvents(new onEat(), this);

fathom kestrel
#

ok

dusky harness
#

that's paper api D:

dense drift
slow kiln
#

Does anyone have any resources about how to go about optimising you code to the fullest i.e using asynchronous code etc, I want to learn more about it, maybe a video or something?

for the spigot framework

dusky harness
# slow kiln Does anyone have any resources about how to go about optimising you code to the ...

use spark: https://www.spigotmc.org/resources/spark.57242/
/spark profiler to start profiling
/spark profiler --stop to stop profiling
once you click the link you'll see this: https://i.imgur.com/78ahR2K.png, click that so that it says sources so that it'll categorize by plugin

for async stuff, that depends on what you're doing, so I'd need more information
but note that you should be very careful when using the bukkit api async - and you shouldn't modify the world (including entities) async

sterile hinge
#

async != optimized

#

a good structure is way more important

dusky harness
#

sort of

slow kiln
dusky harness
#

async is very helpful if done correctly

#

so ig

#

having a good structure + async = good

#

but it depends on what you're doing that needs to be ran async

sterile hinge
slow kiln
dusky harness
#

whats ur plugin name?

slow kiln
#

VerityMC

dusky harness
#

yea ur plugin seems optimized enough to not use async

#

it's only taking up 0.27% of the main thread

sterile hinge
#

also async != async, there's a difference between parallelizing an algorithm and running a task separately

slow kiln
#

public void simulateBlockBreak(BlockBreakEvent e, UUID uuid) {
        Bukkit.getScheduler().runTaskAsynchronously(pickaxeModule.plugin, () -> {
            Pickaxe pickaxe = getUserPickaxe(uuid);
            if (pickaxe == null) return;
            
            pickaxeModule.getEnchantmentList().stream()
                    .filter(enchantment -> pickaxe.getEnchantments().get(enchantment) > 0)
                    .forEach(enchantment -> enchantment.blockBreakHandler(e));

            pickaxe.addBlocksMined(1);
            pickaxe.addExperience(3);
        });

    }

This is currently things I use Asynchronous tasks for, which I don't even think is needed?

sterile hinge
#

then, it's also important to know which methods in spigot are costly and which aren't. That's probably the most important factor for most plugins

dusky harness
slow kiln
sterile hinge
slow kiln
dusky harness
#

anyways im probably going to be afk, good luck πŸ‘

slow kiln
sterile hinge
#

most people also overestimate the cost of a few simple methods and underestimate the issues multithreading brings

slow kiln
sterile hinge
#

yes, especially consider looking into improving the time the method takes before running it async

slow kiln
dusky harness
slow kiln
#

But if I don't spawn them asynchronously the server times out..

dusky harness
#

πŸ€”

sterile hinge
#

showing code would help there

slow kiln
#

    public static void paste(File file, Location location) {
            try {

                final BlockVector3 vector = BlockVector3.at(location.toVector().getX(), location.toVector().getY(), location.toVector().getZ());

                Clipboard schematic = FaweAPI.load(file);
                EditSession editSession = new EditSessionBuilder(FaweAPI.getWorld(location.getWorld().getName())).fastmode(true).build();

                FaweAPI.createQueue(editSession.getWorld(), true).enableQueue();
                
                Operation operation = new ClipboardHolder(schematic)
                        .createPaste(editSession)
                        .ignoreAirBlocks(true)
                        .to(vector).build();

                try {
                    Operations.complete(operation);
                    editSession.flushQueue();
                } catch (WorldEditException e) {
                    e.printStackTrace();
                }

            } catch (MaxChangedBlocksException | IOException e) {
                e.printStackTrace();
            }
    }

Ended up doing this, Idk if it's an anomaly that the schematic doesn't spawn or something else, but it does take up a lot of performance when spawning one

sterile hinge
slow kiln
sterile hinge
#

you should do so in that case

slow kiln
#

But I was running into problems where my schematic wouldn't paste in some cases?

sterile hinge
#

hard to tell what was wrong without seeing that code

dusky harness
#

wait

#

u might be able to do Map<File, Clipboard>

#

im not sure how the #equals in File works

#

uhh

slow kiln
#

Why would I need to cache it? I don't think it's much performance to load it

dusky harness
#

why my embeds never working anymore 😭

#

do you know what files are being loaded?

#

like are you hardcoding the files?

slow kiln
#

It's a singular file

#

it get's it from my plugin folder

#

Is 0.94% considered a large amount when it comes to performance, sorry I'm not really knowledgable on this sort of thing

dusky harness
#

just 1 file?

slow kiln
#

yes

#

Yeah see I've got a problem now

dusky harness
#

well loading the file probably includes IO

#

and IO = slow

slow kiln
#

I have 2 accounts, both spawning the schematic running a command, only one spawns...

#

asynchronously ...

dusky harness
#

yea i think u should run it sync

#

and let FAWE handle async stuff

#

maybe you can cache the schematic in PMineManager

#

so that every time you're pasting the schematic, it's not reading the file

slow kiln
#

Good idea,

#

when running my task async it only takes 0.12% of the main thread yikes

#

like the entire plugin

dusky harness
#

so something like java private final VerityMCPlugin plugin; // assuming you have some sort of plugin field private final Schematic schematic = FaweAPI.load(/* file here */); you might have to do java public PMineManager(/* constructer params */) { // code Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> schematic = FaweAPI.load(/* file here */); )}; }though if you're making the PMineManager instance before the server is fully starting and if FaweAPI.load requires the server being up and running

#

then paste(schematic, location) instead of paste(file, location)

sterile hinge
#

if you don't run it async, it will block the main thread (and when unlucky, you'll run in a deadlock)

#

so the whole paste method should be run async in best case

dusky harness
#

schematics aren't always loading

#

so i'd assume that the fawe api isn't meant to be ran async 🀷

#

Β―_(ツ)_/Β―

#

We suggest that FAWE operations are completed asynchronously.
hmm

#

interesting

sterile hinge
#

it is meant to be ran async, everything else might cause issues

dusky harness
slow kiln
dusky harness
# slow kiln ```java public static void paste(File file, Location location) { ...

so you can change this to ```java
public static void paste(Clipboard schematic, Location location) {
EditSession editSession = null;
try {
final BlockVector3 vector = BlockVector3.at(location.toVector().getX(), location.toVector().getY(), location.toVector().getZ());
editSession = new EditSessionBuilder(FaweAPI.getWorld(location.getWorld().getName())).fastmode(true).build();

            FaweAPI.createQueue(editSession.getWorld(), true).enableQueue();
            
            Operation operation = new ClipboardHolder(schematic)
                    .createPaste(editSession)
                    .ignoreAirBlocks(true)
                    .to(vector).build();

            try {
                Operations.complete(operation);
                editSession.flushQueue();
            } catch (WorldEditException e) {
                e.printStackTrace();
            }

        } catch (MaxChangedBlocksException | IOException e) {
            e.printStackTrace();
        } finally {
            editSession.close();
        }
}
#

or try with resources

slow kiln
#

flushQueue closes it?

dusky harness
#

oh

#

welp

#

ohh

#

i didn't see that

#

nvm then xD

#

although putting it in a finally block is good practice 🀷

#

since unless the server stops, the code will always run

slow kiln
#
Communicate to the EditSession that all block changes are complete, and that it should apply them to the world.
Deprecated
Replace with close() for proper cleanup behavior.
sterile hinge
#

try with resources would be the good practice

dusky harness
#

true - as vector doesn't need to be in the try

slow kiln
#

If FAWE is supposed to be done asynchronously then why isn't my schematics spawning?

I run the command
/mine create on 2 separate accounts one after the other, one of the schematics paste but the other doesn't, this only happens when I put it inside a async scheduler ?

#

Now im getting things where the schematic is only 1/3 pasting

dusky harness
slow kiln
#

async

dusky harness
#

weird πŸ€”

i'd recommend just doing it sync for now since it's probably only going to take like 2% of the thread sync - and maybe you can ask in IntellectualSites discord (who created FAWE) about the issue

slow kiln
#

Yeah it's literally just async that causes the problems, here is it now without async and everything works perfectly, when 2 people load something at the same time there is like 0 noticable performance hits, still got to change the FAWE.load thing

https://spark.lucko.me/8rk03Sd424

sterile hinge
#

well you still did not show your code with the async way

slow kiln
sterile hinge
#

I'd like to see the actual code

leaden sinew
slow kiln
slow kiln
sterile hinge
#

No

#

it will block the main thread until the schematic was pasted

dusky harness
leaden sinew
#

That doesn't necessarily mean in an async task

sterile hinge
#

and if FAWE needs to synchronize on the main thread for some reason it will just crash the server that way

brittle thunder
#

1 schematic could mean any number of blocks

sterile hinge
dusky harness
slow kiln
sterile hinge
#

@lyric gyro 😦

lyric gyro
#

hi~ :3

brittle thunder
#

Emily hates FAWE xD

sterile hinge
#

every sane person does

brittle thunder
#

xD

lyric gyro
#

lol

slow kiln
sterile hinge
#

yes

brittle thunder
#

oh lmao xD

sterile hinge
#

well it's supposed to work when pasting async. If it doesn't, there's something wrong. That can have several reasons and debugging it over a text channel is more than suboptimal

#

and I didn't touch fawe in a while now tbh

#

make sure you're up to date

slow kiln
#

Yeah I'm on the latest version

#

https://imgur.com/a/H9fQaWj This is what it's supposed to look like, when I run the paste inside of a async scheduler it either doesn't paste at all or only a section of it pastes

#

*the object in the centre isn't apart of the schematic

sterile hinge
#

can you check if it's just a visualization issue or an actual pasting issue?

slow kiln
#

I will check now and get video evidience

slow kiln
fathom kestrel
#
    ItemMeta meta = lucky.getItemMeta();
    lucky.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 5);
#

I'm trying to add enchantments with this code

#

and it doesn't work

#

it says "Cannot resolve symbol 'addenchantment'"

pure crater
#

d;spigot ItemStack#addEnchantment

uneven lanternBOT
#
public void addEnchantment(@NotNull Enchantment ench, int level)
throws IllegalArgumentException```
Description:

Adds the specified Enchantment to this item stack.

If this item stack already contained the given enchantment (at any level), it will be replaced.

Throws:

IllegalArgumentException - if enchantment null, or enchantment is not applicable

Parameters:

ench - Enchantment to add
level - Level of the enchantment

pure crater
#

uhm

fathom kestrel
leaden sinew
fathom kestrel
#

1.17

proud pebble
#

1.17 or 1.17.1

fathom kestrel
#

.1

proud pebble
#

does it say the error in your ide or in the server?

dusky harness
#

ah

sterile hinge
slow kiln
proud pebble
fathom kestrel
#

spigot 1.17.1 API

proud pebble
#

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
etc

#

yk what just upload the entire class to pastebin or smth

#

!paste

fathom kestrel
steady ingot
fathom kestrel
#

it isnt

proud pebble
#

it is

#
public void luckyCookie(PlayerItemConsumeEvent e) {
  ...
}
ItemStack lucky = new ItemStack(Material.COOKIE, 1);
lucky.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 1);

#

the code your trying to define is outside of the scope of luckyCookie()

fathom kestrel
#

that isnt supposed to be in the event

proud pebble
#

well what is it supposed to do then?

fathom kestrel
#

I'm going to make a recipe with it

proud pebble
#

you cant kept it out of a method without defining its access modifier

formal crane
sterile hinge
#

java 15+ would tell you what exactly is null

#

you either didn't add the admin command to your plugin.yml or the plugin instance is null

formal crane
#

oh yea i see

#

forgot the plugin.yml

#

ty

cerulean birch
#

anyone know how a bukkit scheduler actually works? like, is it possible to find the source for an implementation of it, or if someone is able to explain it in brief terms?
specifically, the way that it executes tasks on a scheduled basis. looking to make a similar version of it

leaden sinew
#

The tasks are in a queue, and during the game loop, they are executed.

dusky harness
#

game loop = each tick

leaden sinew
#

each tick = game loop

cerulean birch
#

ik what a tick is lol

#

but how do i replicate a "game loop" outside of MC

#

i.e how do i make something happen after x milliseconds

leaden sinew
#

Make a new thread

#

Have a loop inside of it

cerulean birch
#

what type of loop lol

#

while (true) {} ? lol

leaden sinew
#

Yeah

dusky harness
#

or ```java
Thread.sleep(1000L);
System.out.println("1 second passed");

cerulean birch
#

oh

leaden sinew
dusky harness
#

then submit a new task

#

its cached thread pool

leaden sinew
#

But the thread is sleeping

dusky harness
#

so it'll just create a new thread

cerulean birch
#

i was mostly just looking for the timing mechanism

#

which seems to be Thread.sleep

leaden sinew
#

What if all the threads are used?

dusky harness
#

which is why you probably shouldn't use cached thread pool

#

then ur pc go die

#

πŸ’€

cerulean birch
#

lol

dusky harness
#

if you want i can make a scheduler class for u

#

it'll just take a couple minutes

cerulean birch
#

can't i just like make a new class that extends a thread or sum

cerulean birch
leaden sinew
#

Just have a queue and a submitTask method

#

It also depends if you want the task async

cerulean birch
#

every 10 milliseconds it checks if the tasks are scheduled to occur

#

or smthing like that

leaden sinew
#

Sure

cerulean birch
#

it's for a discord bot so i don't think async matters too much compared to bukkit

leaden sinew
#

It depends what you’re doing

cerulean birch
#

yeah

cerulean birch
graceful hedge
# cerulean birch i.e how do i make something happen after x milliseconds

Ideally you would have a single scheduled thread pool executor which execute its tasks by delegating them to a cached thread pool (which would probably be best for general use to achieve truly asynchronous and concurrent, scheduled task coordination asynchronously) however if you for some reason know what tasks are running in the thread pool you might wanna switch it out to something else like javas fixed size thread pool or javas work stealing pool. This is of course with the assumption that you know something called the β€œblocking coefficient” which will determine the amount of threads you might need for the thread pool.

dusky harness
cerulean birch
graceful hedge
#

Bukkit has to queue the async tasks with the general game loop which if you have the ability to can break free from by using as I said a scheduled executor service implementation.

graceful hedge
#

It creates a new thread for every task :0

cerulean birch
graceful hedge
#

depends

#

I mean you achieve better concurrency

#

but it’s probably more cpu consuming

dusky harness
#

done 😀

graceful hedge
#

The biggest reason I can see why you want to avoid Thread::sleep would be, let’s say you do it in a Runnable instance which is passed to the executor, then the thread which runs the runnable will be "seen" as used but in reality it’s (the thread) just waiting. If it’s a cached thread pool, then your cached thread pool’s thread amount will grow unnecessarily.

thorn cape
#

can anyone here help me with my discord bot or no, only plugin related stuff?

dusky harness
#

@cerulean birch
https://paste.helpch.at/enanopopem.Scheduler.java
https://paste.helpch.at/efowohegug.EntryImpl.java <- not needed on java 9+

the delay parameter in Scheduler is how often it should check if the tasks should be ran

so if you put the delay as 1000L, it'll only run tasks every second
note that it won't run at exactly the milliseconds defined in delay, but it'll come pretty close

example usage: ```java
private final Scheduler scheduler = new Scheduler(50L); // 20 times per second

public void something() {
scheduler.runTask(1000L, () -> System.out.println("1 second later!"));
}

cerulean birch
#

Sexy

dusky harness
thorn cape
cerulean birch
#

Message.delete?

thorn cape
#

discordjs

dusky harness
#

oh

cerulean birch
#

Oh

dusky harness
#

i'd recommend asking in djs server then

#

πŸ₯²

thorn cape
#

πŸ₯²

graceful hedge
cerulean birch
#

We’re Java bois here

dusky harness
#

yep

thorn cape
#

you see that's what I thought

cerulean birch
#

Well

#

Do u queue the action

graceful hedge
#

it’s not different from how it would be done in Java like something similar to JDA or Javacord

cerulean birch
#

Idk how it works in djs but in jda you need to queue actions

graceful hedge
#

They don’t have queues the same way JDA does

cerulean birch
#

Oh

graceful hedge
#

iirc it’s just an async function

thorn cape
#

im just having trouble with basic stuff like storing objects and accessing objects but thanks anyways off to the djs server pepeW

dusky harness
#

D:

graceful hedge
#

Well that’s probably good enough

#

But like that isn’t going to be used as a game loop?

dusky harness
#

i dont think so

#

idk

graceful hedge
#

Anyways dkim only nitpick would be to use nanoTime instead of currentTimeMillis

#

But probably doesn’t matter

#

And ofc ScheduledExecutorService πŸ˜‹

dusky harness
dusky harness
#

btw whats the diff between using singleThreadedExecutor vs new thread?

#

oh wait

#

the executor gives u an Executor

graceful hedge
#

One can run multiple tasks

dusky harness
#

but in this case it doesn't matter since im only submitting once, right?

graceful hedge
#

One can only run one task

dusky harness
#

Β―_(ツ)_/Β―

graceful hedge
#

Technically you’d only need a single thread for that

#

And not a thread executor

dusky harness
#

yea

graceful hedge
#

nanoTime is best when you want to compare

dusky harness
#

how come? πŸ‘€

graceful hedge
#

Because of close calls

#

now I doubt this is the case here

#

anyways yeah nanoTime is afaik not guaranteed to be consistent across different jvm instances

dusky harness
#

hmm

#

ah

graceful hedge
#

and currentTimeMillis is clocked time if they haven’t changed it

#

Oh yeah

#

Stackoverflow catvibe

dusky harness
#

lol

#

but ty, didn't know about this πŸ‘€

graceful hedge
#

Btw do you play skyblock on hypixel?

dusky harness
#

nope

graceful hedge
#

Aw rip

#

Anyways multithreading is quite annoying imo due to how difficult it is to test sometimes

dusky harness
#

luckily i remembered that I had to add a Thread.sleep to prevent the program from ending early 😌

graceful hedge
dusky harness
#

Pair?

leaden sinew
#

Or something like that

dusky harness
#

uhh

graceful hedge
#

Enterprise Verbosityℒ️

leaden sinew
#

Ik it’s not a class

#

You would have to make it

dusky harness
#

o

#

idk Map.Entry already existed

#

and plus

#

theres Map.entry() or something like that on java 9+

#

so less code changing if they're on 9+ :)

leaden sinew
#

Shouldn’t you only use it for Maps though?

dusky harness
#

Β―_(ツ)_/Β―

leaden sinew
#

You could make like a Task class with a time and runnable

dusky harness
#

true

graceful hedge
leaden sinew
#

Lol

dusky harness
#

Dkim19375Coreℒ️ used to have an Entry impl lol

graceful hedge
graceful hedge
#

What the hell

dusky harness
#

lol

#

remember this was from almost a year ago

#

so

graceful hedge
#

18th

#

January

#

Yeah

#

That’s comforting at least

graceful hedge
#

DkimBukkitCore πŸ‰

dusky harness
#

πŸ‰ πŸ€”

graceful hedge
#

Jesus

#

Looks like one of those functional java libs with something like QuadrillionOptionalFunction

dusky harness
#

πŸ₯²

graceful hedge
#

What the utterly fuck is this lmao

dusky harness
#

🀣

#

🀣

graceful hedge
#

iOS destroyed that emote

dusky harness
#

WHAT IS THAT

#

LOL

graceful hedge
#

Holy moly cheese

dusky harness
#

@dusky harness tear image

graceful hedge
#

That’s absurdly awful lol

void orchid
#

That's ridiculous

dusky harness
#

printToConsole

#

🀣

#

getServer().getConsoleSender().sendMessage("[" + getDescription().getName() + "] " + msg);

#

ah yes

graceful hedge
#

"Core"

dusky harness
#

still CoreJavaPlugin

#

Β―_(ツ)_/Β―

graceful hedge
#

Ah

dusky harness
#

still... abstract πŸ€”

graceful hedge
#

I just delegate to another class

dusky harness
#

wdym?

#

oh

graceful hedge
#

Because of the fucking rigidity you’d get if you involve your logic with the inherited logic of JavaPlugin

#

Yeah

#

I usually have something like a bootstrap class

dusky harness
#

ooh wanna see something cool

graceful hedge
#

Okay lol

dusky harness
graceful hedge
#

😫

#

something cool

dusky harness
#

😀

#

lol

#

reflection πŸ₯΄

graceful hedge
#

And that looks bad

dusky harness
#

🀣

graceful hedge
#

Even in kotlin

#

Or well

#

Is Pair<Pair<X,Y>,Z> a good pattern in Kotlin?

dusky harness
#

nope

#

πŸ₯²

pure crater
#

Triple

dusky harness
#

but what that function does

graceful hedge
dusky harness
#

is do Bukkit.getEntity

#

in old versions

graceful hedge
#

No

graceful hedge
#

πŸ’©

dusky harness
#

that image

#

is

#

horrifying

graceful hedge
dusky harness
#

@pure crater

#

anyways ima go now

#

cya

#

πŸ‘‹

pure crater
#

Lol

graceful hedge
#

Cya dkim

cerulean birch
#

best way to get a User in JDA? assuming u have the long id and the bot is only in one server?

I assume
return DiscordBot.getBot().getGuild().getJDA().getUserById(id);
(Guild#getJDA#getUserById) isnt the best

limber hedge
#
    public static String getResult(Player player){
        String result;
        result = Main.data.getConfig().getString("Players." + player.getUniqueId().toString() + ".currentResult");
        return result;
    }```

Why does the above return null?

```yml
players:
  6b7b95b0-85b5-30cf-b997-271790f60040:
    currentResult: Kangaroozy```
leaden sinew
#

Also config matches case sensitive

limber hedge
# leaden sinew That can all be one statement btw

I wanna use it alot and wanna make it more organized, I'm using it in this

    public void openInventory(final HumanEntity ent) {
        if(DataUtil.hasResult((Player) ent) == true)
            ent.sendMessage(getResult((Player)ent));
            inv.setItem(13, ResultPlayer);
        if(DataUtil.hasResult((Player) ent) == false)
            inv.setItem(13, NonFound);
        ent.openInventory(inv);
    }
#

ent.sendMessage(getResult((Player)ent));

returns null

leaden sinew
#

You have Player and player in the config

limber hedge
#

ah i understand thank you

limber hedge
warm steppe
#

Why am I getting this?

SLF4J: Failed to load class "org.slf4j.impl.StaticMDCBinder".

even though I have log4j added in dependenciess

repositories {
    mavenCentral()
    maven {
        name = "m2-dv8tion"
        url = "https://m2.dv8tion.net/releases"
    }
}

dependencies {
    implementation("net.dv8tion:JDA:4.3.0_340")

    implementation("org.apache.logging.log4j:log4j-api:2.14.1")
    implementation("org.apache.logging.log4j:log4j-core:2.14.1")
}
tight junco
#

you need to add slf4j i believe

#

idk but it's generally an error you'll very rarely need to worry about in discord bots iirc

warm steppe
#

yeah but it's annoying

sharp cove
#

Hey, whats the best way to name classes?

#

I mean the best organized way?

wheat carbon
#

you should name classes based on what they do

#

and they should only do a single thing

sharp cove
#

I mean like for example, i have a class that triggers the playerjoin event in minecraft?

#

Its fine to name it ''onJoin'' right?

wheat carbon
#

no

#

and if it's "on", then it's listening

#

not triggering

icy shadow
#

you will literally die if you do that

wheat carbon
#

there's 2 issues with naming your class that

#

first it goes against java's class naming conventions, classes need to be named using pascal case

sharp cove
#

Ah, thats why i ask it here

wheat carbon
#

the second issue is that it doesn't really describe what the class does

#

I mean sure, it's technically true

#

you are listening to onjoin

#

the class name will tell you that

#

but it doesn't tell you anything about why it's listening to join, what it's really doing

formal crane
#

how would i fix that when multiple of my plugins start that the messages go on one line?

sharp cove
#

Ah..

#

So i could name it like JoinListener for example?

wheat carbon
#

no

#

I mean yes but you can do better

sharp cove
#

And the first letter needs to be uppercase?

wheat carbon
#

why are you listening to join?

sharp cove
#

Oh for example, i wanna send the player a message when joining.

wheat carbon
formal crane
#

system.out.print

wheat carbon
#

use System.out.println

#

(or ideally a logger)

icy shadow
#

Or better, a Logger

#

^

sharp cove
#

You can use Bukkit.getLogger to right?

formal crane
#

what is the diffrence?

wheat carbon
#

I'd recommend using the logger assigned to your plugin specifically, accessible via JavaPlugin#getLogger

sharp cove
#

I just use System.out.println().

wheat carbon
#

@formal crane println will end the message with a new line, print doesn't

wheat carbon
sharp cove
#

But @wheat carbon what do you recommend then naming a Event class?

formal crane
#

but whats the diffrence between printing it and logging it

sharp cove
#

Ah.

dusky harness
formal crane
#

is there a documentation on how to use the logging or is it just as simple as printing

wheat carbon
#

It's fairly simple

#

you'll need to get an instance of the logger, which you can do via JavaPlugin#getLogger

dusky harness
#

or ```java
plugin.getLogger().info("text");

sharp cove
wheat carbon
#

you need to follow pascal case for class names

#

(I'm not specifically answering your question because the implication is that you'll go and google pascal case and learn about it properly)

formal crane
#

is this structure correct?

forest jay
#

yeah

#

thats how I do mine

#

my onPlayerDeath event doesnt save inventory on 1.7 down to 1.5

brittle thunder
forest jay
#

the save inventory works on all versions above 1.7. I will take in mind using string contants.

brittle thunder
#

Do you get any exceptions thrown on below versions?

forest jay
#

I dont think so

brittle thunder
#

I also dont think compatibility below 1.8 is even worth it, theres barely a few idiots using such outdated version now

forest jay
#

and it goes all the way up to 1.16

brittle thunder
#

Ah, anyway, try not silencing the exceptions

#

Instead of try catch clauses to handle version differences, you different implementations of a class depending on version

#

generating an exception is quite costly

#

The stacktrace

forest jay
#

yeah, we are using Reflection for different versions, and I dont know if player.setKeepInventory() changed between versions

brittle thunder
#

Check javadocs

#

Try to avoid the method of catching and ignoring exceptions

neat pierBOT
forest jay
forest jay
brittle thunder
#

That seems incomplete, try to get the complete stacktrace

forest jay
brittle thunder
#

ah yes

#

its just an NPE

#

Show us this function com.apocgaming.worldcontrol.object.VInv.flatten

forest jay
#

wait a second

#

that was a outdated build

#

here is the latest exception

#

;ok

#

so

#

PlayerDeathEvent is fixed

#

but

#

PlayerRespawn isnt

#

it appears setting health doesnt work

broken elbow
#

πŸ₯² minecraft 1.5

brittle thunder
#

Old setHealth seems to have an int argument

forest jay
#

I give it a int

#

player.setHealth(20);

brittle thunder
#

You're depending on a newer version of spigot

#

The version you're depending on has a double signature

#

Hence it resolves to that

#

Use an interface and provide a separate implementation from another module that depends on 1.5

#

Or alternatively, you can use reflection like you mentioned earlier

#

I'd suggest looking into MethodHandles as well

forest jay
#

alright

#

but

#

it is asking for an int right?

#

I do give it a int, hmm

#

alright, I will try and solve this with what you said above

brittle thunder
#

Since the resolved method at compile-time has a double, its implicitly converted to a double

forest jay
#

alright

normal pewter
#

Any paper plugin developers that can help me out? dm me please

pulsar ferry
#

Ask your question here, doubt anyone will dm

normal pewter
#

makes sense, i saw the service request so i put it there

#

idk how this works lol im new to the whole server thing

pulsar ferry
#

Oh gotcha, yeah use the services, this channel is for support for making plugins

dusky harness
#

seems pretty simple but idk how i'd do it without super messy code:
I have a list of numbers
and i need to get the highest available number
so for example java final int max = Integer.MAX_VALUE; List<Integer> list = /* [max - 1, max - 2] */ would result in max
but java final int max = Integer.MAX_VALUE; List<Integer> list = /* [max, max - 1, max - 2] */ would result in max - 3 and java final int max = Integer.MAX_VALUE; List<Integer> list = /* [max, max - 2] */ would result in max - 1

tight junco
#

these uppercase variables are painful

dusky harness
#

i mean it was supposed to act as constants 🀷

#

lol

dusky harness
pulsar ferry
#

You mean the highest int in the list?

dusky harness
pulsar ferry
#

You can probably use streams

#

list.streams().max(...)

dusky harness
#

but wouldn't that just give the highest number in the list?

pulsar ferry
#

Based on the comparator you give it

dusky harness
#

uhhhhhhhh

#

i gtg now tho D:
maybe ill look at it after

forest jay
#

I want have a delay of 5 min between actions, how can I do this without pausing everything else?

dense drift
#

Schedule a task with bukkit scheduler?

forest jay
#

I was doing that, but it wouldnt run

#

I was doing a delayed task

#

and it never ran

#

a bunch of people tried to help, none of us could figure it out

dull yarrow
#

can anyone help me with curse.jar ?

broken elbow
#

you'll have to explain what that is

dull yarrow
#

curseforge.jar

#

the server jar file for mods

#

rings any bells or no?

broken elbow
#

nope. never used i

#

it*

dull yarrow
#

intresting

#

are you familiar with any mod jar file?

broken elbow
#

nope. haven't played or done anything modded in a long long time

dull yarrow
#

alright this will be quite the ride

#

basically my file is not starting properly if anyone can send me a forge server.jar file and ill test it if it works thanks if it doesn't its a problem with my host

dusky harness
high edge
#

why is that a while loop

graceful hedge
#

lol

dusky harness
#

idk how else to do it

#

wait

#

i could probably loop through the list and do somehting

#

idk

lyric gyro
#

LOL

pulsar ferry
#

I still don't know what it is supposed to do, it returns 8, how is that the highest id?

dusky harness
#

so if the list has 10 9 7

#

it would return 8

#
fun getHighestID(): Int {
    val list = listOf(2, 5, 1, 9, 10).sortedDescending()
    var id = 10
    if (list.isEmpty()) {
        return id
    }
    for (highest in list) {
        if (id > highest) {
            return id
        }
        id = highest - 1
    }
    return id
}
```i think this works too
#

without a while loop lol

pulsar ferry
#

Highest available slow from what? Basically highest not present in the list?

dusky harness
#

nvm i didn't even need this πŸ˜–

#

actually i might

#

idk

high edge
#

Makes no sense

robust flower
#

what is the point of using Sets.newHashSet() instead of new HashSet<>()?

pulsar ferry
#
val list = listOf(2, 5, 1, 9, 10).sortedDescending()
val max = (10 downTo 0).find { it !in list}
#

@dusky harness

dusky harness
#

πŸ‘€

robust flower
pulsar ferry
#

It's the same thing

robust flower
#

really? I have never used find xD

pulsar ferry
#

I used find because it should be val max = (10 downTo 0).find { it !in list} ?: 10

#

Find just calls firstOrNull

dusky harness
#

one thing - since im going from Int.MAX_VALUE - is it safe for me to do Int.MAX_VALUE downTo 0? πŸ‘€

dense drift
#

F

#

What do you want to do

pulsar ferry
#

You're going down from .. max int? Why?

dusky harness
#

entity ID

#

i don't want to have any chance of conflicting with real entities

dense drift
#

Pretty sure there's a way to get the last entity is from bukkit

#

I've seen it somewhere

pulsar ferry
#

I should have asked what the original goal is lmao
This is sounding more and more like an xy issue

dusky harness
#

i thought i said this before

edit: nope turns out i didn't ;-;

#

oops

robust flower
#

Bukkit.getWorld(blah).getEntities().maxOf { it.id } or something like that

#

then you just add 1

dusky harness
#

but then if bukkit makes an entity

robust flower
#

if you run this code on the main thread, that won't happen πŸ™‚

dense drift
#

The number is stored internally somewhere

pulsar ferry
#

Explain what your goal is first Dkim

dusky harness
#

the reason why i need an entity id is so for packets

dusky harness
#

as a static variable

pulsar ferry
#

Why not just UUID.randomUUID?

dusky harness
dusky harness
#

aka int

#

for the client

#

idk why the client doesn't use uuids

robust flower
dusky harness
#

O

#

is that mutable tho

robust flower
#

1.12.2 btw

#

?

#

numbers are not mutable

dusky harness
#

i'd need to modify the variable

#

im making a fake entity - so it won't be tracked in that unless i do it myself

#

which is why im just starting from Int.MAX_VALUE

#

instead of 0

robust flower
#

I didn't understand...

#

do you want bukkit to be aware of the entity or not?

dusky harness
#

no

robust flower
#

then why not just Random().nextInt(Int.MAX_VALUE - 100_000) + 100_000?

pulsar ferry
#

Or just start at max int and go down one by one as you spawn them

dusky harness
#

yea

robust flower
#

I would just use random xD

dusky harness
dusky harness
#

with an existing one

robust flower
#

with 2 billion ids?

dusky harness
#

Β―_(ツ)_/Β―

dusky harness
robust flower
#

haha then why not store the "used values" in a set and generate it again?

dusky harness
#

i was planning to do that (besides the random part) above

robust flower
dusky harness
#

true

robust flower
#

ofc I doubt that would really happen anyway, but yeah I just wanted to point it out

leaden sinew
lyric gyro
#

They are not persistent even between chunks unloading and reloading

robust flower
#

(moved to dev-general)

slim vortex
#

Is it possible to write a SPIGOT plugin that acts as a BUNGEE proxy and just redirects somebody to another server?
like the spigot plugin just intercepts traffic with netty or something

robust flower
#

that seems sketchy at best

topaz gust
#

You are mine now buttercup no playing hypixel you play hypwixel now

slim vortex
#

is there a plugin that exsts that does that

#

I dont know anything about proxy

brittle thunder
#

Not sure, essentially you'll just be mediating packets between the target player and server

#

player sends packet to your proxy server,
proxy server sends it as the player to the target server

#

and vice versa

#

So all you really need to do is establish a connection to the server as the player

#

I assume you'll find samples to joining a server on github

#

Try botting clients maybe

formal crane
#

how do i send an action bar to all online players?

broken elbow
#

loop thru all online players and send it?

formal crane
#

i have this in my on enable but it wont work:

            @Override
            public void run() {
                Bukkit.getOnlinePlayers().forEach(p -> {
                    Bukkit.broadcastMessage("Test");
                    p.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("&7Speel je ook mee? &aMelon&2Network"));
                });
            }
        }, 0, 200);```
robust flower
lyric gyro
#

you don't need a stream to call forEach lmao

formal crane
#

stream?

#

i fixed it btw

lyric gyro
#

was talking about Secret's code

formal crane
#

my project builder didnt go to the right directory

#

oh okay

robust flower
warm steppe
#

Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> {
Bukkit.getOnlinePlayers().forEach() -> {
Bukkit.broadcastMessage("Test");
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("&7Speel je ook mee? &aMelon&2Network"));
}
}, 0, 200);

dusky harness
#

runTaskTimer 😌

leaden sinew
formal crane
#

How would i make a bossbar change color every x seconds? like red, green, blue and then it starts again

leaden sinew
#

Resend the message

limber hedge
#
    public static ArrayList<Pair> getTop(){
        ArrayList<Pair> getVoted = new ArrayList<>();
        String result;
        if(Main.data.getConfig().contains("players")) {
            for (String key : Main.data.getConfig().getConfigurationSection("players").getKeys(false)) {
                ConfigurationSection userData = Main.data.getConfig().getConfigurationSection("players." + key);
                result = Main.data.getConfig().getString("players." + key + ".currentResult");

                getVoted.add(new Pair(userData.getInt("votesFor"), result));
            }

            Collections.sort(getVoted);

        }
        return getVoted;
    }```
I have this, but since my yml is
```yml
players:
  6b7b95b0-85b5-30cf-b997-271790f60040:
    currentResult: Kangaroozy
    hasvoted: true
    votesFor: 1
    votedFor: Kpaw```
Its returning null since it cant find the other 8 values i search for
#

How do I make it return "No Value" when it cant find the data

warm steppe
#

if null do smth lol

limber hedge
#

Im getting an out of bounds error

warm steppe
#

-1

#

i - 1

#

like when you iterate you probably have too large number to search for

#

like if you have 3 elements

limber hedge
#

the above is my whole yml file

#

thats the full thing

warm steppe
#

ah dodnt see it

#

didnt* xd

#

idk man

#

something isn't right

limber hedge
#

This works since it exists in the yml file:

"&e1. " + getTop().get(0).getValue() + "&7 - &e" + getTop().get(0).getKey() + " votes"));

This doesnt work since there is no data:

"&e2. " + getTop().get(1).getValue() + "&7 - &e" + getTop().get(1).getKey() + " votes"));```
#

Right now if it cant find the second one the whole plugin shuts down, I jsut want it to return "No Value" instead of shutting down completely

warm steppe
#

make the method throw Exception

#

and do a try/catch

limber hedge
# warm steppe and do a try/catch
    public static ArrayList<Pair> getTop(){
        ArrayList<Pair> getVoted = new ArrayList<>();
        String result;
        try {
            if (Main.data.getConfig().contains("players")) {
                for (String key : Main.data.getConfig().getConfigurationSection("players").getKeys(false)) {
                    ConfigurationSection userData = Main.data.getConfig().getConfigurationSection("players." + key);
                    result = Main.data.getConfig().getString("players." + key + ".currentResult");

                    getVoted.add(new Pair(userData.getInt("votesFor"), result));
                }

                Collections.sort(getVoted);

            }
        } catch (NullPointerException exception){
            Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA + "[CraftGasmCore] " + ChatColor.RED + "An error occured, please report this here with a screenshot of the error (Leaderboards)");
            exception.printStackTrace();
        }
        return getVoted;
    }```
#

Doesnt stop it from disabling the plugin

warm steppe
#

Exception

limber hedge
#

I tried that too

#

same thing

warm steppe
#

idk then man

#

im on my phone and wont help much but i wish you good luck fixing that error πŸ˜€

lyric gyro
#

Hey Im using "Math" with placeholderapi and my variables aren't working what so ever for "math"

tight junco
#

CraftGasm gasm

proud pebble
#

make multiple and name them based on the player uuid

limber hedge
#

I solved it luckily xP thanks for your help tho

#

appreciate it

robust flower
#

catch (NullPointerException exception) 🀣 that's a sign, man, sign that you're doing something wrong

#

oh and also this static ArrayList<Pair> getTop()

ebon whale
#

Hi there, having a question. How would I go about pushing default settings back into the config on reloading my plugin for cases when users have deleted an entire setting block without them having to delete the entire config to generate a new one?

strange remnant
#

if I use my command and it is returning false it will send the command I send in chat like /sc

#

if (args.length < 1) {
p.sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + "FlipsMC SC" + ChatColor.DARK_GRAY + "]" + ChatColor.RESET + " " + ChatColor.DARK_RED + "You cannot send message with no text!");
return false;

#

This will give me the command back with the message

ebon whale
leaden sinew
hoary scarab
#

Why do you need NMS for that? Does the API have setMaxStack()?

strange remnant
#

Please help me thank you

ebon whale
strange remnant
#

What do you mean?

#

Because I did

leaden sinew