Merge remote-tracking branch 'origin/CommandFramework' into CommandFramework
Dieser Commit ist enthalten in:
Commit
04ca32627d
@ -79,7 +79,7 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
new CommandTPSLimiter();
|
||||
getCommand("nightvision").setExecutor(new CommandNV());
|
||||
getCommand("reset").setExecutor(new CommandReset());
|
||||
getCommand("speed").setExecutor(new CommandSpeed());
|
||||
new CommandSpeed();
|
||||
new CommandTNT();
|
||||
new CommandBau();
|
||||
getCommand("fire").setExecutor(new CommandFire());
|
||||
|
@ -20,40 +20,50 @@
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandSpeed implements CommandExecutor {
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player))
|
||||
return false;
|
||||
Player player = (Player) sender;
|
||||
public class CommandSpeed extends SWCommand {
|
||||
|
||||
if (args.length == 0) {
|
||||
player.sendMessage(BauSystem.PREFIX + "/speed [Geschwindigkeit]");
|
||||
return false;
|
||||
public CommandSpeed() {
|
||||
super("speed");
|
||||
}
|
||||
|
||||
float speed;
|
||||
try {
|
||||
speed = Float.parseFloat(args[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an");
|
||||
return false;
|
||||
@Register(help = true)
|
||||
public void genericHelp(Player p, String... args) {
|
||||
p.sendMessage(BauSystem.PREFIX + "/speed [Geschwindigkeit]");
|
||||
}
|
||||
|
||||
@Register({"default"})
|
||||
public void defaultCommand(Player p) {
|
||||
speedCommand(p, 1);
|
||||
}
|
||||
|
||||
public void speedCommand(Player p, float speed) {
|
||||
if (speed < 0 || speed > 10) {
|
||||
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an");
|
||||
return false;
|
||||
p.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an");
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendMessage("§aGeschwindigkeit wurde auf §6" + speed + " §agesetzt");
|
||||
p.sendMessage("§aGeschwindigkeit wurde auf §6" + speed + " §agesetzt");
|
||||
p.setFlySpeed(speed / 10);
|
||||
p.setWalkSpeed((speed >= 9 ? speed : speed + 1) / 10);
|
||||
}
|
||||
|
||||
player.setFlySpeed(speed / 10);
|
||||
player.setWalkSpeed((speed >= 9 ? speed : speed + 1) / 10);
|
||||
return false;
|
||||
@ClassMapper(value = float.class, local = true)
|
||||
public TypeMapper<Float> doubleTypeMapper() {
|
||||
List<String> tabCompletes = Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
|
||||
return SWCommandUtils.createMapper(s -> {
|
||||
try {
|
||||
return Float.parseFloat(s.replace(',', '.'));
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
}, s -> tabCompletes);
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ commands:
|
||||
reset:
|
||||
protect:
|
||||
bauinfo:
|
||||
speed:
|
||||
skull:
|
||||
freeze:
|
||||
aliases: stoplag
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren