#development

1 messages Β· Page 130 of 1

cerulean birch
#

is there any simple to remove x amount of items of a specific material from a player's inventory, without iterating through the whole list? the api has a pretty easy method to figure out if the player has x much of a material, but not for removing .-.

inner jolt
cerulean birch
#

hm i'll try it out, ty

inner jolt
#

no problem πŸ‘

#

d;spigot PlayerInventory#removeItem(itemStack, items)

uneven lanternBOT
#
@NotNull
HashMap<Integer,ItemStack> removeItem(@NotNull ItemStack... items)
throws IllegalArgumentException```
Description:

Removes the given ItemStacks from the inventory.

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

The returned HashMap contains what it couldn't remove, where the key is the index of the parameter, and the value is the ItemStack at that index of the varargs parameter. If all the given ItemStacks are removed, it will return an empty HashMap.

It is known that in some implementations this method will also set the inputted argument amount to the number of that item not removed from slots.

Parameters:

items - The ItemStacks to remove

Throws:

IllegalArgumentException - if items is null

Returns:

A HashMap containing items that couldn't be removed.

lyric gyro
#

Does anyone know how to make a right click event where someone right clicks there sword and teleports x amount of blocks?

neon wren
#

Use the interaction event? check if the item right clicked is a sword, grab the location and randomly change the location by offsetting it from the original?

lyric gyro
#

Could you make that a little more in code language sorry haha!

neon wren
#

I'm not trying to spoonfeed you the code.
Use PlayerInteractEvent -> check if player#getItem().getType() is the sword -> Use player#getLocation() to get the current location and randomly determine if you are simply going to change the x, or will do the others -> Set the player's location to the clone of the player's original location and add the offset to it.

lyric gyro
#

ohhh okay cheers that makes sense

neon wren
#

It's based on the latest library by the way, but you'd also need to check if they have a item that isn't air.

lyric gyro
#

okay cool

pearl topaz
#

when using a factory, what is the proper way to deal with enums where you have "subtypes"? for example i have:

#

is there a better way to do the ARRAY_X enums

#

i don't want to have to write a new line for every ARRAY_X type if possible, and my ArrayLogger is a generic class parameterised by this X

kind granite
#

thats not really an appropriate time to use an enum

pearl topaz
kind granite
#

because you have generics

#

are you still trying to do that mutable container thing

pearl topaz
#

is this a bad idea then

high edge
#

Probably

kind granite
#

we told you this yesterday

pearl topaz
#

which part? this is new

high edge
#

I'd assume the entire thing from what I've been reading :3

pearl topaz
#

i dont really mind that part

#

im just experimenting with factories

kind granite
#

do you really need a factory here

pearl topaz
#

well it's a cleaner way of wrapping all the loggers together i guess

kind granite
#

no

pearl topaz
#

and im initialising them from a config file

#

so i can do something like

#

MyEnum.valueOf("Foo")

kind granite
#

do you know the shape of the data from the config file

pearl topaz
#

yes

#

but for the type of logger

#

i'm not sure a better way to do it

kind granite
#

use a dao

pearl topaz
#

ok but even if have a data class like

data class loggerValue(type: LoggerType, name: String, sampleRate: Long)
```how does that make it easier to actually instantiate the loggers
#

unless i have some factory that can accept type and return an object of the type of logger i want

pearl topaz
kind granite
#

the whole idea of what you're doing

#

use a dao

hard wigeon
#

How does one get a list of ConfigurationSections in spigot's config API?

#

eg.

- test: 1
  test2: 2
- test: 3
  test4: 4
#

I'd want to serialize that into a list of test and test2

#

ConfigurationSection#getList doesn't allow for a custom object

fiery pollen
#

What if you use ConfigurationSection#getKeys(false) and then just get the configurationsection using ConfigurationSection#getConfigurationSection() and add the configurationsection to a list?

hard wigeon
fiery pollen
#

ow yeah sorry

#

That example

#

is that even valid yaml?

hard wigeon
#

should be, yeah?

#

it's a list of objects

fiery pollen
#

ow yeah

hard wigeon
fiery pollen
#

and what about getValues()?

#

nvm

#

but if you do getKeys()

#

What would you get?

hard wigeon
#

let me find out

broken elbow
#

idk if its possible with spigot's yaml stuff. I know its possible with libs like ConfigMe tho

#

wait

#

@hard wigeon don't you just use getList?

#

oh you said it doesn't allow custom objects?

#

you sure?

hard wigeon
#

not that I can figure out

#

does spigot's have object deserialization?

broken elbow
#

yeah.

#

see md's answer

hard wigeon
#

ah

pearl topaz
#

i appreciate the help but im not understanding what you are suggesting

wintry shadow
#

hello ! How can i save data with my plugin ?

#

whats is the best method ?

slim vortex
#

An easy method is by using YAML or JSON

#

SnakeYAML is built inside of the Spigot API, so that's a straightforward option.

wintry shadow
#

okok

wintry shadow
slim vortex
#

Google's GSON library is nice.

wintry shadow
#

ty

wintry shadow
winged pebble
#

I recommend just trying it out

#

and seeing what you think

slim vortex
#

It's neither easy nor hard. It's a good option in some circumstances.

wintry shadow
#
public class Main extends JavaPlugin {

    private Connection connection;

    @Override
    public void onEnable() {
        System.out.println("ON");

        try {
            Connection con = getConnection();
            assert con != null;
            PreparedStatement posted = con.prepareStatement("INSERT INTO users (first_name, last_name, num_points) " + "VALUES ('ThΓ©o', 'test', 1)");
            posted.executeUpdate();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static Connection getConnection() throws Exception {
        try {
            String driver = "com.mysql.jdbc.Driver";
            String url = "jdbc:mysql://localhost:3306/server_test";
            String username = "root";
            String pasword = "";
            Class.forName(driver);

            Connection conn = (Connection) DriverManager.getConnection(url,username,pasword);
            System.out.println("Connected");

            Statement st = conn.createStatement();

            return conn;


        }catch (Exception e){System.out.println(e);}

        return null;
    }


}
#

ok its work

#

fiouf

#

it's not very clean but it works

lyric gyro
#

I'm no Kotlin expert but I'm fairly sure all default parameters must go at the end, after mandatory ones

#

alternatively you could do blah("blah", sampleRate = 123)

#

not sure if that would work

pearl topaz
#

thanks, i just fixed it with that example

#

but i'll put it at the end anyways

limber lagoon
#

Can somebody pls help me kill my bot that's running through a raspberry pi?

#

I forgot the command πŸ₯²

winged pebble
#

πŸ”¨

#

That should do it

limber lagoon
#

Hammer?

#

Oh

winged pebble
#

slam slam, then no more bot

limber lagoon
#

Right

winged pebble
#

Or pi πŸ˜›

limber lagoon
#

I guess I'm just slow in the head

neon wren
limber lagoon
#

Unfortunately 😦

#

I also can't get my bot to start

neon wren
#

EDITED: So you can't stop the task, nor start your bot now*

#

Discord bot?

limber lagoon
#

Sorry I should've clarified, I wanted to end the screen for my bot

#

But the bot never actually started

#

The command I'm using to try and start the bot is screen java -jar **BotName**.jar

neon wren
#

To end a terminal instance, have you tried CTRL + D, there will be no warnings attached.

limber lagoon
#

Oh alright, thanks

#

Let me try that now

hoary scarab
#

screen -r id

neon wren
#

as usually on a screen you'd run for example: java --version to see what sdk you are running.

limber lagoon
#

Hm that's weird, I remember using this exact command a few months back and it worked fine. I'll try that also, thanks again!

limber lagoon
hoary scarab
#

screen -list

dusky harness
#

screen -S screen_name -X quit to kill it

limber lagoon
#

Ok that's a lot of information lol let me write this down somewhere

dusky harness
#

and ctrl A -> D (without ctrl) to exit without terminating screen

neon wren
#

Possibly you meant sudo instead of screen to run it?

limber lagoon
#

Possibly...

#

Sorry, give me a second to try all these new commands and give feedback πŸ˜…

neon wren
#

For example, you cd into the folder with the jar, and then run sudo java -jar BotName.jar

limber lagoon
#

How do I cd into a specific folder?

#

I tried cd home/pi as well as cd home\pi which is my bot's folder

#

Ah

#

Nevermind

#

Alright so far I should be good, thanks all!

#

Ah wait a minute, it seems I'm unable to type any further commands after starting my bot

#

It just sends me to an empty line

#

Which means I can't exit the terminal without terminating

pearl topaz
#

anyone know why gradle might be giving me

Error: Could not find or load main class telemetryapp.TelAppKt
Caused by: java.lang.ClassNotFoundException: telemetryapp.TelAppKt
```i literally have `src/main/java/telemetryapp/TelApp.kt`
lyric gyro
#

. is not a valid class/package identifier afaik

pearl topaz
#

mistype

lyric gyro
#

a

pearl topaz
#

i tried adding

sourceSets {
    main.java.srcDirs = []
    main.kotlin.srcDirs = ['src/main/java', 'src/main/kotlin']
    main.resources.srcDirs = ['src/main/resources']
}
```to `build.gradle.` but doesnt work still
dusky harness
#

thats how you exit a screen without terminating

#

not sure if theres another way to exit

icy thistle
#

how would I send someone to jail when coding a plugin

#

I'm trying to edit this plugin so it send a player to jail rather then setting their gamemode to spectator when they get killed

#
    eliminate(Player player, Player killer) {
        player.setGameMode(GameMode.SPECTATOR);
        player.sendMessage(ChatColor.RED + "You have been eliminated!");

        InventoryUtils.giveHeadItem(killer, player);

        addElimination(player);
    }
icy thistle
#

edit: how do I ban someone

dense drift
#

d;spigot BanList#addEntry

uneven lanternBOT
#
@Nullable
BanEntry addBan(@NotNull String target, @Nullable String reason, @Nullable Date expires, @Nullable String source)```
Description:

Adds a ban to the this list. If a previous ban exists, this will update the previous entry.

Parameters:

target - the target of the ban
reason - reason for the ban, null indicates implementation default
expires - date for the ban's expiration (unban), or null to imply forever
source - source of the ban, null indicates implementation default

Returns:

the entry for the newly created ban, or the entry for the (updated) previous ban

dense drift
#

@icy thistle

icy thistle
#

I'm using IntelliJ IDEA how do I compile a plugin into a .jar file its been a while since I've done this

dense drift
#

Use a build tool like maven / gradle

icy thistle
#

I have plugin running the command jail playername
however the server says Player not found. when I use player.getDisplayName()
but it works when I manually run the commands

Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "jail " + player.getDisplayName() + " dead");
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "unjail " + player.getDisplayName());
[20:51:30 INFO]: CONSOLE issued server command: /jail TCubed3 dead
[20:51:30 INFO]: Error: Player not found.
[20:51:34 INFO]: jaredy00 issued server command: /jail TCubed3 dead
[20:51:38 INFO]: CONSOLE issued server command: /unjail TCubed3
[20:51:38 INFO]: Error: Player not found.
[20:51:44 INFO]: jaredy00 issued server command: /unjail TCubed3
dense drift
#

player.getName()

icy thistle
#

whats the difference

dense drift
#

Thats the proper method

#

And, is there a player named TCubed3 on your server?

icy thistle
#

yes

dense drift
#

Ah

#

Are you running the SAME command in-game?

icy thistle
#

TCubed3

#

with the d

dense drift
#

Yeah, typo

icy thistle
#

ok then yes

dense drift
#

Hm

icy thistle
#

and it worked ingame

dense drift
#

/jail TCubed3 dead?

icy thistle
#

I'm using essentials jail command

dense drift
#

The command syntax is /jail <jail> <player> <duration> (reason) afaik

icy thistle
#

duration and reason are both optional

#

for whatever reason changing it to player.getName() worked

dense drift
#

Good

#

displayName might contain formatting, like colors

winged pebble
#

This still isn't the bot channel

quasi kraken
#

Hi, so I want to make a GUI Inventory, I have the inventory made, but not sure how to remove the players from moving items in it/adding commands to a head that teleports you to a gamemode.

bitter basin
#

makes things 100 times easier

#

To answer your question otherwise, you would wanna look for InventoryClickEvent, check if its the right inventory by name or smth and then handle your options

#

it will get complex quite quick which is why i would just use the library

spiral prairie
#

sus

prisma briar
#

Umm, I have installed XAMPP with PHP 8.1.4 but when I check my php version using php -v the version is still 8.0.3, it should be 8.1.4. I uninstalled XAMPP that were using PHP 8.0.3 and I install it again with the newest PHP version.

shell moon
#

i installed xampp 4 or 5 years ago, never updated it. still working

prisma briar
#

Some of my project require newest version of PHP and I have tried to only update the php but I ran into some errors and then I decided to reinstall the xampp.

pearl topaz
#

my understanding of suspend fun was that it would wait, but intellij is telling me i dont need suspend

brittle thunder
#

It waits with both suspend and without

#

What suspend does it lets kotlin break down the method call to call the continuation from its result rather than blocking the current thread

#

Reduces chances of task starvation

pearl topaz
#

i read that i'm not meant to mark it as suspend unless forced to, so best to remove that and keep the rest as is?

#

i wasn't sure if it's a good idea to have a coroutine inside each of these that deals with the redis

#

probably not necessary right

brittle thunder
leaden sinew
#

That’s unnecessary. I would go with try {} catch (Exception whoCares) {}

pearl topaz
leaden sinew
pearl topaz
#

no what i did

leaden sinew
#

How are messages valued?

strong wing
#

E][

lyric gyro
#

so true

limber lagoon
#

So I'm looking through the jda docs right

lyric gyro
#

so true

hushed badge
#

right

lyric gyro
#

left

limber lagoon
#

And I'm trying to get some slash commands running, and I see that you need to add jda.upsertCommand("ping", "Calculate ping of the bot").queue(); in your main method for it to work. So I'm wondering if the method was changed or smth

#

My bad I was caught up in a convo didn't get to finish

#

Since I can't use that method

#

Doesn't seem to be recognized

dusky harness
limber lagoon
#

Ah, you know that would explain it. I'd need to create a JDA instance, but what should I initialize it to?

#

I already have a JDABuilder atm

limber lagoon
#

I don't have a JDA instance atm, the code I pasted above was right from the docs

dusky harness
#

JDABuilder#build

limber lagoon
#

I mistaked their jda for a JDABuilder

limber lagoon
dusky harness
#

JDA jda = JDABuilder.createDefault("token").build();

lyric gyro
#

smh dkim

dusky harness
#

πŸ˜ƒ

limber lagoon
#

So I don't need a JDABuilder?

dusky harness
#

well

#

not a JDABuilder variable, no

limber lagoon
dusky harness
#

as seen here

limber lagoon
#

Oh I didn't think it mattered

#

The order of building it, I mean

dusky harness
#
JDA jda = JDABuilder.createDefault(Constant.token) // should be TOKEN btw
              .setActivity(etc)
              .setStatus(etc)
              .build();
 ``` 😌
limber lagoon
#

Why should it be TOKEN

dusky harness
#

naming conventions

#

constants = UPPERCASE_WITH_UNDERSCORES

limber lagoon
#

Oh okay

#

I'll change that

#

Seems like there isn't a setActivity() method though

#

Wait

#

I spoke too soon

#

How can I find the name of the screen I'm on atm?

#

For termius

dusky harness
limber lagoon
#

It says detached πŸ₯²

#

I suppose it doesn't matter right? I was only trying to kill it

#

Well, how do I reattach the screen?

dusky harness
#
screen -R NAME -> Creates a new screen
screen -r NAME -> Resumes screen
screen -X -S NAME kill -> Delete screen
ctrl + a -> d -> Close screen
limber lagoon
#

I appreciate it, lemme copy paste this to the notepad 😎

#

This way, I won't ask the same question twice anymore

lyric gyro
#

ya bet

limber lagoon
#

Is killing a screen the same as deleting a screen?

dusky harness
#

yes

limber lagoon
#

If so, why did you recommend I use screen -S screen_name -X quit to kill a screen earlier?

dusky harness
limber lagoon
#

πŸ₯²

#

So which one should I use? 😳

dusky harness
#

kill

limber lagoon
#

ah

#

well ok I'll use the kill one

#

It seems the kill one worked

dusky harness
#

nice

limber lagoon
#

All is good ||so far||, so thank you!

somber gale
#

I'm quite inexperienced with Gson, so excuse if this is a stupid question, but how would a Java class need to look like if I want to deserialize this JSON input to one?

{
  "file_version": 1,
  "entry_1": {
    "major": "1.x",
    "version": "1.0.0"
  },
  "entry_2": {
    "major": "1.x",
    "version": "1.1.0"
  },
  "entry_3": {
    "major": "2.x",
    "version": "2.0.0"
  }
}

Some notes:

  • entry_n can be any String, not just entry_n
  • There can be any amount of entry_n entries in the JSON.
  • file_version will always be named like that and always has a whole number (no decimals).
  • major and version will always return String and will always be named like this.

So... Does Gson allow this kind of deserialization?

dusty frost
#

probably need to add an array for the entries

#

you have to know the schema you want to deserialize

#

so it would look like json { "file_version": 1, "entries": [ "entry_1": { "major": "1.x", "version": "1.0.0" }, "entry_2": { "major": "1.x", "version": "1.1.0" }, "entry_3": { "major": "2.x", "version": "2.0.0" } ] }

#

then you would need an object for entries

lyric gyro
#

err, for the entries just

"entries": [
  {
    "major": "...",
    "version": "..."
  },
  {
    ...
  }
]

otherwise it would need to be an object

hoary scarab
#

I think he wants the class structure to convert from gson to a class (and back).

lyric gyro
#

yeah but if you have each entry separately rather than in an array then you would need

class Thing {
  int fileVersion;
  Version entry1;
  Version entry2;
  Version entry3;
  Version entry3;
  ...
}

one class for each # of entries

hoary scarab
#

Or a map

lyric gyro
#

Yeah, bottom line is they need to be in a collection of sorts

hoary scarab
#
public class <class> {
    int fileVersion;
    Map<String, ObjectClass> entries;
}

public class ObjectClass {
    String major;
    String version;
}
``` or something.
queen plank
#

I want to rotate a shape made from particles, in this case a double helix. I have the list of vectors representing the helix, and it works fine. However, I want it to point in the direction the player is looking. I do this by getting the players yaw and pitch and feed it into this rotate function. All input values are correct, however my math is so off, I tried following a guide but it did not go any better. The only thing that actually works is the pitch while facing south. I spawn the particles like this:

World w = player.getWorld();
for (Vector v : shape.getVectors()) {
w.spawnParticle(Particle.SCRAPE, location.add(v.getX(), v.getY(), v.getZ()), 10);
  //Revert back to the original location values
  location.subtract(v.getX(), v.getY(), v.getZ());
}

Here is my code for rotating the helix: https://paste.helpch.at/terepasufu.cpp
The helix is pre-calculated and stored in HELIX.getShape()

I copied parts of my actual code to the paste as I have a lot more and only need help with this part and want to keep the code here to a minimum. So if there are any misspelled variable names or missing parenthesis, that is why. The other code does not interfere with this in any way and only handles other shapes and their parameters.

wintry shadow
#

hello ! how do I run a MySql query to find if a column contains a character string.

Like this:

If Swaford_ exist in column "Owner" in table "Town"

#

I tried that :
"SELECT * FROM town WHERE owner LIKE '"+ sender.getName()+ "'", "owner"

#

public void readData(String sqlRequest, String getResultString){
        try {

            Connection con = getConnection();

            assert con != null;
            PreparedStatement statement = con.prepareStatement(sqlRequest);

            ResultSet result = statement.executeQuery();

            while (result.next()){
                System.out.println(result.getString(getResultString));
            }

        }catch (Exception e){System.out.println(e);}
    }
wintry shadow
#
    public void readData(String sqlRequest){
        try {

            Connection con = getConnection();

            assert con != null;
            PreparedStatement statement = con.prepareStatement("SELECT Owner FROM town WHERE Owner='Swaford_'");

            ResultSet result = statement.executeQuery();

            while (result.next()){
                System.out.println(result.getString("Owner"));
            }

        }catch (Exception e){System.out.println(e);}
night ice
#

If you want to select the row of the owner, it will be something like

SELECT * FROM TABLE_NAME WHERE owner = 'NAME';

wintry shadow
#

dosen't work

#

i dont understand

night ice
wintry shadow
#

no error :/

#

oh fuck me

#

lol i am executing a function before the command

#

sry

#

mb

#

x)

brave swan
#

Hi, i've got a problem, i search to get the ingredient's list of a craft for a GUI that show the item's craft in this GUi, but i don't know how. Sorry for my bad English

    public static void createItemCraftGUI(Player player, ItemStack item, ItemMeta meta) {
        itemCraftGUi = Bukkit.createInventory(null, InventoryType.WORKBENCH, "Craft " + item.getItemMeta().getDisplayName());
        List<ItemStack> itemList = new ArrayList<>();
        for(Recipe recipe : Bukkit.getServer().getRecipesFor(item)) {
            if (recipe instanceof ShapedRecipe) {
                ShapedRecipe shaped = (ShapedRecipe) recipe;
                itemList.add(Bukkit.getServer().getRecipesFor(item));
                for (int i = 0; i < itemList.size(); i++) {
                    itemCraftGUi.setItem(i, (ItemStack) Bukkit.getServer().getRecipesFor(item).get(i));
                }
            }
        }
        player.openInventory(itemCraftGUi);
    }
#

I know they are error but i just search how can i get ingredient list

hoary scarab
brave swan
#

I don't know i search many solution, i want to get the necessary's list of an item to be craft

hoary scarab
#
public static void createItemCraftGUI(Player player, ItemStack item, ItemMeta meta) {
    itemCraftGUi = Bukkit.createInventory(null, InventoryType.WORKBENCH, "Craft " + item.getItemMeta().getDisplayName());
    for(Recipe recipe : Bukkit.getServer().getRecipesFor(item)) {
        if (recipe instanceof ShapedRecipe) {
            ShapedRecipe shaped = (ShapedRecipe) recipe;
            int slot = 0;
            for(Entry<Character, ItemStack> entry : shaped.getIngredientMap().entrySet()) {
                itemCraftGUI.setItem(slot, entry.getValue())
                slot++;
            }
            break;
        }
    }
    player.openInventory(itemCraftGUi);
}
``` Or something like this.
lyric gyro
#

hey so im currently working on creating a prefix plugin for my server i have textComponents working however i cant seem to workout how to remove the default username from the chat messages, how would i do this?

brave swan
hoary scarab
#

Also add a null check before setting the item.

icy shadow
#

.entrySet()

hoary scarab
#

^^^

brave swan
hoary scarab
brave swan
hoary scarab
#

Also let me see your code

brave swan
hoary scarab
#

Debug the ingredientmap. I thought it had a char for every slot.

brave swan
hoary scarab
#

just add a message output in the for loop and as the string put the key and value.

brave swan
hoary scarab
#

nope entry.getKey() + " | " + entry.getValue()

hoary scarab
#

Let me see the code with the debug

brave swan
hoary scarab
#

add slot to the debug

hoary scarab
#

put the debug before slot++

hoary scarab
#

change int slot = 0 to 1

#

slot 0 is result mybad

brave swan
#

Thanks

#

it work

#

You're the king

#

I love you

hoary scarab
#

Also there can be multiple recipes for the same itemstack so when you want you can animate the recipe. (I think essentials does this with /recipe)

brave swan
brave swan
#

I've got multiple craft for cobblestone but with itemeta different

#

Cobblestone Tier I, Tier II, Tier III,... like compressed cobblestone

#

But

#

I think when i use Recipe recipe : Bukkit.getServer().getRecipesFor(item) , it's return the bad recipe

hoary scarab
#

You gotta account for that.

#

Modify your code anc check if its the recipe you want to display

brave swan
hoary scarab
#

yeap but like I said the items can still have multiple recipes.

brave swan
hoary scarab
#

Well then again... you have to code accordingly lol. Especially for custom items you have to check the recipe.

hoary scarab
#

πŸ‘

wintry shadow
#

i'm come back. I created database on my server and connect my plugin with this. When i uss Laragon and setup a local data base, its perfect work.

[17:44:35] [Server thread/INFO]: The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
[17:44:35] [Server thread/WARN]: java.lang.NullPointerException
[17:44:35] [Server thread/WARN]:        at ch.swaford.ashdale.MySqlClientManager.insertData(MySqlClientManager.java:40)
[17:44:35] [Server thread/WARN]:        at ch.swaford.ashdale.commands.CommandTownCreate.onCommand(CommandTownCreate.java:38)
[17:44:35] [Server thread/WARN]:        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45)
[17:44:35] [Server thread/WARN]:        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149)
[17:44:35] [Server thread/WARN]:        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchCommand(CraftServer.java:761)
[17:44:35] [Server thread/WARN]:        at net.minecraft.server.v1_16_R3.PlayerConnection.handleCommand(PlayerConnection.java:1936)
[17:44:35] [Server thread/WARN]:        at net.minecraft.server.v1_16_R3.PlayerConnection.c(PlayerConnection.java:1779)
#
[17:44:35] [Server thread/WARN]:        at net.minecraft.server.v1_16_R3.PlayerConnection.a(PlayerConnection.java:1732)
[17:44:35] [Server thread/WARN]:        at net.minecraft.server.v1_16_R3.PacketPlayInChat.a(PacketPlayInChat.java:49)
[17:44:35] [Server thread/WARN]:        at net.minecraft.server.v1_16_R3.PacketPlayInChat.a(PacketPlayInChat.java:1)
[17:44:35] [Server thread/WARN]:        at net.minecraft.server.v1_16_R3.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:28)
[17:44:35] [Server thread/WARN]:        at net.minecraft.server.v1_16_R3.TickTask.run(SourceFile:18)
[17:44:35] [Server thread/WARN]:        at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeTask(SourceFile:144)
[17:44:35] [Server thread/WARN]:        at net.minecraft.server.v1_16_R3.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23)
[17:44:35] [Server thread/WARN]:        at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeNext(SourceFile:118)
[17:44:35] [Server thread/WARN]:        at net.minecraft.server.v1_16_R3.MinecraftServer.bb(MinecraftServer.java:1061)
[17:44:35] [Server thread/WARN]:        at net.minecraft.server.v1_16_R3.MinecraftServer.executeNext(MinecraftServer.java:1054)
[17:44:35] [Server thread/WARN]:        at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.awaitTasks(SourceFile:127)
[17:44:35] [Server thread/WARN]:        at net.minecraft.server.v1_16_R3.MinecraftServer.sleepForTick(MinecraftServer.java:1038)
[17:44:35] [Server thread/WARN]:        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:970)
[17:44:35] [Server thread/WARN]:        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:273)
[17:44:35] [Server thread/WARN]:        at java.lang.Thread.run(Unknown Source)

#

String url = "jdbc:mysql://hihihiihihihihihi:3306/minecraft";

#

and my mysql service is running

formal crane
#

hey, i am trying to detect a packet with protocollib but i get the following error: https://paste.razerstorm.be/iduwigopof.sql
(protocolLib is installed)
(this error pops up at startup/reload)
This is the code i tried (in the onEnable):

        ProtocolManager manager = ProtocolLibrary.getProtocolManager();

        if(getServer().getPluginManager().getPlugin("ProtocolLib") != null ){
            manager.addPacketListener(new PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Play.Client.POSITION) {
                @Override
                public void onPacketReceiving(PacketEvent e) {
                   //handlePing(e.getPacket().getServerPings().read(0));
                }
            });
        }else{
            getLogger().severe("ProtocolLib is niet geinstalleerd op deze server!");
        }```
And this is my gradle import:
```gradle
    maven {
        url = "https://repo.dmulloy2.net/repository/public/"
    }```
```gradle
    compileOnly 'com.comphenix.protocol:ProtocolLib:4.7.0'

anyone that knows how to solve the error?

dense drift
#

Is the plugin version 4.7.0?

formal crane
wintry shadow
#

'm come back. I created database on my server and connect my plugin with this. When i uss Laragon and setup a local data base, its perfect work.

