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;
public class BCauldron {
public static CopyOnWriteArrayList<BCauldron> bcauldrons = new CopyOnWriteArrayList<BCauldron>();
public static CopyOnWriteArrayList<BCauldron> bcauldrons = new CopyOnWriteArrayList<>();
private BIngredients ingredients = new BIngredients();
private Block block;

View File

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

View File

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

View File

@ -12,7 +12,7 @@ import java.util.List;
public class BRecipe {
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 distillruns;// runs through the brewer
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 int difficulty;// difficulty to brew the potion, how exact the instruction has to be followed
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) {
String nameList = configSectionRecipes.getString(recipeId + ".name");
@ -244,7 +244,7 @@ public class BRecipe {
int uid = Brew.generateUID();
ArrayList<ItemStack> list = new ArrayList<ItemStack>(ingredients.size());
ArrayList<ItemStack> list = new ArrayList<>(ingredients.size());
for (ItemStack item : ingredients) {
if (item.getDurability() == -1) {
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 static CopyOnWriteArrayList<Barrel> barrels = new CopyOnWriteArrayList<Barrel>();
public static CopyOnWriteArrayList<Barrel> barrels = new CopyOnWriteArrayList<>();
private static int check = 0;
private Block spigot;
@ -766,7 +766,7 @@ public class Barrel implements InventoryHolder {
int endX;
int endZ;
ArrayList<Integer> stairs = new ArrayList<Integer>();
ArrayList<Integer> stairs = new ArrayList<>();
if (direction == 1) {
startX = 1;
@ -839,8 +839,8 @@ public class Barrel implements InventoryHolder {
int endX;
int endZ;
ArrayList<Integer> stairs = new ArrayList<Integer>();
ArrayList<Integer> woods = new ArrayList<Integer>();
ArrayList<Integer> stairs = new ArrayList<>();
ArrayList<Integer> woods = new ArrayList<>();
if (direction == 1) {
startX = 1;

View File

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

View File

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

View File

@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
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 int checkId = -1;
public static Player checkPlayer = null;
@ -28,7 +28,7 @@ public class Wakeup {
return null;
}
ArrayList<Wakeup> worldWakes = new ArrayList<Wakeup>();
ArrayList<Wakeup> worldWakes = new ArrayList<>();
for (Wakeup wakeup : wakeups) {
if (wakeup.active) {
@ -44,6 +44,7 @@ public class Wakeup {
Wakeup w1 = calcRandom(worldWakes);
worldWakes.remove(w1);
if (w1 == null) return null;
while (!w1.check()) {
p.errorLog("Please Check Wakeup-Location with id: &6" + wakeups.indexOf(w1));
@ -119,7 +120,7 @@ public class Wakeup {
return;
}
ArrayList<String> locs = new ArrayList<String>();
ArrayList<String> locs = new ArrayList<>();
for (int id = 0; id < wakeups.size(); 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
public static ArrayList<Words> words = new ArrayList<Words>();
public static ArrayList<Words> words = new ArrayList<>();
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 Boolean doSigns;
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 to;
@ -270,18 +270,10 @@ public class Words {
boolean isBefore = !match;
if (pre != null) {
for (String pr : pre) {
if (match) {
// if one is correct, it is enough
if (part.endsWith(pr) == match) {
isBefore = true;
break;
}
} else {
// if one is wrong, its over
if (part.endsWith(pr) != match) {
isBefore = false;
break;
}
if (part.endsWith(pr)) {
// If a match is wanted set isBefore to true, else to false
isBefore = match;
break;
}
}
} else {

View File

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

View File

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

View File

@ -51,7 +51,7 @@ public class DataUpdater {
ConfigurationSection matSection = section.getConfigurationSection(id + ".mats");
if (matSection != null) {
// 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)) {
// convert to Material
Material mat = Material.getMaterial(P.p.parseInt(ingredient));
@ -81,7 +81,7 @@ public class DataUpdater {
ConfigurationSection ingredientSection = cauldrons.getConfigurationSection(id + ".ingredients");
if (ingredientSection != null) {
// 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)) {
// convert to Material
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;
public class LanguageReader {
private Map<String, String> entries = new TreeMap<String, String>();
private Map<String, String> defaults = new TreeMap<String, String>();
private Map<String, String> entries = new TreeMap<>();
private Map<String, String> defaults = new TreeMap<>();
private File file;
private boolean changed;
@ -143,6 +143,7 @@ public class LanguageReader {
}
}
@SuppressWarnings("ResultOfMethodCallIgnored")
public void save() {
if (changed) {
/* Copy old File */

View File

@ -14,6 +14,7 @@ public class ReadOldData extends BukkitRunnable {
public FileConfiguration data;
public boolean done = false;
@SuppressWarnings("ResultOfMethodCallIgnored")
@Override
public void run() {
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;
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();
private HumanEntity player;

View File

@ -5,5 +5,5 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
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) {
ArrayList<String> cmds = new ArrayList<String>();
ArrayList<String> cmds = new ArrayList<>();
cmds.add(p.languageReader.get("Help_Help"));
if (sender.hasPermission("brewery.cmd.player")) {

View File

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