Update BauSystem to new CommandFramework #217
@ -66,10 +66,9 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
Mapper.init();
|
Mapper.init();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
CommandRemover.removeAll("tp", "time", "clear");
|
CommandRemover.removeAll("tp", "time");
|
||||||
CommandInjector.injectCommand(new CommandTeleport());
|
CommandInjector.injectCommand(new CommandTeleport());
|
||||||
CommandInjector.injectCommand(new CommandTime());
|
CommandInjector.injectCommand(new CommandTime());
|
||||||
CommandInjector.injectCommand(new CommandClear());
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
getLogger().log(Level.SEVERE, "Failed to replace commands", e);
|
getLogger().log(Level.SEVERE, "Failed to replace commands", e);
|
||||||
Bukkit.shutdown();
|
Bukkit.shutdown();
|
||||||
@ -84,6 +83,7 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
new CommandTNT();
|
new CommandTNT();
|
||||||
new CommandBau();
|
new CommandBau();
|
||||||
new CommandGamemode();
|
new CommandGamemode();
|
||||||
|
new CommandClear();
|
||||||
getCommand("fire").setExecutor(new CommandFire());
|
getCommand("fire").setExecutor(new CommandFire());
|
||||||
getCommand("freeze").setExecutor(new CommandFreeze());
|
getCommand("freeze").setExecutor(new CommandFreeze());
|
||||||
new CommandTestblock();
|
new CommandTestblock();
|
||||||
|
@ -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;
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.bausystem.world.Welt;
|
import de.steamwar.bausystem.world.Welt;
|
||||||
|
import de.steamwar.command.SWCommand;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.defaults.BukkitCommand;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class CommandClear extends BukkitCommand {
|
|
||||||
|
public class CommandClear extends SWCommand {
|
||||||
|
|
||||||
public CommandClear() {
|
public CommandClear() {
|
||||||
super("clear");
|
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))
|
@Register
|
||||||
return false;
|
public void genericClearCommand(Player p) {
|
||||||
Player player = (Player) sender;
|
clear(p);
|
||||||
if (args.length == 0) {
|
p.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde geleert.");
|
||||||
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 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);
|
clear(target);
|
||||||
target.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde von" + player.getDisplayName() + " §7geleert.");
|
target.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde von" + p.getDisplayName() + " §7geleert.");
|
||||||
player.sendMessage(BauSystem.PREFIX + "Das Inventar von " + target.getDisplayName() + " §7wurde geleert.");
|
p.sendMessage(BauSystem.PREFIX + "Das Inventar von " + target.getDisplayName() + " §7wurde geleert.");
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void clear(Player player) {
|
private void clear(Player player) {
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren