diff options
Diffstat (limited to 'src/Java/miscutil')
7 files changed, 78 insertions, 46 deletions
diff --git a/src/Java/miscutil/core/handler/XEventHandler.java b/src/Java/miscutil/core/handler/XEventHandler.java index 3742f29e47..806296d594 100644 --- a/src/Java/miscutil/core/handler/XEventHandler.java +++ b/src/Java/miscutil/core/handler/XEventHandler.java @@ -1,6 +1,7 @@ package miscutil.core.handler; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.api.metatileentity.BaseTileEntity; import miscutil.core.util.Utils; @@ -17,7 +18,7 @@ public class XEventHandler { EntityPlayer playerInternal = event.getPlayer(); try{ - if (entity instanceof BaseTileEntity){ + if (entity instanceof BaseTileEntity && !(entity instanceof BaseMetaPipeEntity)){ IMetaTileEntity X = ((BaseMetaTileEntity)entity).getMetaTileEntity(); if (X instanceof GregtechMetaSafeBlockBase){ diff --git a/src/Java/miscutil/core/util/PlayerCache.java b/src/Java/miscutil/core/util/PlayerCache.java index e247646562..a1474bf07a 100644 --- a/src/Java/miscutil/core/util/PlayerCache.java +++ b/src/Java/miscutil/core/util/PlayerCache.java @@ -26,7 +26,7 @@ public class PlayerCache { Utils.LOG_INFO("Loaded PlayerCache.dat"); } catch (Exception e) { Utils.LOG_INFO("Failed to initialise PlayerCache.dat"); - PlayerCache.createPropertiesFile("CACHE FILE - ", "THIS CONTAINS PLAYERDATA"); + PlayerCache.createPropertiesFile("CACHE_FILE_=", "THIS_CONTAINS_PLAYERDATA"); //e.printStackTrace(); } } @@ -35,7 +35,7 @@ public class PlayerCache { public static void createPropertiesFile(String playerName, String playerUUIDasString) { try { Properties props = new Properties(); - props.setProperty(playerName, playerUUIDasString); + props.setProperty(playerName+" ", playerUUIDasString); OutputStream out = new FileOutputStream(cache); props.store(out, "Player Cache."); Utils.LOG_INFO("Created an empty PlayerCache.dat for future use."); @@ -46,25 +46,25 @@ public class PlayerCache { } public static void appendParamChanges(String playerName, String playerUUIDasString) { - try { - Properties properties = new Properties(); try { Utils.LOG_WARNING("Attempting to load "+cache.getName()); properties.load(new FileInputStream(cache)); + if (properties == null || properties.equals(null)){ + Utils.LOG_WARNING("Null properties"); + } + else { + Utils.LOG_WARNING("Loaded PlayerCache.dat"); + properties.setProperty(playerName+"_", playerUUIDasString); + FileOutputStream fr=new FileOutputStream(cache); + properties.store(fr, "Player Cache."); + fr.close(); + } + } catch (IOException e) { Utils.LOG_WARNING("No PlayerCache file found, creating one."); createPropertiesFile(playerName, playerUUIDasString); - } - - properties.setProperty(playerName, playerUUIDasString); - FileOutputStream fr=new FileOutputStream(cache); - properties.store(fr, "Player Cache."); - fr.close(); - } - catch (Exception e ) { - e.printStackTrace(); - } + } } /** @@ -81,11 +81,10 @@ public class PlayerCache { * @throws Exception */ public static Map<String, String> readPropertiesFileAsMap() throws Exception { - String filename = cache.getName(); - String delimiter = ":"; + String delimiter = "="; @SuppressWarnings({ "rawtypes", "unchecked" }) Map<String, String> map = new HashMap(); - BufferedReader reader = new BufferedReader(new FileReader(filename)); + BufferedReader reader = new BufferedReader(new FileReader(cache)); String line; while ((line = reader.readLine()) != null) { @@ -104,12 +103,13 @@ public class PlayerCache { } public static String lookupPlayerByUUID(String UUID){ + try { Map<String, String> map = null; try { map = readPropertiesFileAsMap(); } catch (Exception e) { - Utils.LOG_ERROR("Caught Exception"+e.toString()); - e.printStackTrace(); + Utils.LOG_ERROR("With "+e.getCause()+" as cause, Caught Exception: "+e.toString()); + //e.printStackTrace(); } for (Entry<String, String> entry : map.entrySet()) { if (Objects.equals(UUID, entry.getValue())) { @@ -117,5 +117,10 @@ public class PlayerCache { } } return null; + } catch (NullPointerException e) { + Utils.LOG_ERROR("With "+e.getCause()+" as cause, Caught Exception: "+e.toString()); + //e.printStackTrace(); } + return null; +} } diff --git a/src/Java/miscutil/gregtech/gui/CONTAINER_SafeBlock.java b/src/Java/miscutil/gregtech/gui/CONTAINER_SafeBlock.java index 09162fcda0..62985e6988 100644 --- a/src/Java/miscutil/gregtech/gui/CONTAINER_SafeBlock.java +++ b/src/Java/miscutil/gregtech/gui/CONTAINER_SafeBlock.java @@ -3,8 +3,9 @@ package miscutil.gregtech.gui; import gregtech.api.gui.GT_ContainerMetaTile_Machine; import gregtech.api.gui.GT_Slot_Holo; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.api.util.GT_Utility; -import miscutil.core.util.PlayerCache; +import miscutil.core.util.Utils; import miscutil.gregtech.metatileentity.implementations.GregtechMetaSafeBlock; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -17,8 +18,9 @@ public class CONTAINER_SafeBlock super(aInventoryPlayer, aTileEntity); } - public String UUID = ((GregtechMetaSafeBlock)this.mTileEntity.getMetaTileEntity()).ownerUUID; + public String UUID = ((BaseMetaTileEntity)mTileEntity).getMetaTileEntity().getBaseMetaTileEntity().getOwnerName(); public String ownerUUID = ((GregtechMetaSafeBlock)this.mTileEntity.getMetaTileEntity()).ownerUUID; + public boolean blockStatus = ((GregtechMetaSafeBlock)this.mTileEntity.getMetaTileEntity()).bUnbreakable; @Override public void addSlots(InventoryPlayer aInventoryPlayer) { @@ -64,9 +66,13 @@ public class CONTAINER_SafeBlock ((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bUnbreakable = (!((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bUnbreakable); if (((GregtechMetaSafeBlock) this.mTileEntity.getMetaTileEntity()).bUnbreakable) { GT_Utility.sendChatToPlayer(aPlayer, "Block is now unbreakable."); - PlayerCache.appendParamChanges(aPlayer.getDisplayName(), aPlayer.getUniqueID().toString()); + // World world; + //world.markBlockForUpdate(x, y, z); + //this.updateProgressBar(par1, par2); + //PlayerCache.appendParamChanges(aPlayer.getDisplayName(), aPlayer.getUniqueID().toString()); } else { GT_Utility.sendChatToPlayer(aPlayer, "Block is now breakable."); + Utils.LOG_WARNING("Owner Name - From GT Values: "+UUID); } return null; } diff --git a/src/Java/miscutil/gregtech/gui/GUI_SafeBlock.java b/src/Java/miscutil/gregtech/gui/GUI_SafeBlock.java index c4b2d540ba..94219dae0e 100644 --- a/src/Java/miscutil/gregtech/gui/GUI_SafeBlock.java +++ b/src/Java/miscutil/gregtech/gui/GUI_SafeBlock.java @@ -12,15 +12,29 @@ public class GUI_SafeBlock super(new CONTAINER_SafeBlock(aInventoryPlayer, aTileEntity), CORE.MODID + ":" + "textures/gui/" + "SafeBlock.png"); } - String UUID = ((CONTAINER_SafeBlock)this.mContainer).UUID; + String UUID = ((CONTAINER_SafeBlock)this.mContainer).ownerUUID; + boolean blockStatus = ((CONTAINER_SafeBlock)this.mContainer).blockStatus; private String tempPlayer = PlayerCache.lookupPlayerByUUID(UUID); @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { - this.fontRendererObj.drawString("Safe", 64, 64, 4210752); + + UUID = ((CONTAINER_SafeBlock)this.mContainer).ownerUUID; + blockStatus = ((CONTAINER_SafeBlock)this.mContainer).blockStatus; + tempPlayer = PlayerCache.lookupPlayerByUUID(UUID); + + if (blockStatus){ + this.fontRendererObj.drawString("Safe Status: Locked", 64, 62, 4210752); + } + else { + this.fontRendererObj.drawString("Safe Status: Unlocked", 64, 62, 4210752); + } + + this.fontRendererObj.drawString("Owner: "+ tempPlayer, 64, 72, 4210752); + if (!CORE.DEBUG){ - this.fontRendererObj.drawString("Owner: "+ tempPlayer, 120, 80, 4210752); + } } diff --git a/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaCondensor.java b/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaCondensor.java index 9a0baf38f6..82f1ad98be 100644 --- a/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaCondensor.java +++ b/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaCondensor.java @@ -41,8 +41,8 @@ public class GregtechMetaCondensor extends GregtechMetaBoilerBase{ rTextures[0][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa))}; rTextures[1][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) }; rTextures[2][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE) }; - rTextures[3][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_MASSFAB) }; - rTextures[4][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_MASSFAB_ACTIVE) }; + rTextures[3][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_POTIONBREWER) }; + rTextures[4][(i + 1)] = new ITexture [] { new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT, Dyes.getModulation(i, Dyes.MACHINE_METAL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_POTIONBREWER_ACTIVE) }; } return rTextures; } diff --git a/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaSafeBlock.java b/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaSafeBlock.java index 4d635a91c6..3ddea2a5b7 100644 --- a/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaSafeBlock.java +++ b/src/Java/miscutil/gregtech/metatileentity/implementations/GregtechMetaSafeBlock.java @@ -39,7 +39,7 @@ public class GregtechMetaSafeBlock @Override public ITexture getOverlayIcon() { - return new GT_RenderedTexture(Textures.BlockIcons.AUTOMATION_SUPERBUFFER); + return new GT_RenderedTexture(Textures.BlockIcons.VOID); } @Override diff --git a/src/Java/miscutil/gregtech/metatileentity/implementations/base/GregtechMetaSafeBlockBase.java b/src/Java/miscutil/gregtech/metatileentity/implementations/base/GregtechMetaSafeBlockBase.java index d4fe9a70b6..e17beb4fe9 100644 --- a/src/Java/miscutil/gregtech/metatileentity/implementations/base/GregtechMetaSafeBlockBase.java +++ b/src/Java/miscutil/gregtech/metatileentity/implementations/base/GregtechMetaSafeBlockBase.java @@ -7,6 +7,7 @@ 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 miscutil.core.util.PlayerCache; import miscutil.core.util.Utils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; @@ -28,16 +29,17 @@ public abstract class GregtechMetaSafeBlockBase extends GT_MetaTileEntity_Tiered @Override public ITexture[][][] getTextureSet(ITexture[] aTextures) { ITexture[][][] rTextures = new ITexture[6][17][]; - ITexture tIcon = getOverlayIcon(), tOut = new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT), tUp = new GT_RenderedTexture(Textures.BlockIcons.ARROW_UP), tDown = new GT_RenderedTexture(Textures.BlockIcons.ARROW_DOWN), tLeft = new GT_RenderedTexture(Textures.BlockIcons.ARROW_LEFT), tRight = new GT_RenderedTexture(Textures.BlockIcons.ARROW_RIGHT); + ITexture tIcon = getOverlayIcon(), tOut = new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_QCHEST), tUp = new GT_RenderedTexture(Textures.BlockIcons.MACHINE_CASING_VENT), tShitGoesWrong = new GT_RenderedTexture(Textures.BlockIcons.NAQUADAH_REACTOR_FLUID_SIDE_ACTIVE); for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tOut}; - rTextures[1][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tRight, tIcon}; - rTextures[2][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tDown, tIcon}; - rTextures[3][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tLeft, tIcon}; - rTextures[4][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tUp, tIcon}; - rTextures[5][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tIcon}; + rTextures[0][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tUp, tIcon}; //Back + rTextures[1][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tIcon}; // Right, Strangely The top side as well when facing East? + rTextures[2][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tIcon}; // Top And Bottom, When Facing South (What the hell?) + rTextures[3][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tIcon}; // Left, Top if facing West and Bottom if facing east? + rTextures[4][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tIcon}; // Top and Bottom when Facing North.. + rTextures[5][i + 1] = new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][i + 1], tOut}; // Front } return rTextures; + } @Override @@ -176,20 +178,22 @@ public abstract class GregtechMetaSafeBlockBase extends GT_MetaTileEntity_Tiered @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - String tempUUID = aPlayer.getUniqueID().toString(); + if (aBaseMetaTileEntity.isClientSide()) { //Utils.LOG_WARNING("Clicky Clicky."); return true; } if (!aPlayer.equals(null)) { + String tempUUID = aPlayer.getUniqueID().toString(); + PlayerCache.appendParamChanges(aPlayer.getDisplayName(), aPlayer.getUniqueID().toString()); if (ownerUUID.equals("")){ Utils.LOG_WARNING("No owner yet for this block."); } else { - Utils.LOG_WARNING("Current stored UUID : "+ownerUUID); + Utils.LOG_WARNING("Current Owner: "+PlayerCache.lookupPlayerByUUID(ownerUUID)+" - UUID: "+ownerUUID); } - Utils.LOG_WARNING("Check if ownerUUID is Null"); + Utils.LOG_WARNING("Is ownerUUID Null"); if (ownerUUID.equals("")){ Utils.LOG_WARNING("OwnerUUID is Null, let's set it."); Utils.LOG_WARNING("Accessing Players UUID is: "+tempUUID); @@ -197,18 +201,20 @@ public abstract class GregtechMetaSafeBlockBase extends GT_MetaTileEntity_Tiered Utils.messagePlayer(aPlayer, "Owner of this safe, now set. Try accessing it again."); Utils.LOG_WARNING("Block Owner is now set to: "+ownerUUID); } - Utils.LOG_WARNING("Check who ownerUUID is if not Null"); + Utils.LOG_WARNING("No, it is not."); + Utils.LOG_WARNING("Checking ownerUUID."); if (!ownerUUID.equals(null)){ - Utils.LOG_WARNING("ownerUUID is not Null, let's see if the player clicking can access the GUI."); - Utils.LOG_WARNING("Accessing Players UUID is: "+tempUUID); + Utils.LOG_WARNING("ownerUUID != Null, if accessor == owner."); + Utils.LOG_WARNING("Accessing is: "+PlayerCache.lookupPlayerByUUID(tempUUID)); if (ownerUUID.equals(tempUUID)){ - Utils.LOG_WARNING("Clicking player is the owner, with a UUID of: "+ownerUUID); + Utils.LOG_WARNING("Owner's UUID: "+ownerUUID); aBaseMetaTileEntity.openGUI(aPlayer); - Utils.LOG_WARNING("GUI should now be open for you sir."); + //Utils.LOG_WARNING("GUI should now be open for you sir."); } else { Utils.messagePlayer(aPlayer, "Access Denied, This does not belong to you."); - Utils.LOG_WARNING("Expecting UUID : "+ownerUUID); + Utils.messagePlayer(aPlayer, "it is owned by: "+PlayerCache.lookupPlayerByUUID(ownerUUID)); + Utils.LOG_WARNING("Expecting Player : "+PlayerCache.lookupPlayerByUUID(ownerUUID)); Utils.LOG_ERROR("Access Denied."); return true; } @@ -272,7 +278,7 @@ public abstract class GregtechMetaSafeBlockBase extends GT_MetaTileEntity_Tiered //this. } else { - + } |