#help-development
1 messages ยท Page 569 of 1
then keep a reference of the usermanager on the user class
and delegate the method to the user manager
Exactly that trying to do, but dont know the adecuated pattern
So far i cant use Di because of what i said
dependency injection
But that oblise you whenever create a instance of the user, to pass the user manager instance thats the point im trying to go
I always forget that completable futures exist
same lol I had to google them
Do i explain my point? That DI is not appropiated in this cases, because if you need to create a instance of the object. Then you have to pass him all the instances to your object
no
the user manager should be the one responsible for creating the user instance
on the loadUser method
right, thats true but still not my really point
his point is he doesn't like injecting UserManager to User in order to call user.save()
Is not because i dont want, is because doesnt look a good desig
Thats why im asking which is the more suitale pattern here
injecting the entire plugin and doing all the save logic automatically
save shoudl not be a method of User, it's not that objects job
Because i dont wanna harcod it using a static getter of the main class, like all plugin done
UserManager.save(user)
exactly
verano's just mad that dependency injection has to be done everywhere and singleton uses static
no no im not mad, i never said that. Im just wondering to learn which pattern is better in a specific case
i will use translator to say what i want
Just use DI honestly it's a no brainer
or just do this
The problem is not that I don't want to use Di, the issue is that it is not appropriate for all cases. Since you will not always be able to initialize your object to pass it the instance. That's my point, in those cases you are left adrift (like me), not knowing what pattern to use.
instead of
UserManager <-> User
you just get
UserManager -> User
so Im using a dependency for embeded sqlite database: xml <dependency> <groupId>org.xerial</groupId> <artifactId>sqlite-jdbc</artifactId> <version>3.39.3.0</version> <scope>provided</scope> </dependency>
and when I enable the server on a 1.8.9 server, I get this error: No suitable driver found for jdbc:sqlite:plugins/DeathMatch/database.db, but when I enable this plugin on a newer version like 1.18 I dont get the error and all is fine, why? This is the code: java public static void connect() { connection = null; try { File file = new File("plugins/DeathMatch/database.db"); if (!file.exists()) file.createNewFile(); String url = "jdbc:sqlite:" + file.getPath(); connection = DriverManager.getConnection(url); System.out.println("Baza de date creata"); statement = connection.createStatement(); } catch (SQLException |java.io.IOException e) { System.out.println("EROARE"); e.printStackTrace(); } }
also path is: jdbc:sqlite://<path> if im not wrong
you might need to shade the driver
shade the sqlite
how
you need to initialize it Class.forName
good chance honestly yeah
but then why on a newer mc server version works?
As long as it's logged
p much
my younger self would leave the catch empty. Regret 100
sout("something went wrong")
In my scenario, when creating a new instance of the User entity, it appears to be necessary to pass the DI reference to access the save, update and delete methods. This may indicate a direct dependency between the User entity and the dependency injection system
Thats what im trying to say
yes we understand you
we say: it does not matter aslong as you're happy with an approach
You're telling me that your user class depends on a user manager?
impossible!
then just fuckin put all the responsibility on the user manager and treat your user like a pure raw data class
simple and efficient
Don;t di to User, it's a nightmare pattern
thats why im asking, but they saying and saying use DI, and i want to learn which pattern is better there
If you want you user.save() so much then it's your only way
yep
just store everything in a hashmap
hashmap<UUID, String> names
hashmap<UUID, String> anythingElse
If you can live with the fact that userManager.save(user) is how it works
actually not
didn't know hashmaps outlast power cycles
But you understand what i meant Elgarl right?
im joking fortunately
Treat your user like a data class
put all the io logic on your user manager and move on
That's the best way to do it
just add a method in User
public void save() { UserManager.save(this); }```
static
talking about nightmare patterns
right, making it static the method or by passing a harcode static instance of the UserManager?
Not static
yes static
UserManager shoudl be a Static
disagree
disagree too
true
you must've gotten it through the user manager
so the user manager is always accessible
unless you're passing around events
but you can just DI the manager to the listeners
User shoudl only be a data class
Exactly
In conclusion the issue is that my logic is not well designed, because that must be putten in the manager. To skip all this issue i mentioned before with passing the instance
I could have done that from the start but i prefer to see if was a way
You usually learn this kind of data structures through just pure experience
I don't blame you it's aight
Just see this as a learning moment and move on
Yes i mean you are right, i understand that. I just get frustrated because people treat me as dumb, when i try to explain what i mean in many ways
Hello, how can I show the player's life on his top ?
The first thing you should think about is uhh
"Is it the user's duty to handle its own saving?"
if you are not coding this not the rgiht channel
basically single-responsibility principle
TAB, boss bar, title ..?
for coding 
What method
Scoreboard
scoreboard = on top
not always
like this
this is my class and https://paste.md-5.net/zesohifize.java
this is the error https://paste.md-5.net/kivukowuye.cs
please help me fixing that main class
Think you can do that with scoreboard teams
public void onZombieDeath(EntityDeathEvent event, int zombieLevel) {
if (event.getEntityType() == EntityType.ZOMBIE) {
Zombie zombie = (Zombie) event.getEntity();
int droppedExp = event.getDroppedExp();
double additionalExp = (int) calculateAdditionalExp(zombieLevel);
// Add the additional experience to the dropped experience
event.setDroppedExp((int) (droppedExp + additionalExp));
}
}
private static double calculateAdditionalExp(int zombieLevel) {
double additioanlExp = 3 + (zombieExpAddPerLevel * (zombieLevel - 1));
return additioanlExp;
}```
Can someone help me? Why doesn't this work ^, I want each level to drop more exp
Let's go over it mentally as this is quite basic
Your onEnable() method is your entry point
Oh yes, they do it with teams prefixes and suffixes if im not wrong
how ? any hint/tutorials ? I don't know how to use scoreboard x)
if (scoreboard.getObjective("showHealth") == null)
scoreboard.registerNewObjective("showHealth", Criteria.HEALTH, "\\u2665", RenderType.HEARTS).setDisplaySlot(DisplaySlot.PLAYER_LIST);```
thanks !
how can I register this ? (onPlayerJoin event ?)
When onEnable() is called:
- plugin is null
- conf is null
Then you
- Get a file configuration from your plugin (which is null), which should throw an error
- Assign your
pluginvariable tothis - do whatever else
But i think I already started instance of plugin and conf in main class
๐
You get/create the scoreboard and add the player on join
1 - You can't put 2 or more parameters on event calls
2 - Zombie level is a custom concept that's not present in spigot, so you need to get it yourself
okay thanks
Nope, your variable is null
You assign it after attempting to get the config
you have only declared it at the top, then never assign it until after you try to use it
You can either put that line after assigning the plugin variable
Oh
I found this on Spigot :```java
ScoreboardManager manager = Bukkit.getScoreboardManager();
final Scoreboard board = manager.getNewScoreboard();
final Objective objective = board.registerNewObjective("Belowname", "dummy");
@EventHandler
public void PlayerJoin(PlayerJoinEvent e) {
final Player p = e.getPlayer();
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(Main.plugin, new Runnable() {
public void run() {
ScoreboardManager manager = Bukkit.getScoreboardManager();
final Scoreboard board = manager.getNewScoreboard();
final Objective objective = board.registerNewObjective("Belowname", "dummy");
objective.setDisplaySlot(DisplaySlot.BELOW_NAME);
objective.setDisplayName(ChatColor.RED + "YourBelowName");
}
},0, 20 * 10);
}
}```
or replace plugin.getConfig() with just getConfig() as your plugin is just this
how do i convert a json string to a json object?
JSON.parse(str)
god no
Depends on the language
why ?
a repleating task shoudl not be needed. just set the scorebaord
gson.fromJson(jsonString, JsonObject.class)
okay thanks
scores on a scoreboard will be updated automatically
Isnt it, because if not that will create the health static it wont be updated ?
its only when you want to change what the scoreboard says that you need to reapply it, i think
yeah, if you will displayed his life, you should update the scoreboard
is this good ?```java
ScoreboardManager manager = Bukkit.getScoreboardManager();
final Scoreboard board = manager.getNewScoreboard();
final Objective objective = board.registerNewObjective("Belowname", "dummy");
@EventHandler
public void PlayerJoin(PlayerJoinEvent e) {
if (board.getObjective("Belowname") == null) board.registerNewObjective("Belowname", Criteria.HEALTH, "\\u2665", RenderType.HEARTS).setDisplaySlot(DisplaySlot.PLAYER_LIST);
}```
Best way would be on the damage event to the player, updating it only when the player is damaged. That what hydratate principle is designed and the best one
as far as I remember if you set teh criteria you don; tneed to update. I could be wrong as it's been a while
you need to use the Main scoreboard, or add the player to your new scoreboard
:l I got an order that need to modify minecraft chunk data from its byte
does 250$ worth it?
:l I mean I have to face with this
what do you need to modify
okay thanks
I need to modify the whole bedrock layer to hide coordinate
:l the packet size in display is so dam large that even vs code on my mac m1 crash
I can only assume that those numbers are block id's or something
in which case you just gotta switch some around
and split ๐
god damn, I haven't managed to crash mine yet ๐คฃ .
your db seems offline?
in 5s I got 100mb of packets?
she's not
I can access to it with phpmyadmin
sounds like the kind of stuff I expertise in
do you know why I have this error message
Hello, how can I show mobs health above their heads ?
bros re-asking his question
hello guys i'm wondering something today
how can I like
show health bar?
above
me ? here it's for mobs, not players
okay thanks
how is that performance wise
just wondering
bro my laptop is using 80% of it's memory
its ddr5 too
ddr5 isn't some magical compression algorithm
it's just a packet being sent to the client
it should be faster-ish
Add players to a Team by name, mobs you add by UUID.toString()
InventoryType.PLAYER does this count for like opening a chest to? because the player inventory is shown, or will this only be true if its just the players inventory when they hit E ?
It's for E
i have 4800mhz ram actusally
pc has 3600
my laptop is uhh
5200 I think
bro got a 6k laptop
bruh I paid 4k for mine
rtx 4090 though
paid itself in like a week
Sorry for asking so many questions ๐ Is there an event for when a player is given an item (such as from the /give command)
Nope
Doesn't have to be specifically for the /give command, just when an item is added to a player's inventory
then also no
Welp
you can write your own spigot patch though
to like create an event upon player#addItem
I'd have no idea how to do that lol
seems overengineered
What you trying to check for in particular?
could be xy problem
do you know how to accept the connetion to my database beside local ?
yes how can I accept the external connection
thx
this is usually not what you want though
That's fair. Pretty much, I'm making a 'randomness plugin' which can be turned on and off. One of the random parts of the plugin is that block and entity drops are randomised, and if a player has 'learned' these drops already I want to show them in the item lore. I'm needing to listen to a lot of events to add/remove the lore (remove because I don't want it to be permanent) but one edge-case I haven't covered yet is if a player is given an item by another plugin or by the /give command
yes that's just for a test, thx too for the prevention
aaa i thought JsonObject and JSONObject were the same so i swapped them
and i was wondering why it didnt work
adsljhfbsadfdsapoidshg
block those commands ๐
or write your own
I still want /give to work lol. I suppose I could override it, but that still doesn't cover items given by other plugins
I don't understand why I have this error ...https://pastebin.com/pKuTDGPq
If I could detect items being added to (or removed from for that matter) any inventory, that would be great too, I'd just have to check if a player is viewing the inventory
yeah you could check the inventory every tick
not ideal
but eh
is it a public plugin or for a specific server
I plan on making it public
you can make it not your problem
make some kind of
/plugin reconsider (player)
command that checks the player inventory and changes their allowed stuff accordingly
that might be best performance wise?
or check it upon inventory open
Wait I got question, can I like link my own MariaDB driver to Spigot instead of shading it to 100 different plugins?
you can make a little plugin that has the driver, iirc other plugins should find it
if not, you can write a patch that does it
You can just use the library loader if it's hosten on maven central
are you asking if you could instead shade mariadb driver into your own spigot server? Absolutely
hi, i have problem whit import nms.
isnt this on paper only
No
just make sure to remove the mysql driver as mysql and maria drivers conflict with each other
Right now, what I've got covered is:
PlayerJoinEvent - add lore to entire inventory if ongoing game, otherwise remove it
PlayerLeaveEvent - remove lore from entire inventory
InventoryOpenEvent - add lore to entire inventory if ongoing game, otherwise remove it
InventoryCloreEvent - remove lore from entire inventory
PrepareItemCraftEvent - add lore to item being crafted
ItemSpawnEvent - remove lore from spawned item
But there's quite a lot this doesn't cover (some of which I think I know a fix though): getting an item from the creative menu, getting an item from another plugin, getting an item from /give, blocks with inventories you don't open (campfires, jukeboxes), picking up an item off the ground which was dropped by a non-player or by a player before a game was started
Uhh something like instead of shading the driver INTO the spigot server, just put the mariadb jdbc connector into some kind of shared libraries folder
I don't understand what you mean, sorry
is the driver on maven central
hi, i have problem whit import nms. my plugin import "import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer;
" but not import: "import net.minecraft.server.v1_19_R3.BlockPosition;
import net.minecraft.server.v1_19_R3.PacketPlayOutBlockBreakAnimation;". You can resolve it?
sure, but you should remove the mysql driver because unless you use some kind of hacky solution to get around the mysql and mariadb driver conflict, just easier if its your server to begin with to just remove mysql driver
is that something that i can do without modifying the spigot tree right now?
bruh i have to open recaf for that
just note that may break some plugins that use it
recaf?
you just open the jar like a zip file
recaf feels better and easier
you don't need that for removing mysql driver
Those imports have moved
Hello, how can I unshow a mob's customName if a player can't see the mob directly ?
why would you want this
??????????
because I don't want players to see mobs with nametags underground
you can hook into their AI and see if they can see the player
correct me if i'm wrong
Eh it's probably better to rayTrace from the player to nearby entities
i open with Luyten
what is the conversation api stuff used for
its kinda unclear to me just from reading the docs
it sounds like a text adventure
like someone executes /region create
and you get asked a question like
"whats the region name called"
oh
asnyc pre chat event
and you can catch that message without having to keep track of who should send what using lists/maps etc
I see
my brain skipped the rest of that convo ๐
I thought maybe I could use it for inventory stuff
but I dont think so
or atleast thats not what its intended for
inventory stuff like
well
if you think about it, selecting some settings from an inventory can also be kinda like a conversation
like you click on the settings item, it would take you another inventory screen
eh you can do player.chat upon click
etc
lol
one of the nice things of it is you can put the player in their own channel with the server
this allows server chat to not clutter the screen
as well as when they go back to main channel they can still scroll through history
of what was being talked about
but, when they are in the channel with the server, you can listen for their input in the chat
and do things with it ๐
link I gave above demonstrates how my plugin does that
prob Material.WATCH
we need to get md to add OWO
Yeah it's watch in old versions
nah pls dont
yes
Relocate it
What about Class.forName?
You change that the location where the shaded version is
is there any way to add onto existing AttributeModifiers ?
without having to remove attribute and add it again
you can;t relocate sqlite
is there any way i am able to make a listener return a value like a boolean?
basically i am trying to make an accept or deny ui where if you hit green, it returns accept and if you hit red, it returns deny
any way to go about this or any alternatives?
yeah i dont get why you couldnt just call the method you wanted right after you dont even need any of that
if clicked slot == accept slot
run code you want to run when accepted
^
how is this code
public class AchievementTier {
@Getter
private final int requirement;
@Getter
private final List<String> commands;
@Getter
private final Sound sound;
@Getter
private final float volume;
@Getter
private final String completionMessage;
public AchievementTier(ConfigurationSection baseSection) {
this.requirement = baseSection.getInt("requirement");
this.commands = baseSection.getStringList("commands");
this.sound = Sound.valueOf(baseSection.getString("sound"));
this.volume = (float) baseSection.getDouble("volume");
this.completionMessage = baseSection.getString("completionMessage");
}
}
like the object should not be responsible for loading it's own data
but eh it looks clean?
who else would be responsible
that would be a monster manager then
like if it had to deserialize all data of the things it manages
extremely valid point
unless you have a manager for every serializable class, which doesnt make sense
do you know why I have this error https://pastebin.com/WSjTKJ0g
eh the plugins I make are usually not that complex
Okay thx
Having a config section constructor seems fine by me
YOu're not doing IO, you're just parsing cached data
Pro tip
You can @Getter the whole class
instead of each field individually
And I'd also @EqualsAndHashCode
public void onZombieDeath(EntityDeathEvent event) {
int zombieLevel = getRandomNumber(minZombieLevel, maxZombieLevel);
if (event.getEntityType() == EntityType.ZOMBIE) {
Zombie zombie = (Zombie) event.getEntity();
int additionalExp = (int) calculateAdditionalExp(zombieLevel);
// Add the additional experience to the dropped experience
event.setDroppedExp(additionalExp);
}
}
private static double calculateAdditionalExp(int zombieLevel) {
int additionalExp = 3 + (zombieExpAddPerLevel * (zombieLevel - 1));
return additionalExp;
}```
Im still having problems with this ^, I dont know why custom levels dont get custom exp drops
you have to add the extra exp to the normally dropped exp
also debug to make sure it's actually what you want
I did that at calculatedAdditionalExp ?
// Add the additional experience to the dropped experience
event.setDroppedExp(additionalExp);
you'd do
event.setDroppedExp(event.getDroppedExp() + additionalExp);
not sure if getDroppedExp exists but eh something simlair must be there
huh let me try
Hello, I need help, I am creating a plugin for version 1.19.4 and I don't know how to fix it what imports to use.
package rpg.drop.api;
import net.md_5.bungee.api.ChatColor;
import net.minecraft.network.chat.ChatComponentText;
import net.minecraft.network.protocol.game.PacketPlayOutChat;
import net.minecraft.network.protocol.game.PacketPlayOutTitle;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class TitleAPI {
public static void sendTitle(Player p, String text) {
ChatComponentText chatTitle = ChatComponentText.Serializer.fromJson("{\"text\": \"" + text + "\",\"color\":\"" + ChatColor.GREEN.name().toLowerCase() + "\"}");
PacketPlayOutTitle title = new PacketPlayOutTitle(PacketPlayOutTitle.EnumTitleAction.TITLE, chatTitle);
PacketPlayOutTitle length = new PacketPlayOutTitle(5, 20, 5);
((CraftPlayer) p).getHandle().b.sendPacket(title);
((CraftPlayer) p).getHandle().b.sendPacket(length);
}
public static void sendActionbar(Player p, String text) {
ChatComponentText icbc = ChatComponentText.Serializer.fromJson("{\"text\": \"" + text + "\"}");
PacketPlayOutChat actionBar = new PacketPlayOutChat(icbc, (byte) 2);
((CraftPlayer) p).getHandle().b.sendPacket(actionBar);
}
public static void sendBroadcast(String text) {
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(text);
}
}
}
player.spigot().sendActionBar() / title
You can do titles without spigot() though
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
import net.md_5.bungee.api.ChatColor;
import net.minecraft.network.chat.ChatComponentText;
import net.minecraft.network.protocol.game.PacketPlayOutChat;
import net.minecraft.network.protocol.game.PacketPlayOutTitle;
These imports are not working for me even though I have the api and server engine in the libraries
you don't need those man
use the API not nms
Hi ! I'm trying to use Reflections in my java plugin but when the plugin try to start, i get this error :
java.lang.ClassNotFoundException: org.reflections.Reflections
sec
oh
set to compile for scope
needs to be shaded into your jar
How?
Hey guys, i got problem there using altColorCodes '&' but it's not coloring nothing and it's returning as "&4"...
there is the file: https://hastebin.com/share/olozapobok.kotlin
^ @near valve
Yes! I've seen it but I can't figure out how to use shadowjar.
can you show us your pom.xml or gradle? you need a specific plugin for shading on them iirc
clean package works on maven
and the default shadowJar on gradle should suffice sometimes even build / jar works depending on the scenario
I'm all about imports, write me something in a private message. I will show you a screen shot
plugins {
id 'com.github.johnrengelman.shadow' version '7.0.0'
id 'java'
}
group 'fr.chomagerie.plugin'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
implementation 'org.reflections:reflections:0.10.2'
compileOnly 'org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT'
}
sourceCompatibility = targetCompatibility = '17'
compileJava.options.encoding = 'UTF-8'
setLibsDirName('../../../Minecraft Server/1.20.1/plugins')
do you get the message at all?
you can use player.spigot().sendTitle()
no need to use NMS/imports
one sec
when you run shadowJar and try the plugin it doesnt shade in reflections right
As I said, I don't understand anything about shadojar, I don't know if it's a plugin, a .jar or something else!
at that point isnt it better for @Data annotation
shadow jar is gradles shade
shadow jar is a plugin (you have it added)
There should be a shadowJar task that got added in the build tab
Hey there! I have a quick question. Does player.getPing() work, or do I need to utilize CraftBukkit and Reflections?
same way you would run build
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/Player.html#getPing()
a non-exact one exists here
declaration: package: org.bukkit.entity, interface: Player
if you want exact use packets
Thank you
Okay i see the shadowJar but when i run it, nothing change in the server when reloading the config
what do you need shadowjar for
for shade reflections in my plugin
check the jar is correct
you should change the jar location inside of the shadowjar task
shadowJar {
destinationDirectory = file("./target/")
}
that replaces setLibsDirName('../../../Minecraft Server/1.20.1/plugins')
yeah i mean i want the output get colored
I've just done it but it doesn't change anything, do I need to change anything else?
plugins {
id 'com.github.johnrengelman.shadow' version '7.0.0'
id 'java'
}
group 'fr.chomagerie.plugin'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
implementation 'org.reflections:reflections:0.10.2'
compileOnly 'org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT'
}
shadowJar {
destinationDirectory = file("../../../Minecraft Server/1.20.1/plugins")
}
sourceCompatibility = targetCompatibility = '17'
compileJava.options.encoding = 'UTF-8'
}
theresd 2 shadowjar sections in that
Oh yes !
The first one is not here juste a copy paste error
When i run shadowJar, i dont get the jar file in my plugins folder
you shouldnโt get the jar
try and set the destination to something like ./target/ and then check in the jar and see if its shaded
can the problem come from the shadowJar default build directory?
no clue
Okay i get the new jar ! i'm trying 1 sec
there any error ! Thanks
hey, is there a way to make it so cactus can spawn on any block? I can't find anything online :/
place on any block*
@EventHandler
public void onRespawn(PlayerRespawnEvent event){
Player player = event.getPlayer();
PersistentDataContainer playerData = player.getPersistentDataContainer();
if(Boolean.TRUE.equals(playerData.get(new NamespacedKey(Overhaul_Systems.getPlugin(), "DoubleJump"), PersistentDataType.BOOLEAN))){
player.setAllowFlight(true);
}
if(Boolean.TRUE.equals(playerData.get(new NamespacedKey(Overhaul_Systems.getPlugin(), "Healthy"), PersistentDataType.BOOLEAN))){
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, -1, 1, false, false, false));
}
}
When the player does die and respawns, they are not given the potion effect. But the setAllowFlight is, they can double jump after they respawned, the Regeneration isn't working tho, and I don't quite get why.
give potion effects one tick later
maybe because you're giving regeneration for a single tick?
oh
also I'd use a pdc wrapper
also could just do if pdc.getOrDefault(..., false)
that method names reminds me of atomics and now im gonna be mislead into thinking that pdc is async safe smh
-1 is infinite.
then try a tick later or your if statements are falling through somehwere, try debug logs
they arent. its just the potion effect. the if statement does work. i put print statememnts in there.
yeah I tried putting the potion effect for 10 minutes and it didn't apply
and what about giving the effect one tick later after that event
huh. that seemed to fix it, I thought you meant like changing the duration of the effect ๐
Why has that happened tho? what's the reasoning for it?
nah :p
RespawnEvent can be finicky when editing the player object because theyre not actually in the world yet iirc
Yeah you need to delay most things with respawn
huh, okay, that's good to know.
Just change it a bit
private final Map<String, CompletableFuture<EnkaUserInformation>> currentRequests = new ConcurrentHashMap<>();
private final Cache<String, EnkaUserInformation> cachedData = CacheBuilder.newBuilder().expireAfterAccess(15, TimeUnit.MINUTES).build();
public CompletableFuture<EnkaUserInformation> fetchData(String id) {
CompletableFuture<EnkaUserInformation> cachedRequest = currentRequests.get(id);
if(cachedRequest != null) {
return cachedRequest;
}
EnkaUserInformation cachedInfo = cachedData.getIfPresent(id);
if(cachedInfo != null) {
return cachedInfo;
}
cachedRequest = CompletableFuture.supplyAsync(() -> {
...
});
currentRequests.put(id, cachedRequest);
return cachedRequest;
}
Better to manage futures manually
So that when your plugin / service shuts down you can join or cancel them all at once and all
You can then make the cache a map and use ttl to invalidate data
thank you for enlighting me on the Cache class
if it doesn't get read
there's expireAfterWrite
if you want to just get nuked after 15 minutes
but given your TTL is variable
I'd just use a map
guava
it's shaded on spigot
?whereami
shade it then
this is literally the official spigot discord server
but anyways
just shade it if it's your own
you do your usual fetch
and insert the result in your cache
you're probably playing with generic types
then you need to make sure that your future does complete with K
so supplyAsync(() -> {
...
return clazz.cast(value);
});
prolly
no
can't you just
thenCompose
OR
skip the supplyAsync part?
but prolly thenCompose
.
Not really
HashMaps are only serializable if all the keys and values are too
it wants another future
it kinda merges them
yeah that works
depends
is your original future async?
If so, that doesn't matter
show code
it's async if you just use the supply / runAsync methods
ah you create a new future
Should work regardless
yeah whatever
I'd convert your cache to a map and implement ttl manually
maybe with some kind of executor going over it every second
I guess that works
but I'd rather put the ttl on the user information class itself
so yeah no point in the bivalue
Bi value, what can the value not decide what it wants to be
Just choose 1 value it needs to stop being so greedy
he a little confused but he got the spirit
loop through the values
make a static executor
great question
bros cooking
meanwhile my dinner just arrived
not sure how to get started on coding this, is there a way to scaleably code something like, 1 = 'aaaa', 2 = 'aaab', 3 = 'aaac', and so to z and then it adds to the counter?
So basically a base 26 number system
hm, kinda.
but you add 26 ^ 4 as the min value
Maybe more of a number to letter combo
where its acendingly higher
aaa > aab correct?
opposite
maybe I'm being stupid but how can I make file have outputDirectory as its parent so I can save it?
file.getParentFile()?
I feel like your video downloaded event is stupid
its async
should pass a byte[] which you then save to a file
ahh
that part
lemme see if theres something else
maybe theres a stream or smthn instead
Hey, i'm trying to make npcs (EntityPlayer w/ Packets)
and i gave him a skin and everything works fine
but the issue is when i try to use packets like headrotate packet or entity move packet
the skin will be not appeared anymore, why?
oh tbf i can just open the downloaded file as a stream then save it to the output i guess
nvm there was this
public static final String ABC = "abcdefghijklmnopqrstuvwxyz"; // Feel free to add numbers
public static final int CHARACTER_COUNT = 4;
public static final int ABC_LENGTH = ABC.length();
public static String convert(int input) {
StringBuilder builder = new StringBuilder();
for(int index = CHARACTER_COUNT; index > 0; index--) {
int remainder = input % ABC_LENGTH;
input /= ABC_LENGTH;
builder.append(ABC.charAt(remainder));
}
return builder.toString()
}
hm
bukkit.yml
How do I check if a player dies to the ender dragon using magic? (dragon's breath)
Also, DamageCause.DRAGONS_BREATH doesn't work
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
There are "laws". "Not working" is an useless statement.
bruh you cant suppress ignored since when
Ok. On player death, I find the player's cause of death. If due to dragon breath, I execute some code. I then tested to see if it would work, which it didn't.
@EventHandler
public static void playerInfected(PlayerDeathEvent event) {
EntityDamageEvent.DamageCause cause;
try{
cause = event.getPlayer().getLastDamageCause().getCause();
}
catch (NullPointerException ne) {
cause = null;
}
if (cause == EntityDamageEvent.DamageCause.DRAGON_BREATH) {
Location deathLoc = event.getPlayer().getLocation();
event.deathMessage(Component.text(event.getPlayer().getName() + " succumbed to the Dragon's Infection."));
util.zombieReinforce(deathLoc, 1, 0, null, CreatureSpawnEvent.SpawnReason.LIGHTNING, null);
}
}
try ethanal, you will be in heaven just in seconds
When the player dies to dragon's breath, the death message is "[PLAYER] died to the Ender Dragon using Magic"
The fact that CโHโO is Hungarian, makes you want to feel yourself in heaven already.
you can save Locations directly into configs thankfully :)) no need for any parsing
save the UUID as a String and load it with UUID.fromString()
Mostly because I am Szรฉkely as well.
in the case of getCause() causing a NullPointerException which my IDE is warning me about
uhmmm there is away to save an actual map into yml but im not knowledged enough on that
So, my dumbass would likely go with the 2 lists unless someone else smarter knows how to save maps to yml
fr
Hands up for those who hates NPE
...
intellij ignoring my suppression warning is even worse
โ๐ป
Okay but what about my original problem?
sad seems that one dont work either
guess ill have to change it for my whole ide
im considering 10% being people doing configs ๐
if you count interfaces like them sure
yeah as long as you dont shuffle them they are fine
probably something in js, or a C varient
illusion
what
how do you save maps in yml
do you mean generics
for this guy
why would I want to save stuff to yml?
not for me
Thanks for the help!
you fuckin
someone else, wasnt sure if you knew or not
what is a template
Configs? :P
I usually save stats into .yml
do you mean something like this, where it would extend a class to identify it
mongodb ๐ฉ
that is generics
that doesnt sounds to be Java my friend
for(Map.Entry<String, Whatever> entry : map.entrySet()) {
String key = entry.getKey();
Whatever whatever = entry.getValue();
config.set(key, whatever);
}
or is it
oh its that easy im dumb lmfao
thats what im saying
generic types
yeah I've done something simpler
have fun
@kind patrol
And you can put your Location in as the key (or value if thats what you have) and save UUID as a string
do you even use Java, Mr. C2H6O?
oop didnt mean to ping
is ok
o.O
wtf are you doing here
?learnjava!
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming. https://media.discordapp.net/attachments/694661573125472256/998143126373941248/6n0v4g.gif
Prob spigot related help or something?
in help development?
When I typed a word in #general he immediatly realized I am prob Hungarian. xd
they were in general asking about being paid to make plugins
a troll i think
Pretty sure itโs just a troll
good luck trying to make money of spigot plugin development
sniped
the one that was here yesterday was mildly entertaining
In C/C#/C++? ๐ค
Interestingly, what I can only say is that he can only do that in Bedrock I think.
mainly cause it said controversal dev shit 
didnt say language earlier, just if anyone had done it lol
He did in fact told that he only learns C based languages...
Look out for stuff bud

Jesus Christ
sorry I don't speak to trolls
that scared the fuck out of me

joe hub

alright downloader done
now mp3 -> ogg converter
Then a resource pack creator -> shove into a file hosting
Some buuuulshit
It's just that c++ is as fast as my mental sanity declining
why are you even in the server in the first place?
No they can be insane. ๐
Just visist Quora... ๐
"My 15-years old son accidentally made my 188,577,283 years old mother pregnant. What do I do?" ๐๐๐
I just finished a 5 hour coding session and I'm oughta start another one
My Mother (19M) Wont Stop Calling Me (15M) Daddy
It all started about 2 weeks ago when my step-sister (24M) got stuck in my spaghetti jar (Marinara), my mother (24F) spirals the jar at my head (246mph). It missed my head and hit my dog (March 5 2002 - October 3 2023). He perished in an instant (Critically Dead). My mother (Tony Pizza) grabs me by the toe and yanks me to the basement (12m x 15m x 11m (Ikea)) and ties me up tight (Very Tight). She put my dogs remains in the chili (Spicy) that she force-fed me with a spoon (Star Wars). She reaches and dangles me step-sister (4mM) but slips on the way back. I (12M) was tied in my basement (12m x 15m x 11m (Ikea)) with no alive family members. I surely starved. But miraculously my mother (Big Jill), with her last slither of life said, "Upvote for part 2..."
why does discord still show blcoked message - show message
i thought you said you had a map?
What the actual fuck?
for loading it's the reverse
yeah you just get that hashmap and call values() and keys() on it to get the iterable values of the map
You can't stop the reality bud.
for(String key : config.getKeys(false)) {
Whatever value = config.get(key, Whatever.class);
map.put(key, value);
}
because 0b is used to indicate a binary number
Hmm... Proof?
problem solved
โจ Configuration sections โจ
btw Bedrock Edition is yer friend. โค๏ธ
True, but MC Java is still, and will always be written in Java.
so your reason for loving cpp is its not oop?
what a shit reason
3 billion devices run java
I guess?
You went to the point where you need translator. ๐ฅฒ
Don't get me wrong but wasn't Java released in like 1995 or something? ๐
Uh yeah sure, but you don't get anything forward with "/j", because I understand nothing out of it huh
/j is a tone inidcator for a joke
oh no how sad?
Isn't Java compiled like, it needs to go trought another process before it reaches to the CPU's code base or something?
go learn skript, im sure you'll love it
Yes
on load:
execute console command "sk disable {NAME :333}"
I am sure this will do.
And I am fucking sure I fucking hate Skript.
what
Fuck you, @noble frost.
i refuse to touch skript, even with a 35ft pole
Skript is a plugin for Java MC servers, if you didn't know.
It has a stupidly odd language to use.
you 1st ask about making money from spigot dev then say cpp is the best language ever to exist, so you probably will love skript
childish bunch of fucks
To be fair epic is literally a child
not talking about epic
correct
I am a child as well.
Turning 17 some days later.
I turned 18 this year
skript has a purpose, but that isnt how its used
i will argue with every skript user till the end of time
well done, it should be used for basic custom commands, or add a drop to when a player dies, not entire servers
others such as @noble frost tried to make an ENTIRE NETWORK using Skript
there's no reason to spend your time learning skript when you can learn java just as fast
which itself is just pathetic
learning java is so satisfying
I self taught Skript... ๐ฅฒ
especially when you can bang out 300-600 lines at a time and step back and take a look at it
Felnลtti.
maybe 3 if you are fast learner
2 if you already know english
It took me 5 months btw
what
so is java if you have a brain and an iq above the amount of money in your wallet
I was like
Java took me like a day to learn and many years to master
on chat:
cancel event
broadcast: "asdasdnyalogasd"
and I have been struggling
FOR MONHTS
to realize
: is unneeded
XDD
Skript is such a weird format
but there were definitely "click" moments like when I learned about hashmaps, lists
Itโs like SQL but even more cursed
or when someone said we were registering a listener twice and OOP just instantly clicked
uhm
it's in the name
a loader
Isn't it the loader?
for classes :>
alias the main?
is there such a thing as Cron jobs in spigot?
just like EA is in the game
(I usually call the main class Loader)
class loader is used if you wanna do some fuck shit like read files inside your jar file
bunch of other shit too but, i used it for that once
not quite
more like inject your custom class replacement
i remember it being like around the code involved in it
yeah i did do that as it was a copy of bento box's module loader lmao
jar file scanning is quite simple
as long as you have Reflections :>
nope
fuck it without that
read inside your own jar file though
Yeah you can do that
i remember something about it being complex and it had to be a huge reflection fuck up
primitive or boxed
afaik
I sometimes extract all the files in my resource folder using JarFile
primitive is just the primitive's default value
otherwise it kinda has none
and complains that it's unset
that's only for method variables tho
anything else is null
โค๏ธ
and you can read packages of a JarFile?
yeah
during runtime?
I use it to copy across all the .yml files
lombok @UtilityClass
fuck off
wonder why this never showed up when i googled "how to read classes from a package during runtime in java" online before
you and your extremely roundy font
because I made it in like 15 minutes
my font looks normal
it was all really complex reflection or using Reflections lib
Lombok bad
looks roundy as shit
wym?
so it does
mf got a 25k monitor
its like 1080p 144hz
top is yours
so is mine
even my main 2k 144hz can't be that roundy
Future fonts
get shit on
no need for pointers in modern languages
love arial
Isnโt arial just Times New Roman but Microsoft
yeah you enforce sans serif
I just use times new roman
that explains it
get shit on
nah
I can't bother being corny with my browser
just use default settings
update once the thing turns red
maybe if you could shut the fuck up for a moment
you'd understand that all the variables passed around are basically pointers
why is it good
except for primitives
if you want manual memory management
Unsafe is the class for you
there is literally no reason for using dynamic allocation in modern times, and basically everyting in java is pointer passing wise as illusion said
you can do that without pointer xd
arrays are objects
you can do a Map<String, byte[]>
it's cursed
and I use it at work
quite a bit
sure
literally only reason i use dynamic alloc in cpp is if object have to outlive current scope, literally no other reason, and in java, you can do that easly
you're just salty that there's no spigot api made in c++ so you can cry about the memory leaks
and lets say polymorfism, which you also dont need pointers for in modern languages
XD
pOwEr
I tried googling but honestly couldn't find anything on this:
How can I convert MP3 -> OGG? Is there no libraries/native ways for this?
ffmpeg mayb
lol
Play it through your speakers and then record it again from the mic
bet
for some reason i thought you were kinda making this up
alright then
holy fuck
You can
9mb
It's called
Configuration sections
yml is honestly a bad database schema
this is just basic java serialization
gl finding a lib for that 
i wish json was more widely accepted
ah sqllite lmao
you can
x/y/z/yaw/worldUuid
oh this needs ffmpeg to be on the mc server tho
just use the spigot library feature
and make your plugin download shit
never heard of that whats that, or at least the naming is different to me
no the way illusion sent is how it should be done
i dont get the issue
one sec
you cant have multiple same-keys in a map
they get overridden
sooo?
The power of multi map
why are your keys the same in the first place lmao
its a key
you only need one uuid and a list of locations
HashMap<UUID, List<Location>>
oh that sounded like a external lib
Itโs guava
lol il try that one day
Which is in spigot
Itโs just a nice wrapper for Map<key, List<value>>
i use it quite a bit in musepluse for the queues + music track loading
its a < <>> < <>> <<> <>><> fest lmfao
not musey plusey
canโt believe you keep listening to me for james
names
i thought it would stop after homosexualdemon
I gotta stop designing protocols honestly
musey plusey getting a big updataty waty ๐คฃ i couldnt find a way to type this out lmfao
never
pls donโt ever stop
somehow I managed to make this work
(master -> client1) Yo this template is updated [skywars, abc123}
(client1 -> master) Ye, I need the files with the hashes "12ab34cd" and "aaabbbccc"
(master -> client2) Yo here's a request that belongs to client1, as far as I'm aware you're already synched based on what you said before
(client2 -> client1) Yo here's the shit you requested, bossman ordered
(client1 -> master) Yo thanks for this, I'm up to date now (unlocks client2 to proxy another request)
took me 2 hours to write all the logic but it works in theory
how are you coding all this? just with spigot plug-ins?
just a few java classes
okay
Hello how can I apply enchantement/custom meta on crafting?
PrepareItemCraftEvent
I though it was CraftItemEvent
Well you probably want them visible before they actually craft it
Thx it worked!
?paste
https://paste.md-5.net/iyuhanadaf.java
I'm currently having an issue where this ability basically ignores the cooldown and is spammable just randomly.
How do I properly set the color of an AreaEffectCloud? This is the code for the AEC that spawns when a dragon fireball hits, but it doesn't go through. Using .getColor() I can see that the color actually does change in code, but I can't see it in game
@EventHandler
public static void onDragonballImpact(EnderDragonFireballHitEvent event) {
Location loc = event.getEntity().getLocation();
event.getAreaEffectCloud().setColor(Color.GREEN);
for (LivingEntity z : loc.getNearbyLivingEntities(8)) {
if (z instanceof Zombie || z instanceof EndZombie) {
Location transfo = z.getLocation();
z.remove();
util.zombieReinforce(transfo, 1, 0, null, CreatureSpawnEvent.SpawnReason.LIGHTNING, util.getRandomSpecial());
transfo.getWorld().strikeLightningEffect(transfo);
for (Player p : transfo.getNearbyPlayers(50)) {
p.playSound(transfo, Sound.ENTITY_LIGHTNING_BOLT_THUNDER, 100, 1);
}
}
}
}
#.setParticle(Particle.REDSTONE,
new Particle.DustOptions(Color.fromBGR(12, 255, 0), 1));
not sure if that will work but give it a try
and then change the Color to Color.GREEN or BGR whatever you want
It works! What made you think that would fix the problem?
I have a ability I made right in front of me that has the same AreaEffectCloud entity that was colored so I just went for it and sent that message
Glad it works tho
is there a list of minecraft blocks/items that aren't entities and that break when the block it's attached to breaks, such as torch, pressureplate, button, various plants.

