|
|
|
@ -1,34 +1,46 @@
|
|
|
|
|
/*
|
|
|
|
|
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.world.Welt;
|
|
|
|
|
import de.steamwar.command.SWCommand;
|
|
|
|
|
import de.steamwar.sql.BauweltMember;
|
|
|
|
|
import de.steamwar.sql.SteamwarUser;
|
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
|
import org.bukkit.command.CommandExecutor;
|
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
|
|
public class CommandBau implements CommandExecutor {
|
|
|
|
|
|
|
|
|
|
public class CommandBau extends SWCommand {
|
|
|
|
|
|
|
|
|
|
public CommandBau() {
|
|
|
|
|
super("bau", "b", "gs");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Register()
|
|
|
|
|
public void genericCommand(Player p) {
|
|
|
|
|
permissionCheck(p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Register("togglebuild")
|
|
|
|
|
public void toggleBuildCommand(Player p, String arg) {
|
|
|
|
|
if (permissionCheck(p)) {
|
|
|
|
|
onToggleBD(p, arg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Register("togglewe")
|
|
|
|
|
public void toggleWECommand(Player p, String arg) {
|
|
|
|
|
if (permissionCheck(p)) {
|
|
|
|
|
onToggleWE(p, arg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Register("toggleworld")
|
|
|
|
|
public void toggleWorldCommand(Player p, String arg) {
|
|
|
|
|
if (permissionCheck(p)) {
|
|
|
|
|
onToggleWorld(p, arg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void onToggleBD(Player p, String arg) {
|
|
|
|
|
SteamwarUser id = SteamwarUser.get(arg);
|
|
|
|
@ -74,23 +86,13 @@ public class CommandBau implements CommandExecutor {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
|
|
|
if (!(sender instanceof Player))
|
|
|
|
|
return false;
|
|
|
|
|
Player player = (Player) sender;
|
|
|
|
|
if (!BauSystem.getOwner().equals(player.getUniqueId())) {
|
|
|
|
|
player.sendMessage(BauSystem.PREFIX + "§cDies ist nicht deine Welt!");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (args[0].equalsIgnoreCase("togglebuild")) {
|
|
|
|
|
onToggleBD(player, args[1]);
|
|
|
|
|
} else if (args[0].equalsIgnoreCase("togglewe")) {
|
|
|
|
|
onToggleWE(player, args[1]);
|
|
|
|
|
} else if (args[0].equalsIgnoreCase("toggleworld")) {
|
|
|
|
|
onToggleWorld(player, args[1]);
|
|
|
|
|
private boolean permissionCheck(Player p) {
|
|
|
|
|
if (!BauSystem.getOwner().equals(p.getUniqueId())) {
|
|
|
|
|
p.sendMessage(BauSystem.PREFIX + "§cDies ist nicht deine Welt!");
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|