#help-development

1 messages ยท Page 253 of 1

maiden thicket
#

interesting

#

hmm

midnight shore
#

i know

quaint mantle
#

ayo if i do runTaskTimer and the task takes a bit to do it wont cause lag spikes right

midnight shore
#

well, yes it will

quaint mantle
#

it doesnt block the main thread, right?

#

oh ti does block the main thread

#

bru

#

I need to do a kick in runTaskTimer but i cant do it in async stuff

midnight shore
#

yeah

#

actually if its just a kick it won't cause anything interesting

quaint mantle
#

if there alot of players it might tkae a while

midnight shore
quaint mantle
#

has https stuff and I dont want lag spikes

midnight shore
#

.. you are right

#

anyone has some ideas?

quaint mantle
#

bruh

scarlet breach
#

whats the problem? the error:
java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.

quaint mantle
#

ayo cna someone help me. how do I kick a player in runTaskAsync?

#

I cant use sync runTask cuz it will lag spike the server every time the task is ran

midnight shore
rotund ravine
midnight shore
rotund ravine
midnight shore
#

how can i fix this?

midnight shore
rotund ravine
#

Obv not

midnight shore
#

Well i'm dumb

#

thank you

midnight shore
#

oh my god whats this now

rotund ravine
rotund ravine
midnight shore
#

i'm just teleporting an entity

quaint mantle
rotund ravine
#

Ask chatgpt

midnight shore
hazy parrot
#

Idk if its just me, but im amazed how much people didn't hear about chatgpt, like its every third tiktok on my fy ๐Ÿ˜„

hazy parrot
midnight shore
#

i'm asking here because i don't want the opinion of a damn machine thats making me mad

tender shard
hazy parrot
#

Also chatgpt gives pretty cool answer

tender shard
#

isn't it true? idk I havent checked, but it's true for integers and stuff

tardy delta
#

double overflow doesnt exist right

tender shard
#

oh might be

#

all I know is that Integer.MAX_VALUE + 1 is the same as Integer.MIN_VALUE

tardy delta
#

it just becomes Double.POSITIVE_INFINITY or negative infinity

#

mmye thats ints

tender shard
#

hm weird, I just did Double.MAX_VALUE + 1 and it returns this: 1.7976931348623157E308

hazy parrot
tender shard
#

huh it's weird. Double.MAX_VALUE + 1 returns a number, and isFinite is also true for that number

#

but Double.MAX_VALUE + Double.MAX_VALUE indeed is Infinity

tardy delta
#

numbers are weird

tender shard
#

also when a double is called double, why is the other thing called float and not single lol

tardy delta
#

cuz single people might get hurt

rotund ravine
# tender shard also when a double is called double, why is the other thing called float and not...

In Java, the data type float is a single-precision 32-bit floating point data type, while double is a double-precision 64-bit floating point data type. The names float and double come from the fact that they are used to store decimal numbers with fractional precision. The name float comes from the fact that the number is represented using a floating decimal point, which can "float" to represent different magnitudes. The name double comes from the fact that it uses twice as many bits as a float, allowing for greater precision.

tardy delta
#

had test about that yesterday

tender shard
#

that's why I asked why it's called float when a double is floating point too

#

and why a float is not just called single

#

float = single precision float
double = double precision float

peak depot
#

any one knows how to create a module manager like in bungeecord where you have one plugin wich creates a folder called modules and there you put in the modules

ivory sleet
#

Yeah you should look at class loaders

#

Then basically you just take a directory stream of said folder, iterate the .jar files and load them properly

peak depot
#
// Create a URL representing the directory containing the class files
File directory = new File("plugins/base/modules/");
URL url = directory.toURI().toURL();

// Create a class loader that loads classes from the specified URL
ClassLoader loader = new URLClassLoader(new URL[] { url });

// Get a stream of the files in the directory
try (DirectoryStream<Path> stream = Files.newDirectoryStream(directory.toPath())) {
  // Iterate the files in the stream
  for (Path path : stream) {
    // Load the class file
    Class<?> clazz = loader.loadClass(path.getFileName().toString());

    // Use the loaded class
   
  }
}
``` like that?
tender shard
#

ofc you wouldn't pass in the file name into loadClass but an actual class name

rotund ravine
# peak depot ```java // Create a URL representing the directory containing the class files Fi...

ChatGPT says:

To make this code load JAR files instead of class files, we can modify the code as follows:

  1. Replace the line DirectoryStream<Path> stream = Files.newDirectoryStream(directory.toPath()) with DirectoryStream<Path> stream = Files.newDirectoryStream(directory.toPath(), "*.jar") to only select JAR files in the directory.

  2. Replace the line Class<?> clazz = loader.loadClass(path.getFileName().toString()) with URL jarUrl = path.toUri().toURL() to convert the path of the JAR file to a URL.

  3. Add a new line URLClassLoader jarLoader = new URLClassLoader(new URL[] { jarUrl }) to create a class loader that loads classes from the JAR file specified by the URL.

  4. Replace the line // Use the loaded class with the code that uses the classes from the JAR file, using the jarLoader class loader to load the classes.

Here is the updated code:

// Create a URL representing the directory containing the JAR files
File directory = new File("plugins/base/modules/");
URL url = directory.toURI().toURL();

// Create a class loader that loads classes from the specified URL
ClassLoader loader = new URLClassLoader(new URL[] { url });

// Get a stream of the JAR files in the directory
try (DirectoryStream<Path> stream = Files.newDirectoryStream(directory.toPath(), "*.jar")) {
  // Iterate the JAR files in the stream
  for (Path path : stream) {
    // Convert the path of the JAR file to a URL
    URL jarUrl = path.toUri().toURL();

    // Create a class loader that loads classes from the JAR file
    URLClassLoader jarLoader = new URLClassLoader(new URL[] { jarUrl });

    // Get a list of all the resources in the JAR file
    Enumeration<URL> resources = jarLoader.getResources("");

    // Iterate over the resources in the JAR file
    while (resources.hasMoreElements()) {
      URL resource = resources.nextElement();

      // Check if the resource is a class file
      if (resource.getFile().endsWith(".class")) {
        // Get the fully qualified class name of the class file
        String className = resource.getFile().replaceAll("/", ".").replace(".class", "");

        // Load the class
        Class<?> clazz = jarLoader.loadClass(className);

        // Use the loaded class
        // ...
      }
    }
  }
}
rocky oxide
#

WorldGuard How to sell purchased land?
How add player to luckperms group?

rotund ravine
# rocky oxide WorldGuard How to sell purchased land? How add player to luckperms group?

