#help-development

1 messages · Page 1767 of 1

quaint mantle
#

Hey, could anyone point me in the right direction for using websockets in java/specifically a spigot plugin? I'm looking to use client side. I have a websocket server elsewhere, and would like to send server data to it. Just curious what'd be the best way to implement that in a plugin, and what lib to use?

warm mica
#

what's wrong with vscode

warm mica
quaint mantle
#

i forgot the name but like reused manual tasks everytime

warm mica
#

slow and there's so much? vscode is the most lightweight ide i've ever used

quaint mantle
#

lightweight but the intellisense is really bad

#

i only use it for json, css, js and html, i think those are the only things it should be used for

#

i mean it was developed in a web environment

warm mica
#

you can do so much with it, and yes of course you can't expect a intellij-like complexity of it, but it's still a great ide for most languages or frameworks

quaint mantle
#

its there when you dont need full help

quaint mantle
warm mica
#

shade it in and run it on a seperate thread

#

actually it's the same as if you'd do it with a normal program

merry pulsar
#

how to check if a world exist

warm mica
#

you can use spigot's new library feature if you want, but i'd just stay with shading it in

warm mica
merry pulsar
ivory sleet
#

nv-websocket-client also got on my mind just rn

#

iirc JDA does use it also

ember estuary
#

Do all plugins use the same config.yml?
If not, where do i save it so only my plugin uses it?

ivory sleet
#
  1. No, 2. In your plugin data folder
ember estuary
#

where is that

ivory sleet
#

However it won’t stop x plugin from accessing your config.yml

ember estuary
#

thats alright

ivory sleet
#

Usually something like:
server/plugins/PluginName/config.yml

ember estuary
#

ah i see

#

i gotta create that folder myself right

ivory sleet
#

Indeed

shut swift
#

hey, does anyone have experience adding features to existing mobs?

ivory sleet
#

Although it’s basically with spigot just Plugin::getDataFolder and then File::mkdirs iirc

ember estuary
#

does file#createNewFile also create non existing folders?

ivory sleet
#

File::createNewFile creates a file not a directory

ember estuary
#

like say i wanna save the file in ./abc, does it create abc?

ivory sleet
#

No

ember estuary
#

ok

young knoll
#

File#mkDirs can handle that

ivory sleet
#

Usually (what I do) is in onLoad:
Path dataPath;
Files.createDirectories(dataPath = this.getDataFolder().toPath().toAbsolutePath());

And in onEnable
Path config;
if (!Files.exists(config = dataPath.resolve("config.yml"))) {
Files.createFile(config);
}
[or something] since Java kinda states the class File is obsolete

#

Also yea I wrote it on phone lol

lean gull
ember estuary
#

because the conditions in the other two are false

#

int i = 9;
if (i < 3)

#

9 is bigger than 3

#

so it wont run

#

convert your for-loop to a while loop and youll get why

#
for (int i = 45; i < 9; i++) {
  inv.setItem(i, borderItem);
}

as while:

int i = 45;
while (i < 9) {
  inv.setItem(i, borderItem);
  i++;
}
#

"as long as i is smaller than 9"

#

but i is never smaller

ivory sleet
#

Yeah the two lower loops are using a dummy variable where the value exceeds the upper bound value used in the condition to determine if the loop should continue to iterate thus they never iterate, not even once

lean gull
#

ah

ember estuary
#

@ivory sleet
Why
Path dataPath;
Files.createDirectories(dataPath = this.getDataFolder().toPath().toAbsolutePath());
instead of
Path dataPath = this.getDataFolder().toPath().toAbsolutePath();
Files.createDirectories(dataPath);
?

ivory sleet
#

Oh it was just easier to write on phone

ember estuary
#

oh ok

#

xD

#

is there any difference?

ivory sleet
#

Yeah lol the latter is actually preferred

#

They do effectively the same thing

ember estuary
#

ok :D

ivory sleet
#

One could say the former is worse because it has to mutate its value

ember estuary
#

well, have to do that anyway, since otherwise i cant use dataPath in onEnable()

ivory sleet
#

Yeah, in principle you could have a private final field in your class where it essentially stores the data path.

ember estuary
#

thats what i was planning to do

ivory sleet
#

Yeah, probably better that way.

#

Arguably just a method to get it

#

Since it might be a waste of variables and unnecessary caching but that’s negligible lol

ember estuary
#
    private final Path dataPath = this.getDataFolder().toPath().toAbsolutePath();

    @Override
    public void onLoad() {
        try { Files.createDirectories(dataPath); } catch (IOException ignored) {}
    }

#

thats what i did

ivory sleet
#

Yeah that should work

ember estuary
#

does it throw an exception when the folders exist?

quaint mantle
#

idk if you would want to just ignore the exception lol

ivory sleet
#

iirc no

quaint mantle
#

if your plugin relies on that data path

ivory sleet
#

floskater afaik it does not

#

But if it does, just use Files::exist and Files::isDirectory or smtng c:

ember estuary
#

ok :D

ivory sleet
ember estuary
#

xD

young knoll
#

what

#

That... isn't even minecraft related

ember estuary
#

ofc it is

#

plugin config files

#

getCommand("challenge").setExecutor(new Challenge());
IntelliJ says "Method invocation 'setExecutor' may produce 'NullPointerException' ", should I fix this using Objects.requireNonNull, or is that usually just ignored?

runic mesa
#

How would i be able to make a fox follow a player with pathfinding

ivory sleet
gray crypt
#
    //places the blocks for the portal
    public void placePortal(Block[] portalBlocks) {
        //separate the blocks from the array
        Block portalLowerBlock = portalBlocks[0];
        Block portalTopBlock = portalBlocks[1];

        //set block types to END_GATEWAY
        portalLowerBlock.setType(Material.END_GATEWAY);
        portalTopBlock.setType(Material.END_GATEWAY);

        //set teleport location for the end gateways
        //only used to listen to the event
        portalLowerBlock.setExactTeleport(true);
        portalLowerBlock.setExitLocation(portalLowerBlock.getLocation().add(0, 3, 0));
    }

does anyone know why I can't do the last two lines of code?

#

IntelliJ says that that method cannot be resolved

twilit wharf
#

my config setup is adding to the config, but is unable to retrieve data

#

This prints nothing: System.out.println(CustomConfigFile.get().getStringList("parkour.maps"));

#

but, this works fine, and adds to the config: java CustomConfigFile.get().set("parkour.maps", maps); CustomConfigFile.save(); CustomConfigFile.reload();

vagrant heron
#

hey, im using bungeecord and im trying to place my players online in certain server, how do i do this? is there a video about it because i cant fine one

patent horizon
#

how do i zoom out on my intellij text editor

twilit wharf
#

then

#

using a ProxiedPlayer, you can do ProxiedPlayer.connect(sv);

vagrant heron
#

ok that to confused for me rn ive been awake for too long lol

twilit wharf
#

here is how I do it in my plugin

