#help-development

1 messages ยท Page 1565 of 1

shut field
#

use getSlot()

#

I did this:

#

yet it is saying that list[0] is out of bounds?

unreal quartz
#

i don't know what i'm looking at

#

an arraylist is initialized with no elements

shut field
#

my bad

unreal quartz
#

you don't need to set the capacity

#

an arraylist automatically resizes

grave kite
shut field
unreal quartz
#

because there are no elements in it

shut field
#

I can send you the error in a txt file if you need it

unreal quartz
#

you can't get the first element out of an empty list

umbral pagoda
#

hi ihave proplem i'm created skypvp plugin with lootchest but when i spawn lootchests after opening 5 lootchests plugin stop respawn more loot

shut field
unreal quartz
#

so you need to add them first

shut field
#

(integer gets incremented every rep)

unreal quartz
#

just add

umbral pagoda
#

so can anyone help me ๐Ÿ™‚

unreal quartz
dusk yarrow
#

How can I turn a name (for example "maxthier") into something like this: ("--------"), "conminelp" would then be for example "---------". So the number of characters in the name in the form of "-".

umbral pagoda
unreal quartz
umbral pagoda
#

@unreal quartz can you help me with the code ?

unreal quartz
#

well there is no code to help with

umbral pagoda
#

how ican

#

send it

unreal quartz
#

?paet

umbral pagoda
#

to you ?

unreal quartz
#

?paste

undone axleBOT
umbral pagoda
#

@unreal quartz can i send it dm to you ?

unreal quartz
#

send it here

quaint mantle
#

@quaint mantle wanna take ownership of my server

#

you're a great guy

#

i'm sure nothing would happen to it

#

โ˜ ๏ธ

shut field
quaint mantle
#

wait wrong channel

#

i apologise

unreal quartz
shut field
#

I been working at this for like a week and it finally workin'

unreal quartz
#

set(int, obj) sets it at that index, which of course will throw an exception since you cant set something at a specific index in an empty array

wild inlet
#

What's the easiest persistent tick counter I can access via API

#

That I wouldn't need to worry about overflows

umbral pagoda
#

@unreal quartz

grave kite
#

is there a way to simplify that?

unreal quartz
wild inlet
umbral pagoda
#

@unreal quartz see it

wild inlet
#

Also, where would I get that count

unreal quartz
#

then that is incredibly tragic

wild inlet
#

Is it stored anywhere?

unreal quartz
#

i have no idea if the server tracks it

#

you might have to do it yourself

wild inlet
#

I really hope it does ๐Ÿ˜ฆ

grave kite
wild inlet
umbral pagoda
#

@unreal quartz you speak to me or another person ?

unreal quartz
#

you haven't sent anything

grave kite
umbral pagoda
#

@unreal quartz see it antd tell me

unreal quartz
#

well your code is a complete mess and hard to follow on

unreal quartz
#

what exactly is the problem

umbral pagoda
#

stop respawn

#

again

#

when i collect the loot 5 times

#

it stop

#

respawn another loot

unreal quartz
#

well what you've sent is completely unrelated

wild inlet
umbral pagoda
unreal quartz
#

well i dont know. its your project. but the code here (appears) to spawn 1 loot box depending on the command and spins some armor stand around every 5 ticks (on an async thread - which you shouldn't do)

wild inlet
wild inlet
#

Every day seems like their API becomes a lot better than base spigot

#

Sad scenes

umbral pagoda
#

@unreal quartz iwill send another code ok ?

unreal quartz
#

completely unacceptable api

umbral pagoda
#

@unreal quartz ok ?

wild inlet
#

So I think it's their fault

#

But still, good enough for me haha

unreal quartz
#

smh mojang

#

if there is anything i can suggest @umbral pagoda

#

?learnjava

undone axleBOT
unreal quartz
#

this is borderline unmaintainable

#

to put it politely

#

i would suggest you first put your loot box spawning code into a single method

#

maybe in doing that you will also spot the error

tardy delta
#

why do i get this?

#

I have this as tabcomplete

#

arguments and result are just empty arraylists

wild inlet
#

are his links being remove for me?

wild inlet
#

oh god

#

The switches

#

the ifs

unreal quartz
#

which means its state is the same between tabcompletions

#

so at some point you've added them all to result

wild inlet
#

@umbral pagoda if you ever repeat yourself more than once in code. Ask yourself if you could do it another way.

If you repeat yourself more than five times, do it another way

tardy delta
#

pff

#

I've deleted the previous tabcomplete so cant look back

sharp bough
unreal quartz
#

bukkit has a method StringUtil.copyPartialMatches which essentially does what you want

tardy delta
#

got it from a tutorialllll

sharp bough
#

iv never really tried to make autocomplete

#

cuz i thought i was really complex

#

no way hahaha

tardy delta
#

oh anyway

sharp bough
urban lava
#

ok i set up the basics of the command

package io.github.Epicmania.healerPlugin;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

public class CommandHeal implements CommandExecutor{
    // This method is called, when somebody uses our command
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        
        return false;
    }

}

#

what now

#

how do i make it so taht the player can be distinguished for events and stuff

unreal quartz
#

i have no idea what you mean by that

quaint mantle
#

How do I run it after a while and not when the server turns on

#

help

urban lava
unreal quartz
unreal quartz
quaint mantle
quaint mantle
quaint mantle
#

which would you recommend me?

unreal quartz
#

the one i just linked

quaint mantle
#

I would like the event to occur every 8 hours, but not start when the server is on.

unreal quartz
#

then schedule it to run every 8 hours using one of the methods i sent

quaint mantle
#

i made this

#

but only once occurs

unreal quartz
#

that will run it once every 30 seconds

#

taskTimer is what uwant

wild inlet
#

Could anyone help with this issue?

#

Want to make sure it's not my fault.

unreal quartz
#

never used specialsource

quaint mantle
#

It works every 30 seconds, but it starts when the server is turned on.

unreal quartz
#

the third argument is the delay

quaint mantle
rich topaz
#

Anyone knows a performant way to send many Particles in 1.16+ ?

quaint mantle
#

It starts after 30 seconds, but after the first message, it runs every 1 second.

lusty cipher
#

yeah

#

30 * 20L for the second as well, no?

#

both are in ticks iirc

urban lava
#

wait in my command how do i return something to the chat

unreal quartz
#

sender.sendMessage?

quaint mantle
#

thanks @unreal quartz @lusty cipher

urban lava
dense pulsar
#

hey im trying to teleport a player somewhere immediatly after respawn

#

I can't get it to work though

slim magnet
#

is InventoryCloseEvent called before or after the inventory is closed

unreal quartz
#

change their respawn location

#

and after

dense pulsar
#

how can I change respawn location

unreal quartz
#

in the respawn event

dense pulsar
#

I saw a set bedspawn

slim magnet
# unreal quartz and after

How do I check if the inventorycloseevent was called because of another inventory was opened instead of the player clicking esc

dense pulsar
#

oh neat, thanks!

unreal quartz
#

you cant

slim magnet
#

