#help-development

1 messages ¡ Page 1754 of 1

wide coyote
#

go to your main class, define PlayerManager variable and create a getter

#

and then use plugin.getPlayerManager().getPlayerBalance(offlineplayer)

quaint mantle
#

creating a global manager is likely the better option, like suggested

rough jay
quaint mantle
#

yes

wide coyote
#

yes

quaint mantle
#

then just init it in onEnable

#

and since you already have playermanager with plugin arg, all old calls can be quickly fixed

rough jay
#

init it?

quaint mantle
#

initialize

#

playermanager = new manager(plugin) pretty much

rough jay
#

oh

#

also when I do this
this.playerManager.loadHashMap();

#

it says Static member 'net.reikeb.maxicity.datas.PlayerManager.loadHashMap()' accessed via instance reference

torn vale
#

I did it, thank you guys 😄

rough jay
#

and when it offers to replace what I placed, and I click on it, it replaces
this.playerManager.loadHashMap();
by
PlayerManager.loadHashMap();

quaint mantle
#

did you make it static?

rough jay
#

no

quaint mantle
#

sounds like you did

wide coyote
#

are you sure

quaint mantle
#

Hey umm... The plugin works just no folder is made

#

package me.Eman.Ecore;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;

public class Main extends JavaPlugin{

public boolean onCommand(CommandSender commandSender, Command command, String label, String[] commandArgs) {
    if (command.getName().equalsIgnoreCase("help")) {
        try {
            Object localVariableScope = new Object();
            commandSender.sendMessage(Main.color("&eGo to &7&owwww.youtube.com/eman49&e,"));
            commandSender.sendMessage(Main.color("&eor do &9&l/discord &efor help!"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    return true;
}


public static String color(String string) {
    return string != null ? ChatColor.translateAlternateColorCodes('&', string) : null;
}

}

wide coyote
#

uh

wide coyote
young knoll
#

You already have it? effectId

torn vale
quaint mantle
#

I was not using my brain

torn vale
quaint mantle
#

forgot about that... new to plugin development sorry

wide coyote
#

np

young knoll
#

There ya go

rough jay
#

so like this?

public static PlayerManager playerManager;

public PlayerManager getPlayerManager() {
    return playerManager;
}

@Override
public void onDisable() {
    playerManager.saveHashMap();
}

@Override
public void onEnable() {
    playerManager = new PlayerManager(instance);
    playerManager.loadHashMap();
}
#

also, saveHashMap and loadHashMap aren't static methods

wide coyote
#

instance is this you can use this

rough jay
#

ok

wide coyote
rotund pond
#

Hello to you !

I would like to discuss some pure Java with you if you don't mind.
I know this is not necessarily the place, but I would like to have your opinion on a subject please.

I often see MC plugins that use a class with a lot of static variables for config files. (Example: Screenshot below the message)
In my opinion, we are clearly in a case of abuse of the static keyword! (Besides the use of the name Main for the main class which is also an error but that is not the subject).
After that, it is true that it is very easy to use this kind of classes ... But I do not find this way of doing correct.

Do you have any thoughts on this subject?
Any suggestions to overcome this problem?
Thank you !

rough jay
# wide coyote any error or fixed?

well for now no error is shown by my IDE so I'm gonna replace everytime I called a new instance of PlayerManager by plugin.getPlayerManager() and test in-game if it fixes my issue

young knoll
rotund pond
young knoll
#

You could also set values to instance variables

rotund pond
young knoll
#

You can still update those variables

rotund pond
#

Yeah but it's complicated for little I think ?
Currently I just have to change the instance of my FileConfiguration when reloading to get the new file and voila

young knoll
#

Yeah that works fine

#

Lemme find a quick example

rotund pond
#

Okay ty 👍

rotund pond
young dome
#

Hello, would you be how to recover the rgb from a block?

young knoll
#

Rgb?

young dome
#

Yeah

#

rgb color

#

I didn't find on google

young knoll
#

What block has an rgb color

young dome
#

All blocks

young knoll
#

The color of the texture?

young dome
#

Yeah

young knoll
#

The textures don’t exist on the server, so you’ll have to hardcode the colors

#

Or generate a yml file of them using python or something

young dome
#

I had however found something which allow to recover the rgb of a block thanks to nms

young knoll
#

That’s... not possible

#

The textures don’t exist on the server, the server has no idea what colour a block is

#

What?

formal dome
#

do sockets come with set in listening properties?

quaint mantle
#

I clicked on buildtools but nothing happend

#

you have to run a command

#

?bt

undone axleBOT
quaint mantle
#

it tells you

#

what do u mean

#

it tells you what to do

#

read the wiki

#

i did pretty much everything

#

Hmm

rough jay
#

What is the event to detect when a player does a command?

errant snow
#

Hey guys, so im trying to add soft dependencies, and I made a hook for luck perms, however I get a NoClassDefFoundError for LuckPerms ContextCalculator when the plugin isn't present on the server. Now obviously it wouldnt be found if the plugin isn't present, but before I load the hook I check if Bukkit.getPlugin("LuckPerms") != null

I'm not sure how to avoid this exception because the hook class shouldn't be instantiated if the plugin isn't present

rough jay
#

to detect when a player simply chats it's AsyncPlayerChatEvent but what is it for a command?

errant snow
#

I have a broadcast for when I add a hook, but none of the messages get printed before the error:

    public void registerHooks() {
        Chat.broadcast("&aAdding hook");
        addHook(HookType.LUCKPERMS);
        Chat.broadcast("&cHook added");
    }
hardy agate
#

I am so lost...

young knoll
spare marsh
#

Bruh java IO is a bit of a pain

ivory sleet
#

What’s up?

rough jay
#

hey

lean gull
rough jay
young knoll
#

What’s the issue

runic mesa
#

How would i have an entity have health above its normal max health

#

i see setMaxHealth is deprecated so how would i do this?

young knoll
#

getAttribute(healthyhingy)

#

Attribute.genericMaxHealth or something

runic mesa
#

yeah

#

what do i do with that tho

young knoll
#

You can add a modifier

#

Or just setBaseValue

runic mesa
#

Thanks it worked, I was wondering how i could have an hp bar for my mob that updates as it gets damaged

quasi patrol
#

I can't figure out why I'm getting a mapping values are not allowed here error in my plugin for the config file.

The config file contains

mentionsmessage: '&c%player_name% has mentioned you in chat!'
vestal matrix
#

would public void onCreatureSpawn(Event e, Creature c) { work as detecting spawns like armor stands from /summon and spawn eggs and all that?

ivory sleet
young knoll
quasi patrol
ivory sleet
#

Alright

spare marsh
#

In previous lines

quasi patrol
young knoll
#

Is that top line a valid comment

#

I thought comments were #

quasi patrol
#

Uh.

spare marsh
#

No

quasi patrol
#

Idk?

spare marsh
#

Comments in yml files should start with a # I think

#
#All placeholders activated by message sender!
mentionmessage: 'false'
hardy agate
#

quick question: how do I return a list of all the keys in a YAML file?

testVar:
  value: HelloWorld!

block2Use:
  value: minecraft:stone

selector2use:
  value: @s

I want to store ["testVar","block2use","selector2use"] in a variable - what method do I use to do this?

quasi patrol
#

Ty.

ivory sleet
#

ConfigurationSection::getKeys

spare marsh
hardy agate
#

what's file in this case

#

and section also

spare marsh
#

You can stream it to a list if you need the keys but try to handle it in case there is an exception.

ivory sleet
#

An instance of ConfigurationSection

hardy agate
#

and hell, what is .getKeys(false)

ivory sleet
#

And section is just the string content

#

getKeys is an instance method of ConfigurationSection

#

false means it won’t look for nested keys

hardy agate
ivory sleet
#

No that was a dummy example

spare marsh
#

No, you say the name of the section

ivory sleet
#

If it’s the root then no need to even get the section.

hardy agate
#

the value in this case

ivory sleet
#

Yuh

spare marsh
#
Names:
  name1: John
  name2: Daniel
#

the section would be Names in this case

hardy agate
young knoll
#

And the Boolean controls if you want to get keys within subsections

hardy agate
ivory sleet
#

There is always

hardy agate
#

...I guess?

#

so what do I call it??

ivory sleet
#

The top level is the root

#

You don’t call it anything

spare marsh
#

just getKeys(false) would do it to get all the parent keys

hardy agate
#

file.getConfigrationSection()?

ivory sleet
#

Though with the assumption you do have an instance of a subsection ConfigurationSection call getRoot() to get the root section instance (which seems not to be your case)

spare marsh
#

file.getKeys(false)

young knoll
#

YamlConfiguration#getKeys

hardy agate
#

that will work?

ivory sleet
#

No

#

It returns a Set<String> instance

#

So it’d have to be
Set<String> exampleVar = ...;

hardy agate
#

what the hell is Set<String>

#

I assume it's different from List<String>?

young knoll
#

Somewhat

spare marsh
#

you have to stream it to an array

young knoll
#

Sets don’t have a get method

ivory sleet
#

It’s a data structure which has a single type parameter that determines the type of elements the set can contain, a set also should ensure no duplicates are contained within the set as opposed to a list

vestal matrix
#
    public void onCreatureSpawn(Event e, Creature c) {
        System.out.println(c.getLocation());
        System.out.println(c.getType());
    }``` why isnt this detecting any spawns? ive tried spawning using a spawn egg and /summon and nothing gets sent to the console, yes its registered
young knoll
#

It’s also faster when doing contains

#

That’s

ivory sleet
#

Not necessarily but if it is a HashSet ye

young knoll
#

Not an event handler method

hardy agate
#

so how do I turn Set<String> into a String[]

young knoll
#

onSpawn(CreatureSpawnEvent event)

vestal matrix
#

ah thanks

ivory sleet
#

iirc toArray(new String[])

young knoll
#

new String[0]

ivory sleet
#

Ah yeah

hardy agate
#

so String[] newExampleVar = exampleVar.toArray(new String[]);

ivory sleet
#

With a 0 between the latter []

hardy agate
#

why

ivory sleet
#

As coll pointed out

#

Because it determines the size of the array

hardy agate
#
String[] newExampleVar = exampleVar.toArray(new String[0]);
#

which is 0 in lenght?

ivory sleet
#

An array’s size must be known at creation

spare marsh
#

Working with a list would be simpler

young knoll
#

If you pass an array that’s too small I think it just makes a new one? Idk

ivory sleet
#

The initial array will have the length of 0 however the toArray method does some magic and stores it contents into the array (sort of) thus returning an array with the contents of the set

hardy agate
ivory sleet
#

.toArray(new String[0]);

spare marsh
ivory sleet
#

But yes

#

Just use new ArrayList<>(fileInstance.getKeys(bool)) then

unreal quartz
#

new ArrayList(set)?

#

no need this stream nonsense

spare marsh
ivory sleet
#

As you’re probably already familiar with a list

young knoll
#

Depends what you are doing I guess

hardy agate
#

ok just to confirm

#

List<String> keys = fileInstance.getKeys(false).stream().toList(); will give me this:
["testVar","block2Use","selector2use"]

young knoll
#

Use the other method

spare marsh
#

You can avoid the stream method.

ivory sleet
hardy agate
#

ok so THIS:
ArrayList<>(fileInstance.getKeys(bool))
will return this:
["testVar","block2Use","selector2use"]

spare marsh
#

List<String> keys = new ArrayList<>(file.getKeys(false));

hardy agate
#

ok so THIS:
List<String> keys = new ArrayList<>(file.getKeys(false));
will return this:
["testVar","block2Use","selector2use"]

ivory sleet
#

Yeah

#

Something like that

spare marsh
#

It will return a list containing those.

hardy agate
#

and file will be config

spare marsh
#

Works similar to an array but instead of doing keys[0] you will do keys.get(0);

quasi patrol
#

Placeholder API stopped working with my plugin...

                        if (plugin.getConfig().getString("mentionsmessage") != null) {
                            person.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(ChatColor.translateAlternateColorCodes('&', PlaceholderAPI.setPlaceholders(player, plugin.getConfig().getString("mentionsmessage")))));
                        }```
hardy agate
spare marsh
hardy agate
quasi patrol
spare marsh
hardy agate
#

alrighty

#

thank you to everyone who helped me!!!

ivory sleet
#

🍉

young knoll
#

🍍

hardy agate
#

oh dear

cinder thistle
hardy agate
#

List<String> keys = new ArrayList<>(config.getKeys(false));

cinder thistle
#

yikes

hardy agate
#

config cannot be resolved

#

🙂

young knoll
#

Do you have a variable named config

hardy agate
#

uh

#

no

#

ok so I see why I'm an idiot here

#

but what do I put?

young knoll
#

An instance of your config

#

Whether it be JavaPlugin#getConfig or what not

hardy agate
#

could I use plugin.getConfig()

hardy agate
#

just hold on a second

quasi patrol
#

Its being entirely weird.

#
public class ChatEvent implements Listener {
    public DataManager data;
    static FastGensChatMentions plugin = null;

    public ChatEvent() {
    }

    public static void initialize(FastGensChatMentions instance) {
        plugin = instance;
    }


    @EventHandler
    public void onChat(AsyncPlayerChatEvent event) {
        Player player = event.getPlayer();
        for (Player person : Bukkit.getOnlinePlayers()) {
            if (event.getMessage().toLowerCase().contains(person.getName().toLowerCase())) {
                if (data.getMutedConfig().getString(person.getUniqueId() + "muted") == null || data.getMutedConfig().getString(person.getUniqueId() + "muted") != null && !Objects.equals(data.getMutedConfig().getString(person.getUniqueId() + "muted"), "true")) {
                    person.playSound(person.getLocation(), Sound.BLOCK_ANVIL_LAND, 3.0F, 1.25F);
                        if (plugin.getConfig().getString("mentionsmessage") == null) {
                            person.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(ChatColor.RED + player.getName() + ChatColor.RED + " has mentioned you in chat!"));
                        }
                        if (plugin.getConfig().getString("mentionsmessage") != null) {
                            person.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(ChatColor.translateAlternateColorCodes('&', PlaceholderAPI.setPlaceholders(player, plugin.getConfig().getString("mentionsmessage")))));
                        }
                        return;
                    }
                }
            }
        }
    }``` When the config line is deleted, it still does ``&c%player_name% mentioned you in chat!``
runic mesa
#

I have a custom mob what event would i use to listen for it being damaged??

young knoll
#

EntityDamageEvent

runic mesa
#

how would i do the specific one tho

young knoll
#

How do you identify your custom mob?

runic mesa
#

You mean define it?

#

Witherskeleton zombo = (Witherskeleton)

young knoll
#

What is it

#

Is it a custom NMS mob or just a mob with some armor and whatnot

runic mesa
#

Just a mob with potions and custom name

young knoll
#

Use a pdc tag

#

?pdc

runic mesa
#

wdym?

young knoll
#

Add a pdc tag to the mob when you spawn it so you can identify it

runic mesa
#

ohhh

#

so i check the damage

#

and if it has the tag

#

i do stuff

young knoll
#

Yes

wide coyote
quaint mantle
#
[23:04:37 ERROR]: Error occurred (in the plugin loader) while enabling LDDuty v1.0 (Is it up to date?)
java.lang.NullPointerException: null
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:357) ~[patched_1.16.5.jar:git-Paper-774]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.16.5.jar:git-Paper-774]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:518) ~[patched_1.16.5.jar:git-Paper-774]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:432) ~[patched_1.16.5.jar:git-Paper-774]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.reload(CraftServer.java:965) ~[patched_1.16.5.jar:git-Paper-774]
        at org.bukkit.Bukkit.reload(Bukkit.java:726) ~[patched_1.16.5.jar:git-Paper-774]
        at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:54) ~[patched_1.16.5.jar:git-Paper-774]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[patched_1.16.5.jar:git-Paper-774]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchCommand(CraftServer.java:826) ~[patched_1.16.5.jar:git-Paper-774]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchServerCommand(CraftServer.java:788) ~[patched_1.16.5.jar:git-Paper-774]
        at net.minecraft.server.v1_16_R3.DedicatedServer.handleCommandQueue(DedicatedServer.java:470) ~[patched_1.16.5.jar:git-Paper-774]
        at net.minecraft.server.v1_16_R3.DedicatedServer.b(DedicatedServer.java:437) ~[patched_1.16.5.jar:git-Paper-774]
        at net.minecraft.server.v1_16_R3.MinecraftServer.a(MinecraftServer.java:1342) ~[patched_1.16.5.jar:git-Paper-774]
        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1130) ~[patched_1.16.5.jar:git-Paper-774]
        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-774]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_301]
#

Anyone seen this error before

proven spoke
#

java.lang.NullPointerException: null

quaint mantle
#

well yes, but what's null lol

young knoll
#

Is that the entire error

quaint mantle
#

yes

eternal oxide
#
  1. its not the full error
quaint mantle
#
[23:11:03 ERROR]: Error occurred (in the plugin loader) while enabling LDDuty v1.0 (Is it up to date?)
java.lang.NullPointerException: null
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:357) ~[patched_1.16.5.jar:git-Paper-774]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.16.5.jar:git-Paper-774]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:518) ~[patched_1.16.5.jar:git-Paper-774]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:432) ~[patched_1.16.5.jar:git-Paper-774]
        at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:594) ~[patched_1.16.5.jar:git-Paper-774]
        at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:298) ~[patched_1.16.5.jar:git-Paper-774]
        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1069) ~[patched_1.16.5.jar:git-Paper-774]
        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-774]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_301]
[23:11:03 INFO]: Running delayed init tasks
[23:11:03 INFO]: Done (10.893s)! For help, type "help"
#
[23:10:57 ERROR]: [org.bukkit.craftbukkit.v1_16_R3.CraftServer] null initializing LDDuty v1.0 (Is it up to date?)
java.lang.NullPointerException: null
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:398) ~[patched_1.16.5.jar:git-Paper-774]
        at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:269) ~[patched_1.16.5.jar:git-Paper-774]
        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1069) ~[patched_1.16.5.jar:git-Paper-774]
        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-774]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_301]
eternal oxide
#

?paste the full startup log

undone axleBOT
quaint mantle
proven spoke
#

alright

eternal oxide
#

odd. I'd guess LDDuty is corrupt

young knoll
#

Wonder if modern java would give a better error

quaint mantle
#

tbh I was using java 16 but I had to move down to 1.8 for a quick project

sullen marlin
#

you're not running spigot

mint briar
#

how i can make my plugin reload itself?

proven spoke
#

reload config?

mint briar
#

no no, eg: my plugin download the dependencies, and for apply this i need restart the server or the plugin

#

and i want reload the plugin

proven spoke
#

oh ok

mint briar
#

(this is for java 16)

proven spoke
#

try PlugMan .__.

mint briar
#

no... I want to make my plugin reload itself

#

without needing external help

#

did you understand?

proven spoke
#

yes

young knoll
#

There are definitely ways to download external dependencies without needing to reload the plugin

mint briar
#

:/

#

so, tell me how

young knoll
#

Something like slimjar

sullen marlin
#

the only supported way to reload is to reload the whole server

young knoll
#

Or the system built into spigot in 1.17

sullen marlin
#

reloading just one plugin could be really bad, eg what happens if another plugin depends on yuour plugin

mint briar
#

pls

proven spoke
#

export -> /reload -> profit

sullen marlin
fleet epoch
#

got a question but don't want to override lol

young knoll
#

This is why we have threads

proven spoke
#

yess

last ledge
#

true

sullen marlin
#

or just the ability to read multiple things at once

young knoll
#

To be fair I already saw the code

fleet epoch
#

well I just don't want to like, belittle someone else's issue

#

don't wanna walk on someone lol

young knoll
#

You have the path needed, but you just have it sitting on a line doing nothing

clever whale
#
public class onPlayerMove implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        Player player = (Player) sender;

        return false;
    }
    @EventHandler
    public void playerMove(PlayerMoveEvent e) {
        Player player = e.getPlayer();


        if (player.hasPermission("shark.move")) {
            e.setCancelled(false);

        } else {
            e.setCancelled(true);

            player.sendMessage(ChatColor.RED + "You cannot move in this lobby!");

            }
        }
    }

Main class:

getCommand("hMove").setExecutor(new onPlayerMove());

Trying to have it so when the command is executed it'd check if the player has permission to move, and if not the PlayerMoveEvent will be disabled

Im quite new to spigot and would appreciate some help

fleet epoch
#

huh

#

i think i get what you mean

young knoll
#

Yeah that’s not how you do that

sullen marlin
#

you didnt register the event listener

fleet epoch
#

alright, thanks you

sullen marlin
#

you just registered the command

young knoll
#

You have an event listener inside a command method

last ledge
sullen marlin
#

implement Listener and call registerEvents

clever whale
#

How would I go about doing that?

#

Ah right, thanks!

young knoll
#

Ah wait no you don’t, but the command just declares a player variable and then returns

clever whale
proven spoke
solid cargo
#

what would be the best way to make a thing. lemme show an example

#

so yeah, what would be the best way to make this? ^

clever whale
proven spoke
#

onEnable() method

clever whale
#

Thanks!

proven spoke
#

no prob

acoustic widget
mint briar
#

hmm?

acoustic widget
#

I'm using this when i'm on development, it reload plugins when it detect file changes

dark osprey
dark osprey
#

Ok

proven spoke
#

.___.👌

opaque panther
#

someon please help me

#

Im trying to make a shop plugin

#

I made a class with the shop menu Inventory and sell inventory as its members

#

So far it is working pretty good, I onlly setup the selling thing

#

but

#

will the inventory change for everyplayer when one player changes it

proven spoke
#

no.

vale ember
#

hey, quick question, what method to use to get item in player's hand if i want plugin to work 1.8-1.17.1?

fleet epoch
#

are you using a listener/event handler?

proven spoke
#
    public ItemStack getItemInHand(Player player) {
        if(Bukkit.getVersion().contains("1.8")) {
            return player.getItemInHand();
        } else {
            return player.getInventory().getItemInMainHand();
        }
    }
#

it work for me .___.

iron palm
proven spoke
fleet epoch
#

donno but i'm using this in my event ItemStack killerWeapon = e.getEntity().getKiller().getItemInUse();

#

My dothetext: (deathlogger.logDeaths)

public class logDeaths {  //line7
    public static void dotheText() throws IOException{  //Line 8

        //1 Create a File
        File file1 = new File(DeathLogger.getPlugin().getDataFolder() + "\\logs\\out1.txt");
        file1.mkdir();


        //2 Create a File Writer Class
        FileWriter fw = new FileWriter(file1);

        //3 Create a Print Writer Class
        PrintWriter pw = new PrintWriter(fw);
    }
}

Main Method: (deathlogger.DeathLogger)

        try {  //line 23
            logDeaths.dotheText();
        } catch (IOException e) {
            e.printStackTrace();
        }

How to I make the directory? A bit lost on this one :))
Know VERY little about this

vale ember
solid cargo
#

how can i create a cosmetic explosion?

proven spoke
vale ember
proven spoke
#

ok

kind coral
kind coral
#

make the checks for it so you can create it if its missing

proven spoke
proven spoke
#

no prob

vale ember
#

should i use PlayerInteractEntity or PlayerInteractAtEntity?

proven spoke
#

for?

vale ember
#

For right clicking on mobs

drowsy helm
#

first

#

well both work interact at just has location

vale ember
#

Ok

sullen marlin
#

Pretty sure only the first will work

#

Second is a subevent and for armor stands

verbal nymph
#

Do I need to make sure that e.getCurrentItem() is not null before this statement?

if(!(e.getCurrentItem().getItemMeta() instanceof Repairable repairableItem)) {
    return;
}```
(I know `instanceof` doesn't throw an error when used on `null` but here I am using a method on something that may be `null` before checking if it's an instance of `Repairable`)
sullen marlin
#

Is it marked nullable

verbal nymph
#

Yes, getCurrentItem() is Nullable, it may be null

sullen marlin
#

So then you need to check it’s not null

verbal nymph
#

Okay, thank you. Was just wondering because usually IntelliJ complains if there is a null check missing, but here it doesn't

sullen marlin
#

Maybe a bug, probably due to the new style instanceof you’re using

karmic mural
#
  java.lang.NullPointerException: Cannot invoke "org.bukkit.configuration.ConfigurationSection.getValues(boolean)" because the return value of "org.bukkit.configuration.file.FileConfiguration.getConfigurationSection(String)" is null
    at me.favn.PluginName.ItemCreator.<init>(ItemCreator.java:22) ~[PluginName-1.0-SNAPSHOT.jar:?]
        at me.favn.PluginName.ItemGenerator.fetchItems(ItemGenerator.java:19) ~[PluginName-1.0-SNAPSHOT.jar:?]
        at me.favn.PluginName.ItemGenerator.<init>(ItemGenerator.java:11) ~[PluginName-1.0-SNAPSHOT.jar:?]
        at me.favn.PluginName.PluginName.onEnable(PluginName.java:18) ~[PluginName-1.0-SNAPSHOT.jar:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[patched_1.17.1.jar:git-Paper-336]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.17.1.jar:git-Paper-336]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.17.1.jar:git-Paper-336]
        at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:561) ~[patched_1.17.1.jar:git-Paper-336]
        at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:475) ~[patched_1.17.1.jar:git-Paper-336]
        at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:730) ~[patched_1.17.1.jar:git-Paper-336]
        at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:317) ~[patched_1.17.1.jar:git-Paper-336]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1217) ~[patched_1.17.1.jar:git-Paper-336]        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[patched_1.17.1.jar:git-Paper-336]
        at java.lang.Thread.run(Thread.java:831) ~[?:?]``` 

ItemCreator:22
```alltheshit = cconfig.getConfig().getConfigurationSection(checkthis).getValues(false);```

(cconfig is passed through from ItemGenerator calling a method on line 11, that code being at line 19...
#

Idk what I am trying to say is I cannot understand this, so can someone please help me understand it?

vale ember
#

That means that config section ur trying to get don't exist

karmic mural
#

Thank you

#

Thanks, I was passing value instead of key, which is why the section didn't exist 😅

iron palm
#

what does the build error ```invalid target release: 1.8.0_312

