Update BauSystem to new CommandFramework #217
@ -65,7 +65,6 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
|
||||
Mapper.init();
|
||||
|
||||
|
||||
new CommandTrace();
|
||||
new CommandTPSLimiter();
|
||||
new CommandNV();
|
||||
@ -77,8 +76,8 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
new CommandClear();
|
||||
new CommandTime();
|
||||
new CommandTeleport();
|
||||
getCommand("fire").setExecutor(new CommandFire());
|
||||
getCommand("freeze").setExecutor(new CommandFreeze());
|
||||
new CommandFire();
|
||||
new CommandFreeze();
|
||||
new CommandTestblock();
|
||||
new CommandInfo();
|
||||
new CommandProtect();
|
||||
|
@ -16,9 +16,9 @@ public class CommandBau extends SWCommand {
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§ebau togglebuild §8[§7Player§8] §8- §7Editiere die Bau Rechte eines Spielers");
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§ebau togglewe §8[§7Player§8] §8- §7Editiere die WorldEdit Rechte eines Spielers");
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§ebau toggleworld §8[§7Player§8] §8- §7Editiere die Werlt Rechte eines Spielers");
|
||||
p.sendMessage("§8/§ebau togglebuild §8[§7Player§8] §8- §7Editiere die Bau Rechte eines Spielers");
|
||||
p.sendMessage("§8/§ebau togglewe §8[§7Player§8] §8- §7Editiere die WorldEdit Rechte eines Spielers");
|
||||
p.sendMessage("§8/§ebau toggleworld §8[§7Player§8] §8- §7Editiere die Werlt Rechte eines Spielers");
|
||||
}
|
||||
|
||||
@Register("togglebuild")
|
||||
|
@ -17,8 +17,8 @@ public class CommandClear extends SWCommand {
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§eclear §8- §7Leere dein Inventar");
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§ebau clear §8[§7Player§8] §8- §7Leere ein Spieler Inventar");
|
||||
p.sendMessage("§8/§eclear §8- §7Leere dein Inventar");
|
||||
p.sendMessage("§8/§ebau clear §8[§7Player§8] §8- §7Leere ein Spieler Inventar");
|
||||
}
|
||||
|
||||
@Register
|
||||
|
@ -16,7 +16,7 @@ public class CommandDebugStick extends SWCommand {
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§edebugstick §8- §7Erhalte einen DebugStick");
|
||||
p.sendMessage("§8/§edebugstick §8- §7Erhalte einen DebugStick");
|
||||
}
|
||||
|
||||
@Register
|
||||
|
@ -19,34 +19,66 @@
|
||||
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.world.Region;
|
||||
import de.steamwar.bausystem.world.Welt;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockSpreadEvent;
|
||||
|
||||
public class CommandFire extends RegionToggleCommand {
|
||||
public class CommandFire extends SWCommand implements Listener {
|
||||
|
||||
@Override
|
||||
String getNoPermMessage() {
|
||||
public CommandFire() {
|
||||
super("fire");
|
||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§efire §8- §7Toggle Feuerschaden");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void toggleCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (toggle(region)) {
|
||||
RegionUtils.actionBar(region, getEnableMessage());
|
||||
} else {
|
||||
RegionUtils.actionBar(region, getDisableMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private String getNoPermMessage() {
|
||||
return "§cDu darfst hier nicht Feuerschaden (de-)aktivieren";
|
||||
}
|
||||
|
||||
@Override
|
||||
String getEnableMessage() {
|
||||
return "§cFeuerschaden deaktiviert";
|
||||
private String getEnableMessage() {
|
||||
return "§cRegions Feuerschaden deaktiviert";
|
||||
}
|
||||
|
||||
@Override
|
||||
String getDisableMessage() {
|
||||
return "§aFeuerschaden aktiviert";
|
||||
private String getDisableMessage() {
|
||||
return "§aRegions Feuerschaden aktiviert";
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean toggle(Region region) {
|
||||
private boolean toggle(Region region) {
|
||||
region.setFire(!region.isFire());
|
||||
return region.isFire();
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (Welt.noPermission(player, Permission.world)) {
|
||||
player.sendMessage(BauSystem.PREFIX + getNoPermMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFireDamage(BlockBurnEvent e) {
|
||||
if (Region.getRegion(e.getBlock().getLocation()).isFire()) e.setCancelled(true);
|
||||
|
@ -20,38 +20,70 @@
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.world.Region;
|
||||
import de.steamwar.bausystem.world.Welt;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.core.Core;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
|
||||
public class CommandFreeze extends RegionToggleCommand {
|
||||
public class CommandFreeze extends SWCommand implements Listener {
|
||||
|
||||
@Override
|
||||
String getNoPermMessage() {
|
||||
public CommandFreeze() {
|
||||
super("freeze", "stoplag");
|
||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§efreeze §8- §7Toggle Freeze");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void toggleCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
Region region = Region.getRegion(p.getLocation());
|
||||
if (toggle(region)) {
|
||||
RegionUtils.actionBar(region, getEnableMessage());
|
||||
} else {
|
||||
RegionUtils.actionBar(region, getDisableMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private String getNoPermMessage() {
|
||||
return "§cDu darfst diese Welt nicht einfrieren";
|
||||
}
|
||||
@Override
|
||||
String getEnableMessage(){
|
||||
return "§cWelt eingefroren";
|
||||
}
|
||||
@Override
|
||||
String getDisableMessage(){
|
||||
return "§aWelt aufgetaut";
|
||||
|
||||
private String getEnableMessage(){
|
||||
return "§cRegion eingefroren";
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean toggle(Region region) {
|
||||
private String getDisableMessage(){
|
||||
return "§aRegion aufgetaut";
|
||||
}
|
||||
|
||||
private boolean toggle(Region region) {
|
||||
region.setFreeze(!region.isFreeze());
|
||||
return region.isFreeze();
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if (Welt.noPermission(player, Permission.world)) {
|
||||
player.sendMessage(BauSystem.PREFIX + getNoPermMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntitySpawn(EntitySpawnEvent e) {
|
||||
if (!Region.getRegion(e.getLocation()).isFreeze()) return;
|
||||
|
@ -46,8 +46,8 @@ public class CommandGUI extends SWCommand implements Listener {
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§egui §8- §7Öffne die GUI");
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§egui item §8- §7Gebe das GUI item");
|
||||
p.sendMessage("§8/§egui §8- §7Öffne die GUI");
|
||||
p.sendMessage("§8/§egui item §8- §7Gebe das GUI item");
|
||||
}
|
||||
|
||||
@Register
|
||||
|
@ -15,7 +15,7 @@ public class CommandGamemode extends SWCommand {
|
||||
|
||||
@Register(help = true)
|
||||
public void gamemodeHelp(Player p, String... args) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spielmodus");
|
||||
p.sendMessage("§cUnbekannter Spielmodus");
|
||||
}
|
||||
|
||||
@Register
|
||||
|
@ -33,7 +33,7 @@ public class CommandGills extends SWCommand {
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§ewatervision §8- §7Toggle WaterBreathing");
|
||||
p.sendMessage("§8/§ewatervision §8- §7Toggle WaterBreathing");
|
||||
}
|
||||
|
||||
@Register
|
||||
|
@ -40,7 +40,7 @@ public class CommandInfo extends SWCommand {
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§ebauinfo §8- §7Gebe Informationen über den Bau");
|
||||
p.sendMessage("§8/§ebauinfo §8- §7Gebe Informationen über den Bau");
|
||||
}
|
||||
|
||||
@Register
|
||||
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
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 org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.SimpleCommandMap;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class CommandInjector {
|
||||
|
||||
private CommandInjector() {
|
||||
}
|
||||
|
||||
private static final String PACKAGE_NAME = Bukkit.getServer().getClass().getPackage().getName();
|
||||
private static final String VERSION = PACKAGE_NAME.substring(PACKAGE_NAME.lastIndexOf('.') + 1);
|
||||
|
||||
public static void injectCommand(Command cmd) throws Exception {
|
||||
Class serverClass = Class.forName("org.bukkit.craftbukkit." + VERSION + ".CraftServer");
|
||||
Field f1 = serverClass.getDeclaredField("commandMap");
|
||||
f1.setAccessible(true);
|
||||
SimpleCommandMap commandMap = (SimpleCommandMap) f1.get(Bukkit.getServer());
|
||||
commandMap.register("BauSystem", cmd);
|
||||
}
|
||||
}
|
@ -33,7 +33,7 @@ public class CommandNV extends SWCommand {
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§enightvision §8- §7Toggle NightVision");
|
||||
p.sendMessage("§8/§enightvision §8- §7Toggle NightVision");
|
||||
}
|
||||
|
||||
@Register
|
||||
|
@ -39,8 +39,8 @@ public class CommandProtect extends SWCommand {
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§eprotect §8- §7Schütze die Region");
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§eprotect §8[§7Schematic§8] §8- §7Schütze die Region mit einer Schematic");
|
||||
p.sendMessage("§8/§eprotect §8- §7Schütze die Region");
|
||||
p.sendMessage("§8/§eprotect §8[§7Schematic§8] §8- §7Schütze die Region mit einer Schematic");
|
||||
}
|
||||
|
||||
@Register
|
||||
|
@ -36,7 +36,7 @@ public class CommandRedstoneTester extends SWCommand {
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§eredstonetester §8- §7Gibt den RedstoneTester");
|
||||
p.sendMessage("§8/§eredstonetester §8- §7Gibt den RedstoneTester");
|
||||
}
|
||||
|
||||
@Register
|
||||
|
@ -39,8 +39,8 @@ public class CommandReset extends SWCommand {
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§ereset §8- §7Setzte die Region zurück");
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§ereset §8[§7Schematic§8] §8- §7Setzte die Region mit einer Schematic zurück");
|
||||
p.sendMessage("§8/§ereset §8- §7Setzte die Region zurück");
|
||||
p.sendMessage("§8/§ereset §8[§7Schematic§8] §8- §7Setzte die Region mit einer Schematic zurück");
|
||||
}
|
||||
|
||||
@Register
|
||||
|
@ -84,7 +84,7 @@ public class CommandScript extends SWCommand {
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§escript §8- §7Gibt das Script Buch");
|
||||
p.sendMessage("§8/§escript §8- §7Gibt das Script Buch");
|
||||
}
|
||||
|
||||
@Register
|
||||
|
@ -17,10 +17,10 @@ public class CommandScriptVars extends SWCommand {
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§escriptvars §8- §7Zähle alle globalen Variablen auf");
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§escriptvars §8[§7Variable§8] §8- §7Gebe den Wert der Variable zurück");
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§escriptvars §8[§7Variable§8] §8[§7Value§8] §8- §7Setzte eine Variable auf einen Wert");
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§escriptvars §8[§7Variable§8] §8<§7remove§8|§7delete§8|§7clear§8> §8- §7Lösche eine Variable");
|
||||
p.sendMessage("§8/§escriptvars §8- §7Zähle alle globalen Variablen auf");
|
||||
p.sendMessage("§8/§escriptvars §8[§7Variable§8] §8- §7Gebe den Wert der Variable zurück");
|
||||
p.sendMessage("§8/§escriptvars §8[§7Variable§8] §8[§7Value§8] §8- §7Setzte eine Variable auf einen Wert");
|
||||
p.sendMessage("§8/§escriptvars §8[§7Variable§8] §8<§7remove§8|§7delete§8|§7clear§8> §8- §7Lösche eine Variable");
|
||||
}
|
||||
|
||||
@Register
|
||||
|
@ -35,7 +35,7 @@ public class CommandSkull extends SWCommand {
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§eskull §8[§eSpieler§8] §8- §7Gibt einen SpielerKopf");
|
||||
p.sendMessage("§8/§eskull §8[§eSpieler§8] §8- §7Gibt einen SpielerKopf");
|
||||
}
|
||||
|
||||
@Register
|
||||
|
@ -36,7 +36,7 @@ public class CommandSpeed extends SWCommand {
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§espeed §8[§7Geschwindigkeit§8] §8- §7Setzte deine Flug- und Gehgeschwindigkeit");
|
||||
p.sendMessage("§8/§espeed §8[§7Geschwindigkeit§8] §8- §7Setzte deine Flug- und Gehgeschwindigkeit");
|
||||
}
|
||||
|
||||
@Register({"default"})
|
||||
|
@ -62,8 +62,8 @@ public class CommandTNT extends SWCommand implements Listener {
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§etnt §8- §7Ändere das TNT verhalten");
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§etnt §8[§7Mode§8] §8- §7Setzte das TNT verhalten auf einen Modus");
|
||||
p.sendMessage("§8/§etnt §8- §7Ändere das TNT verhalten");
|
||||
p.sendMessage("§8/§etnt §8[§7Mode§8] §8- §7Setzte das TNT verhalten auf einen Modus");
|
||||
}
|
||||
|
||||
@Register
|
||||
@ -132,22 +132,22 @@ public class CommandTNT extends SWCommand implements Listener {
|
||||
private void tntToggle(Region region, TNTMode requestedMode, String requestedMessage) {
|
||||
if (requestedMode != null && region.hasTestblock()) {
|
||||
region.setTntMode(requestedMode);
|
||||
RegionToggleCommand.actionBar(region, requestedMessage);
|
||||
RegionUtils.actionBar(region, requestedMessage);
|
||||
return;
|
||||
}
|
||||
switch (region.getTntMode()) {
|
||||
case ON:
|
||||
case ONLY_TB:
|
||||
region.setTntMode(TNTMode.OFF);
|
||||
RegionToggleCommand.actionBar(region, getDisableMessage());
|
||||
RegionUtils.actionBar(region, getDisableMessage());
|
||||
break;
|
||||
case OFF:
|
||||
if (Region.buildAreaEnabled() && region.hasTestblock()) {
|
||||
region.setTntMode(TNTMode.ONLY_TB);
|
||||
RegionToggleCommand.actionBar(region, getTestblockEnableMessage());
|
||||
RegionUtils.actionBar(region, getTestblockEnableMessage());
|
||||
} else {
|
||||
region.setTntMode(TNTMode.ON);
|
||||
RegionToggleCommand.actionBar(region, getEnableMessage());
|
||||
RegionUtils.actionBar(region, getEnableMessage());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -159,11 +159,11 @@ public class CommandTNT extends SWCommand implements Listener {
|
||||
Region region = Region.getRegion(block.getLocation());
|
||||
if (region.getTntMode() == TNTMode.ON) return false;
|
||||
if (region.hasBuildRegion() && region.inBuildRegion(block.getLocation())) {
|
||||
RegionToggleCommand.actionBar(region, "§cEine Explosion hätte Blöcke im Baubereich zerstört");
|
||||
RegionUtils.actionBar(region, "§cEine Explosion hätte Blöcke im Baubereich zerstört");
|
||||
return true;
|
||||
}
|
||||
if (region.hasBuildRegion() && region.inBuildRegionExtension(block.getLocation())) {
|
||||
RegionToggleCommand.actionBar(region, "§cEine Explosion hätte Blöcke im Ausfahrbereich zerstört");
|
||||
RegionUtils.actionBar(region, "§cEine Explosion hätte Blöcke im Ausfahrbereich zerstört");
|
||||
return true;
|
||||
}
|
||||
return region.getTntMode() == TNTMode.OFF;
|
||||
|
@ -64,7 +64,7 @@ public class CommandTPSLimiter extends SWCommand {
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage(BauSystem.PREFIX + "Jetziges TPS limit: " + currentTPSLimit);
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§etpslimit §8[§7TPS§8|§edefault§8] §8- §7Setzte die TPS auf dem Bau");
|
||||
p.sendMessage("§8/§etpslimit §8[§7TPS§8|§edefault§8] §8- §7Setzte die TPS auf dem Bau");
|
||||
}
|
||||
|
||||
@Register({"default"})
|
||||
|
@ -13,6 +13,10 @@ public class CommandTeleport extends SWCommand {
|
||||
super("teleport");
|
||||
}
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage("§8/§etp §8[§7Player§8] §8- §7Teleportiere dich zu einem Spieler");
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p, Player target) {
|
||||
|
@ -39,8 +39,8 @@ public class CommandTestblock extends SWCommand {
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§etestblock §8- §7Setzte den Testblock zurück");
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§etestblock §8[§7Schematic§8] §8- §7Setzte den Testblock mit einer Schematic zurück");
|
||||
p.sendMessage("§8/§etestblock §8- §7Setzte den Testblock zurück");
|
||||
p.sendMessage("§8/§etestblock §8[§7Schematic§8] §8- §7Setzte den Testblock mit einer Schematic zurück");
|
||||
}
|
||||
|
||||
@Register
|
||||
|
@ -21,7 +21,7 @@ public class CommandTime extends SWCommand {
|
||||
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§8/§etime §8<§7Zeit 0=Morgen§8, §76000=Mittag§8, §718000=Mitternacht§8> §8- §7Setzt die Zeit auf dem Bau");
|
||||
p.sendMessage("§8/§etime §8<§7Zeit 0=Morgen§8, §76000=Mittag§8, §718000=Mitternacht§8> §8- §7Setzt die Zeit auf dem Bau");
|
||||
}
|
||||
|
||||
@Register
|
||||
|
@ -1,82 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* 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.Region;
|
||||
import de.steamwar.bausystem.world.Welt;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public abstract class RegionToggleCommand implements CommandExecutor, Listener {
|
||||
|
||||
public RegionToggleCommand() {
|
||||
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player))
|
||||
return false;
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (Welt.noPermission(player, Permission.world)) {
|
||||
player.sendMessage(BauSystem.PREFIX + getNoPermMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (toggle(region)) {
|
||||
actionBar(region, getEnableMessage());
|
||||
} else {
|
||||
actionBar(region, getDisableMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void actionBar(Region region, String s) {
|
||||
if (Region.GlobalRegion.isGlobalRegion(region)) {
|
||||
Bukkit.getOnlinePlayers().stream().filter(player -> Region.getRegion(player.getLocation()) == null).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s)));
|
||||
} else {
|
||||
Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation())).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s)));
|
||||
}
|
||||
}
|
||||
|
||||
abstract String getNoPermMessage();
|
||||
|
||||
abstract String getEnableMessage();
|
||||
|
||||
abstract String getDisableMessage();
|
||||
|
||||
/**
|
||||
* {@code true} for {@link #getEnableMessage()}, {@code false} for {@link #getDisableMessage()}
|
||||
*/
|
||||
abstract boolean toggle(Region region);
|
||||
|
||||
}
|
@ -9,7 +9,4 @@ website: "https://steamwar.de"
|
||||
description: "So unseriös wie wir sind: BauSystem nur besser."
|
||||
|
||||
commands:
|
||||
fire:
|
||||
freeze:
|
||||
aliases: stoplag
|
||||
lockschem:
|
In neuem Issue referenzieren
Einen Benutzer sperren