mirror of
https://github.com/GTNewHorizons/Opis.git
synced 2026-11-22 21:20:04 +00:00
Fixed commands
Fixed TickHandler Fixed other things Added a all param to the getnent Bumped version
This commit is contained in:
1 parent
79332530d5
commit
8a2c5acfe0
22 files changed
+182
-38
No files matched your search
@@ -2,5 +2,5 @@ package mcp.mobius.opis.commands;
|
||||
|
||||
public interface IOpisCommand {
|
||||
String getDescription();
|
||||
String getCommandName();
|
||||
String getCommandNameOpis();
|
||||
}
|
||||
@@ -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<String, Integer> ents = EntityManager.getCumulativeEntities();
|
||||
HashMap<String, Integer> 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 "";
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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<TickHandlerStats> 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 "";
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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(){
|
||||
|
||||
@@ -142,7 +142,7 @@ public class EntityManager {
|
||||
}
|
||||
|
||||
/* Returns a hashmap with the entity name and amount of it on the server */
|
||||
public static HashMap<String, Integer> getCumulativeEntities(){
|
||||
public static HashMap<String, Integer> getCumulativeEntities(boolean showSubType){
|
||||
HashMap<String, Integer> entities = new HashMap<String, Integer>();
|
||||
|
||||
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)
|
||||
|
||||
@@ -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<String, TickHandlerStats> startStats = new HashMap<String, TickHandlerStats>();
|
||||
public static HashMap<String, TickHandlerStats> endStats = new HashMap<String, TickHandlerStats>();
|
||||
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<TickHandlerStats> 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 = "<Unnamed SingleIntervalHandler>";
|
||||
name = "<Unnamed SingleIntervalHandler>"; // This part should be done via reflection to get the handler name./opis
|
||||
}
|
||||
else
|
||||
name = handler.getClass().getName();
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in new issue
Block a user