#help-development
1 messages · Page 641 of 1
So the goal is not that it makes the task run faster but it prevents the entire server from lagging while the task is ongoing then.
tps are not the only important thing
And if you wanted to improve the performance of the actual task you'd use a more optimized method (i.e. the NMS-based alternative)
Yeah thats the idea. This way you can for example reserve 30ms per tick for the actual game and still schedule huge workloads
without the player noticing any tps drops.
I'd argue a good plugin shouldn't drop ticks.
For the players experience it is even critical
I remember older plugins where one player would modify a large area w/ WorldEdit and the server would just pause for a solid 3 seconds
ms per tick are also important
you can have 20 tps and 200 ms per second on your plugin
uh what
My friend consistently broke servers with WorldEdit and to this day I've no clue how.
Destroy time
Im still deciding if he being sarcastic or not
Yeah im using this approach for my machine plugin (pls dont look it up i dont want to update it
)
So no player can hog server resources
Aren't ticks a fixed time unit?
Those are the outliers
Actually no scratch that, game loop
And a plugin like that belongs straight in the garbage.
They're fixed time points (hence "every 5 ticks") but they do not correlate to a specific amount of milliseconds
*Unless this is a 99.9th percentile
And this I believe is because a tick = one cycle of the game loop.
I know XD but still
There's a number of things that can cause fluctuations during a game loop (hence why delta time exists for physics calculations)
it was 20 tps
You can have a single tick >50ms because there are catchup mechanics.
But it still disrupts the game loop.
is not a code error?
Can't believe I just guessed at how ticks worked
A game tick is where Minecraft's game loop runs once.
This is what happens when you try to code your own game engine.
btw every game has a tick loop. This is not exclusive to minecraft.
Yeah been there ^^
The TPS can be maintained at 20 only if the MSPT is no higher than 50.
I was about to point this out until i seen you mentioned it lol
but minecraft has 20 ticks, most games are based on 64, 128 ticks
*There are catchup mechanics that let mc keep 20tps even with one outlier.
and cs2 doesnt have ticks system
They do actually but you will probably find most tutorials refer to it as the game loop or the main loop which is essentially the same thing exception being rendering usually
anyone know what is causing this error:
https://paste.md-5.net/ihiteqokam.cs
https://paste.md-5.net/dobetoyogi.coffeescript
Ah a'ight
Imagine having one outlier within 10 ticks. You can, within a certain frame, pile
some ticks in a shorter period.
Part of me feels like the exact TPS cap doesn't really matter for most games as long as it's not something obnoxiously slow like in the 1-8 range
You are trying to get something from your yml that is not there.
if it is null the code assigns a value to it though so i dont understand what is causing that error
@lost matrix I have tried your workload distributor and it kinda lags, when it has 1 task to do (1 cuboid) it does good. But when I gave it 10 cuboids 50x50 it was lagging
Does the file in question actually exist?
yes it does
Then you didnt implement it properly.
You can do thousands of tasks with millions of blocks.
Ive modified entire 4k x 4k worlds with this.
Loaded every single chunk, got all chests and removed items.
But can it run Doom?

can you run doom
Yeah I think I can imagine some Doom gameplay
It's not perfect but it's usable enough
encode it on ur dna
wdym not properly
literally copied and pasted
Did the plugin create the file or did you create the file manually
the plugin created the file
This returns null
Its not in the config
Well you path for obtaining the file and or creating it is flawed whch is why i am asking about it
earlier it checks if it is null and then assigns a value
how do u paste images in this server
Your config stays the same. You never updated it.
FileConfiguration != File
Former is in memory (already loaded), latter is on disk
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
thanks i think thats the problem
I'll verify your face with my fists.

