#development

1 messages · Page 141 of 1

viral moth
#

yeah that'd explain it

gloomy geode
#

i will go try this now very much appreciated man

viral moth
#

np lol, best of luck

gloomy geode
viral moth
#

for what

gloomy geode
#

im having not good brain moment

viral moth
#

explain and I'll explain

gloomy geode
#

in the Disc class

#

my command

#

that i confusingly named

viral moth
#

send a snippet of what you currently have

#

or just explain it rq

#

bc if you're just trying to get the instance of you're plugin you just have to do Discord.getInstance()

gloomy geode
#

im trying to get my .getConfig() to work in Disc class

viral moth
#

ok

gloomy geode
#

public final class Discord extends JavaPlugin {

public static Discord instance;
public static Discord getInstance() {
    return instance;
}
private static Discord main;
@Override
public void onEnable() {
viral moth
#

Discord.getInstance().getConfig() lol

gloomy geode
#

i had the answer for most of this XD

viral moth
#

also why do you have 2 instance variables? main and instance

gloomy geode
#

oop

#

i forgot to delete one

viral moth
#

sorry about my grammar I'm horrible typing on mobile haha

gloomy geode
#

need some more practice or knowledge before going onto a second one

viral moth
#

it's always nice to practice but know why things work or when something works but you don't know why that is the best time to learn

gloomy geode
#

but it's all part of the learning process

viral moth
#

java is object oriented, trust me it took me forever to understand but that's because I tried learning when I was like 13 lol, I'm sure you can pick it up in a few days

gloomy geode
viral moth
#

i wouldn't mind explaining things however it's 1am and I have to be up early tomorrow, if you want help tmr feel free to ping me and I can try to explain objects

gloomy geode
#

things actually makes sense

gloomy geode
viral moth
#

feel free to ping me whenever, pings exist for a reason haha

gloomy geode
#

probably will take a break for a while tomorrow been at this plugin for about 7 hours

iron karma
#

how i can cancel a runnable?

high edge
#

cancel();

viral moth
#

.cancel();*

high edge
#

If you're in the scope of the runnable it's just cancel

craggy zealot
#

im creating a crafting api and this dosnt work
can someone understand why?

#
public boolean canCraft(PlayerInventory playerInventory) {
        boolean canCraft = true;
        for(CraftItem craftItem : craftItems) {
            if(!playerInventory.containsAtLeast(craftItem.getItem(), craftItem.getAmount())) {
                canCraft = false;
            }
        }
        return canCraft;
    }```
#
public class CraftItem {
    public ItemStack item;
    public int amount;
    public CraftItem(ItemStack item) {
        this.item = item;
    }
    public CraftItem(ItemStack item, int amount) {
        this.item = item;
        this.amount = amount;
    }
    public int getAmount() {
        return amount;
    }
    public ItemStack getItem() {
        return item;
    }
}```
dense drift
#

how do you use it?

high edge
#

Am I missing something or why would this not delete the world file?
(The world path is correct, it's also unloaded, and no it's not the main world)

final File worldFolder = new File(Bukkit.getServer().getWorldContainer().getPath() + "/" + it.getName());
final boolean result = worldFolder.delete();
craggy zealot
# dense drift how do you use it?
        for(GameRecipe gameRecipe : Main.getAllRecipes()) {
            if(gameRecipe.getCraftedItem().getItemMeta().getDisplayName().equalsIgnoreCase(itemStack.getItemMeta().getDisplayName())) {
                if(gameRecipe.canCraft(player.getInventory())) {
                    player.getInventory().addItem(gameRecipe.getCraftedItem());
                    for(CraftItem craftItem : gameRecipe.craftItems) {
                        ItemStack itemStack1 = craftItem.getItem();
                        itemStack1.setAmount(craftItem.getAmount());
                        player.getInventory().removeItem(itemStack1);
                        player.sendMessage(ChatColor.GOLD + "Crafted: " + gameRecipe.getCraftedItem());
                    }
                    return;
                }
            }
        }```
dark garnet
#

Ohhh I didn’t see the getConfigurationSection, thank you!

dense drift
#

@abstract marlin So, when the sign is created, save its lines somewhere and then get those lines, replace everything you need, and set them on the sign without updating them on your storage.

abstract marlin
#

ooo

#

now i get it

pulsar adder
#

when using the "EntityDamageByEntityEvent" event, how can i get the item that was attacked with?

dense drift
#

Attacker#getInventory#getItemInMainHand ?

iron karma
#

how i can update an actionbar?

pulsar adder
dense drift
#

No, is not

dense drift
iron karma
# dense drift Send a new one
new BukkitRunnable() {
            @Override
            public void run() {
                player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
            }
        }.runTaskTimer(plugin, 20, 20);
        player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));```i tried this, but dont works 😦
dense drift
#

Because your message is static

#

Create it inside the run() method

iron karma
# dense drift Create it inside the run() method
String message;
        new BukkitRunnable() {
            @Override
            public void run() {
                message = "&cTe quedan un total de &4&l" + plugin.getCounter().getLives(player) + "&c vidas";
                player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
            }
        }.runTaskTimer(plugin, 20, 20);
        player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));```
#

i tried this but dont works too xd

#

I get an error when reassigning the string value

dense drift
#

Dont define it at the top

#

d;spigot BukkitScheduler#runTaskTimer

uneven lanternBOT
#
void runTaskTimer(@NotNull Plugin plugin, @NotNull Consumer task, long delay, long period)
throws IllegalArgumentException, IllegalArgumentException```
Description:

Returns a task that will repeatedly run until cancelled, starting after the specified number of server ticks.

Parameters:

plugin - the reference to the plugin scheduling task
task - the task to be run
delay - the ticks to wait before running the task
period - the ticks to wait between runs

Throws:

IllegalArgumentException - if plugin is null
IllegalArgumentException - if task is null

dense drift
#

set the delay to 0, and you can remove the second player.spigot().sendMessage

hardy grail
#

Hey I wrote that code that stops a server if there is no player online for 60 seconds. But I don't get why the server does not stop after 60 seconds when the player rejoined and then left again. I hope someone can help me.

Thread waitTillStop=new Thread(() -> {
    try{
        sleep(60000);
    }catch (InterruptedException e){
        throw new RuntimeException(e);
    }
    if(Bukkit.getOnlinePlayers().size()<1){
        Bukkit.shutdown();
    }
});

@EventHandler
public void onPlayerLeave(PlayerQuitEvent event){
    if(Bukkit.getOnlinePlayers().size()<=1){
        waitTillStop.start();
    }
}
dense drift
#

dont use thread sleep, just schedule a bukkit runnable to run after 60 * 20 ticks

abstract marlin
#
for (Player player : Bukkit.getOnlinePlayers()) {
                    String replacedPlayerCount = PlaceholderAPI.setPlaceholders(player, "%bungee_" + tpSign.getTargetServer() + "%");
                    if (tpSign.getLines().length == 0) return;
                    if (tpSign.getLines().length == 1) {
                        sign.setLine(0, tpSign.getLines()[0].replace("{player_count}", replacedPlayerCount));
                    }else if (tpSign.getLines().length == 2){
                        sign.setLine(1, tpSign.getLines()[1].replace("{player_count}", replacedPlayerCount));
                    }else if (tpSign.getLines().length == 3){
                        sign.setLine(2, tpSign.getLines()[2].replace("{player_count}", replacedPlayerCount));
                    }else if (tpSign.getLines().length == 4){
                        sign.setLine(3, tpSign.getLines()[3].replace("{player_count}", replacedPlayerCount));
                    }
                    sign.update();
                }```
#

TpSign is a class which countains Location blocLocation, String TargetServer and String[] lines

dense drift
#

I told you, remove the forLoop, bungeecord placeholders are player independent

abstract marlin
abstract marlin
abstract marlin
dense drift
#

you know that return exits the method, right?

abstract marlin
#
Signs:
  '30':
    sign_location: world -10 72 202
    id: '30'
    target_server: lobby
    lines:
    - '{player_count}/5'
    - test be like
    - ''
    - ''
abstract marlin
dense drift
#

Alright, show your full code

abstract marlin
#
on Enable
Common.runTimer(20, () -> {
            final File file = FileUtil.getFile("signs.yml");
            if (!file.exists()) return;
            final SimpleYaml config = FileUtil.loadConfigurationStrict(file);
            if (config.getConfigurationSection("Signs") == null || config.getConfigurationSection("Signs").getKeys(false) == null) return;
            config.getConfigurationSection("Signs").getKeys(false).forEach(s -> {
                final TpSign tpSign = TpSign.getSign(s);
                if (!(tpSign.getSignLocation().getWorld().getBlockAt(tpSign.getSignLocation()).getState() instanceof Sign))
                    return;
                Sign sign = (Sign) tpSign.getSignLocation().getWorld().getBlockAt(tpSign.getSignLocation()).getState();
                String replacedPlayerCount = PlaceholderAPI.setPlaceholders(null, "%bungee_" + tpSign.getTargetServer() + "%");
                if (tpSign.getLines().length == 0) return;
                if (tpSign.getLines().length == 1) {
                        sign.setLine(0, tpSign.getLines()[0].replace("{player_count}", replacedPlayerCount));
                }else if (tpSign.getLines().length == 2){
                        sign.setLine(1, tpSign.getLines()[1].replace("{player_count}", replacedPlayerCount));
                }else if (tpSign.getLines().length == 3){
                        sign.setLine(2, tpSign.getLines()[2].replace("{player_count}", replacedPlayerCount));
                }else if (tpSign.getLines().length == 4){
                        sign.setLine(3, tpSign.getLines()[3].replace("{player_count}", replacedPlayerCount));
                }
                    sign.update();
            });
        });
#

should i use pastebin or use these embed kina things?

dense drift
#
                    if (tpSign.getLines().length == 1) {
                        sign.setLine(0, tpSign.getLines()[0].replace("{player_count}", replacedPlayerCount));
                    }else if (tpSign.getLines().length == 2){
                        sign.setLine(1, tpSign.getLines()[1].replace("{player_count}", replacedPlayerCount));
                    }else if (tpSign.getLines().length == 3){
                        sign.setLine(2, tpSign.getLines()[2].replace("{player_count}", replacedPlayerCount));
                    }else if (tpSign.getLines().length == 4){
                        sign.setLine(3, tpSign.getLines()[3].replace("{player_count}", replacedPlayerCount));
                    }```
use a `for (int i = 0; i < tpSign.getLines().length; i++)`, this way all lines will be set, not only the last one
abstract marlin
#

oh yea i m dumb i just noticed that

dense drift
#

I'm not sure how return behave on a forEach loop, so I suggest to either replace it with a normal for loop or to find out

abstract marlin
#

return will exist the whole method ie onEnable i guess to stop the for loop there was a method like break or something i also forgot

#

okay imma test it out .. thanks alot for helping this much @dense drift ❤️

dense drift
#

Well do some checks, see if it can find a TpSign by that name, if there is a sign at that location

wary dust
#

Does anyone know what could be causing Jedis IO locks

dense drift
#

Np

graceful hedge
# wary dust Does anyone know what could be causing Jedis IO locks

well, generally you usually need at least 2 connections with redis (for pub sub), one for receiving and one for publishing, idk exactly what you're doing but you ought to use a JedisPool instance (since normal Jedis instances will be blocking)

EDIT: also why you might wanna favor lettuce or redisson as they have concurrent designs for you as opposed to jedis where you almost kind of have to do that step yourself

wary dust
#

Cool, thanks for your help!

hardy grail
dense drift
#

Thats just the default message telling you on what event is an exception, send the error.

dense drift
#

And the code?

hardy grail
#

it works one time idk why it stops working after that

broken elbow
#

you're not initalizing shut anywhere

hardy grail
#

why do I have to initialize it?

#

I don't get why it's working for one time

broken elbow
#

because you're using it and I assume you don't want it to be null?

dense drift
gloomy geode
#
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
        if (!(commandSender instanceof Player)) {
            Msg.send(commandSender, "&cOnly players can use this command.");
            return true;
        }
        //checks if player has permission if not, send message, if does, sends a different message
        if (!(commandSender.hasPermission("discord.discord") )){
            Msg.send(commandSender, "&cYou do not have access to this command.");
            return true;
        } else {
            //send message to player from config.yml
            Msg.send(commandSender, link);
        }

        Player player = (Player) commandSender;
        return true;
    }

how would one make an argument to this, replacing
String[] strings with String[] args makes the command not work so

dense drift
#

The name of the argumente on method definition doesnt matter.

gloomy geode
#
if (args.length == 0){
            Discord.getInstance().reloadConfig();
#

this what is not working

#

args returning red

#

cannot resolve symobl

#

the if statement is very bland with it just check length not for specific word i know

dense drift
#

because args doesn't exist I presume

gloomy geode
dense drift
#

Do you have String[] string or String[] args on your method?

gloomy geode
#

string [] strings because it won

#

wont work the otherwise

#

command makes exception without strings there

dense drift
#

That is the issue, you are trying to use args, but the parameter is named strings

gloomy geode
dense drift
#

If you define it as strings, then use strings.

gloomy geode
#

so my if statement would change to
if (strings.length==0)

dense drift
#

yes

gloomy geode
# dense drift yes

bro it's the littlest things this is aggrovating xD, tysm much appreciated for your time!

stuck hearth
stuck hearth
#

Oh shit

gloomy geode
#

as projects

stuck hearth
#

No worries just thought I'd toss it out there to save some headache in the future.

jovial kettle
#

And yes this will work

gloomy geode
#

already working with me code

#

my*

#

its fine

jovial kettle
#

Sure

icy shadow
#

spawns it how?

#

with /summon?

proud pebble
#

Turns out there is a client server desync with the player's offhand when attempting to put an item in it and the action has been cancelled.

#

on the clientside in survival the item shows up in the player's offhand but its visual only. in creative the item is put in the player's offhand and its not a ghost item.

#

such fun

#

not sure if its been fixed in 1.19 but its there in 1.18.2

lyric gyro
#

don't bother with creative mode, it's a cesspool of inventory-related bypasses, both the server and the client make many assumptions when the player is in creative

proud pebble
#

im more bothered about the item showing up in the offhand as a ghost item tbh

lyric gyro
#

you can try sending an inventory update, don't know if that works for offhand stuff

#

err Player#updateInventory?

proud pebble
#

tried both as regular and in a task and neither made a difference

#

-_- ig ill deal with it, glad that it wasnt an issue with my code atleast it was just a ghost block

#

kinda scared me cus i tried many times to cancel the event when it was that action and the item kept coming back

#

ive have other desyncs with the offhand

#

stupid

#

ig ill deal with it fornow, not crucial for the plugin to work, just irritating.

#

anyways, i got my crafting gui plugin to work, while fixing some issues with clicking the output slot and it deleting the items.

#

and they should all be fixed™️.

graceful juniper
#

Quite a difficult question which I need help going through.

So currently I'm working with chunks but I want to get an array of chunks.
This array will have chunks which are in a 3x3 in the actual mc world.
For Example: Array[(-1,1), (0,1), (1,1)] and so on. It should end up in a 3x3 chunk square.

  • I will need this to be a function that can be used multiple times and get a new set of 3x3 chunks that haven't been used beforehand

Now I'm sort of new to chunks, I know how they are arranged but I just can't get the idea in my head of how to grab all of these chunks in an array. Can anyone help?

atomic trail
#

Does someone know which repository or dependency slf4j logger is located?
I've always just imported it without adding anything, but can't now for some reason

dusky harness
#

Is there a way to know either:

  • How many hearts of damage Player#damage actually will do (as protection cancels some of it out)
  • or how to prevent protection from affecting Player#damage?
#

Atm the workaround is to just do Player#damage and then after that, do Player#setHealth, but the issue is that damage indicator plugins would show an incorrect value (since it only detects Player#damage)

#

Oh wait I can just do Player#damage(0.0) and then call EntityDamageEvent 🤔 (and Player#setHealth)

wintry grove
#

idk the protection formula but you can get the prot level the player has and then do the math with the damage you want to do

dusky harness
#

but then I'd have to invert that to find the damage I'd need to put in the parameter 🥴

Atm I'm just doing 0.1 damage and calling a fake event (then doing #setDamage)

jade wave
#

I cant seem to access it

dusky harness
jade wave
#

Thanks man ❤️

#

Will this work for mc resourcepacks aswell?

dusky harness
#

Don't know which algorithm mc uses

jade wave
#

Got one

dusky harness
#

oh does it use SHA1?

jade wave
#

Yeee

#

Mc resourcepacks use SHA1

dusky harness
#

👍

viral moth
wintry grove
#

that or doing some hacky stuff

viral moth
#

just like

#

damage them

shell moon
#

"".split("-") returned an array with length 0 or 1? xd

stuck hearth
#

Size would be dependent on how many splittable chars are available

viral moth
#

or more

#

it will never be 0

shell moon
gloomy geode
#

whenever i change it to args

viral moth
#

so

#

as someone else mentioned, the variable name doesn't matter

gloomy geode
#

here wait lemme test it and show you

viral moth
#

you're skipping one somewhere and refactoring it will change all occurrences

gloomy geode
#

I think i had another problem yesteryday

#

ohhhh gotcha

#

i definitely was missing one

viral moth
#

send the error message as well as the code that threw the error

gloomy geode
#

if it throws error this time im testing it

#

no it was my atttempt at a reload command that threw it

#

it worked just fine with refactor

#

I couldn't ever figure out how to put the if statement into my command for the reload

#

couldn't think it through

#
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
        if (!(commandSender instanceof Player)) {
            Msg.send(commandSender, "&cOnly players can use this command.");
            return true;
        }
        //checks if player has permission if not, send message, if does, sends a different message
        if (!(commandSender.hasPermission("discord.discord"))) {
            Msg.send(commandSender, "&cYou do not have access to this command.");
            return true;
        } else {
                //send message to player from config.yml
                Msg.send(commandSender, link);
            }

            Player player = (Player) commandSender;
            return true;
        }
    }
#

the comments are to double check i know im writing

#

and a habit im starting lol

viral moth
#

can you put a comment on what's given to error, I'm on mobile so it's more tricky to view

gloomy geode
#

nothing gave an error

#

I was trying to figure out where to put the reload

viral moth
#

oh lol

gloomy geode
#

I couldn't quite wrap my head around it

viral moth
#

reload as in?

gloomy geode
#

/discord reload

#

config

viral moth
#

oh

gloomy geode
#

you can wait if you are going to be back at your computer at some point

viral moth
#

did you get it or still no

gloomy geode
#

no I couldn't get it to work

viral moth
#

I'm in bed lol, have to be up early

gloomy geode
#

oh gotcha it's fine dont worry about it xD

viral moth
#

like I gotta be up early but I have time lol

#

I can help

gloomy geode
#

so is there a way you can guide me without fully teling me?

#

you can dm me also so we dont spam this chat

#

with my dumb questions

viral moth
#

if args[0].equalsIgnoreCase("reload")

#

that's you're if, also check if args.length > 0

#

check length first

#

and then just do Main.getInstance().reloadConfig()

gloomy geode
#

yeah I have that stuff

viral moth
#

and what's the error

gloomy geode
#

It's like the positioning of it

#

in my command executor

#
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
        if (!(commandSender instanceof Player)) {
            Msg.send(commandSender, "&cOnly players can use this command.");
            return true;
        }
        //checks if player has permission if not, send message, if does, sends a different message
        if (!(commandSender.hasPermission("discord.discord"))) {
            Msg.send(commandSender, "&cYou do not have access to this command.");
            return true;
        } else {
                //send message to player from config.yml
                Msg.send(commandSender, link);
            }

            Player player = (Player) commandSender;
            return true;
        }
    }
#

like how to put it where

viral moth
#

try to avoid else statements and use the return at the end of an if statement

#

delete your only else case and put a return at the end of the if above and put the code at the bottom, after getting the player. it doesn't really matter where but it will work at the bottom

#

if that's not the issue , try to do it with your thought process and send me the "wrong" code and I'll try my best to explain how to fix it

gloomy geode
#

alright I will, you might be asleep when i get to it

#

ill just ping you

viral moth
#

if not I'll respond when I wake up

high edge
#

LivingEntity#getEquipment returns a nullable component, when exactly would this be null, since I presume an entity will always have an inventory

dense drift
#

Probably because some entities simply cant hold items, such as Bees

high edge
#

Oh yea that makes sense

#

Thanks

broken elbow
warm steppe
#

your'e*

broken elbow
somber gale
#

Does anyone have a good example to parse expressions in a String?

I would like to make a plugin that allows to define conditions like {playerVersion} > {proxyVersion} to then evaluate and see if it's valid.

Right now would I like to have the following conditions supported:

  • x < y - Check if X is less than Y
  • x <= y - Check if X is less than or equal to Y
  • x > y - Check if X is larger than Y
  • x >= y - Check if X is larger than or equal to Y
  • x = y - Check if X is equal to Y (Should also allow string comparison)
  • x != y - Check if X is not equal to Y (Should also allow string comparison)

Currently have this mess of a setup right now: https://paste.helpch.at/ipoqitolul.java

stuck hearth
#

x.toInt() < y.toInt()

loud sorrel
#

can someone send me a good tut for changing blocks with packets? i cant find a solution online

viral moth
#

@loud sorrel what exactly do you want to do

#

the is a method on the player to send a packet to change a bunch of blocks

loud sorrel
#

i want to change one block for the player w nms

viral moth
#

don't use nms

dense drift
#

You could throw an exception if type is null/invalid @somber gale
Edit: nvm, I see you have a check in there

loud sorrel
#

i want to only do it for specific people tho

viral moth
#

either use the method on the player to change it on the client or use protocol lib

loud sorrel
#

how would i do it w packets tho

viral moth
#

idk the method name but its like player#changeBlockOnClient(Location, BlockData), the method name is wrong and I can't check it but it takes in a location and block data

#

and it will send the packet

loud sorrel
#

actually, i changed it a bit. how would i edit the furnace contents w packets instead

viral moth
#

you can probably get the block data from a furnace and send it to the player, I'm not 100% sure on how you'd do exactly what you want

wintry grove
#

pretty much lmao

#

let me check for it

viral moth
#

I haven't used it much so I don't remember the name

wintry grove
#

yeah let me check

#

d;spigot Player#sendBlockChange

uneven lanternBOT
#
void sendBlockChange(@NotNull Location loc, @NotNull BlockData block)```
Description:

Send a block change. This fakes a block change packet for a user at a certain location. This will not actually change the world in any way.

Parameters:

loc - The location of the changed block
block - The new block

wintry grove
#

there ya go

solemn ocean
#

Im trying to make a class instance based on a string like this: Class<?> cls = Class.forName(args[0]); Mineral mineral = (Mineral) cls.newInstance(); MiningManager.spawnMineral(mineral); but the thing is that when I create new instance I cant pass the parameters of the constructor, any idea?

broken elbow
dense drift
#

d;jdk Class#getConstructor

uneven lanternBOT
#
public Constructor<T> getConstructor(Class... parameterTypes)
throws SecurityException, NoSuchMethodException```
Description:

Returns a Constructor object that reflects the specified public constructor of the class represented by this Class object. The parameterTypes parameter is an array of Class objects that identify the constructor's formal parameter types, in declared order. If this Class object represents an inner class declared in a non-static context, the formal parameter types include the explicit enclosing instance as the first parameter.

The constructor to reflect is the public constructor of the class represented by this Class object whose formal parameter types match those specified by parameterTypes.

Since:

1.1

Parameters:

parameterTypes - the parameter array

Throws:

SecurityException - If a security manager, s, is present and the caller's class loader is not the same as or an ancestor of the class loader for the current class and invocation of s.checkPackageAccess() denies access to the package of this class.
NoSuchMethodException - if a matching method is not found.

Returns:

the Constructor object of the public constructor that matches the specified parameterTypes

broken elbow
#

there we go. I forgot what the command was

dense drift
#

d;jdk constructor#instance

