#development
1 messages ยท Page 43 of 1
nice
Me when I read documentation
I had to use different documentation (ChatGPT)
How can I take the Kyori Component and make it a BaseComponent? (I need that for some book stuff I am doing)
im ngl i don't even know what a BaseComponent is lol
Idk the difference, but it matters ig
um, its a little weird.
Might be worth joining the kyori guild as well
Bungee serializer
BungeeComponentSerializer
you might need to shade it
yeah, I found this: ```java
String legacyJson = LegacyComponentSerializer.legacySection().serialize(kyoriComponent);
BaseComponent[] spigotComponents = TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', legacyJson));
yeah that just serializes it into legacy formatting and then back
this is from net.kyori on maven central
idk the exact artifact name
smth like adventure-text-serializer-bungee
Worked like a charm ๐
Fyi adventure has a page on their wiki about migration
Hello, I have a problem concerning Nametag edit API, I tried to edit the prefix with this
NametagEdit.getApi().setPrefix(player, prefix); but the nametag doesn't change, there is no error in the console btw, thanks for your help
Is it possible to have no identifier for a placeholder when creating an expansion?
Or well it is I just dont know how
why tho?
I just want the placeholder to be %title%, I mean I guess it could be %menu_title% or something, but now I just want to know how it's possible lol
no it is not
Oh, but many plugins uses placeholders like just %player% etc?
I guess they just format those within the plugin without the API
exactly
Ah alright
you can simply use minimessage
Can minimessage also handle placeholders? Didn't know
not in the same was as papi, but you can pass them to MiniMessage#deserialize
https://github.com/Hepno/MinecraftShockCollar I was bored so I decided to make a thing
based
anyone who stars the repo gets my everlasting servitude ๐
done
THANK YOU ๐๐๐
How did you test it
..Don't ask
How did you test it
Uh
Uhhhhh
So I uhhh
Uhhhhhhhhhhhhhhhhhhhhhhhhh
According to my lawyer its confidential and I can't say due to NDA
I am learning css, and I want a style to only apply if the element doesn't have an input child. I know the :not selector exists, but how can I use it to check if it doesnt have an input child?
Does anyone happen to know how I can pass the --imageName=xyz argument to a gradle task, from within a gradle task?
i don't
Thanks Emily
anytime
To pass the --imageName=xyz argument to a Gradle task from within a Gradle task, you can use the project.exec() method to execute a command-line process with the desired arguments.
Here's an example:
task myTask {
doLast {
def imageName = "xyz"
project.exec {
commandLine "gradle", "myOtherTask", "--imageName=${imageName}"
}
}
}
In this example, the myTask Gradle task uses the project.exec() method to execute the gradle command-line tool with the myOtherTask task and the --imageName=xyz argument.
You can modify this example to use your own task name and argument values as needed.
ChatGPT is still our friend
Is it possible to get an object from a string, so like I have the string sword and an itemstack called sword. Can I directly convert the string to the object or do I need to just check using if statements?
Wdym?
You can use a Map
Yeah ig, but is it possible to do that? I've been wondering for a while lol
To do what I said
I know the map is ofc
So I can use "sword".getItemMeta() pretty much
If that makes any sense
val itemMap = mapOf("sword" to ItemStack(Material.DIAMOND_SWORD))
fun String.getItemMeta(): ItemMeta? = itemMap[this]?.itemMeta
"sword".getItemMeta()
:D
I don't really understand the code tbh lol
I understand the map part
But after that I dont
Closest thing you can do is serialize and deserialize the itemstack each time
If you don't want to store a map
Hmm yeah it's because I'm storing them in config but I should probably just use the setItemStack function on config
And getItemStack ofc
Strings are just easier to customize
I'll just make a map lol, thank you
i have an enum of enchantID, a parameter of this enum is an enchant object, which has a parameter of enchantID, for some reason EnchantID is returning null even tho i specified the enchantID inside of the class in its constructor, any idea why?
JACK_HAMMER(new JackHammer(),21), //enum
public JackHammer() {
super("Jackhammer", EnchantType.JACK_HAMMER, List.of("Has a chance to break an","entire layer of your mine"), 1000, CurrencyType.TOKENS, true);
}
An alternative is to put the Class as a parameter in the enum
Then initialize the classes in like onEnable to return them in a method
im assuming theres s reason that im not currently understanding as to why this is the case
Because the field isn't initialized yet ig
U can try using intellij debugger but idk
I'd think it give some error though not null
ยฏ_(ใ)_/ยฏ
to create JACK_HAMMER, you first require an instance of JackHammer, so you go create it, but it asks for the JACK_HAMMER enum constant, which isn't yet created (it's in the process of being created), so it'll be null
How i can check if item taked from creative inventory? (Api 7.2)
Api 7.2?
๐
1.7.2*
Api 7.2 is that bad compared to 8.0?
Are you talking about sponge or what?
I about sponge
Ok then ask here discord.gg/sponge
what would be the best way to make it not be null
before i had a map of EnchantID,Enchant but that required me to make sure i always added each enchant to the map
like it worked
i just wanted something to make sure that EnchantID always linked to the Enchant object
which is how i came up with just having them in the EnchantID enum
Perhaps you can have a lazy init (idk if it is the right therm) for EnchantmentEnum#enchantment on the getter
Enchantment getEnchantment() {
if (this.enchantment == null) {
this.enchantment = (get the value from somewhere);
}
return this.enchantment;
}```
what is the purpose of a combine function in a mutable reduction operation?
the current problem wasnt with the object being null, it was that the object i created was using the EnchantID enum in its constructor, and due to it not being made yet it was set as null
String result2 = vowels.parallelStream()
.collect(StringBuilder::new, StringBuilder::append, StringBuilder::append)
.toString();
``` the third lambda here
d;jdk stream#collect
R collect(Supplier supplier, BiConsumer accumulator, BiConsumer combiner)```
Performs a mutable reduction operation on the elements of this stream. A mutable reduction is one in which the reduced value is a mutable result container, such as an ArrayList, and elements are incorporated by updating the state of the result rather than by replacing the result. This produces a result equivalent to: ```java
R result = supplier.get();
for (T element : this stream)
accumulator.accept(result, element);
return result;
Like [`reduce(Object, BinaryOperator)`](#reduce(T,java.util.function.BinaryOperator)), `collect` operations can be parallelized without requiring additional synchronization.
This is a [terminal operation](package-summary.html#StreamOps).
the result of the reduction
supplier - a function that creates a new mutable result container. For a parallel execution, this function may be called multiple times and must return a fresh value each time.
accumulator - an associative, non-interfering, stateless function that must fold an element into a result container.
combiner - an associative, non-interfering, stateless function that accepts two partial result containers and merges them, which must be compatible with the accumulator function. The combiner function must fold the elements from the second result container into the first result container.
yeah, I've read the javadocs -- I get how it works but I don't understand how the combiner param does anything beneficial
The equivalent code they provided can literally be done with just collect(supplier,biconsumer)
R result = supplier.get();
for (T element : this stream)
accumulator.accept(result, element);
return result;
The accumulator function is appending the list string element to the StringBuilder instance.
The combiner function is merging the StringBuilder instances. The instances are merged with each other with a comma between them.
https://www.digitalocean.com/community/tutorials/java-stream-collect-method-examples right where you got the code from
hmm..
but I mean, why couldn't I just "add the comma" during the initial accumulator expression?
collect.(StringBuilder::new, (a,b) -> a.append(",").append(b))
do you see what I'm saying?
yeah
Why not collect(Collectors.joining(","))?
just learning how to use it first
yeah tbh I don't understand 
Does anyone have any suggestions for features I could add to https://github.com/Hepno/MinecraftShockCollar besides the basic "send api request on damage event"
you are probably not meant to use it directly and instead use Collectors#something
use a proper http client and not curl and process builder ๐
Well curl is the way you access their API
they probably have an example with curl because it works anywhere (windows, linux, mac)
fair
ill look into it
ive come up with some bandaid fix, added a Class<?> for EnchantID which uses Enchant.class then in the static block it then calls
for (EnchantType type : values()) {
try {
type.lunixEnchant = (LunixEnchant) type.lunixEnchantClass.getDeclaredConstructor().newInstance();
} catch (Exception ignored) {
}
}
should hopefully work, might not dont know
curl is just 1 interface for http requests, not one that's very suited for code
i also dont think that will work on a lot of windows systems lol
maybe its something specialized for Collectors yeah. Lol
worked fine when i tested it
I guess I'll just accept the redundancy and move on
yeah it works, but it is an improper use
epic reply fail?
ah fair. i made the entire thing in 5 minutes so i didnt really bother checking lol
wdym
i assume you meant to reply to this
List<String> asList = stringStream.collect(ArrayList::new, ArrayList::add, ArrayList::addAll);```
It is not necessarily redundant, this is another example for ArrayList from jdk
no I meant to reply to the "thats not how it works"
i run linux anyway so
i have no clue if itd run on windows or not
then im afraid thats not what "thats not how it works" means
all g
it seems to work just fine, might come back later if i find a better method
but like me & gaby said already, curl is just http requests, there are better cleaner ways of doing http requests in java
and i think curl isnt installed by default on windows so yeah it probably wont work
fair fair, I'll update it to use http requests later
ty
but this also just seems like overhead. I'm building an arraylist and copying it over to another arraylist
bm do you know more about Stream#collect? I'm curious how it works but I don't really understand ๐ต
* R result = supplier.get();
* for (T element : this stream)
* accumulator.accept(result, element);
* return result;```
the jdk has this in the documentation, which is straight forward, but the way the combiner works is not clear
the combiner is for when you have a parallel stream
^
is it? 
yes
it makes sense though, because of the addAll
lets say you have a very big parallel stream. rather than doing the collecting sequentially you can break the stream into "chunks", collect each chunk, then combine the results using the combiner function
np
aside from fixing the fact that im using curl instead of something more versatile and propper, does anyone have any feature suggestions?
um
neither do i its for the meme ๐ญ
its for the funny
i swear
the more damage you take, the higher the shock is idk
B.A.A.S - Too many caps!
No need to shout.
Barry's Anti Abuse System | v1.4.7
yeah make it kill you lmfao
oh shit yeah good idea
hmmmmm
the ultimate hardcore gameplay
"Minecraft but if I die in game I die IRL too" ๐คฃ
ill 3d print a gun, add some of my random mechanical stuff i have no idea how to use but ill figure it out inside, make a working gun, then make the plugin cause the gun to fire
wait am i allowed to say that
probably
okay good i was worried for a sec because i remembner someone getting banned from discord for saying that lol
I SWEAR
its for the meme ๐ญ
thats an awful lot of effort for a "meme"
it took me 5 minutes to code ๐
its literally just a config and an eventlistener
"please give me suggestions for my plugin guys i promise i dont actually care about it though"
LOOK ๐ญ
no judgement it's just a lil sus
its a meme i swear ๐ญ
if you say so
fuck you ๐
if it involves electric shocks, i'll pass thanks
am i allowed to say that
hopefully
How did you test it tho
that is a very good question
you need a fork and a live socket
Is there an event for when someone uses /papi reload?
Whenever I do it, it breaks my plugin's placeholders
uh
๐ง
?
how fast are plugin -> localhost mysql interactions? i.e if data is stored on the db, is it worth putting effort into caching that data?
Fast, some configuration allow you to change the update time but it can make your server slower
i wouldnt bother but if it ever does become an issue you can add caching then
so effectively if each time data is needed, it is requested directly from the database, it's fine?
you could always test but running the calls (which are network calls btw) on the main thread might not be ideal
yeah obv i'd multithread it
Minecraft servers are not multithreaded unless you specify it in Java args

i guess my main concern is, do I need to bother about modeling data as objects in runtime or am I fine just making calls to SQL?
me personally - last time I used SQL was ages ago as I pretty much just use JSON
and when I use JSON I cache the whole file so
๐ฅฒ
lol
that is what i do rn
what objects are you storing?
if it won't be a huge amount then caching shouldn't be too bad
i think?
imagine groups of users, each group has other data attached such as roles, descriptions, bank balances, etc
my main desire to switch to sql
is bc the relational aspect feels like it will make it so much easier
๐ค interesting
like its a lot easier to filter data and stuff
I would like to ask if anyone here has experience with saving modded item data (NBT). I have a problem with a couple of mods and their items.
What exactly is the issue
oh nvm, maybe I know how to do it
You can simply use paper's itemstack (de)serialize methods. ItemStack#deserializeAsBytes and #serializeAsBytes
d;paper ItemStack#serializeAsBytes
@NotNull
public @org.jetbrains.annotations.NotNull byte[] serializeAsBytes()```
Serializes this itemstack to raw bytes in NBT. NBT is safer for data migrations as it will use the built in data converter instead of bukkits dangerous serialization system.
bytes representing this item in NBT.
Hey, trying to find a way to support custom fonts (resource pack) and image prefixes for my chat plugin but all I can find on that is related to item model data, which has little to nothing to do with how it's handled in chat as far as I can tell?
how can I get the ItemStack from RecipeChoice in a Recipe as the RecipeChoice#getItemStack is deprecated
RecipeChoice uses material, not itemstack
what
you would use RecipeChoice.MaterialChoice or RecipeChoice.ExactChoice
ofcourse check if they are instanceof materialchoice or exactchoice, then cast them and use their getItemStack() method
since they arent deprecated
If have an enum with assorted permissions that I want to store a set of in a database for each player, how should I store that in the database?
e.g. a chmod style system where there can be multiple permission flags associated with each entity
enum Permission {
READ,
WRITE,
EXECUTE;
}
Im considering using the bitmap value in database with enumset in code.. is this sound?
well there are a lot of ways to do it
public enum Permission {
READ(1),
WRITE(2),
EXECUTE(4);
// ...
}
public void save(Player player, Set<Permission> permissions) {
int encodedPermissions = 0;
for (Permission permission : permissions) {
encodedPermissions |= permission.getValue();
}
// .. save
}
public Set<Permission> get(Player player) {
int encodedPermissions = // .. load
Set<Permission> permissions = new HashSet<>();
for (Permission permission : Permission.values()) {
if ((encodedPermissions & permission.getValue()) != 0) {
permissions.add(permission);
}
}
return permissions;
}
That looks roughly like what I was planning yeah, I just wanted to make sure the idea itself was sound
That there's not some glaring obvious reason I shouldn't use this
well I don't really see any issues with it, though there might be better ways of doing it
You could also create a permission table and point user to it via a foreign key
You could also store it in a list form in the player table, ex. ['r', 'w', 'x'] or just a string separated with commas or anything else 'r,w,x'
The only alternative im aware of would be having a one (player) to many (permission) database structure, but Im not a fan of that idea
To my knowledge that's kinda a relational databases no-no
My main worry for the bitmap option is needing to maintain the ordinal mapping correct for the enum
well the ordering of the enum itself wouldn't matter so long as you always have READ(1) and WRITE(2), 1 will always be 1 and 2 will always be 2 no matter if READ comes before or after WRITE in the enum listing
well, the databases are usually capable of serializing/deserializing lists, the main thing is how you'd handle the list itself
public enum Permission {
READ(1),
WRITE(2),
EXECUTE(3);
private static final Permission[] PERMISSIONS = values();
private final int bitset;
Permission (final int bit) {
this.bitset = 1 << bit;
}
public static Set<Permission> fromBitMap(final int bitmap) {
final Set<Permission> permissions = EnumSet.noneOf(Permission.class);
for (final Permission permisson : PERMISSIONS) {
if ((bitmap & permission.bitset) != 0) {
permissions.add(permission);
}
}
return permissions;
}
public static int toBitMap(final Set<Permission> permissions) {
int bitmap = 0;
for (final Permission permissions : permissions) {
bitmap |= permission.bitset;
}
return bitmap;
}
}
No idea if that came out right, I'm writing on my phone
Does that look right?
Idk if I got the terminology right, never screwed with bits like this before
writing all of that on a phone is actually psycho
one question is why do you have a static permission field
Permission.PERMISSIONS?
just use Permission.values() 
also, don't use 3 for execute
since the sum of read and write is also 3
Can't you just use .ordinal()?
Why would you abuse a database like this
in three separate columns is the proper way.
You will have a fun time doing statements like WHERE permissions.permission == 1 or 3 or 7
java creates a defensive copy every call
database is just the storage, all the action takes place in code
still not proper database usage
what's the proper usage if not to store data ๐ค
the ability to lookup data too
Where's the third column am I missing something
like all players who have the READ permission for permission X
what do you mean third column - what type of database is this
player_name | uuid | ... | read | write | execute
-------------------------------------------------
| | | true | false | true
please don't store player_name and uuid in the same table repeatedly
that's not proper SQL
You should make a separate table for player_name to uuid with UUID as primary key
โ๏ธ๐ค
Relational but that only gets me 2: player/foreign key and permission name
second normal form please
yeah with relational you can have more than 2 columns
extra joins => worse performance ๐ฅฑ
fine but you will have fun updating a player's name
In my actual use case there'd be a 3 column uniq constraint
technically two players can have the same name in minecraft
no need to update player name 
not with that attitude they can't
WAIT NO
i read it wrong
clout denied
Wait wait wait, why am I checking numbers like that, am I missing something
to select players/rows with specific permission?
you can't do bit operations in a query
Figures but then I'm even more confused
My idea so far for this is one-to-one:
account,entity,permission_value
unique constraint on account and entity together
alternative, which i thought about and which I think is what your suggesting, was one to many
account,entity,permission_name
with unique constraint on account, entity and permisson together
My main concern with the alternative one though is:
I either need to make a SQL query direct when the modification is being made, or delete all existing permissions before inserting the updated ones when saving later
Neither of which are very appealing to me
Yes, definitely insane.
Hey! I'm currently trying to implement an PAPI Extension:
This is my class: https://haste.base2code.dev/ujitakayen.kotlin
In my onEnable() I call the following: new PlaceHolders(this).register();
PAPI also registers the plugin:
[PlaceholderAPI] Successfully registered expansion: caseopening
However placeholders are not available - the method onPlaceholderRequest is not being called.
Am I missing something?
(Please ping on answer)
Use the onRequest method
and maybe set the canRegister option to true
and make sure that your placeholder begins with %caseopening_<jewlery>% or %caseopening_cases.<something>%
Hey! I just added you do you mind accepting or replying
what command are you using to test?
and this
hello i need help
Error : ```Cannot invoke "java.sql.ResultSet.next()" because "rs" is null
Code : https://mclo.gs/il1D7zh
check if the result set is null
but it's not that's the funny thing
but it is
es ist ja ResultSet rs = MySQL.getResult("SELECT * FROM OnlineTime ORDER BY Time DESC LIMIT 10");
if (isConnected()) {
try {
return connection.createStatement().executeQuery(query);
} catch (SQLException exception) {
exception.printStackTrace();
}
}
return null;
}```
well
I think thatโs the question answered
isConnected is clearly false
Also for what itโs worth this is not a very good way of doing this. Use a connection pool library like HikariCP and just open and close connections on-demand
oh sorry was my mistake just saw it xD
also don't you have to close the value returned by createStatement?
memory leak ๐
i get error "Unable to parse placeholder.." on a deluxetags tag, a space anywhere fixes it, but i do not want a space there. it doesnt show the colors
anyone have a fairly simple example of parallelism I can practice implementing?
i.e something like getting the factorial of a very large number (already done that)
count how many consecutive odd prime numbers there are in the first 1 million natural numbers
eg. 5 and 7 are consecutive odd primes, but 7 and 9 are not
@feral raptor
excellent idea, thank you sir. Will get back to you with the result :P
it's not very fun to count consecutive even prime numbers
i guess you coulddddd do that in parallel though
excuse you it's unique
it didn't even have to try
is there a way I can remove the underwater mining speed penalty for a player?
I am trying to achieve what the aqua affinity enchant does
I know one person that I suspect knows the answer to that
Do you?
yes
I'm not sure
I am
uh i haven't been doing a lot of programming lately, at least not that isn't in existing projects
Any particular reason that might be?
kind of it's client sided
doesn't depth strider help with this?
im really puzzled on this:
i have a mailcow container and a roundcube one, and i want when i access mail.domain.tld to get to roundcube (and working) and only when i access /admin, i want to be redirect to the mailcow container to the admin interface. (nginx btw)
everything i have tried resulted in either both breaking or the admin interface not being accessible anymore
Hey, I got an issue with fetching a list in config..
String configPath = "Skins." + itemName;
ConfigurationSection skinSection = Skinify.getInstance().getConfig().getConfigurationSection(configPath);
if (skinSection != null) {
List<String> skinValues = skinSection.getStringList("");
for (String skinValue : skinValues) {
if (skinValue != null && !skinValue.isEmpty()) {
return true;
}
}
}
return false;
}```
```Skins:
BOW:
- 4601
- 34332
DIAMOND_AXE:
- 4601
- 53244
DIAMOND_HOE:
- 4601
- 5344
DIAMOND_PICKAXE:
- 4601
- 1234
DIAMOND_SHOVEL:
- 4601
- 1233
DIAMOND_SWORD:
- 4601
- 3012```
It returns null somehow?
but this one prints System.out.println(Skinify.getInstance().getConfig().saveToString()); the entire config and it's there ๐ am checking item in hand ```skins.isSkinDefined(player.getItemInHand().toString())``` and it returns DIAMOND_SWORD
skinSection.getStringList("") is not a proper call
if you use config.get("Skins." + itemName) will get you a List, not a ConfigurationSection
so if you want the skins of an item, just do config.getStringList("Skins." + itemName);
yes, makes sense ๐
still not returning correct public boolean isSkinDefined(String itemName) { String configPath = "Skins." + itemName; List<String> skinValues = Skinify.getInstance().getConfig().getStringList(configPath); return !skinValues.isEmpty(); } returns false on the diamond_sword I am holding ?
if(skins.isSkinDefined(player.getItemInHand().toString())) {
MenuUtilities menuUtilities = Skinify.getInstance().menuUtilities(player);
menuUtilities.setItem(player.getItemInHand());
new skinGUI(Skinify.getInstance().menuUtilities(player)).open();
} else {
player.sendMessage(Messages.chatMessage("error_invalid_item"));
}``` the println prints ``` BOW:
- 4601
DIAMOND_AXE:
- 4601
DIAMOND_HOE:
- 4601
DIAMOND_PICKAXE:
- 4601
DIAMOND_SHOVEL:
- 4601
DIAMOND_SWORD:
- 4601``` so I am super confused ๐
ah, that toString() is not giving you DIAMOND_SWORD but much more stuff. you want getItemInHand().getType().name()
worked โค๏ธ appreciate it! ๐
np
I'm looking to dive into NMS again after a few years, back in the day you had to source dive to find what a, b etc were. These days I know Mojang maps exist, how does one setup a project with the mappings? So I can use NMS stuff with the proper names
Ah godsend, thank you!
poor chazza going down the plugin rabbithole again
its changed so much ๐ nms used to be reflection with the alphabet
i feel you
anyone knows what event is called when players swap armors by right clicking?
PlayerArmorStandManipulateEvent or PlayerInteractAtEntityEvent
he might've meant when you right click armor in your hotbar which will equip automatically
but he said "swap" so idk
๐
hopefully he means this then
paper may have an event for it
PlayerArmorChangeEvent in paper api
look at that
incredible
paper ๐
paper saves the day as always
ChangeInventoryEvent when
What packets do I need for client side item lore? I know there's smth like "item/slot meta" but is that enough?
yes
Client sided item lore? Why?
for custom enchantments, adding the name and level to the lore is the most painful part because it can be modified by a dozen other plugins
Fair, good luck on your journey 
Wouldn't that make you the plugin modifying it over the dozen others or are you adding compatability?
what I have rn in mind is to take the lore and display it to the player with my enchantments appended to it
easier said that done, will see how it goes
Ah interesting.
I'll keep an eye out in showcase ๐
Whoops
works flawlessly 
Hmmm
Test1
I swear, after you get enchantment to be displayed on the item you have like 50% of the plugin done 
i gotta see some code
I just add the lore on https://wiki.vg/Protocol#Set_Container_Slot but it was a small test xD
<dependency>
<groupId>me.glaremasters</groupId>
<artifactId>guilds</artifactId>
<version>3.5.6.6</version>
</dependency>
When I add the dependency in pom, it doesn't load any other dependency when I remove this one everything it's fine, someone knows why?
I followed this link: https://wiki.helpch.at/glares-plugins/guilds-w.i.p-migration/developer-api
is it possible to redirect to a link right after clicking a GUI item in Deluxemenus, if so how
Someone can give me the repository and dependency of Guilds ? The one on the wiki is not working
do you have the repo added as well? It is there https://repo.glaremasters.me/service/rest/repository/browse/public/me/glaremasters/guilds/3.5.6.6/
Same thing still not loading any of other dependency in pom when I add the guilds one
Idk I added the jar directly, with repo and dependency is not working
well, are you using the jar or the maven dependency ??
Now the jar and it's loaded
ok
I need some input here. So I have this Mob Coins system with modifiers (different things that can influence the chance and the amount of drops - potion effects, enchantments on weapon, permissions, etc.), all good so far, the problem I'm facing is how to decide what type of coin should be dropped in the first place (there's Common, Rare and Epic coins, each having a different base chance).
With one coin is easy because the start point is the base chance for the type of entity that was killed
The current logic is: get the chance for the entity that's killed > go through each modifier > use the final chance > if the player is lucky enough go through each modifier to calculate the amount of coins > give the coins
How is reflection performance wise?
I have a project that uses a bit more reflection than I'd like (It unfortunately has to)
Depends on how you use it
just calling small functions
here's one of the main spots: https://github.com/Fredthedoggy/TwistCore/blob/master/src/main/java/me/fredthedoggy/twistcore/RemoteModule.java
In your case, probably bad
If you cache the lookup it can be very fast
you are DOOMED
lol
I'm lucky it doesn't run too often then I guess
I'll cache the things I can though, like icon & description I guess
and hope for the best
JavaPlugin#getDescription is public though
oh f*
I'm dumb
that one I didn't need reflection for
a bunch of other ones I do though
why aren't you making use of the regular onEnable/onDisable etc
also, can you not make a Module interface that will be implemented by those plugins and call the methods directly?
It's a system for in-game "twists" for the McYT community, and basically people want to be able to enable and disable them at will
so the plugin enables with onEnable
but the twist enables when selected in the GUI
Well it gets shaded into each plugin, and relocated each time
so each plugin has the same code, but relocated
why
cant the core provide the api?
TwistCore
if the whole thing is relocated.. couldn't you, just, refer to LocalModule.class normally?
if it is shaded in each plugin, how do you access the GUI?
/twist is registered by the "manager" that is decided on load via communication between all of them
and it runs the GUI
and connects to the other ones
only for the local module, since the remote ones are under a different package, and therefore a different (unknown) class
as far as I'm aware atleast
and the major issue is communicating between the relocated instances
I would personally have this core thing as a plugin
Why does core need to be relocated?
this seems like a terrible design ngl
Yeah
Well how else would I make a mainplugin-less module system like this?
since this does work, like I have a working copy running
What's the issue with having a main plugin that controls the rest?
it makes more sense that all plugins sharing the main logic
Or just make all the modules plugins at that point
Mostly friction. The people I'm aiming at are not used to paper/spigot type things, and I end up with 100s of people complaining that it doesn't work because of the dependency being missing
But if they are all using the same "core" why does it need to be relocated anyways? Will you ever have different core versions on each of them? That's sounding even worse
if they are using mods they are certainly used to dependencies
yeah, since what if someone has an old one and a new one?
With this system, it chooses the newest version to be the "manager", and the manager is just backwards compatible
They're not. it doesn't matter how big a log there is saying "DOWNLOAD THE DEPENDENCY", I just get flooded with support requests
I know from experience ._.
Ok Fred
yeah seems like
Sounds like this would work much better with a core plugin, think of it like papi and the extensions
I would prioritise the development process than the stupid users that can just restart the server once they see a big ass warning saying "You need X plugin"
well it's not like it's much harder to do this system than that one, it only took me like 2 hours to make :p
but I actually lose time in the long run with the amount of people there are who don't read the warning
Yeah, you're right that it will work better
I guess I just need to decide what I care most about
You're welcome
๐ซต
Break her finger
Make main plugin load that depency plugin?
I think I will go with something like this
<coin type>:
<entity type>: <chance>
common:
ZOMBIE: 50
CREEPER: 65
rare:
ZOMBIE: 35
CREEPER: 45
epic:
ZOMBIE: 25
CREEPER: 35```
And if a list doesn't have a creature it doesn't spawn anything?
Or rather, a creature doesn't have to be in all 3 lists right?
Yeah it will only consider the entities that are listed. If zombie is not listed on the list of the epic coin it will not drop that type of coin, only common or rare
LGTM.
Another design I considered was
entity:
common: 50
rare : 35
but I think yours is more clear for sure.
https://paste.helpch.at/ivutuvewif.yaml like this, just some dummy values
drops looks a little redundant, but I like it
yeah there will be more stuff added to the coins
makes sense
looking good
Luck 4, Bad Luck 2 and Looting 3
Luck 2 + bad luck 2, you have 50% chance to double your diamonds and 50% to immediately die
technically they would cancel each other I guess (+2 + -2) ๐คฃ
That depends if you consider luck to have the same weight as bad luck.
Personally I think bad luck weighs more
It's neat
Probably a dumb question, but I wonder if using floats instead of doubles for chances would be considered a "premature optimisation" or is a justified use?
100% is 1.0d and 0% is 0.0d and the max number of decimals will be probably around 7, so something like 0.9912345 for 99.12345%
I forgot to mention that, yes, I currently use doubles to represent the chances, sorry.
aaand.. what would that be optimising for?
Do you mean what the chances are for?
No
You are asking if it would be considered a premature optimisation, what would you be optimising for by doing that?
Code maintenance? CPU usage? memory footprint?
Resources usage in general
Thinking more about it, it is not gonna do anything probably
since the only values stored on a long therm are the default chances for each mob type (so maybe around 100 values on a bigger setup) which is equal to 0 in comparison to other systems
I wouldn't bother
yeah
Even if you have two million doubles lying around, that's going to be 16 MB + change
damn, 16MB?
you should use bytes
and implement your own IEEE format
3 bit exponent and 5 bit mantissa ๐
smh Ivan don't mock me 
but think of the gainsss
:p
Bitwise operations can be pretty fast
no they cannot
i forbid it
Nevermind, autoboxing is fast
proof?8
Int -> Integer = 500speed
Bitwise -> ??? = 2 speed maybe?
It would be at least 5
hi, im listening to BlockPlaceEvent and i wanna get the block material thats being "replaced" (vines, light blocks, air, etc...), what would i use to get that? would i just get the block at the BlockPlaceEvent#getBlock's location?
im blind ๐
anyone have suggestions for inventory api/frameworks for 1.19.4 that are easy to use
like GUIs?
ye
made by a staff member here too :)
not like that makes a difference
will try out
I have a quick question, using player.openInventory with target.getInventory(), what is the result?
Will I see the hotbar or only the actual inventory contents?
I am having some pc troubles, so I can't properly test rn.
you will only see the 4 rows I think
so it will include the hotbar?
no
So I'm having issues trying to implement minecraft horns in my plugin for 1.19.2. It would appear that MusicalInstrumentMeta class is not in the 1.19.2 api but the horn items are. Anyone know what I can do to remedy this?
hey ahve you checked the latest aopburo
I just tested it, and it actually does include the hotbar. I was also pretty sure it doesn't, oh well learned something new ๐
wait for real?
And the armor content too, it's the inventory items, hotbar items, and armor content
damn i could swear it is only the inventory
Armor?
you sure?
the inv I get is 4 rows
so 3 inv 1 hotbar
yes but the thing is bugged as fuck and they are somehow merged into the bottom inventory
which is why some invsee plugins have separate commands for viewing the main inventory and viewing the armour, and mirror the items between inventories
calling openInventory with a player inventory is fucked
The 0th slot of the player inventory is their crafting results...
1-4 is crafting slots, 5-8 armor, 36-44 is their hotbar, 45 offhand
it's a mess
or at least it isn't meant to be used by humans
Or well, that's how they are defined in the protocol. Bukkit uses an entirely different set of ID's such as 0-8 mapping to hotbar instead of 36-44
the inventory api is fucked
bukkit api*
there's any lua programmers here?
maybe? why?
do BukkitTasks run at the beginning or end of ticks?
specifically before or after commands
commands run when theyre run
commands are received async so it can't hop on the main thread whenever
like how Bukkit.getScheduler().runTask doesn't run the task on the same tick
thats not true nor is it helpful
ok
ok "<@&333634764085133313>"
help dkim then brister
i am
thats awesome
it would've been faster to just open the code and see lmfao
oh that's a good idea
as far as i can tell packet processing is the first thing that happens
why the hell you still got that role?
aw so chat's first?
why not?
what are the chances of someone figuring out a dupe by running a command on the tick right after another
๐
how about you fix it? lol
you and tanguygab might be the only people to still have that role. cherish it and take care of it. it is your son
honoured
what is that channel?
role settings
lol dkim
lol dkim
we got access to that?
you got access to the member list
what ๐
it is the Members list
and you can "filter" by role
oh
noob
how do I do it?
wow brister 
truly
theres a very decent chance i missed something
those guys didnt even get paid, did they?
nah you're probably right
Please don't tick the children
creep
@dusky harness easy way to confirm, run a server with a debugger and stick breakpoints on both lol
problem solved
are those two called in the same method (tickChildren)?
then yeah bukkit tasks run before packets are processed lol
ez
true
tyty bm ๐ฅฐ
oh ok
๐
Can anyone assist?
for (Map.Entry < String, List < String >> entry: friends.entrySet()) {
String pl = entry.getKey();
List < String > friends = entry.getValue();
player.sendMessage(Bukkit.getPlayer(UUID.fromString(pl)).getName() + "'s friends:");
for (String friend: friends) {
player.sendMessage("- " + Bukkit.getPlayer(UUID.fromString(friend)).getDisplayName());
}
}
Trying to output a players friend list, but instead it is outputting every key of the hashmap.
wdym?
also you should probably just use UUIDs in the hashmap key & value rather than strings, it'll be faster and it's safer
So I am trying to output a players friends list (/friend list) - but instead it outputs all players friend lists
Okay
ah
well, that's to be expected given that you're looping over friends
you probably want to do friends.get(playerUUIDOrWhatever) instead
and then loop over the list from the result
friends.get(UUID).entrySet()?
no
if friends is a Map<String, List<String>> then friends.get(String) is a List<String>
you dont need entrySet
that gives you all the entries
oh, so just do for(UUID entry : friends.get(playerUuid)), correct?
I don't need the second for loop
yup
okayyy
thank you!
also, what is the replacement for #sendMessage?
I have been out of development for a few years
Something like components i think?
if you want to support spigot then you'll probably still need to use sendMessage, or add the adventure dependency manually and shade it
if you only care about paper, then just #sendMessage(Component) (compile against paper-api rather than spigot-api)
can you support both?
So building against spigot-api should be good for paper, what about purpur and the other little ones?
Im currently building against paper, but testing on purpur.
those too
basically if you build against a fork, it'll only work for that fork and the ones below
bukkit -> spigot -> paper -> purpur/pufferfish/airplane/etc
okay easy day
for (UUID entry: friends.get(player.getUniqueId())) {
player.sendMessage(player.getName() + "'s friends:");
player.sendMessage("- " + Bukkit.getPlayer(entry).getDisplayName());
}
Brister, something like this should work right?
oh wait lol
Only if you use their specific api though
yeah the others have said, but the tldr is if you build against spigot, you'll support basically everything but miss out on some of the nice things. the more nice things you enable, the less compatible your plugin is
folia 
why when I do a /papi reload, the placeholder I created in my plugin stops working?
You probably didn't set persist to true. It's on the wiki somewhere.
thanks
not to disappoint but I don't know a single person in here that is particularly well-versed in skript
they have a discord, should prolly ask there
Emily doesn't know a single person, yet is a single person.
Curious
๐
what doesn't work?
im a few issuies in indenting this skript could you help
There's a server made special for skript, join it
yep sure
command /spawn [<player>]:
aliases: hub, lobby
permission: spawn.spawn
permission message: &cSorry, but you don't have permission to execute this command!
description: Teleport you to spawn.
trigger:
if {spawn} isn't set:
message "&4Error:&c spawn is not set!"
stop
else:
argument 1 is not set:
wait 5 seconds
teleport player to {spawn}
message "&6Teleporting..."
else:
if sender has permission "spawn.spawn.others":
if argument is online:
teleport argument to {spawn}
if sender is a player:
message "&6You have been teleported to spawn by &c%player%&6." to argument 1
if sender is not a player:
message "&6You have been teleported to spawn by &cConsole&6." to argument 1
teleport player to {spawn}
else:
message "&cSorry, but you don't have permission to execute this command!"
it doesnt look right eather
yo whats the script discord
Hello, possibly a basic question, unsure. Looked through the wiki and pins but it's possible I passed over an answer.
Is there a simple way to be able to use both mini-message and PAPI at the same time? Or am I stuck having to kinda parse them separately and combine them in a weird convoluted way
I'm trying to support PAPI in my plugin messages, but my entire plugin is using minimessage right now
omg thank you so much
np
Anyone got an example github repo where they've published a library/module to Maven Central? Trying to publish something with build.gradle and it's been a nightmare to setup
you can look at chatchat. that's what the last 4-5 commits are for.
Ah really, thank you! It's been such a head fuck
Ah thank you, making progress..
Execution failed for task ':sdk:publishMavenPublicationToOssrhRepository'.
> Failed to publish publication 'maven' to repository 'ossrh'
> Could not PUT 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/net/analyse/sdk/2.0.0/sdk-2.0.0.jar'. Received status code 401 from server: Unauthorized
* Try:
Now got to figure why its not letting me
- bad credentials maybe?
- lol
- does it not work with more?
- fff
3+ digits
lmao
lmao
- oh
- test
๐ญ
wtf
10000000000. wtf is this lmao
10000000000. test
124214.21412412.21412
1000000000. test
- 1412412
The limit is 9999999999
10000000000. f
odd that it's int limit if it's js
but why 3 digits at minimum?
Anything more than 1 goes left
wait how? I tried that
- this is different to
1. this
it's a different font
it's just longer ones fuck it up
I guess they're trying to add lists?
This is so dumb lmao
it's supposed to be yeah like
- a
- b
- c
a. Hey
10a. test
a10. test
abc. test
- test
At first I thought it is just broken on my side lmao since I just updated the nvidia drivers and haven't restarted yet
Oh mobile it looks like "๏ฟฝ๏ฟฝ๏ฟฝ" for me
lmao. let me check
it might be a leaked feature from forums
because lists work on the first post from forums
for me it seems to actually look like a normal message
just more space between lines
Also it doesn't work on dms 
I mean it doesn't work in your guild either
Same but only this one
yeah same here
lmao
999999999999999999999999999999999999999999. 0
it works on mine
so whenever you go over int limit it goes back to 1?
Does it show everything?
Lmao
๐คฃ
only when you reply ๐คฃ
indeed
-401. Test
011010000110100101100100011001000110010101101110. Test
that would've been even funnier
Haha that's a fun one
test
๐คฃ
im curious how the chat will look when this gets fixed xD
we'll have to wait and see .1
I assumed but was to lazy to manually copy it
write it*
bcz you can't copy from the reply
hidden?
ah ok
matt leaving easter eggs everywhere
Just like me. I like to tell people that my code isn't broken but that I love leaving easter eggs for them to find
in form of bugs
Yeah. Bugs are nice. They do stuff.
010110010110111101110101001000000110001101100001011011100010000001100001011011000111001101101111001000000110010101101110011000110110111101100100011001010010000001101101011001010111001101110011011000010110011101100101011100110010000001101001011011100010000001100100011001010110001101101001011011010110000101101100001000000110100001100101011100100110010100100000011000010110111001100100001000000111000001100001011100110111010001100101001000000110000100100000011000100110100101100111011001110110010101110010001000000110110101100101011100110111001101100001011001110110010100100000011101000110100001100001011101000010000001101001011100110010000001101000011010010110010001100100011001010110111000100000011101010110111001110100011010010110110000100000011110010110111101110101001000000111001001100101011100000110110001111001. Test
hmm
hell nah
Lmao
doesn't even show it all
so
doesn't matter
actually
they completely removed inspect element?
try to TTS that message
yeah
That was a mistake
๐คฃ
it turns into "stop speaking message"
๐ ๐ ๐ ๐ ๐
yeah xD
ur lucky i dont have tts perms
huh is that even a thing?
diamond shape with a dot inside
yeah you can start tts for everyone
diamond shape with a dot inside diamond shape with a dot inside diamond shape with a dot inside
damn
I thought it got removed
oh it did? maybe idk
can I really not inspect element even by enabling some developer mode or something?
I wonder how many kids lost their accounts because of that lmao
a lot
damn there's a settings file?
55798319027847842452871172500245955255238544258506414229481695316111825737104436684825982659841461529424168786857761782786931. A better hidden message
test
base 10?
Damn too big to see all
not on my screen
skill issue
Base 10, convert it to base 16 then to text
hacker !
lmao
ah yeah. it is an ordered list
makes some sense
not a lot
99999999999999999999. test
242. test
123. test
425. test
there we go. we've gotten 1-9 as well
what did you think it was lmao blitz
a jar of honey
ah, I wish it was
#development moment
Test
Test
omg @pulsar ferry
@dense drift
Want to inject some flavor into your everyday text chat? You're in luck! Discord uses Markdown, a simple plain text formatting system that'll help you make your sentences stand out. Here's how to d...
I just want to be annoying
test
test
- list item
- another list item
*insert kappa emoji*
LOL
[hi](@broken elbow)
hi emily
how
also reee, my package isn't appearing on https://central.sonatype.com/search?smo=true&q=net.analyse ๐ข it says it published to nexus
hahahahaha
idk what im doing wrong
kappa
you can hide naything
not just links?
that's funny
[how's your day going]( @leaden plume )
this shit's hilarious
you already are dw
Damn that's pretty neat
Has anyone worked with smth like limited stock shops? I need to implement something and idk how to handle transactions. For example, there can be 2 items left in stock, player A buys 1 and player B attempts to buy 2 but only 1 is left.
basically you need one central authority that processes the transactions
like an SQL database and a single thread
So like the methods to access the stock, sell items, etc. are called on the thread where the manager is running?
if you want it easy yes
I see
public class ShopTransactionHandler {
private final ExecutorService executor = Executors.newSingleThreadExecutor();
private final Queue<Transaction> transactions = new LinkedList<>();
public void addTransaction(Transaction transaction) {
executor.submit(() -> transactions.add(transaction));
}
}```
It this right @minor summit ? ๐ฌ
Oh boy transactions
that is one way of adding stuff to a queue yes
what would another be? 
Fair
... this is the weirdest way to synchronize a list's adding
ยฏ_(ใ)_/ยฏ
Even Collections.SynchronizedList(new LinkedList<>()); would be faster
yeah sorry, I haven't done anything like that so far ๐คฃ
btw should be execute, not submit, i think?
i just remember submit swallowing up exceptions
and so i switched to execute
well it returns a Future, you are expected to deal with the Future appropriately
ye
it's not really about "how do i add this to the list", it's about what the hell you are executing
Ok so what I'm thinking about doing is to add each transaction (aka player attempting to buy an item) to that queue and process them in order to make sure the stock limit is respected
okay, process them where?
that's a good question because idk how I'm going to do that ๐คฃ
the idea is to process the transaction in the moment it is created
"process" meaning to check the stock and if the player can buy the requested amount of items, to subtract the money from their balance, decrease the stock etc.
and why not run that in the executor instead of pushing to a queue?
hmm
sorry, let me rephrase that
you could run that in the executor instead of pushing the element into the queue
so because it is a single threaded executor it will allow one action to be done at a time? 
yes
it will queue the tasks, so, there's your queue already, it's the executor itself
yeah that's fair


