All commands are now console compatible.

This commit is contained in:
ProfMobius committed 2014-02-04 17:45:59 +01:00
1 parent e036fa8802
commit d3b9852d94
14 files changed
+80 -46

No files matched your search

@@ -7,10 +7,13 @@ import mcp.mobius.opis.data.managers.EntityManager;
import mcp.mobius.opis.network.server.Packet_DataScreenAmountEntities;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.MemoryConnection;
import net.minecraft.network.rcon.RConConsoleSource;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraft.util.ChatMessageComponent;
public class CommandAmountEntities extends CommandBase implements IOpisCommand{
@@ -27,7 +30,13 @@ public class CommandAmountEntities extends CommandBase implements IOpisCommand{
@Override
public void processCommand(ICommandSender icommandsender, String[] astring) {
HashMap<String, Integer> ents = EntityManager.getCumulativeEntities();
((EntityPlayerMP)icommandsender).playerNetServerHandler.sendPacketToPlayer(Packet_DataScreenAmountEntities.create(ents));
if (icommandsender instanceof EntityPlayer)
((EntityPlayerMP)icommandsender).playerNetServerHandler.sendPacketToPlayer(Packet_DataScreenAmountEntities.create(ents));
else if (icommandsender instanceof DedicatedServer){
for (String s : ents.keySet())
icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(String.format("%s : %s", s, ents.get(s))));
}
}
@@ -40,7 +49,7 @@ public class CommandAmountEntities extends CommandBase implements IOpisCommand{
@Override
public boolean canCommandSenderUseCommand(ICommandSender sender)
{
if (sender instanceof DedicatedServer) return false;
if (sender instanceof DedicatedServer) return true;
if (((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true;
return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(((EntityPlayerMP)sender).username);
}
@@ -8,10 +8,12 @@ import mcp.mobius.opis.data.managers.ChunkManager;
import mcp.mobius.opis.network.server.Packet_ChunkTopList;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
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 CommandChunkList extends CommandBase implements IOpisCommand {
@@ -42,8 +44,14 @@ public class CommandChunkList extends CommandBase implements IOpisCommand {
System.out.printf("%s\n", stat);
}
*/
((EntityPlayerMP)icommandsender).playerNetServerHandler.sendPacketToPlayer(Packet_ChunkTopList.create(chunks));
if (icommandsender instanceof EntityPlayer)
((EntityPlayerMP)icommandsender).playerNetServerHandler.sendPacketToPlayer(Packet_ChunkTopList.create(chunks));
else if (icommandsender instanceof DedicatedServer){
icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText("[DIM X Z] Time NTEs"));
for (ChunkStats stat : chunks){
icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(stat.toString()));
}
}
}
@@ -56,7 +64,7 @@ public class CommandChunkList extends CommandBase implements IOpisCommand {
@Override
public boolean canCommandSenderUseCommand(ICommandSender sender)
{
if (sender instanceof DedicatedServer) return false;
if (sender instanceof DedicatedServer) return true;
if (((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true;
return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(((EntityPlayerMP)sender).username);
}
@@ -31,8 +31,7 @@ public class CommandFrequency extends CommandBase implements IOpisCommand {
if (astring.length < 1) return;
try{
modOpis.profilerDelay = Integer.valueOf(astring[0]);
if (icommandsender instanceof EntityPlayer)
PacketDispatcher.sendPacketToPlayer(new Packet3Chat(ChatMessageComponent.createFromText(String.format("\u00A7oOpis delay set to %s ticks.", astring[0]))), (Player)icommandsender);
icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(String.format("\u00A7oOpis delay set to %s ticks.", astring[0])));
} catch (Exception e){}
}
@@ -46,14 +46,11 @@ public class CommandHelp extends CommandBase implements IOpisCommand {
new CommandKill(),
new CommandKillAll(),
new CommandHandler()
//new CommandHandler()
};
if (icommandsender instanceof EntityPlayer)
for (IOpisCommand cmd : commands)
PacketDispatcher.sendPacketToPlayer(new Packet3Chat(ChatMessageComponent.createFromText(String.format("/%s : %s", cmd.getCommandName(), cmd.getDescription()))), (Player)icommandsender);
for (IOpisCommand cmd : commands)
icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(String.format("/%s : %s", cmd.getCommandName(), cmd.getDescription())));
}
@Override
@@ -65,7 +62,6 @@ public class CommandHelp extends CommandBase implements IOpisCommand {
@Override
public boolean canCommandSenderUseCommand(ICommandSender sender)
{
if (sender instanceof DedicatedServer) return false;
return true;
}
@@ -35,24 +35,18 @@ public class CommandKill extends CommandBase implements IOpisCommand {
World world = DimensionManager.getWorld(dim);
if (world == null){
PacketDispatcher.sendPacketToPlayer(
new Packet3Chat(ChatMessageComponent.createFromText(String.format("\u00A7oCannot find dim %d in world %d", dim))),
(Player)icommandsender);
icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(String.format("\u00A7oCannot find dim %d in world %d", dim)));
return;
}
Entity entity = world.getEntityByID(eid);
if (entity == null) {
PacketDispatcher.sendPacketToPlayer(
new Packet3Chat(ChatMessageComponent.createFromText(String.format("\u00A7oCannot find entity %d in dim %d", eid, dim))),
(Player)icommandsender);
icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(String.format("\u00A7oCannot find entity %d in dim %d", eid, dim)));
return;
}
entity.setDead();
PacketDispatcher.sendPacketToPlayer(
new Packet3Chat(ChatMessageComponent.createFromText(String.format("\u00A7oKilled entity %d in dim %d", eid, dim))),
(Player)icommandsender);
icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(String.format("\u00A7oKilled entity %d in dim %d", eid, dim)));
return;
}
@@ -65,7 +59,7 @@ public class CommandKill extends CommandBase implements IOpisCommand {
@Override
public boolean canCommandSenderUseCommand(ICommandSender sender)
{
if (sender instanceof DedicatedServer) return false;
if (sender instanceof DedicatedServer) return true;
if (((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true;
return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(((EntityPlayerMP)sender).username);
}
@@ -39,8 +39,7 @@ public class CommandKillAll extends CommandBase implements IOpisCommand {
int nkilled = 0;
if (searchname.equals("Player")){
if (icommandsender instanceof EntityPlayer)
PacketDispatcher.sendPacketToPlayer(new Packet3Chat(ChatMessageComponent.createFromText(String.format("\u00A7oSeriously ? I can't, seriously, I can't. I should remove you from the OP list !"))), (Player)icommandsender);
icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(String.format("\u00A7oSeriously ? I can't, seriously, I can't. I should remove you from the OP list !")));
return;
}
@@ -61,7 +60,7 @@ public class CommandKillAll extends CommandBase implements IOpisCommand {
}
if (icommandsender instanceof EntityPlayer)
PacketDispatcher.sendPacketToPlayer(new Packet3Chat(ChatMessageComponent.createFromText(String.format("\u00A7oKilled %d entities of type %s", nkilled, searchname))), (Player)icommandsender);
icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(String.format("\u00A7oKilled %d entities of type %s", nkilled, searchname)));
/*
World world = DimensionManager.getWorld(dim);
@@ -97,7 +96,7 @@ public class CommandKillAll extends CommandBase implements IOpisCommand {
@Override
public boolean canCommandSenderUseCommand(ICommandSender sender)
{
if (sender instanceof DedicatedServer) return false;
if (sender instanceof DedicatedServer) return true;
if (((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true;
return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(((EntityPlayerMP)sender).username);
}
@@ -8,10 +8,12 @@ import mcp.mobius.opis.data.managers.TileEntityManager;
import mcp.mobius.opis.network.server.Packet_ModMeanTime;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
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 CommandMeanModTime extends CommandBase implements IOpisCommand {
@@ -28,7 +30,17 @@ public class CommandMeanModTime extends CommandBase implements IOpisCommand {
@Override
public void processCommand(ICommandSender icommandsender, String[] astring) {
ArrayList<ModStats> modStats = TileEntityManager.getModStats();
((EntityPlayerMP)icommandsender).playerNetServerHandler.sendPacketToPlayer(Packet_ModMeanTime.create(modStats));
if (icommandsender instanceof EntityPlayer)
((EntityPlayerMP)icommandsender).playerNetServerHandler.sendPacketToPlayer(Packet_ModMeanTime.create(modStats));
else if (icommandsender instanceof DedicatedServer){
icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText("[Name] NTEs MeanTime"));
for (ModStats stat : modStats){
icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(
String.format("[ %s ] %3d %.2f", stat.getModID(), stat.ntes, stat.dstat.getMean())));
}
}
}
@Override
@@ -38,8 +38,7 @@ public class CommandReset extends CommandBase implements IOpisCommand {
public void processCommand(ICommandSender icommandsender, String[] astring) {
MetaManager.reset();
if (icommandsender instanceof EntityPlayer)
PacketDispatcher.sendPacketToPlayer(new Packet3Chat(ChatMessageComponent.createFromText(String.format("\u00A7oInternal data reseted."))), (Player)icommandsender);
icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(String.format("\u00A7oInternal data reseted.")));
PacketDispatcher.sendPacketToAllPlayers(Packet_ClearSelection.create());
//notifyAdmins(icommandsender, "Opis started with a tick delay %s.", new Object[] {modOpis.profilerDelay});
@@ -41,10 +41,9 @@ public class CommandStart extends CommandBase implements IOpisCommand {
modOpis.profilerRun = true;
ProfilerRegistrar.turnOn();
if (icommandsender instanceof EntityPlayer){
if (icommandsender instanceof EntityPlayer)
OpisServerTickHandler.instance.players.add((EntityPlayer)icommandsender);
PacketDispatcher.sendPacketToPlayer(new Packet3Chat(ChatMessageComponent.createFromText(String.format("\u00A7oOpis started with a tick delay %s.", modOpis.profilerDelay))), (Player)icommandsender);
}
icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(String.format("\u00A7oOpis started with a tick delay %s.", modOpis.profilerDelay)));
}
@@ -38,7 +38,10 @@ public class CommandStop extends CommandBase implements IOpisCommand {
OpisServerTickHandler.instance.players.add((EntityPlayer)icommandsender);
for (EntityPlayer player : OpisServerTickHandler.instance.players)
PacketDispatcher.sendPacketToPlayer(new Packet3Chat(ChatMessageComponent.createFromText(String.format("\u00A7oOpis stopped."))), (Player)player);
PacketDispatcher.sendPacketToPlayer(new Packet3Chat(ChatMessageComponent.createFromText(String.format("\u00A7oOpis stopped."))), (Player)player);
if (icommandsender instanceof DedicatedServer)
icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(String.format("\u00A7oOpis stopped.")));
}
@Override
@@ -31,9 +31,8 @@ public class CommandTicks extends CommandBase implements IOpisCommand {
if (astring.length < 1) return;
try{
modOpis.profilerMaxTicks = Integer.valueOf(astring[0]);
if (icommandsender instanceof EntityPlayer)
PacketDispatcher.sendPacketToPlayer(new Packet3Chat(ChatMessageComponent.createFromText(String.format("\u00A7oOpis ticks set to %s ticks.", astring[0]))), (Player)icommandsender);
icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(String.format("\u00A7oOpis ticks set to %s ticks.", astring[0])));
} catch (Exception e){}
}
@@ -10,10 +10,12 @@ import mcp.mobius.opis.data.managers.EntityManager;
import mcp.mobius.opis.network.server.Packet_DataScreenTimingEntities;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
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 CommandTimingEntities extends CommandBase implements IOpisCommand {
@@ -39,7 +41,14 @@ public class CommandTimingEntities extends CommandBase implements IOpisCommand {
} catch (Exception e) {return;}
}
((EntityPlayerMP)icommandsender).playerNetServerHandler.sendPacketToPlayer(Packet_DataScreenTimingEntities.create(ents));
if (icommandsender instanceof EntityPlayer)
((EntityPlayerMP)icommandsender).playerNetServerHandler.sendPacketToPlayer(Packet_DataScreenTimingEntities.create(ents));
else if (icommandsender instanceof DedicatedServer){
icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText("[DIM X Z] Time NTEs"));
for (EntityStats stat : ents){
icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(stat.toString()));
}
}
}
@@ -52,7 +61,7 @@ public class CommandTimingEntities extends CommandBase implements IOpisCommand {
@Override
public boolean canCommandSenderUseCommand(ICommandSender sender)
{
if (sender instanceof DedicatedServer) return false;
if (sender instanceof DedicatedServer) return true;
if (((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true;
return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(((EntityPlayerMP)sender).username);
}
@@ -8,10 +8,12 @@ import mcp.mobius.opis.data.managers.TileEntityManager;
import mcp.mobius.opis.network.server.Packet_TileEntitiesTopList;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
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 CommandTimingTileEntities extends CommandBase implements IOpisCommand {
@@ -37,7 +39,13 @@ public class CommandTimingTileEntities extends CommandBase implements IOpisComma
} catch (Exception e) {return;}
}
((EntityPlayerMP)icommandsender).playerNetServerHandler.sendPacketToPlayer(Packet_TileEntitiesTopList.create(tes));
if (icommandsender instanceof EntityPlayer)
((EntityPlayerMP)icommandsender).playerNetServerHandler.sendPacketToPlayer(Packet_TileEntitiesTopList.create(tes));
else if (icommandsender instanceof DedicatedServer){
for (TileEntityStats stat : tes){
icommandsender.sendChatToPlayer(ChatMessageComponent.createFromText(stat.toString()));
}
}
}
@@ -50,7 +58,7 @@ public class CommandTimingTileEntities extends CommandBase implements IOpisComma
@Override
public boolean canCommandSenderUseCommand(ICommandSender sender)
{
if (sender instanceof DedicatedServer) return false;
if (sender instanceof DedicatedServer) return true;
if (((EntityPlayerMP)sender).playerNetServerHandler.netManager instanceof MemoryConnection) return true;
return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(((EntityPlayerMP)sender).username);
}
+4 -4
View File
@@ -127,11 +127,11 @@ 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());
event.registerServerCommand(new CommandClientShowRenderTick());
//event.registerServerCommand(new CommandClientTest());
//event.registerServerCommand(new CommandClientStart());
//event.registerServerCommand(new CommandClientShowRenderTick());
event.registerServerCommand(new CommandHelp());