#help-development
1 messages · Page 850 of 1
Machine code compilation would be faster that runtime bytecode translation
ofc
but not cross platform
and the runtime can be nice
with things like reflections
i've been reading through crafting interpreters and its got some interesting bits about that
JUST MAKE EM DIRECT ACCESS
Well then I guess
because people use it
its also bytecode so its not as slow as interpreteting the script and its converted to machine code at runtime by the jvm
also class loading and gc
are nice
I use it on daily basis
Class loading is also fast
java isnt even that slow anymore nowadays
Like 0.02 ms when I tested
join the church of valhalla
we all believe it is read for the next LTS 
so just saying MAKE EM DIRECT ACCESSES isn't a very productive statement
How would i go about using Entity.remove() to remove an entity with a specific CustomName, say 'Test'?
probably want to find that entity somehow
I mean that
wasnt that the data oriented shit
for the jvm
loop over all entities, filter them by name, then call remove on them?
Before the server loads the class
like, stack allocated structs
that would be great
that would indeed be great
that would be crazy
It should find the variable, make it accessible and parse it into machine code
mfw every update is just java trying to catch up to c#
it does that later but yeah
Why not at loading?
some parts may actually be compiled immediately idk
Too much memory usage?
dk
But that wouldn't make any sense
should u JIT compile code which is run like once per frame
just takingn up more resources and memory
Since the VM can access anything
than it saves
nah bro
will probably be compiled rather quickly
Yes.
Absolutely
i don't understand your example
but like rendering code called for every vertex should be compiled yeah
what exmapel
once a frame is a lot
it might not be a lot as the other one but its a lot
stuff that probably won't get compiled is one off stuff
in the example of a minecraft server a command you call occasionally
I once read an article that said that the JIT is actually a bad thing
Since the code must be changed at runtime
ugh
articles say all sorts of things
everything has its place
jit is fine
worry about writing good code
I use switch(packet.getClass().getSimpleName()) for packet identifying
And it takes 0.5ns on average
To compare, empty lines (so no code) take 0.25ns
Ah yes
Matching packet classes
Great I can do that
Especially with those mfos changing names every version
But you cannot switch case a class
pattern match
?
just pull a CraftEntity.getEntity
and have a solid 200 if(whatever instanceOf Whatever) lines :)
bro i read that it looked so aids
Shape s = functionThatReturnsAShape();
switch (s) {
case Rectangle r -> r.area();
case Circle r -> r.area();
}
i doubt a hashmap isnt faster
not a great example but
instanceof is a really confusing thing to me, since during testing it's performance varied from 0.25ns to a whopping 0.5ms per declaration
p sure I just proposed adding a createBukkitEntity method in the nms entity class
oh thats much better prob yeah
- The class needs to be sealed
nah wtf why didnt they do that at first
are you sure
- They need to have the same name
I dunno
their arguing was that they'd need to modify every nms entity class
i mean I don't fully understand what you're doing but to me I don't see why it wouldn't work
you're matching on the type
Yep
But I can input all possible class names
And have them execute a line of code
But if I try to input a non-existent class
ERROR
So 1. tis
- Java 18+
- Dunno but I think they need to be sealed
anyways if your system works fine then that's great
im fairly confident that 3 is wrong
I wanna max the performance
as long as you have a default case
idk this seems like premature optimization
have you identified this as the most inefficient part of your program
plugin whatever
I don't
Yes
- Getting the Offline Player's info
- Teleporting
Yes
Paper has like getOfflinePlayerIfCached
Dunno when they cache em tho
To see if someone of This nickname has ever entered the server
And to ensure the user given nickname is correct
Correct it if not
I need to know before my plugin was installed as well
Completable future woo
I was wondering whether I should make it async
Hell nawh
ForkJoinPool.
Same thing
That's the other way I was considering
I'll probably do this
Yes you should use getOfflinePlayer(string) async
Is there a method like that?
Since when?
declaration: package: org.bukkit, class: Bukkit
?contribute
You can find information about contributing to Spigot at the following links:
https://www.spigotmc.org/wiki/cla/
https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/README.md
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/CONTRIBUTING.md
Whaaat
"all players exist"
"web blocking request" For what?
To get the uuid from the name
<dependency>
<groupId>groupId</groupId>
<artifactId>artifactId</artifactId>
<version>version</version>
<scope>system</scope>
<systemPath>path to my plugin.jar</systemPath>
</dependency>
Why importing my other plugin like this I can't access the variables when I do the hook?
why do you use system scope? why don't you just "mvn install" the other dependency?
It's terrible
because its local jar
well system scope is bad but should work. wdym with "cant access the variables"?
Does anyone know why this event occurs after a block is placed?
Additionally the coordinates are not of this chunk, but of the placed block
@EventHandler
public void onChunkUnload(ChunkUnloadEvent event) {
Chunk chunk = event.getChunk();
getLogger().info(String.format("%s | %s", chunk.getX(), chunk.getZ()));
}
No need at read if you don't require exact info
after hook and cast, intellij auto complete for example my plugin instance, but its show:Unresolved reference
Placed block?
It's a chunk event
Are you placing the block way off in the farlands
well, that s right..
i'm using system scope because i can't just import the jar as external libraries because the maven remove it
the maven remove it?
would be helpful if you could show a screenshot of the issue. I don't understand what you're trying to say. and maven will not "remove anything" from your local repository
one second
how?
mvn install on the other dependency, or if you only have the jar: https://blog.jeff-media.com/manually-installing-jar-files-to-your-local-maven-repository/
Sometimes you have a certain .jar file that you need as dependency, but the author of that .jar was too lazy to properly upload it to a public repository. That’s bad, but not a problem. There are two ways to solve this, but only one proper way. The proper way: install the dependency The proper...
i can't send screenshot here
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
depends what you wanna do. if you e.g. wanna call the getOfflinePlayer thingy, I'd just run CompletableFuture#supplyAsync
CompletableFuture<OfflinePlayer> offlinePlayerFuture = CompletableFuture.supplyAsync(() -> {
return Bukkit.getOfflinePlayer(...);
});
sth like that
@EventHandler
public void onChunkUnload(ChunkUnloadEvent event) {
Chunk chunk = event.getChunk();
getLogger().info(String.format("%s | %s (%s)", chunk.getX(), chunk.getZ(), event.getEventName()));
}
well, can anyone explain why this is happening?
I'm sorry for the quality
i will try it
Hey @tender shard, do you have a guide for setting up how to make changes to spigot?
Trying my first attempt at an actual PR, but I have no clue how to get these repos to work together locally.
I only ever PRed stuff to craftbukkit, which is explained here: https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
what are you PRing to spigot? if it isn't really a performance fix it should be to CraftBukkit
the implementation of bukkit
Trying to add methods to OfflinePlayer.
that should go to CraftBukkit
basically spigot-api
well once components go over it will bascially be all of spigot
Player, World, etc. all those classes are bukkit
@kind hatch if you don't know how to setup CB I can help you if you have time
Right, I have CB downloaded, but how do I use my version of Bukkit with the interface methods? Maven install?
yeah
Yea, I have no clue. :p
i did it, its working but.. Unresolved reference
I ran it for 1.20.4
alr
./applyPatches /path/to/buildtools/work/decompile-latest
well it depends how he did it
I always just get mine from git
using git clone
then I apply patches manually
Well aren’t you fancy
doesnt happen to me. are you using a weird server software?
Fuck, I screwed up where it downloaded.
Hopefully I can salvage this rq.
?paste your whole class
Ok, so starting from scratch.
I fork CraftBukkit and clone it.
i first tested it on purpur and then on regular spigot 1.20.4 and it turned out to be the same
then you run buildtools and run applyPatches.sh in the craftbukkit repo with the BT/work/decompile-xxxx as argument
I can't share everything, but that's all
val myOtherPluginProvider = Bukkit.getPluginManager().getPlugin("myOtherPlugin")
if (myOtherPluginProvider == null) {
server.pluginManager.disablePlugin(this)
}
val myOtherPlugin = myOtherPluginProvider as MyOtherPlugin
// myOtherPlugin.plugin ?????
As such right?
i dont think there's a "decompile-latest" directory, is there?
IntelliJ autocomplete but dont work
There is in mine
oh probably because you ran buildtools without --rev ?
doesnt buildtools default to 1.20.2?
you'll need 1.20.4
I built it for 1.20.4
weird, why don't I have a latest folder lol. but yeah, if it's there, that should work
does MyOtherPlugin even have a public getPlugin() method?
Alright, all patches applied.
now you can just open the crafbtukkit folder in IJ or whatever
then do your changes, then run createPatches (only needed if you changed any NMS classes)
why would you even call getPlugin() if you already got the instance of your other plugin?
i have used plugin just for example, any method/variable etc the intellij autocomplete but is Unresolved reference
are they public? can you e.g. call reloadConfig() on myOtherPlugin ?
all are public
how does it look if you decompile MyOtherPlugin in IJ? (Ctrl+B on the class reference)
PlayerInteractEvent sometimes is not sent when damaging an entity
I don't really know how to reproduce 100% of the times
public companion object {
public final lateinit var plugin: org.bukkit.plugin.java.JavaPlugin /* compiled code */
}
Here it's not sent, I damaged the entity while on ground
try Invalidating caches in IJ and check if your kotlin plugin is up to date
Facing like this
alternatively just see if it compiles anyway
yes it compile, maybe i can't access companion?
if it compiles, it's 99% an IJ cache issue
Ok, so now how do I compile these changes into a working spigot jar?
File -> Invalidate Caches & restart
you can't do spigot unless you have a PR
ok
I just test using CraftBukkit
if it still shows the error, check if your kotlin plugin is up to date
mvn install
If I hit it like this there's no issue
For craftbukkit?
yeah
can also just mvn package it
if you wanna compile into spigot IIRC you might have to download and fuck with spigot
I'd do install so you can access the new API from your test jar
though I suppose its uneeded to depend on craftbukkit
yeah usually you'd just install bukkit
but whatever, doesn't matter
but I'd always change the version when installing it, otherwise maven updates it the next day lol
done, invalidate all cache and restarted but its the same
Don’t forget that -p development
which version of kotlin plugin do you have installed?
1.8.0 both
I mean the IJ plugin version
same as you
hm no clue then
although there'S a bunch of 1 star reviews for the kotlin plugin claiming the last update broke stuff lol
everything's working fine for me though on latest IJ ultimate :/
hmm, i will try others things
fake 1 star reviews, delete!!!
we all know 1 star reviews arent real
same goes for 2
and 3
depending on the developer same goes for 4
and yes
i can't access companion variables
@chrome beacon @tender shard thanks for help
Why can't we report false reviews on our own premium resources?
wait, didnt you try to access this from the instance?
you can just do MyOtherPlugin.plugin
@fleet kraken
like this
I don't know if anyone can answer this but what is the benefit of having a plugin what loads groovy scripts dynamically over java code?
This kotlin?
yes
some things in kotlin are indeed very fancy
I just wish I had more coding knowledge lol.
i don't really understand it - I mean, if you don't need to load scripts dynamically, then the benefit is zero lol
I mean the server I play have many modules and they have scripts for each module and it allows them to change values while the server is running
That’s called a config file
Scripts or a normal config?
I guess it‘d be fancy for stuff like missions, tutorials and stuff
Basically like what most games use LUA for
They have a different script for each part of the server I think, I'm not sure how the backend code looks but I know it's using multiple scripts
Bukkit groovy DSL when
plugin is in companion and i just tried to acess it from the provider
yeah as mentioned you just gotta access the companion object like static members in java
MyOtherPlugin.plugin would be the plugin var in the companion object
you can
how?
val myOtherPluginProvider = Bukkit.getPluginManager().getPlugin("myOtherPlugin")
if (myOtherPluginProvider == null) {
server.pluginManager.disablePlugin(this)
}
val myOtherPlugin = myOtherPluginProvider as MyOtherPlugin
// myOtherPlugin.plugin ?????
All of this is not needed ^^
You just do this:
val myOtherPlugin = MyOtherPlugin.plugin
Wow, you're right, I was having so much trouble that I ended up forgetting about it
thank you very much
np! I also was too stupid to see the obvious things at first lol
i had to create two projects myself right now to figure it out lol
It's always the static ones that cause problems xD
what's the way to get player access token on login (1.20)?
?xy
Can’t wait for the legendary xyz problem
that sounds like a scary thing to want
fortunately I don't think that is something mojang gives out
afaik the server does not store their session token. Regardless this smells of wanting to make malware
What maven import do I need to rely on to get my custom craftbukkit changes?
mavenLocal craftbukkit
Assuming you did mvn install
Or just Bukkit if you don’t need any NMs
qq can you detect player pressing 'no' on beacon gui
Doubt it
I would imagine that gui is client side
Well, maybe not because you do have to sacrifice an item
yeah but cancel is just like closing the menu
you can only detect the yes button then
Yay, my method fires. 😄
Now I just gotta figure out how to work with the .dat files. fml
Wot
I'm trying to add OfflinePlayer#getLastLocation();.
The player's location data is stored in their .dat file under an NBT section called Pos.
In theory, I just need to figure out how to parse that and convert it to a Bukkit Location.
Will that work if the player is offline though?
No
So there we go
Do you have one open?
Yeah
I probably need to redo it and introduce an entirely separate system
Something like Bukkit.loadPlayerData(uuid)
Oooo, that sounds fancy.
how can i take a method as a variable?
depends
If it’s a simple method you can use one of the function interfaces and method references
Consumer, BiConsumer, Function, Supplier, etc
But yeah if I make a proper system to load offline player data you should be able to access nearly everything
PDC, inventory, etc
or we could just fake a player logging in and steal that fake player's data
not sure how feasible thatd be tho
Hmm, should I hold off then?
Up to you
I think I'm gonna continue anyways to get practice.
Never hurts to learn
You know, minus the Bukkit#getWorld() call, this does exactly what I was expecting it to. :p
World is probably stored somewhere too
Dang. Would have been very cool if it still stored that info.
?
It doesn't look like there's a straight world name that can be pulled.
Must be something
There seems to be WorldUUIDMost & WorldUUIDLeast
Ah, well that’s usable
At least when opening the player.dat files.
Convert to uuid and then get world by uuid
Is there a method to do that or do I gotta bitshift myself?
oh i actually have a background similar to that
We ballin
Hmmm, I have a feeling that this will work with Multiverse, but I can't get my plugin to load after it to confirm.
Why is there no loadafter? smh
MultiVerse is open source right
just clone it and add something to the plugin.yml
hen build
wait why don't you just write
depend: [Multiverse]
it'll force your plugin to load after xD
@kind hatch a niche trick I learned
you can make your plugin load last
Guaranteed
by adding a softdepend: [zzzzzzzzzzz]
But what if two plugins do that
prob load by name
add more z's
That's pretty neat.
But that's my plugin name
Hi
has some course about analyse Spigot source code?
I was wondering how spigot can bridge Minecraft with Bukkit
Well
Bukkit is just a set of interfaces that define an API
Then came CraftBukkit which provided an implementation of Bukkit and modified NMS to make it all work
When we refer to NMS we're referring to mojang's server code
So for example, when adding an NMS entity to a world, CraftBukkit would wrap the entity to a Bukkit entity and call the event
I know,What I'm trying to say is I want to analyze the source code to know how this process works right
Right
In this case I'd probably remap spigot and just decompile and go over the code
I use paperweight because I'm a gradle fanboy and there's nothing proper for spigot
嗯嗯
thanks
@echo basaltare there some videoes about analyze Craftbukkit source code in the network?
Well.. no
thanks
You don't really need to analyze the code to know how a process is made (unless you want to exactly know how, literally line per line). Usually you just want to know the logic, in which case (and I guess that's the case) you can do it by yourself.
I mean, if you think about it enough, and if you have some knowledge of java (or general OOP porgramming) and minecraft, you will end up discovering the logic on how spigot works with minecraft
(I don't know if that's what you were asking abt)
So I'm having a problem in regards to an inventory search. Whenever a player picks up my custom item, an event takes place and it is supposed to go through the player's inventory and enchant the tools that are in the players inventory. I am running into a problem that when the event reaches my custom item, the loop stops and throws me an "item is null" exception. Is there a way to skip over the item if the loop reaches that item? Here is the code:
@EventHandler
public static void itemPickupEvent(EntityPickupItemEvent event) {
if (!(event.getEntity() instanceof Player)) return;
Player player = ((Player) event.getEntity()).getPlayer();
PlayerInventory inventory = player.getInventory();
if (event.getItem().getItemStack().isSimilar(ItemManager.abundanceDiamond)) {
for (int i = 0; i < inventory.getSize(); i++) {
ItemStack item = inventory.getItem(i);
ItemMeta meta = item.getItemMeta();
if (item == ItemManager.abundanceDiamond) {
System.out.println("Abundance diamond is in the player's inventory");
return;
} else if (item.containsEnchantment(Enchantment.LOOT_BONUS_BLOCKS) || item.containsEnchantment(Enchantment.LOOT_BONUS_MOBS)) {
System.out.println("Enchantments have already been added");
} else if (MaterialPlus.isTool(item.getType())) {
System.out.println(item.getTranslationKey() + " is in your inventory.");
meta.addEnchant(Enchantment.LOOT_BONUS_BLOCKS, 3, true);
meta.addEnchant(Enchantment.LOOT_BONUS_MOBS, 3, true);
item.setItemMeta(meta);
System.out.println(item.getTranslationKey() + " is now enchanted.");
} else if (item != null) {
System.out.println(item.getTranslationKey() + " is in your inventory.");
} else if (item.getItemMeta() == null) {
System.out.println("Item does not have item meta value to it.");
} else if (item == null) {
System.out.println("Empty slot");
}
}
}
}
Just continue if item == null
Add an early return statement?
Return? No
Just do
if(item == null) continue;
Do that directly after using getItem(i)
Then it skips all empty slots
return: stops the execution of the program at that place
break: leave the current loop
continue: go a step further in the current loop
As alex said, you want the continue
wait, there are more statements then return? my java class never taught me that lol
Then you're barely new in OOP, because breaks and continues are learned on loops, which are the third thing they show you usually
Who know how to teleport player to a position?
my prof never did that lol
Literally impossible
but that's good to know
One message removed from a suspended account.
?javadocs
ok
It's Player.teleport
Next time try making a google search or looking at the javadocs
ok
org.bukkit.event.player.teleport?
org.bukkit.event.player does not exist
uhh?
Player player = /*obtain a player*/
player.teleport(/*location here*/)
Player is org.bukkit.entity.Player
"Location" is org.bukkit.Location
package index
declaration: package: org.bukkit.entity, interface: Player
So I added the continue statement but i still got the exception.
Where and how did you put the continue?
You should do the continue even before you do anything with the item
if (item == null) continue
ItemMeta meta = ...
ah
Also you don't need continue statements at the end of the loop
Nor on a if/elif structure
oh gotcha
||Unless you have code out and after the elif||
yo man hows the wallpaper
for (...) {//My amazing loop
if (somethingNullable == null) continue; //Needed
if (cond1) {
//Do something
continue; //loop already ends here, as there's nothing else after this if/elif
} else if (cond2) {
continue; //loop already continues here, uneeded
}
}
for (...) {//My amazing loop
if (somethingNullable == null) continue; //Needed
if (cond1) {
//Do something
continue; //loop continues after the if/elif, this is needed
} else if (cond2) {
continue; //loop does not end here, needed
}
//Do something
}
where my profit
Sorry, I can't hear you from my helicopter
You can't steak a NFT
i can
nah we have discord proof
i bought you
im controlling you right now
you think you are in control
but actually your every thought is mine
tis the matrix
If you are controlling me, then what am I doing rn?
you are thinking about me
still the same answer
STOP CONTROLLING ME
HAHA
No one said i could not control you again
lmao
i am still controlling you
i lied
and now you paid me for buying myself more mindcontroll
Ok Bye im going away with the money
does anyone here knows if it's possible to mock using ormlite?
package vz.pl.first.Commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.*;
import org.bukkit.event.*;
import vz.pl.first.Main;
public class spawn implements CommandExecutor {
public spawn(Main main) {
}
Location lc = new Location(Bukkit.getWorld("world"), 0, 0, 0);
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(cmd.getName().equalsIgnoreCase("spawn")) {
Player player = event.getPlayer();
sender.sendMessage("將您傳送至大廳...");
player.teleport(lc);
}
return false;
}
}
How can I fix it
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.
ok
what is the event fired before the player joins?
?jd-s
error when im trying to despawn npc
com.comphenix.protocol.reflect.FieldAccessException: Field index 0 is out of bounds for length 0
at com.comphenix.protocol.reflect.FieldAccessException.fromFormat(FieldAccessException.java:49) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.reflect.StructureModifier.write(StructureModifier.java:316) ~[ProtocolLib.jar:?]
at org.firestorm.deathpro.Utils.NPC.despawnNPC(NPC.java:92) ~[DeathPro.jar:?]
at org.firestorm.deathpro.EventListener.Corpse.lambda$onDeadBody$0(Corpse.java:30) ~[DeathPro.jar:?]
at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftTask.run(CraftTask.java:101) ~[patched_1.17.1.jar:git-Pufferfish-22]
at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483) ~[patched_1.17.1.jar:git-Pufferfish-22]
at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1569) ~[patched_1.17.1.jar:git-Pufferfish-22]
at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:495) ~[patched_1.17.1.jar:git-Pufferfish-22]
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1485) ~[patched_1.17.1.jar:git-Pufferfish-22]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1284) ~[patched_1.17.1.jar:git-Pufferfish-22]
at net.minecraft.server.MinecraftServer.lambda$spin$1(MinecraftServer.java:321) ~[patched_1.17.1.jar:git-Pufferfish-22]
at java.lang.Thread.run(Thread.java:840) ~[?:?]```
my code
if (uuid != null) {
// Create a PacketContainer for the Entity Destroy packet
PacketContainer destroyPacket = protocolManager.createPacket(PacketType.Play.Server.ENTITY_DESTROY);
// Set the packet data to the NPC's entity ID
destroyPacket.getIntegerArrays().write(0, new int[]{uuid.hashCode()}); // entity ID
// Loop through all online players and send the packets
for (Player player : Bukkit.getOnlinePlayers()) {
protocolManager.sendServerPacket(player, destroyPacket);
}
}
}```
did you ensure that the chunk the entity is in is loaded?
also, you are using pufferfish
Pufferfish? That's the fork of a fork, right?
think so
public class VipJoin implements Listener {
private Node vipNode = Node.builder("iransky.vip").withContext(DefaultContextKeys.SERVER_KEY, "smp").build();
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPlayerPreLogin(AsyncPlayerPreLoginEvent e){
User player = LuckpermsAPI.api.getUserManager().getUser(e.getUniqueId());
if(!player.getNodes().contains(vipNode)){
e.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_FULL);
e.setKickMessage("The Server Is Full! You Need SkyGod Or Higher To Join");
return;
}
for (Player p : Bukkit.getOnlinePlayers()) {
if(p.hasPermission("iransky.vip")) continue;
p.kickPlayer("You Were Kicked Due To A VIP Player Join!");
e.setLoginResult(AsyncPlayerPreLoginEvent.Result.ALLOWED);
break;
}
}
}```
is there anything i need to improve?
better code
easier to read
and is more logical
This is like calling
Apple banana
or
Grape apple
Apple apple is better and
Grape grape too
naming an event with an e can also be confusing
calling it event would be better
avoid using one character variable names if its not something more permanent like a constant.. if everything is done right you should actually never have very short variable names
lets say I have point a and b, int
I could call it just a and b but why? it wouldnt make any sense and if my code is very long how am i supposed to quickly know what the a and b is. in this case naming it pointA and pointB would be better
how can I change the "tab" display using Scoreboard?
At the very least, you are trying to do a dependency injection constructor but you're neither doing anything inside that constructor, nor are you actually using the plugin's instance anywhere in that code
This is probably not the problem (because you never said what the problem is) but that's very unnecessary
Just remove the constructor if you're not using it
And yeah since you are not following naming conventions (lowercase class name) and using a non-existent variable (event.getPlayer()), you do need to learn java first as Goksi mentioned
Also btw you do not need to check for the command name if(cmd.getName().equalsIgnoreCase("spawn")) because you're already registering the command specifically for the name "spawn"
share the error
nvm fixed it
why do you pass an instance of Main into the constructor iwthout ever using it? Why do you check the command's name? Why are you returning false? Why is the class not properly named? And what do you want to fix?
Naming your main class Main is a serious sin
Ego??????
No?
Yeah it's kinda not a good idea for spigot plugins especially lmao
Given that there can be tens of them running on the server
the main class is org.bukkit.craftbukkit.Main though
It depends on your project, but I never name my main class Main, even when I make a standalone
it's still not the main class, otherwise it'd have a public static void main method
anyway, it should definitely not be named "main" but at least "Main"
Whaa
Dependency injection is a joke to you?
and it should be used if it's passed in the constructor
Man with 0 plugining experience talking shit in plugin dev channel
What principle
What the fuck are you talking about
So you aren't gonna tell me
Welp
In bukkit plugins your main class is your plugin, you can query thr config or the data folder from your plugin instance and it's less of a main class than in a standalone
I am gonna be the first one to call troll because I don't wanna deal with this shit and waste my time xD
Just judging by this
Happy coding guys
I'm gone
well only if it's actually needed

In the minecraft client there is something like a bootstrap which is the class with public static void main which passes data over to the actual main class, then there is a Minecraft class that uses the singleton pattern and is always passed around everywhere to get keybinds, settings, etc. that gets this data from the public static void main thingy
You can, but should you?
in every language the main class is the main class of the program. Main classes of plugins are not the main class of the program, rather an addition to the main program and therefore does not make sense to name it Main and why you shouldn't

If you don't want to follow the rules sure, I just explained to you why in plugins or even mods the main class is not named main
A good reason I've seen is that when you make an API, you want users to get the instance of PluginName and not Main, because of common sense
hello, im trying to get a string from a FileConfiguration,
the output of the FileConfiguration.getString("punishment.command.proves") => "MemorySection[path='punishment.command.proves', root='YamlConfiguration']"
p.sendMessage
(
ChatColor.translateAlternateColorCodes('&',
Main.getMessages().getCustomConfig().getString("punishment.command.proves")
.replace("{caseID}", args[0])
.replace("{playerName}", Main._dataBase.getCasePlayerTarget(Integer.valueOf(args[0])).getName())
)
);
and the getCustomConfig() gives me FileConfiguration(aka the file "messages.yml"):
punishment.command.proves: "&6&lHere's the list of proofs of case: {caseID} ({playerName})"
punishment.command.noProve: "&4<heres no proves for the case: {caseID} ({playerName})"
any one know where could be the problem?
oH nO i aM cReAtiNg a GoD oBjEcT iN an aPI tHaT hAs a sTatiC sInglEton
anyways shows your understanding of programming
could anyone recommend me some good resource for learning nms?
with that, I have no more interest debating it
We are following plugin-coding standarts
you make some wild claims, but what is your credentials to say everyone is wrong?
So your opinion
These rules are derived from conventions which every language has one
There are no rules
OmG yOu aRe pAsSinG tHe eNtiRe mAiN iNstAnce, iDioT thAt iS aGaInst tHe rUleS
Hmm, doesn't spigot do that for you, basically?
shouldnt your config look like this?
punishment:
command:
proves: "message"
Anyways, as I said shows your lack of understanding. If you want to have the opinion that everyone is wrong that is fine, but in that sense your opinion is no more correct then everyone else is wrong
such as?
Dots should work I think
can you people pls move your stupid argument into a thread or sth
just fyi, not all of us here just know Java or only spigot
some of us know more programming languages and worked on other stuff before MC even existed
I'm pretty sure most people here do something in java besides spigot, and maybe not only java
maybe, i tried to get another message ("punishment.command.noProve") and the output is the actual string ("&4<heres no proves for the case: {caseID} ({playerName})")
For example I was doing discord bots in nodejs before java, now I do spigot plugins, forge mods (planning on starting fabric modding), I'm also thinking of making some discord bots and I've made a few little utility standalone applications for checking some stuff
print out your whole config using getAsString() and show the result
I was doing stuff in VisualBasic and C before MC even existed 😛
probably before purp was born
Before that I was doing BDFD man
Damn 💀
you mean "#saveToString()"?
Weird dick measuring contest NGL
modifying windows 95-xp and making custom drivers
can you guys please move your useless discussion into a thread, it's a annoying if this channel is spammed with useless shit
Fair
Hmm, true
yes
Thought so LMAO
yeah quite annoying lmao
clickToProve: click me to show!
proves:
noProves: '&4here''s the list of proofs of case: {caseID} ({playerName})'
noProve: '&4&li didn''t find any proves for the case: {caseID} ({playerName})'
drivers back in the day were not always perfect and stuff stopped getting updates routinely so instead of swapping your hardware out you could just improve the driver yourself or otherwise make the fixes yourself
this was more common with GPU drivers
I mean, if your self worth is so low you have to trash talk in a help development channel
It is what it is
so your config is wrong, proves is a configuration section
other times it was getting hardware to play nice together
Damn, can you write drivers for my grandmas gpu for windows 10? She has a computer as old as your C skills and the gpu got no drivers
its hard to say if its just a driver issue
Frostalf, how old are you?
almost 33
Holy cow
Well, windows was saying the device works fine but drivers aren't supported or some shit like that iirc
Or it said there were no drivers installed? Idk
interesting, a trick you could try is modifying the cab file for the driver to make it appear it is compatible and see if windows works with it just fine
easier then making a new driver
okey, i'll take a deeper look at that, i didn't think about printing the config as a string. thanks
windows 10 has compatibility for all the way back to windows xp sp2
np
Hmmm
Is there a way to prevent the EntityDamageByEntityEvent from being emitted when using LivingEntity#damage with a source being specified?
In other words, is there a way to look for legitimate damages from the entity?
Ill check for crit attack in the mean time, but lmk if anyone has a solution
but even if you could get a driver working for it, its still possible the GPU wouldn't work right
windows doesn't do very deep investigation in regards if its working. Really it just detects if it powers on and if windows is able to assign an IRQ
can't you just not specify a source? IIRC all it does it to set the last damage cause
because I can be? and I generally help/teach people
cuz my man enjoys helping people maybe?
Hmm, do you think it outputs a square image on a 16:9 monitor because the gpu driver or could it be some issue with the gpu itself or something
I actually don't need to work at all to be honest
damaging a player without a source doesn't apply the knockback velocity
I do because its boring otherwise
also death messages / kill credit as well
u win the lottery or somethn?
because I make plenty of money as it is
from the various investments I have
indeed
I am not interested in doing it as a job
I am mean that isn't completely true as I have done paid jobs before or commissions people like to call them
however for the most part I just keep it as a hobby
I don't like having some manager who has no clue what they are doing telling me how to do something 😛
But programming isn't all I know, I even know how to do Satellite Communication stuff and networking 🙂
Satellite Communications thanks to the military lmao
frostalf, didn't you even like survive death three times or something
networking is probably more fun for me then programming itself, even more so if I have to also program or make scripts to make some stuff work XD
I have survived death on quite a bit of occasions
GPS was fun to learn about in the Military
to learn that for example your cellphone doesn't communicate with the GPS sats all the time
and in fact its the cell towers that do that
and the cell towers do fancy math based on your signal to give you your GPS coords
the SOS devices you speak of really do wait for a GPS sat to come over head
however it drains those devices quickly
so they don't communicate with the sat as often as you think
Well, maybe alex was right when he said this discussion should be moved to a thread
GPS satellites don't have high bandwidth and thus you need to be in a single spot for like 10-15 minutes so it can pull GPS information, this is why cellphones don't communicate with sats other then being a big power drain
It depends on what is needed, I can setup just about anything as long as I am able to. In the military I had the freedom to just run lines whenever I wanted just about XD
however in civilian world I can't really do that, so I have to rely on what I do have access to which makes it fun sometimes and challenging
imagine how much money one could make by selling cold beer to thirsty firemen
maybe in Germany this would sell?
In the US they would all get fired
well. they're firemen
no, I wasn't thinking about puns XD
its hard to point to any one particular thing because what makes networking great is that its ever evolving and what is needed always is different or changes
the military does have its own protocols, which I can't really tell you
a friend of mine works for ESA on cubesats and they code most stuff for them in python2
Classified materials is not subject to public dispersal NDA or not
?protocol
no wiki.vg link?
funny
oh the little stuff yeah I have tried out making a protocol before but its more of a pain then its worth
because literally you have to install the protocl on everything you want part of it
oh I hate python2, well, generally python, but not because the language is bad, because the backwards compat is non-existant so I have to install fifty python versions before ti works
but it was cool to learn to do regardless because for in home network though it may come in handy at some point
but over the wire communications its useless
python is handy if it gets too complex for a simple bash script
well the issue is all the devices understanding it 😛
yeah, especially because it's often preinstalled on a lot of systems
Python is now preinstalled on systems?
yeah even mac comes with python 3, even though mac usually includes like 20 year old versions of most CLI stuff
I once made a system that was secure because of a protocol and as far as I am aware no one knowing how to deal with it. And this was allowing two systems the same IP without having issues
Have I missed some chapter xd
my ubuntu vm came preinstalled with python3, I think it was something about xfce4
it works in a limited way, but if both systems are doing two different things that don't interfere with each other, its doable to allow them both the same IP on the network
idk I only know that it's preinstalled on macOS 12
Never had mac, probably that
python is a common to be preinstalled software nowadays
Player interact at entity event doesn't work on spigot 1.8.8 when trying to detect if player right clicks on an armor stand. I've tried debugging the even doesn't fire at all while other events work fine in my class. Does anyone know why and how to fix?
deleting it on linux can actually somewhat fuck your system, well, depends on distro and stuff
do you need the exact clicked location?
if not use PlayerInteractEntityEvent
essentially yes, and I did this because I had always been told that it wasn't possible for two machines to have the same IP and during my research really it just came down to the OS's not being happy about it, and as long as the information in the line for either system was not the same it was fine
however on the opposite end of the network from the outside, it made these systems more secure because you couldn't target a specific one
I never did measure the performance so I couldn't say, but you are correct it wasn't really worth it to keep it up and always do this with my systems because you had to ensure there was no overlap in data
I've tried using PlayerInteractEntityEvent and it didn't work as well.
This is my code:
public void onPlayerInteract(PlayerInteractAtEntityEvent event) {
Bukkit.getLogger().info("Player interact event triggered!");
if (event.getRightClicked() instanceof ArmorStand) {
Bukkit.getLogger().info("Player interact event triggered at armor stand");
Iterator<LuckyBlock> iterator = activeLuckyBlocks.iterator();
while (iterator.hasNext()) {
LuckyBlock luckyBlock = iterator.next();
if (luckyBlock.getArmorStand().equals(event.getRightClicked())) {
Bukkit.getLogger().info("Player interact event triggered at lucky block");
luckyBlock.onPlayerInteract(event.getPlayer());
new LuckyBlockLootEvent(event.getPlayer(), luckyBlock);
iterator.remove();
break;
}
}
}
}```
actually I take that back, there was one piece of information that could overlap without issue
and that was the time data
^
what exactly isn't working? PlayerInteractEntityEvent is definitely called when clicking on armor stands
This event in general isn't fired at all when I click on anything, even at a dropped item.
Could it be something in my settings like paper or spigot?
interesting, good luck with that
which event isnt fired? PlayerInteractEntityEvent or PlayerInteractAtEntityEvent? The "At" entity isn't called for many things
Should I try using PlayerArmorStandManipulateEvent?
?nms
both events are not firing
then the ArmorStandManipulateEvent also wouldn't be fired
are you sure you registered the listener properly?
Should be properly registered because I'm also using PlayerMoveEvent and it fired just fine
so it's not a class problem
Bukkit.getPluginManager().registerEvents(this, plugin);
this.plugin = plugin;
this.instance = this;
this.spawnLocations = new ArrayList<>();
this.activeLuckyBlocks = new ArrayList<>();
loadLuckyBlockConfig();
loadLocationsFromConfig();
startSpawningTask();
}```
No clue then, it works fine for me using spigot 1.20.4
Didnt you mention 1.8?
Maybe the armorstand event doesn’t extend the interact event in 1.8
yep, I'm using a 1.8.8 spigot base
possibly, I'll try using armorstandmanipulateevent
i'll see if it works
hi guys i wanna prevent drop saplings from leaves
am i call leavesdecayevent ?
And BlockBreakEvent
well i will g ive my code 1m
btw i need use iterator or list ?
for get leaves drops ?
For what exactly?
w8
@EventHandler
public void onEntitySpawn(LeavesDecayEvent e) {
for (ItemStack drop : e.getBlock().getDrops()) {
if (drop.getType() == Material.OAK_SAPLING) {
drop.setAmount(0); // Fidanı sil
}
}
}```
this will work ?
no, that won't work. getDrops() on a block just returns a "default" list of drops for that type of block
you need BlockDropItemEvent to remove a block's drops
well i did this
@EventHandler
public void onBlockDropItem(BlockDropItemEvent e) {
if (e.getItems().stream().anyMatch(item -> item.getItemStack().getType().name().contains("SAPLING"))) {
e.setCancelled(true);
}
}```
working when i break block
but natural breaks
not working
ah
wait i
cancelling event
for drops from decaying leaves, you'd have to cancel the LeavesDecayEvent and manually set the block to air. it looks like decaying leaves dropping items doesn't call any event
not really
BlockDropItemEvent says "Called if a block broken by a player drops an item."
?help
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous usernames, global display names, and server...
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
btw that would also cancel dropping saplings from chests, etc. And you should rather use Tags.SAPLINGS.isTagged instead of comparing by name
I want to send a title using protocollib, do I need to fake minecraft protocol packet to do that?
in BlockDropItemEvent you should check if the blockstate's getMaterial is tagged with LEAVES
and only then remove every drop that's tagged with SAPLINGS
why do you need protocollib for that?
why don't you just use sendTitle method?
aght ty
no need for protocollib to send titles: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html#sendTitle(java.lang.String,java.lang.String,int,int,int)
declaration: package: org.bukkit.entity, interface: Player
?1.8
Too old! (Click the link to get the exact time)
^^^^
in spigot 1.8 I can send titles but I cannot do fade in, stay, fade out and I don't want to execute command as server
hm well then I'd just send a ClientboundSetTitlesAnimationPacket manually
without protocollib
I mean I could use NMS
PacketPlayOutTitle(EnumTitleAction, IChatBaseComponent, int fadeIn, int stay, int fadeOut)
(in 1.8)
ok thanks, why do you recommend to use nms for that tho?
imho it's much easier than ProtocolLib. you just create the packet from the constructor and send it
remember that there's no mojang maps for 1.8 though lel
but there are third party mappings
i'd just use the spigot mappings in 1.8
Hope I'm not interrupting,
public void spawnAtPos(World world, Location loc) {
Bukkit.getLogger().info("Before");
Block block = world.getBlockAt(loc);
block.setType(Material.BLUE_CONCRETE);
Bukkit.getLogger().info("After");
return ;
}
Any ideas why this function, when it's run, just fails to set the block in the world?
Both logs get outputted, Before and After, but no change is made?
No errors in the log either.
Been looking at tutorials looking for some "block.update" or thinking that it only set the object in memory's type but I don't think that's the case
kk
I don't know if it's related, but doesn't location ship with a world?
Will try that
You're right, thanks!
Hmmm, I changed it to this:
public void spawnAtPos(Location loc) {
Bukkit.getLogger().info("Before");
loc.getWorld().setType(loc, Material.BLUE_CONCRETE);
Bukkit.getLogger().info("After");
return ;
}
Still just silently fails 😠
imagine if they just forgot to call it
I'm not that dull :)
would be funny tho
Location{world=CraftWorld{name=world},x=329.0,y=79.0,z=-1663.0,pitch=0.0,yaw=0.0}
The location seems correct
Which version?
1.20.2
Did you set api-version in plugin.yml?
does that change a lot
Don't believe so, should I have?
Yes
Yes
Not setting an api versions will get you a bytecode manipulated version of the material class
Right, would you mind explaining what it does? :)
Do you have an example of api-version? :)
api-version: "1.20"
does spigot do all of that on runtime??
how can i get a variable made in the spigot plugin on the bungeecord?
Check the Pluginclassloader class or whats it called
Without api version, you only get the legacy material class
I have looked at it before but only because I was trying to inject a fake plugin object
Print out the block before and after changing it, not just the location
Doesnt matter where it is
wtf is going on
Using world.getBlockAt()? :)
Probably doesn’t know 1.20, change it go 1.13 or smth
?
You can also just call getBlock on the location
Then it‘d fail to enable
I'm calling the event from a runnable but it doesn't get called when I listen to it. The runnable runs, the listener is registered, but the event just doesn't trigger
UnsupportedAPIVersionException or sth
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<classifier>remapped-mojang</classifier>
</dependency>
yeah this doesn't exist
As i said, no classifier
1.13 and just pray
actually, I'm stupid
Remapped is 1.17+
So weird
why tf did I assign the listener to a variable and then not register it
holy gof
Idk seems like a you issue
[11:36:21] [Server thread/INFO]: Before
[11:36:21] [Server thread/INFO]: Location{world=CraftWorld{name=world},x=329.0,y=79.0,z=-1663.0,pitch=0.0,yaw=0.0}
[11:36:21] [Server thread/INFO]: REINFORCED_DEEPSLATE
[11:36:21] [Server thread/INFO]: BLUE_CONCRETE
[11:36:21] [Server thread/INFO]: After
no worries
The REINFORCED_DEEPSLATE is the before, and BLUE_CONCRETE after
What I want
But in the world, it doesn't update
that happens every time, I remember registering the listener and then it turns out it isn't registerd
Does it change if you rejoin?
it doesn't ):
It's not because I'm cancelling the original event of BlockPlaceEvent is it?
That is the issue
lmao
what is with the code publishing if I contain mojang's code or can I avoid that somehow?
Soooooooooo
your plugin contains mojang code ?
Well spigot and paper is avoiding it

Why would your plugin contain mojang code?
How do I cancel the placing of one block and swap it out for another block?
Change it one tick later
Best way to asynchronously wait a tick?
Why async?
?scheduling
Do I need to wait a tick, it seems to work even if I set it in the same tick
Well if it works, its fine
You would have to wait a tick if you cancel the event
If you dont cancel it, you can set it right away
goofy spigot stuff
BlockPlaceEvent is called after the block was set, cancelling it would then reset it back
damn my iq is high
I guess my next question is can I spawn a sign with text, or do I have to update it like this:
Block block = loc.getBlock();
loc.getWorld().setType(loc, Material.BIRCH_SIGN);
Sign sign = (Sign) block.getState();
sign.setLine(0, ChatColor.GOLD.toString() + this.niceName() + " generator");
sign.setLine(1, ChatColor.DARK_PURPLE + "Outputs 3 per min");
sign.setLine(2, ChatColor.GRAY + "Stored: 0");
sign.setLine(3, ChatColor.BLUE + "Level " + this.level);
sign.setEditable(false);
sign.update();
Because unfortunately, this doesn't work ):
Or do I have to wait a tick
something crazy happened today
block.setState() ?
No errors?
I think it exist
Doesnt exist
oops then
Hm try not calling update, or call update(true, true)
Will try ^
No clue otherwise, im in the bathtub right now lol
As last resort you can always try to wait a tick lol
You tried to call add in a list on kotlin?
MutableList needed for that
Can I jsut do this:
BukkitScheduler scheduler = Bukkit.getScheduler();
scheduler.runTask(plugin, () -> {
// This is delayed one tick?
});
Yes
Nice, thanks
I am
damn lambdas are fancy
Now play half life
lmao
Don't make your apis too lambda based
last time I used kotlin I got a !!seizure!!
oops
kotlin developers when they see that runTaskLater does not have the consumer as the last paramter and now their whole language collapses 🧠
lmao
lmao
Accurate
I mean like forge's
most used character in kotlin btw
mhm extensions 
Only if you access java api
Otherwise you never need it
I tried using my library with koltin and I had more exclamation marks than polish people have ś and rz sounds
You‘d either use ?: or if you‘re sure it cant be null, dont deckare it nulalable
a lot of stuff can be null, you see
I still write:
if (variable != null) {}
I dont see any reason when one‘d have to use !! when not having to deal with java kotlin interop
well, null is useful

I never experienced this scenario in real life though
damn burchard really did remake forges energy api
did he accidentally remake capabilities or something
I'd say kotlin isn't bad, it's a pretty good programming language, but not for me lol
I've been told to learn kotlin by some experienced people ik irl lol
it's a fine langauge, especially when used in the right place
I hate kotlin‘s name though
Kot means shit in german
Thank god its pronounced differently
well, it's pronounced kotlin, not kootlin
Kotlin has a short o, while the Kot word has a long o
Yeah but its still spelt the same lol
MongoDB is even worse
I remember there was a server that lost all its oneblock data due to json corruption lmfao
?
nah, it was some little server that has a little oneblock gamemode
the data was stored on json and corrupted
And the word is a slur against disabled people in german lol
And the dev of mongodb even is a german!!
well, doesn't english come from german