diff options
author | David <david@panic.tk> | 2019-01-03 17:00:58 +0100 |
---|---|---|
committer | David <david@panic.tk> | 2019-01-03 17:00:58 +0100 |
commit | 78c9bdfbda0e8938065edb7c2d3e760877599a09 (patch) | |
tree | d1d66045414d479567f22c009f280b360c9a1131 | |
parent | 1465818ef8584f4b2b8c56cc92a8993886167d08 (diff) |
Minor code cleanup
-rw-r--r-- | src/main/java/com/redstoner/modules/lagchunks/LagChunks.java | 85 |
1 files changed, 36 insertions, 49 deletions
diff --git a/src/main/java/com/redstoner/modules/lagchunks/LagChunks.java b/src/main/java/com/redstoner/modules/lagchunks/LagChunks.java index b775c89..542f032 100644 --- a/src/main/java/com/redstoner/modules/lagchunks/LagChunks.java +++ b/src/main/java/com/redstoner/modules/lagchunks/LagChunks.java @@ -1,8 +1,11 @@ package com.redstoner.modules.lagchunks; -import java.util.ArrayList; -import java.util.List; - +import com.nemez.cmdmgr.Command; +import com.nemez.cmdmgr.Command.AsyncType; +import com.redstoner.annotations.Commands; +import com.redstoner.annotations.Version; +import com.redstoner.misc.CommandHolderType; +import com.redstoner.modules.Module; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Location; @@ -10,72 +13,56 @@ import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import com.nemez.cmdmgr.Command; -import com.nemez.cmdmgr.Command.AsyncType; -import com.redstoner.annotations.Commands; -import com.redstoner.annotations.Version; -import com.redstoner.misc.CommandHolderType; -import com.redstoner.modules.Module; +import java.util.ArrayList; +import java.util.List; + +@Commands (CommandHolderType.File) +@Version (major = 5, minor = 0, revision = 0, compatible = 4) +public class LagChunks implements Module { + private List<LaggyChunk> laggyChunks = new ArrayList<>(); -@Commands(CommandHolderType.File) -@Version(major = 5, minor = 0, revision = 0, compatible = 4) -public class LagChunks implements Module -{ - private List<LaggyChunk> laggyChunks = new ArrayList<LaggyChunk>(); - - private void scan(int amount) - { + private void scan(int amount) { laggyChunks.clear(); - for (World world : Bukkit.getServer().getWorlds()) - { - for (Chunk chunk : world.getLoadedChunks()) - { - if (chunk.getEntities().length > amount) - { + + for (World world : Bukkit.getServer().getWorlds()) { + for (Chunk chunk : world.getLoadedChunks()) { + if (chunk.getEntities().length > amount) { Location entLoc = chunk.getEntities()[0].getLocation(); laggyChunks.add(new LaggyChunk(entLoc.getBlockX(), entLoc.getBlockY(), entLoc.getBlockZ(), world, - chunk.getEntities().length)); + chunk.getEntities().length + )); } } } } - - @Command(hook = "list_cmd") - public void list(CommandSender sender) - { - if (laggyChunks.size() > 0) - { - ArrayList<String> message = new ArrayList<String>(); - for (LaggyChunk lc : laggyChunks) - { + + @Command (hook = "list_cmd") + public void list(CommandSender sender) { + if (laggyChunks.size() > 0) { + ArrayList<String> message = new ArrayList<>(); + for (LaggyChunk lc : laggyChunks) { message.add("§b[§a" + laggyChunks.indexOf(lc) + "§b]: §a" + lc.x + "§7, §a" + lc.y + "§7, §a" + lc.z - + " §7(" + lc.world.getName() + ") §a- §b" + lc.amount + " entities"); + + " §7(" + lc.world.getName() + ") §a- §b" + lc.amount + " entities"); } message.add("§2-------------------"); getLogger().message(sender, message.toArray(new String[] {})); - } - else + } else getLogger().message(sender, true, "Couldn't find any chunks with that many entities."); } - - @Command(hook = "scan_cmd", async = AsyncType.ALWAYS) - public void scan_cmd(CommandSender sender, int amount) - { + + @Command (hook = "scan_cmd", async = AsyncType.ALWAYS) + public void scan_cmd(CommandSender sender, int amount) { scan(amount); list(sender); } - - @Command(hook = "tp") - public void tp(CommandSender sender, int number) - { + + @Command (hook = "tp") + public void tp(CommandSender sender, int number) { Player player = (Player) sender; - if (number < laggyChunks.size()) - { + if (number < laggyChunks.size()) { player.teleport(laggyChunks.get(number).getLocation()); getLogger().message(player, "§aTeleported to chunk " + number + "!"); - } - else - { + } else { getLogger().message(sender, true, "§4Invalid chunk number! Use §e/lc list §4to show laggy chunks!"); } } |