#
    @EventHandler
    public void onPlayerJoin(ServerConnectEvent e) {
        String type = CustomConfigFile.getConfig().getString("config.join-type");
        ProxiedPlayer pp = LobbySystem.getInstance().getProxy().getPlayer(e.getPlayer().getUniqueId());
        ServerInfo sv;
        if (type.equals("RANDOM")) {
            sv = LobbySystem.getInstance().getRandomLobby();
        }
        else {
            sv = LobbySystem.getInstance().getProxy().getServerInfo("LOBBY2");
        }
        System.out.println(ChatColor.AQUA + "[LobbySystem] >> " + ChatColor.GOLD + "New Player Connected. Sending them lobby " + sv.getName());
        e.setTarget(sv);
    }```
twilit wharf
patent horizon
#

nope

#

cmd +/- cycles through classes

#

and control doesnt do anything

twilit wharf
tranquil viper
patent horizon
#

uhhh

#

whats the alt button on a mac

timid valley
tranquil viper
twilit wharf
patent horizon
#

doesnt seem to be doing anything

tranquil viper
tranquil viper
tranquil viper
#

How is that not custom

#

xd

twilit wharf
tranquil viper
#

just name it config.yml

twilit wharf
#

cause it is different from like spigot.yml

twilit wharf
#

I use YamlConfiguration

tranquil viper
#

Try:

System.out.println(getConfig().getString("parkour.maps"));
young knoll
#

Something about Silkroad Online the game

shut swift
#

hey, I'm looking to create a plugin that adds some arbitrary changes to existing mobs (e.g mob does extra damage). My plan was, on mob spawn, to randomly assign these elements. I'm aware the bukkit api has the "on mob spawn" event, but I'm not sure how to add stuff to existing mobs. Anyone have any insight on this?

ancient plank
ember estuary
#

is there any way to write text like "&1Like&2This" and then convert it into a Component? And get the colorcodes replaced correctly? Because thats way shorter than all that new component.text().color().append(component.text().color().append()...)

quaint mantle
#

well...

#

text(chatcolor.translaltealternativecolorcodes)

paper viper
#

id recommend tbh to use something like adventure (off topic)

#

but its a great lib for components

quaint mantle
#

the translate do nothing but convert & to § which in its unicode is \u00A7

#

so it basically still text

ember estuary
#

and §1 gets interpreted as a color, like it used to?

quaint mantle
#

and when you put it in minecraft, they dont care, they see you have that code, then you get the color on the text

quaint mantle
#

idk

#

but i think you still want to use & instead of that

#

then in translatealternativecolorcodes('&', text)

#

Ex: &cHello
It will convert to \u00A7cHello

#

and the \u00A7c will always be red.

ember estuary
#

ok, great :D

#

actually works, tysm

echo basalt
#

What event gets fired if an entity attempts to attack a Player, but the damage is blocked by a Shield?

worldly ingot
#

afaik, EntityDamageByEntityEvent is still called

ember estuary
#

even attacks blocked by a shield trigger EntityDamageByEntityEvent

obtuse crane
#

hello good evening, someone knows how to get the result of this command but on top, since it only grabs that of a particular player

else if (args[0].equalsIgnoreCase("zombie")) {
                    FileConfiguration mobs4 = plugin.getMobs4();
                    if (!mobs4.contains("Players")) {
                        jugador.sendMessage(ChatColor.RED+"--------------KILLS--------------"); 
                        jugador.sendMessage(ChatColor.GREEN+"Zombie Asesinados: "+ChatColor.DARK_GREEN+"Ninguno");
                        jugador.sendMessage(ChatColor.RED+"--------------KILLS--------------");
                        return true;
                    }else {
                        if (mobs4.contains("Players."+jugador.getUniqueId()+".zombie")) {
                            int cantidadzombie = Integer.valueOf(mobs4.getString("Players."+jugador.getUniqueId()+".zombie")); //aplicar la cantidad basandose en la id del jugador
                            jugador.sendMessage(ChatColor.RED+"--------------KILLS--------------");
                            jugador.sendMessage(ChatColor.GREEN+"Zombie Asesinados: "+ChatColor.YELLOW+cantidadzombie);
                            jugador.sendMessage(ChatColor.RED+"--------------KILLS--------------");
                            return true;
                        }else {
                            jugador.sendMessage(ChatColor.RED+"--------------KILLS--------------"); //si no lleva ninguna kill
                            jugador.sendMessage(ChatColor.GREEN+"Zombie Asesinados: "+ChatColor.DARK_GREEN+"Ninguno");
                            jugador.sendMessage(ChatColor.RED+"--------------KILLS--------------");
                            return true;
                        }
                    }
                }
drowsy helm
#

could you elaborate

ember estuary
#

I don't get it either

#

what do you mean with "but on top"

#

Finally finished my first ever plugin :D
Thanks to everyone who helped me :3

drowsy helm
#

gg

quaint mantle
#

...?

ember estuary
#

anyone wanna test if it works?
I only ran it on my pc till now. not sure if i have to add any dependencies or stuff like that for it to work on other systems

#

IntelliJ is redly underlining the dependency, but idk what that means

drowsy helm
#

soz but no ones gonna do that lol

#

youll need to ask a friend

#

people here are skeptical

ember estuary
#

yea, makes sense xD

#

i could send the code tho, but then thats just too much work to set up for most people

drowsy helm
#

if it works on your server it should work fine on others

#

unless you're doing some OS level stuff it should be fine

ember estuary
#

Why is it underlined?

#

in my pom.xml i have

<dependency>
  <groupId>org.spigotmc</groupId>
  <artifactId>spigot</artifactId>
  <version>1.17.1-R0.1-SNAPSHOT</version>
</dependency>
drowsy helm
#

does it give you a message?

ember estuary
#

when hovering?

#

nope

#

i used Spigot BuildTools to install that NMS stuff

#

if that matters

drowsy helm
#

hoow about on compile?

ember estuary
#

how do i?

#

build project? or how does one compile

drowsy helm
#

if you are on intelliJ (which you are)

#

there is an M button on the right

ember estuary
#

yea xD

drowsy helm
#

just click it and type package

ember estuary
#

still red :/

drowsy helm
#

did it compile though?

#

and did you inclue the repository

ember estuary
#

--- maven-compiler-plugin:3.3:compile (default-compile) @ LevelToWorldborder ---
[INFO] Nothing to compile - all classes are up to date

#

i guess thats a no?

#

i included this one

#

is that the right one?

drowsy helm
#

yeah the repo is fine

#

could you send the whole maven log

ember estuary
drowsy helm
#

well its building fine

#

so nothing to worry about

#

could be just a matter of restarting the ide

ember estuary
#

true, that fixed it

#

lol

gray crypt
#

Does anyone know how to set an EndGateway's state if I have a block?

#
    //places the blocks for the portal
    public void placePortal(Block[] portalBlocks) {
        //separate the blocks from the array
        Block portalLowerBlock = portalBlocks[0];
        Block portalTopBlock = portalBlocks[1];

        //set block types to END_GATEWAY
        portalLowerBlock.setType(Material.END_GATEWAY);
        portalTopBlock.setType(Material.END_GATEWAY);

        //set teleport location for the end gateway
        //only used to listen to the event
        * portalLowerBlock.setExactTeleport(true);
        portalLowerBlock.setExitLocation(portalLowerBlock.getLocation().add(0, 3, 0)); *
    }
#

those two lines don't work

#

Alright I've done this.. seems like it will work

        EndGateway portalData;
        portalData.setExactTeleport(true).setExitLocation(portalLowerBlock.getLocation().add(0, 3, 0));
        portalLowerBlock.setBlockData(portalData.getBlockData());
young knoll
#

You should be setting it to portalData

#

Currently you are just setting it to the data it already has

#

And you should be assigning getBlockData to portalData

gray crypt
#

ah

#

So I should be setting what to portalData?

young knoll
#

setBlockData

gray crypt
#

Ah alright

#

How do I initialize portalData by the way?

#

I tried just doing EndGateway portalData = new EndGateway(); but it didn't like that

waxen plinth
young knoll
#

Or

#

Just use getBlockData since you already have a block

crude charm
#
    public void openSheepRecipeMenu(Player player) {

        Inventory inventory = Bukkit.createInventory(null, InventoryType.DROPPER, CC.translate("&cS&6h&ee&2e&1p &5C&ao&3r&9e"));

        ItemStack redWool = new ItemStack(Material.WOOL, 1, (short) 14);
        ItemStack orangeWool = new ItemStack(Material.WOOL, 1, (short) 1);
        ItemStack yellowWool = new ItemStack(Material.WOOL, 1, (short) 4);
        ItemStack greenWool = new ItemStack(Material.WOOL, 1, (short) 13);
        ItemStack blueWool = new ItemStack(Material.WOOL, 1, (short) 11);
        ItemStack purpleWool = new ItemStack(Material.WOOL, 1, (short) 10);
        ItemStack limeWool = new ItemStack(Material.WOOL, 1, (short) 5);
        ItemStack cyanWool = new ItemStack(Material.WOOL, 1, (short) 9);

        inventory.setItem(0, redWool);
        inventory.setItem(1, orangeWool);
        inventory.setItem(2, yellowWool);
        inventory.setItem(3, greenWool);
        inventory.setItem(5, blueWool);
        inventory.setItem(6, purpleWool);
        inventory.setItem(7, limeWool);
        inventory.setItem(8, cyanWool);

        inventory.setItem(4, sheepCore());

        player.openInventory(inventory);
    }

why are none of the items here setting?

waxen plinth
#

That's a pretty bad way to do that

crude charm
waxen plinth
#

But the code looks like it should work

#

I would double check that this method is being called properly

#

And try clicking in the inventory as the player

sullen marlin
#

also < 1.13, so like how many years outdated

waxen plinth
#

Also I would keep an array of ints and iterate over them rather than doing this madness

#

That too

crude charm
#
ew SheepRecipeMenu().openSheepRecipeMenu(player);

The menu opens but nothing is inside it

sullen marlin
#

could be a bug with custom dropper inventories in that version

obtuse crane
#

This is good?

public boolean onCommand(CommandSender sender, Command comando, String label, String[] args) {
        if (!(sender instanceof Player)) {
            Bukkit.getConsoleSender().sendMessage(plugin.nombre+" no puedes ejecutar comandos desde la consola");
            return false;
        }else {
            Player jugador = (Player) sender;
            if (args.length > 0) {
                if (args[0].equalsIgnoreCase("gallina")) {        
                    FileConfiguration config = plugin.getConfig();
                    if (config.getConfigurationSection("Players").getKeys(false) != null) {
                        List<String> zombie = config.getStringList("Players.name");
                        for(int i=0;i<zombie.size();i++) {
                            
                        }
                        return true;
                    }else {
                        jugador.sendMessage(ChatColor.RED+"Aun no hay top");
                        return true;
                    }
                }
            }
        }
        return true;
    }
waxen plinth
#

No

#

You can improve this in any number of ways

#

The simplest is with better code structure

#

You can do some early return, and you're already doing some

#

If you have a return in an if statement, you don't actually need an else

#

Since a return exits the function

#

Everything after the if statement becomes an implicit else

young knoll
#

Also you probably want to return true after telling the console they can’t use the command

waxen plinth
#
    public boolean onCommand(CommandSender sender, Command comando, String label, String[] args) {
        if (!(sender instanceof Player)) {
            Bukkit.getConsoleSender().sendMessage(plugin.nombre+" no puedes ejecutar comandos desde la consola");
            return true;
        }
        Player jugador = (Player) sender;
        if (args.length == 0) {
            return false;
        }
        if (args[0].equalsIgnoreCase("gallina")) {
            FileConfiguration config = plugin.getConfig();
            if (config.getConfigurationSection("Players").getKeys(false) == null) {
                jugador.sendMessage(ChatColor.RED+"Aun no hay top");
                return true;
            }
            List<String> zombie = config.getStringList("Players.name");
            for(int i=0;i<zombie.size();i++) {
            
            }
        }
        return true;
    }```
#

Here

#

I've restructured your code a bit to make the structure better

#

Whenever you hit a condition that allows you to immediately exit the function, you should return early

#

That makes the flow of your code more linear, reducing the number of branches in it and making it easier to read

#

Also, doing commands this way is tedious and error-prone

#

Ideally you should use a library that adds layers of abstraction so that you don't have to worry about all the manual checks and conversions

#

A good command library will save you an immense amount of effort

quaint mantle
#

this i mean

#

my example

#

heyy, so im wondering if i can convert like, a colored String with Bukkit chatcolours, to a TextComponent

#

im kinda new to this ChatComponent stuff, and if i had to be honest the help page isnt very helpful as its rather outdated

quaint mantle
#

you can scroll up a bit

#

like a few messages

#

yeah

#

what

#

just scroll up to see the answer lol

#

ohh

#

i just answer this a few hours ago

#

mm r u sure

#

because i cant find anything, maybe i scrolled too fast

quaint mantle
#

a few hours ago

quaint mantle
#

yes.

#

so thats not what im asking

#

you're talking about a Text

#

im asking about a TextComponent

#

im not sure they're the same thing, and i doubt they are if i cant use one in the HoverEvent, and not the other

#

ping me in a response)

#

learn component when...

#

im pretty sure component has a text method.

#

didnt care about the textcomponent tho. component still can use hoverevent so i dont really use textcomponent

quasi flint
#

stringtextcomponent?

#

why wouldnt that work

quaint mantle
quaint mantle
quasi flint
#

he can prob use a stringtextcomponent

#

for whatever he wants to achieve

quaint mantle
#

what is that

#

is StringTextComponent a thing?? irdk if ur talking about a class, or what

#

well it literally there

#

fromlegacytext

#

hello???

#

you didnt read javadocs before asking?

quasi flint
#

i though i was on the forge cordduke

quaint mantle
#

TextComponent != BaseComponent[]

#

helloooo

chrome beacon
#

They still aren't the same

quaint mantle
#

dawg

quasi flint
#

maybe this helps

quaint mantle
#

let me better explain my question..

quaint mantle
#

is it possible to convert a Bukkit coloured String (so things w/ ChatColor.GREEN from bukkit.ChatColor to a TextComponent

chrome beacon
#

You would have to write your own system or use the string as is

quaint mantle
#

i see

chrome beacon
#

Since for the moment legacy color codes do still work

quaint mantle
#

so riddle me this then

#

how should i gather the chatcolours of a String, and then convert them to Bungee colours

#

welp... i think my answer is not that obvious to tell you the thing you want then 😛

quaint mantle
chrome beacon
#

Why do you need to convert them? I'd just use Bungee colors in the first place

quasi flint
#

bukkit color ;7

#

yikes

chrome beacon
#

Also doesn't Bukkit color have asBungee method

quaint mantle
chrome beacon
quaint mantle
#

but tbch it returns a String

#

and im not sure if ima messs smt up

chrome beacon
#

Just use legacy text it works for the momemt and you won't have to over think anything

quaint mantle
#

alr, thanks for the help :)

chrome beacon
#

Or you could take a look at Adventure it's quite neat

summer scroll
#

Actually there are 57 errors, and all of them is cannot access ... error.

drowsy helm
#

well that repo doesnt comtain a com.faris.kingkits.api

#

so im assuming theres another thing you need to dep[end on

#

its not included in the pom either

summer scroll
#

What? the code is all there

drowsy helm
#

oh nvm im blind

summer scroll
#

i never got this error before

solid cargo
#

how can i make a drop confirmation? currently i have this but if i swap items between the confirmation, it still stores the old int

tawdry patrol
#

hello, i am wondering if someone with development experience could make or help me create a fairly simple plugin

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Create a thread in case the help channel you are using is already in use!

quasi flint
#

stonks

quaint mantle
#

¯\_(ツ)_/¯

solid cargo
quaint mantle
solid cargo
quaint mantle
#

🤣 Lmf

quaint mantle
quaint mantle
#

the one who asks for help with this

#

and people like them usually confuse java with javascript😐

#

I thought you would get the joke ..

quaint mantle
#

I don't know the syntax is too different

#

Better pascal

tawdry patrol
#

basically im wondering if anyone would know how to configure a plugin where you start with 1 heart and gain 1 everytime you die, once you've hit 10 hearts you're banned for 1-2 days and your balance, enderchest and homes are reset

quaint mantle
#

moment

#

the moment of truth...

#

when he finally say what he is asking for...

#

👌

#

She

#

oh lol

#

asian moment

tawdry patrol
#

lmaoaoa

#

its fine

quaint mantle
#

welp us asian mostly dont really care about the pronoun lel

tawdry patrol
#

stalker

quaint mantle
#

pls donate towards me and josie buying a minecrafr server

tawdry patrol
#

yes pls 🙏

quaint mantle
tawdry patrol
#

ill fix it for you

#

there

quaint mantle
tawdry patrol
#

nothing yet 💔

quaint mantle
#

How old are you

tawdry patrol
#

im 16

crimson terrace
#

where do I put the permissions.yml and how do I use it?

quaint mantle
#

this is not help server channel.

crimson terrace
#

in my plugin

quaint mantle
#

hmm

#

i thought you are saying about pex

crimson terrace
#

nah

quaint mantle
#

working-with-configurations-file

#

i think this is the tag

#

there is a small wiki

#

with that tag

#

go search it and put spigot last

crimson terrace
#

got it

#

so I just put it in the resources folder and call it permissions.yml?

#

and then the p.hasPermission() just takes from that file or is there more to it

quaint mantle
#

figure it yourself is a better way while waiting for answer

serene trench
#

i need to solve it

quaint mantle
#

dev channel only.

serene trench
granite burrow
serene trench
quaint mantle
granite burrow
#

is there a way to check if an item is a pick,axe,shovel,or hoe?

granite burrow
#

no, just so you know this channel is for creating plugins only

quaint mantle
#

then just compare the item name

#

it should suggest you the name if you type pick in intellij

granite burrow
#

alright, ill upload this code to intellij then, it was broken yesterday when I was working on a plugin

eternal oxide
#

names can be changed, check its Material#name() for .contains("_PICKAXE")

granite burrow
eternal oxide
#

getType().name()

granite burrow
#

dam I was close lmao

quaint mantle
eternal oxide
#

no

summer scroll
#

Will InventoryClickEvent fired when player click on their own inventory?

ivory sleet
#

Yuh

summer scroll
#

great

tardy delta
granite burrow
#

how can I get the item in the players main hand in the BlockBreakEvent?
I tried e.getPlayer().getInventory().getItemInMainHand(); but it keeps returning air even though I obviously have a pick in my hand

crude charm
#
    @EventHandler
    public void onMove(PlayerMoveEvent event) {
        Player player = event.getPlayer();

        if (player.getInventory().getBoots() == null) return;

        if (player.getInventory().getBoots().equals(rocketBoots())) {

            player.setAllowFlight(true);

        } else {
            player.setAllowFlight(false);
            player.setFlying(false);

        }

Can someone please tell me wtf is wrong with this. After they take the boots off they can still fly.

#

I dont understand

summer scroll
#

you didnt do anything there

crude charm
#

Wouldn't that cause issues?

#

If they are gmc

#

or if its someone with /fly

summer scroll
#

well, you can use armorequipevent or something like that

granite burrow
#

check if they have permissions to fly or are in gamemode

#

and if they are dont disable it

crude charm
#

I'll figure out a way to check for it

#

but yeah ur right

#

it works if they have smth

summer scroll
#

in your code, if player equip the rocket boots, they able to fly, but if they take off the boots they still can fly because you didnt do anything there

granite burrow
#

yeah, armor equip event would be best for what your trying to do

crude charm
summer scroll
#

yeah it's not exist on spigot api

crude charm
#

paper?

summer scroll
#

paper api has it

crude charm
#

ok I'll move it to paper

granite burrow
#

the only other way I can think of doing it in spigot is checking inventory click event and checking on click if they have boots on, should cover both putting on the boots and taking them off via right clicking outside the gui or adding them on inside

#

but thats more work than switching to paper

granite burrow
#

Its because I didn't declare an API version

#

for anyone wondering the same thing

summer scroll
#

How can I achieve pagination inventory from a list of itemstack?

quaint mantle
#

Well, there's no ready solution with spigot api. You break down the list into part each 36 elements (inventory size - 9). Then, build an inventory. Do a for loop i < 36
inventory.setItem(i)
and then, add next/previous button and listen for them

#

on next button, just cleear the inventory and set the content of the next part

summer scroll
#

I'm having a hard time keeping track of the showed item and what will be the previous page item and next page item.

quaint mantle
#

store the page index somewhere

eternal oxide
#

?paste

undone axleBOT
eternal oxide
#

wrong person

#

@summer scroll ^

blazing scarab
#

Thats how i did it

summer scroll
blazing scarab
summer scroll
tardy delta
#

Is a WeakHashMap<> good for cache or should i use Google's cache builder?

quasi flint
#

What in gods name is a weakhashmap

#

Never heard of that one

eternal oxide
#

Its good if you HAVE to use something like a Player as a key

wet stream
#

how to check in what world is player?

cunning mortar
tardy delta
#

Im using a class which holds a player and some chatchannellists

wet stream
#

Like I want to create plugin what will give you an slow falling plugin when player is in the end

#

How to do it?

crude charm
#

Why is this not working?

    public ShapedRecipe rocketBootsRecipe() {
        ShapedRecipe boots = new ShapedRecipe(rocketBoots());
        boots.shape("SSS",
                    "I I",
                    "* *");

        boots.setIngredient('S', Material.NETHER_STAR);
        boots.setIngredient('I', Material.IRON_BLOCK, 32);
        boots.setIngredient('*', Material.FIREWORK, 64);

        return boots;
    }
getServer().addRecipe(new RocketBoots().rocketBootsRecipe());

eternal oxide
wet stream
#

Intellij

wet stream
#

I know how to create plugin

chrome beacon
wet stream
#

bot how to check the world

chrome beacon
eternal oxide
chrome beacon
#

Quantities don't work in ingredients

crude charm
eternal oxide
#

you can not specify the amount

chrome beacon
#

^

crude charm
#

How do I do it then?

#

if I want to

#

or is it just in no way possible

chrome beacon
#

Use the PrepareCrafting event or whatever and implement your own system

eternal oxide
#

you would have to monitor the pre craft event and check quantities

crude charm
#

oh I cba with that I'll just make an item that requires multiple iron blocks in one

#

and require that custom item

#

assuming thats possible

#
    public ShapedRecipe rocketBootsRecipe() {
        ShapedRecipe boots = new ShapedRecipe(rocketBoots());
        boots.shape("SSS",
                    "I I",
                    "* *");

        boots.setIngredient('S', Material.NETHER_STAR);
        boots.setIngredient('I', Material.IRON_BLOCK);
        boots.setIngredient('*', Material.FIREWORK);

        return boots;
    }

this still isn't working?

eternal oxide
#

have you given the recipe to anyone?

crude charm
#

this is on my test server

eternal oxide
#

player.discoverRecipe(recipe)

crude charm
eternal oxide
#

and you did Bukkit.addRecipe(recipe);

crude charm
summer scroll
eternal night
#

Java works mainly with references to objects

#

When adding a list as a value to a map like this you are basically just handing the map a pointer to that list

summer scroll
#

oh wtf

eternal night
#

You are the later modifying that same list

summer scroll
#

so i'm putting the same List to the map?

eternal night
#

Hence

#

Yes

summer scroll
#

yeah lol

#

how can i fix that?

#

initialize the list again?

eternal night
#

Pretty much yea, just create a new list instance each iteration

summer scroll
#

ah it works, thank you so much

#

my brain was ready to explode

#

finally i got my pagination inventory working

tardy delta
#

i'm getting an npr when trying to get Bukkit.getPlayer(args[0]) when clicking on space after the command name

vocal mirage
#

Hi!
If i have a permission maxamount.1, how can I get the number without knowing what numbers you can be faced to?

i use bungeecord

Thanks

chrome beacon
#

Are you using a permissions plugin?

tardy delta
#

should i run Bukkit.getOfflinePlayer(string) async as it performs a blocking web lookup?

young knoll
#

Yes

tardy delta
#

and if a player == null, will Bukkit.getOnlinePlayers().contains(that player) always return false?

chrome beacon
#

Use isOnline?

#

Also make sure the offline player isn't null

tardy delta
#

it just a player object rn

chrome beacon
#

If you have a player object the player is online

#

Otherwise it would be null

tardy delta
#

ah oke

sweet helm
#

Hi i'm writing on a plugin with the requirement that i can place blocks at 60 replacements per second..
I'm making a display/screen, and im wondering if i can go above 20fps
i'm struggling to find anything above 20fps, as the spigot servers run at 20TPS, so my guess is im stuck at 20 changes on 1 block per second?
I think i could run it faster at the server side, but then the TPS would just check for the state at 20 ticks per second?
Can i manually send block updates to increase the TPS for blocks only? or for a certain area of blocks?

#

honestly, I'd even take 30fps, anything above 20 will be a win for me.

buoyant viper
#

i think if you stick to the safety of spigot 20 sounds like the limit

#

however

sweet helm
#

screw safety

buoyant viper
#

Threads 😼

stone sinew
#

You can send packets in your own thread which can use ms instead of ticks.

sweet helm
#

i thought world changes were impossible using threads?

stone sinew
buoyant viper
#

possibly? if theres some kind of context check maybe but idk

sweet helm
#

hmm.. for some context, the plugin im writing is a wack idea of making a computer, we got a cpu going, next is the gpu. Obviously we want a screen for it,
everything is stored in block form, wool for 1's, glass for 0's, basically, as much as possible in world so its visual...
Same way the screen should be an actual thing we can write to

vocal mirage
#

LuckPerms

stone sinew
#

I don't do threads @sweet helm

sweet helm
#

sorry, didn't want to have multiple convo's at once in one chat

#

but alright

#

So basiclly, i can do as many changes as i want server side, the TPS throttles this to 20 something and thus the world changes are slow to the player,
but if i just send the packets ahead when i change the block, the player should be receiving the blocks as quickly as the server can generate them?

#

i mean if thats the case.... i can smell burning plastic already

#

please confirm? 😅

stone sinew
#

Create a thread and send all block updates to your thread. You can change all blocks for a player at any ms.

tardy delta
#

how can i get the command args to a string?

#

Arrays.asString adds [] iirc

#

prob stringbuilder then

quaint mantle
tardy delta
#

oh forgot that that existed, thanks

crude charm
#

What is wrong with this? I haven't done a crazy amount of work with custom crafts

    public ShapedRecipe rocketBootsRecipe() {
        ShapedRecipe boots = new ShapedRecipe(rocketBoots());
        boots.shape("   ",
                    "SSS",
                    "* *");

        boots.setIngredient('S', Material.AIR);

        return boots;
    }

    @EventHandler
    public void recipe(PrepareItemCraftEvent event) {
                if(event.getRecipe().equals(rocketBootsRecipe())){

                    if (event.getInventory().getMatrix()[6].equals(rocketCore()) 
                      && event.getInventory().getMatrix()[8].equals(rocketCore())) {
                        event.getInventory().setResult(rocketBoots());
                    }

                }
            }
quaint mantle
#

probs using equals on itemstacks

crude charm
#

that wouldn't change if it works or not?

#

@quaint mantle

quaint mantle
#

idk try isSimilar

#

If it wouldnt work either, consider using pdc

crude charm
#

I highly doubt that would fix it but I can try

crude charm
crude charm
#

the issue is with checking, pdc would just make sure that its the right item

quaint mantle
#

Any errors? What do you mean by "doesnt work" ?

crude charm
#

and no there are no errors

quaint mantle
#

Well, do some debug. Log every step and see what happens

crude charm
sharp bough
#

copy and paste some tutorial first

#

chgeck if it works and start editing it from there

crude charm
sharp bough
#

clearly you do lmao

crude charm
#

and stars are from an old thing I had

sharp bough
#

read that

crude charm
#

No

#

because I know how to do it

#

you obviously dont understand my issue

sharp bough
#

well then good luck brute forcing it lmao

#

try every combination you can think of

solid cargo
#

is there any way i can decrease the amount of reccomendations? because whenever i write a method it sometimes seems to just overlap and i dont see what im writing

#

intelij btw

proud basin
#

I know that you can disable that feature

quaint mantle
#

never had any problems with it

#

Do you have 4:e monitor or smrh

tardy delta
#

is this correct english: the player is not in any channels!

crimson terrace
crimson terrace
crude charm
crimson terrace
#

oh ok then. what version would that be?

crude charm
#

1.12.2

crimson terrace
#

damn. I thought I was being smart

#

so RecipeChoice.ExactChoice() isnt a thing?

crude charm
#

It was added in 1.13.2

crimson terrace
#

aight

quaint mantle
#

reject legacy

crude charm
tardy delta
#

reject humanity

#

if a player doesnt have permission to use a command, will a tabcomplete with options be triggered?

plain helm
#

can someone help me testing my plugin?

sharp bough
#

try to use it, it can be really useful if you understand how it works

quaint mantle
sharp bough
plain helm
#

what's funny

tardy delta
#

i was testing my plugin on my server with an alt and now they removed that altmanager :pepe:

plain helm
#

i used to do that too

sharp bough
plain helm
#

jailstick

tardy delta
#

anime girls

sharp bough
#

well you can simulate a player

#

instead of "sending the player to jail" you could try to imagine and follow the steps you are doing

#

and add a command to trigger the event

#

so you can test it on yourself

#

basically you test the first part and then the second with a command

manic furnace
#

How can i add an suffix to a players name with teams and scoreboards?

plain helm
#

i get what you mean

#

ty Lucas

sharp bough
#

np

sharp bough
manic furnace
#

in the 1.17.1

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        ScoreboardManager scoreboardManager = Bukkit.getScoreboardManager();
        Scoreboard scoreboard = scoreboardManager.getNewScoreboard();
        Team team = scoreboard.registerNewTeam("Ducks");
        team.setColor(ChatColor.RED);
        team.setPrefix("[Hi]");
        if (sender instanceof Player) {
            Player p = (Player) sender;
            team.addEntry(p.getName());
            team.addPlayer(p);
            p.sendMessage("Added you to an team!");
        }
        return false;
    }
sharp bough
#

and that doesnt work?

quaint mantle
#

team.setSuffix?

sharp bough
#

docs?

manic furnace
#

no i don't become a suffix or a prefix it just don't change anything

tardy delta
#

do i need to set permissions in my plugin.yml if i create them within my code?

graceful turret
#

how to set skins without leaving the server in 1.17+?

sharp bough
glossy venture
graceful turret
manic furnace
#

sry just tryed something

glossy venture
#

ohk

sharp bough
manic furnace
#

But it don't work with suffix too

young knoll
#

I say you should have them in your plugin.yml so luckperms can tab complete them

graceful turret
#

i want to do something like that: /skin set <Player name> and the skin will be set to command sender without leaving server

graceful turret
sharp bough
graceful turret
sharp bough
#

its a question

#

tf

glossy venture
#

lmao

rotund prawn
#

im learning config.yml file. when i try to get it from other then the main class, it doesnt work. can anyone help me?

glossy venture
#

code?

#

whats the problem

#

like is there an error

spare prism
#

Is there a way to set and get metadata for the itemstack?

tardy delta
#

itemstack.getItemMeta()

glossy venture
spare prism
#

no

#

i mean metadata

glossy venture
#

nbt?

spare prism
#

probably

glossy venture
#

nms

#

not gonna explain it right now

spare prism
#

?

glossy venture
#

idk

#

never heard of it

tardy delta
#

i guess thats dutch

rotund prawn
rotund prawn
# glossy venture code?
package Commands;

import org.bukkit.plugin.Plugin;
import org.bukkit.command.*;
import org.bukkit.entity.Player;

import alma.Tanulas;

public class ConfigTestCommands implements CommandExecutor{

    Plugin plugin = (Plugin) Tanulas.getPlugin(Tanulas.class);
    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        if(cmd.getName() == "ConfigFood") {
            String food = plugin.getConfig().getString("Food");
        
            Player player = (Player) sender;
            player.sendMessage(food);
            
        }
        return true;
    }
}
#