uneven lanternBOT
#
public T newInstance(Object... initargs)
throws InstantiationException, InvocationTargetException, IllegalAccessException, IllegalArgumentException, ExceptionInInitializerError```
Description:

Uses the constructor represented by this Constructor object to create and initialize a new instance of the constructor's declaring class, with the specified initialization parameters. Individual parameters are automatically unwrapped to match primitive formal parameters, and both primitive and reference parameters are subject to method invocation conversions as necessary.

If the number of formal parameters required by the underlying constructor is 0, the supplied initargs array may be of length 0 or null.

If the constructor's declaring class is an inner class in a non-static context, the first argument to the constructor needs to be the enclosing instance; see section 15.9.3 of The Java Language Specification.

If the required access and argument checks succeed and the instantiation will proceed, the constructor's declaring class is initialized if it has...

This description has been shortened as it was too long.

Parameters:

initargs - array of objects to be passed as arguments to the constructor call; values of primitive types are wrapped in a wrapper object of the appropriate type (e.g. a float in a Float)

Throws:

InstantiationException - if the class that declares the underlying constructor represents an abstract class.
InvocationTargetException - if the underlying constructor throws an exception.
IllegalAccessException - if this Constructor object is enforcing Java language access control and the underlying constructor is inaccessible.
IllegalArgumentException - if the number of actual and formal parameters differ; if an unwrapping conversion for primitive arguments fails; or if, after possible unwrapping, a parameter value cannot be converted to the corresponding formal parameter type by a method invocation conversion; if this constructor pertains to an enum class.
ExceptionInInitializerError - if the initialization provoked by this method fails.

Returns:

a new object created by calling the constructor this object represents

dense drift
#

Get the constructor and then pass your arguments to Constructor#newInstance

solemn ocean
#

mmm ok

#

i try thanks

#

Like this? Class<?> cls = Class.forName(args[0]); Constructor<?> constructor = cls.getConstructors()[0]; Mineral mineral = (Mineral) constructor.newInstance(player.getLocation(),MineralType.MINERAL, true); MiningManager.spawnMineral(mineral);

dense drift
#

No

solemn ocean
#

damn

dense drift
#

cls.getConstructor(Location.claas, MineralType.class, Boolean.class)

solemn ocean
#

wait is it static?

#

or you mean cls..getConstructor(Location.claas, MineralType.class, Boolean.class)

dense drift
#

cls*

solemn ocean
#

but the whole thing is ok right?

dense drift
#

More or less

solemn ocean
#

i mean if i switch that

#

hopefully

merry knoll
#

net.minecraft.network.chat.TextComponent is apparent now gone in 1.19, does anyone know what the new alternative is?

lyric gyro
#

Component.literal(String)

#

@merry knoll

merry knoll
dark garnet
viral moth
#

either your server does a lot of reading from the disk/loading data/cpu intensive calculations and that number is accurate, or whatever is computing the mspt is averaging like say the mspt of 100 ticks, if it doesnt have the data from 100 ticks it could give an incorrect result, it is most likely the first option tho as it is hard to miscalculate mspt

dark garnet
#

when i do /papi reload it goes back down tho

viral moth
#

what plugin calculates mspt

#

i can check it if it is on github

dark garnet
restive crypt
#

Hi

#

I have a question

neat pierBOT
#

There is no time to wait! Ask your question @restive crypt!

restive crypt
#

It happens that I am wanting to put in the BelowName the placeholder of the Tag of the "DeluxeTags" plugin but it does not work for me, it does not appear or anything like that, do the placeholders not work for this place or what?

viral moth
viral moth
#

when you reload it, it flushes all its cache and it has to first go and read all the jar expansion files from disk then it has to actually load that code which can take a little bit of time which gives a large mspt

dark garnet
viral moth
#

im not saying its your code im guessing its papi since it completely reloads itself

dark garnet
viral moth
#

wait

#

so its bad until you reload papi and then it fixes itself?

#

are you sure mspt is being reported correctly?

viral moth
dark garnet
#

if the mspt was that high im 99% sure that the tps wouldve gone down too

viral moth
#

yeah so it is most likely calculated wrong, i dont have experience with papi but is your own code calculating it or is it something else?

dark garnet
# dark garnet no

i didnt write the mspt thing btw, someone else wrote it and i just made my fork to change other things

viral moth
#

can you show me where it is being calculated

gloomy geode
#

what you said was correct

viral moth
# dark garnet i think its here

personally i dont like how it is written, thats just my opinion tho its hard to follow. id suggest check tabtps first to verify your numbers and if you want i can make a way to track mspt if yours isnt working

dark garnet
dark garnet
viral moth
#

are you using tabtps?

dark garnet
#

essentials

viral moth
#

ok

#

im assuming those numbers dont match yours

viral moth
dark garnet
pure crater
#

I'm not really sure if this is the way to do it lol. Basically I coded a program which basically hosts an API server that accept requests and respond with a JSON. The only issue is keeping it alive. Currently, I use an infinite loop: https://github.com/MinecraftMediaLibrary/youtube-dl-rest-server/blob/2988c396b73f3af9becfa5eea5a4d108c1d7cc93/src/main/java/io/github/pulsebeat02/RestServer.java#L16

Is that the proper way to keep it alive? The thing is that if I don't add the while loop, the program just ends and the server won't be there.

#

And it works lol

viral moth
#

i havent tested it but in theory it should work

#

hopefully it us simple enough to use lol

somber gale
#

I've also altered my aproach... Not sure if this is better...

lyric gyro
lyric gyro
pure crater
#

Oo I see

icy shadow
#

your welcome

dark garnet
#

altho it doesnt contain the different timings like the old method (1m, 5m, 10m), but it doesnt matter since i didnt use em

dark garnet
# dark garnet looks like this works, ty!

one thing i noticed is that when papi is reloaded (and i assume also when server starts), for the very slightest second (not noticeable unless ur literally watching the mspt as it reloads) it shows a huge number like 92688686942E, i just fixed this by adding a check if the mspt goes above 1,000,000 it'll just show 0

somber gale
#

In the ProxyPingEvent, do I need to set the protocol too, if I change the Protocol name using Protocol#setName(String)?
And if I have to, would setting it to something like -1 work, or what should I set it to?

somber gale
#

Another question: Can I obtain the player name from said ProxyPingEvent? Or would I need to do some tricky workarounds (i.e. do requests to the Mojang API or whatever)?

dense drift
#

getConnection#getName ?

#

d;bungee PendingConnection#getName

uneven lanternBOT
proud pebble
#

shapeless recipes with stack support just dont work

#

the only logic step would be to sort the ingredients list by amount

viral moth
viral moth
#

ima use it for myself as well so give me ideas lol

#

I legit created the code and left bc I had to go to practice, never tested it so that explains the issue(s)

dark garnet
viral moth
#

i don't use papi I just work with the bukkit api

#

you'd have to create your own implementation of that

#

however I think that's fairly simple

dark garnet
#

like 1m, 5m, 10m

viral moth
#

oh yeah I got you

#

also the issue of it being a huge is number easy to fix I just thought of it

viral moth
dark garnet
#

look at my fork to see what i did

viral moth
#

also use the lastest version of the class, its on github

#

idk if you pushed your code or not tho

dark garnet
#

i did

viral moth
#

unless its a new link which i doubt

dark garnet
proud pebble
#

i got shapeless recipes to work

dark garnet
#

i meant for the color

#

i added color to ur old one

viral moth
dark garnet
#

nvm

viral moth
#

my code just gives numbers lol

#

its all contained in one class, just a drag n drop

dark garnet
#

yeye i remembered now

dark garnet
#

@viral moth its not changing:

viral moth
#

push the version of the code youre using

#

hold up, ik the issue

dark garnet
viral moth
#

ok try using my new one

#

i switched it to now actually exclude 0s and it will now affect the front of the array rather than the end so it will tract the latest second rather than the second that happened 10mins ago

viral moth
#

i have an idea

#

let me actually test my code

dark garnet
#

wait i think its something to do with my color thing

#

cause its only happening with color

viral moth
#

a low mspt is good and shouldnt be red lol

dark garnet
viral moth
#

sometimes, which i will check now

dark garnet
#

after i reload papi it shows the big numbers

#

but then goes back to normal

#

if needed i can push my code

viral moth
dark garnet
viral moth
#

no like i did debugging

#

basically the first element in the array was always > one billion

dark garnet
#

lol

viral moth
#

bc that is the current epoc, and it got changed at the end of the tick to actually be the difference in ticks rather than the time it started

#

so now i just ignore the first one

dark garnet
#

o ok

#

still happening for me @viral moth

viral moth
dark garnet
#

o

#

yea i already had that (intellij told me to add it)

#

also u left in debug msg on line 55

viral moth
#

oops

#

lol

#

fixed although i assume you deleted it yourself

#

whats the current issue

dark garnet
#

same as before

#

with big numbers

viral moth
#

ss it

viral moth
#

push your code to github

#

sorry for the issues btw

dark garnet
#

done

viral moth
#

in the for loop can you add this System.out.println(mspt); under this line if (mspt == 0) continue;

#

and ss the console when it does a big number

#

actually

#

that might crash your server if you calling anything bigger than a few seconds

#

im not having that problem, youre calling the one second one right

viral moth
#

so it happens at the start... hmm

#

like when you first reload it right?

#

or am i mistaken

dark garnet
#

like just the first 1-2 seconds i think

#

yea first 2 seconds

viral moth
#

try what i added

#

its not the best but it should fix all issues, if the tick took longer than 1mil ms, skip it

dark garnet
#

except only on the 2nd second

viral moth
#

so just like 5.438578429375832475

#

?

dark garnet
#

basically yea

#

or 2.77777777777777

viral moth
#

ok cool

#

yeah i was gonna actually warn you about that

#

easy fix tho

dark garnet
#

isnt there a decimal formatter

viral moth
#

yep

#

new DecimalFormat("0.00").format(mspt);

dark garnet
#

yee

viral moth
#

is it all good now?

#

also i switches some stuff to use nanoseconds instead so it will give a result in ms but will track the timings more accurately

dark garnet
viral moth
#

new DecimalFormat("0.00").format(mspt).substring(0, 3);

#

prob a better way to do it

#

but that should delete the extra decimals at the end

dark garnet
#

oh i thought u were gonna add it my b

#

ill add to my code

viral moth
#

and ye the /1m was for the nano seconds to convert the result to ms lol

viral moth
#

use that instead

#

bc for the other onw you would lose decimal points if its is over 10mspt

dark garnet
#

'BigDecimal.setScale()' called without a rounding mode argument

#

its no longer changing lol

#

its just frozen

viral moth
#

shiii i forgot

#

setScale(2, RoundingMode.FLOOR))

#

my b

#

that method should be deprecated/removed imo and should require people to use setScale(num, RoundingMode.NONE)

dark garnet
#

looks like that worked

#

no big numbers

viral moth
#

formatting go brr

dark garnet
#

tsym for ur help sam!!

viral moth
#

np

main cloud
solemn ocean
#

Guys does this throws an error if the string args[0] isnt found as value in EnumClass? Im still a bit confused on if they throw errors even on comparations if(EnumClass.valueOf(args[0]) != null) because it says Condition 'PlantType.valueOf(args[0]) != null' is always 'true' so means if the value doesnt exist it doesnt return null?

pulsar ferry
#

valueOf doesn't return null, it throws exception if it doesn't exist

dense drift
#

d;jdk Enum#valueOf

uneven lanternBOT
#
public static T valueOf(Class enumClass, String name)
throws NullPointerException, IllegalArgumentException```
Description:

Returns the enum constant of the specified enum class with the specified name. The name must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)

Note that for a particular enum class T, the implicitly declared public static T valueOf(String) method on that enum may be used instead of this method to map from a name to the corresponding enum constant. All the constants of an enum class can be obtained by calling the implicit public static T[] values() method of that class.

Since:

1.5

Parameters:

enumClass - the Class object of the enum class from which to return a constant
name - the name of the constant to return

Throws:

NullPointerException - if enumClass or name is null
IllegalArgumentException - if the specified enum class has no constant with the specified name, or the specified class object does not represent an enum class

Returns:

the enum constant of the specified enum class with the specified name

shell moon
#

If i had a level system in which each level has his own format, would it be better to:

  1. "parse" the format, which means add the colors (per char) or whatever the format is, every time the placeholder is required
  2. parse all placeholders and save it in a map and get it from there when placeholder is required
    what do you think?
    (parsing the placeholder means setting the colors in each char as &a1&d0&b0 as multiple colors is an option)
viral moth
shell moon
#

different? well 1 is plain color which is "&a"+ level or "&a" replaced in format which can be modified by owner like "{LEVEL}{SYMBOL}"

#

and the other can be many colors which are added every character like &a9&b9&d9 and also replaced in format "{LEVEL}{SYMBOL}"

atomic trail
#

How do I get a player's keybind for dropping items?

viral moth
#

if make something like {LEVEL[a,5,00ffff,b,d]}

#

the [] represent the color format

untold plinth
viral moth
#

so id separate that and just go from there for a lot of customization

shell moon
#

what? xD

#

the question is should i preload formatted or doing live on placeholder required

viral moth
#

oh

#

preload

viral moth
atomic trail
#

It is possible

viral moth
#

really? i didnt know

#

let me know what you did lol

untold plinth
viral moth
untold plinth
#

Eclispe OpenJdk 18

viral moth
#

cool

#

want me to clean it up for you?

untold plinth
#

Sure

viral moth
#

use the new switch cases lol

#

kk gimmie a sec

untold plinth
#

What new switch cases?

viral moth
#

uses lambdas

dense drift
#

d;adventure KeyBindComponent$Builder#keybind

uneven lanternBOT
#
@@NotNull @@Contract("_ -> this")
KeybindComponent.Builder keybind(@NotNull @NotNull String keybind)```
Description:

Sets the keybind.

Since:

4.0.0

Parameters:

keybind - the keybind

Returns:

this builder

viral moth
# untold plinth What new switch cases?
        switch (args[0].toLowerCase()) {
            case "creative", "survival", "adventure", "spectator" -> sender.sendMessage(colorize("&b&lTL &b&l &4You need to pick a player."));
            default -> sender.sendMessage(colorize("&b&lTL &b&l &4You need to pick a gamemode."));
        }
        sender.sendMessage(colorize("&b&lTL &b&o: &4/gamemode [creative,survival,adventure,spectator] [player]"));```


```java
                        if (args[0].equalsIgnoreCase("creative")) {
                            p.setGameMode(GameMode.CREATIVE);
                            p.sendMessage(colorize("&b&lTL &b&o: &aYou've set your gamemode to &e&o" + p.getGameMode() + "&a."));
                        } else if (args[0].equalsIgnoreCase("survival")) {
                            p.setGameMode(GameMode.SURVIVAL);
                            p.sendMessage(colorize("&b&lTL &b&o: &aYou've set your gamemode to &e&o" + p.getGameMode() + "&a."));
                        } else if (args[0].equalsIgnoreCase("adventure")) {
                            p.setGameMode(GameMode.ADVENTURE);
                            p.sendMessage(colorize("&b&lTL &b&o: &aYou've set your gamemode to &e&o" + p.getGameMode() + "&a."));
                        } else if (args[0].equalsIgnoreCase("spectator")) {
                            p.setGameMode(GameMode.SPECTATOR);
                            p.sendMessage(colorize("&b&lTL &b&o: &aYou've set your gamemode to &e&o" + p.getGameMode() + "&a."));
                        } else {
                            p.sendMessage(colorize("&b&lTL &b&l &4You need to pick a gamemode."));
                            p.sendMessage(colorize("&b&lTL &b&o: &4/gamemode [creative,survival,adventure,spectator] [player]"));
                        }```

does the same thing
sterile hinge
viral moth
#

->

#

lambda reference

sterile hinge
#

that's an arrow

#

still nothing to do with lambdas

viral moth
#

yk

#

you right

#

my b

untold plinth
viral moth
#

you need to switch your project's jdk version, let me check rq what version it is

untold plinth
#

for this line java case "creative", "survival", "adventure", "spectator" -> sender.sendMessage(colorize("&b&lTL &b&l &4You need to pick a player."));

viral moth
#

also im changing other stuff lol, got bored so i figured i clean it up

dense drift
#

14 I believe

viral moth
#

yes its 14

#

i wanted to be sure

dense drift
#

Iij tells you some info about each version

viral moth
#

would post a ss but no perms lol

untold plinth
#

Ok it works now

#

14

dense drift
#

Fyi, make sure you use a higher or equal version for your server

viral moth
#

1.18+ requires java 17

#

im assuming youre on a newish server version

viral moth
untold plinth
#

gonna test it rn

viral moth
#

if you need me to explain what i changed i can

#

mainly i removed duplicated code and used switches over if else statements

neat pierBOT
#
📋 Your paste: Sam.
https://paste.helpch.at/sohevezoko

A member of staff has requested I move your message to a paste,
Most likely because it contains a config/error/code snippet.

viral moth
#

how do i make code colored on the paste website

#

nvm

#

im slow

untold plinth
#

SO sam

#

/gamemode works with it telling me the gamemode

#

but /gamemode creative just returns that I need to specify a player

viral moth
#

ok let me look into it, 2 sec

#

ohhhh

#

my bad i know what i did

untold plinth
#

kk

#

also why do you have this import?

#
import java.util.Locale;```
viral moth
#

delete it

untold plinth
#

For me it just says it's useless

viral moth
#

it auto imported it

#

you can specify a Local when calling string#toLowerCase()

#

it auto specified but i deleted it

untold plinth
#

ah

#

anyway

#

now it's telling me that

#

an internal error

#

let me copy the log

#
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
    at me.darklife12345.serverplugin.commands.specialcommands.Gamemode.onCommand(Gamemode.java:42) ~[NSC-0.6.jar:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[purpur-api-1.19-R0.1-SNAPSHOT.jar:?]
    ... 17 more```
viral moth
#

i think i already know it

#

yeah