Means uh its the first time im getting this error
hybrid spoke
iron palm
hybrid spoke
iron palm
#

i changed it to 9 from 8 but it didnt changed wt

#

it is not working

hybrid spoke
#

you specified an higher java version in your pom.xml than you have on your system

#

so going higher will not fix the issue

eternal oxide
#

1.8 is java 8

iron palm
#

this is the java version in pom.xml

hybrid spoke
#

open cmd and type in java -version, whats the output?

iron palm
#

its 16
btw i also have 8 installed

#

1.8*

#

it also used to work fine before changing my project version to 1.6-Beta but this probably does not affect on java version so...

#

even changing project java version to 16 didnt worked!

#

error: invalid target release: 16.0.2

eternal oxide
#

target and source only want a basic level, like 1.8 or 16. It does not work using 16.0.2

acoustic widget
#

Is HikariCP worth it ? I would like to add database (sqlite & mysql) for my plugin, should i use that instead of simply jdbc ? (I'm new at java development)

iron palm
eternal oxide
#

just remove your $java.version and put in an actual number to see if it works

eternal oxide
#

both

iron palm
#

worked lmao

#

thanks again

manic furnace
#

How can i get the tps of my server?

hybrid spoke
manic furnace
#

Is there an aip?

#

i mean api sry

hybrid spoke
#

not really. read the thread, thats how spigot does it. otherwise you have to do something on your own

solid cargo
#

how can i update the GUI on InventoryGUI?

naive jolt
#

https://pastebin.com/MR1JLBPm
Hey I have a problem. So this corpse does not dissapear when the inventory is empty for some reason so I switched the code up A lot to try to make it work but no luck.

hybrid spoke
solid cargo
hybrid spoke
tardy delta
#

inv.setItem()?

hybrid spoke
#

and not doing it frequently

solid cargo
#

oh open it repeadetly?

tardy delta
#

doesnt that updates it automatically?

eternal oxide
#

or call Player#updateInventory()

solid cargo
#

that doesnt work there

#

i tried

hybrid spoke
eternal oxide
#

I thought it updated teh view

hybrid spoke
#

only the players inventory

eternal oxide
#

ah

jolly nymph
#

does anyone know an opensource discord bot that announces every time an author updates their plugin?

tardy delta
#

uhh watch console?

hybrid spoke
hybrid spoke
jolly nymph
#

i tried to and gave up midway lol

solid cargo
#

is there any method i can use to run a task for a specific amount of times with the tick delay also?

#

something like runTaskTimerAsynchrously but do that task 10 times and no more

drowsy helm
#

repeating task has a param for delay doesntt it

solid cargo
#

no, delay is fine, but i want to do it for certain amount of times

drowsy helm
#

you can always have a counter inside of it

#

i dont think theres any task with an inbuilt iteration limit though

solid cargo
#

i had an idea of doing a for loop

#

but i think the for loop will also repeat cause uh

#

every time the task repeats, the loop also repeats

drowsy helm
#

just have an int starting at 0

#

iterate at the end of each iteration of the task then if i >= 10 finish the task

vale ember
#

is it possible to make maven build plugin's jar into multiple directors?

naive jolt
hybrid spoke
crimson terrace
#

the return in line 30 might be the problem

crimson terrace
#

not sure if it works. you tell me 🙂

naive jolt
#

Got it

tardy delta
#

if i do like

new ClassThatExtendsRunnable().runTaskTimer(plugin, 1L, 6L);```
will that create a new object on every run?
drowsy helm
#

yes

#

wait what d oyou mean every run

tardy delta
#

every 6 ticks in my case

drowsy helm
#

oh, no

#

only when the line itself is run it will create a new instance

tardy delta
#

so its the same as

var obj = new ClassThatExtendsRunnable();
obj.runTaskTimer(pluhin, 1L, 6L);
```?
#

ok

drowsy helm
#

yeah

tardy delta
#

oki thanks

#

i was scared

#

and uhh i guess these things are te same

#

ah wait

#

It will try to remove 'as much as possible' from the types and amounts you give as arguments

#

i was hoping there is something like inv.remove(ItemStack...) which returns a boolean

hybrid spoke
#

either you else it or it doesnt make sense

tardy delta
#

uhh

#

yesh

hybrid spoke
tardy delta
#

sad sad

vale ember
#

can someone please help sending actionbar packet via tinyprotocol?

tardy delta
#

why not just sending an actionbar?

vale ember
#

cuz i want it 1.8-1.17.1

tardy delta
#

mwoa

#

i hate those things

vale ember
#

me too

#

but i want multi-version plugin

lavish hemlock
tawny horizon
#

I think ActionBarAPI is only like 1-2 classes and accomplishes that exact task

#

want me to link ya it?

vale ember
#

yep

tardy delta
lavish hemlock
#

:(

tardy delta
#

(:

lavish hemlock
#

at which version is ActionBarAPI useless?

tawny horizon
#

test it for 1.17, it worked fine on 1.16

lavish hemlock
#

my framework is 1.14+, I might incorporate that API into it

tawny horizon
#

yea, i would send ya my framework but its not done, Factions oriented, and based in 1.8.8

lavish hemlock
#

unless Adventure supports actionbars

#

it doesn't

tawny horizon
#

whats Adventure?

lavish hemlock
tawny horizon
#

ahh

lavish hemlock
#

A component-based text lib for Minecraft platforms, has platform support for Spigot but is native for Paper.

tardy delta
#

ah uh looking for a more efficient way

lavish hemlock
#

Bungeecord's text API is close to it.

tawny horizon
#

honestly, lately I have been doing a lot of code related to obfuscating and practicing a lot of reverse engineering

lavish hemlock
tawny horizon
#

^

lavish hemlock
#

then just return that new File from the method and assign your fields to the returned File

#

e.g.

tardy delta
#

if it takes two parameters i cant access the field it only modifies the parameter

#

uhh

lavish hemlock
#

configFile = loadConfig("config.yml");

tardy delta
#

had it like this

#

but i cant modify the File field

lavish hemlock
#

you might have to make a new class for that or smthn

tawny horizon
#

one minute

lavish hemlock
#

It is also not done

#

But it's primarily focused on medium-large sized plugins, and is for 1.14.4+ as I said before.

#

primary projects are iron and mspl-core

#

iron = Gradle plugin that helps with creating a development server.
mspl-core = Core library that contains common or necessary functionality for other parts of the library.

quaint mantle
#

Just use adventure for action bars

lavish hemlock
quaint mantle
#

It does

lavish hemlock
#

goddamn their docs really are unfinished then

quaint mantle
#

javadocs is a thing

lavish hemlock
#

yeah but

#

who enjoys reading javadocs lmao

tawny horizon
#

.paste

#

smh

#

?paste

lavish hemlock
#

?paste

undone axleBOT
lavish hemlock
#

oh

quaint mantle
#

Like, sending an action bar is a single method nothing to explain in docs

lavish hemlock
#

but yeah mspl-core basically provides abstractions over stuff like Adventure and Commodore, as well as some utils.

#

well if the docs don't show it as existing, it's hard to motivate me to look at the javadocs to see if it actually does :p

tardy delta
#

what does this do?
fileConfiguration.setDefaults(defConfig);

tawny horizon
#

basically if the config doesnt exist in the folder

#

it saves the config with the one in your plugin jar

tardy delta
#

isnt that just plugin.saveResource("config.yml", false)?

tawny horizon
#

exactly

tardy delta
#

wew thanks

tawny horizon
#

np lol

hybrid spoke
#

at least in my case, but i didn't updated it for a long time

quaint mantle
#

i remember i used to send action bar in 1.12.2

#

Even 1.9.4

#

Even 1.8.8

lavish hemlock
#

Bungee Chat API OP

quaint mantle
#

adventure better

lavish hemlock
#

Yes

tardy delta
#

heh

#

java.lang.IllegalArgumentException: Length of Base64 encoded input string is not a multiple of 4.

tawny horizon
#

the number of characters ^

tardy delta
#

i think i'm trying to decode a wrong string

#

lemem try real quick

vale ember
#

from what mc version does spigot have built-in actionbar api?

tardy delta
#

smh java.lang.IllegalArgumentException: Illegal character in Base64 encoded data.

tawny horizon
#

send the string

vale ember
#

how to know it 100%?

tawny horizon
#

by testing it XD

hybrid spoke
#

search up the docs

tardy delta
#

grr i'm trying to decode something from yml file

tawny horizon
#

send the string

tardy delta
#

like

safe-chests:
  uuid1: base64string
tawny horizon
#

send the actual base64 sting

tardy delta
#

i havent

tawny horizon
#

and wait

tardy delta
#

it wont save

tawny horizon
#

why do ya wanna use Base64 for it if i may ask

tardy delta
#

not going to save a whole itemstack array to a file

tawny horizon
#

i thought that was a players UUID

#

send your code though

tardy delta
#

but anyways i was trying to get configSection.getKeys(false) but then i saw it was .values

#

but that returns an Object so grr

tawny horizon
#

just cast String to it then

#

or use .toString()

hybrid spoke
#

.toString may just return a debug msg

tardy delta
#

probably this now

tawny horizon
#

i think itemstack has a real toString

tardy delta
#

but getValues(false).values looks cursed

tawny horizon
#

hover over that

#

and send another SS

#

wait

#

nvm

#

let me just look at that

tardy delta
#

this wont work as the key isnt an uuid

tawny horizon
#

use "datafile.getString(key + ".uuid");

naive jolt
hybrid spoke
#

and yes the key isnt an UUID

tawny horizon
hybrid spoke
#

maybe thats the error

tawny horizon
#

not the key itself

hybrid spoke
#

#getValues

#

out for the configuration section

#

that returns a map with the values of the keys & keys under that CS

tawny horizon
#

but are you sure that it returns the values of each subkey as well?

#

one second, ima just test this

hybrid spoke
#

i think the subkey is the value for the key if there is a subkey

tardy delta
#

i think i found it

dataFile.getConfigurationSection("safe-chests").getKeys(false).forEach(key -> {
                ItemStack[] content = InventorySerialisation.itemStackArrayFromBase64(dataFile.getString("safe-chests." + key));
                SafechestGui.getMenus().put(UUID.fromString(key), content);
            });
tawny horizon
#

but he would be trying to handle every subkey at once

hybrid spoke
#

there arent any subkeys so fuck it

tardy delta
#

where dataFile.getString("safe-chests." + key) grabs the content

tawny horizon
#

wouldnt ya also need the subkey on the end if you are not getting deep?

#

for getKeys

hybrid spoke
#

there arent any subkeys

#

he now just gets uuid1, uuid2, uuid3 and fetchs the value for each

tardy delta
#

uhu

tawny horizon
hybrid spoke
#

depends on the usecase

#

public lib? yes. private project? no.

tardy delta
#

if there would be subkeys my brain would really explode

hybrid spoke
#

not sure how you would go for that. probably looping over the keys or getting the CS for each

tawny horizon
#

private or public its important to get in the habit of always assuming your work will be seen and worked on by others

tardy delta
#

heh?

hybrid spoke
#

makes a plugin for my localhost "ready to let players on my server!"

tardy delta
#

grr java.io.StreamCorruptedException: invalid type code: 2D

mortal hare
#

for those who don't want to use DataWatchers for packet entities, here's a detail explanation how to send metadata packets, without having LivingEntity object or doing reflection inside packet object which costs performance. (1.17.1)

        PacketDataSerializer metaData = new PacketDataSerializer(Unpooled.buffer()); // Unpooled.buffer is netty's implementation of ByteBuf interface. Its used to store packet data, before it gets sent through netty's connection pipeline.
        metaData.d(987); // entity id. d method is for writing varInts, mojang has a special implementation of them.

        // Entity Metadata info
        metaData.writeByte(0); // byte index  https://wiki.vg/Entity_metadata
        metaData.d(0); // type registry id (varInt) https://wiki.vg/Entity_metadata
        metaData.d(0x20); // byte bit mask (invisible) https://wiki.vg/Entity_metadata
        metaData.writeByte(255); // mark as end of the packet buffer data. Its required.
        connection.sendPacket(new PacketPlayOutEntityMetadata(metaData));
tardy delta
#

error on this line
ItemStack[] items = new ItemStack[dataInput.readInt()];

#
public static ItemStack[] itemStackArrayFromBase64(String data) {
        try (ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data)); // this line
             BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream)) {
            ItemStack[] items = new ItemStack[dataInput.readInt()];
            // Read the serialized inventory
            for (int i = 0; i < items.length; i++) {
                items[i] = (ItemStack) dataInput.readObject();
            }
            return items;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new ItemStack[0];
    }
mortal hare
tardy delta
#

?paste

undone axleBOT
tardy delta
#

and it writes the length of the itemstack[] first

hybrid spoke
#

seems like it added a "D"

tardy delta
#

uhh

#

when i try again its this
java.io.StreamCorruptedException: invalid type code: 00

#

every time 00

#

👀

mortal hare
#

WOW

#

bat's hitbox is really fucked up

#

pro tip: wanna kill a bat, swing at the air.

tardy delta
#

easier to hit xd

mortal hare
#

its only the half

hybrid spoke
#

sitting yeah, and in air?

hasty prawn
#

In the air it's 1 pixel

mortal hare
#

its actually smaller

naive jolt
mortal hare
#

i have no idea

naive jolt
mortal hare
#

that's vanilla

tardy delta
#

hmm
output.write(items.length) vs dataoutput.writeInt(items.length) was probably my mistake

mortal hare
#

hanging bats have enormous hitboxes

naive jolt
# mortal hare that's vanilla

[Thats how I got people to say im the best archer in minecraft, I just show hitboxes and since its so tall you dont have to hit the bat itself]

karmic mural
#

Okay so I've been working on a plugin that adds some custom items to the game... these items are automatically generated by the plugin by drawing parameters from a config... What I don't know is how do I then obtain those items in-game? 😅

#

I made the plugin print the final ItemStack to console: The itemstack is: ItemStack{DIAMOND x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"extra":[{"text":"Pure Diamond"}], "text":""}, lore=[{"extra":[{"text":"A rare form of Diamond!"}], "text":""}], enchants={LUCK=1}, ItemFlags=[HIDE_ENCHANTS]}}

lost matrix
#

Write a command that looks something like this:
/customitem get <name>
If you have mapped those items to names that is.

karmic mural
#

You see that I am not completely certain of lol

#

I was hoping something in there would help me figure that out 😅

hasty prawn
#

Well it looks like you've already built the ItemStack, all you have to do is add it to the player's inventory.

#

When you want to add it depends on your plugin

karmic mural
#

Of course, of course. But that is the question: How

hasty prawn
#

player.getInventory().addItem()

karmic mural
#

No not like that

#

Like what would I write in that addItem()

hasty prawn
#

The ItemStack

karmic mural
#

So I gotta add these itemstacks I'm creating to a map is what you're saying, then?

lost matrix
#

Depends on your plugin. You could just use a
Map<String, ItemStack>
and get loaded items by their mapped String

karmic mural
#

Hmm yeah that seems pretty nice

#

I was gonna post the code I used but I think I'm just gonna try this first then see if it works 😅

#

I feel good about this

#

Hmm

#

So I tried this:

#

The "name = item" is at the end of the method that makes my itemstack, setting that itemstack to be equal to "item". I then attempted to just put that into the hashmap I created at the top of my class, named "items"



   name = item;
  items.put(itemname, name);

#

That gave me an error saying "this.items" is null

lost matrix
#

