#help-development
1 messages · Page 922 of 1
:)
no clue why I only commented that one method
I gotta actually document and comment shit at some point
I'm having fun with this project
I'm finally getting out of the damn slump which is nice
I barely worked yesterday
gotta do shit
this is true
but it's like 8am and I hate working in the morning
was only going based off the limited code I saw 😛
keep it up and hang around here, you might learn a thing or two
@wet breach I mean this should limit the UUID's to 2 every instansiation
It's like the bracket system if you will, just pairs the players that have joined, I also have yet to handle the case when no player can be matched... I'll have to give them a bye or something like that
That's the point aha
Hello There, There is a problem while launching my own server that is-" -Xmx8G -Xms8G -jar Server.jar 1 nogui
Error: Unable to access jarfile Server.jar"
That's your answer
Unable to access jar
It means your jar file is named incorrectly (in most cases)
No i named it right i guess!
well then #help-server
ok
@echo basalt @lost matrix @wet breach @earnest forum thank you all for the notes ❤️
No idea what i did but ok
.
Oh also I have an idea for the countdown before the match starts, I'll use text displays to make a cool looking countdown in-between the players
is it possible to change the value of a final variable using reflection?
Hello, I am trying to set MongoDB's driver logging level to WARNING but this method does not seem to work anymore. This is what I've tried to far:
MongoDB Sync Driver Version = 5.0.0
Spigot Version = 1.20.4
@Override
public boolean connect() {
ServerApi serverApi = ServerApi.builder()
.version(ServerApiVersion.V1)
.build();
String uri = this.getUri();
MongoClientSettings settings = MongoClientSettings.builder()
.applyConnectionString(new ConnectionString(uri))
.serverApi(serverApi)
.build();
// Changing debugging level for MongoDB Driver
Logger mongoLogger = Logger.getLogger("org.mongodb.driver");
mongoLogger.setLevel(Level.WARNING);
this.mongoClient = MongoClients.create(settings);
this.database = mongoClient.getDatabase(uriBuilder.getDatabase());
try {
Bson command = new BsonDocument("ping", new BsonInt64(1));
Document commandResult = database.runCommand(command);
LoggerUtil.log(
Level.INFO,
LoggerUtil.LogSource.DATABASE,
"Pinged your deployment. You successfully connected to MongoDB!"
);
} catch (MongoException me) {
LoggerUtil.log(
Level.SEVERE,
LoggerUtil.LogSource.DATABASE,
"Error while connecting to MongoDB: " + me.getMessage()
);
return false;
}```
What am I trying to hide?
DB Connection message
[09:24:27 INFO]: [org.mongodb.driver.cluster] Adding discovered server *** to client view of cluster
[09:24:27 INFO]: [org.mongodb.driver.client] MongoClient with metadata {"application": {"name": "WidenCoins"}, "driver": {"name": "mongo-java-driver|sync", "versio...```
?
you can't change a final field without egregious hacks
?paste
mustve been static final fields then
doesn't work either
not even the hacks work for static finals if the compiler inlines it as a constant
*Not anymore
Pre java 11 this was still quite possible
Not for primitives
Yeah true. They get inlined either way.
Ah, the good old times when you could make 1 + 2 = -5
https://codereview.stackexchange.com/questions/123247/corrupting-java-arithmetic-through-reflection
https://pastes.dev/VzZoEdwGg1 can anyone tell me why the dragon is not moving, only the player's attack occurs when approaching and animation
You should not tinker with the pathfinder in the constructor, and you should also not do this shady reflection fkery.
There is a method which is called to initiate the pathfinders, simply override it.
can you store a bytearray list in a fileconfiguration
What for? yml isnt really a format that should be used for serialization honestly.
Its a configuration format, not a persistence one.
should i use json then, if yes what apis do i use
One problem you will encounter here: Generics.
Solution: TypeTokens
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
List<byte[]> list = new ArrayList<>();
String json = gson.toJson(list);
List<byte[]> deserialized = gson.fromJson(json, new TypeToken<List<byte[]>>(){}.getType());
k 👍
should i add craftDragon.getDragonControllerManager().setControllerPhase(DragonControllerPhase.a); or
((CraftEnderDragon) enderDragon.getBukkitEntity()).setPhase(EnderDragon.Phase.CIRCLING);?
and you talking about initPathfinder(); method?
No idea. Old versions are very different from todays.
can I just move it using setposition
You should really not
There are some resources out there that write about pathfinder goals and ai goal selectors.
Hi, how can i get the current item that player have in hand? I've tried getItemInHand and getItemInMainHand but this two method doesn't work. spigot 1.8.8
?1.8
Too old! (Click the link to get the exact time)
This ancient version is highly unsupported.
However: getItemInHand() should work for this very old version.
is deprecated and doesn't get the item in hand
can you make gson use pretty json? so it isn't a nightmare for me to debug something if it isn't being properly saved
Deprecation shouldnt be a concern for you because you are using software from almost a decade ago.
How did you determine if this works or not?
Gson gson = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping();
👍
Can you help me?
I understand what you mean, however, I've already pasted my code
Because this ItemStack itemInHand = p.getInventory().getItemInHand();should understand the item I have in my hand and through this p.getInventory().addItem(itemInHand); he should put it in his inventory but he doesn't
@lost matrix
Show your code pls
ok
have you tried debugging any values
uh i got a tiny tiny problem, each thingi is like 28kb cuz "setPrettyPrinting" is adding a new line for each byte
Try getting the Logger through the slf4j LoggerFactory
is there a way to just turn the byte[] into a string and back to a byte[]
yes use a TextDecoder
Sure, usually you would base64 encode this byte[]
Is the message sent to the player?
why dont you just cancel the event
yes
itemInHand.setAmount(0);
p.getInventory().addItem(itemInHand);
What do you want that to do ?
@lost matrix sorry the message is not send to the player
Well in that case your permission statement is wrong.
And setting the amount to 0 can lead to ghost items in those old minecraft versions.
show the whole event handler
Then you have an exception in your console
nothing
becouse it's bugged
Code doesnt just stop running. If you dont get a message then you either have an exception or the whole codeblock wasnt executed.
Honestly, just cancel the event
Anyways 1.8 is ancient and scuffed, buoo maybe helps you out. Ill pass.
if I delete the event the block in my hand is not placed but disappears from my inventory and when I right click it appears again
I wonder why the permission is "destroy" when you seeminly remove a block the player placed
by default cancelling the event won't do that, you have some code which is bugging the item
becouse it's same for destroy and place
so.. change the name to "modify" at least
wait i try
don't confuse ppl
Almost forgot:
byte[] data = ...;
String encoded = Base64.getEncoder().encodeToString(data);
byte[] decoded = Base64.getDecoder().decode(encoded);
I'm stupid there were definitely some lines that interfered with the setCancelled method before, now it works thanks for everything ahaha
Do they actually need it in b64?
cuz else u could just use getBytes and String#new(byte[])
Myeah but random byte[] sometimes produce horrible stuff like unescaped " and EOF.
If it came from a String then its fine, otherwise it might be risky.
yea, ofc you’d presuppose the source is trusted
but that’s somewhat same if u opt w b64 on a basic level 😅
Its less about trust and more about murphys law. Imagine serializing a POJO with java serialization api
and it produces some unthinkable byte[] which explodes your json when put into a String.

Just random garbage in byte[] is weird sometimes
Eh I mean you can apply “it will go wrong if it can” to b64 no? Like all I’m saying is that it might not be necessary to do that type of conversion, if u really just need it in bytes, use the string alr built-in methods for it, which btw uses a charset iirc
Then again the java serialization api is kinda meh
Not the best example but yea
turning strings into b64 is handy if you are putting them in the DB
especially if you are accepting all kinds of characters or there isn't like restrictions
back
Ugh, im so undecided on the combat system im currently writing.
For example bows: Should i keep the minecraft bowstring pull or should i create a custom one?
I wouldnt know how to increase the drawback in a clean way for the vanilla bow system...
is 4kb reasonable per thing? there can be like 50 or 60 of that thing but def not more
1MB per "thing" would be reasonable if you only have 50 or 60 of them. Could as well load them all into memory then.
might be possible with shaders
Assuming u use a resource pack ^^
would save a lot of processing to keep in mem
Im learning how to write some opengl rn actually 🙂
Oo, oddly handy rn :^)
Same
Its not as hard to get into as i thought. As long as you keep it basic.
But i always forget what attribute, uniform and variyng is...
Well im not starting with hlsl if thats what you mean
Ah you mean the in and out replacements
well attribute is in and varying is out if my guide is correct
Aaand its broken...
one more thing, how do i instantiate an object without calling its constructor (if thats possible)? people say 'Unsafe' but just from the name it doesnt feel very safe
You cant. Literally the only way is by using unsafe allocations.
do i use it then?
Do you absolutely need to?
you could just avoid openGL and just straight interact with openCL can't say it will be easier though
so uh
basically
well
idk how to explain this, i'm trying to make a pet creator plugin, it uses "activators" which are exactly like code blocks, some "activators" like conditional and repeat can have an activator inside an activator aka a map inside a map and can be a map inside a map inside a map which would be very complicated to save without serialization
also pet objects can only have 1 that exists
Just... throw the pet into Gson.
how do i just "throw" the pet into gson
Pet someComplicatedPet = ...;
String json = gson.toJson(someComplicatedPet);
// Or if you have a map of pets
Map<UUID, Pet> petMap = ...;
String json = gson.toJson(petMap);
oh-
to jon snow
I love me some json
when the server stops sometimes it's to slow to save the pets so it just throws
java.lang.NoClassDefFoundError: missing/plugins/executablepets/pets/Pet
at missing.plugins.executablepets.ExecutablePets.onDisable(ExecutablePets.java:55) ~[ExecutablePets-1.0.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:290) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.disablePlugin(PaperPluginInstanceManager.java:223) ~[paper-1.20.4.jar:git-Paper-430]
at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.disablePlugins(PaperPluginInstanceManager.java:147) ~[paper-1.20.4.jar:git-Paper-430]
at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.clearPlugins(PaperPluginInstanceManager.java:153) ~[paper-1.20.4.jar:git-Paper-430]
at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.clearPlugins(PaperPluginManagerImpl.java:97) ~[paper-1.20.4.jar:git-Paper-430]
at org.bukkit.plugin.SimplePluginManager.clearPlugins(SimplePluginManager.java:594) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]```
what do i do?
(Pet is loaded correctly)
and your saving code
https://paste.md-5.net/coconovota.bash
@Override
public void onDisable() {
Pet.cancelTasks();
for (Player player : Bukkit.getOnlinePlayers()) {
playerManager.removePlayer(player);
}
storage.set("global.pets", getPetManager().getPets());
saveStorage();
}```
that snippet gives no context
whats in saveStorage and storage.set
private final Gson gson;
private final File storageFile;
public Storage(ExecutablePets instance) {
this.data = new HashMap<>();
this.gson = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();;
this.storageFile = new File(instance.getDataFolder(), "storage.json");
try {
this.load();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public void set(String path, Object obj) {
data.put(path, obj);
}```
``` public void save() throws IOException {
try (Writer writer = new FileWriter(storageFile)) {
gson.toJson(data, writer);
}
}```
``` public void saveStorage() {
try {
storage.save();
} catch (IOException e) {
throw new RuntimeException();
}
}```
sometimes it throws it and sometimes it doesnt
I see some async stuff there so just try to not do something async ?
Bukkit.getScheduler().cancelTask(taskId);
tasks.remove(taskId);
}``` this is cancelTasks, all tasks are sync so im not sure what's async in the code
should i put the code in synchronized ()
synchronized sucks imo
What error dou get?
check paste
yeah to test quickly
Might be the reason
wouldn't it be abit disappointing if someone loses all the pets and the player pets due to reloading? especially that this isn't a private plugin
why?
One factor is gson
Not sure what u’ do w gson, but maybe u force it to look up classes reflectively for u
In which it maybe fucks things up foru
I tend to avoid gson serialisation in most cases, it’s pretty slow. You might benefit from manually scraping your classes and writing to a json object
^ in any case its fairly advantageous to write custom type adapters for all ur types
When in the environment of spigot
Configurate ❤️
with jackson as backend?
yeah if you want json
i'm not sure if i left some parts of my old serialization, but yeah my old serialization used some reflection but then i switched to gson's serialization, i'll look in the code again rn
i didn't know that so i made my own but then 7smile guy told me gson has serialization
well more so, it may take a reflective approach which if u do classloading can mess things up
oh
and spigot precisely do load and unload classes more or less
Past bedtime for me my bad lmao
i can prob make my serialization system not use reflection if that'd make it better
pass type adapters to gson
alright
This
Yeah using a type adapter can avoid reflection completely
how tho?
It tells gson how to serialize the object without gson having to use reflection to find the variabls
This is why we make adapters 💪
like this .registerTypeAdapter(Pet.class, new PetTypeAdapter())?
Yes
👍
If your dealing with interfaces and inheritance chains check out the hierarchical adapter too
the only thing im having trouble with is deserialization rn
List<?> list = getList(path);
List<T> deserializedList = new ArrayList<>();
if (list == null)
return null;
for (Object o : list) {
try {
T deserialized = gson.fromJson((String) o, clazz);
deserializedList.add(deserialized);
} catch (JsonSyntaxException e) {
return null;
}
}
return deserializedList;
}```
``` private void loadPets() {
if (storage.contains("global.pets")) {
for (Pet pet : storage.getDeserializedList("global.pets", Pet.class)) {
getPetManager().addPet(pet);
}
}
}```
it's saving properly tho
at missing.plugins.executablepets.pets.PetManager.addPet(PetManager.java:30) ~[ExecutablePets-1.0.jar:?]
at missing.plugins.executablepets.ExecutablePets.loadPets(ExecutablePets.java:95) ~[ExecutablePets-1.0.jar:?]
at org.bukkit.craftbukkit.v1_20_R3.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.20.4.jar:git-Paper-430]
at org.bukkit.craftbukkit.v1_20_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:482) ~[paper-1.20.4.jar:git-Paper-430]```
prob a formatting issue
Best way to learn development
soo
it isn't null
and the json is correct?
"pets": [
"stuff here"
]
}```
JSONLint is the free online validator, json formatter, and json beautifier tool for JSON, a lightweight data-interchange format. You can format json, validate json, with a quick and easy copy+paste.
JSON is valid!
the json you sent isn't valid for me unless you put it in a { }
?paste
thats not the full json
I used build tools to use NMS, but can't import anything related to it. why??
compileOnly "org.spigotmc:spigot:1.20.4-R0.1-SNAPSHOT"
How can I create a menu where there are two toggle items and when you call up the menu again the buttons are still the same as previously set?
menu library, make both menus have an instance of each other
im not experieinced with it but in maven you need to change the artifactID from spigot-api to spigot
(take with grain of salt i could be pulling from my ass rn)
they did
But I will a toggle button
holy shit i'm dying I need some sleep
you want a menu with 2 buttons and when you click a button it opens another menu with a button to get to the old menu back right?
smh
literally making the adapter always return a valid pet is still returning null when i try to deserialize
how do i make the type adapter's deserialization work
.setPrettyPrinting()
.disableHtmlEscaping()
.registerTypeAdapter(Pet.class, new PetTypeAdapter())
.create();```
loading code here
But I will save it the properties
@echo basalt are entities still memory leaks? or did they fix it? (your good habit post)
they're still leaks
do they save the world in them?
they save the whole entity and the world
why are you concerned ab this just store uuids
so basically like locations back in the days
they store the nms world
im not concerned i need the player object tho, prob just gonna get it always with bukkit.getplayer
yes
public class MyCustomMenu extends Menu {
private MyCustomMenu2 myCustomMenu2;
private Player player;
public MyCustomMenu(Player player, MyCustomMenu2) {
this.myCustomMenu2 = myCustomMenu2;
this.player = player;
}
public int getSize() {
return 54;
}
public void handleClick(InventoryClickEvent e) {
if (e.getRawSlot() == 0) {
myCustomMenu2.open();
}
}
public void setMenuItems() {
inventory.setItem(0, new ItemStack(Material.BUTTON));
}
}```
same with MyCustomMenu2 but change all 'MyCustomMenu2' with 'MyCustomMenu'
is that what you want?
that is one raw menu util
yo does someone know what kinda api i need to use to create and delete worlds on runtime?
on a server
deleting worlds at runtime is a bit janky
multiverse core
oh my god im so dumb
which intellij settings does this stuff to me?
but you can give it a try
Does what?
click anywhere
How am I supposed to know
didnt help
its intellij maybe some1 knows
Few know IJ beyond "clear caches and restart"
no way it's eclipse
restart worked
Although to be honest I am not a real eclipse power-user either, I barely know how to make my own eclipse plugins
Intellij does have some good documentation
Eclipses docs are like 15-20 years old by now
It really is something from a different era in style and everything
.
@mighty gazelle
No I will save that when a player click on a item then save the probetie to the player e.g. a button and than a grass block @dawn flower
that's really cool isn't it
Tbh it's because you don't really need to. It's so bloated with features but imo it's the best java IDE still.
I don't even use the IJ keybinds lol. Eclipse keybinds >>>>>
it has decent tab completion, that's all I need
I hated vs code so much for this one single simple reason: it didn't tell me the options I have
It does? Maybe you had a shit setup. The main issue I had with VSC and java is it was slower than intellij and it would crash if your classes got massive
no idea tbh, as soon as I started coding in java I switched to IJ because of how much more convenient it was than vsc
It was a pain but one day I sat down and spent like 5 hours converting all my VSC settings to intellij and holy fuck was It worth it
Only initial issue with intellij is the unused method stuff which is beyond brain dead to have enabled lol
Its like yeah no shit it's unused it's API or a library etc
damn I feel that
Dayun blood just go ghost ping
whats so suspicious about this call?
java.sql.SQLException: No value specified for parameter 1
How is this possible? Happened only on some servers with MySQL.
Here is the code:
this.saveQuery = "INSERT INTO " + this.databaseManager.getUsersTable() + " (uuid, data) VALUES (?, ?) ON DUPLICATE KEY UPDATE data = VALUES(data)";
Connection connection = null;
PreparedStatement preparedStatement = null;
try
{
connection = this.databaseManager.getConnection();
preparedStatement = connection.prepareStatement(this.saveQuery);
preparedStatement.setString(1, this.uuid);
String data = GsonUtils.getGson().toJson(this.dataSave);
preparedStatement.setString(2, data);
preparedStatement.executeUpdate();
}
catch (SQLException sqlException)
{
sqlException.printStackTrace();
}
finally
{
this.databaseManager.close(connection, preparedStatement, null);
}```
Anyone SQL expert?
getPlayers() prob returns Set<UUID> not Set<Player>
I'm going to guess that uuid is null
Nope, if is null throw other error. And same jar work on most servers, not work only on 2 servers.
Hello how come p.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(message)); doesn't work and gives this error ? https://paste.md-5.net/wixumakupu.bash
you are using bungeecord api on a spigot server
bungeecord is just a proxy and has nothing to do with spigot, your spigot server doesnt support bungee methods and bungee does not support your spigot methods
therefore how i can send an actionbar??
what r u even doing?
(trying to achieve)?
@smoky adder just use the spigot player.sendActionbar and not th e bungee one
I tried various methods to send an action bar but I couldn't, I tried to import IChatBaseComponent but it won't let me do it https://paste.md-5.net/miveqibaqi.cpp i create a function
it is nms' Component
that new method will fail in the exact same way on an ancient server like 1.8
i use a spigot 1.8.8
you'll have to use nms or some odd library that handles it for you
yes
ancient
?1.8
Too old! (Click the link to get the exact time)
yes i know ahah
you'd have to send the packet manually or use a library for it
how, can I do it?
I tried to do it with packages but it doesn't let me import IChatBaseComponent
thanks
I am getting this error when compiling
Unsupported class file major version 63
Here's my pom.xml file. Anyone has any idea on how to fix?
?paste
Update the shade plugin
to what version?
Still giving me the error
I'd go through and make sure the other plugins are up to date too
if I remove this
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>1.2.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:1.20.4-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:1.20.4-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
<srgIn>org.spigotmc:minecraft-server:1.20.4-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:1.20.4-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>
it compiles
I would encourage you to try gradle at some point
Gradle 💀
Its more widely supported and there are some really neat plugins
Use Java 17 then
Its more widely supported
Not really
one sec lemme download
Also the shadow plugin is unoffical and looking for new maintainers
You can laugh all you want but after experimenting with maven and gradle for a fair amount of years, I can safely say Gradle is definitely more dominant in it’s functionality
love how people fight over which one is better
which is both a pro and a con
With an added bonus of being able to quickly script more functionality into the build steps, rather than having to make a “Mojo”
Its very good at breaking if you don’t read the documentation properly
I agree the docs kinda suck
But you will quickly find disclaimers and best practices which address the issues
Thats expected if you’re using incubating features
Or one of your plugins thereof
Its a race to update but definitely worth it
In my opinion and experience anyways
Nope still giving the error
Changed in pom.xml and project settings
Same error?
There should be some sort of property where you specify the source and target versions
Unsupported class file major version 63
Wait why are you compiling with Java 19
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
</properties>
I believe
Wym I don't recall installing it
The jdk wont matter unless hes using newer features
not for the error
Whats your jdk in the ide settings and how did you set it in your pom.xml?
that's what the target flag is for
although should be using the release flag instead
https://pastebin.com/nU8uPzaC pom.xml
Im suspecting that he is pulling a dependency with class file versions of 63
I have both 21 and 17 installed but none of them works
It started doing this when I added the plugin part for the mojang remapped
This one
The error is the JRE
Not the JDK
the runtime hes using is older than the compiler’s target version
The jdk has no effect as thats just to link the symbols together so you can actually write java code using a standard library
Still doesn't change what I said?
You don't want to be using it since it's out of support
Stay on an lts version
This could be the case
You said not for the error here
And its unrelated to the error
Lol
It think I know what im saying
This could also be the issue
Thank you for your reply. What should I do next?
I can't set a level using slf4j's logger
But the thing is my project uses JDA, so what do I do now?
All I was trying to say is that you shouldn't be using JDK/JRE 19
mm
not sure how this ended up in an argument
Next time try the -verbose:class flag
To get a better idea on which specific class is the issue
Dont tell me what to do. You are just an olive. Ill write my plugins with jdk 19 from now on.
LOL
Wait I'm using java 19?
Nope
If you had, there wouldnt be this error
and i guess that was the dependency i was using which is jda... is there a way of making jda work? cause my plugin also hosts a discord bot
Make sure you depend on the latest version of JDA
I don't think they are building with Java 19
Hm JDA shouldnt require java 19 tbh
I'm sorry for the repetition, 7smile7. Unfortunately, I'm quite pressed for time. Could you please help me with changing the logging level to WARNING in MongoDB Driver Sync 5.0.0? Do you have any idea?
Myeah, try setting the log level via a system property.
Then why doesn't it compile if I use JDA?
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>5.0.0-beta.20</version>
<exclusions>
<exclusion>
<groupId>club.minnced</groupId>
<artifactId>opus-java</artifactId>
</exclusion>
</exclusions>
</dependency>
if I add this it gives that error
Unsupported class file major version 63
Could you send me a guide on how to implement api well? I can't import bountifulapi
Could be a dependency within jda
Check the dependency tree
Is that your api?
just tried
System.setProperty("system.property.com.mongodb.level", "SEVERE");
It didn't work
it's not mine
And using Logger.getLogger("org.mongodb.driver").setLevel(Level.WARNING); doesnt work anymore?
Unfortunately, no
Hello! I would like to make a bossbar that can countdown. I want it to countdown from 6 minutes each time and the countdown will start with /startclock, players can pause it with pause, and can resume it with /resumeclock. Another command that I would like to add would be "/final" which would set the text above the bossbar to "Final" and set the bossbar value to 0.
I would like the time to also be displayed like this: minutes: 9:30 :seconds
I am fairly new to Java and I don't know much about bossbars.
All help is appreciated. Thanks!
how do i get the attacker, this doesn't seem to be working, and the ignoreCancelled = true means to ignore the event if its cancelled, right? ```java
@EventHandler(ignoreCancelled = true)
public void onDamage(EntityDamageEvent e) {
if (e.getEntity() instanceof Player) {
Player player = (Player) e.getEntity();
Common.tell(player, "&3You damaged this guy !!!");
}
}```
Implement, then come back
PS: If you are new to Java then you need to start with something simpler.
And its very important that you learn the basics first.
- Use the
EntityDamageByEntityEvent - Yes
alr thats done
Yes
alr thx
Show me your code
currently learning java
Because its not
package me.casualspeedruner.americanfootballpaper.otherutil;
public class bossbar {
public void setCooldown(String key, long duration) {
}
public long getRemainingTime(String key) {
}
public void removeCooldown(String key) {
}
public void pauseCooldown(String key) {
}
public void resumeCooldown(String key) {
}
}
Implement this class. If you cant: Start with something simpler
not much help but thanks ig
ik
Its literally the best help you can get. You need to learn the basics or else you will be asking others to write the code for you
in the next 3 years without learning much.
Hi! Is there maybe a event that i called when someone take items to their inventory? I mean when someone take a sword from chest to their inventory and then event calls
ik i just need some help with this rn. im still taking a java course
InventoryClickEvent
Basically, when you go to school first time, they teach you then let you solve, not start solving for you
Feel free to ask about specific problems or general approaches 👍
We will help you
but this also calls when i click item in chest
yes
check if name inventory or metadata of player is that gui or set
you can figure out if the item goes from the player inv into the chest or the otherway around with the info provided in that inv
how?
public interface Event {
void matchSpawnLocation(Location location);
void startMinigame(ChatMiniGames chatMiniGames);
void stopMinigame();
List<UUID> getCurrentPlayers();
void join(UUID player);
void leave(UUID player);
boolean isFull();
boolean isActive();
boolean isMinimumPlayers();
}```
Is there anything else I should add? (minigames interface btw)
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/inventory/InventoryClickEvent.html#getClickedInventory() this should return the chest inventory if they clicked in the chest and the player ivnentory if they clicked in their own inv
if i want to like save a true value to player when he damages someone, should i use a pdc or metadata or smth else
and then chceck inventory type?
Often minigames need to have custom listeners and might need to be ticked.
But this would require quite a complicated setup.
well
There's a reason I'm passing my main class to startMinigame
@Override
public void startMinigame(ChatMiniGames chatMiniGames) {
if (!(!isActive() && isMinimumPlayers())) return;
isEventActive = true;
pairPlayersForMatches();
for (MatchPlayers match : matches) {
notifyPlayersAboutMatch(match);
new BukkitRunnable() {
@Override
public void run() {
isMatchActive = true;
for (UUID player : players){
Bukkit.getPlayer(player).teleport(matchSpawnLocation);
}
UUID player1 = match.getPlayer1UUID();
UUID player2 = match.getPlayer2UUID();
if (Math.random() < 0.5) {
handleMatchResult(player1, player2); // Player 1 wins
} else {
handleMatchResult(player2, player1); // Player 2 wins
}
}
}.runTaskTimer(chatMiniGames.getInstance(), 0, 1);
}
}```
This was sorta the system I was gonna use for the minigames
Hmm, but this means you need to manually stop all tasks and unregister listeners in your stopMinigame() method...
It's only like 10% written rn...
Hmm that does sound like an issue
Usually you wouldnt want this as an implementation detail because every minigame will have to register and unregister listeners and start/stop tasks.
And if every minigame has it, then there should be an abstracter way of handling this instead of your implementation.
does anyone know how to show the number of online VIP players in your tab list?
What is a VIP player to you?
it's a rank
And you want to give players a prefix programmatically based on their "rank"?
i just want to show how many vip players are online in the tab box
public enum MinigameType {
PARKOUR("Parkour minigame", Difficulty.PEACEFUL, 16, 2),
SPLEEF("Spleef minigame", Difficulty.PEACEFUL, 16, 2),
SUMO("Sumo minigame", Difficulty.PEACEFUL, 16, 2),
TNT_RUN("TNT Run minigame", Difficulty.PEACEFUL, 16, 2);
private final String displayName;
private final Difficulty difficulty;
private int maxPlayers;
private int minimumPlayers;
MinigameType(String displayName, Difficulty difficulty, int maxPlayers, int minimumPlayers) {
this.displayName = displayName;
this.difficulty = difficulty;
this.maxPlayers = maxPlayers;
this.minimumPlayers = minimumPlayers;
}
public int getMinimumPlayers(){
return this.minimumPlayers;
}
public int getMaxPlayers(){
return this.maxPlayers;
}
public String getDisplayName() {
return this.displayName;
}
public Difficulty getDifficulty() {
return this.difficulty;
}
public void setMinPlayers(int minimumPlayers){
if (!(minimumPlayers <= maxPlayers)) return;
this.minimumPlayers = minimumPlayers;
}
public void setMaxPlayers(int maxPlayers){
this.maxPlayers = maxPlayers;
}
}```
Well I guess that's also the reason I have this enum, it's main purpose is to a: make the gamemodes a bit configurable and b: support system for my implantation ie: directing the listener to whatever minigame needs to be listened to
You can use the header or footer for this.
Player has a method for setting the header and footer.
Well what is the more specific issue you're facing? Do you know how to add something to the tab, do you know how to get the amount of online vip players
Thats not a tab box this is a scoreboard.
Are you programming a plugin?
ahh yeah i didn't realize it's called scoreboard
yeah im editing the config.yml file
for TAB
scoreboard-1.20.3+:
title: <#f678ff>Ricecakes Minecraft</#c778ff>
display-condition: '%player-version-id%>=765'
lines:
- '&7%date%'
- '%animation:MyAnimation1%'
- '&6Online:'
- '* &eOnline&7:||%online%'
- '* &eStaff&7:||%staffonline%'
- '* &evip&7:||%vip%'
- '&6Personal stuff:'
- '* &bPing&7:||%ping%&8ms'
- '* &bWorld&7:||%world%'
- '* &bMoney&7:||$%vault_eco_balance_fixed%'
You have two options:
- Add methods to your interface:
List<Listener> getMinigameListeners();
BukkitRunnable getMinigameTickTask();
Just make sure that the List is immutable and always has the same instances in it.
Then your manager can simply handle the task/listener registrations.
What's option 2?
thanks it is working 😄
Using a custom event bus or delegating the events to your minigames.
Im a bit hesitant because this might be overkill.
Ehm yeah, currently the plan was only 4 games, sumo, spleef, tntrun, and parkour
I'll go with opt 1. then, considering my enum setup, would it be alright to use it in determining which game is currently active?
i want to implement an api on my project
Er well not currently active I suppose, but whichever event needs to be referenced
wait am I supposed to unregister listeners I don't use?
Maybe you should explain more, like, explain what you are doing, what api you wanna implement
Ideally you would never unregister or register new listeners on runtime
Also how concered should I be about running these minigames on different threads?
oh alright
Dont bother. There is very littel you can do async in minecraft.
Ok sounds good
that sucks
compareTo
No operator overloading in Java
That game that got #1 on gamejam:
might add more readability
I wish everyone would use BigDecimal instead of double
idk why vault api is all doubles
it sucks
I have to convert everything before I do anything
They are several hundred times slower than doubles when it comes to arithmetics
what are the comments with @return and @param for, in codes
It's javadoc
It's to describe a function
is it required?
Readability
users preference
well because long time ago ppl didnt know java very well
and precision wasnt a goal directly I reckon
as long as it is eventually precise
additional description of what a function returns and takes
How does a bigdecimal work
like maybe it returns an immutable copy of something
param is do describe params...
conclube would you like to give my start to sumo mini game a review? I'm trying to gather everyone's notes before I make changes
sure :)
?paste
parameters?
what dou want me to review in particular
That's basically the structure for the whole system, it's not just sumo... gonna be 4 minigames total as well as a chat prompt for entries / joining events
Structure and implementation for the most part
But also just any general things that may pop up
there is one anti pattern I think its worth revising in particular
and that is ur mutability in the enum
game?
That looks like some bad web server code
other than that, you might wna consider
- have a separate function initialize() that populates the
minigameEvents, to decouple it - maybe check out the state design pattern
- else I think its good :)
potentially recordify MatchPlayers
but eh
its fine
I honestly dislike using enums now. I very rarely use them anymore. This is an alternative which lets me be more dynamic
if i want to save a true value to player whats best way to do it, pdc or metadata
metadata is cringe. Always use pdc.
ight thanks
i think an enum would be fine there
but like its more when u expose an enum to the api consumer, or use it as a dependency magnet
What if i wanted to create dynamic, temporary attributes on runtime?
well then enum isn't the approach from the beginning
how does this work? looks interesting
I think this is the only enum i have currently
And thats just because i somehow need to serialize an operation
i think it was talked about
but a good approach in general is to abstract over the enum w an interface
so that if u later on wna modify its purpose, its possible
altho u might wna seal the interface and have some restricted class consumers can derive from
How do you make sure 0 at the end, (eg.: 1,40) is kept and not removed
i mean thats not necessary
u're just implementing functionality there
ik i was joking
@worthy yarrow one more thing, whenever u deal with a lot of state, u need to start caring about the notion of ownership
I want to create like a function that returns a String and accepts a BigDecimal and if it's less than 1 it'll return cents in format 00, otherwise if it's more or equal to 1 it'll return 0.00 format. for cents, if it's less than 10, it should return cents, without any zeros, unless if its actually 0
Why not always have the same format
public static void main(String[] args) {
String msg = "Value: %.2f";
float value = 1.4F;
System.out.println(String.format(msg, value));
}
Value: 1,40
Process finished with exit code 0
Wait what?
u have NumberFormat (DecimalFormat, ChoiceFormat and CompactNumberFormat) to work with
and well, Currency also
if u need to get the "currency" symbol or sth
whats better
hi, how can I check with InventoryClickEvent if player took item from his inventory but not move to other or drop (left click this item). This event works the same when player took item out and put item in from chest, I must have two conditionals one from taking out and one from putting inside
I am kind of handling the currency symbol myself by checking if double is less than zero then it's in cents, if value is equal or more than 1 then it's euros
uh sure
I'll post the code in a few minutes.. xd
Will make note of this
the getter was a suggestion from intellij
You are aware that the biggest number you can store in a double with only 2 decimal points taken from the mantissa is about 10 to the power of 300 or ten centillion.
Thats...
100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000....
and more.
second one
ight
The namespacedkey is an immutable constant
I'm not allowing that numbers
so no need for a getter
Im just questioning your BigDecimal choice
Its used if you need incredibly high precisions
???
is it possible to check if the argument for a command is a boolean or not?
or i have to do it manually
If you have exponential scaling in your game and people will eventually only see 43T for their trillions, but you really need those
sweet 50 decimal points of precision, even with very high numbers, then maybe you need BigDecimal.
The main problem with double is that the FP precision is reduced a lot for very big numbers
You should be alble to just check with the operations. Eg if the bottom inv was clicked, and its a shift click, then the player tries to push it to the top inv.
And so on.
Not with the spigot command system. All you get are Strings
No no, it's not even possible to get as much money as this in my server. I've limited it to 50k. Money is quite rare to get and you have to work hard even for a few cents
But I'm using BigDecimal to avoid number overflow because when I had double only, I would always get weird numbers
NaN
Lets see how much precision you got here.
So 50k would mean 5 * 10 ^ 5
One bit goes away for +/-
10 or 11 bits go into the mantissa
You got the impact leading bit and 51 significants left
So you will have at least 12 decimal points for precision. (And thats an generous estimate).
So this would still be fine:
43000.000000000001
That is... a lot of precision imo
But getting some experience with BigDecimals is also fine
Yes
Had to study about mantissa and all of that crap in university I forgot most of it XD
I have to say though, I had java but we never went through the BigDecimal class
which kind of sucks because it's great
no if you type out "on" or "off" into a string in java it will not be a boolean
Boolean.valueOf("on"/"off")?
😿
or should i just use a method to get true and false from the string
you can use valueOf but it'll accept "true" or "false" as an input string
Not sure if it'll work for "1" and "0" I'd have to test but yeah
private Boolean getBoolean(String type) {
if (type.equalsIgnoreCase("on")) {
return true;
}
return false;
}``` i made this
is it efficient
stupid
in that function I can put anything I want, anything else than "on" and it'll be false
return type.equalsIgnoreCase("on") :)
people can only use on/off
i made it like that
you can use off, off123123, offspigotmc, etc.. and it'll be false
can they?
I'm having some problems with this code. It gives me two errors.
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
CraftPlayer cPlayer = (CraftPlayer) player;
ServerPlayer sPlayer = cPlayer.getHandle();
MinecraftServer server = sPlayer.getServer();
ServerLevel level = sPlayer.serverLevel();
GameProfile profile = new GameProfile(UUID.randomUUID(), "Herobrine");
ClientInformation info = ClientInformation.createDefault();
ServerPlayer npc = new ServerPlayer(server, level, profile, info);
PacketContainer playerInfoUpdate = new PacketContainer(PacketType.Play.Server.PLAYER_INFO, npc);
playerInfoUpdate.getPlayerInfoActions().write(0, EnumSet.of(EnumWrappers.PlayerInfoAction.ADD_PLAYER));
playerInfoUpdate.getPlayerInfoDataLists().write(1, Collections.singletonList(new PlayerInfoData(
new WrappedGameProfile(profile.getId(), "Herobrine"),
0,
EnumWrappers.NativeGameMode.CREATIVE,
WrappedChatComponent.fromText("Herobrine")
)));
manager.sendServerPacket(player, playerInfoUpdate);
Caused by: java.lang.IllegalStateException: Unable to set value of field private final java.util.EnumSet net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket.a
Caused by: java.lang.ClassCastException: Cannot cast net.minecraft.server.level.EntityPlayer to net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket
Any idea on how I could fix it? Thanks!
I recommend just using Citizens for your NPCs
Citizens doesn't support offline servers tho, which I use cause some of my friends do not have an account :/
Citizens was so easy to use
It works fine
Couldn't set the skin tho
Well offline mode is for when you're offline
so when you're offline it can't fetch skins
because it's not connecting to the internet
also Minecraft really isn't that expensive
You should get your friends to buy the game
Is it possible to include the skin file in the plugin?
And apply the skin with the file
is there some api that has progress bars or a public method
like [|||||||||||]
with green and gray
It's not hard to make that
You should implement that. Its a good exercise.
i have a code for that but not java, i'll try to convert into java
Don't look at other code
try to figure out the logic yourself
It's a good exercise just like smile said
ok ill just yell at them until they buy the game lol
okay
Yeah the time you spend writing that plugin is worth more then them just buying the game
(or you buying them the game for that matter)
It is
sh
let them figure it out
public static String progressBar(double progress, int length, String filledPrefix, String emptyPrefix, String element) {
}
I got an implementation for this. Lets see your suggestions and ill follow up.
so i get the percentage of that, (length * (progress/[max one, may add])
progress should be between 0.0 and 1.0
You would always map that to a normalized range
You can overload it like this:
public static String progressBar(double current, double max, int length, String filledPrefix, String emptyPrefix, String element) {
return progressBar(current / max, length, filledPrefix, emptyPrefix, element);
}
public static String progressBar(double progress, int length, String filledPrefix, String emptyPrefix, String element) {
...
}
To allow a mapping from 0 to X
But you always normalize it 🙂
Lets see it
What are some good are some good intelliJ plugins for minecraft development?
Light theme
Github copilot if you have it
I think the suggestions are pretty nice sometimes (from what I've seen)
Just the minecraft dev plugin.
can i like vb for (int i = 1; i < (length + 1); { if (i > [precent thing]) { myStringList.add(i, "prefix|"); } else { myStringList.add(i, "prefix|"); } return myStringList.toString(); :)
Hmm. Use a StringBuilder.
but is that good xD

This utilizes the internal optimization of String#repeat
public static String progressBar(double current, double max, int length, String filledPrefix, String emptyPrefix, String element) {
Preconditions.checkArgument(current <= max, "Current must be less or equal to max.");
return progressBar(current / max, length, filledPrefix, emptyPrefix, element);
}
public static String progressBar(double progress, int length, String filledPrefix, String emptyPrefix, String element) {
Preconditions.checkArgument(progress >= 0 && progress <= 1, "Progress must be between [0 ; 1]");
int filled = (int) (progress * length);
int empty = length - filled;
return filledPrefix + element.repeat(filled) + emptyPrefix + element.repeat(empty);
}
Yes like that
Imagine having a max of 10.0 and a current value of 3.74.
The progress bar should have 20 lines in it:
double max = 10.0;
double current = 3.74;
int length = 20;
String filledPrefix = "§a";
String emptyPrefix = "§7";
String element = "█";
String bar = progressBar(current, max, length, filledPrefix, emptyPrefix, element);
Hmm
is this useful tho? 💀
If you dont use a List but a StringBuilder, then its very usable.
Use a StringBuilder and send your attempt.
ok
public static String progressBar(double current, double max, int length, String filledPrefix, String emptyPrefix, String element) {
Preconditions.checkArgument(current <= max, "Current must be less or equal to max.");
return progressBar(current / max, length, filledPrefix, emptyPrefix, element);
}
public static String progressBar(double progress, int length, String filledPrefix, String emptyPrefix, String element) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < (length + 1); i++) {
if (i > progress) {
builder.append(filledPrefix).append(element);
} else {
builder.append(emptyPrefix).append(element);
}
}
return builder.toString();
}```
Btw you can save a ton of if checks, if you simply calculate the amount of filled and the amount of empty elements before looping.
You simply create two loops which add your lines.
i used .append(x + y) but it suggested to use another append
u got string joiner also
i wanted to do that in first place but didn't know how :)
Your String will look like this:
§a█§a█§a█§a█§a█§7█§7█§7█§7█§7█
It will display right, but you can actually reduce the size and compute time quite a bit by creating
§a█████§7█████
Guys is it even possible to update stuff in minecraft faster than a tick happens?
Or only every 50ms
how?
- Calculate number of filled bars
- Calculate number of empty bars
- Add filledPrefix
- For loop: Add # filled bars
- Add emptyPrefix
- For loop: Add # empty bars
ok
so 2 for loops, 1 for filled and another for empty
i tested your example rq, but it shows §7█§a█§a█§a█§a█§a█§a█§a█§a█§a█§a█§a█§a█§a█§a█§a█§a█§a█§a█§a█
and
double max = 10.0;
double current = 10.0;
int length = 20;
String filledPrefix = "§a";
String emptyPrefix = "§7";
String element = "█";
String bar = progressBar(current, max, length, filledPrefix, emptyPrefix, element);
``` i put this
max = current so all should be green
why first is always gray
Show your code
public static String progressBar(double current, double max, int length, String filledPrefix, String emptyPrefix, String element) {
//Preconditions.checkArgument(current <= max, "Current must be less or equal to max.");
return progressBar(current / max, length, filledPrefix, emptyPrefix, element);
}
public static String progressBar(double progress, int length, String filledPrefix, String emptyPrefix, String element) {
StringBuilder builder = new StringBuilder();
for (int i = 1; i < (length + 1); i++) {
if (i > progress) {
builder.append(filledPrefix).append(element);
} else {
builder.append(emptyPrefix).append(element);
}
}
return builder.toString();
}```
Follow these steps pls:
- Calculate number of filled bars
- Calculate number of empty bars
- Add filledPrefix
- For loop: Add # filled bars
- Add emptyPrefix
- For loop: Add # empty bars
Its a problem with your for loop and if statements
i thought of adding to a var if its filled, and add to another if its not and then for loop that times and add
I mean... sure you can do that as well.
But before you do anything: Make sure that progress is a normalized value of 0.0 -> 1.0
but why is that very required
i mean
i used current and max parameters and they work
if its like 5 current it does half of bar
If you dont normalize, then you will have quite confusing calculations that are simply not needed.
Always normalize.
sorry im braindead today, and the i don't get how to normalize it, to make it 0.0 -> 1.0
if i want to have a good structure for mysql user managing :
- create a User entity class with some data ..
- create UserManager with a concurrentMap [caching]
- create DataUserManager [for mysql insert , update , load]
am i right?
idk
what relationship does user manager and data user manager have?
UserManager will load the user from the database from DataUserManger
no?\
Just assume that your method will always get a value from 0.0 to 1.0 passed.
You dont need to normalize it yourself. Just assume that you will get a normalized value.
So that's kind of tricky though, or I'm just stupid. Here's what I want:
Input values are positive doubles.
- if double is less than 1, it should contain only the 2nd part of the string, eg.: 0.50
- if double is less than 0.10, eg.: 0.05, it shouldn't contain 05, but 5.
- if double value is something like 1.50, it shouldn't be 1.5, but should be 1.50, with a zero at the end.
- if double value is exactly the same as int, eg.: 1, 2, 3, 4, etc.., it shouldn't contain the 2nd part of the string, eg.: 1.00, zeros should be removed.
- if double is 0, it shouldn't be something like 0.00, it should be just 0.
I think that's pretty much it, do I have to really manually code this if I want to make it like I described?
but isnt the UserManager responsible for simply caching users?
now u're at the verge of compromising on single responsibility
then how would it load the data from the mysql?
how should i assume that 💀

anyway killer, personally I am extremely against coupling database logic with caching and lookup logic
thanks
thats a big no no for me
You say in your head
"ok. so the value param will be a value between 0.0 and 1.0"
"This is now my assumption. Lets implement the method with this assumption in mind"
Thats how you assume something.
then how are you doing it?
is there a better more advanced system i can make?
as long as it will be a good structured and fast in performance
i know that but my problem is implementing it, i'll think about it later because its 9:25 pm and im quite quite braindead
hit me with your idea xD
well Ill share u some code I wrote the other day as soon as I get home
Alr thanks
Create a so called DAO -> DataAccessObject
It stores nothing.
All it has is:
public Value getData(Key)
public void saveData(Key, Value)
... and some utils you want
This DAO is then used for your DataManager.
The DataManager has a Map<> and simply lets you
ask the DAO for a value and put it into your map and vice versa.
Like described in the guide
Hm? Add more words to those sentences pls. Im not sure what you mean.
like for my situation , i have user class with kills ,deaths and some lobby settings like set day or night for that specfic user [boolean] , and so on ..
i can have :
- loadUser method that return User
- saveUser method [void]
correct?
Sure
so something like this?
yeah sorry , so i can use CompletableFuture ?
with the loading part?
correct?
and i can do this insted?
I mean... myeah. This is fine i guess.
how i can make it better? performance wise , and code sturcutre?
Not much you can do performance wise
You can early return from your map if its already populated
Thats one thing
Exceptions for your CF arent handled. I would not force embed an async call like that.
loadProfile should be sync callable. Same goes for loadUser.
Add a loadUserAsync method which uses the loadUser method async.
like this?
Dont use CompletableFuture in loadProfile
Guys is it even possible to update stuff in minecraft faster than a tick happens?
Or only every 50ms
what i can use insted?
iam not using it anymore :
50ms is 1 tick lol
thats why i ask
Return the user normally. Implement the loadUser method normally. Only use CF in your loadUserAsync method.
is it possible or only every tick?
did that
update what
Well
nothing meaningful can really happen on a shorter interval
minecraft api
Your code isnt just
ok but WHAT
it varies depending on what you're doing
you can send chat messages more than every 50ms
its single threaded except chat?
Your code runs at whatever speed is permissible by your jvm and system
yes
okay does action bar counts as chat too?
no
I believe those can be updated faster
but if you want to find out
?try
?tryitandsee
you can update it at whatever rate you like server-side, the server will still send the packets aligned to its tickrate
not sure about that for action bar
and the client will process it at the same (fixed) tick-rate of 20tps (50ms per tick)
okay
is there a way to dynamically change a methods parameter?
What
Blud
Repeat the question to yourself
😭
You can overload methods
overload?
Sucks in java honestly
Kotlin is so blessed in this regard
have multiple methods with the same name, but different parameters
public int getAge(Dog dog)
public int getAge(House house)
public int getAge(House house, int flatCount)
but i need to enforce this, i have a data pipe and want that the next pipe attached to the pipeline enforces the input to be the others output.
Generics
Well i have the solution forvyou on Kotlin
public boolean get7smile7(Auth authCookie)
In a single line
prove it then i might consider giving kotlin a chance (java is better)
public <IN, OUT> OUT calculate(IN in);
Enjoy
You dont even need to call a method
Or simply take a look at javas functional interfaces. They are designed to be used in streams (or pipelines)
You just append 2 functions or blocks
Where one takes an inpit, and gives an output
And the next takes the input type
And produces another output type etc
Kotlin is noice for scripting or smaller projects for sure.
operator overload my beloved
Yup
my beloved grave
certainly well defined what + does there
won't get weird if both methods yield an integer
🙏
I have the version with comments if you really need it
I explained it pretty well tho
i dont get how this enforces that "in" equals to the last pipe's output that we received?
Its literally just a pipeline without aids
but kotlin is unreadable java is nice and verbose
does anyone know how to use record in java?
Simple solution: Create an infix "together_with"
Then you can have some cool { input: Garbage} together_with { input: Garbage}

