#help-development

1 messages · Page 1462 of 1

summer scroll
#

i'll give u an example.

covert bluff
#

@summer scroll is this fine?

public final class EZAfkPlugin extends JavaPlugin {
    public static EZAfkManager AFKManager = new EZAfkManager();

    public static Team afkTeam;
    public static Plugin instance;
    
    public static EZAfkManager getAFKManager() {
        return AFKManager;
    }
    
    @Override
    public void onEnable() {
        // Plugin startup logic
        AFKManager.initialize();
        instance = (Plugin) this;
        getCommand("afk").setExecutor(new EZAfkCommand());
        getServer().getPluginManager().registerEvents(new PlayerDamageListener(), this);
        getServer().getPluginManager().registerEvents(new PlayerMoveListener(), this);
        afkTeam = AFKManager.getTeam();
    }
#

ignore afkTeam= AFKManager.getTeam();

#

forgot to remove it

summer scroll
#

oh, you already use singleton, so let's use that i guess.

#

first of all make the variable camelCase.

#

AFKManager -> afkManager

covert bluff
#

there

summer scroll
#

on another class

#

EZAfkPlugin.instance.getAfkManager().getTeam()

#

that's how you get the team

covert bluff
#

also what is singleton?

summer scroll
covert bluff
#

EZAfkPlugin.instsance.getAfkMnager().getTeam() doesn't work

#

'cannot resolve method getAfkManager() in Plugin'

#
public final class EZAfkPlugin extends JavaPlugin {
    public static EZAfkManager afkManager = new EZAfkManager();

    public static Team afkTeam;
    public static Plugin instance;

    public static EZAfkManager getAfkManager() {
        return afkManager;
    }

    @Override
    public void onEnable() {
        // Plugin startup logic
        afkManager.initialize();
        instance = (Plugin) this;
        getCommand("afk").setExecutor(new EZAfkCommand());
        getServer().getPluginManager().registerEvents(new PlayerDamageListener(), this);
        getServer().getPluginManager().registerEvents(new PlayerMoveListener(), this);
        afkTeam = afkManager.getTeam();
    }
eternal oxide
#

take static off the method

summer scroll
#

make it non static

covert bluff
#

i have tried that

#

still says the same thing

eternal oxide
#

it won't

covert bluff
#

i've made getAfkManager() non-static and it still says the same thing

eternal oxide
#

if you are using static access you shoudl not be using instance

covert bluff
#

i meant getAfkManager() sry

summer scroll
#
public static EZAfkManager afkManager = new EZAfkManager();
``` and this one too.
eternal oxide
#

if you use instance you should be grabbing that via a static getter(), then accessing non static methods

covert bluff
#

getAfkManager() was static, it gave me an error saying it can't resolve the method

#

i tried making it non-statica ndi t says the same

summer scroll
#

okay

#

i think you're doing the singleton wrong

#
private static EZAfkPlugin instance;

@Override
public void onEnable(){
  instance = this;
}

public static EZAfkPlugin getInstance(){
  return instance;
}
covert bluff
#

Oh

summer scroll
#

EZAfkPlugin.getInstance().getAfkManager().getTeam()

covert bluff
#

no errors anymore, gonna try it out now

#

@summer scroll

[15:17:50 ERROR]: Could not pass event PlayerMoveEvent to EzAFK v1.0-SNAPSHOT
java.lang.NullPointerException: null
        at me.notprankster.ezafkplugin.events.PlayerMoveListener.onPlayerMove(PlayerMoveListener.java:21) ~[?:?]
#

this is line 21

#
   if (afkTeam.hasEntry(p.getName())) {
summer scroll
#

show more code

covert bluff
#
package me.notprankster.ezafkplugin.events;

import me.notprankster.ezafkplugin.EZAfkPlugin;
import me.notprankster.ezafkplugin.commands.EZAfkCommand;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.scoreboard.Team;

public class PlayerMoveListener implements Listener {

    EZAfkCommand afkCommand = new EZAfkCommand();
    Team afkTeam = EZAfkPlugin.afkTeam;

    @EventHandler
    public void onPlayerMove(PlayerMoveEvent event) {
        Player p = event.getPlayer();

        if (afkTeam.hasEntry(p.getName())) {
            afkTeam.removeEntry(p.getName());
            p.sendMessage(ChatColor.GRAY + "You are no longer AFK.");
        }
    }
}

summer scroll
#

you're still doing the same thing.

covert bluff
#

oh wait

#

oh

#

i am actually very sorry

#

i forgot to change the variable

#

i'm being stupid

summer scroll
#

all good

#

just put it inside the method

#

not on the fields

covert bluff
#

did it, starting now

#
package me.notprankster.ezafkplugin.events;

import me.notprankster.ezafkplugin.EZAfkPlugin;
import me.notprankster.ezafkplugin.commands.EZAfkCommand;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.scoreboard.Team;

public class PlayerMoveListener implements Listener {

    @EventHandler
    public void onPlayerMove(PlayerMoveEvent event) {
        Team afkTeam = EZAfkPlugin.getInstance().getAfkManager().getTeam();
        Player p = event.getPlayer();

        if (afkTeam.hasEntry(p.getName())) {
            afkTeam.removeEntry(p.getName());
            p.sendMessage(ChatColor.GRAY + "You are no longer AFK.");
        }
    }
}

#

like this, right?

summer scroll
#

yes, exactly.

covert bluff
#

works perfectly now, thank you

summer scroll
#

np

quaint mantle
#

I don't think listening to movement is the most efficient way of doing things but oh well

torn shuttle
#

it isn't

#

it's far more efficient to store the location of players, put it in a task and then compare the locations within a repeating task and put them out of afk if the location changed between two checks

#

then put the check at 1s or something

keen kelp
#

how do I set set a player's max health

#

like how many hearts they can have

#

since player.setmaxhealth is deprecated

sullen marlin
#

did you try reading the javadoc

sage swift
#

aren't you supposed to use an attribute now or does that not apply to max health

keen kelp
#

that's right

#

is this not how you do it?

#

player.getAttribute(Attribute.GENERIC_MAX_HEALTH).addModifier(new AttributeModifier("MaxHealthModifier", maxhealth, AttributeModifier.Operation.ADD_NUMBER));

hybrid spoke
#

yeah thats exactly what the javadocs says

summer scroll
keen kelp
#

but I get errors? :/

summer scroll
wraith apex
#

Bukkit.getPlayerByName()

dusty herald
#

wtf is that function

dusty herald
wraith rapids
#

there's Bukkit.getPlayer(String)

visual tide
#

is doing ```java
Bukkit.getPluginManager().addPermission('myplugin.something')

mandatory?
#

ok ty

#

so putting them in my plugin.yml is enough then

#

and another question, is using permission: for each command (like so)

commands:
    mycommand:
        description: Returns a helpful message with details about each command.
        permission: myplugin.mycommand
    myothercommand:
        description: Returns a helpful message with details about each command.
        permission: myplugin.myothercommand

or with an if in the code

if (!player.hasPermission('myplugin.mycommand')) {
    player.sendmessage('you aint got perms for this bud')
}

better?

wraith rapids
#

include it in plugin.yml

#

including it in plugin yml sets it as the required permission of the PluginCommand object

#

which allows the /help list to make informed decisions on whom to show the command to, and so on

#

it allows programmatic access to the information, which is better

visual tide
#

ok ty

wraith rapids
#

checking the permission in the command is also redundant unless you want to do something fancy with no-perms failure

#

as the server will check whether a commandsender has the required permission before invoking your command executor

#

and if not, it will print the no-permission message

#

i don't remember if you can customize that in plugin.yml

visual tide
#

ok thanks!

visual tide
wraith rapids
#

i don't know actually

#

it would make sense for it to do that

#

but bukkit and making sense don't always go hand in hand

wraith apex
wraith apex
wraith apex
#

the permission here is just permission to execute the command

#

If you want permission to be enforced for tab complete, you'd have to use the line of code you suggested above in the onTabComplete method

visual tide
#

ok

wraith apex
#

I've never actually bothered with the plugin.yml permission attribute for each command

#

seems like an unnecessary form of double data entry

wraith apex
sullen marlin
wraith rapids
#

as long as you register them somehow be it through plugin.yml or at runtime, it's fine

#

but again, if you don't register a permission to a command, /help lists and shit will display your commands to people who should not have rights to use them, and that can lead to quite a bit of butthurt among admins

#

plugin.yml would generally be preferred over registering them at runtime, as it sort of acts as built-in documentation for all of your commands and permissions

visual tide
#

can you set different permissions for subcommands
as in you need myplugin.mycommand.* to do everything with /mycommand
but you only need myplugin.mycommand.something to do /mycommand something

wraith rapids
#

not through the plugin.yml no

visual tide
#

ah

wraith apex
wraith rapids
#

yeah, plugin.yml doesn't acknowledge the concept of subcommands

wraith apex
#

^

wraith rapids
#

the command system in general doesn't

#

not sure about brigadier, it might

visual tide
languid geode
#

In the terms of material of an itemstack would AddTypeOfInterest or AddMaterialOfInterest which one of the two is beter

#

because im thinking Type is unambiguous

wraith apex
#

Usually why I would just add permissions in code

wraith rapids
#

and you would get yelled at by admins for not registering them properly

#

f.e worldedit not registering its permissions to its commands and shitting up every server's /help list is a permanent source of ass pain for everyone

#

not providing programmatic access for other plugins and the server to see which commands require which permissions is bad practice

#

it "works" but it's not good

wraith apex
#

Well...

wraith rapids
#

if you absolutely don't want to use the plugin.yml, register the permission at runtime in your source

wraith apex
#

there technically is a way to 'grab' all the permissions

wraith rapids
#

only if the permission is declared somewhere

wraith apex
#

it's not great though

wraith rapids
#

that is, if you have registered a command to have that permission

#

or done new Permission() and registered the permission itself

wraith apex
#

then its easy to find them

wraith rapids
#

the commands yes

wraith apex
#

this.getCommand()

wraith rapids
#

but if you don't associate the fucking permissions with the commands

#

the server can't tell what the permission is

#

do you get my drift

wraith apex
#

oh yeah

#

ofc

#

LuckPerms does a thing for generating a perm tree

wraith rapids
#

the server can't tell if you're doing .hasPermission(string) somewhere in your code

wraith apex
#

Never bothered to look into it too much though

wraith rapids
#

for programmatic access, you must either register a permission, or set your command to use a permission

wraith rapids
#

no it can't

#

you would literally have to decompile the jar and look for strings

wraith apex
#

I meant a plugin could be designed to find such permissions

wraith rapids
#

it still can't

wraith apex
#

like luckperms

wraith rapids
#

that is a permissions plugin, it can check calls to it yes

wraith apex
wraith rapids
#

but you shouldn't rely on that

#

the 2 ways to do it are to
1 look at the bytecode of the jar, looking for calls to Permissible::hasPermission(String)
2 be the permission plugin and record all of the checks made to your permissible impl

#

nobody in their right mind would do 1

#

and you shouldn't rely on 2

wraith apex
#

In theory, you could inject an event after a .hasPermission

#

and retrieve the string

wraith rapids
#

and nobody does that

#

just register your permissions

wraith apex
#

and you would know this how?

wraith rapids
#

and even if someone does that

#

you shouldn't rely on it

#

because it's not part of the API

#

don't rely on the permission implementation, rely on the API

wraith apex
#

but 2 gives a much more accurate tree of permissions

wraith rapids
#

it gives just as accurate of a tree as registering them properly

wraith apex
#

than just reading the base permissions for each main command

#

plugin.yml cannot register sub command permissions...

wraith rapids
#

doesn't matter

#

and again, even if it does it better, it's not api

wraith apex
#

Kind of does?

wraith rapids
#

you shouldn't rely on it

#

it doesn't

#

just register your permissions

wraith apex
#

can't really register multiple permissions if they're not supported...

wraith rapids
#

you can register as many permissions as you want

wraith apex
#

if the API doesn't support them, people will look elsewhere

wraith rapids
#

new Permission().register()

#

or you can declare them in your plugin.yml

#

anyways, i'm off, got stuff to do

#

bottom line is: don't be a retard, register your perms, use the api like it's intended, don't rely on some arbitrary impl

wraith apex
#

register is not actually a method

#

for the class Permission

solemn glade
#

I don't know what I'm doing wrong. Can one of you nice people help me figure this out? When I reload the plugin it doesn't kill me.

wraith apex
#

Are you trying to write a command?

#

This is not how you do it

solemn glade
#

No I'm trying to figure out how to make methods

wraith apex
#

ok

#

what method do you want

solemn glade
#

myMethod() string of code that kills me

#

So if I type myMethod(); anywhere in the code it kills me

wraith apex
late ledge
#

Is there a way in java to override methods in objects that are created using the builder pattern?
Lets say I have a Car class with a CarBuilder inside of it (public static). the .build() method on the builder instantiates a Car from a private constructor. Now I would need to override some methods in the Car class. I don't want to pass any code as argument (bifunctions and the like). I personally think it is not possible while still adhering to the OOP style but if anyone has an idea: shoot

visual tide
#

can i add several permissions to a command and require any of them in my plugin.yml?

wraith apex
#

nope

#

command class seems to only allow one permissions to be registered with it

#

:c

late ledge
# solemn glade So if I type myMethod(); anywhere in the code it kills me

make the method

myMethod(Player player) {
    player.setHealth(0);
}

Listener classes are for events however, there is no need to have static methods in them. If this is for testing purposes, make a TestUtils class for it.

If you cannot get a Player object, modify the code like this:

myMethod() {
    Player player = Bukkit.getPlayer(<insert username>);
    player.setHealth(0);
}
wraith apex
#

so for every logic implementation I just do a .hasPermission

vestal dome
#

When you send a plug-in message from the bungeecord to the spigot and vice versa, is there a chance that message could be leaked or reed from another server/player?

visual tide
late ledge
#

yep

wraith apex
late ledge
#

do it in onCommand

wraith apex
#

^

#

some people in code love to do a long if or switch statement

#

checking for args

#

or even command name 🤷‍♂️

vestal dome
wraith apex
#

haha, you can if you want to

visual tide
late ledge
#

ooooorrrrrrr, you could use the MmCommands command framework 😉

#

but it doesnt support multiple perm nodes at this time so doesnt really solve the issue

visual tide
wraith apex
#

one command per class

visual tide
#

ok

wraith apex
#

makes it a lot easier to find

late ledge
# visual tide dont you have to do that if you have several commands in a class

example of how I do my perm checking on commands

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player)) {
            sender.sendMessage("Only a player can do this.");
            return true;
        }
        Player player = (Player) sender;
        if (!player.hasPermission("enchantgui.use")) {
            player.sendMessage("§4§lERROR§8 » §7Insufficient permission.");
            return true;
        }
        String world = player.getWorld().getName();
        if ((getMainConfig().isBlacklist() && getMainConfig().getWorlds().contains(world)) ||
                (!getMainConfig().isBlacklist() && !getMainConfig().getWorlds().contains(world))) {
            player.sendMessage("§4§lERROR§8 » §7EnchantGui is disabled in this world.");
            return true;
        }

        new VirtualEnchantTable(player);
        return true;
#

I am aware color codes are not done properly. its a very old plugin.

tired spoke
#

what is the difference between return true and false?

late ledge
#

in the onCommand method?

tired spoke
#

in the plugin

#

when i need to use false and when i need to use true?

late ledge
#

true means: Command executed successfully. false means Command failed. If false is returned, the usage parameter from the plugin.yml will be printed to the user

#

I always return true because I handle displaying the usage myself

eternal oxide
#

correctly list your commands in your plugin.yml and have one class per command and you don;t need to do any permission checks.

tired spoke
#

i was watching the bedwars1058 author working of the plugin and he uses only return true

#

in his pl.yml not have commands

eternal oxide
#

why not?

late ledge
#

That is because they handle displaying the correct info themselves. You only return false if you want bukkit to display the usage

tired spoke
#

they are all in the java classes

late ledge
tired spoke
#

like: cmdgui.class and is /bw gui command

late ledge
#

the /bw command then has to be in the plugin.yml

summer scroll
#

are they using like precommand event thing?

eternal oxide
#

Use the command system correctly and you remove a lot of hassle

#

so sub commands

late ledge
summer scroll
#

each class per subcommand is gud

tired spoke
#

probabbly yes

late ledge
#
  • it allows you to display errors that fit your plugin style instead of the default errors
tired spoke
#

because there are 2 types of commands, the reguare and admin

#

regular*

eternal oxide
#

yep, have the bw command in the plugin.yml and a permission to use it, then you manually check child command permissions.

tired spoke
#

for example: in pl.yml i set bw and a perm like bw.player
and bw.admin for admin commands?

late ledge
#

yep

#

If you want to dig into subcommands

tired spoke
#

probabbly i don't publish the original plugin because it's privaye, but i can create a little versions for all users

summer scroll
young knoll
#

You can also use a command framework

late ledge
#

mine is an API xD its not an implementation

tired spoke
#

for add like PlaceholderAPI placeholders

#

there is a guide?

summer scroll
#

full explanation on their wiki

late ledge
#

start here

lucid hound
#

My tnt duper breaks whenever I leave the chunks any way to fix it?

opal juniper
#

wrong chat

late ledge
#

and if it is a vanilla duper, better just look it up on youtube

lucid hound
#

Ok

#

Thnx

sullen dome
#

maybe dumb question but... is String#contains case-sensitive? if yes, how to use it ignoring the case?

vestal dome
#

Hey look at the documentation?

eternal oxide
# vestal dome .

messages are send unencrypted and there is no authentication on the channels, so yes a message could be intercepted

sullen dome
#

not really giving me the answer tho

vestal dome
#

I do think it is not case sense tive

#

Why don't you test it?

sullen dome
#

because it needs 5 minutes to compile

#

and it would save time

eternal oxide
#

contains IS case sensitive. use a toLowerCase first

sullen dome
#

alright. thanks bud

eternal oxide
sullen dome
#

did i ever say i hate mysql? if not:

i hate mysql

vestal dome
#

How can you intercept the message...

eternal oxide
#

listen to the channel

#

all plugins have access they only need know the channel key

vestal dome
#

Yes that is true... But I'm talking about notnplugins

eternal oxide
#

in fact you could probably even read the channel

vestal dome
#

But the player....

eternal oxide
#

a vanilla client? no

#

modded, yes

vestal dome
#

Is there a way to cancel a modded player from receiving the message then?

sleek pond
#

you might be able to tell wether they are modded

#

and then maybe not send a packet

eternal oxide
#

You can, but its not that simple

#

they can fake it

vestal dome
#

Can't you use e.setCancelled

eternal oxide
#

no, thats server side

vestal dome
#

I want to cancel a message from a spigot server reaching the player thru a bungeecord

#

Can't the bungeecord cancel the packet.

languid geode
#

pretty darn sure there is an event for that but dont quote me on it

eternal oxide
#

You are going to have to give more detail here. More than just a packet

vestal dome
#

the idea is simple...

#

When a player joins the bungeecord, the bungeecord sends a message to the spigot server authenticating the user and then the spigot sends back to bungeecord to authenticate the user, like a NoProxyJoin plugin, but the thing that I'm scared is about this key getting stolen.

sleek pond
#

you want a specific player to not receive a message, correct?

#

also

#

blocking modded users from joining is a very bad idea

#

most everyone uses at least some performance enhancing mods

#

such as sodium or optifine

vestal dome
sleek pond
#

well

#

you are conveing your idea very badly then

#

because no one understand what you want

vestal dome
#

I don't want them to steal the code that is on the plugin message.

#

I've even encrypted it etc, etc, etc.

#

the idea is to prevent the message from being stolen... that's it

eternal oxide
#

Yeah, we have no idea what packet you want to block

tribal holly
#

why setDisplayName on a player don't work ? is it only reserv for mob ?

sleek pond
tribal holly
#

i setDisplayName("something") but nothing change

vestal dome
#

from the spigot to the bungeecord

#

I want to prevent it from being reed by modded clients

sleek pond
#

?paste

queen dragonBOT
tribal holly
#

player.setDisplayName("test");

#

nothing else

sleek pond
#

hmmm

#

it should work

vestal dome
sleek pond
#

are there any errors?

tribal holly
tribal holly
vestal dome
#

setDIsplayName never worked for me neither so..

paper viper
tribal holly
#

not weird at all

#

i wanna add color to the pseudo of the player above his head

sleek pond
#

i believe there is like .setName

#

or somehting

vestal dome
#

...

vestal wharf
#

how do i cancel certain packets?

#

also why am i getting this error

paper viper
#

ProtocalLib

#

then intercept packets

vestal wharf
#
[17:35:09 WARN]: The exception was: java.net.BindException: Address already in use: bind
[17:35:09 WARN]: Perhaps a server is already running on that port?
[17:35:09 INFO]: Stopping server
[17:35:09 INFO]: Saving players```
paper viper
#

^

vestal dome
#

"Failed to bind port"

tribal holly
#

jadss be more gentle

vestal dome
#

sorry I got PISSED.

tribal holly
#

so don't answer

#

and let other do

paper viper
#

you shouldnt be pissed cause of the code you used to write that was horrible lol

vestal dome
#

we don't talk about that..

vestal wharf
#

how to fix it i closed all terminals where i ran the test server

lunar schooner
#

Hey there, quick question. What class should I be looking at for spawning particles client side only? I couldn't find any class with 'Particle' and 'Packet' in it's name in the net.minecraft.server package in Spigot

vestal dome
#

tho not pissed about that, AT ALL.

vestal wharf
#

sorry for being a idiot

paper viper
#

or activity moniter (mac)

vestal wharf
#

ok

paper viper
#

or by a command on linux

eternal oxide
lunar schooner
sleek pond
#

what do you mean clientside?

lunar schooner
#

I need to spawn a particle only visible to one person, i.e the client

sleek pond
#

you can send a particle packet

#

is a thing I think

paper viper
#

i despise you

lunar schooner
#

Yeah thats what I was looking for, but I couldnt find a class named anything with particle and packet in the same name in the decompiled Spigot

sleek pond
#

plz help

#

what was te website with all the packets

vestal dome
#

...

sleek pond
#

or is that correct?

tribal holly
paper viper
#

^

sleek pond
#

oh

#

i see

tribal holly
#

complicated....

eternal oxide
#

PacketPlayOutWorldParticles

lunar schooner
#

O.o thanks

sleek pond
lunar schooner
#

Odd that that didnt show up when I searched in jdgui

paper viper
#

do you actually decompile the server jar 👀

lunar schooner
#

yeah

paper viper
#

pretty sure IDE's have it built in

lunar schooner
#

Not really

#

Well they do, if you use the non -API dependency

paper viper
#

For intellij it is built in

#

wait what you use the jar?

#

🥲

lunar schooner
#

No

#

I use the maven dependency

#

which does not include the server's source :"D

paper viper
#

Well uh, dont you need the nms anyways if you are working with packets?

#

or the spigot artifact

lunar schooner
#

Nope

#

I do everything with reflection

paper viper
#

That is absolutely cursed

#

man

lunar schooner
#

nah

tribal holly
#

i don't understand i have teams link all to the same scorboard, when i try to set prefix and add a player to a team nothing change on his display name above head ? someone know why ?

lunar schooner
#

I've written some utils for it to make it pretty easy 😄

tired spoke
#

someone can give me the name of this colors:
Purple,
Gold,
Magenta,
Black,
Cactus Green (Dark).

#

for a bedwars plugin

paper viper
#

what you gonna do

lunar schooner
#

I just update the plugin 🙂

tired spoke
paper viper
#

No, im talking about the actual packet itself

lunar schooner
#

but it is less updating than depending directly on the specific dependency

#

Since then I'd have to update every release due to the versioned packaging

#

Now it's just whenever mojang changes something I use

ivory sleet
#

reflection is slow tho

lunar schooner
#

depends

ivory sleet
#

invocations are slow I should say

lunar schooner
#

I do most things statically, so it is only done once when the classloader first loads the class

lunar schooner
#

Working on getting it on MavenCentral 🙂 For now you can use jitpack

paper viper
#

Just saying, working with the actual code is going to significantly faster compared to actual method calls even when you are caching the Method. It is bad for packets because you are going to have a bigger delay before sending the actual packet

ivory sleet
#

Yes you can cache reflective objects but you cant cache Method#invoke or Constructor#newInstance (not talking about the result) and yes its optimized by JIT but even so a hunk of abstraction layers are faster

lunar schooner
#

Yup true, I try my best with most things

#

but I'm not out seeking every last milisecond here 😄

paper viper
#

Reflection should be only used to do impossible things.

ivory sleet
#

🥲

paper viper
#

But this isn't... impossible

#

its just a hack

ivory sleet
#

lel

#

mml and its 20 nms modules

wraith apex
paper viper
#

Because I support 1.8 lmao

wraith apex
#

not really?

paper viper
#

compared to method calls

#

normal method calls

wraith apex
#

right, 100% slower, it will take twice the time. In terms of miliseconds, it's still not noticeable

lunar schooner
#

I use reflection quite a lot, even outside Minecraft. E.g last week I build a class validator for when working with json deserialization, reflection is necessary then

ivory sleet
#

that entirely depends on context and how much you use it logicaldark

paper viper
wraith apex
#

Not using reflection because it is 'slower' is a bad reason

wraith apex
paper viper
#

Yeah idk what you are saying lmao. Using reflection for hacks are not good at all

#

It's slower too

#

and less readable

ivory sleet
#

Attempting to optimize performance in terms of speed isn't bad if it isn't diminishing that is

wraith apex
#

The point is reflection is still a useful tool that you shouldn't just throw away because hurr durr it takes a little bit longer

paper viper
#

since when did we ever mention that

lunar schooner
#

Reflection isn't always used for a hack though. Take e.g Google's Gson, it would not be possible without reflection

paper viper
#

We just said that for this use case

#

you shouldnt do it

wraith apex
#

You use reflection when you have exhausted other faster methods

wraith apex
#

right

lunar schooner
#

Sure it's a bit slower, but it has its purposes. Reflection is useful when there are no other routes to use

wraith apex
#

^

paper viper
#

But there are other routes...

wraith apex
#

That was my point

#

ik I'm bad at explaining that haha

ivory sleet
#

Idk what your point was really

paper viper
#

We literally already stated that in the beginning to only use reflection for doing impossible stuff

lunar schooner
paper viper
#

please consider reading up man

#

lmao

summer scroll
paper viper
#

wdym

tribal holly
#

?

paper viper
#

im confused by what you're asking

#

spigot api has it built in too

lunar schooner
wraith apex
#

You wanna add colour to the players name?

lunar schooner
tribal holly
#

yep

wraith apex
#

easy

tribal holly
#

nice to know but how ?

sudden grail
#

hello

#

someone help me

paper viper
wraith apex
#

You can use scoreboards

#

to give them a coloured name

tribal holly
#

i already use it

sudden grail
#

help

wraith apex
#

ok?

#

then what's the problem

sudden grail
#

uhhh.

#

ok

#

i will

#

uhh.

#

how to give permisson

#

permission

#

:0

lunar schooner
tribal holly
#

dude make a fu*** one message

sudden grail
#

my plugin kitpvp who no have op he cant use for no reason

#

please help

paper viper
sudden grail
#

anyone

lunar schooner
#

Fair point, but I like that puzzle

sudden grail
#

help

#

😦

wraith apex
#

dude

#

shutup

sudden grail
#

:0

#

why

paper viper
#

at that point, you mine as well use NMS

sudden grail
#

he give me this link

paper viper
#

I see no point otherwise

wraith apex
#

there are other people who also need help

lunar schooner
#

I can usually figure things out by looking at the server source 😄

wraith apex
#

you sound entitled

sudden grail
#

ok

#

i will wait

tribal holly
#

i will come back ask support when child will go to the bed

wraith apex
#

but his name doesn't have the prefix

tribal holly
wraith apex
#

above his head

tribal holly
#

and it don't work

sudden grail
#

i dont know

#

Zuzzymc give me this link discord

#

and he said go ask in help development

#

:0

wraith apex
#

If you're developing a plugin

#

you ask for help in here

#

if you're not a dev, you ask in help-server

#

for help with using a plugin

sudden grail
#

oh

#

:00000

#

tahnk sir.

summer scroll
tribal holly
#

that depend how many times do you call it

#

and if the call is async or not

summer scroll
#

every player has a player data.

#

i call it onDisable.

#

so it can't be async i guess?

wraith apex
#

it could be

tribal holly
#

onDisable i don't think so

#

but it could yes

wraith apex
#

anything that is not bukkit

#

or doesn't touch bukkit

#

can be made async**

tribal holly
#

but it's onDisable no really need to here

#

unless he want to do multiple things on it

wraith apex
#

If you want to get efficient, you could queue updates to the database when a player does something that requires a change in the database

#

after x number of minutes, commit the update

tribal holly
wraith apex
#

that way you don't have to do a massive loop and save when the plugin gets disabled

wraith apex
#

I would say keep it open during plugin use and then close it when its disabled

tribal holly
#

tips made it async if later you wanna implement some kind of auto-save

quaint mantle
#

I'd say just save their data as soon at it arrives

wraith apex
#

you're hammering the sql server

summer scroll
tribal holly
#

not a good idea it's better to load localy the data and after process send it back

quaint mantle
#

Oh he's saving like that.

tribal holly
#

SQL request take a lot of time

quaint mantle
#

I'm just saving data every time my minigame's onFinish() method is ran & only saves the players that took part of this game

#

Use HikaryCP

#

or whatever it's called

tribal holly
echo basalt
quaint mantle
#

I hate this

summer scroll
tribal holly
quaint mantle
#

Saving on disable is usually not great lol

echo basalt
#

From my tests, connection time was about 1s, while sending the data took like 50ms

quaint mantle
#

What happens when your server crashes? all their data is gone

tribal holly
tribal holly
#

here he only want to save data on unLoad that's all

summer scroll
#

i'll take some advice too

echo basalt
summer scroll
#

if it's not good and can cause issues, i'd love to know

tribal holly
#

yep this is very long

wraith apex
echo basalt
#

But still that 1s connect time caused some dupes on my plugin :p

wraith apex
#

depending on the queue delay

quaint mantle
#

???

summer scroll
#

i always use async if it's not onDisable

echo basalt
#

As I was syncing items

wraith apex
#

they don't loose 'all' their data

quaint mantle
summer scroll
#

i also save every player quit the server

quaint mantle
#

oh okay

wraith apex
#

No, I'm not talking about his solution

#

haha

quaint mantle
#

If the data comes in at a relatively slow rate I'd say just save it on the spot

wraith apex
#

You sort of have a 'Bean' object to hold this information

summer scroll
#

ah, like create another hashmap

wraith apex
summer scroll
#

and when player transfer balance

#

to another player, put them on hashmap and the amount of coins

#

that works?

quaint mantle
#

no because in my case you don't do some queue shit beforehand 🤔

wraith apex
#

no, you just want to hammer the sql server

#

despite those sort of requests taking time

quaint mantle
#

I said if the data comes in a t a relatively slow rate

#

e.x: at the end of minigames

wraith apex
#

yeah if it comes in a slot rate, that's not a problem, it doesn't do so well for when it comes in quickly

quaint mantle
#

yeah so it just comes down to how he's structured the project

#

Regardless of all that, use HikariCP

wraith apex
#

Ideally you would allow x number of sql operations per second, and do it on another thread to stop the server being overwhelmed with requests

#

the idea of the Bean object is that if a player is just changing 1 variable constantly, it makes no sense to also constantly update it in the database

#

wait for the variable to settle or when x minutes have passed

quaint mantle
#

yeah plenty of options there

#

again, just depends on his server

wraith apex
#

Slaps SQL server You can fit so many statements in here

lapis pollen
#

hey

#

I already have my account verified on spigot

eternal oxide
#

I believe the name must match

lapis pollen
quartz anchor
#

donate to change

quaint mantle
#

stupid question, what event is fired when rightclicking an item?

#

( bone )

tribal holly
#

Hi ! So i'm trying to set a prefix to player (player tag above head) that join a team but when they join the team with prefix of set nothing change:
Here the declaration of the the team :

private void build() {

        this.team.setTeam(scoreboard.registerNewTeam(getTeamEnum().getName()));
        this.team.getTeam().setAllowFriendlyFire(GameSettings.FRIENDLY_FIRE);
        this.team.getTeam().setColor(this.getChatColor());
        this.team.getTeam().setPrefix(this.getPrefix());
        this.team.getTeam().setSuffix(this.getSuffix());
        this.team.getTeam().setOption(org.bukkit.scoreboard.Team.Option.COLLISION_RULE, org.bukkit.scoreboard.Team.OptionStatus.NEVER);
        this.team.getTeam().setOption(org.bukkit.scoreboard.Team.Option.DEATH_MESSAGE_VISIBILITY, org.bukkit.scoreboard.Team.OptionStatus.NEVER);
        this.team.getTeam().setOption(org.bukkit.scoreboard.Team.Option.NAME_TAG_VISIBILITY, org.bukkit.scoreboard.Team.OptionStatus.ALWAYS);

    }

and here the method when i add a player to a team :

public void addPlayer(UUID uuid) {

        Player p = Bukkit.getPlayer(uuid);
        if (p != null && !hasPlayer(uuid)) {
            getPlayerList().add(uuid);
            this.team.getTeam().addEntry(uuid.toString());
            p.setPlayerListName(getPrefix() + p.getName() + getSuffix());
            p.setScoreboard(scoreboard);
            playerStatusList.put(p.getUniqueId(), PlayerStatus.ALIVE);
        }
    }```
just adding that scoreboard is a scoreboard share for all teams color
And of course i check if the prefix value is not empty or null and i confirm there is prefix value
quaint mantle
#

thx 🙂

tribal holly
#
this.scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();```
#

i remove it from the method addPlayer but i can add it in it

#

i made some test with a addPlayer to the score board it change nothing

twilit rivet
#

Is there an event to get any "/command" a player is running, like there is for the AsyncPlayerChatEvent?

#

cheers

tribal holly
#

i add it to the method and nothing change

#
 public void addPlayer(UUID uuid) {

        Player p = Bukkit.getPlayer(uuid);
        if (p != null && !hasPlayer(uuid)) {
            getPlayerList().add(uuid);
            this.team.getTeam().addEntry(uuid.toString());
            p.setPlayerListName(getPrefix() + p.getName() + getSuffix());
            p.setScoreboard(scoreboard);
            playerStatusList.put(p.getUniqueId(), PlayerStatus.ALIVE);
        }
    }
queen dragonBOT
tribal holly
#

this problem begin to blow my mind

#
 public void setupTeams() {

        teamList.add(new Team(TeamsEnum.RED, this.scoreboard));
        teamList.add(new Team(TeamsEnum.BLUE, this.scoreboard));
        teamList.add(new Team(TeamsEnum.GREEN, this.scoreboard));
        teamList.add(new Team(TeamsEnum.YELLOW, this.scoreboard));
        teamList.add(new Team(TeamsEnum.SPECTATOR, this.scoreboard));
        teamList.add(new Team(TeamsEnum.MINOS, this.scoreboard));

    }```
proper notch
#

btw you can do

for (TeamsEnum teamsEnum : TeamsEnum.values)
  teamList.add(new Team(teamsEnum), this.scoreboard);

if you wanted to make that cleaner.

tribal holly
#

well see i change to this

#

thx

tired spoke
#

someone know how to set a lobby-fly? the fly for only the world where i have set the bw-lobby

tribal holly
#

well i agree but that don't change the problem of prefix

tribal holly
tired spoke
#

with a perm?

#

because i want that only vips can do

tribal holly
#

add a check

#

where can i put this so ?

#

i need to add it on a join team "event"

#

and even if i move it i don't understand why it don't work

tired spoke
#

§ and with this and tag a i can set a color console message?

#

and chat msg

lucid hound
#

Why the tps is so low I mean like eating takes so long

#

And mobs don't tick fast

#

Any fix?

tribal holly
rigid otter
#

Hello! How to get net.minecraft.server.* in project maven repository that compatible with what I get spigot-api?

eternal night
#

usually you want to depend on spigot instead of spigot-api

rigid otter
#

Orr ok

eternal night
#

note tho that you will need to run build tools for the specific version of the api at least once before actually compiling the project

#

spigot cannot distribute the spigot maven dependency which includes net.minecraft.server on its own, so this is sadly the only way to install it onto your computer

rigid otter
#

Ahh, so I need to use a library instead of using repository in pom.xml?

eternal night
#

well no, just the reference itself is fine

#

maven will check your local maven repository (which build tools installs it into)

rigid otter
#

Ok, thank you!

jagged badge
#

