#help-development
1 messages ยท Page 253 of 1
i know
ayo if i do runTaskTimer and the task takes a bit to do it wont cause lag spikes right
well, yes it will
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
it loops thru all players and does stuff wiht it
if there alot of players it might tkae a while
yes
has https stuff and I dont want lag spikes
bruh
whats the problem? the error:
java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
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
Simply run a sync task in the async task that kicks them and only kicks them.
Import the correct class when u cast
how can i fix this?
well its the only one
Obv not
bro ๐ญ
oh my god whats this now
?
Dafuq u trying to do
nofink
what?
Idk if its just me, but im amazed how much people didn't hear about chatgpt, like its every third tiktok on my fy ๐
https://chat.openai.com/chat he is talking about this
i'm asking here because i don't want the opinion of a damn machine thats making me mad
looks like your X cord is larger than double/float max value
your x is either infinite, or NaN
Also chatgpt gives pretty cool answer
if it's higher than max_value, it just becomes negative again
isn't it true? idk I havent checked, but it's true for integers and stuff
double overflow doesnt exist right
oh might be
all I know is that Integer.MAX_VALUE + 1 is the same as Integer.MIN_VALUE
hm weird, I just did Double.MAX_VALUE + 1 and it returns this: 1.7976931348623157E308
not sure, but i facepalmed for me ๐
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
numbers are weird
also when a double is called double, why is the other thing called float and not single lol
cuz single people might get hurt
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.
had test about that yesterday
yeah so one is single precision, the other double. both are floating points
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
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
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
// 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?
ofc you wouldn't pass in the file name into loadClass but an actual class name
ChatGPT says:
To make this code load JAR files instead of class files, we can modify the code as follows:
-
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.
-
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.
-
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.
-
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
// ...
}
}
}
}
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.
/lp group <group> adduser <player> This is not a luck perms command.
there is a video?
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:
- First, open a command prompt or terminal and connect to your Minecraft server.
- 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 - 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 - 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.
Thx
Dude, this is so unbelievably wrong. It's like it's trying to pull info from group manager and pex and thinks luckperms is the same.
The proper syntax is /lp group <group> parent add <player>
I'm building a server
I see, i blame chatgpt.
@rocky oxide ask in #help-server instead btw.
ok
I blame you for copy and pasting answers from chatgpt like they are fact.
I'll ask later
Well, Too lazy to look it up.
bye
This is the reason SO banned ChatGPT answers
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.
thx
funny
Shut down bungeecord then delete the plugin and start it again.
nono
if some value in config is messed up, i want it to disable itself
throw exception? ๐
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.
Oh i wrote funny about how wrong chatgpt was.
Isnt chatgpt limited hence why it may provide incorrect answers
But you didn't know it was wrong until I pointed it out. ๐คฆโโ๏ธ
I don't care much though haha.
๐ alright
It has a limited dataset, but it's unclear how much data was put in. The only info was a cutoff date, which I believe was the end of 2021.
Myeah
Yea, that's fine, but stop giving people "answers" that aren't even correct. It's counterintuitive.
You're quite mad at that aren't you? I mean I could simply have told him to RTFM whilst I gave him some direction to go in, though it wasn't correct it does indeed give some information that can be tried and then see "oh it didn't work" let me try and figure out why it doesn't work.
I'll just make LGMTFY links next time I suppose.
I am mad that you put that as the first response. If you don't know LP, that's fine, but I completely disagree with your last statement. If someone is trying to get something to work and you give them an answer that doesn't work, what makes you think they will figure it out?
I mean as long as you fact check chat gpt answers it should be fine?
They are going to come back and ask you why it's not working.
Then they get the RTFM message as usual.
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.
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.
why is everyone using chatgpt lol
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.
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.
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.
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.
how do you know if its wrong lol
If they come back crying of course.
lmao
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.
This guy is not even an eclipse user and shitting on our saviour:
https://puu.sh/JtGAY/74d8418235.png
farhan the goat
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
What does your mvn / gradle file look like?
What's the actual error?
@kind hatch most likely him only using the api and trying to use nms functions
Wait
https://paste.md-5.net/ixedeworaf.cs
Here is my build.gradle
Ah, I thought he already had it compiled.
Not using only api
Already tried that but cannot find CraftPlayer on the 1.19.2 doc and therefore cannot import it
Also, it might be worth using the remapped jar.
Not sure how to do it in gradle though.
? Which doc are you looking at
Just let ur IDE import it
then you are not using "spigot" as dependency
Which IDE are you using?
VScode (don't kill me lol, i don't like the java editors)
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 ?
yes, and yes
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
It's fine, but yes there are other ways.
it's a or b or so
Do you have thr correct extensions
Non mapped: ((CraftPlayer) player).getHandle().b.sendPacket(packet);
Remapped: ((CraftPlayer) player).getHandle().connection.send(packet);
This part is fixed thanks ๐
PlayerConnection connection = ((CraftPlayer) player).getHandle().b;
huh? in 1.19.2, sendPacket is called something else
code in remapped-mojang:
That's how it's done in 1.19. I'll have to download 1.19.2 and 1.19.3 to see what the differences are.
and the actual code after remapping, as the server actually uses it:
so .a is sendPacket ?
I'm confused. It calls send() not sendPacket()
He is saying how it looks when using the remapped shit.
yes
yeah, the method in mojang mappings is called "send"
Thanks, here is the updated version, is it correct ? https://paste.md-5.net/oxoquqalon.java
?tryitandsee
That's what I was using in my original message though.
it's called ServerGamePacketListenerImpl#send(Packet) in mojang mappings
xD, that's the issue, can't try for now i have others errors to fix before ๐
in spigot the class is called "PlayerConnection", but there is no spigot mapping for methods anymore
Come back when you have fixed those then.
so in spigot it'd be PlayerConnection#a
Yea, look closely at my original message again. The nonmapped uses #sendPacket() while the remapped one uses #send().
Yeah i'll do that, thanks so much guys ^^ ๐
Why are you using it on NetworkManager then?
public void m_eteisxqn(C_zyjtrjrl arg0) lol
the nonmapped uses a
that's using "spigot 1.19.2" as dependency, non remapped
What version of NMS? Because for my versions of 1.17 and 1.16, it uses sendPacket()
true, in 1.17 it's still sendPacket:
So it's recent
but in 1.18 and 1.19 it's definitely "a" in spigot or "send" in mojang
Makes sense
Ah, I was unware that it changed since I use the remappings for everything past 1.17
yeah me too. one I found out that ALL spigot mappings were gone in some version, I switched to mojang mappings lol
?paste
I always just use nms.scremingsandals.org to check the mappings, they have all versions since 1.14
why does this not track? the location isnt null and it always changes https://paste.md-5.net/ebejoxuxub.java
(basically what this is is a lodestone compass that tracks the location of the dragon egg)
the location for the egg is EggTrackerFunction.currentEggLocation
Where do you update the item when it moves?
What's that look like?
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.
This will create a new one each time. https://puu.sh/JtGGe/aea46c68a9.png // Fairly certain
Like the use of static and the capital variable name.
ye, whenever i give myself that item it only updates it one time
Re-read what I sent.
how can I use the spigotmc resource api to check if the plugin is Outdated or not
cough EggTracker vs eggTracker cough
@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.
The recipe shouldn't have anything to do with it. I believe they are only calling that method once, but even if they were calling it multiple times, it would only add a duplicate recipe. The issue is the wrong assignment of variables.
He's updating a local variable in the scheduler, not the global variable.
That's not the issue. The global variable is set to the local variable later, therefore making the global variable the localvariable.
ye
and how would i fix that issue?
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.
no, i didnt craft it, i gave the itemstack via a command
What is your command doing?
How? Your global variable is EggTracker not eggTracker
How did that compile?
how to check if plugin is outdated?
and this class is called EggTracker
The other thing I'm wondering is if that scheduler is actually able to do anything.
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/
You need to update the player's inventory, or the item directly for it to change.
it works
thanks
i tested it
Basically you just replace %s with your plugin id: https://api.spigotmc.org/simple/0.2/index.php?action=getResource&id=%s
Then you get some json and parse it
thats the link I was looking for thx
Yeah its hard to find on the spigot website lol
like maby that should be somewhere more easy to find
alr
also.. is there a way to Tread.sleep() in a schedueler?
what are you trying to do?
Why
nvm i found out
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);
}
}
CLOSE? also, there has to be more code.
mmmm wdym ?
looks like a feature, I'd just keep it like that lol
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)
a player has to be active on both the sending and receiving server for PMC API to work
(iirc)
What does that mean?
that one the source and destination server someone has to be online
Well yeah, i'm online.
the send bit happens in PlayerJoinEvent (delayed to next tick)
are there two players?
Why would there need to be two players? I'm trying to make a plugin (server) and a mod (client) communicate with each other
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
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");
});
guys can someone create a clan plugin?
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
Yes probably a lot of people
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
ok ty
Archimedes should be my dependency
well is Archimedes installed on the server as well?
no
Im trying to make the main plugin run without having it installed
the main plugin is shaded btw
if its not installed
ur dependency has to be shaded
right now it cant find the class
wdym ur using Archimedes as dependency aren't you?
but Archimedes is not on the server anywhere
yes
and don't want to have Archimedes.jar in plugins folder
bcs it gets messy with that many plugins
is Archimedes a seperate plugin?
yep
or is it a library
well It started as plugin
then I stripped away extends JavaPlugin
are u sure it will still function without it being a plugin?
yep
it just does some math stuff
rn I realized it doesn't even need to have spigot-api
well anyway u need to shade Archimedes into the plugin ur using it in
well Im doing it just by using scope of provided and using shaded jar? am I?
yea
ooooh
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
thx it works now

// 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
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
what about actually using a datetimeformatter huh
or that
ima try that rq
Doing things the hard wayโข๏ธ
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.
can i have 2 hours without being slapped with chatgpt
Probably not right haha, just let me know if it's not and i'll tell it
no
Instead of using an AI you can do things the right way lol
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
too much work
this way i can give stupid answers to stupid questions
sometimes good questions with good answers
without thinking much
ChatGPT got banned off stack overflow for a reason
meh
that didnt take long
no
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) ~[?:?]
told u it was that part
just delete the unit thingy and replace the unit in switch with pair
I seriously cannot process any of this rn, I just wanna get this bit done so I can go to sleep in peace
Stop using that code and just use a formatter unless you hate yourself
well guess what? I hate myself
That is apparent
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
how do other punishment plugins handle this?
How can I create a dummy plugin that only registers a command
create a plugin that only registers a command
getProxy().getPluginManager().registerCommand(this, )
What do I use as a second argument
sinec when was doing that a thing
I cannot pass an actual command class, because I don't want to replace the functionality
the class that extends command
wdym dont want to replace functionality
u need a class extending commandhandler to make a command iirc
command executor
do you just want to register /sb as a real command
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.
yes
.
i would guess tab just listen to async chat event so you just need to register the command with a class and thats it
TAB doesn't register that command, because that command is changeable in the config
yeah, they are most likely listening to an event
so you just register the command you want with it doing nothing
getProxy().getPluginManager().registerCommand(this, new SbCommand())
And then, I make an emtpy SbCommand class?
extending/implementing the correct stuff but probably
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
how to send action bar to player
ew
...
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
yeah, but the code I have doesn't get outputed in the maven output
?conventions
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
press control twice then type mvn clean package
Your code needs to be in /src/main/java/
Unless you make your own build tool ๐ง ๐
I need to put them in a package called main/java ? mk
are they different in IntelliJ?
In vscode everything looks like a directory so there's no getting them confused
I mean they are just conceptually different things, iirc intellij has a different button for directories making
That's because you've told Intellij that src is a java folder
Prob just go into your file explorer
Dumb that you can't just make dirs tho thats strange design
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
and all my code in the java directory
its in src not src/main/java from that screenshot
Is there a javadoc for import net.minecraft. etc imports ?
No
Nice ๐
its mojang what did you expect
What did you expect? It's decompiled code from Mojang
I moved it now
xd Yeah ๐
Understood lul
Thanks
The only docs is trying to figure it out
You can decompile the jar and snoop around
oh right Olivio do u know what this is supposed to mean
That's a flag for buildtools. It applies the mojang mappings to NMS. Basically deobfuscating it.
What's your full command look like?
uuuh java -jar buildtools.jar --generate-source --generate-docs --rev latest --remapped
i think it sthat
Have you downloaded the most recent version of BuildTools?
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
Is that Powershell :kekw:
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
for some reason i feel like i shouldnt do that
for some reason i think you should
judging that the buildtools page tells you to download git
which i did
so use git bash
theres a difference between git as a program and the git bash
just use gitbash
so it complained about remapped again even with the new buildtools but im about 99% sure thats not cuz im using powershell
im using windows 10 which means my printer still works
i dont trust win 11
why?
see here
Try specifying a version instead of latest.
what's the most correct way to give a player an ItemStack?
The command you used works fine in git bash
player.getInventory#addItem
well
it will return the itemstacks not able to be added.
?jd-s
Use it :p
ah ok
ty
same error in black console
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
I have that message too
Didn't even check since I thought your build failed
Either way it does remap
iirc they said something about 'all api is now here' but does that affect remapped?
aaalright then
um so apparantly op doesnt have the * permissoin
Yes, * is a wildcard operator. So it's not included by default.
- is not a permission that Bukkit understands
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); });
Bukkit.broadcast ?
Wildcard is usually interpreted by permission plugins
Elgar's right in saying that Bukkit has zero concept of it
If you are sending to op players than isOp is all you need
Just check if they are opped then?
thats what i tried before and it didnt msg me cuz im not using a perm plugin on my test server
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
?paste mate
Are you opped on your test server?
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/CraftServer.java#1587-1609 i mean, its basically doing same thing
dont see why it wouldnt work
Im needing some command frameworks recommendations for spigot!
What
Is there a way to use a float value in the "meta.setDamage()" function?
cloud, command framework by aikar for instance
is double not preciese enough
wait
(float) integer?
not working
Well then
iirc aint damage a int between 0 and MAX_DURABILITY? then u shouldnt be able to give it anything but an int
so is there any alternative?
I have no idea what this is
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
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.
findcog Find which cog a command comes from.
names Show previous names and nicknames of a member.
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
you are doing minecraft plugin without knowing java?
can you merge 2 futures into one?
https://programmingbydoing.com/a/dice-doubles.html
i need help on this
it goes on loop
something similar to CompletableFuture.allOf
no i know but i have no idea what you threw
i need to do a program that does multiple times a dice and when they are the same number it stops
why would you do that
you can't have decimal item damage in minecraft
cache the last throw and check if the result equals the newest one
or do you have 2 dices rolling at once?
if you roll both at once just check if they are equal
but i have to
?????
if you say i have to it won't make the game magically accept decimal damage
You have an equal (non-decimal) amount all the time during any thing in spigot.
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
Screenshots?
but there are a few plugins i think can do
No
So yo uhave 20 hp.
Which means 10 x 2. Each 1 is half a heart.
health is decimal
no i'm talking about the durability of the item
hearts just display a rounded amount of your actual health
oh yeah no
@leaden flint why do you both have craftbukkit and spigot
remove one of them.
what's the future method to block the thread until the value is returned?
Why would want to block the thread ever?
I only had spigot and had the same error. Should I remove spigot instead?
shutting down stuff
so i'm sure that they get properly shutdown
Well there's .shutdown for shutting down things if you're using regular runnables
Assuming you're using a service
Just tried removing spigot instead now and only having craftbukkit though error still seems to be there
tf
do not depend on craftbukkit
unfortunately I had the same issue with only spigot ๐ฆ
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
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
?cba
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.
show a screen of your current project setup
Such an awful spammy command.
It's great.
it's also broken english, no clue who wrote it
My bad if this isn't what you wanted. My first time trying this out ๐ https://i.imgur.com/VmYwbiu.png
what about 1000 enter inputs
@worldly ingot could you delete the ?cba command, it's rude and spammy.
you still have the wrong jar imported
?cba
What's wrong with
man discord lags a lot if u try to insert 1000 lines
?cba
Okay, there are questions trying to be answered. Let's not
It's not funny and annoying as hell
but what if we just cba them
also i cant even hit enter, seems like they do have some basic spam detection
That's fine and if you like it so much, don't give us reason to revoke your access to it
if you cba you just don;t answer.
Oh, is it not the one under Bootstrap Jar on the link?
No clue what's wrong with ur eclipse, i'll let the experts help u. Might i suggest maven or gradle?
That link I gave you tells you exactly what jar to use
best fix for eclipse: switch to intellij
Eclipse is nectar from the gods
includes default dark mode btw, no need to search through 1000 menus
Go protect it here https://www.spigotmc.org/threads/how-can-i-make-spigot-plugin.581537/
man screw eclipse and vscode and bluej and...
why do 9 out of 10 IDEs have a default white background man
yeah fr
also hows that relevant here
Why does it not work with what he has? Just curious, i usually use maven or gradle, but i'd assume those jars include the bukkit api
he's using the wrong jar
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
if you still have the error you don;t have the correct jar
I have seen all of them but they are full of things, they are not lighweight, in referene they have many htings i wont use
any gradle professionals?
?ask
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!
lol k xD
If you have a question, please just ask it. Don't look for staff or topic experts
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?
thats the correct jar
ok*
I can't seem to exclude packages/classes.
doesn't seem like refreshing or clean changed anything for me
I need some command apis recommendation for spigot, specially that simpliers and lighweight ones
shadowJar {
exclude 'net.kyori'
exclude 'com.google.gson'
}
the default one
Hmn is not really well designed, doesnt support well structured arguments, permissions parenting, etc
\๐
smallest tho
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
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
Well my clients care tho and they are not spanish, mostly english clients all of them care about sizes
why
thats what she said
youre not alex
They argue that such a stupid plugin like a hubcore cannot be more than 100kb size
?
why not
so then shut them up
1MB is big for a plugin, but not complainable
anyone else scared about ChatGPT?
im more scared about copilot sending me stackoverflow links
lmao
AI is love
no not really
huh
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
Not me using Github copilot + Chat GPT to almost code for me ๐ saving so much time
usually it is better to give us code we can look at freely and not bits and pieces you believe are only necessary
anyways based on the limited information provided, what is even the rotation values you are pulling?
https://paste.md-5.net/muyovabibi.java - Bullet
https://paste.md-5.net/muboxudide.java - Gun
Those values being deltaMovement. They are shot right after each other, without even moving or looking around.
dont mind that Copyright thingy ๐
I just was once bored and thought to set up one of those bad boiz
Is it possible to add nbt to item with item meta?
How can i check if a player is rightclicking him from behind?
PlayerInteractAtEntityEvent
and just check location
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
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?
It will only execute if server, that player is on, contains "auth" in name and player doesn't have mcbc.bungee permission
i decided to test it and it works as i wanted to
it will run if in server auth or doesnt have mcbc.bungee permission
that will execute if the player has auth in name OR they don't have the permission
you mean server right?
Isn't divergence how much the snowball diverges from where it goes?
yes @solid cargo
I was putting in divergence of 50 ( didn't know what it did )
but now I set it to 1 and its petty accurate
yep it is ๐
I didn't realize that
Velocity affects distance
Let barrel length affect divergence
So guns with longer barrels shpuld have less divergence
I had no clue of what divergence means, so I tried some random value. And then figured out, its "randomnes"
great idea
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
call it on a player object
i have a return true; at the end
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
call it on object, not class
also you can smart cast
also this is not how you call your declared variable
Myes that's the worst code I've seen in a bit in here
Please learn Java
i will
Also "var" ๐ญ
also error 404 is usually referred as http error and stands for "Not found", i think it doesn't belong there
oh alright
๐งข
ima put learn java on my todo list
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?
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
if a command is case sensitive it's a poor design
404 biome not found lmao
that returns an event not an entity.
you have to check the event for that stuff
if im getting the entity, then the damage cause, why would it return the event?
more like general http error
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
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 ๐ค
What version are you on?
Also by undefined do you mean it can't find the constructor
1.19.2
And yes, i think EntityPlayer does not accept undefined as param
Undefined as param??
new PlayerInteractManager(nmsWorld) seems to be undefined as the error says, and this one is used as a param for new EntityPlayer
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
Citizens is paid right ?
you can get anything for free :)
It's a freemium plugin
๐
xD i know
And get malware as a bonus!
Just need to remember my spigot logins
I love gifts
Obviously http://ci.citizensnpcs.co/job/Citizens2 is down... ๐
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
technically its called before
event.setCancelled(true); on the event, and re execute what you want
i cant get the block as an itemstack or anything though?
I guess you need to get the block then convert it to an itemstack with it's data
not sure how id do that but ItemStack stack = (ItemStack) e.getBlock(); says cant be casted
why do you want an ItemStack of a Block?
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
that has nothing to do with a Block
lmao just wanted to sent
How do I make Component.text() accept ยง (color codes)?
you can use fromLegacyText or smth
you can do Component.text("&c&lTEST".replace("&", "ยง"))
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
try to for each every player online and just send them "private" message
for (Player p : onlinePlayers) { p.sendMessage("x")..}
its just for debugging
quicker to broadcast
my goal isnt to send everyone a message, the broadcasting is just to debug why the if statement isnt working
what does method t() do
ahh
translates its public String t(String m) { return ChatColor.translateAlternateColorCodes('&', m); }
"&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"
btw this method can throw nullpointerexception
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
Is there a way to make ChatColor accept hex codes or do something similar
oh wait the discussion is already about this
ChatColor red = ChatColor.of("#FF0000");
ah, with the '#'. Okay thanks
wot
maybe semicolon
no
how are you checking if it returns something
system out
please post relevant code, it makes it easier for us and for you too
Other question: How do I apply paper patches to spigot server jar build using build tools?
:/
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
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 ?
I think it's on the minecraft fandom wiki
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.
unique id as in?
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
?pdc
Use the PDC then.
ahh i appreciate it lol
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?
how do import the thing that represents all entities
String obj = "Diamond" //Example
System.out.println(Material.matchMaterial(obj));
System.out.println(Material.getMaterial(obj));
is it just org.bukkit.entity
When using hikariCP, I try to set the database name using
properties.setProperty("dataSource.databaseName", dbConfig.getDatabase());```
But I get this error
Any ideas?
Material.of or Material.valueOf iirc
Connecting with MariaDB
Fixed, I needed to capitalize ALL the letters it turns out
Not for match material
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
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
ggs
I know nothing about saving data to a file, which method is considered the best? Theres so many json, gson, yaml, mysql ect
gson is googles json api, but it pretty much just depends on the use case
hi, does anyone know how to combine two variables like Player.playersneakcount
it would really help
im confused, do you want to get the player sneak statistic
so i made a variable called playersneakcount
but how can i make it a part of player
only spesific to that player i mean
you cant without reflection iirc
save it to their pdc if you only need it for a specific player
?pdc
thanks
@remote swallow the use is storing hashtables, any suggestions?
How dangerous is it to call Bukkit#getOfflinePlayer#getName from an async block?
is there any danger at all?
depends, how big would it get and how often would you be accessing it
there shouldnt be any danger
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.
are you just storing the items? you can probably use pdc if you just need to check if its yours
?pdc
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)
i would probably suggest json for that then
ok and by that you mean actually json not the gson thing people talk about? o wait i re-read what you said, thanks
.
why is my roleMapping null?
roleMapping = new ConcurrentHashMap<>(roleMapTemp);
java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
Is it possibile to get a player starting from a GameProfile?
Do you want to find an online player?
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
Is the player online
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?
If you're using a fake player you probably can't use the CorpseRebornAPI
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);
}
}
Let me explain my problem maybe it would be better
?paste the full stacktrace
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
ive got no clue how you have managed that from an inventory close event
The API doesn't support that
Spawn your own corpses
The best part in all of these that the spawnCorpse() method actually supports the offplayer spawning, but the parameter of the method is an online player
at this point I'll try to use reflections
I can't cause it must be a corpse of CorpseReborn itself
I think I've fixed it by creating a Set and add the player into the Set when they open the inventory and remove it on close. I don't know why but it worked.
If it supports an offline player you can try getting the uuid from the player profile
this might be possible with packetevents
one moment
They don't want to spawn their own
They've clearly said they only want to use that api
ok
It supports Offine Players only the plugin itself
?
cause the plugin from the offline player takes only the skin and that's it
a sec
Do you need other data?
Like inventory and such or?
nono
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
Also there is a method in CorpseData (the corpse object), that gives you the propertyjson of the gameprofile of the corpse
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?
DatTimeFormatter is really confusing. The way I did was https://github.com/ElgarL/GroupManager/blob/a6245f5ce36e136f564117e77851e45d4e3ea8f2/src/org/anjocaido/groupmanager/utils/Tasks.java#L160
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
what about mo
heeheehee
simple to add
but will it work cuz its 2 chars
this?
is there a way to get natural drops when player breaks block?
for example: player has fortune prickaxe and breaks some ore
wouldnt the first m always supercede the mo group?
Do you want to break a block for the player or detect the drops when a player has broken a block
I just tried ([0-9]+)([(?:mo)wdhms]) but it always ignores the o
detect drops on break by player
worked for me at least
still ignores mo and see's as m
BlockBreakEvent
declaration: package: org.bukkit.event.block, class: BlockDropItemEvent
doesnt for me
thats weird
where do u test ur regex
actually no, your regex matches nothing
idk where youre testing your regex but regexr tells me its working
idk what ur doing but it works for me
doh, I had an odd character at teh start when copy paste ๐
oddly it's does a two group match on mo though
well at least it matches it twice to mo
fixed ([0-9]+)((?:mo)|[smhdw])
it was matching mo on each character
@misty ingot there's your regex ([0-9]+)((?:mo)|[smhdw])
ye im trying to make it work
@misty ingot cough cough
thanks
too insignificant ๐
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
?paste mate
also if your method can return null you should use Optional
it cant return null
It's returning minutes. Change TimeUnit.MILLISECONDS.toMinutes if you want seconds
what is the mojang mapped packet class for this
oh nvm thats server bound
i think i got it but idk
nvm lol
bruh
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,...);
...
}
}
return switch?
well i know that exists, but i wasnt looking up that syntax for a question here
why not having a Map<String, EffectPreset> or Map<String, Supplier<EffectPreset>>