aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/util/player
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2017-03-04 12:58:47 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2017-03-04 12:58:47 +1000
commitae21012d216df71f31aed6fbc9d76215fc24ceed (patch)
treecc89accbe6ce5c04b72ed3c5e46b2a185f88be6a /src/Java/gtPlusPlus/core/util/player
parentba89972a22a316030f8c3bd99974f915b1d7aefc (diff)
downloadGT5-Unofficial-ae21012d216df71f31aed6fbc9d76215fc24ceed.tar.gz
GT5-Unofficial-ae21012d216df71f31aed6fbc9d76215fc24ceed.tar.bz2
GT5-Unofficial-ae21012d216df71f31aed6fbc9d76215fc24ceed.zip
+ New texture for the slow builders ring.
+ Added the Alkalus Disk. $ Fixed Frame Box Assembler Recipes. $ Fixed Missing 7Li material. $ Fixed Tiered Tanks not showing their capacity in the tooltip. $ Fixed tooltips for alloys containing Bronze or Steel. $ Fixed Clay Pipe Extruder Recipes. - Removed a handful of Plasma cells for misc. materials. % Changed the Industrial Coke Oven's tooltip, to better describe the input/output requirements. % Cleaned up The Entire Project.
Diffstat (limited to 'src/Java/gtPlusPlus/core/util/player')
-rw-r--r--src/Java/gtPlusPlus/core/util/player/PlayerCache.java79
-rw-r--r--src/Java/gtPlusPlus/core/util/player/PlayerUtils.java78
-rw-r--r--src/Java/gtPlusPlus/core/util/player/UtilsMining.java84
3 files changed, 131 insertions, 110 deletions
diff --git a/src/Java/gtPlusPlus/core/util/player/PlayerCache.java b/src/Java/gtPlusPlus/core/util/player/PlayerCache.java
index 85bba2470a..99635d8fe9 100644
--- a/src/Java/gtPlusPlus/core/util/player/PlayerCache.java
+++ b/src/Java/gtPlusPlus/core/util/player/PlayerCache.java
@@ -1,11 +1,10 @@
package gtPlusPlus.core.util.player;
-import gtPlusPlus.core.lib.CORE;
-import gtPlusPlus.core.util.Utils;
-
import java.io.*;
import java.util.*;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.util.Utils;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
@@ -19,11 +18,11 @@ public class PlayerCache {
if (cache != null){
CORE.PlayerCache = PlayerCache.readPropertiesFileAsMap();
- Utils.LOG_INFO("Loaded PlayerCache.dat");
+ Utils.LOG_INFO("Loaded PlayerCache.dat");
}
- } catch (Exception e) {
+ } catch (final Exception e) {
Utils.LOG_INFO("Failed to initialise PlayerCache.dat");
PlayerCache.createPropertiesFile("PLAYER_", "DATA");
//e.printStackTrace();
@@ -31,21 +30,21 @@ public class PlayerCache {
}
}
- public static void createPropertiesFile(String playerName, String playerUUIDasString) {
+ public static void createPropertiesFile(final String playerName, final String playerUUIDasString) {
try {
- Properties props = new Properties();
+ final Properties props = new Properties();
props.setProperty(playerName+" ", playerUUIDasString);
- OutputStream out = new FileOutputStream(cache);
+ final OutputStream out = new FileOutputStream(cache);
props.store(out, "Player Cache.");
Utils.LOG_INFO("PlayerCache.dat created for future use.");
}
- catch (Exception e ) {
+ catch (final Exception e ) {
e.printStackTrace();
}
}
- public static void appendParamChanges(String playerName, String playerUUIDasString) {
- HashMap<String, UUID> playerInfo = new HashMap<String, UUID>();
+ public static void appendParamChanges(final String playerName, final String playerUUIDasString) {
+ final HashMap<String, UUID> playerInfo = new HashMap<>();
playerInfo.put(playerName, UUID.fromString(playerUUIDasString));
/*try {
@@ -66,49 +65,54 @@ public class PlayerCache {
try
{
- FileOutputStream fos = new FileOutputStream("PlayerCache.dat");
- ObjectOutputStream oos = new ObjectOutputStream(fos);
+ final FileOutputStream fos = new FileOutputStream("PlayerCache.dat");
+ final 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) {
+ catch (final IOException e) {
Utils.LOG_INFO("No PlayerCache file found, creating one.");
createPropertiesFile(playerName, playerUUIDasString);
- }
+ }
}
/**
- * Reads a "properties" file, and returns it as a Map
+ * Reads a "properties" file, and returns it as a Map
* (a collection of key/value pairs).
- *
+ *
* Credit due to Alvin Alexander - http://alvinalexander.com/java/java-properties-file-map-example?nocache=1#comment-8215
* Changed slightly as the filename and delimiter are constant in my case.
- *
+ *
* @param filename The properties filename to read.
- * @param delimiter The string (or character) that separates the key
+ * @param delimiter The string (or character) that separates the key
* from the value in the properties file.
* @return The Map that contains the key/value pairs.
* @throws Exception
*/
@Deprecated
public static Map<String, String> readPropertiesFileAsMapOld() throws Exception {
- String delimiter = "=";
+ final String delimiter = "=";
@SuppressWarnings({ "rawtypes", "unchecked" })
- Map<String, String> map = new HashMap<String, String>();
- BufferedReader reader = new BufferedReader(new FileReader(cache));
+ final
+ Map<String, String> map = new HashMap<>();
+ final BufferedReader reader = new BufferedReader(new FileReader(cache));
String line;
while ((line = reader.readLine()) != null)
{
- if (line.trim().length()==0) continue;
- if (line.charAt(0)=='#') continue;
+ if (line.trim().length()==0) {
+ continue;
+ }
+ if (line.charAt(0)=='#') {
+ continue;
+ }
// assumption here is that proper lines are like "String : <a href="http://xxx.yyy.zzz/foo/bar"" title="http://xxx.yyy.zzz/foo/bar"">http://xxx.yyy.zzz/foo/bar"</a>,
// and the ":" is the delimiter
- int delimPosition = line.indexOf(delimiter);
- String key = line.substring(0, delimPosition-1).trim();
- String value = line.substring(delimPosition+1).trim();
+ final int delimPosition = line.indexOf(delimiter);
+ final String key = line.substring(0, delimPosition-1).trim();
+ final String value = line.substring(delimPosition+1).trim();
map.put(key, value);
}
reader.close();
@@ -120,16 +124,16 @@ public class PlayerCache {
HashMap<String, UUID> map = null;
try
{
- FileInputStream fis = new FileInputStream(cache);
- ObjectInputStream ois = new ObjectInputStream(fis);
+ final FileInputStream fis = new FileInputStream(cache);
+ final ObjectInputStream ois = new ObjectInputStream(fis);
map = (HashMap<String, UUID>) ois.readObject();
ois.close();
fis.close();
- }catch(IOException ioe)
+ }catch(final IOException ioe)
{
- ioe.printStackTrace();
+ ioe.printStackTrace();
return null;
- }catch(ClassNotFoundException c)
+ }catch(final ClassNotFoundException c)
{
Utils.LOG_INFO("Class not found");
c.printStackTrace();
@@ -139,15 +143,16 @@ public class PlayerCache {
return map;
}
- public static String lookupPlayerByUUID(UUID UUID){
- if (UUID == null)
+ public static String lookupPlayerByUUID(final UUID UUID){
+ if (UUID == null) {
return null;
- List<EntityPlayerMP> allPlayers = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
- for (EntityPlayerMP player : allPlayers) {
+ }
+ final List<EntityPlayerMP> allPlayers = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
+ for (final EntityPlayerMP player : allPlayers) {
if (player.getUniqueID().equals(UUID)) {
return player.getDisplayName();
}
- }
+ }
return "Offline Player.";
}
}
diff --git a/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java b/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java
index f81ad561da..6a2253ab54 100644
--- a/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java
+++ b/src/Java/gtPlusPlus/core/util/player/PlayerUtils.java
@@ -2,6 +2,8 @@ package gtPlusPlus.core.util.player;
import java.util.*;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -9,41 +11,39 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
public class PlayerUtils {
- public static void messagePlayer(EntityPlayer P, String S){
+ public static void messagePlayer(final EntityPlayer P, final String S){
gregtech.api.util.GT_Utility.sendChatToPlayer(P, S);
}
- public static EntityPlayer getPlayer(String name){
- List<EntityPlayer> i = new ArrayList<EntityPlayer>();
- Iterator<EntityPlayer> crunchifyIterator = MinecraftServer.getServer().getConfigurationManager().playerEntityList.iterator();
+ public static EntityPlayer getPlayer(final String name){
+ final List<EntityPlayer> i = new ArrayList<>();
+ final Iterator<EntityPlayer> crunchifyIterator = MinecraftServer.getServer().getConfigurationManager().playerEntityList.iterator();
while (crunchifyIterator.hasNext()) {
i.add((crunchifyIterator.next()));
- }
+ }
try{
- for (EntityPlayer temp : i) {
+ for (final EntityPlayer temp : i) {
if (temp.getDisplayName().toLowerCase().equals(name.toLowerCase())){
return temp;
}
}
}
- catch(NullPointerException e){}
+ catch(final NullPointerException e){}
return null;
}
-
- public static EntityPlayer getPlayerOnServerFromUUID(UUID parUUID){
- if (parUUID == null)
+
+ public static EntityPlayer getPlayerOnServerFromUUID(final UUID parUUID){
+ if (parUUID == null)
{
return null;
}
- List<EntityPlayerMP> allPlayers = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
- for (EntityPlayerMP player : allPlayers)
+ final List<EntityPlayerMP> allPlayers = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
+ for (final EntityPlayerMP player : allPlayers)
{
- if (player.getUniqueID().equals(parUUID))
+ if (player.getUniqueID().equals(parUUID))
{
return player;
}
@@ -52,21 +52,21 @@ public class PlayerUtils {
}
//Not Clientside
- public static EntityPlayer getPlayerInWorld(World world, String Name){
- List<EntityPlayer> i = world.playerEntities;
- Minecraft mc = Minecraft.getMinecraft();
- try{
- for (EntityPlayer temp : i) {
- if (temp.getDisplayName().toLowerCase().equals(Name.toLowerCase())){
- return temp;
- }
+ public static EntityPlayer getPlayerInWorld(final World world, final String Name){
+ final List<EntityPlayer> i = world.playerEntities;
+ final Minecraft mc = Minecraft.getMinecraft();
+ try{
+ for (final EntityPlayer temp : i) {
+ if (temp.getDisplayName().toLowerCase().equals(Name.toLowerCase())){
+ return temp;
}
}
- catch(NullPointerException e){}
- return null;
}
+ catch(final NullPointerException e){}
+ return null;
+ }
- public static boolean isPlayerOP(EntityPlayer player){
+ public static boolean isPlayerOP(final EntityPlayer player){
if (player.canCommandSenderUseCommand(2, "")){
return true;
}
@@ -74,11 +74,11 @@ public class PlayerUtils {
}
//Not Clientside
- public static ItemStack getItemStackInPlayersHand(World world, String Name){
- EntityPlayer thePlayer = getPlayer(Name);
+ public static ItemStack getItemStackInPlayersHand(final World world, final String Name){
+ final EntityPlayer thePlayer = getPlayer(Name);
ItemStack heldItem = null;
try{heldItem = thePlayer.getHeldItem();
- }catch(NullPointerException e){return null;}
+ }catch(final NullPointerException e){return null;}
if (heldItem != null){
return heldItem;
}
@@ -87,21 +87,21 @@ public class PlayerUtils {
@SideOnly(Side.CLIENT)
public static ItemStack getItemStackInPlayersHand(){
- Minecraft mc = Minecraft.getMinecraft();
+ final Minecraft mc = Minecraft.getMinecraft();
ItemStack heldItem = null;
try{heldItem = mc.thePlayer.getHeldItem();
- }catch(NullPointerException e){return null;}
+ }catch(final NullPointerException e){return null;}
if (heldItem != null){
return heldItem;
}
return null;
}
-
+
@SideOnly(Side.SERVER)
- public static ItemStack getItemStackInPlayersHand(EntityPlayer player){
+ public static ItemStack getItemStackInPlayersHand(final EntityPlayer player){
ItemStack heldItem = null;
try{heldItem = player.getHeldItem();
- }catch(NullPointerException e){return null;}
+ }catch(final NullPointerException e){return null;}
if (heldItem != null){
return heldItem;
}
@@ -110,16 +110,16 @@ public class PlayerUtils {
@SideOnly(Side.CLIENT)
public static Item getItemInPlayersHand(){
- Minecraft mc = Minecraft.getMinecraft();
+ final Minecraft mc = Minecraft.getMinecraft();
Item heldItem = null;
-
+
try{heldItem = mc.thePlayer.getHeldItem().getItem();
- }catch(NullPointerException e){return null;}
-
+ }catch(final NullPointerException e){return null;}
+
if (heldItem != null){
return heldItem;
}
-
+
return null;
}
diff --git a/src/Java/gtPlusPlus/core/util/player/UtilsMining.java b/src/Java/gtPlusPlus/core/util/player/UtilsMining.java
index 8468c4b3a2..d52dd7ee88 100644
--- a/src/Java/gtPlusPlus/core/util/player/UtilsMining.java
+++ b/src/Java/gtPlusPlus/core/util/player/UtilsMining.java
@@ -7,38 +7,38 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
public class UtilsMining {
-
+
private static boolean durabilityDamage = false;
private static ItemStack stack;
- public static Boolean canPickaxeBlock(Block currentBlock, World currentWorld){
+ public static Boolean canPickaxeBlock(final Block currentBlock, final World currentWorld){
String correctTool = "";
- if (!currentWorld.isRemote){
+ if (!currentWorld.isRemote){
try {
correctTool = currentBlock.getHarvestTool(0);
//Utils.LOG_WARNING(correctTool);
if (correctTool.equals("pickaxe")){
return true;}
- } catch (NullPointerException e){
+ } catch (final NullPointerException e){
return false;}
}
return false;
}
-
- private static void removeBlockAndDropAsItem(World world, int X, int Y, int Z){
+
+ private static void removeBlockAndDropAsItem(final World world, final int X, final int Y, final int Z){
try {
- Block block = world.getBlock(X, Y, Z);
- if (canPickaxeBlock(block, world)){
- if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) != -1) && (block.getBlockHardness(world, X, Y, Z) <= 100) && (block != Blocks.water) && (block != Blocks.lava)){
- block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0);
- world.setBlockToAir(X, Y, Z);
+ final Block block = world.getBlock(X, Y, Z);
+ if (canPickaxeBlock(block, world)){
+ if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) != -1) && (block.getBlockHardness(world, X, Y, Z) <= 100) && (block != Blocks.water) && (block != Blocks.lava)){
+ block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0);
+ world.setBlockToAir(X, Y, Z);
}
else {
Utils.LOG_WARNING("Incorrect Tool for mining this block.");
}
}
- } catch (NullPointerException e){
+ } catch (final NullPointerException e){
}
}
@@ -71,7 +71,7 @@ public class UtilsMining {
for(int j = -2; j < 3; j++) {
for(int k = -2; k < 3; k++) {
// float dur = calculateDurabilityLoss(world, X + i, Y + k, Z + j);
-// DURABILITY_LOSS = (DURABILITY_LOSS + dur);
+// DURABILITY_LOSS = (DURABILITY_LOSS + dur);
// Utils.LOG_WARNING("Added Loss: "+dur);
removeBlockAndDropAsItem(world, X + i, Y + k, Z + j);
}
@@ -88,7 +88,7 @@ public class UtilsMining {
X = (int) aPlayer.posX + 1;}
else {
X = (int) aPlayer.posX - 1;}
-
+
DURABILITY_LOSS = 0;
for(int i = -1; i < 2; i++) {
@@ -108,12 +108,12 @@ public class UtilsMining {
//Set Player Facing
X = (int) aPlayer.posX;
Y = (int) aPlayer.posY;
-
+
if (FACING.equals("facingNorth")){
Z = (int) aPlayer.posZ + 1;}
else {
Z = (int) aPlayer.posZ - 1;}
-
+
DURABILITY_LOSS = 0;
for(int i = -1; i < 2; i++) {
for(int j = -1; j < 2; j++) {
@@ -137,9 +137,9 @@ public class UtilsMining {
DURABILITY_LOSS = 0;
}
}*/
-
-
- public static boolean getBlockType(Block block, World world, int[] xyz, int miningLevel){
+
+
+ public static boolean getBlockType(final Block block, final World world, final int[] xyz, final int miningLevel){
final String LIQUID = "liquid";
final String BLOCK = "block";
final String ORE = "ore";
@@ -149,18 +149,34 @@ public class UtilsMining {
if (world.isRemote){
return false;
}
-
- if (block == Blocks.end_stone) return true;
- if (block == Blocks.stone) return true;
- if (block == Blocks.sandstone) return true;
- if (block == Blocks.netherrack) return true;
- if (block == Blocks.nether_brick) return true;
- if (block == Blocks.nether_brick_stairs) return true;
- if (block == Blocks.nether_brick_fence) return true;
- if (block == Blocks.glowstone) return true;
-
-
-
+
+ if (block == Blocks.end_stone) {
+ return true;
+ }
+ if (block == Blocks.stone) {
+ return true;
+ }
+ if (block == Blocks.sandstone) {
+ return true;
+ }
+ if (block == Blocks.netherrack) {
+ return true;
+ }
+ if (block == Blocks.nether_brick) {
+ return true;
+ }
+ if (block == Blocks.nether_brick_stairs) {
+ return true;
+ }
+ if (block == Blocks.nether_brick_fence) {
+ return true;
+ }
+ if (block == Blocks.glowstone) {
+ return true;
+ }
+
+
+
try {
blockClass = block.getClass().toString().toLowerCase();
Utils.LOG_WARNING(blockClass);
@@ -189,10 +205,10 @@ public class UtilsMining {
return false;
}
}
- catch(NullPointerException e){
+ catch(final NullPointerException e){
return false;
}
}
-
-
+
+
}