whats that

glossy venture
#

what the hell

tardy delta
#
your stuff here
glossy venture
#

how is your project set up bro?

glossy venture
#

that too

tardy delta
#

is there no codeblock tag or something?

glossy venture
#

?

tardy delta
#

like ? paste

tardy delta
#

nvm

crimson terrace
tardy delta
#

kinda just put java after the backticks

crimson terrace
#
this is a codeblock

tacit drift
rotund prawn
#

?

tardy delta
#

?di

undone axleBOT
crimson terrace
#

actually maybe not

rotund prawn
#

i gtg i look into that anothr tim, thanks

tardy delta
#

hmm (Plugin) and the static singleton goes brr

crimson terrace
#

true

shrewd hemlock
tardy delta
#

java.lang.NoSuchMethodError:

shrewd hemlock
#

but this method exitsts

#

there is #getPlayer and #getEntity

#

or tell me what mehod i need when i want to get the Player out of the PlayerDeathEvent?

tardy delta
#

uhh getPlayer() probably

shrewd hemlock
#

yeah

#

thats what i used

#

and it wont work

wispy bridge
#

Did you replace your plugin jar while the server was running?

shrewd hemlock
#

yes

wispy bridge
#

Mmm

#

Well theres your issue

#

Reload or restart your server

shrewd hemlock
#

and then i shutted the server dfown

shrewd hemlock
wispy bridge
#

Oh, so to clarify, during the run of that log you did not replace your plugin jar?

shrewd hemlock
#

no

wispy bridge
#

Im not too sure then

tardy delta
#

normally you cant replace the server jar when running?

silver shuttle
#

you can not

tardy delta
#

there's a lock on it

wispy bridge
silver shuttle
#

impossible

tardy delta
#

uhh i mean the plugin jar

silver shuttle
#

BileTools does this

shrewd hemlock
#

i mean i drag the jar in and then i restart the server

silver shuttle
wispy bridge
#

You can replace the plugin jar while the server is running, you just cant delete it

tardy delta
wispy bridge
#

Just make sure to reload or restart the server

silver shuttle
silver shuttle
tardy delta
#

ah that way

silver shuttle
#

How it works on Windows:
/b unload (plugin)
Replace plugin in directory
/b load (plugin)

On Linux:
Replace plugin with new plugin
BileTools automatically reloads it

tardy delta
#

cool tho

silver shuttle
#

windows can not remove active files, caused by the NTFS file system (it sucks, ik)

#

ZFS would be cool on windows

crimson terrace
#

can you stagger permissions like you do in a config or do you have to make the perm path as one line?

permissions:
  plugin:
    oneSection:
      onePermission:
        description:
        default:

this is what i mean by staggering

tardy delta
#

mwmw

#

uhh

#

never tried

silver shuttle
wispy bridge
#

Yes it can haha

silver shuttle
#

"this file is currently being used by process ..."

wispy bridge
#

Thats for deletion

#

Replacing should work

crimson terrace
wispy bridge
#

I do it very frequently for plugin jars while the server is still running

#

Windows lets me do it with no problems

crimson terrace
#

it would be very infuriating testing plugins when you have to restart the server every time you wanna give it a new version

wispy bridge
#

Reload?

silver shuttle
#

first it asks for admin perms

#

then this

crimson terrace
silver shuttle
#

it wont let you

wispy bridge
#

Are you trying to replace the entire plugins folder? Or just the jar in it

silver shuttle
wispy bridge
#

Oh thats odd, it lets me do that without asking

shrewd hemlock
#

i found the issue.. thanks for help

silver shuttle
wispy bridge
#

¯_(ツ)_/¯

#

It really helps with the workflow haha

tardy delta
#

lets delete sysroot

#

russian roulette

wispy bridge
#

Take new build > Replace old > Reload > Ez

silver shuttle
#

is your old build loaded at that time?

crimson terrace
#

in Linux terminal: kill 1

wispy bridge
silver shuttle
#

odd

wispy bridge
#

Buuut, without reloading you get alot of no such method errors

silver shuttle
wispy bridge
#

I dont need to, it should be the same

#

Im a bit confused as to what you're trying to do

silver shuttle
#

make a RunTaskAsynchronously with a RunTaskTimer that starts in a newly defined random delay

#

the RunTaskAsynchronously runs every tick, but checks if RunTaskTimer is active

#

by getting its taskid

quaint mantle
#

Run it every tick and calculate period manually

#

that wouldnt lag

wispy bridge
#

If you're doing it async and not looking to do any main thread operations you should be fine

quaint mantle
#

I mean, in most of cases you would just do a single check only

#

even on main thread this is nothing

wispy bridge
#

^

#

You're attempting to run the task again while inside of itself, its not gonna let you do that

ivory sleet
wispy bridge
quaint mantle
#

Also starting a thread is an expensive operation

ivory sleet
#

Yeah although you can have something like a work stealing pool

crimson terrace
#

Is this a proper permissions setup in the plugin.yml or do I have to make every permission with the whole path in front?

permissions:
  plugin:
    oneSection:
      onePermission:
        description:
        default:
      secondPermission:
        description:
        default:
    secondSection:
      thirdPermission:
        description:
        default:
silver shuttle
#

just check for permissions in your command executor .-.

young knoll
#

Once again, you should still have them in your plugin.yml so luckperms can tab complete them

#

Among other things

wispy bridge
silver shuttle
#

player.hasPermission(getString("permissions.admin"))

#

top of my every command

#

getString is a method to get a string from the config

wispy bridge
#

I believe they're just trying to look for a userfriendly way to edit it, not how to actually do it

silver shuttle
#

this is user friendly

young knoll
#

Not really sure why you’d need to make permissions editable

paper viper
#

why would you want perms to be configurable

#

yeah

#

should be plugin

wispy bridge
#

Im not sure either LOL

silver shuttle
crimson terrace
wispy bridge
#

Ohhhhhhh, so you do just want to check if a player has a permission?

#

And thats all?

crimson terrace
#

yeah Im just getting confused doing it myself. pls halp

wispy bridge
#

Player#hasPermission

silver shuttle
#
                Location loc = player.getLocation();
                scheduler.runTaskTimer(myPlugin, task -> {
                    if(loc != player.getLocation()) {
                        sender.sendMessage(getString("messages.tp.cancel"));
                        teleporting.remove(player.getUniqueId());
                        task.cancel();
                        return;
                    }
                }, 0L, 20L);

Why does this cancel immediately?

crimson terrace
#

Im trying to get the permissions in the plugin.yml set up

silver shuttle
wispy bridge
silver shuttle
#

nope 100% not

ivory sleet
silver shuttle
#

i am not touching my keyboard

silver shuttle
ivory sleet
#

ah okay

silver shuttle
#

but why does it cancel immediately

eternal oxide
#

you are comparign two Location objects with !=

young knoll
#

Are locations referentially comparable?

silver shuttle
#

should be

eternal oxide
#

you will also have it randomly cancel due to FP math rounding errors

young knoll
#

player.getLocation returns a clone

silver shuttle
#

also, a location only has world, x, y and z

young knoll
#

No

#

It has pitch and yaw too

wispy bridge
silver shuttle
#

try it

quaint mantle
silver shuttle
eternal oxide
#

Location has pitch and yaw

young knoll
silver shuttle
#

why tf doesnt it show then wtf

young knoll
eternal oxide
#

it has multiple constructors

wispy bridge
#

I might be misremembering

ivory sleet
#

well

#

its just an api object to provide necessary context of the players current location when invoked

young knoll
#

If it wasn’t a clone mutating it would move the player

silver shuttle
#

I am just gonna round to the nearest .2

eternal oxide
#

Don;t compare Locations with !=, don;t even compare them using .equals. As they have doubles, you will rarely ever match two locations. Compare teh getBlockX() etc.

wispy bridge
wispy bridge
#

Then nevermind

ivory sleet
#

if you cache the Location instance of Entity::getLocation it wont be automatically updated sadly

eternal oxide
silver shuttle
#

yeah i did that now

dry beacon
#

Does anyone know why this piece of code doesn't enchant the item? I can't seem to solve this ```java

    toggle = true;
    if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_AIR) {
        player.sendMessage("Left Click");

        // Define values
        ItemStack item = new ItemStack(inHand);
        ItemMeta meta = item.getItemMeta();

        if (toggle = true) {

            // Add glow to item in main hand
            item.addUnsafeEnchantment(Enchantment.WATER_WORKER, 1);
            meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
            item.setItemMeta(meta);

        } else {

            // Remove glow from main hand
            item.removeEnchantment(Enchantment.WATER_WORKER);
            meta.removeItemFlags(ItemFlag.HIDE_ENCHANTS);

        }
    }```
young knoll
#

You have a meta instance, use the add enchant method in that

wispy bridge
#

^

silver shuttle
#

How do I cancel a task after it ran x amount of times?

ivory sleet
#

