#help-development
1 messages · Page 818 of 1
Thanks. Send a mail
do I have to worry about that warning?
When I did my first plugin the warning didn't do anything
yoooo
why did urs not show up
dont do that
is it possible to print logs in the cmd when I'm getting an error? so I can debug what could it be
?mappings
Compare different mappings with this website: https://mappings.cephx.dev
I'm pretty new to it so idk
What is this commands for md_5 mapings?
You can do that too if you want
what function can I use to do it?
get the logger from your plugin instance and call one of them methods on it
alr thank you
can anybody remove smoke particle from my worldguard ?
hey, how to register a plugin on maven?
I saw some plugins have colored "redstone" particles. Is that a thing or is that resourcepack-stuff?
or any nexus repo?
It’s a thing
Redstone particle is rgb
Unsupported Java.
Your build is currently configured to use Java 21 and Gradle 8.5.
why is running java 21 is so damn hard
when its been released like 2 months ago
GRADLE 8.5 SUPPORTS JAVA 21
yet i get this error
EXPLAIN
ok this seems to popup whenever error is made while running the application
tbh makes no sense still
and it seems like intellij issue
Seems you found the issue
Easiest way is to check
What are the odds that 1.21 is gonna use java 21
3%
that would be so satisfying
i see no reason why not to upgrade
apart from users being annoyed to upgrade (official launcher has built in jre anyways)
ThreadLocalRandom.current().nextInt(100) + 1
Real chads use nextInt(1,101)
@upper hazel look
Is there any appreciable execution time difference between pulling a value from config and storing it for future use, or just pulling it from the config every time you need it?
Nah real chads just type random numbers while their not looking at theyre keyboard
4 38
Boom just generated 2 random numbers between 0 and 101
59
why dont we just get choco to make them
a bot can just dm choco "Pick a random number between 1 and -1"
Java
System.out.println(“Hello World!”);
That’s how you print right?
Yeah
ye but thast kinda hard hwen u know ur keyboard layout
guys
My nightmares have come to reality
I forgot that I made a testing RDS on aws and found this on my credit card logs
Hey guys working with spigot api 1.8.8 and i am wondering how i would create the death animation to play out just like it normally would when u die?
Let me explain, I have set up simple instant respawn system by setting player's health to 20 when they die and it works fine and takes away the respawn screen just like i want it too, although it does take away the death animation. I was wondering if this is possible to replicate with a specific packet?
Congratulations /j
im trying to add a binary search to my insert function for a leaderboard but for some reason it just like doesnt work, its like somewhat right but most of it is off. Test class is https://paste.md-5.net/sawohuhijo.cs and data printed is
Why are you diying this, tree list / map
the binary search?
ignore the print and temp methods, just the first thing i thought of to test it to make sure it works before adding it into the actual plugin
Ye no reason to diy binary search
oh wait DIY
i did see the binary search in arrays but forgot to check if it could take a comparator
? Hello
Too old! (Click the link to get the exact time)
probs is w packets
hmm how do I access these methods?
I don't see any of that currently
as well as this ?
and is there any alternative to it?
The annotation should tell you what it means?
Hello ! I am trying to use the docker-api in my spigot plugin but i have an issue getting the classes to be loaded: i get a ClassNotFound exception.
Here is the dokcer api url : https://mvnrepository.com/artifact/com.github.docker-java/docker-java/3.3.4
Here is my pom.xml : https://paste.md-5.net/lunasexuho.xml
plugin.yml : https://paste.md-5.net/ijacuwabuf.sql
also here is the structure of the inside of my plugin data folder:
root@MCCODERS:/data/MCCodersServer/plugins# ls -R MCCoders
MCCoders:
config.yml lib translations
MCCoders/lib:
docker-java.jar
MCCoders/translations:
messages_en_US.yml messages_fr_FR.yml```
Please tell me if you need more infos ^^
Note that i tried shading but without any success
I didn't solve the error, i tried diffrent shading approach
Maybe i'm wrong somewhere
i tried checking with : jar tf MCCoders-0.3.0.jar | grep docker
and got return :
com/github/dockerjava/zerodep/shaded/org/apache/commons/codec/language/bm/Rule$Phoneme.class
com/github/dockerjava/zerodep/shaded/org/apache/commons/codec/language/bm/sep_approx_french.txt
com/github/dockerjava/zerodep/shaded/org/apache/commons/codec/language/bm/sep_approx_hebrew.txt
com/github/dockerjava/zerodep/shaded/org/apache/commons/codec/language/bm/sep_exact_hebrew.txt
com/github/dockerjava/zerodep/shaded/org/apache/commons/codec/language/bm/sep_rules_french.txt
com/github/dockerjava/zerodep/shaded/org/apache/commons/codec/language/RefinedSoundex.class
com/github/dockerjava/zerodep/shaded/org/apache/commons/codec/net/URLCodec.class
that meant it was correctly shaded i think ? but still
Here is an example of one of my shading attempt: https://paste.md-5.net/ivewabowug.xml
Here is the error i get with it : https://paste.md-5.net/yosoyecuri.http
That can happen when shading a jar with a manifest hash
Exclude it from the shade
How can i know which file to exclude ?
This does not work
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
did you just layer the sound on top of each other?
/* This value was determined by a
* fair dice roll and is assured to be randomly chosen.
*/
public int random() {
return 3;
}
Well on first try it certainly is
omg haha how long did it take you to find it?
// Waits for neutrons and cosmic rays to randomly flip a bit in x
public int miracleRandom() {
int x = 0xFFFF;
while(x == 0xFFFF) {
}
return x;
}
Would be easier in space i guess
Reminds me of that mario speedrun
Yeah 🙂
oh yeah lmao
neutrons and cosmic rays? In minecraft? sounds interestening
player.setPlayerListName(ChatColor.BOLD + "TEST " + ChatColor.RESET + player.getName());
The bold ChatColor doesnt seem to be working when using setPlayerListName?
Other ChatColors seem to be working
ITALIC does not work either
Guess they don’t work there
They did on paper 1.20.2
ill check spigot 1.20.2 now
spigot 1.20.2
seems like the spigot 1.20.3 update broke specific chatcolors in tablist
Paper for the win lol
paper hasn't come out with 1.20.3 yet and when they do they will probably have the same bug
Nothing paper related here
ill report the bug
?whereami
Someone else mentioned paper, I was responding to them..
?whereami
Jkjk
Ok i reported the bug
what?
What do I need to add In my pom.xml to use: org.apache.commons.lang.StringUtils;
Nothing iirc apache commons is part of spigot?
I remember somethign about dropping lang in favor of lang3
Are you talking about Gettype or smth else
InventoryView#getTitle
but you really should compare inventories by instance not title
You should not detect custom inventories by their name
Did you make sure that they are on the ground and not hanning on a wall?
?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 can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
Alright, add debug messages and check which part of your code acts unexpected
wait cherry and bamboo weren't in 1.19.4
Yeah, right...
nope
1.20 they were added
experimental datapack maybe? cant remember if they were added to that
Do you have the experimental datapack enabled
I mean, the types exist via experimental datapacks.
idk if via-version fucks around there ?
he has via and via backwards so maybe
I mean
what is your plugins api version in your plugin.yml ?
okay
Welp, should work ™️
but I mean, 1.19.4 remains unsupported and I don't have a local setup to verify
I think I am good 😅
cherry signs in 1.19.4 means something enabled the experimental feature flags
that world is fucked anyway
Heyo, random question, changelog for 1.20.3 says
- Material.GRASS is now Material.SHORT_GRASS
Will this be fixed for existing plugins with that bytecode manipulation thingie ?
my beloved
how can i add enough velocity to a player to push them half of the way towards an entity?
Mathh
thats my problem, i dont know any of it
I am always interested if bing does a good job at answering with smth useful, so i decided to ask it your question.
To add enough velocity to a player to push them half of the way towards an entity, you need to calculate the vector between the player and the entity, and then multiply it by a factor that depends on the distance and the desired speed. One possible way to do this is:
- Get the player's location and the entity's location using
player.getLocation()andentity.getLocation(). - Subtract the player's location from the entity's location to get the vector between them using
entity.getLocation().subtract(player.getLocation()). - Get the length of the vector using
vector.length(), which is the distance between the player and the entity. - Divide the vector by the length to get a unit vector in the same direction using
vector.normalize(). - Multiply the unit vector by a factor that determines how fast and how far you want to push the player. For example, if you want to push the player half of the distance at a speed of 10 blocks per second, you can use
factor = distance / 2 / 20, where 20 is the number of ticks per second in Minecraft. - Set the player's velocity to the resulting vector using
player.setVelocity(vector).
Here is an example of how the code might look like:
// Get the player and the entity
Player player = ...;
Entity entity = ...;
// Calculate the vector between them
Vector vector = entity.getLocation().subtract(player.getLocation()).toVector();
// Get the distance
double distance = vector.length();
// Normalize the vector
vector.normalize();
// Calculate the factor
double factor = distance / 2 / 20;
// Multiply the vector by the factor
vector.multiply(factor);
// Set the player's velocity
player.setVelocity(vector);
I hope this helps you with your plugin development. 😊
Source: Conversation with Bing, 06/12/2023
(1) How do I gradually apply velocity in Spigot? - Stack Overflow. https://stackoverflow.com/questions/35214761/how-do-i-gradually-apply-velocity-in-spigot.
(2) How do I set player velocity in Spigot? | Hypixel Forums. https://hypixel.net/threads/how-do-i-set-player-velocity-in-spigot.3409987/.
(3) Solved - Set A Players Velocity? | Bukkit Forums. https://bukkit.org/threads/set-a-players-velocity.145866/.
(4) player.setVelocity() not launching player into Y-Direction. https://bukkit.org/threads/player-setvelocity-not-launching-player-into-y-direction.208939/.
(5) Entity (Spigot-API 1.20.3-R0.1-SNAPSHOT API). https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Entity.html.
(6) 1.16.5 - Trying to spawn entity that has velocity in a ... - SpigotMC. https://www.spigotmc.org/threads/trying-to-spawn-entity-that-has-velocity-in-a-certain-direction.469959/.
(7) Location (Spigot-API 1.20.2-R0.1-SNAPSHOT API). https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Location.html.
I am using player.setVelocity(player.getLocation().getDirection().multiply(Main.instance.getConfig().getDouble("velocity_multiplier")).setY(Main.instance.getConfig().getInt("Y_axis"))); to set velo...
Looks normal for the most part though idk why divide by tps?
Idk either, it is interesting though
hey guys do you know why is my dynmap web isnt loading? here si log https://mclo.gs/WUKhmTo
Visit dynmaps discord
commons was removed in favour of guava, yes
@Override
public void customSpawnFeatures(LivingEntity entity, Player spawner) {
if(spawner == null) return;
entity.getLocation().add(0, 1 , 0);
entity.setAI(false);
entity.setGravity(false);
entity.setInvulnerable(true);
spawner.sendMessage(TextData.getString("data.entity.EVIL_GOLEM.dialogue"));
spawner.playSound(spawner.getLocation(), Sound.UI_TOAST_IN, 100f, 0f);
entity.damage(1, spawner);
new BukkitRunnable(){
@Override
public void run() {
spawner.sendMessage(TextData.getString("data.entity.EVIL_GOLEM.dialogue2"));
spawner.playSound(spawner.getLocation(), Sound.UI_TOAST_IN, 100f, 0f);
for(int i = 0; i < ARMY_SIZE; i++){
IranSkyEntities.getInstance().getServer().getScheduler().runTaskLater(IranSkyEntities.getInstance(), () -> entity.getWorld().spawnEntity(spawner.getLocation().add(random.nextInt(-1, 1), random.nextInt(-1, 1), random.nextInt(-1, 1)), EntityType.PILLAGER), (i * 10L) + 1);
}
new BukkitRunnable(){
@Override
public void run() {
entity.setAI(true);
entity.setGravity(true);
entity.setInvulnerable(false);
}
}.runTaskLater(IranSkyEntities.getInstance(), (ARMY_SIZE * 10L) + 51);
}
}.runTaskLater(IranSkyEntities.getInstance(), 30);
}```
is there anything i can improve?
btw what are commons& guava?
general utility libraries
WeakReferences get GC'd if the thing they reference get GC'd right?
Wait I understand now I read an article nvm
i mean you can keep a hard ref to the object but forget about the weak ref, the WeakRef will get GCd but the other won't
Alr
Yeah I mean depends if you keep a weak ref or strong ref to the other weak ref like WeakRef<WeakRef<T>> (tho thats just dumb but yea)
No Reference objects will get GC'd (that is they behave like any other object)
However the object they reference may get GCd depending on the type. Objects behind WeakRef will get inaccessible if nothing else refers to them
Objects behind Phantom refs stay for even longer (till the GC or finalization I think?)
Yo have reference queues also which ucan register to
but yeah
Well
Yes I think its past finalization
Where as weak indicates state of finalizable
finalizers are the devil
can someone help me my dynmap is looking like this, here is log: https://mclo.gs/KRSe7h3
ask in their discord https://discord.com/invite/pNtzWvaRq7
Ahh alright. I have totally done spigot since
I've been following a tutorial on how to start setting up a plugin with intellij, and I've reached a point where I'm unable to mimic what the tutorial is telling me to do. The tutorial wants me to add the outputFile tag to change the location the project is saved, so that it goes into the plugins folder in my world file. Is there any reason I can't just move the file location itself to the plugins folder manually? Or will it re-create the project file at the original location each time I save it?
or should I just change my output directory? I feel like that might not save the file though to the right place if I'm to re-edit the project again.
the plugins folder in my world file
I assume you mean server folder
not the world itself
Is there any reason I can't just move the file location itself to the plugins folder manually?
You can ofc move the plugin yourself
But I guess I'm worried that if I do manually move it, either I'll have to move it each time I want to test a new version of it (not the worst thing in the world I guess :P) or that the Intellij project will no longer have access to it.
you can always just set your maven/gradle output directory to your server
What am I doing wrong why it seems nms is getting obfuscated https://hastebin.zeeraa.net/zakovelaja.xml
?nms
Thanks 🙂
The only thing I had "forgotten" was "<classifier>remapped-mojang</classifier>" but when I add it net.minecraft disappears
make sure you run BuildTools with --remapped
wlel the classes change
?mappings
Compare different mappings with this website: https://mappings.cephx.dev
EntityTypes becomes EntityType
https://mappings.cephx.dev/1.20.3/net/minecraft/world/entity/EntityType.html mojmap vs spigot maps
version: 1.20.3, hash: 5bb2c97b24
You mean in my plugin, BuildTools is for the server itself, am I wrong?
just run buildtools anywhere
it adds it to maven local which ur plugin can then use
it gives you the args in the article I sent
java -jar BuildTools.jar --rev 1.18.2 --remapped
in your case you'd obv change the verison
id recommend not running it inside ur plugins project folder because you might accidentally commint nms to git
I've only committed NMS to CraftBukkit once
thats what i almost did
I have a problem...
reload maven
weload 
you're missing something very very important son
you see, their is no version
oh..
but Mr Jar plugin begs you add a version
the real solution here is to add it in pluginMangement tags with the version and then just do it like that
but you could also just add the version to every profil
does a player have a PDC
declaration: package: org.bukkit.persistence, interface: PersistentDataHolder
all the sub interfaces of PersistentDataHolder do
what about OfflinePlayer?
Can I not pull the data if the player is offline?
Rip
@young knoll did something relating to ofline pdc for players but idk if it got prd
Not yet
https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/
I can't seem to use ChatColor, what would be the next best option for storing a colour?
just store the color as a string
can I convert it back to a colour? if so how (whats the method)
ChatColor.valueOf should exist iirc
Did Discord changed app icons?
Nah youre just going crazy
Nah, we are good with translateAlternateColorCodes method
Yeah
it depends whats saved
bc translate alt code wont translate BLUE
Is always been that
no it hasnt
Would be sick if it translated {BLUE} for instance
doesnt minedown take that format
Idk
I just know that ChatColor#translateAlternateColorCodes name is way too long
😔
thats why everyone makes a util method
call it just t
And make it just run the previous name lol
c.c for fun
c.ctacttscotfa
(Chat.ChatTranslateAlternateCodeToTheSpecifiedCharacterOnTheFirstArgument)
literally me
why
Why not?
public static String paint(String text) {
return ChatColor.translateAlternateColorCodes('&', text);
}```i'm alr with that alone
hex is for pussies
hex is a wonder of world
The fact that #fff means white in binary is simply awesome
That thing still supports hex, no? Lol
&x&f&f&f&f&f&f
Cursed but it works right
Isn't this what Bungee chat api does?
Very cursed
prob the bungee ChatColor class
idr
It’s cursed that you can use bungee chat api functionally on a normal spigot server.
well its more the name that tend to throw off people
I mean its been packaged with spigot for a long time now x)
I am too lazy to look at the source code to see why
TextComponents
i mean would you rather having to shade the chatapi urself or add it urself if ur spigot server was on bungee bc it didnt shade it
True but couldn’t they just make one for spigot
then what are you gonna use for sending stuff from bungee
its easier to just have all spigot include bungeechat
Plus that way you can send a bungeecord formatted message from spigot
Without having to do weird stuff
All is done by spigot
¯_(ツ)_/¯
Bungee chat
raw text
and let spigot convert it to colored text
since components and minecraft text isnt gonna change on proxy
inventory pr
How to avoid paper armorstand tick when disabled? Does teleporting armorstand work?
This is spigot
if (targetPlayer != null) {
try {
int amount = Integer.parseInt(args[2]);
double maxHealth = targetPlayer.getMaxHealth();
double newMaxHealth = maxHealth + amount * 2;
newMaxHealth = Math.ceil(newMaxHealth * 2) / 2;
targetPlayer.setMaxHealth(newMaxHealth);
player.sendMessage(ColorUtils.translateColorCodes("&#FF4500&lBF &8⏩ &fAdded " + amount + " hearts to " + targetPlayer.getName()));
return true;
} catch (NumberFormatException e) {
player.sendMessage(ColorUtils.translateColorCodes("&#FF4500&lBF &8⏩ &fInvalid amount. Usage: /bf addhearts <player> <amount>"));
return true;
}
} else {
player.sendMessage(ColorUtils.translateColorCodes("&#FF4500&lBF &8⏩ &fPlayer not found. Usage: /bf addhearts <player> <amount>"));
return true;
}``` why does this make the hearts look like this? it happens with all my other cmds / setmaxhealth things too (i cant heal past that half a heart basically is my issue)
How does the path to a sound from a ressource pack has to look like?
any1 know why i cant get past that half heart with that code?
targetPlayer.setHealth(targetPlayer.getMaxHealth());
Isn’t it a spigot config option to allow more than x max or smth
If you only add 1 hp it will add half a heart
You have 10 hearts and 20 hp
meaning 1 heart is 2 hp
oh and set max health is deprecated
use attributes
does it matter if i use deprecated things?
I mean if it's deprecated then there's probably an alternative
In this case, the alternative is attributes
#setMaxHealth() uses attributes under the hood but we'd rather you use the API that you should be using
Try running it
i've done it 18 times
?paste
Ur stuff
Does anyone know how to play a sound from a Ressourcepack?
playSound() lets you pass a string instead of a Sound constant
So if it's a custom sound it will be whatever string you pass
You need to run the shadowJar task or make the build task depend on shadowJar
aaand how?
Currently I got p.playSound(loc, "myressourcepack/minecraft/sounds/custom/sound.ogg", 200.0f, 1.0f); but it's not playing the sound
Well your sound should be registered and have a custom key
how do I do that?
https://www.minecraftforum.net/forums/minecraft-java-edition/redstone-discussion-and/commands-command-blocks-and/2591859-custom-sounds-tutorial should still be up to date I believe
(pack_format is obviously not correct, but the general structure should still be fine)
Thanks!
how can i send a message in the action bar in a event listener? (plugin version 1.8)
make the build task depend on shadowJar
You can't rely on the Intelisense when working with Gradle
It will show that error a lot
Ur intellisense is so borked
eh that's just how it is working with Gradle
it isn't working
that's due to the groovy dsl
kotlin has good autocompletion and error checking
Looks like it's running ShadowJar task now
Kotlin is a pain though
not at all
Kotlin is also ugly
so this: PersistentDataContainer customBlockData = new CustomBlockData(block, plugin); may work
but it doesn't
?notworking
"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.
also that's an external library
you should probably ask mfnalex
and you did you just can't wait it seems
no i used magic instead
whats the new/better was
how rename plugin derictory with configs like -> class (RSkilsDuels) -> jar (R_skils_duels) ->derictory(R_skils_duels)
are to much? (modules)
Believe me, it's small
and it doesn’t matter at all, in fact the main thing is that you feel comfortable
ah wait i was found
attributes
is for do multi instance bw plugin and not multi world
what event is triggered when renaming an entity with a nametag
how do i check if a block is a crop
Tag.CROPS.isTagged(block.getType())
thank u <3
how do i move like a crop from the stage they're on rn in growing to the next one
good question, Ageable?
maybe
ill try this
if (crop instanceof Ageable ageable) {
if (ageable.getAge() == ageable.getMaximumAge()) {
return;
}
if (!isNight(player.getWorld())) {
ageable.setAge(ageable.getAge() + 1);
} else {
ageable.setAge(ageable.getMaximumAge());
}
}
Do you guys know some plugin that in exact time server will automatically shut down and automatically turn on like in 23PM it will shut down and in 8 AM will turn on
no plugin can do that
just make a cron job
where can i make that?
public class Loyal extends JavaPlugin {
CustomConfigSetup setup = new CustomConfigSetup();
@Override
public void onEnable() {
saveDefaultConfig();
setup.createCustomConfig();
}
}```
public class CustomConfigSetup extends Loyal{
File customConfigFile;
FileConfiguration fileConfig;
public void createCustomConfig() {
customConfigFile = new File(getDataFolder(), "specifiedblocks.yml");
if (!customConfigFile.exists()) {
customConfigFile.getParentFile().mkdirs();
saveResource("specifiedblocks.yml", false);
}
fileConfig = new YamlConfiguration();
try {
fileConfig.load(customConfigFile);
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
}
}
public FileConfiguration getFileConfig() {
return fileConfig;
}
}``` what i do wrong here
You can't create an instance of a class that extends JavaPlugin
whyu
what packets do i need to send the player to make the client think he died
do player#kick
simple
or
?????
the nametag character limit is 16 for version < 1.13?
pretty sure it still is
do
for(i = 0, i>100000, i++){
player.sendPacket(RiderPacket)
}
Similar at this
yeah i figured
hahahahahhaah I'm imagining
bro death screen not BSOD
minecraft death screen
yes
kicking is not dying
can this thing bypass the character limit of 1.8 version?
https://www.spigotmc.org/threads/regarding-1-8-16-character-limit-tag.400891/
mmm NMS
i tink
JavaDoc + NMS + Your Experience
e se non avessi esperienza?
ChatGPT + Bard
i know the basics of java development but im not a senior
dont trust ai for nms
not even a junior
sei italiano?
si
sto facendo un plugin delle bedwars multi instaza (Multi server tipo hypixel) per il mio server e stavo pensando anche io a questa cosa. Se vuoi quando trovo la soluzione te la do
saresti un grande se lo fai
manda amicizia
meta.setDisplayName(i); = error: incompatible types: int cannot be converted to java.lang.String
why?
i can't do i.toString()
An int is a primitive not an object
oh okay tysm
im new to java
and to plugin development
if (args[0].equalsIgnoreCase("1")){ for (int i = 0; i == 53; i++){ ItemStack arredo = new ItemStack(Material.PURPUR_BLOCK); ItemMeta meta = arredo.getItemMeta(); meta.setCustomModelData(i); meta.setDisplayName("" + i); arredo.setItemMeta(meta); inv.setItem(i, arredo); } player.openInventory(inv); }
sorry again, somebody can tell me why the gui opens but with no items?
gonna need some more code than that
if (sender instanceof Player){
Player player = (Player) sender;
Inventory inv = Bukkit.createInventory(null, 9*6, "Arredamento");
if (args.length == 1){
if (args[0].equalsIgnoreCase("1")){
for (int i = 0; i == 53; i++){
ItemStack arredo = new ItemStack(Material.PURPUR_BLOCK);
ItemMeta meta = arredo.getItemMeta();
meta.setCustomModelData(i);
meta.setDisplayName("" + i);
arredo.setItemMeta(meta);
inv.setItem(i, arredo);
}
player.openInventory(inv);
}
}
}
return true;
}```
looks correct, add debug statements
okay
int i = 0; i == 53; i++ will never be true
so it won't run
0 isn't 53
Is there anyway to get proper clicked action in creative mode or there will be always Createive? I would like to know when item was right clicked
When a player is in creative all the server knows is set slot x to item
It doesn't know what you did to cause that
This right now isn't filtering the logger message as it is before an if statement
why filter when you want to check to see what somethng is
okey
does HttpURLConnection throw an exception if the response code isn't 200?
It shouldn't
You should be able to getResponseCode() and it will return one of the constants defined in that class
I would maybe recommend HttpClient though if you're using Java 11 or higher. Just a bit of a more refined API
thanks choco, yeah I will probably switch to HttpClient 👌
The docs on the HttpClient class are pretty well written. Gives you a nice snippet example
I'm making an updater class for my plugin
want to make it efficient and async of course
I'm really selling HttpClient here but it has in-built async support :p
if choco is selling something like I sell Inventory PR its gotta be good
Choco is paid by HttpClient
waiting for the human brain to release async support tho fr. I can only do 1 task at once
Some people already have it
how did they get the update before us
Not really anywhere else to ask propper. But what was the reasoning behind yeeting the Enchant Registry now? Not sad its gone (was gonna happen eventually lol) but just seemed outa nowhere lol
the enchant registry is not yeeted
Registry.ENCHANTMENT is still there
as is the nms BuiltInRegistries.ENCHANTMENT
You lost me at nms lmao
internal vanilla code (aka not part of the API)
No I mean... you lost me
I know...
I meant... "you lost me at nms" as in "no deal" as in "god in heaven have mercy, don't make me touch nms"
... erm...
its not a perfect replacement. like how do I add the glowing effect? a hidden enchant? then I have to have special handling for those items in the grindstone, etc, etc, etc.
I do recommend using PDC tho if using a hidden enchant is fine for showing the glowy effect
Fair
Am I going mad... PDC isn't that literally what was just pulled? Or am I being moronic
ItemStack stack;
@Override
public void onEnable() {
l = this;
stack = new ItemStack(Material.ANDESITE);
stack.getItemMeta().setCustomModelData(1);
Bukkit.getPlayer("limpeex").getInventory().addItem(stack);
if(stack.hasItemMeta()){
if(stack.getItemMeta().getCustomModelData() == 1){
System.out.println("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
}
}````
I feel like either I have a gap in my knowledge... or I've used something without knowing its pdc
what is wrong here on stack
?pdc
getItemMeta is a copy
You need to modify it and then use setItemMeta
So it wouldn't be an enchantment... It'd be a PDC holding shit that smells like an enchantment works like an enchantment, but isn't an enchantment
Am I right in that?
Yes
That's moronic imo
And I wanna be clear
Utterly imo
Like no objective reason other than "I liked my enchants being actually enchants as it led to less of a headache"
Now I have to shove a load of new objects into items to store a separate instance of an object that'll then mimic everything to do with enchants.
Then set up a whole enchantment system to fake add the fake enchants to an item in the enchantment table.
Like Jesus christ lmao
I get it for the most part.
But still that utterly sucks. I actually really hate the idea of adding more shit to be stored memory.
In this case literally adding an object to store the data for my other object.
It's completely a personal opinion. But that seems hella messy
Nms is probably gonna just be the play.
And that hurts deep lmao
God I hate mineacademy so badly, it makes people worse developers
Because I got really furious for spending a lot of time in fixing a project that was written in mineacadmies "foundation" library
Yes I’m sure that 10kb of memory will be missed
It is so bad, it's sad
https://github.com/kangarko/Foundation/blob/master/src/main/java/org/mineacademy/fo/plugin/SimplePlugin.java
This is the main class of all its plugins, it is literally loading the server.properties during it
Don't ask me why
Look man. I just personally think having a bodge job wrapper for enchantments shpild of been adressed by making a better system. Not gutting it and having to use a PDC.
It was neat you could bodge it.
Would of been brilliant if it had been made better, not removed.
Imo ofc
Then why not leave it be? Why remove it?
Because it wasn’t api
It also didn’t really do much
Didn’t work with anvils or the table without extra code, all it did was let you access stuff through ItemMeta directly
Which in itself was a really nice QoL thing imo
Consider for a moment that most custom enchant plugins also wanna add general functionality to vanilla enchants.
You know how nice it was to loop through the enchants on an item and find urs and the vanilla stuff?
Now it's gotta be some frankenstein bs with calls to the PDC and enchants
Idk what has changed but an API for custom enchantments would indeed be nice
Sure but it would be a janky hack
It wouldn’t integrate with the registry and wouldn’t work properly for clients
My brother in christ have you looked at Material lately.
This api was born in jank
I thought that was paper
They are busy creating spigot 2.0
Maybe there is some weird thing where both of yall are trying to replace it with diff ideas but I swear paper said they are thinking of replacing kt
Fair.
But yeah man I dunno.
I personally think forcing anyone who wants to do custom enchants to use PDCs is jankier than a registered enchant that doesn't have all the bells and whistles.
At least irs adjacent to what it's supposed to be rather than a container on every single.item u enchant, that then needs to have its metadata changed to look enchanted.
Maybe it's me being dumb.
But the registered enchant that doesn't quite work feels a lot less jank than "this isn't an enchant at all, but we sure as hell gonna make it look like one"
Using a built in api for a very valid use case
Vs reflectively changing a value to inject stuff into a registry that isn’t tied to the vanilla registry
I'll conceded lmao
Conceed
Conceed jesus
Also, as long as inventories ar eloaded item by item by half the popular plugins in the community every time a player clicks, I ain't putting persistent data containers on items lmao
Can't wait for a player to lag machine a server by enchanting loads of items with custom enchants then spam clicking their inv
I mean it’s just a map internally
Right. And?
A map is good yes, but it being called synchronously by every item being loaded is not good juju
Normal inv? Yeah cool.
Player spam clicking and reloading his inv every click
Hell nah
what exactly is your issue?
I mean, I get that single threaded minecraft has its limits
but given that the average server scarcely reaches 50 players I doubt thats much on the server
but now if that is the case u do have certain softwares that address that specific point
When one can fill an inv with items that all have an object (pdc) that needs to be snapshotted on every click...
I don't find that to be a comforting system lmao
have you benchmarked its horizontal scalability?
Tbf i think all items with meta automatically have a container anyway?
I’ve never actually looked if it’s created lazily or not
u mean if ItemMeta is created lazily? (yes it is)
Nah the container inside it
Actually yes. We did.
Turns out in the server we stress tested , 12% of the thread use of a 100 player battle was just inventory snapshots getting made
the pdc container? coll
Ye
do u have the benchmarks?
im just curious what methodology u used
well I dont think the pdc container is created lazily
but item meta is right? so that should do it
Am i an item stack
Maybe
Ideally itemstack would be an interface like everything else
But you can’t instantiate an interface
I think it could be neat with 2 interfaces
one that represents an actual, living item stack residing somewhere such that live manipulations of it is reflected
and one thats just a context, remoteless item stack
Would probably have to be 3, ItemMirror, ItemCopy (naming isn’t my thing) and then the base itemstack
Still couldn’t instantiate them tho
yea
and then maybe we'd introduce factory methods in ItemFactory to create these new coolings
difference between ItemCopy and item base?
btw
What did you use to determine this?
I just kept the base for ease of backwards compat
Spark and timings and actively going into each plugon and seeing like 10 of em were using 0.8 to 1.2 % of thread just getting snapshots
@formal vector u still got the screenies?
I would recommend using a proper profiler to confirm. Only because spark cant show you everything
well I think its highly in the api endusers interest to get this api where we differentiate between "copied" items and "living" items
:)
Yeah
man the new discord icons so goofy
But removing new ItemStack would be a pretty big hit
It’s a very core part of the api
True but same time brother , it doesn't take a genius to figure thst copying an inventory verbatim every time a player clicks is a serious performance issue
oh yeah true, backwards compat def needed ⚒️
also big issue with itemstack is that it never got any static factory methods
Well you never gave such info to begin with lol
so its pretty hard to build compat on top of it (since many explicitly invoke its constructors)
Shame you can’t define a constructor in an interface
fr lol
I did, but I haven't said the funny word yet as every time I say it get told "oh u are the x guy" and a crap load of mockery my way
Lol
So why do you need to do this?
You don't.
***it does it as a natural repercussion of using get holder in any click event ***
So why not just keep it cached then
You can't.
It's not a plugin issue. It's an api issue
Get holder snapshots the holder every time.
If the holder is a block entity... it by effect snapshots the inventorytoo
Item by item
Hmmm not sure why it does that then. But i am sure there is a way around it.
Nope
Well that is a quality issue more then anything lol
U know 12% thread use on one method is insane
That isnt too terrible
I mean we could probably cache it
I’m not sure if there would be any repercussions for that
12% thread usage for checking an inventory holder is ridiculous my guy
In a 100 player fight... 12% being used on that method is ludicrous
I cant think of any either as well as i cant see a reason for needing to make a snapshot to begin with
Sadety
Safety
Seems like the whole snapshot thing should be its own method like chunks
*paper ironically did a solution to this and added a boolean that by standard is true for snapshotting
This doesnt make sense either since there is nothing unsafe in dealing with the live inventory
Live block entity inventory.hplders tho...m
*inventoryHolders
The issue lies in block entities containing an instance f their inventory
I still dont see the issue when chunks need to be loaded for them anyways
How u mean?
You cant manipulate the inventory of a block that is in an unloaded chunk. Therefore you will need the live inventory instanced regardless. I just dont see the reason to automatically make a snapshot except if you wanted to handle the inventory in another thread or at least parts of it. I suppose it makes sense if like you didnt want the inventory changing but i mean the snapshot has to get saved back if it gets changed anyways
Thing I can think of is imagine pissing around with the holder of a chest. And someone breaks the chest as its doing golder.logic
*holder logic
It only changes where it errors
*shrugs
I would rather the logic to hault sooner rather then later
Either way yeah. That's the problem. Did a thread on it ages ago.
So yeah until that's fixed I'm not adding the problem by using sodding pdcs
Because here's the rub. Pdcs make that holder problem worse.
But ud never know as ud only ever see inventory snapshots causing issue in the profiler
still don't get why plugins use InventoryHolders
there are many better solutions than implementing meh api
Agreed. But they do. Lots.of widely used.knes too
because there was a wiki page that used to propose it as a solution
now its been fixed
doesn't paper still have one that does just this
This is why we need those sweet sealed classes
I wonder if MD would be okay with sealing InventoryHolder :P
does it matter? can't servers only use 17+ now adays anyways
I think it would break too much of backwards compat
and the subclasses have to be known at compile time anyway
Yes but md likes his java 8 :p
ahhh
We are bumping to 9 soon™️
sealing wont do much, or well it may do too much
Either way.
Yeah it's a bigger problem than folk realise as it's repercussions arnt seen.
We say nbt is a resource hog, that custom items suck ass for tps.
Ironically they arnt the problem
It's sociology.
Custom items usually trade well in big servers. They are moved around a lot... in SHULKERS.
The lag inherent to custom items is a repercussion of the item being snapshotted 27^27 times each time the inventory is transfered from one chest to another
Should just bump to 11
https://docs.papermc.io/paper/dev/custom-inventory-holder funnily enough paper still has this wicky link
We’ve discussed this but alas no
27^27 times for every plugin that uses it too...
Its lts though lol
y2k pls edit it lol
aw its not a wiki
nvm
Considering I'm not in paper discord I feel like maybe this is something @livid dove should bring up with them. Considering he made his case here I believe it would also be applicable there
I would but I've alrasyd been salty about losing enchant registry today
Need to wind back on the salt lol
ahhh, yeah that's a sad loss. You might still beable to inject into the vanilla registry though
you'd have to unfreeze it though
But now my reservations of making every enchanted item in a plugin a pdc due to get holder...
Can I have my registry back plox
Just lemme have my enchant registry and ve done with it 😭
personally I see no issue with it as long as your using your own namespace :P
imho the easiest way to fix this without doing some pdc shit is to inject into the vanilla registry
Don't make me use pdc papi. Please
no PDC required just a bit of Reflection
We really need to address a way to deal with custom registry content soon™️
isnt that like half addressed lol
we already kinda do Registry#Whatever has a getKey method
Hear me out.
And I'm sorry to be blunt here.
Don't remove the way to bodge job it until its fully addressed.
Add it back in next commit and just remove it when the replacement exists
I'm begging lmao
well there already is a replacement just not in API, because well data driven Enchantments don't exist yet
with Registry.SimpleRegistry() ?
Doesn’t let you add to them
The main problem is
They are frozen
true but its because its frozen you can unfreeze it with reflection no?
We need to burn more coal so we can melt the registries!
Is Enchantment still a simple registry? I thought it was fully NMS Backed now
Not anymore
oh I just meant the bukkit registry class lol
pretty sure there is nothing stopping you from unfreezing the MC registry
ahhh
Didnt we discuss just unfreezing them and that there really isnt any repercussions to that?
having registries frozen makes sense tho
esp since more and more of registries are being synced w client
Does it?
Yeah that’s the thing
What happens if you modify a client synced registry while players are online
exactly
The answer: I have no idea
What we really need is a Configuration Phase loading for the plugin so we can safely allow injection into the registries
which is why there should be a moment during startup where plugins can modify registries
What if a plugin gets unloaded
Right I'm off to bed.
All I know is they took out the map in enchantment registry and its stink poo poo and should be added back in till a true solution is found.
Spigot was born from bodge jobs. Let us keep the bodge till an official.soluton exists
which is a problem coll
Indeed
We could do this like we do world generators
reloaded isn't supported that's already official
I mean, I think its worth to yeet reload functionality
it was never good, never has been and will never be
This would be nice
I like it for non invasive plugins, but I get the point tbh it really shouldn't exist
Yes plugins changing at runtime probably deserves to die
Well its a vanilla thing
But will the slime allow that, who knows

oh for like datapacks right and stuff?
Not that I'm biased... but mythic have took reload and made it essentially a qol feature when making changes to the configs
Reloading configs is fine
It’s ripping out the entire plugin instance and making a new one that is… less ideal
^
Lmao
Anyway I'll pay you 1p if u add the registry back in k thanks bye lmao
Yeah that would be more reasonable
1 pizza for coll
He defo means my 1p offer
Well plugins typically handle their own reloading and should. We probably could just modify the reload command to just only reload server configs and not everything
yea
There’s already a command for that
/spigot reload iirc
Or maybe it’s Bukkit reload
Hola, hay plugin de register/login para la 1.20.2
Seems redundant on that lol
Either way it reloads the various server ymls
don't crosspost offline mode isn't supported here
thank god for my 1 day of spanish class so I can read that sentence /j
anyway, I think its reasonable to consider /reload a bad way of refreshing resources at runtime, classloading issues, binary incompatibility, eventual packet issues, sync issues, mem leaks... the list can be made long if not even longer
Mem leak especially with custom worlds
Which reminds me that i need to look and see if world unloading was fixed
speaking of new things @young knoll I'd really appreciate if you could try out some of your plugins that involve inventories with my PR. I fixed a lot of bugs today and am getting ever closer to a finalized version. I really just need help making sure legacy compat is good to go. Outside of the unavoidable indirect breaking changes
If you really wanted to be able to disable plugins at runtime you could have a Boolean in JavaPlugin that would stop most functionality
Ie events, schedulers, that kind of thing
Eh mem leaks from what I've seen with instanfed worlds comes from asyncly doing it and hence not getting the full stack trace of errors thst prevent the full unload of the world.
There is the back end problem still.
But literally 6 of the 8 mem leaks from world instance plugins I've seen last 3 months have been "there was an error but it being async led to the error not showing half the time"
Still an issue
anyway coll, it may be possible to resync registry entries that are held during runtime with the client (if reload for instance), another issue is ofc if some plugin x holds a reference to a registry element put in by plugin y, and plugin y unloads
E.g everyone points to the radiator boiling , the wall paper peeling and the central heating being way too hot.
But noone is noticing the house is on fire
Maybe we can make a method that lets the server hold the reference instead?
yeah, so even in mojangs code, they wrap registry entries with holder objects all the more
Or maybe a better metaphor is everyone saying Jimmy is clumsy due to him naturally hitting his head on the same beam every day , but noone notices Jimmy needs glasses.
The beam is still there, but he wouldn't hit it twice as much
I wonder what happens if that packet is sent again
🤔
Well i have work so i cant test that right now lol
iirc when looking at papers draft they talked about some sort of client reset mechanism
tho that would prompt texture pack loss among other things
Hmm
I assume you can force the client back into configuration phase
I think proxies do it
It’s probably better to just say no to registry changes after startup
@young knoll any updates on thisa one?
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/pull-requests/919/overview
@eternal night said they were going to make a draft of what it would look like with a generic subclass
But I’m not sure they ever did
oh my bad
lynx never fully tested my inventory pr so yk
I had to do what I had to do
Lol
I’m still unsure on the generic subclass part
no generics UwU
Even if we removed runtime reloading, plugins still load too late to mess with registries/datapacks
Configuration phase ftw
we probably just have to add a new loading phase @young knoll that's inevitable
Static initializers
private final ItemStack myEpicItem = new ItemStack()? Nope that’ll break
Hm I see
No server instance exists that early
Fair enough
I guess the option would be that plugins have to opt in to loading that early
But then… plugins depending on other plugins
well worst case here's what you do.
Add something to the plugin.yml that indicates it should load during configuration phase add a new class
public class MyConfigurationMainClass extends ConfigurationPlugin {
@Override
public void onConfigure() {
Registry.WHATEVER.register(KEY, new Entry());
}
}
true although that dependence isn’t always eagerly established
Yea, welp, ima head off to bed now, gn yall :)
gn
Yeah that’s possible but having another entry point is ehhhh
I mean what is another safe way of even doing that though
Configuration phase is so early
Yeah that could work, but its always awkward when you have two entry points
Again there is the idea of forcing plugins to opt in
As it usually leads to lazy setters
If a plugin opts in that is them asserting they don’t have any static initializers that would cause problems
i found one but its with net.minecraft
I think you just wanna code a location adapter, no?
i dont really know
i just used a ItemStack adapter last time i needed one
That’s all block really is
Spigot wise yeah lmao
would work?
i found this one: https://gist.github.com/SilverCory/b61f8ed07c781c83d98a2f9ab0f61f07
extends TypeAdapter<Location>
but thought it wont work cause Location
You only need to adapt the world
Aka convert it to a string or uuid
The x y and z are just simple numbers
Just make a new one
yea no
Its fine as long as people are not dumb
I guess technically you could have 2 entry points but a plugin would only use 1
in the API? no
You do realize you are using paper?
a block is a world and 3 coords
what?
Old plugins would use the existing JavaPlugin and new ones would extend JavaPlugin2™️
Thats fine just pointing out paper does things differently now especially in regards to chunks
its not hard to make ajson adapter
just implement JsonSerializer and JsonDeserializer
i did
register it with your gson instance
but idk what code to put on the method
like in there
i know theres code on there
You need to write the world uuid, x, y, and z
Assuming you just want to store the location of a block
why not?
there is a lot more to a block than x y and z. There is BlockData, BlockState, World and more not to mention the state, x y and z itself are completely mutable and arbitrary
why are you serializing the block is the big question
i need to store the block
why
what is important about teh block
cause i listen to block break event
and x block in x, y z coords
its unbreakable
and well
if block == blockofjson event.setcancelled(true)
thats it
what if i make like
Coordinates
with members World, Int x, y z
and well i compare that
not the whole block7
I don't really have time to explain everything but your approach is really flawed
Blocks can't be deserialized from json you'll have to find a better approach here
yeah
i guess it was too easy
ill think it
but by the moment
time to sleep
gn for everyone
why can't a Block be deserialized? its just a world and 3 numbers
the exact same as location
I think it depends on what we mean by block x)
Block block, the api Block type
if its the spigot one, then yea
this
Myea
I mean sure you could do that, but you'd be totally in the wrong mind set to be doing something like that
what is different between doing that to Location or Block
you can just do it to Location and call getBlock() on that location
Location and Block are really just the same thing with different methods
personally wouldn't use Location either for such things 🤷♂️ simplify it down to an x y z and cut out all the extra crap
if you absolutely need add the world UUID too
Position (mayhaps)
i don't even get location
Why doesnt location encapsulate the world uuid instead?
in reality location should just really be like NMS BlockPos than you grab everything from the Level/World
True
but I feel like that may be too much of an API change
As weird as this sounds, Blocks don't exist on the server