#help-development
1 messages · Page 195 of 1
@EventHandler
public void onPickup(PlayerPickupItemEvent event) {
Item item = event.getItem();
if (item.getItemStack().getType() != Material.CARROT_ON_A_STICK) return;
Player near = null;
for (var entity : item.getNearbyEntities(1, 1, 1)) {
if (!(entity instanceof Player player)) continue;
if (near == null) {
near = player;
continue;
}
if (player.getLocation().distanceSquared(item.getLocaiton()) < near.getLocation().distanceSquared(item.getLocation())) near = entity;
}
}```
The amount of nesting and unecessary checks just to get the closest player to a location
agree
I would just make a custom user object, based on their uuid and then add a properties to that object
ok ty
Your welcome
private Entity getNearestEntity(Entity source, double minRange) {
Entity result = null;
double resultDistance = minRange*minRange;
for(Entity other : source.getNearbyEntities(minRange, minRange, minRange)) {
double distanceSquared = other.getLocation().distanceSquared(source.getLocation());
if(distanceSquared < resultDistance) {
resultDistance = distanceSquared;
result = other;
}
}
return result;
}
Player PDC is a thing
Ahh right, the thing is, I'm used to the old school where there was no PDC
sounds like a you problem
true
technically players have always had variables
i basically suggested the same thing tho
Imagine 1.8 coder moving to 1.19
but without external distance variable
are you trying to be ironic or something
No, lmao all the clients i used to work they ask me for 1.8 plugins. Now im just rejecting them and just accepting 1.19 comissions
Hello, I'm trying to create a "god entity" for our server. We would like to be able to type into the chat as the god entity. Is there a way to type into chat as some other alias other than yourself and is it possible to create a script where this god entity would have a conversation with some other entity in chat? Feel free to ask more questions if somethings unclear
And now im having amazing zip issues with maven
only differences between 1.8 and 1.19 are:
- no magic values anymore (1.13)
- sendTitle and bossbar api
- PDC
- easy nms
what issues?
you can not force entity to chat
its not being able to do descompress the dependencies
U were talking about that before
you can send messages to players who pass near your entity
for the last line player.getLocation().distanceSquared(item.getLocaiton() < near.getLocation().distanceSquared(item.getLocation()) is giving the fact i cant use < to a location but what i should use?
if you are including zipped files in your jar you must include them unfiltered ie.```xml
<resource>
<directory>resources</directory>
<filtering>true</filtering>
<includes>
<include>*.yml</include>
</includes>
</resource>
<resource>
<directory>resources</directory>
<filtering>false</filtering>
<includes>
<include>*.nbt</include>
</includes>
</resource>```
Is it possible to send chat messages under a different name?
just use player.sendMessage("[God] Hello");
i forgot one bracket
You can send messages to players that imitate the format of chat if you want to preserve your chat formatting.
i changed the code
but that will make, to appear [playerName] [God] Hello not just [God] Hello
if I use the player PDC will it save or not?
You're thinking of Player#chat()
probably
idk there was a guy asking that
we are using sendMessage
it can't have any playername
it's sent by plugin
What could be? File data/regions.yml could not be reloaded. Reason unacceptable code point '' (0x0) special characters are not allowed in "'reader'", position 0
And the file is empty that the best part
🤦♂️
its probably not empty, just unprintable characters
Hmnn
i dont think there is anything in it
pass it thro yamllint
ok
its a site btw
Bro
But the file is empty
Doesnt have any content
🤔
how would i pass it thru there if its empty?
Doesnt make sense
idk ctrl a it and press delete or smth
I mean im just loadingan empty file
Fucking spigot file system that is what i can say haha
this one didnt seem to work
snakeyaml isnt related to spigot afaik
I mean also the host where im testing, doesnt even allow me to open the file
😂
Im trying to open it via the ptedactyl file system and doesnt allow me to see the content
So smth weird in the file
on the source folder right?
I'm getting the error message "Unhandled exception executing command" and I can't figure out what's causing it. Is there something wrong with my formatting here?
hotpotato:
description: kill command
?paste whole stacktrace
That means that something is not code correctly on your command class
Command class? I just overrided "onCommand" and asked if the name of the command sent was equal to the name of the command I registered
paste the whole error thing so we can see
[12:15:45 INFO]: TheWendigo_ issued server command: /hotpotato
[12:15:45 ERROR]: null
Did you mean everything below this? Because i'll flood the chat lol
Paste full stracktrace please
Stacktrace?
org.bukkit.command.CommandException: Unhandled exception executing command 'hotpotato' in plugin HotPotato v1.0-SNAPSHOT at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.CraftServer.dispatchCommand(CraftServer.java:916) ~[paper-1.19.2.jar:git-Paper-232]
at org.bukkit.craftbukkit.v1_19_R1.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:64) ~[paper-1.19.2.jar:git-Paper-232]
at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:264) ~[paper-1.19.2.jar:?]
at net.minecraft.commands.Commands.performCommand(Commands.java:305) ~[?:?]
at net.minecraft.commands.Commands.performCommand(Commands.java:289) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.performChatCommand(ServerGamePacketListenerImpl.java:2294) ~[?:?]
at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$20(ServerGamePacketListenerImpl.java:2248) ~[?:?]
at net.minecraft.util.thread.BlockableEventLoop.lambda$submitAsync$0(BlockableEventLoop.java:59) ~[?:?]
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.19.2.jar:git-Paper-232]
at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]
at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1341) ~[paper-1.19.2.jar:git-Paper-232]
at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:185) ~[paper-1.19.2.jar:git-Paper-232]
at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1318) ~[paper-1.19.2.jar:git-Paper-232]
at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1311) ~[paper-1.19.2.jar:git-Paper-232]
at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1289) ~[paper-1.19.2.jar:git-Paper-232]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1177) ~[paper-1.19.2.jar:git-Paper-232]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:305) ~[paper-1.19.2.jar:git-Paper-232]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
at me.jacky.hotpotato.HotPotato.onCommand(HotPotato.kt) ~[HotPotato.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
... 23 more
Caused by: java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:177) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:124) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
at me.jacky.hotpotato.HotPotato.onCommand(HotPotato.kt) ~[HotPotato.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
... 23 more
you coding minecraft plguins on kotlin
Yee
why
Legitimoose
you'll have to shade the kotlin standard library
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
are you sure
that you added kotlin lib
and blah blah blah
oh koltlin 🤢
Koltin is bad?
i dont really know in m ycase i just done like tht esyntax
Reminds me of lua, which I'm very familiar with
I just like the syntax from C#, Java and TS
Atleast kotlin syntax is better than Python
I didn't do anything specific besides convert the project in IntelliJ
You cant use a library which doesnt exists
you have to shade the kotlin library, meaning including it at runtime and not only at compiletime
I don't know what that means
Oh havent u learn about java before?
Like how the lang works (atleast the basic and important things) and many other things
I did node js a long while ago
I'm moving from data packs to plugins now because of how annoying they are to work with lol
Wait dont comapare JavaScript with Java, they are not similar but now because you know javascript means you cant code directly into Java
Its a common mistake done by lot of people
if i wanted to make a bungee plugin do i need to use a database? or can i just use files like a regular plugin
If you want to share data between servers, use a database. Otherwise, you can just rely on the local databases that your plugins provide.
i just need to allow commands to be used in all servers and store based on that, so that would be fine?
Yes
If you want to make global commands and dont want to mess with a spigot plugin on each sever, bungee is perfect
So in your case a Bungee plugin will be the best option and you can either use flatfile or database storage
ok thanks
Because bungee commands can use on every sever and you dont need to sync the storage, meaning that if u do a spigot plugin u will have to sync the storage
depends on the kind of data
if its data that needs to be stored, this works
but if its data that doesn't need to persist, better off just using sockets
any way to check which entity launched a projectile using projectile launch event?
it should have a method to see shooter?
think its getShooter() or something to that effect
getentity?
event.getentity or somth
that returns the projectile
wel getEntity gets the projectile
according to the docs
there it is
thanks
is there an event of some sorts that triggers when you look at another entity?
or a way to do something like it
without having to loop through every playre every tick
you could use the playermove event
and then from there trigger a timer to activate a task to loop through players that are not moving
to see where they are looking
once they start moving again, halt the task
i can't use that for its purpose
not sure why you couldn't
hello, I'm creating a core for a skyblock .... I want to create an island that is not already occupied by another island, what do you recommend? use external plugins? if so, which ones?
players needs to be able to move
I never said to cancel the event
you can just simply use it because it is always ran
anytime they stop moving, which doesn't cause a playermove event to happen
you have a task to fill that gap
but since players are moving constantly you shouldn't have many tasks 🙂

?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
passing a ThreadPool as an executor its never going to end
you are running it on every executor, which gets renewed
Hey, how could I bump a player 100 blocks in the direction he is looking ?
make them hover a bit off the ground and change their velocity to 100 in the direction
and they will zoom away
Yes but I don't know how to do that
fun fact if you could slow the server down, when players teleport they just run really really fast
java guava looks so complicated 
Hey does the BlockSpreadEvent also apply to water?
?jd-s
no infos
Well the event get not triggered by water
What do you need to detect water spread for?
I want to limit the spread of water
Like for 4 Blocks
code [software / extensions] for clean and suggestions?
Hello, im having a little problem, im using spigot 1.19 and when Someone equip something in the shield slot they can not unequip it, does anyone know if this is a Vanilla bug?
val packetContainer = protocolManager.createPacket(PacketType.Play.Server.ENTITY_DESTROY)
packetContainer.integers.write(0, 1)//size of entities array
packetContainer.integerArrays.write(0, intArrayOf(event.entity.entityId))
I get "Field index 0 is out of bounds for length 0" on both write lines. What am I doing wrong? (ProtocolLib)
It's Kotlin but everything works the same
Are you sure that's the correct packet format?
I've tried not setting the count value
both lines make it seem like I shouldn't write to those places
Is there a reason why you can't use the api
which api
Spigot
No
how would I hide an entity from a player using spigot api
?jd-s
1 sec
I've already looked and I personally couldn't find anything. Perhaps something new that I dont know of like attributes ?
declaration: package: org.bukkit.entity, interface: Player
How could i make a larger array from 2 smaller arrays, for example like this:
ItemStack[] updatedItems = { oldItems, newItems }; but ofc that doesnt work, how else would i do it
I am trying to turn a player's gamemode to adventure when they join and I have some very strange problems. I have this code and it uses player.setGameMode(GameMode.ADVENTURE). This only works when the player is in a rank (on my luckperms permissions plugin) that has the permission *. If they are OP it also does not work. I have some Sysouts to test and right after I set their gamemode, I print their gamemode and it says their gamemode is ADVENTURE although when they join the server, they are in survival. If the player is in a rank with perm*, however; it does set their gamemode to adventure. The gamemode in server.properties is adventure and force-gamemode is set to true. If anyone could help me with this that would be amazing, I just can't seem to figure it out.
@EventHandler
public void onJoin(PlayerJoinEvent event) {
System.out.println("1");
Player player = event.getPlayer();
System.out.println("2");
UUID pUUID = event.getPlayer().getUniqueId();
System.out.println("3");
final Location location = new Location(Bukkit.getWorld("hub"), -0.5, 65, -0.5);
System.out.println("4");
player.teleport(location);
System.out.println("5");
player.setGameMode(GameMode.ADVENTURE);
System.out.println(player.getGameMode());
if (player.hasPermission("wildgames.fly")) {
player.setAllowFlight(true);
player.setFlying(true);
}
System.out.println("7");
BuildModeMap.remove(pUUID);
System.out.println("8");
player.getInventory().clear();
System.out.println("9");
ItemStack item1 = new ItemStack(getItem(new ItemStack(Material.ENDER_EYE), "§a§lGame Selector", "§7Click to open the Game Selector (/gameselector)"));
System.out.println("10");
Inventory inv = player.getInventory();
System.out.println("11");
inv.setItem(4, item1);
System.out.println(player.getGameMode());
player.getInventory().setHeldItemSlot(4);
}
Use a runnable and delay it a tick
hm
do I do that in the onEnable or in the class?
like when I register the listener
In the event handler
ok
Just since it’s player join it might be iffy
First the javaplugin, then runnable, then delay in ticks
hm ok
would there be a better way of doing this
public void enchant(Location loc1, Location loc2) {
double minX = Math.min(loc1.getX(), loc2.getX());
double minY = Math.min(loc1.getY(), loc2.getY());
double minZ = Math.min(loc1.getZ(), loc2.getZ());
double maxX = Math.max(loc1.getX(), loc2.getX());
double maxY = Math.max(loc1.getY(), loc2.getY());
double maxZ = Math.max(loc1.getZ(), loc2.getZ());
for (int x = (int) minX; x <= maxX; x++) {
for (int y = (int) minY; y <= maxY; y++) {
for (int z = (int) minZ; z <= maxZ; z++) {
if (!mats.contains(loc1.getWorld().getBlockAt(x, y, z).getType())) continue;
setBlock(x, y, z, Material.AIR, loc1.getWorld());
}
}
}
}```
optimization wise
Hey sorry but i got a question. When will a block get maximum level?
declaration: package: org.bukkit.block.data, interface: Levelled
I tried this and I'm still getting the same errors:
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Bukkit.getScheduler().runTaskLater(WildGamesHub.getInstance(), () -> {
System.out.println("1");
Player player = event.getPlayer();
System.out.println("2");
UUID pUUID = event.getPlayer().getUniqueId();
System.out.println("3");
final Location location = new Location(Bukkit.getWorld("hub"), -0.5, 65, -0.5);
System.out.println("4");
player.teleport(location);
System.out.println("5");
player.setGameMode(GameMode.ADVENTURE);
System.out.println(player.getGameMode());
if (player.hasPermission("wildgames.fly")) {
player.setAllowFlight(true);
player.setFlying(true);
}
System.out.println("7");
BuildModeMap.remove(pUUID);
System.out.println("8");
player.getInventory().clear();
System.out.println("9");
ItemStack item1 = new ItemStack(getItem(new ItemStack(Material.ENDER_EYE), "§a§lGame Selector", "§7Click to open the Game Selector (/gameselector)"));
System.out.println("10");
Inventory inv = player.getInventory();
System.out.println("11");
inv.setItem(4, item1);
System.out.println(player.getGameMode());
player.getInventory().setHeldItemSlot(4);
}, 1);
}
if (data.getLevel() == data.getMaximumLevel())
Can anyone think of a reason why some methods would only get the initial value of a variable (upon class instantiation), but other methods can change it and get the new correct value without issue
I'm going crazy over this
sorry was too stupid to read around, i already found out sorry for the disturbance but thanks!
what?
i guess weird design patterns are the reason
page is the problem child, in the increment method i'm just adding 1 to it, both messages print the correct value of page
private var page = 1
fun increment() {
Chat.broadcast("&cIncrement page before: $page")
page += 1
if (page > pages.size - 1) page -= 1
Chat.broadcast("&cIncrement page after: $page")
}
This is the problematic method render, it also uses the exact same page variable, it's in the same class and everything, but no matter what the page variable is set to it only reads the initial value of 1, all of the print messages also show 1
override fun render(inventory: Inventory) {
if (preCheck()) return
Chat.broadcast("Pages size: ${pages.size}, Rendering page $page")
pages[page].render(inventory)
Chat.broadcast("Rendered page $page")
}
Some sample output
The expected output would be the white messages show the latest value of page, the value printed in "Increment page after: <num>"
I can't for the life of me wrap my head around it, I tried changing the initial value of page to 0 and the render method uses 0 instead, but it never gets the accurate value of page
you mean you are rendering page 1
but should render page 12
on the screenshot
your increment and render have no connection tho
paste the whole class
aah I delayed it 5 ticks and it worked. Thanks for the help! I was really stuck on this one
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
the increment and render methods are called outside of the class, but they both access the same variable, or at least they should
I checked the compiled java code just to be sure there isn't a weird issue there, but there aren't any discrepancies that I noticed
Anyone?
I mean
there are some ways you can optimize it
but it's really specific and depends on how big the volume is
I mean, it'll vary. Around 25x25 area every 10 blocks broken ish
- like 30 players
So around 18k loops every 2 seconds
Which i dont like
You could... make a weird queue and process chunk snapshots async instead
My set blocn function is rock solid but the looping on the other hand, i could make a different thread, but again. Thats like 18k threads which isn't good either
thread pool
True..
And how would i do this 😅
Let's start with a queue / deque of the locations to be broken
Which should be concurrent so we can add in 1 thread and loop in another at the same time
You can use synchronized blocks or just look for a concurrent queue implementation
Deque<Location> breakableLocations = new ConcurrentLinkedDeque<>();
Okay..
and either break like 50k blocks per second (random number) or limit it to a ms/t variant
Sorry looking up deque because i actually haven't used it before
So would i loop the deque?
Variant A:
private static final int BLOCKS_PER_TICK = 50000;
public void processQueue() {
int iterations = 0;
while(iterations < BLOCKS_PER_TICK && !breakableLocations.isEmpty()) {
Location location = breakableLocations.pollFirst();
...
}
}
Variant B:
private static final double MAX_MILLIS_PER_TICK = 15;
private static final int MAX_NANOS_PER_TICK = (int) (MAX_MILLIS_PER_TICK * 100000);
public void processQueue() {
long endTime = System.nanoTime() + MAX_NANOS_PER_TICK;
Location next = null;
while(System.nanoTime() <= endTime && (next = breakableLocations.poll()) != null) {
next...
}
}
run processQueue sync on each tick
Okay i see, where would i put this or do i need to implement anything?
So now we have the structure to:
- Add elements concurrently to a list, that-
- Get processed sync, on the next thread, without ever having TPS drops
I can see me using this alot
And now we need to:
- Create a snapshot, process it on the thread pool, and populate the deque
This is just a dumbed down version of
Lol
fuckin ell
this
Me neither
it's a lot
Mhm
how can i schedule something to run in x seconds using bungeecord? ive only found how to do it every x seconds
why don't you update the chunk?, it will be much faster than updating block by block
Hello, does anyone know how i can convert a skull value to a skull url?
pretty sure
the stull value is just a base64 serialized json tag that contains the url
Okay, i understand the deque part and splitting the workload, but how would i implement this so i can use it in my own?
Like what do i add to my code already to make the deque and all that work
I probably missed something in the tutorial
Oh, i kinda see how he did it in the github
There was no particle API in 1.8
So... no.
In 1.9 (and even present day) you can spawn particles via Player or World, the latter being for any nearby players
Packets? 🤷♂️
Yes
Yep
There was a popular library back in the day. Forget who it was that made it
Darkbladde13, that's the guy
You basically just copy/paste those two classes into your project and use that as the API. Though really, you should just be updating to a version that isn't 7 years old
Easy fix, dont use 1.8 🤯
run once in x seconds - bungee
?
you just take a world, take a location
and set the type to what you need
and then apply blockdata
if that's for plugin tho
you missed the custom block part
nms
i guess you need CraftWorld or what is it rn
NMSWorld
and BlockPosition
and then IBlockData
You can't set custom blocks like that
Or, you can't make them like that at all.
The client would have absolutely no idea what you're doing
NMS World should have methods for setting blocks
I am simply editing an existing block
with light update and info sending
I mean maybe? No idea how the client would respond honestly. You for sure can't change the texture of it.
Not like that anyways you can't
iirc CraftWorld#setBlockAndData does send the data to players somehow
performs light update and stuff
but idk what is used in 1.19
Does Material.WHEAT represent both the block and item?
this is for older version
EntityDeathEvent including players?
yes
yes
it even has blockdata ageable
aight, ty
is there a mob deathevent
ik
no need for entity i guess
i need entity
alr
but i also want player
Should do
Reason?
so if a mob dies
Whats a mob, its an entity
Hey! I'm not entirely sure if this goes here but I'm looking for someone to help me create a really simple minecraft plugin, I can do graphic design and I already have the concept designed, I just need someone to do the coding, and modeling message me if you're interested!
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
Oh ty
show code
fixing it
maybe you need uppercase AIR
LOL WHAT
System.out.println("J\u0061va".charAt(1));```
prints a
cuz \u0061 is a
and charAt 2 is v
so all chars from \ to 1 are one char
OMG
Woah
now i just need to fix some exceptions
Hey guys I try to use the Set Block Destroy Stage packet with Protocollib and I was wondering what Packet Type I should use for it I mean PacketType.Play.Client is obvious but what to use after that? I tryed PacketType.Play.Client.BLOCK_DIG but this wasn't working for me. Anyone know what to use instead?
https://wiki.vg/Protocol#Acknowledge_Block_Change
how should I go about getting the players mouse direction 10 ticks ago? ik how to get mouse direction but cant figure out how to do the 10 ticks ago part. ik schedulers alr
player#getMouseDirection10TicksAgo();
someone help me psl
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Ok so i started learning java and i tried making a simple fly plugins
But
package org.bukkit.command;
import org.jetbrains.annotations.NotNull;
/**
* Represents a class which contains a single method for executing commands
*/
public interface CommandExecutor {
/**
* Executes the given command, returning its success.
* <br>
* If false is returned, then the "usage" plugin.yml entry for this command
* (if defined) will be sent to the player.
*
* @param sender Source of the command
* @param command Command which was executed
* @param label Alias of the command which was used
* @param args Passed command arguments
* @return true if a valid command, otherwise false
*/
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args);
}
Yes
i cant edit it
and
It sasy cant resolve symbol NotNull and jetbrains
what do?
bruh
dm me
you don't need to use commandExecutor itself
and @NotNull annotation from jetbrains should be in your IDE already
shit
tagging him for 10th time already
imagine naming yourself @fresh templetHandler tho
woops
sorry ahaha
why the frik it even do that
it’s not
i’m pretty certain that they aren’t in the jdk
Hey guys
does someone know if there’s a way I can view all my Java Compiled Classes size? If there’s a program to view your classes size?
why don't you just look inside the jar
Yeah this is a way too
to see size of each .class file
or if you don't have winrar
go to the folder with your .java file
imagine you don’t have WinRaR in Windows it has a Infinity Free Trial
and run javac YourClass.java in powershell in that folder
it will compile your code and generate .class file for you
yeah that’s good thanks but also is there a way to see each line of your code how much size it takes?
yeaa its turned into bytecode
i mean
that’s for sure yea
java compiler simplifies your for(string s : list)
to for(int i = 0; i < list.size(); i++)
well ur making a spigot plugin right?
you could download the plugin spark
to generate a dump for you
Didn’t know that thanks 😊
object size in your VRAM i guess
not as actual file
yes indeed
idk if he wants that
but as actual file is not really relevant
is there even a reason to check your class file size
i cant think of one. but eh
like it's gonna be something around 1kilo or 50kilo
no other options
or it's super small
or it's super giant
My Plugin’s size for right now is 150KBs
my average plugin is around 40
and I want to find a way to reduce it if I can
pretty sure maven has some kind of minimize feature
a lot of repeating code
could look that up
maybe he shaded entire spigot api into plugin hehe
I mean it will be really big plugin
Maybe the size is bigger because it has a lot of Utils classes
who knows lol
we didn't see it
use winrar
or well
yeah I’ll do that
you can write a program
in java
give it a folder
it will loop through all files in the folder
and sysoutprintln their size
🙂
that’s also good idea
i bet half of spigotmc don't know how to write main method in java
u legit just have to type "main" and click enter
for entellij enjoyers ofcourse
Make sure you don’t include non-dev members of Spigot
eclipse has the same feature
for intellij it's sout i guess
Mate I have two OS and one time I wrote in IntelliJ Idea in the system that I don’t really write and I really liked it
eh its perfect for me
i guess i'm average asceticism enjoyer
eclipse is like super lightweight
install archive unpack to folder run and forget
i do agree that testing standalone programs on eclipse is way faster
idk how tbh
they dont recompile or something
Is there any way to get name of inventory in InventoryCloseEvent
I can't find that method 😦
Please help me..
Intellij may use 8GB of memory at all times but it's got a lot of fun stuff under the hood that makes it worth it
Generally it’s a lot more customizable than Eclipse
see no real customization there
which is not in eclipse
for example?
Better refactoring,easy integrated JDKs, integrated database support with automatic SQL query detection in strings. I could go on forever. I used to use eclipse and thought I hated java. Turns out I just hated eclipse.
Better refactoring stands to?
Eclipse also provieds integrated jdks
but i still prefer downloading manually
database support is part of JDBC
not IDE
Not sure if eclipse can but intellij can search comments and strings when refactoring. That with the ability to refactor a variable across the entire project is really nice.
Database support means I don't need a separate application to do anything related to the database. I can create,update,view,delete tables in-house without the need for a program or tests. I can run queries and everything else as well
One thing I really hate in Eclipse is for example if you want to have IntelliJ Auto-Completion there’s no good way to have it
umm
you mean hosting the DB
For example in Eclipse you add all the keybinds to AutoCompletion and after that when you type it’s good right yeah but when declaring a new variable and adding “;” at the end it changes the name to the suggested one which is very annoying
No
what?
I mean I have complete control over a db
I don't need 3rd party software to do anything
Bassically phpmyadmin build into intellij i guess?
IntelliJ AutoCompletion is opening when you’re typing directly
oh you mean that
no need to Ctrl Space or hit “.”
Yeah, sorta
When I used IntelliJ Idea I really liked it
Works on every modern db though
well i host db manually
I tried to implement it in Eclipse but it wasn’t perfect and I removed it
Postgre ❤️
Dude it's not about hosting
both IDEs are good I will say
It's about control
I like them both and I will try to use them both
You can store all of it in intellij rather than needing external software
SQL, ideas, etc.
For like creating dbs for me
well yeah IntellIJ has more features
but from what i can see some features are just implementations of external things
if i would develop an ide i would only add maven/gradle and git support
dark theme and auto-complete on hotkey
nothing else
Well yeah, but productivity-wise that's never going to fly
i mean these are the only things i use in eclipse
and i don't really need anything else
git support just highlights classes with blue to show that they are changed but changes are not commited yet
maven support is like default
dark theme is necessary
Sure, you don't need it but it'd be nice to have
well i'm not fan of integrated external things
You're the odd one out
guess just my experience wants me to learn software
which would probably be on the job
so now i know Postgre
Some git commands
some linux commands
tho switched to github desktop cuz easy
Intellij as pretty much all the features of desktop built in as well lmfao
You don't need to switch applications to handle that
and well eclipse still eats memory but at least i'm able to run server + minecraft + IDE + browser on my laptop
with intellij it just dies 🙂
Yeah, but that's cause your dev environment is on the low end.
some of the features of intellij are just in running state even if i don't use them
I'm using it for rust rn with the linter on constantly so it eats ram
linter?
Lint, or a linter, is a static code analysis tool used to flag programming errors, bugs, stylistic errors and suspicious constructs. The term originates from a Unix utility that examined C language source code.
🙂
the best option i found in eclipse
is own code formats
by default if you have one-line if action it still goes to the next line
if (a)
b();```
but i changed it to java if (a) b();
That's different lol but okay
You're talking formatter I'm talking linter
i said
not connected to linter
when i typed linter in browser it gave me russian database ЛИНТЕР(LINTER) hehe
Yeah, but that's a universal thing. Every basic tool has that
yeah, but the simplicity of it is just 🔥
Yeah, works the exact same on Intellij
like through VS code, VS, IntellIJ, Eclipse i find eclipse most lightweight in size, small in RAM and fast in executing what i need
small features list just makes it easier to find option you need
Yeah, as I said before. Eclipse is fine it just lacks a lot of features that I use in intellij
and execution is hella fast
tho there is one thing which i don't understand in intellij
I mean higher learning curve intellij means that eventually you'll know enough that small feature list becomes irrelevant
You can have multiple
when you open a project there is a window
Open new tab
or open project in existing tab
which is iirc closing your current project
and switching to one you selected
like that's so nice that when i'm creating a new plugin i can just open one random plugin i coded before
and copypaste pom.xml contents
i guess main reason why i'm in eclipse
is that i prefer copypasting over coding
Well if you spend most of your time copypasting lmfao
you can open multiple in intellij too I just don't cause that's messy
The only real multi-project support Intellij has is if you're adding other projects as modules to one over-arching project.
Yeah, but imo it's fine because each project should be it's own window
Otherwise, you'll need to use different windows.
which basically means two instances of ide
Agreed, I usually prefer each project having it's own window. Makes things simpler and easier to determine what's what.
well, you have a Close project button here
Unless you're a coder who uses a lot of bad practice it shouldn't be that big of an issue
Each to their own really. Intellij and Eclipse both have their good and bad. It really comes down to use case and personal preference.
i guess it comes more to pc specs
@fluid river Do you know a good Decompiler plugin for Eclipse?
?
i guess good is not to use decompiler
Decompiler plugin for Java classes
Ig im rdy now
I want to decompile some NMS
Intellij has fernflower 
I mean it’s telling me source not found
Why not just use something like https://marketplace.eclipse.org/content/enhanced-class-decompiler (Just google Eclipse decompiler, not hard to find one 😛 )
Did the same mate I google it but still I asked if there is better
What about JD-GUI
I have it
what about not decompiling
Sometimes I think you need
tho you can just use sources downloaded with buildtools

