#help-development
1 messages Β· Page 395 of 1
lmao
with ChatColor.of(java.awt.Color)? That 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.
i'm getting wrong colors
ChatColor.of, the package name is smth with md5 in the name
//WARNING is a custom md5 chat color (close to gold)
TextComponent context = new TextComponent(
Colors.WARNING.getChatColor() + "You are about to override your blablabla"
);```
And this what i get :
i can't figure out what this would look like in kotlin?
for (int x = -radius; x <= radius; x++)
i've been trying stuff like
for (x in -radius .. radius step 1)
for (x: Double in radius downTo -radius)
and more, but it's all invalid syntax
do i just do a while loop?..
1.19.3-R0.1-SNAPSHOT
https://www.spigotmc.org/wiki/the-chat-component-api/#:~:text=component)%3B-,Colors%20and%20Formatting%20Styles,-(top)
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
thanks i'll try that
for (x in -radius..radius)
shit weird
i'll look this error up
just use java
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
thats not how for loops work in java
Java Gradle Submodule Compiling
can anyone do this for me
Create or find a rainbow animated text that you want to use.
Open your Minecraft texture pack in an image editing software, such as Photoshop or GIMP.
Locate the textures that you want to modify, such as the font or GUI.
Open the texture file you want to modify in your image editing software.
Paste the rainbow animated text onto the texture file, making sure that it is positioned correctly.
Adjust the opacity of the rainbow animated text to match the texture and make it blend in more seamlessly.
Save the modified texture file and add it to your Minecraft resource pack.
Test the texture pack in Minecraft to make sure that the rainbow animated text displays correctly.
If necessary, adjust the rainbow animated text to better fit the texture and repeat the process until you are satisfied with the results.
By following these steps, you should be able to merge a rainbow animated text with a Minecraft texture pack and create a unique and colorful look for your Minecraft game.
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
There all for paying I need a free one :{
now i understand why people say mojangs code goes brr
anyone know how to use hex codes on scoreboard in 1.19.2? i tried the method below but it didn't work properly for some reason, it just seemed to inherit the last integrated color code and use that:
public static String translateHexColorCodes(String text) {
Matcher matcher = hexPattern.matcher(text);
StringBuffer buffer = new StringBuffer(text.length() + 4 * 8);
while (matcher.find()) {
var group = matcher.group(1).toCharArray();
if (group == null)
group = matcher.group(2).toCharArray();
matcher.appendReplacement(
buffer, org.bukkit.ChatColor.COLOR_CHAR + "x"
+ org.bukkit.ChatColor.COLOR_CHAR + group[0] + org.bukkit.ChatColor.COLOR_CHAR + group[1]
+ org.bukkit.ChatColor.COLOR_CHAR + group[2] + org.bukkit.ChatColor.COLOR_CHAR + group[3]
+ org.bukkit.ChatColor.COLOR_CHAR + group[4] + org.bukkit.ChatColor.COLOR_CHAR + group[5]
);
}
return matcher.appendTail(buffer).toString();
}
IridiumColorAPI
so i just add that as a dependency in my plugin and then call the proper method?
bet, thanks yall
is it compatible with variables instead of the actual hex code?
to prevent myself from updating hexes in a million different places, i have variables set in my main class and then i just use those variables everywhere else in my plugin
yeah should be fine. thanks π
anyone knows how to get the id of a sound?
it returns a string, i need the int one for nms
Integer.valueof()
what
ahahahah
what xd?
yeah, chatgpt says .ordinal() makes it but i'm not hearing anything
whats wrong with my gui?
ah
there is probably no clea nway to get the nms id
so replace some things and then do integer.valueof?
shouldnt getKey().getKey() at least return only x.x
no @charred blaze
i dont think this is working, anyone know why?
https://paste.md-5.net/uqanibufop.java
that hurt
oh it turns out there's a thing for it. packet#getSoundEffects. thanks
"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.
xd
or do you have to do Integer.valueOf(lastOf(getKey().getKey().getPath().split("\\.")))
Do you register it etc?
i did, yes
show us
do you happen to have the gradle dependency for it? i cant find it anywhere and im not used to gradle enough to convert it over myself
like this right?
https://paste.md-5.net/fuvukukori.java
yeah im not finding one anywhere in any plugin that uses the api (that i can find), so im just gonna have to figure out how to convert it over myself. thanks tho
that'll work, sure
How can I get 1 random item from List<ItemStack> items
create a random
and
items.get(random.nextInt(items.size()))
or something like that
thought about it
you don;t as random is upper exclusive
so you dont need to?
no
nextInt(5) shoudl give you 0-4
?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.
xD
Is it possible to get the exact pack of a player ?
you bet me fixing my code
Don't use getTitle().contains() to see if the GUI is the one you want
why telling dont use that and not telling what to use? to make conversation longer?
Im storing my items like this though (not sure if it's the best method)
List<ItemStack> items = new ArrayList<>();
String[] itemStrings = args[3].split(",");
for (String itemString : itemStrings) {
Material material = Material.matchMaterial(itemString.trim());
if (material != null) {
ItemStack item = new ItemStack(material);
items.add(item);
}
}``` so is it possible that the player fills in an item that does not exist?
Cause i'm trying to rememorate what is it called in english cause I fortgot the name in english π₯²
i'll send you the code it'll be better
yeah i understand code more than english D: (fr)
public class Menu implements Listener {
private static Inventory inventory;
public static void menu(Player player) {
inventory = Bukkit.createInventory(null, 5*9, "Β§cThe Title");
player.openInventory(inventory);
}
public static Inventory getMenu() {
return inventory;
}
}
but my inventories are different every time
something like that
and then do if (inv.equals(getMenu()))
my brain
thx
No problem
statics bruh
why do i need getMenu method if i can access inventory variable from other classes easily?
I have a plugin that stores block locations and other variables. How can I prevent that data from being lost if the server restarts, gets reloaded, crashes, etc?
store it in some database? like sql
In case you need it in another classes or something, if you have a another way to do it then do your way
its not for a beginner
you'd be best to just store locations in a yaml file
I finally got everything working btw
nice
a yaml file?
yeah cuz it's kotlin??????
?configs
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
fixed what now
issue wasnt about that btw
well maybe you should have mentioned that
as the majority here uses java
????????
please tell me ur joking
π
does it look like i read that?
I'd hope you did lol
jesus chill man i joined the conversation later
yeah but I did in fact mention that I use kotlin
Anyway, now he know and will be able to try to help, chill y'all
I'm chill lol I'm just confused
fair enough
There is too much messages, we can't exactly know everything π₯²
anyway, idk. dont use kotlin
thanks for the opinion ig
π© Kotlin
cool
lmfao does kotlin not allow
for (x = b; x < m; x += s)
i dont use kotlin* -,-
nah
who tf thought that was a good design idea lol
Yo if anyone knows Triumph gui, how would i set the first row to glass panes?
I'm totally fine with having some small inconveniences
oh I'd help you if I were at my laptop
I used triumph gui
give me 3 mins
from a quick look at the docs it looks like this could help you https://github.mattstudios.me/triumph-gui/dev/triumphteam/gui/components/util/GuiFiller.html#fillBetweenPoints(int,int,int,int,dev.triumphteam.gui.guis.GuiItem)
declaration: package: dev.triumphteam.gui.components.util, class: GuiFiller
oh yeah it's the filler
Well cant use BLACK_STAINED_GLASS_PANE in my version -.-
can anyone help me to
Thats my problem
Please
what ver are you using
Old old 1.8.9
ah
if ItemBuilder takes ItemStack for from, you could pass it in
does it?
create the stained pane with a byte magic value
it does indeed
I just checked
Nvm how would i add the byte stuff to this?
```
CrateGUI.getFiller().fill(ItemBuilder.from(Material.STAINED_GLASS_PANE).asGuiItem());```
one sec
no
ItemBuilder.from(new ItemStack(Material.STAINED_GLASS_PANE, 1, bytevalue))
look up the byte value
Whats the 1?
I think it's amount
Aaarh
new ItemStack(Material.STAINED_GLASS_PANE, 1, DyeColor.BLACK.getData())
according to a quick Google search
try that
What event can I use to detect a change in a player's inventory
there's no such event I don't think, you can run a per-tick scheduler and see if there are changes and call your own event
actually Banannus
why don't you use XMaterial
for multiversion support
from XSeries
A library?
yeah
it's a great library
no need to reinvent the wheel, it'll basically cover all of your needs when working with multiversion sounds, particles, materials etc
WHAT IVE NEEDED THAT FOR SO LONG
Damn
Didn't even know it existed
haha live 'nd learn π
so yeah if you use it, just pass XMaterial.BLACK_STAINED_GLASS_PANE.parseMaterial() for ItemBuilder
smth like that
whats wrong with thisss
Im getting "Could not find artifact" π€
did you reload maven?
how many times do i need to paste same code to fix single issue?
bro
bruh
?cba
Pluggg#5737 definitely regrets to for the most part inform you that unfortunately, they essentially are unable to definitely assist with definitely your enquiry, which essentially is fairly significant. Please simply really ask again later or possibly kind of ask someone else about this enquiry, demonstrating that the person that ran this command generally regrets to kind of inform you that unfortunately, they for the most part are unable to generally assist with actually your enquiry in a subtle way. Thank you very sort of much for kind of your time and the person that ran this command specifically wishes you a really good day, so the person that ran this command really regrets to actually inform you that unfortunately, they literally are unable to definitely assist with very your enquiry, or so they particularly thought.
oh i need to shade it
Would something like this work? This is just a snippet
public class ParticleHandler {
public static Plugin plugin;
public static final String CHEST_DATA_FILE = "chest_data.dat";
public Map<Location, ChestObject> chests = new HashMap<>();
public ParticleHandler(Plugin plugin) {
this.plugin = plugin;
loadChestData();
}
public void AddLoc(ChestObject chest, CommandSender sender){
Location loc = chest.getLocation();
if(chests.containsKey(loc)) return; }
chests.put(loc, chest);
sender.sendMessage("Added (" + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ") to the list.");
saveChestData();
}
public void RemoveLoc(Location loc, CommandSender sender) {
if(chests.containsKey(loc)){
chests.remove(loc);
sender.sendMessage("Removed (" + loc.getX() + ", " + loc.getY() + ", " + loc.getZ() + ") from the list.");
saveChestData();
return;
}
}``` This is only for the chests Map, I can do the same for the ChestObject class
jeez
HOW MANY COMMANDS ARE ON THIS DISCORD SERVER
lol
all of them
bump
?help
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous names and nicknames of a member.
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
sad
?cc list in #bot-commands
bump
I think you're better off creating a spigot thread, this is a lot of text lol
sorta same here
I already did that, but I still want to bump
alr
I'm sorry that you are not the center of attention on thy discord server and overall the spigot community
i have a for each consumer of a path to follow, how can i make a projectile follow it exactly
could you show the code?
if i have an inventory, how do i determine if its a player inventory as opposed to a chest, hopper, etc
instanceof PlayerInventory
thanks
it does somewhat
I am drunk
so noit gonna explain
plz help me π
I still can't find the way to do it
actually I could just copy and paste the code into the kotlin file and it'd convert it to kotlin code
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
but I'm not at my pc rn π¦
pathfindingResult.thenAccept(result -> {
if (result.successful() && !projectile.isDead()) {
result.getPath().getPositions().forEach(position -> {
player.getWorld().spawnParticle(Particle.DRIP_LAVA, BukkitMapper.toLocation(position), 5);
Bukkit.getScheduler().runTaskLater(this, () -> {
Location block_target = BukkitMapper.toLocation(position);
Vector target_vector = block_target.add(0, 0, 0).toVector().subtract(projectile.getLocation().toVector()).normalize();
projectile.setVelocity(target_vector);
}, 3L);
});
} else {
player.sendMessage("Path not found!");
}
});
this is the main part
nah sorry pal I can't help you here π¦
Cant get it to work :/
GUI not working as expected
is there something like AnvilRepairEvent/AnvilRenamEvent?
I want to check some things when player renames their item
there is in paper/purpur
Got it working, but its Null?
whats the name in Paper?
Im using their API
arraydeque
List()?
Heres the line
CrateGUI.getFiller().fill(ItemBuilder.from(new ItemStack(XMaterial.BLACK_STAINED_GLASS_PANE.parseMaterial())).asGuiItem());
is it PrepareResultEvent?
Oh cant even get it it to shade,,,'
Anyone got good docs on updating json boolean values?
maven
xseries
Hmm how old of a version?
https://paste.md-5.net/uteqahomam.cs if you mean the error when i use it, there you go
aint got any other errors
kinda works ig
mojang having fun referencing other groups in a certain group file
so i gotta make sure that one is loaded before and that i dont have any circular references
Same error
ya
someone told me that private void writeObject() and private void readObject() are called during serialization and deserialization of an object, though IntelliJ doesnt say they are
it says they arent used
Just intellij being useless
Disable the dumb usage things they are just fucking annoying and generally unhelpful IMHO
So these are being called?
Yes
by internal java code yes
Intellij just doesn't know it
π good to know, thanks
Yet another thing that peeves me about intellij
Is anyone here good with maven, cant get it to shade "XSeries"
I heard maven @tender shard
Try using the latest version of the shade plugin. 3.4.1
Already tried didnt work
?paste
https://paste.md-5.net/leviyekahu.xml Updated version
how do i determine what caused InventoryCloseEvent? player or something forced it to?
how do I get Result Item from Anvil?
PrepareAnvilEvent and getInventory().getResult() i presume
This is what I just tried.
Workd fine with placed-down Anvils, but I'm using Plugin-opened Inventory.
My goal is to just get Value entered into that Text Field and confirm it on Rename
declaration: package: org.bukkit.inventory, interface: AnvilInventory
this maybe ?
yeah, but I can't seem to get ClickEvent when clicking Result
Hi
Does anyone know how to check if the player is on top of a certain block?
i smell slavic language
You can try getting a block at player's Y position -1
but it will only work if the player is standing on it
aya! Looks like neighbor to me
im Polish
Czech here
o tak
bruh Iterables.getLast seriously
what about contents[contents.length - 2]
I already tried that, resulted in the same way
ugh you dont need a stream?
ehh I broke my plugin. Someone help please
https://paste.md-5.net/umeqogibol.cs - error
If you need to see any code tell me
The error happened after I implemented a data save system, that saves data
public void loadChestData() {
File file = new File(plugin.getDataFolder(), CHEST_DATA_FILE); // line 99 --------------------------
if (file.exists()) {
try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file))) {
Object obj = ois.readObject();
if (obj instanceof Map<?, ?> data) {
for (Map.Entry<?, ?> entry : data.entrySet()) {
if (entry.getKey() instanceof Location && entry.getValue() instanceof ChestObject) {
chests.put((Location) entry.getKey(), (ChestObject) entry.getValue());
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}```
Yeah just figured that out. Not sure how to specify it though. Here's the class
https://paste.md-5.net/najeporote.java
I also added a null check
but it needs to be not null obviously
why is it static
because I like the word
jk
idk man, thought it might work
my brain fucks up sometimes
Sorry, most of the times*
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
ok so i actually misread and its called TranslatableContents
Does this also work?
oh still need to remove static
or does it have to be public main pluginInstance
ya, so what im trying to do is adding a prefix to a scoreboardteam, and it wants me to pass a component. but i dont really understand what that component means
I get this error at startup, but it doesnt seem to affect anything. Commands work java.io.FileNotFoundException: plugins\ScrapCollection\chest_data.dat (The system cannot find the path specified) ...
I guess it makes sense
that it cant be found, if it doesnt exist
huh
public void saveChestData() {
if(plugin==null) return;
File file = new File(plugin.getDataFolder(), CHEST_DATA_FILE);
try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file))) {
oos.writeObject(chests);
} catch (IOException e) {
e.printStackTrace();
}
}```?
isnt that called saving
or am I doing something horribly wrong
ohh. Good point. My brain has been fried many so many times today I completely forgot that
Soo uh where should it be created
just in loadchestdata?
and check if it exists
if not, create one
omg ty!
Alright so now I have this, but the createfile doesnt use a name right? So how can I load a file with a name if I created a file without that name?java public void loadChestData() { if(plugin==null) return; File file = new File(plugin.getDataFolder(), CHEST_DATA_FILE); // line 99 if (file.exists()) { try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file))) { Object obj = ois.readObject(); if (obj instanceof Map<?, ?> data) { for (Map.Entry<?, ?> entry : data.entrySet()) { if (entry.getKey() instanceof Location && entry.getValue() instanceof ChestObject) { chests.put((Location) entry.getKey(), (ChestObject) entry.getValue()); } } } } catch (Exception e) { e.printStackTrace(); } } else{ try { file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } }
no
ah
your File object
π€¨
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.
new File()
like what is CHEST_DATA_FILE
well yeah
i know that
so thats the file name
I've already done too much programming today. Understanding a new concept is too far-reached for me atm
I just wanted to finish this lol
its not new
you create the File using new File
which is where you specify the filename
ohhh
OHHHH
I think I get it
let me test my code
Alright, so if I ignore the 593 errors, it's working
?paste
https://paste.md-5.net/eyawilusad.md - error 1
https://paste.md-5.net/avimuweqen.md - long error(s)
https://paste.md-5.net/jayijokiyo.md - error 3
I think these are all the same errors though, but Im not entirely sure
public void loadChestData() {
if(plugin==null) return;
File file = new File(plugin.getDataFolder(), CHEST_DATA_FILE); // line 99
if (file.exists()) {
try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file))) {
Object obj = ois.readObject();
if (obj instanceof Map<?, ?> data) {
for (Map.Entry<?, ?> entry : data.entrySet()) {
if (entry.getKey() instanceof Location && entry.getValue() instanceof ChestObject) {
chests.put((Location) entry.getKey(), (ChestObject) entry.getValue());
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
else{
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public void saveChestData() {
if(plugin==null) return;
File file = new File(plugin.getDataFolder(), CHEST_DATA_FILE);
try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file))) {
oos.writeObject(chests);
} catch (IOException e) {
e.printStackTrace();
}
}```
question, how do i serialize an spigot class that implements ConfigurationSerializable as a byte array?
this is what I'd do if it'd implement java.io.Serializable, but the interfaces arent the same
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(serializationInput);
byte[] objectBytes = bos.toByteArray();
the internal serialization just spits out a Map<String, Object>
why do you want byte arrays
ConfigurationSerializable cant be serialized to a byte array afaik, unless you serialize it yourself
Alright I got rid of the error but now I've got this error and I havent a single clue what this means
https://paste.md-5.net/fesijunove.md
ConfigurationSerializable is meant for the yml serialization stuff
read the line with your classes in it
and then look for the class and line number
and show us the line where the error occurred
does that parse existing spigot classes?
im about as sure that im about to get hit by a meteor about the ability of this thing to parse either a itemstack or a map
Also uh what are these things? Why are they being ignored?
you ignore them
why
those methods return an object
boolean return values that tell you if it worked
which you discard
no they dont
a boolean
ohh alright, so those warnings dont matter
so thats not causing my java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.bukkit.Location error
uhh you were talking about lines of code?
.
ah alright
i did in fact NOT get hit by a meteor
whats your point
it wont
I thought you were talking to Moterius here lol
brb
you cant serialize a Map<String, Object> to a byte array atleast not like that
how do you save an itemstack as a byte array
without implementin serialization for an itemstack yourself
yeah exactly, so I guess you can turn anything into a byte array, you just need to serialize it yourself
Idk can someone help, How do I compile .java from string?
yes
have you googled it?
I googled but didnt work π¦
what did you try
Hmm I see. That sucks
But do I necessarily need to save that Map?
I think I do
just tested it and CopyOnWriteArraySet#addAll with 500 elements takes 20 times longer than calling #add on every element
1100Β΅s vs 54Β΅s
rephrased it, ye
how did they even do that
also you need to test taht like a billion times to get some reliable result
didnt know that stuff called toArray which basically defeats my point, but i was still confused cuz add creates a new copy of the whole internal array
Yes I am? But now Im wondering if I truly need to save that Map,
i have no clue how i have 545 recipes loaded but minecraft only has 379 or smth :/
The public Map<Location, ChestObject> chests = new HashMap<>();
okay
Perhaps shapeless recipes?
you want to save that to the file?
I think so. Im pretty sure it's necessary because it stores all the locations of the blocks I believe
only shaped recipes π so that cant be possible at all
oh well depending on how you did that its probably where you are making the mistake
Hmm odd. Perhaps you found the secret recipes of Minecraft
Yes Im pretty sure it is
damn raw gold block is a thing
does that include recipes with like different wood types and interchangeable stuff?
normally shouldnt
so where di you get the idea that mc only has 379 recipes
google ig π
they better havent added hundreds of items?
well they did add like 4-5 new biomes and reworked overworld terrain generation
they added a wood type
they added deepslate
lemme just assume its correct cuz i gotta load 1000 files
and all these things look pretty legit
yeah
tf is a pink_stained_glass_pane_from_glass_pane tho π€
why wouldnt it be
it means they painted it instead of crafting it from pink glass blocks
i.e. painting glass panes pink
this game is a brainfuck
somethow the recipe files also include this crap
like it doesnt even have data :/
lmao
yeah idk shit about recipes other than that there are a lot and they suck to parse
can anyone ask that bing bot how many items mc has lol, i dont trust google anymore π
well the parsing for shaped recipes works for 100% now
what are you making btw
its just mojang that decided to be an idiot to sometimes use a json array, sometimes an object etc
a recipe loading system for minestom, as it doesnt have recipes by default
gotta implement crafting too
yikes
last time i checked there was just a big todo
I mean sounds like a fun project though
lol
doesnt seem right lmao
and it isnt aware of 1.19
its outdated af
so we went from 537 to 111
so my map tends to resize a lot lol, gave it an initial capacity of 380 places but if mc has a few thousand items π
I think its talking about reciped added in 1.18
prob
why even give it a capacity if you dont know how it should be yet xD
right
oooof
should look at my memory dump
uhh minestom is 1.19.2
adding new recipes should work, that map is gonna get resized but not too big of a deal cuz it only happens at startup
as long as mojang isnt a bitch and changes the json format
what map are you using
i was trying to figure that out a few hours ago
and to go to the conclusion, i have no damn clue if it matters
like its called initialcapacity meaning it will just scale up for more elements
ye
every single shaped recipe object seems to be 40B
22KB recipes, not bad at all
what
Ughhhhh can someone please help me with this like Im 5 years old? I just spent half an hour trying to get something working but it just ended up looking weird and I didnt understand it.
I need to save public Map<Location, ChestObject> chests = new HashMap<>(); public void loadChestData() { if(plugin==null) return; File file = new File(plugin.getDataFolder(), CHEST_DATA_FILE); // line 99 if (file.exists()) { try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file))) { Object obj = ois.readObject(); if (obj instanceof Map<?, ?> data) { for (Map.Entry<?, ?> entry : data.entrySet()) { if (entry.getKey() instanceof Location && entry.getValue() instanceof ChestObject) { chests.put((Location) entry.getKey(), (ChestObject) entry.getValue()); } } } } catch (Exception e) { e.printStackTrace(); } } else{ try { file.getParentFile().mkdirs(); // Create directory if it doesn't exist file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } }
https://paste.md-5.net/ihecicizex.java - ParticleHandler, not completely finished bcs I gave up
https://paste.md-5.net/onikeridak.java - the serializblelocation class
@pseudo hazel
I realize plugin is not properly assigned in the serializableLocation class, but thats because I gave up after already changing 50% of my code
I would reccomend using ConfigurationSerializable for the location serializer
and whats a ChestObject
The thing that my entire plugin revolves around
it stores variables for blocks
it has nothing to do with Chests
would that prevent me from having to change 50% of my code?
no
...
if you want to write something that works properly you need to rewrite most of it anyways
but the goal in the end is to do more with less lines of code
if you created a serialization for teh ChestObject and SerializableLocation you can easily store those in a yml file
Ill continue tomorrow. Too late now
is this a bug
where the result item of a smithing table recipe copies lore and display name of the base item
when in reality the barrier is supposed to say &cError
and no lore
easy fix because i just have to make an event for a PrepareSmithingEvent to intercept the result item, but its kinda annoying and seems like its unintential
Why player.setMaxHealth is deprecated in the latest version ?
it now uses attributes
Road to angular, day #1, xDD
Everything i try data is null
public GraveDataManager(Main plugin) {
gson = new Gson();
configFile = new File(plugin.getDataFolder(), "gravedata.json");
initializeConfig();
}
private void initializeConfig() {
try {
FileReader fileReader = new FileReader(configFile);
data = gson.fromJson(fileReader, GraveData.class);
if (!configFile.exists() || data == null) {
gson.toJson(new GraveData(), new FileWriter(configFile));
data = gson.fromJson(fileReader, GraveData.class);
}
} catch (IOException e) {
e.printStackTrace();
}
}
I cant figure out why
In your file it is probably written "null"
What does GraveData look like?
its blank
blank
if it's blank then fromJson is functioning correctly
but data is null
gravedata.json is empty yes
yes
Does toJson write a null file when you have an empty class?
Like
Jackson Json i know puts {} so that it doesnt throw null when reading
im switching over to gson cause its packaged with spigot
You're free to do that
but why do you expect data to not be null
if the contents of gravedata is nothing
I'm not sure how exactly I was being a dick, but you're free to think that.
tell me this isnt dickish
Any attitude you read from that is entirely your own
I legitimately do not know what toJson does in that scenario.
so I simply advised you to check the documentation instead of offering bogus advice
I apologize if I came off as mean
thank you i appologize for missreading the text
ok im back with another weird thing
public void saveData(){
try{
gson.toJson(data, new FileWriter(configFile));
for(String str : data.getLocationList()){
System.out.println(str);
}
} catch (IOException e){
e.printStackTrace();
}
}
this is running correctly
its printing the string
but it doesnt save to the file
inside data is a list of strings
Yea
and new FileWriter() is returning a writeable file?
You need to flush & close the writer
it checks if it exists beforehand
i looke dit up and it doesnt need to be closed
leme look up what flush does
Use try with resource
try ((FileWriter n = FileWriter(xxx))) {
n.dostuff();
}``` I believe is the syntax.
Yep
or be lazy and @Cleanup new FileWriter
so/16584777 :
It is better to close each open stream individually as all are separate stream. If there are some error occurs in nested stream, then stream won't get close. So its better to close each nested stream exclusively.
Sugar is tasty though
Hi, i want to make unclickable menu in chest that make command when we interact with the item, anyone have example ?
With or without libs ?
If you want without just open an inventory, and listen to InventoryClickEvent, verify if it is the good inventory and then check if it is the good item and then handle the command
With you have a lot of libs out there
SmartInvs (I believe it works in 1.19) : https://github.com/MinusKube/SmartInvs
CocosMenu : https://github.com/zitreF/CocosMenu
Idk somethings like deluxemenu i want to make it myself
Which version are you using ?
Command
Create a command, than create and open the inventory to the player, handle the clicks to execute your command with a listener
Ok but som1 say me if i do this, only one person on the server can open the inventory
Its going to close it for other people
Who said that ?
thank you, working on getting it working rn
got it
It shouldn't do this
np
Ok so its not writing the data but its writing json now.
to the file?
i try what you said
So ?
when disabling it it prints the correct information
but doesnt put it in the file
public void saveData(){
try (FileWriter fileWriter = new FileWriter(configFile)){
gson.toJson(data, fileWriter);
for(String str : data.getLocationList()){
System.out.println(str);
}
} catch (IOException e){
e.printStackTrace();
}
}
i try it soon
configFile = new File(plugin.getDataFolder(), "gravedata.json");
does it point to a valid file
when it prints it does but ti doesnt save it
hhang on it might be an issue with how i reload the plugin
i cant find anything on it
what happens when using /reload
i would assume it runs the disable and enable functions of all plugins
and no errors print
nope
ok
i found the issue
not the solution
but the issue
now its saving on disable but erasing on enable so where i initialize it smthng is wrong
Show your Main class
theres a lot going on ill just show you where i initialize the config
private void initializeConfig() {
try (FileReader fileReader = new FileReader(configFile)) {
data = gson.fromJson(fileReader, GraveData.class);
if (!configFile.exists() || data == null) {
System.out.println("Hello");
data = new GraveData();
saveData();
}
}catch (IOException e){
e.printStackTrace();
}
}
?paste
package me.silentprogram.rees.data.graves;
import com.google.gson.Gson;
import me.silentprogram.rees.Rees;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class GraveDataManager {
GraveData data;
Gson gson;
File configFile;
public GraveDataManager(Rees plugin) {
gson = new Gson();
configFile = new File(plugin.getDataFolder(), "gravedata.json");
initializeConfig();
}
private void initializeConfig() {
try (FileReader fileReader = new FileReader(configFile)) {
data = gson.fromJson(fileReader, GraveData.class);
if (!configFile.exists() || data == null) {
System.out.println("Hello");
data = new GraveData();
saveData();
}
}catch (IOException e){
e.printStackTrace();
}
}
public void saveData(){
try (FileWriter fileWriter = new FileWriter(configFile)){
gson.toJson(data, fileWriter);
} catch (IOException e){
e.printStackTrace();
}
}
public GraveData getData(){
return data;
}
}
theres not a lot
but i have multiple "main classes"
its a plugin for a friend so i broke a few rules
I just want the "onEnable" method and the "onLoad"
private void startup(){
dataManager = new GraveDataManager(plugin);
data = dataManager.getData();
plugin.getServer().getPluginManager().registerEvents(new DeathChestListener(this), plugin);
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
dataManager.saveData();
}, 0, 1000);
}
π
this is run onEnable()
ONENABLE
Is that all that's inside your onenable
@Override
public void onEnable() {
saveDefaultConfig();
startup();
}
private void startup() {
configManager = new ConfigManager(this);
if (configManager.isGraveEnabled()) {
gravesMain = new GravesMain(this);
}
}
package me.silentprogram.rees;
import me.silentprogram.rees.data.graves.GraveData;
import me.silentprogram.rees.data.graves.GraveDataManager;
import me.silentprogram.rees.listeners.DeathChestListener;
public class GravesMain {
GraveData data;
GraveDataManager dataManager;
private final Rees plugin;
public GravesMain(Rees plugin){
this.plugin = plugin;
startup();
}
private void startup(){
dataManager = new GraveDataManager(plugin);
data = dataManager.getData();
plugin.getServer().getPluginManager().registerEvents(new DeathChestListener(this), plugin);
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
dataManager.saveData();
}, 0, 1000);
}
public void disable(){
dataManager.saveData();
}
public GraveData getData(){
return data;
}
}
onEnable
yeah show me your "GraveDataManager" class
hier
ye here
the print hello is for testing
most reliable debugger
honestly
ok i think its working but all i did was remove the print hello
so idk
π
Dude, I LOVE GITHUB COPILOT
Whats the new way to get a minecraft skull
the material used to be SKULL_ITEM whats the updated material name?
cant find anyhting on the forums
its all outdated
nor the documentation
PLAYER_HEAD iirc
Yep
thank you
it would be a string that has world,x,y,z,pitch,yaw
target if maven, out/build if ij build system
Is there any way to run code on the next tick if a plugin is being disabled, or is that absolutely impossible?
X,y,z also double to teleport to the center od block
You can also take in care that locations are serializable/deserializable objects, so you can directly do:
Location location = ;
Config config = ;
config.set("game-location", location);
Location loc = config.getLocation("game-location");
When you forget your login so you canβt verify
For foro related issue you must contact an staff
Mainly contact a forum staff
They can help you
But don dm them
tmp-support (at) spigotmc.org
right, but they take such a huge time for response haha
Anyways, I need some helpπ€£ Iβm lost in the sauce with creating a plug-in that when you break a certain block that is listed in a custom yml after breaking so many of any of the blocks it drops an item
so you have a list of blocks, and if you break it x times, you want it to drop something?
sorry for pinging tho, it wasnt my intenttion
it's all good
Hi, stupid question how can i get whereβs the player is watching and spawn a particle in front of his visual?
You have to get the player eye locaiton if im not wrong
could also getLineOfSight no?
I tried the eye location but it spawn in the middle of the player model
or getTargetBlock?
If it is air doesnβt get a null
Do you want the exact hit location (so block or entity hit)
or do you just want a few Blocks in front of the Player?
Blocks are not null, they can be air
you can always just check
2 one
blocks can be null on ray traces etc
Thereβs a list of blocks that count towards the X amount, once the X amount of broken blocks has been reached it drops a custom item
yeah, but he is not using ray trace
What?
Just a few block in front of the player
I can explain my thing alittle more
okay i understand what you need
getTargetBlock uses ray trace
that doesn't return null tho
Oh lamo thats is new, i never heard about it
Mainly 1.19 for sure π
- Get his eye location
- Get the getDirection() vector
- Multiply direction vector by N (N is the distance you want to show particles)
- Add direction vector to eye location. Now you have a location in front of the player
Thanks
I can help you
I understand what you needing
You wanna go to dm or?
what part do you need help with specifically?
I was looking at getTargetBlock(), not exact which makes more sense
Ima be honest like the entire thing, this has me confused af, I spent like 8hours today watching a spigot coding course tryna just learn different shit about spigot and none of it has come together to help me get this thought into the code
Oh no dont do that
If you really want to code plugins, start from beggining
I am
Learning Java
Oh yeah this method use a BlockIterator instead ofc. But it doesnt account for a bunch of things like Block shape
It has a Java basics section i have gone through
I woud straight forward suggest learning Java, and not touching spigot api
I should have a general idea of the basic Java stuff that will get me through most of the stuff
I would mainly recommend learning Java concepts, like fields, types, POO, sync and async, etc
There are lot of things more ofc but its a mess naming all
No, python is whole ass
Hahaha
Dont u agree? Hahaha
oh right, programing tis something you must really like
Get more familiar less ass it becomes
If not, dont go there
Well then just use 2 structures:
A Map
A List or Set
The Map contains players as keys and Integers as values.
Use the UUID of a Player instead of the Player itself.
Map<UUID, Integer>
When the player joins: Add him to the Map
When he leaves: Remove him from the Map
The value in the Map is your per-player counter.
On BlockBreakEvent: If broken block material is in your List/Set
-> Get the int of that player from the map, increment it by 1 and write it back in the map
-> If this counter is X then drop an item and write 0 back in the map again
Removing them would mean if they broke letβs say 20 blocks and the amount is set at 22 to give the reward, if they leave and join back does that progress reset?
Yes if you dont save it into a persistent storage
Yes the progress resets then
All java types are memory mainly
Ok so noted, ima need to have that stored somewhere
I donβt want the progress to reset
Yes, either FlatFile or Database*
My bad its 3 am and im kinda sleeping
Cyao
You good
Get this working first and then we can help you with persistence.
Ima need to get a lot of other stuff working before i even do that
Iβm still stuck on square 1, the startπ€£
I hope to add some advancements to my server, but I didn't found how to register them
besides I didn't found a function to set their parent
Gson π
Yes. But Spigot also provides Gson on default.
If you make a lib for spigot plugins then you should depend on Spigot
Ah ok
You can serialize everything with Gson
This doesnt block projectile attacks
Or flint&steel
Or lava buckets
BlockIgniteEvent or PlayerInteractEvent. Both work
I want to create a 3 * 9 inventory for a confirmation-gui.
The only thing I can't wrap my head around is how I will automatically move the items to the slot I want (basically slot 11 and 15).
oooh
Well how much java knowledge do you have? Because there are some more advanced concepts in this guide.
and what covers this?
a fair amount. been coding for a couple years
just had a break lol
Alright, then this guide will teach you how to write your own GUI lib which you can use to pump out
dozens of GUIs in no time.
This is actually super interesting, ty
would also be interesting for me since i didnt account for that either lmao
You need to cancel PlayerInteractEvent if the player holds a lava bucket
Unless you want to let them place the lava but only prevent the damage. This would be complicated but doable.
rather the 2nd one tbh
Then you will need a manager that keeps track of placed lava blocks and where they flow using the BlockFromToEvent.
oh yeah what i was wondering but never really researched tbh, when i implement a listener, can i just add multiple events in one method?
oh damn
You are not allowed to ever create an instance of your JavaPlugin class
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
It is, but you can still use dependency injection
Wait you're supposed to parse null when setting the owner of a created inventory? o.O
?
i'm reading the gui guide
whoops
wrong link
i mean like... does it make a difference wether you parse the player or null?
Well you can also create your own custom InventoryHolder but thats a whole different approach to GUIs
Can I jusy leave 'getcriteria' null when creating a new advance ment
Not really
naaaaah don't need that. i've just been using the player
it will be given by a listener
also if i wanted to create a vault-system... how would i save the inventories that belong to a player when restarting the server? or just saving the items in those inventories in general?
just saving them in a file?
Youβll have to decide if you want to save it to files or a database or wherever
ic
you can create a database i think
You can, thatβs not necessarily the best way
database? o_o haven't done that yet at all
Really depends on your use case
Sure. Or if the inventories need to be consistent between servers then in a Database
^
ahh
ic
so basically if it were a bungee-server it would be a database?
interesting
well not my use case tho
lmao
Well you can just dump the whole inventory in a Base64 String and save it as blob.
Then DB is as easy as a File.
soooo, would i just save it in a HashMap or sum?
:o
okay that's new land for me lmao
damn
Yeah but thatβs not exactly elegant use of a database lmao
Could use an object store or something too
You can put the inventories in a Map<UUID, VaultInventory> when a player joins and save it when he quits gain.
yeah that would be my thinking as well
- async saving the map every 15mins or so because of crashes
or upon closing the inventory... but i guess that's not that... optimized?
Depends how risk averse you want to be
You can save it periodically, or you can save when they close
could it be funky when multiple players use it at once?
If you save when they close itβs not quite as optimized for writes because you may be writing it a bunch of times, but you wonβt lose any data if the server crashes
i suggest that if there'll be lots of players joining your server, it'll be faster to use a database
I donβt see how, unless youβre putting them all into one file
The problem with writing on every close is properly handling all the IO.
IO shall not be done on the main thread or your server will just lag for sure.
i'm not really thinking of that kinda usage tbh. also bc minecraft servers are dying
I would hope they arenβt doing any IO on the main thread anyway
like every known server i know
*And you can not read it again while you are saving. So this has to be taken into consideration.
oh that's fair
hmm
I mean, not just the online players but all players who have ever joined your server
That would have to be really slow IO to be an issue tbf
You wouldnβt be writing the whole server every time you write
Anyway you should not delete their data even if they haven't log in for a few month
If youβre storing it in files I would also hope youβd compartmentalize it by player
i haven't done ANYTHING with databases so that would be kinda out of the question for now
duh
The best time to learn something was yesterday
The second best time is today
Lol
Average DB access on a DB on the same machine is >25ms
On decentralized machines its easily >100ms depending on the DB size, your connection
speed and what type of persistent storage is used.
Thats 50% of the servers tick up to 200% of the servers tick.
This will lead to lag, no matter what.
Iβm talking about canβt read while youβre writing
you can try mysql i think
Ah ok XD
You should never do IO on the main thread
Yeah i sure hope the OS handles this
My database is called just another markup language
But the chances of the player closing their vault inventory and being angry they canβt reopen it within those 100ms
Is very small
Blazing fast
wow okay i know so much less than i expected o_o
There shouldnβt really be any user input for an sql injection to occur here to be fair
Just dump the inventories into files for now. <UUID>.json or <UUID>.yml
One file per player. I can hook you up with the serialisation if you want to,
That would be my recommendation
It's fast too
oh shit a file per player? o.O
the whole files?
One file per player yeah
That's faster than 1 file for entire server
really?
Significantly
i always thought the more files the worse
Yeah cuz you get smaller files
huh
sure. Create a folder in your plugins folder player-vaults and in there you have dozens of files. One per player.
ohhh that makes sense
If youβre trying to access them all at the same time sure
Just just werks
But youβll only be doing one at a time anyway
okay that makes sense tbh
That's how I do it in my plugin
The problem here is:
If you have stored 1000 player vaults in a file and you want to load only one vault when
a player joins then you would have to load that giant file just to read one vault from it.
^
Youβre doing more selective reads than mass reads so it makes sense to split it up
oh that's very true
damn
If you were mostly going to be reading everybody then one file might be better
OH MY, I got another idea for a new thing :D
With this you let the OS handle all the hard work:
File playerFile = new File(pluginFolder, playerUid.toString() + ".yml");
if(playerFile.exists()) {
// load data from file
} else {
// create data for new player
}
Not atomic, bad /s
Atomic?
-.-
okay i would have to think about how exactly to implement all that but that's really nice :D
Why atomic
Wdym why atomic
Why
Why what
Well I was making a joke that you canβt be sure the file still exists when you try to read from it after the check, and you canβt be sure the file doesnβt exist when you try to create it after the check
Because the operation there isnβt atomic
Now, in this use case that isnβt really required, so it was more a joke
Resources
In that resources folder
Is that intellij thing rly?
Looks like it
I just have it in src lmao
Not really no
bc i created the project before i was using intellij plugins and never bothered to change my system xD
I mean you can theoretically have it anywhere
Itβs just convention for it to be there
like me in src π
Probably messages
NO WAY
shouldn't the translations be placed in assets.lang.(**.lang)?
π
i mean, ig it depends on how u implement it
Depends how many languages you intend to support I guess
thanks
I mean just recently I added translations to my lib
Before I had everything in config
That's also a good way
I'd stick to en.yml or en-us.yml
Well I wonder can I just leave 'getcriteria' returning null when creating a new advancement
Try it and see