#help-development
1 messages · Page 1960 of 1
Yes
okay ill try that out thank you
discord:
- tellraw @a {"text":"https://discord.gg/spigotmc","underlined":true,"color":"blue",clickEvent:{action:open_url,value:"https://discord.gg/spigotmc"}}
YML parser has no problem with this, how do I go about this?
Here's the error I get ^
wait
look at that screenshot instead
"invalid chtat component"
use json reader
look at the last link I sent
Im a bit confused, I used thread.sleep and it crashed my server, do i use async on that part where it is doing thread.sleep then? Im making a cooldown bar like this
::::::::::::::::::::::::::::::::::::.......
But when its executed because of thread.sleep it crashes server, so do i just put this into async? Will the bar still work after that ? Do i use bukkit scheduler or
the permission will be the same as the main command
hi md5 🙂
nooo won't work
must be discord.* then
cause i tried "discord"
maybe i do "discord.*"
no
it would literally be minecraft.command.tellraw
aliases dont have permissions
they just execute the command
but i have it in a /discord command?
commands.yml really isnt good, but the essentials echo command is sometimes used
its an alias
all an alias does is execute the commands you listed
if you want something more advanced you need a plugin
there's like 10000 custom command plugins
top result on google
so i cant just have a default minecraft perm that allows de-opped to do all alias commands?
ALIASES ARE NOT COMMANDS
Feels really trashy to add a whole plugin for 1 command
well use a plugin that allows you to add 1000 commands 😉
I know but the fact that I can do /discord as an OP but not as a deop tells me that there's a built in permission
the permission is the tellraw permission
because aliases just execute the commands you listed
yes
alr just send me the commands plugin instead pretty please
https://www.google.com I think your looking for this
people will be happy they were able to help 
Plugin to have a broadcast every 10 min?
bump
Plugin to have a broadcast every 10 min?
Hey
Are you cooding your own plugin?
And if you are asking how to code your plugin for brocasting. I would recommend using timestamps with a runnable
nono just if there's a plugin for it
cant chat in there
Try verifying your account
are you writing in python? lol
fixed
Kotlin
I was thinking
is returning new completablefuture object as a callback to the bukkit runnable
bad if im using bukkit runnables, or is it ok
i don't have thread pool, and i don't want to execute my code in fjp so im using bukkit runnables
You can make use of a BukkitRunnable to handle your CompletableFutures, yeah, that's fine
Out of curiosity: what does the scheduler do that the concurrency API doesn't?
You can actually call a method sync on the main thread form within a CF
You could Thread#sleep() to handle your futures if you really wanted to lol
Operates based on ticks, Maow
Plugin association of tasks as well
API or implementation difference?
yes but i need to return it as a value from a function
im returning CompletableFuture<Boolean> for later handling
internally its just probably a wrapper around ExecutorService
Well, that'd be the reasonable conclusion.
But CraftBukkit works in strange ways.
public CompletableFuture<ItemStack> getPlayerItemAsync(JavaPlugin plugin, UUID playerID) {
return CompletableFuture.supplyAsync(() -> {
try {
return Bukkit.getScheduler().callSyncMethod(plugin, () -> this.getPlayerItem(playerID)).get();
} catch (InterruptedException | ExecutionException e) {
return null;
}
});
}
public ItemStack getPlayerItem(UUID playerID) {
Player player = Bukkit.getPlayer(playerID);
return player == null ? null : player.getInventory().getItemInMainHand();
}
Example
private final ThreadPoolExecutor executor = new ThreadPoolExecutor(
4, Integer.MAX_VALUE,30L, TimeUnit.SECONDS, new SynchronousQueue<>(),
new ThreadFactoryBuilder().setNameFormat("Craft Scheduler Thread - %1$d").setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER)).build()); // Paper
it uses ThreadPoolExecutor internally
it constructs threadpool manually
although that's paper
i don't know spigot
i don't want to use CompletableFuture with FJP, due to that i have blocking IO operations
it reduces your parallelism
What is FJP?
ForkJoinPool
Ah i see. Then just supply a single thread executor.
i have no idea how to manage an executor in my case
i need to shutdown somehow
whenever its not used
Why? Thats not something you should care about. Let java handle when to put threads to sleep.
you need to shutdown your executors
You can do that when the server stops. Just create an executor when it starts with the desired amount of threads. Then onDisable flush it in a blocking fashion.
and how would i encapsulate the thread executor
You dont really need to. Just create an instance and use it where its needed.
so you're saying that i should pass it as an argument
If you really want to encapsulate it:
public class SingletonThreadPool {
private static final ExecutorService EXECUTOR = Executors.newSingleThreadExecutor();
public static <T> T use(Function<ExecutorService, T> function) {
return function.apply(EXECUTOR);
}
}
usage
CompletableFuture<Integer> cf = SingletonThreadPool.use(executor -> CompletableFuture.supplyAsync(() -> 10, executor));
Enum#valueOf(String)
Enum.valueOf()?
Does not exist in kotlin
i don't know kotlin
lol
Uhh you should be able to use valueOf
Are you trying it on Enum or your actual enum type?
Unresolved Reference
Because it doesn't exist on Enum
im trying it in
playsound
public static final Sound GLASS
// Enum constant ordinal: 22
Sooo Sound.valueOf(args[0])?
I mean it's the same as Java's but yeah
I don't know why Kotlin doesn't have Enum.valueOf though
ok, but why singleThreadExecutor for io operations, wouldn't it be faster if i used couple threads instead
Even if you parallelize with multiple threads...IO to a single physical disk is intrinsically a serialized operation. Each thread would have to block, waiting for its chance to get access to the disk. In this case, multiple threads are probably useless...and may even lead to contention problems.
answered myself
im saving files to hard drive
so yeah
Do actionbars,tablistheaders,footers and title sending have an api in 1.18
Yes yes yes and yes
1.8 cringe
Lol
Meh
I stopped caring about the 1.8 debate
Same shit, different day as my dad would say
md5 :yooo:
hi
whats the usecase
He question is there a way to check from a list of locations what is the nearest from the player location and teleport them then there
I mean, just a plain for loop would do
vector distance, but i bet there's a method for that
use distanceSquared for this ^
Okay
final List<Location> locations = ...;
final Location playerLocation = ...;
Collections.min(locations, Comparator.comparing(l -> l.distanceSquared(playerLocation)));
I was thinking about this but what is a very simple method to do inventory pages? What would be the code behind it logically? Im not asking for spoonfeeding code, im just really wondering like -- what would it look like? if anyone can briefly write some pseudocode
There are two ways.
- Having multiple inventory instances encapsulated in a wrapping class that handles the switching between them.
- Having a single inventory that gets re-populated if you switch to another page.
So either a wrapping class with something like a List<GUIInventory> or one GUIInventory that can be updated with several page contents.
i unblocked you because you are being nice now
Really just depends on your abstractions
You can also have a LinkedList approach where each GUIInventory holds a reference to the next and to the previous one
Oh
Well i was thinking of something like getting the array of the data and just making the inventory every time the user flips the page and saves the number of the page so then it can remove X amount from array something like that
Hard to maintain, not a great idea.
and just calculating things if more pages are needed etc
Yeah you can have a single context and compute the amount of pages you need to display that content + the offset for each page
So one of my plugin's files is taking up alot, alot of storage (for ex someone sent a ss of 789MB of data), and the format is like so
uuid
value
uuid
value
any better alternative? (this has to be loaded so i can check specific values for specific players, meaning 789MB won't cut it)
dont you have a db
custom, i put it right here
No that's your structure
its
uuid
value
oh, no ext
Oh so it's just line-by-line then?
yes
This sounds like you might have a ton of duplicates.
Analyse the File and check for duplicated IDs.
Use DataOutputStream/DataInputStream or SQL
nope, it only allows for one key to exist at any given time
with a single value
Storing it as binary would reduce that size by a lot
How do you assert that?
Probably via Map
.
Other way around. A HashSet uses a backing HashMap for storage.
I meant keySet
i mean if there was a builtin db i'd use it (one that people don't have to setup, most people using my plugin struggle editing the config lol)
Do you need all data to be loaded at all times?
Well a lot of people already have DBs
Yes
it handles who is in the game and who is off the game
But 800mb can easily be couple hundred mb in memory...
however it also stores some extra data
Why are you storing this persistently?
i might use this
Then you should re-design your data storage
because it... has to be stored persistently
its not a round game
it just affects the world
Yeah but every time the server shuts down, you essentially invalidate the "is player online" data.
wdym
I dont quite understand this... Everyone that isnt online is just offline. What do you need the offline data for all the time?
That is also true ^
no no no
its like
if you are off, you can't join the server anymore, thats what i was talking about
its like an elimination system
nope
i aint doing that
But then why dont you load player specific data when a player tries to join?
you.... make a very valid point
why not
not storing on players
i hadn't tought of that
so you mean like
I mean all you really need to do is just store a list of UUIDs lol
uuidofplayer (file)
data (in the file)
i also store a tiny amount extra data needed
so yeah
AsyncPlayerPreLoginEvent is async and you can block the player there while you load his data.
Then one file per player would be better.
Just <UUID>.txt
storing all his content. This way you can load <UUID>.txt when the player joins because you will
have his uuid and therefor his file name.
I'd also personally recommend using data output/input streams due to binary being smaller and faster.
oh yeah
But then he would need to encode everything in binary... and that might be a LOT of work.
It's not :p
DataInputStream/DataOutputStreams do that
As he said it's only "a tiny amount of extra data"
And those streams provide a fuck ton of great utils
That make it really easy to encode/decode stuff.
How would you store a List<String> for example in binary?
<size of list> <string size> <string contents> <string size> <string contents>
Then you just read the list size, and iterate till you reach the end.
Yeah. And the you need a bytebuffer and know the size of each character. And the encoding and so on.
Nope
writeUTF/readUTF
Just store it as Java's modified UTF-8
And the size of a character in that format is always 1 byte iirc
(even though a char is 2 bytes? wtf Java?)
Legit I can write an implementation rn off the top of my head
try (DataInputStream src = ...) {
final int size = src.readInt();
final String[] strings = new String[size];
for (int i = 0; i < size; i++ {
strings[i] = src.readUTF();
}
}
Done
I doubt that this is really beneficial to be honest. Json is way less error prone and the overhead is acceptable because all IO should be done async regardless.
And the user wont notice a difference between waiting 5ms or 30ms in login.
The speed isn't the concern it's the size
^
i should also use a inflator/deflator stream wrapping the data streams
should also provide a tiny boost
You'd wanna wrap the data streams around the flators
Sacrificing stability, readability and maintainability for size does not sound like a good idea to me.
I would rather try another approach instead of hammering a 800mb blob into a smaller size.
It's still stable, readable, and maintainable. What are you on about?
Like having a <UUID>.json file for each user and only load data when its needed.
this, its really easy to modify this
and really easy to read
If you need stability between changing the format, JSON isn't going to help you. Add a fucking versioning byte.
e.g. 0 = version 1, 1 = version 2 (new and improved!)
and so on
I'd argue it's readable due to the fact it's more readable than mainly encoding/decoding it I've done this before
Instead of using a lot of bit magic, you're just working with method calls
Binary data is not readable. And its for sure not easily maintainable.
Gson will save me hours and hours of development time while someone
dabbling in binary will have to implement custom serializations for each new
type of data.
Theoretically, you don't need to implement custom serializers/deserializers.
I wrote a library that can generate them automatically, and its default implementation uses data input/output.
Is that stable? Fuck no.
Ive come to the conclusion that binary data is not worth it unless minimal size is an absolutely crucial requirement.
Which is rarely the case.
https://i.imgur.com/LJJcqqX.png what kind of delay are we talking about?
- 1 tick because we need to make the PlayerJoinEvent finished triggering
- an arbitrary value, which may vary based on the server performance
- an arbitrary value, which may vary based on the player connection
But it's still an example of how easy it is for someone to do the same thing.
Binary data is readable when you're the one who wrote it.
It's easier to analyze a format you made because you know the patterns.
I can't remember an entire class file off the top of my head but I can remember a data file I wrote in binary.
Its probably a fixed amount of ticks. Try it one tick later and see what happens.
And json is standardized so everyone knows the pattern... not a good argument
alr thanks for your input buddy! i'll tell you
Why should people need to read my cached data files?
Either they're a contributor, in which case they can read the code, or they're just a curious server owner, who I'm not trying to appeal to.
"But ma bugtesting" - Then they can file an issue report so I can analyze it for them.
Also you could easily maintain binary given the proper abstractions.
Make one mistake when implementing binary serialization -> might corrupt everything without any chance of recovery.
I wrote said abstractions in like, less than 3 hours.
Well that's why you implement testing first.
Either through manual testing or unit testing.
So you can just throw any class at your serializer and it will scan all fields via reflections and has a ton of serializations for all kinds of collections and data structures?
And recursive serialization.
No I was referring to the actual serializer/deserializer bit, not scanning and common implementations.
But, yes, I have a framework that does that.
Even then, I'd argue that automatic serialization like that leaves you with a lot less control.
Alright you do you... I clearly have a different opinion on that topic. Wont even get started with data migration. Storing all that in a sql or nosql db would be fun for sure.
A problem I have with Gson is that you have to implement manual serialization just to have a better API in some cases.
You ever read a version manifest? The thing is filled with garbage that is just better to filter out.
(But, then you need to implement manual serialization, which is a nightmare with Gson)
(I know this because I had to write abstractions just to work with it)
Huh? how is that a nightmare? Its object oriented and way better than every other serialization library in that regard.
And you dont have to implement custom serializers you can simply define rules for your Gson instance on what needs
serialization and what doesnt-
Dont just throw keywords at me... Nullability is not a problem exclusive to Gson. And i dont even know what you mean my "chained method calls".
Meh
imma still not go with json
i deeply not like json when there are better alternatives
@Override
public JsonElement serialize(PlaceholderExpression src, Type typeOfSrc, JsonSerializationContext context) {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("original", src.getOriginal());
jsonObject.add("icon", context.serialize(src.getIcon()));
return jsonObject;
}
Thats as complex as it gets with custom serialization when using Gson.
Hell yeah, resist the public mentality @rough drift. You deserve a cookie 🍪
Try it the other way around now
public class MyPlayerDataFile {
private String abc;
public String getAbc() {
return abc;
}
}
Gson gson = new Gson();
gson.load(string, MyPlayerDataFile.class);
```or smt like that
thats just bad design
@Override
public PlaceholderExpression deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject jsonObject = json.getAsJsonObject();
String original = jsonObject.get("original").getAsString();
ItemStack icon = context.deserialize(jsonObject.get("icon"), ItemStack.class);
PlaceholderExpression condition = new PlaceholderExpression(original);
condition.setIcon(icon);
return condition;
}
Simple...
What if one of those are null?
Hell, what if all of them have the potential to be null?
We're talking theoretical situations here, not your actual use-case.
meanwhile, data output streams:
out.writeUTF(abc);
in.readUTF();
pfff
much easier to use those ngl
Then they are just null... which means the constructor will be called with null values. Which will be a problem with every de-serialisation method.
Sure but it's still a fuckin' nightmare in Gson
Mainly since you work with a lot of optional data at once
The code ive sent is null safe. Gson handles all of that.
imagine the json structure changes, you have to change the class you load to and every class that uses it
Anyway I don't feel like arguing anymore since it's literally 4 AM for me
And it's my fucking birthday
Aaaand I'm not in a great mood
oh happy bday
Oh happy birthday 
gn maow :D
I also got mine in a month. I just hope nobody bothers me XD
(i guess its gn since 4am)
Probably only sleepin' at like 5-6 AM
ohk
Sleep schedules
private fun getOutputStream(file: String): DataOutputStream {
return DataOutputStream(DeflaterOutputStream(FileOutputStream(file)))
}
private fun getInputStream(file: String): DataInputStream {
return DataInputStream(InflaterInputStream(FileInputStream(file)))
}
```tada
How do i use bukkit scheduler because i try to use it but my server is still lagging.....
I need to use thread.sleep
wdym
yeah kotlin is good
Kotlin is fantastic
somethings i prefer java for some stuff (like api's that don't have a kotlin impl)
I think most of Kotlin's APIs are better but ye
You seen Clikt yet? Compare that shit to JCommander lmao
Yeah i use kotlin too...
I don't code in Kotlin very often but it does consistently make me happy.
I'm just one of those people who is stuck with Java out of the comfort of already knowing it :/
How do I use bukkit scheduler (https://ibb.co/44sZWw5) because my server still lags when I do
override fun run() {
for (i in 1..100) {
myshitFunction()
Thread.sleep(cooldownTime.toLong())
}
for (i in 4 downTo 1) {
myshitFunction()
Thread.sleep(230)
}
}
}.runTask(Instance.plugin)
its like kambrik but for CLI (https://kambrik.ejekta.io/)
Bukkit.getScheduler().scheduleSyncRepeatingTask or smt
i dont understand...
Never use Thread.sleep when working with Spigot
Bukkit.getScheduler().scheduleSyncRepeatingTask(yourPluginInstance, runnable, delay, interval) smt like that
Never use Thread.sleep in general, it's usually not a good idea :p
A runnable won't magically fix the fact that you're pausing the server thread
i mean, it can be helpful if you have no other option
tho generally its so slim, don't use it
Help me understand how to use cooldowns and other things like that I want to implement
why not learn the bukkit api first-
I knew someone who commonly put - at the end of their messages
?help
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.
They talked behind my back like all the time :p
Ditched their ass
Now I'm the one who talks behind their back >:)
Just use the BukkitScheduler like you've done above. But instead of using Thread.sleep use nested Schedulers or something like TaskChain (an additional dependency)
i put it when i think my point has been conveyed so i just don't write anymore xD
I put it as an actual cut-off
like when I stop a sentence in the middle of ty-
-ping it
?scheduling I recommend reading this
well i just ctrla ctrlc send other msg, ctrlv
o
e.g. when my boyfriend says some stupid shit and I have to take a moment to process and make fun of him
lmao
Cooldowns should always be done with a timestamp.
So when a user executes and action -> you add a timestamp
When he tries it again you simply calculate the time between now and the timestamp
Eg delta is 3211ms and the cooldown would be 5s. Then you can tell him to wait around 2.7s before he can use that action again.
Dont use schedulers or threads for that.
That is confusing.
Im talking about a cooldown actionbar, that does a little animation like :::::::.....
wouldn't it be more accurate to round to 3.2 so the player has to wait 2.8
(in the msg)
3.21 -> 2.79
If you format that using %.1f then it will be 2.7
fair
Then you would still handle the cooldown with a timestamp. The only difference is that you check the stamp every N ticks. (5 should be fine)
This requires a scheduler.
?scheduling
Is there some easy way to store just 1 int between restarts or do I have to create a binary file for it?
Hm you could just use the PersistentDataContainer of the main world
If you really dont want to write into a file
Oh, I didn't know that world itself has also a PersistentDataContainer, thx
Pretty new feature
Bukkit.getWorlds().get(0).getPersistentDataContainer().set(NamespacedKey.fromString("custom:version"), PersistentDataType.INTEGER, 90);
Do you know In what version it was added, because I want to know how much backwards compatible it would be?
Hm... quite recent. A workaround would be to use the PDC of a fixed chunk.
So the PDC of the chunk 0/0 at the main world. But lets see when the world got a PDC.
?stash
hmm, I'll probably need to use something different then xd
because I want to support more versions than just 1.18.1
So the PDC of the chunk 0/0 at the main world.
Just hack it in there
But dumping data into a binary file is really not that much effort.
chunk pdcs exist since 1.16 iirc
Perfect. You wouldnt want to support anything earlier.
hmm, that's probably ok
Yea, just make sure to not grab 0/0 but preferably the servers spawn chunks (which might be moved)
chunk PDC has the unfortunate issue that chunks unload and load
so if someone moves the world spawn but you grab the PDC of the chunk at 0/0 a bunch -> loading that chunk over and over
@Data
public class SomeConstants {
@Getter
private static final transient SomeConstants instance = loadOrCreate();
private static final transient Gson GSON = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().create();
private static SomeConstants loadOrCreate() {
JavaPlugin plugin = JavaPlugin.getPlugin(SmileCore.class);
File folder = plugin.getDataFolder();
File file = new File(folder, "constants.json");
if (!file.exists()) {
return new SomeConstants();
}
try {
return GSON.fromJson(Files.readString(file.toPath()), SomeConstants.class);
} catch (IOException e) {
e.printStackTrace();
return new SomeConstants();
}
}
private SomeConstants() {}
private int version;
private String info;
private double temp;
public void save() throws IOException {
JavaPlugin plugin = JavaPlugin.getPlugin(SmileCore.class);
File folder = plugin.getDataFolder();
folder.mkdirs();
Files.writeString(new File(folder, "constants.json").toPath(), GSON.toJson(this));
}
}
String info = SomeConstants.getInstance().getInfo();
SomeConstants.getInstance().setInfo("New Info");
@Override
public void onDisable() {
try {
SomeConstants.getInstance().save();
} catch (IOException e) {
e.printStackTrace();
}
}
Thats all a bit hacky but at least you can add as much data into the constants class and it will always be up to date without changing anything.
hmm, isn't it better to save the data using byte streams?
Huh? Why? What do you mean by better?
Lmao 7smile7 is just getting his ass beat by the bytes
The user does not notice a difference between 2ms and 20ms. Its literally 1/50th of a second.
idk, I think, that it has smaller size + you don't want the user to mess with data, that aren't in config, so he won't write there something incorrectly, and json is really easy to edit
And here you can literally just add a Map<String, Integer> or even some deeply nested shit with complex classes and you dont have to change a single line of code besides adding all the data you want.
base64 encode it then. You guys with your binary data. You can do that when fiddling with optimizing pdc types but
for stuff like that you should value modularity over everything else. Coming back to bin data and changing stuff without
invalidating every data out there is just not worth anyones time.
I mean. If its literally just a single int and you are 100% certain that you wont ever have to add any other data then go ahead and write your 4 bytes into a file.
hell you can even just use the name of an empty file
Ooh reminds me of the folders programming lang
Fun fact: A newer spec of it is name-agnostic.
I really need to update my vocabulary. I use "stuff" too often
Oh god
Esoteric languages are funny. Do you know MOO
What the fk. This is actually a thing.
yif
Ah yes that's my favorite instruction
Oh ye and you can write like
some programs in it
there's no way to do file IO or UI so it's basically as useless as brainfuck
but
y'know :)
brainfuck can use IO
stdout
Not file IO
Sure. You can use stdout to do file IO
Hey, how can I disable switching spectator targets?
I want to allow a spectator to get into an entity, but I don't want them to switch entities without dismounting from the first one and then mounting to another.
Is there an event called when doing that, or do I have to play with packets?
No I'm pretty sure Brainfuck doesn't support piping or redirection or whatever the fuck
It has access to stdout. It can do anything. You could even do http requests if you wanted.
Pretty sure theres an event
Can I run Brainfuck in Brainfuck?
Might be the teleport event with teleport reason
that the reason why I asked if there isn't some better solution that creating a 4 bytes file (I solved it by writing it to the spawn chunk)
its turing complete. You can do anything. Even write an interpreter for itself.
Yep, PlayerTeleportEvent.TeleportCause.SPECTATE
Thank you!
Can I run Minecraft in Brainfuck?
have fun with that
If you want to check if a Player is currently spectating someone you can just use
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/Player.html#getSpectatorTarget()
declaration: package: org.bukkit.entity, interface: Player
I'll eventually remake this into a bytecode lang w/ a VM implementation
I know, thank you 😄
how do i make a command only i can use?
Why do you need that
Add a permission or a programmatical condition with your UUID or name
Definitely permission...
^^
Which is best? Oracle JDK or OpenJDK or other?
OpenJDk
I mean. If he wants it to be absolute then permissions wont cut it as everyone else with this permission or op could execute that command
Basically the same. Just different licensing.
No diff? like performance or etc?
Its the same jvm. No difference at all performance wise.
If you want to improve your performance you should focus on jvm arguments. Mainly for garbage collection.
*After youve optimized minecraft/bukkit/spigot for your needs
Isnt there like
?performance
?optimize
?optimise
hm
?optimization
🤔
?makespigotnotlag
?lag
?help
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.
?flags
Aikar's garbage collection flags: https://aikar.co/2018/07/02/tuning-the-jvm-g1gc-garbage-collector-flags-for-minecraft/
I see
was looking for this
https://www.spigotmc.org/threads/guide-server-optimization⚡.283181/
is there a way to make a custom food eatable while max hungry
Hello. I need help with Chunk Format. On the page there is a https://wiki.vg/index.php?title=Chunk_Format to outdated examples, and for the required version 1.18 only to Node.js. Has anyone come across Chunk Format and can help with Java code example?
Retexture a golden apple
but then i would get the effect from a golden apple wouldnt i?
Node.js?
What are you trying to do?
World scanner for specified items
How to save a custom .yml file after editing them?
I recommend using Prismarine
What al i even looking at?
Thanks, I'll take a look
fileConfiguration.save(file)
This page has code examples on a Node.js https://wiki.vg/index.php?title=Chunk_Format
Wait it already links to prismarine chunk...
Sorry for the ping...
😆
That implementation is 1.18
If you cannot get it working head over to their discord
I'm going to implement something similar in Java
👍 ty
Ah why not refrence NMS then?
I can not find an example of decrypting files of regions
Hey, does anyone know how to code custom entity pathfinding
I assume this requires some sort of work with packets
or NMS
nms. Packets dont make the entities behave differently.
What version are you on?
sigh
You need to run BuildTools once for 1.8.8 to install it into your local maven repo.
Then the dependency is the same with the exception of the artifactID which is now spigot instead of spigot-api
?bt
You cant just manually add a maven dependency. How do you compile?
Ok but how do you compile your jars? Do you build artifacts?
Ok and what do you mean by "manually adding" the dependency. Using mvn install:install-file?
I mean. Just run BuildTools once and add
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
uuugh
1.8.8
1.8.8 the best
yes it's not
definitely not
Too old! (Click the link to get the exact time)
oh is that site up again?
1.8.8 can almost go to school
it was gone for some months
1.8.8 can almost buy alcohol in my country
💀
yeah everyone aged 7 or older is legally allowed to buy alcohol
https://paste.md-5.net/osebudivak.cs
14:29:46 [INFO] returned: []
14:29:46 [INFO] punishments: []
14:29:46 [INFO] punishmmentType: Ban
14:29:46 [INFO] 1111
14:29:46 [INFO] 2222
14:29:46 [INFO] list before: []
14:29:46 [INFO] list after: [md.mirrerror.cloudbans.units.punishments.BanPunishment@9def369]
Why returned is always empty? Is it because I fill it async and return it sync? If so, how can I avoid it?
list after: [md.mirrerror.cloudbans.units.punishments.BanPunishment@9def369] smth like this
but it returns an empty arraylist
removed the async part and now it returns what I want, lmao
but I have to do it async
cause it is a db connection
how can I fix it?
You wait for the transaction to complete. Async of course. One viable tool for this are CompletableFutures.
what the fuck
that's fucked up imo
Hes joking. I think its 15 or 16
can u give me an example pls
That because beer is a staple food here.
No hard alcohol.
List<String> result = new ArrayList<>();
ProxyServer.getInstance().getScheduler().runAsync(Main.getInstance(), () -> {
// db connection etc...
result.add(resultSet.getString("test"));
});
return result;
The problem here is that the list will be empty when you return it because the database call takes a while.
yeah
but how can I avoid it
I mean
to do it async
but to return a correct object
Solution: Dont return a List but return a CompletableFuture of that list.
public CompletableFuture<List<String>> fetchData() {
return CompletableFuture.supplyAsync(() -> this.loadData());
}
private List<String> loadData() {
List<String> result = new ArrayList<>();
// db connection etc...
result.add(resultSet.getString("test"));
return result;
}
A completable future doesnt have that object right away. But it tells you that it will have that object eventually.
So you dont use the object directly but rather define actions for that object as soon as the CompletableFuture has it.
public void tellPlayerAllBans(Player player) {
CompletableFuture<List<String>> listFuture = this.fetchAllBannedPlayers();
listFuture.thenAccept(list -> {
for (String name : list) {
player.sendMessage(name);
}
});
}
public CompletableFuture<List<String>> fetchAllBannedPlayers() {
return CompletableFuture.supplyAsync(() -> this.loadAllBannedPlayers());
}
private List<String> loadAllBannedPlayers() {
List<String> result = new ArrayList<>();
// db connection etc...
result.add(resultSet.getString("test"));
return result;
}
Compact version:
public void tellPlayerAllBans(Player player) {
this.fetchAllBannedPlayers().thenAccept(list -> list.forEach(player::sendMessage));
}
public CompletableFuture<List<String>> fetchAllBannedPlayers() {
return CompletableFuture.supplyAsync(this::loadAllBannedPlayers);
}
private List<String> loadAllBannedPlayers() {
List<String> result = new ArrayList<>();
// db connection etc...
result.add(resultSet.getString("test"));
return result;
}
CompletableFutures are really hard to understand initially. And you need to fully grasp the concept of lambdas because you will see them used a lot
in CF contexts.
it doesn't work either, @lost matrix
public CompletableFuture<List<Punishment>> fetchPunishments(String key) {
return CompletableFuture.supplyAsync(() -> this.retrievePunishments(key));
}
if(dataManager instanceof MySQLManager) ((MySQLManager) dataManager).fetchPunishments(key).thenAccept(list -> this.punishments = list);
Don't think about the result, think about what are you going to do with it
I'm going to initialize all my fields in the class 🙂
@Override
public void retrieveData() {
DataManager dataManager = Main.getDataManager();
String key = Utils.getKey(name);
if(dataManager instanceof ConfigManager) if(!dataManager.isRegistered(key)) dataManager.registerPlayer(key);
if(dataManager instanceof MySQLManager) ((MySQLManager) dataManager).fetchPunishments(key).thenAccept(list -> this.punishments = list);
else this.punishments = dataManager.retrievePunishments(key);
System.out.println("retrieved: " + punishments);
}
you have design problems
yeah maybe
it will work automatically?
so i am trying to use this to deserialize an itemstack array in the same file as the menu class, how would i do so?
Does it need to be NMS
Well, what does the original n() do
well its where the sunlight burning part is stored
Override it
yeah but then I have to rewrite every single method inside it
or most of them
cuz they are protected
Not much you can do there
also how do i find these methods
how to write it?
[wb, craftingi]
thx
Know your way around a decompiler or use remapped
how would i make an ArrayList<ItemStack> just an ItemStack?
https://paste.md-5.net/lijokucaka.java would this work to load itemstacks from a file?
how to use no-clip in 1.17?
go into spectator mode?
I'm not sure I understand. There are no blocks that clip through terrain as far as I'm aware
there was a way to set no-clip to true before they updated Nms
what is JUnit
like how does it work and what is an example case of when to use it
that isnt a coding question
yes
yeah but I want it to walk
like move to another location
and turn its head also
in the direction it is facing
then use pathfinder goals
I've found this but it's for 1.13.2
public void moveToLoc(Entity en, Location loc){
EntityCreature cr=((EntityCreature) ((CraftEntity) en).getHandle());
cr.getNavigation().a(loc.getX(), loc.getY(), loc.getZ(), 1);
}
or maybe its possible to make an invisible entity then make it the target of the mob
not sure if that is worth trying
yeah that does nothing
i have three arraylists, how would i merge them into one arraylist or something of the same purpose
public transient ArrayList<ItemStack> menuitems = new ArrayList<>();
public transient ArrayList<Integer> menupositions = new ArrayList<>();
public transient ArrayList<String> menunames = new ArrayList<>();
I think its pathfinder goals have to defined
in its constructor
but idk how to do that
make your own class
I assume you wanna make a Menu class
I've had issues with goals and paper before, although I was using NMS
this is in the class
i need to merge these three arrays somehow
since they output to json
On Spigot my mob did everything right. On Paper he kinda just stood there with a blank stare 🧍♂️
make your own class
@EventHandler
public void onLeftCLick(PlayerInteractEvent e) {
if (e.getAction() == Action.LEFT_CLICK_AIR){
if (e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getDisplayName().equalsIgnoreCase("§6Gyrokinetic Wand")){
new GyrokineticStorm(e.getPlayer()).play();```
How do i addnull check in this?
basically make a class Menu
.getName(), .getPosition(), .getItem()
then an arraylist of that class
honestly idek what u wanna do
what
anyways you shouldnt check items by names
that was the easiest way i could find soo yeaa..
this is just to mess around with friends soo no need to make it too fancy
but i need to make a null check if held item aint null bcz if its null it spams console
What's null
then do it
probably getItemInMainHand or getItemMeta
he knows how to get that
in his code
Or do it the other way ;)
if(item == null) return;
thats what i usually do ^
Yeah but he has to know what's going to be null
oo thx
If you just check a random thing that can't be null that's not very helpful
Nevermind lol
i can use if(item == null) return; this right
yes
Hi guys! I have a problem
Basically i want to have a variable named Health which can go up to Integer.MAX_VALUE and i want it to be my max health. But there is a catch: I don't want to have 500+ hearts. I want it to cap at 20 hearts maximum. How can i do this?
its a very neat way ty
setHealthScale() probably something with that
or you could store the health somewhere else
is streaming and filtering Bukkit.getOnlinePlayers less efficient than looping over them and checking with an if?
ty! it worked perfectly
did it actually
i think yes
i want to have these three arrays in a .json file
but since gson can't understand itemstacks, i have to deserialize menuitems seperately
so
" if you have a small list; for loops perform better, if you have a huge list; a parallel stream will perform better. ... So although the difference is not that big, for loops win by pure performance. That being said; performance is not the only important metric to measure your code by"
i cant make a class
wait, now there is another problem. my hp in general caps at 520 even if i have more than that
the scale, or the actual health
I am not spanish or whatever that language is
either way
just make your own health system
that is my own health system
although it will interfere with other plugins but whatever
and thats not spanish
o alr
basically i wasn't setting the max health so it stayed to the one i had before testing this
null check is only working with items not with empty hand should i add a air check too?
The game crashed whilst unexpected error
Error: java.lang.NullPointerException: Cannot read field "A" because "☃" is null
Codice di uscita: -1
what the hell is this
Hey
I'm trying to spawn a custom zombie using nms
it works
but the zombie just stands still
even though I haven't removed any of its goals
or targets
Is there any reason for this?
https://pastebin.com/x4bssZPW
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
CustomZombie.java
CustomZombie.EntityTypes.spawnEntity(zombie, new Location(p.getLocation().getWorld(), p.getLocation().getX() + 2, p.getLocation().getY(), p.getLocation().getZ()));```
where it is spawned
Hey, I am currently having a problem many people in forums had, but I couldn't find any helpful answer. It's about world generation and how to just modify the existing world generator and not setting up a new one. In my case, I want to replace every generating block in a chunk so that every chunk consists of a random block. All the forum answers were rather confusing for me, so it would be great if someone can help me, maybe in DMs or so.
Does it do anything if you hit it
nope
no kb
but it takes damage
so you can kill it
been stuck on this for like 4 hours
Hmm weird, I have no idea. If you were using 1.18 I could help you more but... 😟
Well for one, 1.18 has mojmaps so it's not obfuscated.
Probably no one in here, afaik all the active helpers in here don't support 1.8.
Most the people asking questions are on 1.8
Or, most people who support 1.8 are asking questions, not answering them.
Generally if you're going to support 1.8 you're kinda on your own.
Your best bet is to find also outdated forum threads then
that doesn't stand still
yeah no luck with that
Yikes, well I'm not sure what's wrong with what you're doing tbh.
can i ask spigot questions here?
I don't know can you?
i dont know thats why i ask
Read the channel description
ok thanks
am trying to code in 1.8.8 i downloaded buildtools and ran it with git bash, i restarted intellij but i still cant change the version in pom
?paste the not working pom you're trying to use
1.8 nms scares me
like the code?
did u specify the version
well yeah no one uses 1.8 anymore
no reason to
if someone uses it its "fOr pVp"
1.8 nms also is stinky
ok
yeah
are u using mave or gradle
maven
show me ur dependency
why?
to see if u wrote it correctly
I love the why?
Then you save it and send the url
yes so replace spigot-api w just spigot
and replace the version w 1.8.8-R0.1-SNAPSHOT
ok
oh that works
thanks
but its wierd in tutorials its spigot-api and it works but yeah
spigot-api includes org.spigotmc and org.bukkit
spigot includes those w nms and craftbukkit
oh
do you use Minecraft developer plugin?
Yes
doesnt give u nms
wierd
Wasn't talking NMS
yeah i know he wanted nms tho
1.8.8 NMS 🤢
1.8.8 🤢
1.8 🤢
old legacy versions 🤢
java makes me rage quit
Then get better, scrub
no
Fair enough
L
Oracle SQL makes me rage
Honestly same
https://paste.md-5.net/dicopaduno.bash this error says my array is null when i have added stuff to it ;/
the class: https://paste.md-5.net/yukocusapo.java
yeah im going back to haxe after im done with my plugin
same
The heck is haxe
No mercy
looking to hire a java programmer to rewrite an old plugin for 1.16.5
its a fairly complex world gen plugin called
Cityworld.
ty
no ai is nice kekw
Question, would it be possible to use packets to create "sharding", where players build in the same location, though blocks appear visible only to them (client-sided) as packets are sent to them only? Minimalizing server resource usage
is there a way to cache packets in a player? i mean
i cache the packets inside their files/memory, and then instead of keep resending the same packets in cycle, i just tell them to use packet n°3 then n°4 then n°5 then back to n°1 in a loop
its for animated stuff, no i won't be using texture packs/data packs, right now the packets are cached on the server and i keep sending them to the player in a loop, instead i thought it would be better if i send them only once and tell them "switch to this packet for this, or to that packet"
poor zombie
is anyone here familiar with 1.8.8 NMS?
?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!
Should I learn more java that I get to a fairly advanced level or do I learn another language
the only other language I might learn is Rust
other than Rust maybe C#
Depends on your goals
make ?dataja or edit ?ask to https://dontasktoask.com/ ngl
Rust is a very cool language and definitely worth learning if you ask me
My main goal is to progress as a developer
that might be too general
Try a new language but I think it's good to have at least one language you could consider yourself an expert in
For interviews you will usually be able to pick a language to work in
how much time of experience is an expert
Having a language you know like the back of your own hand is extremely valuable for interviews
I've been doing Java for about 8 years and I feel very confident in my skills
damn 8 years
Where the actual line of "expert" is is hard to say
Yeah this is possible.
But I could write code to do most things without the help of an IDE, without looking up how to do any of it
I don't have any other language I'm that good with
So I always interview in java
And it's been really useful
caching packets into player memory?
My friend knows a lot of languages, definitely a lot more than me, but he's not really an expert of any of them so he struggles a bit more in interviews
It's not even so much about skill as it is just familiarity
I guess I know his answer to "Would you rather be an expert in one language or know a bunch of languages"
Knowing the standard library off the top of your head makes a huge difference
You should always be a bit of both
I can use a lot of languages but I'm far better with Java than any other
ic
I am a Java expert, with a good amount of Kotlin knowledge, and I know a lot of langs but am not a big fan of/am not good at them.
ok then ill focus on java
tbh i find java perfect eitherway
it might not be as fast but its fine
I don't, I'm just good at it.
i find java organized
It's pretty simple, fast, has good naming conventions, streams are really nice
but it's not really good to make good looking applications with though
Rust is probably the most immaculately designed language I have ever seen but it's hard to write
I find the problems with Java stem from verbosity
How do people make really cool looking apps btw
I think even an expert in rust could have difficulty writing code that will compile and work the first try
is there some markup language for apps or smth
It's become a lot less verbose lately
Fxml?
otherwise how do people make cool looking apps
okay makes sense
is javafx
the only good way
to make java apps
Not within it's object hierarchies.
Also yeah basically "good looking" Java apps come down to:
- Requiring an extensive knowledge of Swing
- Using JavaFX
I never really had a problem with those
You can usually keep hierarchies relatively simple
I mean
Not when you have 2 modules
One API and one impl
And they sorta
mirror each other
Which is a very common pattern from what I've seen :p
It's unmaintainable.
I always encourage people to write a JSON parser
is there a reason why json is better than YML
It's a good intermediate project that teaches you about a lot of good concepts
And I mean that's not the only problem I have with Java.
You have this situation where you need a factory class because using constructors doesn't give you enough power.
But y'know a factory per class is obnoxious, so static factory methods, although not everyone agrees on using them.
Yml is much more annoying to parse
(Also sometimes your factories need to store a bit of state)
(And people will scream static abuse)
sounds easier than parsing json
Uhh YML is hard to parse because YML is an obnoxiously complicated format
or maybe not
I can express json's entire format in just 11 lines of bnf
Yeah lol ^
You literally cannot represent yaml with bnf
what even is bnf
A format for describing file formats
Backus-Naur Form: It's a grammar that allows you to describe formats/languages.
what
It's a bit like regex but much more powerful
Is YAML context-sensitive?
Oh dear
So yeah BNF is described as a "metasyntax"
Meaning it's syntax for describing syntaxes
i dont get it kekw
Meanwhile here's json
It's typically used by people designing lexers/parsers
Or also by parser generators like ANTLR
It's 13 lines but you can easily get it to 11
oh so do parsers use bnf
It's really simple and gets the job done