why not :(

unreal quartz
#

if you really need to know you can wait a tick and see if there is a non crafting inventory opened

#

but in order to open a new inventory, you close the old one

slim magnet
#

like I mean will it be consistent always

unreal quartz
#

it's more of a hack than a solution

rich topaz
urban lava
#

wait when i sender.sendMessage is the message red by default

#

or do i have to do something to make it that way

unreal quartz
#

no

left falcon
#

Does Bukkit.getOnlinePlayers() return the leaving player when the PlayerQuitEvent gets handled?

chrome beacon
#

Probably how so?

#

I mean you can always try and see if it does

eternal oxide
#

The death event doesn't, so best not to assume the quit will

urban lava
chrome beacon
#

I thought events were supposed to be ran before things happened

#

But yeah I can see why

eternal oxide
#

not the death event. The player is dead at that point

chrome beacon
#

Aight

slim magnet
unreal quartz
unreal quartz
urban lava
unreal quartz
#

ChatColor.RED + "......"

left falcon
#
sender.sendMessage(ChatColor.RED + "The syntax of this command is /help add/remove [player]");
eternal oxide
urban lava
#

thanks

shadow gazelle
#

Is there an event for a player firing an arrow?

left falcon
#

ProjectileLaunchEvent

#

It does apply to other mobs and projectiles too

chrome beacon
#

Yeah

shy wolf
#

how to get and chest in world?

quaint mantle
#

LM

shy wolf
#

like


   world.getwhat?
quaint mantle
#

How do I make a task to run only once?

chrome beacon
#

Then use Location#getBlock (iirc)

quaint mantle
#

@unreal quartz Is this the best way to finish an event in 1 minute?

#
        BukkitScheduler scheduler = getServer().getScheduler();
        scheduler.scheduleSyncDelayedTask(this, new Runnable() {
            @Override
            public void run() {
                // Do something
            }
        }, 20L);
    }```
rich topaz
#

60 * 20L

dense pulsar
#

is there a way to turn off the safe teleport where it will not teleport you inside of blocks

shy wolf
#

how to set items in chast?

sharp bough
#

and add items to it

undone axleBOT
urban lava
#

what does it mean if the resource is out of sync with the plugin.yml file

chrome beacon
#

It means you have two different copies of the file. One saved and one in cache

urban lava
#

how do i fix that

#

wait i fixed it

#

paper cant load my jar

chrome beacon
#

What's the error

urban lava
chrome beacon
#

Well does that class exist

urban lava
#

do i need that class

#

my pain calss is called

#

HealerPluginMain

chrome beacon
#

NMS ||or use Paper||

chrome beacon
torn shuttle
#

oh no I'm stuck in some serious decision paralysis

urban lava
#

ohhhhhhhh

torn shuttle
#

and also literally stuck because my back hurts

dense pulsar
#

I have a command teleporting a player to a Location underground that i mine out to be a 1x2, just enough for the player to sit in it

chrome beacon
#

?spoon

undone axleBOT
#

Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.

dense pulsar
#

however, when I teleport the player to that block they get automatically teleported ontop of the world

#

is there a way to perfectly teleport a player to the middle of a block

quaint mantle
#

make the values end in 0.5

#

x and z

chrome beacon
#

Not the problem

dense pulsar
#

that might do it

quaint mantle
#

im talking abt the middle of block thing

#

im not sure about the top of world thing

urban lava
#

wait how do i send a msg to the terminal

#

isnt it like getlogger smth

dense pulsar
#

it only should teleport ontop of the world if the player is in the block

quaint mantle
#

console.getlogger?

dense pulsar
#

i'll see if it works

chrome beacon
#

Yeah I'm not sure why it would teleport you up

quaint mantle
#

plugin.getLogger().info("text");

chrome beacon
#

I'm pretty sure it shouldn't do that

quaint mantle
dense pulsar
#

Its the respawn point that likes to teleport up. The actual player.teleport does not do that

chrome beacon
#

Ah

quaint mantle
#

theres multiple u can do

#

like .error or something makes it red

urban lava
quaint mantle
#

that one will send with ur plugin tag

#

Bukkit.getServer().getConsoleSender().sendMessage("STRING");

#

this one will just send a straight message to it

urban lava
#

yeah i want tfor plugin tag

dense pulsar
#

ahhhhhh finally that worked, thanks @quaint mantle

urban lava
#

its for onEnable and disable

urban lava
#

wait should plugin be my plugin name

quaint mantle
#

yes

chrome beacon
quaint mantle
#

what will show up in /pl, console

#

basically what spigot will id your plugin as

#

when theres errors, etc

chrome beacon
#

Not what he's asking

quaint mantle
#

ohh

#

wait

chrome beacon
#

He's asking about the variable

quaint mantle
#

no

#

plugin is ur main class

#

in plugin.yml

mystic tartan
#

Is there a way to change a player's nametag without changing their name in tab complete and such

quaint mantle
#

teams

#

scoreboard teams

#

wait

#

no thats for prefixes and suffixes

#

im not sure about completly changing the name

urban lava
#

is the main class the package

#

or the class with the onenable and disable classes

quaint mantle
#

its the class that extends JavaPlugin

quaint mantle
urban lava
#

ahhhhh

#

ok

#

so in plugin yml it should jsut be the name of that class

chrome beacon
quaint mantle
#

i usually like to make a static function in it that returns itself

#

so no hassle to get an instance of it from somewhere else

mystic tartan
#

I'm changing the name field in their gameprofile and it works, but this changes the tab complete stuff

urban lava
#

so if the main calss is HealerPluginMain.java

#

in the plugin yml it shoul dbe

quaint mantle
#

ur package directory

#

to it

#

yes

urban lava
#

main: HealerPluginMain

quaint mantle
#

no

chrome beacon
#

And package

quaint mantle
#

ur package directory

#

then

#

.HealerPluginMain

urban lava
#

ok

quaint mantle
#

so

#

dev.crqpts.healerplugin.HealerPluginMain

#

for example

urban lava
#

ok thanks

quaint mantle
#

if u ever got problems with something

#

should always try google it

#

like whenever i forget whats needed in the plugin yml

#

i search up

#

"plugin YAML"

#

comes up with a page on the bukkit forums or something

#

and it shows each entry detailed description

dense pulsar
#

googling is an underrated skill

quaint mantle
#

yeah

#

always try to keep key words only

#

because if u add like

#

"the, how"

#

its gonna find pages that include those words

#

which are very common words

urban lava
#

ok

quaint mantle
#

so you will get highly unrelated stuff

urban lava
#

ill keep that in mind

quaint mantle
#
BukkitWiki

When Bukkit loads a plugin, it needs to know some basic information about it. It reads this information from a YAML file, 'plugin.yml'. This file consists of a set of attributes, each defined on a new line and with no indentation.

A command block starts with the command's name, and then has a list of attributes.

A permission block starts wit...

#

this is what i mean

waxen plaza
#

Is there anything special I should do to my plugin.yml before I post it on spigot mc?

dense pulsar
#

author: @waxen plaza

waxen plaza
#

and I use my spigot name?

dense pulsar
#

whatever name you generally go by

quaint mantle
#

maybe a description too if u like

waxen plaza
#

ok

chrome beacon
#

Eh do what you want I mean there's nothing special needed

fluid cypress
#

for 1.17 plugins, is it still necessary to use jdk 8? or do we have to use 16?

chrome beacon
#

You can use 16 since server uses 16

fluid cypress
#

ok thx

quaint mantle
#

why cant there just be an easy way to get tps

#

honestly

urban lava
#
package io.github.Epicmania.healerPlugin;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

public class CommandHealer implements CommandExecutor{
    // This method is called, when somebody uses our command
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (args[0] != "add" || args[0] != "remove" ) {
            sender.sendMessage(ChatColor.RED + "The syntax of this command is /healer add/remove [player]");
        }
        else if (args.length==0) {
            sender.sendMessage(ChatColor.RED + "The syntax of this command is /healer add/remove [player]");
        }
        else if (args[0] == "add") {
            if (Bukkit.getPlayer(args[1]) == null) {
                sender.sendMessage(ChatColor.RED + "Enter a valid username");
            }
        }
        else if (args[0] == "remove") {
            if (Bukkit.getPlayer(args[1]) == null) {
                sender.sendMessage(ChatColor.RED + "Enter a valid username");
            }
        }
            
        return false;
    }

}
#

oops

#

meant to click shift

#

this code should make if they dont enter the right args for the command it tells them what is wrong

quaint mantle
#

also

urban lava
#

for example if they enter /healer it should say the syntax of the command

#

but it doesnt work

quaint mantle
#

instead of doing a check for the second argument being null twice

#

just do it before the add and remove check

urban lava
#

yeah i was gonna do that

#

but im lazy

#

ill do it later probably

tame coral
#

You need to return true; when the syntax is correct or else the command will always send a error message

quaint mantle
#

^

urban lava
#

ah ok

#

so i should take out the return false at the bottom and add it in the inocrrect if instances

#

and return true in the correct instances

quaint mantle
#

no

#

keep it

urban lava
#

oh

#

that way if it doesnt hit any ifs

#

it still returns false

tame coral
#

Exactly

quaint mantle
#

theres no erorr in the incorrect if instances

#

its just a misinput

urban lava
quaint mantle
#

yes

#

the return will just stop anything past it

urban lava
#

that makes sense thanks

#

ok i changed it to this

package io.github.Epicmania.healerPlugin;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

public class CommandHealer implements CommandExecutor{
    // This method is called, when somebody uses our command
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (args[0] != "add" || args[0] != "remove" ) {
            sender.sendMessage(ChatColor.RED + "The syntax of this command is /healer add/remove [player]");
            return true;
        }
        else if (args.length==0) {
            sender.sendMessage(ChatColor.RED + "The syntax of this command is /healer add/remove [player]");
            return true;
        }
        else if (args[0] == "add") {
            if (Bukkit.getPlayer(args[1]) == null) {
                sender.sendMessage(ChatColor.RED + "Enter a valid username");
                
            }
            return true;
        }
        else if (args[0] == "remove") {
            if (Bukkit.getPlayer(args[1]) == null) {
                sender.sendMessage(ChatColor.RED + "Enter a valid username");
            }
            return true;
        }
            
        return false;
    }

}

but it still shows an error if there are no arguements, and if i type the command any way else it says "The syntax of this command is /healer add/remove [player]".

quaint mantle
#

check if args length is 0 first

#

because if args[0] is null

#

u will get a nullptr

#

on the first if

#

because theres nothing to check

hasty prawn
#

I think it's IndexOutOfBoundsException, not nullptr but yeah that's what you need to do

urban lava
#

ok thanks

quaint mantle
#

i dont think it is

urban lava
#

also will doing /reload confirm update my plugin

quaint mantle
#

because theres nothing in the list anywyas

urban lava
#

if the new jar is there

quaint mantle
#

yes

#

can cause some errors tho

hasty prawn
#

Yeah it is, accessing args[0] when the list size is 0 throws IndexOutOfBounds

quaint mantle
#

its just a faster server restart

#

ah ok

hasty prawn
#

I mean your solution is right either way, just a technicality lol

quaint mantle
#

i usually havent had any problems with reloading

urban lava
#

ok thanks

#

it works now

hasty prawn
#

Yeah reloading for development purposes is fine usually

#

Just don't do it on the production server if you have one

quaint mantle
#

shouldnt do it on the main server though

#

yep

urban lava
#

the next issue is that it shouldnt show anything if I type in /healer add Epicmxnia but it still says the syntax msg

chrome beacon
#

Don't return false

quaint mantle
#

yeah honestly u shouldnt be returning false unless ur dealing with stuff that can throw errors

#

and even then just use a throw catch

quaint mantle
hasty prawn
#

It still says Syntax error because of the first line

if (args[0] != "add" || args[0] != "remove" ) {

args[0] is "add", it isn't "remove", so that if statement is true

urban lava
#
package io.github.Epicmania.healerPlugin;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

public class CommandHealer implements CommandExecutor{
    // This method is called, when somebody uses our command
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        
        if (args.length==0) {
            sender.sendMessage(ChatColor.RED + "The syntax of this command is /healer add/remove [player]");
            return true;
        }
        else if (args[0] != "add" || args[0] != "remove" ) {
            sender.sendMessage(ChatColor.RED + "The syntax of this command is /healer add/remove [player]");
            return true;
        }
        else if (args[0] == "add") {
            if (Bukkit.getPlayer(args[1]) == null) {
                sender.sendMessage(ChatColor.RED + "Enter a valid username");
                
            }
            return true;
        }
        else if (args[0] == "remove") {
            if (Bukkit.getPlayer(args[1]) == null) {
                sender.sendMessage(ChatColor.RED + "Enter a valid username");
            }
            return true;
        }
            
        return false;
    }

}
#

ty btw for helping me out all of you guys

quaint mantle
#

oh right yeah dessie is right

#

use an &&

hasty prawn
#

Just change || to &&

tardy delta
#

GRr still didnt solve my tabcomplete problem

quaint mantle
#

because even if it isnt "add"

#

and its "remove"

#

will still return false

hasty prawn
#

Yeah that ALWAYS catches ๐Ÿ˜†

urban lava
#

wait is && or?

quaint mantle
#

npo

hasty prawn
#

&& is and

quaint mantle
#

its and

hasty prawn
#

|| is or

quaint mantle
#

|| is or

urban lava
#

ohhh

#

cuz then it will always trigger

quaint mantle
#

i mean

urban lava
#

im stupid

hasty prawn
#

Crqpts we're on the same page for every message i stg

quaint mantle
#

& is the and symbol lol

quaint mantle
urban lava
#

yeah ik

#

i jsut wanted to makes ure

quaint mantle
#

do u want help with the next part or are you ok?

quaint mantle
urban lava
#

um it still shows the syntax for anything i put

quaint mantle
#

ive heard of that before but im not bothered to install it

chrome beacon
#

Hotswapping is the best way

quaint mantle
#

because its just the 1 plugin

quaint mantle
chrome beacon
#

Hotswap and reload is the way to go

quaint mantle
#

Hotswapping has been more trouble for me than just making a new jar

#

show the code again

chrome beacon
urban lava
#
package io.github.Epicmania.healerPlugin;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

public class CommandHealer implements CommandExecutor{
    // This method is called, when somebody uses our command
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        
        if (args.length==0) {
            sender.sendMessage(ChatColor.RED + "The syntax of this command is /healer add/remove [player]");
            return true;
        }
        else if (args[0] != "add" && args[0] != "remove" ) {
            sender.sendMessage(ChatColor.RED + "The syntax of this command is /healer add/remove [player]");
            return true;
        }
        else if (args[0] == "add") {
            if (Bukkit.getPlayer(args[1]) == null) {
                sender.sendMessage(ChatColor.RED + "Enter a valid username");
                
            }
            return true;
        }
        else if (args[0] == "remove") {
            if (Bukkit.getPlayer(args[1]) == null) {
                sender.sendMessage(ChatColor.RED + "Enter a valid username");
            }
            return true;
        }
            
        return false;
    }

}
chrome beacon
#

Sadly Java 11

quaint mantle
eternal night
#

string comparison using == ๐Ÿ˜ฑ

quaint mantle
#

cringe

#

i forgot

#

use .equals

urban lava
#

so like

quaint mantle
#

equalsIgnoreCase

hasty prawn
#

Surprised the compiler didn't yell for that one tbh

quaint mantle
#

i think it is

urban lava
#

args[0].equalsIgnoreCase("add")

chrome beacon
#

How much Java do you know?

quaint mantle
#

ys

urban lava
#

idr how far i got

chrome beacon
#

Because things like these aren't really spigot only

urban lava
#

yeah

quaint mantle
#

i started spigot same time as java

urban lava
#

sorry ๐Ÿคทโ€โ™‚๏ธ

quaint mantle
#

pretty stupid of me

hasty prawn
#

Same

quaint mantle
#

but ive used c++ before so i got the hang of it pretty quickly

hasty prawn
#

Honestly doing them at the same time gave me something to practice with atleast

#

Cause I had plugin ideas

quaint mantle
#

even now i want to make plugins but idk what to do

tardy delta
quaint mantle
#

yeah we just covered that

urban lava
quaint mantle
#

wait

#

im gonna fix up ur code a little bit

#

clean it up

urban lava
#

thanks lol

quaint mantle
#
package io.github.Epicmania.healerPlugin;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

public class CommandHealer implements CommandExecutor{
    // This method is called, when somebody uses our command
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        
        if (args.length==0) {
            sender.sendMessage(ChatColor.RED + "The syntax of this command is /healer add/remove [player]");
            return true;
        }
        else if (args[0] == "add") {
            if (Bukkit.getPlayer(args[1]) == null) {
                sender.sendMessage(ChatColor.RED + "Enter a valid username");
                
            }
            return true;
        }
        else if (args[0] == "remove") {
            if (Bukkit.getPlayer(args[1]) == null) {
                sender.sendMessage(ChatColor.RED + "Enter a valid username");
            }
            return true;
        }
        sender.sendMessage(ChatColor.RED + "The syntax of this command is /healer add/remove [player]");
        return true;
    }

}
#

i just removed the != part

#

because ur already checking if theyre equal to it

#

so if none of the if statements are true

#

send the syntax message

urban lava
#

cool

#

that makes sense

quaint mantle
#

also

urban lava
#

ty

chrome beacon
#

Use switch statements instead of spamming else if

quaint mantle
#

instead of using chatcolor.red and stuff

#

i make a utils class

#

or just use main class

#

static function

#

translate

#

ChatColor.translatebyalternatecolorcodes

#

or something

#

i forgot

#

and use the "&" symbol

urban lava
#

im stupid remember

quaint mantle
#

&c for red, &4 for dark red

#

nah everyone starts somewhere

#
public static String translate(String text){
  return ChatColor.translateAlternateColorCodes('&', text);
}
#

u can put this in ur main class

#

and do

#

MainClassName.translate("&cSyntax blablabla")

#

and it will return the translated text

lyric grove
#

Hi, i use this to send a item to all online players, but it doesn't send it to all the players

urban lava
#

im sorry im still confused

quaint mantle
#

give me a second

#

this is the chart u can use

#

basically

#

if u want a bold light red message

#

that says "Hello there!"

#

use &c and &l

#

its a bit complicated

#

so u can just use ChatColor.RED + ChatColor.BOLD + "message"

#

etc

quaint mantle
#

return stops the entire function

#

u dont need to do anything

urban lava
#

so woudl i just add &c to the start of the string

quaint mantle
#

it will just iterate on its own

urban lava
#

im confused on where i'd add it

#

where did ur pfp go

lyric grove
#

oh should i just remove the return?

quaint mantle
#

basically just shortening down what u just used

#

i removed it

#

because cringe

quaint mantle
#

no need to have it

quaint mantle
urban lava
#

also this is still happening, when the elif shows that args[0] is add or remove, it should either show nothing or the "enter a valid usename" thing, but instead it says "The syntax of this command is /healer add/remove [player]"

quaint mantle
#

send the entire thing again

waxen plaza
#

Can I add colors to description with color codes?

urban lava
#

wait im adding the stuff you said

quaint mantle
#

alright

#

can u change ur name

#

this is my old name

#

has a q in it

#

pretty cringe

lyric grove
hasty prawn
#

You have to donate to change your Spigot username I think

quaint mantle
quaint mantle
lyric grove
#

oh ok

hasty prawn
#

Try it and see if it works

urban lava
#
package io.github.Epicmania.healerPlugin;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

public class CommandHealer implements CommandExecutor{
    // This method is called, when somebody uses our command
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        
        if (args.length==0) {
            sender.sendMessage("&cThe syntax of this command is /healer add/remove [player]");
            return true;
        }
        else if (args[0] == "add") {
            if (Bukkit.getPlayer(args[1]) == null) {
                sender.sendMessage("&cEnter a valid username");
                
            }
            return true;
        }
        else if (args[0] == "remove") {
            if (Bukkit.getPlayer(args[1]) == null) {
                sender.sendMessage("&cEnter a valid username");
            }
            return true;
        }
        sender.sendMessage("&cThe syntax of this command is /healer add/remove [player]");
        return true;
    }

}
quaint mantle
quaint mantle
#

wait

#

so

#

epic

#

do like

#

/healer add Epicmxnia

#

and tell me what it says

#

Hello someone know how i do in SQLibrary package

in MySQL

SELECT * FROM table WHERE uuid = player uuid
and then it will do
player.sendMessage(data)
i dont know how
someone can help me?

#

like pvp stats or something

tardy delta
#

My tabcomplete still doesnt work..

@Override
    protected @Nullable List<String> tabComplete(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args) {


        if (arguments.isEmpty()) {
            arguments.add("help");
            arguments.add("accept");
            arguments.add("request");
            arguments.add("decline");
        }
        if (args.length == 1) {
            for (String a : arguments) {
                if (a.toLowerCase().startsWith(args[0].toLowerCase()))
                    result.add(a);
            }
            return result;
        }
        return null;
    }
tardy delta
#
protected List<String> arguments = new ArrayList<>(); // tabComplete
    protected List<String> result = new ArrayList<>(); // tabComplete
#

yes

#

lemme show

quaint mantle
#

How would i rename a inventory title (Dropper) without reopening it or causing it to flicker from 1.13+?

urban lava
#

@quaint mantle

tardy delta
#

for some reason result isn't updated or something

quaint mantle
#

u forgot to add the function

urban lava
#

i didnt do it right i think

quaint mantle
#
public String translate(String text){
  return ChatColor.translateAlternateColorCodes('&', text);
}
urban lava
#

i put in the other .java file

quaint mantle
#

put this somewhere in ur class

chrome beacon
quaint mantle
#

i removed the static

#

and then do

urban lava
#

should it be in this .java file

quaint mantle
#

translate("&ctext")

#

yes

quaint mantle
quaint mantle
chrome beacon
hasty prawn
quaint mantle
#

ik you can do String result =

#

but it give me error that i cant call it with String

urban lava
#

now its just

chrome beacon
quaint mantle
#

okay

solemn valley
#

Is there any way to stop falling block despawning without NMS? I'm having it as a passenger on an armorstand and would only use NMS if there's no other way

quaint mantle
#

try do

#

try to mix up the messages

#
public class CommandHealer implements CommandExecutor{
    // This method is called, when somebody uses our command
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        
        if (args.length==0) {
            sender.sendMessage("&cThe syntax of this command is /healer add/remove [player] (no args)");
            return true;
        }
        else if (args[0] == "add") {
            if (Bukkit.getPlayer(args[1]) == null) {
                sender.sendMessage("&cEnter a valid username");
                
            }
            return true;
        }
        else if (args[0] == "remove") {
            if (Bukkit.getPlayer(args[1]) == null) {
                sender.sendMessage("&cEnter a valid username");
            }
            return true;
        }
        else {
          sender.sendMessage("&cThe syntax of this command is /healer add/remove [player]");
        }
        return true;
    }

}
#

i added (no args) to the first one

solemn valley
quaint mantle
#

just to see whats happening

waxen plaza
#

By default, the Java language level is set to 5 which is not supported by the current Java version. Update the language level to 6+.Update source level in PrivateVaults
Why does this appear? I have my language level set to 16

urban lava
#

kk

waxen plaza
hasty prawn
#

File -> Project Structure, send an SS of that

urban lava
#

ok so the no args one only triggers when there are no args
it always triggers the other one otherwise

waxen plaza
solemn valley
#

As I have heard you can detect it taking damage

#

and cancelling the event

hasty prawn
# waxen plaza

Check your Module SDK version too, and if you're using Gradle/Maven, check those.

waxen plaza
#

all 16

hasty prawn
#

๐Ÿค” try restarting and/or invalidating caches

waxen plaza
#

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project PrivateVaults: Fatal error compiling Now I get this error

hasty prawn
#

Yeah try restarting

quaint mantle
#
public class CommandHealer implements CommandExecutor{
    // This method is called, when somebody uses our command
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        
        if (args.length==0) {
            sender.sendMessage(translate("&cThe syntax of this command is /healer add/remove [player] (no args)"));
        }
        else if (args[0] == "add") {
            if (Bukkit.getPlayer(args[1]) == null) {
                sender.sendMessage(translate("&cEnter a valid username"));
            } else {
                sender.sendMessage("found player");
            }
        }
        else if (args[0] == "remove") {
            if (Bukkit.getPlayer(args[1]) == null) {
                sender.sendMessage(translate("&cEnter a valid username"));
            } else {
                sender.sendMessage("found player");
            }
        }
        else {
          sender.sendMessage(translate("&cThe syntax of this command is /healer add/remove [player]"));
        }
        return true;
    }

}
#

try this

#

see what happens

solemn valley
#

?

#

oh wasn't for mee

urban lava
#

he is talking to me

#

lol

tardy delta
hasty prawn
tardy delta
hasty prawn
#

You have to put the arguments in

#

Put the return after the add() calls to arguments

waxen plaza
#

It works now ๐Ÿ˜„

urban lava
#

@quaint mantle still has same results as before

#

im so confused on what is wrong

hasty prawn
#

Epic make sure you're actually uploading the JAR before reloading

quaint mantle
#

i swear to god

#

if that is why

tardy delta
#

aah

#

so arguments = array

hasty prawn
#

Yeah, you had the arguments right the first time. Still add all your options to it

quaint mantle
hasty prawn
#

if (arguments.isEmpty()) {
            arguments.add("help");
            arguments.add("accept");
            arguments.add("request");
            arguments.add("decline");
        }
return StringUtil.copyPartialMatches(args[0], arguments, new ArrayList<>());
quaint mantle
#

wait

#

the code i was sending u was using == for string comparison

#
public class CommandHealer implements CommandExecutor{
    // This method is called, when somebody uses our command
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        
        if (args.length==0) {
            sender.sendMessage(translate("&cThe syntax of this command is /healer add/remove [player] (no args)"));
        }
        else if (args[0].equalsIgnoreCase("add")) {
            if (Bukkit.getPlayer(args[1]) == null) {
                sender.sendMessage(translate("&cEnter a valid username"));
            } else {
                sender.sendMessage("found player");
            }
        }
        else if (args[0].equalsIgnoreCase("remove")) {
            if (Bukkit.getPlayer(args[1]) == null) {
                sender.sendMessage(translate("&cEnter a valid username"));
            } else {
                sender.sendMessage("found player");
            }
        }
        else {
          sender.sendMessage(translate("&cThe syntax of this command is /healer add/remove [player]"));
        }
        return true;
    }

}
#

try this

urban lava
quaint mantle
#

copy the whole thng

tardy delta
urban lava
#

ok

hasty prawn
#

It's negligible either way

urban lava
#

lets go

solemn valley
urban lava
#

waht else was there

quaint mantle
#

moral of the lesson

urban lava
#

oh the elseeeeee

quaint mantle
#

equalsignorecase

urban lava
#

at the bottom

quaint mantle
#

yes i added that

#

i thought uwas copying the whole thing

#

shouldve mentioned it

#

mybadd

urban lava
#

that was what fixed it i think

#

its fine

quaint mantle
#

u need help with the next part

#

or we alg?

urban lava
#

wait i need to set smth up if there is no input for args[1]

#

i can do that on my own i think tho

quaint mantle
#

okay

#

u know how to cast?

urban lava
#

also imma go get up for like 5 minutes

#

cuz i haven't moved in 3 hours

tardy delta
#

still the same

quaint mantle
#

nvm u wont need to cast

tardy delta
#

with this

@Override
    protected @Nullable List<String> tabComplete(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args) {

        if (arguments.isEmpty()) {
            arguments.add("help");
            arguments.add("accept");
            arguments.add("request");
            arguments.add("decline");
        }
        return StringUtil.copyPartialMatches(args[0], arguments, result);
torn shuttle
#

I've got an annoying question

    private MoonPhaseDetector.MoonPhase processMoonPhase(String path, MoonPhaseDetector.MoonPhase pluginDefault) {
        if (!configHas(path))
            return pluginDefault;
        try {
            return MoonPhaseDetector.MoonPhase.valueOf(fileConfiguration.getString(path));
        } catch (Exception ex) {
            new WarningMessage("Custom event file " + filename + " has an incorrect moon phase entry for " + path);
        }
        return pluginDefault;
    }

this is how i am currently parsing enums from config but the really annoying thing is I need one method per enum which feels really inefficient, is there a way to use the pluginDefault value in the constructor to infer the enum type and then get to the #valueOf method so I can return any enum type via casting instead?

hasty prawn
hasty prawn
tardy delta
#

why cant we access mc debug mode smh

quaint mantle
#

if u need help ask other people

urban lava
#

ty for all ur help

hasty prawn
urban lava
#

its like 4 pm for me lol

hasty prawn
#

And calling the method something else I assume as well

quaint mantle
#

goodbye

torn shuttle
tardy delta
hasty prawn
#

I'm not really sure what you're trying to do I guess

hasty prawn
torn shuttle
#

I want a generic processor that returns Object which I can cast into a specific enum and the enum it returns and tries to find is based on what I put on the constructor

#

unless there's an even better way of doing it which is possible

#
private Object processEnum(String path, Object enumDefault){
... same internal logic ...
}

sort of like that

#

I'm not sure it would be possible at all since java wouldn't necessarily know what the object is? that's why I ask

hasty prawn
#

Yeah you're not even gonna know what to cast it to without already doing what you're doing pretty much

solemn valley
torn shuttle
#

feels like there's some enum functionalities missing for this to work

hasty prawn
somber hull
#

yea, i figured it out. thanks

torn shuttle
#

damn it do I really have to add one new method per enum I process

#

this sucks

hasty prawn
#

Do you have to use enums?

torn shuttle
#

yeah

hasty prawn
#

Yeah, guess you'll just have to do it like that then :/

#

I can't really think of a better way

solemn valley
hasty prawn
#

Set it to 1 then

solemn valley
#

So that or -1 won't work

solemn valley
hasty prawn
#

Just set it to 1 every few seconds

solemn valley
#

Ah yup

#

That works

torn shuttle
#

man sucks to suck I guess

#

here I go processing enums again

waxen plaza
#

java: package com.privatevaults.commands does not exist I suddenly get this error... wth is going on

#

my own package doesn't exist?

hasty prawn
#

Is IntelliJ saying that or the server

waxen plaza
#

intellij

hasty prawn
#

Interesting... restart again I suppose?

waxen plaza
#

already did multiple times

#

sometimes it compiles but most of the time I get this error

urban lava
#

Bukkit.getPlayer isnt working, whenever the name is anypart of my username in order(my username is Epicmxnia so e or ep shows up as a name)

#
            if (Bukkit.getPlayer(args[1]) == null) {
                sender.sendMessage(translate("&cEnter a valid username"));
                
            } else {
                sender.sendMessage("found player");
                sender.sendMessage(args[1]);
            }
waxen plaza
#

I got it to work, I think

unreal quartz
#

use getPlayerExact if you don't want it to make an attempted match

urban lava
autumn ingot
#

is there any way to detect if a player is pressing their spacebar (jumping) when they're on a vehicle? e.g. let's say they're riding a chicken, how do you detect when they jump, since the initial and final y-locations wont change?

unreal quartz
#

nope

#

client does not send jumps like that

urban lava
#

so what do i do then

#

if getplayer and getplayer exact dont work

unreal quartz
#

well getplayerexact should work

#

either bukkit is broken / the documentation has been wrong for years, or you forgot to compile your plugin or something

urban lava
#

maybe my overall code is wrong

#

@unreal quartz this is the code

package io.github.Epicmania.healerPlugin;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

public class CommandHealer implements CommandExecutor{
    public String translate(String text){
          return ChatColor.translateAlternateColorCodes('&', text);
        }
    // This method is called, when somebody uses our command
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        
        if (args.length==0) {
            sender.sendMessage(translate("&cThe syntax of this command is /healer add/remove [player]"));
        }
        else if (args.length==1 && (args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("remove"))) {
            sender.sendMessage(translate("&cAdd the username of the player that should be added/removed as a healer"));
        }
        else if (args[0].equalsIgnoreCase("add")) {
            if (Bukkit.getPlayerExact(args[1]) == null) {
                sender.sendMessage(translate("&cEnter a valid username"));
            } else {
                sender.sendMessage("found player");
                sender.sendMessage(args[1]);
            }
        }
        else if (args[0].equalsIgnoreCase("remove")) {
            if (Bukkit.getPlayerExact(args[1]) == null) {
                sender.sendMessage(translate("&cEnter a valid username"));
            } else {
                sender.sendMessage("found player");
                sender.sendMessage(args[1]);
            }
        }
        else {
          sender.sendMessage(translate("&cThe syntax of this command is /healer add/remove [player]"));
        }
        return true;
    }
#

it shoudl only say that found player when the arg is the name of a player online on the server

autumn ingot
#

i thought if manually listening for the spacebar but since thatโ€™s not possible this is the next best option

ivory sleet
urban lava
#

if i put in the first letter of my ign

#

it says it found a player

chrome beacon
#

Yeah that's how it works

urban lava
#

wait

#

one sec

#

i think i just had a compiling issue

#

ok now i need to work out

#

if i add someone to the healer list

#

how do i like save their name

granite stirrup
#

Lmao a capital E char code is 69 ๐Ÿคฃ

unreal quartz
#

didn;t we go over this

unreal quartz
granite stirrup
#

Ima go fix my brainfuck interpreter cuz for some reason it's printing wrong characters or doing wrong things xd

merry kindle
#

hey i was wondering why my database isn't connecting?

#

it says no suitable driver found

#

but it worked on my old project

granite stirrup
#

You have no driver

subtle kite
#

how do you call if a player uses a command

granite stirrup
merry kindle
granite stirrup
#

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

subtle kite
# granite stirrup ?jd

Is there a way to not make more then 1 class.

I'm trying to do like if
example
player.getcommand.("hi")
player.sendmessage("hello")

merry kindle
#

why?

#

making multiple classes is a lot better

granite stirrup
#

Sorry if want to listen to commands it needs to be a in a separate class

merry kindle
#

thats false you can do it in one class

subtle kite
#

annoying lowkey but ok

merry kindle
#

but its more custom to do in multiple classes

granite stirrup
#

Oh wait

#

Listener is a interface I forgot

dusty sphinx
#

in BungeeCord, is there a way to not send a player to a server during login? I have logic PostLogin that chooses a server to send them to

subtle kite
#

@dusty sphinx on join event
make the player run a command (join server)

#

?

dusty sphinx
#

no that wont do

#

hmm

subtle kite
#

idk

granite stirrup
#

I don't think it's possible

#

Bungeecoord chooses what server to send you to

#

Also I don't think you can send players to servers in post login

#

You need to do it when they are in the server

somber hull
#

this doesnt seem to be running..

#
new BukkitRunnable() {
            public void run() {
                if (!(plugin.activeEvents.containsKey(plr))){
                    return;
                }
                TNTPrimed tnt = (TNTPrimed) plr.getLocation().getWorld().spawnEntity(plr.getLocation(), EntityType.PRIMED_TNT);
                tnt.setFuseTicks(2 * 20);
            }
        }.runTaskTimer(plugin,0,5 * 20);
#

No errors

#

It just dont summon the tnt

#

i can try to send message to the player

buoyant viper
#
public static <T extends Enum> T process(String path, T def) {
        /* code to get to the path, idk */
        String eName = path; // the value / name of the enum
        T eValue = (T) Enum.valueOf(def.getClass(), eName);


        return eValue != null ? eValue : def;
    }```
#

im on my phone so no thorough testing but it passed rextester.com so

torn shuttle
#

oh shit

#

alright I'll give it a shot in a minute, I'm currently wrangling a different frankenstein's monster

quaint mantle
#

Hello someone know how in
SQLibrary
in MySQL
you can replace '?' to string arg?
like
player_uuid or something

#
query("SELECT * FROM PVP_stats WHERE uuid = ?")
unreal quartz
#

use that in a prepared statement

#

you can set each ? there

buoyant viper
#

ill be happy to be of aide if u need

quaint mantle
unreal quartz
#

Connection#prepareStatment(query)

timid kraken
#

how do i get my current project version in code?

buoyant viper
#

trying to set it during jar compilation im guessing?

timid kraken
#

making a custom auto updater

#

so i wanna know my current version

buoyant viper
#

u could hardcode it in? idk

unreal quartz
buoyant viper
#

or that

timid kraken
torn shuttle
hybrid spoke
buoyant viper
#

i also forgot that version is even specified in plugin.yml, or rather forgot about that file as a whole

tulip pike
#

Hey, I got the new 1.17.1 spigot
When I try to make a project on that version it won't show it

#

Can someone help me with it?

torn shuttle
#

somehow I am now stuck making a system that makes arbitrary amounts of configuration folders, creates arbitrary amounts of configuration defaults and reads arbitrary amounts of configuration files

#

also parses those files into something that can be safely used by plugins

#

how did I even get here

dense pulsar
#

how would you guys go about a cooldown on placing a paticular block

torn shuttle
#

just one block or for several blocks

dense pulsar
#

maybe a permission on a block place event tied to a scheduled bucket command that gives and takes it?

torn shuttle
#

god no

dense pulsar
#

just for one block, tnt in my case

torn shuttle
#

does it need to persist through restarts

dense pulsar
#

nah

#

all in memory

torn shuttle
#

hashmap<UUID, long> where long is the next valid unix time and uuid is player uuid

dense pulsar
#

and the on block place event checks it?

torn shuttle
#

yeah

dense pulsar
#

sounds good

#

thanks

somber hull
#
    public void start(Player plr) {
        plugin.activeEvents.put(plr, this);
        plr.sendMessage("Hi1");
        new BukkitRunnable() {
            public void run() {
                if (!(plugin.activeEvents.containsKey(plr))){
                    return;
                }
                plr.sendMessage("Hi");
                TNTPrimed tnt = (TNTPrimed) plr.getLocation().getWorld().spawnEntity(plr.getLocation(), EntityType.PRIMED_TNT);
                tnt.setFuseTicks(2 * 20);
            }
        }.runTaskTimer(plugin,0,5 * 20);

        plugin.activeEvents.remove(plr);
    }
