SteamWar/BauSystem
Archiviert
13
0

update for CommandClear

Dieser Commit ist enthalten in:
Zeanon 2021-04-01 22:00:29 +02:00
Ursprung 7116fed5b2
Commit 9eb36a05a6
2 geänderte Dateien mit 23 neuen und 50 gelöschten Zeilen

Datei anzeigen

@ -66,10 +66,9 @@ public class BauSystem extends JavaPlugin implements Listener {
Mapper.init();
try {
CommandRemover.removeAll("tp", "time", "clear");
CommandRemover.removeAll("tp", "time");
CommandInjector.injectCommand(new CommandTeleport());
CommandInjector.injectCommand(new CommandTime());
CommandInjector.injectCommand(new CommandClear());
} catch (Exception e) {
getLogger().log(Level.SEVERE, "Failed to replace commands", e);
Bukkit.shutdown();
@ -84,6 +83,7 @@ public class BauSystem extends JavaPlugin implements Listener {
new CommandTNT();
new CommandBau();
new CommandGamemode();
new CommandClear();
getCommand("fire").setExecutor(new CommandFire());
getCommand("freeze").setExecutor(new CommandFreeze());
new CommandTestblock();

Datei anzeigen

@ -1,67 +1,40 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.world.Welt;
import de.steamwar.command.SWCommand;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.command.defaults.BukkitCommand;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class CommandClear extends BukkitCommand {
public class CommandClear extends SWCommand {
public CommandClear() {
super("clear");
description = "Leere dein Inventar oder das eines anderen Spielers.";
usageMessage = "/clear [Spieler]";
}
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
if (!(sender instanceof Player))
return false;
Player player = (Player) sender;
if (args.length == 0) {
clear(player);
player.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde geleert.");
return true;
}
// check if admin
if (Welt.noPermission(player, Permission.world)) {
player.sendMessage(BauSystem.PREFIX + "$cDu darfst hier keine fremden Inventare leeren.");
return false;
}
Player target = Bukkit.getPlayerExact(args[0]);
if (!(target instanceof Player)) {
player.sendMessage(BauSystem.PREFIX + "§cDas ist kein Spieler.");
return false;
@Register
public void genericClearCommand(Player p) {
clear(p);
p.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde geleert.");
}
@Register
public void clearPlayerCommand(Player p, Player target) {
if (Welt.noPermission(p, Permission.world)) {
p.sendMessage(BauSystem.PREFIX + "$cDu darfst hier keine fremden Inventare leeren.");
return;
} else {
clear(target);
target.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde von" + player.getDisplayName() + " §7geleert.");
player.sendMessage(BauSystem.PREFIX + "Das Inventar von " + target.getDisplayName() + " §7wurde geleert.");
return true;
target.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde von" + p.getDisplayName() + " §7geleert.");
p.sendMessage(BauSystem.PREFIX + "Das Inventar von " + target.getDisplayName() + " §7wurde geleert.");
}
}
private void clear(Player player) {
player.getInventory().clear();