|
|
|
@ -1,22 +1,3 @@
|
|
|
|
|
/*
|
|
|
|
|
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;
|
|
|
|
@ -24,12 +5,98 @@ import de.steamwar.bausystem.Permission;
|
|
|
|
|
import de.steamwar.bausystem.SWUtils;
|
|
|
|
|
import de.steamwar.bausystem.world.Detonator;
|
|
|
|
|
import de.steamwar.bausystem.world.Welt;
|
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
|
import org.bukkit.command.CommandExecutor;
|
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
|
import de.steamwar.command.SWCommand;
|
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
|
|
public class CommandDetonator implements CommandExecutor {
|
|
|
|
|
|
|
|
|
|
public class CommandDetonator extends SWCommand {
|
|
|
|
|
|
|
|
|
|
public CommandDetonator() {
|
|
|
|
|
super ("detonator", "dt");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Register(help = true)
|
|
|
|
|
public void genericHelp(Player p, String... args) {
|
|
|
|
|
help(p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Register("wand")
|
|
|
|
|
public void wandCommand(Player p) {
|
|
|
|
|
if (permissionCheck(p)) {
|
|
|
|
|
SWUtils.giveItemToPlayer(p, Detonator.WAND);
|
|
|
|
|
p.updateInventory();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Register("detonator")
|
|
|
|
|
public void detonatorCommand(Player p) {
|
|
|
|
|
if (permissionCheck(p)) {
|
|
|
|
|
SWUtils.giveItemToPlayer(p, Detonator.WAND);
|
|
|
|
|
p.updateInventory();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Register("item")
|
|
|
|
|
public void itemCommand(Player p) {
|
|
|
|
|
if (permissionCheck(p)) {
|
|
|
|
|
SWUtils.giveItemToPlayer(p, Detonator.WAND);
|
|
|
|
|
p.updateInventory();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Register("remove")
|
|
|
|
|
public void removeCommand(Player p) {
|
|
|
|
|
if (permissionCheck(p)) {
|
|
|
|
|
p.getInventory().removeItem(Detonator.WAND);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Register("detonate")
|
|
|
|
|
public void detonateCommand(Player p) {
|
|
|
|
|
if (permissionCheck(p)) {
|
|
|
|
|
Detonator.execute(p);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Register("click")
|
|
|
|
|
public void clickCommand(Player p) {
|
|
|
|
|
if (permissionCheck(p)) {
|
|
|
|
|
Detonator.execute(p);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Register("use")
|
|
|
|
|
public void useCommand(Player p) {
|
|
|
|
|
if (permissionCheck(p)) {
|
|
|
|
|
Detonator.execute(p);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Register("clear")
|
|
|
|
|
public void clearCommand(Player p) {
|
|
|
|
|
if (permissionCheck(p)) {
|
|
|
|
|
p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Register("delete")
|
|
|
|
|
public void deleteCommand(Player p) {
|
|
|
|
|
if (permissionCheck(p)) {
|
|
|
|
|
p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Register("reset")
|
|
|
|
|
public void resetCommand(Player p) {
|
|
|
|
|
if (permissionCheck(p)) {
|
|
|
|
|
p.getInventory().setItemInMainHand(Detonator.clearDetonator(p.getInventory().getItemInMainHand()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void help(Player player) {
|
|
|
|
|
player.sendMessage("§8/§edetonator wand §8- §7Legt den Fernzünder ins Inventar");
|
|
|
|
@ -45,44 +112,4 @@ public class CommandDetonator implements CommandExecutor {
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
|
|
|
|
|
if (!(sender instanceof Player))
|
|
|
|
|
return false;
|
|
|
|
|
Player player = (Player) sender;
|
|
|
|
|
|
|
|
|
|
if (args.length == 0) {
|
|
|
|
|
help(player);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!permissionCheck(player)) return false;
|
|
|
|
|
|
|
|
|
|
switch (args[0].toLowerCase()) {
|
|
|
|
|
case "wand":
|
|
|
|
|
case "detonator":
|
|
|
|
|
case "item":
|
|
|
|
|
SWUtils.giveItemToPlayer(player, Detonator.WAND);
|
|
|
|
|
player.updateInventory();
|
|
|
|
|
break;
|
|
|
|
|
case "remove":
|
|
|
|
|
player.getInventory().removeItem(Detonator.WAND);
|
|
|
|
|
break;
|
|
|
|
|
case "detonate":
|
|
|
|
|
case "click":
|
|
|
|
|
case "use":
|
|
|
|
|
Detonator.execute(player);
|
|
|
|
|
break;
|
|
|
|
|
case "clear":
|
|
|
|
|
case "delete":
|
|
|
|
|
case "reset":
|
|
|
|
|
player.getInventory().setItemInMainHand(Detonator.clearDetonator(player.getInventory().getItemInMainHand()));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
help(player);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|