To sell purchased land in WorldGuard, you would first need to find a buyer and agree on a price for the land. Once you have found a buyer, you can use the /rg sell command to transfer ownership of the land to the buyer. The specific syntax for this command is /rg sell [region] [player], where [region] is the name of the region that you are selling and [player] is the username of the player who is buying the land. (https://dev.bukkit.org/projects/regionforsale?gameCategorySlug=bukkit-plugins&page=32&projectID=40512)

To add a player to a LuckPerms group, you would first need to have the luckperms.group permission, which allows you to manage groups and permissions in LuckPerms. Once you have this permission, you can use the /lp group <group> adduser <player> command to add the player to the specified group. The <group> and <player> arguments should be replaced with the name of the group and the username of the player, respectively.

It's important to note that these instructions are specific to WorldGuard and LuckPerms, and may not be applicable to other protection or permissions plugins. If you are using a different plugin, you may need to consult that plugin's documentation for information on how to sell land or add players to groups.

kind hatch
#

/lp group <group> adduser <player> This is not a luck perms command.

rocky oxide
#

there is a video?

rotund ravine
# kind hatch `/lp group <group> adduser <player>` This is not a luck perms command.

I am not fact checking haha is it this?
To add a player to a group in LuckPerms, you need to use the lp group command. This command has a number of sub-commands that allow you to manage the members of a group, including adding and removing players.

Here is an example of how to add a player to a group using the lp group command:

  1. First, open a command prompt or terminal and connect to your Minecraft server.
  2. Next, use the lp group command to select the group that you want to add the player to. For example, if you want to add the player to the "moderator" group, you would use the following command:
    lp group moderator
  3. Once you have selected the group, you can use the add sub-command to add the player to the group. For example, if you want to add the player "Notch" to the "moderator" group, you would use the following command:
    lp group moderator add Notch
  4. If the player was added to the group successfully, you should see a message indicating that the player was added to the group.

Keep in mind that you need to have the appropriate permissions in LuckPerms in order to add players to groups. If you are not sure whether you have the necessary permissions, you should contact your server administrator for help.

rocky oxide
#

Thx

kind hatch
rocky oxide
#

I'm building a server

rotund ravine
rocky oxide
#

ok

kind hatch
rocky oxide
#

I'll ask later

rotund ravine
rocky oxide
#

bye

molten hearth
#

This is the reason SO banned ChatGPT answers

kind hatch
# kind hatch Dude, this is so unbelievably wrong. It's like it's trying to pull info from gro...

Actually, I'm sorry. I misread what ChatGPT said. It's wrong on two fronts.
First is that it's using the group subcommand to try and assign players to a group. This is wrong. The group subcommand is for **managing **the groups.
If you wanted to add a player to one of the groups you would use the user subcommand.

/lp user <player> parent add <group>

Second, lp group moderator this command does nothing.

#

It'll just hit you with a help menu.

rocky oxide
#

thx

crystal palm
#

what's the correct way to disable a bungeecord plugin?

#

plugin.onDisable()?

rotund ravine
crystal palm
#

nono

#

if some value in config is messed up, i want it to disable itself

#

throw exception? ๐Ÿ’€

kind hatch
# rotund ravine funny

Funny? I think you mean accurate. Forget the personal experience I have with LP, but the info I provided is backed by the official LuckPerms Wiki. The "answer" from ChatGPT is clearly wrong. I'm sure LP had it's wiki up before the cutoff date for CGPT's dataset. If it was truly able to parse context correctly, it would have given the right answer.

rotund ravine
ivory sleet
#

Isnt chatgpt limited hence why it may provide incorrect answers

kind hatch
#

But you didn't know it was wrong until I pointed it out. ๐Ÿคฆโ€โ™‚๏ธ

rotund ravine
crystal palm
#

๐Ÿ’€ alright

kind hatch
ivory sleet
#

Myeah

kind hatch
rotund ravine
#

I'll just make LGMTFY links next time I suppose.

kind hatch
ivory sleet
#

I mean as long as you fact check chat gpt answers it should be fine?

kind hatch
rotund ravine
#

I've decided to be too lazy to figure out their issues and simply give them non-curated ChatGPT answers, feel free to correct me each time.

kind hatch
#

Believe it or not. The whole purpose of a manual is to make things easy to understand. Sure, you might not want to spend the time reading it all, so I don't mind giving people the cliffnotes version of a command or whatever they need. However, at least the information I provide is backed.

tardy delta
#

why is everyone using chatgpt lol

kind hatch
#

I don't have an issue with ChatGPT, it's cool software, but it's not right in many cases.

#

So spouting it's answers as fact everywhere will likely do more harm than good.

rotund ravine
#

Well, it'll only do harm if they do not try to understand what is happening. I know spigot plugin devs and server admins are usually brainless in that regard. But if they keep getting answers where they'd need to think, they'd probably be better off.

kind hatch
#

Sadly, a lot of people don't try. That's why we provide some basic help, then give them the RTFM answer if they are clearly just grabbing for answers.

rotund ravine
#

Exactly, I do that, if the ChatGPT answer is wrong. Then they're better off reading the manual.

I just recently started using it for that instead of actually helping them myselves, this saves a lot of time and it is right some of the time so win for me and loss for them.

tardy delta
#

how do you know if its wrong lol

rotund ravine
kind hatch
#

lmao

rotund ravine
#

Of course I screen it shortly to make sure there is no computer-ending stuff in it.

#

But I don't look more in to it usually.

covert yacht
#

Hello, i have some errors in my code and i am not sure if the cause is my imports or just type issue.

Here is the code, it's used to spawn NPCs, the issue is located inside the display() function. I commented the errors i get from my editor here.
https://paste.md-5.net/eniruhocec.java

rotund ravine
rotund ravine
#

@kind hatch most likely him only using the api and trying to use nms functions

#

Wait

covert yacht
kind hatch
covert yacht
#

Not using only api

rotund ravine
#

Correct ur not

#

Change (Player) to CraftPlayer to get the correct handle

covert yacht
kind hatch
#

Also, it might be worth using the remapped jar.

#

Not sure how to do it in gradle though.

rotund ravine
#

Just let ur IDE import it

tender shard
tender shard
#

oh on the docs you say?

#

ofc it's not in the docs, it's not part of the api

rotund ravine
#

Which IDE are you using?

covert yacht
#

VScode (don't kill me lol, i don't like the java editors)

rotund ravine
#

Do you have a java linter?

#

Does it not suggest the imports?

covert yacht
#

Yes, it imports from import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;

Is it correct ? I assume that if i want to update to another version i'll need to change it ?

tender shard
#

yes, and yes

rotund ravine
#

That's correct and yes

#

Now, not sure how it is. Does the non-remapped jar still call the sendPacket function sendPacket? @tender shard or some generic thing like b

covert yacht
#

So not the best way ? ๐Ÿค”

#

Yes i saw a and b

rotund ravine
river oracle
kind hatch
covert yacht
#

This part is fixed thanks ๐Ÿ™‚

PlayerConnection connection = ((CraftPlayer) player).getHandle().b;
tender shard
tender shard
#

code in remapped-mojang:

kind hatch
tender shard
covert yacht
#

so .a is sendPacket ?

rotund ravine
#

Yes

#

well

#

on .b.b

kind hatch
rotund ravine
tender shard
tender shard
covert yacht
rotund ravine
#

?tryitandsee

kind hatch
tender shard
#

it's called ServerGamePacketListenerImpl#send(Packet) in mojang mappings

covert yacht
tender shard
#

in spigot the class is called "PlayerConnection", but there is no spigot mapping for methods anymore

rotund ravine
tender shard
#

so in spigot it'd be PlayerConnection#a

kind hatch
covert yacht
rotund ravine
tardy delta
#

public void m_eteisxqn(C_zyjtrjrl arg0) lol

kind hatch
tender shard
rotund ravine
#

So it's recent

tender shard
#

but in 1.18 and 1.19 it's definitely "a" in spigot or "send" in mojang

rotund ravine
#

Makes sense

kind hatch
#

Ah, I was unware that it changed since I use the remappings for everything past 1.17

tender shard
#

yeah me too. one I found out that ALL spigot mappings were gone in some version, I switched to mojang mappings lol

serene sigil
#

?paste

undone axleBOT
tender shard
serene sigil
#

(basically what this is is a lodestone compass that tracks the location of the dragon egg)

#

the location for the egg is EggTrackerFunction.currentEggLocation

kind hatch
#

Where do you update the item when it moves?

serene sigil
#

wdym?

#

i have a loop that always updates the location

kind hatch
#

What's that look like?

rotund ravine
kind hatch
#

It's probably because you are applying the changes to the local itemstack you created in that method instead of to the global variable.

#

However, there are some other things I'm questioning here.

rotund ravine
kind hatch
#

Like the use of static and the capital variable name.

serene sigil
#

ye, whenever i give myself that item it only updates it one time

kind hatch
#

Re-read what I sent.

peak depot
#

how can I use the spigotmc resource api to check if the plugin is Outdated or not

kind hatch
#

cough EggTracker vs eggTracker cough

serene sigil
#

lol sry

#

didnt see that

rotund ravine
#

@kind hatch Should be fine since he is setting the reference later, though the issue is most likely that the itemstack is being cloned due to it being granted in a recipe? Not sure, too lazy to look.

kind hatch
rotund ravine
#

That's not the issue. The global variable is set to the local variable later, therefore making the global variable the localvariable.

serene sigil
#

and how would i fix that issue?

rotund ravine
#

What I am saying is that he is granted the item via the recipe, the recipe is granting a "cloned item" so the issue is that any reflection in the original items metadata will not be reflected in the recipe granted item.

serene sigil
#

no, i didnt craft it, i gave the itemstack via a command

rotund ravine
serene sigil
#

its a command only for ops

#

?paste

undone axleBOT
serene sigil
#

basically it does this

kind hatch
#

How did that compile?

serene sigil
#

i changed it to lower case

#

lol

#

its in a different class

peak depot
#

how to check if plugin is outdated?

serene sigil
kind hatch
#

The other thing I'm wondering is if that scheduler is actually able to do anything.

tender shard
# peak depot how can I use the spigotmc resource api to check if the plugin is Outdated or no...

Iโ€˜ll just throw this in. You can use that, or look at the code for the SpigotMC endpoint: https://www.spigotmc.org/threads/spigotupdatechecker-powerful-update-checker-with-only-one-line-of-code.500010/

kind hatch
#

You need to update the player's inventory, or the item directly for it to change.

serene sigil
#

i tested it

tender shard
#

Then you get some json and parse it

peak depot
#

thats the link I was looking for thx

tender shard
#

Yeah its hard to find on the spigot website lol

peak depot
#

like maby that should be somewhere more easy to find

serene sigil
#

also.. is there a way to Tread.sleep() in a schedueler?

tardy delta
#

what are you trying to do?

rotund ravine
#

Why

undone axleBOT
serene sigil
#

nvm i found out

long zephyr
#

hi ^^, does anyone know why I am getting these empty pixels? (Size is CLOSE)
code:

int posx = player.getLocation().getBlockX();
        int posz = player.getLocation().getBlockZ();
int size = 128 << worldmap.scale;
        for (int x = posx - size/2; x <= posx + size/2 ; x +=64) {
            for (int z = posz - size/2 ; z <= posz + size/2; z += 64) {
                updater(x,z);
            }
        }
rotund ravine
#

CLOSE? also, there has to be more code.

long zephyr
tender shard
hot meteor
#

I'm slowly losing my mind trying to send a packet to any client that logs in. I registered a custom channel ("warpten:main") and am sending a packet through it:

server.getMessenger().registerOutgoingPluginChannel(plugin, "warpten:main");
server.getMessenger().registerIngoingPluginChannel(plugin, "warpten:main", this); // this implements IPluginMessageListener

ByteArrayDataOutput outputStream = ByteStreams.newDataOutput();
outputStream.writeInt(...);
outputStream.writeString(...).
player.sendPluginMessage(plugin, "warpten:main", outputStream.toByteArray());

Yet it looks like I'm not actually sending anything, as my client-side (written with Fabric) does not appear to receive anything. I also don't see anything in wireshark (but that's not a definite proof, as I don't think the plugin i'm using is up-to-date)

ivory sleet
#

a player has to be active on both the sending and receiving server for PMC API to work

#

(iirc)

hot meteor
#

What does that mean?

tardy delta
#

that one the source and destination server someone has to be online

hot meteor
#

Well yeah, i'm online.

#

the send bit happens in PlayerJoinEvent (delayed to next tick)

tardy delta
#

are there two players?

hot meteor
#

Why would there need to be two players? I'm trying to make a plugin (server) and a mod (client) communicate with each other

tardy delta
#

there needs to be a player online on the side where the plugin message comes from and one on the server where it should arrive iirc

hot meteor
#

So.... I need a player online on the client, but I can't be on the client without a player .... ?

#

You guys completely lost me. This is literally all the fabric code I have:

        ServerPlayNetworking.registerGlobalReceiver(channel, (server, player, handler, buf, responseSender) -> {
            System.out.println("ServerPlayNetworking.registerGlobalReceiver callback");
        });
buoyant violet
#

guys can someone create a clan plugin?

sharp heart
#

Hello, I have a problem with spigot 1.8.8, on spawning an entity when the player is offline, If this one join the server, he can't see the entity, even by using #addEntity method from WorldServer

vocal cloud
rotund ravine
undone axleBOT
buoyant violet
#

ok ty

twilit roost
#

Archimedes should be my dependency

tall dragon
twilit roost
#

no
Im trying to make the main plugin run without having it installed

#

the main plugin is shaded btw

tall dragon
#

if its not installed

#

ur dependency has to be shaded

#

right now it cant find the class

twilit roost
twilit roost
#

why dependency tho

tall dragon
#

wdym ur using Archimedes as dependency aren't you?

#

but Archimedes is not on the server anywhere

twilit roost
#

yes
and don't want to have Archimedes.jar in plugins folder
bcs it gets messy with that many plugins

tall dragon
#

is Archimedes a seperate plugin?

twilit roost
#

yep

tall dragon
#

or is it a library

twilit roost
#

well It started as plugin
then I stripped away extends JavaPlugin

tall dragon
#

are u sure it will still function without it being a plugin?

twilit roost
#

yep
it just does some math stuff

rn I realized it doesn't even need to have spigot-api

tall dragon
#

well anyway u need to shade Archimedes into the plugin ur using it in

twilit roost
#

well Im doing it just by using scope of provided and using shaded jar? am I?

smoky oak
#

provided means the jar will be there

#

like separately

tall dragon
#

yea

twilit roost
#

ooooh

tall dragon
#

u need to use scope compile

#

that will include it in ur jar

smoky oak
#

or u could just put the library ur using into the plugins folder

#

on a different topic im probably being an idiot again but why cant i use --remapped

twilit roost
tall dragon
misty ingot
#
    // turn mo,w,d,h,m,s into seconds
    private long getDuration(String duration) {
        long dur = 0;
        if (duration.equals("-1")) {
            return -1;
        }
        String[] split = duration.split("mo|w|d|h|m|s");
        for (int i = 0; i < split.length; i++) {
            if (duration.contains("mo")) {
                dur += Long.parseLong(split[i]) * 2592000;
            } else if (duration.contains("w")) {
                dur += Long.parseLong(split[i]) * 604800;
            } else if (duration.contains("d")) {
                dur += Long.parseLong(split[i]) * 86400;
            } else if (duration.contains("h")) {
                dur += Long.parseLong(split[i]) * 3600;
            } else if (duration.contains("m")) {
                dur += Long.parseLong(split[i]) * 60;
            } else if (duration.contains("s")) {
                dur += Long.parseLong(split[i]);
            }
        }
        return dur;
    }

this code is supposed to turn, say 1mo3w7h to "1 month 3 weeks and 7 hours (in seconds)"
but when I type for ex 1w1d it turns it into "2 weeks (in seconds)"
I have been trying to fix this for a bit but my brain is just exhausted and stackoverflow isnt helping

smoky oak
#

thats cuz ur not procesing the split strings

#

the duration thing is the whole string

#

so since it splits into two parts

#

but ur checking if the whole string contains mo

#

or w

#

it runs the week part twice

#

u want to do if(split[i].contains())

#

actually

#

that wouldnt solve it either but as said

#

the issue here is that ur checking the entire string

#

maybe call in ur if clauses replace("w","")

#

on the duration string

tardy delta
#

what about actually using a datetimeformatter huh

smoky oak
#

or that

misty ingot
#

ima try that rq

vocal cloud
#

Doing things the hard wayโ„ข๏ธ

rotund ravine
# misty ingot ``` // turn mo,w,d,h,m,s into seconds private long getDuration(String du...

I gave ur query to chatGPT:
It looks like the problem is that the code is only checking for the presence of the time units (e.g. "mo" for months, "w" for weeks, etc.) in the input string, rather than the actual values of the time units. This means that if the input string contains multiple time units, the code will only use the last time unit it finds.

For example, if the input string is "1w1d", the code will first split the string into the array ["1w1d"]. Then, it will check if the string contains "mo", which it doesn't, so it will move on to check for "w". Since the string does contain "w", it will use the value of the first element in the array, "1w1d", as the number of weeks and convert it to seconds. This is why you are getting the incorrect result of "2 weeks".

To fix this issue, you can use the String.split() method to split the input string into an array of time unit and value pairs. For example, you could use a regular expression that matches a time unit followed by one or more digits, like this:

String[] split = duration.split("(mo|w|d|h|m|s)[0-9]+");

Then, you can loop through the array and use a switch statement to convert each time unit and value pair to seconds. For example:

for (String pair : split) {
    String unit = pair.substring(0, 2);
    long value = Long.parseLong(pair.substring(2));
    switch (unit) {
        case "mo":
            dur += value * 2592000;
            break;
        case "w":
            dur += value * 604800;
            break;
        case "d":
            dur += value * 86400;
            break;
        case "h":
            dur += value * 3600;
            break;
        case "m":
            dur += value * 60;
            break;
        case "s":
            dur += value;
            break;
    }
}

This should correctly parse input strings like "1mo3w7h" and "1w1d" and convert them to the correct number of seconds.

smoky oak
#

can i have 2 hours without being slapped with chatgpt

rotund ravine
#

Probably not right haha, just let me know if it's not and i'll tell it

vocal cloud
#

Instead of using an AI you can do things the right way lol

smoky oak
#

also th eonly part in that code that looks like it could be wrong is that unit declaration

#

but if it is i have no idea how

rotund ravine
#

this way i can give stupid answers to stupid questions

#

sometimes good questions with good answers

#

without thinking much

vocal cloud
#

ChatGPT got banned off stack overflow for a reason

rotund ravine
#

meh

smoky oak
#

that didnt take long

smoky oak
#

its been out what

#

2 days

#

ish

misty ingot
# rotund ravine Probably not right haha, just let me know if it's not and i'll tell it
    private long getDuration(String duration) {
        long dur = 0;
        if (duration.equals("-1")) {
            return -1;
        }
        String[] split = duration.split("(mo|w|d|h|m|s)[0-9]+");
        for (String pair : split) {
            String unit = pair.substring(0, 2);
            long value = Long.parseLong(pair.substring(2));
            switch (unit) {
                case "mo":
                    dur += value * 2592000;
                    break;
                case "w":
                    dur += value * 604800;
                    break;
                case "d":
                    dur += value * 86400;
                    break;
                case "h":
                    dur += value * 3600;
                    break;
                case "m":
                    dur += value * 60;
                    break;
                case "s":
                    dur += value;
                    break;
            }
        }
        return dur;
    }

didnt work

Caused by: java.lang.StringIndexOutOfBoundsException: Range [0, 2) out of bounds for length 1
        at jdk.internal.util.Preconditions$1.apply(Preconditions.java:55) ~[?:?]
        at jdk.internal.util.Preconditions$1.apply(Preconditions.java:52) ~[?:?]
        at jdk.internal.util.Preconditions$4.apply(Preconditions.java:213) ~[?:?]
        at jdk.internal.util.Preconditions$4.apply(Preconditions.java:210) ~[?:?]
        at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98) ~[?:?]
        at jdk.internal.util.Preconditions.outOfBoundsCheckFromToIndex(Preconditions.java:112) ~[?:?]
        at jdk.internal.util.Preconditions.checkFromToIndex(Preconditions.java:349) ~[?:?]
        at java.lang.String.checkBoundsBeginEnd(String.java:4589) ~[?:?]
        at java.lang.String.substring(String.java:2703) ~[?:?]
smoky oak
#

told u it was that part

#

just delete the unit thingy and replace the unit in switch with pair

misty ingot
#

I seriously cannot process any of this rn, I just wanna get this bit done so I can go to sleep in peace

vocal cloud
#

Stop using that code and just use a formatter unless you hate yourself

misty ingot
#

well guess what? I hate myself

vocal cloud
#

That is apparent

misty ingot
#

what am I even writing anymore

    DateTimeFormatterBuilder formatterBuilder = new DateTimeFormatterBuilder()
            .appendValue(ChronoField.MONTH_OF_YEAR, 1)
            .appendLiteral("mo")
            .appendValue(ChronoField.DAY_OF_WEEK, 1)
            .appendLiteral("w")
            .appendValue(ChronoField.DAY_OF_MONTH, 1)
            .appendLiteral("d")
            .appendValue(ChronoField.HOUR_OF_DAY, 1)
            .appendLiteral("h")
            .appendValue(ChronoField.MINUTE_OF_HOUR, 1)
            .appendLiteral("m")
            .appendValue(ChronoField.SECOND_OF_MINUTE, 1)
            .appendLiteral("s");
    DateTimeFormatter formatter = formatterBuilder.toFormatter();
    private long getDuration(String duration) {
        if (duration.equals("-1")) {
            return -1;
        } else {
            return formatter.parse(duration).getLong(ChronoField.SECOND_OF_MINUTE);
        }
    }

Caused by: java.time.format.DateTimeParseException: Text '1w1d1h1m1s' could not be parsed at index 1

smoky oak
#

why dont u just use oflocalizedtime

#

ah right thats only up to a day

misty ingot
#

how do other punishment plugins handle this?

flat galleon
#

How can I create a dummy plugin that only registers a command

smoky oak
#

create a plugin that only registers a command

flat galleon
#

getProxy().getPluginManager().registerCommand(this, )

#

What do I use as a second argument

remote swallow
#

sinec when was doing that a thing

flat galleon
#

I cannot pass an actual command class, because I don't want to replace the functionality

smoky oak
#

the class that extends command

#

wdym dont want to replace functionality

#

u need a class extending commandhandler to make a command iirc

remote swallow
#

command executor

smoky oak
#

implements CommandExecutor

#

ye that

flat galleon
#

This is what is said in TAB's documentation

#

Second row last column

remote swallow
#

do you just want to register /sb as a real command

flat galleon
#

Note: This command will not appear in command auto-complete, because it's not a real registered command. Registered commands must be defined in plugin jar directly and cannot be dynamic. If you want to solve this, you can try getting a dummy private plugin made which registers that command.

remote swallow
#

i would guess tab just listen to async chat event so you just need to register the command with a class and thats it

flat galleon
remote swallow
#

yeah, they are most likely listening to an event

#

so you just register the command you want with it doing nothing

flat galleon
#

getProxy().getPluginManager().registerCommand(this, new SbCommand())

#

And then, I make an emtpy SbCommand class?

remote swallow
#

extending/implementing the correct stuff but probably

misty ingot
#
    DateTimeFormatterBuilder formatterBuilder = new DateTimeFormatterBuilder()
            .appendValue(ChronoField.MONTH_OF_YEAR, 1)
            .appendLiteral("mo")
            .appendValue(ChronoField.DAY_OF_WEEK, 1)
            .appendLiteral("w")
            .appendValue(ChronoField.DAY_OF_MONTH, 1)
            .appendLiteral("d")
            .appendValue(ChronoField.HOUR_OF_DAY, 1)
            .appendLiteral("h")
            .appendValue(ChronoField.MINUTE_OF_HOUR, 1)
            .appendLiteral("m")
            .appendValue(ChronoField.SECOND_OF_MINUTE, 1)
            .appendLiteral("s");
    DateTimeFormatter formatter = formatterBuilder.toFormatter();
    private long getDuration(String duration) {
        if (duration.equals("-1")) {
            return -1;
        } else {
            return formatter.parse(duration).getLong(ChronoField.SECOND_OF_MINUTE);
        }
    }

Caused by: java.time.format.DateTimeParseException: Text '1w1d' could not be parsed at index 1
how fix

slender mulch
#

how to send action bar to player

misty ingot
#

...

shut field
#

I am outputing via maven (clean package) in IntelliJ and it only has a dependency I need in it, and I am also outputing the code I need in a different artifact when I use the build artifact

#

how do I output both the clean package and code all in one

chrome beacon
#

?

#

If you're using maven don't use build artifact

shut field
chrome beacon
#

You probably have the folder structure wrong

#

Show us how your project looks

shut field
#

I suppose that is what I am asking for help with

remote swallow
#

?conventions

shut field
#

Torture is the main class

#

I have a dependency I am shading the pom.xml and when I use clean package it is the only thing in the jar, none of my code

#

and when I use build artifact only my code is outputed, not the dependency

#

how do I use a mvn command to get both the dependency and code

remote swallow
#

press control twice then type mvn clean package

chrome beacon
river oracle
#

Unless you make your own build tool ๐Ÿ”ง ๐Ÿ˜‰

shut field
chrome beacon
#

A directory

#

not a package

shut field
#

are they different in IntelliJ?

river oracle
#

In vscode everything looks like a directory so there's no getting them confused

river oracle
shut field
#

I don't see a directory button

river oracle
#

Damn rough intellij moment

#

Might need to right click or something

chrome beacon
#

That's because you've told Intellij that src is a java folder

river oracle
#

Prob just go into your file explorer

chrome beacon
#

^

#

or use the Minecraft Development plugin to setup a new working project

river oracle
#

Dumb that you can't just make dirs tho thats strange design

shut field
#

oh I can make a directory outside src

#

and by main do you mean the word main or the lowercase name of my main function

river oracle
#

main

#

The word

#

src/main/java is the exact directory name you need

shut field
remote swallow
#

its in src not src/main/java from that screenshot

covert yacht
#

Is there a javadoc for import net.minecraft. etc imports ?

covert yacht
#

Nice ๐Ÿ˜…

remote swallow
#

its mojang what did you expect

chrome beacon
#

What did you expect? It's decompiled code from Mojang

shut field
covert yacht
covert yacht
#

Thanks

river oracle
#

The only docs is trying to figure it out

#

You can decompile the jar and snoop around

smoky oak
kind hatch
#

That's a flag for buildtools. It applies the mojang mappings to NMS. Basically deobfuscating it.

smoky oak
#

i know that

#

what im asking is why buildtools tells me it doesnt know remapped

kind hatch
#

What's your full command look like?

smoky oak
#

uuuh java -jar buildtools.jar --generate-source --generate-docs --rev latest --remapped

#

i think it sthat

kind hatch
#

Have you downloaded the most recent version of BuildTools?

smoky oak
#

its a recent ish version, one that should have come out after 1.19.2 was published but i didnt download the newest right before compiling

#

i can try that

smoky oak
#

see the only reason im using powershell is this one:

#

whic doesnt exist for normal shell

#

for some reason my right click menu has pshell in it

chrome beacon
#

Git Bash Here ;/

#

Use it

smoky oak
#

for some reason i feel like i shouldnt do that

remote swallow
#

for some reason i think you should

#

judging that the buildtools page tells you to download git

smoky oak
#

which i did

remote swallow
#

so use git bash

smoky oak
#

theres a difference between git as a program and the git bash

remote swallow
#

just use gitbash

kind hatch
#

Yea, and?

#

If you don't want to use gitbash, then at least use cmd.

smoky oak
#

so it complained about remapped again even with the new buildtools but im about 99% sure thats not cuz im using powershell

smoky oak
#

i dont trust win 11

rotund ravine
kind hatch
quaint mantle
#

what's the most correct way to give a player an ItemStack?

rotund ravine
chrome beacon
#

The command you used works fine in git bash

remote swallow
quaint mantle
#

ok

#

no need to check for inv full, etc. ?

rotund ravine
#

it will return the itemstacks not able to be added.

chrome beacon
#

?jd-s

undone axleBOT
chrome beacon
#

Use it :p

quaint mantle
#

ah ok

rotund ravine
quaint mantle
#

ty

smoky oak
#

same error in black console

remote swallow
#

just use git bash

#

ive always used it to run build tools and i get 0 issues

smoky oak
#

so 1) using a specific version does not help

#

and im running the latest buildtools versino

#

so why in the world dont i get the remapped

chrome beacon
#

I have that message too

#

Didn't even check since I thought your build failed

#

Either way it does remap

smoky oak
#

iirc they said something about 'all api is now here' but does that affect remapped?

#

aaalright then

smoky oak
#

um so apparantly op doesnt have the * permissoin

kind hatch
#

Yes, * is a wildcard operator. So it's not included by default.

eternal oxide
#
  • is not a permission that Bukkit understands
smoky oak
#

is there a simpler way of doing this, then? Im trying to get messages to op players
Bukkit.getOnlinePlayers().forEach(e -> { if(e.isOp()||e.hasPermission("*")) e.getPlayer().sendMessage(msg); });

hazy parrot
#

Bukkit.broadcast ?

worldly ingot
#

Wildcard is usually interpreted by permission plugins

#

Elgar's right in saying that Bukkit has zero concept of it

eternal oxide
#

If you are sending to op players than isOp is all you need

kind hatch
smoky oak
tropic moss
#

Hello I'm trying to make a menu that have a icon 'SIGN' that open a non existent sign and the content written there is returned to me.
For that i started locking and I found that with protocolLib is possible but when I try to do it I get an error that I don't know how to solve.

#
//Method to create the 3 packets
//BLOCK_CHANGE, OPEN_SIGN_EDITOR, TILE_ENTITY_DATA
public void open(Player player) {
            ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
            Location location = player.getLocation();

            position = new BlockPosition(location.getBlockX(), location.getBlockY() + (255 + location.getBlockY()), location.getBlockZ());

            //Create the NBT
            NbtCompound nbt = NbtFactory.ofCompound("SignData");
            nbt.put("Text1", "lineas");
            nbt.put("id", "minecraft:oak_sign");
            nbt.put("x", position.getX());
            nbt.put("y", position.getY());
            nbt.put("z", position.getZ());

            PacketContainer blockChange = protocolManager.createPacket(PacketType.Play.Server.BLOCK_CHANGE);
            blockChange.getBlockPositionModifier().write(0, position); //Location
            blockChange.getBlockData().write(0, WrappedBlockData.createData(Material.OAK_SIGN)); //Block
            protocolManager.sendServerPacket(player, blockChange);

PacketContainer tileEntity = protocolManager.createPacket(PacketType.Play.Server.TILE_ENTITY_DATA);
            tileEntity.getBlockPositionModifier().write(0, position);
            tileEntity.getNbtModifier().write(0, nbt);
            tileEntity.getIntegers().write(0,9); // 9 - Set the text on a sign
            protocolManager.sendServerPacket(player, tileEntity);

            PacketContainer openSign = protocolManager.createPacket(PacketType.Play.Server.OPEN_SIGN_EDITOR);
            openSign.getBlockPositionModifier().write(0, position);
            protocolManager.sendServerPacket(player, openSign);

            
        }```
#

The problem that i'm getting is a 'com.comphenix.protocol.reflect.FieldAccessException: Field index 0 is out of bounds for length 0' that points me to the line 'tileEntity.getIntegers().write(0,9); // 9 - Set the text on a sign' and I don't know why

smoky oak
#

?paste mate

undone axleBOT
kind hatch
sterile token
#

Im needing some command frameworks recommendations for spigot!

trim creek
#

What

ruby pebble
#

Is there a way to use a float value in the "meta.setDamage()" function?

ivory sleet
smoky oak
#

wait

trim creek
#

(float) integer?

ruby pebble
trim creek
#

Well then

smoky oak
#

iirc aint damage a int between 0 and MAX_DURABILITY? then u shouldnt be able to give it anything but an int

ruby pebble
#

so is there any alternative?

buoyant violet
#

i need help on this

#

it goes on loop

ruby pebble
buoyant violet
#

?hel

#

?help

undone axleBOT
#
CafeBabe Help Menu
*Red V3*
**__Admin:__**

selfrole Add or remove a selfrole from yourself.

**__Cleanup:__**

cleanup Base command for deleting messages.

**__Core:__**

embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.

**__Downloader:__**

findcog Find which cog a command comes from.

**__Mod:__**

names Show previous names and nicknames of a member.
userinfo Show information about a member.

**__ModLog:__**

listcases List cases for the specified member.
reason Specify a reason for a modlog case.

**__Permissions:__**

permissions Command permission management tools.

buoyant violet
misty current
#

can you merge 2 futures into one?

buoyant violet
misty current
#

something similar to CompletableFuture.allOf

ruby pebble
buoyant violet
ruby pebble
#

thought about my own problem ;-;

#

sorry

misty current
#

you can't have decimal item damage in minecraft

misty current
#

or do you have 2 dices rolling at once?

#

if you roll both at once just check if they are equal

ruby pebble
rotund ravine
#

Whny

#

Why*

misty current
#

if you say i have to it won't make the game magically accept decimal damage

rotund ravine
#

You have an equal (non-decimal) amount all the time during any thing in spigot.

leaden flint
#

Hery, very likely an easy fix but I'm trying to learn how to make a simple plugin but I get 'The package org.bukkit is not accessible'. But I have 'craftbukkit-1.19.2.jar' in my referenced libraries on eclipse

ruby pebble
rotund ravine
#

So yo uhave 20 hp.

#

Which means 10 x 2. Each 1 is half a heart.

misty current
#

he's talking about item damage

#

health damage can be decimal

leaden flint
hybrid spoke
#

health is decimal

ruby pebble
misty current
#

hearts just display a rounded amount of your actual health

rotund ravine
#

@leaden flint why do you both have craftbukkit and spigot

#

remove one of them.

misty current
#

what's the future method to block the thread until the value is returned?

rotund ravine
#

@misty current sounds like a bad idea

#

are you sure?

vocal cloud
#

Why would want to block the thread ever?

leaden flint
#

I only had spigot and had the same error. Should I remove spigot instead?

misty current
#

so i'm sure that they get properly shutdown

vocal cloud
#

Well there's .shutdown for shutting down things if you're using regular runnables

#

Assuming you're using a service

leaden flint
#

Just tried removing spigot instead now and only having craftbukkit though error still seems to be there

hazy parrot
#

tf

eternal oxide
#

do not depend on craftbukkit

leaden flint
#

unfortunately I had the same issue with only spigot ๐Ÿ˜ฆ

eternal oxide
#

you are importing the wrong jar

#

?bootstrap

undone axleBOT
#

Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.

Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163

leaden flint
#

Ahh thanks, that fixed that error but replaced it with 'The type org.bukkit.(all the ones I'm trying to import) is not accessible

#

e.g. org.bukkit.location is not accessible

rotund ravine
#

?cba

undone axleBOT
#

Jan Tuck#0142 definitely regrets to for the most part inform you that unfortunately, they essentially are unable to definitely assist with definitely your enquiry, which essentially is fairly significant. Please simply really ask again later or possibly kind of ask someone else about this enquiry, demonstrating that the person that ran this command generally regrets to kind of inform you that unfortunately, they for the most part are unable to generally assist with actually your enquiry in a subtle way. Thank you very sort of much for kind of your time and the person that ran this command specifically wishes you a really good day, so the person that ran this command really regrets to actually inform you that unfortunately, they literally are unable to definitely assist with very your enquiry, or so they particularly thought.

eternal oxide
#

show a screen of your current project setup

vocal cloud
#

Such an awful spammy command.

rotund ravine
eternal oxide
#

it's also broken english, no clue who wrote it

vocal cloud
#

If you like being unhelpful sure

#

Clogs up chat with the same copy pasted junk

leaden flint
smoky oak
#

what about 1000 enter inputs

eternal oxide
#

@worldly ingot could you delete the ?cba command, it's rude and spammy.

eternal oxide
hybrid spoke
#

?cba

molten hearth
#

What's wrong with

smoky oak
#

man discord lags a lot if u try to insert 1000 lines

molten hearth
#

?cba

worldly ingot
#

Okay, there are questions trying to be answered. Let's not

vocal cloud
#

It's not funny and annoying as hell

hybrid spoke
smoky oak
#

also i cant even hit enter, seems like they do have some basic spam detection

worldly ingot
#

That's fine and if you like it so much, don't give us reason to revoke your access to it

eternal oxide
#

if you cba you just don;t answer.

leaden flint
rotund ravine
#

No clue what's wrong with ur eclipse, i'll let the experts help u. Might i suggest maven or gradle?

smoky oak
#

my 'updating' is hitting enter once and changing a number

#

so id recommend maven yes

eternal oxide
hybrid spoke
#

best fix for eclipse: switch to intellij

eternal oxide
#

Eclipse is nectar from the gods

smoky oak
rotund ravine
smoky oak
#

man screw eclipse and vscode and bluej and...

#

why do 9 out of 10 IDEs have a default white background man

hybrid spoke
#

yeah fr

rotund ravine
hybrid spoke
#

rather would have no background

#

transparent

leaden flint
#

Ahhh right ok I believe I have the right one now, only difference being 1.19.2 instead of 1.18 - Just got the error with the types not being accessible

rotund ravine
#

What?

#

So does it work, or does it not work?

eternal oxide
#

if you still have the error you don;t have the correct jar

sterile token
heavy perch
#

any gradle professionals?

hazy parrot
#

?ask

undone axleBOT
#

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

heavy perch
#

lol k xD

sterile token
leaden flint
#

Oh damn hmm, the jar I'm using now is spigot-api-1.19.2-R0.1-SNAPSHOT-shaded.jar
The only other jar in that path is the same one without shaded, would that be it?

eternal oxide
#

thats the correct jar

hybrid spoke
eternal oxide
#

click on yoru project in the left pane and press F5

#

or project menu and clean

heavy perch
#

I can't seem to exclude packages/classes.

leaden flint
#

doesn't seem like refreshing or clean changed anything for me

sterile token
#

I need some command apis recommendation for spigot, specially that simpliers and lighweight ones

heavy perch
#
shadowJar {
  exclude 'net.kyori'
  exclude 'com.google.gson'
}
heavy perch
#

that's my excludings

#

and they don't seem to be excluded

sterile token
tardy delta
#

\๐Ÿ‘€

sterile token
#

I need something like a ligthweight and simply command api, which allow you simpe BaseCommand-CommandArgument structure, also with tab completation and permissions parenting. But i dont know why all the frameworks around are heavier fur such a simple api that wouldnt take that maount of classes

tardy delta
#

i dont really care whether its heavy or not lol

#

like if your jar is 13mb who cares

#

if it were to be a gigabyte i'd care

sterile token
#

Well my clients care tho and they are not spanish, mostly english clients all of them care about sizes

tardy delta
#

why

hybrid spoke
#

thats what she said

tardy delta
#

youre not alex

sterile token
#

They argue that such a stupid plugin like a hubcore cannot be more than 100kb size

hybrid spoke
tardy delta
#

why not

tardy delta
#

like cant they give real arguments lol

#

they just saying it cant be that big, why?

hybrid spoke
#

1MB is big for a plugin, but not complainable

winged anvil
#

anyone else scared about ChatGPT?

tardy delta
#

im more scared about copilot sending me stackoverflow links

winged anvil
#

lmao

hybrid spoke
#

AI is love

smoky oak
winged anvil
#

huh

sterile token
#

GPT-3 is amazing, really well designed IA example

#

I have seen a guy that use it to study a 70 hours school class in 1 day by the thanks of GPT-3 IA

covert yacht
twilit roost
wet breach
#

anyways based on the limited information provided, what is even the rotation values you are pulling?

twilit roost
#

dont mind that Copyright thingy ๐Ÿ˜„
I just was once bored and thought to set up one of those bad boiz

ruby pebble
#

Is it possible to add nbt to item with item meta?

vivid skiff
#

How can i check if a player is rightclicking him from behind?

twilit roost
#

PlayerInteractAtEntityEvent
and just check location

solid cargo
#
            if (player.getServer().getInfo().getName().contains("auth") || !player.hasPermission("mcbc.bungee")) {

will this also execute if a player with permission mcbc.bungee is in the server auth?

#

too lazy to test

vivid skiff
#

Im tring to import NMS for 1.16.5 in maven but it can't find the depedency, i checked the maven repository folder and 1.16.5 is installed but maven can't find it, how can i fix it?

twilit roost
solid cargo
#

i decided to test it and it works as i wanted to

hazy parrot
#

it will run if in server auth or doesnt have mcbc.bungee permission

eternal oxide
humble tulip
#

@twilit roost what's the divergence?

#

You're passing bullet distance as divergence?

humble tulip
#

Isn't divergence how much the snowball diverges from where it goes?

eternal oxide
#

yes @solid cargo

twilit roost
twilit roost
humble tulip
#

Velocity affects distance

#

Let barrel length affect divergence

#

So guns with longer barrels shpuld have less divergence

twilit roost
#

I had no clue of what divergence means, so I tried some random value. And then figured out, its "randomnes"

heavy prairie
#

uhh im trying to make my own plugin that basically detects the biome by ur location and sends it trough a command

#

im trying to use the getLocation() func (idk if it is a function) but i cant find it anywhere

#

i get errors

smoky oak
#

call it on a player object

heavy prairie
#

i have a return true; at the end

hazy parrot
#

brrr

#

?learnjava

undone axleBOT
hazy parrot
#

call it on object, not class

#

also you can smart cast

#

also this is not how you call your declared variable

river oracle
#

Myes that's the worst code I've seen in a bit in here

heavy prairie
#

i dont remember much from java

#

i took some online courses some time ago

river oracle
#

Please learn Java

heavy prairie
#

i will

river oracle
#

Also "var" ๐Ÿ˜ญ

hazy parrot
#

also error 404 is usually referred as http error and stands for "Not found", i think it doesn't belong there

heavy prairie
#

i put that as a small joke

#

dont mind that

hazy parrot
#

oh alright

sonic goblet
#

๐Ÿงข

heavy prairie
#

ima put learn java on my todo list

tardy delta
#

why are people still using equals ignore case

#

dont want to see people doing /BIOME

#

also are you combing js http status codes and java?

dry forum
#
        if (!(e.getEntity().getLastDamageCause() instanceof Player)) {
            return;
        }``` trying to only run the code if the entity that died was killed by a player, when the damagecause is broadcasted, its the event, not the player or anything  https://cdn.discordapp.com/attachments/829796363188830218/1050889469319974952/image.png
eternal oxide
#

if a command is case sensitive it's a poor design

tardy delta
#

404 biome not found lmao

desert loom
#

you have to check the event for that stuff

dry forum
#

if im getting the entity, then the damage cause, why would it return the event?

hazy parrot
dry forum
#

ah ok i see now

#

i dont need a damagecause for player?

#

entity.getLastDamageCause().getCause() returns an enum

#

im trying to check if an entity was killed by a player

#

i am

#

is it just if the event is instanceof player?

#

ah ok thanks

river oracle
#

getKiller can be null

#

just so you know

covert yacht
#

Hi i can't seem to make the EntityPlayer propery, it returns me an error.

The constructor EntityPlayer(MinecraftServer, WorldServer, GameProfile, PlayerInteractManager) is undefined

and 

The constructor PlayerInteractManager(WorldServer) is undefined``` (L50)

https://paste.md-5.net/ivivoyugon.java#L50
#

I assume that because PlayerInteractManager is undefined EntityPlayer cannot be defined ๐Ÿค”

chrome beacon
#

What version are you on?

#

Also by undefined do you mean it can't find the constructor

covert yacht
#

1.19.2

And yes, i think EntityPlayer does not accept undefined as param

chrome beacon
#

Undefined as param??

covert yacht
#

new PlayerInteractManager(nmsWorld) seems to be undefined as the error says, and this one is used as a param for new EntityPlayer

chrome beacon
#

Yeah if it can't find the constructor it doesn't exist

#

Open the class and check what you need

#

If you can't figure out how nms works I recommend using a premade plugin such as Citizens

#

It has a great API you can use

chrome beacon
#

No

#

You can get it for free

#

Read the Spigot page

tardy delta
#

you can get anything for free :)

chrome beacon
#

It's a freemium plugin

chrome beacon
covert yacht
chrome beacon
#

And get malware as a bonus!

covert yacht
#

Just need to remember my spigot logins

covert yacht
dry forum
#

is there a way to get a block or something before its placed? i have a block with lore "32", and if the lore is 32, it places 32 blocks in the direction the block is placed but im not sure how to get the lore and im 90% sure the blockplaceevent is called after the block is placed

tardy delta
#

technically its called before

covert yacht
dry forum
#

i cant get the block as an itemstack or anything though?

covert yacht
#

I guess you need to get the block then convert it to an itemstack with it's data

dry forum
#

not sure how id do that but ItemStack stack = (ItemStack) e.getBlock(); says cant be casted

eternal oxide
#

why do you want an ItemStack of a Block?

undone axleBOT
dry forum
#

im just trying to get the lore of an item before its placed

#

๐Ÿ˜•

eternal oxide
#

that has nothing to do with a Block

dry forum
#

idk how to do it

#

couldnt find anything on google

tardy delta
#

lmao just wanted to sent

rare gorge
#

How do I make Component.text() accept ยง (color codes)?

river oracle
#

Components have #color methods

#

oh wait thats moj maps

#

unsure

hazy parrot
rare gorge
#

i figured out why it was broken

#

i accidentally had \\u00A7 instead of \u00A7

sour tundra
quartz basalt
#
        if (stack.getItemMeta().getDisplayName().equalsIgnoreCase(t("&7&l32 &r&7Block Bridge"))) {
            Bukkit.broadcastMessage("works");``` why is "works" not getting broadcasted? when i broadcast the name of the item its the correct name, i copy and pasted it so its 100% right
sour tundra
#

try to for each every player online and just send them "private" message

#

for (Player p : onlinePlayers) { p.sendMessage("x")..}

quartz basalt
#

its just for debugging

rare gorge
quartz basalt
#

quicker to broadcast

rare gorge
#

mejbi's solution looks easy

#

just put it in a method called broadcastMessage

quartz basalt
#

my goal isnt to send everyone a message, the broadcasting is just to debug why the if statement isnt working

hazy parrot
sour tundra
quartz basalt
#

translates its public String t(String m) { return ChatColor.translateAlternateColorCodes('&', m); }

sour tundra
#

"&7&l32 &r&7Block Bridge".replace("&", "ยง")

#

hm

#

maybe insted of comparing name to string, try to check if the name contain some key word like : "Bridge"

quartz basalt
#

well that worked for some reason

#

ig ill just need to use that ty

sour tundra
#
public String t(String m) {
    if (m == null) return null;
    return ChatColor.translateAlternateColorCodes('&', m);
}
#

i recommend you making something like this

#

or maybe @|NotNull| annotation

last sleet
#

Is there a way to make ChatColor accept hex codes or do something similar

#

oh wait the discussion is already about this

sour tundra
#

ChatColor red = ChatColor.of("#FF0000");

last sleet
#

ah, with the '#'. Okay thanks

subtle pewter
sour tundra
#

wot

quaint mantle
hazy parrot
hazy parrot
subtle pewter
hazy parrot
subtle pewter
hazy parrot
#

:/

rare gorge
#

How can i get a readable string from TextComponent? I am getting them from item.lore() and trying to read it in strings
ok so item.getLore() does this, but its deprecated because idk bruh
if there's a better way lmk please

last sleet
#

I assume arrow velocity plays a role in arrow damage, but does anyone know how you would get a double damage from a vector arrowMomentum and double arrowDamage ?

desert loom
#

I think it's on the minecraft fandom wiki

tardy island
#

how should i go about setting a unique id on an item, threads on spigot suggest different things. i was wondering if there's a best approach.

remote swallow
#

unique id as in?

tardy island
#

as in lets say i give a player a chest. i want that chest to contain like playername.epochtime or something but it has to be hidden

remote swallow
#

?pdc

kind hatch
#

Use the PDC then.

tardy island
#

ahh i appreciate it lol

azure gate
#

hlo

#

should i use api for making inventories for my plugin

quaint mantle
#

Material.matchMaterial and Material.getMaterial dont work.

#

Im using a string called "Diamond" and it doesnt detect it in either case.

#

Is something wrong with doing that?

blazing locust
#

how do import the thing that represents all entities

quaint mantle
#
String obj = "Diamond" //Example

System.out.println(Material.matchMaterial(obj));
System.out.println(Material.getMaterial(obj));
blazing locust
#

is it just org.bukkit.entity

warm trout
#

When using hikariCP, I try to set the database name using

properties.setProperty("dataSource.databaseName", dbConfig.getDatabase());```
#

But I get this error

#

Any ideas?

remote swallow
quaint mantle
sullen marlin
#

Not for match material

tardy island
#

i just made a item that you can rightclick, open an inventory, put item in and it will still be there when you reopen. happy happy, this was a good learning experience as my second plugin

blazing locust
#

how do i

#

get entities' properties

misty ingot
#
    DateTimeFormatterBuilder formatterBuilder = new DateTimeFormatterBuilder()
            .appendValue(ChronoField.MONTH_OF_YEAR, 1)
            .appendLiteral("mo")
            .appendValue(ChronoField.DAY_OF_WEEK, 1)
            .appendLiteral("w")
            .appendValue(ChronoField.DAY_OF_MONTH, 1)
            .appendLiteral("d")
            .appendValue(ChronoField.HOUR_OF_DAY, 1)
            .appendLiteral("h")
            .appendValue(ChronoField.MINUTE_OF_HOUR, 1)
            .appendLiteral("m")
            .appendValue(ChronoField.SECOND_OF_MINUTE, 1)
            .appendLiteral("s");
    DateTimeFormatter formatter = formatterBuilder.toFormatter();
    private long getDuration(String duration) {
        if (duration.equals("-1")) {
            return -1;
        } else {
            return formatter.parse(duration).getLong(ChronoField.SECOND_OF_MINUTE);
        }
    }

trying to turn text like 1mo1w7h into 1 month, 1 week, 7 hours (in seconds)
error:
Caused by: java.time.format.DateTimeParseException: Text '1w1d' could not be parsed at index 1

tardy island
#

I know nothing about saving data to a file, which method is considered the best? Theres so many json, gson, yaml, mysql ect

remote swallow
#

gson is googles json api, but it pretty much just depends on the use case

lofty belfry
#

hi, does anyone know how to combine two variables like Player.playersneakcount

#

it would really help

remote swallow
#

im confused, do you want to get the player sneak statistic

lofty belfry
#

so i made a variable called playersneakcount

#

but how can i make it a part of player

#

only spesific to that player i mean

remote swallow
#

you cant without reflection iirc

#

save it to their pdc if you only need it for a specific player

#

?pdc

lofty belfry
#

thanks

tardy island
#

@remote swallow the use is storing hashtables, any suggestions?

heavy perch
#

How dangerous is it to call Bukkit#getOfflinePlayer#getName from an async block?

#

is there any danger at all?

remote swallow
remote swallow
tardy island
#

The plugin creates an item and each item created (unlimited) gets put in the hash table, I'd only read from it once on start.

remote swallow
#

are you just storing the items? you can probably use pdc if you just need to check if its yours

#

?pdc

tardy island
#

not exactly I should have been more precise with what's being stored. It's EpochTime (used to identify items, its in their meta) and a class which creates an inventory. So its a hashmap(Key:EpochTime, Pair: BundleItemsClass)

remote swallow
#

i would probably suggest json for that then

tardy island
#

ok and by that you mean actually json not the gson thing people talk about? o wait i re-read what you said, thanks

hard socket
#

why is my roleMapping null?

#

roleMapping = new ConcurrentHashMap<>(roleMapTemp);

#

java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0

vast raven
#

Is it possibile to get a player starting from a GameProfile?

chrome beacon
#

Do you want to find an online player?

vast raven
#

I'm using CorpseRebornAPI and since I need to spawn a corpse, but the method .spawnCorpse() must require a player, but I only have the GP, I was wondering if you can get it

chrome beacon
#

Is the player online

vast raven
#

Not always

#

so I'm creating a fake player starting from his propertyMap (GP)

#

But once I have the GP, how do I pass to a player?

chrome beacon
#

If you're using a fake player you probably can't use the CorpseRebornAPI

summer scroll
#

Hey, I'm trying to open an inventory when an inventory with specific inventory holder close, but I'm getting a StackOverflowError, I'm guessing that error occurs because the code never stops.

    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
    public void onToolCupboardInventoryClose(InventoryCloseEvent event) {
        if (event.getPlayer() instanceof Player player &&
                event.getInventory().getHolder() instanceof TCInvHolder holder) {

            new TCInventory(holder.tc())
                    .open(player);
        }
    }
vast raven
undone axleBOT
summer scroll
vast raven
#

So basically I need to spawn a corpse even if a player is offline, I overlooked on the pl src, and I need to start from a json of the propertyMap, until the player object where I need to use the spawnCorpse() method here

#

@chrome beacon

remote swallow
chrome beacon
#

Spawn your own corpses

vast raven
#

at this point I'll try to use reflections

vast raven
summer scroll
chrome beacon
alpine urchin
#

one moment

chrome beacon
#

They've clearly said they only want to use that api

alpine urchin
#

ok

vast raven
chrome beacon
#

?

vast raven
#

cause the plugin from the offline player takes only the skin and that's it

vast raven
chrome beacon
#

Like inventory and such or?

vast raven
#

CorpseReborn takes as parameter the Player, cause it needs to get the skin, but speaking of inv there is another parameter for that

#

In my case there's no need of setting an inventory for the corpse

vast raven
misty ingot
#
    DateTimeFormatterBuilder formatterBuilder = new DateTimeFormatterBuilder()
            .appendValue(ChronoField.MONTH_OF_YEAR, 1)
            .appendLiteral("mo")
            .appendValue(ChronoField.DAY_OF_WEEK, 1)
            .appendLiteral("w")
            .appendValue(ChronoField.DAY_OF_MONTH, 1)
            .appendLiteral("d")
            .appendValue(ChronoField.HOUR_OF_DAY, 1)
            .appendLiteral("h")
            .appendValue(ChronoField.MINUTE_OF_HOUR, 1)
            .appendLiteral("m")
            .appendValue(ChronoField.SECOND_OF_MINUTE, 1)
            .appendLiteral("s");
    DateTimeFormatter formatter = formatterBuilder.toFormatter();
    private long getDuration(String duration) {
        if (duration.equals("-1")) {
            return -1;
        } else {
            return formatter.parse(duration).getLong(ChronoField.SECOND_OF_MINUTE);
        }
    }

trying to turn text like 1mo1w7h into 1 month, 1 week, 7 hours (in seconds)
error:
Caused by: java.time.format.DateTimeParseException: Text '1w1d' could not be parsed at index 1

how can I fix this?

misty ingot
#
    private long getDuration(String duration) {
        long dur = 0;
        if (duration.equals("-1")) {
            return -1;
        } else {
            // split at mo|w|d|h|m|s and get numbers next to it
            String[] split = duration.split("(?<=mo|w|d|h|m|s)");
            for (String s : split) {
                if (s.endsWith("mo")) {
                    dur += Long.parseLong(s.substring(0, s.length() - 2)) * 2592000;
                } else if (s.endsWith("w")) {
                    dur += Long.parseLong(s.substring(0, s.length() - 1)) * 604800;
                } else if (s.endsWith("d")) {
                    dur += Long.parseLong(s.substring(0, s.length() - 1)) * 86400;
                } else if (s.endsWith("h")) {
                    dur += Long.parseLong(s.substring(0, s.length() - 1)) * 3600;
                } else if (s.endsWith("m")) {
                    dur += Long.parseLong(s.substring(0, s.length() - 1)) * 60;
                } else if (s.endsWith("s")) {
                    dur += Long.parseLong(s.substring(0, s.length() - 1));
                }
            }
        }
        return dur;
    }

figured it out 1 min ago

eternal oxide
#

Just a regex

#

mine is simpler and cleaner ๐Ÿ˜‰

misty ingot
#

what about mo

tardy delta
#

heeheehee

eternal oxide
#

simple to add

misty ingot
eternal oxide
#

you just have to add a [mo] in the regex (probably)

#

or (mo)

misty ingot
eternal oxide
#

yes

#

it may need () not []. test and see

#

[] is any of, () is all of (I think)

onyx fjord
#

is there a way to get natural drops when player breaks block?

#

for example: player has fortune prickaxe and breaks some ore

smoky oak
chrome beacon
eternal oxide
#

I just tried ([0-9]+)([(?:mo)wdhms]) but it always ignores the o

smoky oak
#

([0-9]+)((mo)|[smhdw])

#

there u go

onyx fjord
smoky oak
#

worked for me at least

eternal oxide
onyx fjord
#

BlockBreakEvent

smoky oak
#

thats weird

#

where do u test ur regex

eternal oxide
#

actually no, your regex matches nothing

smoky oak
#

idk where youre testing your regex but regexr tells me its working

eternal oxide
#

passing a string of 2mo9w1d1h5m

smoky oak
#

idk what ur doing but it works for me

eternal oxide
#

doh, I had an odd character at teh start when copy paste ๐Ÿ™‚

#

oddly it's does a two group match on mo though

smoky oak
#

well at least it matches it twice to mo

eternal oxide
#

fixed ([0-9]+)((?:mo)|[smhdw])

smoky oak
#

ah right group delimiter

#

or whatever that grouping things called

eternal oxide
#

it was matching mo on each character

smoky oak
#

ah

#

yea thatd make more sense liek that

eternal oxide
#

@misty ingot there's your regex ([0-9]+)((?:mo)|[smhdw])

misty ingot
smoky oak
misty ingot
#

thanks

smoky oak
#

so apparantly some people cant see Elgar

#

noted

eternal oxide
#

too insignificant ๐Ÿ™‚

misty ingot
#
    private static final Pattern periodPattern = Pattern.compile("([0-9]+)((?:mo)|[smhdw])");

    public static Long getDuration(String period){

        if(period == null) return null;
        period = period.toLowerCase(Locale.ENGLISH);
        Matcher matcher = periodPattern.matcher(period);
        Instant instant=Instant.EPOCH;

        while(matcher.find()){
            int num = Integer.parseInt(matcher.group(1));
            String typ = matcher.group(2);
            switch (typ) {
                case "mo":
                    instant = instant.plus(Duration.ofDays(num * 30));
                    break;
                case "w":
                    instant = instant.plus(Duration.ofDays(num * 7));
                    break;
                case "d":
                    instant = instant.plus(Duration.ofDays(num));
                    break;
                case "h":
                    instant = instant.plus(Duration.ofHours(num));
                    break;
                case "m":
                    instant = instant.plus(Duration.ofMinutes(num));
                    break;
                case "s":
                    instant = instant.plus(Duration.ofSeconds(num));
                    break;
            }
        }
        return TimeUnit.MILLISECONDS.toMinutes(instant.toEpochMilli());
    }

typed in 1mo1w1d1h1m1s and it returned 15 hours 13 minutes and 1 second
Note - I want the duration in seconds

smoky oak
#

?paste mate

undone axleBOT
smoky oak
#

also if your method can return null you should use Optional

misty ingot
#

it cant return null

smoky oak
#

if period==null return null

#

whats that then

#

a hallucination?

misty ingot
#

ah

#

um

#

ehm

eternal oxide
misty ingot
#

ayy it works

#

thanks guys

glossy venture
#

what is the mojang mapped packet class for this

#

oh nvm thats server bound

#

i think i got it but idk

#

nvm lol

#

bruh

smoky oak
#

bah im getting insane over this. might not count as develeopement per se, i need design advice.
So I'm creating a bunch of no further determined effects, stacking them in a Set of interface EffectPreset.
Is there a better way than doing something akin to

getEffect(String effectType){
  EffectPreset newEffect = switch(effectType){
    case "a": return new EffectA(location, player,...);
    ...
  }
}
tardy delta
#

return switch?

smoky oak
#

well i know that exists, but i wasnt looking up that syntax for a question here

tardy delta
#

why not having a Map<String, EffectPreset> or Map<String, Supplier<EffectPreset>>