#
        if (modifySelf) player = (Player) sender;
        else {
            player = Bukkit.getPlayerExact(args[1]);
            if (player == null) {
                sender.sendMessage(colorize("&b&lTL &b&o: &4This person isn't online"));
                return false;
            }
        }``` this is the fix
#

ill just send the whole code

#

hold up

untold plinth
#

Welp

#

moment of truth

viral moth
#

im trying to write code without testing it more often so i can think of problems before they happen, currently im still failing but thats why i dont mind helping with this stuff lol

untold plinth
#

Well it works for the player who executes it ...

#

But you cannot execute it at other people

#

/gamemode creative <player> just makes you in creative

#

even if that person isn't a person or is offline

viral moth
#

lemme check it

#

im slow 💀

untold plinth
#

You're getting there

#

once slow step at a time

viral moth
#

modifySelf = args.length == 1 || (args.length == 2 && args[1].equalsIgnoreCase("self"));

#

replace modifySelf = true with that

#

wait

untold plinth
#

Well if this works then

#

50 lines of code deleted

viral moth
#

modifySelf = args.length == 1 || args[1].equalsIgnoreCase("self");

viral moth
#

lmk if it works

untold plinth
#

oops srry I got distracted

#

Yeah no it doesn't work

#

still same bug

viral moth
#

like

#

this is your code?

pure crater
#

d;spigot Gamemode

uneven lanternBOT
#
public enum GameMode
extends Enum<GameMode>```
GameMode has 4 fields, 3 all implementations, 4 methods, and  1 extensions.
Description:

Represents the various type of game modes that HumanEntitys may have

pure crater
#

d;spigot GameMode#valueOf

uneven lanternBOT
#
public static GameMode valueOf(String name)
throws IllegalArgumentException, NullPointerException```
Description:

Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:

name - the name of the enum constant to be returned.

Throws:

IllegalArgumentException - if this enum type has no constant with the specified name
NullPointerException - if the argument is null

Returns:

the enum constant with the specified name

untold plinth
#

Yeah I added that line

pure crater
#

Btw, you can just do valueOf

#

instead of a switch statement

#

take the argument, make it all caps and do valueOf

viral moth
untold plinth
#

bruh

untold plinth
pure crater
#

why did u change it

untold plinth
#

I didn't

viral moth
#

i did

pure crater
#

oh

viral moth
#

not him

untold plinth
#

he's making my code shorter

#

like 50 lines removed

viral moth
#

tbf i can shorten ir more

#

hold up

pure crater
#

colorize please dont do this

#

use an actual chat component api

untold plinth
#

I will do that for ever

#

why use an api

pure crater
#

because apis are... good?

#

lol

#

and do work for you?

#

XD

untold plinth
#

and boom

#
    public String colorize(String msg) {
        return ChatColor.translateAlternateColorCodes('&', msg);
    }```
viral moth
#

ok i switched to using valueOf, it shortened the code

#

what was the issue again tho

pure crater
viral moth
viral moth
#

i also am now using the api directly lol

untold plinth
#

now the code is WIDE

viral moth
#

the code is short tho so its fineeee

#

less than half the original length

untold plinth
#

60 lines exactly removed

#

It works now

#

ty

viral moth
#

np

#

you understand the version i maade right?

#

if you do thats great, if now i dont recommend using code you dont understand

untold plinth
#

i mean I don't know java

#

I just learned some spigot

untold plinth
viral moth
#

yeah thats what i changed but like looking at the code can you understand the logic

untold plinth
#

Yeah

atomic trail
#

Trying to get a players keybind for dropping items, this is what I have rn but it doesn't work Component.keybind("key.drop").keybind() I assume I have to specify the player somehow? This just returns key.drop atm

atomic trail
#

it is possible, just cant get it to work

#

Nvm its not possible

#

ur right

dense drift
#

Yes, you cant get it, but you can display it to them

floral beacon
#

ok so can someone tell me because i am either stupid or nowhere is written

when we use Bukkit#dispatchCommand and execute some command for some player

does that trigger some command event and which?

#

is any event ever triggered actually?

viral moth
#

most likely, logically it should, look for an event that gets triggered before firing a command and test it, best wat to figure it out lol

gloomy geode
warm steppe
#

Runtasklater

gloomy geode
#

im confused

warm steppe
#

Bukkit.getscheduler().runtasklater() iirc

gloomy geode
#

I need to add the timer option to config.yml

#

on enable

warm steppe
#

Yes

gloomy geode
#

like a value to be configured

warm steppe
#

Get time from config, convert it to ticks and viola

gloomy geode
#

I'm trying to get the time in the config

#

in a subheading of each announcement

#

to make each time configurable differently

gloomy geode
#

im being stupid

#

sorry for ping also

#

why is this giving error

warm steppe
#

;

#

In the end

#

Also u could replace it with lambda

gloomy geode
#

that makes the whole thing red

#

i did have it like that mb

gloomy geode
warm steppe
#

Bukkit.getScheduker().runTaskLater(this, () -> {}, 0, 20L);

viral moth
#
        Bukkit.getScheduler().runTaskTimer(plugin, () -> {
            //your code
        }, 0, 1);```
example
gloomy geode
#

so for timer task how would the top line look, i had it just a second ago and deleted it

#
Bukkit.getScheduler().runTaskLater(this, new TimerTask() -> {
viral moth
#

no

#

so

#

let me explain what a lambda does, ill do a simple explanation

gloomy geode
#

yeah sorry lol

#

i didnt read up on this

viral moth
#

basically, any interface that has only one method can be replaced with a lambda, an TimerTask() is an interface, so rather than you having to make a new instance and override the method, the lambda is short hand for that

gloomy geode
#

so the lambda is the timer task

#

kinda

viral moth
#

() -> [} replaces

new TimerTask() {
            @Override
            public void run() {
            }
      } ```
gloomy geode
#

ohhhh

viral moth
#

in this case yes, a lambda can take the place of any interface with one method

gloomy geode
#

oh i think what i was doing wrong was closing the parentheses at the top

viral moth
#

no

gloomy geode
#

no i meant before

#

I was definitely closing parentheses with the lambda before

#

before the bottom line

viral moth
#

ok

#

well

#

you dont call the constructor of TimerTask

gloomy geode
#

that makes sense

#

and i was trying to do it

viral moth
#
        Bukkit.getScheduler().runTaskTimer(plugin, () -> {
            System.out.println("hi");
        }, 0, 20);```
#

run that code

#

it will print out "hi" to the console one time every 20 ticks

#

so get an understanding of a basic example, and then modify it to what you need

gloomy geode
#

the task timer fixed it, i had runTaskLater

#
Bukkit.getScheduler().runTaskTimer(this, () -> {
                for(Player allplayers : Bukkit.getOnlinePlayers()){
                    gconfig.getString("Announcement1");
                    allplayers.sendMessage(A1);
                }
        }, 0, 20L);
viral moth
#

run task later is a different method

#

it only takes one number at the end, so just 20 not 0, 20

gloomy geode
#

delay and ticks it says

viral moth
#

Bukkit.getScheduler().runTaskTimer(plugin, () -> {}, how long to wait before starting the task for the first time, the time period to wait between executions of the task);

#

run task later doesnt repeat something every X amount of ticks, so it doesnt need the last arg

gloomy geode
#

I sound stupid whenver i get into this chat xD, i swear i've learned some basics

viral moth
#

is your goal to repeatedly do something over and over or just do something once at a later time

gloomy geode
#

It's repeatedly

viral moth
#

then you want runTaskTimer

gloomy geode
#

so i do use two numbers

viral moth
#

yes

#

read the descriptions of the methods

gloomy geode
#

thank you, i will read up on that

#

also can you answer the question i had before lol

viral moth
#

reply to the question so ik what youre referring to

gloomy geode
viral moth
#

have you used the config file before?

gloomy geode
#

yeah I used it in the last one to configure my discord message

#

just simple /discord

viral moth
#

want me to tell you the steps or do you want me to give you the completed code

gloomy geode
#

Wait ill send what i have

#
getLogger().info("Starting up...");
        if(!(folder.exists())){
            folder.mkdir();
            getLogger().info("Creating new directory...");
            if(!(file.exists())){
                try {
                    getLogger().info("Creating new file...");
                    file.createNewFile();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }

            } else {
                getLogger().info("Found your config.yml...");
            }
        }
        config.addDefault("Prefix","&7Soapzy's Timed Announcements | ");
        config.addDefault("Announcement1","This is an automatic broadcast that hasn't been edited.");
        config.addDefault("Announcement2","You better edit this broadcast or you a lil on the rainbow side.");
        config.addDefault("Announcement3","Change the broadcast, this is a threat.");
        config.options().copyDefaults();
        saveDefaultConfig();
        getCommand("timedannouncements").setExecutor(new TACommand());
#

so basic

#

create directory and file

#

and adding the messages

#

but i want like a subheading called timer for each announcement, 1,2,3 that they set for each one to go off in different intervals

viral moth
#

ok for one, the default config file is safe to use, bukkit makes the dir and handles all the checks

#

2, i know this doesnt seem related, but do some research on maps

#

the config and maps use key value pairs

#

they both follow that same idea

gloomy geode
#

alright thats all you need to tell me, ill look at it and hollar if i have a problem

#

I seen some stuff about maps but wasnt sure if it was right

viral moth
#

because a key has a value but you could have a key that returns a value but the value it returns can also be a key

gloomy geode
viral moth
#

learning about key-value pairs is very useful

viral moth
#

bukkit makes sure the file exists

#

if not it makes it

#

if the dir doesnt exist it makes it

#

youre doing it twice since its being done 1 time already by default

gloomy geode
viral moth
#

yes

gloomy geode
#

okay i will replace it now

#
instance=this
this.getConfig();
#

so this will work

somber gale
#

Anyone good enough with Configurate to know what I would need to do if I have this configuration setup?

conditions:
  - type: '<'
    key: 1
    value: 2
  - type: '>'
    key: 2
    value: 1

I'm fine with having to deal with a List<Map<...>> here. Just can't quite figure out what exactly I need to do to actually obtain this..

viral moth
#

youre using bukkit's configuration api?

somber gale
#

Anyone good enough with Configurate to know what I would need to do if I have this configuration setup?

#

I assume I need to use childrenList() here as that returns a List<? extends ConfigurationNode> and I could then turn it into a map...

#

Actually... Now that I think about it could I simplify this to a String list...

graceful hedge
#

ye, idk if this is to any help but by default configurate does register a map, and list type serializer

gloomy geode
#

so lemme example real quick

#
Announcement1:
      Time:
#

simple as that basically

scarlet marsh
#

is there any way i could modify the font that is used, and sent, when checking for a placeholder?

Trying to essentially insert a specific unicode, though they are mostly outside of the default font to avoid people being able to copy-paste them in chat.

so %bondrewd_guildmenu% will return a unicode from the default font tho the actual one i need is inside say guild font file.

Seeing as it returns just a basic string ill assume not but

gloomy geode
#
24.06 02:22:54 [Server] ERROR Could not load 'plugins/original-TimedAnnouncements-1.0-SNAPSHOT.jar' in folder 'plugins'
24.06 02:22:54 [Server] INFO org.bukkit.plugin.InvalidPluginException: Unsupported API version 1.19
24.06 02:22:54 [Server] INFO at org.bukkit.craftbukkit.v1_18_R2.util.CraftMagicNumbers.checkSupported(CraftMagicNumbers.java:375) ~[paper-1.18.2.jar:git-Paper-"072f54c"]
24.06 02:22:54 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:149) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
24.06 02:22:54 [Server] INFO at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:415) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
24.06 02:22:54 [Server] INFO at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:323) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
24.06 02:22:54 [Server] INFO at org.bukkit.craftbukkit.v1_18_R2.CraftServer.loadPlugins(CraftServer.java:418) ~[paper-1.18.2.jar:git-Paper-"072f54c"]
24.06 02:22:54 [Server] INFO at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:288) ~[paper-1.18.2.jar:git-Paper-"072f54c"]
24.06 02:22:54 [Server] INFO at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1164) ~[paper-1.18.2.jar:git-Paper-"072f54c"]
24.06 02:22:54 [Server] INFO at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:316) ~[paper-1.18.2.jar:git-Paper-"072f54c"]
24.06 02:22:54 [Server] INFO at java.lang.Thread.run(Thread.java:831) ~[?:?]

got this error but i have the spigot 1.18.2 dependecies

#

nvm i had the wrong version in plugin.yml lol

#

nvm again, got the same error except 1.18.2 wasn't supported on my 1.18.2 server lol

lyric gyro
#

yeah it's just 1.16, 1.17, 1.18, 1.19 etc, excluding the patch version

gloomy geode
#

my last plugin was the same thing, however, it worked

#

plugin snapshot is 1.18.2 spigot and server is 1.18.2 paper

lyric gyro
#

just type 1.18, not 1.18.2

gloomy geode
#

oh gotcha

#
api-version: 1.18
lyric gyro
#

ye

gloomy geode
#

also is paper any different than spigot coding?

#

Im just curious if I might as well just use paper or not

lyric gyro
#

it adds a ton more API, like mob goals, pathfinding, safe item/entity serialisation, lots of expansions around things like tags, particles, worldgen i think and other stuff, full JSON components support

#

it has way too many changes for me to list them all

gloomy geode
#

or just tell me if i might as well use it

#

instead of having to explain xD

lyric gyro
#

it adds on top of spigot, but it adds a lot lol, you are not losing anything by targeting paper
and the majority of people run paper anyways

stuck hearth
#

Wow that's such an amazing deal

#

🦐

winged pebble
#

You might even say it seems unbelievable

stuck hearth
#

Some might suggest it be a scam

winged pebble
#

"Too good to be true" Some say

atomic trail
#

Any good way to check if a player is already inside a GUI? Using Triumph Gui
I only want this to run if a player is not already inside the GUI

            if ((event.getClick() == ClickType.DROP || event.getClick() == ClickType.CONTROL_DROP) && reward.isAllowBulkBuy()) {
                bulkPurchaseGui.open(player, shop, reward);
                return;
            }
wise kayak
icy sonnet
sterile hinge
#

don't use that StringUtils class

icy sonnet
#

Just Utils then ?

sterile hinge
#

just use the normal replace method

icy sonnet
#

I don't know what that is, I got the code from here like 1,5 years ago

sterile hinge
#

lol

icy sonnet
#

And I haven't touched coding or anything in like 1 year cuz of school

#

So does anyone know a Fix lemme know please

stuck canopy
#

help

#

why is aikar dependency not working

fiery pollen
#

reload maven?

stuck canopy
#

I did

icy sonnet
#

Can someone help me please.

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/youfi/IdeaProjects/JoyChat/src/main/java/me/reverse/joychat/utils/HexUtil.java:[4,44] package org.apache.groovy.parser.antlr4.util does not exist
[ERROR] /C:/Users/youfi/IdeaProjects/JoyChat/src/main/java/me/reverse/joychat/utils/HexUtil.java:[28,28] cannot find symbol
  symbol:   variable StringUtils
  location: class me.reverse.joychat.utils.HexUtil
[ERROR] /C:/Users/youfi/IdeaProjects/JoyChat/src/main/java/me/reverse/joychat/utils/HexUtil.java:[48,29] cannot find symbol
  symbol:   variable StringUtils
  location: class me.reverse.joychat.utils.HexUtil
[INFO] 3 errors 
[INFO] -------------------------------------------------------------
#

this is the full error

#

HexUtil

dense drift
#

Change the StringUtil import, I believe it should be the one from apache text class

#

d;spigot StringUtils

uneven lanternBOT
#
public interface Strider
extends Vehicle, Steerable```
Strider has 2 methods, 2 extensions, and  19 super interfaces.
Description:

Represents a Strider.

icy sonnet
#

Strider ?

#

This was the old import

#

but this also doesn't worl

#

work

#

but the StringUtils isnt the same as StringUtil from bukkit

stuck canopy
#

I have the repository but it still doesnt work

warm steppe
icy sonnet
stuck canopy
#

HELP

lyric gyro
atomic trail
#

tempCost = tempCost / reward.getMultiplier();
tempCost is 10 and the multiplier is 1.001. After this runs 64 times the tempCost is still 10, can someone explain this?

lyric gyro
#

Can you show the full code?

stuck canopy
atomic trail
# lyric gyro Can you show the full code?
                            for(int i = 1; i <= amount; i++) {
                                sold+=tempCost;

                                tempCost = tempCost / reward.getMultiplier();
                                tempSellPrice = tempSellPrice / reward.getMultiplier();
                            }
                            logger.info("3: Multiplier: " + reward.getMultiplier());
                            logger.info("3: TempCost: " + tempCost + "TempSellPrice: " + tempSellPrice);
                            reward.setCost(tempCost);
                            reward.setSellPrice(tempSellPrice);
lyric gyro
stuck canopy
#

paste

#

?paste

neat pierBOT
#
FAQ Answer:

Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
HelpChat Paste - How To Use

lyric gyro
stuck canopy
lyric gyro
#

Chances are it’s being rounded up

atomic trail
lyric gyro
#

Hmm

untold plinth
#
package me.darklife12345.psp;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerJoinEvent;

import java.util.HashMap;
import java.util.Map;

