#help-development
1 messages · Page 2169 of 1
public class Command implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {}
error: Not annotated parameter overrides @NotNull parameter
put notnulls in front of the parameters
and its just a warning not an error
you can ignore it if you want
that's a warning
you can ignore it
You can ignore it
if i running server
[06:17:07 ERROR]: Error occurred while enabling XCrasher v1.0-SNAPSHOT (Is it up to date?)
java.lang.NullPointerException: null
at java.util.Objects.requireNonNull(Objects.java:208) ~[?:?]
at me.blacksnowdot.xcrasher.XCrasher.onEnable(XCrasher.java:13) ~[xCrasher-1.0-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[pufferfish-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[pufferfish-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:541) ~[pufferfish-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugin(CraftServer.java:560) ~[pufferfish-1.18.2.jar:git-Pufferfish-68]
at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugins(CraftServer.java:474) ~[pufferfish-1.18.2.jar:git-Pufferfish-68]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:666) ~[pufferfish-1.18.2.jar:git-Pufferfish-68]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:433) ~[pufferfish-1.18.2.jar:git-Pufferfish-68]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:318) ~[pufferfish-1.18.2.jar:git-Pufferfish-68]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1165) ~[pufferfish-1.18.2.jar:git-Pufferfish-68]
at net.minecraft.server.MinecraftServer.lambda$spin$1(MinecraftServer.java:317) ~[pufferfish-1.18.2.jar:git-Pufferfish-68]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
show me this error
thats for another reason...
whats line 13 of the Crasher class
that im guessing is your main class
Objects.requireNonNull(getCommand("xcrash")).setExecutor(new Command());
^
^
ha ninjad you
um ok
because if you actually register the command that will be useless
or put a @SupressWarnings("ConstantConditions")
It just means that you get this error:#help-development message
If you encounter nuulPointerExeption
getCommand("crash").setExecutor(new Command());
its ok?
Yes
kk
compatibility
With?
But you register it by doing JavaPlugin#getCommand
So it'll still be /pluginname:command
so the server will register them instead of you having to extends Command for all your command classes and forget to put things
This can't be it
indeed i coded a commandapi that fits my needs
tnx fixed
Because so many people forget to out it in the plugin.yml
petition for a ?objectsrequirenonnull command that links to oracle docs
half the people here use it wrong
well there are command frameworks that do the stuff for you lol
they just use it because intellij suggests to
It'll be so much easier to extend command and have a constructor that requires the command
and when you don't know java
yea
no more questioning about why to register the commands
you do everything the ide tells you
I know, but I'm just saying, bukkits solution isn't very ideal
if you want to you can code a commandapi yourself so you don't have to use the yml file
java.lang.NullpointerException: give me a cold beer
it's not that hard to make a basic one
I did and then realized that someone probably already did something better than me so i found lamp and now i use that
i've had exceptions in my ide lol
lol
some plugin afaik
it just reads what the vm says and forwards it to you
i wanted to use one i found online too but i ended up making one for fun and also because if i code it, i can make it exactly how i want it
it took more than a week but it works very well
I was thinking the same but then if i find a bug while working on a project I'll have to go fix that
?
fun fact, that happened to me the other day but i also took the time to improve it
because there was some if else garbage from 6 months ago i wanted to change
a small pyramid of doom
Hello, i search an plug-in for restart my Minecraft server when his RAM is 80% of her utilisation, if you know an plug-in to do that please contact me. (mention or private message)
btw the idea is totally stupid
Ok sorry
restaring your server every day sounds better
public class ArmourUtil {
public static boolean isLeather(ItemStack piece) {
return piece.getType().name().contains("leather");
}
}
is this fine?
I think that may return true for leather itself
just do name().endsWith("_LEATHER")
also I'd use a Set<Material> for this
erm
I meant startsWith
yes
mb
is startswith case sensitive?
yes
gotcha
i literally sent you code
I'd do it like this
private static final Set<Material> LEATHER_ARMOR = new HashSet<>();
static {
for (Material value : Material.values()) {
if(value.name().startsWith("LEATHER_")) LEATHER_ARMOR.add(value);
}
}
public static boolean isLeather(Material material) {
return LEATHER_ARMOR.contains(material);
}
.
what does assert do?
it throws an AssertionException when the expression isn't true
String myString = "asd";
assert myString.equals("asd") : "This should have never happened!";
yesterday someone told that it doesnt do anything
bullshit
i think thats because an ide often claims you need to assert to avoid null pointer exception when it doesn't prevent it people assumes it does nothing
assert is for debug. Normally does nothing at runtime
ah
yes, -ea but IIRC spigot always has this enabled
but yeah it's mainly used in unit tests etc
in normal plugin code or whatever you would probably never use it
I've read an article that 'assert' actually has runtime costs even when disabled. Not sure if its still the case but i
dont use it either way.
I don't either
Ye used to be the case
fun createWorld(world: World?): String {
val worldDir: File = world.worldFolder
var worldName = "mbwr_" + Math.random() * 1000
while (true) {
Thread.sleep(500)
if(Bukkit.getWorld(worldName) != null) {
break;
} else {
worldName = "mbwr_" + Math.random() * 1000
}
}
FileUtil.copy(worldDir, File(worldDir.parent, worldName))
val creator: WorldCreator = WorldCreator(worldName)
val newWorld: World? = Bukkit.createWorld(creator)
return worldName;
}
Getting error:
Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type World?
see line 2 on world.worldFolder
do i have to fork bungeecord to change the internal messages / languge file
createWorld takes World?
world might be null. Thats why you have to assert that its not (!!) or only safely call methods using ?.
Perhaps File? is also an alternative here
Assuming you wanna keep chaining the possibility of absence
"on a nullable receiver of type World?"
You can edit the messages.yaml if you open the jar in winrar for example
My suggestion would be to not pass World? but World to this function.
it isnt because File is always non nullable
would i then have to compile again
Yes but since the world parameter itself might point to null
Nope, just replace the file
You could address it by either asserting, or mapping the null type or flat mapping it
the thing is Bukkit.getWorld() has the World? type so when i pass a world parameter into my function it needs to be World?
Also this fun is a bit weird because why would you create a world and pass an already created world to it??
Then dont call the method if getWorld() returns nothing
Perhaps assert that the world is already non null before passing it into that function kostiskat?
alright wait
How can I use system.getenv in gradle? I mean from where it gets the info
I would rather do something like
Bukkit.getWorld()?.let{ createWorld(it) }
and define createWorld as
fun createWorld(world: World): String {
from the environment
kotlin looks cursed tbh
How dare you
👉👈😭

yeah it does
but at least every method in kotlin is fun
such a funny language
ok, so how can I add my own variables?
Lol
i've never seen something like ?.let{ createWorld() } in my whole life
Optional::ifPresent tho
like this?
createWorld(Bukkit.getWorld("mbw_prototype")?.let{createWorld(it)})
It does sure
It gets really cursed if you add stuff like infix functions.
init {
super.effects.add(FlameDamageEffect())
super.effects.add(IgniteEffect() onlyWhen { ChanceRoll of 0.2 isSuccessful })
}
But that’s the kotlin equivalent
nevermind im stupid
oh no no
Altho kotlin nonnull types can be expressed in terms of nullable types so that’s nice
?. in java would be a good thing i guess
We have ?. in Java
Using Optional tho
It’s basically Optional::map or flatMap or ifPresent
There is a coding style where you only use Optionals inside your service.
And you never unwrap anything. When you get external values you wrap them
and if you send them then you unwrap then again. Internally everything is optional.
is it possible using attribute modifers to increase the max health of the player while an armour piece is worn
Yes. Just add the mod to the ItemStack and apply it for a certain slot.
it's optional to do it like this though
In kotlin they basically embedded that style into the language
scnr
in rust its just
let optional: Option<u32> = Some(6);
match optional {
Some(x) => prinln!("it is present")
None => println!("nawww")
}``` which makes it more fun in my eyes
Ye
🌚
Use a non-ancient version of which the support wasnt dropped half a decade ago.
or just doing
if let Some(x) = optional {
println!("we got em")
}```
long time since i used it lol
it works on other plugins
its not cuz it works that you should use it
You need to add the nms dependencies on your compiletime classpath.
like?
Which dependency manager do you use?
maven
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.io/repository/maven-releases/</url>
</repository>
<repository>
<id>nms-repo</id>
<url>https://repo.codemc.io/repository/nms/</url>
</repository>
do u mean this?
lol an illegal NMS repo
wrong quote
I always quote the wrong messsages
no idea why
Then
- Run BuildTools
- Add the spigot dependecy but instead of
spigot-apiyou usespigot(artifactId)
@quaint mantle
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
ah
sush
i
if only void in java worked like Unit in kotlin
I mean they’re pretty much equivalent
only if java was nullsafe
Lol yeah
@NonNull is basically the same but it automatically adds Validate.notNull or something similar
ooh does it
Yeah if you tell IntelliJ to
but yeah I get it, you all hate the red pepperoni
Or if you use Lombok
yeah lombok

return player.sendMessage(“Invalid arguments”) 🥵
i'd love that
returning a void?
lmao?
I mean returnable void doesn’t really work in Java sadly idk maybe it works in kotlin with inline functions?
i always wondered why you simply couldnt return a void
not actually returning it but you know what i mean
you can return Void if you want to
You can with return;
thats just return null lol
return; in a void method returns void
you can do it in kotlin because both of them return unit
and unit is just a singleton object
But it’s really useless tho
is there a better way to do this
if (meta.getLore() != null) {
ArrayList<String> lore = (ArrayList<String>) meta.getLore();
} else {
ArrayList<String> lore = new ArrayList<String>();
}
i find it useful for just removing curly braces on if statements
ye guess its preference
List<String> lore = meta.hasLore() ? meta.getLore() : new ArrayList<>();
hm I don't because sometimes you wanna add something later and then you have to add the brackets anyway. or you forget it and now have a weird logic error that doesn't throw any compile errors
i dont like how it looks
the only thing where I don't use brackets is for stuff like
if(event.getClickedBlock() == null) return;
there was a time i coded like
if ... then....
else ...
can the color tag of leather armour be removed or is it client side
A bit contradictory to your first argument but sure
yeah but in that case it's almost certain that I will never need more logic than just "return" in that part
Yep, tho I always add curly brackets to solidify the scopes
add a flag to the meta
I even add brackets to safeguard statements.
In kt not anymore because this line would be
val block = event.clickedBlock ?: return
But in java i do
hi conclure
Sup
new void🤣
wdym
hm yeah I only do that when I add overly verbose debug stuff lol
if (event.getClickedInventory() == null) {
main.debug("Return: getClicked Inv is null");
return;
}
if (!(event.getClickedInventory().getHolder() instanceof GUIHolder)) {
main.debug("Return: clicked inventory is no GUIHolder");
return;
}
final GUIHolder guiHolder = (GUIHolder) event.getClickedInventory().getHolder();
if (guiHolder.getContext() != GUIContext.PREVIEW_MENU) {
main.debug("Return: GUICOntext is not PREVIEW");
return;
}
Sure but thats an inconsistency. Having brackets form the beginning also better supports the open/closed principle.
Code "should be open for extension, but closed for modification"
ayy i've never thought about doing stuff with the holder itself
one also shouldnt do that
i normally put all my code in my gui class
normally you shouldnt implement inventoryholder
but I didn't know that 4 years ago lol
my invholder simply saves some information about the context of the gui that was open so I can check it in the inventoryclickevent
alex is here
yeah but as said one shouldn't implement inventoryholder :/
alex is like a german handyman
so meanwhile I just add my context as PDC to the clicked item when I create the GUI
then I can just do something like
- get the clicked item's PDC
- does it have a PDC tag of DataType GUIContext?
- If yes, I know what to do next lol
mine is similar to that
if no, it's just a placeholder item or similar
I wish I could find a way to store runnables inside a PDC lol
yes and then compile it lol
but tbh one could just create a Map<Long,Runnable> and save the ID on the PDC
i wish i could write pdc data to inventory interfaces xD
btw I need some opinions on what to improve / add / change on my Cooldown API: https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/de/jeff_media/jefflib/cooldown/Cooldown.java
at least that would make them persistent beyond reloads
unlike putting them in wrappers
it's always annoying to have to write cooldown logic everytime so I just put into a library class
cooldowns of items?
of whatever
multithreads?
items, commands, ...
well i manage item cooldowns
by putting the material on cooldown
xD
its client sided mainly
but eh
how can i get a players permission
could also be used for events e.g.
private Cooldown attackCooldown = new Cooldown();
and then in EntityDamageByEntityEvent, if the attacker is in cooldown, cancel the event
so yeah it can be used for everything
it accepts "object" as "cooldown subject"
For this I'd actually reccomend the Luck Perms API obviously not required but the other way is harder
i mean cooldowns are basically just delta times
🤔
mine was a little simpler
i only know that you can check with Player#hasPermission()
thats just incorrect
Bukkit has the builtin method for checking perms
heard about that
Adding a full lib for it is the more difficult one
actually it's part of Permissible, not Player
yeah and not everyone uses LP
i Mean if your going to be dealing with adding removing and getting permission lists its gonna be easier to use luck perms
many big servers still use PermissionsEx or similar
luckperms api is still a pain too
nah
Are bukkit perms a bit of pain? yeah; but id rather deal with that than add a stupid requirement like luckperms to my resource
^
why are most of your streams on twitch only like half a minute lol
If you are doing nothing but checking permissions, just use the Permissible methods
everyone's going to watch them if you say "no"
was test streams :c
anyways is there a better way for this?
https://github.com/FourteenBrush/MagmaBuildNetworkReloaded/blob/master/src/main/java/me/fourteendoggo/MagmaBuildNetworkReloaded/user/UserSnapshot.java
- deete streams *...
?
oh
That its the cooldown once I sent you If I not wrong
@tardy delta
?paste
Id have the snapshots immutable
could possibly add a way to get a string of the time left nicely formatted 😄
anyone familiar with this error when trying to join my server I just added a resource pack requirement to one of my plugins I'm working on
https://paste.md-5.net/itefutugoy.md
This is a client sided error btw
but idk if its an enhancement considering the cons ntl
yeah that's a good idea
right now it returns a long that's based off the precision used
i have my snapshot wrapped in a atomicreference in the user class so isnt that also good?
e.g. if you set the cooldown to use nanoseconds, it returns the remaining nanoseconds
hmm
I can write you a full code review later
yh
if you really want to lol
its my old plugin but i was thinking how to do it better
for (EntityType entityType : EntityType.values()) {
if (entityType.getEntityClass().isAssignableFrom(Monster.class)) {
why does getEntityClass method return null in here
oh right
because UNKNOWN is also an EntityType
and that has null as class
just do if(type == EntityType.UNKNOWN) continue;
all other EntityTypes have a class assigned
actually @tender shard how would you format time left into a nice string? i have done it and was wondering if there is a better way actually
let me check, I have some code for this in some comission I did
https://paste.md-5.net/xusajahopo.java
this is how i do it
i used to make such a method
chilll
sucks
hm I checked the wrong plugin. In this I only have this
public String getTimeLeftFromMinutes(double minutes) {
return getTimeLeftFromSeconds((int) (minutes * 60));
}
public String getTimeLeftFromSeconds(int seconds) {
return String.format("%02d:%02d:%02d", seconds / 3600, (seconds % 3600) / 60, (seconds % 60));
}
Let me look for the other plugin that does it properly (it says stuff like 2 hours 3 minutes, then when it's less than an hour, it says 50 minutes 23 seconds, etc
if only I could remember the plugin name
yh thats what mine currently does too
lemme save that lol
?paste
not very nice
but also not completely shit
yeah mine sucks. I had to rush this plugin because I announced "we'll do an event this weekend" and I didn't even start the event plugin then lol
ahh yea thats fair
it was an "advancement speedrun" plugin where people could win prizes like plugins and other stuff by basically being the first one to win certain advancements from some datapack
u mean mine?
ah was about to say i could also send you a method to parse the output of formatTimeShort() if you wanted.
well it just shows
00:00:17 for e.g. 17 seconds
more like a timer how a microwave would show it lol
ah..
or 01:12:17 for one hour, 12 minutes, 17 seconds so yeah perfect for a microwave but not so much if it should look fancy lol
this was mine
yh and mine would output "1 hour 12 minutes 17 seconds" for that
1 hours still
there should be a lib for this
e.g. with an option to show only "1 hour 12 minutes" and only show the seconds when it's less than one hour
bruh im so stupid
how come
i was wondering why my database file wasnt generated but i forgot the datafolder didnt exist
i was creating it afterwards

yeah it calls saveResource
😂
i just moved it a little higher
its still not generated aaaaaaaaaa
my file explorer seems to be broken
is it better? 🙂
It doesn't say 1 hours
It'll say 1 hour
stuff is kinda broken
What is?
yh mine does too
Fourteenbrush why dont u cache online player data
Maybe u do and just return it as a future
Can't tell from your ocde tbh
fun createWorld(world: World): String {
val worldDir: File = world.worldFolder
var worldName = "mbwr_" + Math.random() * 1000
while (true) {
Thread.sleep(500)
if(Bukkit.getWorld(worldName) != null) {
break;
} else {
worldName = "mbwr_" + Math.random() * 1000
}
}
send(worldName)
Thread.sleep(5000)
FileUtil.copy(worldDir, File(worldDir.parent, worldName))
val creator: WorldCreator = WorldCreator(worldName)
val newWorld: World? = Bukkit.createWorld(creator)
return worldName;
}
is this how you properly make a world copying function?
isnt there already a copy world method in bukkit
there is?
hmm my database seems to return nothing even when i just inserted it
nah nvm u can copy worldcreator not the world itself
why are you blocking the thread?
hm?
Fourteen what its your whenComplete method?
when i do this it does not add the defaults to the config file
executes something when the future has completed its work
i only seem to get 'Got home: null' lol
meaning there was no exception
dont think thats theres anything wrong with this
Oh so its basically a future task
ye
I want to do something like that for redis
Because its really annoying sending and receiving string with redis
Class<?> Vec3D = Class.forName("net.minecraft.server." + serverVersion + ".Vec3D");
[09:01:07 WARN]: java.lang.ClassNotFoundException: net.minecraft.server.v1_18_R2.Vec3D
Why using relefction for that ?
Oh you are using it for multi mc versión right
onstructor<?> vec3DConstructor = Vec3D.getConstructor(double.class, double.class, double.class);
Object vec3d = vec3DConstructor.newInstance(
d(), d(), d());
// PacketPlayOutExplosion with fat arguments
Class<?> PacketPlayOutExplosion = Class.forName("net.minecraft.server." + serverVersion + ".PacketPlayOutExplosion");
Constructor<?> playOutConstructor = PacketPlayOutExplosion.getConstructor(
double.class, double.class, double.class, float.class, List.class, Vec3D);
Object explosionPacket = playOutConstructor.newInstance(
d(), d(), d(), f(), Collections.emptyList(), vec3d);
sendPacket(victim, explosionPacket);
v1_18_R2 is not stable?
Why are you using reflection?
1.17+ doesn't have the NMS version in the package name
I want to modify EntityZombieHusk but It seems like to modify, I have to touch minecraft-server.jar not spigot bukkit(Spigot don't have EntityZombieHusk class).
But I have no idea what minecraft-server.jar is.
How can I modify minecraft-server and build?
it's called net.minecraft.core.BlockPos
oh
I dont know why the heck spigot doesnt use and standard for everything, java versión, package id, etc
Everything?
You want Spigot to reverse the choice Mojang made to update Java?
Or just update dead versions?
how do you check if an entity right click event didn't also open an inventory
i mean
playerinteractevent
if a playerinteractevent didn't open an inventory like chest or furnace
You can't, really, unless you check if the block clicked is an inventory holder. Though that's only a rough estimate
if (block.getState() instanceof InventoryHolder) { }
how is that rough that sounds precise
yeah for example a villager can only have one viewer IIRC
if i check im not shift clicking
There may be situations where right clicking a block doesn't open an inventory
uhh
so it could be a right-click villager event but another player also has that inv open so nothing would happen
Then yeah, villagers as well
i can't think of one
or a chest could be obstructed
Cat
I always forget cats obstruct chests lol
Any of you know a plugin that use redis but with a Packet system for sending and receiving? I have chexked tousans open source plugin with redis and didnt find anything
You could just take a look at a redis tutorial
It doesn't have to be a Spigot plugin
I made one a short while ago but it's all proprietary for the company I was working for 😅
It's not overly complicated though. So long as your Redis pub/sub messages are prefixed with an integer id, you can map to your packet classes that are registered somewhere (in a Map or whatever)
Mine does (3
Map<Integer, Supplier<? extends YourPacketInterface>> and a Map<Class<? extends YourPacketInterface, Integer> and you're set
Conclure do you have a tuto or its open source?
Or make that Supplier a Function<InputBufferThingWhereYouReadData, YourPacketInterface> if you'd rather that
Yeah I thought and how i Map the data from packet?
Thst what I dont know
https://github.com/Conclure/Eventful main runner got some examples
The first thing you write to the message would be the numerical id of the packet
im doing event.setCancelled(true) on a PlayerInteractEvent where they throw a snowball, but it's not cancelling the snowball throw
(In common module)
fun createWorld(): String {
val worldname = "testworld"
val worldcreator: WorldCreator = WorldCreator(worldname)
val world: World? = worldcreator.createWorld()!!
world?.worldBorder?.setCenter(0.0,0.0)
world?.worldBorder?.size = 100.0
return worldname;
}
this isnt creating a world, any ideas?
Then any data that follows it would be the data in the packet
Chocó
Chocö
mine too, i'm german
hello
i cant add dependencies can anybody help me?
im sorry i really had to
How are you adding dependencies
normalls
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.4</version>
<scope>provided</scope>
</dependency>
So maven
yes
And what's the problem
did you reload your project?
reload disk?
i want to make any negative effects not work on my player can this be done in a single event (potion splashes, tipped arrows)
he explained it in detail though, can't you read? smh
cant add dependencies
lol
im doing event.setCancelled(true) on a PlayerInteractEvent where they throw a snowball, but it's not cancelling the snowball throw
try projectile launch event @lethal python
if you make changes to your pom theres some icon that you have to click for them to take effect
ok i will thank you
if i use this cb ```java
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String commandLabel, String[] args)
{
if (sender instanceof Player)
{
switch (cmd.getName().toLowerCase())
{
case "debugmenu":
return DebugMenuCommand.tabComplete(sender, args);
case "updateitem":
return UpdateItemCommand.tabComplete(sender, args);
}
}
return Collections.emptyList();
}
no i cant get the specified path for dependency
interface*
declaration: package: org.bukkit.event.entity, class: EntityPotionEffectEvent
oh thats looks pain
ty
guys what items display a "use" animation when you right click them on anything
i only do that for vanilla commands i override
snowballs do because you're throwing them
and fire charges and flint and steel but they set fire
that java syntax?
What are you trying to do?
ye java 16
whats those -> doing xD
just the same as switch cases
im trying to make it so when you right click this specific item it plays the use animation like you're punching with the item
i love the new syntax
You can send a packet for that
i only know them from c++ where they represent accessing a pointers object instance member
ye
It’s a switch expression
or just use player#swingMainHand
i don't know how to do that could you explain it
kk
Looks like lambdas but they aren’t
Ah it's api now. Great :)
you can use it for every LivingEntity but most probably won't show any animation
kk ty so just a different way to express switch syntax haha
Is there a posibility for queuing a packet?
Because my goal is to some packets be listened like an event. And other to be get on an command
thats where i know these arrows from xD
Yeah I use MessageCenter::send for that
//Export for Java as .dll && .so
extern "C"
{
JNIEXPORT jlong JNICALL Java_IniReader_initPtr(JNIEnv* env, jclass cls) { return reinterpret_cast<std::uintptr_t>(new IniReader()); }
JNIEXPORT void JNICALL Java_IniReader_deletePtr(JNIEnv* env, jclass cls, jlong ptr) { delete (IniReader*)ptr; }
JNIEXPORT jboolean JNICALL Java_IniReader_openFilePtr(JNIEnv* env, jclass cls, jlong ptr, jstring str) { return ((IniReader*)ptr)->openFile(env->GetStringUTFChars(str, 0)); }
}
so the new syntax being abit confusing
best tutorial ever
thats in german
Yes
waffel
Verano are you italian?
Im spanish
Specific from Uruguay
Verano are you italian?
teach us a word in spanish
ta madre
Hola, como estas?
Hi, how are you?
Mom = mamá
Father = papá
honestly i love how JRE's cpp wrapper for data types is literally the same as in java. just wrapping the primitive but if u dont use it everything crashes
So for doing a redis packet system I will need a unique id per packet
And them how do i set the data from the packet?
That burning my brains
sftp
I turn the string to a byte array
why the fuck this happens
we are learning languages on this server
And just make the first read/write to be the id
german, spanish, anything
So you are using BinaryJedisPubSub?
Nah Jedis sucks
@worn tundra https://www.spigotmc.org/threads/custom-gui-with-textures.509305/
could you help me ?
Or well correction, it isn’t really that scalable compared to lettuce
uh
Hence why I distance myself from it
What you use conclure?
so if i use this java @Override public List<String> onTabComplete(CommandSender sender, Command cmd, String commandLabel, String[] args) { //... } should i ```java
public class main extends JavaPlugin implements Listener, TabCompleter
{
public List<String> onTabComplete(CommandSender sender, Command cmd, String commandLabel, String[] args)
{
//...
}
}
Lettuce its a redis driver for Java right?
i think i accidentally deleted a jdk yesterday when freeing up space and now intellij keeps crashing whenever i launch
wat to do
reinstall the JDK?
install a JDK
do i have to go through all the oracle bs
Also how you can delete a jdk?
ok cool
breathe copium xD
Lettuce is a redis client written in Java
idk there was just a folder i saw and i didnt really think much of it lol
so i just deleted it
oops
Yeah as all we dont see what contains and delete it
Anyway verano these two snippets from my LettuceMessenger.java are probably what you need to look at
Conclure jedis sucks a lot
sudo apt install smh
my brother in christ im on windows idk
closest i got is scoop install -g openjdk-17
install apt on windows 😎

Who tag me?
I did.
is that ur bf?
@sterile token so using Lettuce its better than Jedis right?
her bio says girl tho
yesno
Verano is correct here
Lol why the heck its tagging me self
A ubiquitous answer
u know what really hurt me? i watched a video where the guy like said "introverts are the only ones who can comprise of the .3% of truely superior developers, and extroverts like steve jobs use them to get filthy rich"... kinda true though i guess
Conclure thanks I will read about lettuce
true people have made fortunes off of my code
i mean its not untrue
Myeah although with that being said, there’s no really hard barrier for being introvert and extrovert, those two terms are extremely simplistic for describing behavior of humankind
i mean why is my database not working aaaaaa
yea iknow but u get the idea
like
the ones who are truely upper standard dont really ever get to make the money for themselves
Conclure my idea for my redis packet api is:
-
Be able to register listeners for listening each packet
-
Each packet contains any java data type
What do you think?
Idk maybe in theory
it isn't false 😔 ive fixed lots of bugs n ported code for ppl n then they sell their software n i dont make a dime
nowadays all u need is unity a 30minutes seminar on coding and some base knowledge in this tree structure thing that ppl use who dont understand basic syntax xD
im like an unpaid intern
does anyone know what do to with this
Uh sure
intellij wont load any projects properly
probably need to uninstall/reinstall intellij
aaaa
probably wasnt a jdk issue at all then
i cant get netherite materials, its not showing up
just install the JDK 17 and ur happy
anyone?
btw why did the BuildTool force me to use JDK 17 ?
Paciencia
For redis my opinion is:
Redisson > Lettuce > Jedis
Why the heck do you want to listen for all packets and what does that have to do with redis?
bc minecraft uses newer java
i had to reinstall it because projects were just crashing whenever i opened it
You probably use an ancient version
i mean i honestly dont care to use the latest JDK, just sometimes oracles is charging money and sometimes they throw their copy after u
I want to do a library for cross-server communication with redis but better without sending annoying strings
no the newest and i added it as dependency
how can i check if the bukkitrunnable is already scheduled?
Then you have access to netherite materials
Also with packets I wasnt talking about mc packets
Yeah but the good version of redisson costs which is a bit of an issue
Especially if you just want to create let’s say an open source library
Lettuce its free?
Yes
Allright thanks
yes 🥗 is free
Not that I have done any benchmarks but from what I’ve heard both scale really good
But jedis sucks a lot from what you told me
Yes
The base Redisson version has practiacally everything besides some very specific featurs like local caches for certain data structures.
I always used jedis I wont use it any more
It wasn’t designed to be used concurrently
Apparently it’s slower also, at least that’s what they tell us
Conclure lettuce contains caching and pub sub
Yes
Sorry for being annoying I know I fuck a lot
You have an old spigot version on your classpath
Look here for instance smile https://redisson.pro/#compare-editions
Certain stuff you get access w/pro to seems to be way faster
fixed by invalidating caches :)
all thos bitches
?paste
It has master slave, pattern pub sub, sharding, pooling etc
https://paste.md-5.net/ekurejakic.xml this is my pom is not it right?
Yes they have remote cache commands where you send a minimal byte structure that executes a command that was called before remotely.
The default stuff is as fast as it gets when just sending redis commands like every other library.
Hmm alright
how can i check if a BukkitRunnable is scheduled? Im creating one by using new MyRunnableHere and i would like to cancel it, but when i do it without running .runTask it throws me an exception saying the runnable is not scheduled yet
BukkitRunnable#isCancelled
This sounds like an xy problem.
I would suggest that you let the runnable cancel itself.
>>> BukkitScheduler::isQueued <<<
that will throw the exception too
heh
You specify the java versions twice. Other than that it looks alright.
Did you add any other dependencies (like jars) outside of your pom.xml?
bruh i see what a bs
Again… x)
it is a BukkitRunnable where the task field is not initilized yet
so i cant getTaskId
Smells like a big design issue on your side.
Tell us what you are trying to do.
i have a game class
do u guys know how i can delete an entire folder instead of the files in it?
and there, i have some runnable fields like gameCountdownTask
when i initialize a new game object, the task is assigned to my other class
so
Sure. There are several util methods in guava or commons lang that recursively go through a directory in order to delete it.
You can also just do that yourself quite easily.
private final MyRunnable runnable = new MyRunnable();
and then, i have a shutdown method
that cancels the runnable
i would store a boolean hasStarted
Yeah as smile said, just go with a directory stream recursively and delete any files
ugh
what methods could i use? (kotlin)
nop
or let your game class extend bukkitrunable
Yes that would be my suggestion as well.
All those runnables can be just methods that get called by one runnable.
Idk if there are more convenient stuff in kotlin but in Java you’d use Files::newDirectoryStream and just Path/Paths (Files::deleteIfExists might also be a good one)
wrong quote hehe
I think kt has File#deleteRecursive() or something like that
@tardy delta what plugin destroys all entities/animals/mobs?
no because if i want to remove something i can simply delete the field and the lines who uses it
i tried doing that but its not showing up in the intellisense and its throwing an error
but i just remembered that i have a started boolean
KIt Sorting System
Conclure its amazing you can use object directly while jedis doesnt support it
RedisClient client = RedisClient.create("redis://localhost"); StatefulRedisConnection<String, JsonObject> connection = client.connect(); RedisStringCommands sync = connection.sync();
JonObject json = sync.get("key");
Really thanks conclure if you didnt told me about lettuce I would be still using shity jedis
cries in jedis usage
when i add those its adding 1.13 bukkit wtf
Is there any proper way to shift text up and down in an inventory title? I've been using negatively spaced texture pack, but none of the characters shift up and down only left and right.
@lost matrix my bad i had messed up some shit in pom while converting java to kotlin
the function shows up in intellisense now
[ERROR] .... [Essentials] There's a good chance you're reloading your server right now. If that's the case, why do you hate yourself? Expect no support from the EssentialsX team when using /reload.
"Why do you hate yourself?"
Lol
that was funny of them
maybe Vault is depending on it and so vault is adding it, but u do have spigot-api 1.18.2 there too so idk
what if we just PR removing /reload
use /stop instead
im not programmer enough to understand
or /restart but that has to be configured
we make a suggestion to spigot devs to delete /reload from spigot forever 🦀
instructions too difficult to understand. Ended up switching from paper to spigot
reload is fine for testing purposes
but why tho :o
instructions unclear, idk how it works
instructions unclear, self destructing
I fixed it but this still happens
Adelemphii wants pasta
i want food in general
i actually bought pasta just today
also bits of coconut
but they arent as juicy and delicious as i expected
i know this is gonna sound really stupid but what if u put spigot-api above vault in the dependency list
give me some juicy coconut
🥥
i wish i understood what this means
maybe maven is detecting bukkit 1.13 bc of vaults possible dependency on it and since its first it could be using that as the bukkit api instead of spigot-api idk
invalidate caches and restart
yes, same
did u hit the maven refresh button
ye hit it with da coconut
coconuts arent as delicious as i expected
they sound exotic and juicy and stuff
but they are plain
they are good
y
idk sometimes it fixes stuff for me
Albert Heijn has them like cubes too
lol
Just remove the old spigot version from your classpath. Shouldnt be too hard.
i tried
what is the date
🥴
its just a joke
@tardy delta i think im on the road to becoming a master minecraft coder

hey guys this isn't a technical question but i told my brother to think of a armour set so we can fight with custom armours but he ain't coming up with any armour abilites or anything so can you just give me some ideas this is the head it is called dark warden:
i cannot make interface objects
= new Tootoo
but i can make interface variables
Tootoo x;
just learned a bit more about instanceof
holy this worked 🥴
Lol
🥴 🥴
Yeah agree
hold on are you uhc player?
Happen something similar to me but when using custom vars on proyect
No, im just a bedwars player
I used to do 200 kills perday on a non premium server
0w0
Yeah i was really ill in that moment
But now i dont usually play mc because i code plugins
Its like when you code you dont play much
You have to make bedwars no play
A bedwars plugin?
yeaa
Good idea but arent already some on spigot?
Verano
yeah?
how many grams of pasta would be enough for a meal?
Because im not very hungry but i want to eat some food
cuz its the evening
i dont want to make too much pasta cuz i wont finish it
I dont really know but it depend if you are alone and how angry you are
i eat 240gram
in any case
that sounds a bit much doesnt it?
Yeah i usually eat around 200gram if im not really hungry
i think maybe i should prepare only 100 grams
Yeah and if you still hungry eat something extra
How much you eat?
LMFAO
for me its hard to eat a lot of food
i can eat only small amounts of food
I eat 1 burguer from burguer king and im literally full
its not because i want to eat small amounts of food but my body is weak and cannot handle big amounts
home made burgers are better 🙂
just get oats with yogurt
Agree but was an example
Yeah atm i dont eat one since 1 month or more
how would i go about making a weapon that bypasses 50% of the armour protection
custom weapon? Arent that client-side?
Ahh nothing i just catch it
I usually tag the PDC of an itemStack and then it has special properties which I can code into a listener
basically just a vanilla weapon with a new lore
Yeah i catch some seconds before
You can use PDC for that
So them you can set a custom property to that item
i just realized this is not the general channel
i was here talking with people about coconuts and pasta
Not sure this would work, but for the entitydamageevent, getDamage(DamageModifier.ARMOR), halve that, and then do setDamage(DamageModifier.ARMOR,value)
can I register commands / listeners AFTER the on_enable event?
yes
hey so i am making a command that saves a players current location to a config file under the key "spawn-location". However when I run the command it says that it has done it however nothing changes in the config. Here is the code for it, any ideas would be great!
public static Plugin main = ParkourTag.getPlugin(ParkourTag.class);
public static void SetPKTSpawn(Player p, String prefix) {
Location location = p.getLocation();
main.getConfig().set("spawn-location", location);
p.sendMessage(prefix + "Set game spawn to your location!");
}```
You need to save the config
this is in an external command file separate from the main class
main.saveConfig();?
Yeah
awesome i'll give it a go thank you :)
I need to run a task async, I thought about doing:
Bukkit.getScheduler().scheduleAsyncRepeatingTask(this, () -> {
}, 0, 20);
```However it's deprecated, I can safely use it no? (It's for I/O, no bukkit api's involved)
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
}, 0, 20);
```?
map doesnt contain itemstacks even i added them
or bukkit runnable
hello, im trying to make a commands strings the specified colors by their name but i dont know how to make it by short way
What do i have first do on the BlobkBreakEvent for a claim plugin?
Im really annoyed :(
agree
First you have to have a method to claim/unclaim areas and a way to check if a block is in an area
Yeah, cuboid
I have a cuboid class for that
then you can simply check contains
Im first checking if claim exists right?
But them im stuck
I dont know what to first check
Because on break event i need to check lot of things
I personally have something like
private void noteCancelled(@NotNull Player player) {
long time = System.currentTimeMillis();
Long lastComplain = lastComplainTime.get(player.getUniqueId());
if (lastComplain == null || time > (lastComplain + 10_000)) {
lastComplainTime.put(player.getUniqueId(), time);
player.sendMessage(Component.text(this.pl.getI18N().get(I18NKey.ACTION_NOT_PERMITTED, player.locale()), NamedTextColor.RED));
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent e) {
Block block = e.getBlock();
/* `>> 4` Has the same effect as `x / 16`; may god hail binary operators.
* Interestingly enough, this trick even works for negative values,
* which might be the case as `>>` is dependent on the sign extension
*/
int chunkX = block.getX() >> 4;
int chunkY = block.getZ() >> 4;
if (presenceConfig.isHarvestableCrop(block.getType())) {
if (!data.canHarvest(e.getPlayer().getUniqueId(), block.getWorld().getUID(), chunkX, chunkY)) {
e.setCancelled(true);
noteCancelled(e.getPlayer());
}
} else {
if (!data.canBreak(e.getPlayer().getUniqueId(), block.getWorld().getUID(), chunkX, chunkY)) {
e.setCancelled(true);
noteCancelled(e.getPlayer());
} else {
block.removeMetadata("presence_spongeplacer", pl);
}
}
}
?paste
If player is a non owner or member dont allow to break
if owner and breaking protection delete claim
if member dont allow breaking the protection block
As you said they are really painfull
Well, you are stuck on the fun part it seems
yes
what
thats what it says
There are a LOT of events you have to listen to. This is just my listener class for blocks. https://paste.md-5.net/ujugazelaj.java
I personally use https://github.com/Geolykt/Presence/blob/main/src/main/java/de/geolykt/presence/common/PermissionMatrix.java for the member/non-owner etc. stuff
yes
i've never worked with bytes 👀
Though I wrote this entire plugin with enormous care to make it as fast as I knew how; there are better ways to do it
they are ints at the class file layer anyways
Hi, I created my library where I have a class that extends from PathfinderMob. When I implement my library in another plugin and I extend that class and use normal spigot/paper methods from Entity class like setNoGravity, setCustomNameVisible etc. I have NoSuchMethodException. Why?
(both plugins are on the server, library and my plugin that implements it)
probably because your lib uses mojmap but does not reobf the jar that is used by the main plugin
both plugins has this task
assemble {
dependsOn(reobfJar)
}```
but probably my main plugin implements the lib without reobf (with -dev suffix)
Eh, this is probably a gradle moment
I mean i publish my lib via github packages and idk why I have only -dev files
but when run gradle build
I have normal one
i kinda hate the fact that the default logger does not support placeholders
LOG4J
This is literally the exploit
PathfinderMob is not API is it
slf4j
Why would you be able to call spigot methods on a subclass of an nms class
Also, slf4j does support local placeholders
it is, nms and mojmap
check the blocks location to see if it is inside one of your claims.
Then check who owns the claim.
Then see if this player has permission to break blocks in the claim.
well ye i mean local like info("test : {}", 1)
Yes but the API methods are not implemented on the nms classes
They are implemented in craftbukkit
Well in presence I do following:
- Get the claim that is at the given location
- If the claim does not exist, do nothing
- If the claim exists, get the permission matrix attached to it
- Get the owner of said claim
- If the claim does not have a permission matrix, use the owner's permission matrix
- If the player that is breaking the block is equal to the owner of the claim, query the permission matrix as the owner
- If the player is trusted by the owner, query the permission matrix as an member
- If the player is not trusted by the owner and not the owner, query the permission matrix as a stranger
- If the permission as queried by the above 3 steps is given, do nothing
- Otherwise cancel the event and (optionally) notify the player of the cancellation
verano still working on the claims plugin 🤤
Well writing a claiming plugin was the most fun experience I had in bukkit world
My issue is that i dont know how to do it without nested if
otherwise, I mean how can I use that methods?
what is the issue behind that?
Well depends on what your class does
public class ClaimListener implements Listener {
@EventHandler
public void onBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
Claim claim = this.plugin.getClaims().getClaim(block.getLocation());
if (claim == null) return;
if (claim.getOwner().equals(player.getUniqueId())) return;
player.sendMessage("§cYou cannot build on §f" + claim.getUuid() + " §c claim");
event.setCancelled(true);
}
}
// getClaim() mehtod
public Claim getClaim(Location location) { return this.claims.stream().filter(claim -> claim.getCuboid().contains(location)).findFirst().orElse(null); }
// Claims var
Set<Claim> claims
You said it extends PathfinderMob
Which makes no sense unless you are adding a complete new mob
ah I see
geol up to now all is okay
Your getClaim method has a complexity of O(n), that your issue or what?
Well you cannot do anything with a subclass of the abstract class that is PathfinderMob
class in main plugin that extends from class in the lib that extends from PathfinderMob
So your lib creates an actual new entity
He?
yeah
Well, if that mob is not based on an existing mob you will have to implement a craftbukkit layer for it too
which can obviously extend existing craftbukkit layers
where are defaults from a config actually coming from? Are they coming from the file within the jar?
e.g. CraftLivingEntity
so doing it via lib has no sense?
Well no you can define your own custom logic that way
What should i check next on the event?
I am just saying that, for you to be able to call api methods, you need a proper craftbukkit wrapper around your custom entity class
If you have 10 000 000 claims in total it will take 1 000 000 times longer to retrieve the claim than if you had 10 claims.
This is bound to create issues in the long run
But you onBreak method is completely sufficent if you do not want to have things like trusting users and such things
I mean i coded that logic but not for all methods
you did ?
so you are basing stuff off armorstand ?
it is fully new entity type with arrmostand model
Well yea, then have fun implementing the craftbukkit layer for that
Methods that i coded for armorstands, like small, pose, invisible etc. works, but methods that are in extended class like setNoGravity, custom name etc. doesn't work
Does your craftbukkit wrapper extend CraftLivingEntity
Im using a cuboid class
or I belive CraftCreature is the one that wraps PathfinderMob
I dont actually know why you tell that but okay
It still takes that much time given that you effectively do
for (Claim claim : claims) {
if (claim.bleh(blob)) {
return claim;
}
}
Are you saying that because im using Stream?
Or i dont understand why you are saying that
Yeah, the streams API is basically a for loop
Which means that performance-wise this is hell
Functionally, it isn't an issue however
to be honest, having chunks not be aligned on a grid makes everything much much harder
I know
