Update from Git Manager GUI
This commit is contained in:
@@ -2,9 +2,12 @@ package de.viper.survivalplus.commands;
|
||||
|
||||
import de.viper.survivalplus.Manager.BlockManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class BlockCommand implements CommandExecutor {
|
||||
|
||||
@@ -20,28 +23,40 @@ public class BlockCommand implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage(config.getString("messages.general.only_players"));
|
||||
sender.sendMessage(color(config.getString("messages.general.only_players", "§cDieser Befehl ist nur für Spieler!")));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!player.hasPermission("survivalplus.block")) {
|
||||
player.sendMessage(color(config.getString("messages.general.no_permission", "§cDu hast keine Berechtigung für diesen Befehl!")));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length != 1) {
|
||||
player.sendMessage(config.getString("messages.block.usage"));
|
||||
player.sendMessage(color(config.getString("messages.block.usage", "§cVerwendung: /block <Spieler>")));
|
||||
return true;
|
||||
}
|
||||
|
||||
Player target = Bukkit.getPlayerExact(args[0]);
|
||||
if (target == null || target == player) {
|
||||
player.sendMessage(config.getString("messages.block.invalid_player"));
|
||||
player.sendMessage(color(config.getString("messages.block.invalid_player", "§cDieser Spieler konnte nicht gefunden werden oder bist du selbst.")));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (blockManager.hasBlocked(player, target)) {
|
||||
player.sendMessage(config.getString("messages.block.already_blocked").replace("%player%", target.getName()));
|
||||
String msg = config.getString("messages.block.already_blocked", "&cDieser Spieler ist bereits blockiert!");
|
||||
player.sendMessage(color(msg.replace("%player%", target.getName())));
|
||||
} else {
|
||||
blockManager.blockPlayer(player, target);
|
||||
player.sendMessage(config.getString("messages.block.blocked").replace("%player%", target.getName()));
|
||||
String msg = config.getString("messages.block.blocked", "&aDu hast %player% blockiert.");
|
||||
player.sendMessage(color(msg.replace("%player%", target.getName())));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private String color(String msg) {
|
||||
if (msg == null) return "";
|
||||
return ChatColor.translateAlternateColorCodes('&', msg);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user