#

[17:44:35] [Server thread/INFO]: The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

burnt sonnet
#

Hey gifs showing like links no pictures

#

How fix that

grim oasis
#

Where? and is this development related?

burnt sonnet
#

Idk where to write

grim oasis
#

you want to send a gif here? just send the link

#

you won't be able to embed it

burnt sonnet
#

If someone send gifs a see links

grim oasis
#

Where?

burnt sonnet
#

On every server

grim oasis
#

Discord?

burnt sonnet
#

Yes

grim oasis
quaint skiff
#

Hi, I wanted to code a plugin which gives every player a random item which he has to collect to get a reward. So I made a hashmap<UUID, Material> but every time I get to the point if(forceItem.containsKey(uuid)) it doesnΒ΄t do the rest of the event though it has my UUID with a random material Saved in the hashmap

grim oasis
#

?paste

neat pierBOT
#
FAQ Answer:

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

grim oasis
#

send the class over

#

or whatever relevant code you have

quaint skiff
grim oasis
#

Have you tried any debug messages?

quaint skiff
#

Yes because of that I know which line of code the problem is

grim oasis
#

so let's add some more

#

logger forceItem.containsKey(uuid)
loop map and log each uuid
log uuid

#

Does it proceed to if(item != null)?

quaint skiff
#

no it only goes till if(forceItem.containsKey(uuid))

grim oasis
#

okay, so try logging those 3 things i listed

#

see what they're saying

quaint skiff
#

what do you mean with logger forceItem.containsKey(uuid)? like after the if?

grim oasis
#

log it

#

log all those values

#

Bukkit.getLogger().info(forceItem.containsKey(uuid)+"");

#

or however you want to do your debug message

grim oasis
quaint skiff
grim oasis
#

wym

#

like, blank like?

#

null?

quaint skiff
#

no there just wasnt a message

grim oasis
#

where did you put them

quaint skiff
#

@EventHandler public void onInventoryClick(InventoryClickEvent e) { Inventory inv = e.getClickedInventory(); Player p = (Player) e.getWhoClicked(); UUID uuid = p.getUniqueId(); p.sendMessage(uuid); for(UUID uuid1 : forceItem.keySet()) { p.sendMessage(uuid1); } Bukkit.getLogger().info(forceItem.containsKey(uuid) + ""); if(forceItem.containsKey(uuid)) { p.sendMessage("Player found"); Material getForceItem = forceItem.get(uuid); if (inv != null && inv.contains(getForceItem)) { giveReward(p); p.sendMessage("reward"); } } }

grim oasis
#

?codeblocks

neat pierBOT
#
FAQ Answer:

Use codeblocks for formatting code or configuration files:
```<language name>
<your code here>
```

For example:
```yaml
test:

  • β€œhi”
  • β€œthere”
    ```

Produces:

test:
- β€œhi”
- β€œthere”```
grim oasis
#

Try logging the uuid instead

#

and maybe log the player

#

p.sendMessage(uuid); not even this sent to the player?

quaint skiff
quaint skiff
grim oasis
#

ah

#

and are you sure you set the item in the map

#

how did you do that?

#

oh i see the command, did you debug that?

quaint skiff
#

Yes Java public void setForceItem(Player p) { setForbidden(forbidden); List<Material> items = new ArrayList(Arrays.asList(Material.values())); items.removeIf((material) -> {return !material.isItem();}); items.removeIf((material) -> {return forbidden.contains(material);}); int randomNumber = random.nextInt(items.size()); Material mat = items.get(randomNumber); forceItem.put(p.getUniqueId(), mat); p.sendMessage("Β§4Manhunt Β§8| Β§7" + mat); p.sendMessage(forceItem.toString()); if(p.getInventory().contains(mat)) { giveReward(p); }

grim oasis
#

try debugging the command and/or the setForceItem method

quaint skiff
#

setForceItem is already debugged because of p.sendMessage("Β§4Manhunt Β§8| Β§7" + mat); right?

grim oasis
#

and you get that message when you run the command?

quaint skiff
#

yes

grim oasis
#

instead of the forceitem.tostring try looping the keyset

#

log that and see

#

because that would be right after adding it...

quaint skiff
#

I am the only one added so its only one uuid

grim oasis
#

ok wait

#

we're missing a message here I realize

#

we should have player uuid:
forceitems uuids:
player:
contains:

grim oasis
#

or we missed somethin

quaint skiff
#

yeah because i only wrote the command and not did the event

grim oasis
#

is command just the label?

quaint skiff
#
            Bukkit.getLogger().info(uuid + "");
        }```
quaint skiff
# grim oasis is `command` just the label?
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        for(Player p : Bukkit.getOnlinePlayers()) {
            setForceItem(p);
            Bukkit.getLogger().info("command");
        }
        return false;
    }```
grim oasis
#

send your class

#

imma make some debug messages

#

?paste

neat pierBOT
#
FAQ Answer:

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

quaint skiff
grim oasis
hoary scarab
#

Any reason why getCommand("command").setAliases(Arrays.asList("alias_1", "alias_2")) wouldn't work?

#

Like if I type the aliases the command doesn't run.

grim oasis
#

command executor?

hoary scarab
#

yes

grim oasis
#

what it look like

#

have you checked the actual cmd.getName() value

#

in the past, when I type an alias it goes through as the name

#

no idea why

hoary scarab
#

yeah outputs command

grim oasis
#

ooft

quaint skiff
# grim oasis https://paste.helpch.at/wobugesuxu.java

[20:24:45 INFO]: sfi | 541c6d78-b2c5-4125-ad36-70c272e844e2
[20:24:45 INFO]: cmd | 541c6d78-b2c5-4125-ad36-70c272e844e2
[20:24:51 INFO]: pUuid: 541c6d78-b2c5-4125-ad36-70c272e844e2
[20:24:51 INFO]: player: CraftPlayer{name=Sensaicraft}
[20:24:51 INFO]: event | false

grim oasis
#

brother

#

wot

#

somebody explain this witchcraft?

queen plank
#

Wait, this public void setForceItem(Player p) and public HashMap<UUID, Material> forceItem = new HashMap<>(); are both non static. Are you making a new object every time you add a player?

#

Might that be why?

grim oasis
#

he never makes a new map though that I see

queen plank
#

Adding to the Sensaicraft discussion

grim oasis
#

and in the command you can see the value(s)

queen plank
#

Well i creates a new one with every object

#

and if they make one every time they add a player

#

it wont add

#

to the same map as the listener one

#

try making them static

grim oasis
#

i might be missing something, but ya give that a go

#

see what happens

queen plank
#

I cant come up with anything better

quaint skiff
hoary scarab
grim oasis
#

I don't get why you see the values in the onCommand method though

grim oasis
#

does it run at all

#

the executor

hoary scarab
#

nope

grim oasis
#

hmm, I wonder if you have to update something else after setting aliases. commands are confusing to me

hoary scarab
#

If I add the aliases directly to the plugin.yml they work.

quaint skiff
queen plank
grim oasis
#

ok well that's progress

#

still confused sadly

hoary scarab
icy thistle
#

when I download source code for a plugin project how do I know how to compile it so it works the way intended

#

same for java version used

hoary scarab
#

So it looks like I need to mess with the command map because setAliases doesn't do anything after registering the command🀦

grim oasis
#

ya... figured it was something weird like that

queen plank
hoary scarab
# grim oasis ya... figured it was something weird like that
public void setBaseAliases() {
    if(!getConfig().isSet("Commands.Base_Aliases")) return;

    CommandMap commandMap = null;
    try {
        final Field f = Bukkit.getServer().getClass().getDeclaredField("commandMap");
        f.setAccessible(true);
        commandMap = (CommandMap) f.get(Bukkit.getServer());

        Command cmd = commandMap.getCommand("command");
        cmd.unregister(commandMap);
        cmd.setAliases(getConfig().getStringList("Commands.Base_Aliases"));
        commandMap.register("command", cmd);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
quaint skiff
queen plank
#

Did you Copy paste or change it yourself?

quaint skiff
#

I changed it my self but kept an eye on the problems tab and there was nothing

queen plank
#

Try just copy pasting it, see what happens. I'm not saying you have, but you could've missed something

worn jasper
#

uh any ideas why I could be getting this?
Error:

Caused by: java.lang.ClassCastException: class java.util.UUID cannot be cast to class java.lang.String (java.util.UUID and java.lang.String are in module java.base of loader 'bootstrap')```
Line of the issue:
```JAVA
public boolean isOwnerOfClan(UUID uuid, @Nullable String clanId) {
  return db.getString("clans." + clanId + ".owner").equals(uuid.toString());
}

specifically, the issue seems to be uuid.toString()?

#

like, is it normal that I can't cast it to a string?

queen plank
#

UUID.toString() works fine. There should be no problems with it. I can't see anything wrong

#

You can't cast it though

#

This UUID.toString() is fine, (String) UUID is not

broken elbow
#

aby chance your db stores it as a UUID instead of a String?

worn jasper
#

okay no

#

it's a string

#

String.valueOf(uuid) that's how I store it

#

unless... okay found the issue

quaint skiff
worn jasper
#

ty guys

queen plank
#

Nice! Happy to help! πŸ™‚

queen plank
barren ore
#

Hi would anyone be able to help me why I am receiving a null here? :

java.lang.NullPointerException
at me.fiftyone.bungee.core.CoreListener.serverSwitch(CoreListener.java:98)

What I am trying to do is for a player to be sent a title when switching servers
Here is the code:

final Title t = ProxyServer.getInstance().createTitle();
                String sectorMsg = StringUtils.replace(Bungee.getInst().getApi().getGeneralConfig().SECTOR_CHANGE, "%old-sector%", e.getFrom().getName());
                sectorMsg = StringUtils.replace(sectorMsg, "%new-sector%", newSectorName);
                t.subTitle(TextComponent.fromLegacyText(sectorMsg));  <--- This is the line 98
                t.fadeIn(1);
                t.fadeOut(20);
                t.stay(40);
                t.send(player);
proud pebble
#

in the stacktrace

#

cause it will say what was null

barren ore
#

?paste

neat pierBOT
#
FAQ Answer:

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

barren ore
#

It's really weird because it doesn't tell me what is null just tells where which line

#

This is the full error:

proud pebble
#

im going to take a guess and say its saying that sectorMsg is null

#

are you sure its not null?

dusky harness
#

what is sectorMsg? (what does it print?)

proud pebble
barren ore
#

Omg guys never mind I made an oopsie thanks for your help tho

#

I forgot to delete my config and the new line for .getGeneralConfig().SECTOR_CHANGE didn't generate

hoary citrus
#

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'linkedaccounts (name,uuid,token) VALUES ('not_Nuggets','0488d5c5-ebc9-38c9-90...' at line 1

#

this is the new error sorry

#

public static void createPlayer(Player player, String token) {
        try {
            UUID uuid = player.getUniqueId();
            if(!exists(uuid)) {
                PreparedStatement ps2 = plugin.sql.getConnection().prepareStatement("INSERT IGNORE INFO linkedaccounts"
                + " (name,uuid,token) VALUES (?,?,?)");

                ps2.setString(1, player.getName());
                ps2.setString(2, uuid.toString());
                ps2.setString(3, token);
                ps2.executeUpdate();
            }

        } catch(SQLException e) {
            e.printStackTrace();
        }```