More code pls

karmic mural
#

One sec

naive jolt
#

https://pastebin.com/ABwEdXgY
Hey I have a problem. So this corpse does not dissapear when the inventory is empty for some reason so I switched the code up A lot to try to make it work but no luck.

karmic mural
naive jolt
tardy delta
#

for some reason nothing gets written to the file while the map isn't empty

SafechestGui.getMenus().forEach((key, value) -> dataFile.set("safe-chests." + key, InventorySerialisation.itemStackArrayToBase64(value)));
#

saved it

#

it's a Map<UUID, ItemStack[]> which gets transformed to a Map<UUID, String>

tawny horizon
#

to players?

torn vale
#

Im canceling a sound Id with the ProtocolLib API. Does any1 know if this plugin works for any version with viaversion? Because every version has like a other sound Id

lavish hemlock
#

Hey, if I create multiple Connections asynchronously via the scheduler, are they all going to be on different threads?

tawny horizon
#

yep

lavish hemlock
#

Good.

tawny horizon
#

you could always test it with Thread#currentThread

#

i think

lavish hemlock
#

True.

ivory sleet
#

iirc it uses a cached thread pool for its asynchronous tasks

lavish hemlock
#

Eh that's fine anyways.

#

I just needed to know so I could keep track of multiple connections at once.

ivory sleet
#

Yeah but it may reuse the threads, yeah what you doing anyways?

lavish hemlock
#

SQL module for my framework.

ivory sleet
#

Ah

#

Nice

tardy delta
#

do i need to save my yml directly after setting one thing maybe?

ivory sleet
#

Uh well

lavish hemlock
#

Currently just trying to figure out how to abstract its data classes though.

ivory sleet
#

Ideally you’d cache it FourteenBrush

lavish hemlock
#

I want to be able to provide an interface so that I can have 2 ways of storing/retrieving info, one with and one without SQL.

tardy delta
#

well i dont understand why my message gets logged and nothing has been saved

ivory sleet
#

And then save with a sync buffer every x duration and save at certain justified events like join and leave

tardy delta
#

it's a Map<UUID, ItemStack[]> which i'm trying to save this way

SafechestGui.getMenus().forEach((key, value) -> {
            dataFile.set("safe-chests." + key, InventorySerialisation.itemStackArrayToBase64(value));
            Utils.logDebug("saved safechest " + key + ":" + Arrays.toString(value));
        });
novel basin
#

Can someone help me. Im making a plugin has a command. Im trying to turn an arg(the arg is the player's ign) to a player so i can give that player stuff but i cant figure it out.

tardy delta
#

after that the config.save bla bla bla but the message gets logged and it isnt saved

undone axleBOT
ivory sleet
#

Well

#

You need to call dataFile::save

tardy delta
#

i do

ivory sleet
#

I can’t spot it in thecode you sent

tardy delta
#

well yea its below

novel basin
tardy delta
#

its saved because the code below it gets saved

tardy delta
novel basin
tardy delta
#

smh

#

the link from in your browser

novel basin
#

shoot sorry :))

tardy delta
#

you want an else

#

or an early return

#

and store the player somewhere

#
Player hunter = Bukkit.getPlayerExact(args[idk]);
if (hunter == null) // the message stuff
else // do something with the player
#

casting won't work

hardy agate
#

just a general java question: how do I get every element in a list after a certain index

example:
["thingZero","thingOne","thingTwo","thingThree","thingFour","thingFive"]
I want to store ["thingTwo","thingThree","thingFour","thingFive"]

how would I do this? Thanks!

hardy agate
#

and if I don't provide a second argument, it will default to the last?

hybrid spoke
#

you need a second argument.

#

subList(fromIndex, toIndex). if you want it to go to the last element, use #size() as toIndex

hardy agate
#

ok thank you!

tardy delta
#

i don't get it

#

nothing is set to the file and its saved

#

also hmmm

RFC 2045, which defined Base64, REQUIRES a newline after 76 characters (max).
hollow bluff
#

EntityDamageByEntityEvent

tardy delta
#

cant a string with \n be saved into config or something?

round gale
#

you need to make a List<String>

#

Can you disable TabComplete in a PlayerCommandPreprocessEvent?

tardy delta
#

who knows

#

but its just a string why is that a problem

round gale
#

because Java doesn't understand it as a line break i guess, is it just getting "deleted" and just the n is in the config?

tardy delta
#

so split it by the \n?

#

and make it a list?

round gale
#

because \anything just means "deal with it as a normal character"

tardy delta
#

uhh it wont get saved

#

things after it do

#

i dont understand it

#

not even a key

tardy delta
#

maybe snakeyml might be the problem?

hybrid spoke
tardy delta
#

i'm now trying it with the java.util.Base64 class

gleaming grove
#

Hi it is possible to set HEX or RGB color to sheep?

young knoll
#

No

gleaming grove
#

😮

tardy delta
#

that looks like vsc

gleaming grove
#

so "Jeb" name tag works only on the Client side?

tardy delta
#

i guess

ivory sleet
#

Yeah

young knoll
#

Yes

ivory sleet
#

Technically you could have a timer switching the color every so often though it won’t be smooth transitions

hybrid spoke
gleaming grove
#

some random galactic

hybrid spoke
#

can you send it in here? 🥺

gleaming grove
#

@GodCipher it would't be cheap transaction 😉

tardy delta
#

now the string is without \n and stuff but for some reason it wont get saved

mortal hare
#

js user

quaint mantle
#

terrible thing

mortal hare
#

well

#

i used std::cout << "Hello";

#

once

#

brain farts happen

quaint mantle
#

L

#

its normal

#

¯_(ツ)_/¯

#

but var

eternal night
#

var is super useful huh ?

gleaming grove
#

anyway var makes programming faster a bit

quaint mantle
#

I ran out of nitro, so :explosion_of_the_brain:

#

idl var

eternal night
#

Anyway, afaik sheep in java don't use hex under the hood

tardy delta
#

hmm yes intellij has some genius ideas

ivory sleet
#

Pretty sure you can disable the super call when gening

tardy delta
#

anyways to prevent me from using JavaPlugin.getPlugin(MyPlugin.class) cant i just do this in my mainclass so i can use MyPlugin.getInstance() afterwards?
private MyPlugin instance = JavaPlugin.getPlugin(this)?

#

and a getter

#

sounds stupid

ivory sleet
#

Well

#

You could in every other class use something like:
private final MyPlugin plugin = JavaPlugin.getPlugin(MyPlugin.class);

eternal night
#

DI is sobbing

ivory sleet
#

Though Idk why you’d have to depend on MyPlugin with every other class

young knoll
#

Wonder if that would be marked as a bad code practice

ivory sleet
#

That’s some sort of abstraction breach

ivory sleet
young knoll
#

The question always comes down to “Would it make it past premium inspection”

ivory sleet
#

🥲

ivory sleet
#

May I ask how come most of your classes depend on MyPlugin, the main plugin class instance?

young knoll
#

All the runnables

ivory sleet
#

Ah

tardy delta
#

i need the plugin

#

for uhh

#

configs, namespacedkeys etc

#

for some reason i lost the jetbrains annotation package :/

ivory sleet
#

Ah, sometimes you can delegate a certain functionality to another class then go on and pass that other class instance instead of your main class instance, for instance this would be a middle ordered class https://github.com/Conclure/cityrp-core/blob/master/paper/src/main/java/me/conclure/cityrp/paper/utility/concurrent/BukkitTaskCoordinator.java I guess, though the code isn’t great

GitHub

Contribute to Conclure/cityrp-core development by creating an account on GitHub.

tardy delta
#

i like the doggo 🙂

hybrid spoke
young knoll
#

Namespace keys work well as static fields

#

Or an enum

quaint mantle
#

no you didn't

tardy delta
#

meow

#

private static final DiscordBridgePlugin PLUGIN = DiscordBridgePlugin.getPlugin(DiscordBridgePlugin.class);

ivory sleet
#

That’s fine

#

But I mean there are better ways xD

tardy delta
#

you're right

#

maybe a time to switch to di

ivory sleet
#

Yeah di would make it a bit more loosely coupled

tardy delta
#

is this the same as instance = this in main class?

instance = getPlugin(getClass());
lost matrix
tardy delta
#

not anymore?

eternal night
#

There is a static parse method

lost matrix
#

I currently default on something like this:

public class NamespaceProvider {

  private static final String NAMESPACE = "MyPlugin".toLowerCase(Locale.ROOT);

  public static NamespacedKey create(final String key) {
    return NamespacedKey.fromString(NAMESPACE + ":" + key);
  }

}
tardy delta
#

oh

young knoll
#

I use the static getplugin method

lost matrix
#

This looks viable:

public class Namespaces {

  public static final NamespacedKey DAMAGE = NamespaceProvider.create("damage");
  
}
young knoll
#

?paste

undone axleBOT
young knoll
lavish hemlock
lost matrix
#

Ah i see

lavish hemlock
#
public interface Namespaces {
    NamespacedKey DAMAGE = NamespaceProvider.create("damage");
}
lost matrix
#

What you mean

#

No. I want verbosity. Implicit scopes and access modifiers are doodoo 💩

iron palm
#

is there a way to replace something in getStringList like getString?

lost matrix
iron palm
#

replaceall wasnt working or i was using it wrong

lost matrix
#
  1. Get the index of an element
  2. Write a new Object to that index
#

replaceall is a bulk operation and should also work

iron palm
lost matrix
# iron palm wasnt working i think

Something like this:

    final String oldElement = "foo";
    final String newElement = "baz";
    list.replaceAll((element) -> element.equals(oldElement) ? newElement : oldElement);

But thats a bit of overhead

iron palm
iron palm
#

uh guess i found an easier way
*not working

lost matrix
#

Another way would be this:

  public <T> void replaceFirst(final T oldElement, final T newElement, final List<T> list) {
    int replaceIndex = -1;
    for (int index = 0; index < list.size(); index++) {
      if (list.get(index).equals(oldElement)) {
        replaceIndex = index;
        break;
      }
    }
    if (replaceIndex > -1) {
      list.set(replaceIndex, newElement);
    }
  }
#

Hm this looks ugly

eternal night
#

Kind of useless to store the index there

#

Just set when found, won't run into a CME as you are accessing by index

iron palm
lost matrix
eternal night
#

Tbf if you only do equals there is also just List#indexOf

#

Which does the same

lost matrix
#
  public <T> void replaceFirst(final T oldElement, final T newElement, final List<T> list) {
    final int index = list.indexOf(oldElement);
    if (index > 0) {
      list.set(index, newElement);
    }
  }
#

...

hollow sand
#

Anyone know how I would be able to use custom textures with spigot?

eternal night
#

Like custom model data ?

hollow sand
#

ye

#

Like I have a png which I want to use, but Ik you have to use like packs n stuff

young knoll
#

You need a resource pack

eternal night
#

Which your resources pack then can map to a custom texture

hollow sand
#

I wanted to ask like

#

if y'all would know how to make a png into a json?

golden turret
#

hello, i would like to create multiple structures and they would work like a beacon. how could i do that

young knoll
#

Very carefully

eternal night
#

Work like a beacon in terms of giving potion effects to players ?

young knoll
#

You need some way to efficiently detect the structures

#

And then save their location

golden turret
golden turret
iron palm
golden turret
#

i will use like an activator so the player just right click and it detects the structure

#

but i dont know how to do it

stone sinew
maiden thicket
golden turret
maiden thicket
#

like store x1, y1, y1, x2, y2, z2

#

based on radius

#

and center of structure

#

and then if player walks in

stone sinew
maiden thicket
maiden thicket
stone sinew
#

I have to relook for the methods. One sec

golden turret
#

also, these structures are got from a schematic

#

but there is no problem, i can load them first

stone sinew
#

Well you said the player has to make them... so either check if all blocks match the schematic or create a shape based on the schematic and check the shape when the player places a block.

I'm still looking for the shape code

mortal hare
#
        PlayerConnection connection = ((CraftPlayer)holder).getHandle().b;
        Location loc = player.getLocation();
        PacketPlayInFlying.PacketPlayInPositionLook positionPacket = new PacketPlayInFlying.PacketPlayInPositionLook(
            loc.getX(),
            loc.getY(),
            loc.getZ(),
            loc.getYaw(),
            loc.getPitch(),
            player.isOnGround()
        );
        connection.sendPacket(positionPacket);
#

am i sending the wrong packet

#

or

#

what

chrome beacon
#

Probably

mortal hare
#

Entity Position and Rotation This packet is sent by the server when an entity rotates and moves.

#

this packet is sent by the server

#

maybe i should look inside packetwrapper git page

#

the same packet

#

i dont get it

next stratus
#

Hey, I wanna change a lot of blocks really fast but without lagging out a whole server what's the best way to do it?

golden turret
#

im cancelling the inventory click in 1.16 but when i do that i can see the hand doing the left click aanimation

#

also i can other players doing the same too

mortal hare
#

thus netty doesn't know how to sent received type packet back

#

and it should've been obvious for me since it doesnt have entityId inside its own constructor args

golden turret
golden turret
stone sinew
#

@golden turret Unfortunately I am not finding any exact code for the structures but you might have better luck. Look through portal generation and such. Code that would need to check for structures like lighting a nether portal or placing an ender eye in an end portal frame. Etc..

maiden thicket
#

Server#getStructureManager()

young knoll
#

I agree

#

1.17 all the way

stone sinew
#

Actually.... I'm not seeing that in 1.17.1

eternal night
golden turret
eternal night
#

Why does discord mobile remove the last bracket from my hyperlinks

tender shard
#

discord bad

stone sinew
eternal night
#

Probably horribly outdated local maven repo ?

stone sinew
#

Nope I don't use dependency managers

eternal night
#

Then a horribly outdated local spigot jar

stone sinew
#

Yeah probs. When was it added?

eternal night
#

Eeeh like maybe 3 weeks ago ?

#

Not long at least

stone sinew
#

Thats why then

#

I have a jar from a month ago

eternal night
#

That would do it yea

stone sinew
#

Is latest actually latest or is it still the base 1.17.1?

eternal night
#

Should be latest

#

When was it ever base 1.17.1

#

The structure API was added on the 5th of Oktober btw 😅

tender shard
stone sinew
tender shard
#

lol

eternal night
#

Real heros just look at the source code of a plugin to enjoy it

stone sinew
tender shard
#

wrong reply

#

I meant yapperyapps

stone sinew
#

I know lol. But no I won't. Only reason I use managers is for shading. Which I rarely do.

candid galleon
#

I use managers for dependencies

eternal night
#

I mean if you ever plan on working with multiple people you'll have to

tender shard
#

I still remember when someone wanted to introduce me to maven and I hated it 😄 now I couldn't live without it anymore

candid galleon
#

But I use the project manager IJ has for exporting

stone sinew
eternal night
#

Rip

stone sinew
#

I still hate github but started using it for new projects

#

Still rarely use it though cause i don't update those plugins xD

tender shard
#

github is awesome. when you're a student, you get tons of free stuff there 😄

maiden thicket
stone sinew
maiden thicket
#

o

stone sinew
#

Building the new version now.

#

Nope latest doesn't contain Bukkit.getStructureManager(). Trying 1.17.1

vale ember
#

Can someone help creating NPC with skin (1.8-1.17.1 support) or link to ready 1-2 class realization (not ready plugin)?

eternal night
#

A single class (or event two) that supports that many versions will probably be nearly impossible to find and if it exists is horribly ugly

vale ember
#

i have reflection utils, not count that

#

tinyprotocol

stone sinew
eternal night
#

Build tools.

#

Maybe your eclipse didn't index correctly

#

Latest should work perfectly fine

stone sinew
#

Odd. Both 1.17.1 and latest don't contain it.

stone sinew
vale ember
stone sinew
#

Ok just did latest again and recaf shows it in this one...

#

Yeap it shows in eclipse too. 🤷 IDK why the first 2 didn't work

vale ember
#

can someone please help, is there a way to make maven copy plugin jar into multiple directories at once????

grizzled briar
#

Hi there, I'm having some issues with getting the human entity of a player

#

I'm new to programming plugins in java

#

I have the player object from the commandSender

#

now I need the human entity of the player

young knoll
#

Why

grizzled briar
#

entity.openInventory