diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java index 83af51c6..994cb395 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java @@ -40,6 +40,9 @@ public class BauCommand extends SWCommand { @LinkedInstance(BauServer.class) private BauServer bauServer; + @LinkedInstance(InfoCommand.class) + private InfoCommand infoCommand; + public BauCommand() { super("bau", "b", "gs"); } @@ -52,8 +55,7 @@ public class BauCommand extends SWCommand { @Register("info") public void infoCommand(Player p) { - // TODO: Implement this - // CommandInfo.sendBauInfo(p); + infoCommand.sendBauInfo(p); } @Register("togglewe") diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java new file mode 100644 index 00000000..edbcb6f3 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java @@ -0,0 +1,71 @@ +package de.steamwar.bausystem.features.bau; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.config.BauServer; +import de.steamwar.bausystem.features.tpslimit.TPSWarpUtils; +import de.steamwar.bausystem.linkage.LinkageType; +import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.bausystem.linkage.LinkedInstance; +import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.flags.Flag; +import de.steamwar.command.SWCommand; +import de.steamwar.core.TPSWatcher; +import de.steamwar.sql.BauweltMember; +import de.steamwar.sql.SteamwarUser; +import org.bukkit.entity.Player; + +import java.util.List; + +import static de.steamwar.bausystem.features.tpslimit.TPSWarpUtils.getTps; + +@Linked(LinkageType.COMMAND) +public class InfoCommand extends SWCommand { + + @LinkedInstance(BauServer.class) + private BauServer bauServer; + + public InfoCommand() { + super("bauinfo"); + } + + @Register(help = true) + public void genericHelp(Player p, String... args) { + p.sendMessage("§8/§ebauinfo §8- §7Gibt Informationen über den Bau"); + } + + @Register + public void genericCommand(Player p) { + sendBauInfo(p); + } + + public void sendBauInfo(Player p) { + p.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(bauServer.getOwnerID()).getUserName()); + Region region = Region.getRegion(p.getLocation()); + p.sendMessage(BauSystem.PREFIX + "§eTNT§8: " + region.get(Flag.TNT).getChatValue().toUpperCase() + " §eFire§8: " + region.get(Flag.FIRE).getChatValue().toUpperCase() + " §eFreeze§8: " + region.get(Flag.FREEZE).getChatValue().toUpperCase()); + if (region.getFloorLevel() != 0) { + p.sendMessage(BauSystem.PREFIX + "§eProtect§8: " + region.get(Flag.PROTECT).getChatValue().toUpperCase()); + } + + List members = BauweltMember.getMembers(bauServer.getOwnerID()); + StringBuilder membermessage = new StringBuilder().append(BauSystem.PREFIX).append("Mitglieder: "); + + for (BauweltMember member : members) { + membermessage.append("§e").append(SteamwarUser.get(member.getMemberID()).getUserName()).append("§8["); + membermessage.append(member.isWorldEdit() ? "§a" : "§c").append("WE").append("§8,"); + membermessage.append(member.isWorld() ? "§a" : "§c").append("W").append("§8]").append(" "); + } + p.sendMessage(membermessage.toString()); + + StringBuilder tpsMessage = new StringBuilder(); + tpsMessage.append(BauSystem.PREFIX).append("TPS:§e"); + tpsMessage.append(" ").append(getTps(TPSWatcher.TPSType.ONE_SECOND)); + tpsMessage.append(" ").append(getTps(TPSWatcher.TPSType.TEN_SECONDS)); + if (!TPSWarpUtils.isWarping()) { + tpsMessage.append(" ").append(TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_MINUTE)); + tpsMessage.append(" ").append(TPSWatcher.getTPS(TPSWatcher.TPSType.FIVE_MINUTES)); + tpsMessage.append(" ").append(TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES)); + } + p.sendMessage(tpsMessage.toString()); + } + +}