Both OP list and priviliged list are now used to determined who can run what.

This commit is contained in:
ProfMobius committed 2014-03-20 17:05:40 +01:00
1 parent aadf0f736f
commit 3628b4b09d
18 files changed
+69 -28

No files matched your search

@@ -8,6 +8,7 @@ import mcp.mobius.opis.data.holders.basetypes.AmountHolder;
import mcp.mobius.opis.data.managers.EntityManager;
import mcp.mobius.opis.network.enums.DataReq;
import mcp.mobius.opis.network.server.Packet_DataList;
import mcp.mobius.opis.server.PlayerTracker;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
@@ -65,7 +66,7 @@ public class CommandAmountEntities extends CommandBase implements IOpisCommand{
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);
return PlayerTracker.instance().isOp(((EntityPlayerMP)sender).username);
}
@Override
@@ -7,6 +7,7 @@ import mcp.mobius.opis.data.holders.stats.StatsChunk;
import mcp.mobius.opis.data.managers.ChunkManager;
import mcp.mobius.opis.network.enums.DataReq;
import mcp.mobius.opis.network.server.Packet_DataList;
import mcp.mobius.opis.server.PlayerTracker;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
@@ -73,7 +74,7 @@ public class CommandChunkList extends CommandBase implements IOpisCommand {
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);
return PlayerTracker.instance().isOp(((EntityPlayerMP)sender).username);
}
@Override
@@ -13,6 +13,7 @@ import mcp.mobius.opis.commands.IOpisCommand;
import mcp.mobius.opis.data.holders.stats.StatsMod;
import mcp.mobius.opis.data.holders.stats.StatsTileEntity;
import mcp.mobius.opis.data.managers.TileEntityManager;
import mcp.mobius.opis.server.PlayerTracker;
import mcp.mobius.opis.tools.ModIdentification;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
@@ -141,7 +142,7 @@ public class CommandDataDump extends CommandBase implements IOpisCommand {
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);
return PlayerTracker.instance().isOp(((EntityPlayerMP)sender).username);
}
@Override
@@ -1,6 +1,7 @@
package mcp.mobius.opis.commands.server;
import mcp.mobius.opis.server.OpisServerEventHandler;
import mcp.mobius.opis.server.PlayerTracker;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -48,7 +49,7 @@ public class CommandEntityCreate extends CommandBase {
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);
return PlayerTracker.instance().isOp(((EntityPlayerMP)sender).username);
}
}
@@ -4,6 +4,7 @@ import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
import mcp.mobius.opis.modOpis;
import mcp.mobius.opis.commands.IOpisCommand;
import mcp.mobius.opis.server.PlayerTracker;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
@@ -53,7 +54,7 @@ public class CommandFrequency extends CommandBase implements IOpisCommand {
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);
return PlayerTracker.instance().isOp(((EntityPlayerMP)sender).username);
}
@Override
@@ -9,6 +9,7 @@ import mcp.mobius.opis.data.holders.stats.StatsTickHandler;
import mcp.mobius.opis.data.managers.TickHandlerManager;
import mcp.mobius.opis.network.enums.DataReq;
import mcp.mobius.opis.network.server.Packet_DataList;
import mcp.mobius.opis.server.PlayerTracker;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -60,7 +61,7 @@ public class CommandHandler extends CommandBase implements IOpisCommand {
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);
return PlayerTracker.instance().isOp(((EntityPlayerMP)sender).username);
}
@Override
@@ -3,6 +3,7 @@ package mcp.mobius.opis.commands.server;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
import mcp.mobius.opis.commands.IOpisCommand;
import mcp.mobius.opis.server.PlayerTracker;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.Entity;
@@ -67,7 +68,7 @@ public class CommandKill extends CommandBase implements IOpisCommand {
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);
return PlayerTracker.instance().isOp(((EntityPlayerMP)sender).username);
}
@Override
@@ -8,6 +8,7 @@ import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
import mcp.mobius.opis.commands.IOpisCommand;
import mcp.mobius.opis.data.managers.EntityManager;
import mcp.mobius.opis.server.PlayerTracker;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.Entity;
@@ -90,7 +91,7 @@ public class CommandKillAll extends CommandBase implements IOpisCommand {
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);
return PlayerTracker.instance().isOp(((EntityPlayerMP)sender).username);
}
@Override
@@ -6,6 +6,7 @@ import mcp.mobius.opis.commands.IOpisCommand;
import mcp.mobius.opis.data.holders.stats.StatsMod;
import mcp.mobius.opis.data.managers.TileEntityManager;
import mcp.mobius.opis.network.server.Packet_ModMeanTime;
import mcp.mobius.opis.server.PlayerTracker;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
@@ -60,7 +61,7 @@ public class CommandMeanModTime extends CommandBase implements IOpisCommand {
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);
return PlayerTracker.instance().isOp(((EntityPlayerMP)sender).username);
}
@Override
@@ -13,6 +13,7 @@ import mcp.mobius.opis.data.managers.TileEntityManager;
import mcp.mobius.opis.network.enums.ClientCommand;
import mcp.mobius.opis.network.server.Packet_ClientCommand;
import mcp.mobius.opis.server.OpisServerTickHandler;
import mcp.mobius.opis.server.PlayerTracker;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
@@ -61,7 +62,7 @@ public class CommandReset extends CommandBase implements IOpisCommand {
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);
return PlayerTracker.instance().isOp(((EntityPlayerMP)sender).username);
}
@Override
@@ -65,7 +65,7 @@ public class CommandStart extends CommandBase implements IOpisCommand {
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);
return PlayerTracker.instance().isOp(((EntityPlayerMP)sender).username);
}
@Override
@@ -62,7 +62,7 @@ public class CommandStop extends CommandBase implements IOpisCommand {
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);
return PlayerTracker.instance().isOp(((EntityPlayerMP)sender).username);
}
@Override
@@ -4,6 +4,7 @@ import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
import mcp.mobius.opis.modOpis;
import mcp.mobius.opis.commands.IOpisCommand;
import mcp.mobius.opis.server.PlayerTracker;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
@@ -53,7 +54,7 @@ public class CommandTicks extends CommandBase implements IOpisCommand {
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);
return PlayerTracker.instance().isOp(((EntityPlayerMP)sender).username);
}
@Override
@@ -9,6 +9,7 @@ import mcp.mobius.opis.data.holders.stats.StatsEntity;
import mcp.mobius.opis.data.managers.EntityManager;
import mcp.mobius.opis.network.enums.DataReq;
import mcp.mobius.opis.network.server.Packet_DataList;
import mcp.mobius.opis.server.PlayerTracker;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
@@ -70,7 +71,7 @@ public class CommandTimingEntities extends CommandBase implements IOpisCommand {
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);
return PlayerTracker.instance().isOp(((EntityPlayerMP)sender).username);
}
@Override
@@ -7,6 +7,7 @@ import mcp.mobius.opis.data.holders.stats.StatsTileEntity;
import mcp.mobius.opis.data.managers.TileEntityManager;
import mcp.mobius.opis.network.enums.DataReq;
import mcp.mobius.opis.network.server.Packet_DataList;
import mcp.mobius.opis.server.PlayerTracker;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
@@ -67,7 +68,7 @@ public class CommandTimingTileEntities extends CommandBase implements IOpisComma
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);
return PlayerTracker.instance().isOp(((EntityPlayerMP)sender).username);
}
@Override
+3
View File
@@ -89,6 +89,9 @@ public class modOpis {
profilerDelay = config.get(Configuration.CATEGORY_GENERAL, "profiler.delay", 1).getInt();
profilerMaxTicks = config.get(Configuration.CATEGORY_GENERAL, "profiler.maxpts", 250).getInt();
microseconds = config.get(Configuration.CATEGORY_GENERAL, "display.microseconds", true).getBoolean(true);
String[] users = config.get(Configuration.CATEGORY_GENERAL, "privileged", new String[]{}).getStringList();
for (String s : users)
PlayerTracker.instance().addPrivilegedPlayer(s,false);
config.save();
@@ -179,7 +179,7 @@ public class OpisPacketHandler implements IPacketHandler {
void onPacketToServer(INetworkManager manager, Packet250CustomPayload packet, Player player, Byte header) {
if (header == Packets.REQ_CHUNKS){
Packet_ReqChunks castedPacket = new Packet_ReqChunks(packet);
if (this.isOp(player)){
if (PlayerTracker.instance().isOp(player)){
ArrayList<Chunk> list = new ArrayList();
World world = DimensionManager.getWorld(castedPacket.dim);
@@ -203,7 +203,7 @@ public class OpisPacketHandler implements IPacketHandler {
else if (header == Packets.REQ_DATA){
Packet_ReqData castedPacket = new Packet_ReqData(packet);
if (this.isOp(player)){
if (PlayerTracker.instance().isOp(player)){
DataReqHandler.instance().handle(castedPacket.maintype, castedPacket.subtype, castedPacket.target, castedPacket.param1, castedPacket.param2, player);
}
}
@@ -220,8 +220,6 @@ public class OpisPacketHandler implements IPacketHandler {
}
}
public boolean isOp(Player player){
return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(((EntityPlayerMP)player).username) || MinecraftServer.getServer().isSinglePlayer();
}
}
+35 -8
View File
@@ -3,8 +3,12 @@ package mcp.mobius.opis.server;
import java.util.HashMap;
import java.util.HashSet;
import mcp.mobius.opis.modOpis;
import mcp.mobius.opis.overlay.OverlayStatus;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.common.Configuration;
import cpw.mods.fml.common.IPlayerTracker;
import cpw.mods.fml.common.network.Player;
@@ -18,21 +22,44 @@ public class PlayerTracker implements IPlayerTracker{
public HashMap<String, Boolean> filteredAmount = new HashMap<String, Boolean>(); //Should the entity amount be filtered or not
public HashMap<Player, OverlayStatus> playerOverlayStatus = new HashMap<Player, OverlayStatus>();
public HashMap<Player, Integer> playerDimension = new HashMap<Player, Integer>();
private HashSet<String> playerPriviliged = new HashSet<String>();
private HashSet<String> playerPrivileged = new HashSet<String>();
public void addPriviligedPlayer(String name){
this.playerPriviliged.add(name);
public void addPrivilegedPlayer(String name, boolean save){
this.playerPrivileged.add(name);
if (save){
modOpis.instance.config.get(Configuration.CATEGORY_GENERAL, "privileged", new String[]{}).set((String[])playerPrivileged.toArray());
modOpis.instance.config.save();
}
}
public void rmPriviligedPlayer(String name){
this.playerPriviliged.remove(name);
public void addPrivilegedPlayer(String name){
this.addPrivilegedPlayer(name, true);
}
public boolean isPlayerPriviliged(String name){
return this.playerPriviliged.contains(name);
public void rmPrivilegedPlayer(String name){
this.playerPrivileged.remove(name);
modOpis.instance.config.get(Configuration.CATEGORY_GENERAL, "privileged", new String[]{}).set((String[])playerPrivileged.toArray());
modOpis.instance.config.save();
}
public boolean isPlayerPrivileged(String name){
return this.playerPrivileged.contains(name);
}
public void reloeadPriviligedPlayers(){
String[] users = modOpis.instance.config.get(Configuration.CATEGORY_GENERAL, "privileged", new String[]{}).getStringList();
for (String s : users)
PlayerTracker.instance().addPrivilegedPlayer(s,false);
}
public boolean isOp(Player player){
return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(((EntityPlayerMP)player).username) || MinecraftServer.getServer().isSinglePlayer() || PlayerTracker.instance().isPlayerPrivileged(((EntityPlayerMP)player).username);
}
public boolean isOp(String name){
return MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(name) || MinecraftServer.getServer().isSinglePlayer() || PlayerTracker.instance().isPlayerPrivileged(name);
}
@Override
public void onPlayerLogin(EntityPlayer player) {
}