#help-development
1 messages · Page 2246 of 1
so if i were to make them into variables of the object they would be null?
yes
k
and primitives will be 0, or false if a boolean
kinda sorta null
What are they then if not null?
they are 'nothing'
apparantly thats different from null
refer to alex explanation above i guess
Btw don't u wanna separate right wing vs leftwing?
im still working on that
Check first answer
The line will be the direction of the location of the dragon
eh i got a completely different issue right now
see my plan was to part the dragon
part here part there
but apparantly you cant remove single parts of the dragon
welp im an idiot
you still can't remove parts of that
I think you can only apply potions to LivingEntities. ComplexEntityPart is not a livingentity
yeah i suspected as much
damn
so its a modded thing
unless i want to mess with custom block models
which i really dont have the energy for
Hey, I want to filter all declared fields in a interface class that have the type Tag<Material> and I don't know how to do it, here my possible idea:
Arrays.stream(Tag.class.getDeclaredFields()).filter(tag -> //verify if tag has Tag<Material> type)
Here's the interface class: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Tag.html#PLANKS
declaration: package: org.bukkit, interface: Tag
you can't
the generic type gets erased at compile time
in the bytecode, those fields will just be "Tag" and not "Tag<Material>"
is the dragon animation handled by the server or the client?
oh, thanks
you could only get the Tag, then do getValues() and check if any of those values is instanceof Material
Okay thanks
e.g. like this (haven't tested it though)
Set<Tag<Material>> materialTags = Arrays.stream(Tag.class.getDeclaredFields()).filter(field -> {
try {
return ((Tag<?>)field.get(null)).getValues().iterator().next() instanceof Material;
} catch (Exception e) {
return false;
}
}).map(field -> {
try {
return (Tag<Material>) field.get(null);
} catch (Exception e) {
return null;
}
}).collect(Collectors.toSet());
Thank you very much
Why are you trying to list all members?
is it possible to make a plugin that stops endermen from teleporting onto bottom half slabs?
Without messing with the AI you could listen to the teleport event and cancel it for any Endermen where the location below them is half slabs. https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityTeleportEvent.html
Is it possible to have a resource pack with a custom sound file and make the plugin play that sound?
Is it possible to make a new sound id or sum so i don't have to replace current sounds?
Like how does ItemAdder do it and i seen some resource pack in 1.12 add a new song without replacing anything but not sure how it works
p.playSound(p.getLocation(), "name.of.sound.has.set.in.resourcepack", 20F, 20F); I believe
ah ok so name of sounds would be the file name?
like this minecraft:ambient.customsong.1 or just ambient.customsong.1
ill just watch a yt :P and look at docs
thanks! much appreciated
is there a way to load classes which can be accessed between plugins?
because you can access other plugins from plugins so i wondered why this was not working.
im currently using
URLClassLoader ucl = new URLClassLoader(
new URL[] { pkgCUrl },
JavaPluginLoader.class.getClassLoader()
);
// ...
Class.forName("c.pkg.PackageC", true, ucl)
.getMethod("loadPackage")
.invoke(null);
``` where `pkgCUrl` is a url to a jar file
accessing this from plugin B, throws java.lang.NoClassDefFoundError: c/pkg/PackageC
^ in B
any one could tell how to use boss bars
I got Tab plugin which uses boss bar already
I want to be sure my plugin is the one which takes
first bar positon
so like multiple boss bars
is it possible to know at which positon is my boss bar
is there any good BossBar lib
maybe if you use some reflection and craftbukkit
So psitening of my boss bar is important
but i think it is handled by the client
Because I am trying to use boss bar to display custom gui over custom font
and then all goes in trash bin if boss bar positon is in wrong place
as i said, it may be handled by the client
so you can control it
one thing you could do is to use reflection and craftbukkit and clear all bossbars and display all of them in the order you want
because the bossbar dont have a priority system
Why using multiple boss bars ? Just using the action bar is way enough
Why someone would make bossbar api in 2022
Why is a string variable I set null?
Bukkit bossbar api exists since 1.9 (2016)
Dude. You Are Genius.
And i know how to solve that problem
code
Use negative spaces font made by AmberWat on github
And it would allow you to position the font without using multiple bossbar
public class StaffCommand implements CommandExecutor {
String msg;
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if(!(sender instanceof Player)) return false;
Player player = (Player) sender;
if(!sender.hasPermission("lukaessentials.staffgui")) {
player.sendMessage(ChatColor.RED + "You can't do that!!");
}
msg = args[1];
//GUI CREATION
Inventory staffGUI = Bukkit.createInventory(player, 54, ChatColor.RED + "Staff Menu");
//GUI ITEMS
ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD);
SkullMeta playerHeadMeta = p;
player.sendMessage();
return false;
}
}
``` @golden turret
Also ascent in font.json can help you vertical align it
what is null there
not really lol
🤔
i'm still learning
?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.
ok
first you need to check if the lenght of the args is what you want
/command args0 agrs1 args2...
yeah i know, i just quickly recreated it for you because it's my friends problem not mine
and he did chec
/command args0, args.length = 1
/command args0 args1, args.length = 2
here you are getting the args1
no
and probably you are typing /command or /command agrs0
array indexes starts in 0
so 1 is the 2nd index
I know that bro
i just quickly recreated my friends issue
package ajo_29.testplugin.testplugin.commands;
import io.papermc.paper.event.player.AsyncChatEvent;
import io.papermc.paper.event.player.ChatEvent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChatEvent;
import org.jetbrains.annotations.NotNull;
public class customchat implements CommandExecutor, Listener {
String prefi;
String suffix;
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!(sender instanceof Player)) return false;
Player plr = (Player) sender;
if (args.length == 3) {
Player target = Bukkit.getPlayerExact(args[0]);
if (args[2] == "prefix") {
plr.sendMessage("ur bad");
prefi = args[2];
}
}
return false;
}
@EventHandler
public void onPlayerChat(PlayerChatEvent event) {
Player plr = event.getPlayer();
String msg = event.getMessage();
event.setCancelled(true);
Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', prefi + " " + plr.getDisplayName() + " " + msg));
}
}```
this is my friends code
he sent it to me
aaa
String prefi; is null
he's not?
actually he is
lol
but not suffix
he's not using suffix yet
2nd, probably he is chatting before running the command
so the prefix will be null
as he only initializes the variable after running the command
but it's null after running the command
does the command even work?
yes
just a question
everything works but the variable is not being set
im not seeing any agrs[1] there
and?
could you send me the full command he is typing pls
ur not helping
i found the problem
its nowhere near what u were saying
thanks for the help <3
oh
🤔
well, in the code you gave there, i did not see any args[1]
yeah because we tried that
why does it need that though
that didnt work
because what you were doing is
Ohh no i get it
is
we changed to args[2] to see if it worked
/command args0 args1 args2 but the args1 wasnt being used
yeah but args1 didnt work at first
sure
package ajo_29.testplugin.testplugin.commands;
import io.papermc.paper.event.player.AsyncChatEvent;
import io.papermc.paper.event.player.ChatEvent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChatEvent;
import org.jetbrains.annotations.NotNull;
public class customchat implements CommandExecutor, Listener {
String prefi;
String suffix;
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!(sender instanceof Player)) return false;
Player plr = (Player) sender;
if (args.length == 3) {
Player target = Bukkit.getPlayerExact(args[0]);
if (args[1].equals("prefix")) {
plr.sendMessage("ur bad");
prefi = args[2];
}
}
return false;
}
@EventHandler
public void onPlayerChat(AsyncChatEvent event) {
Player plr = event.getPlayer();
String msg = event.message().toString();
event.setCancelled(true);
Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', prefi + " " + plr.getDisplayName() + " " + msg));
}
}
is that working now?
no
yeah but it doesnt set the prefix
aaaa
ik
ik
just to be sure
print the code you are using to register the command and listener
public void onEnable() {
getServer().getPluginManager().registerEvents(new customchat(), this);
getCommand("customchat").setExecutor(new customchat());
}```
this one?
Conventions pls
you creating 2 objects
and updating the variable for only 1 of the objects
a fix for taht would be using only 1 object
by using customchat chat = new customchat();
and passing chat in the setExecutor and registerEvents
@daring egret "i know java" my ass
?
that is an advanced option
and a better one
once you learn oop and how to apply it, back to your plugin and use oop
object oriented programming
[20:49:39 INFO]: TEST dein0man TextComponentImpl{content="hello there", style=StyleImpl{obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=not_set, color=null, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}
oh
oh
u right
WizardlyBump17
how do u access the message as a raw string
because the only thing close is event.message() which doesn't work
man
event.getMessage?
doesn't exist in AsyncChatEvent
it does
?jd-s
but then why is it red and not auto-correct
but it doesn't work
thats not for asyncchatevent
which version are using
@golden turret it probably doesn't exist in AsyncChatEvent?
how do I send a string message as a player?
1.19
use AsyncPlayerChatEvent
this hurts lmao
print the event.getMessage on the ide
thanks man
I took message string, edited my targeted elements, now how do I send this string so it appears as if the player sent it?
Can someone please help me with this? I want to send a message to every player who is on the server, but not to myself. My code looks like this so far. for(Player all : Bukkit.getOnlinePlayers()) { all.sendMessage(new String(message)); }
You can let the player write something in chat
using what function
Bukkit has a broadcast method
String message = "Hi to everyone";
Bukkit.broadcastMessage(message);
I know that but then the message goes to me anyway and I don't want that.
Then do a for loop and skip yourself
How does it
Player player = ...;
player.chat("Im dirt.");
The message should go to all players who are on the server, just not to the sender
Then do that. create a for loop with a conditional statement (if) in it
How does it?
What do I have to write in the If query
(pseudo code)
For player in Bukkit.getOnlinePlayers()
If ( player is not sender )
player.sendMessage(message)
EndIf
EndFor
Continue 😋
anyon e?
does anyonem lkmwoiw
Are you depending on the other class?
any way to make this?
i have one plugin that loads the class, and i want to make it usable from another one
Thank you very much
Then do that. I dont understand what the problem is. They are both on the same jvm so you
can reflectively access every class of every plugin.
What is the actual purpose of this?
the point is dyanmically loading modules for other plugins
and i know that plugins can access other plugins
no i have
loader plugin A
user plugin B
and package C
A is supposed to load C, and then B is supposed to be able to use C
no reflection
Ooh... that will be very hard because every plugin has its own classloader
yeah but they are all parented to JavaPluginLoader.class.getClassLoader()
bump
Yes
and do you know how?
Did you make sure that plugin A loads package C after plugin B is loaded?
A is set to load: STARTUP
and the loading happens in onLoad
so its basically the first thing that happens
So even before B has any chance to load?
why isn't setInvisible imported into my plugin? I'm quite confused about the import
What version?
Do you have vault in your pom?
i add the vault on plugin lib
1.16.2
ahh yeah, i just deleted some files and it made some import from my plugin error instantly
if you really want to use 1.16.2 for whatever reason, you have to set the flag on the NMS entity. There's a field called "persistentInvisibility" (in 1.16, the name will be different) and then set the shared flag 5 to true
but how do i can change it from 1.16.2 to 1.16.5 ?
are you using maven?
yep
then change the version of your spigot dependency from 1.16.2-R0.1-SNAPSHOT to 1.16.5-R0.1-SNAPSHOT
its already 1.16.5, what
punishMenu.setItem(0, placeHolder); i know this is a stupid question but how do i set more than 1 slot with the same item? I've tried creating arrays and things
for loop and and set the same item on different indices
Does anyone know a good site for Retexturing Skull with higher resolutions?
alr its fixed now, i need to change the .iml to 1.16.5 too
thank you
actually you don't need that, unless you manually added spigot as dependency, which you should never do when using maven
ahh i see, im still dumb on maven and importing like that
Hey! I'm trying to create a plot with my own custom generator in a new void world. Ideally i would like a method like generatePlot(int chunkX, int chunkZ) which generates a plot of 4x4 chunks at the given chunks coordinates (chunkX and chunkZ) using my own ChunkGenerator. Rn, i just finished created my ChunkGenerator and i'm wondering how can i use it to create my plot?
My ChunkGenerator (screenshot) : https://media.discordapp.net/attachments/600329318559776781/991671068362280970/2022-06-29_13.45.28.png?width=1276&height=671
What i want (this is something i built as an example) : https://cdn.discordapp.com/attachments/600329318559776781/991460006748758076/2022-06-28_23.42.11.png
Maybe i can use ChunkGenerator#generateNoise(WorldInfo, Random, int, int, ChunkData) manually, but i don't know how to do that.
How to insert a string array directly in method?
Arrays.asList() ?
Hii! Im currently coding a Test Plugin, where I want to use some functions of Bungeecord but its just an Bukkit Plugin.
When i execute the CMD i get an error:
org.bukkit.command.CommandException: Unhandled exception executing command 'tpm' in plugin aosidjasdjlias v0.1
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.8.9.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot-1.8.9.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) ~[spigot-1.8.9.jar:git-Spigot-db6de12-18fbb24]``` <- Part one (to long)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [spigot-1.8.9.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot-1.8.9.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.9.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.9.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.9.jar:git-Spigot-db6de12-18fbb24]
at java.base/java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.NoClassDefFoundError: net/md_5/bungee/api/ProxyServer
at cmd.TestPermissionManager.onCommand(TestPermissionManager.java:15) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.8.9.jar:git-Spigot-db6de12-18fbb24]
... 15 more
Caused by: java.lang.ClassNotFoundException: net.md_5.bungee.api.ProxyServer
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:101) ~[spigot-1.8.9.jar:git-Spigot-db6de12-18fbb24]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86) ~[spigot-1.8.9.jar:git-Spigot-db6de12-18fbb24]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587) ~[?:?]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
at cmd.TestPermissionManager.onCommand(TestPermissionManager.java:15) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.8.9.jar:git-Spigot-db6de12-18fbb24]``` <- Part 2
Incompatible types. Found: 'java.util.List<java.lang.String>', required: 'java.lang.String[]'
String[] str = {"lore1", "lore2"};
Most games (minecraft included) use a noise algorithm. I suggest OpenSimplexNoise. It generates a double[][] (range 0.0 - 1.0) which you can tune and use as a height map
You cant use BungeeCord features on Spigot. Those are two completely different applications.
I already created and used a simplex noise algorithm. The issue is to use my ChunkGenerator manually
Array initializer is not allowed here
error
Where is this method from? It should use varargs here. Looks like a design flaw.
actually it's my method
is there still a way to use them?
Implement the
ChunkGenerator#generateNoise(WorldInfo, Random, int, int, ChunkData)
method and just go through the ChunkData by using some nested for loops.
What are you trying to do?
just testing some things. i want to broadcast just a message. if its not possible thats ok too
Oh ok, I thought ChunkData could only be accessed during the gen state of a world. Thanks, i'll try this out ^^
Its possible. But Bungeecord and Spigot are two separate applications. If you want to execute code on Bungeecode then you need to send a message
from spigot to bungee and let it know that it should execute something. This is usually done through the plugin messaging channel.
ok i'll try that thanks
example:
@Override
public void generateNoise(WorldInfo worldInfo, Random random, int chunkX, int chunkZ, ChunkGenerator.ChunkData chunkData) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
double height = noiseGen.at(x, z);
int mcHeight = (int) (255 * height);
for (int y = 1; y < mcHeight; y++) {
Material material = y == mcHeight - 1 ? Material.DIRT : Material.GRASS_BLOCK;
chunkData.setBlock(x, y, z, material);
}
}
}
}
mcHeight is between 0 - 255
This just generates dirt with one layer of grass on top
How to force player to hold a specific Item in hand?
and make him not able to scroll over
Listen to the PlayerItemHeldEvent and cancel it
And the swap event too. He might press F to swap off and main hand
and click event too
he might interact with the item in the inventory
but how to set it to Main Hand?
even tho if all Hotbar slots are occupied
when I click it now it gets duplicated
yep thx
i hate to ask but how long does it typically take for issue reports on jira to get looked at
you can simply cancel the event if the clicked slot is the current slot
anywhere from some days to months
allrighty
and check if the keyboard slot is the current slot
if (event.getRawSlot() == player.getInventory().getItemHeldSlot() || event.getHotbarButton() ==player.getInventory().getItemHeldSlot()) {
event.setCancelled(true);
return;
}```
?jd-s
Hey guys, could someone tell me what's wrong here ? It doesn't trigger at all (whether it's the 1st time the player die on the x time)
public class DeathListener implements Listener {
@EventHandler
public void onPlayerDeath(PlayerRespawnEvent e) {
Player player = e.getPlayer();
int deathCount = player.getStatistic(Statistic.DEATHS);
if (deathCount == 0) {
player.getInventory().addItem(new ItemStack(Material.BREAD, 16)
, new ItemStack(Material.STONE_SWORD)
, new ItemStack(Material.STONE_PICKAXE)
, new ItemStack(Material.STONE_AXE)
, new ItemStack(Material.STONE_SHOVEL)
);
player.sendMessage(ChatColor.GREEN + "Tu as reçu le kit de la honte, tu ne l'aura qu'une seule fois !");
}
}
}```
you can always duplicate items in creative mode
ye I didn't realize that :DD
what doesn't trigger?
the whole event? or the deathCount == 0 part?
The whole event
did you register it?
^
Yep, it worked when I was listening to the playerDeathEvent, but it was giving items before the player respawns
I was spamming key the treasure was at and it went thru
So I switched to the PlayerRespawnEvent, and it doesn't work anymore
there is another event i guess
if you just print a message at the first line in that code, does it get printed?
?jd-s
@lost matrixty for the post it's starting to make some sense
Yup
declaration: package: org.bukkit.event.inventory, class: InventoryDragEvent
but when i join and leave the json is always null
@shy shadow
I put a sout in the 1st line and it does appear in the console yes
wrong ping
No worries 😄
@twilit roost
thx
Which json?
with the playerdata
smhw I need to get slot int
Maybe getting itemstack and then checking on which slot has the item?
public class DeathListener implements Listener {
@EventHandler
public void onPlayerDeath(PlayerRespawnEvent e) {
System.out.println("test event player respawn event");
Player player = e.getPlayer();
int deathCount = player.getStatistic(Statistic.DEATHS);
player.sendMessage(String.format("You have died %d times", deathCount));
if (deathCount == 0) {
player.getInventory().addItem(new ItemStack(Material.BREAD, 16)
, new ItemStack(Material.STONE_SWORD)
, new ItemStack(Material.STONE_PICKAXE)
, new ItemStack(Material.STONE_AXE)
, new ItemStack(Material.STONE_SHOVEL)
);
player.sendMessage(ChatColor.GREEN + "Tu as reçu le kit de la honte, tu ne l'aura qu'une seule fois !");
}
}
}```
With this, the sout does print in the console, and the player receive the message You have died x times 🤔
Edit : Found the solution, had to put 1 instead of 0, since the previous event was trigger before the "event", but this is now triggered after, so it's not 0 but 1 ! Thanks for your help !
just try copy the same code from the InventoryClickEvent
Well... then you didnt write anything into the PlayerData while the player was online...
InventoryDragEvent doesnt have getSlot or any other method for getting slots
yes it does
it extends InventoryClickEvent
so it have
do i git to run buildtools?
did u mean:
Do I need Git to run buildtools?
buildtools already installs git on windows
if you dont have it
cant confirm on linux and mac
does the java download link from https://www.java.com/download/ie_manual.jsp include the jdk
or do i need the separate download
seperate
install one from adoptoopenjdk
you can use others jdk too
that is the one i use
what about this one
fuck oracle jdk
whats wrong with it
Temurin you mean
How to generate a list of all items in minecraft?
Material.values() ??????
I mean
its a placeholder
that is for mac
Bakka
you input how much gigs of ram you put in
It's a placeholder
mb ty xd
Hey, what can I use to store negative floats in MySQL database ? I tried int, float and bigdecimal
does joining a completablefuture on the main thread also blocks the main thread?
yes
If you want to use the result of a CompletableFuture on the main thread then you just have to start a bukkit task.
mye thats what i want to avoid
Sometimes that might be inevitable sadly
Just... FLOAT ?
I might be a dumdum again, I'l ltry again
?jd-s
ugh
PlayerData playerJoinedData = new PlayerData();
playerJoinedData.setClanId(event.getPlayer().getUniqueId());
playerJoinedData.setLastSeenName(event.getPlayer().getName());
persistenceHandler.savePlayerData(event.getPlayer().getUniqueId(), playerJoinedData);```
so something like this @lost matrix
why noClassDefFoundError in gradle compile ?
at the top of your build.gradle where it says plugins {} add id 'com.github.johnrengelman.shadow' version '7.1.2'
public void fetchAndBroadcast() {
CompletableFuture.supplyAsync(this::someAsyncStuff).thenAccept(synced(Bukkit::broadcastMessage));
}
@SneakyThrows
public String someAsyncStuff() {
Thread.sleep(500);
return "Infos";
}
// In a utility class
public static <T> Consumer<T> synced(Consumer<T> consumer) {
return (in) -> Bukkit.getScheduler().runTask(this.plugin, () -> consumer.accept(in));
}
and then shadowJar {
archiveBaseName.set('<name of your plugin>.jar')
}
kekw
at the end of it
Sure. But you wouldnt create a PlayerDataPersistenceHandler every time a player logs in. You can
just reuse the same over again
so
what i dont understand is
where would i use that to write to the PlayerData class
like in which class
@severe turret files are not added to the compiled file
Gradel shadow plugin is probably missing
public void createLocation(UUID uuid, Location location, String locationName) {
try {
PreparedStatement ps = pS("UPDATE locations SET (locWorld=?, locX=?, locY=?, locZ=?, locName=?) WHERE UUID=?");
ps.setString(1, location.getWorld() == null ? location.getWorld().getName() : "world");
ps.setFloat(2, (float) location.getX());
ps.setFloat(3, (float) location.getY());
ps.setFloat(4, (float) location.getZ());
ps.setString(5, locationName);
ps.setString(6, uuid.toString());
ps.executeUpdate();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
This is the full code
@lost matrix
i guess you dont need ()
No need to cast them to floats. Sql can handle doubles.
Now you need to use the shadow plugin. Let a task depend on 'shadowJar'
a bit weird for me to import whole lombok stuff just for the @Sneakythrows
@lost matrix how to make?
What exception are you getting?
I still get the same error
oh non
It didn't update
I dont see the error... where did you post it?
What is an unspecified State in BlockData?
wdym
In the Method getAsString there is a boolean Argument called hideUnspecified
What does that unspecified mean
Yeah but what is an unspecified State
if something is not specified
I already know that thats what's in the Javadoc, I've read it, but that doesnt answer my question
Example?
if you have a block that dont have the waterlogged property
For MariaDB you might need to remove the brackets.
UPDATE locations SET locWorld=?, locX=?, locY=?, locZ=?, locName=? WHERE UUID=?
Try that
Hi! Is it possible to broadcast using PluginMessageListener? (to entire Proxy)
eclipse is very annoying
click "Add 'requires spigot api' ..."
spigot doesn't even properly support modules
btw why do you use eclipse if you find it annoying yourself? 😄
Name of automatic module 'spigot.api' is unstable, it is derived from the module's file name.
idk is was recommened
intelliJ is much easier to use and also way better imho
but tbh I never saw eclipse complaining about modules. what JDK version are you using?
just use java 8 and you don't have to worry about modules. 1.8.8 doesnt support anything newer anyway iirc
well but you need to have diferent font ascent for every boss par positon
java version "1.8.0_331"
Java(TM) SE Runtime Environment (build 1.8.0_331-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.331-b09, mixed mode)
no idea. is eclipse also set to use java 8 in the project settings or however its called there?
hm I can only speak for intellij, but that one brings its own JDKs too
maybe eclipse also does this? idk
havent touched eclipse in 3 years
xd
@lost matrix https://paste.md-5.net/inuxakonen.cs
yes, you can create advancement
since 1.12
achievements/advancements are serverside
?jd-s
hopefully that makes sense
should I be creating a config.yml file?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
doesnt say
wdym
I want to make a configuration file for the plugin
like the docs say
but it doesnt where where / if I make a file
JavaPlugin#saveDefaultConfig?
that will save the default config, based on the config.yml inside the src/main/resources, if on maven/gradle, or src/ if on eclipse
im on intellij noe
are you using maven or gradle?
print your idea with the project open
with the folders opened too
Anyone knows what intellij idea version can i use for Windows 7?
why are you on windows 7
idk
Windows 11 is a thing
w10 🙂
yeah
w10 is perfect
im so confused why they removed dragging files between apps in the taskbar in windows 11
such a useful feature
Hey, I've discovered a bug in my custom crafting gui, I can't craft sticks or wooden pickaxe if I use Birch Planks or Spruce, only Oak Planks are accepted
Here is the ingredient map of the wooden pickaxe
{a=ItemStack{OAK_PLANKS x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=32767}}, b=ItemStack{OAK_PLANKS x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=32767}}, c=ItemStack{OAK_PLANKS x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=32767}}, d=null, e=ItemStack{STICK x 1}, f=null, g=null, h=ItemStack{STICK x 1}, i=null}
We can see when it's a slot where you have to put a Oak Planks there is UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=32767}
What I have to add to my code to accept other types of planks or what can I do to verify if the item required has UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=32767}?
How do I send these fancy kick messages?
\n in kick message
makes a new line
no kidding
yeah should work
alr alr
maybe a collection of the item stacks and check if it's any of the itemstacks in the collection
there should be built in interface for ItemStack collections
defo
I wonder when does server resource pack gets unloaded from the client
can you send kick messages with custom font
imagine custom kick message UI
declaration: package: org.bukkit, interface: Tag
Yeah but I need to verify if the item required has UNSPECIFIC_META:{meta-type=UNSPECIFIC, Damage=32767} to use them
@severe turret
Are you registering recipes for your custom crafting?
To accept multiple types of wood you simply need to register the recipe for every type of wood.
There is sadly no way to specify custom predicates for crafting at the moment.
I do Bukkit.recipeIterator() for getting the recipes
And doing what with them?
Every ItemStack that has no ItemMeta has an unspecific one
I'm really confused on how I am supposed to load a config.yml from the resources folder, into the plugins's data folder and have it loaded. bungee api btw
No, I tested it and for exemple Polished Diorite recipe ingredient map is {a=ItemStack{ANDESITE x 1}, b=ItemStack{ANDESITE x 1}, c=ItemStack{ANDESITE x 1}, d=ItemStack{ANDESITE x 1}} and there's no UNSPECIFIC_META
I'm verifying if the items in the craftings slots are the right one
How?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
That only created a blank config.yml, not one loaded from my resources folder
you can use this to create a new Tag<Material>
i assume you mean Polished Andesite
or is your recipe system broken
Then you missed this part:
FileOutputStream outputStream = new FileOutputStream(configFile); // Throws IOException
InputStream in = getResourceAsStream("config.yml"); // This file must exist in the jar resources folder
in.transferTo(outputStream); // Throws IOException
oh yeah polished andesite
No
And no
use nbt yeeee
I do not have an InputStream#transferTo method
any alternatives?
Please explain how you are checking for ingredient integrity so we can help you
Sure. Guava and Apache commons both have utility methods. But they do pretty much exactly the same.
anyway
Is there a way to change the bungeecord chat type back to chat?
2 outcomes
- An exception is being thrown
- Your file is being copied
i mean like, my bungee plugin is running language level 8, so that method doesnt exist, so what should i do.
ah nvm, maybe i can do something with the bytes
read with buffer and then write that
Have you tried both methods? The post specifies two approaches. One for older versions.
byte[] buf = new byte[1024];
while (input.read(buf) != 0) {
output.write(buf);
}
idk if thats how that works but whatverr
might have to change the condition to smth else
eh. buffering. I'd just read all bytes and then write them in one batch
that might use a lot of memory depending on file size
Depends on the type of Recipe, if it's a ShapedRecipe I create a list of possible of positions and verify for every position if all the items is positioned good, if it's not we go into another position and do the same thing, if no position matched we can't do a craft, if a position matched we set the result slot
To verify if the item is good, I do: (specifiedItemStack and neededItemStack are null/air || specifiedItemStack and neededItemStack are similar) && specifiedItemStack's amount is higher or equal to neededItemStack's amount
and this works too
i think this is how the transferTo method is implemented internally
(sarcastic voice) Yeah. Because someone has a 2MB config file with 20k lines of code.
yes
nah but for other files you may need to copy buffering is the way to go
might want to copy an icon or image or smth
or extract a native
So you are not using the RecipeChoices?
i did something similar
for a default crafting inventory
the code is on github
could take a look at it
No, do I have to use that?
A multi material choice could look like this
[STONE, COBBLESTONE, ANDESITE]
When you just get it as an ItemStack then it will be only
STONE
Checking on equality by simply calling isSimilar() on this ItemStack ignores the other two.
Create an Inventory.
In a manager you define a Map<UUID, YourInventory>
When someone opens the ender chest you check if they have a mapped inventory and open it instead.
You can map 2 UUIDs to the same Inventory instance.
Yeah but ShapedRecipe's ingredient map don't have array or list of itemstack that can be used for a slot
They have RecipeChoices
Which are of type Predicate<ItemStack>
Huh?
ok...
ew
Does anyone have experience synchronizing inventories across multiple server instances?
Yeah I see that, I've printed getChoiceMap() and print list and that's good
But it's list of ItemStack or Material?
Concurrent sync or data transfer sync?
No
No what
Data transfer
concurrent could potentially work too
You would need to serialize the inventory and store it in a place that is accessible for every instance.
For example a DB.
Are there any built in solutions when it comes to serializing it?
There is just one big issue with transferring between instances because the writing into a DB is slower than the actual transfer
Kind of. You can use the BukkitObjectOutputStream to serialize an ItemStack[] to raw bytes or a Base64 String
So it's a list of Material?
Its not a list of ItemStacks or Materials.
getChoiceMap() returns a Map<Character, RecipeChoice>
I'm trying to add a new item into the game called TNT Wand, with an enchantment glint. I added the code with no errors, following a tutorial, and the is listed in /help , but when I type /givewand , it shows up in chat, and isn't showing the suggested usage
Yeah I'm worried the player changes server before the DB is updated... I've thought about doing a server switch cooldown whenever their inventory is updated, but not sure if that's the only approach
commands:
givewand:
description: Gives a wand to the player
usage: /<command>
``` like is this the problem?
I made a model for this. One moment.
ok I checked the logs, and my server is registering the command
the problem is that its not spawning in the item
So you will def need to bring the proxy into this
Those are the two approaches
big probelm with your question.
A. We don't know the tutorial
B. You shared 0 code and shared a config
C. You added 0 context other than it doesn't work
why does HumanEntity exist? when u could just have player
HumanEntity can be emulated by NPC's
an advanced NPC could utilize all methods provided by HumanEntity to open inventories and more
The question is the likely hood of such an event occuring if your thinking about casting its generally safe to automatically cast blindly, but I generally wouldn't advise it
your kind of just playing the odds with that one
Basically what you need to do is save the players data, wait for the DBs write to be done, and only then you should transfer the player over.
sounds cool :/
MyPlugin.java
package com.kyle.myplugin;
import com.kyle.myplugin.commands.Commands;
import com.kyle.myplugin.items.ItemManager;
import org.bukkit.plugin.java.JavaPlugin;
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
ItemManager.init();
getCommand("givewand").setExecutor(new Commands());
}
@Override
public void onDisable() {
}
}
ItemManager.java
package com.kyle.myplugin.items;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
public class ItemManager {
public static ItemStack wand;
public static void init() {
createWand();
}
private static void createWand() {
System.out.println("createWand()");
ItemStack item = new ItemStack(Material.STICK, 1);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§4T§fN§4T §fWand");
List<String> lore = new ArrayList<>();
lore.add("This wand will summon an");
lore.add("§4Explosion §rWhenever you");
lore.add("use it!");
meta.setLore(lore);
item.addEnchantment((item.getType() == Material.BOW) ? Enchantment.PROTECTION_ENVIRONMENTAL : Enchantment.ARROW_INFINITE, 1);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(meta);
wand = item;
}
}
Commands.java
package com.kyle.myplugin.commands;
import com.kyle.myplugin.items.ItemManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
System.out.println("onCommand()");
if(!(sender instanceof Player)) {
sender.sendMessage("Only players can use that command!");
return true;
}
Player player = (Player) sender;
if(cmd.getName().equalsIgnoreCase("givewand")) {
System.out.println("command = givewand");
player.getInventory().addItem(ItemManager.wand);
}
return true;
}
}
plugin.yml
name: MyPlugin
version: 1.0
author: Kyle
main: com.kyle.myplugin.MyPlugin
api-version: 1.13
commands:
givewand:
description: Gives a wand to the player
usage: /<command>
using IntelliJ editor
video is here
github is here
and this is my OG question
I'm 14 min into the video
hope thats enough information! 🙂
What is the new equivalent to read nbt data from a file? NBTInputStream doesn't exist anymore. I'm trying to read a schematic file.
FileInputStream stream = new FileInputStream(file);
NBTInputStream nbtStream = new NBTInputStream(new GZIPInputStream(stream));
CompoundTag nbtdata = (CompoundTag) nbtStream.readTag();
Okay so I replaced in the previous verification the specifiedItemStack and neededItemStack are similar to getChoiceMap().get(cha) != null && getChoiceMap().get(cha).test(specifiedItemStack)
I tested with wooden pickaxe and it's working, when i'm trying to do sticks it's not working I'm searching why
This looks better
How can i get players in a certine radius of a location
anyone have good guide on 1.8.8 custom items?
yea I got you gimme a second
Update to a non-ancient version that is actually played and use the PersistentDataContainer
he just wants enchant glow lol, but that item builder though lmao
thats the weirdest singleton I've seen in my life
World#getNearbyEntitites(...)
How do i get a BoundingBox
You dont need one if you just want to get them in a radius
Collection<Entity> players = world.getNearbyEntities(location, radius, radius, radius, entity -> entity instanceof Player);
public Collection<Entity> getPlayersAround(Location location, double radius) {
World world = location.getWorld();
return world.getNearbyEntities(location, radius, radius, radius, entity -> entity instanceof Player);
}
Does anybody know how to play Sounds using PluginMessaging with Bungeecord?
You need two plugins. One that runs on the Minecraft servers and one that runs on the Proxy server.
Then you send a message from the minecraft server to the proxy server and the proxy server notifies
every minecraft server, which will then play sounds for their players.
I just want to even make an item xd
cant even do that
how can i make an entity a player
says i cant give it an entity
casting
like its registering the commands
needs to be player
(Entity) player
Where
please add brackets to your loop
and addPlayer((Player) player)
You mean the text and progress?
yea
Sure... just set the text and progress
how do i know the bossbar key
im wanting to change it in a diffrent event
so on death it is removed
Keep track of the BossBar
Google what "uuid" is an acronym for
i figured
Hey, so I get this error https://srcb.in/FwO1qBonSM and i can't seem to fix it, I tried checking if target returns null or not, I tried checking if the users is offline / online but nothing worked, I am still getting the same error. Can anyone help?
show code
my first guess it that youre doing if (Bukkit.getPlayer("name").isOnline())
public void InvClickEvent(InventoryClickEvent event){
System.out.println("Fired");
}```
This doesn't fire if i swap hotbars but if I add
```java
if (event.getAction() == InventoryAction.HOTBAR_SWAP || event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD || event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) {
System.out.println("Fired");
}```
This does fire why is this happening?
Bukkit.getPlayerExact is returning null
and i guess you utils method doesnt lik that
also args[0] can never be null
I tried Bukkit.getPlayer and it did the same thing
null too lol
oh
you should check if the target is null instead of args0
is there any way to change the path created by ConfigurationSerialization to a different name without moving packages?
Player target = Bukkit.getPlayerExact(args[0]);
if (target == null) {
sender.sendMessage("target isnt online");
} else {
Location safespot = Utils.findSafeLocationFor(target);
// other stuff
}```
@pastel relic
thats what I did
Caused by: java.lang.NullPointerException: Cannot invoke "org.bukkit.entity.Player.getWorld()" because "player" is null
at me.nikolakrzheski.deluxertp.utilities.TeleportUtils.generateLocation(TeleportUtils.java:59) ~[DeluxeRtp-3.1.jar:?]
at me.nikolakrzheski.deluxertp.utilities.TeleportUtils.findSafeLocation(TeleportUtils.java:68) ~[DeluxeRtp-3.1.jar:?]
at me.nikolakrzheski.deluxertp.commands.RTP.onCommand(RTP.java:55) ~[DeluxeRtp-3.1.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
... 21 more
wheres the code
oh
move this into ur else
ok wait
how do i get the health of an entity on entitydamage event
cast it to living entity
what u doing
oh, that worked
packet manipulation
ty @tardy delta & @earnest forum
im building ui lib
what type of packet manip you doing
can you remove the text before a log, like [time] [main/INFO] Something
I need it to print some text based ui on start
instead of logger
yeet
simple enough
well no tbf I just need to bypass that in certain scenarios
little bit of reflection and boom its gone
well I need it to be there
just not always
actually I am fine with the logger, I just don't want the text behind it
well i'd just remove it 100% of the time for maximum effectiveness
the date and time?
date, time, server thread and plugin which printed from
why would you want to do that
but these are logging data
then read the latest.log and reformat it
well I need to print it to console
not latest.log
again reformat the latest.log and reformat it
what?
its so easy to reformat it and trail real time as well
sending commands is also easy if you use something like tmux or screen
wdym reformat
if you trail the latest.log you can remove and add whatever the fuck you want to the lines put in the log file
no messing with the server required
How would that help me print to the cmd/terminal the server is running in...?
Why doesn't Skeleton entity have GENERIC_ATTACK_SPEED attribute?
because it uses a bow
and the bow has a fixed attack speed
So there isn't any way to speed it up?
its in python but its my server panel that I scrapped together
How can I change skeleton attack speed using any event? 🤔
I am talking from a plugin's perspective, no extra software
can you make args show up when you type a command without using subcmds?
can I just print A to the console without the extra stuff
oh then you have to remove the server logger
I don't want to remove the entire logger, it should still be used
I wouldn't see another way to do it
I just don't want the extra stuff
maybe using terminal thingy
like move back to start of line and \b the shit out of it
seems like a hastle for literally little to no gain if I wanted a nice format I'd use my own panel as I do
any advice on doing so?
there might be a bow charge event
i wonder how protocollib solves issues with paper's packet limiter
?
since it listens for packets before it reaches paper's packet limiter
say i have the health of an entity at 70.75172519683838 and i want to set a bossbar to the health how can i make the number between 0 and 1.0
using the starting health of the mob
i guess you are talking about tabcompletion
yes.
I didn't know what it was called ^^
override TabCompletor#onTabComplete to return a list which the options
depending on the args length
and how do I do that?
okay, thx again
for (Player player : Bukkit.getOnlinePlayers()) {
for (String permission : permissions) {
if (!player.hasPermission(permission)) {
players.add(player);
break;
}
}
}``` Will this `break` break from both for loops or just the nested one?
it would break from nested one
got it
Thats very specific to that health tho
floor it and then divide by 100
time to go to my graduation smh
what if i have the health of like 489
bro
what is this code
so much repeating code 
shut
worse than smpcore
im using command framework now
did you make the framework
I am doing in a SignChangeEvent ```java
Block block = event.getBlock();
Sign sign = (Sign) block;
```[18:39:47 ERROR]: Could not pass event SignChangeEvent to PixliesCore v2.0.0
java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock cannot be cast to class org.bukkit.block.Sign (org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock and org.bukkit.block.Sign are in unnamed module of loader java.net.URLClassLoader @759ebb3d)```
event.getBlock() should give me an org.bukkit.block.Block, not an org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock so I don't know what's going on.
or r u bad
more documented than mine
i see nothing wrong with this approach of command managing, its just that its hardcoded more
lmao its from my old plugin
I just make my command framework use hashmaps
won't be as fast as raw if's
but it's fast enough
enough
That still wont work
if i have a big health of like 400
i will get 4 and it has to be between 0 and 1
how I do commands
https://stackoverflow.com/questions/929103/convert-a-number-range-to-another-range-maintaining-ratio
I'll show you mine
tho i gotta write it in disc not yet pushed
no cap
which one do you want, the class based one or the non class based one
im not sure if this will work
but divide 1 by the max health
and then multiply by the current health
class based
k
non class based is kinda cringe imo
i hate math
just gets super messy
Eh i have it because I can
yk
for small things it's useful
well yeah i can see that
but if you've heard of crazy crates
i think they have like a 2k line comand listener
a bunch of commands
o no
just in if else's
LifeSteal SMP Plugin by IkeVoodoo. Made with https://github.com/IkeVoodoo/SMPCore - LSSMP/src/main/java/me/ikevoodoo/lssmp/commands at v3 · IkeVoodoo/LSSMP
not even switch 😢
(health/maxhealth) * 100 would always return you health from 0 to 100
just make sure that the max health wont have 0 in it
command system is still a WIP
otherwise your computer will blow up
so the max health is 500 of a warden
dont need the *100 part but yeah
if you want health from 0 to 1 then yeah
good commit
why is there a new package for each class?!?!
it's a new package for each command tree
ah I se
it's neatly organized
(450 current health warden/500 max health warden) * 100 would you return 90 health for you
hes using bossbar so *100 isnt needed
sheesh
what is SMPCore?
then yea dont add * 100
The entire backbone
lifesteal is basically just an implementation of a bunch of abstract classes and interfaces
and a couple annotations
i see
LifeSteal SMP Plugin by IkeVoodoo. Made with https://github.com/IkeVoodoo/SMPCore - LSSMP/src/main/java/me/ikevoodoo/lssmp/config at v3 · IkeVoodoo/LSSMP
this is how I handle configs
why does it have so many stars
great question
Ⓜ️
tho the 29 forks
nothing yet