I have a runnable bukkit in a wall class. And I would like to get my wall object (this) in this runnable. But here this will refer to the runnable and not to the wall. Is there any way to get my wall without storing it somewhere?

  public void run() {
    ....
    WallManager.getInstance().destroyWall(this (##THE WALL##) );
    ....
  }
}.runTaskTimer(ac, 0L, 5L);```
eternal night
#

the one you want to reference using this

jagged badge
#

Wall

eternal night
#

Wall.this.myMethodName()

#

would work then

#

to call a method in the class Wall

jagged badge
#

it's not a methode from class wall. It's a method from the class WallManager.
In class Wall, I want to use a WallManager methode:
public void destroyWall(Wall wall) {}
but Wall.this should work 🙂

#

thx

eternal night
#

Yeah was more of an example xD

sharp bough
#

could someone point me in a better direction to do this? https://paste.md-5.net/wijuxoyihe.cs
its X locations each location has 4 values and they might change depending on the other 3 values, theres a constant cooldown on timeLeft, unless the other 3 values fulfill a certain condition, i have no idea how to improve this

eternal oxide
#

getSpawned should really be isSpawned

sharp bough
#

hm yea

#

still i feel like this is really bad for the server

#

like a lot of calls, conditions, a constant cooldown

twilit rivet
#

Is there a way to use an if statement for an event? The code I have now is ```java
@EventHandler
public void onPlayerMessage(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
data.addChat(player.getName(), player.getUniqueId(), event.getMessage());
}

@EventHandler
public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
    Player player = event.getPlayer();
    data.addChat(player.getName(), player.getUniqueId(), event.getMessage());
}
sharp bough
#

you could register both events and make them run the same function

#

or class idk

eternal oxide
sharp bough
#
  '1':
    world: world
    X: -329.95103133350807
    Y: 106.0
    Z: 134.54906892122315
    spawned: false
    unlocked: false
    clicked: false
    timeleft: 0```
#

up to 28

#

wait i forgot to add the return on the conditions, that should help too

sharp bough
#

oh wow continue is so cool

#

never used that lol

#

thank you

eternal oxide
#

rename getSpawned to isSpawned and getUnlocked to isUnlocked and its much more readable.

sharp bough
#

ok

eternal oxide
#

How often are you running that? Once per minute?

sharp bough
#

once a second

#

its a cooldown

#

so im trying to make it as friendly as possible

weary geyser
#

Wait your getting from the config once a second without caching?

sharp bough
#

wdym

weary geyser
#

Are you getting stuff from the config

sharp bough
#

yea

weary geyser
#

Directly

#

?

eternal oxide
#

Doesn;t matter, config is just a map access

sharp bough
#

jez

weary geyser
#

okay

sharp bough
#

this bot is so annoying lol

#

i will add a try and catch later tho

#

rn i know exactly what im working with so i just want to make it work

eternal oxide
#

yep, get it to work first is always a good plan 🙂

eternal oxide
tribal holly
#

do you see the message or did i need to repost ?

eternal oxide
#

Ok, its a simple task with teams

tribal holly
#

what do you mean ?

eternal oxide
#

adding a prefix to the players name over their head

tribal holly
#

yep ?

eternal oxide
#

I'll show you it working, then give you the code

#

?paste

queen dragonBOT
eternal oxide
tribal holly
#

yep but i do the same thing

#

i don't understand why mine don't work

eternal oxide
#

show me some code.

tribal holly
#

all in the first message

eternal oxide
#

You are only setting the playerListName

#

you need to team.setPrefix

tribal holly
#

addEntry don't ass the player to the team ?

eternal oxide
#

You havn't set the prefix on the team

loud swift
#

Could anyone tell me how persistent data holder works internally?
Does it load the data from a file each time the holder is loaded into the server and store it to the file every time its unloaded?

tribal holly
#

i do inside the build method : ```java
private void build() {

    this.team.setTeam(scoreboard.registerNewTeam(getTeamEnum().getName()));
    this.team.getTeam().setAllowFriendlyFire(GameSettings.FRIENDLY_FIRE);
    this.team.getTeam().setColor(this.getChatColor());
    this.team.getTeam().setPrefix(this.getPrefix());
    this.team.getTeam().setSuffix(this.getSuffix());
    this.team.getTeam().setOption(org.bukkit.scoreboard.Team.Option.COLLISION_RULE, org.bukkit.scoreboard.Team.OptionStatus.NEVER);
    this.team.getTeam().setOption(org.bukkit.scoreboard.Team.Option.DEATH_MESSAGE_VISIBILITY, org.bukkit.scoreboard.Team.OptionStatus.NEVER);
    this.team.getTeam().setOption(org.bukkit.scoreboard.Team.Option.NAME_TAG_VISIBILITY, org.bukkit.scoreboard.Team.OptionStatus.ALWAYS);

}```
eternal oxide
#

ah

lusty cipher
#

Without Paper's player.getClientBrandName(), is there any way to detect if a player/client is using LabyMod/OptiFine or something else?

eternal oxide
#

Then you are either not setting the scoreboard correctly to the player or you are funking up the storing of yoru team

#

are you always using the same scoreboard?

#

scoreboard = scoreboardManager.getMainScoreboard();

tribal holly
eternal oxide
#

also Teams are persistent, so if you already created the team you code will now be erroring out trying to create teh team a second time.

tribal holly
#
this.scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();```
loud swift
eternal oxide
#

thats NewScoreboard

tribal holly
#

yep

tribal holly
eternal oxide
#

are you creating the scoreboard Once for all teams, or a new one each time?

tribal holly
#

scoreboard is always the same during the game

#

and init onLoad

acoustic token
#

what is the url to the 1.16.5 maven repository

eternal oxide
#

Then Simplify your code till it works. I gave you code that you've seen work

lusty cipher
tribal holly
#

i add his method on addPlayer i do this now :

public void addPlayer(UUID uuid) {

        Player p = Bukkit.getPlayer(uuid);
        if (p != null && !hasPlayer(uuid)) {
            getPlayerList().add(uuid);
            this.team.getTeam().addEntry(uuid.toString());
            p.setPlayerListName(getPrefix() + p.getName() + getSuffix());
            setScoreboardForPlayers();
            playerStatusList.put(p.getUniqueId(), PlayerStatus.ALIVE);
        }
    }


 private void setScoreboardForPlayers() {

        for (Player player : Bukkit.getOnlinePlayers()) {
            player.setScoreboard(scoreboard);
        }
    }```
#

but still don't work

eternal oxide
#

are you adding the player to the team by name?

tribal holly
#

uuid

#

but if a player join during the setup of team i need to add him in the scoreboard

eternal oxide
#

add the player by name not uuid. It works here with name

tribal holly
#

k

#

HOOOOOOOOO

#

IT WORK

#

it was this

#

add with uuid don't work

#

maybe need an update

eternal oxide
#

add with uuid is for entities

#

like mobs

tribal holly
#

thanks a lot guys

wraith rapids
#

@wraith apex

if the API doesn't support them, people will look elsewhere
The API supports what you want to do. You just don't want to do it

register is not actually a method
yes, permissions are registered upon instantiation

an arbitrary implementation is favoured if its less complex or the API doesn't support something the developer wants.
you should keep the end user in mind. currently you are debating the difference of an one-line addition to your code, or two at most to your plugin.yml, both of which can easily be abstracted away by using a proper and established command framework which does the work for you; not having to write this one line of code is not worth breaking compatibility with the api and relying on an arbitrary permission plugin. not every end user even uses a permission plugin to begin with, and many people still do not use luckperms. In addition to this, luckperms doesn't do what you believe it to do, and you still need to assign a permission to your command for inter-plugin compatibility to work properly

this.getCommand() only has the option to set one command permission
And one command permission is perfectly sufficient. Plugins such as /help list providers will use this singular permission to determine whether players have the access to this command. If you have subcommands which have their own permissions, you should set them as a parent to the root command permission so it is inherited. You can do this either via plugin.yml or programmatically using Permission::addParent. This is the case whether you use luckperms or not, and doing so is good practice

@visual tide

can i add several permissions to a command and require any of them in my plugin.yml?
yes you can; do what I said above

#

bottom line remains as: don't be a retard, follow the convention, use the api

ivory sleet
#

Lol nice one

tardy delta
#

?paste

queen dragonBOT
tardy delta
#

should this work as lock method for a chest/barrel just every block that can be locked? btw the MagmaBuildNetwork.playersWantingLock is a list with players who executed the command.
https://paste.md-5.net/agepavehoj.cs

weary geyser
#

public static variable 😐

tardy delta
#

uh

wraith rapids
#

don't expose state directly

#

make a getter method for it and make the field itself private

#

making it static is unnecessary and is presently only the case because you don't know how to access an instance field

tardy delta
#

yea dont want to call the method every time..

wraith rapids
#

you can not want to do it all you want

#

but you still should

#

i don't want to stop at the red lights either

#

don't call getState multiple times

#

each getState clones the entire block state

#

which can be catastrophically expensive

#

call it once and store the blockstate in a variable for the rest of the method's execution

#

or use paper(lib) and call getState(false) to avoid the clone in the first place

#

don't use a list of players, use a set of players

#

you do not need nor do you want duplicate elements

#

don't create a new namespaced key each time, create it once and store it in a field for the rest of the session

#

oher than that, it looks fine

#

well. the if conditions are pretty spaghetti

#

probably want to clean those up

tardy delta
#

but if i want to call getState once i have to declare it one time at the top of the code but that causes every time a player interacts it would check the state of the block seems unnecassary

#

uhu yea bit complecated

wraith rapids
#

BlockState state = block.getState();

#

you are already doing this

#

just move it up

#

if (!(event.getClickedBlock().getState() instanceof TileState))
and use it here

tardy delta
#

well i have to check if the block even has a state

wraith rapids
#

yes

#

you can check whether the variable has something in it

#

just move the variable declaration up

#

and use the variable in your code

#

rather than repeating the method

#

if (!(state instanceof TileState))

wraith apex
# wraith rapids <@96713843618619392> > if the API doesn't support them, people will look elsewh...

@wraith rapids

  1. No it doesn't that's why I will use reflection.
  2. This is not mentioned in the java doc, even if they are registered, they're not attached to anything, you have to store these somewhere.
  3. I am the end user, even if I were to release the plugin, the end user shouldn't need to poke around in the yml and probably never will because that is kept inside the .jar I never gave an exact diagnosis on what luckperms actually does behind the scenes I was just speculating on what it does. The fact is, it does produce an accurate permission tree. I'm debating the unnecessary double entry of data. Why would I register my command once in the yml and then have to get it and attach an executor to it? I should just be able to add them and remove them when a plugin is enabled and disabled. I'm not relying on any permissions plugin. If people don't use a permissions plugin, that's not my problem.
  4. In your opinion? I'm not creating a command for every variant or way that it can be executed just because I want to add a permission in the traditional sense. Permissions should be suitably documented by the plugin developer not just left in the yml for the end user to find.

bottom line is: I know what I'm talking about, and I'll break API conventions if it makes plugin development more efficient. Just provide good documentation when you do so if you plan to hand it off to an end user.

wraith rapids
#

if you are registering your command and a permission for that command then that is fine

#

and yes, you may be the end user in this particular case

#

but do not fucking teach newbies bad habits

#

you can shit up your apartment all you want, but don't teach the child to shit in his bed

#

Why would I register my command once in the yml and then have to get it and attach an executor to it? I should just be able to add them and remove them when a plugin is enabled and disabled.
this is what basically all command frameworks do yes

#

I'm not creating a command for every variant or way that it can be executed just because I want to add a permission in the traditional sense
and i'm not telling you to do that

tardy delta
#

maybe reuse block but yea

wraith rapids
#

no

#

call block.getState() once

#
Block block = event.getClickedBlock();
        if (!(event.getClickedBlock().getState() instanceof TileState)) {
            TileState state = (TileState) block.getState();
        }
#

vs

tardy delta
#

yea i know

#

the event.getClickedBlock()

wraith rapids
#
Block block = event.getClickedBlock();
BlockState blockstate = block.getState();
        if (!(blockstate instanceof TileState)) {
            TileState state = (TileState) blockstate;
        }
tardy delta
#

owh okay

wraith rapids
#

Permissions should be suitably documented by the plugin developer not just left in the yml for the end user to find.
i'm not advocating for documentation, I'm advocating for programmatic access, of which the plugin.yml is the default gateway

#

if you have an alternative method that does it properly, then use it, but what you've been saying so far is that you do not use plugin.yml and have not mentioned a command framework, which is misleading to the beginners

ivory sleet
#

Breaking api conventions if it makes plugin development more efficient lol

wraith rapids
#

the commandmap is exposed in paper api :fingerguns:

ivory sleet
#

Yeah spigot argues for that it’s an improper api design

#

But Idk tbf

#

I mean consider how many plugins that actually reflectively grab the cmdmap

#

On top of that it also has an interface like wat

wraith rapids
#

improper api is better than nonexistent api

#

at least there's a standard of some kind, even if it is ass backwards

ivory sleet
#

Yeah

acoustic nymph
#

I'm pretty sure doing this is not possible, I've searched on google a bit and some people have said its not possible but I'm going to ask here just in case someone knows a workaround.
Is it possible to have both "Copy to clipboard" and "Run a command" when clicking json chat message? This is what I've tested but only the last setClickEvent is applied and not both

TextComponent text = new net.md_5.bungee.api.chat.TextComponent("TestMessage");
                    text.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/command"));
                    text.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, shortcut));```

Basically I have a list of texts that I want to allow a user to copy to their clipboard and I want to send them a custom notification showing them what they have copied using the actionbar and thats why I want to run a command along with the copying to the clipboard, the command handles the notification about what text they just copied
wraith rapids
#

no, the action that is performed is controlled by the action tag of the component, which can only have one value at a time

acoustic nymph
#

gotcha, I'll have to scrap the idea then unless something changes in the future that allows it to be possible, thanks for confirming

quaint mantle
#

can i somehow get an download url through spigot api or spiget?

tacit drift
#

when a Chicken Jockey is spawned from a spawner, is it spawning a chicken ridden by a zombie or a zombie riding a chicken?

#

🤔

wispy fossil
#

from one point of view, it's all three

wraith rapids
#

it's spawning a zombie

tacit drift
#

fuck

wraith rapids
#

the spawn logic then rolls a die and determines that it should ride a chicken

#

both entities are spawned

tacit drift
#

so

#

i could check for both?

wraith rapids
#

what are you doing

tacit drift
#

i want to disable chicken jockey spawning

wraith rapids
#

listen to entity spawn event, check if the entity is a chicken and is being ridden by a zombie

tacit drift
#

ok

wraith rapids
#

or check if the entity is a zombie and is riding a chicken

#

either works

slim kernel
#

Hello!
I am trying to make a plugin in 1.16.5 than does something after a player sneaked for 5 seconds. I tried to make it with the PlayerToggleSneakEvent and did a scheduler in the event running for 5 seconds and it breaks if someone unsneaks. But it didnt work anymore when more than one Player were sneaking at the same time. Anyone an idea how I could do it, so that it works for more players at the same time? Thank you!