we can't even see that its smaller than ur pp
Heh. If I'm small then you're measured in negative numbers, my friend :)
I mean it's odd the problem started when I added more cuboids
Ticks is a bit arbitrary really. These days the main game loops are set to run as fast as possible. The only loops which typically are not are usually your rendering loops as you want those in sync with the refresh rate the hardware can handle. But tick loops is a bit arbitrary as well in that its really whatever you consider 1 loop to be. Typically ticks refer to the in game time speed however in game time speed are decoupled and dont usually dictate how fast everything else can be processed lol
Then you created one WorkloadRunnable per cuboid
so 10 workloadrunnables every 1 ticks?
I mean then those workloadrunnables will overlap each other
Depending on what you are doing probably could offload some of the work to another thread
Something to maybe consider is a hierarchical system.
cant place works async
Cant place no, but you certainly can read and do other things
i.e. a root workload scheduler that is able to split time between multiple schedulers (one per each big task)
You do a little of one task, then a little of the next, and so on.
That way, they all perform at "the same time" and aren't dependent on one finishing before the other.
what do you guys think of my custom config class is there any optimisation i could do? https://paste.md-5.net/posicujaji.java
You could always just keep track of runnables that are scheduled and if whether or not they have been ran
And adjust accordingly on scheduling or executing the next task
"it's only reading" doesn't mean thread safe
I'm sure you know about that funny hash map infinite loop
In most instances you cant remove and place at the same time. However reading is different in that it doesnt modify the data or change the ordering. There is of course always the exceptions
And for hashmap there is concurrenthashmap
Which is a thread safe hashmap if you need it
Actually lemme explain better.
Consider you have multiple tasks occurring at once
These tasks are split up into smaller parts
Task 1 and task 2 should appear as if they're operating concurrently, so we can't just do all of task 1 and then do all of task 2, we need to do part of task 1 and then part of task 2
However it would be slow to always run each task every cycle, we want to do task 1 for a few ticks, task 2 the next few ticks, repeat
So you need a scheduler that decides which task gets run, and those tasks decide which micro-task gets run (which is probably just going to be the next one)
In other words
task = process
micro-task = instruction
lol
I'm sure you got the gist I just wasn't happy with my original explanation
And what are you trying to accomplish in doing this in regards to the cuboids?
It means we can process all cuboids concurrently while keeping TPS at 20, like with the original workload distributor
Well no
Its linear processing
So it will never be truly concurrent. Which is why i asked what are you trying to accomplish with the cuboids that you need such a system
Because what you are trying to setup may very well just make completing tasks slower
Operating systems handle processes on singular cores in a ""concurrent"" fashion. Since there's no way to execute multiple processes at the same time, they provide each process with a small period of time (a time slice) to execute instructions and swap between each process to give the impression of concurrent processing.
Round robin scheduling, it's basically what I've planned out above.
You can execute multiple processes at the same time. Not sure where you got that you cant
Unless you are referring to processes as in work needing to be done?
Only one WorkloadRunnable ever. The server starts, you create one.
Then you can schedule workloads with this one runnable.
Wont lag if each workload is snall enough.
On a multi-core system, true concurrency can be achieved as multiple instructions can be executed simultaneously by different cores (which further utilize round robin scheduling so that multiple cores can handle multiple processes).
But when working with a single core, you cannot have multiple instructions from different processes executing simultaneously.
How the OS executes stuff is completely different then how applications execute stuff. Even if you have a single core you can still execute processes concurrently because threading still exists for single cores
I'm speaking from a very primitive perspective on multitasking.
Until the early 2000s, most desktop computers had only one single-core CPU, with no support for hardware threads
each one is around 50x50x50
We don't have support for hardware threads in a Minecraft context either, whatever those would even be in that context.
Java supports it so yes you do
I'm using the term as an analogy
We're executing a set of tasks like how an OS executes a set of processes
Some stuff is multi threaded in mc as well as you can create threads
Minecraft is single-threaded and apparently not thread-safe so we can argue we're limited to one core, no threads.
Except you cant apply this concept to applications
Yes you can lol
Minecraft is multithreaded. Just not everything is
An OS is an application, all a round robin scheduler is is an algorithm for multitasking tasks.
So no you are not limited to a single core
Java threads for example when they are created can in fact execute on other cores if the os dictates it should
I know an os is technically an application if you want to be technical but you really cant compare it like one due to where it sits in the layers and what it does
That's an implementation detail.
Not sure what you mean that is an implementation detail.
However the OS chooses to execute Java's code is not Java's responsibility.
But it is because java can decide to over rule the os and put all threads on a very specific core
The parts where it is single-threaded are still of importance.
Isn't most chunk/entity logic single-threaded?
In mc? Depends which ones you are referring to
Actually chunk logic might no longer be single-threaded.
I don't know, haven't looked deeply into it.
World generation for example is multi threaded.
Anyways
Regardless we're making the assumption that we can't use multithreading for everything because not everything is safe to use multithreading with.
But i am not sure how this all relates to what you are doing
Well here's the thing, if you have multiple players spawn new tasks, why should one player wait for another player's task to finish?
He is lterally just philosophing about scheduling in operating systems...
;D
I'm going to rephrase that. It's not the Java language's responsibility. I assume this is a JVM argument?
I don't recall seeing an API for saying "I want this thread in particular to be on this core"
Because it isnt available in the api
So to the eyes of a Java programmer, Thread could refer to either an OS or hardware thread.
It will never refer to a hardware thread
No application has the ability to mess with hardware threads except the OS itself
Correction: It could refer to code that runs on either an OS or hardware thread.
Not even correct either. Everything runs on a hardware thread. Threads spawned by an application are virtual threads which run on a hardware thread
I still think this is important though
Imagine the first task takes 5 seconds to complete
Well it depends on what those tasks are for
That's 5 seconds before the other player even sees their task (the second task) begin to start.
Which is why i asked because i dont know
And what if you're the unlucky 5th player? That's an entire 20 seconds.
I'm not sure either.
I mean I'd still need to see an implementation of this to be sure it actually has a benefit.
so what is the best method to place many blocks then?
I think an issue would arise from complexity since more tasks = more time for each to complete.
There's less of an issue if you can take advantage of multithreading but I dunno.
You would slice up the modification to smaller modifications. Pausing the task if it goes beyond a time limit for a task and then continuing after a short break
I'm curious as to if cooperative multitasking would maybe work (i.e. fibers/coroutines)
Only issue is that that doesn't natively exist in Java (yet) and would therefore be a pain to implement lol
Ah well if you wanted:
- Kotlin has a coroutines system although I'm not sure how compatible this is with Minecraft/Bukkit.
- Foreign languages, primarily Rust, can provide coroutines but you'd need to distribute platform-specific native binaries, and you would need some bridge API between the language and Minecraft/Bukkit.
I mean project loom will address coroutines relatively well
Yeah but it's probably going to take a bit before it's actually available
re: Valhalla
Should i save ZonedDateTime as String or convert to TimeStamp in database?
Coroutines work just fine
Whatever you want
I would probably convert to smth easy to save. So it’s all up to you.
ok
Id would probably save timestamp + zone id
k 'll try
Coroutines for kotlin only work if you use kotlin jvm
Why my intellig idea keeps freezing and telling me it needs more memory. Every time after I increase it. Now its already 6 GB. Isn't it enough?
invalidate caches or reinstall intellij
you might also want to use intellij idea EAP
What
There is no kotlin jvm
You run it on any jvm
It's compiled to normal bytecode
https://gyazo.com/1ddf5a15c3291d2031648a458ffaa310
How do i let a hologram scroll colors like this?
its just changing the text each time
Oowh so i have to do it manually then
eeem what the duck?
I also think it is a runnable but wont removing and adding the armorstand create lagg?
just change it's customdisplayname?
your plugin is corrupt, recompile it
weirdly enough
it was just because of me renaming the file? :D
I didnt have to recompile it, just not rename it
strange
DIdnt java 21 add virtual threads
I have a very weird issue that I've never come across before:
I have a static block in an enum:
static {
System.out.println("HERE");
// create matName set
for (StackableMachines stackableMachine : values()) {
matMap.put(stackableMachine.material, stackableMachine);
matNameSet.add(stackableMachine.material.name().toUpperCase(Locale.ROOT));
}
System.out.println("HERE");
// create modMachines map
for (StackableMods mod : StackableMods.values()) {
final List<StackableMachines> modMachinesList = new LinkedList<>();
for (StackableMachines machine : values()) {
if (machine.getMaterial().name().startsWith(mod.getModPrefix())) modMachinesList.add(machine);
}
modMachines.put(mod, modMachinesList.toArray(new StackableMachines[0]));
}
}
And when I call a function on the enum for the first time I get a java.lang.ExceptionInInitializerError: null; But it doesn't even come to the sout; And why is the InInitializerError null.
Any help would be greatly appreciated :D
Nvm, figured it out
smort
what is "a function"
which function?
and why not use the constructor instead of a static block
Because the constructor would be called for every enum entry
they're iterating through every value anyway
I would still go for lazy initializatzion instead.
Static blocks tend to break the classloader
What do you mean with lazy initializatzion?
by lazy !!
Let me give you an example real quick
Thx :D
@Getter
@AllArgsConstructor
public enum VehicleType {
CAR(false),
BICYCLE(false),
PLANE(true),
HELICOPTER(true);
private final boolean flying;
private static EnumSet<VehicleType> flyingVehicles;
public static EnumSet<VehicleType> getFlyingTypes() {
if(this.flyingVehicles == null) {
initializeFlyingVehicles();
}
return EnumSet.copyOf(this.flyingVehicles);
}
private static void initializeFlyingVehicles() {
this.flyingVehicles = EnumSet.noneOf(VehicleType.class);
for(VehicleType type : values()) {
if(type.isFlying()) {
this.flyingVehicles.add(type);
}
}
}
}
Ooh, you init whenever you need it, but only once then
Yes. This a common trick to increase startup times of applications. Especially in the web space.
Only initialize data the first time its needed.
Fair, but I find that annoying when you have multiple functions and in all of them you'd have to check if the data was init first.
Let me write a simple abstraction for that really quick
You can simply write a class Lazy<T> which encapsulate this mechanic of containing an uninitialized element
and calling a supplier for the first time it is needed.
public class Lazy<T> implements Supplier<T> {
private T element = null;
private final Supplier<T> initializer;
public Lazy(Supplier<T> initializer) {
this.initializer = initializer;
}
@Override
public T get() {
return element == null ? (element = initializer.get()) : element;
}
}
This results in great reusability
@Getter
@AllArgsConstructor
public enum VehicleType {
CAR(false),
BICYCLE(false),
PLANE(true),
HELICOPTER(true);
private final boolean flying;
private static final Lazy<EnumSet<VehicleType>> flyingVehicles = new Lazy<>(VehicleType::fetchFlyingVehicles);
private static EnumSet<VehicleType> fetchFlyingVehicles() {
EnumSet<VehicleType> fetched = EnumSet.noneOf(VehicleType.class);
for(VehicleType type : values()) {
if(type.isFlying()) {
fetched.add(type);
}
}
return flyingVehicles;
}
public EnumSet<VehicleType> getFlyingVehicles() {
return flyingVehicles.get();
}
}
Its a bit complicated to understand if you dont have functional programming internalized...
Hello, I have a question, for a give command for example, where arguments such as targetpalyer and amount are optional, am I obliged to rewrite the code a little each time?
when there are no args, when there are 1, 2 etc...
is this a good thing? or a bad thing?
I'm rather confused how you are calling the #add function here: flyingVehicles.add(type); When the type of flyingVehicles is a Lazy<T>
I should have renamed that. It refers to the local variable
ahhh, that makes more sense
If parameters are optional then you might want to provide defaults.
This way you can re-use your code.
Ahhh, I think I finally understood
yup; Well, yeah, ig. It's good to know and thanks for showing me how this might be used. But I'll worry about smth like that when performance becomes an issue.
Stability? You mentioned something about it being more reliable with classloader, but how so?
so do something like this (the x and y are examples to show that the code is repeated.
on command
if (args is null) {
x
y
}
if(args.size == 1) {
x
y
}
if(args.size == 2) {
x
y
z
b
}
doing this is not emebetant? (I mean in programming it's not something to be avoided?)
Thank you master
args will never be null, as long as you are using the onCommand function provided by smth like the TabExecutor
Integer amount = NumberUtils.parse(args[2]);
if(amount == null) {
amount = 1; // If no number provided -> use 1
}
Player target = PlayerUtils.fetchByName(args[1]);
if(target == null) {
target = sender; // If no player provided -> use sender
}
target.getInventory().addItem(new ItemStack(Material.DIAMOND, amount));
You still need array length checks btw
can you not do
switch(args.size) {
case: 1,2,3,4 -> yeet1
case: 6,9,100,19 -> yeet2
}
I would look for an external command library. Spigots is quite crude and ungreatful to work with.
yes, but in the case where target and amount are not obligatory (we give 1 diamond to execute) we are obliged to repeat
Im using that as well.
Main problem is the very steep learning curve.
Why steep?
the class registering itself
Mine is larger :D
Ah i see. The obligatory
new AdminCommand();
line. Not constructor abuse at all ^^
No? Just use fallback values
do you have a small example?
@lost matrix got any suggestions to improve perfomance on this?
There... is nothing happening here. Performance wise there is nothing to gain.
Structurally this looks good. One caveat: Your isEnabled variable should be named enabled
and the getter for it should be isEnabled(). Everything else looks clean.
??? This won’t affect performance
getAllowedMaterials should probably return a Set<Material>
Im assuming that you call contains() on this?
What is the difference between set and arraylist
Why do you have a setIsEnabled method that sets the value of the config section to the boolean?
Your not changing the value in the enum then
set cannot hold the same item
i.e. all items are unique
Quicker lookup via HashSet?
Ye, thats why there is an isEnabled() Function
it returns the value from config
I also want the fallback value
ooh, your isEnable boolean is meant for fallback? Why not make it final then
ahh, now I see that there were 2 bools
Sets do not allow duplicates. This comes with the benefit of having very fast contains() implementations.
HashSet for example scales O(1). This means contains is always fast regardless of size.
ArrayList scales O(n). This means it gets linearly worse.
Example could look like this
| N Elements | List.contains() | Set.contains() |
| 1 | 1ms | 2ms |
| 10 | 10ms | 2ms |
| 100 | 100ms | 2ms |
| 1000 | 1s | 2ms |
| 10000 | 10s | 2ms |
I go over this a bit more in this thread:
https://www.spigotmc.org/threads/guide-beginners-guide-on-improving-your-codes-performance.396161/
psss. ArrrayList has .get
Yes sets are by definition unordered and dont have an index access.
But index access is used very rarely in properly written applications.
You need to keep track of those instances yourself.
Use a manager class which contains a Map<Integer, YourEntity> to
keep track of your virtual entities.
heres the use case of the enum
Ugh this article is quite old. Only had programmed for 6 months when i wrote it and it shows...
getFancyName() 😆
Catching Nullpointers is something i would strongly advise against
My poor console tho
Dont get me wrong, you should handle them. Just not by catching them.
wdym not catching them
try {} catch() {} on NPEs means that you didnt bother handling them
Then how do i bother handling them
You should check with if(element == null) instead
they are generated if there is an error with the json
Is that jsonsimple you are using?
fixed it
duesnt get throw a null pointer thow
is this worth doing over Math.pow(double base, double exponent) that returns a double?
public static int pow(int base, int exponent) { int result = 1; for (int i = 0; i < exponent; i++) { result *= base; } return result; }
well, yes
there has to be method that returns boolean so you can check it
This is faster than the Math.pow implementation.
Math.pow is optimized for floating point operations.
save the master.ger(something) into a variable
no
if master is null then yes
if the string im searching for cannot be found
i remember somewhere of a way to save on iterations, but i forgot where
it was some sort of programming trick for faster time or something
master.get(arg)
if master == null, this will throw an NPE
if it's not, it will either return a string or null
Yeah it has to do with bit shifting and multiply by a modulo of n^p iirc...
Probably not worth it
so in your case
String something = master.get(something); // also make sure that master != null if you didn't already
if (something == null) {
bad;
}
JSONObject g = (JSONObject) something;
fixedd
replace return; with continue;
true
i don't think so
if master.get() returns null, casting null will throw smth
only go over the 1 isntance that has null as the return value, not break the entire loop
you have to cast it after checking if it's null
cast? you mean the (JSONObject)?
Hi, on location.tostring, i can reconvert to location?
if you cast null i'm pretty sure it'll throw an exception
lets try
Not sure if it works like i intend it to
public static int power(int base, int exponent) {
if (exponent == 0) {
return 1;
}
int temp = power(base, exponent / 2);
int result = temp * temp;
if (exponent % 2 == 1) {
result *= base;
}
return result;
}
Hm this saves on iterations for smaller exponents.
Main drawback is that its recursive.
This is for sure faster. Every exponent that would make this slower than a loop
would lead to an overflow anyways.
you have to create your own methods to serialize and deserialize bukkit location
ah, thank you, but i rather keep it non recursive
Do you want to store locations in yml files?
public static String locationToString(Location location) {
StringBuilder builder = new StringBuilder();
return builder.append(location.getWorld().getName())
.append(":")
.append(location.getBlockX())
.append(":")
.append(location.getBlockY())
.append(":")
.append(location.getBlockZ()).toString();
}
public static Location locationFromString(String string) {
String[] splitted = string.split(":");
return new Location(Bukkit.getWorld(splitted[0]),
Double.parseDouble(splitted[1]),
Double.parseDouble(splitted[2]),
Double.parseDouble(splitted[3]));
}
for example this.
no, database
In that case you need to serialize it yourself
@buoyant viper if ur still trying to make a straight line on ur scoreboard without using &m- try &m─
i think they can be ignored but you can try bumping them to latest versions if they aren't already
I cant find the maven-resources-plugin in my pom.xml
Btw, while we are on the topic of coding, efficiency and practices; What is a decent rule of thumb for when to throw exceptions, errors or just return smth like null?
Hey, i have a problem, on my serverstop, i loop an array to stock all my data in db, but but it seems to be taking too long, so he spits.
you usually throw exceptions when you make your own api
and nulls when you have to
That's what I've been doing; Internally using null for private stuff, cause I know too expect it, but then exceptions for public stuff
I mean you can check nulls using standard if statement but java has Optional and its useful sometimes
Optional reduces useless if's
exceptions are annoying anyways
I only use Optionals if I see no other way to show that no value coould be returned
^
Well... I see their use, as in, "hey, smth has gone wrong and YOU have to deal with it"
Nope
It doesnt
python is so ass
its the same for nulls
but then the language will just throw nullptr exception anyways
if we are strictly talking about null pointer checks thats a useless exception to add yourself since it will already be thrown if you fuck it up
unless your code can accept nulls as valid values
then its on the api implementation to deal with it
thats how I see it
wait so is there still an issue?
nope
okay nice xD
public static Location serializeLocation(String locationString) {
String[] parts = locationString.split(",");
if (parts.length != 4) {
return null; // La chaîne n'est pas valide
}
String worldName = parts[0];
double x = Double.parseDouble(parts[1]);
double y = Double.parseDouble(parts[2]);
double z = Double.parseDouble(parts[3]);
return new Location(Bukkit.getWorld(worldName), x, y, z);
}
is good?
yes looks good, except this is deserialization
if you want to put it into the database, you want it to go the other way around
I would throw exception instead of returning null
what exception
probably custom
thats what i do
so its more clear where to look
you could also do optional ofnullable i guess
at that point just return null xD
yeah maybe u right..
you throw exceptions when you really need this method
and I guess he really needs to serialize and deserialize it
well if you dont really need a method then why do you have it
but some methods accept null's
I don't think so he want to accept Location that is null
especially if he deserialize it and serialize it
Idk if this topic is at the right place here, but I´ll ask it anyways...
Goal: PlayerHead before the name in Chat
Problem: ResourcePacks force me to use the pixels at least height 8
- How can I make it so it is the single pixel that is shown in the chat,
- My plan is to use special Character negative spaces and ancent to align the pixels correctly
you probably can't send player head on chat (at least not in one message)
but then you can fetch it from for example namemc
or gameprofile
Coroutines are not native to java therefore there is no bytecode for such things. And i meant to say it only works if you compile it to native.
That is pretty much all you do. You create offset characters. One for each color your want.
Then you get the skin of a player, scale his head to 8x8 pixels and reconstruct it
with your special characters. The chat might be a hefty place for this because you are
using up 64 characters just to represent the head.
Itemstacks would work in the same manner. Just by using 16x16 pixels and
having an invisible pixel. Keep in mind that this will tank quite a bit.
Its better to distribute a resourcepack with item icons which replace characters.
Let me check if i have screenshots from a project i worked on that did this
but imagine you can put itemstacks in chat
that would be awesome
Hm i just found this where i used the icons in the tab list
Ah and in the lore
So its possible just needs a resourcepack
Hi, I'm trying to code a plugin, but when I try to put accents in my messages such as é, à è..., it becomes é... I put my projet in UTF-8, but i still have the problem... Has anyone an idea ?
You need to tell maven to use the utf-8 charset as well
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
I'm using Gradle, and I checked
Yes, but I've this enconding problem, so I don't know where does it come from
Are they weird only in console or also in the client?
wait
I will send you gradle code
They're weird in console & in chat
mate
Btw this file encoding is only applied to your resources. Not the source code.
is the file itself also saved as UTF8? open the file and check the bottom status bar
ty
okay, so how do I put UTF-8 on my source code ?
Yes
Jetbrains IDEs have that info in the bottom right corner
try adding this to your build file
compileJava.options.encoding = "UTF-8"
or this or whatever ```groovy
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
yea
It finally works, thank you
You can compile it to jar like any other java application and coroutines will work
I've another question, I used to use ChatColor, but it's not depreciated in favor of net.kayori w/ Component.text..., isn't there any other easier methods do format text and colors ?
kyori provides Component and with components their own color system
private static final LegacyComponentSerializer SERIALIZER =
LegacyComponentSerializer
.builder()
.hexColors()
.extractUrls()
.hexCharacter('#')
.character('&')
.useUnusualXRepeatedCharacterHexFormat()
.build();
public static TextComponent colored(String text) {
return SERIALIZER.deserialize(text);
}
using colored(String text) it will translate your String 🙂 (you can use hex)
I use Component.text but when I want to compare e.g. itemStack.displayName and Component.text("smth) it doesn't work
but Component.text("hi") doesn't color your message
yes, but when I add .color(NamedTextColor.DARK_BLUE), it looks like this
[12:56:52 INFO]: TextComponentImpl{content="Team §1blue", style=StyleImpl{obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=not_set, color=null, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}
[12:56:52 INFO]: TextComponentImpl{content="Team", style=StyleImpl{obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=not_set, color=null, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[TextComponentImpl{content="blue", style=StyleImpl{obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=not_set, color=NamedTextColor{name="dark_blue", value="#0000aa"}, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}]}
this ^^ put this in your ChatUtil class or however you call it
I'm sorry but I don't understand this code
I'll be able to compare displayName() and my string thx to that ?
this method just allows you to use COLORS in component
default minecraft colors and hex
Sir this is spigot
but he asks for kyori
I'm asking for methods to format text, not kyori
oh
I use kyori, but I'm not satisfied
then use ChatColor.translateAlternateColorCodes('&', "&7your text");
ye
I recommend making utility class for that
the simplest way
but it doesnt work for hex 😦
Why do you need hex?
hexes are cool
I'm not only looking for colors, I'm looking for compare a .displayName() which gives a Component and a string
dude you are using paper
lmao
This is spigot
?whereami
if you use paper you have to use kyori. If you should use default spigot api
But I can tell you you can cast the getItemMeta#displayName() to a TextComponent and then TextComponent#content()
oooor he can use deprecated methods XD
wouldn't that return the raw string with no colors
Yeah, isn´t that what he wants?
i don't know i just joined the convo lol
@lunar wigeon
md5's components are pretty good
thought he'd want colors
you guys should try them
HSB != hex
but I think you can use RGB
or Color.decode
it would be very handy if you'd show us more than one line
do you have a plugin.yml file?
also the "Modern"PluginLoadingStrategy is a paper thing
haha
just paste the full log
your class is called me.mcorsen.main.Main
but in plugin.yml you used com.mcorsen.main.Main
me != com
in plugin.yml change "main" to me.mcorsen.main.Main
It should be in src/main/resources if you use maven/gradle
If you're using maven, it goes in the resources folder.
Otherwise it goes in the main directory.
Then make sure it lives in the project root.
Hey guys, can someone help me with creating the teams and random team select for my minigame similar to skywars?
Looking at PluginDescriptionFile, this is the pattern used to verify plugin names:
private static final Pattern VALID_NAME = Pattern.compile("^[A-Za-z0-9 _.-]+$");
This pattern allows spaces.
Looking at NamespacedKey, this is the checker for namespaces:
private static boolean isValidNamespaceChar(char c) {
return (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '.' || c == '_' || c == '-';
}
This pattern does not allow spaces.
This means this would throw an exception right:
Plugin plugin = ...; // Plugin with name with space
NamespacedKey key = new NamespacedKey(plugin, "my-key");
Pr time
damn bruh just looking for some help, The teams and team select has stumped me, could you or anyone just send me in the right direction?
Plugins explicitly throw an exception if they have a space in their name
Your game should have a team handler which is just a map of that relates what team each player chose
where tho
Try and find out
don't have an environment setup
if (!VALID_NAME.matcher(name).matches()) {
throw new IllegalArgumentException("name '" + name + "' contains invalid characters.");
}
name = name.replace(' ', '_');
i shouldve been more specific, im trying to make players automatically be assigned to teams evenly
wait did I really miss the next line
Yeah so that's just an even distribution
oh I did that's embarassing
Ah seems it was changed to replace spaces with _
pretend I didn't say anything
List of players, list of teams
who calls their method "a" o0
Pre obfuscated
Loop through all players and assign the next team
:p
And loop around
Crazy? I was crazy once
okay perfect ill give it a shot, thank you!
set as passenger
it is directly at your feet
It's just that you are directly in between two blocks
if you want it to follow the player, set as a passenger and apply a translation
i'm working on a discord bot that should be working when my server network is working. it's best to tie it together with a bungee plugin, right? so that the bot would be always online except for when the proxy goes down
then add 0.5, 0, 0.5
ty
your math is bad
show some code
you are using transformations
so you should not be adjusting the location
don;t bother set it as a passenger
yes, then set a translation
so?
yes
yes
adjust translation to where you want it
no, your origin is zero as its a passenger
you translate relative
setTansformation(getTranslation... adjust
the translation is a vector
as a passenger you'll likely only have to adjust the Y component of Translation
-1 or -1..5
yes it will as it's a passenger
you are probably still trying to teleport it
thats what the tranformation is for
a negative Y vector
Matrix math. How does it work, amirite?
throw numbers at it until it works
matrix rotation sucks
Hi, I purchased a resource from Spigot and I'm having an issue where the money is paid but I can't download the resource. Where should I raise an issue?🥲
?support
Thank you and have a great day!👏
is it possible to limit slash commands in jda to only be accessible specific channels when creating them? or should i just check in SlashCommandInteractionEvent?
IChatBaseComponent.ChatSerializer.a("{"text": "" + line + ""}");
can i do for example :
Utils.color(line)
using nms 1.16.5 , for custom entites
want to set the name with colors
Would I be able to create a plugin that allows jukeboxes to be ejected by a button?
sounds doable
I think i know what to do for ejecting a disc, but what would I do to accept a red stone signal input
how do i create a thread in jda? can't find much info on that
ThreadChannel
ig u can just use IThreadContainer#createThreadChannel
but yeah u get a ThreadChannel object
yeah i found it in the docs but i don't know how to construct one
oh i see, lemme look into it onw
soo ?>?
and what would i use as a ThreadContainer? a channel (MessageChannelUnion) does not seem to implement it
actually wait
is just using the color tag not good enough? i.e. ,"color":"#abcdef"
do u know what a MessageChannelUnion is?
i can cast it to GuildChannel, ritght?
not exactly i'm just going with the flow while coding lol, i've only made one bot before
it seems like i can
well rn that's it, regarding the relevant part
override fun onModalInteraction(event: ModalInteractionEvent) {
if (event.modalId != "appeal") return
val comment = event.getValue("appeal")?.asString ?: return
// ???
}
i feel like something can be done with event.channel.asGuildMessageChannel() but i can't see anything
does kotlin allow String comparison with == ?
I know its not valid in Java
yes
why so?
since it may not be a TextChannel
ah, well i can always check beforehand, right?
yup
and another question, is there any way to retrieve the title of the modal from ModalInteractionEvent? all i have is a modalId and I do not know if it's possible to get a modal from its id
that returns a ModalInteraction and i don't see anything in ModalInteraction that returns modal/title
actually, this is an xyproblem probably, so i basically want to pass information received in SlashCommandInteractionEvent into the modal, so that it can also be treated in ModalInteractionEvent, and my first idea was the title, but maybe there are other ways
now that i think of it, i probably don't need to pass it into the command
i can just make fields in the modal
yeah
that works
Is there an event that fires when a shrieker is activated?
I found the BlockReceiveGameEvent, but that isn't fired for Shriekers, right?
Oh, so I probably just used it wrong.
Thanks
Kotlin does not have a special JVM. If you mean their compiler, then yes, but this is kind of pointless to bring up since I didn't say that you could use Kotlin coroutines without using Kotlin (after all, anyone with experience with them knows that suspend is a compiler feature)
Java 21 literally does not exist yet.
next release
that is weird. what if zou wanted to do an actual == comparison
===
lol well ok
And while yes the JDK 21 project does say they're adding virtual threads, that's not available to anyone yet.
Additionally the point I was trying to make is that Java, in its current state, for most people, makes it hard to work with coroutines.
(I do wonder how many goddamn previews their memory/FFI API has to go through though)
Oh shit they're adding string templates, okay.
hello, have a question, on my plugin I need to load all the content of my db in a map and put it back / update it in the db when the server stops and every 5 min.
but over time imagine that I have 15000 lines to load it will no longer be possible if?
Why do you need to load it all
Because its block locations and i need to check on blockbreak if the location is in my db
good luck keeping all those block locations/data in memory
at least load/unload on chunk load/unload
no point in keeping block locations in memory for chunks that are not loaded
Try making suspending function, wonder if results would differ
So i use cache and on chunk enter i load all blocks in it?
no, on chunk load
there is no on enter
you can also be in one chunk and break blocks in another
yea
so only load data for chunks as they load
Be glad it doesn't have to literally compile a state machine
On chunk load event ?
you need to loop all loaded chunks in onEnable to load data, then load your data in the chunk load event too.
drop/save your data in chunk unload
Just load all at server start in asynchrone is bad ?
no thats fine
So i can?
enterprise code go brr
are you not an English speaker?
No good
Yes its ok to load your data async
Why do you take this question?
You were having problems understanding what I was saying
Wanted to find out if it was age, language or trolling.
Looks like he is using a translator to me 
seems so
I just want be sure for your response . Because before it you said it was bad.
^ I never said loading your data async was bad. Which is why it seemed you were confused
You advised against it, saying that priority should be given to "chunk loading"
It happens sometimes, but usually
In onEnable loop all loaded chunks and (async) load your data for those chunks.
in ChunkLoadEvent load any data you have for that chunk.
in ChunkUnloadEvent save any data which has changed and unload all junk data for the unloading chunk
can you send the code I shall try?
Okay thanks
How to create an invisible glowing slime and stretch iton a region to mark it for the player for a few seconds?
Display Entity has a scale
why make it invisible
^ Display entities are a much better option
Hello good people,
Might I enquire how would one sneak own ChannelDuplexHandler into a connection pipeline to sneak on the packers sent to the client? Since the NetworkManager in PlayerConnection is private upwards of version 1.19 I know not of a way to access it
Reflection?
depends, what kinda slime do you mean
I really don't want to, mayhaps there is a simpler, more legitimate way?
if it's private, you can only use reflection
Welp, ok then. Thank u
uhm
for (Player player : players.getPlayers()) {
(((CraftPlayer)player).getHandle()).playerConnection.sendPacket((Packet)packet);
(((CraftPlayer)player).getHandle()).playerConnection.sendPacket((Packet)new PacketPlayOutEntityVelocity(entityfallingblock.getId(), x, y, z));
}```
```yaml
Cannot find symbol```
so im getting the error "Cannot find symbol"
?nms
which szmbol
but yeah you are not using mojang maps
or you are but your code doesn't
?switchmappings
we need an ?alexindex 🙂
M?
just clariyfing
yes
are you using gradle? did you already set up mojang mappings or NMS in the first place?
what even is the symbol that it cannot find?
you either did not correctly import NMS classes in the first place, or you used remapped-mojang but are still trying to use spigot mappings
if it's the first: see first link
if it's the second: see second link
how do i mention a role with JDA without it looking awkward? i currently just do "<@$roleId>"
it would be very helpful if you could start by showing the full error you get
well what even is "players"?
I have 0 clue
wow
getAsMention()
thx
well "players" doesnt come out of nowhere. why don't you just check what it is?
alr lemme check
public static void sendVelocityBlock(Location loc, Material mat, byte data, World players, Integer delay, Vector vec) {
WorldServer worldServer = ((CraftWorld)loc.getWorld()).getHandle();
EntityFallingBlock entityfallingblock = new EntityFallingBlock((World)worldServer);
entityfallingblock.setLocation(loc.getX(), loc.getY(), loc.getZ(), 0.0F, 0.0F);
PacketPlayOutSpawnEntity packet = new PacketPlayOutSpawnEntity((Entity)entityfallingblock, 70, mat.getId() + (data << 12));
double x = vec.getX();
double y = vec.getY();
double z = vec.getZ();
for (Player player : players.getPlayers()) {
(((CraftPlayer)player).getHandle()).playerConnection.sendPacket((Packet)packet);
(((CraftPlayer)player).getHandle()).playerConnection.sendPacket((Packet)new PacketPlayOutEntityVelocity(entityfallingblock.getId(), x, y, z));
}
SUtil.delay(() -> removeBlock(entityfallingblock, players), delay.intValue());
}
SUtil
"players" must be a field
oh wait
wtf
"players" is a world
why is the world called players
yeah anyway, World#getPlayers() clearly does exist https://hub.spigotmc.org/javadocs/spigot/org/bukkit/World.html#getPlayers()
declaration: package: org.bukkit, interface: World
nope got nothing
((CraftPlayer) target).getHandle().connection.connection.channel gives u the netty channel
then just inject
declaration: package: org.bukkit, interface: World
getPlayers has existed for ages
how does it work tho
Unless i got smth wrong, since 1.19 NetworkManager is private and u can't do that
ru coding against spigot?
?learnjava
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.
"connection" in ServerGamePacketListenerImpl is private
weird
that means you decided to use "player" somewhere without ever declaring what it is anywhere
it changed
?whereami
hmmm
I swear I did
Maybe it's patched in paper
its public in 1.19.2. I remember it changed around then https://nms.screamingsandals.org/1.19.2/net/minecraft/server/network/ServerGamePacketListenerImpl.html
I host on purpur so it should work, gonna try it
nope
1.19.4 made it private
1.19.2 was the last time I saw it public
k
Are teams still the preferred method for hiding nametags?
I think so
I am pretty sure u can use a separate scoreboard and put everyone on the same team there. Just don't forget to disable teamate invis pot visibility
network or something became private
17 interfaces, 8 abstract classes and 70 regular classes
I wonder if I'm going overboard with interfaces
hi
how can i create a holograms (im using dh holograms) for show the timing remaining to a mine spawn with realmines
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing D:\STUFF\189server\plugins\Spectaculation-0.2-SNAPSHOT.jar with C:\Users\xxx\Downloads\Skyblock-main\Skyblock-main\target\Skyblock-0.2-SNAPSHOT-shaded.jar
any reason this happens?
because you're using the maven-shade-plugin
and have declared an execution for it, probably during package
the question should rather be, why did you use a totally different name for the .jar
there is no such thing
make sure to use decorators
Every class and every method has to have an interface of it
ehh
and bridges
and blackjack
I do have an adapter somewhere
good enough
is it me or do some images just appear blur when I click on them
might be the resolution
looks fine to me
Because my monitor's 2k and it might be downscaling
first pic looks blurry on my 1080p monitor
And I also have really strong contrast settings on my 2k monitor which means sharex might be tripping
mans flexing his 4k screen
I do want to get one
but I'm not in the right financial situation for that
mac looks so fancy
2k is plenty
on 16 inches lol
I already use 120% on everything at 2k
I paid mad money for my 17 inch 1440p 16:10 screen on my laptop
Was nice for coding in class
but now I'm done with school
only time I've seen a school from inside during the last 10 years was once when I was drunk and visited my old school, and when there's elections going on
as in getScoreboardManager().getNewScoreboard()?
I use a 32" 1440
ayy reached 30 stars
Yup
Nice
I looked at my mod that other day and it had 41k downloads lmao
probably you also have to set the "general" visibility or sth
don't you need protocollib?
i would just use TextDisplays for holograms btw
You never "need" protocol lib
i'm pretty sure you do for per player stuff
Well, holographic displays maybe since it requires it if I remember correctly
not quite
but sometimes
There's native API for setting entity visibility in bukkit
But no native api for per-player metadata
can always use NMS. but for per player stuff, theres api for that
I live in the UK. I miss the sun.
I live in a coastal city
but I honestly can't focus on anything rn
and got a weird headache so I might just go out for a walk
we get about 4 weeks of sun, and 47 of rain
it's the opposite here
Like 5 days of rain per year
and summer for the other 360 days
How should I make a countdown?
using HashMap or Cache and System.currentTimeMillis
for database
is it a small query that happens every second
or is it a big query that happens every hour?
no
wydm
just a countdown from whatever amount that sends a message every second
???
you can easily do that with a scheduler
?scheduling
for database which one am i need use ?
- is it a small query that happens every second?
- or is it a big query that happens every hour?
Is there a way to make a repeating task stop after x amount of times or x amount of seconds?
Think about it, and you'll find your answer
That theme coloring for the code block is cursed
haha yes it is
Dark blue, dark green, and black against a dark gray background
Only do the queries you need
When a player joins, do a query, fetch their data, save once in a while
and when the player quits you save once more and remove from the cache
what if I do both at the same time?
i mean save datas per hour and save datas per left
is it necessary ?
ah this smiley 😄
Hello, is there an easy way to store a persistent data in a Block ?
?blockpdc
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
okay thanks
he made it btw 😄
you can also use metadata
metadata is not persistent
I know
I want to make custom blocks using ItemDisplay (packet-based) and I need to identify the block inside the ItemDisplay (to resend the custom block after a restart for example)
but itemdisplays are entities and hence already implement PersistentDataHolder
but they'll be packet based
aah yeah
so I can't retreive it after a restart
then you can just use CustomBlockData
that's what I'm going to do 😄
'cause that's useful
Cannot resolve method 'getPlayers' in 'World'
for (Player player : players.getPlayers()) {
(((CraftPlayer) player).getHandle()).playerConnection.sendPacket((Packet) packet);
(((CraftPlayer) player).getHandle()).playerConnection.sendPacket((Packet) new PacketPlayOutEntityVelocity(entityfallingblock.getId(), x, y, z));
}```
what I did wrong
Or wrong import
for a start name it world if it IS a world
Or they are using bukkit 1.2 or sth lol
true
hi ElgarL
hi
Hello elgar
hi too
they said i need use uuid in hashmap for save datas at offline server
i got my reply but i wonder ur reply
why i can't use player in offline server?
im not offline player
i just wonder
uuid is persistent. Player is not
if the player relogs the current Player object will not be valid
a new one is created
Offline mode?
ahh
alright
use UUID and get a Player when you need it
Wait, in offline mode servers, is the uuid a random uuid or the actual uuid of the player? 
its a UUID based upon their name in offline mode
And that means? 
you answered my other question
if two players log in with the same name at different times they use the same UUID
But is the UUID the UUID the player with that name would usually have in online mode? Sorry for me being stupid 
no
its somethign like UUID.fromString("OfflinePlayer:" + name)
online UUID is assigned by Mojang and has no relation to a players name
an online UUID is always the same for an account
Hmm, but is it possible to change the uuid of a player before they are logged into the server fully? I don't have any use for this, just curious 
if using bungee, yes
like this
nothing more
And if spigot, no? Or can you maybe change it inside the packet or somrthing? 
heY!
I just realized that spigotmc supports only x mb of plugin size
but my plugin needs to have some stuff shaded
is there some way to upload it and bypass the limit?
in thoery you could assign yoru own ids
Hmm, ig. Well, I don't really know what to use that info for anyways lol 
use libraires entry in plugin.yml
I have this
but for example JDA and SQLITE-JDBC isn't a plugin
or is there some other "param" ?
It's param called libraries, search it up, it downloads dependencies from maven central
oh!
oke
tysm
And inside of your pom change scope to provided
Hmm, wait. Could you in theory make a plugin that would allow offline mode people to join an online mode server? 
What do u prefer for caching and save player data ?
on left the server save datas from hashmap
or save datas from hashmap every 1 hour ?
In thoery you can replace all teh minecraft server code and do whatever you want
Mixins 
No, online mode servers authenticate on mojang first, that is why you sometimes get session expired
I mean yes, if you change server code lol
😄 why u use schnitzel ?
It is my religion 
Fair enough
I'm a follower of the great and holy, of the schnitzel

what data specifically?
Well, I would do both to make sure the data is safe 
money, level
do you need access to that offline?
Offline player ig 
no, when the player is not logged in
ok
then save when log out and every x minutes
i will explain u better? my project
