update for CommandTime
Dieser Commit ist enthalten in:
Ursprung
e01d9b6b90
Commit
5d37594efc
@ -66,9 +66,8 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
Mapper.init();
|
||||
|
||||
try {
|
||||
CommandRemover.removeAll("tp", "time");
|
||||
CommandRemover.removeAll("tp");
|
||||
CommandInjector.injectCommand(new CommandTeleport());
|
||||
CommandInjector.injectCommand(new CommandTime());
|
||||
} 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 CommandBau();
|
||||
new CommandGamemode();
|
||||
new CommandClear();
|
||||
new CommandTime();
|
||||
getCommand("fire").setExecutor(new CommandFire());
|
||||
getCommand("freeze").setExecutor(new CommandFreeze());
|
||||
new CommandTestblock();
|
||||
|
@ -52,12 +52,12 @@ public class CommandTPSLimiter extends SWCommand {
|
||||
|
||||
private BukkitTask tpsLimiter = null;
|
||||
|
||||
private List<String> arguments = new ArrayList<>(Arrays.asList("0,5", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"));
|
||||
private List<String> tabCompletions = new ArrayList<>(Arrays.asList("0,5", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"));
|
||||
|
||||
public CommandTPSLimiter() {
|
||||
super("tpslimit");
|
||||
if (TPSUtils.isWarpAllowed()) {
|
||||
arguments.addAll(Arrays.asList("21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40"));
|
||||
tabCompletions.addAll(Arrays.asList("21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ public class CommandTPSLimiter extends SWCommand {
|
||||
} catch (NumberFormatException e) {
|
||||
return 0D;
|
||||
}
|
||||
}, s -> arguments);
|
||||
}, s -> tabCompletions);
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
|
@ -1,67 +1,87 @@
|
||||
/*
|
||||
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 de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.defaults.BukkitCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandTime extends BukkitCommand {
|
||||
|
||||
public class CommandTime extends SWCommand {
|
||||
|
||||
private static List<String> tabCompletions = Arrays.asList("0", "6000", "12000", "18000");
|
||||
|
||||
|
||||
public CommandTime() {
|
||||
super("time");
|
||||
this.description = "Ändert die Zeit auf der Spielwelt";
|
||||
this.usageMessage = "/time <Zeit 0=Morgen, 6000=Mittag, 18000=Mitternacht>";
|
||||
}
|
||||
|
||||
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return false;
|
||||
} else if (args.length == 0) {
|
||||
sender.sendMessage(BauSystem.PREFIX + this.usageMessage);
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (Welt.noPermission(player, Permission.world)) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern");
|
||||
return false;
|
||||
}
|
||||
|
||||
int time;
|
||||
try {
|
||||
time = Integer.valueOf(args[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an");
|
||||
return false;
|
||||
}
|
||||
if (time < 0 || time > 24000) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an");
|
||||
return false;
|
||||
}
|
||||
|
||||
Bukkit.getWorlds().get(0).setTime(time);
|
||||
return false;
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage(BauSystem.PREFIX + "/time <Zeit 0=Morgen, 6000=Mittag, 18000=Mitternacht>");
|
||||
}
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p, int time) {
|
||||
if (Welt.noPermission(p, Permission.world)) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern");
|
||||
return;
|
||||
} else {
|
||||
if (time < 0 || time > 24000) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an");
|
||||
return;
|
||||
} else {
|
||||
Bukkit.getWorlds().get(0).setTime(time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Register
|
||||
public void genericCommand(Player p, Time time) {
|
||||
if (Welt.noPermission(p, Permission.world)) {
|
||||
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern");
|
||||
return;
|
||||
} else {
|
||||
Bukkit.getWorlds().get(0).setTime(time.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ClassMapper(value = int.class, local = true)
|
||||
public TypeMapper<Integer> doubleTypeMapper() {
|
||||
return SWCommandUtils.createMapper(s -> {
|
||||
try {
|
||||
return Integer.parseInt(s);
|
||||
} catch (NumberFormatException e) {
|
||||
return 0;
|
||||
}
|
||||
}, s -> tabCompletions);
|
||||
}
|
||||
|
||||
public enum Time {
|
||||
NIGHT(18000),
|
||||
DAY(6000),
|
||||
DAWN(0),
|
||||
SUNSET(12000),
|
||||
NACHT(18000),
|
||||
TAG(6000),
|
||||
MORGEN(0),
|
||||
ABEND(12000);
|
||||
|
||||
private int value;
|
||||
|
||||
private Time(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren