From 8a2c5acfe009c9147bfd6d3b0b723a40d9b5cfd7 Mon Sep 17 00:00:00 2001 From: ProfMobius Date: Mon, 10 Mar 2014 13:22:03 +0100 Subject: [PATCH] Fixed commands Fixed TickHandler Fixed other things Added a all param to the getnent Bumped version --- mcp/mobius/opis/commands/IOpisCommand.java | 2 +- .../server/CommandAmountEntities.java | 21 +++++++++---- .../commands/server/CommandChunkDump.java | 5 ++++ .../commands/server/CommandChunkList.java | 10 +++++-- .../opis/commands/server/CommandDataDump.java | 8 ++++- .../commands/server/CommandFrequency.java | 8 ++++- .../opis/commands/server/CommandHandler.java | 21 +++++++++++-- .../opis/commands/server/CommandHelp.java | 9 ++++-- .../opis/commands/server/CommandKill.java | 8 ++++- .../opis/commands/server/CommandKillAll.java | 11 +++++-- .../commands/server/CommandMeanModTime.java | 10 +++++-- .../opis/commands/server/CommandReset.java | 8 ++++- .../opis/commands/server/CommandStart.java | 8 ++++- .../opis/commands/server/CommandStop.java | 10 +++++-- .../opis/commands/server/CommandTPS.java | 5 ++++ .../opis/commands/server/CommandTicks.java | 8 ++++- .../server/CommandTimingEntities.java | 10 +++++-- .../server/CommandTimingTileEntities.java | 10 +++++-- .../opis/data/holders/TickHandlerStats.java | 2 ++ .../opis/data/managers/EntityManager.java | 10 +++++-- .../data/managers/TickHandlerManager.java | 30 +++++++++++++++++-- mcp/mobius/opis/modOpis.java | 6 ++-- 22 files changed, 182 insertions(+), 38 deletions(-) diff --git a/mcp/mobius/opis/commands/IOpisCommand.java b/mcp/mobius/opis/commands/IOpisCommand.java index 9f1ac86..972bba7 100644 --- a/mcp/mobius/opis/commands/IOpisCommand.java +++ b/mcp/mobius/opis/commands/IOpisCommand.java @@ -2,5 +2,5 @@ package mcp.mobius.opis.commands; public interface IOpisCommand { String getDescription(); - String getCommandName(); + String getCommandNameOpis(); } diff --git a/mcp/mobius/opis/commands/server/CommandAmountEntities.java b/mcp/mobius/opis/commands/server/CommandAmountEntities.java index ff9517a..a679ed3 100644 --- a/mcp/mobius/opis/commands/server/CommandAmountEntities.java +++ b/mcp/mobius/opis/commands/server/CommandAmountEntities.java @@ -21,7 +21,12 @@ public class CommandAmountEntities extends CommandBase implements IOpisCommand{ public String getCommandName() { return "opis_nent"; } - + + @Override + public String getCommandNameOpis() { + return this.getCommandName(); + } + @Override public String getCommandUsage(ICommandSender icommandsender) { return ""; @@ -29,11 +34,16 @@ public class CommandAmountEntities extends CommandBase implements IOpisCommand{ @Override public void processCommand(ICommandSender icommandsender, String[] astring) { - HashMap ents = EntityManager.getCumulativeEntities(); + HashMap ents; + + if (astring.length == 1 && astring[0].equals("all")) + ents = EntityManager.getCumulativeEntities(true); + else + ents = EntityManager.getCumulativeEntities(false); if (icommandsender instanceof EntityPlayer) ((EntityPlayerMP)icommandsender).playerNetServerHandler.sendPacketToPlayer(Packet_DataScreenAmountEntities.create(ents)); - else if (icommandsender instanceof DedicatedServer){ + else{ for (String s : ents.keySet()) icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(String.format("%s : %s", s, ents.get(s)))); } @@ -49,8 +59,9 @@ public class CommandAmountEntities extends CommandBase implements IOpisCommand{ @Override public boolean canCommandSenderUseCommand(ICommandSender sender) { - if (sender instanceof DedicatedServer) return true; - if (((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if (sender instanceof DedicatedServer) return true; + if ((sender instanceof EntityPlayerMP) && ((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if (!(sender instanceof DedicatedServer) && !(sender instanceof EntityPlayerMP)) return true; return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(((EntityPlayerMP)sender).username); } diff --git a/mcp/mobius/opis/commands/server/CommandChunkDump.java b/mcp/mobius/opis/commands/server/CommandChunkDump.java index ae5e980..526f22b 100644 --- a/mcp/mobius/opis/commands/server/CommandChunkDump.java +++ b/mcp/mobius/opis/commands/server/CommandChunkDump.java @@ -25,6 +25,11 @@ public class CommandChunkDump extends CommandBase implements IOpisCommand{ return "chunkdump"; } + @Override + public String getCommandNameOpis() { + return this.getCommandName(); + } + @Override public String getCommandUsage(ICommandSender icommandsender) { return ""; diff --git a/mcp/mobius/opis/commands/server/CommandChunkList.java b/mcp/mobius/opis/commands/server/CommandChunkList.java index df5ddc1..d5c9087 100644 --- a/mcp/mobius/opis/commands/server/CommandChunkList.java +++ b/mcp/mobius/opis/commands/server/CommandChunkList.java @@ -22,6 +22,11 @@ public class CommandChunkList extends CommandBase implements IOpisCommand { return "opis_chunk"; } + @Override + public String getCommandNameOpis() { + return this.getCommandName(); + } + @Override public String getCommandUsage(ICommandSender icommandsender) { return ""; @@ -46,7 +51,7 @@ public class CommandChunkList extends CommandBase implements IOpisCommand { */ if (icommandsender instanceof EntityPlayer) ((EntityPlayerMP)icommandsender).playerNetServerHandler.sendPacketToPlayer(Packet_ChunkTopList.create(chunks)); - else if (icommandsender instanceof DedicatedServer){ + else { icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText("[DIM X Z] Time NTEs")); for (ChunkStats stat : chunks){ icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(stat.toString())); @@ -65,7 +70,8 @@ public class CommandChunkList extends CommandBase implements IOpisCommand { public boolean canCommandSenderUseCommand(ICommandSender sender) { if (sender instanceof DedicatedServer) return true; - if (((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if ((sender instanceof EntityPlayerMP) && ((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if (!(sender instanceof DedicatedServer) && !(sender instanceof EntityPlayerMP)) return true; return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(((EntityPlayerMP)sender).username); } diff --git a/mcp/mobius/opis/commands/server/CommandDataDump.java b/mcp/mobius/opis/commands/server/CommandDataDump.java index 9605ca8..c354d96 100644 --- a/mcp/mobius/opis/commands/server/CommandDataDump.java +++ b/mcp/mobius/opis/commands/server/CommandDataDump.java @@ -31,6 +31,11 @@ public class CommandDataDump extends CommandBase implements IOpisCommand { return "opis_dump"; } + @Override + public String getCommandNameOpis() { + return this.getCommandName(); + } + @Override public String getCommandUsage(ICommandSender icommandsender) { return ""; @@ -134,7 +139,8 @@ public class CommandDataDump extends CommandBase implements IOpisCommand { public boolean canCommandSenderUseCommand(ICommandSender sender) { if (sender instanceof DedicatedServer) return true; - if (((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if ((sender instanceof EntityPlayerMP) && ((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if (!(sender instanceof DedicatedServer) && !(sender instanceof EntityPlayerMP)) return true; return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(((EntityPlayerMP)sender).username); } diff --git a/mcp/mobius/opis/commands/server/CommandFrequency.java b/mcp/mobius/opis/commands/server/CommandFrequency.java index 370af16..7c82572 100644 --- a/mcp/mobius/opis/commands/server/CommandFrequency.java +++ b/mcp/mobius/opis/commands/server/CommandFrequency.java @@ -21,6 +21,11 @@ public class CommandFrequency extends CommandBase implements IOpisCommand { return "opis_delay"; } + @Override + public String getCommandNameOpis() { + return this.getCommandName(); + } + @Override public String getCommandUsage(ICommandSender icommandsender) { return ""; @@ -46,7 +51,8 @@ public class CommandFrequency extends CommandBase implements IOpisCommand { public boolean canCommandSenderUseCommand(ICommandSender sender) { if (sender instanceof DedicatedServer) return true; - if (((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if ((sender instanceof EntityPlayerMP) && ((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if (!(sender instanceof DedicatedServer) && !(sender instanceof EntityPlayerMP)) return true; return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(((EntityPlayerMP)sender).username); } diff --git a/mcp/mobius/opis/commands/server/CommandHandler.java b/mcp/mobius/opis/commands/server/CommandHandler.java index 6ede52f..4e93d86 100644 --- a/mcp/mobius/opis/commands/server/CommandHandler.java +++ b/mcp/mobius/opis/commands/server/CommandHandler.java @@ -14,6 +14,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.network.MemoryConnection; import net.minecraft.server.MinecraftServer; import net.minecraft.server.dedicated.DedicatedServer; +import net.minecraft.util.ChatMessageComponent; public class CommandHandler extends CommandBase implements IOpisCommand { @@ -22,6 +23,11 @@ public class CommandHandler extends CommandBase implements IOpisCommand { return "opis_handler"; } + @Override + public String getCommandNameOpis() { + return this.getCommandName(); + } + @Override public String getCommandUsage(ICommandSender icommandsender) { return ""; @@ -30,7 +36,15 @@ public class CommandHandler extends CommandBase implements IOpisCommand { @Override public void processCommand(ICommandSender icommandsender, String[] astring) { ArrayList stats = TickHandlerManager.getCumulatedStats(); - ((EntityPlayerMP)icommandsender).playerNetServerHandler.sendPacketToPlayer(Packet_DataScreenTimingHandlers.create(stats)); + //((EntityPlayerMP)icommandsender).playerNetServerHandler.sendPacketToPlayer(Packet_DataScreenTimingHandlers.create(stats)); + + if (icommandsender instanceof EntityPlayerMP) + ((EntityPlayerMP)icommandsender).playerNetServerHandler.sendPacketToPlayer(Packet_DataScreenTimingHandlers.create(stats)); + else{ + for (TickHandlerStats s : stats) + icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(String.format("%s : %.2f", s.getName(), s.getGeometricMean()))); + } + } @Override @@ -42,8 +56,9 @@ public class CommandHandler extends CommandBase implements IOpisCommand { @Override public boolean canCommandSenderUseCommand(ICommandSender sender) { - if (sender instanceof DedicatedServer) return false; - if (((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if (sender instanceof DedicatedServer) return true; + if ((sender instanceof EntityPlayerMP) && ((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if (!(sender instanceof DedicatedServer) && !(sender instanceof EntityPlayerMP)) return true; return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(((EntityPlayerMP)sender).username); } diff --git a/mcp/mobius/opis/commands/server/CommandHelp.java b/mcp/mobius/opis/commands/server/CommandHelp.java index 45c671a..95dbb33 100644 --- a/mcp/mobius/opis/commands/server/CommandHelp.java +++ b/mcp/mobius/opis/commands/server/CommandHelp.java @@ -20,6 +20,11 @@ public class CommandHelp extends CommandBase implements IOpisCommand { return "opis_help"; } + @Override + public String getCommandNameOpis() { + return this.getCommandName(); + } + @Override public String getCommandUsage(ICommandSender icommandsender) { return ""; @@ -46,11 +51,11 @@ public class CommandHelp extends CommandBase implements IOpisCommand { new CommandKill(), new CommandKillAll(), - //new CommandHandler() + new CommandHandler() }; for (IOpisCommand cmd : commands) - icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(String.format("/%s : %s", cmd.getCommandName(), cmd.getDescription()))); + icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(String.format("/%s : %s", cmd.getCommandNameOpis(), cmd.getDescription()))); } @Override diff --git a/mcp/mobius/opis/commands/server/CommandKill.java b/mcp/mobius/opis/commands/server/CommandKill.java index 13d89da..39325be 100644 --- a/mcp/mobius/opis/commands/server/CommandKill.java +++ b/mcp/mobius/opis/commands/server/CommandKill.java @@ -22,6 +22,11 @@ public class CommandKill extends CommandBase implements IOpisCommand { return "opis_kill"; } + @Override + public String getCommandNameOpis() { + return this.getCommandName(); + } + @Override public String getCommandUsage(ICommandSender icommandsender) { return ""; @@ -60,7 +65,8 @@ public class CommandKill extends CommandBase implements IOpisCommand { public boolean canCommandSenderUseCommand(ICommandSender sender) { if (sender instanceof DedicatedServer) return true; - if (((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if ((sender instanceof EntityPlayerMP) && ((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if (!(sender instanceof DedicatedServer) && !(sender instanceof EntityPlayerMP)) return true; return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(((EntityPlayerMP)sender).username); } diff --git a/mcp/mobius/opis/commands/server/CommandKillAll.java b/mcp/mobius/opis/commands/server/CommandKillAll.java index 83dcda4..f805982 100644 --- a/mcp/mobius/opis/commands/server/CommandKillAll.java +++ b/mcp/mobius/opis/commands/server/CommandKillAll.java @@ -26,6 +26,11 @@ public class CommandKillAll extends CommandBase implements IOpisCommand { return "opis_killall"; } + @Override + public String getCommandNameOpis() { + return this.getCommandName(); + } + @Override public String getCommandUsage(ICommandSender icommandsender) { return ""; @@ -59,8 +64,7 @@ public class CommandKillAll extends CommandBase implements IOpisCommand { } } - if (icommandsender instanceof EntityPlayer) - icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(String.format("\u00A7oKilled %d entities of type %s", nkilled, searchname))); + icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(String.format("\u00A7oKilled %d entities of type %s", nkilled, searchname))); /* World world = DimensionManager.getWorld(dim); @@ -97,7 +101,8 @@ public class CommandKillAll extends CommandBase implements IOpisCommand { public boolean canCommandSenderUseCommand(ICommandSender sender) { if (sender instanceof DedicatedServer) return true; - if (((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if ((sender instanceof EntityPlayerMP) && ((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if (!(sender instanceof DedicatedServer) && !(sender instanceof EntityPlayerMP)) return true; return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(((EntityPlayerMP)sender).username); } diff --git a/mcp/mobius/opis/commands/server/CommandMeanModTime.java b/mcp/mobius/opis/commands/server/CommandMeanModTime.java index ad67964..6ddceb0 100644 --- a/mcp/mobius/opis/commands/server/CommandMeanModTime.java +++ b/mcp/mobius/opis/commands/server/CommandMeanModTime.java @@ -22,6 +22,11 @@ public class CommandMeanModTime extends CommandBase implements IOpisCommand { return "opis_mods"; } + @Override + public String getCommandNameOpis() { + return this.getCommandName(); + } + @Override public String getCommandUsage(ICommandSender icommandsender) { return ""; @@ -33,7 +38,7 @@ public class CommandMeanModTime extends CommandBase implements IOpisCommand { if (icommandsender instanceof EntityPlayer) ((EntityPlayerMP)icommandsender).playerNetServerHandler.sendPacketToPlayer(Packet_ModMeanTime.create(modStats)); - else if (icommandsender instanceof DedicatedServer){ + else{ icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText("[Name] NTEs MeanTime")); for (ModStats stat : modStats){ icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText( @@ -53,7 +58,8 @@ public class CommandMeanModTime extends CommandBase implements IOpisCommand { public boolean canCommandSenderUseCommand(ICommandSender sender) { if (sender instanceof DedicatedServer) return true; - if (((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if ((sender instanceof EntityPlayerMP) && ((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if (!(sender instanceof DedicatedServer) && !(sender instanceof EntityPlayerMP)) return true; return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(((EntityPlayerMP)sender).username); } diff --git a/mcp/mobius/opis/commands/server/CommandReset.java b/mcp/mobius/opis/commands/server/CommandReset.java index ecda06b..d2e3ac0 100644 --- a/mcp/mobius/opis/commands/server/CommandReset.java +++ b/mcp/mobius/opis/commands/server/CommandReset.java @@ -29,6 +29,11 @@ public class CommandReset extends CommandBase implements IOpisCommand { return "opis_reset"; } + @Override + public String getCommandNameOpis() { + return this.getCommandName(); + } + @Override public String getCommandUsage(ICommandSender icommandsender) { return ""; @@ -54,7 +59,8 @@ public class CommandReset extends CommandBase implements IOpisCommand { public boolean canCommandSenderUseCommand(ICommandSender sender) { if (sender instanceof DedicatedServer) return true; - if (((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if ((sender instanceof EntityPlayerMP) && ((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if (!(sender instanceof DedicatedServer) && !(sender instanceof EntityPlayerMP)) return true; return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(((EntityPlayerMP)sender).username); } diff --git a/mcp/mobius/opis/commands/server/CommandStart.java b/mcp/mobius/opis/commands/server/CommandStart.java index 42ee359..f97fa14 100644 --- a/mcp/mobius/opis/commands/server/CommandStart.java +++ b/mcp/mobius/opis/commands/server/CommandStart.java @@ -30,6 +30,11 @@ public class CommandStart extends CommandBase implements IOpisCommand { return "opis_start"; } + @Override + public String getCommandNameOpis() { + return this.getCommandName(); + } + @Override public String getCommandUsage(ICommandSender icommandsender) { return ""; @@ -57,7 +62,8 @@ public class CommandStart extends CommandBase implements IOpisCommand { public boolean canCommandSenderUseCommand(ICommandSender sender) { if (sender instanceof DedicatedServer) return true; - if (((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if ((sender instanceof EntityPlayerMP) && ((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if (!(sender instanceof DedicatedServer) && !(sender instanceof EntityPlayerMP)) return true; return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(((EntityPlayerMP)sender).username); } diff --git a/mcp/mobius/opis/commands/server/CommandStop.java b/mcp/mobius/opis/commands/server/CommandStop.java index bea8214..3c353a5 100644 --- a/mcp/mobius/opis/commands/server/CommandStop.java +++ b/mcp/mobius/opis/commands/server/CommandStop.java @@ -24,6 +24,11 @@ public class CommandStop extends CommandBase implements IOpisCommand { return "opis_stop"; } + @Override + public String getCommandNameOpis() { + return this.getCommandName(); + } + @Override public String getCommandUsage(ICommandSender icommandsender) { return ""; @@ -40,7 +45,7 @@ public class CommandStop extends CommandBase implements IOpisCommand { for (EntityPlayer player : OpisServerTickHandler.instance.players) PacketDispatcher.sendPacketToPlayer(new Packet3Chat(ChatMessageComponent.createFromText(String.format("\u00A7oOpis stopped."))), (Player)player); - if (icommandsender instanceof DedicatedServer) + if (!(icommandsender instanceof EntityPlayer)) icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(String.format("\u00A7oOpis stopped."))); } @@ -54,7 +59,8 @@ public class CommandStop extends CommandBase implements IOpisCommand { public boolean canCommandSenderUseCommand(ICommandSender sender) { if (sender instanceof DedicatedServer) return true; - if (((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if ((sender instanceof EntityPlayerMP) && ((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if (!(sender instanceof DedicatedServer) && !(sender instanceof EntityPlayerMP)) return true; return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(((EntityPlayerMP)sender).username); } diff --git a/mcp/mobius/opis/commands/server/CommandTPS.java b/mcp/mobius/opis/commands/server/CommandTPS.java index 7cc28f9..4763c2d 100644 --- a/mcp/mobius/opis/commands/server/CommandTPS.java +++ b/mcp/mobius/opis/commands/server/CommandTPS.java @@ -13,6 +13,11 @@ public class CommandTPS extends CommandBase implements IOpisCommand { return "opis_tps"; } + @Override + public String getCommandNameOpis() { + return this.getCommandName(); + } + @Override public String getCommandUsage(ICommandSender icommandsender) { return ""; diff --git a/mcp/mobius/opis/commands/server/CommandTicks.java b/mcp/mobius/opis/commands/server/CommandTicks.java index 8076647..97594f8 100644 --- a/mcp/mobius/opis/commands/server/CommandTicks.java +++ b/mcp/mobius/opis/commands/server/CommandTicks.java @@ -21,6 +21,11 @@ public class CommandTicks extends CommandBase implements IOpisCommand { return "opis_ticks"; } + @Override + public String getCommandNameOpis() { + return this.getCommandName(); + } + @Override public String getCommandUsage(ICommandSender icommandsender) { return ""; @@ -46,7 +51,8 @@ public class CommandTicks extends CommandBase implements IOpisCommand { public boolean canCommandSenderUseCommand(ICommandSender sender) { if (sender instanceof DedicatedServer) return true; - if (((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if ((sender instanceof EntityPlayerMP) && ((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if (!(sender instanceof DedicatedServer) && !(sender instanceof EntityPlayerMP)) return true; return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(((EntityPlayerMP)sender).username); } diff --git a/mcp/mobius/opis/commands/server/CommandTimingEntities.java b/mcp/mobius/opis/commands/server/CommandTimingEntities.java index b723a90..1c0ed14 100644 --- a/mcp/mobius/opis/commands/server/CommandTimingEntities.java +++ b/mcp/mobius/opis/commands/server/CommandTimingEntities.java @@ -24,6 +24,11 @@ public class CommandTimingEntities extends CommandBase implements IOpisCommand { return "opis_ent"; } + @Override + public String getCommandNameOpis() { + return this.getCommandName(); + } + @Override public String getCommandUsage(ICommandSender icommandsender) { return ""; @@ -43,7 +48,7 @@ public class CommandTimingEntities extends CommandBase implements IOpisCommand { if (icommandsender instanceof EntityPlayer) ((EntityPlayerMP)icommandsender).playerNetServerHandler.sendPacketToPlayer(Packet_DataScreenTimingEntities.create(ents)); - else if (icommandsender instanceof DedicatedServer){ + else{ icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText("[DIM X Z] Time NTEs")); for (EntityStats stat : ents){ icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(stat.toString())); @@ -62,7 +67,8 @@ public class CommandTimingEntities extends CommandBase implements IOpisCommand { public boolean canCommandSenderUseCommand(ICommandSender sender) { if (sender instanceof DedicatedServer) return true; - if (((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if ((sender instanceof EntityPlayerMP) && ((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if (!(sender instanceof DedicatedServer) && !(sender instanceof EntityPlayerMP)) return true; return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(((EntityPlayerMP)sender).username); } diff --git a/mcp/mobius/opis/commands/server/CommandTimingTileEntities.java b/mcp/mobius/opis/commands/server/CommandTimingTileEntities.java index 62150df..a74943b 100644 --- a/mcp/mobius/opis/commands/server/CommandTimingTileEntities.java +++ b/mcp/mobius/opis/commands/server/CommandTimingTileEntities.java @@ -22,6 +22,11 @@ public class CommandTimingTileEntities extends CommandBase implements IOpisComma return "opis_te"; } + @Override + public String getCommandNameOpis() { + return this.getCommandName(); + } + @Override public String getCommandUsage(ICommandSender icommandsender) { return ""; @@ -41,7 +46,7 @@ public class CommandTimingTileEntities extends CommandBase implements IOpisComma if (icommandsender instanceof EntityPlayer) ((EntityPlayerMP)icommandsender).playerNetServerHandler.sendPacketToPlayer(Packet_TileEntitiesTopList.create(tes)); - else if (icommandsender instanceof DedicatedServer){ + else{ for (TileEntityStats stat : tes){ icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(stat.toString())); } @@ -59,7 +64,8 @@ public class CommandTimingTileEntities extends CommandBase implements IOpisComma public boolean canCommandSenderUseCommand(ICommandSender sender) { if (sender instanceof DedicatedServer) return true; - if (((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if ((sender instanceof EntityPlayerMP) && ((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true; + if (!(sender instanceof DedicatedServer) && !(sender instanceof EntityPlayerMP)) return true; return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(((EntityPlayerMP)sender).username); } diff --git a/mcp/mobius/opis/data/holders/TickHandlerStats.java b/mcp/mobius/opis/data/holders/TickHandlerStats.java index 3fb45c8..deeb6f5 100644 --- a/mcp/mobius/opis/data/holders/TickHandlerStats.java +++ b/mcp/mobius/opis/data/holders/TickHandlerStats.java @@ -13,6 +13,7 @@ public class TickHandlerStats implements ISerializable, Comparable{ public DescriptiveStatistics dstat = new DescriptiveStatistics(); // Stored in microseconds ! private String name; private Double geomMean = null; + public int npoints = 0; public TickHandlerStats(String name){ @@ -21,6 +22,7 @@ public class TickHandlerStats implements ISerializable, Comparable{ public void addMeasure(long timing){ dstat.addValue((double)timing/1000.0); + npoints += 1; } public double getGeometricMean(){ diff --git a/mcp/mobius/opis/data/managers/EntityManager.java b/mcp/mobius/opis/data/managers/EntityManager.java index 2869b2b..94eefcc 100644 --- a/mcp/mobius/opis/data/managers/EntityManager.java +++ b/mcp/mobius/opis/data/managers/EntityManager.java @@ -142,7 +142,7 @@ public class EntityManager { } /* Returns a hashmap with the entity name and amount of it on the server */ - public static HashMap getCumulativeEntities(){ + public static HashMap getCumulativeEntities(boolean showSubType){ HashMap entities = new HashMap(); for (int dim : DimensionManager.getIDs()){ @@ -152,7 +152,7 @@ public class EntityManager { for (int i = 0; i < world.loadedEntityList.size(); i++){ Entity ent = (Entity)world.loadedEntityList.get(i); //String name = ent.getClass().getName(); - String name = getEntityName(ent); + String name = getEntityName(ent, showSubType); if (!entities.containsKey(name)) entities.put(name, 0); @@ -254,7 +254,11 @@ public class EntityManager { } public static String getEntityName(Entity ent){ - if (ent instanceof EntityItem) + return getEntityName(ent, false); + } + + public static String getEntityName(Entity ent, boolean showSubType){ + if (ent instanceof EntityItem && !showSubType) return "Dropped Item"; if (ent instanceof EntityPlayerMP) diff --git a/mcp/mobius/opis/data/managers/TickHandlerManager.java b/mcp/mobius/opis/data/managers/TickHandlerManager.java index c604b7c..93a2165 100644 --- a/mcp/mobius/opis/data/managers/TickHandlerManager.java +++ b/mcp/mobius/opis/data/managers/TickHandlerManager.java @@ -1,5 +1,6 @@ package mcp.mobius.opis.data.managers; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -12,6 +13,21 @@ public class TickHandlerManager { public static HashMap startStats = new HashMap(); public static HashMap endStats = new HashMap(); + public static Class SingleIntervalHandlerReflect; + public static Field wrapped; + + static { + try{ + SingleIntervalHandlerReflect = Class.forName("cpw.mods.fml.common.SingleIntervalHandler"); + wrapped = SingleIntervalHandlerReflect.getDeclaredField("wrapped"); + wrapped.setAccessible(true); + + } catch (Exception e) { + + throw new RuntimeException(e); + + } + } public static void addHandlerStart(IScheduledTickHandler handler, long timing){ String name = getHandlerName(handler); @@ -35,6 +51,7 @@ public class TickHandlerManager { for (String key : startStats.keySet()){ totalStats.put(key, new TickHandlerStats(key)); totalStats.get(key).setGeometricMean(startStats.get(key).getGeometricMean() + endStats.get(key).getGeometricMean()); + totalStats.get(key).npoints = startStats.get(key).npoints + endStats.get(key).npoints; } ArrayList sortedStats = new ArrayList(totalStats.values()); @@ -46,9 +63,18 @@ public class TickHandlerManager { public static String getHandlerName(IScheduledTickHandler handler){ String name = handler.getLabel(); if (name == null || name.equals("")) - if (handler instanceof SingleIntervalHandler) + if (handler instanceof SingleIntervalHandler){ + try{ + Object ticker = wrapped.get(handler); + name = ticker.getClass().getName(); + } catch (Exception e) { + throw new RuntimeException(e); + } + + //name = ((SingleIntervalHandler)handler).wrapped.getClass().getName(); - name = ""; + name = ""; // This part should be done via reflection to get the handler name./opis + } else name = handler.getClass().getName(); diff --git a/mcp/mobius/opis/modOpis.java b/mcp/mobius/opis/modOpis.java index 30f53b5..d4a2cd3 100644 --- a/mcp/mobius/opis/modOpis.java +++ b/mcp/mobius/opis/modOpis.java @@ -55,7 +55,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.TickRegistry; import cpw.mods.fml.relauncher.Side; -@Mod(modid="Opis", name="Opis", version="1.1.3a_alpha") +@Mod(modid="Opis", name="Opis", version="1.1.4_dev_alpha") @NetworkMod(channels={"Opis", "Opis_Chunk"},clientSideRequired=false, serverSideRequired=false, connectionHandler=OpisConnectionHandler.class, packetHandler=OpisPacketHandler.class) public class modOpis { @@ -101,7 +101,7 @@ public class modOpis { } else { ProfilerRegistrar.registerProfilerTileEntity(new TileEntityProfiler()); ProfilerRegistrar.registerProfilerEntity(new EntityProfiler()); - //ProfilerRegistrar.registerProfilerTick(new TickHandlerProfiler()); + ProfilerRegistrar.registerProfilerTick(new TickHandlerProfiler()); } } @@ -127,7 +127,7 @@ public class modOpis { event.registerServerCommand(new CommandKill()); event.registerServerCommand(new CommandKillAll()); event.registerServerCommand(new CommandReset()); - //event.registerServerCommand(new CommandHandler()); + event.registerServerCommand(new CommandHandler()); //event.registerServerCommand(new CommandClientTest()); //event.registerServerCommand(new CommandClientStart());