tight junco
#

why do you seperate the string

#

i assume just for code formatting

hoary citrus
#

yea

tight junco
#

Your issue is likely that IGNORE INFO part

#

You could likely just do INSERT INTO linkedaccounts

sand ermine
#

Instead of INSERT INTO

tight junco
#

this is what i do to recreate your table and it works

#

so INSERT INTO linkedaccounts (name, uuid, token) VALUES (?, ?, ?)

hoary citrus
#

oh im an idiot

#

this is my first time using SQL and I read INTO as INFO

#

my bad xd

sand ermine
hoary citrus
#

yea what app is that

tight junco
#

when testing SQL stuff i use https://sqliteonline.com

#

my dark mode extension is making the colours kinda wonk but yeah i use it a ton

sand ermine
twilit delta
#

Okay;

im learning NMS and I found this example on the web, and I changed some stuff.

public class BigWither extends EntityWither {
    public BigWither(Location loc){
        super(EntityTypes.aZ, ((CraftWorld) loc.getWorld()).getHandle());

        this.b(loc.getX(), loc.getY(), loc.getZ());

        this.r(false);
        this.n(true);
        this.a(new ChatComponentText(ChatColor.GREEN + "MyEntity"));
    }
}

First, what do I return?
Second, when I call it up, do I do this?

connection.a(new PacketPlayOutSpawnEntity(BigWither));
hoary citrus
#

again with the SQL nonsense

"PreparedStatement ps = plugin.sql.getConnection().prepareStatement("SELECT name FROM linkedaccounts where token=?");"

this line is producing a nullpointerexception. I already checked, and the argument I giving for token isn't null.

hoary citrus
#

xd

#

wawit nvm

leaden sinew
#

Either plugin, sql, or connection is null

hoary citrus
#

ah I think plugin is null

#

yea it is but idk how to make it not null 5Head

night ice
lyric gyro
#

testFunction(Array<MyObject>::class.java)

fun <T> testFunction(t:T):T{
  return getDataFromRestAPI("url", T::class.java)
}``` How come testFunctions returning a `Class<Array<MyObject>>>` and not just an `Array<MyObject>`
#

You're passing Array<MyObject>::class.java, testFunction expects a T instance, not a Class<T>

sand ermine
#

Anyone can recommend best way to fill in empty slots in a GUI?

formal crane
#

Is it possible to add a nbt to a spawned entity?

twilit delta
#

How can I change the metadata of an outgoing spawn entity packet with protocol lib?

formal crane
formal crane
#

Okay so i tried adding an nbt tag to a entity with this code:

            Entity huisdier = p.getWorld().spawnEntity(p.getLocation(), EntityType.WOLF);
            huisdier.setCustomNameVisible(true);
            huisdier.setCustomName(Util.chat("&cGerda"));
            NBTEditor.set( huisdier, "hond", "ddgpets" );```
but it won't work, this is the code where i check for the nbt:
```java
        if(NBTEditor.contains(e.getEntity(), "ddgpets")) {
            Bukkit.broadcastMessage("Test 2");
            e.setCancelled(true);
        }
lyric gyro
#

testFunction(arrayOf<MyObject>()) or however you create arrays in kotlin

dark garnet
#

i need help with some batch, for some reason setlocal EnableDelayedExpansion is making it so that when the 2nd call command is ran, it goes back to the directory where the called file is:
Specific Export.bat:bat call backend\specific.bat call "%~dp0backend\export.bat" false
specific.bat: https://paste.srnyx.xyz/acojemavol.bat

#

example: specific.bat makes it go to modpack/OO/1.18.2. then, when it does call "%~dp0backend\export.bat" false, it goes back to modpack/Tools (which is where Specific Export.bat is)

#

when i remove setlocal EnableDelayedExpansion in specific.bat it works, but i need it in order for other parts of the script to work

#

ok i think i fixed it
i had to put setlocal EnableDelayedExpansion in Specifix Export.bat (before call backend\specific.bat) for some reason

proud pebble
#

with a switchcase for all buttons and default was glass panes

spiral prairie
#

yes

#

thats the way to go

restive isle
#

is there a way to change the name fo a item you have in your invertory? with spigot or just with a minecraft command?

wintry shadow
#

hey how can i "compound command"

like this :

/towncreate <args> -> /town create <args>

pseudo steppe
#

Could anyone help me so im Using Deluxechat premium But i use it in a faction server but now the ranks dont have the right color and YOu cant see the faction name anymore?

restive isle
spiral prairie
#

get the item

#

change item meta

#

set item

restive isle
#

thanks can i ask you questions if i cant figure it out?

spiral prairie
#

sure

restive isle
spiral prairie
#

player.getInventory.getItem or something like this

restive isle
spiral prairie
#

that wont work on every end lol

#

you might just want to take a look at the documentation

restive isle
#

ItemStack itemStack = new ItemStack(Material.IRON_SWORD); this doesnt give me a iron sword? what did i do wrong

lyric gyro
#

not sharing the rest of the code

restive isle
#

lol

#

its on player movement

#

@EventHandler
public void onMove(PlayerMoveEvent e) {
ItemStack itemStack = new ItemStack(Material.IRON_SWORD);
}

lyric gyro
#

Well, you are creating an iron sword item, but you aren't doing anything with it

restive isle
#

so how would i do that?

#

giving the player that item\

lyric gyro
#

If you want to add it to the player's inventory, get the player from the event, get their inventory and add the item, should be something like so event. getPlayer().getInventory().addItem(item)
Be aware that the move event is called on every single tiny movement so you're going to fill that quickly

restive isle
#
@EventHandler
    public void onMove(PlayerMoveEvent e) {
        

        ItemStack itemStack = new ItemStack(Material.GOLD_BLOCK);


        ItemMeta meta = itemStack.getItemMeta();

        meta.setDisplayName(MyFirstPlugin.balance.toString());
        meta.setLore(Arrays.asList("line 1", "line2"));

        itemStack.setItemMeta(meta);
        if (balance_int == 1) {
            e.getPlayer().getInventory().addItem(itemStack);
            balance_int = balance_int-1;
        }


    }

@grim oasis here

#

and MyFirstPLugin has ```java
public static Integer balance;

