aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/xmod/gregtech/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common')
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java9
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java8
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/helpers/FlotationRecipeHandler.java79
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java480
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java2
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java38
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IsaMill.java289
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_Fusion_MK4.java93
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_FrothFlotationCell.java492
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/chemplant/GregtechMTE_ChemicalPlant.java138
10 files changed, 1423 insertions, 205 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java
index be180bf4e9..a4a396e4cf 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaSpecialMultiCasings.java
@@ -47,8 +47,8 @@ public class GregtechMetaSpecialMultiCasings extends GregtechMetaCasingBlocksAbs
GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".6.name", "Structural Solar Casing");
GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".7.name", "Salt Containment Casing");
GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".8.name", "Thermally Insulated Casing");
- GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", ""); // Unused
- GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", ""); // Unused
+ GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".9.name", "Flotation Cell Casings");
+ GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".10.name", "Reinforced Engine Casing");
GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".11.name", ""); // Unused
GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", ""); // Unused
GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", ""); // Unused
@@ -64,6 +64,7 @@ public class GregtechMetaSpecialMultiCasings extends GregtechMetaCasingBlocksAbs
GregtechItemList.Casing_SolarTower_Structural.set(new ItemStack(this, 1, 6));
GregtechItemList.Casing_SolarTower_SaltContainment.set(new ItemStack(this, 1, 7));
GregtechItemList.Casing_SolarTower_HeatContainment.set(new ItemStack(this, 1, 8));
+ GregtechItemList.Casing_Reinforced_Engine_Casing.set(new ItemStack(this, 1, 9));
}
public IIcon getIcon(int aSide, int aMeta) {
@@ -88,6 +89,10 @@ public class GregtechMetaSpecialMultiCasings extends GregtechMetaCasingBlocksAbs
return TexturesGtBlock.Casing_Material_Stellite.getIcon();
case 8:
return TexturesGtBlock.Casing_Machine_Simple_Top.getIcon();
+ case 9:
+ return TexturesGtBlock.TEXTURE_CASING_FLOTATION.getIcon();
+ case 10:
+ return TexturesGtBlock.Casing_Material_Talonite.getIcon();
}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java
index 7903da8c6d..93322d2ef1 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/TexturesGtBlock.java
@@ -281,6 +281,7 @@ public class TexturesGtBlock {
public static final CustomIcon TEXTURE_CASING_ADVANCED_VOLCNUS = new CustomIcon("TileEntities/MACHINE_CASING_ADVANCED_VOLCANUS");
public static final CustomIcon TEXTURE_CASING_ROCKETDYNE = new CustomIcon("TileEntities/MACHINE_CASING_ROCKETDYNE");
public static final CustomIcon TEXTURE_CASING_GRINDING_MILL = new CustomIcon("TileEntities/MACHINE_CASING_GRINDING_FACTORY");
+ public static final CustomIcon TEXTURE_CASING_FLOTATION = new CustomIcon("TileEntities/MACHINE_CASING_FLOTATION");
// Custom Pipes
public static final CustomIcon TEXTURE_PIPE_GRINDING_MILL = new CustomIcon("TileEntities/MACHINE_CASING_PIPE_T1");
@@ -388,6 +389,13 @@ public class TexturesGtBlock {
//Control Core Bus
private static final CustomIcon Internal_Overlay_Hatch_Control_Core = new CustomIcon("iconsets/OVERLAY_CONTROL_CORE_BUS");
public static final CustomIcon Overlay_Hatch_Control_Core = Internal_Overlay_Hatch_Control_Core;
+ // Milling Ball Bus
+ private static final CustomIcon Internal_Overlay_Bus_Milling_Balls = new CustomIcon("iconsets/OVERLAY_MILLING_BALL_BUS");
+ public static final CustomIcon Overlay_Bus_Milling_Balls = Internal_Overlay_Bus_Milling_Balls;
+ // Catalyst Bus
+ private static final CustomIcon Internal_Overlay_Bus_Catalyst = new CustomIcon("iconsets/OVERLAY_CATALYSTS");
+ public static final CustomIcon Overlay_Bus_Catalyst = Internal_Overlay_Bus_Catalyst;
+
//Dimensional
private static final CustomIcon Internal_Overlay_Machine_Dimensional_Blue = new CustomIcon("TileEntities/adv_machine_dimensional_cover_blue");
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/FlotationRecipeHandler.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/FlotationRecipeHandler.java
new file mode 100644
index 0000000000..333939d800
--- /dev/null
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/FlotationRecipeHandler.java
@@ -0,0 +1,79 @@
+package gtPlusPlus.xmod.gregtech.common.helpers;
+
+import java.util.HashMap;
+
+import gregtech.api.enums.OrePrefixes;
+import gregtech.api.util.GT_Recipe;
+import gregtech.api.util.GT_Utility;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.material.Material;
+import gtPlusPlus.core.util.data.AES;
+import gtPlusPlus.xmod.gregtech.api.enums.CustomOrePrefix;
+import net.minecraft.item.ItemStack;
+
+public class FlotationRecipeHandler {
+
+ private static HashMap<String, Material> sMaterialMap = new HashMap<String, Material>();
+ private static HashMap<String, ItemStack> sMilledMap = new HashMap<String, ItemStack>();
+ private static final AES sEncodingHandler = new AES();
+
+ public static boolean registerOreType(Material aMaterial) {
+ String aMaterialKey = sEncodingHandler.encode(aMaterial.getUnlocalizedName());
+ if (sMaterialMap.containsKey(aMaterialKey)) {
+ CORE.crash("Tried to register a Flotation material to an ID already in use. ID: "+aMaterialKey);
+ return false;
+ }
+ else {
+ sMaterialMap.put(aMaterialKey, aMaterial);
+ sMilledMap.put(aMaterialKey, aMaterial.getMilled(1));
+ }
+ return true;
+ }
+
+ public static int getHashForMaterial(Material aMaterial) {
+ return getMaterialsID(aMaterial).hashCode();
+ }
+
+ public static String getMaterialsID(Material aMaterial) {
+ for (String aKey : sMaterialMap.keySet()) {
+ if (sMaterialMap.get(aKey).equals(aMaterial)) {
+ return aKey;
+ }
+ }
+ return "BAD_MATERIAL_ID";
+ }
+
+ public static Material getMaterialOfMilledProduct(ItemStack aMilled) {
+ for (String aKey : sMilledMap.keySet()) {
+ ItemStack aTempMilledStack = sMilledMap.get(aKey);
+ if (GT_Utility.areStacksEqual(aTempMilledStack, aMilled, true)) {
+ return sMaterialMap.get(aKey);
+ }
+ }
+ return null;
+ }
+
+ public static ItemStack findMilledStack(GT_Recipe aRecipe) {
+ if (aRecipe == null || aRecipe.mInputs == null || aRecipe.mInputs.length <= 0) {
+ return null;
+ }
+ return findMilledStack(aRecipe.mInputs);
+ }
+
+ public static ItemStack findMilledStack(ItemStack[] aInputs) {
+ if (aInputs == null || aInputs.length <= 0) {
+ return null;
+ }
+ for (ItemStack aStack : aInputs) {
+ if (CustomOrePrefix.milled.get().contains(aStack)) {
+ return aStack;
+ }
+ }
+ return null;
+ }
+
+ public static AES getEncoder() {
+ return sEncodingHandler;
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java
index 6201a782de..73a60889c6 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java
@@ -1,44 +1,26 @@
package gtPlusPlus.xmod.gregtech.common.render;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigInteger;
+import java.io.*;
import java.net.URL;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.Base64;
import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.List;
import java.util.UUID;
-import javax.crypto.Cipher;
-import javax.crypto.NoSuchPaddingException;
-import javax.crypto.spec.IvParameterSpec;
-import javax.crypto.spec.SecretKeySpec;
-import javax.xml.bind.DatatypeConverter;
-
import org.apache.commons.io.IOUtils;
import org.lwjgl.opengl.GL11;
import com.mojang.authlib.GameProfile;
-import gregtech.api.enums.GT_Values;
-import gregtech.api.util.GT_Log;
import gregtech.api.util.GT_Utility;
import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.data.AutoMap;
+import gtPlusPlus.api.objects.data.Pair;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.lib.CORE.ConfigSwitches;
import gtPlusPlus.core.proxy.ClientProxy;
-import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.data.AES;
import gtPlusPlus.core.util.data.FileUtils;
+import gtPlusPlus.core.util.math.MathUtils;
import gtPlusPlus.core.util.sys.NetworkUtils;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.model.ModelBiped;
@@ -49,29 +31,28 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.RenderPlayerEvent;
-import net.minecraftforge.common.UsernameCache;
public class GTPP_CapeRenderer extends RenderPlayer {
- private final ResourceLocation[] mCapes = {
+ private static final ResourceLocation[] mCapes = {
new ResourceLocation("miscutils:textures/OrangeHD.png"),
new ResourceLocation("miscutils:textures/FancyCapeHD.png"),
new ResourceLocation("miscutils:textures/TesterCapeHD.png"),
+ new ResourceLocation("miscutils:textures/PatreonCapeHD.png"),
new ResourceLocation("miscutils:textures/DevCapeHD.png"),
- new ResourceLocation("miscutils:textures/PatreonCapeHD.png") };
+ };
- private final ArrayList<String> mData;
+ private final boolean mInit;
public GTPP_CapeRenderer() {
- downloadCapeList();
- ArrayList<String> aTemp = new ArrayList<String>();
- try {
- aTemp = returnDatData();
+ mInit = init();
+ }
+
+ private final boolean init() {
+ if (mInit) {
+ return false;
}
- catch (Throwable t) {
- aTemp = new ArrayList<String>();
- }
- mData = aTemp;
+ return CapeUtils.init();
}
private static boolean hasResourceChecked = false;
@@ -80,107 +61,127 @@ public class GTPP_CapeRenderer extends RenderPlayer {
private ResourceLocation tResource = null;
public synchronized void receiveRenderSpecialsEvent(RenderPlayerEvent.Specials.Pre aEvent) {
+
+ // Check we have set Render Manager
if (this.renderManager == null) {
hasSetRenderer = false;
}
+
+ // Set Render Manager
if (!hasSetRenderer) {
if (RenderManager.instance != null) {
setRenderManager(RenderManager.instance);
+ hasSetRenderer = true;
}
- }
- AbstractClientPlayer aPlayer = (AbstractClientPlayer) aEvent.entityPlayer;
- if (!ConfigSwitches.enableCustomCapes) {
- aEvent.setCanceled(true);
- Logger.WARNING("A1");
- return;
- }
-
- if (hasResourceChecked) {
- if (!hasCape && !CORE.DEVENV) {
- aEvent.setCanceled(true);
- Logger.WARNING("A2");
+ }
+
+ // Actually Render
+ if (hasSetRenderer) {
+
+ // We have capes turned off, so let's not render.
+ if (!ConfigSwitches.enableCustomCapes) {
return;
}
- }
- // Make sure we don't keep checking on clients who dont have capes.
- if (!hasResourceChecked) {
-
- // Time to Spliterate some data
- Map<String, ResourceLocation> aPlayerData = new HashMap<String, ResourceLocation>();
- Map<String, String> aNameMap = new HashMap<String, String>();
- int i = 0;
- if (!CORE.DEVENV) {
- for (String s : mData) {
- String[] aSplit = s.split("@");
- int a[] = new int[] { 0, mCapes.length - 1 };
- int aID = Integer.parseInt(aSplit[1]);
- // Quick Check to prevent lag
- Logger.WARNING("Trying to create UUID from - " + aSplit[0]);
- UUID aPlayerID = UUID.fromString(aSplit[0]);
- Logger.WARNING("Result: " + aPlayerID.toString());
- if (aPlayerID != null) {
- if (UsernameCache.containsUUID(aPlayerID)) {
- Logger.WARNING("UsernameCache contains a last known username for current players UUID.");
- if (!UsernameCache.getLastKnownUsername(aPlayerID).toLowerCase()
- .equals(ClientProxy.playerName)) {
- Logger.WARNING("Last known name does not match current name. Checking next UUID.");
- continue;
- } else {
- Logger.WARNING("Last known name does match current name.");
- }
- } else {
- Logger.WARNING("UsernameCache did not hold results for current player, oops.");
- continue;
- }
- }
- String aPlayerName = this.getPlayerName("iteration-" + (i++), aSplit[0]);
- aNameMap.put(aSplit[0], aPlayerName);
- aPlayerData.put(aPlayerName, this.mCapes[Math.max(a[0], Math.min(aID, a[1]))]);
+ // We have already checked if this player has a cape, but since they do not, we best not render.
+ if (hasResourceChecked) {
+ if (!hasCape && !CORE.DEVENV) {
+ return;
}
}
- // Set flag to only render this event if player has a cape.
- for (String s : aNameMap.values()) {
- if (s.toLowerCase().equals(ClientProxy.playerName)) {
+ // Allocate client player object
+ AbstractClientPlayer aPlayer = (AbstractClientPlayer) aEvent.entityPlayer;
+
+ // Make sure we don't keep checking on clients who dont have capes.
+ if (!hasResourceChecked) {
+
+ // Get players UUID
+ String aPlayerUUID = aPlayer != null ? aPlayer.getGameProfile().getId().toString() : "BAD";
+
+ // If for whatever reason this fails, we just exit early.
+ if (aPlayerUUID.equals("BAD")) {
+ return;
+ }
+
+ // Automatically allocate a Dev cape while in Dev mode.
+ if (tResource == null && CORE.DEVENV) {
+ tResource = mCapes[4];
hasCape = true;
- tResource = aPlayerData.get(ClientProxy.playerName);
- break;
}
- }
- // Dev capes for dev mode.
- if (CORE.DEVENV) {
- hasCape = true;
- tResource = mCapes[3];
- }
+ String aPlayerName = ClientProxy.playerName;
- // Safety Check
- if (tResource == null) {
- if (aPlayerData.get(aPlayer.getDisplayName()) != null) {
- tResource = aPlayerData.get(aPlayer.getDisplayName());
- } else {
- hasCape = false;
+ // Check cape lists for the cape this player owns.
+ if (!hasCape) {
+ for (Pair<String, String> aData : CapeUtils.mOrangeCapes) {
+ if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) {
+ tResource = mCapes[0];
+ hasCape = true;
+ break;
+ }
+ }
}
+ if (!hasCape) {
+ for (Pair<String, String> aData : CapeUtils.mMiscCapes) {
+ if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) {
+ tResource = mCapes[1];
+ hasCape = true;
+ break;
+ }
+ }
+ }
+ if (!hasCape) {
+ for (Pair<String, String> aData : CapeUtils.mBetaTestCapes) {
+ if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) {
+ tResource = mCapes[2];
+ hasCape = true;
+ break;
+ }
+ }
+ }
+ if (!hasCape) {
+ for (Pair<String, String> aData : CapeUtils.mPatreonCapes) {
+ if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) {
+ tResource = mCapes[3];
+ hasCape = true;
+ break;
+ }
+ }
+ }
+ if (!hasCape) {
+ for (Pair<String, String> aData : CapeUtils.mDevCapes) {
+ if (aData.getKey().equals(aPlayerUUID) || aPlayerName .equals(aData.getValue())) {
+ tResource = mCapes[4];
+ hasCape = true;
+ break;
+ }
+ }
+ }
+ hasResourceChecked = true;
}
- // Only run once.
- hasResourceChecked = true;
+ if (hasResourceChecked) {
+ // We have met all the conditions, let's render that cape.
+ renderCapeOnPlayer(aEvent, aPlayer);
+ }
}
- if (GT_Utility.getFullInvisibility(aPlayer) || aPlayer.isInvisible()
- || GT_Utility.getPotion(aPlayer, Integer.valueOf(Potion.invisibility.id).intValue())) {
- aEvent.setCanceled(true);
- Logger.WARNING("A3");
- return;
- }
+ }
+ private final boolean renderCapeOnPlayer(RenderPlayerEvent.Specials.Pre aEvent, AbstractClientPlayer aPlayer) {
float aPartialTicks = aEvent.partialRenderTick;
try {
-
if (tResource == null && CORE.DEVENV) {
tResource = mCapes[3];
}
+
+ // If player is invisible, don't render.
+ if (GT_Utility.getFullInvisibility(aPlayer) || aPlayer.isInvisible()
+ || GT_Utility.getPotion(aPlayer, Integer.valueOf(Potion.invisibility.id).intValue())) {
+ aEvent.setCanceled(true);
+ return false;
+ }
if ((tResource != null) && (!aPlayer.getHideCape())) {
bindTexture(tResource);
@@ -221,14 +222,22 @@ public class GTPP_CapeRenderer extends RenderPlayer {
GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
((ModelBiped) this.mainModel).renderCloak(0.0625F);
GL11.glPopMatrix();
+ return true;
}
} catch (Throwable e) {
- if (GT_Values.D1) {
- e.printStackTrace(GT_Log.err);
- }
+
}
+ return false;
}
+ @SuppressWarnings("unused")
+ @Deprecated
+ /**
+ * Should be able to get the username from a UUID
+ * @param name - Players Name
+ * @param uuid - Players known UUID
+ * @return - The newest Player name
+ */
private String getPlayerName(String name, String uuid) {
try {
Logger.WORLD("[Capes++] Trying to UUID check " + name + ".");
@@ -271,29 +280,242 @@ public class GTPP_CapeRenderer extends RenderPlayer {
return name;
}
- private void downloadCapeList() {
- if (!NetworkUtils.checkNetworkIsAvailableWithValidInterface()) {
- return;
- }
- try {
- File dat = new File(Utils.getMcDir(), "GTPP.dat");
- if (FileUtils.doesFileExist(dat)) {
+
+
+ private static class CapeUtils {
+
+ private static char SPLIT_CHARACTER = 'ยง';
+ private static AES sAES;
+
+ // UUID - Username
+ private static final AutoMap<Pair<String, String>> mOrangeCapes = new AutoMap<Pair<String, String>>();
+ private static final AutoMap<Pair<String, String>> mMiscCapes = new AutoMap<Pair<String, String>>();
+ private static final AutoMap<Pair<String, String>> mBetaTestCapes = new AutoMap<Pair<String, String>>();
+ private static final AutoMap<Pair<String, String>> mPatreonCapes = new AutoMap<Pair<String, String>>();
+ private static final AutoMap<Pair<String, String>> mDevCapes = new AutoMap<Pair<String, String>>();
+
+ private static final boolean init() {
+ CapeUtils.handleOldCapeCache();
+ if (CORE.DEVENV) {
+ return true;
+ }
+ try {
+ if (shouldDownloadCapeList()) {
+ downloadCapeList();
+ }
+ }
+ catch (Exception e) {
+ return false;
+ }
+ writeCacheToMaps();
+ return true;
+ }
+
+
+ private static boolean shouldDownloadCapeList() {
+ if (!doesCapeCacheExistLocally()) {
+ return true;
+ }
+ if (isCapeCacheWeekOld()) {
+ return true;
+ }
+ return false;
+ }
+
+ private static final boolean isCapeCacheWeekOld() {
+ if (!doesCapeCacheExistLocally()) {
+ return true;
+ }
+ else {
+ File dat = CapeUtils.getCapeCache();
Date dateLastMod = new Date(dat.lastModified());
Date dateNow = new Date(System.currentTimeMillis() - (7l * 24 * 60 * 60 * 1000));
- if (!dateLastMod.before(dateNow)) {
- return;
+ if (dateLastMod.before(dateNow)) {
+ return true;
}
}
- InputStream inputStream = new URL("https://alkcorp.overminddl1.com/GTPP.dat").openStream();
- FileOutputStream fileOS = new FileOutputStream(dat);
- IOUtils.copy(inputStream, fileOS);
+ return false;
+ }
- } catch (Throwable t) {
- Logger.INFO("Unable to download GT++ cape list.");
+ private static final void downloadCapeList() {
+ if (!NetworkUtils.checkNetworkIsAvailableWithValidInterface()) {
+ return;
+ }
+ try {
+ File dat = getCapeCache();
+ File temp = allocateTempFile();
+ InputStream inputStream = new URL("https://alkcorp.overminddl1.com/CapeCache.dat").openStream();
+ FileOutputStream fileOS = new FileOutputStream(temp);
+ IOUtils.copy(inputStream, fileOS);
+ if (isDownloadedCapeListBigger(temp)) {
+ fileOS = new FileOutputStream(dat);
+ IOUtils.copy(inputStream, fileOS);
+ }
+ } catch (Throwable t) {
+ Logger.INFO("Unable to download GT++ cape list.");
+ }
+ }
+
+ private static final boolean isDownloadedCapeListBigger(File aFile) {
+ double aExistingFileSize = (doesCapeCacheExistLocally() ? getCapeCache().length() : 0);
+ double aNewFileSize = aFile.length();
+ if (aNewFileSize > aExistingFileSize) {
+ return true;
+ }
+ return false;
+ }
+
+ private static void handleOldCapeCache() {
+ File aCacheFile = FileUtils.getFile("GTPP", "dat");
+ if (FileUtils.doesFileExist(aCacheFile)) {
+ aCacheFile.delete();
+ }
+ }
+
+ private static final boolean doesCapeCacheExistLocally() {
+ File aCacheFile = FileUtils.getFile("CapeCache", "dat");
+ if (FileUtils.doesFileExist(aCacheFile)) {
+ return true;
+ }
+ return false;
+ }
+
+ private static final File getCapeCache() {
+ File aCacheFile = FileUtils.getFile("CapeCache", "dat");
+ if (FileUtils.doesFileExist(aCacheFile)) {
+ FileUtils.createFile(aCacheFile);
+ }
+ return aCacheFile;
+ }
+
+ public static final List<String> getDataFromCache(){
+ File aCacheFile = getCapeCache();
+ List<String> aCache = FileUtils.readLines(aCacheFile);
+ if (aCache != null && !aCache.isEmpty()) {
+ return aCache;
+ }
+ return new AutoMap<String>();
+ }
+
+ private static final File allocateTempFile() {
+ File tempFile = null;
+ try {
+ tempFile = File.createTempFile("gtpp-", null);
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ if (tempFile == null) {
+ tempFile = FileUtils.createFile("", "gtpp-"+MathUtils.randInt(Short.MAX_VALUE, (Integer.MAX_VALUE/2)), "tmp");
+ }
+ tempFile.deleteOnExit();
+ return tempFile;
+ }
+
+
+ public static final void writeCacheToMaps() {
+ List<String> aCacheData = getDataFromCache();
+ if (aCacheData != null && !aCacheData.isEmpty()) {
+ if (sAES == null) {
+ sAES = new AES();
+ }
+ AutoMap<String> aDecodedData = new AutoMap<String>();
+ for (String aToDecode : aCacheData) {
+ aDecodedData.put(sAES.decode(aToDecode));
+ }
+ if (!aDecodedData.isEmpty()) {
+ AutoMap<Pair<String, String>> aCapeType1 = new AutoMap<Pair<String, String>>();
+ AutoMap<Pair<String, String>> aCapeType2 = new AutoMap<Pair<String, String>>();
+ AutoMap<Pair<String, String>> aCapeType3 = new AutoMap<Pair<String, String>>();
+ AutoMap<Pair<String, String>> aCapeType4 = new AutoMap<Pair<String, String>>();
+ AutoMap<Pair<String, String>> aCapeType5 = new AutoMap<Pair<String, String>>();
+ boolean didProcessStringData = false;
+ Logger.INFO("Decoded String Count: "+aDecodedData.size());
+ for (String aToSplit : aDecodedData) {
+ String[] aSplitData = aToSplit.split(""+SPLIT_CHARACTER);
+ if (aSplitData != null && aSplitData.length >= 2) {
+ if (aSplitData[0] != null) {
+ Integer aCapeTypeID2 = Integer.parseInt(aSplitData[0]);
+ if (aCapeTypeID2 != null) {
+ int aCapeTypeID = aCapeTypeID2;
+ Pair<String, String> aFinalString = new Pair<String, String>("UUID: "+aSplitData[1], "Username: "+(aSplitData[2] != null && aSplitData[0].length() > 0 ? aSplitData[2] : "Not Specified"));
+ Logger.INFO("Cape Type: "+aCapeTypeID);
+ switch (aCapeTypeID) {
+ case 0:
+ aCapeType1.add(aFinalString);
+ Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType1.size()+" users.");
+ break;
+ case 1:
+ aCapeType2.add(aFinalString);
+ Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType2.size()+" users.");
+ break;
+ case 2:
+ aCapeType3.add(aFinalString);
+ Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType3.size()+" users.");
+ break;
+ case 3:
+ aCapeType4.add(aFinalString);
+ Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType4.size()+" users.");
+ break;
+ case 4:
+ aCapeType5.add(aFinalString);
+ Logger.INFO("Added user to map "+aCapeTypeID+", map now holds "+aCapeType5.size()+" users.");
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (!aCapeType1.isEmpty() || !aCapeType2.isEmpty() || !aCapeType3.isEmpty() || !aCapeType4.isEmpty() || !aCapeType5.isEmpty()) {
+ didProcessStringData = true;
+ }
+ else {
+ // did not process any data
+ }
+ if (didProcessStringData) {
+ if (!aCapeType1.isEmpty()) {
+ for (Pair<String, String> aUser : aCapeType1) {
+ Logger.INFO("Adding Generic cape for "+aUser.getKey());
+ mOrangeCapes.add(aUser);
+ }
+ }
+ if (!aCapeType2.isEmpty()) {
+ for (Pair<String, String> aUser : aCapeType2) {
+ Logger.INFO("Adding Blue cape for "+aUser.getKey());
+ mMiscCapes.add(aUser);
+ }
+ }
+ if (!aCapeType3.isEmpty()) {
+ for (Pair<String, String> aUser : aCapeType3) {
+ Logger.INFO("Adding Beta cape for "+aUser.getKey());
+ mBetaTestCapes.add(aUser);
+ }
+ }
+ if (!aCapeType4.isEmpty()) {
+ for (Pair<String, String> aUser : aCapeType4) {
+ Logger.INFO("Adding Patreon cape for "+aUser.getKey());
+ mPatreonCapes.add(aUser);
+ }
+ }
+ if (!aCapeType5.isEmpty()) {
+ for (Pair<String, String> aUser : aCapeType5) {
+ Logger.INFO("Adding Dev cape for "+aUser.getKey());
+ mDevCapes.add(aUser);
+ }
+ }
+ }
+ }
+ else {
+ // No data decoded
+ }
+ }
+ else {
+ // Nothing was cached?
+ }
}
}
-
- /* TODO: fix this stuff \u002a\u002f\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0072\u0065\u0074\u0075\u0072\u006e\u0044\u0061\u0074\u0044\u0061\u0074\u0061\u0028\u0029\u007b\u000a\u0009\u0009\u0046\u0069\u006c\u0065\u0020\u0064\u0061\u0074\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0046\u0069\u006c\u0065\u0028\u0055\u0074\u0069\u006c\u0073\u002e\u0067\u0065\u0074\u004d\u0063\u0044\u0069\u0072\u0028\u0029\u002c\u0020\u0022\u0047\u0054\u0050\u0050\u002e\u0064\u0061\u0074\u0022\u0029\u003b\u000a\u0009\u0009\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0048\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0028\u0029\u003b\u000a\u0009\u0009\u0074\u0072\u0079\u0020\u0028\u0042\u0075\u0066\u0066\u0065\u0072\u0065\u0064\u0052\u0065\u0061\u0064\u0065\u0072\u0020\u0062\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0042\u0075\u0066\u0066\u0065\u0072\u0065\u0064\u0052\u0065\u0061\u0064\u0065\u0072\u0028\u006e\u0065\u0077\u0020\u0046\u0069\u006c\u0065\u0052\u0065\u0061\u0064\u0065\u0072\u0028\u0064\u0061\u0074\u0029\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u006c\u0069\u006e\u0065\u003b\u000a\u0009\u0009\u0009\u0077\u0068\u0069\u006c\u0065\u0020\u0028\u0028\u006c\u0069\u006e\u0065\u0020\u003d\u0020\u0062\u0072\u002e\u0072\u0065\u0061\u0064\u004c\u0069\u006e\u0065\u0028\u0029\u0029\u0020\u0021\u003d\u0020\u006e\u0075\u006c\u006c\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0048\u002e\u0061\u0064\u0064\u0028\u006c\u0069\u006e\u0065\u0029\u003b\u000a\u0009\u0009\u0009\u007d\u000a\u000a\u0009\u0009\u007d\u0020\u0063\u0061\u0074\u0063\u0068\u0020\u0028\u0049\u004f\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u0065\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0065\u002e\u0070\u0072\u0069\u006e\u0074\u0053\u0074\u0061\u0063\u006b\u0054\u0072\u0061\u0063\u0065\u0028\u0029\u003b\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u000a\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0061\u0053\u0070\u006c\u0069\u0074\u0044\u0061\u0074\u0061\u0043\u0068\u0065\u0063\u006b\u005b\u005d\u0020\u003d\u0020\u0048\u002e\u0067\u0065\u0074\u0028\u0030\u0029\u002e\u0073\u0070\u006c\u0069\u0074\u0028\u0022\u0025\u0022\u0029\u003b\u000a\u0009\u0009\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0061\u0043\u006c\u0065\u0061\u006e\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0028\u0029\u003b\u000a\u0009\u0009\u0066\u006f\u0072\u0020\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0020\u003a\u0020\u0061\u0053\u0070\u006c\u0069\u0074\u0044\u0061\u0074\u0061\u0043\u0068\u0065\u0063\u006b\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0069\u0066\u0020\u0028\u0073\u0020\u0021\u003d\u0020\u006e\u0075\u006c\u006c\u0020\u0026\u0026\u0020\u0073\u002e\u006c\u0065\u006e\u0067\u0074\u0068\u0028\u0029\u0020\u003e\u0020\u0030\u0020\u0026\u0026\u0020\u0021\u0073\u002e\u0065\u0071\u0075\u0061\u006c\u0073\u0028\u0022\u0020\u0022\u0029\u0029\u0020\u007b\u000a\u0009\u0009\u0009\u0009\u0061\u0043\u006c\u0065\u0061\u006e\u0044\u0061\u0074\u0061\u002e\u0061\u0064\u0064\u0028\u0073\u0029\u003b\u000a\u0009\u0009\u0009\u007d\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u004d\u0041\u0049\u004e\u005f\u0053\u0054\u0041\u0054\u0049\u0043\u005f\u0049\u0056\u0020\u003d\u0020\u0022\u0030\u0031\u0030\u0030\u0030\u0030\u0030\u0031\u0020\u0030\u0031\u0030\u0031\u0030\u0030\u0031\u0022\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u004d\u0041\u0049\u004e\u005f\u0053\u0054\u0041\u0054\u0049\u0043\u005f\u004b\u0045\u0059\u0020\u003d\u0020\u0022\u0030\u0031\u0030\u0030\u0030\u0031\u0030\u0030\u0020\u0030\u0031\u0031\u0030\u0031\u0031\u0031\u0022\u003b\u000a\u0009\u0009\u000a\u0009\u0009\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0020\u0061\u0044\u0061\u0074\u0061\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0041\u0072\u0072\u0061\u0079\u004c\u0069\u0073\u0074\u003c\u0053\u0074\u0072\u0069\u006e\u0067\u003e\u0028\u0029\u003b\u000a\u0009\u0009\u0066\u006f\u0072\u0020\u0028\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0068\u0020\u003a\u0020\u0061\u0043\u006c\u0065\u0061\u006e\u0044\u0061\u0074\u0061\u0029\u0020\u007b\u0009\u0009\u0009\u000a\u0009\u0009\u0009\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u003d\u0020\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0028\u0068\u002c\u0020\u004d\u0041\u0049\u004e\u005f\u0053\u0054\u0041\u0054\u0049\u0043\u005f\u0049\u0056\u002c\u0020\u004d\u0041\u0049\u004e\u005f\u0053\u0054\u0041\u0054\u0049\u0043\u005f\u004b\u0045\u0059\u0029\u003b\u000a\u0009\u0009\u0009\u0061\u0044\u0061\u0074\u0061\u002e\u0061\u0064\u0064\u0028\u0064\u0065\u0063\u0072\u0079\u0070\u0074\u0065\u0064\u0053\u0074\u0072\u0069\u006e\u0067\u0029\u003b\u000a\u0009\u0009\u007d\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0061\u0044\u0061\u0074\u0061\u003b\u0009\u0009\u000a\u0009\u007d\u000a\u0009\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u006d\u0064\u0035\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0069\u006e\u0070\u0075\u0074\u0029\u0020\u0074\u0068\u0072\u006f\u0077\u0073\u0020\u004e\u006f\u0053\u0075\u0063\u0068\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u007b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u0020\u006d\u0064\u0020\u003d\u0020\u004d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u004d\u0044\u0035\u0022\u0029\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0062\u0079\u0074\u0065\u005b\u005d\u0020\u006d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u0020\u003d\u0020\u006d\u0064\u002e\u0064\u0069\u0067\u0065\u0073\u0074\u0028\u0069\u006e\u0070\u0075\u0074\u002e\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0029\u0029\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0042\u0069\u0067\u0049\u006e\u0074\u0065\u0067\u0065\u0072\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0042\u0069\u0067\u0049\u006e\u0074\u0065\u0067\u0065\u0072\u0028\u0031\u002c\u0020\u006d\u0065\u0073\u0073\u0061\u0067\u0065\u0044\u0069\u0067\u0065\u0073\u0074\u0029\u003b\u000a\u0009\u0009\u0072\u0065\u0074\u0075\u0072\u006e\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u002e\u0066\u006f\u0072\u006d\u0061\u0074\u0028\u0022\u0025\u0030\u0033\u0032\u0078\u0022\u002c\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0029\u003b\u000a\u0009\u007d\u000a\u000a\u0009\u0070\u0072\u0069\u0076\u0061\u0074\u0065\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u0020\u0069\u006e\u0069\u0074\u0043\u0069\u0070\u0068\u0065\u0072\u0028\u0066\u0069\u006e\u0061\u006c\u0020\u0069\u006e\u0074\u0020\u006d\u006f\u0064\u0065\u002c\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u0053\u0074\u0072\u0069\u006e\u0067\u002c\u0020\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0029\u000a\u0009\u0009\u0009\u0074\u0068\u0072\u006f\u0077\u0073\u0020\u004e\u006f\u0053\u0075\u0063\u0068\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u002c\u0020\u004e\u006f\u0053\u0075\u0063\u0068\u0050\u0061\u0064\u0064\u0069\u006e\u0067\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u002c\u0020\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u004b\u0065\u0079\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u002c\u000a\u0009\u0009\u0009\u0049\u006e\u0076\u0061\u006c\u0069\u0064\u0041\u006c\u0067\u006f\u0072\u0069\u0074\u0068\u006d\u0050\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u0020\u007b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0053\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0053\u0070\u0065\u0063\u0020\u0073\u006b\u0065\u0079\u0053\u0070\u0065\u0063\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0053\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0053\u0070\u0065\u0063\u0028\u0074\u006f\u0042\u0079\u0074\u0065\u0041\u0072\u0072\u0061\u0079\u0028\u006d\u0064\u0035\u0028\u0073\u0065\u0063\u0072\u0065\u0074\u004b\u0065\u0079\u0029\u0029\u002c\u0020\u0022\u0041\u0045\u0053\u0022\u0029\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0049\u0076\u0050\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0053\u0070\u0065\u0063\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0049\u0076\u0050\u0061\u0072\u0061\u006d\u0065\u0074\u0065\u0072\u0053\u0070\u0065\u0063\u0028\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u0053\u0074\u0072\u0069\u006e\u0067\u002e\u0067\u0065\u0074\u0042\u0079\u0074\u0065\u0073\u0028\u0029\u0029\u003b\u000a\u0009\u0009\u0066\u0069\u006e\u0061\u006c\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u0020\u0063\u0069\u0070\u0068\u0065\u0072\u0020\u003d\u0020\u0043\u0069\u0070\u0068\u0065\u0072\u002e\u0067\u0065\u0074\u0049\u006e\u0073\u0074\u0061\u006e\u0063\u0065\u0028\u0022\u0041\u0045\u0053\u002f\u0043\u0046\u0042\u0038\u002f\u004e\u006f\u0050\u0061\u0064\u0064\u0069\u006e\u0067\u0022\u0029\u003b\u000a\u0009\u0009\u0063\u0069\u0070\u0068\u0065\u0072\u002e\u0069\u006e\u0069\u0074\u0028\u006d\u006f\u0064\u0065\u002c\u0020\u0073\u006b\u0065\u0079\u0053\u0070\u0065\u0063\u002c\u0020\u0069\u006e\u0069\u0074\u0069\u0061\u006c\u0056\u0065\u0063\u0074\u006f\u0072\u0029\u003b\u000a\u0009\u0009