#help-development
1 messages ยท Page 1565 of 1
it returns the slot that was clicked. As I said I need another one
it said that it was out of bounds even when I gave it no set capacity
because there are no elements in it
I can send you the error in a txt file if you need it
you can't get the first element out of an empty list
hi ihave proplem i'm created skypvp plugin with lootchest but when i spawn lootchests after opening 5 lootchests plugin stop respawn more loot
but I am trying to set the elements, not using them
so you need to add them first
like this?
(integer gets incremented every rep)
just add
so can anyone help me ๐
How can I turn a name (for example "maxthier") into something like this: ("--------"), "conminelp" would then be for example "---------". So the number of characters in the name in the form of "-".
?
use a string builder and repeat - for the length of the string
@unreal quartz can you help me with the code ?
well there is no code to help with
code is bigger
how ican
send it
?paet
to you ?
?paste
send it here
@quaint mantle wanna take ownership of my server
you're a great guy
i'm sure nothing would happen to it
โ ๏ธ
IT WORKED, thanks, your the homie
btw the integer arg isn't required
ik, I removed it
I been working at this for like a week and it finally workin'
set(int, obj) sets it at that index, which of course will throw an exception since you cant set something at a specific index in an empty array
What's the easiest persistent tick counter I can access via API
That I wouldn't need to worry about overflows
@unreal quartz
is there a way to simplify that?
if you store the number of ticks in a long, it will take 14623560.375443937 millenia to overflow
Stick them in an array, or string comparisons (Less performant)
@unreal quartz see it
Damn, what if my server uptime is 14623561 millenia?
Also, where would I get that count
then that is incredibly tragic
Is it stored anywhere?
I really hope it does ๐ฆ
Aren't there any methods for that?
?
@unreal quartz you speak to me or another person ?
you haven't sent anything
like Material.compareColorless(..., ...);
@unreal quartz see it antd tell me
well your code is a complete mess and hard to follow on
and ?
what exactly is the problem
lootchest after respawn 5 times
stop respawn
again
when i collect the loot 5 times
it stop
respawn another loot
well what you've sent is completely unrelated
Maybe, not sure. Your best bet is checking what methods are available to material, or to itemstack
ok whats code do you want ?
well i dont know. its your project. but the code here (appears) to spawn 1 loot box depending on the command and spins some armor stand around every 5 ticks (on an async thread - which you shouldn't do)
@unreal quartz Turns out Paper has a method.
https://papermc.io/javadocs/paper/1.16/org/bukkit/Bukkit.html#getCurrentTick()
declaration: package: org.bukkit, class: Bukkit
interact
@unreal quartz iwill send another code ok ?
if my calculations are correct that will overflow only after 3.40481298674531 years
completely unacceptable api
@unreal quartz ok ?
It's from an NMS counter
So I think it's their fault
But still, good enough for me haha
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.
this is borderline unmaintainable
to put it politely
i would suggest you first put your loot box spawning code into a single method
maybe in doing that you will also spot the error
why do i get this?
I have this as tabcomplete
arguments and result are just empty arraylists
i can't see any of this guy's code
are his links being remove for me?
result seems to be a field
which means its state is the same between tabcompletions
so at some point you've added them all to result
@umbral pagoda if you ever repeat yourself more than once in code. Ask yourself if you could do it another way.
If you repeat yourself more than five times, do it another way
wait is it that simple?
bukkit has a method StringUtil.copyPartialMatches which essentially does what you want
got it from a tutorialllll
iv never really tried to make autocomplete
cuz i thought i was really complex
no way hahaha
oh anyway
thats actually a great advice lol
ok i set up the basics of the command
package io.github.Epicmania.healerPlugin;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class CommandHeal implements CommandExecutor{
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
return false;
}
}
what now
how do i make it so taht the player can be distinguished for events and stuff
i have no idea what you mean by that
ok so i want it to be like
/healer add Epicmania
/healable add EpicmaniaAlt
Then when Epicmania hits EpicmaniaAlt it heals EpicmaniaAlt the amount of damage Epicmania would normally do
use runTaskLater, and you don't want it async unless you know what that means
I do not know.
keep their uuids in a set somewhere

