#help-development
1 messages · Page 869 of 1
any errors in the console?
there is a max length limit for messages, but I don't remember how much that is
you can send arraylist to players??
i dont think so
yes there is
nope it just sends a blank line to me
show the code
ok
Whats the best way to show countdown timers inside lore of an item that's sat inside a inventory? can't be move etc. Loop the inventory while open?
256k bytes it seems, neat
256kb
256k / 2 => amount of chars
not necessarily
You’re assuming it’s just raw characters
isn't it
But there’s also the component data
not if it's utf8 encoded which I think it is
true
utf8 means each character is 1-4 bytes
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
if (warpsc.getConfigurationSection("warps") != null) {
commandSender.sendMessage("§bAvailable Warps: §f" + String.join(", ", GetWarpList()) );
} else {
commandSender.sendMessage("§cThere are currently none existing warps.");
}
return true;
}
there
tf
example like Available warps: home, castle, etc
open chat and scroll up
type something in chat and then run the command
and open chat
and see
2 empty lines?
wtf
this wasnt an issue before but when the warps list got really big it went empty like that
split the warp list into a multiple messages
bro your minecraft is broken
it's happening to other people too
but apparently
it does work in console tho
isn't it strings.join thoug
or maybe same thing
yeah im using String.join
Anything in the client logs
Because looking at that code it should always send something
nope nothing just the empty line in chat
it used to work but stopped working sometime when the list got pretty big
try removing the String.join part and see what it logs then
if not you could always debug with breakpoints
So I'm making an armor system that gives buffs to the player. Would the best way to do this is make a custom nbt which has all the armor buffs then grab the nbt each time?
I feel like this would be the most efficient way
yes
if im correct there is no such thing as a haste attribute so what would be a way of giving a player haste without an Effect
packets
Uhh, manually block breaking system
👍
block breaking packets
not haste packets
you could make a custom mining system
anything i can do thats easy?
haha
i dont want to a million lines now
cause its tzhis smal ting
in my large ass code
im sure you do
not the actual code, the implementation of it
Everyone has the hypixel mining system code
real y2k?
basically
I mean you don’t even need any packets for it on modern versions
Well, maybe for client side effects
Well then yeah you only really need the BlockDamageEvent, BlockDamageAbortEvent, schedulers, and player.sendBlockDamage
same result :/
still sends me an empty line
but still works in console
try different client
same result lol
this happens for everyone else on the server btw
What kind of stats
send something simple like "Hello" and see
still doesn't work then other problem
I think they said it already, if the list is long its not showing on the chat
yeah ^ i think that's the problem
wdym by this, sending messages per warp?
@young knoll @Staff very important question what sounds better
Transaction#submit or Transaction#complete
complete
Are you sending it off to something
class RepairTransaction(private val item: ItemStack) {
private val meta: Damageable = item.itemMeta as Damageable
private var expRequired: Int = 0
private var damage: Int = 0
private var conditions: MutableList<(Player) -> Boolean> = ArrayList()
private var failure: (Player, FailureReason) -> Unit = { _, _ -> run {} }
private var success: (Player) -> Unit = {}
fun exp(exp: Int) = apply { this.expRequired = exp }
fun damage(damage: Int) = apply { this.damage = damage }
fun success(function: (Player) -> Unit) = apply { this.success = function; }
fun failure(function: (Player, FailureReason) -> Unit) = apply { this.failure = function }
fun condition(function: (Player) -> Boolean) = apply { this.conditions.add(function) }
fun submit(player: Player) {
if (!conditions.all { it.invoke(player) }) {
failure.invoke(player, FailureReason.FAILED_CUSTOM_CONDITION)
return
}
if (player.getTrueExperience() < this.expRequired) {
failure.invoke(player, FailureReason.NOT_ENOUGH_EXP);
return
}
meta.damage = this.damage
item.setItemMeta(meta)
success.invoke(player)
}
enum class FailureReason {
NOT_ENOUGH_EXP,
FAILED_CUSTOM_CONDITION,
}
}```
Or are you just finishing it
also I should switch FailureReason to a class instead of an enum
I just thought that'd be much more flexible
The heck is getTrueExperience
bukkit experience is jank
its an extension function that actually gets the correct value
not my code
Transaction#transact
public <T> T getUserData(UUID id, String location, Class<T> type, T def) {
if (data.isSet(formatLocation(id, location))) {
return type.cast(data.get(formatLocation(id, location)));
}
return def;
}
Im scared to test this as I dont wanna break user data
Would this work for MemorySelection/FileConfiguration for getting a users data?
Or is this risky to do because instead of using something like getBoolean for a boolean, im casting it directly to the type
You should at least check before you cast
What would be the best way to check?
Class#isInstance
So like this?
public static <T> T getUserData(UUID id, String location, Class<T> type, T def) {
if (data.isSet(formatLocation(id, location))) {
Object value = data.get(formatLocation(id, location));
if (type.isInstance(value)) {
return type.cast(value);
}
}
return def;
}
Yeah looks alright
You could store the result of formatLocation in a variable so you don’t call it twice
Good idea
Found out that MemeorySelection has a getObject (which asks for a class)
But im reciving unboxing errors for booleans and have 0 idea why that is
Infact a lot of things are returning as unboxing warnings, like Integers
Warnings or errors?
Just warnings
I think I know why though
Its cause theres a chance of there being a null
And I added a check and it disappeared
let's go
Result of 'PlayerData.getUserData(p.getUniqueId(), "TagEquipped", Boolean.class).equals(key)' is always 'false'
lovely now this pops uuppppp
UGHHHH
I dont understand why that decided to show up
I want to change the name of all diamond swords in the player inventory in the game to a random name every 1 minute.
But how can I do this since I cannot do this with any event?
Scheduler
So we don't use timers only in event methods?
What
I thought I could only call schedulers within event methods
Yes I ask a lot of questions lmao, this I cant find the answer to anyhwere online
public MetaFuncs(ItemStack item) {
this.item = item;
this.tags = new LinkedHashMap<>();
ItemMeta itemMeta = item.getItemMeta();
if (itemMeta != null) {
PersistentDataContainer dataContainer = itemMeta.getPersistentDataContainer();
for (NamespacedKey key : dataContainer.getKeys()) {
Object value = dataContainer.get(key, perst.getOrDefault(key.getKey(), PersistentDataType.STRING));
if (value != null) {
this.tags.put(key.getKey(), value);
}
}
}
}
Is there a generic type for PersistentDataType? For any class type including weird ones like a String List?
Create custom datatype
I cant seem to find anything to do that and id like to allow for any persistant data type to be used instead of purely just strings
Use ByteBuffer as helper
I have custom ones, like this:
public class StringListTagType implements PersistentDataType<byte[], String[]> {
public StringListTagType() {
}
public @NotNull Class<byte[]> getPrimitiveType() {
return byte[].class;
}
public @NotNull Class<String[]> getComplexType() {
return String[].class;
}
public byte @NotNull [] toPrimitive(String @NotNull [] complex, @NotNull PersistentDataAdapterContext context) {
Gson gson = new Gson();
return gson.toJson(complex).getBytes();
}
public String @NotNull [] fromPrimitive(byte @NotNull [] primitive, @NotNull PersistentDataAdapterContext context) {
Gson gson = new Gson();
return gson.fromJson(new String(primitive), String[].class);
}
}
Im unsure how id approach this perfectly however, to work with ANY class
Noo dont use json
I dont like the idea of having to manually do it one at a time
Okay, but Im still stuck on my other question
As to how I can use generic classes with PersistantDataTypes
Yeah I get that but thats not hte implementation of generic classes
Im talking be able to do PersistantDataType<T, T>
Here ill give an example
public void materialize(ItemMeta itemMeta) {
for (String key : this.tags.keySet()) {
Object value = this.tags.get(key);
PersistentDataType dataType = PersistentDataType.STRING;
if (value instanceof Integer) {
dataType = PersistentDataType.INTEGER;
} else if (value instanceof Integer[]) {
dataType = new IntListTagType();
} else if (value instanceof String[]) {
dataType = new StringListTagType();
}
itemMeta.getPersistentDataContainer().set(new NamespacedKey(Main.instance, key), dataType, value);
}
This is part of my code to materialize the keys back to the item for my MetaFuncs class
I want it so PersistantDataContainer can use Generic classes and not specific classes
Similar to what I did here:
public static <T> T getUserData(UUID id, String location, Class<T> type) {
String format = formatLocation(id, location);
if (data.isSet(format)) {
Object value = data.get(format);
if (value != null) {
if (type == Boolean.class && value instanceof Boolean) {
return (T) value;
} else {
return data.getObject(format, type);
}
}
}
return (T) "null";
}
Ignore the fact I used a string for null, it wouldnt silence the "potential null value" warning
its temporary
However if this isnt physically possible thats fine, I would like for it to be a possibility however
Is there a way to check what the PersistantDataType of an object is beforehand then?
You should do proper implementation
That way I can just create a list of the ones I need
Honestly I didnt think of this beforehand when coding and thats entirely my fault
I made this MetaFuncs code back when I had started to learn java to code spigot plugins
And havent made really big changes since, but realized inefficiencys with it and was wanting to fix them
I dont know a ton on how PersistantData works with the containers so I decided to ask how I could do so
Anyone got a good Subcommand & tabcomplete template?
general advice would be to use a real command framework
like cloud, acf, commandapi, ...
or you can code your own if you really feel like torturing yourself
for example i made mine around a managment framework
Speaking of however, is there a way to do this?
no
Well im stumped them on how to do this
Like what how buffer handle data so?
they write everything into bytes and an int for the lenght of the data, seems good
huh?
not like a buffer specific, more like data serialization
serializing it to json is not the way
wrap the byte array with Guava's ByteStreams, read a length int, read x bytes, turn the read bytes into a string, append to list and repeat until you reach an EOF marker or read x items from a list length written at the beginning of the stream
You can use the new list type
declaration: package: org.bukkit.persistence, class: ListPersistentDataTypeProvider
Well thats useful, im still confused on how I can check what persistantdatatype is being used from a key
you'll have to loop over the existing types and check if it's the correct one https://github.com/mfnalex/CustomBlockData/blob/master/src/main/java/com/jeff_media/customblockdata/CustomBlockData.java#L367
Do you mind if I use that segment of code and credit you?
As this is awesome
sure, np
Yay my code works now 👍
protocolManager.sendServerPacket(target, packet);
} catch (InvocationTargetException e) {
e.printStackTrace();
}```
error is Exception 'java.lang.reflect.InvocationTargetException' is never thrown in the corresponding try block
any Idea?
the try-catch is useless
apparently not in the throws then
ITE is checked, so it either has to be defined or PLib/whatever uses a trick to rethrow it unchecked
okay
Throwing checked exceptions without declaring them isn't nice
Well I just finished removing static abuse from a bunch of my code
Does anyone know?
As long as it works why worry?
I might use entityremovefromworldevent tho
Or just be normal and use entitydeathevent
They all don't work, i found out after writing this xd
ItemDespawnEvent is for dropped items, EntityDeathEvent for living entities, and EntityRemoveFromWorldEvent doesn't have a cancel method
It should work. Did you try to debug it?
ItemDespawnEvent
Unless if you have a plugin like ClearLag that manually clears dropped items every x seconds
Actually I think arrow isnt a dropped item. Its an entity of some sort
but ItemDespawnEvent.. should still catch it
EntityRemoveFromWorldEvent.. if it doesnt have a cancel method, you could just get the current entity thats about to despawn and spawn a new one of the same type and everything
I will try this thank you 🤝
What is the best way to get random rewards based on their chances.
This is what i currently have (its very bad)
public Reward getRandomReward() {
double random = Math.random();
for (Reward reward : rewards) {
if (random < reward.getChance()) {
return reward;
}
}
return null;
}
Do you know how to make a dice? if you do
Make the first number of the dice 0, and the last number of the dice "chance" and assign a higher number to chance if the chance should be lower
a dice? are you talking about random ints?
please never call random ints dice again
ints are numbers
so essentially random ints are random numbers
ints are whole numbers
-1,3,926,-192
etc etc
you can use the random object to generate a random int
or a random whole number
So is my answer to their question wrong or did I just say it in the wrong way?
It was an example
a weird one xd
you are assuming someone knows how to code a dice using random ints but doesnt know what random ints are
thats
very confusing
in the code snippet the user has provided it shows that they are using the Math.random() class, so im assuming they know what random ints are?
number = random.nextInt(x) + 1;```
Assign 100 to "x" for the items you want to be 1% chance and 10 for the items you want to be 10% chance
thats not too bad, cache the Random though
make it static
on top of the class
if you've used Random... yeah not for Math class
Got it, thanks!
double random = spr.nextDouble(getTotalChance());
for (Map.Entry<Material, Number> entry : items.entrySet())
if ((random -= entry.getValue().doubleValue()) < 0)
return entry.getKey();
return Material.COBBLESTONE;
}```
I used this to get random Material. Get the random value from the total weight (chance) of all keys, loop through the map entry, if the value of random after subtracting the weight of the entry is less than 0, the key of that entry will be selected.
I feel like that makes some items very biased lol
Hey guys Im using database and I have two questions
Am I have to use Mysql with Redis?
What is advantage to use Redis?
each have their own advantage based on your use case
How would I retrieve Villager entity object from InventoryClickEvent from Merchant Inventory
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/MerchantInventory.html#getMerchant() this?
declaration: package: org.bukkit.inventory, interface: MerchantInventory
oh wait..
there is not way to retrieve entity
even if u got getMerchant
and you check like getMerchant instanceOf?
well merchantInventory.getMerchant() instanceof Villager)
return false
any instanceOf return false?
print getClass().getName() ¯_(ツ)_/¯
if I start a new thread from my code and the /stop the server, will it stop the thread too or will it keep the server up?
what unspoken hackery are you trying to achieve?
Hax
The thread will outlast onDisable but will still die to the process termination iirc
unless bukkit does sumn hacky
which it prob does
I'd clean your shit up onDisable tho
just making sure my three threads don't harm the server stopping lol
Like for love of god
?scheduling
TL;DR yes
Hey anyone has experience with creating a economy provider for Vault?
When I register my custom economy provider it doesn't seem to work because when I use Vault API to deposit money it gets added to essentials balance and not my custom provider balance.
logger.info("Registering CoCEconomy as a Vault economy provider...");
economyProvider = new EconomyProvider(this);
if(Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) {
logger.severe("Missing Vault dependency");
getServer().getPluginManager().disablePlugin(this);
return;
}
Bukkit.getServer().getServicesManager().register(Economy.class, economyProvider, this, ServicePriority.Highest);
Economy adapter = Bukkit.getServicesManager().load(Economy.class);
logger.info("Registered economy adapter: " + adapter.getName());
Here I log the adapter on the last line and it prints my adapter name instead of Essentials one.
So it seems like it registered properly but Vault doesn't seem to use it.
Hello, I have a problem, I am coding a Minecraft plugin for the first time by following tutorials, however an error is preventing me from continuing: "Incompatible operand types ItemType and Material"
ItemType?
depend on what?
I already have my economy plugin depend on Vault so it loads after Vault.
The other plugin that uses Vault API to deposit money depends on Vault and my economy plugin so that loads last.
ItemType isn't in the API yet
How so ?
I don't know what ItemType you're using. What does your code look like? Where is ItemType imported from?
it's the code :
package fr.DreamerXU.PowerGems;
import java.util.Arrays;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@SuppressWarnings("deprecation")
public class PowerGemsLestiners implements Listener {
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
player.getInventory().clear();
player.getInventory().addItem(new ItemStack(Material.IRON_PICKAXE, 2));
ItemStack customsword = new ItemStack(Material.IRON_SWORD, 1);
ItemMeta customM = customsword.getItemMeta();
customM.setDisplayName("§cMa super épée custom");
customM.setLore(Arrays.asList("première ligne", "deuxieme ligne"));
customM.addEnchant(Enchantment.VANISHING_CURSE, 1, true);
customM.addItemFlags(ItemFlag.HIDE_ENCHANTS);
customsword.setItemMeta(customM);
player.getInventory().setItemInOffHand(customsword);
ItemStack customwool = new ItemStack(Material.WHITE_WOOL, 8);
player.getInventory().setHelmet(customwool);
player.updateInventory();
}
@EventHandler
public void onInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
Action action = event.getAction();
ItemStack it = event.getItem();
if (it != null && it.getType() == Material.DIAMOND_HOE) {
player.sendMessage("Vous venz de faire un click");
}
}
}
Hey i want a plugin helphIs there any command from which i can make znpcs work as a consoleIf a non-op player cliks on that znpcSo it gives creative
Oh. Item_Stack_, not ItemType
.
Honestly your snippet looks fine. I don't see any incompatible equality checks here
that wouldnt make sense either
Probably a better question for #help-server
there is nothing wrong with it
No one answering me there..
then be patient
It's been 3 minutes :p
The only thing that is mildly annoying me here is the package name
ok, I'll try, thank you for your help
ok sorry
But your code looks fine. I don't see any issue with it. The error you sent doesn't make sense. Did you save the file?
And another thing is, are you sure it even is in that class
yes
Where is the error and what is the error exactly
you could try to invalidate caches
but in the line import org.bukkit.Material;
material is crossed out
I can't upload an image, but it looks like this: import org.bukkit.Material;
Hey I'm working on a plugin that lets you take exits in a minecart highway, anybody got simple ideas for if you want to go east/west when entering the main line? I'm using an overpass thing here
and the error is in :
if (it != null && it.getType() == Material.DIAMOND_HOE) {
player.sendMessage("Vous venz de faire un click");
}
what api are you using
me ?
sorry, but i don't understand
You clearly aren't using spigot api we can't help you
i use this API : spigot-api-1.20.2-experimental-20231021.103123-1
Why are you using experimental if you're toying around with it you should know what you're doing
I didn't know exp builds existed
In the experimental builds Material has been deprecated in favor of ItemType and BlockType please use them accordingly
thank you for helping me, it works, have a nice day
Sometimes I wonder how people even get a hold of that
Fr
Yeah its not even on the repository I'm pretty sure
You specifically have to seek it out
Buildtools can build it
I dev spigot for more than one year and I didn't know that
But you either need to know the flag or click the gui button
And the gui button comes with a nice big warning
Experimental spigot api builds are hosted on the spigot repo
lol, but why? That just makes the devs who are just starting out have their worst experience, as they get stuck with the first thing they see a lot of the time.
new devs should import the regular builds
Experimental builds should still be able to be imported for tests but not as easily accessible ???
So just make it a niche odd version that no one remembers and call it a day
To give developers the option to start migrating / testing there plugins with the api changes.
And potentially provide feedback.
Does anyone know a good way to execute something when a very specific time has met? Example, execute some code when the time is exactly 6000 ticks
i use timestamps, you can also use an schedule
scheduled tasks maybe, is better idea to what ive said
For being real, with the time going of the years spigot is destroying their good api that used to be 1.8 , 1.9 and up to 1.12 compared to new apis
what do you mean exactly? I got a repeating task that runs every 20 ticks.
but what you trying to do?
Whenever a specific time is reached, I want to execute a piece of code, but only once. I know I can use a boolean flag to avoid this, but is there no other way?
So the problem is also more about, what is reliable? As currently I am using if time >= 6000 && time <= 6020 (which I don't like at all)
Just use runTaskLaster one
Its executed 1 time, its queue and once the time go away its executed
And how am I going to check when that very specific time tick is reached? it's not about delaying, it's about executing for example exactly during midnight
you have to be really specific when asking MrGeneral
because then we have this type of confusions and not really good comprenhenssion of your objective
Apologies if it was confusing, but is the problem statement clear now? I cannot find a way to do this in a reliable manner without having a task run every tick
But the range is not reliable, so I'm looking for a way to do this without a range of ticks. And executing every tick, could potentially cause performance issues
so I I were to configure my taks to run every tick, and I don't make it too heavy, should be fine?
its minecraft, you are not creating a buisness 😂
Not sure what that means, but I'll remember that
we really over engeenier many things about minecraft, and we end just losting time. Instead of using what first works and not giving many rounds around it
is basically the first rule of development, if it works, don't move it
Believe me, I prefer not changing it, but users sometimes experience the code running twice and as a result some other things happening. I'll most likely mark this is a bug with low probability and move on
Anyhow, thank you for the ideas
is there a way to do like a hopper in an Bukkit.Inventory?
or something like inventory.append(itemstack)
When running my plugin i get a java.lang.NoClassDefFoundError error. I never had this before and I didn't really change any code. What could cause this?
https://paste.md-5.net/cuhegohufi.xml
you can iterate over hte inventory contents, and then add the item to the empty slots, and you can try to stack over items with the existing material
yup thats what i'm gonna do thx
Your server is trying to find the SpawnCommand class. Try rebuilding your plugin and make sure to wait until it is completed
already tried that a couple of times and did it again just to make sure but didnt fix it sadly
Where is your SpawnCommand located?
How are you building the jar?
cant send pics here but in a package named commands which is in gg.school where also the Main class is
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
https://i.imgur.com/7EqZYrg.png with the "package" thing
it's supposed to be under: gg/school/commands/SpawnCommand
well the code is ye, i thought u ment the class
The error literally means that your server is trying to find your class under that path .If it's not there, you get that error
if i decompile the plugin again, its there, thats why im just not getting it why it drops an error
did you restart your server?
Clean and then package
omg that worked lmao
thank u so much
do u have an explanation of what the "clean" thing does?
i see, ty
guys anyone knows why protocol lib latest version doesn't work in 1.20?
Hello people of the spigot discord. I am currently having some issues with my invsee command and have no idea how to fix it.
So the command when ran will open up the specified person inventory. And I have implemented a way to make it so when the person who has the inventory open and makes an edit like moves the an item to a different item slot it should update on the player's inventory and it does not. the code of my plugin. How would I make so it does that.
https://pastebin.com/gMXUDHAh
Hey! I've released some time ago my first plugin, and now that I'm planning for a v2, I wanted to know if someone could help me out and help me review my code, because it's very far away from perfection and I know there are a lot of issues, but I don't know where to start. I can send the repo if someone is willing to help, don't wanna make any kind of self-promotion or anything. Thanks!
Doesn't just opening the other players inventory allow this?
post a github link
precisely does. Though I'm not sure for how long this should be considered support behavior
Are inventories like one per player meaning new objects aren't made
considering it just maps the inventory to a GENERIC_9x4 menu and is absolutely disgusting
internally?
yeah
It must not? I am kinda creating an inventory with Bukkit.createInventory
like how does it work
Have you tried just opening the other players inventory for the other player?
I will change my code to try that.
Internally inventories aren't really a huge deal. Internally what bukkit calls Inventories are called Containers and the real deal is Menu's aka InventoryViews. I mean if you think about it its a glorified ArrayList
also why does bukkit create a new Player every tick
Inventories are just arrays mapped to slots on the client
it doesn't afaik
Inventories don't actually even do the mapping its legit just an array xD
so wait, is it safe to cache a Player as a field
no
depending on the lifetime
It's safer to just use UUID
for Menu's I usually preserve the field object because it'll be thrown out when the player logs off
so I save the player object in the field since I know it won't stay in scope outside of its expected life time
when it comes to caching data in Maps etc player object is usually a dumb idea
no
I'd have to double check but I'm pretty sure the hashcode is just the UUID
Checked out new ListPersistentDataTypes, and now my code is unable to distinguise an array from a regular value
for (String key : this.tags.keySet()) {
Object value = this.tags.get(key);
NamespacedKey namespacedKey = new NamespacedKey(Main.instance, key);
PersistentDataType dataType = PersistentDataType.STRING;
for (PersistentDataType<?, ?> persistentDataType : PRIMITIVE_DATA_TYPES) {
Class<?> cls = persistentDataType.getComplexType();
if (cls.isInstance(value)) {
dataType = persistentDataType;
break;
}
}
itemMeta.getPersistentDataContainer().set(namespacedKey, dataType, value); //Errors here
//The provided value was of the type String[]. Expected type String
}
From what im aware, PersistantDataType.STRING == ListPereistentDataType.STRING
So im unsure how to tackle this problem
So then
At least thats what intellij says
what
??
I could've sworn when I used a player key it didn't work
those aren't the same thing
IntelliJ is telling me it is
ListPersistentDataType.STRING is a list
For some reason
Changing it to viewer.openInventory(targetPlayer.getInventory()); has indeed fixed the issue thank you
ok nvm now its not wth
0 idea why it was before, it was giving me warnings about it
beat you to it @quaint mantle
you're welcome
I'm on a phone
if (hash == 0 || hash == 485) {
hash = 97 * 5 + (this.getUniqueId() != null ? this.getUniqueId().hashCode() : 0);
}
return hash;
yeah its just hte UUID prey much
it does, until the object gets collected
I mean pleanty of plugins use Player as a key even though its stupid its done
Oh wait nvm
I know why it didn't work
I think I did String, Something
But I called Player#toString
"The provided value was of the type String[]. Expected type String"
Just updated the array and its still saying the same error (both list and basic types)
Class<?> cls = persistentDataType.getComplexType();
Would this line have something to do with it screwing up, if so what is the best solution to check if its a list or regular value
This was like a year or so ago tho
I mean technically you can store it and add/remove on join but man alive that gets so difficult to deal with
seems like a learnjava moment
UUID is king
Ye I use uuid only now
this seems demening but I came up with a solution anyways
ty for the help
nope nvm im not stupid, tested it with a hashmap and its telling me that PersistentDataType and the list version are Duplicate Map keys
which makes 0 sense
Hello I have a problem, when i'm summoning an ItemDisplay with spigot api and setting the GUI DisplayTransform, it's the same as the display in inventory,
But, with packets, even if I set the same scale and same Display transform, it show me a texture like a resource pack.
Or, if someone know how to rotate on himself an itemdisplay
PRIMITIVE_DATA_TYPES.put(PersistentDataType.STRING, String.class);
PRIMITIVE_DATA_TYPES.put(ListPersistentDataType.STRING, String[].class);
// Why is ListType and DataType apparently the same key, its apparently a duplicate wihich makes 0 sense
because they are
PersistentDataType.LIST.strings()
is how you get the string type for lists
not that it will yield you a String[].class anyway tho
it would be a List<String>
oh
Thats a weird way of accessing those
Confused me
Then again that is my fault for not fully reading the docs
Well, your way doesn't work because ListPersistentDataType extends PersistentDataType
which is why you can do ListPersistentDataType.STRING
the interface inherits those fields from its parent
@EventHandler
public void onPlayerDamage(final EntityDamageByEntityEvent e) {
if (!(e.getDamager() instanceof Player) || !this.main.isOn()) {
return;
}
final Player p = (Player)e.getDamager();
for (final PotionEffect effect : p.getActivePotionEffects()) {
if (effect.getType().equals((Object)PotionEffectType.INCREASE_DAMAGE)) {
final ItemStack weapon = (p.getItemInHand() != null) ? p.getItemInHand() : new ItemStack(Material.AIR);
final int sharpnessLevel = weapon.containsEnchantment(Enchantment.DAMAGE_ALL) ? weapon.getEnchantmentLevel(Enchantment.DAMAGE_ALL) : 0;
final int smiteLevel = weapon.containsEnchantment(Enchantment.DAMAGE_UNDEAD) ? weapon.getEnchantmentLevel(Enchantment.DAMAGE_UNDEAD) : 0;
final int baneLevel = weapon.containsEnchantment(Enchantment.DAMAGE_ARTHROPODS) ? weapon.getEnchantmentLevel(Enchantment.DAMAGE_ARTHROPODS) : 0;
final int strengthLevel = effect.getAmplifier() + 1;
final int damagePerLevel = this.main.getConfig().getInt("damage-per-level");
final double totalDamage = e.getDamage();
final double weaponDamage = (totalDamage - 1.25 * sharpnessLevel - 1.75 * smiteLevel - 1.75 * baneLevel) / (1.0 + 1.3 * strengthLevel) - 1.0;
final double finalDamage = 1.0 + weaponDamage + 1.25 * sharpnessLevel + 1.75 * smiteLevel + 1.75 * baneLevel + damagePerLevel * strengthLevel;
e.setDamage(finalDamage);
break;
}
}
}
I have an error with this code, upon hitting an entity with a sharpness enchant everything work perfectly, but if I hit them with a sword that has both enchant like SMITE and SHARPNESS than the strength potions doens't add up any damage.
I was going to ping you because I didn't know aobut internals, but it seems you have a 6th sense for knowing when talk about your API is happening much like my sixth sense of inventory awareness
true
Gotcha
Hi guys, im trying to debug my spigot plugin. it worked fine until i added SpiGUI as dependency. now it only works when packaged, but when debugging the plugin doesnt start and throwsa java.lang.NoClassDefFoundError: com/samjakob/spigui/SpiGUI
Im using maven and spigot for 1.20.4
Does anyone has an idea?
Did you shade it?
i'm fairly new to java development. how would i do it in intellij?
allright, as a new one. I really recommend learning first the basics of IJ (IntelliJ) and then only Java. Once you learn java basics you can start learning plugins development
https://blog.jeff-media.com/common-maven-questions/ "How to shade dependencies"
People just getting started with maven always ask me the same 3 questions, so here’s a a short FAQ! How to change the output directory? Read this. How to shade dependencies and what it means Sometimes you are using certain libraries (for example, my CustomBlockData class, or similar stuff) that is not already present at...
e.getVehicle().removePassenger(e); does this make "e" dismount?
Yes
ty
if I Cmd+B / Ctrl+B onto Message(getString(path)!!), shouldnt IJ jump to the String constructor instead of the class? At least that's what it does in java, why not in kotlin 🥲
ofc not, I use the IJ defaults
Thank you, i tried adding the shade plugin. But when i do shade:shade (in plugins) i get the following:
Failed to create shaded artifact, project main artifact does not exist.
Anything i miss?
Working with Java from a code view isn't the problem since im used to other languages and working with java in my internship too. But i have problems with the dependency system... What isn't really clear to me is that packaging does work, but when running the debugging server it doesnt work.
Well you use a build system like maven or gradle
to manage dependencies and packaging for you
just run package as usual
do not run any special goals or lifecycles
mvn package will compile your code, throw it into a .jar, and then also shade all dependencies into that same .jar
how can i put an item in cooldown? like the shield when get hitted by a pillagerù
declaration: package: org.bukkit.entity, interface: HumanEntity
okay i got it now! Thank you very much!
every tutorial on running the spigot server in debug told me to build the artifact which ended up not working. but changing it to the mvn package goal now works
e.setCooldown(e.getInventory().getItemInMainHand(), 5); doesn't work
obviously not
look at the method signature
check the type of what you use instead
and read what your IDE tells you
5 ticks is 1/4 of a second
(and itemstacks are not materials)
yeps
and how can i put in cooldown the item in main hand
you can't cooldowns apply to all items of the type
Your code will not even compile
There is no ability to apply a cooldown to just 1 item
either you use the method and do it per type, or write your own logic
anyone with experience making websites have any idea of why the fuck chrome and brave which both run on chromium have such a big difference in font size displays
I inspected elements and they're both set to 1.15 rem base size which I understand might different from browser to browser but these are basically the same browser
should I just hardcode the root size myself?
It looks like a different font is being used.
I know right?
it feels like that to me too
Brave may not use the fonts provided by google by default.
Is that what your website is set to use?
yes
Link?
See, it says it's Open Sans, but I know it's not. Image on the right is what the font should look like.
A theoretical question - when spawning armor stands through a custom plugin on a local server (localhost, my machine), everything works fine, but when the same plugin is put on a live server (a server host), with the same plugin layout as the local server, the armor stands don't spawn. What could be the issue?
conflicting other plugins is my nr1 guess
Impossible, as I have an identical plugin layout both on my local server, and on my live server
ah u're running a single plugin?
The only thing that's different is that it works locally, but not on the live server
I have maybe 5 other plugins, but all are identical to one another (on my local and live servers)
hmm, interesting
I'm not even sure where to go from since everything works perfectly fine when tested locally
and we go under the presumption both servers are configured the same, that is the config files for the server and the plugins
100% identical, made sure of that, plus all the plugins are updated
I also assume u've tried to recompile the plugin and restart the server
so there are no outdated mismatched versions
of course yeah
My guess, your server host is effing with you by adding its own plugin
I would have seen it though, no?
if another plugin were added
some hosts add their own plugin for advertising (free hosts)
Yep, it looks different for me now too.
I'm using a premium package from bloom hosting, not free
no clue then
I need to go make a proper global html importer that is site-wide
Some config is different, world name or somethign silly
^ else u can maybe try to intercept the entity spawn event
If its free host, some of they limit entities spawning
that could be it also :>
as mentioned, I'm using one of the more expensive packages on bloom host
e.setCooldown(Material.SHIELD, 40);
why it doesn't set cooldown for the shields i have in my inventory
and I'd like to thank you, I just figured out the issue
would recommend contacting the support
apparently you can't use a custom and command spawn reason in creature spawn event at the same time
How did… what
I only allowed my plugin to handle entity spawning
and it resolved the issue
🥲
no idea lol
but thanks for mentioning the spawn packet part
made my draw my attention to it
e.setCooldown(Material.SHIELD, 40);
why it doesn't set cooldown for the shields i have in my inventory
do u have more code?
cooldown is on a MATERIAL not an item
It’s for all items of that type
public void onRightClick(PlayerInteractEntityEvent event){
Player p = event.getPlayer();
Player e = (Player) event.getRightClicked();
ItemStack taser = new ItemStack(Material.STICK);
ItemMeta tmeta = taser.getItemMeta();
String tnome = this.getConfig().getString("nome-taser");
tnome.replaceAll("&", "§");
tmeta.setDisplayName(tnome);
Integer tcmdata = this.getConfig().getInt("cmdata-taser");
tmeta.setCustomModelData(tcmdata);
if (p.getInventory().getItemInMainHand().getItemMeta().getDisplayName().equals(tnome)) {
if (!taserati.contains(p)) {
if (!cooldown_taserate.contains(p)) {
if (!taserati.contains(e)) {
if (e.isBlocking()) {
if (p.getFacing() == e.getFacing()) {
taserati.add(e);
cooldown_taserate.add(p);
Integer durata = this.getConfig().getInt("durata-taser-in-secondi");
durata = durata*20;
e.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, durata, 3));
e.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, durata, 255));
for (Player lp : Bukkit.getOnlinePlayers()) {
if (lp.getLocation().distance(p.getLocation()) < 8) {
lp.playSound(lp.getLocation(), "minecraft:block.anvil.land", 1, 2);
}
}
e.getVehicle().removePassenger(e);
e.setCooldown(Material.SHIELD, 40);
// more code```
xd
oh my....
Is it making it to that line
please use guard clauses
do not nest your code like this
agony
pow
actually taught me how to make my code much more beautiful ngl so thank you
took me a solid hour to write ❤️
Hi, i have been reading too much about n-ario trees and i will apply it for commands. But im struggling a bit the looping for finding a child node of a child node
what in the world is that
n-ario trees, is a specifc type of tree structure. You have binary, n-ario tree
ohhh
not sure how many different types are but they all trees structure
i just struggling with how i will find a child node of a child node, i fail at that part because of recursivity which i dont really manage it well
ru just writing a naive implementation?
sort of it, because im trying to represent commands structure
So i realized the structure is that tree type specific which is called n-ario tree
i already know the theory of the tree type i want to apply, just messing around finding child nodes of child node
Hikari sucks
skill issue
is there any plugin which can make intellJ make sound when compile process is over
Dang how long is your compile
5 hours
Setup a post task to open an audio file
Make it play never gonna give you up
Isnt there any way for forzing writeable book edition without the player having the book? Mainly forcing book writte menu via code
I have seen whole 1.8 api and no method exists, dont start saying update version. Just tell me if there or not
right thanks, that what was looking for
depending how much data you would have, preferible SQL
well depends on your needs
what is mrsql
MySql or mrsql
The husband of MsSql
What about this?
EntityPlayer entity = (EntityPlayer) player;
entity.openBook()
I find by checking NMS packages
Pretty sure they still need a book
you mean the item stack right?
Mhm
hello, im currently running 2 servers connected with a proxy, it seems like the quitevent is called after the joinevent and therefore the data loading and unloading doesnt work. (old data is being loaded) Is there any fix to this besides using a runnable and delaying the loading process?
For that cases i do catching with a an in memory database, for example Redis
can you tell me more abou this?
What you do is instead of loading data when player join each server, you load it once connect to proxy stays in redis.
Redis is an in memory database that can be accessed by multiple servers
so sql bad, redis good?
*It can also be persistent but yeah
no no, they are different things
Redis is not designed by default for being persistent, (IT CAN)
yeah
thats smart
What you do is having a cache inside redis
Because is in memory is so fast
I can explaint it if you giveme time
so all my prior getting data in memory with hashmaps is useless and i should burn it?
of course, i would really like to hear it. :)
allright give me time i iwll translate so you perfect understand
ok
i've now just seen that redis is a nosql database, therefore combining it with mongodb would be smarter, right?
The first thing to understand is that redis is entirely an in-memory db, i.e. it stores everything temporarily. It is capable of being persistent, but it is not very common to use it for that.
It is almost always used in parallel with a persistent db such as Mongo, Mysql, SqlServer, etc to store all the information permanently.
In case of redis, it has 2 very good functions to take advantage of it, one is the cache system that is basically like creating a HashMap inside Java, it is the same. You indicate a name of the set that would come to be like the table (in SQL), then the key that must be unique for each data (the uuid of the player generally) and finally the data to store.
And its other functionality is a publishing / subscription system, it is a channel where you publish and receive information in real time. It is very useful, to send messages / actions between many servers. For example to create a global /msg, where the player being in lobby can talk with the survival player.
yeah is what i do in fact. Im a mongo db lover haha
so I've been only working with SQL so far and not with any NoSQL database, what is the difference? I know sql is sorted and nosql is unsorted data, but is sql faster or nosql faster ?
well, none is more faster than the other. A poor and bad design SQL db can be worst than NoSQ
thanks for the explanation, thats what i needed, i have been struggling this whole day with setting up a proxy and all the data maangement
yeah im specialized in this topic hehe
so nosql is basically just a different format?
I worked with redis for 2y
yeah they 2 database concept, in SQL you have a query lang and data is stored in tables, the most improtant thing is that SQL database are relationals
wait but how do i find stuff in an unsorted db??
i mean thats not really true
It depends the key you are using for each insert
i work with Mongo and the data is find really similar, in SQL you indicate the query like SELECT * FROM users WHERE uuid=someUUID and in Mongo, you use a filter, like Filters.eq("uuid", "some-uuid")
I dont really sure what you mean by unsorted
idk maybe im using the wrong word
unstructured database?
but this doesnt matter, so you'd recommend combining redis with mongodb as these two are both nosql ?
i guess it would be kinda stupid to combine a nosql database with an sql one
However, what you should know is that SQL and NoSQL are 2 different types of databases. And the main difference between them is that SQL is a relational database that stores information in tables. And you use a query lang for interacting with the db
And mongo stores the information in bson documents, which is basically json data but in binary format. Which means that any type of data can be stored in binary format.
okay
Thats most of theory explaining really vargue and fast
Then you can read more in deep
What would like to know now?
Hey guys currently having trouble connecting with Redis (Jedis) in my [Practice] plugin. In my [gBasic] plugin which is my network-bridge plugin, connects just fine, but i noticed after just adding Jedis to my [Practice] plugin that it timeouts after a few minutes of idling.
I am using the same code as I am in my [gBasic] plugin, and I am using the same connection credentials. Everything seem's correct.
It's all the same, so I don't know it's breaking.
https://paste.md-5.net/cikalenohu.java (JedisUtil.java) class
This is the class I instantiate in my Core.java (main class).
JedisConnectionException: Failed to connect to any host resolved for DNS name. (followed by Connection timeout connectionException)
https://paste.md-5.net/oyuwesowuk.md
If someone could assist me 1 on 1 that'd be great!
What should i do guys
@anyone
Is your config the same? Is it in the right folder?
Yes
You should debug your values to really verify that. It sounds more like the host or something is wrong (thus unreachable) and after n attempts it just time outs
Can somebody point me to a modern tutorial on pathfinding for mobs? I've found a few from 2014/2015, but none of the classes/methods they reference seem to exist anymore...or maybe I'm missing something very obvious?
Okay i will do so.
I mean not that already haven't i will triple-check now, i just don't seem to see anything that would cause such.
Well depends how you are looking for them since there is mappings
Some tutorials might show you with a mapped version of the jar while others using the unmapped version
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
ask in their discord
wait they have a discord
So it only has support for upto 1.20.1 apparently
Based on a post from oct 7 with the same error I got so
oh well guess ill wait til i can use it
Anyone good with redis here?
yes, what are you looking for
Remember to just ask your duded instead of losting time looking for one specialized
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Isn't there pricing in AWS based on the RAM and processor power of the servers?
I looked at the website but I couldn't understand it.
is there a formula to calculate the cost if the price goes up every 1.2x each time? I was looking at geometric series but it doesn't seem to work correctly:
val enchantValue = enchant.getInitialCost() * ((1.2.pow(enchantLevel.toDouble()) - 1) / (1.2 - 1)) * i```
i got this
but looping gives me 206K
1.20.2 works for me
I think you have to download it off of the jenkins?
Do you know what value to expect?
i think its 206K
i just made a simple program in rust to check if it was right
and it wasn't so
Looks like you applied the interest formula right?
It can be simplified tho
A = P(1+r)^t
Can you potentially send me this please?
Whoa...
How did you create that weird font, the current level and cost font?
tbf i might have done my rust code wrong so it might be right
tiny text
i just use a fancy text generator
Huh
Yeah just use the compound interest formula @rare rover
Neat, ill check that out
alright, thank you very much
what is this font in current level and cost ?
this ^^
Oh awesome this has other tools as well
This is really cool
haha, no worries xD
Im trying using a custom command with setblock ~ ~ ~ minecraft:dirt 0 replace {nbt} how can i manage to do it in code without calling the command with the exact result?
I forgor it was many months ago, maybe theres a link to the jenkins on the spigotpage
Unless you want me to send you just the .jar file
that's not a valid command. What is that 0?
can't know how to do it in code if I don't know wtf the command is @cobalt thorn
guessing you can just change that block at the location, but idk what 0 and {nbt} are. those aren't part of the regular minecraft:setblock command
i know they are placeholder
the command is much longer so that's why i didn't sent the entire command
and the command is for 1.12
so that's why (0 is blockstate)
Either or works
Hey, can someone point me in the right direction?
in my plugin I need to get the distance between a player and some block periodically. If theyre more than, for instance, 20 blocks from some point, I want to do something
In this (admittedly simplified) example, would I want to use Location#distance(otherLocation) or Location#distanceSquared(otherLocation)? Whats the difference between these and which do I need?
(sorry if this is dumb, maths wasn't my strong suit)
Left is distance squared (but which each line being ^2)
Right is just left but with the square root taken from it
This actually helps a tonne
Tysm for the explanation <3
I've written an own ban systen for adding QoL stuff like an executor. I will also add something like a ticket uuid for ban appeals (but that's not the topic).
While writing, I realized that if (for some reason) an admin isn't trustworthy and has access to server files, the executor could be changed, which I... Just don't want. Would it make sense to write an encoder & decoder to encode the username of an executor and if so, is there a good way, except Base64 to implement a text encoder? I feel like Base64 is extremly easy to decode or do I misunderstand Base64?
You're already doomed if somebody you don't trust has access to your server
Using base64 is just gonna make it more difficult for your admin, but that's pretty much about ot
Base64 is basically being used when you want to convert a binary with bytes ranging from 0-255 to a String that is human readable, such as if you want to put it somewhere where binary wouldn't work (e.g. in a json)
The plugin isn't exactly for me, I basically do it as training and plan to release it eventually to the public. And I've learned to trust absolutely nobody, lol
Ya that's not worth it, there are probably more important things you should think about instead
I've run out of things to think about so I just do anything now lmao
Whoever got access to the server could just replace the whole plugin altogether
and much much worse
The administrators of servers should know better than to give access to the server files to untrusted people
If they do, it's on them, not on your plugin
yeah, makes sense tbh
What I'm still trying to figure out is how to write a proper nick-command.
I wrote my nick-command like 3 years ago and it's just Player#setDisplayName, which only changes the name in chat, iirc but I want to change the chat name, tablist name and name-tag.
declaration: package: org.bukkit.entity, interface: Player
Right, I forgot about that. But that's still missing the name tag
My therum
all good figured it out
arl
just do it with a scoreboard team
Scoreboard Teams change name tags? Haven't used scoreboard stuff in a longer time
Yes. Check it out, super easy to use, you just add the players name to the team and boom set the display name (supports chat colors)
Map<UUID, Team> very simple
Huh, that makes a lot of sense, thank you
base64 provides no security, its purpose is to serialize data for the purpose to transfer over a medium that allows only printable characters, its also handy to just use to serialize binary data in general sometimes
ohhhhhh
hi frosty the snowman
@EventHandler
public void onPlayerDamage(final EntityDamageByEntityEvent e) {
if (!(e.getDamager() instanceof Player) || !this.main.isOn()) {
return;
}
final Player p = (Player)e.getDamager();
for (final PotionEffect effect : p.getActivePotionEffects()) {
if (effect.getType().equals((Object)PotionEffectType.INCREASE_DAMAGE)) {
final ItemStack weapon = (p.getItemInHand() != null) ? p.getItemInHand() : new ItemStack(Material.AIR);
final int sharpnessLevel = weapon.containsEnchantment(Enchantment.DAMAGE_ALL) ? weapon.getEnchantmentLevel(Enchantment.DAMAGE_ALL) : 0;
final int smiteLevel = weapon.containsEnchantment(Enchantment.DAMAGE_UNDEAD) ? weapon.getEnchantmentLevel(Enchantment.DAMAGE_UNDEAD) : 0;
final int baneLevel = weapon.containsEnchantment(Enchantment.DAMAGE_ARTHROPODS) ? weapon.getEnchantmentLevel(Enchantment.DAMAGE_ARTHROPODS) : 0;
final int strengthLevel = effect.getAmplifier() + 1;
final int damagePerLevel = this.main.getConfig().getInt("damage-per-level");
final double totalDamage = e.getDamage();
final double weaponDamage = (totalDamage - 1.25 * sharpnessLevel - 1.75 * smiteLevel - 1.75 * baneLevel) / (1.0 + 1.3 * strengthLevel) - 1.0;
final double finalDamage = 1.0 + weaponDamage + 1.25 * sharpnessLevel + 1.75 * smiteLevel + 1.75 * baneLevel + damagePerLevel * strengthLevel;
e.setDamage(finalDamage);
break;
}
}
}
I have an error with this code, upon hitting an entity with a sharpness enchant everything work perfectly, but if I hit them with a sword that has both enchant like SMITE and SHARPNESS than the strength potions doens't add up any damage.
so is it easy to decode? Yes but no. There is a specification on how base64 is supposed to work, but you are free to modify or deviate as well as use any tools at your disposal to implement. Because of this, typically no two encoders or decoders are the exact same unless they follow the exact same standard
this is why it is common that a tool that encodes also provides a decoder as well
Isn't smite not supposed to be able to work with sharpness?
Oh so you can customize your Base64 encoding? I had no idea
They work together but cant be put together normally
as long as it uses 64bits and provides serialization using printable characters you can pretty much implement however
they do work together
the only downside is, that if your encoder is different then its inherent your decoder be used since no other decoder would really work
ic, mb, I thought they would also just not work together
Many things have specifications, and believe it or not you actually don't need to conform to spec 100%
this is only necessary if you want compatibility with everything else
Yeah only the plugin is supposed to encode/decode it
but if compatibility is not necessary or needed, implement however you want 😛
My plugin is basically supposed to be a completly closed system to be able to handle pretty much everything on the server
then yeah, just use your own encoder or decoder in fact I have a class already made you can use
1
oh, interesting
it makes use of snakeyamls encoder/decoder
which conveniently is part of spigot 🙂
ooooo
license is MIT so feel free to use it
thanks
Do I understand correctly that a Multimap is nothing else than a Map<K, List<V>> or Map<K, Set<V>>?
Or tbh before I ask shit now, does it even make sense to serialize attributeModifiers of an item's itemMeta if you want to store the item in a json?
Anyone's IntelliJ crashing with update 2023.3.2?
I have not updated IJ in ages lol
Nvm I updated Copilot to latest and it doesn't crash anymore
Lol why not
too lazy
Well you have a point
my intellij has been crashing since ages
some memory issue
I was updating my ij today and it was lagging so bad during applying patches
And then when it booted up and prompted me to download the dictionary for grammar checking, I did
i just got used to presing ctrl s after every few lines
My pc just stopped responding for like a solid 5 minutes, then disconnected from both monitors, and then took a solid minute to stop lagging
Lmao
Maybe a fresh reinstall would solve this?
sounds like a good reason to never update IJ again
Do you have anything to do rn?
im in school x)
Idk why this happened lol, it was the first for me
history class
any takes?
Why wont you just serialize the whole ItemStack to json and not worry about all the details.
because the details are lost if i don't, no?
Which codec are you using? Gson?
To serialize to json??
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
// Serializing an ItemStack
ItemStack itemStack = ...;
String json = gson.toJson(itemStack.serialize());
// Deserializing an ItemStack
Type type = new TypeToken<Map<String, Object>>(){}.getType();
ItemStack deserialized = ItemStack.deserialize(gson.fromJson(json, type));
wha
I asked like 50 times on this server on how to serialize/deserialize item-stacks and this is the only time i got a straight answer lmao
Man, I never worked with JSON in code before, okay? xD
Hey, one more quick question, when the server is stopping, will all players be kicked/leave from the server (and their PlayerQuitEvent's be called) before my plugin's onDisable method gets called?
Or is that not something that you can know?
Its fine. Just take a dive into Gson. It can serialize a lot.
Yes
Damn, I'll use that ig, rip my time lol
🙏
yes on or moment
Sry that sentence makes no sense to me...
Answering "yes" on and "or" question lol
I mean, it makes sense that you meant the first part, but still
It was a two part question with the latter being conditional. And i answered the first one which made
the second question obsolete. In my mind it was ok 🤷
But im not a native speaker
Does minecraft cache player .dat files or load-as-required?
I don't think that's an english only thing (I'm not a native speaker either)
offline player data is cached for a decent amount of players.
Whats the concern?
How damaging would it be to rm a player data file during runtime?
as long as they are offline
Completely fine
Awesome thanks 😄
Also, long time no see in here congrats on helper : D sure you've had it a while now XD

One more thing: what if I want it to be an array of ItemStacks instead of just 1? For-Loop?
Nvm I did it. Use a string builder and add the commas and brackets manually
yo spigoteers do you know where can i find Steve and Alex default skins (texture and signature)
still a lil ugly bc it's not perfectly aligned but eh fine ig
Uhm.
The proper way would be to register a serializer and then just call
ItemStack[] array = ...;
String json = gson.toJson(array);
Want an example?
anybody
Probably in the default resource pack, i'm guessing
oh- then i'm no help, sorry
public class ItemStackSerializer implements JsonSerializer<ItemStack>, JsonDeserializer<ItemStack> {
private final Type mapType = new TypeToken<Map<String, Object>>() {}.getType();
@Override
public JsonElement serialize(ItemStack src, Type typeOfSrc, JsonSerializationContext context) {
return context.serialize(src.serialize());
}
@Override
public ItemStack deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
return ItemStack.deserialize(context.deserialize(json, this.mapType));
}
}
Usage:
Gson gson = new GsonBuilder()
.disableHtmlEscaping()
.registerTypeHierarchyAdapter(ItemStack.class, new ItemStackSerializer())
.create();
// Serializing an array or List or anything with ItemStacks in it
ItemStack[] content = ...;
String json = gson.toJson(content);
// Deserializing anything in that regard
ItemStack[] deserialized = gson.fromJson(json, ItemStack[].class);
you're alr
wasn't there a site where you could query skins
but no idea what it was called
Has a REST API
They dont have a texture and signature. They are used by the client as fallback textures and dont need signing.
But you can surely find a random signed skin which simply copied them.
that makes a lot of sense
Btw you should use Gson as a top level serializer.
Simply throw the entire object at it, and if something doesnt work, register a serializer.
So just serialize the entire object and write the json String to a file.
Dont tinker with it in String form.
What does extends JavaPLugin do?
🙃
sites
It extends the JavaPlugins class
i'll keep that in mind, thanks
what does it do?
btw is there a gson config manager class out there? Do I have to write it myself and spend a whole day at it?
Spigot will be very confusing if you dont learn the basics of java first.
I would recommend you to start writing some generic java code that can be run in your terminal, and
look at some tutorials first.
No idea how the requests work, I just simply know they exist to pull skins/skin data from
What do you expect this config manager to do?
just read the data and save it
google java inheritence. also what smile says
Once you write one, youll never write one again 😛
Thats... just Gson
ive been using the same gson class for like 3 years now
Eg.
„Hey server can you tell me this and that?“
„Yes sure here is the response“
thats literally it
no
yes
like that request lol
so I basically make a wrapper thats it
i know networking programming XD
what request
this one
want things to look nice
if its even valid, doubt it is
why wouldnt it be
works literally the same as all other requests
whats so special about it
cause im like 99% sure if he wants skins he should use the mojang skin server XD there is 100% a API for it
skins.minecraft.net IIRC
I see. Yes a wrapper would be appropriate.
But keep it simple. Shouldnt take more than half an hour.
Probably wanna use it as a general serializer, not just for config files.
it might seem crazy what im about to say
but
where do you think such an API would get its data
do you know the full name of requests?
you know theres
„api requests“?
Can I also add stuff like inventory titles to the show there?
wait
i won't need it, nvm
Why are you sounding so condescending lmfao, you do realize im telling him to use mojangs skin server right?
Here is a website where you can upload any skin you want and get it signed.
https://mineskin.org/
Here is a java wrapper for their REST API
https://github.com/InventivetalentDev/MineskinClient
They use several dozens of mc accounts to upload and sign skins, and cache the signature/texture on their own servers.
the REST server the mojang uses to serve skins
if it works it works
What does a signed skin mean? What's a signed and what's an unsigned skin?
selected
you can have multiple skins saved in your account
assigned skin is the one you selected
unasigned are the „stored“ ones
So if you read my message, you would see that i said "No idea if that request works though" and that one simply existed for him to use
Was more of less hinting at him to try it and see, as i have no idea how that specific REST he sent works/if it even works at all
Notchian clients only display skins which have a valid signature from Mojang.
yea
As in stored in GameProfile?
aah, ic
Hello, small little question, does anyone knows where the implementation of ClientGamePacketListener in the (Remapped) NMS Code is? I'm searching all the day for it because i want to know where for example the handleAddEntity is implemented. Would be nice if anyone can help me please.
on the client ? 
The ClientGamePacketListener is the thing that handles the packets from the server to the client on the client so like
you won't find that implementation in spigot
Oh okay, is there an option to see the Clientsided code of Minecraft where this is implemented?
What do you need this for?
I want to understand packets in general from ground, i mean completely. I'm programming since 7 years on smaller things in java primery in the Spigot field and want to go deeper in the code of mc for general purpose to see if i understand it after it better. (Server as also Clientsided)
ye, I wanted to say mcp but iirc fabric can be mojmapped making it easier to understand for a spigot user


