#help-development
1 messages · Page 688 of 1
Is there a collection that lets us do get(key) and get(index) in O(1)?
I'm thinking binary tree or something
there isnt
but you can just use 2 collections
or hope for best case in linkedhashmap
would be O(log n) right
yea
your branch produces this https://jitpack.io/com/github/RedstoneTools/abstracraft/cb942de698/build.log
no wait
wrong one - why the hell does it not change the commit shown when you choose another branch
jitpack is so stupid, why are you even using it? just publish to maven central
I'm quite new, I'm going to make a plugin, but with which program do I open .jar and .class
idk I've never seen it work properly
😄
usually, none
that's compiled code
mans looking for an IDE
if you want to play with compiled code there are tools for that
why do you think you need to open a .jar file?
Now I'm confused where to start to make the plugin, can you send me a wiki or a tutorial video?
😄
thx
if you do get it to work, let me know pls lol
k
their example does work
which is like
the exact same as what i have
but it uses the correct gradle
ima try w gradle 7.3.3 as that works for their example project
but im so confused
whyyyyyyy does String.split not work on chars D:
public static final String CHAR_NEGATE = "!";
public static final String CHAR_KEY_VALUE_SEPARATOR = "=";
public static final String CHAR_CONDITIONS_SEPARATOR = ",";
this just feels wrong
I want it to be chars
public class HologramManagerv1 {
private HashMap<String, ArrayList<String>> hologram = new HashMap<>();
public void registerHologram(TextDisplay hologram, ArrayList<String> text){
//this.hologram.put(hologram.getUniqueId().toString(), text);
ConfigFile.setUp(hologram.getUniqueId().toString());
ConfigFile.getCustomFile().addDefault(hologram.getUniqueId().toString(), hologram.getText());
}
}``` The config file class is not writing a new file everytime a hologram is created
public class ConfigFile {
public static File file;
public static FileConfiguration customFile;
public static void setUp(String name){
file = new File("holograms/"+name+".yml");
if (!file.exists()){
try {
file.createNewFile();
}catch (IOException e){
System.out.println("Error occured");
}
}
customFile = YamlConfiguration.loadConfiguration(file);
}
public static FileConfiguration getCustomFile(){
return customFile;
}
public static void save() throws IOException {
customFile.save(file);
}
public static void reload(){
customFile = YamlConfiguration.loadConfiguration(file);
}
}``` Heres the config file
lmao what
wat errors
holograms/<name>.yml is that your plugin path?
yeah
it just doesn't have overload for char lol
I thought having holograms/ would create a new folder
String#split(...) requires a String as parameter, not a char
char + "" :3
I reset Intellij IDEA and even hello world doesn't work even though SpigotAPI is installed 🤦🏻
yeh
but plugin is enabled
.toString is so bad
what do you mean by "reset"
What's the problem?
restore default settings
the interface is ridiculously broken so I pressed "restore default settings" as it says on the internet
and everything was reset including my old projects..
yeah but its deleted from ideaprojects folder
anyway
?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.
if the problem is in ide, how can i get an error
anyway as a said
This is the second time I've posted here today and I don't want people to say "trying to code others" for me
i want to make mention in chat. can i use tab completer without command? like player type in chat @ and then appears tab with nicknames
bec it does regex
Time to learn OOP
aight, who dared to delete my message in the review thread :D
oh it's just a cute dog
I can't be mad at you
could you point out the errors?
static aboose
@EventHandler
public void onEntityPickupItem(EntityPickupItemEvent e){
plugin.getLogger().info("pickup");
}
@EventHandler
public void onEntityDropItem(EntityDropItemEvent e){
plugin.getLogger().info("drop");
}
All other events are firing, why these aren't?
try to print debug
I'm doing that already
are you sure you registered them ?
yeah, all other events in this class are firing
getServer().getPluginManager().registerEvents(playerEvents, this);
does any gradle expert know why gradle cannot find my script from buildSrc/...?
onEntityPickupItem started working
but drop still doesn't
I have no idea how
here's the whole repo if it helps https://github.com/mfnalex/lightpermsx
Try send to who was pickup/drop
im already doing that
U logging to console, i mean send to entity on that event.
how do i do that?
Thrown when an entity creates an item drop.
What a weird description
getEntity().sendMessage()
uhh
i think this fires when the entity dies
oh there's PlayerDropItemEvent
ill see if it works
Called when sniffer digs out item
when mushroom gets sheard I think
When cat gifts item to player
when entity dies by wither and drops wither rose
Probably when villagers throw food around too
it did
yep
I guess that event should get better description...
Wasn't there someone who was editing the docs or something ?
@kind hatch
@young knoll
I got it working myself. Additionally to declaring the actual script in buildSrc/src/main/groovy/lightpermsx.java-conventions I also had to declare a build.gradle in buildSrc/ with the following content:
plugins {
id 'groovy-gradle-plugin'
}
I could then apply my "lightpermsx.java-conventions" script file using plugins { id 'lightpermsx.java-conventions' } in my subproject. However gradle was also angry that i declared the lombok plugin like this in my buildSrc/src/main/groovy/lightpermsx.java-conventions.gradle file:
plugins {
id "io.freefair.lombok" version "8.2.2"
}
I had to replace this with just id "io.freefair.lombok" (so without the version). Obviously it then complained about this plugin not being specified anywhere, which I fixed by creating a build.gradle file in the root project that consists of nothing but this:
plugins {
id "io.freefair.lombok" version "8.2.2" apply false
}
wow that makes me really not want to try gradle
Set the priority to highest
And try again
ikr lmao
and the worst thing is the docs always only explain 50%
e.g. it explains how to write the buildsrc script but it totally ignores that you need the groovy-gradle-plugin in the buildSrc's build.gradle
you really cannot read just one part of the gradle docs, you have to read literally EVERYTHING to make something work
another question about gradle. I now have my core module and bukkit module working, both share a script in buildSrc/. Obviously I want the bukkit module's .jar to include the core module's classes. Ofc I could use the shadow plugin but people once told me it's also possible to do with directly with gradle, without third party plugins - does anybody know how?
idk if its good that my quest and my user both know they exist, but i cant think of another way to implement it
i want quests to be really flexible and i dont know how
this is a loot table from a hunger game plugin. How do I make enchanted books that are usable in anvils?
EnchantmentBookMeta
eh doodoo
I had to do something similar at work
And while I don't have to display stuff in a menu so it changes the code structure a bit
like do I just list it as - ENCHANTED_BOOK 1 rarity:1 cost:1 EnchantmentBookMeta:sharpness:1
until you have 10k lines of addStep
having a seizure?
"Actually I don't think I want to implement it like that"
I'm trying to determine if a player would have to turn left or right to face the target. (for a boss bar compass plugin) I guess would need the angle between the player and the location, but how could I do that?
I fixed it already
How do I get the player's inventory in PlayerLoginEvent?
e.getPlayer().getInventory().getContents()
Returns an array full of nulls while the player has items
Nvm I replaced it with PlayerJoinEvent.
(I thought I'll need PlayerLoginEvent instead of PlayerJoinEvent for a specific task)
does anyone know why my cooldown on right click is not working is not working
https://pastebin.com/S467rz7a
https://pastebin.com/WLCL2a2H
?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.
wdym
👌
with ok replace ok
I don't remember but can events be static ?
the listener? yes
you'd have to register it differently then no ?
no
oh ok
that's why it makes little sense to make the method static, the registerEvents thingy wants a class instance
but it'd ofc work nonetheless
As far as I know, apart from MythicMobs, there are no good custom mob creators for plugins, but what if use datapacks and animated java together with the plugin, is it possible to somehow create a system with it?
I would assume yes, you'd just have to dispatch the commands to control the entities.
But performance would probably die (compared to plugin)
hm
I have heard of ModelEngine (tho that one is paid but has demo with 6 models)
What event is used to detect when an item is added to the player's inventory (via drop, /give, creative)?
I think /give and drop it's OnPickedUpItem event
but with creative... i'm not sure but i think that you can compare inventory before giving item and after with OnInventoryClick event but i'm not sure
I would say the same
Since form what I know, the create inventory is special, more client controlled.
tgere is not a single event
thats bad
/give does not fire pickupitemevent
I think you could do something like...
@EventHandler
public void onPickedUpItem(EntityPickupItemEvent event){
// code that you need
}
@EventHandler
public void onInventoryClick(InventoryClickEvent event){
if(event.getWhoClicked() instanceof Player){
Player player = (Player) event.getWhoClicked();
Inventory beforeInv = event.getInventory();
Bukkit.getScheduler().runTask(plugin, comparingInventories(beforeInv, player));
}
}
public void comparingInventories(Inventory beforeInv, Player player){
Inventory afterInv = player.getInventory();
if(!beforeInv.equals(afterInv)){
// Code
}
}
what is the correct way of doing setCursor()?
then i think on command send..?
Yes, pretty sure that pickupitemevent only gets called if you actually pick an entity item up
i think you could try to check if the command that was sent is /give or something like this
give someoneelse diamond 1
would be.. non-trivial
maybe you could check arguments?
execute as someoneelse run give @s diamond 1
i have only this idea
Is it possible to make a shapelessrecipe that just returns the ingredient that was put in? For example, if I put in a diamond sword with sharpness 3, the output would be the same exact item? I'm trying to do this with every tool.
Yes it does
does it?
Yes
you'd probably not want to make a recipe for this
I would just use PrepareRecipeEvent or whatever and do this manually there
okay, I guess I am checking wrong then
Oh then you could do this #help-development message
oh thanks
hmm
ill test it later
but comparing is checks when the item is added or removed from inventory..
It can be destroyed by pickup or do they have to do something with it?
Does that trigger an event like despawn?
An api for fetching resource information
yes
its on their website
in the about section i believe
An arrow, Projectile.getShooter get i.e. Player. How about the Bow or Crossboss that use to shoot that arrow?
not possible, unless you do it in teh launch event
If impossible, how Minecraft's enchantment work? Since the enchantment is in the Bow, and not in the Arrow.
you need to use EnchantmentMeta
oh wait you’re asking how to get the shooter of a projectile?
just listen to the shoot event and store a uuid player to uuid entity hashmap
actually, sword with fire i think on second hand can make the arrow fire
even if bow doesnt have any enchantments
Yeah, I only thing this method
Really? I've never experienced this
don’t think that’s true on java edition @quaint mantle
sounds like a bedrock moment
How would I load the properties of a hologram everytime the plugin starts, do I have to loop through all of the entities and check if the entity is a textdisplay?
More like a Java question but still: can I extend my "User" class which contains all methods like user.isOnSlimeBlock() to the Player interface? so I can use all the basic Player methods like: user.getName() without having to re-write all of them in my User class?
these are all interfaces, what you can do is use composition instead
Other topic. I see people always use UUID, what about the name instead? Since this is just a very short period of storing data.
As in you would store the object yourself in a class rather than extending it. Spigot doesn’t handle the implementation of all the functions.
hmmm
it’s just not good practice as names can become funky with scoreboard teams. UUid is the better practice and always accurate
Yes enchantment swapping is a thing in java
At least it was, may have been partially patched
Not since like ages ago
I mean we can test it right now
go for it, i’ll be incredibly shocked if 1.20.1 has enchantment swapping to the extent of holding fire aspect in my offhand making my bow arrows flammable
Right, that’s what i thought
I don't think you can, unless creating a wrapper
Uff
Yep enchant swapping still works
Killed a sheep and swapped to a looting 200 sword, got a ton of meat
Why don't they store all necessary properties inside the Projectile? So that it will be independent from the player, which is the shooter.
that’s different than fire aspect on arrows
anybody know if I can disable this specific warning?
"More actions" doesn't show anything useful
Remove lombok
that'd be a pain, I need it for equals and hashcode all the time
why are you using lombok warnings?
You can add a PDC tag with additional information to your arrow on the launch event.
They on ProjectileHit you determine actions based on the projectiles PDC tags.
i believe in IJ you can disable a certain type of warning in the code settings
hunt around a bit
I don't understand the point of the lombok code gen stuff
It takes like 2 clicks to actually generate the methods
thx found it
right but some argue it would be more readable to know at a glance of a member variable if it has a getter or smt else
and then update them everytime I add a new member
and then forget that and wonder why my hashsets aren't working anymore
sounds pretty lame
as I said, I'm using it for equalsAndHashCode and if you forget a field there, you're fucked
also lombok's hashcode and equals methods are better than IJ's one
what is lombok
does anyone know how I can achieve sth like this using gradle, but only for one submodule's shadow artifact?
If you’re using maven for your Spigot plugins (which you should do), it’s easy to make maven automatically save your plugin’s .jar in your plugins folder. There’s two ways of doing this: 1. The lazy way (not recommended) If you only work alone on one computer, you can just directly declare the output location in...
https://projectlombok.org/ check out the video
it's java annotations on crack
Is any way to change vanilla sounds to different one without using any nms/packet manipulation?
Resource pack?
yeah just use a resource pack with custom namespaced sounds
I also want to change sound with conditions.
how tf did you do that
[ name ] ( link )
Recently
discord w
A week or two?
Im always struggling with translations because they are a lot of work.
What would you guys think about an annotation processor which generates
translations. For example this method:
public void someAction(Player target) {
if(!this.combatManager.isInCombat(target)) {
@Translated("combat.not_in_combat")
String msg = "You are not in combat!";
target.sendMessage(msg);
return;
}
// Do something
}
Would be replaced by
public void someAction(Player target) {
if(!this.combatManager.isInCombat(target)) {
String msg = Translations.translate("combat.not_in_combat");
target.sendMessage(msg);
return;
}
// Do something
}
While also generating a class containing all translation keys and default values.
public class Translations {
private static final Map<String, String> translations = new HashMap<>();
// generated
static {
translations.put("combat.not_in_combat", "You are not in combat.");
}
// end generated
public static String translate(String key) {
return translations.get(key);
}
public static void load(FileConfiguration configuration) {
// Some generated code to load translations from a config file
}
public static void save(FileConfiguration configuration) {
// Some generated code to save translations to a config file
}
}
Resulting in a default yml when calling save the firtst time.
combat:
not_in_combat: "You are not in combat."
This would make translatable Strings really easy to use everywhere, without having
to switch to another class and add a key/value somewhere.
Thoughts?
so like kotlin features but worse? 
thats exactly how we do that at work
some of these things are similar to kotlin. how are they worse?
just that we named it Messages
and messages pulls its messages out of the translation file
i don't think there's a kotlin equivalent for EqualsAndHashCode or ToString or Builder or SneakyThrows or Log or Delegate
maybe there are and I don't know them. But still, lombok can be nice. It can also be shitty if someone is obsessed with using it all the time
it has its usecases sometimes
using annotations instead of actual language keywords lol
That would be an interesting project for me because i've never written something that generates code
at compile time. I think ill try to tackle this when i get back.
i don't really get which annotations exactly you mean that have keywords equivalents in kotlin
oh i didnt saw the annotation
i dont think that will be useful
Hm, why?
looks like an extra step to me
you could just write the generated code
comes out the same
Ok, but the point here is to not having to write the generated code because its a bunch of boilerplate.
if you have a bunch of Translation.tranlsate or @Translated is equivalent
its oneliner "boilerplate"
You would spare yourself writing the Translations class. Which would be hundreds of lines of boilerplate.
And if you want to change a key, you would have to change it in the Translations class + every instance where the key is used.
the keys are pre-set
and you just load in the different translations from different files
Ok but someone has to write this file.
I dont want to do that.
and then an easy peasy method #translate(Language, key)
Thats hundreds of lines of boilerplate i dont want to deal with.
looks like a you problem to me. thats how you deal with messages industrially
Doesnt mean i cant create something that takes potentially hours of work off my chest 🙂
never said that, just that it wouldnt be really useful
I find having to write less boilerplate and not having to worry about keys in random
translation files having to match keys in my code, to be very useful.
Idk, but I personally couldn't find an event for that
i still dont get where you take the boilerplate from
the keys would be the same in all translation files. the keys in your code have to match this file since it never change
Not having to interrupt my code flow by switching to some config files is always a big plus in my books.
I would never have to write the config file.
All i do is add an annotation above a String. Everything else gets generated.
yeah well i dont get the point of that. you do you
someone? ;')
The point, as stated before, is not having to write hundreds of lines in random ymls and making sure the
keys match up with the keys in my code. It would save me literally hours of work. I dont see whats not to
get there...
with a build src maybe 🤔
i think you got that wrong. not the keys match your code, your code matches the keys. its nothing more then what you want to do just that the translations file already exists and you go the easy way. right now you want to save one hour of work, if even, by spending tens of hours processing annotations
You must be working on tiny projects if translations only take up that little time.
-> Someone has to write the translation file. Why would i interrupt my coding by
going in a translation file, adding keys there, adding a default value, making sure
the key ive added is also used in the code, instead of simply adding an annotation
above a String? How is that not an insane improvement?
build src?
Anyways im doing this. Maybe im wrong and its useless.
Will still learn a lot 😄
Crowdin 
not really, our message properties is 10k+ lines long
Sounds like hundreds of manhours could be saved with my method here...
I think you dont understand it tbh.
Do what hypixel does
automatically translate keys
At a packet level
This is an implementation detail. They still need to write the key-value translations somewhere.
I want to generate them from my code.
Yea nothing wrong with that
yo quick question how do you make so cooldown is off when hitting?
what do i need?
I prefer data generation if possible, tho regarding translations just fallback to crowdin 
Crowdin def is useful if i want to generate files for other languages afterwards 🙂
I think you can manipulate the attack speed attribute
Well I use it because of its api and just their service in general
Yeah cya
no i get your idea, it would just make everything chaotic
but doing that on every item? isn't that meh?
also this is wrong. it takes 2 secs to add a new line
Think you can manipulate just the entity no?
i want player attack like 1.7.10
just a plain Copy task ?
Ah ye, i mean getting the identical mechanics might be a bit hard but I think just manipulate attack speed attribute somewhere
Either api level, if that doesnt work maybe at nms or even packet level
can the attribute be hidden?
I think on items yea
Thank you i will try that
Thats an item flag iirc
anyways, i stated my points, i find it useless & creating circumstances. good that you try to learn with that but you will def. walk into dead ends, little spoiler.
and just like my spigot signature says: "If You Have an Idea that You Genuinely Think is Good, Don’t Let Some Idiot Talk You Out of It.”"
Lol good luck apprentice?
i learned most of my stuff from this discord thb 🙂
(:
anyone know how to display an image and text side by side in a gh readme
yep! emily already suggested that, at first I had issues with that because I used the git bash /c/path notation and that just failed silently lmao. got it working with this
tasks.register("exportToTestServer", Copy) {
dependsOn build
from shadowJar.archiveFile
into 'C:\\mctest\\plugins'
}
Wait, you can launch a testing server from IDE?
huh why do I need to specify it for the shadowJar task then
lynx stfu
because kotlin is a pain imho
yeah lynx stfu
yea stfu 👍
it is just there to depend on other tasks
agreed stfu
Kotlin dsl supremacy 
so when people run "build", they get the expected result
yeah there are two kinds of tasks, uh, the ones that actually do the things, and the ones that like collect other tasks
actionable and uh
true..
using kotlin for a java project just seems wrong
lifecycle tasks i think?
definitely didn't google that one
that sounds like phases and goals in maven
So groovy seems more justifiable? ._.
java-custom-annotation 
well I have to use something
Fairs
gradle java dsl when
Fr
but yea, don't need specify it I think. Gradle should notice that you need shadowJar contents, so you automatically depend on shadowJar
everytime I want to give kotlin a try, I get overly aggressive after 5 minutes and switch to java again
so yeah, no, I will not use kotlin for gradle
tempted to try this out and ask the real gradle experts (zml/octy lol)
well my shadowJar config currently looks like this. let's comment out the dependsOn part quickly and see if it still runs shadow
what
no no no
not on the build task
the build task needs it
its a lifecycle task
the copy task does not need a depends on build
its gonna depend on shadowJar implicitly via calling the output on the shadowJar task
also 🤓 techzksnically you'd use assemble, not build
fuck off
payback for my stfu earlier
you want me to do as octy as well?
wellso you mean I shall just declare exportToTestServer without dependsOn?
tasks.register("exportToTestServer", Copy) {
from shadowJar.archiveFile
into 'C:\\mctest\\plugins'
}
yee
lol
I want to explictly tell it that it should run after it build all the stuff
off to submitting my ESTA I go
it shall not work just because I randomly called shadowJar.archiveFile
what's an ESTA
Electronic System for Travel Authorization
Einkommensteueranmeldung
ah the thing you used to fill out in the plane
no
where they asked you if you were responsible for 9/11
you fill it out before
yeah but 15 years ago you did it on the plane
I remember how they asked if I prepared the 9/11 attacks becauuuse
if you lie on that form they can prohibit you from entering
ok just to understand, so I wanna have the logic right instead of just making it work (everything works btw, thanks!)
/buildSrc/src/main/groovy/lightpermsx.shade-all.gradle
plugins {
id 'com.github.johnrengelman.shadow'
}
build {
dependsOn shadowJar
}
shadowJar {
archiveClassifier = ''
}
/bukkit/build.gradle
plugins {
// ...
id 'lightpermsx.shade-all'
}
// ...
tasks.register('exportToTestServer', Copy) {
dependsOn build
from shadowJar.archiveFile
into 'C:\\mctest\\plugins'
}
This means that when I run "exportToTestServer" it MUST run build beforehand, right? And through build { dependsOn shadowJar } in my buildSrc script, I tell it that it MUST also run shadowJar when i run build, is that correct?
And if I were to remove the dependsOn build, then it would still work, but I don't want that because I want to explicitly mark it as dependsOn - is this all correct / did I understand this right?
because this is confusing, what does shadowJar depend on? what if I were to run this alone?
most people just throw everything into allprojects { }and call it a day
or blindly copy/paste other people's code
usually noticble if they sometimes use ' quotes, sometimes " quotes, sometimes (syntax) and sometimes not, etc
I use that for version support modules
repositories like paper, spigot
yeah that's discouraged in the gradle docs
you should do that in a custom script in buildSrc and then include that as plugin in the modules where you need it
why does it say all tasks are up to date even though I changed a class and now the tests wouldn't compile? 🥲
seems like I manually have to do build { dependsOn test } too?
sounds about right
i hate it when the border patrol people fuck me
Does any one know who to add a cooldown on a right click?
store last execution timestamp on click, on next click check if timestamp and now exceeds your cd, if so give it free
if I get a value from a FileConfiguration (YamlConfiguration) but the option doesnt exist, will it error or just return null?
null
null
because its a stringlist
getStringList is an exception and returns an empty list
that one will be empty
yooo I just found out that switch statements with the class name are like 250 times faster than checking the exact same amount of cases by using instanceof
Source?
trust them bro
what?
public @interface mfnalexEvent {
in theory it works
but idk I don't play with annotations
they're a gimmick
what
mans not making one ounce of sense
My plugin loads a lot of different worlds and then it takes about 9 GB. (-Xmx12G). Will my permormance fall significantly if I set it to -Xmx4G?
uhh
try it
okay
Trying bruh
how will this cause a null pointer exception? It says if its unresolved, itll be null. Are there instances that the player's address might be unresolved?
you want to write your own annotation. Yes, just create one
public @interface MyCustomAnnotation { }
now you can use it
https://www.baeldung.com/java-custom-annotation
it literally says it might be null but you still call getHostAddress() on it
if it's coming from an IP, then no, it can never be unresolved
so I can just ignore it I assume
i'd at least do a null check
yeah that's also wrong
oh no, code crime
if at all you'd be using { }
I'm on phone lol
I like annotion better over the method
🤣
But thanks guys for sharing and guidance
what's the default behaviour if given wrong arguments? Returning without doing anything, or throwing an exception? The description in the javadocs doesnt say
Here, AttributeInstance#remove(AttributeModifier), I'm wondering if it causes an error if the instance doesnt have the named modifier applied
it's the same as with checking the class name and see if they're the same
but instance of actually checks if they are in common rather than their bottom class being the same
goofy ahh System.currentTimeMillis "benchmark"
try catch
wait no
check for null
lol
This is how all the real ones benchmark I don't have time for jmh 😎
not with that attitude :^)
Oh byt I'm not cringe I use System.nanoTime
📈
what exactly are you supposed to use if not those 2? 🤔
pretty sure libs a the core use those too
with warmup and all to prevent bad data
I meant that purely for packets where two packet classes of the same name cannot exist
has anyone made auto update configs?
e.g.: v1.0 has typo in some naming:
insuficient-permisions: ...
and they fixed it in v1.1 but want to transfer the previous setting to the current naming:
insufficient-permissions: ...
how could I make something like this, but without having to manually add what I want to be transfered due to change or sum
there’s no spigot api way to “alter” a config files rows, you are able to make it add all the missing rows based on the config file in your resources folder but that won’t change any of the currently stored data
the way you would create a config based on how you want to do it is manually storing alterations of one variable and using file objects inside of java
Why not just add the new row with whatever value is set to the old one, then delete the old one?
well I wouldn't know what the old one was
I don't want to make some VCS stuff
that was my second messages approach, but the point is this isn’t available in spigot api’s utilities
the issue is you would have to with that approach.
afaik spigot api also removes comments when you use Configuration#set
soo maybe I should make my compeltely own config system?
oh no
some people do make their own.
is there anyway to reset the data of a player completely?
as in the player data folder?
since 1.16 or so it can also keep comments
I want them to have fresh data after login (just need to clear advancement cache)
fair enough
is it also on Bungeecord tho?
no, the bungeecord config system is horrible
what?
cries in bungeecord
hmm I'm doing something about advancements
on bungeecord I usually just use SnakeYaml
I need the advancement needed to be reseted
where everything is a Map<String,Object>
that’s the player data folder
mfw type safety
well it is storing in RAM
a casting nightmare
Everything is type safe if you cast it enough
when player log out it is in the file
i like this logic
I need to reset it without making player log out
east method right i’m there
easy*
oc I did read
but I need it to not showing the toast
so I'm using the PacketPlayOutAdvancement
Iterator<Advancement> iterator = Bukkit.getServer().advancementIterator();
while (iterator.hasNext())
{
AdvancementProgress progress = event.getPlayer().getAdvancementProgress(iterator.next());
for (String criteria : progress.getAwardedCriteria())
progress.revokeCriteria(criteria);
}```
this doesn’t work for you?
nope
error?
it show the toast when I give them advancements
like :l
I got a customer
who doesn't like bungeecord
so he decide to do it this way
real
he save everything player have and load it back on another profile 😄
i’m not sure i understand
real
|| proceeds to work on bungee plugin ||
hmm
it is about saving and load datas :l
you have diffirent inventory for each worlds
as in the player’s data folder?
alright
and what about that stops resetting advancements from working?
what?
what is your issue
I got it working now
but the issue come when I load it
literally
oh so loading a players advancements is not working?
so you didn’t
it is kinda hard to display
send some code
this is normal minecraft behavior
i’m not sure what packet would disable that
you could listen for them and stop them from being sent butzz
you could?
if(!speedUpdater.isCancelled()) speedUpdater.cancel();
java.lang.IllegalStateException: Not scheduled yet
?
it's not that simple, if you simply run something in a loop to "account for warmup" that eventually isn't going to yield anything useful, first you need a wide set of varied data to actually benchmark (pick random classes from a set etc), so the jit doesn't get clever and is like "this entire tree of checks is useless if the same one is being picked all the time". then you have the whole gc thing and the fact that you have to put the result of your things somewhere so that the jit doesn't literally throw everything away because "it doesn't really do anything", blackhole it
jmh takes care of and accounts for those and many more things and it is very easily parameterisable too
do i have to wrap this in an illegalStateException try/catch? if(!(speedUpdater.isCancelled())) speedUpdater.cancel(); doesnt work either
hmm about advancement
I could change the Advancement Data from shouldShowToast to false with reflection right?
oooh it's not scheduled to run in the first place
is there a way to query if a task is scheduled without getting an exception?
cuz this also throws one
Sounds like a serious over-exeggeration.
Switching from class to config -> 2s+
Finding right position -> 2s+
Writing proper key & default value -> ~10s
Switching from config to class -> 2s+
So at the very least 16s for all of that.
Then add an average of 4s per line because of runtime
conflict debugging (cant ensure key match on compile time with your method).
And you claimed 10k+ lines.
Thats 200k seconds or ~55h of simply writing translations into
a config file.
Is it possible to modify NMS/Spigot source in plugins using Instrumentation?
Or something like JVMSelfAttach
You can use bytecode manipulation tools like ASM to modify bytecode on runtime.
But there are only very few edge cases where this makes sense.
nonsense lol, anyways i moved on
and you should too
Yeah
I was thinking to make some sort of mixin api for Spigot
there were people before you with the same thought
but they gave up on smth not sure what it was
you can't really modify a class that's already loaded without a proper JVM prepared for hotswapping like the jbr
Ignite exists
And it always ended it absolute havoc every time so far. XD
I'm thinking about something that you can just plop into the plugins folder
That won't work
what would the point of that even be though
^^
you just compile your plugin with the library
not really possible, to properly do mixins you need to wrap the entire server classloader for mixin support and read the mixins from plugins at, like, psvm lol
Can't java agents modify bytecode on runtime?
modify a clasa that is being loaded, but not one that's already been loaded, unless again you're using a hotswapping prepared jvm etc
Very Terrible Solution ™️
public abstract class VoidRunnable extends BukkitRunnable {
private boolean isScheduled = false;
public synchronized boolean isScheduled() {
return isScheduled;
}
@Override
public synchronized void cancel() throws IllegalStateException {
isScheduled = false;
super.cancel();
}
@Override
public synchronized BukkitTask runTask(Plugin plugin) throws IllegalArgumentException, IllegalStateException {
isScheduled = true;
return super.runTask(plugin);
}
...
}
Yes, but swapping the classloader that is already used by the jvm might not be possible without
a wrapper classloader.
and even then with the jetbrains runtime you are limited to changing method bodies, not really adding/removing methods or fields
I was able to add bytecode to the start of FriendlyByteBuf#writeId
that is changing method body yes
or you could just use Protocollib?
Huh? You mean I gave up my sanity for nothing?
Intercepting the packet is much easier
Currently reading up on annotation processors. I did not know that you can
annotate types since java8?
// Class instance creation expression
new @Interned MyObject();
// Type cast
myString = (@NonNull String) str;
// implements clause
class UnmodifiableList<T> implements @Readonly List<@Readonly T> {...}
// Thrown exception declaration
void monitorTemperature() throws @Critical TemperatureException {...}
TIL
sorta development related, but if any of ya'll use gitbook with a custom domain -- how do you make your custom domain point to the root /. mine always appends a default /some-page route to the url and i can't figure out how to not do that
annotating types is great. it avoids the ugly
@NotNull
public String getString() {
}
and makes the way nicer and more correct
public @NotNull String getString() {
}
it also fixes nullability for arrays
public @Nullable String @NotNull [] getStrings() {
}
i would love a better way that double annotating but it works
ofc spigot api doesn't use java 8 nullability stuff, so the array annotations in spigot api are broken
Readability wise i like the former more
everything past the first is ugly
before i commit to this, is there a better way of figuring out if a task's been scheduled than doing this nonsense?
public @NotNull List<@Nullable String> getStrings() {
}
you can't do that with the first
and if you want to annotate the generics, they should be in the same place
and if you want to be consistent, you should annotate the type rather than the method
Why do you need this in the first place? This looks like a design problem.
i wish intellij had a @Empty and @NotEmpty
let smile do that
he wanted to look into annotations anyways
the fuck is empty and not empty gonna do 
yeah, im curious about that too
it's for some strings
collections 🤔
Would be hard to validate
like a Path class
i dont want to do a try/catch to catch the IllegalStateException because apparantly you cannot query if a BukkitRunnable is scheduled for some reason
Which means calling isCancelled if it's not scheduled throws one
what string would be useful for annotate with not empty
Ok but why do you need to check if a runnable is queried?
I mean
but would be cool to have
because said runnable might run and operate on a no longer existent value throwing a NPE
The runnable has to wait two ticks cuz minecraft is dumb and events fire before the actual event gets processed said two ticks later
So if the state the runnable depends on changes in those two ticks -.-
none of the annotations are enforced at runtime
unless you use intellij to compile that stuff
you can use like, @Pattern from the jetbrains lib if you want to prevent empty strings I guess
"none of the annotations are enforced at runtime"
"unless..." something that has nothing to do with runtime
🥲
tsk tsk
Give a concrete example on what you are doing pls. I dont understand how values can be null.
You are passing the values to the runnables context on creation. They cant be magically null later on.
none of the emilies are enforced at runtime
unless you send them fox tail pictures
ha
but yea, usually annotations don't save you from still calling preconditions/validate
they just make the developer experience a shit load nicer
because even thicc skulled people like emily get a nice warning when they pass null into their fav method
Lmaoo
But there are some annotations that can be used for checks. This is only usefull if your IDE actually understands the logic
behind those annotations tho.
Well, "can be used for checks" depends on your compilation chain tho
May we just all hope jspecify saves us
Static code analysis is hard. And i dont see a nice way to enforce the "Empty" and "NotEmpty" annotations for collections...
Alright, i formulated that wrong. If a player loses a certain state, I need to clean up the runnables that might still be attached to said player.
The problem is, those runnables are not guaranteed to have been called, since they are dependent on player actions (namely, switching items) so my options are 1) Custom Runnable class 2) try/catch for illegalStateException
What prevents you from prepending your runnable with something like
if(!stillHasState(player)) {
this.cancel();
return;
}
// Do the usual
Simply dont run it if the player doesnt have the desired state later on.
Yeah well isn’t that just @NonNullByDefault followed by @Nullable upon explicit declaration of it. I think I saw this project a year ago or two when they still had a couple of problems to solve (which they may still have)
because the marker for said state gets removed after the handlers and runnables are supposed to be removed, not before
pretty much last I checked 

would be nice tho to have a joined annotation collection
Absolutely
so I don't have to pick between three different projects
🥲
But i would suggest doing this:
public class SomeSpecialRunnable extends BukkitRunnable {
private final List<UUID> players;
public SomeSpecialRunnable() {
this.players = new ArrayList<>();
}
public void addPlayer(UUID playerId) {
this.players.add(playerId);
}
public void removePlayer(UUID playerId) {
this.players.remove(playerId);
}
@Override
public void run() {
players.stream().map(Bukkit::getPlayer).forEach(this::someSpecialAction);
}
private void someSpecialAction(Player player) {
// Do something special
}
}
Simply schedule this runnable when the server starts. Then add/remove players to/from it when their state changes.
Or if you want the player to be automatically be dropped when they are offline or not valid anymore
public class SomeSpecialRunnable extends BukkitRunnable {
private final List<UUID> players;
public SomeSpecialRunnable() {
this.players = new LinkedList<>();
}
public void addPlayer(UUID playerId) {
this.players.add(playerId);
}
@Override
public void run() {
this.players.removeIf(playerId -> {
Player player = Bukkit.getPlayer(playerId);
if (!this.stillValid(player)) {
return true;
}
this.someSpecialAction(player);
return false;
});
}
private boolean stillValid(Player player) {
if(player == null) {
return false;
}
// Other checks
return true;
}
private void someSpecialAction(Player player) {
// Do something special
}
}
hey can i delete my spigot account?
cant you use a WeakList, or is that not a thing
You can use a List<WeakReference<Player>> if you really want to
WeakList would be a bit weird because you have no idea what this list is backed by.
For example a LinkedList here makes the removeIf operation O(1) which is really nice.
where is linkedList>
?
actually
can you set the reference to a runnable to null from inside itself?
cuz if i just do that when it runs i can null check it, and if it's null its no currently scheduled
No, you cant reach the outer scope from within your runnable scope.
Unless you use an AtomicReference.
Aromic 🍒 lol
You are absolutely hacking your way through here.
I'm convinced i can do this without try/catch
You are doing something that will break or be really hard to work with later on.
Where do you need a try catch?
to check if its scheduled, to cancel it if it is
there's no way to check that without potentially throwing IllegalStateException
How about you dont cancel your tasks?
Just start a single task when the server starts.
Inside this task you keep a List<UUID> for all players that need to be ticked by the task.
If a player leaves or loses his state -> simply remove him from the List.
Scheduling repeating tasks for each player is a management nightmare.
it's not a repeating task
almost
its for everything changing the focus item
which for SOME reason takes 2 ticks to properly update item held and generic attack speed
Ok, i see the problem. Let me think of something nice for this...
you can;t cancel a non repeating task
uh
wrong
BukkitRunnable testRunnable = new BukkitRunnable() {
@Override
public void run() {
}
};
testRunnable.runTaskLater(Echo.getInstance(),200);
testRunnable.cancel();
i specifically tested that
why do you want to cancel it
this doesnt throw an error
just return in it
How do i do that?
I thought about it.
Dont cancel the tasks at all. Just schedule a new task.
There is no need to cancel the task.
wym schedule a new task?
like an empty one?
but that still wouldnt get rid of the task if its already scheduled would it?
But you dont need to get rid of the task. It will be executed like normally
and then 2 ticks later the new calculation will be ran.
well the problem is, that task manipulates a player object
one of the ways the state can be lost is by quitting
NPE
If you pass a Player to the task then it wont be null, even when the player quits.
If you switch to an item and then back, does your system clean up the stats this item provided?
yesnt
it just calls another runnable
so it gets set wrong and then set correctly one or two ticks later
Ok so if you switch to an item for one tick, then after 2 ticks you have the item effects and after 4 ticks you lose them again.
I dont see a problem.
Unless you want to prevent players from achieving the effects for 1 tick.
thats not really an issue, the problem is that under certain circumstances it causes exceptions
I have one 'clean up' method, which sets everything back to default
but that leaves the runnable
How do I create my dependency? I posted it on github. Next, I added the repository:
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>```
what's next?
``` <dependency>
<groupId>org.gt</groupId>
<artifactId>HeadHunter-Locations</artifactId>
<version>1.0.0</version>
</dependency>```
the dependency is red and writes that nothing was found in the OTHER repository
Then dont run it if the player is no longer online. No NPE then 🙂
Did you publish a release?
yeah
Send the jitpack page
true
so what should I do?
send ur repo
^^
still doesn't work
so I need to do this?
jitpack will default try to compile using java 8 unless you tell it otherwise in a jitpack.yml
and with the "release" is everything ok?
seems to be selected 17
what about gradle build config or whatever
and they seem to be the same, if you download resources from them, then this repository will be there
Where can I find that pull request?
I don't know, I haven't used it, it seems to me more complicated
I need to login
u signed the cla yet?
Idk what is cla?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
gotta give your first born child, etc. address and stuff
although that's the full patch, not the diff
You don't
they will
should deprecate them 😏

Is there an ETA for this pull request?
i just hope we can all happily move on from API level format methods once string templating hits 🙏
10,501 years
soon™️
That is one decision i despise from paper. Deprecating the String methods.
xd, fair
I mean, having an incomplete format in the API is bleh
preferably we get string templating soon
Also changing the plugin loader, which breaks plugin hot reloading
then people can just use the component methods with something like sendMessage(LF."§aHi there")
Has it even been incubated yet?
in 21
I should start reading JEPs again...
it entered in preview directly
yea
so hopefully landing sooner than later
and people can stop sobbing about needing api level format support (for incomplete formats)
legacy, will-be-removed, jank section char color codes are bad.
components are good, more powerful. and if you still want strings you got minimessage (or some other string-based format)
like legacy :^)
&4Mini Message is the greatest!
§x§f§6§8§3§8§3hi is great right?
when the random codes are so ingrained into your skull you just find it more convient even though it just sucks
yes
well yea, minedown
I use MineDown
I am sure it will also provide a nice string template processor
got my sweet BaseComponent 🙂
ah yes, BaseComponent[]. super nice to work with
I don't use BaseComponent[]
I use BaseComponent
I removed the array
and then we are in the beautiful world where the API can leave behind the legacy trash, people just use like MD."" or MM."" in their methods
I couldn't wait for choco's PR
and the server side can be happy
I'd get behind this if tihs was added it'd make components so much less of a pain to use granted actually hard coding strings is a sin so you'll never catch me using that in my code unless I'm doing debug
except fuck that shit
👀
real question guys why does it matter hard coding strings is sinful repent from your ways
the JEP is rather nice, dunnon what you are on about orbyfied
imagine u have to change it at some point
.
u have to replace it everywhere
also, basecomponent isn't immutable which is jank
makes it hard to work with from an api consuming input. have to clone it in order to not screw with plugins
public static BaseComponent unarray(final BaseComponent[] components) {
TextComponent base = new TextComponent();
base.setExtra(List.of(components));
return base;
}
totally valid and safe 😎

Everything is mutable with enough memory jank
you're house is mutable. (I'm going to mutate your living room)
Did you write an annotation processor for dynamic code generation before?
I cant find decent content to learn this.
doesn't baeldung have something nice on this
i like gradle becuz of how it is configurable and has actual build script instead of shitty xml lol
i recall playing around with their tutorial
woh I may have brain damage, but XML is great
Not sure if it goes deep enought for me. Ill take a look.
xml is weird html
iirc they made a full builder from annotations
xml is the most valid thing ever 🧠
which should get you most of the shit you need for basic code gen
gradle is more powerful than maven
i rather would use yaml or json lol
Those are interchangable statements.
yeah
not groovy only
ktl
kotlin is also here
same shit
I have a system right now where I'm adding vectors to a map because I'm trying to seperate this into a sort of "model" to be able to be copied, right now the origin is setting at the block of jungle wood. (the one to the left of the white wood) and I would like the origin to start at the bottom instance of amethyst, how could I do that?
no same shit
gradle uses kotlin by default
and kotlin and groovy is two different things
:\
the syntax is whole different lol
*groovy
it's syntax, yeah
Kotlin DSL needs to be explicitly used. Groovy is the default.
nope
for gradle
look at latest updates to gradle
Let me check
8.2 gradle uses different language by default
LOL
months old
yeah
cool
😳
I like this
kotlin is way better tho, way better intellij support and looks better than groovy
groovy has better support
nah
i would argue it's "better"
- fuck kotlin
groovy has that nasty js smell on it.
imo kotlin is way nicer
yeah
is a horse a vehicle? I'm trying to determine if a player's attack is a crit
groovy is weird dynamic typed language with java syntax
only argument for kotlin is null safety,
click source
find parent classes
kotlin also have properties
and see
so so so so true, I keep saying groovy is the javascript of the jvm
no, no body uses it
and adults alike
which is why we should move to php
lynx you need to learn the ways of java applets
this is cruel to groovy emily
Will finalize Spigot's chat API afterwards
the groovy runtime is cruel to groovy yes
Then looking into better hover events
Then looking into either adopting MiniMessage syntax, or MineDown
i will smack you
Still wish y'all didn't drop MiniMessage support for BungeeChat
That's going to waste my time
Fk i cant modify existing files with an annotation processor unless i modify the AST via some internal compiler APIs 
actually, does spigot support the message securities added in 1.19.2+
or something like that
Yes, but BungeeCord doesn't iirc
Or at least it's difficult to
Velocity's struggled with similar issues
the update that killed proxies
doesn't chat securities break if you use any chat plugins though
yeah
kinda lame addition if it breaks the second I want to make my chat look cool 🆒
most chat plugins just replace your message with system message type anyways
so there is no point
Does serverbound mean its sent to the server?
oh yeah 😎
Thanks
I was thinking of this
lol
player.getAttackCooldown() <= 84.8f
Why's this false on a fully charged attack?
may need to reinstall some themes or@plugins
cuz its not percent but a fraction
best clazz
for tests?
yes
X
lol
idk how to call it
if I call it Player I'll have import issues in the bukkit module
and do MockPlayer
I'm testing my core module, it has no dependencies