#

I get the Hi1 message

#

but not the Hi message

hasty prawn
hasty prawn
#

And you're probably not getting hi because plugin.activeEvents doesn't contain Player in it's keys so it's returning

somber hull
#

ok, yea it is canceling

#

why tho...

#

it is being put, then checked if there

hasty prawn
#
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
  if (!(plugin.activeEvents.containsKey(plr))){
    return;
  }
  plr.sendMessage("Hi");
  TNTPrimed tnt = (TNTPrimed) plr.getLocation().getWorld().spawnEntity(plr.getLocation(), EntityType.PRIMED_TNT);
  tnt.setFuseTicks(2 * 20);
}, 0, 5 * 20);
#

It's probably not there then

#

You tell it to return if it's not

somber hull
#

but its being put there

#

plugin.activeEvents.put(plr, this);

#

if (!(plugin.activeEvents.containsKey(plr))){

hasty prawn
#

Oh whoops didn't see that

#

Well, try the other Runnable and see if that works, and put hi above the if check and see if it prints then

somber hull
#

alright

tulip pike
#

@reef wind can you help me with it?

somber hull
#

OH

#

So

tulip pike
#

I made my plugin 1.17.1 and it says that it doesn't support it

somber hull
#
 plr.sendMessage("Hi2");
        plugin.activeEvents.remove(plr);
#

its running this before the runnable ends

hasty prawn
#

Oh! Yeah that's what it is.

#

I forget that all schedulers are ran 1 tick later

tulip pike
hasty prawn
#

Even if you put the delay as 0

dense pulsar
#

@torn shuttle```java

private static final HashMap<UUID, Long> tntTimer = new HashMap<>();

@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {

    if (event.getBlockPlaced().getType().equals(Material.TNT)) {

        Player player = event.getPlayer();

        if (tntTimer.containsKey(player.getUniqueId())) {

            long remainingTime =  tntTimer.get(player.getUniqueId());

            if (remainingTime > Instant.now().getEpochSecond()) {
                event.setCancelled(true);
                player.sendMessage(Utils.chat("&eTNT TIMER: &bYou must wait " + (remainingTime - Instant.now().getEpochSecond()) + " seconds"));
            }
        }

        tntTimer.put(player.getUniqueId(), tntTimer.get(player.getUniqueId()) + 5);
    }

}
hasty prawn
tulip pike
#

OMG I LOVE IT

#

Seriously, I've been watching vids ๐Ÿ˜‚

hasty prawn
#

Oh wow! Lol I do the plugins for it ๐Ÿ˜„

somber hull
#

so, how do i have the line run after the runnable?

tulip pike
hasty prawn
#

Just remove them inside the Runnable instead of outside

somber hull
#

They are outside..

tulip pike
#

I do have a problem with 1.17.1

somber hull
#
    public void start(Player plr) {
        plugin.activeEvents.put(plr, this);
        plr.sendMessage("Hi1");
        new BukkitRunnable() {
            public void run() {
                if (!(plugin.activeEvents.containsKey(plr))){
                    return;
                }
                plr.sendMessage("Hi");
                TNTPrimed tnt = (TNTPrimed) plr.getLocation().getWorld().spawnEntity(plr.getLocation(), EntityType.PRIMED_TNT);
                tnt.setFuseTicks(2 * 20);
            }
        }.runTaskTimer(plugin,0,5 * 20);
        plr.sendMessage("Hi2");
        plugin.activeEvents.remove(plr);
    }
hasty prawn
#

Yeah put it inside instead of outside

somber hull
#

o

#

but then it woul repeat

#

?

#

right..

#

I want the runnable to run for 5 seconds

#

then stop

torn shuttle
#

always try to exit out as early as possible

hasty prawn
somber hull
hasty prawn
#

Do you want it to run every 5 seconds?

somber hull
#

i want it to run every 2 seocnds

#

for 10 seconds

#

so should i do a delayedtask?

torn shuttle
#

time to have fun with counters

somber hull
#

I chnaged the 5 to 2

hasty prawn
#

Yep lmao

somber hull
#

so keep the repeating task

#

right, then add a delayed task after it

#

to change that hasmap

hasty prawn
#

You can, or you can loop a runTaskLater() 5 times with 2 second intervals from each other

somber hull
#

awesome

#

thanks

ivory sleet
#

Sounds like runTaskTimer is more appropriate

somber hull
ivory sleet
#

Oo

hasty prawn
#

Probably, just have to cancel it at some point.

ivory sleet
#

Myeah

somber hull
#

Ok im just gonna do the delayedtask

#

wait 10 seconds

#

and change that hashmap

timid kraken
#

what is the spigot plugins/update folder used for?

#

does it have some kind of auto updating?

somber hull
#

Ok, everything works great

#

But

#

It runs like 3 times

#

rather than once

hasty prawn
#

Can you send code

hasty prawn
somber hull
#
    public void start(Player plr) {
        plugin.activeEvents.put(plr, this);
        plr.sendMessage("Hi1");
        // Waits 10 seconds to cancel the event.
        Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
            @Override
            public void run() {
                plugin.activeEvents.remove(plr);
            }
        }, 10 * 20);
        new BukkitRunnable() {
            public void run() {
                if (!(plugin.activeEvents.containsKey(plr))) {
                    return;
                }
                TNTPrimed tnt = (TNTPrimed) plr.getLocation().getWorld().spawnEntity(plr.getLocation(), EntityType.PRIMED_TNT);
                tnt.setFuseTicks(2 * 20);
            }
        }.runTaskTimer(plugin, 0, 2 * 20);
    }
timid kraken
somber hull
#

its just event.start(plr); thats calling it

hasty prawn
somber hull
#

@hasty prawn i think its running more times the longer the server is up...

hasty prawn
#

Oh wait, runTaskLater I mean

somber hull
#

alright

lusty cipher
#

I only know of 3rd party plugins that do it for you

hasty prawn
#

Could be, I never messed with auto updating.

lusty cipher
#

Yeah, same, I only print a warning to the console if its outdated ๐Ÿคทโ€โ™‚๏ธ

somber hull
#

Yea, it is spawning 3 tnt, the third time i have run it

lusty cipher
#

Obviously works, if two updates I released over a month ago are still by far the most used versions ๐Ÿ‘

hasty prawn
hasty prawn
#

It should spawn 5 tnt not 3 ๐Ÿค”

#

Well actually it should spawn infinite since you never cancel

somber hull
#

If i run it again

#

It spawns 4 at a time

hasty prawn
#

Oh

somber hull
#

if i run it again it spawns 5 at a time

#

etc

hasty prawn
#

Oh, yeah it's because you're not canceling it

somber hull
#

should i use smthng other than return;?

hasty prawn
#

In the runTaskLater() Runnable you need to do Bukkit.getScheduler().cancelTask(<task id of the timer>)

somber hull
#

how do i ghet the taskID....

tired dagger
#

So, I know that making the config static is not good practice. Conversely, I don't want there to be multiple instances of the Config class because I feel that will lead to future problems with saving and stuff I don't want to deal with. Would making this Config class use a singleton pattern be considered bad?

opal juniper
#

Method under BukkitTask

quaint mantle
#

Conclure ๐Ÿ˜

ivory sleet
#

you can cancel it inside and outside without needing to track the task id

#

Hello PES_Blush

quaint mantle
#

Heyo

opal juniper
ivory sleet
#

?scheduling look here

undone axleBOT
somber hull
#

Ok

ivory sleet
#

BukkitTask theTask = Bukkit.getScheduler().runTask(null, task -> {
task.cancel();
});

theTask.cancel();

opal juniper
#

I thought you would need to store the id

#

Oh

quaint mantle
#

@ivory sleet I actually read that, itโ€™s very useful ๐Ÿ‘€

ivory sleet
#

It takes a consumer conveniently enough

opal juniper
#

Well yeah the BukkitTask would work

ivory sleet
#

Yeah it isnโ€™t for 1.8 sadly

#

It was added around 1.13

quaint mantle
#

Should do one on what we was talking about

hasty prawn
#

Oh I didn't know it took a consumer

opal juniper
#

1.8 can ๐Ÿ–•

hasty prawn
#

that's cool

ivory sleet
#

Yeah, functional interfaces PES_SadGePray PES_SadGePray

hasty prawn
#

Not that cancelling it inside helps here but still useful to know :O

somber hull
#

Ok waitr

ivory sleet
#

Oh yeah my bad tldr

somber hull
#

how do i gte the ID

hasty prawn
#

You can just store the BukkitTask and cancel it then

somber hull
#

So i would have to rewrite this

        new BukkitRunnable() {
            public void run() {
                if (!(plugin.activeEvents.containsKey(plr))) {
                    
                }
                TNTPrimed tnt = (TNTPrimed) plr.getLocation().getWorld().spawnEntity(plr.getLocation(), EntityType.PRIMED_TNT);
                tnt.setFuseTicks(2 * 20);
            }
        }.runTaskTimer(plugin, 0, 2 * 20);
hasty prawn
#

No just add BukkitTask task = at the start

somber hull
#

And store it?

#

ok

hasty prawn
#

And then inside the runTaskLater just do task.cancel()

#

You'll have to swap the order you create them in I think

somber hull
#

ok

#
    public void start(Player plr) {
        plugin.activeEvents.put(plr, this);
        BukkitTask task = new BukkitRunnable() {
            public void run() {
                if (!(plugin.activeEvents.containsKey(plr))) {
                    this.cancel();
                    return;
                }
                TNTPrimed tnt = (TNTPrimed) plr.getLocation().getWorld().spawnEntity(plr.getLocation(), EntityType.PRIMED_TNT);
                tnt.setFuseTicks(2 * 20);
            }
        }.runTaskTimer(plugin, 0, 2 * 20);
        // Waits 10 seconds to cancel the event.
        new BukkitRunnable(){
            @Override
            public void run() {
                plugin.activeEvents.remove(plr);
                task.cancel();
            }
        }.runTaskLater(plugin, 10 *  20);
    }```
#

i also added the this.cancel

hasty prawn
#

Don't need both

somber hull
#

?

hasty prawn
#

You can do one or the either, don't need both of them

somber hull
#

but i want the runTaskTimer to run every 2 seconds for 10 seconds..

hasty prawn
#

Yeah it would, you're just stopping it after 10 seconds twice

#

Honestly the this.cancel() is probably a better idea

#
    public void start(Player plr) {
        plugin.activeEvents.put(plr, this);
        new BukkitRunnable() {
            public void run() {
                if (!(plugin.activeEvents.containsKey(plr))) {
                    this.cancel();
                    return;
                }
                TNTPrimed tnt = (TNTPrimed) plr.getLocation().getWorld().spawnEntity(plr.getLocation(), EntityType.PRIMED_TNT);
                tnt.setFuseTicks(2 * 20);
            }
        }.runTaskTimer(plugin, 0, 2 * 20);
        // Waits 10 seconds to cancel the event.
        new BukkitRunnable(){
            @Override
            public void run() {
                plugin.activeEvents.remove(plr);
            }
        }.runTaskLater(plugin, 10 *  20);
    }
somber hull
#

wait...

#

why cant i just create a variable

#

add 1 every time its ran

hasty prawn
#

You can if you want to do it that way I guess