#help-development
1 messages Β· Page 1962 of 1
/playsound minecraft:music_disc.otherside ambient <p> ~50 ~70 ~20 0.2
/stopsound <p>
#help-server - Asking about plugins
#help-development - asking for plugin development support
is there anyway to set skullOwner with different texture?
like skullOwner = md5
but texture will be mine
Trying to set an existing skull texture to another one?
yes
Have you try searching like this on google "SpigotMC set existing skull texture to another texture"
When i cannot do it myself, I search it like that on google. And if i dont find any way i come to spigot
I already did. there are a lot of threads about "how to set skull texture" but no help about existing texture
anyone knows the way to fix this sql problems?
What library are you using?
HikariCP
Opinions?
It has an error
That why
It looks like Spigot-Jar doesnt contain that method
I will take a look at the NetworkManager class
Did you remap
Well first, what version
1.8.8
Oh f
And i check the obfuscated code and didnt find something that looks like returning the version
Because i know that for joining a server the server must know the version, so tge version its sent
ViaVersion has an API for this
mm yes
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "com.woolmc.basic.Basic.getCommand(String)" is null
i beg to differ
frucking java
also dont hate on me for defining plugin but still using this
i needed that to execute .reloadconfig
Is it in your plugin.yml
Thatβs definitely causing it
π€ π³οΈ
reload or basicreload?
im too lazy to code in /basic and have reload be a subcommand of it
reload is the class
basicreload is the command
you register command "basicreload" onEnable
but said a command "reload" in plugin.yml
oh
brain.exe stopped responding
there we are
now its working
your help is appreciated
Hi. I use an ubuntu 20.04 server.
I've been told to host the minecraft server using a separate user account - Not root
I was wondering how this actually improves security...?
Also, I run a website using caddy. I don't know what 'user' caddy is running under, if it is even running under a user.
lets say someone were to use a backdoored plugin to gain access to your machine
although the chances are unlikely
there is always possibilities
they wont have full root access
just the access you give the separate account on your machone
Hey guys, I got a folder in my resources folder that contains a lot of files. How would I go about saving the entire folder into the plugin's data folder without having to manually use saveResource() on each of them?
an example of how to load/save your own files π
oh that method is just to update a config in moving data from the config to its own file
that highlighted section is the load method
that is the save method for the file
yeah the load method I showed does that too π
and then once you have that you can do this https://github.com/frostalf/ServerTutorial/blob/master/ServerTutorial/src/main/java/pw/hwk/tutorial/data/DataLoading.java#L41-L52
keep in mind when modifying your files, they are modified in memory only until you call the save() method
well the last link shows you how to do it, once you have a reference for the file you can do getString() or setString()
that project is open source, feel free to use it as a reference π
it comes from yamlconfiguration()
getData() just returns that object from the save/load class
well if nickData() is a yamlconfiguration object, then that would work and would set nickreq_list: args[1] in whatever yaml file
generally you want to use the specific set though for the type of data
so setString() is what most use
maybe it changed π€
set should work, now to see it in the file, you need to call the save() method
I am making a headdrop plugin which drop mob head on death. but problem is when someone place and break the head, it became default name(Player's Head). is there any way to fix it?
like with setOwner but with different texture or something else?
Yeah that looks right, however you shouldn't need to specify the file to save
unless that is how you setup your method
yep going to need to keep track of them player heads so you can always reset them and tag the item
File nickreq = new File(plugin.getDataFolder(), "nickreq.yml");
YamlConfiguration nickData = YamlConfiguration.loadConfiguration(nickreq);
the way I have it is the better way π
it ensures you always grabbing the file from the plugin's folder
well the way you are doing the path is correct technically, but the more appropriate way is what I have shown. It removes any ambiguity in the path. Anyways I changed your object from FileConfiguration to YamlConfiguration instead
but with those changes it should work
the reason I keep my load/save methods in a separate class is because you need to ensure you retain the reference to your file
easier to ensure that when you have a whole class dedicated for that π
They are both files yes, but FileConfiguration is the base class and YamlConfiguration extends it, but it is more precise in that it knows it is a yaml file and not just a config file
Well it is a plugin that I need to update, I just use it as a teaching tool π
one of the best parts of it I think is that it makes use of the conversation API which I think gets under utilized in the bukkit/spigot api lol
what do you mean?
frostalf pls check dm
Ah I see now, this is why I use a caching mechanism
to keep all the configs in memory so that they can be manipulated without the data actually changing in the file
Just keep your config in memory using a custom class and then either implement a timer to save what is in memory every so often or whenever you want it to happen
oh I see what you mean now lmao
you need to get and hold the old data
and then add it all back
to add to it
not if you add the old data plus new data together π
Get the list, add your stuff, then re-set it
plsπ₯²
It's a List, right?
List<String> nicknames = getconfig().getList("Nicknames");
nicknames.add("new nickname");
getConfig.set("Nicknames", nicknames);
getconfig().save();
if you get it as a string that is fine too
you just can run that string through a buffer
and then you can just append to it
StringBuilder
works for that
I made this. but it only work for latest placed head
What are you even trying to do
that is because you created your hashmap that is suppose to keep track of the heads in the event class
so the only thing that gets added to it is anything recent
nickData.getStringList
instead of getConfig() it is nickData()
so what to do? that is the only things came in my brain ;-;
Yes because your HashMap can only have unique keys
Use a List of Locations instead
alright
Up, still stuck on it :S
You're adding it to the list and afterwards you need to save it by calling set and then save
How are your files named?
They are images, basically items/material_name.png
Subfolder items contains all of them, and I don't wanna do saveResource on each and every one of them
Trying to find a way to maybe iterate over the files in the resources/items
anyone have an idea how to get a chest's contents in EntityExplodeEvent
Oh i think i got something for that in my lib. One moment.
declaration: package: org.bukkit.entity, interface: Player
note that this is limited to a single block iirc
Does it have to be done as player
I don't want w player to simulate breaking it
π₯²
you need a player because that player is the receiver of the fake packet
Can I use nonexisting player
what are you talking about. This method will show a fake block destruction progress to the specific player you called the method on
sure if you just run this method on all those players ?
Gotcha thanks
tho again, this method is limited to a single block
generally, not the most reliable
I'm working on a bungeecord plugin, I need to play a sound to a player what is the quickest and easiest way to do this?
he is using bungee btw
^
Can you further explain? This is like my first time working with bungeecord
he wants to handle it on bungeeside
yeah
You can also just not send a packet but simply use Spigots API for that. Which basically sends a packet in the impl.
Oh
Bungee
yeah but there is no impl in bungee
i do know that
Why would he want to do that on bungee? It has no context on locations or anything Player related.
Thats the issue, I want to get the sound the player.
is there a plugin that disable elytra?
Tons probably. But wrong channel.
π€·
Sentence makes no sense to me. What are you trying to do?
sad
There is a NamedPacketPlayOut thing
i cant find one
but im not quite sure about the impl
https://www.spigotmc.org/resources/no-elytra.34781/
First thing that came up when searching
In a bungeecord plugin which goes on the proxy is a event that checks the players message, then plays a sound. But I cant get player data from proxy so I cant play a sound. Is that better worded?
This might be an xy problem
Yeah that makes more sense.
Then what you want is the Protocolize library. Pretty much ProtocolLib for BungeeCord. This ensures cross version compatability.
that one did not work
I've spent the last hour looking for a fix, ty lol.
i try that one
Lets hope me and my incompetents can get it to work. Thanks again.
I mean you can always look at the protocol specifications and build a packet with bytes by yourself.
But usually you should avoid such workloads (like sending sounds and doing anything non proxy related) on bungeecord.
Yeah I will try to avoid it in the future, but its only a small plugin so should cause to much harm.
okay so I looked into the hashmap compute method after being shown it today
a much better way to write this, which adds 1 to each entityType key or sets it to 1 if null
for(Entity e : c.getEntities()) {
EntityType k = e.getType(); // k is EntityType in entityMap
if(entityMap.containsKey(k)) {
entityMap.put(k, entityMap.get(k) + 1); // Sets EntityType key to previous value +1
} else {
entityMap.put(k, 1); // Sets amount of EntityType to 1
}
}```
would be ```java
for(Entity e : c.getEntities()) {
entityMap.compute(e.getType(), (k, v) -> (v != null) ? v += 1 : v = 1);
}
I think?
.
that should probably use Map#merge
compute is rather ugly as you have to do the null check yourself
for (final Entity entity : entities) {
entityTypeCount.merge(entity.getType(), 1, Integer::sum);
}
gotcha, the documentation confused me
the implementation of merge in HashMap goes brr
fr fr
is it possible for a plugin to do other plugin's commands? Such as multiverse's commands
you should use api's
Yes. But you should prefer using their API
most plugins provide an API you can develop against to fetch its data
i mean the not api
So you wanna hack your way through?
why would you not want to use the API o.O π
how would you use the api
OH ok
nothing nothing
its fine
sorry
Not gonna support that when there is a well documented api present. But search for dispatchCommand. Will lead to bugs and you might need to implement your own Player interface.
https://gist.github.com/Flo0/196276deb71db2133080cc3a6e472126
Couldnt get my gradle to work properly. Here it is.
copyResourceDirectory(final JarFile source, final String path, final File target)
copies a directory from within a jar to a file location.
In my plugin, I want to list something and list a list with TabCompletion.
My list looks like this:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]
But when I show it on TabCompletion it looks like this:
What can I do so that its sorted?
not sure if minecraft respects the order
its sorted
the 2, 3, 4 etc are down
1 is lower then 2 ^^
How?
10, 11, 12, etc, 20, 21, 22 etc
dunno if Collections#sort would work
think mc handles the sorting itself
I already sorted it
You cannot sort it yourself
The client does it
Is there a way to sort it numeric?
well you have already been told that the client actually sorts them the way it does
and it considers even numbers to be strings whilst sorting I believe
Ok
Hi guys, how can i remove the possibility to get 9 ingots from a block? Basically i have a custom block named "compact gold block" thats made using 32*5 gold blocks. But when i put this item in the crafting grid, it returns 9 ingots which i don't want
PrepareItemCraftEvent -> Check the matrix -> if it contains your custom block then set the result to null.
*If you want to prevent crafting with it all together.
Otherwise you would want to check the recipe key
im gettin angry at my code
Im using gradle to build my jar, it builds it in /gradle/libs, how can i make it automatically go into my plugins folder? Thanks.
How is this all in one plugin called again that also provides a Economy.class service?
I need to quickly test a Vault impl and forgot the plugins name because i usually dont use any plugins
i thought you were talking about vault itself
Essentials
Use a symlink
a what
a symbolic link
you create it in your servers directory
and it points to your build/lib/output-jar-1.0.0.jar
Why cant gradle just build to different directories?
Thats what I asked
create a copy task then /shrug
Β―_(γ)_/Β―
Unresolved reference: copyDocs
are you just copy pasting things ?
What are you talking about ?
you'll have to throw some brain meat at the docs
Symlink is an OS feature, not gradle
Why use an OS feature when you can do it in gradle itself
It's easier
Its building into /build/libs why is there no easy way to change that in gradle
It is so stupid
there literally is :/
It is not easy, i been looking on google and cant find anything about it
create a copy task that depends on your build task
Yeah i have no clue how to do that
which takes the output of the build task (your jar file) and copies it to your server home
OS features are generally better
CopyDocs unresolved reference
How!!!!!!!!!!!!
google symlink creation ?
create a symlink in your servers plugin folder
that point to the jar you are building on your local PC
do you need the filename and jar file
to be linked
will have to recreate the symlink when you update however
how can i create a yaml file?
by creating a new file first
File(file).createNewFile();
check if it exists
or use plugin.saveResource if it is included in your jar (with default or something)
then load it with YamlConfiguration.loadConfiguration(file) to get a FileConfiguration object to work with
is there no way to check if a file is empty tho?
isEmpty() probably
if you change the original jar file the symlink gets broken
nah there is no method like that lemme look it up
oh ty
ah there is a File#length == 0
fileconfig.getString("bla-bla-bla") or smth
declaration: package: org.bukkit.configuration.file, class: FileConfiguration
FileConfiguration#get(String key)
whiwh return an object ._.
oh so the same as the default config of the plugin
yup
ty
how can i get an already created file? I don't want to make one, i'm using a command to read values from a specific file
@tender shard and I are having e-sex in the vc
Thats a very general Java question.
Do you want to use the configuration api of spigot for that or just read a general File?
File someFile = new File(plugin.getDataFolder(), "somefile.yaml");
YamlConfiguration someYaml = YamlConfiguration.loadConfiguration(someFile);
bruh i changed a sysout line and suddenly my things work
its .yml
dunno if it would matter
yeah tysm
try to run code at specific time at the day
DateFormat dateFormatter = new SimpleDateFormat("HH:mm:ss");
Date date = null;
try {
date = dateFormatter .parse("20:34:30");
} catch (ParseException e) {e.printStackTrace();}
timer.schedule(new MyTimeTask(), date);
}
private static class MyTimeTask extends TimerTask
{
public void run()
{
Bukkit.broadcastMessage("Banana is Big");
}
}```
but nothing happens
am I doing something wrong
when does the player object knows that it has played before? i am checking if Player#hasPlayedBefore and it returns true when i joined for the second time?
causing issues with my database
i think it gets if this player has data in the usercache.json
he is in there
player data files
and they get saved within some time i guess?
so not specifically when the player quits the game?
it gets saved when the player quits as well as when the world saves
and it should return true when you join a second time since you have played before
well show code
lemme commit to github and send it
https://github.com/FourteenBrush/MagmaBuildNetworkReloaded/blob/430ae12c47303eb65875e64fe037a44156c963fc/src/main/java/me/fourteendoggo/MagmaBuildNetworkReloaded/listeners/PlayerListener.java#L32
it sends "handling first join" for the third time now
<player>.dat files are used by servers to store the state of individual players. The format is also used within level.dat files to store the state of the singleplayer player, which overrides any <player>.dat files with the same name as the singleplayer player. These files are in NBT format.
and then im getting this error on my database
https://paste.helpch.at/ceyemekadu.sql
im throwing the runtime exception myself but im talking about the sql exception
UUID already in the table?
I'd use a ScheduledExecutorService (in combo with something persistent to save the date [time stamp] in case of arbitrary shutdowns)
Can anyone tell me please how to update spigot with IntelliJ?
Define "update spigot"
Do you want to fork it?
im doing that?
Let mcdev create a clean maven project and copy your src folder into the new project. Intellij can handle that.
problem is that Player#hasPlayedBefore seems to return false instead of true
i guess the player data not being saved immediately
isn't that what you been wanting?
Which event are you testing the played before?
test in join
Does anyone know what happened to the GameProfiles?
database stuff in login hmh ill see
public double calculateRequiredXPToNextLevel (int currentLevel) {
int startingXP = (int) plugin.getConfig().get("StartingXP");
double increment = (double) 1 + (plugin.getConfig().get("FarmLevelIncrement") / 100);
double totalXP = startingXP;
for (int i = 0; i < currentLevel; i++) {
totalXP *= increment;
}
return totalXP;
}
This function gives the following error: Operator '/' cannot be applied to 'java.lang.Object', 'int' --> At the "double increment..." line.
hey im trying to make a vector for my fireball explosion, but its quite off the default fireball knockback. I just want to increase the knockback and not completely change it
any ideas on how to do that
well it seems to work
i was using login because it happens earlier so i'd have more time to do database stuff
Hi guys, i'm sending a PacketPlayOutPlayerListHeaderFooter packet to a player, the point is that i want it to update. i tried using a runnable but it doesn't work
anyone?
anyways is it useful to explicitly clear a reference? im having an user class which holds a weakreference to the player itsis bound to, when they logout im intending to clear the reference
might be done automatically but thats why im asking
you can make objects null to be GC'ed faster. Not a bad thing to really do, but also really not necessary unless you trying to go for those micro optimizations lol
nah ok
and something else...
i have a vanish command and when the player is vanished, he has fly enabled. But when they switch to survival while still vanished, the fly dissapears and im trying to avoid that but this doesnt seem to work, the debug message gets printed anyway
maybe delaying by one tick would be somethign?
meh
its ugly to call event.getPlayer() 3 times
π€
π
lemme see if it works
eyy works
lemme change 2 ticks to one tick lmao it looks like im falling a bit
i would
creates the template pom.xml, plugin.yml, main class and little other things
lmao noobs
well personally i use gradle init instead
saving time is just making your own template and copying it when you need a new plugin lol :0
why won't they add gradle kotlin dsl support???
they?
idk maybe him
oh yeah
i thought there are few ppl
@CommandOptions(name = "menu")
public class GameMenuCommand extends CustomCommand {
@Override
protected boolean execute(Player player, String[] args) {
PlayerUtilitiesKt.sendMessage(player, "&eOpening the game menu");
GameMenuInventory gameMenu = new GameMenuInventory();
player.openInventory(gameMenu.getInventory());
return true;
}
}
public abstract class CustomCommand implements CommandExecutor {
private final CommandOptions information;
public CustomCommand() {
this.information = getClass().getDeclaredAnnotation(CommandOptions.class);
}
// Stuff
public String name() {
return information.name();
}
}
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface CommandOptions {
String name();
String permission() default "none";
int argsRequired() default 0;
}
The error happens when the plugin starts and tells me that customcommand name is null, even though it is not
java.lang.NullPointerException: null
at me.quzack.survival.commands.CustomCommand.name(CustomCommand.java:33) ~[?:?]
at me.quzack.survival.commands.CommandManager.<init>(CommandManager.java:17) ~[?:?]
at me.quzack.survival.GameMain.onEnable(GameMain.kt:18) ~[?:?]
But all of it should already be given
on CustomCommand
and it is null
try using getAnnotation
not getDeclaredAnnotation
or maybe you event cant
idk
public CommandManager(GameMain plugin) {
String directory = this.getClass().getPackage().getName();
Reflections reflections = new Reflections(directory + ".implementation");
for(Class<? extends CustomCommand> file : reflections.getSubTypesOf(CustomCommand.class)) {
try {
CustomCommand command = file.getDeclaredConstructor().newInstance();
Objects.requireNonNull(plugin.getCommand(command.name())).setExecutor(command);
}catch(NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException exception) {
exception.printStackTrace();
}
This is how it's registered
why ping
can u send full log?
i feel it's not all
java.lang.NullPointerException: null
at me.quzack.survival.commands.CustomCommand.name(CustomCommand.java:33) ~[?:?]
at me.quzack.survival.commands.CommandManager.<init>(CommandManager.java:17) ~[?:?]
at me.quzack.survival.GameMain.onEnable(GameMain.kt:18) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:518) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:432) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.reload(CraftServer.java:965) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.Bukkit.reload(Bukkit.java:726) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:54) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchCommand(CraftServer.java:826) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.PlayerConnection.handleCommand(PlayerConnection.java:2185) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.PlayerConnection.c(PlayerConnection.java:2000) ~```
[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.PlayerConnection.a(PlayerConnection.java:1953) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.PacketPlayInChat.a(PacketPlayInChat.java:49) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.PacketPlayInChat.a(PacketPlayInChat.java:7) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.PlayerConnectionUtils.lambda$ensureMainThread$1(PlayerConnectionUtils.java:35) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.TickTask.run(SourceFile:18) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:136) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:109) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.MinecraftServer.bb(MinecraftServer.java:1271) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.MinecraftServer.executeNext(MinecraftServer.java:1264) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:119) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.MinecraftServer.sleepForTick(MinecraftServer.java:1225) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1139) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-794]
at java.lang.Thread.run(Thread.java:829) [?:?]
?paste bro
that makes me feel that information is null, can you try logging if it's null or not in constructor?
not the name
but information
Ok
.<init>(CommandManager.java:17) -> Your constructor
.name(CustomCommand.java:33) -> the line where the NPE happened
Show this line pls
ig it is
i made a code where I did for when a player looks at an armor stand another armor stand on top rotating around it, the problem is that, from the moment the armor stand appears it doesn't rotate in the player's position, unless that you move too close to her
he dont rotate to my direction when spawn
?paste
Guys, does anyone know how I can get all chunks from point A to point B
Example:
firstLocation(...).to(second Location(...))
you can use vectors to achieve that
Edited the text
I need to find chunks
well i think still vectors is your best option
get all blocks between the locations with a ray trace. then add all Chunks from each Block to a Set
fun getChunks(first: Chunk, radius: Int): List<Chunk> {
val chunks: MutableList<Chunk> = ArrayList()
for (x in first.x - radius..first.x + radius) {
for (z in first.x - radius..first.z + radius) {
val chunk = first.world.getChunkAt(x, z)
if(chunks.contains(chunk)) continue
chunks.add(chunk)
server.broadcast(Component.text("Chunks: ${chunks.size}"))
}
}
return chunks
}
I have this code
I found such an example on the form of a spigot
this appears to get chunks in a radius, which is not what you want
thats not even close to what you want
But I need to find from one point to another. I'm really really bad at math
Maybe someone has an example or there is some kind of library that does this*?
thx
Hey, what's the fastest way to iterate over a lot of blocks without lag?
actually ```java
public static List<Block> getBlocksInBetween(final Location from, final Location to) {
Preconditions.checkArgument(from.getWorld() != null && from.getWorld().equals(to.getWorld()));
final World world = from.getWorld();
final Vector start = from.toVector();
final Vector direction = to.toVector().subtract(from.toVector());
final int distance = (int) Math.floor(direction.length());
final double yOffset = 0;
final BlockIterator blockIterator = new BlockIterator(world, start, direction, yOffset, distance);
final ArrayList<Block> blockList = new ArrayList<>();
blockIterator.forEachRemaining(blockList::add);
return blockList;
}```
that gets you a List of Blocks. Then all you need to is grab all the Chunks
Async if you are only reading
I'm trying to find blocks within a pasted schematic area
if you are only reading still Async
I've been told fawe has some methods to do it but I can't import it due to them only using java 17 now
You didn't misunderstand me a bit, I want to get all the chunks from point A to point B in order to add them to the ticket later (so that they are not disable)
And you're not for me
hey how would i create a scheduler that will run code after an event has taken place? i cant seem to put it outside the event
sry
I did understand. I gave you the code you need
or is there another way other than using bukkitscheduler/runnable\
?scheduling
I wish I could work out how to import fawe because that has what I need :/
then why arent you using java 17
Was about to ask ^^
I support 1.8-1.18
Or you just drop all that legacy nonsense
yea
I paid someone to add that support I'm not dropping it quickly lol
well regardless, you can still use java 17
What I'd the user only has java 8 installed?
is a PlayerQuitEvent fired for all players when the server shutdown?
Yes, the people using the plugin if they got java 8 installed will it still work
a plugin is server side
yea
it has nothing to do with the users java version
Hm
If its gracefully shut down then yes
I have my project moduled it's a shame I can't set only 1 part of it to java 17 lol
you can
if im returning a completablefuture somewhere and the excptionally method is handled, will future.whenComplete(result, throwable) -> {} ever return something notnull for the throwable?
just set teh source and target on the module
It will
hOw can I give the player a random spawner (a spawner that spawns a random entity)
which exceptions will it catch?
like when do they happen? not the ones that could happen when the result is calculated?
or just interupptedexceptions
It will catch exceptions during completion
doesn't take the result ?
so you have to handle one of them?
whenComplete is basically your all handeling end of a future
ye
where you can handle either the exception or the result
exceptionally is just an error handler
which will still return a result when you handle that?
Well that exception handler can basically convert the exception into a result again
iirc
ah ye you can specify a result
I mean it is what your function returns
How to check if a player kills an entity
listen to the death event and check the killer
ok
``if(Bukkit.getServer().getOnlinePlayers().contains(Bukkit.getPlayerExact(args[0]))){ //Sender send request
Player tradeWith = Bukkit.getPlayer(args[0]);
player.sendMessage(cPrefix + ChatColor.GREEN + "Vous avez envoyΓ© une demande d'Γ©change Γ : " + tradeWith.getName());
requestTrade.put(tradeWith,player);
tradeWith.sendMessage(cPrefix + ChatColor.GREEN + player.getName() + " vous envoie une demande d'Γ©change !");
}
else if(args[0].equalsIgnoreCase("accept")){ //Target accept trade
if(requestTrade.containsKey(player)){
Player tradeWith = requestTrade.get(player);
if(Bukkit.getOnlinePlayers().contains(tradeWith)){
Inventory tradeInv = Bukkit.createInventory(null,54,">>Trade");
player.openInventory(tradeInv);
tradeWith.openInventory(tradeInv);
requestTrade.remove(player);
}else{
player.sendMessage(cPrefix + "Ce joueur n'est pas en ligne !");
requestTrade.remove(player);
}
}else{
player.sendMessage(cPrefix + ChatColor.RED + "Aucune demande en attente !");
}
}
``
For traderequests, firendrequests, clanrelations etc. you should use a graph.
Otherwise its really hard to maintain relations of that kind
This is how trade requests would look in a graph
like it triggers the error when there is no sender as the key for requesttrade
I'm looking forward to it
And you should def decouple your logic from your command.
A command should only be used to parse user input and resolve contexts.
The actual logic should be done in other classes.
like I only check permission and instance of sender and I execute a void from another class (containing the logic)
?
Basically
Ok yeah I see
This way if you want to have the same functionality from within a GUI or in a clicked message or for an API they all can just call the same method.
This is close to my limit to how big a sub command gets. 5 lines is a soft limit for me. 3 is nice.
Which framework is that
whoa
acf or cloud?
or ur own?
ACF. I understand it when you hate it but ive put hundreds of hours into it until i understood every aspect. Not user friendly.
But i refuse to switch to anything else because ive put too much time into understanding it.
lol
wait this is not possible?
try with parameter
?
nvm
ooooh
lol
valueOf
The type is resolved by the context. So String r = get(); or String r = YourClass.<String>get();
But latter is obsolete
yeah i know the latter is obsolete
thank god for final var r = this.<String>get();
basically you're using it as get(Object) -> Object
weird
mye
but you can just have a hashmap, with a hashset of uuids and a uuid
so that the uuid is the invited and the set is the inviters
since like, im not sure if u want ur players to be able to send more than one trade request to a person
Sure but handling that bidirectional data can be tricky
using a graph will let u send multiple requests to multiple people
Hm?
and you only want to receive multiple requests, not send them in bulk
or am i wrong? I didnt really use graphs
You can always limit the nodes and kill others if you add a new one.
And for friend requests you def want to be able to send as many as you like.
Trade requests are a bit different. I think a normal mapping approach is just fine.
I would just prefer a graph.
Gotta learn graphs then ig
I've realized that the DataInputStream class (https://github.com/openjdk/jdk18/blob/master/src/java.base/share/classes/java/io/DataInputStream.java#L423) often uses + where I would think that | is more appropriate. Does this have a reason or is it more of a question of choice? If latter, does it impact performance?
for the graph you told me to work on I have to set one edge and 2 vertices for the 2 players ?
btw in ACF,
@CommandAlias("group")
public class GroupCommand extends BaseCommand {
@Subcommand("invite")
@CommandAlias("ginvite")
public void onGroupInvite(Player player, OnlinePlayer playerToInvite) { }
}
how does it know the argument after "invite" is what we want (aka onlineplayer) and how does it convert the arg to onlineplayer, what if i had another class?
Maybe the compiler optimizes that. + and | are really similar. Maybe there is a reason regarding the sign bit. But i couldnt dive into that atm. Too tiered XD
I guess I'll ask the openjdk irc
Please forward the answer if you get one
I will
i assume it looks through the parameters of the method and lists them, and then when parsing uses some kind of parser which converts a string to an offline player
But how does it ake it a player
what if i had a class I created, how would it know the logic and convert it
using a parsing function
so it checks for each possible class and do that??
only the classes you register
wdym
as commands
can some1 help with that?
and what even is this:
@Subcommand("pset")
@CommandCompletion("@allplayers:30 @flags @flagstates")
public void onResFlagPSet(Player player, @Flags("admin") Residence res, EmpireUser[] users, String flag, @Values("@flagstates") String state) {
res.getPermissions().setPlayerFlag(player, Stream.of(users).map(EmpireUser::getName).collect(Collectors.joining(",")), flag, state, resadmin, true);
}
you have to register your command classes right
ye
yeah so when you do that it looks through the methods and registers them as subcommands
Ok but thats not my question
there should be a list of possible objects u can use in ur para
param
what if the class I use has a special way of parsing from a string
how would it somehow parse it
register a parser probably
i dont know how acf works
but i assume thats how it would wokr
This is then done using so called context resolvers
confusing
Its not easy to get a grasp of. Also took me a while. But its really powerful.
Let's see if we are getting a response. The irc channel only has 15 clients connected to it which appears to be a really low number for such a huge project
private final Map<String, Clan> clanMap = new HashMap<>();
public void register(BukkitCommandManager commandManager) {
commandManager.getCommandCompletions().registerCompletion("@Clans", context -> new ArrayList<>(this.clanMap.keySet()));
commandManager.getCommandContexts().registerContext(Clan.class, context -> clanMap.get(context.popFirstArg()));
}
Basically this
Made up example
oh so it accepts anything from the keyset, and passes it from the value in the map?
Then your command could look like this:
@Subcommand("edit clan")
@CommandCompletion("@Clan")
public void onClanEdit(Player player, @Values("@Clan") Clan clan) {
clan.openEdit(player);
}
whats @Values(@Clan) doing
@Values is a preliminary filter. It only accepts values provided by the completion.
damn thats really cool
So if you type /clans edit clan sam but "sam" is not a valid completed argument then the player will get a message
and how can u set that message
Line 17 is the name function and the I posted the CommandManager here #help-development message
Thats a different story. You can define custom context error handler which handle the messages in a broad way.
Like Please specify one of [someclans] or define custom handlers for specific classes.
brigader isnt very intuitive imo
if else if is the best
yeah but its a good engine
especially for commands with more than 2 sub commands π
Build that pyramid
Any idea?
Cant look into reflections atm because im a bit tiered. Did you specify a retention policy so that the annotation can be retrieved on runtime?
switch (args[0]) {
case "foo" -> {
switch (args[1]) {
case "bar" -> {
switch (args[2]) {
case "am" -> {
System.out.println("ogus");
}
}
}
}
}
}
``` best way of doing it
Yes.
Yes
The retention policy was already set, Discord didn't let me send messages lol
I don't understand what the issue with this is, it did work fine a day ago
java moment
am i the only one who thinks today's annotations in frameworks and libs are a bit abused
They are a bit abused
Is there a way to send 2 actions bars like this?
resource packs
Yeah, probs resourcepacks + reserved chars
But this are 2 different texts
does it show up whenever actionbar doesnt?
Yes
And different Hight
you can modify fonts in minecraft
Just create a invis item, and set the name to the text you want to display
and make cool stuff out if nowadays
Hello, would you know what this NPE is due to, it is called when I change world and is caused when I log all the packets (making sure there are no null values in the decoder) that the server receives? PS: There is no log on the client side and just a lost connection on the server side
The coins are everytime displayed but the Other Action bar is coming later
Full stack trace
It probably is the stacktrace
There is nothing at all
titles are also a thing. And boss bars.
Just all logs of packets
You probably sent invalid packets
What spigot version?
Could you be encrypting the packets wrongly?
1.8.8
I don't send any packet
Well... update to a supported version. Ancient versions like that have unresolved bugs in them.
I just receive and log
But you need to deencrypt them so the offline mode server can work with it
If you are working with an online mode server, you need to reencrypt them as the encryption keys between client <-> logger and logger <-> server are going to be different
Basically, I get all the information that arrives on the channel (io.netty.Channel) of the player and I process it to get understandable information
oh, so no funky things on the connection side
Do you think that with an online mode server it will work?
It could be that you are accidentally consuming the bytes from the channel but I am not the expert in that matter
I receive byte and I transform it into something readable thanks to the decoder of io.netty
Could the following code cause lag and if so how can I optimize it to make it not lag? https://gist.github.com/UntouchedOdin0/58e4f525a672a141589fb71890326d38
public CommandManager(GameMain plugin) {
String directory = plugin.getClass().getPackage().getName();
Reflections reflections = new Reflections(directory + ".commands.implementation");
Can it not get the file in the package command.implementation? Probably not since it does loop through the files.I think it thinks the name is null. But it's not
Do that in async task
Would that be better?
This will not bother your main Thread
Dangerous
Dangerous how so?
Unspecified behavior. What if someone breaks blocks while you check for data?
Accessing bukkit methods from another thread is always dangerous unless its a BukkitScheduler method.
What you can do is split this task over several ticks
I mean, I just wanna loop the blocks within a region without it causing any lag to the server somehow. I would import fawe to use their systems but they expect everyone to be using a newer Java version and not everyone can support it
And why do you use a CuboidRegion? Spigot has BoundingBoxes.
I mean redlib doesn't offer BoundingBoxes.
Do your own async block editing
Hold on, it's trying to access a file that does not even exist now, I made a TestCommand file before and it's still trying to load it in
Why is it trying to register a class that doesn't even exist??
This looks interesting, just gonna be complex to do it aha. I just need to do it for looping that's all
And at worst, how could I know which packet is annoying
?
Not that I think
And do you have an alternative or another idea?
Well you could do sysouts and check guess when it happens that way, but that is a pretty bad approach given that networking is multi-threaded iirc
Uh, this happens when I change world, and in terms of packets it's mostly the chunk loading packets that are in large numbers
how should i call my class that holds are the caches?
how is your architecture set up?
smh
Would this be a cause of lag spikes? https://i.imgur.com/XZnVaK8.png
Don't forget use this
NO
Yes, it's not beautiful without
its ugly with
USE this
im going to tell about the kids in your basement
If you do not have local variables, using this is overkill outside of setters and constructors
I'd call the class <pluginname>Data
nonpersistentdata π
Though if it is only used with SQL, <pluginname>SQLCache
got multiple db implementations lol
Or just RemoteDataCache
hmh ye maybe
although that implies a bit that the cache itself is remote. AAAAAAAA
Just go back the flatfile, everything is easier here
Then you get stupid stuff like
public class UUIDIntIntConcurrentMap<V> {
@NotNull
private final ConcurrentHashMap<UUID, RegionatedIntIntToObjectMap<V>> root = new ConcurrentHashMap<>();
UUIDIntIntConcurrentMap<V> lmao
this is beautiful
(I should really just use the chunk PDC for it, but I want to have it concurrent)
ConcurrentHashMap<UUID, RegionatedIntIntToObjectMap<V>>π€
@NotNull
Well I am calling it like 9 million times every 5 seconds, so there is a reason I have this set up
nice
If I were to use boxed ints GC would be invoked every 5 secs instead of every 2 minutes
How do I provide my graph node type with Player type instead of int
Player value;
int weight;
Node(Player value, int weight){
this.value = value;
this.weight = weight;
}
}
there is a graph in Guava ?
Yes
(I'd honestly use UUIDs instead)
bruh im stupid
com.google.common.graph.Graph
a stupid question but what's graph
data structure
Uh, basically an assortment of nodes
with nodes and weighted connections
π₯±
I guess you could say that an array is a graph?
what do you ppl think is the best gui library (i suck at those lol)
Where as each element of the array is a node? Idk. However a graph can also connect multiple nodes to a single node and can connect a node to itself
InventoryGUI by phoenix616. But there a bit of a bias there because I know the dev a bit more than most other devs
incendo/Interfaces
How do i cancel end portal creation?
Without completely disabling the end
make an event listener find the EndPortalCreate event and then e.setCancelled(true);
I think
Reflections is trying to load classes that don't exist for no reason
I tried cancelling PortalCreateEvent and PlayerPortalEvent
that did not work
Only works for nether portals
in the InventoryGui library, how do you get the InventoryHolder to put in the GUI when making it
cuz it requires a holder object
and Holder requires InventoryGui
im so confused
lol
Link it?
how tho
No just link the library so I know which one it is :/
Do you know how I could use a graph for a trade plugin
like set it up put the players in and all that stuff
You can implement your own InventoryHolder
Make it null
Or that
then i cant get it via holder tho
https://wiki.phoenix616.dev/library:inventorygui:usage have you read the docs?
What?? [15:20:43 INFO]: Registering class commands.implementation.TestCommandLol this package does not exist in my project
Hm, what do yo uwant to achieve?
This is how I register my commands ```h
init {
val directory = javaClass.getPackage().name
val reflections = Reflections("$directory.implementation")
for (file in reflections.getSubTypesOf(CustomCommand::class.java)) {
try {
Bukkit.getConsoleSender().sendMessage("Registering class " + file.typeName)
val command = file.getDeclaredConstructor().newInstance()
Objects.requireNonNull(plugin.getCommand(command.name()))!!.setExecutor(command)
} catch (exception: NoSuchMethodException) {
exception.printStackTrace()
} catch (exception: IllegalAccessException) {
exception.printStackTrace()
} catch (exception: InvocationTargetException) {
exception.printStackTrace()
} catch (exception: InstantiationException) {
exception.printStackTrace()
}
}
}
It might be synthetic
*class does not exist, not the package
thats a lot of catches
What is that supposed to mean?
is this kotlin?
Yes
I have no clue what this does, so sadly I do not think that I can help here
Just beware that it may be synthetic depending on the circumstances
also what do you put for the String[] rows when making the inventorygui
(or that it is an "inner" class)
It gets all the files in package commands.implementation and loops over all of them which is a sub class of custom command
doesn't kotlin have | syntax for catch blocks?
any string you like. It can be a -z, 0 - 9, A - Z a combination of all, well anything
I don't know, right now I'm trying to fix this annoying bug
https://paste.md-5.net/tawujaxehi.cs is one example use of this lib
Hi !
I'm trying to make the spectator's tab name doesn't change itself in italic and darker.
I'm trying to do :
player.setPlayerListName(ChatColor.RESET + + player.getName());
But it still works halfway... The player's name isn't italic but it stays dark...
Do you know how to do what i'd like to do ?
ChatColor.RESET + ChatColor.WHITE + ...
(I tryed to search on forums but I didn't find the solution)
I tryed it but it didn't work too
nvm his website with examples has a completely differently-named variable for the rows section lol
tbh you might need some packet fucknuggetry
Oh
seeing whether this packet is sent would be a useful start
I've never worked with packets tbh, but I'll try π
You need to listen for packets. Should probably use ProtocolLib for that.
Okayy i'll search for this, thank you ! <3
It keeps trying to register TestCommand even though it's in a different package and it also does not exist
Ok but do you really need to scan the jar for commands? Why not just call a method with an instance.
What happens if you decompile your plugin?
Will the class show in the expected location or in another location?
depends if its obfuscated or not
I have the impression that this packet is the problem, it is the one that is triggered every time I get kicked: "PacketPlayOutMapChunk"
Make sure you dont minimize with maven or else unused classes will just be removed
this is kotlin, so likely gradle is used
I think I'll just do that
if it works that is 
last few times ive tried to use minimise it doesnt remove shit lol
is it ok to ask about server plugins setup for plotsquared, worldedit and voxelsniper in this chat?
ty
how would i make it so in InventoryGui the item depends on the player who accesses it
this gui btw
cuz it gets the player only when they click an item in the gui but it doesnt do anything like that for showing the gui
Read the docs, its not so difficult
The found tag instance cannot store Double as it is a NBTTagIntWhat does this error mean?
I keep getting it when getting the value from a pdc
It simply tells you that an int is not a double... whats the line that causes this?
And also provide the code
double currentXp = persistentDataContainer.get(key, PersistentDataType.DOUBLE);
Most of the class isn't really relevant
but this is it if it would be
How do you store the data in the pdc?
@EventHandler
public void onPlayerJoin(PlayerJoinEvent playerJoinEvent) {
Player player = playerJoinEvent.getPlayer();
PersistentDataContainer persistentDataContainer = player.getPersistentDataContainer();
NamespacedKey keyxp = new NamespacedKey(plugin, "farmingxp");
NamespacedKey keylevel = new NamespacedKey(plugin, "farmingxp");
if (!persistentDataContainer.has(keyxp, PersistentDataType.DOUBLE) && !persistentDataContainer.has(keylevel, PersistentDataType.INTEGER)) {
persistentDataContainer.set(keyxp, PersistentDataType.DOUBLE, 0.0);
persistentDataContainer.set(keylevel, PersistentDataType.INTEGER, 0);
}
}
this is the code that initiates the values
Im getting yandere vibes from your code
Also, why do you assign the same value 2 times?
Understandable
anyone have a workaround for using player in lambda
Bukkit.getOnlinesPlayer().forEach(player -> { player bla bla });
I dont see any immediate causes here. But it sounds like you store an int value somewhere and try to read it as a double later.
its for the InventoryGui api
and their weird event system thing
Damn, I keep missing these stupid errors
Oh send link please*
That was it indeed, thanks
basically making a dynamic element in https://github.com/Phoenix616/InventoryGui
What was the problem?
their docs dont really help in the example lol
What type is viewer?
Stored as int, read as double
HumanEntity?
As you said
Whats the functional interface then
wdym
It does
Thank you so much, you're a life saver! I'll study this now
Lambdas are just stateless objects, still objects (:
thats what i mean
They are objects with no instance variables and just a single concrete method
Are you going to make me read the src now?
Ok so the lambdas target is a class called Action why doesnt he just use something normal like Consumer<Player>... Now i have to find out where thats from because i dont have it in my ide π¦
Can you pls just hover over the lambda and open the target class for me?
Im assuming that "viewer" is a HumanEntity
But im not sure
yep its humanentity
so do i just cast?
Then cast it to Player
lol why is it grayed out doesnt that usually mean the cast isnt actualy being used
like it doesnt need the cast?
im confused
yep
but now its not red
it means cast isnt required
but it is
Yes. That happens if you use methods which are present in the current object already
the viewer is already player or the type the viewer is contains the method/field you want
bug ig
no, i doubt it was a bug, can you show the whole line of code
Hi, I'm trying to get the gamemode in a Player Info packet (tab) with ProtocolLib. https://wiki.vg/Protocol#Player_Info says that the gamemode is an array of VarInt. So, my code is :
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
manager.addPacketListener(new PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Play.Server.PLAYER_INFO) {
@Override
public void onPacketSending(PacketEvent event) {
PacketContainer packet = event.getPacket();
System.out.println(packet);
int[] gameMode = packet.getIntegerArrays().read(1);
System.out.println(gameMode.toString());
}
});
But I get this error :
No field with type [i exists in class PacketPlayOutPlayerInfo
I really don't understand...
Oh I'm sorry, maybe I've just not understood the wiki
You should just get the gamemodes.
@Override
public void onPacketSending(PacketEvent event) {
PacketContainer packet = event.getPacket();
System.out.println(packet);
StructureModifier<EnumWrappers.NativeGameMode> gameModeStructureModifier = packet.getGameModes();
}
Ohhh thank you so much, I didn't see that I could do that
StructureModifier because i assumed that you want to hide if someone goes into spectator
:D Thank you !
oh darn smile beat me to it
Hi. Is Item#setPickupDelay in ticks or seconds?
^
Everything in spigot is measured in ticks
I have question long its a time format?
long is data type
Allright
Oh yeah. Actually never used conversations XD
And why long values are used on sleep(20L)?
Unix timespan is the time in milliseconds since the unix epoch
time in ms since 1970
because integer have 32 bit limit
its uhm, yeah im not a huge fan
Allright so 20L = 1 second?
technically yes
I never understand the format of L
assuming the server isnt lagging
depends on your tps
Hmn?
L is just a flag on your value
ticks per second
to mark that your inputted value is long
Wait longs arent mili-seconds format
no its literally just a number
Cuz 1000ms = 1 second
Long is just a datatype
longs are just integers. But longer
Integer largest number available to save: 2147483648
Long largest number available to save: 9223372036854775807
I would like to make pagination on my menu api
sometimes integer isnt enough
for example unix timestamp clock would stop at 2038 if the value was integer instead of long
MenuButton button1 = new MenuButton(new ItemStack(Material.BOOK), (action) -> action.getWhoClicked().sendMessage("Clicked on slot" + action.getSlot())); // Creating a button
MenuButton button2 = new MenuButton(new ItemStack(Material.ENCHANTED_BOOK), (action) -> action.getWhoClicked().sendMessage("Clicked on slot" + action.getSlot())); // Creating a button
Menu menu = new Menu("&6Menus", 9).setButton(3, button1).setButton(6, button2).build(); // Creating the menu
MenuHandler.getInstance().setup(); // Menu handler setup
MenuHandler.getInstance().register(uuid, menu); // Registering a menu
MenuHandler.getInstance().unregister(uuid); // Unregistering a menu
menu.open(player); // Opening menu to player
menu.close(player); // Forcing menu closing
Could be more simple?
If you are asking this how its works my own menu api
its not for me
Its for my library
I will be publishing
So im trying to get people opinions
Im thinking about adding pagination system. But i didnt find how to do it
Is it on github?
or a gist
wrote something similar for my previous plugin :0
Allrgith i will upload as a public repo
So your MenuButton is just a record(ItemStack, Consumer<InventoryClickEvent>)
Exactly
Yes this is inside Menu class
This was my best listener done by me. Its amazing. Its not harcoded, doesnt use ugly if-else
Then for paginations you have several options. For example a wrapper class that contains a List<Menu> and handles linking them.
I thought exactly that when i was taking a nap
i made a new inventory when i clicked a certain button and filled it with new gui items