nemám rád javu
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
package dev.trixinity.eventmanager.commands;
|
package dev.trixinity.eventmanager.commands;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.GameMode;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementace příkazů pro správu eventů.
|
* Implementace příkazů pro správu eventů.
|
||||||
@@ -84,17 +84,31 @@ public class EventCommand implements CommandExecutor {
|
|||||||
sender.sendMessage("");
|
sender.sendMessage("");
|
||||||
sender.sendMessage(ChatColor.RED + ChatColor.BOLD.toString() + "- "
|
sender.sendMessage(ChatColor.RED + ChatColor.BOLD.toString() + "- "
|
||||||
+ ChatColor.RED + "/build off/on");
|
+ ChatColor.RED + "/build off/on");
|
||||||
sender.sendMessage(ChatColor.RED + ChatColor.BOLD.toString() + "- " + ChatColor.RED + "/event off/on");
|
sender.sendMessage(ChatColor.RED + ChatColor.BOLD.toString() + "- "
|
||||||
sender.sendMessage(ChatColor.RED + ChatColor.BOLD.toString() + "- " + ChatColor.RED + "/pvp off/on");
|
+ ChatColor.RED + "/event off/on");
|
||||||
sender.sendMessage(ChatColor.RED + ChatColor.BOLD.toString() + "- " + ChatColor.RED + "/spawn (hráč)");
|
sender.sendMessage(ChatColor.RED + ChatColor.BOLD.toString() + "- "
|
||||||
sender.sendMessage(ChatColor.RED + ChatColor.BOLD.toString() + "- " + ChatColor.RED + "/gmc");
|
+ ChatColor.RED + "/pvp off/on");
|
||||||
sender.sendMessage(ChatColor.RED + ChatColor.BOLD.toString() + "- " + ChatColor.RED + "/heal (hráč/*)");
|
sender.sendMessage(ChatColor.RED + ChatColor.BOLD.toString() + "- "
|
||||||
sender.sendMessage(ChatColor.RED + ChatColor.BOLD.toString() + "- " + ChatColor.RED + "/teleport (hráč) (hráč)");
|
+ ChatColor.RED + "/spawn (hráč)");
|
||||||
sender.sendMessage(ChatColor.RED + ChatColor.BOLD.toString() + "- " + ChatColor.RED + "WorldEdit příkazy");
|
sender.sendMessage(ChatColor.RED + ChatColor.BOLD.toString() + "- "
|
||||||
|
+ ChatColor.RED + "/gmc");
|
||||||
|
sender.sendMessage(ChatColor.RED + ChatColor.BOLD.toString() + "- "
|
||||||
|
+ ChatColor.RED + "/heal (hráč/*)");
|
||||||
|
sender.sendMessage(ChatColor.RED + ChatColor.BOLD.toString() + "- "
|
||||||
|
+ ChatColor.RED + "/teleport (hráč) (hráč)");
|
||||||
|
sender.sendMessage(ChatColor.RED + ChatColor.BOLD.toString() + "- "
|
||||||
|
+ ChatColor.RED + "WorldEdit příkazy");
|
||||||
sender.sendMessage("");
|
sender.sendMessage("");
|
||||||
sender.sendMessage(ChatColor.RED + ChatColor.STRIKETHROUGH.toString() + "---------------------------------");
|
sender.sendMessage(ChatColor.RED + ChatColor.STRIKETHROUGH.toString()
|
||||||
|
+ "---------------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zpracuje příkaz build.
|
||||||
|
*
|
||||||
|
* @param sender Odesílatel příkazu
|
||||||
|
* @param args Argumenty příkazu
|
||||||
|
*/
|
||||||
private void handleBuild(CommandSender sender, String[] args) {
|
private void handleBuild(CommandSender sender, String[] args) {
|
||||||
if (args == null || args.length < 2) {
|
if (args == null || args.length < 2) {
|
||||||
sender.sendMessage(ChatColor.RED + "Použití: /event build <on/off>");
|
sender.sendMessage(ChatColor.RED + "Použití: /event build <on/off>");
|
||||||
@@ -102,15 +116,25 @@ public class EventCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String command = args[1].toLowerCase();
|
String command = args[1].toLowerCase();
|
||||||
if ("on".equals(command)) { // Bezpečnější porovnání řetězců
|
if ("on".equals(command)) {
|
||||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "rg flag __global__ build -w EVENT allow");
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(),
|
||||||
|
"rg flag __global__ build -w EVENT allow");
|
||||||
sender.sendMessage(ChatColor.GREEN + "Build mód byl zapnut!");
|
sender.sendMessage(ChatColor.GREEN + "Build mód byl zapnut!");
|
||||||
} else if ("off".equals(command)) {
|
} else if ("off".equals(command)) {
|
||||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "rg flag __global__ build -w EVENT deny");
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(),
|
||||||
|
"rg flag __global__ build -w EVENT deny");
|
||||||
sender.sendMessage(ChatColor.RED + "Build mód byl vypnut!");
|
sender.sendMessage(ChatColor.RED + "Build mód byl vypnut!");
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Použití: /event build <on/off>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zpracuje příkaz teleport.
|
||||||
|
*
|
||||||
|
* @param sender Odesílatel příkazu
|
||||||
|
* @param args Argumenty příkazu
|
||||||
|
*/
|
||||||
private void handleTeleport(CommandSender sender, String[] args) {
|
private void handleTeleport(CommandSender sender, String[] args) {
|
||||||
if (args == null || args.length < 3) {
|
if (args == null || args.length < 3) {
|
||||||
sender.sendMessage(ChatColor.RED + "Použití: /event teleport <hráč> <cíl>");
|
sender.sendMessage(ChatColor.RED + "Použití: /event teleport <hráč> <cíl>");
|
||||||
@@ -126,28 +150,45 @@ public class EventCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
player.teleport(target.getLocation());
|
player.teleport(target.getLocation());
|
||||||
sender.sendMessage(ChatColor.GREEN + String.format("Hráč %s byl teleportován k hráči %s!",
|
sender.sendMessage(ChatColor.GREEN + String.format(
|
||||||
|
"Hráč %s byl teleportován k hráči %s!",
|
||||||
player.getName(), target.getName()));
|
player.getName(), target.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zpracuje příkaz pvp.
|
||||||
|
*
|
||||||
|
* @param sender Odesílatel příkazu
|
||||||
|
* @param args Argumenty příkazu
|
||||||
|
*/
|
||||||
private void handlePvP(CommandSender sender, String[] args) {
|
private void handlePvP(CommandSender sender, String[] args) {
|
||||||
if (args.length < 2) {
|
if (args == null || args.length < 2) {
|
||||||
sender.sendMessage(ChatColor.RED + "Použití: /event pvp <on/off>");
|
sender.sendMessage(ChatColor.RED + "Použití: /event pvp <on/off>");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String command = args[1].toLowerCase();
|
String command = args[1].toLowerCase();
|
||||||
if (command.equals("on")) {
|
if ("on".equals(command)) {
|
||||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "rg flag __global__ pvp -w EVENT allow");
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(),
|
||||||
|
"rg flag __global__ pvp -w EVENT allow");
|
||||||
sender.sendMessage(ChatColor.GREEN + "PvP bylo zapnuto!");
|
sender.sendMessage(ChatColor.GREEN + "PvP bylo zapnuto!");
|
||||||
} else if (command.equals("off")) {
|
} else if ("off".equals(command)) {
|
||||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "rg flag __global__ pvp -w EVENT deny");
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(),
|
||||||
sender.sendMessage(ChatColor.RED + "PvP bylo vypnuto!");
|
"rg flag __global__ pvp -w EVENT deny");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Použití: /event pvp <on/off>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zpracuje příkaz spawn.
|
||||||
|
*
|
||||||
|
* @param sender Odesílatel příkazu
|
||||||
|
* @param args Argumenty příkazu
|
||||||
|
*/
|
||||||
private void handleSpawn(CommandSender sender, String[] args) {
|
private void handleSpawn(CommandSender sender, String[] args) {
|
||||||
if (args.length < 2) {
|
if (args == null || args.length < 2) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Bukkit.dispatchCommand(sender, "spawn");
|
Bukkit.dispatchCommand(sender, "spawn");
|
||||||
} else {
|
} else {
|
||||||
@@ -163,9 +204,15 @@ public class EventCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "spawn " + target.getName());
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "spawn " + target.getName());
|
||||||
sender.sendMessage(ChatColor.GREEN + "Hráč " + target.getName() + " byl teleportován na spawn!");
|
sender.sendMessage(ChatColor.GREEN + "Hráč " + target.getName()
|
||||||
|
+ " byl teleportován na spawn!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zpracuje příkaz gamemode.
|
||||||
|
*
|
||||||
|
* @param sender Odesílatel příkazu
|
||||||
|
*/
|
||||||
private void handleGamemode(CommandSender sender) {
|
private void handleGamemode(CommandSender sender) {
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage(ChatColor.RED + "Tento příkaz může použít pouze hráč!");
|
sender.sendMessage(ChatColor.RED + "Tento příkaz může použít pouze hráč!");
|
||||||
@@ -177,8 +224,14 @@ public class EventCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(ChatColor.GREEN + "Herní mód byl změněn na Creative!");
|
sender.sendMessage(ChatColor.GREEN + "Herní mód byl změněn na Creative!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zpracuje příkaz heal.
|
||||||
|
*
|
||||||
|
* @param sender Odesílatel příkazu
|
||||||
|
* @param args Argumenty příkazu
|
||||||
|
*/
|
||||||
private void handleHeal(CommandSender sender, String[] args) {
|
private void handleHeal(CommandSender sender, String[] args) {
|
||||||
if (args.length < 2) {
|
if (args == null || args.length < 2) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
player.setHealth(player.getMaxHealth());
|
player.setHealth(player.getMaxHealth());
|
||||||
@@ -190,7 +243,7 @@ public class EventCommand implements CommandExecutor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[1].equals("*")) {
|
if ("*".equals(args[1])) {
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
player.setHealth(player.getMaxHealth());
|
player.setHealth(player.getMaxHealth());
|
||||||
player.setFoodLevel(20);
|
player.setFoodLevel(20);
|
||||||
|
|||||||
Reference in New Issue
Block a user