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();
|
new CommandTPSLimiter();
|
||||||
getCommand("nightvision").setExecutor(new CommandNV());
|
getCommand("nightvision").setExecutor(new CommandNV());
|
||||||
getCommand("reset").setExecutor(new CommandReset());
|
getCommand("reset").setExecutor(new CommandReset());
|
||||||
getCommand("speed").setExecutor(new CommandSpeed());
|
new CommandSpeed();
|
||||||
new CommandTNT();
|
new CommandTNT();
|
||||||
new CommandBau();
|
new CommandBau();
|
||||||
getCommand("fire").setExecutor(new CommandFire());
|
getCommand("fire").setExecutor(new CommandFire());
|
||||||
|
@ -20,40 +20,50 @@
|
|||||||
package de.steamwar.bausystem.commands;
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import org.bukkit.command.Command;
|
import de.steamwar.command.SWCommand;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import de.steamwar.command.SWCommandUtils;
|
||||||
import org.bukkit.command.CommandSender;
|
import de.steamwar.command.TypeMapper;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class CommandSpeed implements CommandExecutor {
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Override
|
public class CommandSpeed extends SWCommand {
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
if (!(sender instanceof Player))
|
|
||||||
return false;
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
if (args.length == 0) {
|
public CommandSpeed() {
|
||||||
player.sendMessage(BauSystem.PREFIX + "/speed [Geschwindigkeit]");
|
super("speed");
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
float speed;
|
@Register(help = true)
|
||||||
try {
|
public void genericHelp(Player p, String... args) {
|
||||||
speed = Float.parseFloat(args[0]);
|
p.sendMessage(BauSystem.PREFIX + "/speed [Geschwindigkeit]");
|
||||||
} catch (NumberFormatException e) {
|
}
|
||||||
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an");
|
|
||||||
return false;
|
@Register({"default"})
|
||||||
}
|
public void defaultCommand(Player p) {
|
||||||
|
speedCommand(p, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void speedCommand(Player p, float speed) {
|
||||||
if (speed < 0 || speed > 10) {
|
if (speed < 0 || speed > 10) {
|
||||||
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an");
|
p.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an");
|
||||||
return false;
|
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);
|
@ClassMapper(value = float.class, local = true)
|
||||||
player.setWalkSpeed((speed >= 9 ? speed : speed + 1) / 10);
|
public TypeMapper<Float> doubleTypeMapper() {
|
||||||
return false;
|
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:
|
reset:
|
||||||
protect:
|
protect:
|
||||||
bauinfo:
|
bauinfo:
|
||||||
speed:
|
|
||||||
skull:
|
skull:
|
||||||
freeze:
|
freeze:
|
||||||
aliases: stoplag
|
aliases: stoplag
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren