From a7fbefbef487b0e257ecd71573efa412eeb68b87 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 17 Apr 2021 15:37:51 +0200 Subject: [PATCH] Add SpeedCommand.java --- .../bausystem/features/util/SpeedCommand.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/util/SpeedCommand.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/SpeedCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/SpeedCommand.java new file mode 100644 index 00000000..7fe2a530 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/SpeedCommand.java @@ -0,0 +1,37 @@ +package de.steamwar.bausystem.features.util; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.linkage.LinkageType; +import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.command.SWCommand; +import org.bukkit.entity.Player; + +@Linked(LinkageType.COMMAND) +public class SpeedCommand extends SWCommand { + + public SpeedCommand() { + super("speed"); + } + + @Register(help = true) + public void genericHelp(Player p, String[] args) { + p.sendMessage("§8/§espeed §8[§e1§8-§e10§8] §8- §7Setzte deine Flug- und Laufgeschindigkeit."); + p.sendMessage(BauSystem.PREFIX + "Aktuelle geschwindigkeit: §e" + p.getFlySpeed() * 10F); + } + + @Register + public void speedCommand(Player p, float speed) { + speed = speed / 10F; + if(speed < -1F) { + p.sendMessage(BauSystem.PREFIX + "§c" + speed + " ist zu klein"); + return; + } else if(speed > 1F) { + p.sendMessage(BauSystem.PREFIX + "§c" + speed + " ist zu hoch"); + return; + } else { + p.setFlySpeed(speed); + p.setWalkSpeed(speed); + p.sendMessage(BauSystem.PREFIX + "Aktuelle geschwindigkeit: §e" + p.getFlySpeed() * 10F); + } + } +}