#development
1 messages · Page 147 of 1
No need to spam every channel
Chat Chat Chat
the plugin. yes. and the event is called ChatChatEVent
because we're creative
like that
as the cool kids say, our imagination is bussin or something
Busy? 
no cap that shit is bussin
yeah it is that
e.getCaught() probably returns null
you might want to check that first before setting it to something else
I'm having an extremely odd issue.
I'm looping through my plugin's config which is similar to this:
tasks:
break:
- OAK_PLANKS:10
place:
- BIRCH_PLANKS:10
This is the loop I use to retrieve all of the items.
HashMap<String, Integer> map = new HashMap<>();
String path = "ages." + age.toString().toLowerCase() + ".tasks";
for (String key : plugin.getConfig().getConfigurationSection(path).getKeys(false))
{
for (String material : plugin.getConfig().getConfigurationSection(path + "." + key).getKeys(false))
{
Bukkit.getServer().getConsoleSender().sendMessage(material); // Logs the items in order
int amount = plugin.getConfig().getInt(path + "." + key + "." + material);
map.put(key + "." + material, amount);
}
}
Bukkit.getServer().getConsoleSender().sendMessage(map.toString()); // Incomplete map?
Whenever I print inside the loop, it prints all the items in the config; however, whenever I print the map itself, it only contains a few of the items. Can anyone help? Thanks
OAK_PLANKS:10 is in a list, not an additional key, but your search for more keys (getKeys(false))
Whoops, my bad. It's actually written like this:
tasks:
break:
OAK_PLANKS:10
place:
BIRCH_PLANKS:10
should work
Inside the loop it will print these properly, I just don't know why the map is missing items.
theres no reason it shouldnt work
the key for the map might not be unique
but tbh all that string concatenation stuff is just a huge source of issues
you have 47 items, tere's 47 items in the map
Hm, I guess I went to far on the trace. Let me see if I can find where it messes up later on.
Okay, it seems the issue was with how I was displaying them in my GUI, and I misread the console. Thanks for helping out! 🙂
#config.yml
chat-format: "%luckperms_prefix% &7%player%&8: &f%message%"```
```java
//code
@EventHandler
public void ChatFormatting(AsyncPlayerChatEvent e){
String msg = e.getMessage();
Player p = e.getPlayer();
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
msg = PlaceholderAPI.setPlaceholders(e.getPlayer(), msg);
e.setFormat(ChatColor.translateAlternateColorCodes('&', getConfig().getString("chat-format")).replace("%player%", p.getDisplayName()).replace("%message%", msg));
}else{
e.setFormat(ChatColor.translateAlternateColorCodes('&', getConfig().getString("chat-format")).replace("%player%", p.getDisplayName()).replace("%message%", msg));
}
}```
whenever i use a placeholder from PAPI in Chat-format from config.yml it throws an error in the console and gets back to vanilla chat format, any idea why?
the error in console is Could not pass PlayerChatAsyncEvent event to ChatterPlus 1.0
probably because the placeholders aren't actually being parsed so your format contains % in it
what do I have to do ?
well make sure your message doesn't contain % after its being parsed
yea what exactly does parsed mean? ik I'm stupid
should I make the built-in-my-plugin placeholders like {PLAYER} and {MESSAGE} so it doesn't contain %?
that's what the setPlaceholder method does. it parses placeholders.
?
well I Mean the problem is most likely not in there. since if anyone adds % anywhere in their format, it will still start throwing. Best solution is to use paper instead of spigot. But if you don't want to, then check the format for % first, then remove them and maybe even show a warning in console
yea I already use paper
well then use their AsyncChatEvent instead
alright thanks!, but do I have to do something else after that? I'm not currently on my pc
well you'll have to see how that works first. bcz it works completely different than AsyncPlayerChatEvent
everyone here uses gradle or maven to build their jars
rather than intellij's default sussy build tool
maven is just as sussy if not more sus
dont you dare sus maven
stop me
🛑
you'll need to add that package as a dependency
if you havent already
syntax seems right
is the package on maven central
maven central is the main and default repo for dependencies
thats where maven usually downloads all the external libraries from
tbh i dont think i understand the entirety of maven well enough to explain it well to you
id recommend watching a few video tutorials on it
nicee
Okay, maybe it's just me. But I swear this should work 
public static void openWarn(Player player, String reason) {
ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
BookMeta meta = (BookMeta) book.getItemMeta();
meta.addPage("Reason: " + reason);
book.setItemMeta(meta);
player.getInventory().addItem(book);
}
Does somebody see what I did wrong?
When I open the book it just says * Invalid book tag *
Just set the build directory to your local server, it should overwrite it.
what
i geluess that would replace the jar but it wont update it, your server will still be running the old jar
that's also a very silly way of replacing it, if you're on linux you can just mv the new jar into the old one
Does Bukkit.getScheduler().runTaskAsynchronously() create new threads?
No it doesn't
It uses a thread pool
I mean it will create new threads at first, obviously it can't just like run stuff on threads that are never even created, but they are reused
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java?until=4f34a67b5ed70f88ef857d13de1ee3ec433f0ad7&untilPath=src%2Fmain%2Fjava%2Forg%2Fbukkit%2Fcraftbukkit%2Fscheduler%2FCraftScheduler.java#99
Thanks!
Hey, I'm having some problems with p.setHealth();
for some reason it gives me an error when i use p.setHealth(0); or
p.setHealth(0.0); or p.setHealth(0.0D);. Does anyone know why?
what error?
Use https://paste.helpch.at/ for errors, logs and configs. So we don't spam the discord.

did you solve the issue?
No.
can u send the entire class?
Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
• HelpChat Paste - How To Use
can u send line 29?
p.setHealth(0);
Huh
wait what
Oh I misread the exception
but hmm
was there any more to the stacktrace/error? or is that it
That's it.
all I can think of is some other plugin / some listener in your plugin doing some dumb stuff in the death event causing it to blow up
but that looks very weird and incomplete
Usually EventException would lead to another error but not sure why it'd error in setHealth
Oh wait check in a player death listener
oh wait
Emily
already beat me to it
:((

Do you want to see the death listener?
sure
Well, it has a lot of code. So might be hard finding something.
It might be because I set the player health to 20 in the death listener.
but that's the killer
so it shouldn't be related
No I also set player health.
still quite weird how the error doesn't contain what the actual error is
of p?
Yes.
So that the respawn screen doesn't show.
what version?
1.8.8
Yes there is the spigot.respawn thing.
note that it doesn't work on newer versions though - or I think you can change some gamerule or smth
Oh
why not use that?
or maybe try setting health and all that a tick later
That teleports the player to the spawn point, I have a location in config.
but can't you #teleport?
I haven't tried that..
and if the spawn plugin overrides it, try a tick later
but respawn should call respawn event and so you should be able to do it on the same tick
anyways I gtg, but try that and see how it goes 👍
I don't think It does call respawn event.
oh then try a tick later
Yeah, I'll try that.
🥰
that doesnt exist
also, just removing the % doesnt work either
declaration: package: io.papermc.paper.event.player, class: AsyncChatEvent
Ohh cause i though he meant like use paper on your server
but im using the Spigot API
thx ill try it
[ERROR] Failed to execute goal on project ChatterPlus: Could not resolve dependencies for project
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.19.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>```
have you added the correct repo?
yea
<repositories>
<repository>
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.19.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.2</version>
<scope>provided</scope>
</dependency>
</dependencies>```
do they have a 1.19.1 repo out? you might want to try 1.19 instead since the 1.19.1 minecraft version has not been released yet
tried that too, but I asked in spigot forums and I will later try cancelling the event and broadcasting a new message to the server using a custom format from the config
that's an option I guess, but you need to be careful as it might break compatibility with plugins like DiscordSRV, which rely on the uncanceled event and are listening for it with the MONITOR priority
DiscordSRV Chat logging channels have their own formatting anyways
yeah but they won't be able to get the message at all if you cancel the event
is what I'm saying
When I try to compile my project I get this, https://paste.helpch.at/qepibaguze.sql. Any idea what is causing it and how to fix it? My pom: https://paste.helpch.at/ahiwamuwug.xml
thats the fix using gradle, but its probably pretty similar to fix for maven
https://stackoverflow.com/questions/67997715/maven-compiler-plugin-unsupported-class-file-major-version-60
here's a maven one actually. you might need to update your maven-shade version
Ahh, that was it. I simply changed the version 3.2.4 -> 3.3.0, I thought the java version was the problem as I just changed it from 16 -> 17.
Thank you!
public void getName(Player sender, String nick) {
for (String key : OreNLore.getInstance().getPlayerNicks().getConfigurationSection("data.").getKeys(false)) {
nickMap.put(UUID.fromString(key), OreNLore.getInstance().getPlayerNicks().getString("data." + key + ".nick"));
if (nickMap.containsValue(nick)) {
String realName = OreNLore.getInstance().getPlayerNicks().getString("data." + key + ".realname");
sender.sendMessage(realName);
} else {
sender.sendMessage("doesn't exist");
}
}
}```
I'm trying to loop through yaml file to get the realname of the player, but I only want to get the name of the player that's connected to the nick value. What steps should I take to ensure I can only get the real name of the player that's connected to the nick.
Here's my yaml file:
```yaml
data:
fbfbfe36-a993-410f-abc9-85ea7fcf55b4:
nick: InsideIntel
realname: InsideIntel
b0c6ef0c-2d98-4ae4-83cb-6fa1163be32d:
nick: test
realname: ChakyClan
right now I get an output of
InsideIntel
ChakyClan```
You loop through everything, and just display what's in it, you need to retrieve the nick and realname for your config entry, check if it matches, if it does break the loop and return, and if it doesn't, continue the loop
Isn't that what i'm doing other than not breaking the loop?
Not really, you just check if your nicks map contains the given nickname, however it doesn't check to which player it belongs to
In that case, do i even need the .nick and .realname in the yaml file being i can get the player name from the uuid itself?
or is it better to do it this way
Well yes, since if you want persistency, you need to somehow link the player to the nickname, you wouldn't really need the realname, since you can just use uuid and get their name through the player instance
now time to figure out how to do this, been trying to figure out how to just send one players name
alr, thx for ur help, i hope i can figure this out, my brain doesn't like yaml files
Some pseudo code that will help you a bit probably
String getName(sender, nickname) {
loop (your entire list of config data) {
nickname = the nickname retrieved from your current loop iteration
if (nicknames dont't match) {
continue the loop
}
otherwise return the realname for this player using the uuid key value, with Bukkit#getPlayer(uuid)#getName
}
}
Hopefully that makes sense
You'd also only need something like this in your storage
data:
uuid:
nickname:
uuid:
nickname:
(also, don't forget to strip the strings of color and formatting)
np, good luck
How would I do this if two players have the same nick?
Well you wouldn't, since you wouldn't really be able to tell which player you're targetting
Well
for if players have the same nick, I want to send both of the players, not just one
or well all of the players i guess
Well then have it return a set of players, you'd do the same as now, just not break the loop
Is is possible to detect when player opens his inventory?
(i've read that its client side, so no packet is sent, aka cannot be detected)
Nope

Which is bs
ikr
i wanna make a conbination of actions "keys"
to open player storage (like backpacks or vaults)
which conbinations do you think would be good to use
Combination?
(looking for more than 1 conbination)
i mean, first idea was when player sneak and inmediately opens inventory
but since its not possible to detect, idea is not valid
conbinations like: double shifting
or shifting and clicking, etc
Some use the knowledge book from player's inventory
like a shortcut to open inventories

any idea about actions
like sneaking (not jumping please)
and that stuff
damn, sneak + open player inventory was such good idea
they only way would be using mods to detect key pressed

You could detect on inventory open using the event if they are sneaking and just take over
What?
player pressing E to open his inventory is client side
d; OpenInventoryEvent
public class InventoryOpenEvent
extends InventoryEvent
implements Cancellable```
InventoryOpenEvent has 1 extensions, 1 implementations, 1 all implementations, and 6 methods.
Represents a player related inventory event
^
i know there is an open inventory event
but all forums i read says it's client side
when opening player inventory
yeah i think it is until they click something
yes, but the idea is listeing to open inventory, not clicking it
that breaks the magic
so idk what other key combinations to use
since E is not an option
any good idea?
I read about it, like in more than 10 posts
Okay
https://www.spigotmc.org/threads/how-to-check-when-a-player-opens-his-inventory.347367/#post-3222168
A player opening their own inventory isn't something the server receives, yeah
The client just does not send the info and the server considers it to be "open at all times"
Not quite
Only if they're moving stuff around the inventory and also moving in the world
Which applies to any inventory really, since it doesn't make sense to move stuff in an inventory if you're moving in the world

some people use F, you could use sneak + F
and by F, I mean to switch items to your offhand
You can use RecipeChoice.ExactChoice
rip
List<Recipe> recipes = Bukkit.getRecipesFor(item); is what I use.
1.8.8 -> 1.19
As long as the items were added to bukkits recipe list and aren't added as a result during an event the code I provided should work.
If its your recipe... Add it to the list properly.
How do you add the recipe?
Ok then you aren't doing what I said xD
Lets say I send a packet to hide an entity from a player, once they tp to another world and then tp back, the entity is now visible, do i just check if the player is near the entity and resend the packet or send the packet every second or smth
cause i think they can also walk out of render distance and back in and they can see the entity again
and i dont wanna check nearby entities every tick or move event
you can set the result as an itemstack, but you cannot set an ingredient as an itemstack
hey im trying to make a config.yml to change the message, but it shows this error
Use https://paste.helpch.at/ for errors, logs and configs. So we don't spam the discord.
my /fly code:
https://paste.helpch.at/sugubetene.bash
my config.yml:
https://paste.helpch.at/yekamonoci.makefile
my main.java:
Line 10 in your utils class, you'll probably find the issue there
I guess either main.getConfig().getString("fly-enabled") or main.getConfig().getString("fly-disabled") returns null, hard to say as you stripped too much context
Anyone know how to forcefully perform a thread dump on a spigot server
Or with ptero panel?
like the jstack output?
no, it's just all the stacktraces
For all the active threads?
yeah, active and waiting, both jvm and application threads
well jstack is nice if you want to run it from outside the server
Sorry, is that a java program?
yes
Hmm, I'm not sure if I would be able to set that up
Theres no way I could do that from within a plugin?
there are different ways for that
like there is Thread#dumpStack() and Thread#getAllStackTraces
Essentially, my issue is that Java is creating way too many threads and causing my server to "crash"
So I need to analyze the threads to see what's creating so many
This will help, thanks
for that you can probably use JFR too, not sure
Ill look into it, thanks
https://bestsolution-at.github.io/jfr-doc/openjdk-17.html#jdk.ThreadStart you'd need to look up how to actually record that event, but that sounds like an easy way to find out where the threads are coming from
ok, lemme try
you need to listen to the packets and cancel the ones / allow the ones that would normally show or hide it
after the initial disable you do