Embrace Java 7's diamond operator project-wide.

This commit is contained in:
Andreas Troelsen 2017-03-13 21:23:24 +01:00
parent 98d3cf0245
commit 0eeed4ff01
34 changed files with 112 additions and 112 deletions

View File

@ -36,10 +36,10 @@ public class ArenaClass
this.configName = name;
this.lowercaseName = name.toLowerCase().replace(" ", "");
this.items = new ArrayList<ItemStack>();
this.armor = new ArrayList<ItemStack>(4);
this.perms = new HashMap<String,Boolean>();
this.lobbyperms = new HashMap<String,Boolean>();
this.items = new ArrayList<>();
this.armor = new ArrayList<>(4);
this.perms = new HashMap<>();
this.lobbyperms = new HashMap<>();
this.unbreakableWeapons = unbreakableWeapons;
this.unbreakableArmor = unbreakableArmor;
@ -137,7 +137,7 @@ public class ArenaClass
* @param stacks a list of items
*/
public void setItems(List<ItemStack> stacks) {
this.items = new ArrayList<ItemStack>(stacks.size());
this.items = new ArrayList<>(stacks.size());
for (ItemStack stack : stacks) {
addItem(stack);
}

View File

@ -92,7 +92,7 @@ public class ArenaImpl implements Arena
private RewardManager rewardManager;
private ClassLimitManager limitManager;
private Map<Player,ArenaPlayer> arenaPlayerMap;
private Map<Player,PlayerData> playerData = new HashMap<Player,PlayerData>();
private Map<Player,PlayerData> playerData = new HashMap<>();
private Set<Player> arenaPlayers, lobbyPlayers, readyPlayers, specPlayers, deadPlayers;
private Set<Player> randoms;
@ -155,17 +155,17 @@ public class ArenaImpl implements Arena
this.leaderboard = new Leaderboard(plugin, this, region.getLeaderboard());
// Player stuff
this.arenaPlayerMap = new HashMap<Player,ArenaPlayer>();
this.arenaPlayers = new HashSet<Player>();
this.lobbyPlayers = new HashSet<Player>();
this.readyPlayers = new HashSet<Player>();
this.specPlayers = new HashSet<Player>();
this.deadPlayers = new HashSet<Player>();
this.randoms = new HashSet<Player>();
this.arenaPlayerMap = new HashMap<>();
this.arenaPlayers = new HashSet<>();
this.lobbyPlayers = new HashSet<>();
this.readyPlayers = new HashSet<>();
this.specPlayers = new HashSet<>();
this.deadPlayers = new HashSet<>();
this.randoms = new HashSet<>();
// Classes, items and permissions
this.classes = plugin.getArenaMaster().getClasses();
this.attachments = new HashMap<Player,PermissionAttachment>();
this.attachments = new HashMap<>();
this.limitManager = new ClassLimitManager(this, classes, makeSection(section, "class-limits"));
String defaultClassName = settings.getString("default-class", null);
@ -174,10 +174,10 @@ public class ArenaImpl implements Arena
}
// Blocks and pets
this.repairQueue = new PriorityBlockingQueue<Repairable>(100, new RepairableComparator());
this.blocks = new HashSet<Block>();
this.repairables = new LinkedList<Repairable>();
this.containables = new LinkedList<Repairable>();
this.repairQueue = new PriorityBlockingQueue<>(100, new RepairableComparator());
this.blocks = new HashSet<>();
this.repairables = new LinkedList<>();
this.containables = new LinkedList<>();
// Monster stuff
this.monsterManager = new MonsterManager();
@ -607,7 +607,7 @@ public class ArenaImpl implements Arena
return;
// Set operations.
Set<Player> tmp = new HashSet<Player>();
Set<Player> tmp = new HashSet<>();
tmp.addAll(lobbyPlayers);
tmp.removeAll(readyPlayers);
@ -1298,7 +1298,7 @@ public class ArenaImpl implements Arena
public void assignRandomClass(Player p)
{
Random r = new Random();
List<String> classes = new LinkedList<String>(this.classes.keySet());
List<String> classes = new LinkedList<>(this.classes.keySet());
String className = classes.remove(r.nextInt(classes.size()));
while (!plugin.has(p, "mobarena.classes." + className))
@ -1480,7 +1480,7 @@ public class ArenaImpl implements Arena
@Override
public List<Player> getAllPlayers()
{
List<Player> result = new LinkedList<Player>();
List<Player> result = new LinkedList<>();
result.addAll(arenaPlayers);
result.addAll(lobbyPlayers);
result.addAll(specPlayers);
@ -1514,7 +1514,7 @@ public class ArenaImpl implements Arena
@Override
public List<Player> getNonreadyPlayers()
{
List<Player> result = new LinkedList<Player>();
List<Player> result = new LinkedList<>();
result.addAll(lobbyPlayers);
result.removeAll(readyPlayers);
return result;

View File

@ -153,7 +153,7 @@ public class ArenaListener
this.allowMonsters = arena.getWorld().getAllowMonsters();
this.banned = new HashSet<Player>();
this.banned = new HashSet<>();
}
void pvpActivate() {
@ -465,7 +465,7 @@ public class ArenaListener
// If the arena isn't destructible, just clear the blocklist.
if (!softRestore && protect) {
List<Block> blocks = new LinkedList<Block>(arena.getBlocks());
List<Block> blocks = new LinkedList<>(arena.getBlocks());
event.blockList().retainAll(blocks);
return;
}

View File

@ -52,12 +52,12 @@ public class ArenaMasterImpl implements ArenaMaster
this.plugin = plugin;
this.config = plugin.getConfig();
this.arenas = new ArrayList<Arena>();
this.arenaMap = new HashMap<Player, Arena>();
this.arenas = new ArrayList<>();
this.arenaMap = new HashMap<>();
this.classes = new HashMap<String, ArenaClass>();
this.classes = new HashMap<>();
this.allowedCommands = new HashSet<String>();
this.allowedCommands = new HashSet<>();
this.enabled = config.getBoolean("global-settings.enabled", true);
}
@ -125,7 +125,7 @@ public class ArenaMasterImpl implements ArenaMaster
}
public List<Arena> getEnabledArenas(List<Arena> arenas) {
List<Arena> result = new ArrayList<Arena>(arenas.size());
List<Arena> result = new ArrayList<>(arenas.size());
for (Arena arena : arenas)
if (arena.isEnabled())
result.add(arena);
@ -133,7 +133,7 @@ public class ArenaMasterImpl implements ArenaMaster
}
public List<Arena> getPermittedArenas(Player p) {
List<Arena> result = new ArrayList<Arena>(arenas.size());
List<Arena> result = new ArrayList<>(arenas.size());
for (Arena arena : arenas)
if (plugin.has(p, "mobarena.arenas." + arena.configName()))
result.add(arena);
@ -141,7 +141,7 @@ public class ArenaMasterImpl implements ArenaMaster
}
public List<Arena> getEnabledAndPermittedArenas(Player p) {
List<Arena> result = new ArrayList<Arena>(arenas.size());
List<Arena> result = new ArrayList<>(arenas.size());
for (Arena arena : arenas)
if (arena.isEnabled() && plugin.has(p, "mobarena.arenas." + arena.configName()))
result.add(arena);
@ -156,7 +156,7 @@ public class ArenaMasterImpl implements ArenaMaster
}
public List<Arena> getArenasInWorld(World world) {
List<Arena> result = new ArrayList<Arena>(arenas.size());
List<Arena> result = new ArrayList<>(arenas.size());
for (Arena arena : arenas)
if (arena.getWorld().equals(world))
result.add(arena);
@ -164,7 +164,7 @@ public class ArenaMasterImpl implements ArenaMaster
}
public List<Player> getAllPlayers() {
List<Player> result = new ArrayList<Player>(arenas.size());
List<Player> result = new ArrayList<>(arenas.size());
for (Arena arena : arenas)
result.addAll(arena.getAllPlayers());
return result;
@ -172,11 +172,11 @@ public class ArenaMasterImpl implements ArenaMaster
public List<Player> getAllPlayersInArena(String arenaName) {
Arena arena = getArenaWithName(arenaName);
return (arena != null) ? new ArrayList<Player>(arena.getPlayersInArena()) : new ArrayList<Player>();
return (arena != null) ? new ArrayList<>(arena.getPlayersInArena()) : new ArrayList<Player>();
}
public List<Player> getAllLivingPlayers() {
List<Player> result = new ArrayList<Player>();
List<Player> result = new ArrayList<>();
for (Arena arena : arenas)
result.addAll(arena.getPlayersInArena());
return result;
@ -184,7 +184,7 @@ public class ArenaMasterImpl implements ArenaMaster
public List<Player> getLivingPlayersInArena(String arenaName) {
Arena arena = getArenaWithName(arenaName);
return (arena != null) ? new ArrayList<Player>(arena.getPlayersInArena()) : new ArrayList<Player>();
return (arena != null) ? new ArrayList<>(arena.getPlayersInArena()) : new ArrayList<Player>();
}
public Arena getArenaWithPlayer(Player p) {
@ -271,7 +271,7 @@ public class ArenaMasterImpl implements ArenaMaster
// Establish the map.
classes = new HashMap<String, ArenaClass>();
classes = new HashMap<>();
Set<String> classNames = section.getKeys(false);
// Load each individual class.
@ -331,7 +331,7 @@ public class ArenaMasterImpl implements ArenaMaster
List<ItemStack> stacks = ItemParser.parseItems(str);
arenaClass.setItems(stacks);
} else {
List<ItemStack> stacks = new ArrayList<ItemStack>();
List<ItemStack> stacks = new ArrayList<>();
for (String item : items) {
ItemStack stack = ItemParser.parseItem(item);
if (stack != null) {
@ -536,7 +536,7 @@ public class ArenaMasterImpl implements ArenaMaster
createArenaNode(section, "default", plugin.getServer().getWorlds().get(0), false);
}
arenas = new ArrayList<Arena>();
arenas = new ArrayList<>();
for (World w : Bukkit.getServer().getWorlds()) {
loadArenasInWorld(w.getName());
}

View File

@ -23,7 +23,7 @@ public class ArenaPlayerStatistics
public void reset() {
if (ints == null) {
ints = new HashMap<String, MutableInt>();
ints = new HashMap<>();
}
ints.clear();

View File

@ -20,8 +20,8 @@ public class ClassLimitManager
public ClassLimitManager(Arena arena, Map<String,ArenaClass> classes, ConfigurationSection limits) {
this.limits = limits;
this.classes = classes;
this.classLimits = new HashMap<ArenaClass,MutableInt>();
this.classesInUse = new HashMap<ArenaClass, HashSet<String>>();
this.classLimits = new HashMap<>();
this.classesInUse = new HashMap<>();
loadLimitMap(arena.getPlugin());
initInUseMap();

View File

@ -108,7 +108,7 @@ public class MASpawnThread implements Runnable
plugin.getServer().getPluginManager().callEvent(complete);
// Then force leave everyone
List<Player> players = new ArrayList<Player>(arena.getPlayersInArena());
List<Player> players = new ArrayList<>(arena.getPlayersInArena());
for (Player p : players) {
arena.playerLeave(p);
}
@ -278,7 +278,7 @@ public class MASpawnThread implements Runnable
}
private void removeCheatingPlayers() {
List<Player> players = new ArrayList<Player>(arena.getPlayersInArena());
List<Player> players = new ArrayList<>(arena.getPlayersInArena());
for (Player p : players) {
if (region.contains(p.getLocation())) {
continue;

View File

@ -53,7 +53,7 @@ public class MAUtils
public static Map<Integer,List<ItemStack>> getArenaRewardMap(MobArena plugin, ConfigurationSection config, String arena, String type)
{
//String arenaPath = "arenas." + arena + ".rewards.waves.";
Map<Integer,List<ItemStack>> result = new HashMap<Integer,List<ItemStack>>();
Map<Integer,List<ItemStack>> result = new HashMap<>();
String typePath = "rewards.waves." + type;
if (!config.contains(typePath)) return result;
@ -141,7 +141,7 @@ public class MAUtils
/* Iterate through the ArrayList, and update current and result every
* time a squared distance smaller than current is found. */
List<Player> players = new ArrayList<Player>(arena.getPlayersInArena());
List<Player> players = new ArrayList<>(arena.getPlayersInArena());
for (Player p : players) {
if (!arena.getWorld().equals(p.getWorld())) {
plugin.getLogger().info("Player '" + p.getName() + "' is not in the right world. Kicking...");
@ -261,7 +261,7 @@ public class MAUtils
*/
public static List<String> stringToList(String list)
{
List<String> result = new LinkedList<String>();
List<String> result = new LinkedList<>();
if (list == null) return result;
String[] parts = list.trim().split(",");
@ -303,7 +303,7 @@ public class MAUtils
int lz2 = z1 + 6;
// Save the precious patch
HashMap<EntityPosition,Integer> preciousPatch = new HashMap<EntityPosition,Integer>();
HashMap<EntityPosition,Integer> preciousPatch = new HashMap<>();
Location lo;
int id;
for (int i = x1; i <= x2; i++)

View File

@ -283,7 +283,7 @@ public class MobArena extends JavaPlugin
}
private void registerInventories() {
this.inventoriesToRestore = new HashSet<String>();
this.inventoriesToRestore = new HashSet<>();
File dir = new File(getDataFolder(), "inventories");
if (!dir.exists()) {

View File

@ -23,13 +23,13 @@ public class MonsterManager
private Set<LivingEntity> mounts;
public MonsterManager() {
this.monsters = new HashSet<LivingEntity>();
this.sheep = new HashSet<LivingEntity>();
this.golems = new HashSet<LivingEntity>();
this.pets = new HashSet<Wolf>();
this.bosses = new HashMap<LivingEntity,MABoss>();
this.suppliers = new HashMap<LivingEntity,List<ItemStack>>();
this.mounts = new HashSet<LivingEntity>();
this.monsters = new HashSet<>();
this.sheep = new HashSet<>();
this.golems = new HashSet<>();
this.pets = new HashSet<>();
this.bosses = new HashMap<>();
this.suppliers = new HashMap<>();
this.mounts = new HashSet<>();
}
public void reset() {

View File

@ -24,8 +24,8 @@ public class RewardManager
public RewardManager(Arena arena) {
this.plugin = arena.getPlugin();
this.arena = arena;
this.players = new HashMap<Player,List<ItemStack>>();
this.rewarded = new HashSet<Player>();
this.players = new HashMap<>();
this.rewarded = new HashSet<>();
}
public void reset() {

View File

@ -133,7 +133,7 @@ public class CommandHandler implements CommandExecutor
* @return a list of commands whose patterns match the given string
*/
private List<Command> getMatchingCommands(String arg) {
List<Command> result = new ArrayList<Command>();
List<Command> result = new ArrayList<>();
// Grab the commands that match the argument.
for (Entry<String,Command> entry : commands.entrySet()) {
@ -209,7 +209,7 @@ public class CommandHandler implements CommandExecutor
* method, but this is neater, albeit more manual work.
*/
private void registerCommands() {
commands = new LinkedHashMap<String,Command>();
commands = new LinkedHashMap<>();
// mobarena.use
register(JoinCommand.class);

View File

@ -127,7 +127,7 @@ public class SetupCommand implements Command, Listener {
player.getInventory().setContents(getToolbox());
player.getInventory().setHeldItemSlot(0);
this.missing = new ArrayList<String>();
this.missing = new ArrayList<>();
this.next = color(String.format(
"Setup Mode for arena &a%s&r. Type &e?&r for help.",
"&a" + arena.configName() + "&r"

View File

@ -38,7 +38,7 @@ public class PlayerListCommand implements Command
list = MAUtils.listToString(arena.getPlayersInArena(), am.getPlugin());
} else {
StringBuilder buffy = new StringBuilder();
List<Player> players = new LinkedList<Player>();
List<Player> players = new LinkedList<>();
for (Arena arena : am.getArenas()) {
players.addAll(arena.getPlayersInArena());

View File

@ -16,7 +16,7 @@ public class ArenaCompleteEvent extends Event {
public ArenaCompleteEvent(Arena arena) {
this.arena = arena;
this.survivors = new HashSet<Player>();
this.survivors = new HashSet<>();
this.survivors.addAll(arena.getPlayersInArena());
}

View File

@ -39,8 +39,8 @@ public class Leaderboard
{
this.plugin = plugin;
this.arena = arena;
this.boards = new ArrayList<LeaderboardColumn>();
this.stats = new ArrayList<ArenaPlayerStatistics>();
this.boards = new ArrayList<>();
this.stats = new ArrayList<>();
}
/**
@ -183,7 +183,7 @@ public class Leaderboard
if (stat == null) continue;
// Create the list of signs
List<Sign> signs = new ArrayList<Sign>();
List<Sign> signs = new ArrayList<>();
current = header;
for (int i = 1; i < rows; i++)
{

View File

@ -95,7 +95,7 @@ public class ArenaRegion
}
public void reloadSpawnpoints() {
spawnpoints = new HashMap<String,Location>();
spawnpoints = new HashMap<>();
Set<String> keys = spawns.getKeys(false);
if (keys != null) {
for (String spwn : keys) {
@ -105,7 +105,7 @@ public class ArenaRegion
}
public void reloadChests() {
containers = new HashMap<String,Location>();
containers = new HashMap<>();
Set<String> keys = chests.getKeys(false);
if (keys != null) {
for (String chst : keys) {
@ -131,7 +131,7 @@ public class ArenaRegion
verifyData();
// Prepare the list
List<String> list = new ArrayList<String>();
List<String> list = new ArrayList<>();
// Region points
if (region) {
@ -363,7 +363,7 @@ public class ArenaRegion
}
public List<Chunk> getChunks() {
List<Chunk> result = new ArrayList<Chunk>();
List<Chunk> result = new ArrayList<>();
if (p1 == null || p2 == null) {
return result;
@ -406,7 +406,7 @@ public class ArenaRegion
}
public List<Location> getSpawnpointList() {
return new ArrayList<Location>(spawnpoints.values());
return new ArrayList<>(spawnpoints.values());
}
public Collection<Location> getContainers() {
@ -626,7 +626,7 @@ public class ArenaRegion
}
// Find all the spawnpoints that cover the location
Map<String,Location> map = new HashMap<String,Location>();
Map<String,Location> map = new HashMap<>();
for (Map.Entry<String,Location> entry : spawnpoints.entrySet()) {
if (p.getLocation().distanceSquared(entry.getValue()) < MobArena.MIN_PLAYER_DISTANCE_SQUARED) {
map.put(entry.getKey(), entry.getValue());
@ -673,7 +673,7 @@ public class ArenaRegion
@Override
public void run() {
// Grab all the blocks, and send block change events.
final Map<Location,BlockState> blocks = new HashMap<Location,BlockState>();
final Map<Location,BlockState> blocks = new HashMap<>();
for (Location l : points) {
Block b = l.getBlock();
blocks.put(l, b.getState());
@ -702,7 +702,7 @@ public class ArenaRegion
}
private List<Location> getFramePoints(Location loc1, Location loc2) {
List<Location> result = new ArrayList<Location>();
List<Location> result = new ArrayList<>();
int x1 = loc1.getBlockX(); int y1 = loc1.getBlockY(); int z1 = loc1.getBlockZ();
int x2 = loc2.getBlockX(); int y2 = loc2.getBlockY(); int z2 = loc2.getBlockZ();

View File

@ -126,11 +126,11 @@ public class ItemParser
public static List<ItemStack> parseItems(String s) {
if (s == null) {
return new ArrayList<ItemStack>(1);
return new ArrayList<>(1);
}
String[] items = s.split(",");
List<ItemStack> result = new ArrayList<ItemStack>(items.length);
List<ItemStack> result = new ArrayList<>(items.length);
for (String item : items) {
ItemStack stack = parseItem(item.trim());

View File

@ -17,7 +17,7 @@ public class PotionEffectParser
if (s == null || s.isEmpty())
return null;
List<PotionEffect> potions = new ArrayList<PotionEffect>();
List<PotionEffect> potions = new ArrayList<>();
for (String potion : s.split(",")) {
PotionEffect eff = parsePotionEffect(potion.trim());
if (eff != null) {

View File

@ -26,8 +26,8 @@ public class InventoryManager
this.dir = new File(arena.getPlugin().getDataFolder(), "inventories");
this.dir.mkdir();
this.items = new HashMap<Player,ItemStack[]>();
this.armor = new HashMap<Player,ItemStack[]>();
this.items = new HashMap<>();
this.armor = new HashMap<>();
}
public void storeInv(Player p) throws IOException {

View File

@ -8,7 +8,7 @@ import java.util.List;
public class InventoryUtils
{
public static List<ItemStack> extractAll(int id, List<ItemStack> items) {
List<ItemStack> result = new ArrayList<ItemStack>();
List<ItemStack> result = new ArrayList<>();
for (ItemStack stack : items) {
if (stack.getTypeId() == id) {

View File

@ -26,7 +26,7 @@ public class SheepBouncer implements Runnable
}
// Put all the sheep in a new collection for iteration purposes.
sheep = new HashSet<LivingEntity>(arena.getMonsterManager().getExplodingSheep());
sheep = new HashSet<>(arena.getMonsterManager().getExplodingSheep());
// If there are no sheep, reschedule and return.
if (sheep.isEmpty()) {

View File

@ -34,7 +34,7 @@ public class WaveManager
public void reset() {
reloadWaves();
wave = 0;
singleWavesInstance = new TreeSet<Wave>(singleWaves);
singleWavesInstance = new TreeSet<>(singleWaves);
}
public void reloadWaves() {
@ -119,7 +119,7 @@ public class WaveManager
}
private SortedSet<Wave> getMatchingRecurrentWaves(int wave) {
TreeSet<Wave> result = new TreeSet<Wave>(WaveUtils.getRecurrentComparator());
TreeSet<Wave> result = new TreeSet<>(WaveUtils.getRecurrentComparator());
for (Wave w : recurrentWaves) {
if (w.matches(wave)) {
result.add(w);

View File

@ -42,7 +42,7 @@ public class WaveParser
{
public static TreeSet<Wave> parseWaves(Arena arena, ConfigurationSection config, WaveBranch branch) {
// Create a TreeSet with the Comparator for the specific branch.
TreeSet<Wave> result = new TreeSet<Wave>(WaveUtils.getComparator(branch));
TreeSet<Wave> result = new TreeSet<>(WaveUtils.getComparator(branch));
// If the config is null, return the empty set.
if (config == null) {
@ -358,7 +358,7 @@ public class WaveParser
}
// Prepare the map.
SortedMap<Integer,MACreature> monsterMap = new TreeMap<Integer,MACreature>();
SortedMap<Integer,MACreature> monsterMap = new TreeMap<>();
int sum = 0;
String path = "monsters.";
@ -378,7 +378,7 @@ public class WaveParser
}
private static List<Location> getSpawnpoints(Arena arena, String name, ConfigurationSection config) {
List<Location> result = new ArrayList<Location>();
List<Location> result = new ArrayList<>();
String spawnString = config.getString("spawnpoints");
if (spawnString == null) {
@ -414,7 +414,7 @@ public class WaveParser
return null;
}
Map<String,List<Upgrade>> upgrades = new HashMap<String,List<Upgrade>>();
Map<String,List<Upgrade>> upgrades = new HashMap<>();
String path = "upgrades.";
for (String className : classes) {
@ -424,7 +424,7 @@ public class WaveParser
if (val instanceof String) {
itemList = (String) val;
List<ItemStack> stacks = ItemParser.parseItems(itemList);
List<Upgrade> list = new ArrayList<Upgrade>();
List<Upgrade> list = new ArrayList<>();
for (ItemStack stack : stacks) {
list.add(new GenericUpgrade(stack));
}
@ -433,7 +433,7 @@ public class WaveParser
// New complex setup
else if (val instanceof ConfigurationSection) {
ConfigurationSection classSection = (ConfigurationSection) val;
List<Upgrade> list = new ArrayList<Upgrade>();
List<Upgrade> list = new ArrayList<>();
// Items (Generic + Weapons)
itemList = classSection.getString("items", null);
@ -468,7 +468,7 @@ public class WaveParser
}
public static Wave createDefaultWave() {
SortedMap<Integer,MACreature> monsters = new TreeMap<Integer,MACreature>();
SortedMap<Integer,MACreature> monsters = new TreeMap<>();
monsters.put(10, MACreature.ZOMBIE);
monsters.put(20, MACreature.SKELETON);
monsters.put(30, MACreature.SPIDER);

View File

@ -20,7 +20,7 @@ public class WaveUtils
*/
public static List<Location> getValidSpawnpoints(Arena arena, List<Location> spawnpoints, Collection<Player> players) {
MobArena plugin = arena.getPlugin();
List<Location> result = new ArrayList<Location>();
List<Location> result = new ArrayList<>();
// Ensure that we do have some spawnpoints.
if (spawnpoints == null || spawnpoints.isEmpty()) {

View File

@ -64,7 +64,7 @@ public class AbilityManager
* Load all the core abilities included in MobArena
*/
public static void loadCoreAbilities() {
if (abilities == null) abilities = new HashMap<String,Class<? extends Ability>>();
if (abilities == null) abilities = new HashMap<>();
register(ChainLightning.class);
register(DisorientDistant.class);
@ -96,7 +96,7 @@ public class AbilityManager
* @param classDir a directory of .class (and/or .java) files
*/
public static void loadCustomAbilities(File classDir) {
if (abilities == null) abilities = new HashMap<String,Class<? extends Ability>>();
if (abilities == null) abilities = new HashMap<>();
// Grab the source directory.
File javaDir = new File(classDir, "src");
@ -179,7 +179,7 @@ public class AbilityManager
}
private static List<File> getSourceFilesToCompile(File javaDir, File classDir) {
List<File> result = new ArrayList<File>();
List<File> result = new ArrayList<>();
if (javaDir == null || !javaDir.exists()) {
return result;

View File

@ -43,7 +43,7 @@ public class AbilityUtils
* @return a random arena player, or null if none were found
*/
public static Player getRandomPlayer(Arena arena) {
List<Player> list = new ArrayList<Player>(arena.getPlayersInArena());
List<Player> list = new ArrayList<>(arena.getPlayersInArena());
if (list.isEmpty()) return null;
return list.get(random.nextInt(list.size()));
@ -57,7 +57,7 @@ public class AbilityUtils
* @return a list of nearby players
*/
public static List<Player> getNearbyPlayers(Arena arena, Entity boss, int x) {
List<Player> result = new ArrayList<Player>();
List<Player> result = new ArrayList<>();
for (Entity e : boss.getNearbyEntities(x, x, x)) {
if (arena.getPlayersInArena().contains(e)) {
result.add((Player) e);
@ -74,7 +74,7 @@ public class AbilityUtils
* @return a list of distant players
*/
public static List<Player> getDistantPlayers(Arena arena, Entity boss, int x) {
List<Player> result = new ArrayList<Player>();
List<Player> result = new ArrayList<>();
for (Player p : arena.getPlayersInArena()) {
if (MAUtils.distanceSquared(arena.getPlugin(), p, boss.getLocation()) > (double) (x*x)) {
result.add(p);

View File

@ -25,7 +25,7 @@ public class ShufflePositions implements Ability
entities.add(boss.getEntity());
// Grab the locations
List<Location> locations = new LinkedList<Location>();
List<Location> locations = new LinkedList<>();
for (LivingEntity e : entities) {
locations.add(e.getLocation());
}

View File

@ -43,9 +43,9 @@ public class BossWave extends AbstractWave
public BossWave(MACreature monster) {
this.monster = monster;
this.bosses = new HashSet<MABoss>();
this.abilities = new ArrayList<Ability>();
this.potions = new ArrayList<PotionEffect>();
this.bosses = new HashSet<>();
this.abilities = new ArrayList<>();
this.potions = new ArrayList<>();
this.activated = false;
this.abilityAnnounce = false;
this.setType(WaveType.BOSS);
@ -57,7 +57,7 @@ public class BossWave extends AbstractWave
@Override
public Map<MACreature,Integer> getMonstersToSpawn(int wave, int playerCount, Arena arena) {
Map<MACreature,Integer> result = new HashMap<MACreature,Integer>();
Map<MACreature,Integer> result = new HashMap<>();
result.put(monster, 1);
return result;
}
@ -92,7 +92,7 @@ public class BossWave extends AbstractWave
}
public Set<MABoss> getMABosses() {
Set<MABoss> result = new HashSet<MABoss>();
Set<MABoss> result = new HashSet<>();
for (MABoss b : bosses) {
if (!b.isDead()) {
result.add(b);

View File

@ -38,7 +38,7 @@ public class DefaultWave extends AbstractWave
Random random = new Random();
// Prepare the monster map.
Map<MACreature,Integer> monsters = new HashMap<MACreature,Integer>();
Map<MACreature,Integer> monsters = new HashMap<>();
// Generate some random amounts.
for (int i = 0; i < toSpawn; i++) {
@ -60,7 +60,7 @@ public class DefaultWave extends AbstractWave
}
private Map<MACreature,Integer> getFixed() {
Map<MACreature,Integer> result = new HashMap<MACreature,Integer>();
Map<MACreature,Integer> result = new HashMap<>();
// For fixed waves, we just convert the accumulated map
int last = 0;

View File

@ -27,7 +27,7 @@ public class SpecialWave extends AbstractWave
int value = random.nextInt(monsterMap.lastKey());
// Prepare the monster map.
Map<MACreature,Integer> result = new HashMap<MACreature,Integer>();
Map<MACreature,Integer> result = new HashMap<>();
for (Map.Entry<Integer,MACreature> entry : monsterMap.entrySet()) {
if (value > entry.getKey()) {

View File

@ -33,7 +33,7 @@ public class SupplyWave extends AbstractWave
Random random = new Random();
// Prepare the monster map.
Map<MACreature,Integer> monsters = new HashMap<MACreature,Integer>();
Map<MACreature,Integer> monsters = new HashMap<>();
int toSpawn = (int) Math.max(1D, playerCount * super.getAmountMultiplier());
@ -66,7 +66,7 @@ public class SupplyWave extends AbstractWave
public Wave copy() {
SupplyWave result = new SupplyWave(monsterMap);
result.drops = new ArrayList<ItemStack>(this.drops);
result.drops = new ArrayList<>(this.drops);
// From AbstractWave
result.setAmountMultiplier(getAmountMultiplier());

View File

@ -24,7 +24,7 @@ public class SwarmWave extends AbstractWave
@Override
public Map<MACreature,Integer> getMonstersToSpawn(int wave, int playerCount, Arena arena) {
// Prepare the monster map.
Map<MACreature,Integer> result = new HashMap<MACreature,Integer>();
Map<MACreature,Integer> result = new HashMap<>();
// Add the monster and the swarm amount.
int toSpawn = (int) Math.max(1D, amount.getAmount(playerCount) * super.getAmountMultiplier());

View File

@ -27,7 +27,7 @@ public class UpgradeWave extends AbstractWave
@Override
public Map<MACreature,Integer> getMonstersToSpawn(int wave, int playerCount, Arena arena) {
return new HashMap<MACreature,Integer>();
return new HashMap<>();
}
public void grantItems(Arena arena, Player p, String className) {
@ -49,9 +49,9 @@ public class UpgradeWave extends AbstractWave
}
public Wave copy() {
Map<String,List<Upgrade>> upgrades = new HashMap<String,List<Upgrade>>();
Map<String,List<Upgrade>> upgrades = new HashMap<>();
for (Map.Entry<String,List<Upgrade>> entry : this.upgrades.entrySet()) {
upgrades.put(entry.getKey(), new ArrayList<Upgrade>(entry.getValue()));
upgrades.put(entry.getKey(), new ArrayList<>(entry.getValue()));
}
UpgradeWave result = new UpgradeWave(upgrades);
result.giveAll = this.giveAll;