#development
1 messages · Page 122 of 1
sry sry lmao i got distracted
when the number key check is outside of if (event.getCurrentItem() != null && event.getCurrentItem().getItemMeta() != null) it works
if (event.getClick() == ClickType.NUMBER_KEY) {
event.setCancelled(true);
}
if (event.getCurrentItem() != null && event.getCurrentItem().getItemMeta() != null) {
ItemStack item = event.getCurrentItem();
if ((item.isSimilar(Morph.skeletonBow()) && slot == 0) || (item.isSimilar(Morph.skeletonArrow()) && slot == 27)) {
event.setCancelled(true);
}
}```
but then it applies to every slot
if i remove the slot == X then it works (except it affects the item no matter slot its in)
Should I be going for something like this or should I just make an action system instead?
I feel like an action system would be better in the long run but maybe a bit harder to understand?
code: https://pastebin.com/8STk4WWR
I am having trouble figuring this out-
essentially what my intentions are is to get the command to send what the player put for the arguments of the command as a chat visible to all players
However, it is showing up like this;
Use string#join
I don’t think u can pass array like that
Args is an array Either use what Blitz said or Arrays#toString or use String Joiner
String msg = Arrays.toString(args); ?
Actually i am a bit doubtful abt tht
It at least shows the message, but default includes "[]" and commas between the args
Use string#Builder and append each element
I was gonna say that it will include those brackets and comma
How do I use string#Builder?
Hmm…Phone sucks😅
actually. string#join shouldn't add the commas and []
you should be able to specify a separator
what am I talking about
Wait…there was something like StringJoiner or so which we can specify Delimiter right?
There are multiple String Classes…i am actually confused what all does what 😂
how do you put an itemstack into an armorstand slot? I cant find any method that does so 
the String class has a join method
like a skull into a armorstand's head
There is a setHelmet method right?
deprecated
d;spigot EntityEquipment#setHelmet
void setHelmet(@Nullable ItemStack helmet, boolean silent)```
Sets the helmet worn by the entity
helmet - The helmet to put on the entity
silent - whether or not the equip sound should be silenced
String msg = String.join("", args); such as this?
guess gotta use the deprecated one, ty tho
It isn’t
This worked, thank y'all!
then I'm getting it wrong
d;spigot LivingEntity#getEquipment
@Nullable
EntityEquipment getEquipment()```
Gets the inventory with the equipment worn by the living entity.
the living entity's inventory
Then you do ^
I'm just doing this, I dont understand
You don't need the second setHelmet, you're already setting
issue still persists
same with this question
ping me if u reply to either
Is it possible to create a world that's say 1000x1000 and the rest would be void outside that?
You should share full code or at least full click event in a bin to be able to reply. As i said, number key is also cancelled when click event is cancelled, thats of course when checks are made correctly (i have no idea if thats your case).
If its a GUI for a plugin, then you should cancel at the beginning when the inventory is recognized and use slots instead of checking items, idek what you are trying to do tbh
Possible? Yeah, most likely. How? I have not clue, probably using world generator
I was thinking maybe create a world generator that uses the default world generation unless getting x amount of chunks away from the spawn. However can't seem to figure how to get the default world generation
how i can define a player in other methods?
Wdym
i need to get player
for papi config
i dont know what im doing
but its not work
i want to put papi in config but i dont know how i can do
ok now its work
but still dont know how to get player
im using this
static CommandSender sender;
public static Player p = (Player) sender;
for get player because i dont really know what i can do
its from my CommandHandler to Core
its no work anymore bruh
is anyone able to help me with lp api
papi dont work
lol
https://github.com/xNotro/PlayerInfo/tree/master/src/main/java/org/xnotro/playerinfo
(EventManager) papi hook
i dont know whats wrong but papi make my %something% invisible
if someone know how fix this bug please ping me.
it works
really?
https://imgur.com/AqSmLV9 bruh no
why papi dont replace thing??
do you have the expansions installed?
Is it possible to change a player's glow color without changing their username color too?
Oh dear, that's a lot of static
yea yea
i need to remove much of statics
check code
oh its in EventManager
yup
🤔
there i can get the player
if i remove it works
to assign the playerNameMessagePAPI etc variables (EventHandler), but I don't even see where they use that variable
just using random tut from internet
its just found only hooking
where do you use playerNameMessagePAPI
PlaceholderAPI.setPlaceholders(PLAYER, TEXT); <- this is a String object
PLAYER - player to parse placeholders for
TEXT - text to parse placeholders from
that's all you need to do
and for config?
wdym
the %something% should be use on config
yes
you would preferably have a shorter method to parse the placeholders in and return a string
hm
public static String color(Player player,String text){
return ChatColor.translateAlternateColorCodes('&', PlaceholderAPI.setPlaceholders(player,text));
}
that's what I usually have
this is for color hehe
so what's i need to do?
I think it's pretty self explanatory
you need to return the string with the placeholders parsed/set
PlaceholderAPI#setPlaceholders does that
and how its work this method>
?
like
color(player, getConfig().getString("path");
i dont understand how that should be used.
Hi, my server is on 1.17 and I use ViaVersion so players can join using 1.18 and I just realised that player heads does not show up in menus when im on 1.18...
Please help :/
could you print the value of slot when you try to move the item?
so?
o smart one sec
here is my entire onInventoryClick:
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
int slot = event.getSlot();
if (TeamManager.isUndead(player)) {
// If in menu, don't let them manipulate inventory
if (!MorphManager.isMorphedPersistent(player)) {
event.setCancelled(true);
JoinMenu.select(player, event.getSlot());
}
// If morphed and skeleton, don't let them move bow/arrow
if (MorphManager.isMorphedPlayer(player)) {
for (String key : Main.morphs.getKeys(false)) {
String value = Main.morphs.getString(key);
assert value != null;
UUID uuid = UUID.fromString(value);
Entity entity = Bukkit.getEntity(uuid);
if (entity instanceof Skeleton) {
if (event.getCurrentItem() != null && event.getCurrentItem().getItemMeta() != null) {
boolean skeletonBow = event.getCurrentItem().isSimilar(MorphManager.skeletonBow()) && slot == 0;
boolean skeletonArrow = event.getCurrentItem().isSimilar(MorphManager.skeletonArrow()) && slot == 27;
if (skeletonBow || skeletonArrow) {
event.setCancelled(true);
}
if ((skeletonBow || skeletonArrow) && event.getClick() == ClickType.NUMBER_KEY) {
event.setCancelled(true);
}
}
player.sendMessage(slot + " " + event.getCurrentItem().getType());
}
}
}
}
}```here's video with debug msgs: https://media.srnyx.xyz/java_9zzwig9z50.mp4
whats wronmg?
im trying to cancel number key moving for a specific item in a specific slot
oh
is there a packet for when a player hits another entity?
Does anyone know if you're supposed to wrap the DAO classes with jetbrains exposed, or interact with them directly?
i'm doing the latter rn but it's kinda laggy
You can interact with them directly, you might need a data class as a wrapper depending on what you do but a lot of the times that's fine
Though i am not entire sure I mostly use DSL instead
hmm
when interacting with them directly it seems to be doing more queries than it probably should though
but Idk if that's the caching not working, or intented behaviour
i guess i'll wrap them
19.02 12:49:32 [Server] INFO org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
19.02 12:49:32 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:154) ~[spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
19.02 12:49:32 [Server] INFO at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:133) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
19.02 12:49:32 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:292) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
19.02 12:49:32 [Server] INFO at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:198) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
19.02 12:49:32 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:525) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
19.02 12:49:32 [Server] INFO at java.lang.Thread.run(Thread.java:748) [?:1.8.0_292]
19.02 12:49:32 [Server] INFO Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
19.02 12:49:32 [Server] INFO ... 6 more```
but i dont see any problem with my plugins.yml
name: Discord
version: 1.0
author: Convace
commands:
discord:
description: d
usage: /discord
permission: discord.use```
the problem is that it doesn't exist
plugin__s__.yml?
it's in the packet
oh lmao
@Nullable
public <T extends BaseUser> T toUser(
final Class<T> clazz,
final CosmeticManager cosmeticManager,
final int entityId,
final List<ArmorItemDAO> armorItems,
final Wardrobe wardrobe,
final int armorStandId
) {
// ...
if (clazz.equals(User.class)) return new User(this.uuid, entityId, playerArmor, wardrobe, armorStandId);
if (clazz.equals(NPCUser.class)) return new NPCUser(this.uuid, entityId, playerArmor, armorStandId);
return null;
}
Do I really have to cast here?
yes, because equals is a method that is called at runtime, not something that can be proven at compile time
What does .equals have to do with it?
that's the method that decides what type to return
that doesn't affect it, even without the equals check it still does not work
You're probably right about the runtime part though
what "does not work"?
anything about this?
return new User(this.uuid, entityId, playerArmor, wardrobe, armorStandId);
yeah, what does not work about that? Compilation Error?
Well yeah, you need to cast it
I was doing something wrong, ignore this ^
k I was just wondering if anyone is intrested and if so where would I post that
in this discord server
cuz yk it has devs
in dev general ig
i was able to fix this by doing:
if (event.getCurrentItem() != null && event.getCurrentItem().getItemMeta() != null) {
boolean skeletonBow = event.getCurrentItem().isSimilar(MorphManager.skeletonBow());
boolean skeletonArrow = event.getCurrentItem().isSimilar(MorphManager.skeletonArrow());
if ((skeletonBow && slot == 0) || (skeletonArrow && (slot == 27 || event.getClick() == ClickType.NUMBER_KEY))) {
event.setCancelled(true);
}
}
if (event.getHotbarButton() == 0) {
event.setCancelled(true);
}```focusing on this part:
```java
if (event.getHotbarButton() == 0) {
event.setCancelled(true);
}```
Good to hear you fixed it!
I personally use inventory holder to check if its my plugin inventory
And the first thing i do is cancel it
After that i check clicked slot and do stuff
Nice!!!
Traceback (most recent call last):
File "C:\Users\dumit\test\traduceri.py", line 27, in <module>
main()
File "C:\Users\dumit\test\traduceri.py", line 18, in main
with open(file_path, 'wt', encoding='utf8') as file:
PermissionError: [Errno 13] Permission denied: 'C:/Users/dumit/test/Constantine.S01E01.1080p.BluRay.x264-YELLOWBiRD.srt'```
Any idea how to fix this? 😒
this is the code <https://gist.github.com/iGabyTM/a6f30123f125c35f7133d2121032a6bb>
hi. so. trying to use adventure and relocating it but the question is... MiniMessages are in adventure api 4.10.0-SNAPSHOT, are they also in the bukkit platform version of adventure?
not sure what u mean but you could probably exclude adventure from minimessage
that's the thing... trying to implement mini-message and I get this: https://paste.helpch.at/oqequbabim.apache
try excluding the adventure dependency from minimessage
Have you tried running the program as administrator or elevated privileges' on the drive.
I only need these right?
You also need to relocate tho
both?
Relocate all of net.kyori tbh lol
yes
is there a trick to not define API version in plugin.yml?
set it to 1.13 and call it a day
well my plugin works on 1.8 and on 1.17
Ok
That field was introduced in 1.13 so anything lower doesn't even know it exists
np
tf? https://paste.helpch.at/ciqakejoza.bash
build.gradle: https://paste.helpch.at/rovixixene.cs
relocated it all like you said
if you support <1.12, then you shouldn't specify api-version
unless you want to do Material compatibility yourself
(since spigot already handles it for you)
hm remove the exclude, run gradlew dependencies --configuration runtimeClasspath and share the whole output
Is there any support for bungeecord/waterfall?
for..?
format = PlaceholderAPI.setPlaceholders(player, format);
player is a proxies player
PAPI is for bukkit only
Thats what I was asking thankyou
np
What would be the easiest way to get formatted messages on bungee via papi?
from the adventure api or also triumph-gui?
from mm
none is really "easiest", any form of messaging between server and proxy but that can get pretty convoluted and not nice
I mean the EASIEST way would be to just reinvent the wheel tbh
got told to do so but ye, thanks.
my plugin just got over 1mb size pain

Oh no, a whole megabyte
from 20kb :-:
is it normal that MiniMessage makes everything italic by default?
MiniMessage doesn't heads do
It's not about mini message, that's default in minecraft
It just doesn't override the default formatting
Yes that should fix @worn jasper
Add decoration(TextDecoration.ITALIC, false) to the parent component
the what and what
best version of HikariCP to use?
Someone help. I'm descending into madness
Jitpack gradle not working
It literally finds the artifacts, then proceeds to not publish
https://jitpack.io/com/github/reviversmc/modget-auth/fe9ee4fbaa/build.log
https://github.com/ReviversMC/modget-auth/tree/fe9ee4fbaa1b9febd2087d93788e7eef57819ebe
No need to dunk on Jitpack rn. I don't control the project
Latest I presume!
was running 5.0.0 when I tested and no issues I updated to 5.0.1 and I had a user having issues
if you support java8, latest was 2.3.4 i think (but not latest version)
4.0.3
how would you setup a github action for checking if the plugin's code is good? been checking on it but I'm blind I think
am i doing something wrong? Bukkit.setSpawnRadius(Main.config.getInt("settings.spawn-protection"));
players can still break blocks and stuff
Wdym by "if the code is good"?
also, how can i detect offhand swaps (by using keybind [default f])?
PlayerSwapHandItemsEvent
So I am currently making a withdraw plugin. I am extremely new to plugin making which is why i'm starting off simple.
Also, there are like no tutorials for this which is why I'm asking here. Anyone know how to do this (i'm not asking for code i'm just asking how to get started)
I guess a better way to phrase it is: Can I do hotswapping for java 17-18?
is it a fully functioning withdraw plugin code?
it's terrible code to convert diamonds -> vault -> diamonds
but the code is well tested at least.
so I really don't want to change it
how does hypixel's minions have small heads? while using player heads its just more big
d;spigot ArmorStand#setSmall
void setSmall(boolean small)```
Sets whether this armor stand is scaled down.
small - whether this is scaled down
you can use that, just remove lines 26 - 27
unless you mean like codacy
u can also add a new gradle command like ./gradlew clean test
(idk if the clean is necessary, but why not 🤷)
greet
jetbrains runtime includes dcevm
you can use that with hotswapagent
anyone know an answer to this?
and i have another question
what exactly does .append(stuff) do?
cause in a part of my plugin it replaces each letter of a swear word with *, but it just does result.append("*")
StringBuilder result = new StringBuilder();
If result is a StringBuilder it just adds the star at the end
d;jdk stringbuilder#append
public StringBuilder append(long lng)```
Appends the string representation of the long argument to this sequence.
The overall effect is exactly as if the argument were converted to a string by the method String.valueOf(long), and the characters of that string were then appended to this character sequence.
lng - a long.
a reference to this object.
public static String censor(String message) {
String[] words = message.split(" ");
StringBuilder result = new StringBuilder();
for (String word : words) {
if (Main.lists.getStringList("banned-words").contains(word.toLowerCase())) {
for (char ignored : word.toCharArray()) {
result.append("*");
}
result.append(" ");
} else {
result.append(word).append(" ");
}
}
return result.toString().trim();
}```
i wanna make it instead append &k to the swear word (and then &r at the end)
append(ChatColor.OBFUSCATED).append(word).append(ChatColor.RESET).append(' ')
oh so it matters where the append is?
Yes
ohhh
append is string concatenation but better
^
Iirc string concatenation in java 11+ is faster than string builder
Ofc string builder is still more useful in cases like this
it compiles to stringbuilder anyway
Not in newer versions
oh?
it worked, ty!
I think it was changed either 11 or 15, but it uses a new concatenation system that is faster than string builder, can't find the place i saw it so i could be wrong
i think it was 11
it uses some magic
oh no it was 9
i think it generates the implementation dynamically or something
depends, only if the amount of operands is know. Using it in a for loop will still be slower (+more memory overhead) afaik
Yeah i think so
sir this is #development
Error sent every time a message is sent: https://paste.srnyx.xyz/labepufuda.properties
ChatManager.java: https://paste.srnyx.xyz/ekerovixex.java
ChatListener.java: https://paste.srnyx.xyz/cumojacite.java
config.yml/groups: https://paste.srnyx.xyz/xozebanuxu.yml
messages.yml/chat-format: ```yml
- Chat Format -
%prefix% - Team prefix
%player% - Player name
%message% - Message sent
chat-format: "%prefix%%player% &8> %message%"```
debug the format before setting it at line 46
debug?
print it to console
https://srnyx.has.rocks/java_eqpUOADaWx.png its adding an extra % to the first %s for some reason
omg
he is replacing them before setting them as the format
format = format.replace("%player", "%s");
well most of them

i forgot to add another % after player
how can i invoke invoke Block#breakNaturally() using copied item from hand
i've managed to copy item from hand (+ remove enchantments as that is what i need)
but i don't know how to invoke Block#breakNaturally() like it's broken with that copied item from hand
I'm doing that, but when I set the helmet equipment to the player head it shows big, while hypixel's one is small
Block#breakNaturally(player.getInventory.getItemInMainHand())?
the paramater can be any itemstack.
mainhand is just an example
ok so invoking works like that
thank you, i learned something new today
:DD
invoking? what you on about?
alright i somehow broke another chat thing
since discord doesnt have chat colors, i have to block swears using ****, it was working before (no clue what made it break), but now it doesnt
here's my ChatManager.java: https://paste.srnyx.xyz/motaxawofi.java
and here's a screenshot of the debug msgs: !PROFANITY! ||https://srnyx-needs.to-sleep.xyz/java_CYSzDDfp5c.png||
breakNaturally just has 2 methods.
for the future, if you dont know if something elses then look at the spigot api docs
cause thats what i did
and it tells you when you search breaknaturally that theres a method without a parameter and one with itemstack as a parameter
invoking works like what exactly?
changing
event.setMessage(censor(event.getMessage(), false, event.getPlayer(), group));
to
event.setMessage(ChatColor.stripColor(censor(event.getMessage(), false, event.getPlayer(), group)));
fixes discord anti-swear but breaks in-game anti-swear 
i fixed this! :D
changed String[] words = event.getMessage().split(" "); to
String[] words = message.split(" ");```
Best place to upload plugin code so it can be used in maven
Maven central is such a pain though
DkimTutorial™️ 😌
Do you have a link?
it's not really
if you're having a bad day it can take like.. 30 minutes tops? 10~15 minutes if not
All you need is:
- Set up a sonatype account
- Open an issue and claim the group ID
- Get gpg up and running

