Cleanup
This commit is contained in:
parent
fa7c9cec5f
commit
efc89bbbb6
17 changed files with 27 additions and 137 deletions
|
@ -8,6 +8,8 @@ import dark.core.network.PacketManagerEffects;
|
|||
|
||||
public class CommonProxy
|
||||
{
|
||||
public static final int GUI_COAL_GEN = 0, GUI_FUEL_GEN = 1, GUI_FURNACE_ELEC = 2, GUI_BATTERY_BOX = 3;
|
||||
|
||||
public void preInit()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
|
|
@ -30,7 +30,7 @@ import cpw.mods.fml.common.network.Player;
|
|||
* @author DarkGuardsman */
|
||||
public class PacketHandler implements IPacketHandler, IPacketReceiver
|
||||
{
|
||||
public static PacketHandler instance;
|
||||
protected static PacketHandler instance;
|
||||
|
||||
public static HashMap<Integer, IPacketManager> packetTypes = new HashMap<Integer, IPacketManager>();
|
||||
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
package dark.core.prefab.access;
|
||||
|
||||
public enum AccessLevel
|
||||
{
|
||||
NONE("None"),
|
||||
BASIC("Basic"),
|
||||
USER("Standard"),
|
||||
ADMIN("Admin"),
|
||||
OWNER("Owner");
|
||||
|
||||
public String displayName;
|
||||
|
||||
private AccessLevel(String name)
|
||||
{
|
||||
displayName = name;
|
||||
}
|
||||
|
||||
/** Gets the access level in varies ways
|
||||
*
|
||||
* @return AccessLevel NONE instead of null if correct level can't be found. */
|
||||
public static AccessLevel get(Object ob)
|
||||
{
|
||||
if (ob instanceof String)
|
||||
{
|
||||
for (AccessLevel access : AccessLevel.values())
|
||||
{
|
||||
if (access.displayName.equalsIgnoreCase((String) ob) || access.name().equalsIgnoreCase((String) ob))
|
||||
{
|
||||
return access;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ob instanceof Integer)
|
||||
{
|
||||
int i = (Integer) ob;
|
||||
|
||||
if (i >= 0 && i < AccessLevel.values().length)
|
||||
{
|
||||
return AccessLevel.values()[i];
|
||||
}
|
||||
}
|
||||
|
||||
return NONE;
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import dark.api.AccessLevel;
|
||||
import dark.core.prefab.helpers.NBTFileLoader;
|
||||
|
||||
public class GlobalAccessManager
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
package dark.core.prefab.access;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** Used by any object that needs to restrict access to it by a set of usernames
|
||||
*
|
||||
* @author DarkGuardsman */
|
||||
public interface ISpecialAccess
|
||||
{
|
||||
/** Gets the player's access level on the machine he is using
|
||||
*
|
||||
* @return access level of the player, make sure to return no access if the player doesn't have
|
||||
* any */
|
||||
public AccessLevel getUserAccess(String username);
|
||||
|
||||
/** gets the access list for the machine
|
||||
*
|
||||
* @return hasMap of players and there access levels */
|
||||
public List<UserAccess> getUsers();
|
||||
|
||||
/** sets the players access level in the access map
|
||||
*
|
||||
* @param player
|
||||
* @return true if the level was set false if something went wrong */
|
||||
public boolean addUserAccess(String username, AccessLevel level, boolean save);
|
||||
|
||||
/** Removes the user from the access list
|
||||
*
|
||||
* @param username
|
||||
* @return */
|
||||
public boolean removeUserAccess(String username);
|
||||
|
||||
/** Gets a list of users with this specified access level.
|
||||
*
|
||||
* @param level
|
||||
* @return */
|
||||
List<UserAccess> getUsersWithAcess(AccessLevel level);
|
||||
|
||||
}
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import dark.api.AccessLevel;
|
||||
|
||||
public class UserAccess
|
||||
{
|
||||
|
|
|
@ -78,5 +78,4 @@ public abstract class BlockMachine extends BlockTile implements ITileEntityProvi
|
|||
return super.createTileEntity(world, metadata);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -83,6 +83,7 @@ public class TileEntityEnergyMachine extends TileEntityMachine implements IElect
|
|||
}
|
||||
|
||||
/** Does this tile have power to run and do work */
|
||||
@Override
|
||||
public boolean canFunction()
|
||||
{
|
||||
return !this.isDisabled() && (this.runPowerLess() || this.consumePower(this.WATTS_PER_TICK, false));
|
||||
|
|
|
@ -11,10 +11,10 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.prefab.tile.TileEntityAdvanced;
|
||||
import dark.api.AccessLevel;
|
||||
import dark.api.ISpecialAccess;
|
||||
import dark.core.interfaces.IExternalInv;
|
||||
import dark.core.interfaces.IInvBox;
|
||||
import dark.core.prefab.access.AccessLevel;
|
||||
import dark.core.prefab.access.ISpecialAccess;
|
||||
import dark.core.prefab.access.UserAccess;
|
||||
import dark.core.prefab.invgui.InvChest;
|
||||
|
||||
|
@ -25,6 +25,7 @@ public class TileEntityInv extends TileEntityAdvanced implements IExternalInv, I
|
|||
{
|
||||
protected IInvBox inventory;
|
||||
protected boolean lockInv;
|
||||
protected int invSlots = 1;
|
||||
/** A list of user access data. */
|
||||
protected final List<UserAccess> users = new ArrayList<UserAccess>();
|
||||
|
||||
|
@ -33,7 +34,7 @@ public class TileEntityInv extends TileEntityAdvanced implements IExternalInv, I
|
|||
{
|
||||
if (inventory == null)
|
||||
{
|
||||
inventory = new InvChest(this, 1);
|
||||
inventory = new InvChest(this, this.invSlots);
|
||||
}
|
||||
return inventory;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import dark.core.prefab.access.ISpecialAccess;
|
||||
import dark.api.ISpecialAccess;
|
||||
import dark.api.ITerminal;
|
||||
|
||||
public class CommandHelp extends TerminalCommand
|
||||
{
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import dark.api.ITerminal;
|
||||
|
||||
/** @author Calclavia, DarkGuardsman */
|
||||
public class CommandRegistry
|
||||
|
|
|
@ -4,8 +4,9 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import dark.core.prefab.access.AccessLevel;
|
||||
import dark.core.prefab.access.ISpecialAccess;
|
||||
import dark.api.AccessLevel;
|
||||
import dark.api.ISpecialAccess;
|
||||
import dark.api.ITerminal;
|
||||
|
||||
public class CommandUser extends TerminalCommand
|
||||
{
|
||||
|
|
|
@ -12,13 +12,11 @@ public abstract class ContainerTerminal extends Container
|
|||
public ContainerTerminal(InventoryPlayer inventoryPlayer, TileEntityTerminal tileEntity)
|
||||
{
|
||||
this.tileEntity = tileEntity;
|
||||
this.tileEntity.playersUsing.add(inventoryPlayer.player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
this.tileEntity.playersUsing.remove(par1EntityPlayer);
|
||||
super.onContainerClosed(par1EntityPlayer);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
package dark.core.prefab.terminal;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import dark.core.interfaces.IScroll;
|
||||
import dark.core.prefab.access.ISpecialAccess;
|
||||
|
||||
/** Basic methods to make it easier to construct or interact with a terminal based tile. Recommend to
|
||||
* be used by tiles that want to mimic computer command line like interfaces. As well to restrict
|
||||
* access to the tile in the same way a computer would
|
||||
*
|
||||
* @author DarkGuardsmsan */
|
||||
public interface ITerminal extends ISpecialAccess, IScroll
|
||||
{
|
||||
/** Gets an output of the string stored in the console. */
|
||||
public List<String> getTerminalOuput();
|
||||
|
||||
/** Adds a string to the console. Server side only. */
|
||||
public boolean addToConsole(String msg);
|
||||
}
|
|
@ -3,7 +3,8 @@ package dark.core.prefab.terminal;
|
|||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import dark.core.prefab.access.ISpecialAccess;
|
||||
import dark.api.ISpecialAccess;
|
||||
import dark.api.ITerminal;
|
||||
|
||||
/** @author Calclavia, DarkGuardsman */
|
||||
public abstract class TerminalCommand
|
||||
|
|
|
@ -3,31 +3,18 @@ package dark.core.prefab.terminal;
|
|||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import universalelectricity.prefab.network.IPacketReceiver;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import dark.api.ITerminal;
|
||||
import dark.core.network.PacketHandler;
|
||||
import dark.core.prefab.access.AccessLevel;
|
||||
import dark.core.prefab.access.ISpecialAccess;
|
||||
import dark.core.prefab.access.UserAccess;
|
||||
import dark.core.prefab.machine.TileEntityEnergyMachine;
|
||||
import dark.core.prefab.machine.TileEntityMachine.SimplePacketTypes;
|
||||
|
||||
/** @author Calclavia, DarkGuardsman */
|
||||
public abstract class TileEntityTerminal extends TileEntityEnergyMachine implements IPacketReceiver, ITerminal
|
||||
|
|
Loading…
Reference in a new issue