I would always use ACF: https://github.com/aikar/commands
#help-development
1 messages · Page 1828 of 1
Cloud Command Framework is cool
all command frameworks go through bukkit command api, even brigadier goes through it (in craftbukkit at least)
Ty, I’m quite new to plugins 🙂
np, there's many others but I prefer ACF - it was made by the PaperMC dev
Oh yea, was just wondering if for a simpler plugin it made sense mostly
it's a bit complicated at first, I can show you some examples if you need any
but it's really way easier once you learnt the basics
When I get to using it I’ll ask 🙂
oki
as you can see
this API involves bukkit command API events to do some tab completions
its just a wrapper for brigadier
so?
public void kothTimer() {
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
scheduler.runTaskTimer(this, new Runnable(){
@Override
public void run() {
KothMain.playerTimer ++;
}
}, 20);
}
``` so smth like that?
so i just wanted to prove that its impossible to get brigadier working independently without modifying the spigot's code
you call it "playerTimer" - do you need to have one timer per player, or one global timer?
one timer per player
I don't think anyone said otherwise^^
Wow, looking at the examples I see what you are talking about
then this approach doesn't work at all
i need to add them to a list and iteate
ik
iterate**
just i want to get the timer working for me first
Here's a tiny example for a really basic command @tulip owl
package de.jeff_media.filteredhoppers.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.*;
import de.jeff_media.filteredhoppers.FilteredHoppers;
import de.jeff_media.jefflib.TextUtils;
import de.jeff_media.jefflib.data.tuples.Pair;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandAlias("filteredhoppers")
public class MainCommand extends BaseCommand {
private static final FilteredHoppers main = FilteredHoppers.getInstance();
@Subcommand("reload")
@CommandPermission("filteredhoppers.reload")
@Description("Reloads the configuration")
public static void onReload(CommandSender sender, String[] args) {
sender.sendMessage("§aFilteredHoppers has been reloaded.");
main.reload();
}
@Default
@HelpCommand
public static void onHelp(CommandSender sender, String[] args) {
Pair<String,String>[] help = new Pair[] {
new Pair<>("giveitem","Gives you the magic hopper thing"),
new Pair<>("reload","Reloads the configuration")
};
for(Pair<String,String> pair : help) {
sender.sendMessage("§7/filteredhoppers " + pair.getFirst() + "§r - " + pair.getSecond());
}
}
@Subcommand("giveitem")
@CommandPermission("filteredhoppers.giveitem")
@Description("Gives you the magic hopper thing")
public static void onGive(Player player, String[] args) {
player.getInventory().addItem(main.getMagicItem());
}
}
and you register that command like this in your onEnable:
PaperCommandManager commandManager = new PaperCommandManager(this);
commandManager.registerCommand(new MainCommand());
(You want to use PaperCommandManager even when you're using Spigot)
i do get the error Cannot resolve method 'runTaskTimer(com.santapexie.santa_koth.KothCommand, anonymous java.lang.Runnable, int)' tho
you need to provide two intervals
e.g. 20, 20 instead of just 20
Ty, do I need to touch plugin.yml at all?
first number = initial delay, second number = further delays
does this API fixes the issues with minecraft namespaces for brigadier?
no, not at all
Nice 🙂
what issues are there? Paper's ACF registers your commands with your plugin's namespace
Can you make like sub commands?
Yea
yes, they are included in what I sent
In the GH it shows examples
by registering brigadier commands you're fooling spigot that its minecraft mojang command
what I sent has subcommands: "reload", "help" and "giveitem"
that way autocompletion of the command resolves with minecraft namespace
Cannot resolve method 'runTaskTimer(com.santapexie.santa_koth.KothCommand, anonymous java.lang.Runnable, int, int)' still get this
but i guess if it handles tabcompletion via bukkit command api
this shouldnt be an issue
show the full code you're using pls
public void kothTimer() {
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
scheduler.runTaskTimer(this, new Runnable(){
@Override
public void run() {
KothMain.playerTimer ++;
}
}, 20, 20);
}
longs not ints
is that in your main class? the one that extends JavaPlugin?
that's your problem.
"this" has to be a reference to your main classes' instance
ye
nice 🙂 I already use other api for commands (some have this option). I´m planing make my own command system (like to have control over it self ) 🙂
does it have to be in the main class then
compiler will figure that out itself
no
just provide a reference to your main instance
k done
working now @calm star ?
I know is not best way and create lots of work 🙂 but I learn a lot on the way how stuff works when do it self 🙂
just putting the timer on the hotbar and ill see
oh by the way @tulip owl since you asked about tab completion: ACF will take care of basic tab completion like for the subcommands. I can show another example for custom tab completers if you like
seeing how aikar's command project is made make my dissapointed in myself
but hey
its 5 years old
but your time is still a global int, isn't it? You want to have some per player timers IIRC
and has 60+ contributors
/crown <player> <on/off> that’s what I was doing. I’m presuming I need to do a custom one for the on/off?
i just want the timer rn
public void kothTimer() {
if (KothMain.kothStarted) {
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
KothMain kothMain = new KothMain();
scheduler.runTaskTimer(kothMain, new Runnable() {
@Override
public void run() {
KothMain.playerTimer++;
System.out.println(KothMain.playerTimer);
}
}, 20, 20);
}
}
``` this puts nothing in the console
when i use it like:
if(args[0].equalsIgnoreCase("start")) {
sender.sendMessage(ChatColor.GREEN + "King of the Hill started!");
KothMain.kothStarted = true;
this.kothTimer();
}
does it say King of the Hill started?
yes
erm
why are you creating a NEW instance of your main plugin?
I am like 100% sure that you will got some console error
no error
you can't instantiate your main class and you never want to do that anyway
then you didn't restart your server after compiling your plugin again
i reloaded
he should get illegalargumentexception
Also, @tender shard should I use an API/wrapper for the config too?
because main class is already inited
org.bukkit.command.CommandException: Unhandled exception executing command 'koth' in plugin KingOfTheHill v0.1
ye
either by dependency injection (passing "this" onto the other class instance) or by using a static getter to get your main classes instance
wdym?
ooh
I'm 99% of the time fine with the builtin YamlConfiguration
Okay 🙂
of course it depends on what you're actually doing
Yea, just simple stuff atm but it could expand (custom plugin for a minigame thing)
most of the time I have a class with lots of static final Strings, e.g.
public class Config {
public static final String CHECK_FOR_UPDATES = "check-for-updates";
public static final String DO_WHATEVER = "do-whatever";
}```
and then I do things like
```java
if(main.getConfig().getBoolean(Config.CHECK_FOR_UPDATES)) {
// check for updates
}
'com.santapexie.santa_koth.KothMain.this' cannot be referenced from a static context
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.
you can't use "this" in static contexts
because you don't have any instance
show your full main class pls, or at least the method where that error is thrown
@calm star There's two general ways to get your main instance into another class
- Method: Static getter
This is your main class:
public class Test extends JavaPlugin implements Listener , CommandExecutor {
private static Test instance;
{
instance = this;
}
public static Test getInstance() {
return instance;
}
}
Then you can do Test.getInstance() in all other classes to get your main instance
- Way is dependency injection
Main class:
public class Test extends JavaPlugin implements Listener , CommandExecutor {
@Override
public void onEnable() {
new SomeOtherClass(this);
}
}
OtherClass:
public class SomeOtherClass {
private final Test main;
public SomeOtherClass(Test main) {
this.main=main;
}
}
ok
how would i make a timer seperately for each player and make each stop and start independently?
What event would i use to increase all mobs health
depends on when you want to do it
maybe like when they spawn type thing
There's a CreatureSpawnEvent or sth like that
you can use this https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/entity/CreatureSpawnEvent.html
declaration: package: org.bukkit.event.entity, class: CreatureSpawnEvent
of course you can. but you don't need to, you already have a reference to your main's instance
i can just use my static getter
then you can just store the map as field inside your other class
depends. is that timer started by the player itself, using a command?
when its started, all players inside an area will start the timer counting up
so already have a list of players inside that area?
then you will have to check all online players, loop over them, check if they are inside the area, and if yes, put them into your map
i just have a ```java
@EventHandler
public void playerInBorder(PlayerMoveEvent e) {
Player p = e.getPlayer();
Location l = p.getLocation();
Border border = new Border(new Vector(-2,0,2), new Vector(2,256,-2));
if (KothMain.kothStarted == true) {
if (border.contains(l)) {
System.out.println("In Border");
//add players to list
}
}
}
listener
so would i add players to a list
thats in a different class
ahh
i think i get it
I add players to a list, iterate through the list returning player, then I set the timer for that player to 0 with the map
and if they are not in the border, i just stop the stopwatch
event.getEntity().setTicksLived(-32768);
Anyone know why this method does not allow anything less than 0?
With vanilla commands, I can set this to a negative value to make an item not despawn
/summon item ~ ~ ~ {Age:-32768,Item:{id:"minecraft:bow",Count:1b}}
Using this method, I get an error telling me I'm not allowed to do that
Which I find to be dumb and stupid and dumb
i created a recipe manually here and the recipe book works now, it marks the recipe as available when i have the items, but when i click on them, it only takes the apple to the crafting table
the craft is the old 1.8 craft
but the gold block have a tag called "test"
Yeah the client just doesn’t understand
does it work if you manually put it in there? I imagine it would
I’m not sure if you can detect a click in the book, if you can then you can manually do it
I think I tried once, I don't believe I was successful
Test with NMS to see if setting the value negative works properly, then make a report in Jira
ooh
gg!
what is that website? I really want to familiarize myself with the protocol
We should probably have an event for that
yes
wait what
people have written Minecraft servers in node?
what the fuck
who would do this
you can find everything in this world
@tender shard in my timer method, how can i reference the player when putting my map?
Someone asked here the other day about making one in python
since every day, at least 4 people here try to create another instance of their main class, or just don't know how to get their main instance at all, I quickly wrote this: https://blog.jeff-media.com/getting-your-main-classes-instance-in-another-class/
Any suggestions / ideas for improvement etc?
If it’s for spigot, JavaPlugin::getPlugin, JavaPlugin::getProvidingPlugin
on top of that
You should rarely need to pass your main class instance down to a lower level component
I do it fairly often and don't see any problems in doing so. E.g. when a listener wants to log something, or access the config
or if a command wants to reload the config
Then you can pass the logger or config down
Because it couples your code architecture
so I should pass my logger AND my config? I could instead just pass my JavaPlugin
tell me a better method then if you need to access the config and the logger
Yes now your class is dependent on an instance of JavaPlugin
So whenever you need the logger
of course it is, it accesses the logger and the config. and JavaPlugin provides both
A side effect is that you also need the pass a java plugin instance
Spigot Plugin building error
which makes the component less reusable
And it makes it coupled
which is problematic in a testing environment
yes, my listener isn't meant to be used anywhere else. It was made for a specific plugin.
And it’s fragile
I’m talking general code architecture
Passing your main plugin class to every other class is objectively worse than passing the dependencies directly
If you would have read the post I sent, you'll notice it explains absolute beginner concepts. It's meant for someone who just gets started and wants to access something from their main class
If you already tell them not to do that at that point, noone would ever be able to start coding plugins
Yes well, I mean you kinda asked for suggestions 
and as I said - if a listener needs your logger and your config, there's no point in not providing the javaplugin
yeah, for the beginner explanation, not general suggestions about DI 😄
Your listener is tightly coupled to javaplugin
Thus whenever you want to instantiate a listener instance
You have to pass a javaplugin instance
of course it is, it listens to some bukkit events
Which ENFORCES mocking of javaplugin in a test environment
And it enforces mocking if you wanna reuse it in a different context
and of the event class too
so you obviously don't have suggestions on how to explain beginners on how to get their config in a listener but rather on how to make the listener run in some testing environments
Wat
I’m just saying passing the configuration directly is much better
Or whatever dependency you may have
so what if the listener schedules a task?
Yes that’s the issue with Bukkit
Anyways you can the create a middle class
Or middle level component
gg!
yes but please let's not discuss this 😄 I was simply writing a tiny tutorial on how get your main instance from listeners, whether you think that's a good or bad idea, I'm sure you agree that 99% of beginners have that question at some point
In that way you won’t have classes and functions jumping between high and low level
ye
you're still using obfuscated mappings? 😦
Are exit conditions a good practice in event listeners? If(...) return;
Mfnalex I totally see why you’d pass da plugin instance so yeah and if it’s merely spigot it’s probably fine Ig
yes, avoiding the arrow anti pattern
Thankfully you don’t need it for namespaced keys anymore
ive now done this:
public void kothTimer() {
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
scheduler.runTaskTimer(KothMain.getInstance(), new Runnable() {
@Override
public void run() {
for (Player tempPlayer : KothMain.getInstance().playersInBorderList) {
KothMain.getInstance().playerTimer.put(tempPlayer, KothMain.getInstance().playerTimer.get(tempPlayer) + 1);
System.out.println(KothMain.getInstance().playerTimer);
}
}
}, 20, 20);
}
``` but i get errors
and idk how to make the maven config into gradle config
What is that?
java.lang.NullPointerException: Cannot invoke "java.util.List.iterator()" because "com.santapexie.santa_koth.KothMain.getInstance().playersInBorderList" is null
at com.santapexie.santa_koth.KothCommand$1.run(KothCommand.java:52) ~[Koth-0.1.jar:?]
at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftTask.run(CraftTask.java:101) ~[patched_1.17.1.jar:git-Paper-386]
at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483) ~[patched_1.17.1.jar:git-Paper-386]
at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1567) ~[patched_1.17.1.jar:git-Paper-386]
at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:490) ~[patched_1.17.1.jar:git-Paper-386]
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1483) ~[patched_1.17.1.jar:git-Paper-386]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1282) ~[patched_1.17.1.jar:git-Paper-386]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[patched_1.17.1.jar:git-Paper-386]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
yeah I only wrote that to send it to people who do stuff like "new MainClass()" in their listeners
I totally agree that it's not ideal
you never created your HashMap
Alright thanks
public Map<Player,Integer> playerTimer = new HashMap<>();
oh
I hope it's okay to send my blog posts all the time 😄
sitll get error
Everytime I answered the same questions 12 times I decide to just write it down in general so I don't have to rewrite the same thing again and again
So yes, @mighty sparrow , having a couple of returns is way better than having huge nested if statements
show code and full error message please
Someone make a compiler hack that accepts ifnt()
the first error i get comes from
@EventHandler
public void playerInBorder(PlayerMoveEvent e) {
Player p = e.getPlayer();
Location l = p.getLocation();
Border border = new Border(new Vector(-2,0,2), new Vector(2,256,-2));
if (KothMain.kothStarted == true) {
if (border.contains(l)) {
System.out.println("In Border");
KothMain.getInstance().playersInBorderList.add(p);
} else {
KothMain.getInstance().playersInBorderList.remove(p);
}
}
}
show your main class
my guess: your field "playersInBorderList" is always null because you never assign it
Because I always write with exit conditions but I get a weird problem. Everything works fine until someone try to reproduce animals (cow, chicken, etc.). I know its caused by my return statement because it says its about the PlayerInteractEvent.
show your code pls
Ill show the code once im at home
public final class KothMain extends JavaPlugin {
static BossBar kothBossbar = Bukkit.createBossBar("King of the Hill Event", BarColor.BLUE, BarStyle.SOLID);
static Boolean kothStarted = false;
private static KothMain instance;
public Map<Player,Integer> playerTimer = new HashMap<Player, Integer>();
public List<Player> playersInBorderList;
@Override
public void onEnable() {
instance = this;
this.getServer().getPluginManager().registerEvents(new InBorderListener(), this);
this.getServer().getPluginManager().registerEvents(new PlayerJoinListener(), this);
this.getCommand("koth").setExecutor(new KothCommand());
serverTickEvent(this.getServer());
}
For code, try sending it with
oh ye sry
looks fine. Please send the FULL error message you get again
ik i forgot my list
oh yeah lmao
I looked at playerTimer
lol
yeah my first guess was right, you declare your list but never create it
By using ?paste, it doesnt flood the channel with code, I think its a better practice
replace public List<Player> playersInBorderList; with public List<Player> playersInBorderList = new ArrayList<>();
ye
@tender shard you good with Kotlin?
now i get no errors
(my plugin is made in that)
but I never used it except to try it out a bit
Yes if you can read it its good
yeah reading is no problem
i get this error every second
[23:41:27 WARN]: [KingOfTheHill] Task #23 for KingOfTheHill v0.1 generated an exception
java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "java.util.Map.get(Object)" is null
at com.santapexie.santa_koth.KothCommand$1.run(KothCommand.java:53) ~[Koth-0.1.jar:?]
at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftTask.run(CraftTask.java:101) ~[patched_1.17.1.jar:git-Paper-386]
at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483) ~[patched_1.17.1.jar:git-Paper-386]
at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1567) ~[patched_1.17.1.jar:git-Paper-386]
at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:490) ~[patched_1.17.1.jar:git-Paper-386]
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1483) ~[patched_1.17.1.jar:git-Paper-386]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1282) ~[patched_1.17.1.jar:git-Paper-386]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[patched_1.17.1.jar:git-Paper-386]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
because of
public void kothTimer() {
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
scheduler.runTaskTimer(KothMain.getInstance(), new Runnable() {
@Override
public void run() {
for (Player tempPlayer : KothMain.getInstance().playersInBorderList) {
KothMain.getInstance().playerTimer.put(tempPlayer, KothMain.getInstance().playerTimer.get(tempPlayer) + 1);
System.out.println(KothMain.getInstance().playerTimer);
}
}
}, 20, 20);
}
show line 53 in KothCommand pls
oh I already see
you try to increment a value for a player that's not in your map yet
sry gtg sleep il check tmrw
check if the player is already in the map, if not, use 0 instead of Map.get(tempPlayer)
getOrDefault would be good here
it does
but anyway, again 😄 Does some one has any suggestions for the blog post I wrote about how to get the main instance in other classes, BESIDES that it's often not a good idea to actually require the main instance at all in other classes? 🙂
is there a reason you use an initializer block instead of the onEnable method or something similar?
Comic sans
I always do this because that way I immediately have the instance set. E.g. if you use onEnable(), it might happen that you later add an onLoad() and then you have to move the instance = this part to onLoad instead - if you create other objects there that might require the main class.
I'd rather set it as soon as possible instead
ALthough that happens almost never, I don't see any downsides in using the init block
yeah there's probably not a downside. I was just curious
also init blocks are fancy lol
it does look cool
yeah also static init blocks. I always use them e.g. when I need to get some enums by their names for some kind of map or sth
you can't
you can only get the string they entered
but e.g. if they entered "/tp" you can't know whether it's essentials TP or another plugins TP command
what do you need it for?
I wonder if that event could provide a command instance
use getMessage and split it by spaces
String commandName = event.getMessage().split(" ")[0]
that SHOULD return /tp when entering /tp bla bla
maybe it also just returns "tp" instead of "/tp", not sure
yeah it seems to include the /
All commands begin with a special character; implementations do not consider the first character when executing the content.
It will never be null iirc
it will never be null
and you also can't split by an empty string
getMessage() is @ NotNull and splitting it will also never return an empty array. it returns at least an array of length 1
not really, since the command wasn't processed yet^^
of course you could manually go through the command map
I just wonder why that would be useful in any case
Mmh true
Hi
hi
Any idea with this
ServerPlayer entityPlayer = ((CraftPlayer) player).getHandle();
returns java.lang.NoSuchMethodError: 'net.minecraft.server.level.ServerPlayer org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer.getHandle()'
Use mojmap
are you using mojang remapped already?
I used the <classifier>remapped-mojang</classifier> in my project
do you also remap your final jar to use obfuscated mappings again?
like - do you have the "special-sauce" plugin in your pom.xml as well?
I removed it earlier let's try it
you MUST have it
the reason is:
you are coding against the mojang-remapped version but the server is using obfuscated mappings
so the server won't understand the mojang mappings
(note: in my blog post i'm using 1.18 instead of 1.18.1, you'll have to replace it for 1.18.1)
Hello, what's the best method to broadcast a message to the server?
Bukkit.getServer().broadcastMessage("") is deprecathed
ask paper
Because they want people to use adventure
what about broadcast(message, permission)
What about it
ok nvm
I think i can use that to broadcast to players with that permission and it's not deprecated in spigot
because paper wants you to use basecomponents
or that, my bad
anyway
you can SAFELY use the deprecated method
as long as spigot does not mark it deprecated, you are fine to use it
even when spigot sometime marks it deprecated, it won't be removed for, probably, years
although you should switch to the new version as soon as spigot marks it deprecated
in fact, everything that gets marked deprecated in paper, don't worry about it as long as it's not deprecated in spigot
and if you want your plugins to be compatible with spigot, do NOT use paper as dependency
private void savePlayerStats(Player player) throws Exception {
ServerPlayer entityPlayer = ((CraftPlayer) player).getHandle();
MinecraftServer server = entityPlayer.getServer();
PlayerList playerList = server.getPlayerList();
Method savePlayerFileMethod = playerList.getClass().getSuperclass().getDeclaredMethod("save", ServerPlayer.class);
savePlayerFileMethod.setAccessible(true);
savePlayerFileMethod.invoke(entityPlayer);
savePlayerFileMethod.setAccessible(false);
}```
Seems like I am unable to access this protected method anymore
Getting [00:26:30 WARN]: java.lang.NoSuchMethodException: net.minecraft.server.players.PlayerList.save(net.minecraft.server.level.EntityPlayer)
It looks like this in the decompiled PlayerList class
protected void save(ServerPlayer entityplayer) {
if (entityplayer.getBukkitEntity().isPersistent()) {
this.playerIo.save(entityplayer);
ServerStatsCounter serverstatisticmanager = entityplayer.getStats();
if (serverstatisticmanager != null) {
serverstatisticmanager.save();
}
PlayerAdvancements advancementdataplayer = entityplayer.getAdvancements();
if (advancementdataplayer != null) {
advancementdataplayer.save();
}
}
}
It’s not going to be mapped at runtime
I guess if you don't use things that aren't in spigot it works..?
Correct
Ok.
it depends on whether they actually use / require stuff only provided by paper, not spigot
if you want to be compatible with spigot, you should use only spigot as dependency
if you know 100% what you're doing, you can use only paper as dependency and only call paper methods / classes if you checked they exist
if you're lucky, you can only use paper and don't check it and it might still work
yeah but why risk to accidently use paper only stuff instead of just using spigot in the beginning? 🙂
Because I don’t know how to remap with gradle D:
I don't know that too
perfect time to switch to maven 😛
or ask someone here who knows how to
So im making a plugin where you can open a gui, and put spawners inside. Then it calculates the XP and you can yoink it from the gui. My question is, what is the best way to keep track of the items in the gui for later use. Save the needed values, like what type, and then just generate the spawner from those values? Or just save the itemstack? Also is it bad to create a new gui everytime i want to update it?
pretty sure theres a mevn command for it, idk
creating a GUI takes next to nothing
I wouldnt worry about performance in GUIs
yeah but we're talking about gradle not maven
it's not 😛 gradle is fine too, I just don't know enough to properly use it and have no reason to learn it as maven can do everything I need
oh i wasnt paying attention, i thought you meant transferring to maven
wait
oh well
yeah I meant "switch to maven" because they don't know how to do stuff in gradle
got it
but it was more a like a joke
obviously gradle could do it too, we just dont know how
and yeah, what'S wrong in simply saving the itemstacks @somber hull ?
nothing, i just dont know what would be easier
Hello, I have two plugins. the second depends on the first, when reloading the first because I modify it or for some other reason the second stops working because the first was modified, is there any way to depend on a plugin without having this error?
dont reload plugins
😐
Well then you dont unhderstand it 😐
I'd simply store the itemstacks. unless you're giving those items away, in which case obviously only give clone()s of that itemstacks away
that's exactly the reason why you must not use /reload
if you changed any .jar files: restart the server. if you only changed config files: the plugin should have its own reload command for that
is there a way to set a recipe here as craftable?
already did that
hm that's really strange because it's totally working fine for me in my custom crafting manager plugin
let me compile it again for 1.18.1 and try again
@golden turret working 100% fine for me. Can you maybe show your FULL code on github or sth?
yes just give me some time
sure
btw I'm using this to register my recipes in all my plugins with custom crafting recipes: https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/de/jeff_media/jefflib/RecipeUtils.java
Maybe check if you're doing something a little different or sth?
basically is that
ignore the lines with my nick
it was just to clear my recipes
to dont affect
hmmm
you're mixing ExactChoices with MaterialChoices
maaaybeee
maaaaaybe
try to only use ExactChoice
then I have no idea, maybe wait for md_5 coming online and ask him directly
or create a forums post too
can't hurt to ask there as well
because I have no idea
because i created a recipe 1 materialchoice and 1 exact choice
right there
all I can say is that I have a plugin that allows to use custom recipes using configs and it's working fine
and at least the recipe was marked as craftable
and it also relies on PDC tags to identify its own custom items as ExactChoices
erm but wait
you're still using that wlib thing
did you write that yourself?
if you where's the source for that?
yeah okay then
it must be something wrong with how you are handling your Items internally
just for fun: try to print out the ItemStack when registering the recipe
and also print it out in the CraftItemPrepareEvent or however its called, the item that actually gets inserted into the matrix
and also print out their hashcode
see if both are the same
just as an idea for debugging
I suspect at least either the toString or the hashCode will return sth different for the actual recipe item and the item you try to use
k
can you maybe also push your WLib changes? I'll try to also do some debugging
any other dependencies required that I need to install locally?
just the respective spigot versions?
yes
I got them all on my nexus so that's no problem
🙏
just push your changes and I'll see whether I find something 🙂
just did that
okay gimme some minutes 😄
(probably longer lol)
pls teach me 1 thing @golden turret
what gradle task do I have to run to get WLib to my local mvn repo?
I have no idea about gradle
gradle publishToMavenLocal
thx
I now get this
C:\Users\mfnal\IdeaProjects\WLib\core\src\main\java\com\wizardlybump17\wlib\WLib.java:5: error: cannot find symbol
import com.wizardlybump17.wlib.command.reader.EntityTypeArgsReader;
^
symbol: class EntityTypeArgsReader
location: package com.wizardlybump17.wlib.command.reader
forgor
pushed
k 1 sec
oki worked, thx
okay and how do I now build the finished .jar in the actual plugin? ^^
I find those gradle tasks so confusing
with maven I always just do mvn clean install and done 😄
gradle shadowJar
How can i get the players prefix when they talk in chat? This isn't working for me.
import net.luckperms.api.LuckPerms;
import net.luckperms.api.model.user.User;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
public class Events implements Listener {
TestPlugin plugin;
public LuckPerms lp;
public Events(TestPlugin instance) {
plugin = instance;
}
@EventHandler
public void onChat(AsyncPlayerChatEvent e) {
Player p = e.getPlayer();
User user = lp.getPlayerAdapter(Player.class).getUser(p);
if (user.getCachedData().getMetaData().getPrefix() == null)
return;
String prefix = user.getCachedData().getMetaData().getPrefix();
Bukkit.broadcastMessage("test");
Bukkit.broadcastMessage(prefix);
e.setFormat(plugin.getConfig().getString("PREFIX") + prefix + e.getPlayer().getDisplayName() + ": " + e.getMessage());
}
}```
ERROR:
https://www.toptal.com/developers/hastebin/wilajanile.properties
There are no errors loading the plugin. Just when i talk in chat, there is no prefix that shows. Only my name
^ yeah lp seems to be null
the error message even says "this.lp" is null
your IDE should have underlined your usage of lp.doSomething too
Nothing is underlined. It says there are no problems found. Would i be easier to use LP for the groups, or using Vault?
Where do I get those classes from? Is there a specific library? (1.18.1 Spigot API)
vault
from the nms
?buildtools
are you using remapped?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Now how much easier is it tho? Because i feel like im close right now using LP.
It seems like you use the remapped spigot .jar but try to use the old obfuscated names for classes
i would use vault because it will work with any permissions plugin
There is no EntityPlayer or PacketPlayOutWhatever in the mojang mappings
Yeah, always use Vault instead of directly accessing LuckPerms
Gotcha. Its just all the examples and stuff about vault are outdated that ive found. Are there examples somewhere that are updated?
Although tbh noone really uses any other perms plugins except really big servers who don't bother to update because they suck and are stuck in the past
vault basically hasn't changed in 7 years
Yeah that's probably it. I am kinda new to the seperated libraries I gotta be honest lol.
I want to update a Spigot 1.8 API Plugin to the current version (Spigot 1.18.1)
okay you'll have some work to do then
EntityPlayer is called ServerPlayer IIRC
and it's in another package as well
PacketPlayOut... is now called Clientbound...
Wait, are those custom items as ingredients?
yeah, RecipeChoice.ExactChoice
yes
There would be nothing like this right? I wish xD
e.getPlayer.getPrefix()```
I think it exists since a loooong time already 😄
but yeah I also tend to miss new things
So how do I setup the thing you mentioned?
e.g. BlockFace#getOppositeFace
you will have to manually check what the classes are called now
how many classes do you get errors for?
if it's a few, I'll look it up for you
I was messing with the ShapedRecipe object again and I don't see where it supports anything other than Material
give a list of all classes that can't be resolved pls
hm on 1.18?
Oh
It exists since AT LEAST 1.13 IIRC
Actually before I'm going to list them
😄 everyone is, sometimes
Yeah well I'm one at all times 😎
Do you know how to solve the following problem with Inventory titles? Gotta identify my inventories and I figured out that is kind of outdated what I've done back then.
hm you should rewrite that anyway
you should never identify inventories by their title
Also do you know the SUCCESSFUL_HIT updated sound? (Villager buy sound)
The enum value seems to got deleted
nah sorry you'll have to look through the list and see for yourself
it was probably just renamed to something including "VILLAGER"
just try it with /playsound
Aight thx
Yo @golden turret
Shall I also include the previous packages?
any idea why I get Cause: error: invalid source release: 17 although I set intellij to run gradle with java17?
my OS's default JDK is still 16 but I set IntelliJ to use java 17
give me the full class names, including package names
I'll try to find the new names for you
this is in wlib?
no wlib built fine
Yeah I think I don't have all packages left
it's the plugin itself
I spammed the Import Hot key on some classes sometime ago so some got lost i think XD
02:16:06: Executing 'shadowJar'...
> Task :compileJava NO-SOURCE
> Task :processResources NO-SOURCE
> Task :classes UP-TO-DATE
> Task :shadowJar UP-TO-DATE
> Task :api:compileJava FAILED
2 actionable tasks: 1 executed, 1 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':api:compileJava'.
> error: invalid source release: 17
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 318ms
02:16:06: Execution finished 'shadowJar'.
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists```
I try my best tho
ugh
gradle.properties
there's no gradle.properties lol
do I create it in the root? or inside bukkit or api?
gradle/
create gradle/gradle-wrapper.properties
/wrapper
oh yeah
yeah and what do I add there?
distributionUrl=https://services.gradle.org/distributions/gradle-7.3.2-bin.zip
it should be there 🤔
my intellij config is like this
btw can u go to build.gradle
in settings
yeah one sec
not project settings
ah yeah that was the problem
no idea why it has an additional setting for that
got it compiled, ty
- GameProfile (com.mojang.authlib.GameProfile)
- Property (com.mojang.authlib.properties.Property)
- Base64 (org.apache.commons.codec.binary.Base64)
- EntityPlayer
- CraftPlayer
- PacketPlayOutSpawnEntityLiving
- PacketPlayOutGameStateChange
Only ones i could find so far.
I update you if i find more
Nope
oh FML
Dunno what that even is
hm
Just some plugins some1 recommended me to use
well anyway
so
class and and two are still called the same, but they are in their own .jar file now
y that sucks
you can find it by doing this:
Run Buildtools
Extract the final .jar
go to META-INF/libraries
they should have kept it the way it was
im on it hold on
https://www.spigotmc.org/threads/recipe-book-not-working-with-nbt-ingredients.507642/ https://hub.spigotmc.org/jira/browse/SPIGOT-6794 bruh
what's the advantage using maven
you don't have to do many things manually but just click a button
I am tired of using third party softwares like git, maven etc.
hard to explain in less than 10 sentences
you are only tired of that because you never saw the benefits
You know i was used to only have Java, the JDK and my Eclipse on my PC to get started
I hated it too at first
Okay okay lets setup maven then first
in fact, you can see how much I hated it at first, one sec I'll get the link
Ty
Anyone know a non nms way to make a ridable enderdragon like in hypixel (looking for 1.18)
native minecraft source
https://github.com/JEFF-Media-GbR/ChestSort/pull/7 See? I HATED maven at first. Now I would never go back
However i always made a Enderdragon using the specific class for it. then i put the player as passenger and kinda made the enderdragon dealing 0 dmg or not evne attacking the player dunno how anymore tho lol
but it's working fine in my lib that only uses PDC
fuckign hell i dont want to read
you use eclipse right?
i will try using items manually them
now dont tell me to switch to intellij
any change you MIGHT switch to IntelliJ? Because I know that eclipse HATES projects being converted to maven
just a question
alex got a point
that was the reason why I hated maven

