#help-archived
1 messages · Page 215 of 1
@frigid ember how do you save an effect
Try giving the effect with a 1 tick delay
how do i add a delay?
new BukkitRunnable() {
public void run() {
//MY CODE
}
}.runTaskLater(plugin, delayInTicks);```
so... do anyone know how to send a response from a sent message and then receive that answer on spigot
because the only thing that ik how to do is sent from bungee to spigot and spigot to bungee
without sending an answeerr
learn java
Just delay the addPotionEffect
^^
so... no one knows?
I have a number saved on a BUNGEE plugin and I want to get it. So for it Im trying to using plugin messaging. I have a method called getNumber in the spigot plugin and I want to make it return the number from the BUNGEE plugin. How can I do it?
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
try {
out.writeUTF("Message");
out.writeUTF("messagehere");
out.writeUTF(ChatColor.GOLD + "another");
} catch (IOException e) {
return;
}
player.sendPluginMessage(plugin, "BungeeCord", b.toByteArray());
try {
b.close();
out.close();
} catch (IOException e) {
}
hum
but that will just send
Ik how to do that
I need to receive an answer and return it in the method
How do i override an vanilla comand? For example /kill with custom messages
Nothing to be sorry about 👍
I have a number saved on a BUNGEE plugin and I want to get it. So for it Im trying to using plugin messaging. I have a method called getNumber in the spigot plugin and I want to make it return the number from the BUNGEE plugin. How can I do it?
@edgy cove ...
? wdym?
Oh...
what do i put for plugin
its the main class
ok
but the instance of it
so if u are making it inside the main class just put this
eh litteraly this
it's not the main class
im putting the code in anther class
oh ok
in my listener
uh I cant explain very well but I will try
sorry to butt in... but is there an updated "Auto Command" Plugin?
u can create a public static variable for ex:
in the main class or this class
main class
ok
i already have a private static ForJump instance; if that's what you mean
wait that's private
public static Plugin plugin;
// AND THEN IN THE ON ENABLE...
public void onEnable() {
plugin = this;
}
// IN YOUR EVENT CLASS
BukkitRunnable#runTaskLater(MainClass.plugin, 5L);
sorry to butt in... but is there an updated "Auto Command" Plugin?
@frigid ember wdym?
like uhhh this https://dev.bukkit.org/projects/tce
You want to encapsulate that...
Why dont u use that one then?
oh soo it works even if its old version?
lol oke
idk if it will work
i found something recent which is compatible with 1.13 sooo
probably...?
ima try oof
yus
....
uh...
you'd want to make it private and make a getter for it
If it's not private, I could easily go and change that plugin variable to my own plugin
and that'll mess a lot of things up
yea
@past orbit try WHEAT?
That's why a public getter exists 😐
https://www.spigotmc.org/threads/gui-multiple-pages.338528/#post-3150868 Is this the best way to make an unknown amount of GUI pages?
private static MESystem instance;
public MESystem() {
instance = this;
}
public static MESystem getInstance() {
return instance;
}
boom
done
@past orbit well u can use the legacy material support in last case but I will check here 1 sec
oh
How do i get an offline player?
Player target = Bukkit.getOfflinePlayer(args[0]).getPlayer();
I ahve this
declaration: package: org.bukkit, interface: OfflinePlayer
But it throws error
because Player and OfflinePlayer are two separate things.
Caused by: java.lang.NullPointerException
at de.skylead.commands.ban.onCommand(ban.java:22) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
... 15 more
you need to do OfflinePlayer player = Bukkit.getOfflinePlayer
But i need to get if the player has an perm
print args[0] out is it null?
whats that target?
an offline player
well thats the null thing but it should not be possible
OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]);
if (target == null)
return false;
why are you checking if an OfflinePlayer has permissions anyways?
or it is?
ah it have@NotNullannotation
why don't you just not allow people to ban players with a higher rank
what?
@umbral dirge you can check if the player is null
it might help
public class ban implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
Player p = (Player) sender;
if(p.hasPermission("skylead.kick")) {
if(args.length > 1) {
OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]);
if(target.getPlayer().hasPermission("skylead.kick.bypass")) {
p.sendMessage("§8● §3§lSkyLead §8» §7Diese Person darf nicht gebannt werden.");
return false;
}
MySQL.createPlayer(target.getPlayer());
MySQL.banPlayer(target.getPlayer(), 1, false);
kickManager.kickBannedPlayer(target.getPlayer(), 1);
if(args[1] == "1") {
p.sendMessage("§8● §3§lSkyLead §8» §7Du hast " + args[0] + " für Hacking 30 Tage gebannt.");
}
for(Player pl : Bukkit.getOnlinePlayers()) {
if(!pl.getName().equals(p.getName())) {
if(pl.hasPermission("skylead.notify")) {
pl.sendMessage("§8● §3§lSkyLead §8» §7" + p.getName() + " hat " + args[0] + " für Hacking 30 Tage gebannt.");
}
}
}
} else {
p.sendMessage("§8● §3§lSkyLead §8» §7Bitte benutze§8: §7/ban <SPIELER> <GRUND>");
}
} else {
p.sendMessage("§8● §3§lSkyLead §8» §7Bitte benutze§8: §7/ban <SPIELER> <GRUND>");
return false;
}
return false;
}
}
I need to get if the player has an permissin
@wispy pewter its a OfflinePlayer what is never null
Ah oke
oh
its because u do
target.getPlayer()
just use target.hasPermission()
but idk if it will work btw
Check the docs
PermissionsEx.getUser(target.getName()).has("skylead.ban.bypass")
toggle my listeners/event handlers
hummm
so u can unregister listeners if Im correct
and then register them
or
u could make a boolean
like boolean enabled
if(!enabled) return;
i had to make a toggle for my fabriuc mod
in every listener
i think the hard part is how do i add arguments to commands
this is all i know so far https://www.spigotmc.org/wiki/create-a-simple-command/#designing-the-command
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
oh man
Its easy!
when u create your onCommand method
the String[] parameter are the args
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
if(args.length < 1) {
// NOT ENOUGH ARGS
return;
}
if(args[0].equals("start") {
//START CODE
return;
}
if(args[0].equals("stop") {
//START CODE
return;
}
}```
something like this
eh in what version are u?
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
String arg = args.length > 0 ? args[args.length -1] : "";
return Arrays.asList("farm", "farmland", "furnace").stream()
.filter(s -> (arg.isEmpty() || s.startsWith(arg.toLowerCase(Locale.ENGLISH))))
.collect(Collectors.toList());
}``` I found this on internet....
1.16
How can I launch a boat with a player up in the air? I've tried setting the velocity with setVelocity, but it doesn't work with players in the boat (only with empty boats).
For, say, a skyblock core. Is using different world files for each island better or using just one world?
hi. If I'm not defining crafting recipes in the main class, how do I define it in the other class?
oh eh
I dont think its rlly a material
u can try cast the block, MaterialData, or block data into Crops
to see if it works
Please @ me if you know btw 🙂
@lime crater dont put this and yes new ClassName()
Sorry?
hi. If I'm not defining crafting recipes in the main class, how do I define it in the other class?
@lime crater
isnt that u wanted to know or Im just so confused? hahhaa
"this" ?? what do you mean? "yes"??
https://prnt.sc/ttcno8
ok can u show me exacly what u want to do and your code rn
I have nothing in my main class regarding this, that's what I want to figure out.
In my other class where I want to have the recipe I have https://prnt.sc/ttcpep
it should toggle right?
Could be any crafting recipe, doesn't matter.
is there a non deprecated way in 1.13+ of getting the name of an inventory
i think i'm blind i can't find anything
InventoryView
@EventHandler
public void test(CreatureSpawnEvent e) {
if(e.getEntity() instanceof IronGolem) {
IronGolem golem = (IronGolem) e.getEntity();
float falldis = 0;
if(golem.getFallDistance() > 0 && !golem.isOnGround()) {
falldis = golem.getFallDistance();
}
if(golem.isOnGround()) {
golem.damage(falldis * 2);
}
}
Hello Guys I am new to coding
and trying to code a plugin to make ig take fall damage
what did I do wrong 😅
Sorry if I am big noob haha
Does someon know what event is fired when an Anvil lands?
@grim halo EntityChangeBlockEvent
Ah right. Thanks.
some code I used:
Wow that’s a very generic event
Block block = e.getBlock();
if(block.getRelative(BlockFace.DOWN).getType() == Material.AIR)
return;
hello anyone can help me i cant post anything or reply in the spigot forums
@EventHandler
public void onAnvilLand(EntityChangeBlockEvent event) {
Block block = event.getBlock();
if (block.getType() != Material.ANVIL || block.getRelative(BlockFace.DOWN).getType() != Material.AIR) {
return;
}
// Do stuff with landed Block
}
This should work right?
how can i make a command tab complete?
i want to add start and stop
so when they type /m4j, start and stop pop up
@wary ledge Bukkit.getPluginCommand("").setTabCompleter(new YourClassImplementingTabComplter);
just a snippet of course.
i got that
but how do i add the things that pop up
like how does it know what to show
i already have a working command
do i add to it or change it
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {```
so then do i make a new class
If I have this in my main class and it works perfectly,
ItemStack grass = new ItemStack(Material.GRASS);
ItemMeta meta = grass.getItemMeta();
meta.setDisplayName(ChatColor.GRAY + "boop");
meta.setUnbreakable(true);
meta.addEnchant(Enchantment.ARROW_DAMAGE, 5, true);
grass.setItemMeta(meta);
NamespacedKey grasskey = new NamespacedKey(this, "grass_key");
ShapedRecipe grassrecipe = new ShapedRecipe(grasskey, grass);
grassrecipe.shape(" ", " S ", " C ");
grassrecipe.setIngredient('S', Material.STONE);
grassrecipe.setIngredient('C', Material.COBBLESTONE);
Bukkit.addRecipe(grassrecipe);```
After changing NamespacedKey(this, ...) to the plugin name outside in another class, why wouldn't that work?
hey guys, when changing the max health attribute of an entity, its helath doesn't update nor does it regenate up to the new max health value. What has to be done to fix this?
@fossil shoal
Objects.requireNonNull(entity.getAttribute(Attribute.GENERIC_MAX_HEALTH)).setBaseValue(health);
uh
How can I wait for a variable become true and then make a code?
how does that work?
I know that, the attribute is set successfully
and are you then setting the health?
How can I wait for a variable become true and then make a code?
@edgy cove , what do you mean?
I have a method
that makes a thing
but that thing is not instantly
so I need to wait for a boolean to become true
and then return a double on the method
Is there no way to make the health regenerate up to the newly set max health?
while stops the entire server
@fossil shoal , yes it is possible
so I cannot use it
as like this I cannot transform the boolean in true after the thing finishes
okay, how? 🙂
im going off a spigot forum post
you do entity.setHealth(new health goes here)
public class TabComplete implements TabCompleter {
private static final String[] COMMANDS = { "m4j" };
//create a static array of values
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
final List<String> completions = new ArrayList<>();
StringUtil.copyPartialMatches(args[0], COMMANDS, completions);
Collections.sort(completions);
return completions;
}
}```
@edgy cove , do you have a basic java knowledge?
I would highly recommend you looking into that
@wary ledge , yes
@peak marten What I mean is make the entity naturally "regain" this health
Eh MrGeneralQ on some things
Error:(20,19) java: method copyPartialMatches in class org.bukkit.util.StringUtil cannot be applied to given types; but it no work
i has been lied to
so for example entity spawns with 20 -> I set new max health to 20 -> it slowly gains health up to 40
@fossil shoal , why would you not be able to ? if you want regenerating health, you will need a bukkit runnable and retrieve the entity you want to regen it's health
You need a bukkit runnable for that
@wary ledge , what do you mean?
i get that error
Don't use that.
you will need to build in the logic, and for example say, if the arg[0].equalsIgnoreCase("some sub command")
then:
return your new array of Strings (autocompletions)
Also, don't forget to sort them.
what line
Example of my plugin:
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String s, String[] args) {
if (args.length == 0) {
return this.bloodmoonService.getSubCommands().keySet().stream().filter(a -> sender.hasPermission("bloodmoon." + a)).sorted().collect(Collectors.toList());
}
It returns a list of all the registered subcommands of the bloodmoon command
So based on your command, you return a different result
but how do i set sub commands
not good
public class PluginCommands implements CommandExecutor {
@Override
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
if (args.length < 1) {
sender.sendMessage(ChatColor.RED + "Please use /m4j <start/stop>");
}
else {
if (args[0].equals("start")) {
ForJump.active = true;
sender.sendMessage(ChatColor.GREEN + "Mine for Jump started!");
}
else {
if (args[0].equals("stop")) {
ForJump.active = false;
sender.sendMessage(ChatColor.RED + "Mine for Jump stopped!");
}
else {
sender.sendMessage(ChatColor.RED + "Please use /m4j <start/stop>");
}
}
}
return true;
}
}```
@peak marten this is not what I am talking about. The entity does not naturally regenerate health past 20, that means that even if I set its health to 40 (for example) using setHealth and then it gets hit, it won't regenerate its health back to 40 (which is the max health in this example). What I am asking is why is the health regeneration does not go past 20 even though I increased the max health and whether there is something I can do to change that.
switch (args[0].toLowerCase()) {
case "start":
// c
break;
case "stop":
// c2
break;
default:
break;
}
Okay so, in your new class you write:
List<String> commands = new ArrayList<String>();
commands.add("start");
commands.add("stop");
if(args.length < 0){
return new ArrayList<String>(commands);
}
@fossil shoal , I could be wrong, but are you sure that automated health regeneration is even a thing?
is that it
No matter if it actually exists or not, you can solve your issue by using the runnable.
@peak marten so u know how?
If spigot doesn't do it for you, then you can make it work
mobs don't regenerate health naturally
@edgy cove , your use case is a bit vague
Thank you for the confirmation @quick arch
bot dumb
The bot warned me great
yeah it's dumb
I saw the message
Horses, donkeys, mules, llamas and the wither are the only mobs that regenerate health naturally over time.
@peak marten I want to wait for a boolean becomes true and then return something in my method.
That boolean becomes true from the Main Method and I want to it to wait on a method in another class.
Probably could just use the regeneration effect to regenerate their health
instead of creating a runnable
but that's going to be relatively slow
Interesting, didn't even think about that
Picono, you want to wait for a variable to become true, would that be in the same method? If yes, you need to use a do while, if not, you need to use a runnable
still unsure on what you actually mean
@peak marten you're right, should have checked that before, wiki (https://minecraft.gamepedia.com/Healing#Mob_healing) says that most mobs don't heal naturally. Thank you.
You're welcome
is there a way for an item not to go inside hopper
when dropped on it?
thank you
You're welcome
Hey I need help with WorldGuard maven api.
Repository:
<repository>
<id>sk89q-repo</id>
<url>http://maven.sk89q.com/artifactory/repo/</url>
</repository>
Dependency:
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId>
<version>6.1.3-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
Somehow IntellIJ keeps giving me errors and it takes years to load the project
Error:
Could not find artifact com.sk89q.worldguard:worldguard-bukkit:pom:6.1.3-SNAPSHOT in spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/)
It says that it is trying to get it from hub.spigotmc.org but it doesn't actually load it from the given http://maven.sk89q.com/artifactory/repo/.
Anyone know a fix?
DeathInfo:
e9d30742-403e-4726-8b0f-de85903ede35:
'0':
location: world, 229, 72, 251
reason: Lazinq fell out of the world
time: 1596480049777
tryna get this info back out again
but it is not working :/
ikr loadData looks like shit
thats probably why its not working
ConfigurationSection se = getConfig().getConfigurationSection("deathlocation." + uuid + "." + deaths.indexOf(data));
.
But it's called DeathInfo not deathlocation
do
mvn clean install
@rare prairie https://hastebin.com/aqahicurir.sql get this the log.
and there has to be a ". " at the end I think
uuuuuuuuuuuuuuuuf
ConfigurationSection se = getConfig().getConfigurationSection("DeathInfo." + uuid + "." + deaths.indexOf(data) + ".");
returns null
@rare prairie https://hastebin.com/aqahicurir.sql get this the log.
522 Origin Connection Time-outso probably worldguard repo is overloaded
522 Origin Connection Time-outso probably worldguard repo is overloaded
@rare prairie When I do it in my browser I get no errors with browsing to that repo.
try to remove placeholderapi repo, build your project, after that if the build success, add back the papi repo and build again
or remove the m2 folder from users, if have (dont know intellij generating this folder)
wait placeholderapi is getting 522 error...
great
For, say, a skyblock core. Is using different world files for each island better or using just one world?
Hello I have a method called getNumber with the parameter playername in my API class in my spigot plugin and I want to it return a number that is saved on my bungeecord plugin. Here is a small scehematic of the messages that I sent of what is happenning: https://prnt.sc/tte5bl. So explaining writing... in my method I send a message to bungee and then bungee when it gets that messages send a message for spigot with the number (the listener of received messages is in the main class). Now when I receive that number I add it in a Map... so in my method I need to send the message and then when the main class receives the message I need to return the number that is saying on the message (that was putted on a map). How can I do this? (I already made everything sending messages I just need to make something to wait until the Map contains the number and then yes get the number from it and return it on the method)
I really appreciate help hahahahahah
Hey there, is there a way to get an entity if its in the line of sight of an player?
placeholderapi got ddosed
all of clip's shit is down
how do i make the default rank/group on luckperms a different to "default"
Did you google? 😐
For, say, a skyblock core. Is using different world files for each island better or using just one world?
ye
So did you read the wiki thread that comes up?
nvm ill just set the default to the thing i want
how do I change plugin priority
idk
can someone idiot check me pls
How can I find the Spigot API docs for 1.8.8?
was support for wildcard permissions removed in 1.13+
@heavy pelican http://jd.andross.fr/1.8.8/doc/
Thx
How can I make a Material that is a string variable? (Material.VAR)
because Material. + VAR doesnt work
Material#matchMaterial
Thanks!
is plot squared in 1.16?
creeper.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(40); is this how u set the health for entities?
private void saveData() {
for (Map.Entry<UUID, List<Data>> myDataMap : dataMap.entrySet()) {
List<Data> deaths = dataMap.get(myDataMap.getKey());
myDataMap.getValue().forEach(data -> {
String saveKey = "DeathInfo." + myDataMap.getKey() + ".";
String intPlace = saveKey + deaths.indexOf(data) + ".";
getConfig().set(intPlace + "location", locToString(data.getLocation()));
getConfig().set(intPlace + "reason", data.getReason());
getConfig().set(intPlace + "time", data.getTime());
});
}
saveConfig();
}```
I need to get this info again
but I havent really had a huge succes yet
so all the creepers that spawn in my world will have the health of 40?
could some1 maybe help
DeathInfo:
e9d30742-403e-4726-8b0f-de85903ede35:
'0':
location: world, 228, 69, 257
reason: Lazinq fell out of the world
time: 1596481945677
'1':
location: world, 221, 64, 263
reason: Lazinq fell out of the world
time: 1596481950063
'2':
location: world, 213, 68, 251
reason: Lazinq fell out of the world
time: 1596481958142```
stored like this
can be 3 of each player
but can also be 1, 2
the location is stored by my own locToString
and I also have a stringToLoc
private void loadData() {
if(getConfig().getConfigurationSection("DeathInfo") != null) {
ConfigurationSection sec = getConfig().getConfigurationSection("DeathInfo");
for (String uuid : sec.getKeys(true)) {
Integer sec1 = getConfig().getInt(sec + "." + uuid + ".");
}
}
}```
is what I currently have
Why do you have a . at the end
to complete the path
shouldve also done that behind sec :/
like this
Does anyone know a toggle command for toggling a event??
what?
a toggle line of code in java that allows you to toggle an event
call the event?
no to turn it off and on
via config.yml?
NO
/*
*/```
is there a way to hide messages like these in console?
[08/03/2020 04:00:55 pm] [Server thread/INFO]: Villager EntityVillager['Fletcher'/114315, l='ServerLevel[world]', x=-540.48, y=63.94, z=-90.72] died, message: 'Fletcher was slain by Drowned'
I am trying to host a strictly vanilla server, but today I accidentally saw this message when I glanced in the console and now I feel like I am cheating for knowing this information lol. If I had to compare this to something else, it is like accidentally seeing a mineshaft through the ground while the server chunks are trying to render, so I have to try and forget I even saw that
hi i am using the plugin of factions3 and i have a question about the dynmap because i want to change the color for each one region on the map. How can can i do it?
and a friend told me to do the question here
is there a way to hide messages like these in console?
[08/03/2020 04:00:55 pm] [Server thread/INFO]: Villager EntityVillager['Fletcher'/114315, l='ServerLevel[world]', x=-540.48, y=63.94, z=-90.72] died, message: 'Fletcher was slain by Drowned'I am trying to host a strictly vanilla server, but today I accidentally saw this message when I glanced in the console and now I feel like I am cheating for knowing this information lol. If I had to compare this to something else, it is like accidentally seeing a mineshaft through the ground while the server chunks are trying to render, so I have to try and forget I even saw that
Spigot.yml has an option
I think it's show-villager-deaths or something
Anyone by chance have a fix for GoldenCrates item dupe with visual item rolls enabled?
@frigid ember What kind of menu?
Guys how can i use MySQL ? Need an account ?
yo so im reading a book about java, and it keeps mentioning operand, but it doesn't define it, what does operand mean?
so arithmetic operations?
Those are arithmetic operands.
hmm
Ther are also logical operands
== != > < <= >= && ||
Anyone have any thoughts on how to make different plugin permission error messages show a rank needed instead of just no permission?
And operands for bit manipulation ~ & | ^
@cerulean musk You need to install mysql on your server. There are a lot of tutorials on that.
İ have a plugin and its support MySQL. But it wants username passowrd and ..
Need a MySQL account or idk ?
You need a MySQL server
@cerulean musk As stated above. You need to install a mysql database on your server. There you can manage your profiles.
Oh i will try it thanks.
yes. literally the modulo operand
Hey guys, can somebody help me with the ConversationFactories?
I try to use them as a little input service. I would like to send a message to the player if he did input a wrong number or message (e.g the wanted player is not online or the input is not a number).
And there is the problem. I cant send a message to the player immediatly after a prompt.
Can somebody help me with this issue?
anyone know a plugin for creating chest like menus that you can open with a commands
@Override
public @Nullable Prompt acceptInput(ConversationContext context, String answer) {
Player p = (Player) context.getForWhom();
if (answer.equals("yes") && answer.equals("no") {
p.sendMessage("Wrong input! Only yes or no allowed.");
}
return null;
}
Thats not the original code but it will produce the same issue
"eqauals"?
Does anybody know how to send messages in a prompt or immediatly afterwards
@sinful spire sorry i quickly wrote that with notepad
ok
hey I was wondering if it was possible to disable the overworld on my server and only have the nether
I know you can disable the nether and end but what about the overworld
set the server spawn to a nether world and disable portal travel
how do I disable portals?
wait i cant send screenshot here :-:
gotta be verified
?
Just add a "}" to the end of your class to complete the class body...
hey so im very new to programming java like really new im trying to make a plugin that lets players use /help to notify any avaible staff that have the perm playerhelp.staff so that they can come help them and i dont understand how to fix this error
hm
wdym exactly
The character }
Put one more at the end of your class...
You have more opening brackets { than closing ones }
Also would you mind to copy the command method in here.
Just add 3x ` at the start and end to format code.
ok
Code goes here
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
@Override
public void onEnable() {
}
@Override
public void onDisable() {
}
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (label.equalsIgnoreCase("help")) {
if (sender instanceof Player) {
Player player = (Player) sender;
if (player.hasPermission("playerhelp.use")) {
player.sendMessage(ChatColor.RED + "A Staff member will be with you shortly!");
for (Player all : Bukkit.getServer().getOnlinePlayers()) {
for (Player p : Bukkit.getOnlinePlayers()) {
if (player.hasPermission("playerhelp.staff")) {
player.sendMessage(ChatColor.DARK_RED + player.getName() + ChatColor.DARK_RED + " Needs Help!!");
}
}
return true;
}
}
}
else {
sender.sendMessage(ChatColor.DARK_RED + "You do not have Permission to access this command!");
return true;
}
return false;
}
}
how do i give mobs potion effects like a zombie for example
so i know what u mean 7smile7 but like if i put one like this look what happens
is it possible for me to do:
float x = .5;
float y = .0;
float z = .5;
or what should i do to get the players x y and z
double x = player.getLocation().getX();
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!label.equalsIgnoreCase("help")) {
return false;
}
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.DARK_RED + "You do not have Permission to access this command!");
return true;
}
Player player = (Player) sender;
if (!player.hasPermission("playerhelp.use")) {
return true;
}
player.sendMessage(ChatColor.RED + "A Staff member will be with you shortly!");
for (Player online : Bukkit.getOnlinePlayers()) {
if (online.hasPermission("playerhelp.staff")) {
online.sendMessage(ChatColor.DARK_RED + player.getName() + ChatColor.DARK_RED + " Needs Help!!");
}
}
return true;
}
@restive granite I formatted your method to make it more readable. Try to escape more early if certain conditions are not met.
tanks
alright, I have GUI, and I want it when a player presses on a certain field (already know how to do that) i want it to look for someone to write a string in chat. However i want this string to NOT be a command, but still be able to do something special. Is this possible?
zombie.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 3)); am i doing this right?
wait chick for ```java
float x = .5;
float y = .0;
float z = .5;
couldn't you just do ```java
float x = .5, y = .0, z = .5;
```?
oh alright
@solid sundial You cant recommend chat input to the player.
alright, I have GUI, and I want it when a player presses on a certain field (already know how to do that) i want it to look for someone to write a string in chat. However i want this string to NOT be a command, but still be able to do something special. Is this possible?
@solid sundial
On player click, close inventory and send them a mesage telling them to type one
Listen to the async chat event and on chat, check if you are waiting for a user input, if so there you have it
ok
hey guys, i have a plugin on called regionclaim for 1.16 I dont see a direct uninstall method as i seem to have found a better option with more features. To do this am i just turning off the plugin, deleting the folder and restarting the server or is there other steps i have to do?
Remove the jar and you are good to go
i have it so that it closes the GUI. That answers my question but im just asking now, im ok if this does not work, if it only listens for that string during the time period where my GUI is out
My first time playing around with plugins. Thankyou for your time
i have it so that it closes the GUI. That answers my question but im just asking now, im ok if this does not work, if it only listens for that string during the time period where my GUI is out
@solid sundial If your GUI is out, the player won't be able to chat
@solid sundial You can put the player id in a set and listen for the async chat event.
@solid sundial https://imgur.com/mHD83ty
to any staff that can see this is it possible to make more than one help room because there are so many conversations colliding
that gif helps lots
You could look at the source of the anvil gui
The chat thing your are trying to do works but may be confusing to people
yeah lol
yeah i agree with @solid sundial there should be more than 1 help room
@frigid ember https://www.spigotmc.org/resources/deluxemenus.11734/
This was already recommended to you
Did you try it? Just because they didnt test it for 1.16 doesnt mean it wont run there. If it runs on 1.15 you have a very good chance that it runs on 1.16
ill test
bicxter
there's a 1.16 deluxemenus dev build
that's working perfectly fine without any reported issues
hmm for some reason the permissions that i put seem to not be showing up in luck perms
ok
that's working perfectly fine without any reported issues
@frigid ember in https://ci.extendedclip.com/job/DeluxeMenus/ ?
probs
@restive granite You can register permissions in your plugin.yml
https://www.spigotmc.org/wiki/plugin-yml/#wikiPage
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
it wont work :(
i mean
i cant find the 1.16 dev build thing
just google around, pretty sure you can ask around in their discord
if there are no plugins out there that fit your needs, go watch the 100 spigot coding tutorials out there and make one
Im pretty sure your looking for a GUI, and there are about 4-5 tutorials for that out there
@grim halo tysm !
set the server spawn to a nether world and disable portal travel
@grim halo how do I disable portals?
why do I have high ping on my server when I use localhost?
yes
0.0
and tps is 20
@ripe narwhal not possible
You aint on localhost if you have a high ping
send a screenshot
and timings pls
WTF
send timings please
timings?
Im getting timed out
how
Im not kidding Im using localhost
is there a way to fix this?
try 127.0.0.1
ok
true but I mean
@limpid fulcrum Here i wrote you a plugin that blocks all portal teleportations that have a "NORMAL" type world as target.
@ripe narwhal What are your specs?
of my computer?
No of your washing machine
...
cpu i7-8750h
ram 32 gb
uh
I have the server on a ssd with 3gb per sec speed
This should be plenty... do you have mutliple servers running?
type ping localhost in your console pls
How? Its a server on the same machine right?
yes
I dont understand how my ping goes up and the tps stays at 20
shouldn't the tps go down
TPS and latency have nothing in common.
oh ok
btw sometimes when I join it takes some time to load chunks
and I stay at 0 ping on those times
@torn robin He has >2000ms on his localhost server... this is not possible
Impressive
it means it's not calculated
That’s quite the latency
lol
Local host ping more or less is 0
are you sure you're not joining thru the router ip?
Cause it’s a local host
or the public ip?
Im sure
localhost is 0
but I think its the loading chunks thing thats doing this
Das not how ping works last I checked
ik but that is doing something
is it possible to use my variable through different methods. I know it is, but for some reason it not working
it takes some time to load chunks so I guess its slow internet?
so you made sure that:
- There is only one server running (no other javas in your task manager)
- You dont have hamachi or something like this running
- You are connected via "localhost"
Let me check
And chunkloading has nothing to do with your ping
1- yes
2- just checked
3- Im sure
@solid sundial Yes you can pass variables if you have them in the right scope.
i get that
i need help
but how and why does it not work
ok so my ping goes super high when I get on the server
and when I play for a little while
it gets lower
idk why
now I got timed out
cuz I rejoined
my plugin wont load
@solid sundial One example
check your plugin.yml
umm
@solid sundial Another example. And there are many more.
are you coding or is this a plugin you got from spigot
a plugin i got from spigot
in where
game
yeah
So you downloaded a plugin from spigot and it doesnt load?
Did you put it in your "plugins" folder
why was i warned
Read what the bot said...
7smile7 how do i do it when my variable is a Location
ye, but my method that i want it in only takes ClickNPCevent @grim halo
Local host ping more or less is 0
@torn robin localhost ping is the time that electron travel inside your computer circuit and the server sends them back
doesnt let me
@sturdy oar Thats not quite how this works...
yeah it doesnt let me send error
Fiber is light not electrons
@sturdy oar that is a gross oversimplification of networking
Yes
@grim halo can i dm you the pic
👀 👀 👀
@primal topaz Sure
I know perfectly how the mc protocol works , although networking is still magic to me
for some reason my hashmaps keep clearing themselves and become empty https://github.com/ramdon-person/SimplePolice/blob/master/SimplePolice/src/com/voidcitymc/plugins/SimplePolice/Jail.java#L18-L20
is there anyway I can fix this?
they’ll become empty anytime you restart your plugin and or declare a new instance of that class
so I should make those methods static?
making them static won’t fix the issue. The problem is how your code is setup right now it won’t save when the server restarts. My recommendation is if you want to save the data for a longer period of time (meaning through a restart) use a database or yml file.
I don't need to data to save for a restart
or depending on what you're saving, a json file.
I actually want to wipe it on restart
but thats not my problem
my problem is it's wiping no on restart
and what I don't understand, is I have another class thats very similar and it doesn't have problems of hashmaps resetting
do you declare an instance of that class anywhere?
the one I'm having issue with or the other one?
the one you’re having issues with.
yes I do
for the one without issues, I just have one instance, but for the one with issues I have multiple
which kind of makes sence
I guess
that’s the issue
every time you declare a new instance of that class the maps will be wiped
ah maybe I'll have my worker class store an instance, and just have all the classes use that
though a method
if you want to save them create one instance of it in your main class and then when you need to use them get the instance from your main class
if that’s makes sense
yes, I did something like that in my other plugin
I just don't want to clutter my main class
though
but I might have to
just have a private method that’s creates all the instance you need one instance of in your main class and call that method onEnable. Then just create getters for those instances in your main class
just have a private method that’s creates all the instance you need one instance of in your main class and call that method onEnable. Then just create getters for those instances in your main class
oh yeah I have that 🙂
thanks
rip thats disabled
hmm thats odd it looks like the hashmaps are still clearing
even though I'm storing it in the main https://github.com/ramdon-person/SimplePolice/blob/master/SimplePolice/src/com/voidcitymc/plugins/SimplePolice/SPPlugin.java#L79-L81
thats the code in the main
just do private Jail jailer; and then onEnable do jailer = new Jail();
see if that fixes it
hmm okay
I haven't gotten a response from spigot in over a week about being locked out of my account
I am writing a permissions plugin which works fine, but tabcomplete does not work for any commands. anyone got an idea? I just create a new PermissionAttachment and set the permissions there, shouldn't that be enough for Bukkit/Spigot to allow tab complete?
@pastel condor if you’re absolutely positive no other instances of that class are being created then I don’t know why it would be clearing unless you manually clear it somewhere or redeclare the map again somewhere.
Has there been a fix for the end city? My server still crashes every time someone tries to go to the endcity unfortunately
how do i make tab complete commands?
my command is /m4j start/stop
so i just want to make start and stop pop up
implement TabCompleter
public class ACommand implements CommandExecutor, TabCompleter {
}
the compiler should automatically warn you to add the inherited functions
if you click the auto-add button then it'll add the method
the method is something like
List<String> tabComplete(...)
yeah no Error:(11,8) java: net.neednot.mine.PluginCommands is not abstract and does not override abstract method onTabComplete(org.bukkit.command.CommandSender,org.bukkit.command.Command,java.lang.String,java.lang.String[]) in org.bukkit.command.TabCompleter
yeah so specify onTabComplete
anyone familiar with worldguards new api?
it should have a button to auto add the methods
do i make a new method separate from the command?
the method returns a list of strings to recommend at the specified argument position
do i remove @org.jetbrains.annotations.NotNull
if you return "a", "b", "c", then it will recommend a b and c
what is @org.jetbrains.annotations.NotNull for
are you using intellij?
yes
It's for the IDE to know that the specified field will never be null
or at least should never be null
you can delete it if you want to, but if it's not causing issues you should leave it
and where do i put the list of recommendations?
rn it returns null
so return an array that you want?
String[] args so do i put the list inside []
how can i make a player open their own inventory?
Think of it as the same as onCommand Need
but instead of returning true/false you return the suggestions
how can i make a player open their own inventory?
@spring coyote ```java
p.openInventory(p.getInventory());
yeah so where the heck do i put the list
oh
String[] argsso do i put the list inside []
@wary ledge You must return a list. E.g.
String[] asd = new String[] { "one","two"};
return Arrays.asList(asd);
hello, where can I report an bug? 😐
what's the bug?
https://prnt.sc/ttilh8
@wary ledge check the length of the String[] array and only return the list when the length is 1
since 1.13 release, we can make team's (vanilla). since that date, it is not possible to show up the prefix in the chat
https://prnt.sc/ttilh8
@wary ledge ```java
if(args.length<=1) {
return Arrays.asList(commands);
}
return null;
since 1.13 release, we can make team's (vanilla). since that date, it is not possible to show up the prefix in the chat
@pseudo sky I don't think it's a spigot problem, however I don't have any idea about teams and stuff, maybe you should ask in the spigot forums
thanks
np
since 1.13 release, we can make team's (vanilla). since that date, it is not possible to show up the prefix in the chat
@pseudo sky btw bug reports go here: https://hub.spigotmc.org/jira/secure/Dashboard.jspa but please only do that if you are 100% sure it's really a spigot bug. for example did you try with vanilla?
Can i get help here for the spigot website?
Don't think team prefixes ever showed in the chat unless it's done by a plugin 🤔
Can i get help here for the spigot website?
@frigid ember what's your problem?
Don't think team prefixes ever showed in the chat unless it's done by a plugin 🤔
@quick arch I think so too
Well i got locked out of my acc and i don’t know my email or password and i can’t do anything, can I make a new account?
I was reading https://www.spigotmc.org/wiki/plugin-yml/#permissions, and I stumbled across the children section for permissions... then I came across this....:
A child node of false inherits the inverse parent permission.
What in the Dimmsdale does this Dimmadome mean
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
I believe you should contact the staff at tmp-support (at) spigotmc.org. the rules forbid second accounts, so better try to contact them first
Well i got locked out of my acc and i don’t know my email or password and i can’t do anything, can I make a new account?
@frigid ember
email?
I think there's a pretty high chance of you getting your account back
A friend of mine lost her account, email them and got it back
yes send a mail to tmp-support@spigotmc.org
Forgot what the response was though
oh ok, thanks
alright with me
How can I get a block ID from a block object?
1.16
you can do Block#getType()
it will return a Material e.g. Material.GRASS
or do you really need the numeric ID?
I would prefer the numeric ID
🤔
not possible without some dirty hacks using 3rd party libraries
You have to use a library to do that
numeric IDs are gone since 1.13+
Ah ok
(for a good reason)
^ +1
Good to know, thanks for the help
may I ask why you need the numeric id?
There's a library to get their ids
but it's a mess
1233 lines worth of enums, https://i.imgur.com/uMr1uzQ.png
🤢
yeah there's something like XMaterial or something but I would never use that xD
yeah, that
I'm just messing around with BlockBreakEvent
I was gonna use the id in a switch case so certain things would happen if you broke certain blocks
Couldn't you just use the type 🤔
just use the enum
you can also do that with Material
Yeah I know that now lol
switch (block.getType()){
case Material.STONE:
// stuff
// cases
default:
// stuff
but without the Material. part 🙂
I don't use em' for materials at all ._.
I don't know why but in switch it's only STONE e.g.
it's wonky
(I have to admit I always compare block.getType().name() for backwards compatibility)
backward compatibility is too much work
well I don't want to break 1.15 compatibility just because I check if something is blackstone for example
pretty sure spigot natively supports backwards compatability
no
you get something like a NoSuchFieldException or similar when using material enums that are not present in the used mc version
try/catch scope to hide it all :kappa:
try catch Throwable
yeah that's possible too but I don't think it will be much faster^^
my current method is to create an arraylist<Material> in the onEnable that uses Material.getMaterial(...) and then comparing the enums at runtime
I think that's the most efficient approach
i just support 1 version
lucky you^^
https://github.com/JEFF-Media-GbR/Spigot-BestTools/blob/master/src/main/java/de/jeff_media/BestTools/BestToolsUtils.java it's nasty but it's fast and cross compatible
i don't care, building the map takes no more than 2ms in onEnable(), after that everything is stored inside a HashMap<Material,Tool>
!Set#contains(%insert material%)
If I were to make a custom stuff for my server, is it better to keep it all in one plugin or spread it out across multiple plugins?
depends
I'd say spread it out
if those stuff works indepedently of each other I would make more than one plugin, if they share many stuff either make one plugin or several plugins that share a common library or sth
Don't be too bloated like Essentials
Alright thanks
I'm new to this whole plugin thing so I'm just figuring out how I should sort my stuff
I'd try to make separate plugins that each have their own use case, and it should only be responsible for that. however it depends. there is no general answer and everyone has a different approach
for example I wouldn't mix a plugin that changes ender dragon fights with a plugin that adds a gamemode command^^ but nothing wrong with a plugin that includes a gamemode, /give, /god etc command. you know what I mean
Alright cool
Thanks for the recommendations
How could I get the entity that killed the player in an OnPlayerDeathEvent?
you get the dead entity and call entity#getKiller
public void onEntityDeath(EntityDeathEvent e) {
Player murderer = e.getEntity().getKiller(); // might be null if not killed by a player
}```
I thought get killer only returns a player?
I don't know if its possible to get a non-player-killer as getKiller() only returns player
yes thats true
don't know if it's possible to get non-player killers
well maybe with the on EntityDamageByEntityEvent
and then check if the new health is less than 0
I don't think NMS is required
but I don't know
That didn't work for me when I tried it
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event) {
EntityPlayer nmsPlayer = ((CraftPlayer) event.getEntity()).getHandle();
if (nmsPlayer.getKillingEntity() == null) {
return;
}
Entity entity = CraftEntity.getEntity((CraftServer) event.getEntity().getServer(), nmsPlayer.getKillingEntity());
if (!(entity instanceof LivingEntity)) {
return;
}
LivingEntity livingEntity = (LivingEntity) entity;
if (!(entity.getScoreboardTags().contains("alpha"))) {
return;
}
event.getEntity().spawnParticle(Particle.SMOKE_LARGE, livingEntity.getLocation(), 120, 0.6, 1, 0.6, 0.1);
livingEntity.remove();
event.setDeathMessage(event.getEntity().getDisplayName() + " was defeated by an Alpha " + StringUtils.capitailizeWord(livingEntity.getType().toString().toLowerCase()));
}```
This was my solution to it, though.
Really basic nms nothing complex
is this for players only or something 🤔
the code by @winged sparrow is for every entity
Checking for when a specific entity kills a player and performing an action afterward
but it requires to import the specific MC version's classes, right?
would be a nice addition to spigot if they could add something like that to the API
Yeah it was super accessible with just the nms player
(or bukkit ofc)
yeah sometimes it's strange that some basic features are missing
NBT manipulation would be nice nice nice to have
From the comfort of abstraction
refresh
what's the error if you hover with the mouse?
Wait..
yeah it can be fucky. One time IntelliJ forgot the whole spigot api for me for no reason mid-coding
yeah I always change my pom and refresh it then lol
Do what he said
Or you can use sender instead
Invalidate Caches / Restart
but it works at the top so straaaaaaange
Sender doesn't work since it's not a player object
wait..
does it?
I thought sender could be either player or console
it can
yeah it can be both
I mean I know that but I didn't realize sendMessage was a method that could be used with sender
of course it can^^
sendMessage is for any CommandSender
you can even use .spigot().sendMessage() on a CommandSender
yeah
Also, this is cleaner https://i.imgur.com/SWcmiKl.png
yeah nested if's are nasty
Indeed
thats where the word "nested" comes from obviously 😛
dw, nested ternaries are worse
I remember my first code.. executing commands on a command send event and checking strings and it's this huge line of nested if statements
Alright, so I am working on a plugin that uses scoreboards in addition to my Spigot plugin (private server and plugin) and I need to set an objective (called "SetLives") to a specific value. I can get the value easily, however I have no idea how to set scoreboard objective values. Can somebody please help me with that issue? Thanks.
Nested ternary (not for MC), https://i.imgur.com/KE2jUV0.png
oh god
yup...
Nested ternary (not for MC), https://i.imgur.com/KE2jUV0.png
@quick arch this is either retarded or genius
probably both
kind of reminds of this https://en.wikipedia.org/wiki/Fast_inverse_square_root
although it has nothing to do with that
@past orbit try using sender instead rn :/ ig it’s not working for you
@past orbit You have declared the player variable inside the if statement / brackets, and below you cannot use it because it is outside that code block
🤔
Is it more performance heavy on the server if I do calculations with a lot of decimal places?
oh yeah the intendation is wrong
I thought the second player usage was inside the "upper" if statement
always format your code and it would have been obvious ^^
Not really. It's roots and shit that will eat your performance alive
Is it more performance heavy on the server if I do calculations with a lot of decimal places?
@spring coyote I think if you use a double it doesn't matter how many decimals it has
but I might be wrong
maybe a bit more than dealing with integers, but it's a very small impact I believe.
yes integers are of course a bit faster but I think it doesnt matter if you calculate 200d - 0.999947216vs. 200d - 0.9
yeah if I dont use a lot of decimal places for this then the difference will be obvious
thx
lol it even seems to be faster with more decimals somehow
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
few decimals:
1454100 nanoseconds
many decimals:
784600 nanoseconds
integer:
1185500 nanoseconds
tried it five times and "many decimals" was always faster
that's wonky
Tried it on repl.it, Integers ended up being faster. (1,000,000) https://i.imgur.com/s0P2yUL.png
8517900 nanoseconds
many decimals:
7202500 nanoseconds
integer:
7337600 nanoseconds
this time it was quite the same
seems to be quite random^^
wonky
might also depend on the CPU and its instruction set or something, IDK
intel user here^^
@quick arch do you use AMD by any chance?
yeah
let my try on my AMD server, 5 mins
amd
few decimals:
30336400 nanoseconds
many decimals:
554100 nanoseconds
integer:
573800 nanoseconds
I was testing with an amd ryzen 7 3700x
I'm on a 2014 AMD CPU