It's kinda like a class in kotlin
if only there was a type system that could do this 
If you like exhausting your fingers from typing 20 million extra lines in your lifetime then please go ahead
so you don't litter your syntax with random bs
verbose = boilerplate but it also = readable code
Kotlin can be readable
This is just a gimmick
verbosity is the key to finding your inner piece
rust vibes
I obviously dont use this in production code
I like java
its not a gimmick after looking at your screenshots it got proven again
@lost matrix
Well if you want context, this was a challenge to produce the most unreadable kotlin code possible in a single line
I just had to give next its name because it was confusing me
Heres a good example of good kotlin code
Afaik
Ah, thats a big topic. Try using streams and java functional interfaces a lot. It helps you understand.
Try replacing all your inheritance with composition. Then it will come naturally.
composition > inheritance, but with composition there is no real dependency inversion or is there?
what is a functional interface
Consumer<T> Supplier<T> Function<T, U> BiFunction<T, V, U> BiConsumer... and so on
lambda?
They are coupled. Making an interface functional, qualifies it for usage as a lambda expression.
Oo love those things
Me and my homies HATE lambdas
You and your homies are weird
Lambdas are the best
Lambdas are my life
just Reciever.(Param…) -> Return
Lambdas are forever
Heil the λαmbda
Imagine using MethodHandles
kotlin < java
It kinda is if you think about it
Kotlin is NOT java
Kotlin compiles to jvm bytecode, jvm is JAVA virtual machine
Sure it compiles to the JVM, but it also compiles to multiple other representations
Making it its own separate language
Thats just one of many backends
If you want we can go into verified and ill show you the basics for streams and functional interfaces.
and it is basically nothing like java
sure
Eh, it's still stuck in the same kinda oop hell
oop?
What
Kotlin is functional by drfault
The issue with jvm langs is, as hard as you try, you will always be stuck to some oop-iness
Well yes thats the JVMs fault
Not kotlin’s