they are all .java iirc
He is proving everything that Eclipse is missing
Built into intellij 
eclipse has same two buttons tho
Including fernflower
update project
Can I customize the IntelliJ UI?
Of course
Depends what you mean by customize but yeah
I wanna rearrange the buttons
Hey, I still don't understand how I can bump a player a 100 blocs forward, can anyone help me please ?
Just update the players location
you mean teleport them 100 blocks forward?
ez
No, like with a jumppad
I think you’re gonna need to use velocities
You'd need to play with velocity and have a check for location etc..
Haven't mess with them personally haha
same
Yes but I don't know how 😕 I tried to play with velocities but I always push me in diagonal
You can google some tutorial for Velocities
also I can send you a video about a JumpPad Plugin
Yes I'd like to please
the channel is called SyntaxError
you can see his videos
he has tutorials for plugins with unique ideas
Okay thx
also please don’t skip and copy-paste instead watch the entire video just a tip don’t take is as offending
99% of code tutorials should be text. Can't change my mind
Most often there are either no docs at all or the docs are so bad that the dev could have just not made any in the first place
yeah that's why i run text java blog
in russian
sometimes i link pictures of what's happening
but that's console app so not really necessary
i know it's not related to spigot development, but could someone help with c? pm
knitter
Do someone know if the blockspreadevent count for water?
water is BlockFromToEvent
Well i limit the water for x Blocks with the BlockFromToEvent but if the water flow to the ground its spread and the limit dont work for All sides thats why i thought maybe BlockSpreadEvent would help
Hello guys, is there a way to check if an event is running?
For example let's say you ran a command like "/givespeedtoeveryone" with a speed duration of 5mins, so all online players receive speed, but if a player joins the server after the command is executed does not receive it, how can i check if the event givespeedtoeveryone is still active and give the speed to the player who has logged in?
that's more of a OOP question
Make a cache that contains active effects and their end time stored as a long. When a player joins do the math to determine how long it has left based on that.
And data structures
so when a player joins, i check if he is stored, if not i give to him the effect?
When a player joins you check if they've received this exact buff by using a unique id per command usage. If they have not you apply either the full effector if you want it to be based on duration left, you give them the amount left based on a stored expiry time.
Alright, understood ❤️
wtf is that
a search result 🙂
I didn;t read it, just searched
Would it be possible to make a plugin that uses Unsafe to inject into worldmanager and just make worlds fully thread safe
🤔
The timestamp method looks fine
then minecraft updates and it breaks everything
that's why I called the post a joke
yeah a runnable only makes sense to show a timer or sth
is there any fancy way to serialize custom java Object which contains Bukkit Object?
uhhh what do you wanna serialize it to? Json? a yml entry? csv?
and what Bukkit Object?
that too
I tried save it into .yml by String
It's ArrayLIst of Itemstack
use ConfigurationSerializable
ItemStacks are already serializable
since ItemStack is already that
umm..
just do myYaml.set("mylist",myList); lol
Is there any tutorial for ConfigurationSerializable?
?jd
I tried to find information about that but It was so hard 😦
Okay Thanks I'll tried that
ima send you an example of a ConfigurationSerializable class hold on
Oh thanks! 🙂
got like 50 here
Wow...
I use this class for serializing and deserializing boss bar information to and from config https://paste.md-5.net/hulonigibu.java
it implements ConfigurationSerializable at its core
Okay really thank you! 👍
the main things are the deserialize and serialize methods, aswell as the @SerializableAs("") at the top
Okay I gonna check it right now with document you sent 🙂
public class Person implements ConfigurationSerializable {
private final String name;
private int age;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
@Override
public Map<String, Object> serialize() {
Map<String,Object> map = new HashMap<>();
map.put("name", name);
map.put("age", age);
return map;
}
public static Person deserialize(Map<String,Object> map) {
String name = (String) map.get("name");
int age = (int) map.get("age");
return new Person(name, age);
}
}
I usually use static final strings for the keys of each attribute, makes it easier to edit
Oh I got it thanks for your help!
does the nether have time ticks like the overworld?
the whole server does
thats what times the spreading of lava and water for example
I saved custom java object which implements ConfigureSerializable.
But I don't know how to load that object again
I tried to use config.get(path) method but it doesn't work 😢
how to get object from configuration file?
did you register the class?
you can use the deserialize method for that.
You need to register it to ConfigurationSerialization
best time for that imo is onLoad()
yes I registered it
But when I use config.get(path). it invoke deserialize method automagically?
basically. you can do "CustomObject customObject = (CustomObject) config.get(path)"
omg I did not know this hahah thanks man! I googled but not found something like this
hmm.. I used that method...
well, did you register the serializable class?
yeah I will show you my code
are there any errors in console?
public class sertest implements ConfigurationSerializable {
{
ConfigurationSerialization.registerClass(sertest.class);
}
ummm... just a moment plz
that won;t work.
org.yaml.snakeyaml.error.YAMLException: Could not deserialize object
thats my thought too, should be tthat exact error
it only registers it when you instance the class. You need to register it before accessing the config
main class extends JavaPlugin right?
plugins have no main method
yeah
like registering event?
and register the ConfigurationSerializable class there
Okay Let me try
that method is used before the onEnable() method so you can prepare stuff like that
@Override
public void onLoad() {
ConfigurationSerialization.registerClass(sertest.class);
}
Is it right?
🙂
dont forget the SerializableAs annotation so you get rid of the path for a class name
paths are ugly in config
Okay I got it!
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player p = (Player) sender;
NamespacedKey key = new NamespacedKey(Housing.inst, "playerData." + p.getUniqueId() + ".testNum");
p.getPersistentDataContainer().set(key, PersistentDataType.DOUBLE, 0.0);
return false;
}
``` Would this be the correct way to set data for a player?
And if I restart the server would it keep this data?
I just wanted to make sure it works
and I just realised
I won't ened the getuniqueid
because its p.getPersistentDataContainer()
belongs to that player
I set up this
but it's not outputting to that directory
you must specify an execution
it works in my other plguins like that
shade?
you sent a screenshot of the maven-shade-plugin without any executions
it will not do anything
what are you trying to achieve?
i just realised in my old plugins it uses maven-jar-plugin
not shade
i didnt set it to shade that was the default
shade and jar are two totally different plugins
anyway, yeah, the maven-jar-plugin is the correct one to change the output dir
I just use this thing
idk why it used shade
:/
well it works now
so im happy
which one is better way to save data?
using internal variable like HashMap and saving it into yml file in every 5 minutes (every fixed period)
or
every time access to yml file and change some of data.
So long as saving is async it makes no difference
so... it's same speed?
File access is slow, so do it async
hmm.. how can i use async?
Scheduler or Futures
hello
I remember that in snapshot 20w14infinity nether portal frames could have different colours
Is it possible in 1.19? (no datapack, no texture pack)
Like is it possible (from plugin) to place down a nether portal block in specific colour?
Or does it necessarily need a texture/data pack?
Cuz 20w14infinity didn't store all the portal blocks as texture i guess but just generated a random colour
It probably did that client side though
So I doubt there's a way for the server to tell the client what color to render it as.
You'd have to do some NMS digging to really see how they did it and then check if they left code (which I doubt) in 1.19
oki
yeah but my problem is now that the default server packets that get send to the player overrides my sended block damage progress
in a bungeecord plugin ServerConnectedEvent event, how can I get the size of the players on the server that the event occurred on
how to create custom block using the NMS?
how do i get sound from block data
What do you mean and why do you want to use NMS for them?
Probably easier that way with world gen and all
declaration: package: org.bukkit.block.data, interface: BlockData
Ah perhaps
create custom block
There are some open source projects down below, check out how they do it
https://septicuss.notion.site/Blocks-d2cdd4b22d9f495193d5759030ed749c
But if you're going for the world gen, you should just simply set the blockdata while generating the world
What version of MC is that for? Modern versions have access to custom model data
Custom model data is for items
And blocks
Nope
Yup
Otherwise all those complicated plugins wouldn't exist
Mind showing where I can set a placed blocks custom model data?
Yeah custom model data only exists for items not blocks
^
Generally you have to use like block states for custom blocks
"custom blocks" are usually done through mushroom blocks or noteblocks with "not avilable in vanilla" blockstates
As explained here
I thought they did something. Huh I'll have to look through my bookmarks
Hey man I want you to be right LMAO
Trueee
I wish they had custom model data for blocks
Haha
Oh it's the item frame method. I guess I didn't look too much into it. My bad
same
actually you can add Custom Model Data to blocks with modding
Well modding just goes over the point of it doesn't it
what is better?
If you're like me and making a modded server mods are better than the item frame method
Having multiple Runnable Anonymous Inner Classes or making a outer class which extends Runnable and then doing it from the class
Depends if you're reusing the code a lot. If you are then making a class is superior
At some point I use it a lot
Get a larger audience if they don't have to download external required mods by themselves / through a launcher. Resource packs are just a < 2mb download on join and you already get so much content.
pass it a single executor not teh whole pool
Wym get a larger audience lol. Some of the interest is from it being modded
Means that a user can join / find out your server by just pasting the IP in and voila
For mods peeps have to download extra stuff which raises the bar for potentially joining
Can't argue with this tbh
Ah that's not an issue per-se. The lobby is vanilla and explains everything
They can decide from there
Well that's more like a workaround
I mean mods allow a unique experience you can't experience in vanilla
Can you tell me what type of click event to use, that when clicked, a new message was sent from the plugin to the player?
I don't understand your message? What's being clicked
how can i put an actionbar in a game ?
Like what? I can be certain that nearly any mod mentioned could be recreated to some extent in vanilla
Example
Custom player animations. Tonnes of custom blocks with custom break sounds. Custom GUIs with easy scrollable UIs
It's a clicked message that sends a command in chat
Yeah, thanks
Custom player animations.
https://www.youtube.com/watch?v=_4-pdYOqfPg
And ItemsAdder for ex adds player emotes
Tonnes of custom blocks with custom break sounds.
This is the most basic thing. Up to like a 1000+ custom blocks can be added through block states and infinite custom sounds.
Custom GUIs with easy scrollable UIs
Yeah this ones a little of a workaround, but Mineclub for example has you click those arrows on the right (it's a dynamic scroll thingy)
Yeah but it'd be a nightmare to manage the state for all that
It looks a lot more natural when modded
But the upside being being
- No external downloads
- Under 10 mb resource pack
- Easier to join the server and experience the stuff right away
Again, that's not an issue
Well yeah but thats just nitpicking. Have you seen the GUIs on MCC Island?
Not nitpicking. It's one of many reasons
For which you're ready to sacrifice hundreds of potential players?
There's a reason why all large upcoming servers are using these mechanics
and not mods
Like I said it's not an issue
Rarely has anyone mentioned modded as being a reason they'd rather not play
What's the most popular modded server?
No clue. Doesn't matter either
Aight
We have 7000 people in our discord with 0 advertising
That's nice
does anyone know a good CLI argument parser for java, similar to getopts in bash?
I agree with you, modding is trash
Doesn't apache commons have something for that?
idk, what's it called? 😄
Not really trash, has it's own use cases. It's just that there's a higher bar to access a modded server as opposed to a vanilla server.
how do i get all the blocks in an area when i have the leftMark and the rightMark
sorta like worldedit
You loop them
hello, I'm creating a core for a skyblock .... I want to create an island that is not already occupied by another island, what do you recommend? use external plugins? if so, which ones?
How do I change the name above a player's head in a Spigot plugin?
PlayerProfile and NMS/packets
Recommend for what? Setting the island? Pasting the schematics?
pasting the schematic
with these API can I avoid the two islands being close?
thats upto your code
Hi everyone! I have a question here I have like int c = 6
and I need in if what if what if the number of diamonds is equal to c then some actions take place then how to find out how many diamonds the player has in the inventory
might use a for loop cuz idk if this is what youre looking for
hey
this is prob super basic
but um
what does
(int i = 0; i < args.length; i++) this mean
in particalarly
what does ++ do ?
oh
so
Can you give me an example like where its used
because i see it used a lot with args/strings and idk if i will need one for my custom enchants plugin
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
kk tysm
there's a much easier way
just in case you're not using a command, instead the asyncchat event
String.join args
then split the message like this:
message.split("sendmessage");
this will return an array, just do ur checks then get the [1] index in the array
itll return everything after /sendmessage
hi, how do u check if the itemstack u dropped is a shulkerbox with an item inside?
and in Item from?
actually nvm i meant Item not itemstack
bruh there must be a way
did you bother searching?