if (toggle = true) {

eternal oxide
#

count

wispy bridge
ivory sleet
#

will always be true

silver shuttle
eternal oxide
#

yes you can

wispy bridge
#

Why not?

quaint mantle
#

Why so

dry beacon
# wispy bridge ^

I used unsafeenchant because I'm trying to enchant a shield with aqua infinity

silver shuttle
#

lemme show u what i mean

wispy bridge
eternal oxide
#

use a BukkitRunnable and put the int outside the run method

silver shuttle
young knoll
#

The meta method has a Boolean to bypass enchantment restrictions

wispy bridge
#

Yes make sure to do that haha

silver shuttle
wispy bridge
#

Can I see the whole snip?

eternal oxide
silver shuttle
#
                final int delay = getInt("values.delay");
                scheduler.runTaskTimerAsynchronously(myPlugin, task -> {
                    double ssX = Math.round(player.getLocation().getX() * 10) / 10D;
                    double ssY = Math.round(player.getLocation().getY() * 10) / 10D;
                    double ssZ = Math.round(player.getLocation().getZ() * 10) / 10D;
                    Location sLoc = new Location(player.getWorld(), ssX, ssY, ssZ);
                    if(!loc.equals(sLoc)) {
                        sender.sendMessage(getString("messages.tp.cancel"));
                        teleporting.remove(player.getUniqueId());
                        task.cancel();
                        return;
                    }
                    if(delay == 0) {
                        sender.sendMessage(getString("messages.tp.successful"));
                        player.teleport(tp);
                        teleporting.remove(player.getUniqueId());
                        task.cancel();
                        return;
                    }
                    sender.sendMessage(getString("messages.tp.time").replace("%time%", "" + delay));
                    delay -= 1;
                }, 0L, 20L);
silver shuttle
young knoll
#

You gotta use the non lambda version

kindred tusk
#

Hello, I tried my plugin in 1.7.10 and it's working fine but in 1.17 it crash whre the plugin needs to send a command in the console given in a post request here is my crash:
I am using Bukkit.dispatchCommand

eternal oxide
#

prevents re assignment

wispy bridge
#

Yeppers

eternal oxide
#

unless atomic

silver shuttle
#

i tried atomic

eternal oxide
#

use a BukkitRunnable

silver shuttle
#

but i cant compare them

#

without setting them

silver shuttle
kindred tusk
silver shuttle
eternal oxide
#

?

wispy bridge
#

You can store a runnable in a task

silver shuttle
eternal oxide
#

new BukkitRunnable

tardy delta
#

because i cant call event.getRecipients do i need to switch from async chat event to chat event?

young knoll
#

Why can’t you call it

tardy delta
#

Caused by: java.lang.IllegalStateException: Asynchronous getNearbyEntities!

eternal oxide
#

thats not from getRecipients

tardy delta
#

ah uh my mistake i also call that somewhere

young knoll
#

You need to sync back to the main thread for that stuff

misty current
#

does EntityDamageEvent#getDamage() return the value in hearts or health?

young knoll
#

Don’t force the chat event to run sync

wispy bridge
misty current
#

thanks

tardy delta
#

oh ok

young knoll
#

I mean it can probably be over 20

tardy delta
#

so scheduler.runtask

wispy bridge
#

Yeah I rushed to clarify LOL

misty current
left swift
#

BukkitRunnable performed every 1 tick, where I send the packet to players is a heavy load on the server?

ivory sleet
#

no

misty current
#

unless it's a 1GB packet i don't see how it could be that heavy

silver shuttle
wispy bridge
#

cancel()

eternal oxide
#

this.cancel()

misty current
#

both server and client send and recieve many more than a packet per tick so it won't be an issue

young knoll
#

A tick is much shorter than a minute

silver shuttle
young knoll
#

Anyway if it’s just packets you can probably run it async

misty current
#

i meant tick

#

idk why i wrote minute

eternal oxide
silver shuttle
#

ok

misty current
#

player movements by themselves are sent about 80 times per second aren't they

wispy bridge
quaint mantle
#

i Wonder if sending packets async is actually useful

misty current
#

afaik playermoveevent is called multiple times per tick so

ivory sleet
#

yuh

misty current
#

probably many packets per tick are too for movement

quaint mantle
#

Arent they got queued by netty*

young knoll
#

Saves a bit of load on the main thead

silver shuttle
tardy delta
#

Anyone knows how to turn my name in chat red?

spare prism
tardy delta
#

Oh ok

#

Just wondering why my name was red and how to remove it

spare prism
tardy delta
#

Im using a Chatplugin but it goes brr and i couldn't remove the color so that's why

kindred tusk
#

Hello, I am making a new BukkitRunnable and in my run methode I have Bukkit.dispatchCommand and when this is executed the plugin crash and I have this error:

eternal oxide
#

Your runnable is async

kindred tusk
#

at the end I have .runTaskAsynchronously(main.plugin);

eternal oxide
#

you have to jump back to sync to use the API

kindred tusk
#

where main.plugin is the class where I have JavaPLugin

kindred tusk
eternal oxide
rough jay
#

My TabExecutor doesn't work, why?

#

are you sure?

glossy venture
#

how do i run something after all plugins have loaded

#

not enabled

#

but loaded

eternal oxide
#

actually the space after area is the first args

glossy venture
#

no

eternal oxide
#

yes, tabcompleter does not include the command

glossy venture
#

well yes

#

your explanation is scuffed

eternal oxide
#

yes, as soon as you press space, your length is 1

#

but as you havn;t typed anything yet it will be an empty string

rough jay
#

So I need to do this?

public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] args) {
    List<String> lis = new ArrayList<>();
    if (args.length == 1) {
        lis.add("new");
        lis.add("remove");
        lis.add("set");
        lis.add("add");
        lis.add("info");
    } else if (args.length == 4) {
        lis.add("owner");
        lis.add("coowner");
    }
    return lis;
}
glossy venture
#

run after plugins have loaded

tranquil mango
#

How can I check if a player right or left clicked while interacting with an entity?

quaint mantle
#

hello i have problems with hikaricp

#
    public void connectMySQL() {

        String host = getConfig().getString("mysql.host");
        int port = getConfig().getInt("mysql.port");
        String database = getConfig().getString("mysql.database");
        String username = getConfig().getString("mysql.username");
        String password = getConfig().getString("mysql.password");

        HikariConfig config = new HikariConfig();


        config.setMaximumPoolSize(10);
        config.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");

        config.setJdbcUrl("jdbc:mysql://" +
                host + ":" + port + "/" + database + "?useSSL=false");
        config.setUsername(username);
        config.setPassword(password);


        hikari = new HikariDataSource(config);


    }
#

21:47:10 WARN]: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

#

what is wrong

#
    public Connection getConnection() {
        try {
            return hikari.getConnection();
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return null;
    }
plain helm
#

I don’t think it is a class

#

Maybe the Creeper class has a method to get the creeper’s state

#

Or you can just spawn a creeper and spawn a lightning at its location

wary flume
plain helm
#

Since in intellij you can download a plugin that will set up your environment for plugins

ancient plank
#

vs isn't good for java at all kek

wary flume
#

oof im kinda new to java ive tried Python and Js before

quaint mantle
#
  final ItemStack bloodMoonBoots         = addLore(new ItemStack(Material.LEATHER_BOOTS),         "BloodMoon Boots",      cool);```
how do i recreate this line to be unbreakable
manic furnace
#

how can i add a scoreboard to multiple players?

ivory sleet
wary flume
ivory sleet
#

altho java quite enforces oo as opposed to the other two

manic furnace
#

I mean in java code

#

I mean with a plugin

wary flume
ivory sleet
#

its very minimal

#

can you send your class or smtng?

#

and how you use it

#

but the exception hints at your db not being reachable at all

#

maybe passed the wrong credentials etc

quaint mantle
#
 final ItemStack bloodMoonBoots         = addLore(new ItemStack(Material.LEATHER_BOOTS),         "BloodMoon Boots",      cool);```

how do i recreate this line to be unbreakable
ancient plank
#

don't spam young padawan

#

patience is key

foggy estuary
#

?paste

undone axleBOT
quaint mantle
#

am i young padawan

quaint mantle
#

thank you

wary flume
#

Lasse333 making a plugin

sterile token
#

Hi

#

I want to know how does Bungeecord or Spigot event system works. Like how it manage the events calling?

rotund prawn
#

why am i getting these errors? can anyone help?

sterile token
#

Thats not the logger

#

The logger its called, Logger

rotund prawn
#

the exmaple says that it is

#

is just copied it

sterile token
#

Logger logger = plugin.getLogger();

rotund prawn
foggy estuary
#

Does anyone know how to code it so the scoreboard tells you the timer instead of printing it out. Like for example in my code Bank Heist Timer:(whatever time is left)