Use Java 7 Language Level

This commit is contained in:
Sn0wStorm 2016-05-27 19:31:05 +02:00
parent 816dacf76b
commit 581dd69f38
18 changed files with 51 additions and 57 deletions

View File

@ -13,7 +13,7 @@ import org.bukkit.material.Cauldron;
import org.bukkit.material.MaterialData; import org.bukkit.material.MaterialData;
public class BCauldron { public class BCauldron {
public static CopyOnWriteArrayList<BCauldron> bcauldrons = new CopyOnWriteArrayList<BCauldron>(); public static CopyOnWriteArrayList<BCauldron> bcauldrons = new CopyOnWriteArrayList<>();
private BIngredients ingredients = new BIngredients(); private BIngredients ingredients = new BIngredients();
private Block block; private Block block;

View File

@ -9,14 +9,14 @@ import org.bukkit.potion.PotionEffectType;
import java.util.*; import java.util.*;
public class BIngredients { public class BIngredients {
public static Set<Material> possibleIngredients = new HashSet<Material>(); public static Set<Material> possibleIngredients = new HashSet<>();
public static ArrayList<BRecipe> recipes = new ArrayList<BRecipe>(); public static ArrayList<BRecipe> recipes = new ArrayList<>();
public static Map<Material, String> cookedNames = new HashMap<Material, String>(); public static Map<Material, String> cookedNames = new HashMap<>();
private static int lastId = 0; private static int lastId = 0;
private int id; private int id;
private ArrayList<ItemStack> ingredients = new ArrayList<ItemStack>(); private ArrayList<ItemStack> ingredients = new ArrayList<>();
private Map<Material, Integer> materials = new HashMap<Material, Integer>(); // Merged List Of ingredients that doesnt consider Durability private Map<Material, Integer> materials = new HashMap<>(); // Merged List Of ingredients that doesnt consider Durability
private int cookedTime; private int cookedTime;
// Represents ingredients in Cauldron, Brew // Represents ingredients in Cauldron, Brew
@ -225,7 +225,7 @@ public class BIngredients {
// when ingredients are not complete // when ingredients are not complete
return -1; return -1;
} }
ArrayList<Material> mergedChecked = new ArrayList<Material>(); ArrayList<Material> mergedChecked = new ArrayList<>();
for (ItemStack ingredient : ingredients) { for (ItemStack ingredient : ingredients) {
if (mergedChecked.contains(ingredient.getType())) { if (mergedChecked.contains(ingredient.getType())) {
// This ingredient type was already checked as part of a merged material // This ingredient type was already checked as part of a merged material
@ -334,7 +334,7 @@ public class BIngredients {
//convert the ingredient Material to String //convert the ingredient Material to String
public Map<String, Integer> serializeIngredients() { public Map<String, Integer> serializeIngredients() {
Map<String, Integer> mats = new HashMap<String, Integer>(); Map<String, Integer> mats = new HashMap<>();
for (ItemStack item : ingredients) { for (ItemStack item : ingredients) {
String mat = item.getType().name() + "," + item.getDurability(); String mat = item.getType().name() + "," + item.getDurability();
mats.put(mat, item.getAmount()); mats.put(mat, item.getAmount());

View File

@ -18,12 +18,12 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
public class BPlayer { public class BPlayer {
private static Map<String, BPlayer> players = new HashMap<String, BPlayer>();// Players name/uuid and BPlayer private static Map<String, BPlayer> players = new HashMap<>();// Players name/uuid and BPlayer
private static Map<Player, Integer> pTasks = new HashMap<Player, Integer>();// Player and count private static Map<Player, Integer> pTasks = new HashMap<>();// Player and count
private static int taskId; private static int taskId;
// Settings // Settings
public static Map<Material, Integer> drainItems = new HashMap<Material, Integer>();// DrainItem Material and Strength public static Map<Material, Integer> drainItems = new HashMap<>();// DrainItem Material and Strength
public static Material pukeItem; public static Material pukeItem;
public static int hangoverTime; public static int hangoverTime;
public static boolean overdrinkKick; public static boolean overdrinkKick;

View File

@ -12,7 +12,7 @@ import java.util.List;
public class BRecipe { public class BRecipe {
private String[] name; private String[] name;
private ArrayList<ItemStack> ingredients = new ArrayList<ItemStack>();// material and amount private ArrayList<ItemStack> ingredients = new ArrayList<>();// material and amount
private int cookingTime;// time to cook in cauldron private int cookingTime;// time to cook in cauldron
private int distillruns;// runs through the brewer private int distillruns;// runs through the brewer
private byte wood;// type of wood the barrel has to consist of private byte wood;// type of wood the barrel has to consist of
@ -20,7 +20,7 @@ public class BRecipe {
private String color;// color of the destilled/finished potion private String color;// color of the destilled/finished potion
private int difficulty;// difficulty to brew the potion, how exact the instruction has to be followed private int difficulty;// difficulty to brew the potion, how exact the instruction has to be followed
private int alcohol;// Alcohol in perfect potion private int alcohol;// Alcohol in perfect potion
private ArrayList<BEffect> effects = new ArrayList<BEffect>(); // Special Effects when drinking private ArrayList<BEffect> effects = new ArrayList<>(); // Special Effects when drinking
public BRecipe(ConfigurationSection configSectionRecipes, String recipeId) { public BRecipe(ConfigurationSection configSectionRecipes, String recipeId) {
String nameList = configSectionRecipes.getString(recipeId + ".name"); String nameList = configSectionRecipes.getString(recipeId + ".name");
@ -244,7 +244,7 @@ public class BRecipe {
int uid = Brew.generateUID(); int uid = Brew.generateUID();
ArrayList<ItemStack> list = new ArrayList<ItemStack>(ingredients.size()); ArrayList<ItemStack> list = new ArrayList<>(ingredients.size());
for (ItemStack item : ingredients) { for (ItemStack item : ingredients) {
if (item.getDurability() == -1) { if (item.getDurability() == -1) {
list.add(new ItemStack(item.getType(), item.getAmount())); list.add(new ItemStack(item.getType(), item.getAmount()));

View File

@ -29,7 +29,7 @@ import org.apache.commons.lang.ArrayUtils;
public class Barrel implements InventoryHolder { public class Barrel implements InventoryHolder {
public static CopyOnWriteArrayList<Barrel> barrels = new CopyOnWriteArrayList<Barrel>(); public static CopyOnWriteArrayList<Barrel> barrels = new CopyOnWriteArrayList<>();
private static int check = 0; private static int check = 0;
private Block spigot; private Block spigot;
@ -766,7 +766,7 @@ public class Barrel implements InventoryHolder {
int endX; int endX;
int endZ; int endZ;
ArrayList<Integer> stairs = new ArrayList<Integer>(); ArrayList<Integer> stairs = new ArrayList<>();
if (direction == 1) { if (direction == 1) {
startX = 1; startX = 1;
@ -839,8 +839,8 @@ public class Barrel implements InventoryHolder {
int endX; int endX;
int endZ; int endZ;
ArrayList<Integer> stairs = new ArrayList<Integer>(); ArrayList<Integer> stairs = new ArrayList<>();
ArrayList<Integer> woods = new ArrayList<Integer>(); ArrayList<Integer> woods = new ArrayList<>();
if (direction == 1) { if (direction == 1) {
startX = 1; startX = 1;

View File

@ -20,7 +20,7 @@ public class Brew {
// represents the liquid in the brewed Potions // represents the liquid in the brewed Potions
public static Map<Integer, Brew> potions = new HashMap<Integer, Brew>(); public static Map<Integer, Brew> potions = new HashMap<>();
public static long installTime = System.currentTimeMillis(); // plugin install time in millis after epoch public static long installTime = System.currentTimeMillis(); // plugin install time in millis after epoch
public static Boolean colorInBarrels; // color the Lore while in Barrels public static Boolean colorInBarrels; // color the Lore while in Barrels
public static Boolean colorInBrewer; // color the Lore while in Brewer public static Boolean colorInBrewer; // color the Lore while in Brewer
@ -150,10 +150,7 @@ public class Brew {
} }
public boolean reloadRecipe() { public boolean reloadRecipe() {
if (currentRecipe != null) { return currentRecipe == null || setRecipeFromString(currentRecipe.getName(5));
return setRecipeFromString(currentRecipe.getName(5));
}
return true;
} }
// Copy a Brew with a new unique ID and return its item // Copy a Brew with a new unique ID and return its item
@ -573,7 +570,7 @@ public class Brew {
meta.setLore(existingLore); meta.setLore(existingLore);
return; return;
} }
List<String> newLore = new ArrayList<String>(); List<String> newLore = new ArrayList<>();
newLore.add(""); newLore.add("");
newLore.add(prefix + lore); newLore.add(prefix + lore);
meta.setLore(newLore); meta.setLore(newLore);
@ -674,7 +671,7 @@ public class Brew {
} }
} }
public static enum PotionColor { public enum PotionColor {
PINK(1, PotionType.REGEN), PINK(1, PotionType.REGEN),
CYAN(2, PotionType.SPEED), CYAN(2, PotionType.SPEED),
ORANGE(3, PotionType.FIRE_RESISTANCE), ORANGE(3, PotionType.FIRE_RESISTANCE),
@ -691,7 +688,7 @@ public class Brew {
private final int colorId; private final int colorId;
private final PotionType type; private final PotionType type;
private PotionColor(int colorId, PotionType type) { PotionColor(int colorId, PotionType type) {
this.colorId = colorId; this.colorId = colorId;
this.type = type; this.type = type;
} }

View File

@ -389,7 +389,7 @@ public class P extends JavaPlugin {
} }
// loading Ingredients into ingMap // loading Ingredients into ingMap
Map<String, BIngredients> ingMap = new HashMap<String, BIngredients>(); Map<String, BIngredients> ingMap = new HashMap<>();
ConfigurationSection section = data.getConfigurationSection("Ingredients"); ConfigurationSection section = data.getConfigurationSection("Ingredients");
if (section != null) { if (section != null) {
for (String id : section.getKeys(false)) { for (String id : section.getKeys(false)) {
@ -430,6 +430,7 @@ public class P extends JavaPlugin {
// keys have players name // keys have players name
for (String name : section.getKeys(false)) { for (String name : section.getKeys(false)) {
try { try {
//noinspection ResultOfMethodCallIgnored
UUID.fromString(name); UUID.fromString(name);
if (!useUUID) { if (!useUUID) {
continue; continue;
@ -462,7 +463,7 @@ public class P extends JavaPlugin {
} }
public ArrayList<ItemStack> deserializeIngredients(ConfigurationSection matSection) { public ArrayList<ItemStack> deserializeIngredients(ConfigurationSection matSection) {
ArrayList<ItemStack> ingredients = new ArrayList<ItemStack>(); ArrayList<ItemStack> ingredients = new ArrayList<>();
for (String mat : matSection.getKeys(false)) { for (String mat : matSection.getKeys(false)) {
String[] matSplit = mat.split(","); String[] matSplit = mat.split(",");
ItemStack item = new ItemStack(Material.getMaterial(matSplit[0]), matSection.getInt(mat)); ItemStack item = new ItemStack(Material.getMaterial(matSplit[0]), matSection.getInt(mat));
@ -763,6 +764,7 @@ public class P extends JavaPlugin {
return msg; return msg;
} }
@SuppressWarnings("ResultOfMethodCallIgnored")
public static void saveFile(InputStream in, File dest, String name) throws IOException { public static void saveFile(InputStream in, File dest, String name) throws IOException {
if (in == null) return; if (in == null) return;
if (!dest.exists()) { if (!dest.exists()) {

View File

@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
public class Wakeup { public class Wakeup {
public static ArrayList<Wakeup> wakeups = new ArrayList<Wakeup>(); public static ArrayList<Wakeup> wakeups = new ArrayList<>();
public static P p = P.p; public static P p = P.p;
public static int checkId = -1; public static int checkId = -1;
public static Player checkPlayer = null; public static Player checkPlayer = null;
@ -28,7 +28,7 @@ public class Wakeup {
return null; return null;
} }
ArrayList<Wakeup> worldWakes = new ArrayList<Wakeup>(); ArrayList<Wakeup> worldWakes = new ArrayList<>();
for (Wakeup wakeup : wakeups) { for (Wakeup wakeup : wakeups) {
if (wakeup.active) { if (wakeup.active) {
@ -44,6 +44,7 @@ public class Wakeup {
Wakeup w1 = calcRandom(worldWakes); Wakeup w1 = calcRandom(worldWakes);
worldWakes.remove(w1); worldWakes.remove(w1);
if (w1 == null) return null;
while (!w1.check()) { while (!w1.check()) {
p.errorLog("Please Check Wakeup-Location with id: &6" + wakeups.indexOf(w1)); p.errorLog("Please Check Wakeup-Location with id: &6" + wakeups.indexOf(w1));
@ -119,7 +120,7 @@ public class Wakeup {
return; return;
} }
ArrayList<String> locs = new ArrayList<String>(); ArrayList<String> locs = new ArrayList<>();
for (int id = 0; id < wakeups.size(); id++) { for (int id = 0; id < wakeups.size(); id++) {
Wakeup wakeup = wakeups.get(id); Wakeup wakeup = wakeups.get(id);

View File

@ -15,13 +15,13 @@ public class Words {
// represends Words and letters, that are replaced in drunk players messages // represends Words and letters, that are replaced in drunk players messages
public static ArrayList<Words> words = new ArrayList<Words>(); public static ArrayList<Words> words = new ArrayList<>();
public static List<String> commands; public static List<String> commands;
public static List<String[]> ignoreText = new ArrayList<String[]>(); public static List<String[]> ignoreText = new ArrayList<>();
public static FileConfiguration config; public static FileConfiguration config;
public static Boolean doSigns; public static Boolean doSigns;
public static Boolean log; public static Boolean log;
private static Map<String, Long> waitPlayers = new HashMap<String, Long>(); private static Map<String, Long> waitPlayers = new HashMap<>();
private String from; private String from;
private String to; private String to;
@ -270,19 +270,11 @@ public class Words {
boolean isBefore = !match; boolean isBefore = !match;
if (pre != null) { if (pre != null) {
for (String pr : pre) { for (String pr : pre) {
if (match) { if (part.endsWith(pr)) {
// if one is correct, it is enough // If a match is wanted set isBefore to true, else to false
if (part.endsWith(pr) == match) { isBefore = match;
isBefore = true;
break; break;
} }
} else {
// if one is wrong, its over
if (part.endsWith(pr) != match) {
isBefore = false;
break;
}
}
} }
} else { } else {
isBefore = true; isBefore = true;

View File

@ -13,7 +13,7 @@ import com.dre.brewery.P;
public class ConfigUpdater { public class ConfigUpdater {
private ArrayList<String> config = new ArrayList<String>(); private ArrayList<String> config = new ArrayList<>();
private File file; private File file;
public ConfigUpdater(File file) { public ConfigUpdater(File file) {

View File

@ -54,7 +54,7 @@ public class DataSave extends BukkitRunnable {
} }
try { try {
cancel(); cancel();
} catch (IllegalStateException e) { } catch (IllegalStateException ignored) {
} }
FileConfiguration configFile = new YamlConfiguration(); FileConfiguration configFile = new YamlConfiguration();

View File

@ -51,7 +51,7 @@ public class DataUpdater {
ConfigurationSection matSection = section.getConfigurationSection(id + ".mats"); ConfigurationSection matSection = section.getConfigurationSection(id + ".mats");
if (matSection != null) { if (matSection != null) {
// matSection has all the materials + amount as Integers // matSection has all the materials + amount as Integers
Map<String, Integer> ingredients = new HashMap<String, Integer>(); Map<String, Integer> ingredients = new HashMap<>();
for (String ingredient : matSection.getKeys(false)) { for (String ingredient : matSection.getKeys(false)) {
// convert to Material // convert to Material
Material mat = Material.getMaterial(P.p.parseInt(ingredient)); Material mat = Material.getMaterial(P.p.parseInt(ingredient));
@ -81,7 +81,7 @@ public class DataUpdater {
ConfigurationSection ingredientSection = cauldrons.getConfigurationSection(id + ".ingredients"); ConfigurationSection ingredientSection = cauldrons.getConfigurationSection(id + ".ingredients");
if (ingredientSection != null) { if (ingredientSection != null) {
// has all the materials + amount as Integers // has all the materials + amount as Integers
Map<String, Integer> ingredients = new HashMap<String, Integer>(); Map<String, Integer> ingredients = new HashMap<>();
for (String ingredient : ingredientSection.getKeys(false)) { for (String ingredient : ingredientSection.getKeys(false)) {
// convert to Material // convert to Material
Material mat = Material.getMaterial(P.p.parseInt(ingredient)); Material mat = Material.getMaterial(P.p.parseInt(ingredient));

View File

@ -10,8 +10,8 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
public class LanguageReader { public class LanguageReader {
private Map<String, String> entries = new TreeMap<String, String>(); private Map<String, String> entries = new TreeMap<>();
private Map<String, String> defaults = new TreeMap<String, String>(); private Map<String, String> defaults = new TreeMap<>();
private File file; private File file;
private boolean changed; private boolean changed;
@ -143,6 +143,7 @@ public class LanguageReader {
} }
} }
@SuppressWarnings("ResultOfMethodCallIgnored")
public void save() { public void save() {
if (changed) { if (changed) {
/* Copy old File */ /* Copy old File */

View File

@ -14,6 +14,7 @@ public class ReadOldData extends BukkitRunnable {
public FileConfiguration data; public FileConfiguration data;
public boolean done = false; public boolean done = false;
@SuppressWarnings("ResultOfMethodCallIgnored")
@Override @Override
public void run() { public void run() {
File datafile = new File(P.p.getDataFolder(), "data.yml"); File datafile = new File(P.p.getDataFolder(), "data.yml");

View File

@ -17,7 +17,7 @@ import static de.diddiz.util.BukkitUtils.compressInventory;
import static de.diddiz.util.BukkitUtils.rawData; import static de.diddiz.util.BukkitUtils.rawData;
public class LogBlockBarrel { public class LogBlockBarrel {
private static final List<LogBlockBarrel> opened = new ArrayList<LogBlockBarrel>(); private static final List<LogBlockBarrel> opened = new ArrayList<>();
public static Consumer consumer = LogBlock.getInstance().getConsumer(); public static Consumer consumer = LogBlock.getInstance().getConsumer();
private HumanEntity player; private HumanEntity player;

View File

@ -5,5 +5,5 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
public interface WGBarrel { public interface WGBarrel {
public abstract boolean checkAccess(Player player, Block spigot, Plugin plugin); boolean checkAccess(Player player, Block spigot, Plugin plugin);
} }

View File

@ -163,7 +163,7 @@ public class CommandListener implements CommandExecutor {
public ArrayList<String> getCommands(CommandSender sender) { public ArrayList<String> getCommands(CommandSender sender) {
ArrayList<String> cmds = new ArrayList<String>(); ArrayList<String> cmds = new ArrayList<>();
cmds.add(p.languageReader.get("Help_Help")); cmds.add(p.languageReader.get("Help_Help"));
if (sender.hasPermission("brewery.cmd.player")) { if (sender.hasPermission("brewery.cmd.player")) {

View File

@ -40,8 +40,8 @@ import java.util.UUID;
public class InventoryListener implements Listener { public class InventoryListener implements Listener {
/* === Recreating manually the prior BrewEvent behavior. === */ /* === Recreating manually the prior BrewEvent behavior. === */
private HashSet<UUID> trackedBrewmen = new HashSet<UUID>(); private HashSet<UUID> trackedBrewmen = new HashSet<>();
private HashMap<Block, Integer> trackedBrewers = new HashMap<Block, Integer>(); private HashMap<Block, Integer> trackedBrewers = new HashMap<>();
private static final int DISTILLTIME = 401; private static final int DISTILLTIME = 401;
/** /**