I want to use the least late type for the server.
declaration: package: org.bukkit.scheduler, interface: BukkitScheduler
which would you recommend me?
the one i just linked
I would like the event to occur every 8 hours, but not start when the server is on.
then schedule it to run every 8 hours using one of the methods i sent
Could anyone help with this issue?
Want to make sure it's not my fault.
never used specialsource
It works every 30 seconds, but it starts when the server is turned on.
the third argument is the delay
Anyone knows a performant way to send many Particles in 1.16+ ?
wait in my command how do i return something to the chat
sender.sendMessage?
works
thanks @unreal quartz @lusty cipher
k thanks
hey im trying to teleport a player somewhere immediatly after respawn
I can't get it to work though
is InventoryCloseEvent called before or after the inventory is closed
how can I change respawn location
in the respawn event
I saw a set bedspawn
How do I check if the inventorycloseevent was called because of another inventory was opened instead of the player clicking esc
oh neat, thanks!
you cant
why not :(
if you really need to know you can wait a tick and see if there is a non crafting inventory opened
but in order to open a new inventory, you close the old one
would this work even if the tps isnt 20
like I mean will it be consistent always
it's more of a hack than a solution
wait when i sender.sendMessage is the message red by default
or do i have to do something to make it that way
no
Does Bukkit.getOnlinePlayers() return the leaving player when the PlayerQuitEvent gets handled?
The death event doesn't, so best not to assume the quit will
then hwo would i make it red
I thought events were supposed to be ran before things happened
But yeah I can see why
not the death event. The player is dead at that point
Aight
I dont think so, because deathevent is cancellable
by using the red chat color
no its not
i dont know the syntax for the command how would i make this red
sender.sendMessage("The syntax of this command is /help add/remove [player]");
ChatColor.RED + "......"
sender.sendMessage(ChatColor.RED + "The syntax of this command is /help add/remove [player]");
Pretty sure death event the player passed in that event will not be in getOnlinePlayers() but it may be the respawn event.
thanks
Is there an event for a player firing an arrow?
Yeah
how to get and chest in world?
LM
like
world.getwhat?
How do I make a task to run only once?
You need a location
Then use Location#getBlock (iirc)
@unreal quartz Is this the best way to finish an event in 1 minute?
BukkitScheduler scheduler = getServer().getScheduler();
scheduler.scheduleSyncDelayedTask(this, new Runnable() {
@Override
public void run() {
// Do something
}
}, 20L);
}```
This is in a second
60 * 20L
is there a way to turn off the safe teleport where it will not teleport you inside of blocks
how to set items in chast?
you can get the inv of the ches t
and add items to it
?scheduling
what does it mean if the resource is out of sync with the plugin.yml file
It means you have two different copies of the file. One saved and one in cache
What's the error
Well does that class exist
NMS ||or use Paper||
Well then change it in your plugin.yml
oh no I'm stuck in some serious decision paralysis
ohhhhhhhh
and also literally stuck because my back hurts
I have a command teleporting a player to a Location underground that i mine out to be a 1x2, just enough for the player to sit in it
?spoon
Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.
however, when I teleport the player to that block they get automatically teleported ontop of the world
is there a way to perfectly teleport a player to the middle of a block
Not the problem
that might do it
it only should teleport ontop of the world if the player is in the block
console.getlogger?
i'll see if it works
Yeah I'm not sure why it would teleport you up
plugin.getLogger().info("text");
I'm pretty sure it shouldn't do that
@urban lava
Its the respawn point that likes to teleport up. The actual player.teleport does not do that
Ah
oh thanks
that one will send with ur plugin tag
Bukkit.getServer().getConsoleSender().sendMessage("STRING");
this one will just send a straight message to it
yeah i want tfor plugin tag
ahhhhhh finally that worked, thanks @quaint mantle
its for onEnable and disable
np
wait should plugin be my plugin name
yes
Spigot already has built in messages no need to fill the console with more
what will show up in /pl, console
basically what spigot will id your plugin as
when theres errors, etc
Not what he's asking
He's asking about the variable
Is there a way to change a player's nametag without changing their name in tab complete and such
teams
scoreboard teams
wait
no thats for prefixes and suffixes
im not sure about completly changing the name
its the class that extends JavaPlugin
that one yes
You will have to work with packets
i usually like to make a static function in it that returns itself
so no hassle to get an instance of it from somewhere else
I'm changing the name field in their gameprofile and it works, but this changes the tab complete stuff
main: HealerPluginMain
no
And package
ok
ok thanks
if u ever got problems with something
should always try google it
like whenever i forget whats needed in the plugin yml
i search up
"plugin YAML"
comes up with a page on the bukkit forums or something
and it shows each entry detailed description
googling is an underrated skill
yeah
always try to keep key words only
because if u add like
"the, how"
its gonna find pages that include those words
which are very common words
ok
so you will get highly unrelated stuff
ill keep that in mind
When Bukkit loads a plugin, it needs to know some basic information about it. It reads this information from a YAML file, 'plugin.yml'. This file consists of a set of attributes, each defined on a new line and with no indentation.
A command block starts with the command's name, and then has a list of attributes.
A permission block starts wit...
this is what i mean
Is there anything special I should do to my plugin.yml before I post it on spigot mc?
author: @waxen plaza
and I use my spigot name?
whatever name you generally go by
maybe a description too if u like
ok
Eh do what you want I mean there's nothing special needed
for 1.17 plugins, is it still necessary to use jdk 8? or do we have to use 16?
You can use 16 since server uses 16
ok thx
package io.github.Epicmania.healerPlugin;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class CommandHealer implements CommandExecutor{
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args[0] != "add" || args[0] != "remove" ) {
sender.sendMessage(ChatColor.RED + "The syntax of this command is /healer add/remove [player]");
}
else if (args.length==0) {
sender.sendMessage(ChatColor.RED + "The syntax of this command is /healer add/remove [player]");
}
else if (args[0] == "add") {
if (Bukkit.getPlayer(args[1]) == null) {
sender.sendMessage(ChatColor.RED + "Enter a valid username");
}
}
else if (args[0] == "remove") {
if (Bukkit.getPlayer(args[1]) == null) {
sender.sendMessage(ChatColor.RED + "Enter a valid username");
}
}
return false;
}
}
oops
meant to click shift
this code should make if they dont enter the right args for the command it tells them what is wrong
also
for example if they enter /healer it should say the syntax of the command
but it doesnt work
instead of doing a check for the second argument being null twice
just do it before the add and remove check
You need to return true; when the syntax is correct or else the command will always send a error message
^
ah ok
so i should take out the return false at the bottom and add it in the inocrrect if instances
and return true in the correct instances
Exactly
so i jsut return true for those too?
that makes sense thanks
ok i changed it to this
package io.github.Epicmania.healerPlugin;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class CommandHealer implements CommandExecutor{
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args[0] != "add" || args[0] != "remove" ) {
sender.sendMessage(ChatColor.RED + "The syntax of this command is /healer add/remove [player]");
return true;
}
else if (args.length==0) {
sender.sendMessage(ChatColor.RED + "The syntax of this command is /healer add/remove [player]");
return true;
}
else if (args[0] == "add") {
if (Bukkit.getPlayer(args[1]) == null) {
sender.sendMessage(ChatColor.RED + "Enter a valid username");
}
return true;
}
else if (args[0] == "remove") {
if (Bukkit.getPlayer(args[1]) == null) {
sender.sendMessage(ChatColor.RED + "Enter a valid username");
}
return true;
}
return false;
}
}
but it still shows an error if there are no arguements, and if i type the command any way else it says "The syntax of this command is /healer add/remove [player]".
check if args length is 0 first
because if args[0] is null
u will get a nullptr
on the first if
because theres nothing to check
I think it's IndexOutOfBoundsException, not nullptr but yeah that's what you need to do
ok thanks
i dont think it is
also will doing /reload confirm update my plugin
because theres nothing in the list anywyas
if the new jar is there
Yeah it is, accessing args[0] when the list size is 0 throws IndexOutOfBounds
I mean your solution is right either way, just a technicality lol
i usually havent had any problems with reloading
Yeah reloading for development purposes is fine usually
Just don't do it on the production server if you have one
the next issue is that it shouldnt show anything if I type in /healer add Epicmxnia but it still says the syntax msg
Don't return false
yeah honestly u shouldnt be returning false unless ur dealing with stuff that can throw errors
and even then just use a throw catch
can u show us the updated code
It still says Syntax error because of the first line
if (args[0] != "add" || args[0] != "remove" ) {
args[0] is "add", it isn't "remove", so that if statement is true
package io.github.Epicmania.healerPlugin;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class CommandHealer implements CommandExecutor{
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length==0) {
sender.sendMessage(ChatColor.RED + "The syntax of this command is /healer add/remove [player]");
return true;
}
else if (args[0] != "add" || args[0] != "remove" ) {
sender.sendMessage(ChatColor.RED + "The syntax of this command is /healer add/remove [player]");
return true;
}
else if (args[0] == "add") {
if (Bukkit.getPlayer(args[1]) == null) {
sender.sendMessage(ChatColor.RED + "Enter a valid username");
}
return true;
}
else if (args[0] == "remove") {
if (Bukkit.getPlayer(args[1]) == null) {
sender.sendMessage(ChatColor.RED + "Enter a valid username");
}
return true;
}
return false;
}
}
ty btw for helping me out all of you guys
Just change || to &&
GRr still didnt solve my tabcomplete problem
Yeah that ALWAYS catches ๐
wait is && or?
npo
&& is and
its and
|| is or
|| is or
i mean
im stupid
Crqpts we're on the same page for every message i stg
& is the and symbol lol
bahahaha yes
do u want help with the next part or are you ok?
use plugman to reload your plugin instead of the entire server
um it still shows the syntax for anything i put
ive heard of that before but im not bothered to install it
Hotswapping is the best way
because its just the 1 plugin
u could use some debug messages
Hotswap and reload is the way to go
Hotswapping has been more trouble for me than just making a new jar
show the code again
Use DCEVM it helps
package io.github.Epicmania.healerPlugin;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class CommandHealer implements CommandExecutor{
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length==0) {
sender.sendMessage(ChatColor.RED + "The syntax of this command is /healer add/remove [player]");
return true;
}
else if (args[0] != "add" && args[0] != "remove" ) {
sender.sendMessage(ChatColor.RED + "The syntax of this command is /healer add/remove [player]");
return true;
}
else if (args[0] == "add") {
if (Bukkit.getPlayer(args[1]) == null) {
sender.sendMessage(ChatColor.RED + "Enter a valid username");
}
return true;
}
else if (args[0] == "remove") {
if (Bukkit.getPlayer(args[1]) == null) {
sender.sendMessage(ChatColor.RED + "Enter a valid username");
}
return true;
}
return false;
}
}
Sadly Java 11
hmm, ill look into it. thanks
string comparison using == ๐ฑ
so like
equalsIgnoreCase
Surprised the compiler didn't yell for that one tbh
i think it is
args[0].equalsIgnoreCase("add")
How much Java do you know?
ys
not much :c, i did the codecademy course over a year ago
idr how far i got
Because things like these aren't really spigot only
yeah
i started spigot same time as java
sorry ๐คทโโ๏ธ
pretty stupid of me
Same
but ive used c++ before so i got the hang of it pretty quickly
Honestly doing them at the same time gave me something to practice with atleast
Cause I had plugin ideas
even now i want to make plugins but idk what to do
args[0].equalsIgnoreCase("add") not ==
yeah we just covered that
yeah same for me, cuz if i dont know what to use it for i just forget everything
suggest reading to see other peoples replies before replying lol
wait
im gonna fix up ur code a little bit
clean it up
thanks lol
package io.github.Epicmania.healerPlugin;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class CommandHealer implements CommandExecutor{
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length==0) {
sender.sendMessage(ChatColor.RED + "The syntax of this command is /healer add/remove [player]");
return true;
}
else if (args[0] == "add") {
if (Bukkit.getPlayer(args[1]) == null) {
sender.sendMessage(ChatColor.RED + "Enter a valid username");
}
return true;
}
else if (args[0] == "remove") {
if (Bukkit.getPlayer(args[1]) == null) {
sender.sendMessage(ChatColor.RED + "Enter a valid username");
}
return true;
}
sender.sendMessage(ChatColor.RED + "The syntax of this command is /healer add/remove [player]");
return true;
}
}
i just removed the != part
because ur already checking if theyre equal to it
so if none of the if statements are true
send the syntax message
also
ty
Use switch statements instead of spamming else if
instead of using chatcolor.red and stuff
i make a utils class
or just use main class
static function
translate
ChatColor.translatebyalternatecolorcodes
or something
i forgot
and use the "&" symbol
im stupid remember
&c for red, &4 for dark red
nah everyone starts somewhere
public static String translate(String text){
return ChatColor.translateAlternateColorCodes('&', text);
}
u can put this in ur main class
and do
MainClassName.translate("&cSyntax blablabla")
and it will return the translated text
Hi, i use this to send a item to all online players, but it doesn't send it to all the players
give me a second
this is the chart u can use
basically
if u want a bold light red message
that says "Hello there!"
use &c and &l
its a bit complicated
so u can just use ChatColor.RED + ChatColor.BOLD + "message"
etc
You are returning in a loop
so woudl i just add &c to the start of the string
it will just iterate on its own
yep
oh should i just remove the return?
use continue instead of return if you need to skip an iteration, otherwise you dont need continue
also this is still happening, when the elif shows that args[0] is add or remove, it should either show nothing or the "enter a valid usename" thing, but instead it says "The syntax of this command is /healer add/remove [player]"
send the entire thing again
Can I add colors to description with color codes?
wait im adding the stuff you said
alright
can u change ur name
this is my old name
has a q in it
pretty cringe
i used return as im using multiple arguments
You have to donate to change your Spigot username I think
i meant no need in the loop
read what i said
oh ok
Like, adding &4?
Try it and see if it works
package io.github.Epicmania.healerPlugin;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class CommandHealer implements CommandExecutor{
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length==0) {
sender.sendMessage("&cThe syntax of this command is /healer add/remove [player]");
return true;
}
else if (args[0] == "add") {
if (Bukkit.getPlayer(args[1]) == null) {
sender.sendMessage("&cEnter a valid username");
}
return true;
}
else if (args[0] == "remove") {
if (Bukkit.getPlayer(args[1]) == null) {
sender.sendMessage("&cEnter a valid username");
}
return true;
}
sender.sendMessage("&cThe syntax of this command is /healer add/remove [player]");
return true;
}
}
could always try it and see
i believe it shpould
wait
so
epic
do like
/healer add Epicmxnia
and tell me what it says
Hello someone know how i do in SQLibrary package
in MySQL
SELECT * FROM table WHERE uuid = player uuid
and then it will do
player.sendMessage(data)
i dont know how
someone can help me?
like pvp stats or something
My tabcomplete still doesnt work..
@Override
protected @Nullable List<String> tabComplete(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args) {
if (arguments.isEmpty()) {
arguments.add("help");
arguments.add("accept");
arguments.add("request");
arguments.add("decline");
}
if (args.length == 1) {
for (String a : arguments) {
if (a.toLowerCase().startsWith(args[0].toLowerCase()))
result.add(a);
}
return result;
}
return null;
}
did you register it?
protected List<String> arguments = new ArrayList<>(); // tabComplete
protected List<String> result = new ArrayList<>(); // tabComplete
yes
lemme show
How would i rename a inventory title (Dropper) without reopening it or causing it to flicker from 1.13+?
@quaint mantle
for some reason result isn't updated or something
i didnt do it right i think
public String translate(String text){
return ChatColor.translateAlternateColorCodes('&', text);
}
i put in the other .java file
put this somewhere in ur class
So here's a tip:
Get all of the stats async when the player joins and then cache it.
should it be in this .java file
how i do that?
i dont know how to call it in string or something
nah, it goes in the .thisismyepicmethod file this is sarcasm
How much Java do you know and have you worked with SQL before?
Try using return StringUtil.copyPartialMatches(args[0], arguments, new ArrayList<>());
instead of
for (String a : arguments) {
if (a.toLowerCase().startsWith(args[0].toLowerCase()))
result.add(a);
}
return result;
ik SQL from my old works on javascript
and java i know 3 years
ik you can do String result =
but it give me error that i cant call it with String
Perfect, since there are a lot of people here we can continue in DMs if you want
okay
Is there any way to stop falling block despawning without NMS? I'm having it as a passenger on an armorstand and would only use NMS if there's no other way
try do
try to mix up the messages
public class CommandHealer implements CommandExecutor{
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length==0) {
sender.sendMessage("&cThe syntax of this command is /healer add/remove [player] (no args)");
return true;
}
else if (args[0] == "add") {
if (Bukkit.getPlayer(args[1]) == null) {
sender.sendMessage("&cEnter a valid username");
}
return true;
}
else if (args[0] == "remove") {
if (Bukkit.getPlayer(args[1]) == null) {
sender.sendMessage("&cEnter a valid username");
}
return true;
}
else {
sender.sendMessage("&cThe syntax of this command is /healer add/remove [player]");
}
return true;
}
}
i added (no args) to the first one
as it despawns after like 5 seconds
just to see whats happening
ok, come
By default, the Java language level is set to 5 which is not supported by the current Java version. Update the language level to 6+.Update source level in PrivateVaults
Why does this appear? I have my language level set to 16
lemme try
kk
Are you using IntelliJ
Yes
File -> Project Structure, send an SS of that
ok so the no args one only triggers when there are no args
it always triggers the other one otherwise
Or is NMS the only way
As I have heard you can detect it taking damage
and cancelling the event
Check your Module SDK version too, and if you're using Gradle/Maven, check those.
all 16
๐ค try restarting and/or invalidating caches
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project PrivateVaults: Fatal error compiling Now I get this error
Yeah try restarting
public class CommandHealer implements CommandExecutor{
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length==0) {
sender.sendMessage(translate("&cThe syntax of this command is /healer add/remove [player] (no args)"));
}
else if (args[0] == "add") {
if (Bukkit.getPlayer(args[1]) == null) {
sender.sendMessage(translate("&cEnter a valid username"));
} else {
sender.sendMessage("found player");
}
}
else if (args[0] == "remove") {
if (Bukkit.getPlayer(args[1]) == null) {
sender.sendMessage(translate("&cEnter a valid username"));
} else {
sender.sendMessage("found player");
}
}
else {
sender.sendMessage(translate("&cThe syntax of this command is /healer add/remove [player]"));
}
return true;
}
}
try this
see what happens
does not shows anything at all
Have you tried detecting it?
It works now ๐
Epic make sure you're actually uploading the JAR before reloading
Yeah, you had the arguments right the first time. Still add all your options to it
what are you putting in
if (arguments.isEmpty()) {
arguments.add("help");
arguments.add("accept");
arguments.add("request");
arguments.add("decline");
}
return StringUtil.copyPartialMatches(args[0], arguments, new ArrayList<>());
wait
the code i was sending u was using == for string comparison
public class CommandHealer implements CommandExecutor{
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length==0) {
sender.sendMessage(translate("&cThe syntax of this command is /healer add/remove [player] (no args)"));
}
else if (args[0].equalsIgnoreCase("add")) {
if (Bukkit.getPlayer(args[1]) == null) {
sender.sendMessage(translate("&cEnter a valid username"));
} else {
sender.sendMessage("found player");
}
}
else if (args[0].equalsIgnoreCase("remove")) {
if (Bukkit.getPlayer(args[1]) == null) {
sender.sendMessage(translate("&cEnter a valid username"));
} else {
sender.sendMessage("found player");
}
}
else {
sender.sendMessage(translate("&cThe syntax of this command is /healer add/remove [player]"));
}
return true;
}
}
try this
i only copied the added else stat4ements
copy the whole thng
and for performance was my thing better or not?
ok
It's negligible either way
EntityDamageEvent and BlockDamageEvent don't do much
waht else was there
moral of the lesson
oh the elseeeeee
equalsignorecase
at the bottom
yes i added that
i thought uwas copying the whole thing
shouldve mentioned it
mybadd
wait i need to set smth up if there is no input for args[1]
i can do that on my own i think tho
still the same
nvm u wont need to cast
with this
@Override
protected @Nullable List<String> tabComplete(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args) {
if (arguments.isEmpty()) {
arguments.add("help");
arguments.add("accept");
arguments.add("request");
arguments.add("decline");
}
return StringUtil.copyPartialMatches(args[0], arguments, result);
I've got an annoying question
private MoonPhaseDetector.MoonPhase processMoonPhase(String path, MoonPhaseDetector.MoonPhase pluginDefault) {
if (!configHas(path))
return pluginDefault;
try {
return MoonPhaseDetector.MoonPhase.valueOf(fileConfiguration.getString(path));
} catch (Exception ex) {
new WarningMessage("Custom event file " + filename + " has an incorrect moon phase entry for " + path);
}
return pluginDefault;
}
this is how i am currently parsing enums from config but the really annoying thing is I need one method per enum which feels really inefficient, is there a way to use the pluginDefault value in the constructor to infer the enum type and then get to the #valueOf method so I can return any enum type via casting instead?
Try using Entity#setTicksLived maybe?
do new ArrayList<>() instead of result
why cant we access mc debug mode smh
its almost 6am im gonna go sleep now
if u need help ask other people
sheesh you do that
ty for all ur help
Are you saying you have to make a processMoonPhase method for each enum, changing the type of pluginDefault?
its like 4 pm for me lol
And calling the method something else I assume as well
I don't have to but I would like to yeah
fixed it! thank you sir
Well you just want a generic process(String path) that returns the enum type of whatever that path is?
I'm not really sure what you're trying to do I guess
๐
I want a generic processor that returns Object which I can cast into a specific enum and the enum it returns and tries to find is based on what I put on the constructor
unless there's an even better way of doing it which is possible
private Object processEnum(String path, Object enumDefault){
... same internal logic ...
}
sort of like that
I'm not sure it would be possible at all since java wouldn't necessarily know what the object is? that's why I ask
Yeah you're not even gonna know what to cast it to without already doing what you're doing pretty much
Ah, that's an option - but what would I set it to? Since it sets the ticks lived
feels like there's some enum functionalities missing for this to work
0 I guess? I assume they die once that reaches 100, (considering that'd be 5 seconds)
yea, i figured it out. thanks
Do you have to use enums?
yeah
Yeah, guess you'll just have to do it like that then :/
I can't really think of a better way
oh ah wait nvm
Caused by: java.lang.IllegalArgumentException: Age must be at least 1 tick
Set it to 1 then
So that or -1 won't work
Doesn't change much
Just set it to 1 every few seconds
java: package com.privatevaults.commands does not exist I suddenly get this error... wth is going on
my own package doesn't exist?
Is IntelliJ saying that or the server
intellij
Interesting... restart again I suppose?
already did multiple times
sometimes it compiles but most of the time I get this error
Bukkit.getPlayer isnt working, whenever the name is anypart of my username in order(my username is Epicmxnia so e or ep shows up as a name)
if (Bukkit.getPlayer(args[1]) == null) {
sender.sendMessage(translate("&cEnter a valid username"));
} else {
sender.sendMessage("found player");
sender.sendMessage(args[1]);
}
I got it to work, I think
that is intentional
use getPlayerExact if you don't want it to make an attempted match
i did and the same thing happened
is there any way to detect if a player is pressing their spacebar (jumping) when they're on a vehicle? e.g. let's say they're riding a chicken, how do you detect when they jump, since the initial and final y-locations wont change?
well getplayerexact should work
either bukkit is broken / the documentation has been wrong for years, or you forgot to compile your plugin or something
maybe my overall code is wrong
@unreal quartz this is the code
package io.github.Epicmania.healerPlugin;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class CommandHealer implements CommandExecutor{
public String translate(String text){
return ChatColor.translateAlternateColorCodes('&', text);
}
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length==0) {
sender.sendMessage(translate("&cThe syntax of this command is /healer add/remove [player]"));
}
else if (args.length==1 && (args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("remove"))) {
sender.sendMessage(translate("&cAdd the username of the player that should be added/removed as a healer"));
}
else if (args[0].equalsIgnoreCase("add")) {
if (Bukkit.getPlayerExact(args[1]) == null) {
sender.sendMessage(translate("&cEnter a valid username"));
} else {
sender.sendMessage("found player");
sender.sendMessage(args[1]);
}
}
else if (args[0].equalsIgnoreCase("remove")) {
if (Bukkit.getPlayerExact(args[1]) == null) {
sender.sendMessage(translate("&cEnter a valid username"));
} else {
sender.sendMessage("found player");
sender.sendMessage(args[1]);
}
}
else {
sender.sendMessage(translate("&cThe syntax of this command is /healer add/remove [player]"));
}
return true;
}
it shoudl only say that found player when the arg is the name of a player online on the server
what i wanted to do was make it so any mob thatโs near a block will โjump ontoโ the block. you know how when you ride a horse they automatically jump on one block heights? kind of like that
i thought if manually listening for the spacebar but since thatโs not possible this is the next best option
First of all use getPlayer over getPlayerExact unless you know what the exact variant means
ok but when i use getPLayer
if i put in the first letter of my ign
it says it found a player
Yeah that's how it works
wait
one sec
i think i just had a compiling issue
ok now i need to work out
if i add someone to the healer list
how do i like save their name
Lmao a capital E char code is 69 ๐คฃ
didn;t we go over this
.
Ima go fix my brainfuck interpreter cuz for some reason it's printing wrong characters or doing wrong things xd
hey i was wondering why my database isn't connecting?
it says no suitable driver found
but it worked on my old project
You have no driver
how do you call if a player uses a command
?jd
that makes no sense to me how do i fix that cause the database im trying to connect to right now works on my old project but not this one
ยฏ_(ใ)_/ยฏ
Is there a way to not make more then 1 class.
I'm trying to do like if
example
player.getcommand.("hi")
player.sendmessage("hello")
?
Sorry if want to listen to commands it needs to be a in a separate class
thats false you can do it in one class
annoying lowkey but ok
but its more custom to do in multiple classes
in BungeeCord, is there a way to not send a player to a server during login? I have logic PostLogin that chooses a server to send them to
No don't think so
idk
I don't think it's possible
Bungeecoord chooses what server to send you to
Also I don't think you can send players to servers in post login
You need to do it when they are in the server
this doesnt seem to be running..
new BukkitRunnable() {
public void run() {
if (!(plugin.activeEvents.containsKey(plr))){
return;
}
TNTPrimed tnt = (TNTPrimed) plr.getLocation().getWorld().spawnEntity(plr.getLocation(), EntityType.PRIMED_TNT);
tnt.setFuseTicks(2 * 20);
}
}.runTaskTimer(plugin,0,5 * 20);
No errors
It just dont summon the tnt
i can try to send message to the player
i think i got your answer
public static <T extends Enum> T process(String path, T def) {
/* code to get to the path, idk */
String eName = path; // the value / name of the enum
T eValue = (T) Enum.valueOf(def.getClass(), eName);
return eValue != null ? eValue : def;
}```
im on my phone so no thorough testing but it passed rextester.com so
oh shit
alright I'll give it a shot in a minute, I'm currently wrangling a different frankenstein's monster
Hello someone know how in
SQLibrary
in MySQL
you can replace '?' to string arg?
like
player_uuid or something
query("SELECT * FROM PVP_stats WHERE uuid = ?")
uhoh xd
ill be happy to be of aide if u need
how? what the code?
Connection#prepareStatment(query)
how do i get my current project version in code?
trying to set it during jar compilation im guessing?
nop
making a custom auto updater
so i wanna know my current version
u could hardcode it in? idk
declaration: package: org.bukkit.plugin, interface: Plugin
or that
not the best way to do things tbh
thanks
appreciate it but this one would take longer to explain than to resolve
depends
im aware, i just forgot that JavaPlugin has ways to get metadata
i also forgot that version is even specified in plugin.yml, or rather forgot about that file as a whole
lol
Hey, I got the new 1.17.1 spigot
When I try to make a project on that version it won't show it
Can someone help me with it?
somehow I am now stuck making a system that makes arbitrary amounts of configuration folders, creates arbitrary amounts of configuration defaults and reads arbitrary amounts of configuration files
also parses those files into something that can be safely used by plugins
how did I even get here
how would you guys go about a cooldown on placing a paticular block
just one block or for several blocks
maybe a permission on a block place event tied to a scheduled bucket command that gives and takes it?
god no
just for one block, tnt in my case
does it need to persist through restarts
hashmap<UUID, long> where long is the next valid unix time and uuid is player uuid
and the on block place event checks it?
yeah
public void start(Player plr) {
plugin.activeEvents.put(plr, this);
plr.sendMessage("Hi1");
new BukkitRunnable() {
public void run() {
if (!(plugin.activeEvents.containsKey(plr))){
return;
}
plr.sendMessage("Hi");
TNTPrimed tnt = (TNTPrimed) plr.getLocation().getWorld().spawnEntity(plr.getLocation(), EntityType.PRIMED_TNT);
tnt.setFuseTicks(2 * 20);
}
}.runTaskTimer(plugin,0,5 * 20);
plugin.activeEvents.remove(plr);
}
I get the Hi1 message
but not the Hi message
Use Bukkit.getScheduler().runTaskLater(). Really only need to use new BukkitRunnable() if you're self cancelling the Runnable I believe.
alright, ill try that
And you're probably not getting hi because plugin.activeEvents doesn't contain Player in it's keys so it's returning
it tells me i have to put new
ok, yea it is canceling
why tho...
it is being put, then checked if there
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
if (!(plugin.activeEvents.containsKey(plr))){
return;
}
plr.sendMessage("Hi");
TNTPrimed tnt = (TNTPrimed) plr.getLocation().getWorld().spawnEntity(plr.getLocation(), EntityType.PRIMED_TNT);
tnt.setFuseTicks(2 * 20);
}, 0, 5 * 20);
It's probably not there then
You tell it to return if it's not
but its being put there
plugin.activeEvents.put(plr, this);
if (!(plugin.activeEvents.containsKey(plr))){
Oh whoops didn't see that
Well, try the other Runnable and see if that works, and put hi above the if check and see if it prints then
alright
@reef wind can you help me with it?
no worky, its an issue with the return
OH
So
I made my plugin 1.17.1 and it says that it doesn't support it
plr.sendMessage("Hi2");
plugin.activeEvents.remove(plr);
its running this before the runnable ends
ONETRYSMP?
Even if you put the delay as 0
@torn shuttle```java
private static final HashMap<UUID, Long> tntTimer = new HashMap<>();
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
if (event.getBlockPlaced().getType().equals(Material.TNT)) {
Player player = event.getPlayer();
if (tntTimer.containsKey(player.getUniqueId())) {
long remainingTime = tntTimer.get(player.getUniqueId());
if (remainingTime > Instant.now().getEpochSecond()) {
event.setCancelled(true);
player.sendMessage(Utils.chat("&eTNT TIMER: &bYou must wait " + (remainingTime - Instant.now().getEpochSecond()) + " seconds"));
}
}
tntTimer.put(player.getUniqueId(), tntTimer.get(player.getUniqueId()) + 5);
}
}
Mhm
Oh wow! Lol I do the plugins for it ๐
so, how do i have the line run after the runnable?
That's so cool!
Just remove them inside the Runnable instead of outside
They are outside..
I do have a problem with 1.17.1
public void start(Player plr) {
plugin.activeEvents.put(plr, this);
plr.sendMessage("Hi1");
new BukkitRunnable() {
public void run() {
if (!(plugin.activeEvents.containsKey(plr))){
return;
}
plr.sendMessage("Hi");
TNTPrimed tnt = (TNTPrimed) plr.getLocation().getWorld().spawnEntity(plr.getLocation(), EntityType.PRIMED_TNT);
tnt.setFuseTicks(2 * 20);
}
}.runTaskTimer(plugin,0,5 * 20);
plr.sendMessage("Hi2");
plugin.activeEvents.remove(plr);
}
Yeah put it inside instead of outside
o
but then it woul repeat
?
right..
I want the runnable to run for 5 seconds
then stop
throw in ignore cancelled, high priority, make the first check a null check to see if the hashmap contains the player, if the timer is done make sure to clear the player entry
always try to exit out as early as possible
Remove them on the last iteration
... how?
Do you want it to run every 5 seconds?
time to have fun with counters
I chnaged the 5 to 2
Yep lmao
alright
so keep the repeating task
right, then add a delayed task after it
to change that hasmap
You can, or you can loop a runTaskLater() 5 times with 2 second intervals from each other
Sounds like runTaskTimer is more appropriate
AAAAAAAAAAAAA
Oo
Probably, just have to cancel it at some point.
Myeah
what is the spigot plugins/update folder used for?
does it have some kind of auto updating?
Can you send code
I think it's used for plugins that support auto-updating
public void start(Player plr) {
plugin.activeEvents.put(plr, this);
plr.sendMessage("Hi1");
// Waits 10 seconds to cancel the event.
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
plugin.activeEvents.remove(plr);
}
}, 10 * 20);
new BukkitRunnable() {
public void run() {
if (!(plugin.activeEvents.containsKey(plr))) {
return;
}
TNTPrimed tnt = (TNTPrimed) plr.getLocation().getWorld().spawnEntity(plr.getLocation(), EntityType.PRIMED_TNT);
tnt.setFuseTicks(2 * 20);
}
}.runTaskTimer(plugin, 0, 2 * 20);
}
how do i make my plugin support it?
its just event.start(plr); thats calling it
Google!
@hasty prawn i think its running more times the longer the server is up...
Use runTask instead of scheduleSyncDelayedTask
Oh wait, runTaskLater I mean
alright
This isn't a feature of Spigot itself, is it?
I only know of 3rd party plugins that do it for you
Could be, I never messed with auto updating.
Yeah, same, I only print a warning to the console if its outdated ๐คทโโ๏ธ
Yea, it is spawning 3 tnt, the third time i have run it
Obviously works, if two updates I released over a month ago are still by far the most used versions ๐
How many times are you running event.start(Player), just once?
yea just once
It should spawn 5 tnt not 3 ๐ค
Well actually it should spawn infinite since you never cancel
No, it spawns 3 at a time the third time i run it
If i run it again
It spawns 4 at a time
Oh
Oh, yeah it's because you're not canceling it
should i use smthng other than return;?
In the runTaskLater() Runnable you need to do Bukkit.getScheduler().cancelTask(<task id of the timer>)
how do i ghet the taskID....
So, I know that making the config static is not good practice. Conversely, I don't want there to be multiple instances of the Config class because I feel that will lead to future problems with saving and stuff I don't want to deal with. Would making this Config class use a singleton pattern be considered bad?
Method under BukkitTask
Conclure ๐
Heyo
You canโฆ wait how
?scheduling look here
Ok
BukkitTask theTask = Bukkit.getScheduler().runTask(null, task -> {
task.cancel();
});
theTask.cancel();
@ivory sleet I actually read that, itโs very useful ๐
It takes a consumer conveniently enough
Well yeah the BukkitTask would work
Should do one on what we was talking about
Oh I didn't know it took a consumer
1.8 can ๐
that's cool
Yeah, functional interfaces

Not that cancelling it inside helps here but still useful to know :O
Ok waitr
Oh yeah my bad tldr
how do i gte the ID
You can just store the BukkitTask and cancel it then
So i would have to rewrite this
new BukkitRunnable() {
public void run() {
if (!(plugin.activeEvents.containsKey(plr))) {
}
TNTPrimed tnt = (TNTPrimed) plr.getLocation().getWorld().spawnEntity(plr.getLocation(), EntityType.PRIMED_TNT);
tnt.setFuseTicks(2 * 20);
}
}.runTaskTimer(plugin, 0, 2 * 20);
No just add BukkitTask task = at the start
And then inside the runTaskLater just do task.cancel()
You'll have to swap the order you create them in I think
ok
public void start(Player plr) {
plugin.activeEvents.put(plr, this);
BukkitTask task = new BukkitRunnable() {
public void run() {
if (!(plugin.activeEvents.containsKey(plr))) {
this.cancel();
return;
}
TNTPrimed tnt = (TNTPrimed) plr.getLocation().getWorld().spawnEntity(plr.getLocation(), EntityType.PRIMED_TNT);
tnt.setFuseTicks(2 * 20);
}
}.runTaskTimer(plugin, 0, 2 * 20);
// Waits 10 seconds to cancel the event.
new BukkitRunnable(){
@Override
public void run() {
plugin.activeEvents.remove(plr);
task.cancel();
}
}.runTaskLater(plugin, 10 * 20);
}```
i also added the this.cancel
Don't need both
?
You can do one or the either, don't need both of them
but i want the runTaskTimer to run every 2 seconds for 10 seconds..
Yeah it would, you're just stopping it after 10 seconds twice
Honestly the this.cancel() is probably a better idea
public void start(Player plr) {
plugin.activeEvents.put(plr, this);
new BukkitRunnable() {
public void run() {
if (!(plugin.activeEvents.containsKey(plr))) {
this.cancel();
return;
}
TNTPrimed tnt = (TNTPrimed) plr.getLocation().getWorld().spawnEntity(plr.getLocation(), EntityType.PRIMED_TNT);
tnt.setFuseTicks(2 * 20);
}
}.runTaskTimer(plugin, 0, 2 * 20);
// Waits 10 seconds to cancel the event.
new BukkitRunnable(){
@Override
public void run() {
plugin.activeEvents.remove(plr);
}
}.runTaskLater(plugin, 10 * 20);
}
You can if you want to do it that way I guess
