#help-development
1 messages · Page 1644 of 1
I mean I suppose but gradle plugins are kinda pro/con debatable
shit i didn’t see that xD
The strongest argument is that gradle is faster and a lot more concise in terms of less boilerplate and verbosity
what does it do i did it
Maven is fine but like 
I want this to be triggered later and want to pass it on
It shoudl organize your imports. Add any missing includes
The plugin environment as a whole is great, it's just IMO Gradle lacks basic features and can be complicated to initially learn
use a interface
hey that’s pretty neat
although
Hmm yeah it does add a lot of mobility and customizability which can be frustrating for someone who wants it dead simple
Which is what I want 
But given the speed I think it pays up
is it eclipse only?
i guess
interface FutureVoid {
void run();
}
//
void myFunction() {
}
//
otherFunction(this::myFunction);
@river spear
I do enjoy my nap waiting for the Gradle daemon to start

No clue, I don;t use other IDEs
fair enough lmao
i’m too lazy to learn keybinds
🤨
okay thanks
didn’t mean to say that
whats it like having kids
is it worth it


Definitely not worth it.
xD
lmao
lmao
brutally honest
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Gonna teach them what you’re spending your days on?
don't give code to someone that doesn't know how shit works imajin
Grandkids are great, you can hand them back when you've had enough
lol
lmao

sure you may have fun doing shit with your kids and teaching them shit, but you can't fuck whenever you want and you will eventually get tired of the little demons.
any upside of using bukkit service provider than making your own
is this from experience
cause last time i checked you were the child
it's not
The ServicesManager interface?
check the pfp
just facts
lmao
thats not a child
registeredserviceprovider
are you saying I look old?
swagger
im saying you look great for your age
you don't know my age
80
are you assming?
It’s in API so it’s a component for all plugins imagine
this is harassment
assming xD
that doesn't say shit
boomer music
anyone can like it
I bet you would love it if you tried it
sounds like something a boomer would say
I bet you can find little kids that like it
sounds like something a boomer just said 🤔
this sounds so wrong without context
sec lemme go check with the basement
that I know of, you can find more.
there won’t be any 😎
@reef wind why is your name prouddesk
guess 3 times
Lol
What music?
Does someone know if it is possible to show the frosty vignette (when a player is within powder snow) with spigot ?
I think it's a client side thing or ?
Ans why do you feel the need to ping me everytime you lose an argument
look above
you are involved with a lot of stuff
I don't even like jazz that much, it's kinda bad ngl
Because I listen to a lot of musoc
You've seen my music collection before
also move to #general
not if it involves you
What involves me?
smh
go to #general
I don't like your playlist, I think it's meh
no
Can agree, his playlist is shit
Hey guys got a little issue.
I want to change the biome of a whole chunk and I am trying it like this:
World world = chunk.getWorld();
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = 0; y < world.getMaxHeight(); y++) {
int worldX = (chunk.getX() * 16) + x;
int worldZ = (chunk.getZ() * 16) + z;
world.getBlockAt(worldX, y, worldZ).setBiome(biome);
}
}
}
But it doesn't have any effect when I am checking on F3
Can anyone help me?
your math looks wrong
chunk.getX() * 16 would mean that when youre at 5000,5000 for example you would be getting 80,000, 80,000
well example for the calculation:
but it's chunk.getX() that should be -6 in that case
oh right
Why not just get the block location from the chunk?
final Block block = chunk.getBlock(x, y, z);
I tried that before, didn't work for some reason
Right, they changed.
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = 0; y < world.getMaxHeight(); y++) {
// int worldX = (chunk.getX() * 16) + x;
// int worldZ = (chunk.getZ() * 16) + z;
chunk.getBlock(x, y, z).setBiome(biome);
}
}
}
I will try it like this, one sec
it says this code is unreachable ...
package me.David.HelloWorld;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
public void OnEnable()
{
}
public void OnDisble()
{
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(label.equalsIgnoreCase("hello"))
{
if(!(sender instanceof Player))
{
sender.sendMessage("You need to be a player to run this command");
return true;
}
if(!sender.hasPermission("helloworld.use"));
{
sender.sendMessage(ChatColor.RED + "You do not have permission to use this command");
return true;
}
Player p = (Player) sender;
p.sendMessage("Hello" + p.getName());
return true;
}
return false;
}
}
Doesn't work with the chunk blocks as well. It's very strange. I got a command to check if the blocks are from a certain biome. The commands displays the setted biome but when I check F3 nothing changed
oh
Did you relog in between?
thanks :)
nope I didn't... sooo it takes effect when u relog, but does it also work for the server like this? I mean for example I change the biome to something where special mobs spawn
I'm pretty sure it's only client side.
Not sure if there's a way to forcefully update it somehow.
Of course.
Ah found a way to do it without relog
?jd
Im not sure if found a bug or what happens here...
I try to get the bedspawn with the getBedSpawnLocation method from a OfflinePlayer.
If the player never had a bed on the server, the method returns null which is correct.
If the player had a bed, the method returns a instance of a location which is also correct.
If the player had a bed and break the bed, the method still returns a instance of a location, which is not correct. The method should return null again.
Any ideas if that is correct and i don't understand that or if that is a bug ?
If I'm using protocollib and a packet has 3 shorts, do I have to use packet#getshorts#readsafely(0), #readsafely(1) and #readsafely(2)?
List<ServerInfo> waitingServers = new ArrayList<>();
for (ServerInfo info : foundServers) {
applyStateToConsumer(info.getName(), s -> {
p.sendMessage(s);
if (s.equalsIgnoreCase("pre_game")) {
p.sendMessage(ChatColor.GREEN + "This server is pre game!");
waitingServers.add(info);
}
}, p);
}```
would i be able to immediately iterate through waitingServers, or do i have to do some fancy stuff? atm i don't think i can iterate
@torn oyster why you dont test it ?
Yes it should work as it is just a list, the problem is that you try to iterate on a empty list. saw you don't try to iterate on waitingServers
i do try to iterate on it
nothing
it doesnt say "This server is pre game!" at all
So show more code (e.g. what is the variable foundServer and how will it filled with data).
theres a BlockBreakEvent but i cant seem to find block place event 🕵️
List<ServerInfo> foundServers = new ArrayList<>(getProxy().getServers().values());
for (ServerInfo info : foundServers) {
applyTypeToConsumer(info.getName(), s -> {
if (s.equalsIgnoreCase(minigame)) {
p.sendMessage(ChatColor.GREEN + "This server is the minigame, " + minigame);
} else {
foundServers.remove(info);
}
}, p);
}```
thats another one
declaration: package: org.bukkit.event.block, class: BlockPlaceEvent
Hi everyone. I have a problem with my plugin and I don't understand why it appears. My goal is to make a weather module which manages the weather of a specific world. So there are different types of weather : SUNNY, RAIN and STORM.
However, I have a problem with the RAIN weather. Indeed, when the user wants the rain to be enabled for a specific world, I use the WeatherChangeEvent to detect a weather change and I cancel it in case in which the new weather isn't rain. However, when I use the /weather clear command and the event is cancelled, it is called a lot of times. I don't know of to fix that. Can someone helps me, please ?
Version used : 1.8 (I want my plugin to support 1.8 to 1.17).
Code :
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onWeatherChange(WeatherChangeEvent event) {
System.out.println("WeatherChangeEvent");
event.setCancelled(true);
}
Note : The sysout is displayed like a loop in the console.
Hi ! I need to make a "custom ai target" for wither skeleton. I wanna them to target everyone but not some player. The test of "is a pleyr to not target" is working (i debug it) but i got a weird issue : when i summon for the first time the skeletons they don't target the safe player. But when they target an other entity, kill him then they will target back the safe player with any reason. Is there some kind of issue existing with this or just set target very buggy ?
Is this per player or everyone
Should be a entitytargetevent
this is what i use to manage this
everyone
Maybe don’t cancel it but set it to whichever weather you want
after killing the cow the target go on me but actualy in the code i cancel it when they try
This will cause a recursive problem because when storm or thunder is set, it call the event.
if i'm doing getServer().sendPluginMessage(), do i need a player online?
if so
then this sucks
when i use it for bungee yep you need a player
Nope,
if(event.getWeatherChange() != Weather.WHAT_YOU_WANT) {
// Change weather
}
im sending it from spigot > bungeecord
there is 1 player on bungee
not on the backend tho
yep you need to have at least one player
omfg
I never like the bungee plugin message, redis was the biggest update ever
event.getWeatherChange() doesn't exist.
Idk what it is, I dont use the event, use whatever you need to get the weather its changing to
it was psudo code 🙂
Yeah but there is only toWeatherState that returns a boolean. I tried what you said but I have the same result
how do i work around it
i really need to be able to do it
with 0 people online
Use MySQL or a messaging service API like redis
I made my own messaging service with MySQL when i didn't know about proper ones and it actually worked
how
i've just spent like 10 hours trying to do all this
im not spending another 10 trying to change it to some other thing
I spent 3 days working on a problem because i got the number 1 and 2 mixed up
xD
Well, there isn't much you can do apart from learn something else if you need 1 player online
you can't for my part i was need it to know player number on all server and on the first boot i create a runTaskTimer that check if on player is connected and if yes i send the message ales i wait until player connect
i cant do that
a player will never be able to connect
without this plugin messaging
what do you want to do exactly ?
trying to get an int from the backend server
well
value
if that value is what i want
it connects the player
you don't know what its for
be more precise
Pffft, Just use raw Sockets
just know this
trying to get an int from the backend server
well
value
if that value is what i want
it connects the player
how do i do that
well with this i can't do nothing for u bro
what is the backend server ? what is the int for ? why a int ?
i said "value"
its a string
not int
okay replace by string sry
Well, when a Connection is attempted you create a seperate connection and send some Data outside of the Main connection
I really recommend you learn something like redis, its so good.
It can be used for other purposes as well such as caching data
how?
You'd still need to establish a connection
?
of course
His problem is he can't send things to the bungee when there is no one online
Redis wont magically connect the Server and bungee
It was a suggestion
Overkill solution:
Attach a PDC entry that is increased on every run and nuked on every tick
Memory leaks incoming
why
Is it possible to use a spigot plugin in bungeecord
No because they are both very different API
You will likely forget to remove the Key on disconnect
hmm :))
Just don't forget then.
👍
aye
a Map<Player,V> is totally fine
If you're afraid of forgetting to remove the key on disconnect, a WeakHashMap implementation would do fine
In some cases, Player can be used as key. It's not a Industry Standard or whatever you want. If handled correctly, it's perfectly fine. However, I agree that in some cases, UUID are better.
If your only goal is to store some data whilst the player is online, then using UUID is redundant imo.
You could take advantage of the fact that there will only be one player instance per player which means we could in principle also use an IdentityHashMap although we would have to remove the entry on disconnect.
I wish we had mixins available so we can assign a field to do it with 0 overhead
😌
Hashmaps have a certain inefficency after all
The only bad thing with Player storage is that we need to have a Player all the times and it can add an operation cost to retrieve it.
You mean like the hash computation?
In this case you'd have the Player object available already
No, for example, if the uuid of a Player is only manipulated we need to retrieve it has a Player using Bukkit.getPlayer() for example. And we don't know the complexity of this method.
It can be n (where n is the number of players of the server)
Oh yeah, tho pretty sure its O(1)
It's anywhere from O(k/n) to O(n)
Bukkit::getPlayer should by default delegate to CraftServer::getPlayer which just queries the player lookup map iirc
Where as k is the capacity of the underlying hashmap
I doubt the underlying lookup map has to rely on buckets or whatever its called
Custom map implementation?
myes maybe
There are few bucket-less map implementations
the craft implementation isn't my field of expertise
And designing one for this is overkill imo
Neither for me
Tho I trust the capable maintainers of the software that it isn't too unreliable
how do i send a plugin message using sockets
i dont have a player online
and i need to be able to send it
RabbitMQ or Redis pubsub mb?
idk what to do with it
where do i start
i have a method
The issue with Sockets IS that it also requires opening the connection, destinguishing the Socket Type and a Bit more
At Second thought you might be better Off using a lib unless you want to send Just Tony amounts of data
You need a Server Socket to Bind to (should be the Bungee) which can be created with https://docs.oracle.com/javase/8/docs/api/java/net/ServerSocket.html#ServerSocket-int- and a Client Socket to Bind from https://docs.oracle.com/javase/8/docs/api/java/net/Socket.html#Socket-java.net.InetAddress-int-
Then use it's getInputStream and getOutputStream for magic
Since you'd send Strings you'd send byte[] Bytes = string.toBytes(StandardCharsets.UTF_8); out.write(Bytes.length); out.write(Bytes); and read recieve with String Str = new String(input.readNBytes(input.read()), StandardCharsets.UTF_8);
Of course since you connect multiple clients to a Server you'd need identification and whatnot so perhaps you should be using a lib that does that for you
(+ you will need to Reserve a Thread on the Serverside to wait for connections which is inefficent)
Actually ServerSocket::accept does this to an acceptable degree
If i check if NBT is == to something but the NBT doesnt exist on that entity will i get null? or will it pass as its not equal?
through persistent data container
myes
null or no?
an absent value for a key is probably going to be represented with null
null
because people don't know what Optional<T> is apparently :)
😌
Also got JSpecify which if we're lucky might be natively implemented in the JDK in the future
yeah found out about it recently also
also does EntityBreedEvent.getEntity() return the child?
Any way to optimize this?
if (fatherData.has(new NamespacedKey(plugin, "family"), PersistentDataType.STRING)) {
if (motherData.has(new NamespacedKey(plugin, "family"), PersistentDataType.STRING)) {
if (Objects.equals(fatherData.get(new NamespacedKey(plugin, "family"), PersistentDataType.STRING), motherData.get(new NamespacedKey(plugin, "family"), PersistentDataType.STRING))) {
event.setCancelled(true);
return;
}
}
}
It feels like im doing something wrong
make it more readable
that's already optimized
create the key once
oh, true
yeah lol apart from that not much to optimize
i was just about to do that
alright
thank you
if (Objects.equals(fatherData.get(fatherKey, PersistentDataType.STRING), motherData.get(fatherKey, PersistentDataType.STRING))
|| Objects.equals(fatherData.get(motherKey, PersistentDataType.STRING), motherData.get(motherKey, PersistentDataType.STRING)))
if one of these is null it will give NPE?
If so, how do i stop that
dont think so
Objects::equals takes 2 arguments where both intentionally accept and handle null accordingly
Alright
And i just realized, i want to also check if father key is == to mother key
no shorter way to do that other than adding 2 more ||?
I would suggest extracting out some explanatory variables
/*
Equivallant to Objects.equals()
*/
public boolean equals(Object a, Object b) {
if (a == b) return true;
if (a == null) return false;
return a.equals(b);
}
so like if (fatherIsMother) rather
lol no worries
just got back from school im not thinking straight
school having a negative impact on an innovative mind
I should take a nap lol
a wise decision
Ok
Intellij keeps saying that i should do this
what the fuck does this mean
assert fatherMother != null;
it means dont do it
if the following condition after the assert is false
then it throws an AssertationError
however
a special jvm flags needs to be set in order for it to even work
So usually we go with a null check
yeah
or
Objects::requireNonNull
depending on what you're doing
ok
im checking if two things are ==
and if one of them is null
i just want it to be false
alright
Ftr, this is useful for:
- Method references
- Non-null parameters
yeah
Meanwhile, Objects::equals is for null-safe value-comparison.
Basically, i have
String fatherFather = fatherData.get(fatherKey, PersistentDataType.STRING);
String fatherMother = fatherData.get(motherKey, PersistentDataType.STRING);
String motherMother = fatherData.get(motherKey, PersistentDataType.STRING);
String motherFather = fatherData.get(fatherKey, PersistentDataType.STRING);
and i want to check if any of them are equal to each other
if its null
wait wat
then its not equal to it
two of those are redundant
String fatherFather = fatherData.get(fatherKey, PersistentDataType.STRING);
String fatherMother = fatherData.get(motherKey, PersistentDataType.STRING);
String motherMother = motherData.get(motherKey, PersistentDataType.STRING);
String motherFather = motherData.get(fatherKey, PersistentDataType.STRING);
thats better
what is the maven dependency for bukkit 1.17.1?
bukkit?
this is a spigot server
yes
believe does not exist
Do you mean CraftBukkit?
yes
mere bukkit was abandoned long time ago
ik i can import it with jar and have craftbukkit but i want it with maven
i have spigot 1.17.1 imported with maven but it does not have craftbukkit
You have to add to ur local repos
yeah
i tried this wich is the same as the spigot version and it does not work
1.17.1-R0.1-SNAPSHOT
well yeah, the versions are gonna be different
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>```
what is the version name?
spigot
?
why do you need bukkit
nms
public Boolean checkParents(PersistentDataContainer fatherData, PersistentDataContainer motherData) {
NamespacedKey fatherKey = new NamespacedKey(plugin, "father");
NamespacedKey motherKey = new NamespacedKey(plugin, "mother");
List<String> fatherStrings = new ArrayList<>();
List<String> motherStrings = new ArrayList<>();
fatherStrings.add(fatherData.get(fatherKey, PersistentDataType.STRING));
fatherStrings.add(fatherData.get(motherKey, PersistentDataType.STRING));
motherStrings.add(motherData.get(motherKey, PersistentDataType.STRING));
motherStrings.add(motherData.get(fatherKey, PersistentDataType.STRING));
for(String i : fatherStrings){
if(motherStrings.contains(i)) return true;
}
return false;
}
}
am i insane?
you run build tools and it will be installed to your local repo
return boolean not Boolean
under the spigot group and the artifact is just spigot
oop
Yeah
you should make fatherKey and motherKey fields of the class checkParents is in
also there's probably a more efficient way to do that search but eh, idk
wait
if any of these are null
will i get an NPE?
what do you mean local repo? i have the spigot api i need craftbukkit
Maven Local
it's where all of the libraries on your computer are located
as opposed to Maven Central, which is a remote repo
yes i know what you need and i have told you how to get it
why boxed boolean
also what I think they mean is that it's org.spigotmc:spigot:1.17-R0.1-SNAPSHOT
Ok.
So how would i reference the local repo in the dependency?
Boolean is a class, boolean is a primitive
take a look in your .m2 folder but i am very certain the version string is the exact same
ok so i have this right
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>``` what do i put for the version i am confused
and if i dont have a repo what is the group id?
use the spigot group id and just spigot for the artifact
your versoin string is correct
hyperlink by returning the type Boolean you implicitly return Boolean.FALSE or Boolean.TRUE or null, assume you store it to a variable whose type is the primitive variant boolean then it would have to invoke Boolean::booleanValue implicitly which is just straight method overhead
ok ive got this ```
<dependency>
<groupId>spigot</groupId>
<artifactId>spigot</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
but its telling me it doesn't exist
```Missing artifact spigot:spigot:jar:1.17-R0.1-SNAPSHOT```
oh
i am dumb
sorry i am still kind of new to maven lol
it appears to be working now thanks
nice :)
wait so does this import also include the spigot api?
yes
ok so i can get rid of the other one then right?
if you want
ok
hey, if any of these are null will it throw an NPE?
yes
fuck
no
🧄
only if fatherData or motherData is null tho
oh
hi! What is the best minecraft server startup flag/parameters ?
those cant be null
otherwise, get would just return null
wrong channel fam
nah i been toold to go here
no you haven't
go to the correct channel and you won't get sarcastic responses
oh no, i am now going to cry myself to sleep thinking about this
timbers: shivered
i know but do they work i mean do they make the overall performance better?
Yes
?flags
Aikar's garbage collection flags: https://aikar.co/2018/07/02/tuning-the-jvm-g1gc-garbage-collector-flags-for-minecraft/
That’s the entire intention behind them
memory consumption
I'm having a bit of a weird issue. When using player.setCollidable(false) it disables arrows from working properly on players using <1.9. (Using protocolsupport for the version support.)
Any idea on how I can disable collision without causing an issue like that?
How do i check if an entity is a cow, sheep, pig, horse, etc anything breedable
like whats the most efficient way
who needs docs when you can get random people on the internet to link you to them for you and get mad you simultaneously
class You implements Submissive, Breedable
trhat should work right?
thx
cause im big dum
cuz nothing is in there
?code
Hi. I have two questions:
- Does anyone have any recommendations for stuff to make plugin dev a bit easier/cleaner? Just some general utilities.
- Would you recommend using a GUI framework or just coding GUI by yourself? (GUI in this context means chest GUIs)
can someone help me compile this?
https://github.com/softpak/HOSE
- Check out BKCommonLib, helper but also awesome-minecraft gh repo
- InventoryFramework, Canvas, triumph-gui, interfaces are just some
I've seen Canvas
IF seems a bit overcomplicated though, since it uses a very... Swing-esque panel system
I was mainly asking if I should use one.
BKCommonLib'll probably be useful though, thanks.
I’d make an easy system with a consumer for clicking, @stone sinew does it not throw an error?
Probably something to do with chunks
No it loads fine atleast from the world setting showing in console but If I try to teleport to it, the server lags and eventually crashes
It never teleports me either it just stays on "Loading world..."
if someone can help me with this i would really appricieate it.
https://github.com/softpak/HOSE
please PM me.
Btw, another question, what is the minimum version of the game I should (actively) support?
Up to you
Hmm 1.8 usually
Since there’s for some peculiar reason a lot of servers staying on that version
Nothing peculiar about it. Its the best option for optimization. All higher versions add to much to the game.
It’s outdated
And well iirc spigot uses a lib which doesn’t work with Java 16 or something so it makes it limited to what version you’d use to run the server
You can join 1.8 with 1.17 clients
Can't remove them from the game
I believe it's the YAML library lol
1.12, easy to maintain, and gets those 1.8 suckers moving
Actually the Apache commons one
yapperyaps it’s a hell to first and foremost having to support a wide range of versions especially if you involve nms
Or Lang
Idr exactly but yeah
idk
In 1.17 they swapped to just pure obfuscation and then encouragement of building against mojmaps
I use nms with minions 😉 I support 1.8.8 up to 1.17.1
On minions revamped I support backwards compatibility. 1.17 down to 1.8.8
I mean, with modern mapping tools they could easily do consistent jar mapping.
Yes a lot of plugins do
But that doesn’t take away the irrefutable fact that it would have been much easier if everyone just stayed on latest
anything i can imporve here?
improve*
it feels like there are too many if statements
If they made the game take less time to load in future versions and servers then it might be used by more people.
And btw, I'm referring to the tools used with Fabric.
e.g. Matcher and Stitch.
Haven’t compared start up times directly but that’s probably true on the flip side
Certainly, this is probably a question for md5 himself
create a Chance object, create an Api to manage chances
then loop through the chances
apply the event to them
adds for much more expandability
for this part?
if (randNum.nextBoolean()) {
childData.set(fatherKey, PersistentDataType.STRING, fatherData.get(fatherKey, PersistentDataType.STRING));
} else {
childData.set(fatherKey, PersistentDataType.STRING, fatherData.get(motherKey, PersistentDataType.STRING));
}
if (randNum.nextBoolean()) {
childData.set(motherKey, PersistentDataType.STRING, motherData.get(fatherKey, PersistentDataType.STRING));
} else {
childData.set(motherKey, PersistentDataType.STRING, motherData.get(motherKey, PersistentDataType.STRING));
}
always look for ways to include things in an api
Its cause it has to load so many more items,blocks mobs etc.... then 1.8 which yeah of course cause the game updated but certain gametypes that people play don't need all the extra BS
y'know
the Spigot NBT system is real ugly :p
i agree
i have a nicer looking one
but people kept yelling at me to use the normal one
What's the other one?
I'm curious to see why they might be saying that.
Bananapunchers NBTEditor
Mm well yes that’s probably the cost of more features
its one class
But quite frankly not only features
In addition more security and better code architecture and more stuff are multi threaded
Oh
There’s a lot of pros with newer versions also
PDC is slow as hell
Multi threaded isn't really needed in previous versions cause it doesn't contain all the additionals
So what’s your definition of needed then?
In newer versions of course its needed. Cause of all the new blocks and algorithms to chunk load etc...
No I’m genuinely curious, if you say multi threading wasn’t needed and all the new features?
class BreedApi {
@Getter
private static final Set<BreedHandler> HANDLERS = new HashSet<>();
@Getter
private static BreedApi inst;
{
inst = this;
}
public static void addBreedHandler(BreedHandler h) {
HANDLERS.add(h);
}
}
interface BreedHandler {
void apply(SomeEvent e);
}
//Whatever event you in
for (BreedHandler h : BreedApi.getHandlers()) {
h.apply(event);
}
Is that Lombok?
In 1.8 there wasn't as many features and chunk loading was handled fine single threaded. But in future versions with all the new features multi threading was absolutely necessary.
why not. 
I respect the usage of Lombok in internal code (aka implementations).
In APIs, it leads to more confusion.
im not overusing it here
Get their velocity and set it in the opposite direction.
Yes but taking away the multi threading part? What’s your definition of needed? Is it only the merely adequate features 1.8 is providing, then sure stick to 1.8 it makes no sense if you don’t care about any improvements to bump version.
Also that {} isn't static.
There's legitimately a difference afaik.
do you even understand it
you instantiate it on onEnable
you cant access the instance in a static initializer
and its a fucking example
not everything is perfect
Wait but hold up
omg
Why are you even using it like a Singleton when everything is already static?
It's a bad example tho
This isn't a visible part of the fucking example either :p
🙂 I was not teaching them the api part
And you do know that HyperLink is a beginner, right?
Reading this it went from 0-100 real quick
I'm sorry but it's legit just a horrible example :p
then make one yourself and stop complaining
Like, of course I don't understand it bc it doesn't make sense.

i hate people like you. its a bad example but the api is not the focus. its the abstractation and expandability of what hes doing. if you were to fucking read the original post then you would know why. im on a phone. i couldnt give two shits about writing out a fully fledged system for a two minute spigot project for someone in a help discord. do it yourself, and stop complaining
Okay but you do know that that also encourages a beginner to do something like what was shown in the example?
If someone doesn't immediately understand that it's the abstraction part, they'll copy it.
If they copy it and expects it 3o4ks that's their fault
@somber hull Hey buddy! dont copy everything I said! Learn from it!
Works*
you happy now? im not a teacher i help to the best of my knowledge
stop being such a dick and further expand on what i say to make the learning process better for the person requesting it @lavish hemlock
I'm glad you said that at least :p
Let’s talk about Kotlin, shall we?
and this is my normal personality
javathon
Here:
// Users of your API can implement this interface to handle an event.
public interface BreedHandler {
void update(SomeEvent event);
}
// This encapsulates your handlers and also allows said handlers to be updated when an event happens.
public class BreedApi {
// Use Set instead of List if you:
// - Don't have duplicates.
// - Don't need to get a value at a specific index.
private final Set<BreedHandler> handlers = new HashSet<>();
// Call this via your implementation classes, like in one of your events or your plugin class.
public void update(SomeEvent event) {
handlers.forEach(handler -> handler.update(event));
}
public boolean addHandler(BreedHandler handler) {
return handlers.add(handler);
}
public Set<BreedHandler> getHandlers() {
return handlers;
}
}
// BreedApi can then either be a Singleton or field on another publicly accessible class.
// A user would implement the interface, and then add it to the API via addHandler.
art thou pronouncing it Pythohn or Pythin
Hehe
Observer :0
basically what I did but removed static from the method
addHandler:3
i dont know why you gave me such a bad time over a change that I rushed
addBomp:3
Very pointless helper method haha
whut
object.get().add() is a bad design pattern
What?
and may be confusing with immutability
Having single line helper methods that really do nothing is a bad design pattern
When you already have a getter for the map
its a set, and i agree to some poimt
getHandlers
used for iteration
Cause then I guarantee your project is full of useless helper methods
Bomp might be nice in case you derive from it and want to extend its behavior
^
It's generally conventional in Java too.
depending on obtaining an object and adding to it is also insecure
I don't personally like methods like that but yeah.
and sometimes should be avoided
True, if handlers is ever changed, then it can break things when updates happen.
But man I wasn't trying to give you a hard time, just pointing out a flaw since the full example wasn't posted :/
is that an apology
No.
😩
It's just me stating something.
To sum up adders, getters, and setters:
"Not a fan of it, but it's better to have them than to not."
Bonzi loves helper methods for noobs
its not for noobs
its genuinely a better design in most cases
First off that add method is not a setter
It's an adder.
But anyways, setters shouldn’t really be a thing if you care about immutability. There are small cases of course. Getters are fine. And what makes it better design sorry?
But seriously, what happens if the name of handlers is changed in a future update, you don't have any methods for accessing it, and someone uses a later version of the plugin with another plugin that uses handlers but from an older version of the other plugin?
I would say it’s a command method if we’re still on the topic of terminology
fair
These things exist to avoid binary compatibilities because there is no other way to access a field safely.
Btw ever heard of the query and command separation principle
I haven't.
Yeah well hmm it’s not crucial, Java breaks it already but it’s something notable to say the least ¯_(ツ)_/¯
Unless you work with Kotlin, in which case you make handlers delegate to a new property with a different name and then also deprecate handlers.
And by "delegate," I mean get() = newHandlers, not by.
in which case, the compiled code would actually be something like BreedApi.getHandlers().add, which is gross, but not visible to API users, as it looks like BreedApi.handlers.add
Yeah there’s probably not any better suitable term for it
Kotlin's @Deprecated is so nice btw 🥺
You can legit specify the reason why something was deprecated
And IntelliJ displays it
You can also specify whether or not using the deprecated value is a warning or error.
..
Javas @Deprecated is just well
Wellll
🥴
I believe the only thing @Deprecated does is add an attribute to the element (I might be mistaken) and also display compiler warnings, it also has a bit of light support in all IDEs.
Oh, interesting, @Deprecated has runtime retention
You can reflect @Deprecated :)
I know one thing for sure, Bukkit has a lot of them

Well it also has to be Minecraft's fault, right?
Ritee
to an extent yes
Minecraft code barely changes…?
1.13 was the perfect time to drop anything below 1.13
but ofc, that didn't happen
It has changed over the years quite significantly
NMS its self changes a lot every update as well
Did you know:
Enchantments in old versions of Minecraft were very fucking cursed?
I was in a dev group that was working on a mod loader for an older version of the game, like 1.4 or something.
Not surprising lol
I was doing jar mapping, so I got to see Minecraft's enchantment code.
Gimme a sec I'll fetch it again
most of minecraft is :/
I'm having difficulties with item lore currently, I can't get lore to update after the item is in the players inventory, works fine before.
I'm working with custom enchants and the information looks fine in the output but it refuses to update the lore
I would send pictures but I dont have perms
// Writes the enchantments to the items' lore.
public static void updateItemStackLore(ItemStack itemStack, ArrayList<CustomEnchantment> customEnchantments) {
if (itemStack == null || itemStack.getItemMeta() == null || customEnchantments == null) return;
ItemMeta itemMeta = itemStack.getItemMeta();
ArrayList<String> itemLore = new ArrayList<>();
// We need to remake it now.
for (CustomEnchantment customEnchantment : customEnchantments) {
itemLore.add(getEnchantmentsItemLore(customEnchantment));
}
itemMeta.setLore(itemLore);
itemStack.setItemMeta(itemMeta);
System.out.println("The new item lore should be: " + itemLore);
System.out.println("Should be new item meta: " + itemStack.getItemMeta());
}
This is my code
And the item lore and item meta are correct
Its just not updating the item
Minecraft used to have some cursed internal item names too
Diamonds used to be emerald internally
Block was Tile
internally
that is
(at least, iirc, that might just be MCP trivia)
return the item
its not memorized or whatever
it has no internal access, its just an object
Huh?
change the return type to ItemStack and return itemStack
thats my name
That didn't work
But changing my game mode from creative to survival did
Creative is janky
Apparently creative mode is prone to replication issues like that
Yes
send your code, it shouldnt make a difference. the inventory must be updating everytime you open it
What part of my code?
where you create the inventory. or is that what youre doing?
You probably need to setItem for creative mode
Because it doesn’t bother syncing with the server
Really? 🤔
setItem?
Not the same as it does in survival
Can't you check if a plugin is loaded by the server?
well, you could make a util method for checking
Utils.isLibraryPresent() or smthn
you could just store the plugin as a LibraryPlugin after checking it
so
if (Utils.isLibraryPresent()) {
LibraryPlugin plugin = ...
}
Put your library access in a utility class. So any access to it auto checks the presence
Nope, can;t see a thing
excellent
Basically, here's my code. The intention is that when a chunk generates, kill all the villagers already inside. This is a small part within a larger plugin, but for some reason, e.getChunk().getEntities() is empty, despite there being entities in newly generated chunks
Not all entities are loaded when the Chunk is. You will have to delay your removal. But its also probably better to use .remove() over setHealth.
Do you have any ideas on how I can accomplish this other than use ChunkLoadEvent, because I want players to be able to get villagers, just not find them naturally.
And ChunkLoadEvent would remove them whenever a player joined, or otherwise reloaded their base chunks
You would have to tag any villagers you spawned in yoruself so they are not deleted. PDC.
Those entities still exist though, even if they're not loaded...right? So is there any way to load them in to check?
ChunkLoadEvent has an isNewChunk method
You wait, until they are loaed
to the rescue?
Can I track their SpawnReason and if they weren't spawned by either a command or a spawnegg, remove them?
or would that not work because villagers in chunks when they are generated technically aren't spawned
I did
My new code is on my server and not working
because I'm figuring that chunks load at a different time than when entities load
So long as you only remove if new then you won't delete any of your own.
how much should I delay and, and frankly, how do I delay it
Also you don’t need that cast
?scheduling
e will not exist.
Anyone know of a runtime dependency management library that is reliable with relocation features and supports Java 9+?
create a final variable to hold a reference to the chunk
hover over your error
don't think its an error
try it and see
just means its a final variable, no error here
what is protocolib used to?
live debugging with intelij and gradle?
hi, i'm having a yml file that store like
WhiteWorld:
"example"
so when i write
getConfig().getString("WhiteWorld");
it will get the WhiteWorld or the example ?
like WhiteWorld: "example" ?
when I edit the code on intelij, it doesnt sync over
probs theres some sort of issue with gradle then
imma try figure out whats going on
yep
and it get the "example" ?
Unable to open debugger port (localhost:5005): java.net.ConnectException "Connection refused: connect" I think thats the issue
can you try it and stop questioning
ok ty
try and see what happens
it's probably related to slot ID?
Have you tried comparing the clicked inventory to the top inventory
compare getSlot to getRawSlot. If they are equal its the top inventory. Or the player has no inventory open.
Probably also works
thank you, and yes i saw this
@jade perch is hdl still maintained :c_:
Not really anything that needs to be changed about it
but what the fuck is this
I have no idea what half of it is...
im looking stuff up
but still
what the fuck
You should see my updated example
@somber hull #help-development message
And removing Lombok
It's just a generic term
It's used to describe something that interacts with something else
So yeah, very generic
Got it
thank you
cause i looked it up
and there was a java api thing, that didnt make sense for how it was being used
An example of how people would use it:
// An implementation of BreedHandler in another plugin that uses your API.
class MyBreedHandler implements BreedHandler {
void update(SomeEvent event) {
// Print a value of the event to the log, this is just for example purposes.
System.out.println(event.value);
}
}
// ... On Plugin Load ...
YourPlugin
.getBreedApi() // This is just an example, you can put an instance of BreedApi wherever you want.
.addHandler(new MyBreedHandler());
// Or, if you want to use BreedApi as a Singleton:
BreedApi.INSTANCE.addHandler(new MyBreedHandler());
Wellllll, not really much.
You want to call BreedApi.update when you have an instance of SomeEvent
Like in an event handler
Wait... So why was this recomended to me
I dont see how it would be useful at all...
I mean the example doesn't do anything
But the main purpose is that it lets people extend your plugin with new features via their plugins.
Or, alternatively, just get values from your plugin.
Which is why it's an API.
Ohhhh
You can also use it yourself, if the API is designed well enough, then maybe it'll even make things easier for you, lol.
Ok, so basically it has nothing to do with what im trying to do? The guy that said it origionally just kinda said some random thing?
I still want to understand it so if it would be useful later i know about it
He was suggesting you make an API for your plugin so that other people can extend it.
Since you asked "is there anything I can improve?"
Ok
So, technically, he was suggesting a thing you could improve.
Ig lol
Ok wait
so
would i create a new .java file for the interface part?
I still dont fully understand how that works
Yes
I don't think you can put multiple classes in a file, I just did so to reduce redundancy.
Got it
i swear i saw smthng like that, it just cant be public or smthng
So would this whole thing allow people to make plugins for the plugin? Kinda like Slimefun addons? Or would they have to edit the source code?
Yeah, it would allow people to make plugins for the plugin.
Which is mainly recommended for public plugins.
ok
and possibly last thing
handlers.forEach(handler -> handler.update(event));
what is going on here
forEach thing in handlers idk whats after this
i get that its a consumer
But i dont get what a consumer is
nvm i found a indian guy on youtube to explain it
yeah, sorry about that
it's called a lambda
in this situation, it's equivalent to
for (BreedHandler handler : handlers) {
handler.update(event);
}
basically
so it just creates a loop of itself?
forEach is a method for lists
public void update(EntityBreedEvent event) {
handlers.forEach(handler -> handler.update(event));
}
does this not create a loop of itself?
yeah, pretty much
oh ok
-> creates a new lambda, an empty lambda looks like () -> {}
lambdas can also be single statements, so brackets {} aren't required
() just means "no value," basically
got it
handler is a single value, but for more than one I believe it's (value1, value2) ->
yeah
a lambda is basically a way of passing a function as a parameter
Ok
forEach looks like
And consumer just means lambda?
a consumer is a function that takes in a value but returns nothing
so it's equivalent to void function(thing)
ok
i understand now
alright
last thing, cause i gtg take the trash out
if i wanted to make this "api" public
would i just share the interface, and the api class?
no, someone would have to import your plugin through Maven or Gradle
you don't have to worry about that though
Here's what forEach looks like btw:
public void forEach(Consumer<BreedHandler> consumer) {
for (BreedHandler handler : elements) { // I don't remember the actual name for 'elements'
consumer.accept(handler);
// accept -> call the function and give it handler, the 'handler' in this for loop is where the handler in the lambda comes from
}
}
Java instantly recognizes Consumer as an interface that can take a lambda btw
the others would be:
Producer<T> -> takes in no value, returns a value of type T (T function())
Function<T, R> -> takes in a value of type T, returns a value of type R (R function(T))
alright
there's also
BiConsumer and BiFunction
which take in two values instead of one, like BiFunction<T, U, R>, which is R function(T, U)
ok, thank you so much. Ill be back in a few minutes
and that is Java functional programming in a nutshell :)
now I'll tell you some more stuff while you're gone:
You can make your own versions of Consumer and etc. since they're just interfaces
// This is a function that takes in 3 values and returns nothing
// This annotation isn't absolutely required iirc, but it's helpful since it tells you if the interface doesn't meet requirements from the compiler
@FunctionalInterface
public interface TriConsumer<T, U, V> { // I hope you know what type parameters are
void accept(T first, U second, V third);
}
// e.g. TriConsumer<String, String, Integer> =
// Function equivalent: void function(String s1, String s2, int i)
// Lambda equivalent: (s1, s2, i) -> { }
you don't need type parameters either
@FunctionalInterface
public interface CoolFunction {
String doThing(String s);
}
i thought it was object orioented 😳
That is equivalent to String function(String)
One note here: In java its not Producer<T> but Supplier<T>
Oh, sorry, you're right
Alright so
never heasrd of em
You know List?
well, List is declared like List<T>
T is a type parameter
when you create a new List
you can specify what T is
so
// Side-note: There are no restrictions to the names of type parameters.
public class WithTypeParameter<T> {
public T giveMeAValue() {
// irrelevant
}
}
and so
you create a new WithTypeParameter like
WithTypeParameter<String> wtp = new WithTypeParameter<>();
and so now the class knows that T is a String when you reference wtp
so if you call giveMeAValue on wtp, it returns a String
the classname is just that right? theres nothing fancy going on there?
Oh
nvm