grim oasis
#

send the class in a paste

restive isle
#

you mean this
public class MyFirstPlugin extends JavaPlugin {

grim oasis
#

because it says there is an NPE on line 96

restive isle
#

public class Events implements Listener {

grim oasis
#

the entire class

restive isle
#

sorry uhhm what do you mean with that

grim oasis
#

all the text

restive isle
#

im not really used to all these termsπŸ˜„

#

ohh

grim oasis
#

a class is a single file

restive isle
#

i read the entry class

grim oasis
#

where the other } is located, is where the class stops

#

so... at the bottom

sand mesa
#

Hello there, is there a solution for taking the entity player is looking at without using 50 lines where we check every mobs around the player ?

restive isle
grim oasis
#

not for a paste

#

?paste

neat pierBOT
#
FAQ Answer:

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

restive isle
#

here

grim oasis
#

can you run the server again to get the updated error

#

ooh, but I see your issue actually

#

It looks like you get the item meta of a fresh itemstack

#

Which, the item stack probably won't have

restive isle
#

so what should i do?

grim oasis
#

and then we can go from there

#

cause I could be right, could be wrong

#

could be this MyFirstPlugin.balance.toString()

#

πŸ€·β€β™‚οΈ

restive isle
grim oasis
#

Can you send the MyFirstPlugin class?

restive isle
grim oasis
#

Because, I'm gonna be honest, you're doing a lot of things oddly

#

But you're new so

restive isle
#

ye 😁

#

meta.setDisplayName(MyFirstPlugin.balance.toString());
it allready is

grim oasis
#

what is?

restive isle
#

oh nvm

#

MyFirstPlugin.balance.toString() what should this be?

#

then?

grim oasis
#

Well you never initialized balance

proud pebble
#

looks like balance is uninitalized, no value is ever set.

grim oasis
#

if balance was an int it would initialize as 0 (instead of Integer)

proud pebble
#

balance is set as the object form of integer instead of the keyword

#

weird

grim oasis
#

ya, it's a bit odd

proud pebble
#

also static abuse very much

grim oasis
#

but, beginner code

restive isle
#

what do you mean by intialize

grim oasis
#

you initialized amount here to 1

#

public static Integer balance;

#

balance is never initialized

restive isle
#

oh

proud pebble
#

same with playerWhoBoughtTheShop

grim oasis
#

basically, you defined balance as an Integer type, but never initialized the value

restive isle
#

oh i understand

#

yes it works!

proud pebble
#

also balance is global

#

is that intensional?

restive isle
#

what do you mean with global?

proud pebble
restive isle
#

oh ye

#

idrk what im doing tbh

proud pebble
#

i can see that

restive isle
#

but its fine rigth?

proud pebble
#

Β―_(ツ)_/Β―

round sail
#

If you’re happy with any outcome then it’s fine 😝

restive isle
#

how do i do that>

warm steppe
#

ItemStack#getItemMeta()

#

iirc

proud pebble
kind granite
#

null check it first

#

bukkit is special like that

restive isle
#

what should be on whatever or on something else

#

like should i deifine the meta

proud pebble
#

the meta is already defined since you are doing item.getItemMeta()

#

whatever and somethingelse is just placeholders for whatever meta you want to modify

restive isle
#

ItemStack itemStack = new ItemStack(Material.GOLD_BLOCK);

    ItemMeta meta = itemStack.getItemMeta();

    meta.setDisplayName(MyFirstPlugin.balance.toString());
    meta.setLore(Arrays.asList("line 1", "line2"));

    itemStack.setItemMeta(meta);
    if (balance_int == 1) {
        e.getPlayer().getInventory().addItem(itemStack);
        balance_int = balance_int-1;
    }

where should i put it? after the player got the item?

#

i really dont understand this could you just put it in for me?

proud pebble
#

i dont know where you even want this

restive isle
#

uhg

#

idk?

#

so i want that the name of the item changes in your inveroty

#

and I firstly did it by clearing the item and then replacing it

#

but thats not clean cz you will see the item popping out and in to your invertory first of all

proud pebble
#

then just set the slot

#

instead of removing it first

#

you dont have to remove it

restive isle
#

how do i do that>

proud pebble
#

p.getinventory.setitem(slot,itemstack);

restive isle
#

ty

#

what is slot 1 etc?

proud pebble
restive isle
#

ty

wintry shadow
#

the uuid changes if you change your nickname ?

lyric gyro
#

nope, that's the whole point of UUIDs

#

unless you use online-mode=false (and not have a proxy to take care of authentication) which ☠️

wintry grove
kind granite
#

are you using the java plugin

worn jasper
#

uhm is this params supposed to be the identifier?

pulsar ferry
# wintry grove https://paste.helpch.at/yineduyuku.makefile

I'm assuming it's because of that project block down there, what are you even doing there? thonk
I have never seen that being used like that, but anyways, the project would be considered differently, so the plugin you're applying above doesn't apply to the specific project

#

That is very cursed

wintry grove
pulsar ferry
#

For real though, what are you doing with that project block down there?

wintry grove
#

probably wrong

pulsar ferry
#

Well if you want a module to depend on those you'd create the module and put that inside its own build.gradle

wintry grove
#

yeah ty

worn jasper
# dense drift yes

ty. Also, in the return, Does the ChatColor apply for everything after the text? For example, the name of the player?

cerulean birch
#

does the BukkitScheduler run asynchronous tasks in order, or is it unpredictable?
i.e if I run task A async, then run task B async, can I expect A to run and finish before B is started? or should I make my own single thread executor instead

kind granite
#

are they not unpredictable by their asynchronous nature

cerulean birch
#

i guess i'm asking if it uses a single thread to execute tasks async or several

cerulean birch
#

you can still have tasks run in order asynchronously, if they're all run on the same separate thread

vestal forge
#

you can look at implementation

#

but its probably using some threadpool

#

or just do

#
runAsync{
//sometask

//someothertaskthatneedstobecalledasync()




}
vestal forge
pearl topaz
#

could someone explain this to me please

val arrayType = object : TypeToken<ArrayList<T>>() {}.type
slim vortex
#

Does anybody have a maven repo with Paper Server version on it? (not the API, but the actual server with net.minecraft.server)

lyric gyro
#

there is no publishable server jar

slim vortex
#

Damn. The project owner is using maven so I can't use it

kind granite
#

it's working around type erasure

pearl topaz
#

thanks

lyric gyro
#

how can i delete two entries from a list where only two parameters match

barren ore
#

What can I do about this?

[01:38:32] [Server thread/ERROR]: Could not load 'plugins/Core.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: me/fiftyone/core/Main has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0```
Tried doing what people said online about changing compiler compliance level but still nothing changes throws the same error
prisma briar
barren ore
#

Issue is when I change java version of my Linux server from 11 to 17 so it can run the "file version 61.0" my server no longer wants to start no logs or anything

#

I am running 1.16.5

barren ore
#

Don't think so I have a VPS server bought from OVH

#

I have Java 11 and Java 17 installed onto it

#

And I can change the versions using sudo update-alternatives --config java

#

If i change the version to 11 the server starts up perfectly fine but throws that error that I showed above

#

If I switch to 17 to try make that error go away my server doesnt start at all

prisma briar
#

Well I don't know the details on configuring java version on linux, but usually you only want to change the java version on the startup parameters of the minecraft server.

barren ore
#

How do i change those?

#

Whats the parameters

#

You mean something like : "C:\Program Files\Java\jre1.8.0_311\bin\javaw.exe" -Xmx2048M -Xms2048M -jar forge-1.16.5-36.2.20.jar
pause

#

?

prisma briar
#

To start the minecraft server do you have to run something like java -jar server.jar or something.

#

Yeah that part

#

Change this "C:\Program Files\Java\jre1.8.0_311\bin\javaw.exe" to your java 17 path

#

And use java.exe, not javaw.exe

barren ore
#

Could it be because the Java 17 isnt a jdk?

#

I have just noticed my Java 11 is like this /usr/lib/jvm/java-11-openjdk-amd64/bin/java

#

The Java 17 appears to be like this /usr/lib/jvm/java-17-oracle/bin/java

#

Says oracle

prisma briar
#

Well that depends on your installation folder.

barren ore
#

Yes it's different on linux however, im not running my server locally unfortunately :/

#

Hmm ok 1.16.5 will not even run on java 17 so now i'm completely confused how to run this plugin now :/

dusty frost
#

yes it will lol

barren ore
#

idk then it just won't let me start my server using Java 17 is there any other way to just make the plugin use the class version 55.0

winged pebble
#

55 is java 11 iirc

#

You could set the target of your project to 11

#

But for future reference, you have to run buildtools with the version of java that you are wanting

#

That will give you the server jar in the versino that you need

barren ore
#

Ah my issue might be that I didnt use BuildTools yikes

dusty frost
#

or just use Paper lmao

prisma briar
winged pebble
#

For a vps you're usually ssh'ing in

#

Which means you don't have a gui besides the terminal

torpid raft
#

but yeah ^ managing it is very different on windows vs linux

#

you will also want to expose your server to the public when it's on your vps while you might not need to on your pc if you only want to run it locally

prisma briar
#

Ah okay, but to transfer file you usually use ftp client right?

#

And to start the minecraft server you'll run the command just like in Windows localhost

hoary citrus
#

so I've created a discord bot inside of my plugin, and I need to get the plugin instance for my sql instance.

However, whenever I do the usual MainClass plugin;

blah blah
it returns null

#
DiscordLinkRoles plugin;
    public DiscordLinkCommand(DiscordLinkRoles plugin) {
        this.plugin = plugin;
    }```
#

I need to access "plugin.sql"
that being public MySQL sql;

winged pebble
#

What returns null?

#

The plugin arg?

hoary citrus
#

indeed

winged pebble
#

How are you initializing it

hoary citrus
#

initializing the "plugin" arg?

#

I showed it above

winged pebble
#

No, the class

#

Show me where you're instatiating it

hoary citrus
#

wdym. sorry if I seem dumb, its cuz I am but its also 5am

winged pebble
#

Where are you calling the constructor for DiscordLinkCommand

hoary citrus
#

ohh

#

in my Bot.java class

#
bot = JDABuilder.createDefault(token)
                .addEventListeners(new DiscordLinkCommand(plugin))
                .build();```
#

the error says its occuring on this line

PreparedStatement ps = plugin.sql.getConnection().prepareStatement("SELECT name FROM linkedaccounts WHERE token=?");```
#

and so I checked if plugin was null with a simple if(plugin == null) {
print that its null }

#

and it said it was null

winged pebble
#

Show me where that plugin var gets initialized

sand ermine
#

@hoary citrus

#

getCommand("worldinfo").setExecutor(new WorldCommand(this));

#

like this bit i think he means

hoary citrus
#

well thats what I showed, I also showed where plugin gets initialized in the event listener

winged pebble
#

No, that's a different plugin variable

#

You should me inside the DiscordLinkCommand class

hoary citrus
#

I showed you the one inside the discordlinkcommand class

winged pebble
hoary citrus
#

DiscordLinkRoles plugin;
    public DiscordLinkCommand(DiscordLinkRoles plugin) {
        this.plugin = plugin;
    }```
#

and my bot class, whcih is the one with the code you just replied too,

initializes it like so

public Bot(DiscordLinkRoles plugin) {
        Bot.plugin = plugin;
    }```
winged pebble
#

Show your Bot class

#

The whole thing

hoary citrus
#
public static JDA bot;
    public static DiscordLinkRoles plugin;

    public Bot(DiscordLinkRoles plugin) {
        Bot.plugin = plugin;
    }

    

    public static void discordBot() throws LoginException {
        
        bot = JDABuilder.createDefault(token)
                .addEventListeners(new DiscordLinkCommand(plugin))
                .build();

    }```
winged pebble
#

And where is Bot.discordBot() called?

hoary citrus
#

in my main class

winged pebble
#

Show it

hoary citrus
#
ry {
            Bot.discordBot();
        } catch (LoginException e) {
            e.printStackTrace();
        }```
winged pebble
#

Show more

hoary citrus
#

apparently I cant

#
public static MySQL sql;
    public SQLGetter data;

    @Override
    public void onEnable() {



        sql = new MySQL();
        this.data = new SQLGetter(this);

        try {
            sql.connect();
        } catch(ClassNotFoundException | SQLException e) {
            Bukkit.getLogger().info("DB ISNT CONNECTED idiot!");
        }

        if(sql.isConnected()) {
            Bukkit.getLogger().info("DB IS CONNECTED. GOOD JOB");
            data.createTable();
        }


        getCommand("test").setExecutor(new TestCommand());
        getCommand("linkaccount").setExecutor(new DiscordLink());


        try {
            Bot.discordBot();
        } catch (LoginException e) {
            e.printStackTrace();
        }

    }```
winged pebble
#

You're never calling the constructor of Bot

#

So Bot.plugin is never initialized

hoary citrus
#

but it isnt needed inside bot

#

its needed inside discordlinkcommand

winged pebble
#

Yeah I know

#

But you're never passing the plugin instance through

hoary citrus
#

where do I need to pass it through?

winged pebble
#

So Bot.plugin never receives an instance of your plugin

hoary citrus
#

I just made the sql instance in my main class static

#

and made a local variable in the event listener

#

fixes the issue :p

winged pebble
#

You could have just passed the plugin instance through Bot's static method too

#

Would have been better probably

#

Too much static going on

thorn cape
#

Is there anyway to mimic the effects of Bukkit.hidePlayer without removing their name from tabcomplete and tablist?

prisma briar
#

Maybe some packets too.

heady prism
#

Or Bukkit.hiseplayer and send the packet for tab to the player still

warm steppe
#

?learn-java

neat pierBOT
#
FAQ Answer:

Online Courses:
Online courses are also great for learning java. Some websites that offer them are:

  • Coursera - Free unless you want a certificate
  • PluralSight - Great courses from what I've seen. Mostly Paid
  • Udemy - Never used them myself but they seem to all or at least most be paid.
    My first ever course was one from Coursera. - I can say it was pretty good at introducing me to the programming world as a whole not just java.

Oracle Docs:
Oracle docs can help a lot at learning and understanding java:

  • Start with this,
  • Breeze through this (skipping stuff that doesn't seem relevant like bitwise operators),
  • Hit this.
    They're the first three from this larger thing which you should definitely go through overall. But those three should be enough for slightly better understanding of what is happening here without feeling like a huge time sink.
    That one is a small part of this larger site wherein "Essential Java Classes" and "Collections" also have good useful stuff

Other services:
Some other cool services that will help you learn java are:

As you can see there are plenty of good ways to learn as long as you're willing to invest the time. Have fun learning!

warm steppe
#

@hoary citrus

#

?di

neat pierBOT
spiral prairie
#

Do schedulers get stopped when the owning plugin disables?

tight junco
#

i believe so

spiral prairie
#

cool

wintry shadow
#

hey i can't test if my arguments is null or not

#
if(args[0] != null){
  etc....
}
#

if my argument 0 is empty, my server return this error :

tight junco
#

You need to check args length to see if it exists

#

so if (args[0] != null) would be if (args.length == 0)

graceful juniper
#

How does someone create a new itemmeta for an item if getItemMeta() returns null

neon wren
#

Can you explain what you are doing in code or put it in a paste?

graceful juniper
#

Essentially, when the player picks up an item, i want to edit the itemmeta. However, trying to do so will spit out a nullpointer, halting the entire process of editting the itemmeta and giving the item to the player.

neon wren
#

I can't really write up a example right now, so hopefully someone else can help but that event should work fine for getting a item's meta but you'd just need to make sure it's the correct item and entity.

inner jolt
#

not sure if this is what you're looking for

graceful juniper
#

Sorry I didnt specify, I am using 1.16.5 (im comfortable with this and most of my personal projects are on this version).
I am indeed using EntityPickUpItemEvent which allows me to grab the material and use my own extension of ItemStack.

Currently my personal extension of ItemStack is just exactly what ItemStack does but does it's own code to add information into the item via the ItemMeta.

#

This is what my extension does. It only does this.

  private void init() {

        ItemMeta meta = getItemMeta();

        meta.setDisplayName(material.getRarity().getColour() + material.getName());

        List<String> lore = new ArrayList<>();

        lore.add(" ");
        lore.add(material.getRarity().getColour() + material.getRarity().getName());

        meta.setLore(lore);

        meta.getPersistentDataContainer().set(material.getKey(), PersistentDataType.STRING, material.getKey().getKey());
        meta.getPersistentDataContainer().set(material.getRarity().getKey(), PersistentDataType.STRING, material.getRarity().getKey().getKey());

        setItemMeta(meta);

    }
#

Removing this piece of code makes it work perfectly. It's just the ItemMeta which isn't correct

inner jolt
#

replace ItemMeta meta = getItemMeta(); with

if (this.hasItemMeta()) {
  ItemMeta meta = getItemMeta();
} else {
  ItemMeta meta = new ItemStack(Material.IRON_SWORD).getItemMeta();
}
#

this way you're checking if the item has meta, and if it doesn't then you're creating a new one

graceful juniper
#

I will have a go, I will reply further if I have more issues. Thank you :D

inner jolt
#

no problem!

graceful juniper
#

@inner jolt
Quick question
Would this essentially work as the same:

ItemMeta meta = hasItemMeta() ? getItemMeta() : new ItemStack(this.material.getMaterial()).getItemMeta();
inner jolt
#

i don't think that a new itemstack with the material is guaranteed to have an itemmeta though

#

which is why i normally generate it using an iron sword

graceful juniper
#

Are you able to use itemmeta from another type of material?

inner jolt
#

I've done it in the past without any issues, but I'm not sure if it's the best solution

graceful juniper
#

Alright

#

All works now, tysm @inner jolt

inner jolt
graceful juniper
#

You too!

pearl topaz
#

how important is the single responsibility principle? for example I have a method deserialiseAndSet(value: String) which takes a serialised value for the object and then updates the value of the object to that value

#

if it's important, this is a guaranteed method provided by the interface that all objects of this type implement

#

there's no real application for just a deserialise() method outside of this, and it would also mean I'd need to parameterise my interface w generics since the return value would have to be different for each class

icy shadow
#

the design certainly won't scale very well

#

and it is a bad practice to be bundling that much logic together

#

However if it's not public code then you can take the risk of later suffering if you're feeling lazy

#

If you intend to publish / share the code you should absolutely be following the design principles more strictly

lyric gyro
#

daarom boys

#

inshallah

pearl topaz
#

I'm struggling to figure out a cleaner way of doing it

#

imo it feels better to couple the logic rather than parameterise the interface

#

especially when a lot of the time that parameter will just be *

icy shadow
# pearl topaz in what way?

you're coupling deserialization logic with object mapping, and whatever else the target class does - the better option imo would be a Deserializer interface that can generate a Map, then you do object mapping, and then all that logic is done somewhere away from the models in a service class or something

#

But I don't know the full context so that might be completely inapplicable

lyric gyro
#

yeah well I think you should consider using a reflective inverted bimap implementation as your current system should declare an interface with a more clearly defined contract and you should really be splitting your 4 line method into 8 different classes for the Single responsibility Liskov principle which you learn about in Section 7 of Advanced Java course

icy shadow
#

True!

pearl topaz
icy shadow
#

To represent the deserialized output

#

Which can then be loaded into the object attributes

icy shadow
#

It is quite hard to give proper architectural advice when all the information I have is 1 method though

pearl topaz
# icy shadow It is quite hard to give proper architectural advice when all the information I ...

I have classes that overload Mutable types like MutableLong, in order to set the value in a Redis DB whenever the underlying value of the mutable type is changed, e.g. I have a LongLogger.

these all implement the MyLogger interface which guarantees the deserialiseAndSet() method as well as serialise(). we're serialising to and from strings as that is what is stored in redis

I have an API that can update the value of any of these loggers by it's name. it accepts a serialised string. there's a map of them so I can just use the key to get the logger, and then since it's a map like Map<String, MyLogger> I can just do myLogger.deserialiseAndSet(value) without having to know what type of logger it is

#

the deserialised output is just of the type of the logger, e.g. Double for DoubleLogger

#

that's why I would have to parameterise the interface like MyLogger<T> so I can guarantee the method fun deserialise(value: String): T if I were to decouple the logic

molten wagon
#

Is it someone get memory leaks in IntelliJ IDEA 2021.3.2 when use suggestions with Material class (I have increasing ram several times)?

now it use 8Gb and it need even more (I have 55% more ram to use, but should not need all ram for it self).

odd prawn
#

no

dense drift
#

I know that you can make package private classes by declaring it without public, is there any way to make smth like "project private"? Meaning it can be accessed by classes from the current project but not other projects.

lyric gyro
#

Wel firah πŸ”₯

lyric gyro
#

that's what java modules are for :)

dense drift
#

AH YES

somber gale
#

Oh how I HATE Gradle

#

this piece of shit seriously shouldn't be used at all

#

Never saw any software so bad with dependencies

leaden sinew
#

What the heck is that formatting

dusky harness
#

unless it's giving compilation errors

#

then u prob need to check build.gradle(.kts) πŸ™ƒ

lyric gyro
#

fucking lmao

#

no read guides and learn how to use tooling
no ask for help with tooling
yes complain and blame tooling for user errors

somber gale
#

The build.gradle file is perfectly fine as I used that project like half a year ago and didn't change a thing

#

I never have those issues using maven, yet people always say Gradle is better

lyric gyro
#

guess what

#

because it is

#

ask for help, big boy

somber gale
#

I really don't care. The project is dead anyway

winged pebble
#

Apparently you do

lyric gyro
#

yeah it doesn't look like you don't care lol

somber gale
#

I just wanted to share my hate for Intelij + Gradle acting horrible

lyric gyro
#

gradle works perfectly fine if you know what you're doing

#

like, y'know, how everything is

inner jolt
#
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
    if (e.getView().getTitle().equals(ChatColor.AQUA + "Auction House")) e.setCancelled(true);
}

@EventHandler
public void onInventoryDrag(InventoryDragEvent e) {
    if (e.getView().getTitle().equals(ChatColor.AQUA + "Auction House")) e.setCancelled(true);
}

The player is able to use "F" in order to move the item from the inventory into their offhand. The item is duplicated, with one copy going into the Player's offhand and theo ther staying in the inventory. Is there a way to fix this?

pulsar ferry
#

If the player is in creative that is an issue, MC doesn't validate the inventory in creative, if they are in survival or adventure then the item is a ghost item and disappears after
And also, comparing inventory titles is not a good idea to verify if the inventory is the correct one

inner jolt
#

i've only been testing it in creative

#

What do you suggest for inventory verification?

pulsar ferry
#

Either comparing inventories directly or using a custom InventoryHolder

inner jolt
#

Got it, thank you

dense drift
hoary citrus
winged pebble
#

Experience and practice

warm steppe
#

also tf is that formatting

thorn cape
#

Is there any way to get an item name like potion item names? Say like Potion of Swiftness etc.

#

Because I am trying to read potions from a file and don't know how I would set the name

spiral prairie
light wraith
#

can i send code ?

#

If i can, how can i send code ?

neat pierBOT
#
FAQ Answer:

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

shell moon
dense drift
#

I belive thats client side

pulsar ferry
#

Iirc you can get it from the server, paper exposes it I think, spigot doesn't

dense drift
#

d;paper ItemMeta#getLocalizedName

uneven lanternBOT
#
@Deprecated @NotNull
@NotNull String getLocalizedName()```
Description:

Gets the localized display name that is set.

Plugins should check that hasLocalizedName() returns true before calling this method.

Deprecation Message:

Use displayName() and cast it to a TranslatableComponent. No longer used by the client.

Returns:

the localized name that is set

pulsar ferry
#

It could be

#

d;paper ItemStack#displayName

uneven lanternBOT
shell moon
#

Wait, itemstack has setDisplayname?

#

wtf

#

wasnt it ItemMeta exclusive?

somber gale
#

I assume it's Paper

#

Tho, not a fan of the naming... ItemStack#displayName()

lyric gyro
#

ItemStack#displayName and ItemMeta#displayName return different components… whoever thought it was a good idea to name them the same thing needs to reevaluate their choices kek

dense drift
#

How come lol

lyric gyro
#

ItemMeta is basically the item's NBT, so that one returns the display.Name NBT path

lyric gyro
#

ItemStack#displayName returns what the game uses for when like e.g. you kill someone with a renamed item, it puts it in [] (actually it puts the NBT display name as argument for a translation entry, that renders to []) and adds the item hover event

lyric gyro
spiral prairie
#

who needs the ItemStack#displayName method?

lyric gyro
#

I've used it one time so there definitely is use for it

#

and that's the most useful alternative to "chat item" things like [i] or whatever

spiral prairie
#

ah

lyric gyro
#

it's quite niche still

lyric gyro
#

"lol"?🀨

dense drift
#

Interesting, I guess thats useful at some point

dapper stag
#

hello to everyone who needs a developer of servers and assemblies

smoky hound
lyric gyro
#

uncool status dude

grim oasis
queen plank
#

My IDE is telling me this new Random().nextDouble(someDouble); is not valid. Why?

kind granite
#

i dont know

#

whats it saying

queen plank
#

The method nextDouble() in the type Random is not applicable for the arguments (double)

kind granite
#

d;jdk Random#nextDouble

uneven lanternBOT
#
default double nextDouble()```
Description:

Returns a pseudorandom double value between zero (inclusive) and one (exclusive).

Returns:

a pseudorandom double value between zero (inclusive) and one (exclusive)

kind granite
#

i mean

#

it doesn't take a parameter

queen plank
#

I find this tho double java.util.random.RandomGenerator.nextDouble(double bound). The description is: Returns a pseudorandomly chosen double value between zero(inclusive) and the specified bound (exclusive).

#

When I inspect it

kind granite
#

yeah that's what id expect

#

youre passing an argument that it's not expecting

queen plank
#

I changed it

#

Sorry, did it wrong the first time

#

That is the reason I am confused. There is a function that takes in a double as a bound

lyric gyro
#

huh can you show a screenshot of the full error or smth?

#

?imgur

neat pierBOT
#
FAQ Answer:

You won't be able to upload images here directly to avoid spam, so please use https://imgur.com/upload to upload images/screenshots.
You can also use a screenshot service like gyazo or jinx and post those links here.

queen plank
#

Here: https://imgur.com/a/dBsJKFe. I can't screenshot what the error says when I hover over the .nextDouble() but it tells me this The method nextDouble() in the type Random is not applicable for the arguments (double)

#

If it wasn't clear, this.odds is a double

lyric gyro
#

how are you trying to compile this? maven/gradle or what?

queen plank
#

Maven

#

It is in my IDE tho, I'm not even compiling it

lyric gyro
#

yeah but (any decent) IDE might or might not show some errors depending on some build configurations

#

can you share your pom file?

queen plank
#

Yup, hold on