public class OnPlayerJoin implements Listener {
    Map<String, Long> cooldown = new HashMap<>();

    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent e) {
        Player p = e.getPlayer();
        if (p.hasPlayedBefore()) {
            Bukkit.broadcastMessage(p.getName() + " has joined again");
        } else {
            Bukkit.broadcastMessage(p.getName() + " hsa joined for the first time.");
            cooldown.put(p.getName(), System.currentTimeMillis() / 1000 + 900);
        }

    }
    @EventHandler
    public void onPlayerDamage(EntityDamageByEntityEvent e) {

        Player p = (Player) e.getEntity();
        Player d = (Player) e.getDamager();

        if (cooldown.containsKey(p.getName())) {
                if (cooldown.get(p.getName()) > System.currentTimeMillis()) {

                    long timeleft = (cooldown.get(p.getName()) - System.currentTimeMillis())/1000;

                    d.sendMessage(ChatColor.RED + "This person is protected from damage for " + ChatColor.YELLOW + timeleft + ChatColor.RED + " minutes.");
                    e.setCancelled(true);
                }
        }

    }

}```
#

so I have this code

#

and I wonder why

#

It won't cancel damage

shell moon
#

@untold plinth

untold plinth
#

hm

shell moon
#

do you really believe that a number divided by 1000 can be greater than the number itself?

untold plinth
#

hm

#

cooldown.put(p.getName(), System.currentTimeMillis() / 1000 + 900); ?

shell moon
#

cooldown.put(p.getName(), System.currentTimeMillis() / 1000 + 900);
means
cooldown.put(p.getName(), 1,000,000 / 1000 + 900); = 1000 + 900 = 1900
when checking
if (cooldown.get(p.getName()) > System.currentTimeMillis()) {
it means
if (1900 > 1,000,000) {

#

that will probably, at least in this universe, never be true

untold plinth
#

I am not good a math ok

shell moon
#

you dont need to be good at math to know that 1 thousend is less than 1 million

untold plinth
#

you explained it weird

shell moon
#

kinda

#

but you are the one comparing them

untold plinth
#

so uh

shell moon
#

replace

cooldown.put(p.getName(), System.currentTimeMillis() / 1000 + 900);
with
cooldown.put(p.getName(), System.currentTimeMillis() + 900);

untold plinth
#

kk

shell moon
#

will won't work as desired as you'll only have 0.9 seconds of invulnerability

untold plinth
#

I need 15 minutes of it

shell moon
#

then add that time in milliseconds

#

15 * 60 * 1000

untold plinth
#

cooldown.put(p.getName(), System.currentTimeMillis() + 15 * 60 * 1000);?

shell moon
#

yes and no

#

yes, should work

#

no, well, try to use ( ) to make sure

#

even when multiplications are done first

#

use ( ) to dont confuse your self

untold plinth
#

cooldown.put(p.getName(), System.currentTimeMillis() + (15 * 60 * 1000));

shell moon
untold plinth
#

ok gonna test it out 1 more time

shell moon
#

Suggestion, use UUID, instead of names

#

but that's optional (i would do it)

untold plinth
#

What's the benefit

fiery pollen
#

names can change, uuid's can't

shell moon
#

as mentioned, its a suggestion, not benefits at all as you are not saving data

#

so shouldn't affect at all

#

but its always recommended to use uuids

fiery pollen
#

oh hes not saving data

shell moon
#

indeed, he isn't

untold plinth
#

i mean I kinda am for

#

15 minutes

shell moon
#

he's using the hasPlayedBefore

#

no, thats not storing data

#

prob in cache

#

but still not saving data

#

you are using minecraft data instead, which already should track connections

#

so uuid should be the same, even if you change names, hasPlayedBefore should return false

#

however, you'll lose the invulnerability if you reconnect with a different name

untold plinth
#

who's gonna do that

shell moon
#

no one

#

thats the thing

fiery pollen
#

it is possible (if someone actually wants too), so its just better to work with uuid's

untold plinth
#

Also what's the file in servers that store player data so I can clear it and make sure it tells me I joined for the first time?

fiery pollen
#

then you are sure that it can't happen

shell moon
#

yeah, but changing will not give them invulnerability again

#

so is not a real issue

fiery pollen
#

oh yeah true

stuck canopy
#

how to use aikar repository..........

#

acf-paper doesnt work ah

untold plinth
shell moon
#

ofc, that's what you did there

shell moon
#

left milliseconds time / 1000

#

is seconds

#

if you want 14m 20s

#

you'll have too google and find a method for that

untold plinth
#

10000

shell moon
#

10000 what?

lyric gyro
untold plinth
#

Divide by 10000?

shell moon
#

??

lyric gyro
#

words dont need description
a picture is worth more than a thousand words

shell moon
#

bruh what is your actual question?

fiery pollen
#

lmao

lyric gyro
untold plinth
#

Wut you talking about ; - ;

#
    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent e) {
        Player p = e.getPlayer();
        if (p.hasPlayedBefore()) {
            Bukkit.broadcastMessage(p.getName() + " has joined again");
        } else {
            Bukkit.broadcastMessage(p.getName() + " hsa joined for the first time.");
            cooldown.put(p.getName(), System.currentTimeMillis()  + (15 * 60 * 1000));
        }

    }```
#

did you skip the whole chat where math was explained to me

shell moon
#

900 is not 1 milliseconds

#

thats 900 milliseconds or 0.9 seconds

#

wouldnt work either, but its not 1 millisecond

untold plinth
#

it works now

lyric gyro
#

I suppose you want to make players have a certain spawn protection

so you first in on player join put cooldown.put(p.getName(), System.currentTimeMillis()); (keep everything in miliseconds for sanity)

and then in damage event, you want to calculate the timeleft by this:
long timeLeftInSeconds = (cooldown.get(p.getName())-System.currentTimeMillis())/1000;

and the check:
if(timeLeftInSeconds > 420){
event.setCancelled(true);
}

#

ok duh

untold plinth
#

I already have the working code

lyric gyro
#

ok

lyric gyro
#

?

untold plinth
#
package me.darklife12345.psp;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerJoinEvent;

import java.util.HashMap;
import java.util.Map;

public class OnPlayerJoin implements Listener {
    Map<String, Long> cooldown = new HashMap<>();

    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent e) {
        Player p = e.getPlayer();
        if (p.hasPlayedBefore()) {
            Bukkit.broadcastMessage(p.getName() + " has joined again");
        } else {
            Bukkit.broadcastMessage(p.getName() + " hsa joined for the first time.");
            cooldown.put(p.getName(), System.currentTimeMillis()  + (15 * 60 * 1000));
        }

    }
    @EventHandler
    public void onPlayerDamage(EntityDamageByEntityEvent e) {

        Player p = (Player) e.getEntity();
        Player d = (Player) e.getDamager();

        if (cooldown.containsKey(p.getName())) {
                if (cooldown.get(p.getName()) > System.currentTimeMillis()) {

                    long timeleft = (cooldown.get(p.getName()) - System.currentTimeMillis())/1000;

                    d.sendMessage(ChatColor.RED + "This person is protected from damage for " + ChatColor.YELLOW + timeleft / 60 + ChatColor.RED + " minutes.");
                    e.setCancelled(true);
                }
        }

    }

}
fiery pollen
#

bro why are you posting your whole class every time

#

just put what you changed or something

shell moon
#

cuz deleted user is telling him his code doesnt work

untold plinth
shell moon
#

but we know it does xd

untold plinth
#

and he's tryna explain something that is invalid

lyric gyro
#

dont get me wrong thats just cute

shell moon
#

i dont get whast your point here

untold plinth
#

he's mad at me

shell moon
#

everyone did that with its first plugins lmao

#

even i did when i first started lmao

untold plinth
#

because he posted something like "do you get it now" earlier and I said no

lyric gyro
#

not really

#

i think thats cute

#

and you should keep doing it
but with a limit

lyric gyro
#

and personally i spammed clip for my first plugin code

untold plinth
#

that's not even my first plugin ; - ;

#

I'm just stupid

shell moon
#

you're trying to make someone fell bad

#

anyone who read you message can see that lol

lyric gyro
#

ok im sorry

shell moon
#

anyways, Dark, feel free to ask if any question

untold plinth
#

ok

lyric gyro
#

but your pfp makes people's day worse by making them break NNN

untold plinth
lyric gyro
#

wat dat

untold plinth
#

discorsd

lyric gyro
#

oh alr that makes sense

untold plinth
#

settings

#

it hides pfps

lyric gyro
untold plinth
shell moon
#

you can't

#

with your current code

#

you have to "heavily" modify it

#

and save a bukkit task instead (prob)

untold plinth
#

; -;

shell moon
#

your code is simple, thats what it does

#

but what you just asked for is a bit more complex (for starters)

#

as it requires to modify his code (a lot)

untold plinth
#

it's my code though

shell moon
#

ik

untold plinth
#

his code

shell moon
#

you need to make a runnable/task