Spigot changed in a fucking bad way
because eclipse gets confused when converting an existing eclipse project to maven
nah you just missed the last century
shall I move my plugins to the bin and reinvent them?! xD
spigot got better and better with every release
Yeah cuz i have a life xD
prob is a ton changed in the newer versions that makes it really hard to do it...
There was a time I was really good at Spigot Coding
Seems like I gotta relearn thingsn ow
okay @thick gust we can try it using eclipse
Great as well
I want to steer clear of nms because im not too good at it and don't wanna learn at the moment
No fuck it i go all in
create a new eclipse project, tell it to use maven
Lets go IntellIj
okay that's easier
Got a cracked version
Like I know it... just not that well
Whatever
lol
and stop using cracked things
I already have it
free version is more than you ever need
Homie just installed a virus ☠️
Dunno if my workspace is correctly but yeah
alright. did you import your eclipse project?
Bro i forgot if this was the free version or not
Oh yeah should already tell you
You can’t have a view of every project in IntelliJ
I installed a lot of JetBrains software KEKW
right click your project's root folder -> add framework support -> maven
Yes ik it’s a bit anti eclipse cult
Wait wait wait
Do I have to rightclick EVERY PROJECT
And add this?
Or just a single workspace?
oh wait
Also can you tell me how to import eclipse projects?
you opened your whole eclipse workspace dir lol
Yeah xD
I want to import them once again to make sure i didn't miss any changes i just did while using eclipse u know
File -> Open... -> Choose your plugin folder that you used in eclipse
First of all lets do that
NOT the whole eclipse folder
Import whole workspace won't work? 😄
just your projects folder
Okay okay ._.
lets create a thread
how could i create a new PersistentDataContainer? 🤔
Yeah that will be fine. I'll do the same atm with VS Code lol
because i want to use a map
#getAdapterContext().newPersistentDataContainer()
sometimes you do
you very rarely need to create one
anyone know what im doing wrong?
no
So click No?
@thick gust please create a thread in this channel
nvm, i just saw what i wanted to do
so, i changed EssenceTier#getBaseItem and Essence#getItem to raw pdc
and Essence.fromItem stopped working
no progress
if someone wants to see https://github.com/WizardlyBump17/WSpawnerEssence
wait
How i can convert a String Array in a String? Example: My array contais "A" and "B", i need "A B"
String.join
How would I get the total count of an item a user has in their inventory that has a certain lore and item?
iterate the inventory and check whil you increase an integer
How would I actually get the amount in a slot though?
does some1 know the new class for PacketPlayOutGameStateChange mojang remapped?
md_5 can you add a method so I can modify the Age value of entities?
not ticksLived
✨age✨
I want to make items like I can with this command /summon item ~ ~ ~ {Age:-32768,Item:{id:"minecraft:bow",Count:1b}}
to make them just not despawn without having to mess with the ItemDespawnEvent
@hexed hatch setTicksLived does this for items
public void setTicksLived(int value) {
super.setTicksLived(value);
// Second field for EntityItem
item.age = value;
}```
then why doesn't it allow for negative values
It gives me an error telling me no
and that makes me very sad
I often wish I was alive for -32768 ticks
Mood
btw is there really no table for spigot packet names / mojang packet names?
yeah ok, so we do need something at least for the special case of -32768
open a feature request
gay
stop talking about gay stuff, I'm the only one here allowed to do that
that's kinda selfish
anyway @sullen marlin small question: do you know anything about the recipe book having bugs regarding to Recipes ExactChoices?
everyone has the right to gay it up as they please
yeah alright I take it back
software developers
yes there's already a bug report, and its either a client bug or a very hard to fix server bug
and their rampant homosexuality
hmmm you got a link to that bug report?
I suspect it is at least partially client related
I didnt find anything regarding it
most software devs are LGBT in some way
because my lib works fine with ExactChoices including itemstacks with custom PDC data
especially because the server doesnt have anything to do with the red/green outlines or 'can craft' stuff
and if they aren't
but I checked the source of the person who had problems with it today and the code seemed totally fine to me
they're just not very good at software dev
thanks
or furries
but you would know that, wouldn't you?
yeah that's exactly the problem. However I wonder when it occurs because my custom crafting lib thingy didnt have this problem
really strange
uwu lol

@golden turret https://hub.spigotmc.org/jira/browse/SPIGOT-6794
does someone want to make my jira feature request for me so I don't have to?
yes
god yes
all I see is a ton of patch files and I don't understand them
you take and don't give, don't you
the final .jar?
yes
@lavish hemlock hey baby wanna make my jira post for age -32768
uwu no
@golden turret I didnt change anything in the lib's source
I don't know how to use JIRA
oh my god
yes
literally worthless
but im in phone rn
well, I do, but I don't know how to with Spigot's system lmao
ah okay
and i need my lib
DM me pls
😭 you're so abusive
and tell me again your group id you used pls
cry about it
talking with me?
yes
DM me
and tell me your group id for wlib
otherwise I wont find it in my repo
com.wizardlybump17.wlib
ok one sec
If the issue is on Jira someone will look at it eventually
coll sweetheart honey gravy baby darling wanna make my jira post for me
also, do someone know a online app that can compile my source code from java?
make like a stereotypical black grandma and compare people to desert items, puddin'
im in phone rn and i need to build a plugin
lol
grandma grindset
can you not get to a PC in the next 24 hours
how could you need a plugin that urgent
it's hard md
this is why I have a laptop
bed warm and cozy, everything beyond it is pain and suffering
people do all of the best things in beds
😏
sleep
eat
fuck
watch TV
browse memes
what about us
eat
so true I do in fact do most of these things
bruh
well
bed snacks are great md
drop the judgement
/j-esus christ I'm joking
licking the crumbs sensually off of your covers
yes love sleeping in crumbs
I can relate
that's why you lick them off
or alternatively you just wear like
50 layers of clothing
so you don't feel them
but md_5
btw md_5 I'd like to insult you but I won't
for years I wondered how the auto responder worked on spigotmc
where is the others md_?
yeah if you live in siberia
and then just by accident discovered there's a donor forum and it's explained there
or just grow up and live with the crumbs
is it legal to marry crumbs?
wtf even is a "crumb"?
your mum
gotem
😳
HA HA HA
ha
fucking destroyed
There’s an auto responder?
a small piece of food
like when you eat a biscuit and pieces break off onto the floor
god he's so wise
or in this case your bed
my bf recently destroyed my bed and now I don't know what to do
demand a new one
MD is available
Rainbow profile.
he also destroyed my expensive keyboard
by spilling beer over it
and it wasn't even proper beer
sounds destructive
it was some "energy drink / beer mix"
that is the worst thing I have heard of
what the fuck
my dad mixes like
nah he just tends to be a bit clumsy when he's drunk
gatorade and energy drink
I think
he insists that it's good but he's also the kind of person to enjoy peanut butter + sardines
nah we got "pre"-mixed energy/beer things in germany. pretty disgusting if you ask me
beer
I'd say yes but I have my eyes on someone else rn
Here‘s the fool + the disgusting „beer“ on one pic
it's not even allowed to be called "beer", it may only be called "mixed beverage including beer" lol
Ingredients / allergens
70% beer (water, BARLEY malt, hops extract), water, sugar, carbon dioxide, acidifier citric acid, aroma, guarana extract 0.04%, antioxidant ascorbic acid, taurine, aroma caffeine, caramel sugar syrup
the fk
bull semen
what
yes
I am disappointed I cannot purchase this abomination in australia
you are disgusting
don't tell us what to do
:imagine:
only mdaddy_5 gets to tell us what to do
CO2?
kill me
Is it carbonated
Yo gamers, is it ok for me to use one of the existing minecraft items png files, just color shifted for my custom item in my resource pack?
I don't think doing so has ever been a problem for anybody
Should be fine as long as you don't try to sell them or something
awesome =] I figured it was probably fine, mojang seems to be pretty chill as long as you aint trying to make money
Is there a way to know if a player right clicked on a customblock from a datapack ?
define custom block
custom blocks really aren't a officially supported feature
but my go-to is using the petrified oak slab variants
How do I go about damaging an item? Doesn't seem to be anything related to durability in the ItemStack or ItemMeta classes
what?
Damageable
Hmmm is that something I would have to cast to? A flag I have to set?
I know there is an unbreakable flag
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/meta/Damageable.html Lookin like I may have to cast the ItemMeta I am getting back to a damageable?
What is setDurability then?