trying to install maven central and it is a pain, still not working
no its not
will it run on JAV16?
🥴
I unzipped file and then added Environment Variables
u sure ur not hosting a maven repo
don't I need the Apache Maven to upload it
No
guess i found the wrong how toos to get this done
I want my plugin to available for others to use in their plugins if they choose
IMO the official sonatype guide is fairly understandable (https://central.sonatype.org/publish/publish-guide/)
or if you want i can paste in my DkimTutorial™️
😉
¯_(ツ)_/¯
or theres some stuff on google
if u dont have any experience with publishing or signing etc then imo the official guide isn't enough
I didn't have any experience with either tho but idk, to each their own ig
only admins can set the DJ role of the server!
oops
¯_(ツ)_/¯
lmao
for my latest two plugins to have no errors on a clean build I need to have them on maven, using ajar in library throw's tons of errors
🙈
ok, guess I should of not been lazy and not re-opened my cmd prompt
now for fixing the 5 plugins that don't have working maven dependency
Does anyone know why " &cIncorrect Usage! &7Use &b/appoint help &7to see correct command usage." is not sending when a player does "/appoint"
It's giving an error:
args is empty when someone does /appoint
Oh, so I should just move that into one of the if statements then?
well this should be your first check java if (args.length < 1) { player.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + " &cIncorrect Usage! &7Use &b/appoint help &7to see correct command usage.")); }
and you should be returning there
if (!(TeamManager.isStaff(player) || player.isOp()) && !(player.isSneaking() || BypassManager.check(player)))
this will check if player is staff or op and if they r either sneaking or bypassing
only one from both have to be true (or in this case false, since they r inverted) in order to continue, right?
If either are false in either condition, then they will become true
o sry i forgot to say its an if statement
I assumed it was
ok so if either r false it will continue right?
So you are checking (!(condition || otherCondition) && !(condition || otherCondition))
So for the first (), if either is true, then the whole () becomes false
Same with other set
So both need to be false to continue
At least I am pretty sure
It seems like a weird way to write the statement
thats what i have rn except with exclamation marks cause it cancels the event if it succeeds
Could you show your full code?
// Check Locked Block
player.sendMessage("(staff: " + TeamManager.isStaff(player) + " || op: " + player.isOp() + ") && (sneak: " + player.isSneaking() + " || bypass: " + BypassManager.check(player) + ")");
if (!(TeamManager.isStaff(player) || player.isOp()) && !(player.isSneaking() || BypassManager.check(player))) {
player.sendMessage("check 1");
if (LockManager.isLocked(event.getBlock())) {
player.sendMessage("check 2");
if (LockManager.isLockedForPlayer(event.getBlock(), player)) {
player.sendMessage("check 3");
event.setCancelled(true);
new MessageManager("block-locked")
.replace("%block%", LockManager.getName(event.getBlock()))
.replace("%player%", Bukkit.getOfflinePlayer(UUID.fromString(Objects.requireNonNull(LockManager.getLocker(event.getBlock())))).getName())
.send(player);
player.playSound(player.getLocation(), Sound.BLOCK_CHEST_LOCKED, 1, 1);
return;
}
}
}```
And that doesn't work right?
nope, requires them all to be false (based from the first player.sendMessage thing which doesnt have exclamation marks)
So then does it work without !?
nope
Can you send the output?
Well both sneak and bypass are false
ye it dont make sense
Wait do you want the if statement to continue if either is false?
I thought you wanted either to be true
if ((!isStaff || !isOp) && (!isSneaking || !isBypassing))
without !:
set 1:
staff: true
op: false
set 2:
sneak: true
bypass: false
gonna label them so its easier
Try the new one I sent you
now it requires all of them to be false
Only one from both sets should need to be false
if (!((TeamManager.isStaff(player) || player.isOp()) && (player.isSneaking() || BypassManager.check(player))))
That's not what I sent
ik but i think thats working
So what's the issue?
how do i get the entity right clicked in PlayerInteractEntityEvent?
event#getRightClicked()
It depends on the event tbh, bukkit has like 0 consistency
Well but one is player
I have a integer returning 9.0 and I only want it to return 9
show code
integers do not have decimals
thats what I thought, I think I figure it out
I copied some javascript code into my plugin and missed the Math.floor
anyone know why this isnt working?
@EventHandler
public void onPlayerEntityInteract(PlayerInteractEntityEvent event) {
if (event.getPlayer().getInventory().getItemInMainHand().getType() == Material.NAME_TAG) {
if (Main.morphs.contains(event.getRightClicked().getUniqueId().toString())) {
event.setCancelled(true);
}
}
}```
`Main.morphs` file looks like this:
```yml
e907083e-5db6-41fc-9e32-5c4d99a08712: b43731f4-1277-40f9-b6e5-dd233291954e```player uuid ^ morph entity uuid ^
What is the contents of morphs?
read bottom of msg
is this a hashmap? What is it?
a data file
I'm just suspicious of the .contains call
yeah i thought that would be the problem
how would i detect if the entity's uuid exists anywhere in the file?
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
public final class EventListeners extends JavaPlugin implements Listener {
@Override
public void onEnable() {
System.out.println("Plugin has been enabled");
getServer().getPluginManager().registerEvents(listener: this, plugin: this);
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
System.out.println("A player has joined the server.");
}
}```
getServer().getPluginManager().registerEvents(listener: this, plugin: this);
not working
why> :>
math floor returns a double, if you want it as a integer thrn cast it as int
also if your using floor or ceil or whatever cast your inputs as double.
otherwise you might end up with inaccurate results
yes I fixed that, once I noticed I missed removing Math.floor
getServer().getPluginManager().registerEvents(this, this);
fixed this by doing:java @EventHandler public void onPlayerEntityInteract(PlayerInteractEntityEvent event) { String old = event.getRightClicked().getCustomName(); event.getPlayer().sendMessage(Main.morphs.getKeys(false).toString()); if (event.getPlayer().getInventory().getItemInMainHand().getType() == Material.NAME_TAG) { event.getPlayer().sendMessage("NAME TAG"); for (String key : Main.morphs.getKeys(false)) { String value = Main.morphs.getString(key); assert value != null; if (value.contains(event.getRightClicked().getUniqueId().toString())) { event.getPlayer().sendMessage("SUCCESS"); event.setCancelled(true); } } } }
Please make listener classes then it can be getServer().getPluginManager().registerEvents(new YourListenerClass(), this); makes it all more organized.
i have another issue:java @EventHandler public void onAttack(EntityDamageByEntityEvent event) { Entity damager = event.getDamager(); Entity victim = event.getEntity(); if (damager instanceof Player || damager instanceof Arrow || damager instanceof Trident || damager instanceof IronGolem) { Player entity = MorphManager.getPlayer(victim); // AFK invulnerability if (Main.config.getBoolean("settings.afk-invulnerable") && damager instanceof Player && entity != null && AfkManager.afk.contains(entity)) { event.setCancelled(true); } } }this doesnt work. it only works when both players are alive (no morphs)
ping if reply
How can I get the actual damage an item will inflict on a player (listening to EntityDamageByEntityEvent)?
#getFinalDamage()
So if I want to create a part of my config that has the ability for unlimited strings under a section how would I do that? For instance I want to allow the server admin to make as many things as they want in the configuration, and under each section they create they can add as many strings as they'd like
something like ```yaml
Group1:
- "number1"
- "number2"
- "number3"
Group2:
- "number1"
- "number2"
- "number3"
and so on
How can I extend an event so I can replace it inside an event handler and it will still be called? I want to extend EntityDamageByEntityEvent and create a second implementation of getFinalDamage(), which uses other fields in the class. I want my custom event to be called under the same conditions as EntityDamageByEntityEvent.
ConfiguationSection#getStringList(path)
How can I send each list item to chat as a new message rather than just one message with the entire list
For each loop
Groups:
'Group1':
permission: '' # Permission node required for a user to appoint / fire the listed groups below.
groupNames: # LuckPerms group names this permission class should be allowed to appoint/fire.
- ''
- ''
this would be the config so I would do ConfigurationSection#getStringList(Groups.?.groupNames)
so just .getConfigurationSection("Groups.group1").getStringList("groupNames");? Sorry I am a bit new to making fully configurable plugins.
I want people to be able to create multiple groups and include multiple group names which when they run a command, the list of groupNames for the group they have permission for would send in their chat
Im pretty sure that would only work for if group1 is actually named group1
Try group 2
what
Group2 for group1
Im just trying to make it so the server admin can make as many groups as they want and add as many groupNames as they want without having to make it static and repeating it with Group1, Group2, Group3.... up to Group50
then you can use this
:
make a loop of all the keys in the 'Groups' Config Section
you can found some code for it on internet @junior shard it's easy
still persists
Anyone know a way of getting icons (pngs or whatever) for a given Material?
guessing it's client side but worth a try
https://minerender.org/ maybe this helps? idk
u can use the vanilla resource pack
and find the block/item
but i dont think theres anything that links to Material
yeah i guess thats probably the easiest way
not sure I need anything that fancy, just a material icon to render onto dynmap
oh
well
if that had a rest api it would be great
if you don't need them in-game, there's probably plenty of ways to do it
https://mcasset.cloud/ might be my saviour
MC Assets is a browser for Minecraft asset files. Explore all Textures, Sounds, Models, Fonts, Shaders, and more from any Minecraft version, without having to extract the files yourself
or download the texturepack
has coding changed for to set a player glowing because my code don't work anymorejava case 2: { if (!player.isGlowing()) { player.setGlowing(true); e.setCancelled(true); e.getWhoClicked().sendMessage(Utilities.color(plugin.getConfig().getString("Prefix")) + player.getName() + " " + Utilities.color(plugin.getConfig().getString("glow-on"))); } else { player.setGlowing(false); e.getWhoClicked().sendMessage(Utilities.color(plugin.getConfig().getString("Prefix")) + player.getName() + " " + Utilities.color(plugin.getConfig().getString("glow-off"))); e.setCancelled(true); } e.setCancelled(true); } e.setCancelled(true);
😌 😌😌😌😌😌😌😌😌😌😌😌😌😌😌😌😌😌😌😌😌😌😌😌
you dont type out listener: or plugin:. the reason they show up is because of the ide. it should be #registerEvents(this,this).
also dont use sysout
use Bukkit.getLogger().info("your message here") or your plugins logger
which would be EventListeners.getLogger().info("other messages or smth")
efficiency doesnt matter, its more cause your not really supposed to use sysout for plugins. you will get a message in console about it telling them to nag the author to change it
if your talking about the listener: and plugin: they are prompts generated by the ide thats visual only. you dont type them out or anything.
i think they are generated if a method has javadoc params set.
with /**
Is there a way to set multiple output directories in pom.xml? Tired of commenting 1 or the other when ever I want it outputted to a specific location.
hi guys im having issues enabling mysql support to my spigot plugin, im running maven
this is my console error, trying to connect to the database :
java.sql.SQLException: No suitable driver found for jbdc:mysql://xxxxxxxxxx:3306/xxxxxxxxuseSSL=false
i fixed it i think
the issue was a typo, i wrote jbdc instead of jdbc
lol
A member of staff has requested I move your message to a paste,
Most likely because it contains a config/error/code snippet.
can anyone help me with this?
yes 1 min
the error is not complete
What is a morph ?
also did you try debuging ?
[19:17:12 WARN]: at RCore-1.0.jar//relismdev.cf.rcore.MySQL.connect(MySQL.java:27)
[19:17:12 WARN]: at RCore-1.0.jar//relismdev.cf.rcore.RCore.onEnable(RCore.java:30),
what are those lines ?
@lyric gyro
need the class of the connection??
yes I need to check
synchronized (this) {
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database + "?autoReconnect=true&useUnicode=yes", username, password);
}```
this is some of my code
MorphManager.java: https://paste.srnyx.xyz/cufiredube.java
the new driver package is different, isnt it?
yes
that's old code
I use hikari now
do you support 1.8 and java8?
?
(in your plugins)
do i also have to add the synchronized (this) ??
no
it depends
and if you shade mysql-connector or not
on plugins no because spigot got the mysql connector package if I'm not wrong
yeah, issue is that 1.8.8 doesnt work well with mysql 8.x
now it gives me this : https://pastebin.com/1h9WkBfq
your database credientals are wrong
i doublechecked and they are correct, also i cant even join the server now
Failed to login : invalid session
it's because of the error
yep it's an credientals error
it can't find the host
maybe an error on port or ip
or maybe your database isn't public if done on a vps
and you are testing on your own pc
do you have any tool to check if credentials are correct?
i can dm you my credentials, i dont mind it
if they can afford to keep on using software that's been eol for more than half a decade, they can afford to rewrite the plugin
yes, it gives an advantage
but thats why pvp servers kick/ban ppl who double click :))
since theres more to it
¯_(ツ)_/¯
im making a cooldown thing, but for some reason it isnt working:
private final Map<Entity, Duration> cooldownTimes = new HashMap<>();
public boolean onCooldown(Entity entity, Duration duration) {
boolean cooldown = cooldownTimes.containsKey(entity) && cooldownTimes.get(entity).toMillis() > System.currentTimeMillis();
cooldownTimes.put(entity, Duration.ofMillis(duration.toMillis()).plusMillis(System.currentTimeMillis()));
return cooldown;
}```here's the `if` statement im using: `if (!onCooldown(player, Duration.ofMillis(5000)))`
and when using `Bukkit.broadcastMessage(String.valueOf(!onCooldown(player, Duration.ofMillis(5000))));` (to debug), it tells me every 5 seconds (5000 milliseconds) that its `true`, which means it should be working
here's the entire file: https://paste.srnyx.xyz/tofonozelo.java
Well, would you like to tell us what isnt working?
Yeah, what is not working exactly? (btw, you should try passing variables instead of using static for literally everything)
what does "[Server] INFO org.bukkit.event.EventException: null" mean?
probably something is null
maybe more share the full stacktrace
or that's everything?
the null just means that theres no description to the error
we'll need the entire stacktrace
Error I get in console https://pastebin.com/9rcQjxFZ
is this your plugin or someone else's
Mine
21.02 21:39:50 [Server] INFO Caused by: java.lang.NullPointerException
21.02 21:39:50 [Server] INFO at me.mason.rankupgui.events.ClickEvent.clickEvent(ClickEvent.java:29) ~[?:?]
what's on line 29
of ClickEvent
if (plugin.getVaultAPI().getEconomy().has(player, 10000)){
both are together?
wdym?
worked together
yes
xddddd
well most likely
- plugin is null
- getVaultAPI() returns null
- getEconomy() returns null
print out getVaultAPI() and getEconomy()
one of them is prob null
he probably has
private Main plugin;
and hasn't assigned it
second one:
player.playSound(player.getLocation(), Sound.BLOCK_CHEST_LOCKED, 1, 1);
new MessageManager("block-locked")
.replace("%block%", LockManager.getName(event.getClickedBlock()))
.replace("%player%", Bukkit.getOfflinePlayer(UUID.fromString(Objects.requireNonNull(LockManager.getLocker(event.getClickedBlock())))).getName())
.send(player);```
How would i assign it
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
otherwise is the rest, getVaultAPI returns null
or getEconomy returns null
why the ping xD
we need ClickEvent
i was asking TUXicalo xd
Uuid from String but #getName?
in your case, it's weird how you do the things there
instead of using isOnCooldown thing
i rather making it to check if is on cooldown
and then (inside the code add the cooldown)
not doing it in one method
idk about that, i didnt make that part of it, but it works 🤷♂️
as it might leads to issues when you first start coding plugins
fixed it, it needed to be assigned
good to hear!
thank you for ur help
It's getName from getOfflinePlayer, not fromString
Bruh, discord on phone sucks
yeah
guys i need help with my config file, it only copies the first line into the plugin folder
well, we need more info than that
you probably made it wrong
saveDefaultConfig() usually works
(ofc ignores comments when modified using saveConfig())
#general-plugins / #general-plugins-2, this channel is for plugin/software development
Ah okay
I have this error when I try to save my world creators world names to a yaml file
error: https://paste.helpch.at/rapevenuwu.rb
world creator class: https://paste.helpch.at/itatumifuh.java
DataManager Class: https://paste.helpch.at/jihobaguni.java
ok to test it out i used some code from another plugin that uses multiple methods
its giving me the same result (debug msgs says it should work, but it just doesnt)
me?
of course no
oh ok
don't set UUIDs, set Strings (UUID#toString)
since UUID doesn't implement ConfigurationSerializable
oh ok ty
(also you'll have to delete the worlds.yml or delete the UUID part)
yea 
btw when i remove if (!hasNoCooldown(player)) it works, which means it has something to do with the if statement
im not rly sure tbh
now guys if i want to find the world name in there would i use getString
You should start doing step by step
otherwise finding the issue might be hard
(tbh i have no idea what your action do)
is there like a way to do event managers or command managers, that read the command files using reflection to add them to the, well command list and stuff
If I wanted to check if the name testingabc under worlds existed in my code how would i do that?
https://paste.md-5.net/ewefinazax.makefile
I currently use reflections for it but I want to know if there is another way that doesnt make me use a big lib lmao
why? just wondering

you can look how the command's framework do it, and implement it to your project
how do you store a type in a variable? e.g.
myVariable.type = String or myVariable.type = boolean
no, i want a variable to store the type that an object is using for something external
or do you mean like Class<T>
or something
i mean i guess you could use Class<T>
like String.class, Boolean.class, (wrappers for primitives) and use that to store stuff, but it's a bit unclear on what you are trying to accomplish
Or just use Object
but why
you are going to do a bunch of instanceof checks?
well i've got a bunch of monitor classes that monitor data of certain types, and i'm trying to extract json values to make a map of these like:
"monitors": {
"monitor1": {
"datatype": "int",
"a": 1
"b": 2,
}
}
and then monitors.get("monitor1").dataType should return Integer
or something like that
Object won't work here
You still have to instance check on Class
Well, i'd prefer Class in this case
👍 was just giving the option based on his variable message.
if you have an interface Monitor, and classes like IntMonitor, StringMonitor that implement that interface, can you make a map like HashMap<String, Monitor> and then store IntMonitor etc as values?
it's not possible to use generics here via an abstract class, as IntMonitor etc individually extend from MutableInt etc
Yes
thanks
how can i get the type of boat destroyed in VehicleDestroyEvent?
VehicleDestroyEvent#getVehicle#getType
that just gets the type of vehicle i think
yeah, would that not be what you're after?
i wanna get like if its an acacia boat or something
but i think that just returns boat, minecart, etc...
I mean yeah, the EntityType enum doesn't go into more depth
so how could i get the material type of it?
that is the material type
the EntityType enum
is the entity equivalent of the Material enum
oh oh
okay so if you get the type and see if it's a boat
then I think you can cast it to a Boat type and that has getWoodType
and that returns a TreeSpecies lmao
like this right? vehicle instanceof Boat boat
uh no
because it won't be an instanceof Boat
it'll be an instance of Vehicle
you'd want event.getVehicle().getType() == EntityType.BOAT or similar
then you can cast it to a Boat
not sure if im doing something wrong or not:
Inconvertible types; cannot cast 'org.bukkit.entity.EntityType' to 'org.bukkit.entity.Boat'
love when oak boat species is called GENERIC unlike every other one
oh and cant forget about spruce being called REDWOOD
literally why 
I'm about to flip right now lol
I run gcc and it works fine in a normal command prompt tab
then i go into goland and use the terminal there
and it says it can't recognize gcc
even tho the path variable is set
I may be misunderstanding something, why would the vehicle not be instanceof Boat?
you on windows, I bet the VSC terminal has a different PATH
It would be, they were comparing the getType not the Vehicle object
This ^
Yeah im on windows
It's odd cause when i do echo %PATH%
it shows up
lol
whatever, I just didnt use the terminal provided and used command prompt to do it
cause im lazy
okay yeah actually it might
ok how can i convert it to OAK
convert what
GENERIC treespecies
like, in what context?
Boat boat = (Boat) vehicle;
Material material = Material.valueOf(boat.getWoodType() + "_BOAT");
attacker.getWorld().dropItemNaturally(vehicle.getLocation(), new ItemStack(material));```
You could do boat.getWoodType().replace("GENERIC", "OAK")
Yeah
weird how something like this didnt work:
if (boat.getWoodType() == TreeSpecies.GENERIC) {
material = Material.OAK_BOAT;
}
if (boat.getWoodType() == TreeSpecies.REDWOOD) {
material = Material.SPRUCE_BOAT;
}```
i get the same error in console as if it wasnt there
and i tried adding debug msgs but they wouldnt work
What error?
java.lang.IllegalArgumentException: No enum constant org.bukkit.Material.GENERIC_BOAT
That was in console or compile error?
Can you show your full code using this?
Oh, that was when you were using .valueOf
You get the error because you have Material material = Material.valueOf(boat.getWoodType() + "_BOAT"); at the top
thats for all the other boats
but shouldnt it redefine by the material = in the if statements?
ahh i get now
this works:
Boat boat = (Boat) vehicle;
Material material = null;
if (boat.getWoodType() == TreeSpecies.GENERIC || boat.getWoodType() == TreeSpecies.REDWOOD) {
if (boat.getWoodType() == TreeSpecies.GENERIC) {
material = Material.OAK_BOAT;
}
if (boat.getWoodType() == TreeSpecies.REDWOOD) {
material = Material.SPRUCE_BOAT;
}
} else {
material = Material.valueOf(boat.getWoodType() + "_BOAT");
}
assert material != null;
attacker.getWorld().dropItemNaturally(vehicle.getLocation(), new ItemStack(material));```
but imma do the replace thing cause its a lot simpler and what i was originally gonna do
yeah Strings are slow
o the if statement way?
also the assertion is cute
sadly this is Java where assertions are only checked at compile time when you're running a Test framework
remove what?
assert materia != null
intellij screams at me if i remove it 
assert throws an error, you shouldn't use it unless you are testing
Use if (null) return
ok
or put the code inside if (not null) {}
not if you're not running a test build 😉
do this
not this
It depends if they have code afterwards
early exiting is always where it's at
Since when does it not thrown an error?
is it supposed to literally be not null?
No, you have to check if material is null
since always
Java's assertions are shit
you have to be running a test framework for assertions to do anything
ive been using assertions a bit (there were like 5 in my plugin) and nothing broke cause of them
this is probably why lmao
yeah they do literally nothing in normal usage
I'm going to add a bunch of assertions everywhere now just to confuse people
lol
lmao
see in most languages, assertions do work in real programs, because why not?
Rust's assert! macro works everywhere
and it's a good way to assert something is true
What about Skript?
Its the best programming language
What's the best way I can go about registering a command for my papi expansion?
Was looking at the jsexpansion and ended up with something like this but not sure if I need to do anything else as nothing happens when it executes (doesn't say unknown command though)
Field field;
try {
field = Bukkit.getServer().getClass().getDeclaredField("commandMap");
field.setAccessible(true);
CommandMap commandMap = (CommandMap) field.get(Bukkit.getServer());
commandMap.register("papichess", new ChessCommand("chess"));
} catch (Exception e) {
e.printStackTrace();
return false;
}```
you can't register a command in a standalone papi expansion
maybe not register, but at least get the command working
it's a theme
just make a standalone plugin???
wtf lol
prob gotta do something with /papi reload though
but then people would ask why I made the chess menu be deluxemenus
if it's an "expansion" it makes more sense
the whole point was chess in dm
:L
well yeah that's still super cursed
blame whoever did the js expansion
you have the Java capabilities, just use a GUI library and do it yourself
it'd be 50x more performant
well, you're like 90% of the way to being a standalone plugin lmao
the only difference is that PAPI loads you and not Bukkit
which is very cursed because I don't think expansions are even supposed to do that
Get out
i can run deluxemenus with minecraft 1.8
i run my 1.8 with jdk 11 :)
please write in spigot page that plugin supports 1.8
🙂 🙃
Leave.
mongo
for what
ok 👍
depends on if you want relational or not lol
Not sure
what kind of data are you storing?
I wanna make a point of sale system for a quick service restaurant
Does anyone know how i can make it so if you type a custom command, the code in the repeats until the custom command is typed again? kinda like a toggle system
Create bukkit task and assign a variable, when command is run again, check if not null and cancel, then assign a new bukkit task
Sorry I’m really new to developing, is there a link you could possibly send me to geo me out
There isnt a tutorial to make a command that stop the previous repeating task when its performed
This dont work like that. Hence why we strongly suggest people to learn java (at least basics) before jumping into spigot or bungeecord
My explanation was pretty simple, issue is you dont have any idea about java.
private BukkitTask task = null;
//inside command
if task is not null, cancel it
assign new task with the repeating thing
Simple as that
does someone has a good tutorial about multi modular project with gradle on intellij because I'm searching rn and I only found indian dudes with crap mic and windows 7
yea like I said I was new
Would need a map. Has to be per player. (I assume by his original question)
he said a custom command to repeating task, never mentioned seomthing about per player feature
¯_(ツ)_/¯
I understand, as i said new people should learn java first
java is not spigot
java is the language
and knowing that, seriously help when jumping into spigot
if thats the case, yeah, simply make it a hashmap
Well he said when a player types a command.
a player can mean operator or admin
however, as you mention, he probably want to make a particles trail
Either one could be right just giving the options lol
or something that follows the player
i know lol
for updateRedis() it says "Private methods in interfaces should have a body". but how can i add the body in the interface when using variables from my classes?
You don’t need public, and interfaces can’t have private methods
Wouldn’t make sense
and then it says "Class 'BooleanLogger' must either be declared abstract or implement abstract method 'setValue()' in 'Logger"
That one is pretty self-explanatory, you need to override the method setValue() in BooleanMonitor
"Method does not override method from its superclass"
The interface has no parameter
You can use generics
interface Logger<T> and setValue(T value) but yes
this uses an array so
mhm
generics over primitives (implements Logger<boolean>) are not a thing
so you need to implements Logger<Boolean> and override both methods from Logger and MutableBoolean
i think it's better to just use an empty interface
all i want is to be able to make a map HashMap<String, Logger> that i can store any type of logger in as a value
whatever floats your boat ¯_(ツ)_/¯
Wdym an empty interface
I assume a marker interface? Like Bukkit's Listener kinda deal
I don't think that would work for them
@pearl topaz you could use a Map<Class, Logger>
Then use loggerMap.get(Boolean.getClass()), etc.
i think it works fine
i'm wondering though
can you specify a subtype as a generic in Kotlin?
but i dont think this is possible in java
Well that won't work because updateRedis() is private in Logger
Wait
this.redis.set(this.loggerName, this.value.toString()); You change it to a String anyways?
What's the point of this?
you can only store strings as redis values
if (args.length == 1) {
if (Bukkit.getServer().getWorlds().toString().contains(args[0])) {
Bukkit.getServer().getWorld(args[0]).setTime(1000);
new MessageManager("plugin.time")
.replace("%time%", "day")
.replace("%world%", args[0])
.send(sender);
} else {
new MessageManager("errors.invalid-world")
.replace("%world%", args[0])
.send(sender);
}
return true;
}```https://paste.srnyx.xyz/baqofehivi.properties
World is returning null
Its better to do a null check
if (Bukkit.getServer().getWorld(args[0]) != null) right?
Yp
intellij still says this: https://srnyx.is-from.space/zmkQAMZ2c5.png
Yeah…it warns you that the world might be null and you should handle it
come on...
getWorlds().toString()
really?
Tbh, I don’t understand the second if
Same
is clear
that he wants to check
if world
with that name exists
but thats not the way
please, learn some java first
you can't simply use toString()
for everything to check
thats not how things are done
final String wName = args[0];
final World world = Bukkit.getServer().getWorld(wName);
if(world == null)
return;
world.setTime(1000);
yeah you can do that
however, not sure if that set the time of the world
or it restarts the day count
i am not sure about that..i just wrote how to handle that null checks
isnt this the same as #development message ?
yep....i just stored it into a variable...thats the only diff
alr, well intellij still gives me the same warning
Its a warning, bcs the method is annotated as @Nullable, its kinda a marker annotation iirc, so just handle the check there and you would be good to go
Also don't always dependent on IJ... it sometimes too dumb...
using this still gives me the same error (when running /day wo or smth)
provide the full code and error
CommandDay.java: https://paste.srnyx.xyz/lacacuyuni.java
Error: https://paste.srnyx.xyz/qefomotuca.properties
it only gives the error if i only put in part of a world (ex: wor, world_neth, etc...)
The cause is pretty self explanatory
Also, put the world into a variable and then check if is not null
Theoretically, if the world doesn't exists, Bukkit.getServer().getWorld(args[0]) != null this should be false right?
Yeah, it is weird


