Fix formating

- Removed all remaining tabs (not sure how to got through the last
cleanup).
- Updated some comments.
This commit is contained in:
Pim van der Loos 2019-04-18 17:11:18 +02:00
parent da224bfc1a
commit 4b5de17bb6
No known key found for this signature in database
GPG Key ID: C16F020ADAE6D5A8
8 changed files with 110 additions and 113 deletions

View File

@ -10,21 +10,21 @@ import nl.pim16aap2.armoredElytra.util.ArmorTier;
public class FlyDurabilityHandler implements Listener public class FlyDurabilityHandler implements Listener
{ {
private final NBTEditor nbtEditor; private final NBTEditor nbtEditor;
public FlyDurabilityHandler(NBTEditor nbtEditor) public FlyDurabilityHandler(NBTEditor nbtEditor)
{ {
this.nbtEditor = nbtEditor; this.nbtEditor = nbtEditor;
} }
// Do not decrease elytra durability while flying. This also cancels durability decrease when // Do not decrease elytra durability while flying. This also cancels durability decrease when
// it should (i.e. getting hit) while flying, but I don't really care. // it should (i.e. getting hit) while flying, but I don't really care.
@EventHandler @EventHandler
public void onItemDamage(PlayerItemDamageEvent e) public void onItemDamage(PlayerItemDamageEvent e)
{ {
if (e.getItem().getType() == Material.ELYTRA) if (e.getItem().getType() == Material.ELYTRA)
if (nbtEditor.getArmorTier(e.getItem()) != ArmorTier.NONE) if (nbtEditor.getArmorTier(e.getItem()) != ArmorTier.NONE)
if (e.getPlayer().isFlying()) if (e.getPlayer().isFlying())
e.setCancelled(true); e.setCancelled(true);
} }
} }

View File

@ -17,7 +17,6 @@ public class GetArmorValueOld implements GetArmorValue
int pos = nbtString.indexOf(",Slot:\"chest\",AttributeName:\"generic.armor\""); int pos = nbtString.indexOf(",Slot:\"chest\",AttributeName:\"generic.armor\"");
if (pos > 0) if (pos > 0)
{ {
// If so, get the value of the generic.armor attribute.
pos--; pos--;
String stringAtPos = nbtString.substring(pos, pos + 1); String stringAtPos = nbtString.substring(pos, pos + 1);
return Integer.parseInt(stringAtPos); return Integer.parseInt(stringAtPos);

View File

@ -74,8 +74,7 @@ public class NBTEditor
return; return;
} }
// Old versions use the old format. It is assumed here that all versions from 1.13.2 on will use the // Old versions use the old format. It is assumed here that all versions from 1.13.2 on will use the new format.
// new format. Might want to put this in a nice interface instead of an ugly boolean.
// Spigot's 1.13.1 uses the old format, but 1.13.2 uses the new format. They share the same version number though. // Spigot's 1.13.1 uses the old format, but 1.13.2 uses the new format. They share the same version number though.
if (version.equals("v1_9_R1" ) || version.equals("v1_9_R2" ) || version.equals("v1_10_R1") || if (version.equals("v1_9_R1" ) || version.equals("v1_9_R2" ) || version.equals("v1_10_R1") ||
version.equals("v1_11_R1") || version.equals("v1_12_R1") || version.equals("v1_13_R1") || version.equals("v1_11_R1") || version.equals("v1_12_R1") || version.equals("v1_13_R1") ||
@ -113,8 +112,8 @@ public class NBTEditor
NBTTagInt = getNMSClass("NBTTagInt"); NBTTagInt = getNMSClass("NBTTagInt");
NBTTagIntCtor = NBTTagInt.getConstructor(int.class); NBTTagIntCtor = NBTTagInt.getConstructor(int.class);
NBTTagCompound = getNMSClass("NBTTagCompound"); NBTTagCompound = getNMSClass("NBTTagCompound");
setTag = NBTTagCompound.getMethod("set", String.class, NBTBase); setTag = NBTTagCompound.getMethod("set", String.class, NBTBase);
NBTTagList = getNMSClass("NBTTagList"); NBTTagList = getNMSClass("NBTTagList");
addCompound = NBTTagList.getMethod("add", NBTBase); addCompound = NBTTagList.getMethod("add", NBTBase);
@ -219,7 +218,6 @@ public class NBTEditor
} }
} }
private Class<?> getNMSClass(String name) throws ClassNotFoundException private Class<?> getNMSClass(String name) throws ClassNotFoundException
{ {
return Class.forName(NMSbase + name); return Class.forName(NMSbase + name);

View File

@ -2,5 +2,5 @@ package nl.pim16aap2.armoredElytra.util;
public enum Action public enum Action
{ {
NONE, REPAIR, ENCHANT, COMBINE, CREATE, BLOCK NONE, REPAIR, ENCHANT, COMBINE, CREATE, BLOCK
} }

View File

@ -4,17 +4,17 @@ import org.bukkit.Material;
public enum ArmorTier public enum ArmorTier
{ {
// Tier: tier armor-value, tier armor-toughness, repair // Tier: armor-value, armor-toughness, repair
NONE (0 , 0 , null ), NONE (0 , 0 , null ),
LEATHER (3 , 0 , Material.LEATHER ), LEATHER (3 , 0 , Material.LEATHER ),
GOLD (5 , 0 , Material.GOLD_INGOT), GOLD (5 , 0 , Material.GOLD_INGOT),
CHAIN (5 , 0 , Material.IRON_INGOT), CHAIN (5 , 0 , Material.IRON_INGOT),
IRON (6 , 0 , Material.IRON_INGOT), IRON (6 , 0 , Material.IRON_INGOT),
DIAMOND (8 , 2 , Material.DIAMOND ); DIAMOND (8 , 2 , Material.DIAMOND );
private int armor; private int armor;
private int toughness; private int toughness;
private Material repair; private Material repair;
private ArmorTier (int armor, int toughness, Material repair) private ArmorTier (int armor, int toughness, Material repair)
{ {

View File

@ -13,67 +13,67 @@ import nl.pim16aap2.armoredElytra.ArmoredElytra;
public class Messages public class Messages
{ {
private Map<String, String> messageMap = new HashMap<String, String>(); private Map<String, String> messageMap = new HashMap<>();
private ArmoredElytra plugin; private ArmoredElytra plugin;
private String locale; private String locale;
private File textFile; private File textFile;
public Messages(ArmoredElytra plugin) public Messages(ArmoredElytra plugin)
{ {
this.plugin = plugin; this.plugin = plugin;
this.locale = plugin.getLocale(); locale = plugin.getLocale();
textFile = new File(plugin.getDataFolder(), locale + ".txt"); textFile = new File(plugin.getDataFolder(), locale + ".txt");
readFile(); readFile();
} }
// Read locale file. // Read locale file.
private void readFile() private void readFile()
{ {
// Load the default en_US from the resources. // Load the default en_US from the resources.
plugin.saveResource("en_US.txt", true); plugin.saveResource("en_US.txt", true);
try (BufferedReader br = new BufferedReader(new FileReader(this.textFile))) try (BufferedReader br = new BufferedReader(new FileReader(textFile)))
{ {
String sCurrentLine; String sCurrentLine;
while ((sCurrentLine = br.readLine()) != null) while ((sCurrentLine = br.readLine()) != null)
{ {
String key, value; String key, value;
String[] parts = sCurrentLine.split("=", 2); String[] parts = sCurrentLine.split("=", 2);
key = parts[0]; key = parts[0];
value = parts[1].replaceAll("&((?i)[0-9a-fk-or])", "\u00A7$1"); value = parts[1].replaceAll("&((?i)[0-9a-fk-or])", "\u00A7$1");
String[] newLineSplitter = value.split("\\\\n"); // Wut? Can I haz more backslash? String[] newLineSplitter = value.split("\\\\n"); // Wut? Can I haz more backslash?
String values = newLineSplitter[0]; String values = newLineSplitter[0];
for (int idx = 1; idx < newLineSplitter.length; ++idx) for (int idx = 1; idx < newLineSplitter.length; ++idx)
values += "\n" + newLineSplitter[idx]; values += "\n" + newLineSplitter[idx];
this.messageMap.put(key, values); messageMap.put(key, values);
} }
br.close(); br.close();
} }
catch (FileNotFoundException e) catch (FileNotFoundException e)
{ {
plugin.myLogger(Level.SEVERE, "Locale file " + this.locale + ".txt does not exist!"); plugin.myLogger(Level.SEVERE, "Locale file " + locale + ".txt does not exist!");
} }
catch (IOException e) catch (IOException e)
{ {
plugin.myLogger(Level.SEVERE, "Could not read locale file! (" + this.locale + ".txt)"); plugin.myLogger(Level.SEVERE, "Could not read locale file! (" + locale + ".txt)");
e.printStackTrace(); e.printStackTrace();
} }
} }
// Get a string from a key. Returns "null" if null. // Get a string from a key. Returns "null" if null.
public String getString(String key) public String getString(String key)
{ {
String value = null; String value = null;
value = this.messageMap.get(key); value = messageMap.get(key);
if (value == null) if (value == null)
{ {
value = "ArmoredElytra: Translation not found! Contact server admin!"; value = "ArmoredElytra: Translation not found! Contact server admin!";
plugin.myLogger(Level.WARNING, "Failed to get translation for key " + key); plugin.myLogger(Level.WARNING, "Failed to get translation for key " + key);
} }
return value; return value;
} }
} }

View File

@ -133,7 +133,7 @@ public class Update
JSONObject latest = (JSONObject) array.get(array.size() - 1); JSONObject latest = (JSONObject) array.get(array.size() - 1);
// Get the version's title // Get the version's title
this.versionName = (String) latest.get(API_NAME_VALUE); versionName = (String) latest.get(API_NAME_VALUE);
} }
} }
catch (IOException e) catch (IOException e)
@ -141,7 +141,7 @@ public class Update
// There was an error reading the query. // There was an error reading the query.
// Does not print stacktrace, so people won't see any errors from this plugin // Does not print stacktrace, so people won't see any errors from this plugin
// when Bukkit Dev's servers are down, // when Bukkit Dev's servers are down,
// So people won't think the plugin is broken, while the actualy problem is // So people won't think the plugin is broken, while the actual problem is
// much, much smaller. latestVersion will be null, though, which will prompt a // much, much smaller. latestVersion will be null, though, which will prompt a
// warning in the log instead. // warning in the log instead.

View File

@ -9,7 +9,7 @@ import org.bukkit.inventory.ItemStack;
public class Util public class Util
{ {
// Check if an item is broken or not. // Check if an item is broken or not.
public static boolean isBroken(ItemStack item) public static boolean isBroken(ItemStack item)
{ {
return item.getDurability() >= item.getType().getMaxDurability(); return item.getDurability() >= item.getType().getMaxDurability();