#

thats how I was trying to do it

eternal oxide
#

you need to store the sneaking player UUID against the task id, then you get the right task to cancel based upon the player.

quaint mantle
#
new BukkitRunnable() {
                int ticksRunned;

                @Override
                public void run() {
                    ticksRunned++;

                    if (!player.isSneaking())
                        cancel();

                    if (ticksRunned != (20 * 5))
                        return;

                    // do stuff when player is sneaking
                }
            }.runTaskTimer(plugin, 0, 1);
slim kernel
#

yeah thats an even better version but I think it overwrites it somehow if others are doing it to but I dont know

eternal oxide
#

I just told you how to do it for multiple players

slim kernel
#

Yeah I saw it but dont really understand do you have an example maybe?

rare hazel
#

I'm making a queue plugin where an entire server is dedicated to the queue where they are frozen and invisible in a void and can not chat or move. I was thinking of just spawning everyone in the same cords, is that a bad idea? i know 2B2T have a plugin like this, but they spawn the player on a long line. Is there any good reason for placing players on different cords or is the same?

summer scroll
#

if the player is invis, sure i guess.

#

like hided using Player#hidePlayer or something

opal juniper
#

You could hide them, yeah

rare hazel
#

@opal juniper yeah atm i have all player hidden, but my i'm more curious if it is bad to have a lot of players in one cord

opal juniper
#

Would you rather only have a couple of chunks loaded or hundreds as they wait?

#

You could even just have the 0,0 chunk loaded and unload all others manually

rare hazel
#

@jeffmcjefferson So a chunk can not get overloaded? I'm somewhat sorry if this is a dumb question 😅

opal juniper
#

Afaik, no….

ivory sleet
#

Just have like 4 chunks loaded but cancel unnecessary packets maybe

opal juniper
#

Could you not just use the method under world?

rare hazel
#

@opal juniper i have no idea what the "the method under world" is?

opal juniper
#

It’s like world#unloadChunk(x,z) iirc

tardy delta
#

its a lock command

#

something is wrong when i rightclick a block like dirt it gives a EventException null

#

bcs it has no state i assume

opal juniper
#

Well, you could start by ruling out some blocks

#

Which blocks do you want to lock?

#

Just Chests?

tardy delta
#

blocks that are instanceof Lockable so like chests barrels etc

#

look the code

opal juniper
#

Riiiight

#

You should probs do that earlier on

eternal oxide
#

same with blockstate, you define and set it in a local scope

#

line 7 is not setting teh actual blockstate, its setting is own local blockstate

tardy delta
#

well how do i fix it?

eternal oxide
#

line 7 Delete BlockState from the beginning.

tardy delta
#

ow yea forgot that

eternal oxide
#

you never even use teh TileState you create up there

#

line 19 creates its own

#

line 35 never checks for a valid TileState

#

actually nothing from line 11 up is ever used in the code below

#

well block is used in line 22

opal juniper
#

What is the custom Block data that allows you to use a custom texture for a variant of a block type?

#

I swear there was a way

opal juniper
granite stirrup
#

customModelData

opal juniper
#

indeed!

granite stirrup
#

idk how to setup one tho

opal juniper
#

oh it doesn't work on blocks

granite stirrup
#

no

opal juniper
#

only items

#

<

#

oh well

granite stirrup
#

it only works on items

#

u can use armorstands

#

i think

opal juniper
#

Yeah but i would like it to work like a block ><

tardy delta
opal juniper
granite stirrup
eternal oxide
#

line 18 change to if (tileState == null) return;

#

line 23 use blockState instead of block.getState()

#

line 9 delete, and always set teh state

granite stirrup
eternal oxide
#

line 29 use p instead of getting the player again

wraith rapids
#

@tardy delta

#

dude

#

literally

#

god

#

call getState once

grim sage
#

Hey, can I ask here for help about git with intellij ?

wraith rapids
#

do not call it twice

eternal oxide
#

line 33 use p instead fo getting player again

wraith rapids
#

why is it so hard

tardy delta
#

iknow im fixing the basics now

eternal oxide
#

line 36 use tileState

eternal night
#

pfft, if you don't use git by writing the machine code needed for it yourself are you even a real developer smh

wraith rapids
#

don't call blockstate twice
don't create a new key each time
don't expose the player list publicly, create an accessor method
don't use a list for it, use a set, you don't want duplicate elements
clean your if spaghetti

granite stirrup
# opal juniper interesting idea

also with customModelData u can change the model of a item in it so u can have multiple models but u can just put the block model on it

wraith rapids
#

assess these issues and it should be fine

grim sage
# opal juniper sure

ok :b

So i'm new with git and I created a new branch named "test" as you can see on the first screen, but I don't understand why the branch isn't displayed as the second screen :/

tardy delta
grim sage
wraith rapids
#

a blockstate does not have a pdc

#

a tilestate has a pdc

#

line 36 use tileState

granite stirrup
#

u pretty much can make anything with datapacks and texturepacks

eternal night
#

But the branch test is displayed on the right side ? All the way at the top next to master

#

The part where it actually branches off will not happen until you commit something on that branch

#

That isn't on your main braNch

#

Right now, test and main are identical

tardy delta
#

why is this always true?

eternal night
#

Because every block has a state

eternal oxide
#

blocks always have a state

#

I did tell you to delete that line

tardy delta
#

:/

eternal oxide
#

you never set blockstate

#

you just deleted teh whole if section

wraith rapids
#

    private final NamespacedKey key; //assign in constructor

    @EventHandler // Lock method
    public void onContainerClick(PlayerInteractEvent event) {

        Block block = event.getClickedBlock();
        Player p = event.getPlayer();
        
        if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return;

        BlockState blockstate = block.getState();
        if (!(blockstate instanceof TileState) || !(blockstate instanceof Lockable)) return;
        
        TileState state = (TileState) blockState;
        Locable lockable = (Locable) blockState;
        
        PersistentDataContainer container = tileState.getPersistentDataContainer();

        if (MagmaBuildNetwork.playersWantingLock.remove(event.getPlayer().getUniqueId())) {
            
            event.setCancelled(true);
            container.set(key, PersistentDataType.STRING, p.getUniqueId().toString());
            blockstate.update(); //apply the lock!
            p.sendMessage(ChatColor.DARK_GREEN + "Locked!");

        } else {
            String lock = container.get(key,PersistentDataType.STRING);

            if (lock != null && !lock.equals(p.getUniqueId().toString())) {
                event.setCancelled(true);
                event.getPlayer().sendMessage(ChatColor.RED + "You cannot open this!");
            }
        }
    }

#

fix'd

tardy delta
#

uhu

wraith rapids
#

well, aside from fucking indentation

tardy delta
#

xd

wraith rapids
#

notepad doesn't do well with indents

tardy delta
#

thanks i'll try it

wraith rapids
#

no

#

do not try it

#

read it

#

compare it to what you wrote

tardy delta
#

yea

wraith rapids
#

spot the differences

#

then rationalize the differences

#

if you don't know why something is different, ask about it

tardy delta
#

correct my faults ._.

granite stirrup
#

;-;

#

BrOOO

#

that stupid

#

ugly

#

cunt

#

dickking

#

bot

#

keeps warning

#

me

#

for

#

stupid

#

shit

wraith rapids
#

maybe you should spam less

eternal oxide
#

don;t type the same thing twice, or all caps

#

type like me, so many typos you never type teh same thing twice 🙂

tardy delta
#

ow yea i think its Lockable not Locable

granite stirrup