package me.absolutely.firstplugin.commands;
import java.util.Locale;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class FirstCommandPlugin implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player)sender;
if (args.length < 1) {
sender.sendMessage(ChatColor.RED + "Usage: /gamemode <gamemode>");
if (!sender.hasPermission("gamemode.set")) {
sender.sendMessage(ChatColor.RED + "You are not permitted to do this");
}
return true;
} else {
GameMode mode = this.getGameModeByName(args[0]);
if (mode == null) {
sender.sendMessage(ChatColor.RED + "Gamemode '" + args[0] + "' not found.");
return true;
} else {
player.setGameMode(mode);
player.sendMessage(ChatColor.LIGHT_PURPLE + "Your gamemode has been updated to " + ChatColor.GOLD + mode.name());
return false;
}
}
}
private GameMode getGameModeByName(String id) {
id = id.toLowerCase(Locale.ENGLISH);
return !id.equalsIgnoreCase("gmc") && !id.contains("creat") && !id.equalsIgnoreCase("1") && !id.equalsIgnoreCase("c") ? (!id.equalsIgnoreCase("gms") && !id.contains("survi") && !id.equalsIgnoreCase("0") && !id.equalsIgnoreCase("s") ? (!id.equalsIgnoreCase("gma") && !id.contains("advent") && !id.equalsIgnoreCase("2") && !id.equalsIgnoreCase("a") ? (!id.equalsIgnoreCase("gmt") && !id.contains("toggle") && !id.contains("cycle") && !id.equalsIgnoreCase("t") ? null : null) : GameMode.ADVENTURE) : GameMode.SURVIVAL) : GameMode.CREATIVE;
}
}
This is the code ive been messing with anyone know why the permission isnt working its just letting everyone use the command
import java.util.Locale;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class FirstCommandPlugin implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player)sender;
if (args.length < 1) {
sender.sendMessage(ChatColor.RED + "Usage: /gamemode <gamemode>");
if (!sender.hasPermission("gamemode.set")) {
sender.sendMessage(ChatColor.RED + "You are not permitted to do this");
}
return true;
} else {
GameMode mode = this.getGameModeByName(args[0]);
if (mode == null) {
sender.sendMessage(ChatColor.RED + "Gamemode '" + args[0] + "' not found.");
return true;
} else {
player.setGameMode(mode);
player.sendMessage(ChatColor.LIGHT_PURPLE + "Your gamemode has been updated to " + ChatColor.GOLD + mode.name());
return false;
}
}
}
private GameMode getGameModeByName(String id) {
id = id.toLowerCase(Locale.ENGLISH);
return !id.equalsIgnoreCase("gmc") && !id.contains("creat") && !id.equalsIgnoreCase("1") && !id.equalsIgnoreCase("c") ? (!id.equalsIgnoreCase("gms") && !id.contains("survi") && !id.equalsIgnoreCase("0") && !id.equalsIgnoreCase("s") ? (!id.equalsIgnoreCase("gma") && !id.contains("advent") && !id.equalsIgnoreCase("2") && !id.equalsIgnoreCase("a") ? (!id.equalsIgnoreCase("gmt") && !id.contains("toggle") && !id.contains("cycle") && !id.equalsIgnoreCase("t") ? null : null) : GameMode.ADVENTURE) : GameMode.SURVIVAL) : GameMode.CREATIVE;
}
}
This is the code ive been messing with anyone know why the permission isnt working its just letting everyone use the command
Last edited:
