diff --git a/mcp/mobius/opis/commands/CommandFrequency.java b/mcp/mobius/opis/commands/CommandFrequency.java index c826074..f7b89d1 100644 --- a/mcp/mobius/opis/commands/CommandFrequency.java +++ b/mcp/mobius/opis/commands/CommandFrequency.java @@ -1,12 +1,17 @@ package mcp.mobius.opis.commands; +import cpw.mods.fml.common.network.PacketDispatcher; +import cpw.mods.fml.common.network.Player; import mcp.mobius.opis.modOpis; 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.packet.Packet3Chat; import net.minecraft.server.MinecraftServer; import net.minecraft.server.dedicated.DedicatedServer; +import net.minecraft.util.ChatMessageComponent; public class CommandFrequency extends CommandBase { @@ -25,7 +30,9 @@ public class CommandFrequency extends CommandBase { if (astring.length < 1) return; try{ modOpis.profilerDelay = Integer.valueOf(astring[0]); - notifyAdmins(icommandsender, "Opis delay set to %s ticks.", new Object[] {astring[0]}); + if (icommandsender instanceof EntityPlayer) + PacketDispatcher.sendPacketToPlayer(new Packet3Chat(ChatMessageComponent.createFromText(String.format("\u00A7oOpis delay set to %s ticks.", astring[0]))), (Player)icommandsender); + } catch (Exception e){} } diff --git a/mcp/mobius/opis/commands/CommandStart.java b/mcp/mobius/opis/commands/CommandStart.java index 931e523..b289ccf 100644 --- a/mcp/mobius/opis/commands/CommandStart.java +++ b/mcp/mobius/opis/commands/CommandStart.java @@ -1,6 +1,7 @@ package mcp.mobius.opis.commands; import cpw.mods.fml.common.network.PacketDispatcher; +import cpw.mods.fml.common.network.Player; import mcp.mobius.opis.modOpis; import mcp.mobius.opis.data.EntityManager; import mcp.mobius.opis.data.EntityProfiler; @@ -9,6 +10,7 @@ import mcp.mobius.opis.data.TileEntityProfiler; import mcp.mobius.opis.server.OpisServerTickHandler; 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.packet.Packet3Chat; @@ -41,8 +43,11 @@ public class CommandStart extends CommandBase { ProfilerRegistrar.registerProfilerTileEntity(new TileEntityProfiler()); ProfilerRegistrar.registerProfilerEntity(new EntityProfiler()); - PacketDispatcher.sendPacketToAllPlayers(new Packet3Chat(ChatMessageComponent.createFromText(String.format("\u00A7oOpis started with a tick delay %s.", modOpis.profilerDelay)))); - //notifyAdmins(icommandsender, "Opis started with a tick delay %s.", new Object[] {modOpis.profilerDelay}); + 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); + } + } @Override diff --git a/mcp/mobius/opis/commands/CommandStop.java b/mcp/mobius/opis/commands/CommandStop.java index 3561b71..057338d 100644 --- a/mcp/mobius/opis/commands/CommandStop.java +++ b/mcp/mobius/opis/commands/CommandStop.java @@ -1,10 +1,13 @@ package mcp.mobius.opis.commands; import cpw.mods.fml.common.network.PacketDispatcher; +import cpw.mods.fml.common.network.Player; import mcp.mobius.mobiuscore.profiler.DummyProfiler; import mcp.mobius.opis.modOpis; +import mcp.mobius.opis.server.OpisServerTickHandler; 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.packet.Packet3Chat; @@ -31,9 +34,12 @@ public class CommandStop extends CommandBase { ProfilerRegistrar.registerProfilerTileEntity(new DummyProfiler()); ProfilerRegistrar.registerProfilerEntity(new DummyProfiler()); + + if (icommandsender instanceof EntityPlayer) + OpisServerTickHandler.instance.players.add((EntityPlayer)icommandsender); - PacketDispatcher.sendPacketToAllPlayers(new Packet3Chat(ChatMessageComponent.createFromText(String.format("\u00A7oOpis stopped.")))); - //notifyAdmins(icommandsender, "Opis stopped.", new Object[] {}); + for (EntityPlayer player : OpisServerTickHandler.instance.players) + PacketDispatcher.sendPacketToPlayer(new Packet3Chat(ChatMessageComponent.createFromText(String.format("\u00A7oOpis stopped."))), (Player)player); } @Override diff --git a/mcp/mobius/opis/commands/CommandTicks.java b/mcp/mobius/opis/commands/CommandTicks.java index d442d03..d300bd0 100644 --- a/mcp/mobius/opis/commands/CommandTicks.java +++ b/mcp/mobius/opis/commands/CommandTicks.java @@ -1,12 +1,17 @@ package mcp.mobius.opis.commands; +import cpw.mods.fml.common.network.PacketDispatcher; +import cpw.mods.fml.common.network.Player; import mcp.mobius.opis.modOpis; 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.packet.Packet3Chat; import net.minecraft.server.MinecraftServer; import net.minecraft.server.dedicated.DedicatedServer; +import net.minecraft.util.ChatMessageComponent; public class CommandTicks extends CommandBase { @@ -25,7 +30,9 @@ public class CommandTicks extends CommandBase { if (astring.length < 1) return; try{ modOpis.profilerMaxTicks = Integer.valueOf(astring[0]); - notifyAdmins(icommandsender, "Opis ticks set to %s ticks.", new Object[] {astring[0]}); + + if (icommandsender instanceof EntityPlayer) + PacketDispatcher.sendPacketToPlayer(new Packet3Chat(ChatMessageComponent.createFromText(String.format("\u00A7oOpis ticks set to %s ticks.", astring[0]))), (Player)icommandsender); } catch (Exception e){} } diff --git a/mcp/mobius/opis/server/OpisServerTickHandler.java b/mcp/mobius/opis/server/OpisServerTickHandler.java index 9a9ab43..e2c52fd 100644 --- a/mcp/mobius/opis/server/OpisServerTickHandler.java +++ b/mcp/mobius/opis/server/OpisServerTickHandler.java @@ -1,7 +1,11 @@ package mcp.mobius.opis.server; +import java.util.ArrayList; import java.util.EnumSet; +import java.util.HashSet; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.network.packet.Packet3Chat; import net.minecraft.util.ChatMessageComponent; import mcp.mobius.opis.modOpis; @@ -22,6 +26,8 @@ public class OpisServerTickHandler implements ITickHandler { public long profilerUpdateTickCounter = 0; public long clientUpdateTickCounter = 0; public long profilerRunningTicks; + public HashSet players = new HashSet(); + public static OpisServerTickHandler instance; @@ -50,8 +56,12 @@ public class OpisServerTickHandler implements ITickHandler { profilerRunningTicks = 0; modOpis.profilerRun = false; ProfilerRegistrar.registerProfilerTileEntity(new DummyProfiler()); - ProfilerRegistrar.registerProfilerEntity(new DummyProfiler()); - PacketDispatcher.sendPacketToAllPlayers(new Packet3Chat(ChatMessageComponent.createFromText(String.format("\u00A7oOpis automaticly stopped after %d ticks.", modOpis.profilerMaxTicks)))); + ProfilerRegistrar.registerProfilerEntity(new DummyProfiler()); + + for (EntityPlayer player : players) + PacketDispatcher.sendPacketToPlayer(new Packet3Chat(ChatMessageComponent.createFromText(String.format("\u00A7oOpis automaticly stopped after %d ticks.", modOpis.profilerMaxTicks))), (Player)player); + + players.clear(); } } }