diff options
Diffstat (limited to 'src')
3 files changed, 44 insertions, 113 deletions
diff --git a/src/Java/gtPlusPlus/core/handler/events/UnbreakableBlockManager.java b/src/Java/gtPlusPlus/core/handler/events/UnbreakableBlockManager.java index 4abffed1bc..fcda57aa93 100644 --- a/src/Java/gtPlusPlus/core/handler/events/UnbreakableBlockManager.java +++ b/src/Java/gtPlusPlus/core/handler/events/UnbreakableBlockManager.java @@ -43,8 +43,6 @@ public class UnbreakableBlockManager{ int Z = ((BaseMetaTileEntity)mTileEntity).zCoord; Utils.LOG_WARNING("Grabbing TileEntity @ [x,y,z] |"+X+"|"+Y+"|"+Z+"|"); - - try{ GregtechMetaSafeBlock MetaSafeBlock = ((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()); TileEntity BaseMetaTileEntity = ((BaseMetaTileEntity)mTileEntity).getTileEntity(X, Y, Z); diff --git a/src/Java/gtPlusPlus/core/util/player/PlayerCache.java b/src/Java/gtPlusPlus/core/util/player/PlayerCache.java index 01845bcaeb..969de8dc08 100644 --- a/src/Java/gtPlusPlus/core/util/player/PlayerCache.java +++ b/src/Java/gtPlusPlus/core/util/player/PlayerCache.java @@ -5,10 +5,9 @@ import gtPlusPlus.core.util.Utils; import java.io.*; import java.util.*; -import java.util.Map.Entry; -import net.minecraft.client.Minecraft; -import net.minecraft.world.World; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.server.MinecraftServer; public class PlayerCache { @@ -48,7 +47,7 @@ public class PlayerCache { public static void appendParamChanges(String playerName, String playerUUIDasString) { HashMap<String, UUID> playerInfo = new HashMap<String, UUID>(); playerInfo.put(playerName, UUID.fromString(playerUUIDasString)); - + /*try { Utils.LOG_INFO("Attempting to load "+cache.getName()); properties.load(new FileInputStream(cache)); @@ -64,17 +63,17 @@ public class PlayerCache { } } */ - + try - { - FileOutputStream fos = new FileOutputStream("PlayerCache.dat"); - ObjectOutputStream oos = new ObjectOutputStream(fos); - oos.writeObject(playerInfo); - oos.close(); - fos.close(); - Utils.LOG_INFO("Serialized Player data saved in PlayerCache.dat"); - } - + { + FileOutputStream fos = new FileOutputStream("PlayerCache.dat"); + ObjectOutputStream oos = new ObjectOutputStream(fos); + oos.writeObject(playerInfo); + oos.close(); + fos.close(); + Utils.LOG_INFO("Serialized Player data saved in PlayerCache.dat"); + } + catch (IOException e) { Utils.LOG_INFO("No PlayerCache file found, creating one."); createPropertiesFile(playerName, playerUUIDasString); @@ -119,60 +118,36 @@ public class PlayerCache { public static HashMap<String, UUID> readPropertiesFileAsMap() { HashMap<String, UUID> map = null; - try - { - FileInputStream fis = new FileInputStream(cache); - ObjectInputStream ois = new ObjectInputStream(fis); - map = (HashMap<String, UUID>) ois.readObject(); - ois.close(); - fis.close(); - }catch(IOException ioe) - { - ioe.printStackTrace(); - return null; - }catch(ClassNotFoundException c) - { - Utils.LOG_INFO("Class not found"); - c.printStackTrace(); - return null; - } - Utils.LOG_WARNING("Deserialized PlayerCache.."); - return map; + try + { + FileInputStream fis = new FileInputStream(cache); + ObjectInputStream ois = new ObjectInputStream(fis); + map = (HashMap<String, UUID>) ois.readObject(); + ois.close(); + fis.close(); + }catch(IOException ioe) + { + ioe.printStackTrace(); + return null; + }catch(ClassNotFoundException c) + { + Utils.LOG_INFO("Class not found"); + c.printStackTrace(); + return null; + } + Utils.LOG_WARNING("Deserialized PlayerCache.."); + return map; } - public static String lookupPlayerByUUID(UUID UUID){ - - try { - World worldw = Minecraft.getMinecraft().thePlayer.worldObj; - //if (!worldw.isRemote){ - - - try { - Map<String, UUID> map = null; - try { - map = readPropertiesFileAsMap(); - } catch (Exception e) { - Utils.LOG_INFO("With "+e.getCause()+" as cause, Caught Exception: "+e.toString()); - //e.printStackTrace(); - } - for (Entry<String, UUID> entry : map.entrySet()) { - if (Objects.equals(UUID, entry.getValue())) { - return entry.getKey(); - } - } - return null; - } catch (NullPointerException e) { - Utils.LOG_INFO("With "+e.getCause()+" as cause, Caught Exception: "+e.toString()); - //e.printStackTrace(); - } - - - //} - - - } catch (Throwable r){ - Utils.LOG_INFO("With "+r.getCause()+" as cause, Caught Exception: "+r.toString()); + public static String lookupPlayerByUUID(UUID UUID){ + if (UUID == null) + return null; + List<EntityPlayerMP> allPlayers = MinecraftServer.getServer().getConfigurationManager().playerEntityList; + for (EntityPlayerMP player : allPlayers) { + if (player.getUniqueID().equals(UUID)) { + return player.getDisplayName(); + } } - return null; + return "Offline Player."; } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java index 05661df905..8f0fc9cb35 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/machines/GregtechMetaSafeBlockBase.java @@ -7,7 +7,6 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.handler.events.UnbreakableBlockManager; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.player.PlayerCache; import gtPlusPlus.core.util.player.PlayerUtils; @@ -22,7 +21,7 @@ public abstract class GregtechMetaSafeBlockBase extends GT_MetaTileEntity_Tiered public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false, bUnbreakable = false; public int mSuccess = 0, mTargetStackSize = 0; public UUID ownerUUID; - UnbreakableBlockManager Xasda = new UnbreakableBlockManager(); + //UnbreakableBlockManager Xasda = new UnbreakableBlockManager(); private boolean value_last = false, value_current = false; public GregtechMetaSafeBlockBase(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription) { @@ -249,6 +248,7 @@ public abstract class GregtechMetaSafeBlockBase extends GT_MetaTileEntity_Tiered aNBT.setBoolean("bOutput", bOutput); aNBT.setBoolean("bRedstoneIfFull", bRedstoneIfFull); aNBT.setInteger("mTargetStackSize", mTargetStackSize); + if (ownerUUID != null) aNBT.setString("ownerUUID", ownerUUID.toString()); } @@ -269,18 +269,6 @@ public abstract class GregtechMetaSafeBlockBase extends GT_MetaTileEntity_Tiered } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aSide == getBaseMetaTileEntity().getBackFacing()) { - mTargetStackSize = (byte) ((mTargetStackSize + (aPlayer.isSneaking()? -1 : 1)) % 65); - if (mTargetStackSize == 0) { - GT_Utility.sendChatToPlayer(aPlayer, "Do not regulate Item Stack Size"); - } else { - GT_Utility.sendChatToPlayer(aPlayer, "Regulate Item Stack Size to: " + mTargetStackSize); - } - } - } - - @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { /*if (aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isUniversalEnergyStored(getMinimumStoredEU()) && (aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified() || aTimer % 200 == 0 || mSuccess > 0)) { */ @@ -307,42 +295,12 @@ public abstract class GregtechMetaSafeBlockBase extends GT_MetaTileEntity_Tiered } - - - - - - - - /*mSuccess--; - moveItems(aBaseMetaTileEntity, aTimer); - aBaseMetaTileEntity.setGenericRedstoneOutput(bInvert); - if (bRedstoneIfFull) { - aBaseMetaTileEntity.setGenericRedstoneOutput(!bInvert); - for (int i = 0; i < mInventory.length; i++) - if (isValidSlot(i)) { - if (mInventory[i] == null) { - aBaseMetaTileEntity.setGenericRedstoneOutput(bInvert); - aBaseMetaTileEntity.decreaseStoredEnergyUnits(1, true); - break; - } - } - } - }*/ } } - /*protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - int tCost = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, mTargetStackSize == 0 ? 64 : (byte) mTargetStackSize, mTargetStackSize == 0 ? 1 : (byte) mTargetStackSize, (byte) 64, (byte) 1); - if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) { - mSuccess = 50; - aBaseMetaTileEntity.decreaseStoredEnergyUnits(Math.abs(tCost), true); - } - }*/ - @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return true; + return false; } @Override |