Fixes a bunch of warnings

This commit is contained in:
Kristian Knarvik 2022-07-21 18:28:00 +02:00
parent 38d2efa46f
commit df467cd956
20 changed files with 479 additions and 592 deletions

View File

@ -13,7 +13,7 @@ import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class Chests implements Listener { public class Chests implements Listener {
public Main plugin; public final Main plugin;
public Chests(Main m) { public Chests(Main m) {
this.plugin = m; this.plugin = m;
@ -48,14 +48,14 @@ public class Chests implements Listener {
if (plugin.getArena(p) != null) { if (plugin.getArena(p) != null) {
int a = plugin.getArena(p); int a = plugin.getArena(p);
if (plugin.Playing.get(a).contains(p.getName()) && plugin.canjoin.get(a)) { if (plugin.Playing.get(a).contains(p.getName()) && plugin.canjoin.get(a)) {
if (!plugin.restricted || (plugin.restricted && plugin.worldsNames.values().contains(p.getWorld().getName()))) { if (!plugin.restricted || (plugin.restricted && plugin.worldsNames.containsValue(p.getWorld().getName()))) {
if (block != null) { if (block != null) {
if (block.getState() instanceof InventoryHolder) { if (block.getState() instanceof InventoryHolder) {
ItemStack[] itemsinchest = ((InventoryHolder) block.getState()).getInventory().getContents().clone(); ItemStack[] itemsinchest = ((InventoryHolder) block.getState()).getInventory().getContents().clone();
int blockx = block.getX(); int blockx = block.getX();
int blocky = block.getY(); int blocky = block.getY();
int blockz = block.getZ(); int blockz = block.getZ();
String blockw = block.getWorld().getName().toString(); String blockw = block.getWorld().getName();
if (!plugin.getChests().contains("Storage." + blockx + "," + blocky + "," + blockz)) { if (!plugin.getChests().contains("Storage." + blockx + "," + blocky + "," + blockz)) {
plugin.getChests().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X", blockx); plugin.getChests().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X", blockx);
plugin.getChests().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Y", blocky); plugin.getChests().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Y", blocky);

View File

@ -9,7 +9,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
public class CommandBlock implements Listener { public class CommandBlock implements Listener {
public Main plugin; public final Main plugin;
public CommandBlock(Main m) { public CommandBlock(Main m) {
this.plugin = m; this.plugin = m;
@ -22,13 +22,13 @@ public class CommandBlock implements Listener {
String pname = p.getName(); String pname = p.getName();
for (int x : plugin.Watching.keySet()) { for (int x : plugin.Watching.keySet()) {
if (plugin.Watching.get(x).contains(p.getName())) { if (plugin.Watching.get(x).contains(p.getName())) {
if (handleIngameCommands(p, cmd) == true) { if (handleIngameCommands(p, cmd)) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
} }
if (plugin.getArena(p) != null) { if (plugin.getArena(p) != null) {
if (handleIngameCommands(p, cmd) == true) { if (handleIngameCommands(p, cmd)) {
event.setCancelled(true); event.setCancelled(true);
} }
} else if (cmd.toLowerCase().trim().equals("/back")) { } else if (cmd.toLowerCase().trim().equals("/back")) {

View File

@ -1,12 +1,5 @@
package me.Travja.HungerArena; package me.Travja.HungerArena;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.sk89q.worldedit.IncompleteRegionException; import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
@ -14,7 +7,6 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.BukkitPlayer; import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.SessionManager; import com.sk89q.worldedit.session.SessionManager;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
@ -29,7 +21,6 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Damageable;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
@ -43,8 +34,15 @@ import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Score; import org.bukkit.scoreboard.Score;
import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Scoreboard;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class HaCommands implements CommandExecutor { public class HaCommands implements CommandExecutor {
public Main plugin; public final Main plugin;
public HaCommands(Main m) { public HaCommands(Main m) {
this.plugin = m; this.plugin = m;
@ -75,8 +73,7 @@ public class HaCommands implements CommandExecutor {
double spawnz = Double.parseDouble(Spawncoords[2]); double spawnz = Double.parseDouble(Spawncoords[2]);
String spawnworld = Spawncoords[3]; String spawnworld = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(spawnworld); World spawnw = plugin.getServer().getWorld(spawnworld);
Location Spawn = new Location(spawnw, spawnx, spawny, spawnz); return new Location(spawnw, spawnx, spawny, spawnz);
return Spawn;
} }
@Override @Override
@ -123,7 +120,7 @@ public class HaCommands implements CommandExecutor {
p.sendMessage(ChatColor.RED + "Argument not an integer!"); p.sendMessage(ChatColor.RED + "Argument not an integer!");
return false; return false;
} }
if (plugin.worldsNames.values().contains(ThisWorld)) { if (plugin.worldsNames.containsValue(ThisWorld)) {
p.sendMessage(ChatColor.RED + "This world already has an areana! \n (only one arena per world possible, yet!)"); p.sendMessage(ChatColor.RED + "This world already has an areana! \n (only one arena per world possible, yet!)");
return false; return false;
} }
@ -187,9 +184,9 @@ public class HaCommands implements CommandExecutor {
} else if (args[0].equalsIgnoreCase("Help")) { } else if (args[0].equalsIgnoreCase("Help")) {
help_sub(sender, playr, console); help_sub(sender, playr, console);
} else if (plugin.restricted && !plugin.worldsNames.values().contains(ThisWorld)) { } else if (plugin.restricted && !plugin.worldsNames.containsValue(ThisWorld)) {
p.sendMessage(ChatColor.RED + "That can't be run in this world!"); p.sendMessage(ChatColor.RED + "That can't be run in this world!");
} else if (!plugin.restricted || plugin.restricted && plugin.worldsNames.values().contains(ThisWorld)) { } else if (!plugin.restricted || plugin.restricted && plugin.worldsNames.containsValue(ThisWorld)) {
//////////////////////////////////////// LISTING /////////////////////////////////////////////// //////////////////////////////////////// LISTING ///////////////////////////////////////////////
if (args[0].equalsIgnoreCase("List")) { if (args[0].equalsIgnoreCase("List")) {
if (p.hasPermission("HungerArena.GameMaker") || plugin.Watching.get(a).contains(pname) || p.hasPermission("HungerArena.List")) { if (p.hasPermission("HungerArena.GameMaker") || plugin.Watching.get(a).contains(pname) || p.hasPermission("HungerArena.List")) {
@ -233,14 +230,13 @@ public class HaCommands implements CommandExecutor {
} }
if ((plugin.Playing.get(a) != null) && (plugin.location.get(a).size() != 0)) { if ((plugin.Playing.get(a) != null) && (plugin.location.get(a).size() != 0)) {
;
if (plugin.Playing.get(a).contains(pname)) { if (plugin.Playing.get(a).contains(pname)) {
p.sendMessage(ChatColor.RED + "You are already playing!"); p.sendMessage(ChatColor.RED + "You are already playing!");
} else if (plugin.Dead.get(a).contains(pname) || plugin.Quit.get(a).contains(pname)) { } else if (plugin.Dead.get(a).contains(pname) || plugin.Quit.get(a).contains(pname)) {
p.sendMessage(ChatColor.RED + "You DIED/QUIT! You can't join again!"); p.sendMessage(ChatColor.RED + "You DIED/QUIT! You can't join again!");
} else if (plugin.Playing.get(a).size() == plugin.maxPlayers.get(a)) { } else if (plugin.Playing.get(a).size() == plugin.maxPlayers.get(a)) {
p.sendMessage(ChatColor.RED + "There are already " + plugin.maxPlayers.get(a) + " Tributes in that Arena!"); p.sendMessage(ChatColor.RED + "There are already " + plugin.maxPlayers.get(a) + " Tributes in that Arena!");
} else if (plugin.canjoin.get(a) == true) { } else if (plugin.canjoin.get(a)) {
p.sendMessage(ChatColor.RED + "That game is in progress!"); p.sendMessage(ChatColor.RED + "That game is in progress!");
} else if (!plugin.open.get(a)) { } else if (!plugin.open.get(a)) {
p.sendMessage(ChatColor.RED + "That game is closed!"); p.sendMessage(ChatColor.RED + "That game is closed!");
@ -327,7 +323,7 @@ public class HaCommands implements CommandExecutor {
} else { } else {
plugin.Ready.get(a).add(pname); plugin.Ready.get(a).add(pname);
if (plugin.config.getBoolean("broadcastAll")) { if (plugin.config.getBoolean("broadcastAll")) {
plugin.getServer().broadcastMessage(ChatColor.AQUA + "[HungerArena] Game " + a + ": " + ChatColor.GRAY + String.valueOf(plugin.Ready.get(a).size()) + "/" + plugin.maxPlayers.get(a) + " Players ready!"); plugin.getServer().broadcastMessage(ChatColor.AQUA + "[HungerArena] Game " + a + ": " + ChatColor.GRAY + plugin.Ready.get(a).size() + "/" + plugin.maxPlayers.get(a) + " Players ready!");
} else { } else {
for (String gn : plugin.Playing.get(a)) { for (String gn : plugin.Playing.get(a)) {
Player g = plugin.getServer().getPlayer(gn); Player g = plugin.getServer().getPlayer(gn);
@ -348,12 +344,10 @@ public class HaCommands implements CommandExecutor {
} else if (args[0].equalsIgnoreCase("Leave")) { } else if (args[0].equalsIgnoreCase("Leave")) {
if (plugin.getArena(p) != null) { if (plugin.getArena(p) != null) {
a = plugin.getArena(p); a = plugin.getArena(p);
if (plugin.canjoin.get(a) == true) { if (plugin.canjoin.get(a)) {
clearInv(p); clearInv(p);
p.teleport(getArenaSpawn()); p.teleport(getArenaSpawn());
if (plugin.Frozen.get(a).contains(pname)) {
plugin.Frozen.get(a).remove(pname); plugin.Frozen.get(a).remove(pname);
}
if (plugin.Playing.get(a).size() != 1) { if (plugin.Playing.get(a).size() != 1) {
plugin.RestoreInv(p, pname); plugin.RestoreInv(p, pname);
@ -393,7 +387,7 @@ public class HaCommands implements CommandExecutor {
if (args.length >= 2) { if (args.length >= 2) {
if (checkarena(args[1], sender)) { if (checkarena(args[1], sender)) {
a = Integer.parseInt(args[1]); a = Integer.parseInt(args[1]);
if (!plugin.Watching.get(a).contains(pname) && plugin.getArena(p) == null && plugin.canjoin.get(a) == true) { if (!plugin.Watching.get(a).contains(pname) && plugin.getArena(p) == null && plugin.canjoin.get(a)) {
plugin.Watching.get(a).add(pname); plugin.Watching.get(a).add(pname);
p.teleport(Bukkit.getPlayer(plugin.Playing.get(a).get(0))); p.teleport(Bukkit.getPlayer(plugin.Playing.get(a).get(0)));
for (Player online : plugin.getServer().getOnlinePlayers()) { for (Player online : plugin.getServer().getOnlinePlayers()) {
@ -416,7 +410,7 @@ public class HaCommands implements CommandExecutor {
sobj.setDisplaySlot(DisplaySlot.SIDEBAR); sobj.setDisplaySlot(DisplaySlot.SIDEBAR);
p.setScoreboard(scoreboard); p.setScoreboard(scoreboard);
plugin.scoreboards.put(p.getName(), p.getScoreboard()); plugin.scoreboards.put(p.getName(), p.getScoreboard());
} else if (plugin.canjoin.get(a) == false) { } else if (!plugin.canjoin.get(a)) {
p.sendMessage(ChatColor.RED + "That game isn't in progress!"); p.sendMessage(ChatColor.RED + "That game isn't in progress!");
} else if (plugin.Playing.get(a).contains(pname)) { } else if (plugin.Playing.get(a).contains(pname)) {
p.sendMessage(ChatColor.RED + "You can't watch while you're playing!"); p.sendMessage(ChatColor.RED + "You can't watch while you're playing!");
@ -665,9 +659,9 @@ public class HaCommands implements CommandExecutor {
try { try {
maxh = players.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue(); maxh = players.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
} catch (Exception e) { } catch (Exception e) {
maxh = ((Damageable) players).getMaxHealth(); maxh = players.getMaxHealth();
} }
sender.sendMessage(ChatColor.GREEN + playernames + " Life: " + ((Damageable) players).getHealth() + "/" + maxh); sender.sendMessage(ChatColor.GREEN + playernames + " Life: " + players.getHealth() + "/" + maxh);
} else if (console || (p != null && p.hasPermission("HungerArena.List"))) { } else if (console || (p != null && p.hasPermission("HungerArena.List"))) {
sender.sendMessage(ChatColor.GREEN + playernames); sender.sendMessage(ChatColor.GREEN + playernames);
} }
@ -715,7 +709,7 @@ public class HaCommands implements CommandExecutor {
sender.sendMessage(ChatColor.RED + "Use playername !"); sender.sendMessage(ChatColor.RED + "Use playername !");
return false; return false;
} }
if (console || (playr && ((Player) sender).hasPermission("HungerArena.Kick"))) { if (console || (playr && sender.hasPermission("HungerArena.Kick"))) {
if (plugin.getArena(target) != null) { if (plugin.getArena(target) != null) {
a = plugin.getArena(target); a = plugin.getArena(target);
plugin.Playing.get(a).remove(target.getName()); plugin.Playing.get(a).remove(target.getName());
@ -834,9 +828,7 @@ public class HaCommands implements CommandExecutor {
plugin.Frozen.get(a).add(players); plugin.Frozen.get(a).add(players);
} }
} }
if (plugin.Kills.containsKey("__SuM__")) {
plugin.Kills.remove("__SuM__"); plugin.Kills.remove("__SuM__");
}
if (plugin.Watching.get(a) != null) { if (plugin.Watching.get(a) != null) {
for (String sname : plugin.Watching.get(a)) { for (String sname : plugin.Watching.get(a)) {
Player spectators = plugin.getServer().getPlayerExact(sname); Player spectators = plugin.getServer().getPlayerExact(sname);
@ -875,8 +867,8 @@ public class HaCommands implements CommandExecutor {
plugin.MatchRunning.put(a, null); plugin.MatchRunning.put(a, null);
List<String> blocksbroken = plugin.data.getStringList("Blocks_Destroyed"); List<String> blocksbroken = plugin.data.getStringList("Blocks_Destroyed");
List<String> blocksplaced = plugin.data.getStringList("Blocks_Placed"); List<String> blocksplaced = plugin.data.getStringList("Blocks_Placed");
ArrayList<String> toremove = new ArrayList<String>(); ArrayList<String> toremove = new ArrayList<>();
ArrayList<String> toremove2 = new ArrayList<String>(); ArrayList<String> toremove2 = new ArrayList<>();
for (String blocks : blocksplaced) { for (String blocks : blocksplaced) {
String[] coords = blocks.split(","); String[] coords = blocks.split(",");
World w = plugin.getServer().getWorld(coords[0]); World w = plugin.getServer().getWorld(coords[0]);
@ -944,7 +936,7 @@ public class HaCommands implements CommandExecutor {
} }
} }
block.setBlockData(BlData); block.setBlockData(BlData);
} catch (Exception | NoSuchMethodError xx) { } catch (Exception | NoSuchMethodError ignored) {
} }
} }
} }
@ -991,7 +983,7 @@ public class HaCommands implements CommandExecutor {
private void open_sub(CommandSender sender, String[] args) { private void open_sub(CommandSender sender, String[] args) {
Set<Integer> list = plugin.open.keySet(); Set<Integer> list = plugin.open.keySet();
if (args.length >= 2) { if (args.length >= 2) {
list = new HashSet<Integer>(); list = new HashSet<>();
if (checkarena(args[1], sender)) { if (checkarena(args[1], sender)) {
list.add(Integer.parseInt(args[1])); list.add(Integer.parseInt(args[1]));
} }
@ -1045,20 +1037,16 @@ public class HaCommands implements CommandExecutor {
if (plugin.Playing.get(a).size() <= 1) { if (plugin.Playing.get(a).size() <= 1) {
sender.sendMessage(ChatColor.RED + "There are not enough players!"); sender.sendMessage(ChatColor.RED + "There are not enough players!");
} else if (plugin.canjoin.get(a) == true) { } else if (plugin.canjoin.get(a)) {
sender.sendMessage(ChatColor.RED + "Game already in progress!"); sender.sendMessage(ChatColor.RED + "Game already in progress!");
} else { } else {
plugin.setTorch(a, false); plugin.setTorch(a, false);
if (plugin.config.getString("Auto_Start").equalsIgnoreCase("true")) { if (plugin.config.getString("Auto_Start").equalsIgnoreCase("true")) {
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha start " + a), 20L);
public void run() {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha start " + a);
} }
}, 20L); List<Integer> shuffle = new ArrayList<>();
}
List<Integer> shuffle = new ArrayList<Integer>();
for (i = 1; i <= plugin.location.get(a).size(); shuffle.add(i++)) { for (i = 1; i <= plugin.location.get(a).size(); shuffle.add(i++)) {
} }
Collections.shuffle(shuffle); Collections.shuffle(shuffle);
@ -1095,11 +1083,9 @@ public class HaCommands implements CommandExecutor {
tribute.teleport(toLoc); tribute.teleport(toLoc);
i += 1; i += 1;
} }
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
public void run() {
sender.sendMessage(ChatColor.AQUA + "All Tributes warped!"); sender.sendMessage(ChatColor.AQUA + "All Tributes warped!");
plugin.MatchRunning.put(a, "warped"); plugin.MatchRunning.put(a, "warped");
}
}, 10L); }, 10L);
} }
} }
@ -1116,7 +1102,7 @@ public class HaCommands implements CommandExecutor {
} else { } else {
if (checkarena(args[1], sender)) { if (checkarena(args[1], sender)) {
a = Integer.parseInt(args[1]); a = Integer.parseInt(args[1]);
if (plugin.canjoin.get(a) == true) { if (plugin.canjoin.get(a)) {
sender.sendMessage(ChatColor.RED + "Game already in progress!"); sender.sendMessage(ChatColor.RED + "Game already in progress!");
} else if (plugin.Playing.get(a).size() == 1) { } else if (plugin.Playing.get(a).size() == 1) {
sender.sendMessage(ChatColor.RED + "There are not enough players!"); sender.sendMessage(ChatColor.RED + "There are not enough players!");

View File

@ -24,7 +24,7 @@ import org.bukkit.material.MaterialData;
import java.util.List; import java.util.List;
public class BlockStorage implements Listener { public class BlockStorage implements Listener {
public Main plugin; public final Main plugin;
public BlockStorage(Main m) { public BlockStorage(Main m) {
this.plugin = m; this.plugin = m;
@ -59,8 +59,8 @@ public class BlockStorage implements Listener {
if (plugin.config.getString("Protected_Arena").equalsIgnoreCase("True")) { if (plugin.config.getString("Protected_Arena").equalsIgnoreCase("True")) {
event.setCancelled(true); event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You can't break blocks while playing!"); p.sendMessage(ChatColor.RED + "You can't break blocks while playing!");
} else if ((plugin.canjoin.get(a) || protall) && ((!plugin.restricted) || ((plugin.restricted) && (plugin.worldsNames.values().contains(p.getWorld().getName()))))) { } else if ((plugin.canjoin.get(a) || protall) && ((!plugin.restricted) || ((plugin.restricted) && (plugin.worldsNames.containsValue(p.getWorld().getName()))))) {
if (((plugin.management.getStringList("blocks.whitelist").isEmpty()) || ((!plugin.management.getStringList("blocks.whitelist").isEmpty()) && (!plugin.management.getStringList("blocks.whitelist").contains(String.valueOf(b.getType().name()))))) ^ (plugin.management.getBoolean("blocks.useWhitelistAsBlacklist"))) { if (((plugin.management.getStringList("blocks.whitelist").isEmpty()) || ((!plugin.management.getStringList("blocks.whitelist").isEmpty()) && (!plugin.management.getStringList("blocks.whitelist").contains(b.getType().name())))) ^ (plugin.management.getBoolean("blocks.useWhitelistAsBlacklist"))) {
event.setCancelled(true); event.setCancelled(true);
p.sendMessage(ChatColor.RED + "That is an illegal block!"); p.sendMessage(ChatColor.RED + "That is an illegal block!");
} else { } else {
@ -139,7 +139,7 @@ public class BlockStorage implements Listener {
if (!event.isCancelled()) { if (!event.isCancelled()) {
if (((plugin.Playing.get(a)).contains(p.getName())) || (protall)) { if (((plugin.Playing.get(a)).contains(p.getName())) || (protall)) {
if ((plugin.canjoin.get(a)) || (protall)) { if ((plugin.canjoin.get(a)) || (protall)) {
if ((!plugin.restricted) || ((plugin.restricted) && (plugin.worldsNames.values().contains(b.getWorld().getName())))) { if ((!plugin.restricted) || ((plugin.restricted) && (plugin.worldsNames.containsValue(b.getWorld().getName())))) {
if ((b.getType() == Material.SAND || b.getType() == Material.GRAVEL) && (b.getRelative(BlockFace.DOWN).getType() == Material.AIR || b.getRelative(BlockFace.DOWN).getType() == Material.WATER || b.getRelative(BlockFace.DOWN).getType() == Material.LAVA)) { if ((b.getType() == Material.SAND || b.getType() == Material.GRAVEL) && (b.getRelative(BlockFace.DOWN).getType() == Material.AIR || b.getRelative(BlockFace.DOWN).getType() == Material.WATER || b.getRelative(BlockFace.DOWN).getType() == Material.LAVA)) {
int n = b.getY() - 1; int n = b.getY() - 1;
while (b.getWorld().getBlockAt(b.getX(), n, b.getZ()).getType() == Material.AIR || b.getWorld().getBlockAt(b.getX(), n, b.getZ()).getType() == Material.WATER || b.getWorld().getBlockAt(b.getX(), n, b.getZ()).getType() == Material.LAVA) { while (b.getWorld().getBlockAt(b.getX(), n, b.getZ()).getType() == Material.AIR || b.getWorld().getBlockAt(b.getX(), n, b.getZ()).getType() == Material.WATER || b.getWorld().getBlockAt(b.getX(), n, b.getZ()).getType() == Material.LAVA) {
@ -174,7 +174,7 @@ public class BlockStorage implements Listener {
if (!event.isCancelled()) { if (!event.isCancelled()) {
if (plugin.canjoin.get(a)) { if (plugin.canjoin.get(a)) {
if (plugin.Playing.get(a).contains(event.getPlayer().getName())) { if (plugin.Playing.get(a).contains(event.getPlayer().getName())) {
if ((!plugin.restricted) || ((plugin.restricted) && (plugin.worldsNames.values().contains(event.getPlayer().getWorld().getName())))) { if ((!plugin.restricted) || ((plugin.restricted) && (plugin.worldsNames.containsValue(event.getPlayer().getWorld().getName())))) {
Block b = event.getBlockClicked().getRelative(event.getBlockFace()); Block b = event.getBlockClicked().getRelative(event.getBlockFace());
String w = b.getWorld().getName(); String w = b.getWorld().getName();
addPlacedBlockToList(b, w, a); addPlacedBlockToList(b, w, a);
@ -192,7 +192,7 @@ public class BlockStorage implements Listener {
if (!event.isCancelled()) { if (!event.isCancelled()) {
if (plugin.canjoin.get(a)) { if (plugin.canjoin.get(a)) {
if (plugin.Playing.get(a).contains(event.getPlayer().getName())) { if (plugin.Playing.get(a).contains(event.getPlayer().getName())) {
if ((!plugin.restricted) || ((plugin.restricted) && (plugin.worldsNames.values().contains(event.getPlayer().getWorld().getName())))) { if ((!plugin.restricted) || ((plugin.restricted) && (plugin.worldsNames.containsValue(event.getPlayer().getWorld().getName())))) {
Block b = event.getBlockClicked().getRelative(event.getBlockFace()); Block b = event.getBlockClicked().getRelative(event.getBlockFace());
String w = b.getWorld().getName(); String w = b.getWorld().getName();
addDestroyedBlockToList(b, w, a); addDestroyedBlockToList(b, w, a);
@ -224,10 +224,7 @@ public class BlockStorage implements Listener {
//SubRoutines: //SubRoutines:
private boolean protall() { private boolean protall() {
if (plugin.config.getString("Protected_Arena_Always").equalsIgnoreCase("True")) { return plugin.config.getString("Protected_Arena_Always").equalsIgnoreCase("True");
return true;
}
return false;
} }

View File

@ -15,7 +15,7 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
public class Boundaries implements Listener { public class Boundaries implements Listener {
public Main plugin; public final Main plugin;
public Boundaries(Main m) { public Boundaries(Main m) {
this.plugin = m; this.plugin = m;
@ -24,8 +24,8 @@ public class Boundaries implements Listener {
@EventHandler @EventHandler
public void boundsCheck(PlayerMoveEvent event) { public void boundsCheck(PlayerMoveEvent event) {
Player p = event.getPlayer(); Player p = event.getPlayer();
Boolean inGame = plugin.getArena(p) != null; boolean inGame = plugin.getArena(p) != null;
Boolean spectating = plugin.isSpectating(p); boolean spectating = plugin.isSpectating(p);
if (plugin.config.getBoolean("WorldEdit")) { if (plugin.config.getBoolean("WorldEdit")) {
if (insideBounds(p.getLocation()) && (inGame || spectating) || (!insideBounds(p.getLocation()) && inGame)) { if (insideBounds(p.getLocation()) && (inGame || spectating) || (!insideBounds(p.getLocation()) && inGame)) {
event.setCancelled(true); event.setCancelled(true);
@ -53,8 +53,8 @@ public class Boundaries implements Listener {
Map<String, Object> temp = plugin.spawns.getConfigurationSection("Arena").getValues(false); Map<String, Object> temp = plugin.spawns.getConfigurationSection("Arena").getValues(false);
for (Entry<String, Object> entry : temp.entrySet()) { for (Entry<String, Object> entry : temp.entrySet()) {
if (plugin.spawns.getConfigurationSection("Arena." + entry.getKey()) != null) { if (plugin.spawns.getConfigurationSection("Arena." + entry.getKey()) != null) {
String[] min = ((String) plugin.spawns.get("Arena." + entry.getKey()) + ".Min").split(","); String[] min = (plugin.spawns.get("Arena." + entry.getKey()) + ".Min").split(",");
String[] max = ((String) plugin.spawns.get("Arena." + entry.getKey()) + ".Max").split(","); String[] max = (plugin.spawns.get("Arena." + entry.getKey()) + ".Max").split(",");
try { try {
World world = Bukkit.getWorld(min[0]); World world = Bukkit.getWorld(min[0]);
double x = Double.parseDouble(min[1]); double x = Double.parseDouble(min[1]);
@ -66,16 +66,17 @@ public class Boundaries implements Listener {
double y2 = Double.parseDouble(max[2]); double y2 = Double.parseDouble(max[2]);
double z2 = Double.parseDouble(max[3]); double z2 = Double.parseDouble(max[3]);
minl = new Location(world2, x2, y2, z2); minl = new Location(world2, x2, y2, z2);
} catch (Exception e) {
System.out.println(e);
return false;
}
if (minl != null && maxl != null) { if (minl != null && maxl != null) {
return l.getX() >= minl.getBlockX() return l.getX() >= minl.getBlockX()
&& l.getX() < maxl.getBlockX() + 1 && l.getY() >= minl.getBlockY() && l.getX() < maxl.getBlockX() + 1 && l.getY() >= minl.getBlockY()
&& l.getY() < maxl.getBlockY() + 1 && l.getZ() >= minl.getBlockZ() && l.getY() < maxl.getBlockY() + 1 && l.getZ() >= minl.getBlockZ()
&& l.getZ() < maxl.getBlockZ() + 1; && l.getZ() < maxl.getBlockZ() + 1;
} }
} catch (Exception e) {
System.out.println(e);
return false;
}
} }
} }
} }

View File

@ -11,7 +11,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
import java.util.List; import java.util.List;
public class ChatListener implements Listener { public class ChatListener implements Listener {
public Main plugin; public final Main plugin;
public ChatListener(Main m) { public ChatListener(Main m) {
this.plugin = m; this.plugin = m;
@ -31,19 +31,12 @@ public class ChatListener implements Listener {
p.sendMessage(msg); p.sendMessage(msg);
for (Entity e : near) { for (Entity e : near) {
if (e instanceof Player) { if (e instanceof Player) {
((Player) e).sendMessage(msg); e.sendMessage(msg);
} }
} }
} else if (near.size() == 0) { } else {
p.sendMessage(msg); p.sendMessage(msg);
p.sendMessage(ChatColor.YELLOW + "No one near!"); p.sendMessage(ChatColor.YELLOW + "No one near!");
} else if (!(near.size() == 0)) {
for (Entity en : near) {
if (!(en instanceof Player)) {
p.sendMessage(msg);
p.sendMessage(ChatColor.YELLOW + "No one near!");
}
}
} }
} else { } else {
event.setCancelled(true); event.setCancelled(true);

View File

@ -7,7 +7,6 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -17,14 +16,12 @@ import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.DisplaySlot;
public class DeathListener implements Listener { public class DeathListener implements Listener {
public Main plugin; public final Main plugin;
public DeathListener(Main m) { public DeathListener(Main m) {
this.plugin = m; this.plugin = m;
} }
public FileConfiguration config;
int i = 0;
int a = 0; int a = 0;
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
@ -64,11 +61,9 @@ public class DeathListener implements Listener {
double spawny = Double.parseDouble(Spawncoords[1]); double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]); double spawnz = Double.parseDouble(Spawncoords[2]);
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz); final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
public void run() {
player.teleport(Spawn); player.teleport(Spawn);
plugin.RestoreInv(player, player.getName()); plugin.RestoreInv(player, player.getName());
}
}, 10L); }, 10L);
} }

View File

@ -15,7 +15,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
public class FreezeListener implements Listener { public class FreezeListener implements Listener {
public Main plugin; public final Main plugin;
public FreezeListener(Main m) { public FreezeListener(Main m) {
this.plugin = m; this.plugin = m;
@ -23,8 +23,8 @@ public class FreezeListener implements Listener {
int i = 0; int i = 0;
int a = 0; int a = 0;
private HashMap<Integer, Boolean> timeUp = new HashMap<Integer, Boolean>(); private final HashMap<Integer, Boolean> timeUp = new HashMap<>();
private ArrayList<Integer> timing = new ArrayList<Integer>(); private final ArrayList<Integer> timing = new ArrayList<>();
@EventHandler @EventHandler
public void onPlayerMove(PlayerMoveEvent event) { public void onPlayerMove(PlayerMoveEvent event) {
@ -42,13 +42,11 @@ public class FreezeListener implements Listener {
timing.add(a); timing.add(a);
if (!playing.getLocation().getBlock().getLocation().equals(plugin.location.get(a).get(i).getBlock().getLocation())) { if (!playing.getLocation().getBlock().getLocation().equals(plugin.location.get(a).get(i).getBlock().getLocation())) {
playing.teleport(plugin.location.get(a).get(i)); playing.teleport(plugin.location.get(a).get(i));
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
public void run() {
if (!timeUp.get(a)) { if (!timeUp.get(a)) {
timeUp.put(a, true); timeUp.put(a, true);
timing.remove(a); timing.remove(a);
} }
}
}, 30L); }, 30L);
} }
} else { } else {
@ -101,7 +99,7 @@ public class FreezeListener implements Listener {
if (l != null && l.size() != 0) { if (l != null && l.size() != 0) {
try { try {
pLoc = (Location) l.get(0).value(); pLoc = (Location) l.get(0).value();
} catch (Exception e) { } catch (Exception ignored) {
} }
} }
if (pLoc != null) { if (pLoc != null) {

View File

@ -2,7 +2,6 @@ package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.HaCommands; import me.Travja.HungerArena.HaCommands;
import me.Travja.HungerArena.Main; import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -26,7 +25,7 @@ public class JoinAndQuitListener implements Listener {
this.commands = h; this.commands = h;
} }
int a = 0; int arena = 0;
@EventHandler @EventHandler
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
@ -42,11 +41,7 @@ public class JoinAndQuitListener implements Listener {
for (int i : plugin.Out.keySet()) { for (int i : plugin.Out.keySet()) {
if (plugin.Out.get(i).contains(pname)) { if (plugin.Out.get(i).contains(pname)) {
plugin.Playing.get(i).add(pname); plugin.Playing.get(i).add(pname);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> p.sendMessage(ChatColor.AQUA + "You have saved yourself from being ejected from the arena!"), 40L);
public void run() {
p.sendMessage(ChatColor.AQUA + "You have saved yourself from being ejected from the arena!");
}
}, 40L);
plugin.Out.get(i).remove(pname); plugin.Out.get(i).remove(pname);
pfound = true; pfound = true;
} }
@ -61,15 +56,13 @@ public class JoinAndQuitListener implements Listener {
double spawny = Double.parseDouble(Spawncoords[1]); double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]); double spawnz = Double.parseDouble(Spawncoords[2]);
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz); final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
public void run() {
p.teleport(Spawn); p.teleport(Spawn);
p.sendMessage(ChatColor.RED + "You have been teleported to last spawn because you quit/forfeited!"); p.sendMessage(ChatColor.RED + "You have been teleported to last spawn because you quit/forfeited!");
plugin.RestoreInv(p, p.getName()); plugin.RestoreInv(p, p.getName());
if (plugin.Quit.get(i) != null) { if (plugin.Quit.get(i) != null) {
plugin.Quit.get(i).remove(p.getName()); plugin.Quit.get(i).remove(p.getName());
} }
}
}, 40L); }, 40L);
pfound = true; pfound = true;
} }
@ -83,15 +76,13 @@ public class JoinAndQuitListener implements Listener {
double spawny = Double.parseDouble(Spawncoords[1]); double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]); double spawnz = Double.parseDouble(Spawncoords[2]);
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz); final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
public void run() {
p.teleport(Spawn); p.teleport(Spawn);
p.sendMessage(ChatColor.RED + "You have been teleported to spawn because you quit/died/forfeited!!"); p.sendMessage(ChatColor.RED + "You have been teleported to spawn because you quit/died/forfeited!!");
plugin.RestoreInv(p, p.getName()); plugin.RestoreInv(p, p.getName());
if (plugin.Dead.get(i) != null) { if (plugin.Dead.get(i) != null) {
plugin.Dead.get(i).remove(p.getName()); plugin.Dead.get(i).remove(p.getName());
} }
}
}, 40L); }, 40L);
pfound = true; pfound = true;
} }
@ -106,8 +97,7 @@ public class JoinAndQuitListener implements Listener {
double spawny = Double.parseDouble(Spawncoords[1]); double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]); double spawnz = Double.parseDouble(Spawncoords[2]);
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz); final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
public void run() {
p.teleport(Spawn); p.teleport(Spawn);
p.getInventory().clear(); p.getInventory().clear();
p.getInventory().setBoots(null); p.getInventory().setBoots(null);
@ -120,13 +110,12 @@ public class JoinAndQuitListener implements Listener {
if (plugin.inArena.get(i) != null) { if (plugin.inArena.get(i) != null) {
plugin.inArena.get(i).remove(p.getName()); plugin.inArena.get(i).remove(p.getName());
} }
}
}, 40L); }, 40L);
pfound = true; pfound = true;
} }
} }
} }
if ((plugin.restricted && plugin.worldsNames.values().contains(p.getWorld().getName())) || !plugin.restricted) { if (!plugin.restricted || plugin.worldsNames.containsValue(p.getWorld().getName())) {
if (!pfound && plugin.config.getString("Force_Players_toSpawn").equalsIgnoreCase("True") && (plugin.spawns.getString("Spawn_coords.0") != null)) { if (!pfound && plugin.config.getString("Force_Players_toSpawn").equalsIgnoreCase("True") && (plugin.spawns.getString("Spawn_coords.0") != null)) {
String[] Spawncoords = plugin.spawns.getString("Spawn_coords.0").split(","); String[] Spawncoords = plugin.spawns.getString("Spawn_coords.0").split(",");
String w = Spawncoords[3]; String w = Spawncoords[3];
@ -136,11 +125,9 @@ public class JoinAndQuitListener implements Listener {
double spawnz = Double.parseDouble(Spawncoords[2]); double spawnz = Double.parseDouble(Spawncoords[2]);
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz); final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
plugin.RestoreInv(p, p.getName()); plugin.RestoreInv(p, p.getName());
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
public void run() {
p.teleport(Spawn); p.teleport(Spawn);
p.sendMessage(ChatColor.RED + "You have been teleported to spawn!!"); p.sendMessage(ChatColor.RED + "You have been teleported to spawn!!");
}
}, 40L); }, 40L);
} }
} }
@ -149,10 +136,10 @@ public class JoinAndQuitListener implements Listener {
@EventHandler @EventHandler
public void onQuit(PlayerQuitEvent evt) { public void onQuit(PlayerQuitEvent evt) {
Player p = evt.getPlayer(); Player p = evt.getPlayer();
String pname = p.getName(); String playerName = p.getName();
for (int i : plugin.Frozen.keySet()) { for (int i : plugin.Frozen.keySet()) {
if (plugin.Frozen.get(i).contains(pname)) { if (plugin.Frozen.get(i).contains(playerName)) {
plugin.Frozen.remove(pname); plugin.Frozen.remove(playerName);
String[] Spawncoords = plugin.spawns.getString("Spawn_coords.0").split(","); String[] Spawncoords = plugin.spawns.getString("Spawn_coords.0").split(",");
String w = Spawncoords[3]; String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w); World spawnw = plugin.getServer().getWorld(w);
@ -162,41 +149,31 @@ public class JoinAndQuitListener implements Listener {
Location Spawn = new Location(spawnw, spawnx, spawny, spawnz); Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
p.teleport(Spawn); p.teleport(Spawn);
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR); p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
if (plugin.scoreboards.containsKey(p.getName())) {
plugin.scoreboards.remove(p.getName()); plugin.scoreboards.remove(p.getName());
}
if (plugin.Kills.containsKey(p.getName())) {
plugin.Kills.remove(p.getName()); plugin.Kills.remove(p.getName());
} }
} }
} }
}
@EventHandler @EventHandler
public void onPlayerQuit(PlayerQuitEvent event) { public void onPlayerQuit(PlayerQuitEvent event) {
final Player p = event.getPlayer(); final Player p = event.getPlayer();
final String pname = p.getName(); final String playerName = p.getName();
if (plugin.getArena(p) != null) { if (plugin.getArena(p) != null) {
a = plugin.getArena(p); arena = plugin.getArena(p);
plugin.Out.get(a).add(pname); plugin.Out.get(arena).add(playerName);
plugin.Playing.get(a).remove(pname); plugin.Playing.get(arena).remove(playerName);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
public void run() { if (plugin.Out.get(arena).contains(playerName)) {
if (plugin.Out.get(a).contains(pname)) { plugin.Quit.get(arena).add(playerName);
plugin.Quit.get(a).add(pname); plugin.Out.get(arena).remove(playerName);
plugin.Out.get(a).remove(pname);
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR); p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
if (plugin.scoreboards.containsKey(p.getName())) {
plugin.scoreboards.remove(p.getName()); plugin.scoreboards.remove(p.getName());
}
if (plugin.Kills.containsKey(p.getName())) {
plugin.Kills.remove(p.getName()); plugin.Kills.remove(p.getName());
} plugin.winner(arena);
plugin.winner(a); plugin.inArena.get(arena).add(playerName);
plugin.inArena.get(a).add(pname);
} else if (plugin.getArena(p) == null) { } else if (plugin.getArena(p) == null) {
plugin.Quit.get(a).add(pname); plugin.Quit.get(arena).add(playerName);
}
} }
}, 1200L); }, 1200L);
} }

View File

@ -12,7 +12,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
public class PvP implements Listener { public class PvP implements Listener {
public Main plugin; public final Main plugin;
public PvP(Main m) { public PvP(Main m) {
this.plugin = m; this.plugin = m;
@ -24,9 +24,7 @@ public class PvP implements Listener {
public void PlayerPvP(EntityDamageByEntityEvent event) { public void PlayerPvP(EntityDamageByEntityEvent event) {
Entity pl = event.getEntity(); Entity pl = event.getEntity();
Entity dl = event.getDamager(); Entity dl = event.getDamager();
if (pl instanceof Player && dl instanceof Player) { if (pl instanceof Player p && dl instanceof Player d) {
Player p = (Player) pl;
Player d = (Player) dl;
if (plugin.getArena(p) != null && plugin.getArena(d) != null) { if (plugin.getArena(p) != null && plugin.getArena(d) != null) {
a = plugin.getArena(p); a = plugin.getArena(p);
if (plugin.canjoin.get(a)) { if (plugin.canjoin.get(a)) {
@ -53,32 +51,21 @@ public class PvP implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
} }
} else if (pl instanceof Player && dl instanceof Projectile) { } else if (pl instanceof Player p && dl instanceof Projectile projectile) {
Projectile projectile = (Projectile) dl;
Player p = (Player) pl;
if (projectile.getShooter() instanceof Player) { if (projectile.getShooter() instanceof Player) {
if (plugin.getArena(p) != null) { if (plugin.getArena(p) != null) {
Player shooter = (Player) projectile.getShooter(); Player shooter = (Player) projectile.getShooter();
if (plugin.getArena(shooter) != null) { if (plugin.getArena(shooter) != null) {
if (plugin.gp.get(plugin.getArena(p)) != null) { if (plugin.gp.get(plugin.getArena(p)) != null) {
if (plugin.gp.get(plugin.getArena(p)) != 0) { event.setCancelled(plugin.gp.get(plugin.getArena(p)) != 0);
event.setCancelled(true);
} else {
event.setCancelled(false);
} }
} }
} }
} } else if (projectile.getShooter() instanceof Entity e) {
} else if (projectile.getShooter() instanceof Entity) {
Entity e = (Entity) projectile.getShooter();
if (e instanceof Skeleton) { if (e instanceof Skeleton) {
if (plugin.getArena(p) != null) { if (plugin.getArena(p) != null) {
if (plugin.gp.get(plugin.getArena((Player) e)) != null) { if (plugin.gp.get(plugin.getArena((Player) e)) != null) {
if (plugin.gp.get(plugin.getArena(p)) != 0) { event.setCancelled(plugin.gp.get(plugin.getArena(p)) != 0);
event.setCancelled(true);
} else {
event.setCancelled(false);
}
} }
} }
} }
@ -89,8 +76,7 @@ public class PvP implements Listener {
@EventHandler @EventHandler
public void PlayerDamage(EntityDamageEvent event) { public void PlayerDamage(EntityDamageEvent event) {
Entity e = event.getEntity(); Entity e = event.getEntity();
if (e instanceof Player) { if (e instanceof Player p) {
Player p = (Player) e;
if (plugin.getArena(p) != null) { if (plugin.getArena(p) != null) {
a = plugin.getArena(p); a = plugin.getArena(p);
if (plugin.gp.get(a) != null && plugin.gp.get(a) != 0) { if (plugin.gp.get(a) != null && plugin.gp.get(a) != 0) {

View File

@ -12,7 +12,7 @@ import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
public class SignsAndBeds implements Listener { public class SignsAndBeds implements Listener {
public Main plugin; public final Main plugin;
public SignsAndBeds(Main m) { public SignsAndBeds(Main m) {
this.plugin = m; this.plugin = m;

View File

@ -11,7 +11,7 @@ import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
public class SignsAndBedsOld implements Listener { public class SignsAndBedsOld implements Listener {
public Main plugin; public final Main plugin;
public SignsAndBedsOld(Main m) { public SignsAndBedsOld(Main m) {
this.plugin = m; this.plugin = m;
@ -26,8 +26,7 @@ public class SignsAndBedsOld implements Listener {
return; return;
} }
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (b.getState() instanceof org.bukkit.block.Sign) { if (b.getState() instanceof org.bukkit.block.Sign sign) {
org.bukkit.block.Sign sign = (org.bukkit.block.Sign) b.getState();
String line1 = sign.getLine(0); String line1 = sign.getLine(0);
String line2 = sign.getLine(1); String line2 = sign.getLine(1);
String line3 = sign.getLine(2); String line3 = sign.getLine(2);

View File

@ -22,7 +22,7 @@ import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.DisplaySlot;
public class SpectatorListener implements Listener { public class SpectatorListener implements Listener {
public Main plugin; public final Main plugin;
public SpectatorListener(Main m) { public SpectatorListener(Main m) {
this.plugin = m; this.plugin = m;
@ -59,8 +59,7 @@ public class SpectatorListener implements Listener {
@EventHandler @EventHandler
public void SpectatorItems(EntityPickupItemEvent event) { public void SpectatorItems(EntityPickupItemEvent event) {
if (event.getEntity() instanceof Player) { if (event.getEntity() instanceof Player p) {
Player p = (Player) event.getEntity();
if (denyInteraction(p)) { if (denyInteraction(p)) {
event.setCancelled(true); event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!"); p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
@ -93,8 +92,7 @@ public class SpectatorListener implements Listener {
} else if (event.getDamager() instanceof Projectile) { } else if (event.getDamager() instanceof Projectile) {
Projectile arrow = (Projectile) offense; Projectile arrow = (Projectile) offense;
ProjectileSource shooter = arrow.getShooter(); ProjectileSource shooter = arrow.getShooter();
if (shooter instanceof Player) { if (shooter instanceof Player BowMan) {
Player BowMan = (Player) shooter;
String bowManName = BowMan.getName(); String bowManName = BowMan.getName();
for (int i : plugin.Watching.keySet()) { for (int i : plugin.Watching.keySet()) {
if (plugin.Watching.get(i) != null) { if (plugin.Watching.get(i) != null) {
@ -151,16 +149,12 @@ public class SpectatorListener implements Listener {
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz); final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
p.teleport(Spawn); p.teleport(Spawn);
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR); p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
if (plugin.scoreboards.containsKey(p.getName())) {
plugin.scoreboards.remove(p.getName()); plugin.scoreboards.remove(p.getName());
}
if (plugin.Kills.containsKey(p.getName())) {
plugin.Kills.remove(p.getName()); plugin.Kills.remove(p.getName());
} }
} }
} }
} }
}
@EventHandler @EventHandler
public void MobNerf(EntityTargetEvent event) { public void MobNerf(EntityTargetEvent event) {
@ -170,7 +164,7 @@ public class SpectatorListener implements Listener {
return; return;
} }
if (target instanceof Player) { if (target instanceof Player) {
String targetName = ((Player) target).getName(); String targetName = target.getName();
for (int i : plugin.Watching.keySet()) { for (int i : plugin.Watching.keySet()) {
if (plugin.Watching.get(i) != null) { if (plugin.Watching.get(i) != null) {
if (plugin.Watching.get(i).contains(targetName)) { if (plugin.Watching.get(i).contains(targetName)) {

View File

@ -1,7 +1,6 @@
package me.Travja.HungerArena.Listeners; package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main; import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -14,12 +13,16 @@ import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.*; import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.projectiles.ProjectileSource; import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.DisplaySlot;
public class SpectatorListenerOld implements Listener { public class SpectatorListenerOld implements Listener {
public Main plugin; public final Main plugin;
public SpectatorListenerOld(Main m) { public SpectatorListenerOld(Main m) {
this.plugin = m; this.plugin = m;
@ -103,8 +106,7 @@ public class SpectatorListenerOld implements Listener {
} else if (event.getDamager() instanceof Projectile) { } else if (event.getDamager() instanceof Projectile) {
Projectile arrow = (Projectile) offense; Projectile arrow = (Projectile) offense;
ProjectileSource shooter = arrow.getShooter(); ProjectileSource shooter = arrow.getShooter();
if (shooter instanceof Player) { if (shooter instanceof Player BowMan) {
Player BowMan = (Player) shooter;
String bowManName = BowMan.getName(); String bowManName = BowMan.getName();
for (int i : plugin.Watching.keySet()) { for (int i : plugin.Watching.keySet()) {
if (plugin.Watching.get(i) != null) { if (plugin.Watching.get(i) != null) {
@ -161,16 +163,12 @@ public class SpectatorListenerOld implements Listener {
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz); final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
p.teleport(Spawn); p.teleport(Spawn);
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR); p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
if (plugin.scoreboards.containsKey(p.getName())) {
plugin.scoreboards.remove(p.getName()); plugin.scoreboards.remove(p.getName());
}
if (plugin.Kills.containsKey(p.getName())) {
plugin.Kills.remove(p.getName()); plugin.Kills.remove(p.getName());
} }
} }
} }
} }
}
@EventHandler @EventHandler
public void MobNerf(EntityTargetEvent event) { public void MobNerf(EntityTargetEvent event) {
@ -180,7 +178,7 @@ public class SpectatorListenerOld implements Listener {
return; return;
} }
if (target instanceof Player) { if (target instanceof Player) {
String targetName = ((Player) target).getName(); String targetName = target.getName();
for (int i : plugin.Watching.keySet()) { for (int i : plugin.Watching.keySet()) {
if (plugin.Watching.get(i) != null) { if (plugin.Watching.get(i) != null) {
if (plugin.Watching.get(i).contains(targetName)) { if (plugin.Watching.get(i).contains(targetName)) {

View File

@ -10,7 +10,7 @@ import org.bukkit.event.player.PlayerTeleportEvent;
public class TeleportListener implements Listener { public class TeleportListener implements Listener {
public Main plugin; public final Main plugin;
public TeleportListener(Main m) { public TeleportListener(Main m) {
this.plugin = m; this.plugin = m;
@ -19,7 +19,7 @@ public class TeleportListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onTP(PlayerTeleportEvent event) { public void onTP(PlayerTeleportEvent event) {
Player p = event.getPlayer(); Player p = event.getPlayer();
if (plugin.worldsNames.values().contains(event.getTo().getWorld().getName()) && plugin.Tele.contains(p)) { if (plugin.worldsNames.containsValue(event.getTo().getWorld().getName()) && plugin.Tele.contains(p)) {
event.setCancelled(true); event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are a dead tribute... How are you supposed to get back into the arena...."); p.sendMessage(ChatColor.RED + "You are a dead tribute... How are you supposed to get back into the arena....");
plugin.Tele.remove(p); plugin.Tele.remove(p);

View File

@ -9,7 +9,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.PlayerChangedWorldEvent;
public class WorldChange implements Listener { public class WorldChange implements Listener {
public Main plugin; public final Main plugin;
public WorldChange(Main m) { public WorldChange(Main m) {
plugin = m; plugin = m;
@ -21,7 +21,7 @@ public class WorldChange implements Listener {
String pname = p.getName(); String pname = p.getName();
String ThisWorld = p.getWorld().getName(); String ThisWorld = p.getWorld().getName();
String FromWorld = event.getFrom().getName(); String FromWorld = event.getFrom().getName();
if (!plugin.worldsNames.values().contains(ThisWorld) && plugin.worldsNames.values().contains(FromWorld)) { if (!plugin.worldsNames.containsValue(ThisWorld) && plugin.worldsNames.containsValue(FromWorld)) {
plugin.RestoreInv(p, pname); plugin.RestoreInv(p, pname);
} }
} }

View File

@ -12,7 +12,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
import java.util.Collection; import java.util.Collection;
public class spawnsListener implements Listener { public class spawnsListener implements Listener {
public Main plugin; public final Main plugin;
public spawnsListener(Main m) { public spawnsListener(Main m) {
this.plugin = m; this.plugin = m;
@ -30,10 +30,10 @@ public class spawnsListener implements Listener {
} catch (Exception e) { } catch (Exception e) {
HandItem = p.getItemInHand().getType().name(); HandItem = p.getItemInHand().getType().name();
} }
if (HandItem == plugin.config.getString("spawnsTool")) { if (HandItem.equals(plugin.config.getString("spawnsTool"))) {
String[] info = plugin.setting.get(p.getName()).split("-"); String[] info = plugin.setting.get(p.getName()).split("-");
if (Integer.parseInt(info[1]) != plugin.config.getInt("maxPlayers") + 1) { if (Integer.parseInt(info[1]) != plugin.config.getInt("maxPlayers") + 1) {
String coords = l.getWorld().getName() + " " + ((double) l.getX() + .5) + " " + ((double) l.getY() + 1) + " " + ((double) l.getZ() + .5); String coords = l.getWorld().getName() + " " + (l.getX() + .5) + " " + (l.getY() + 1) + " " + (l.getZ() + .5);
int arena = Integer.parseInt(info[0]); int arena = Integer.parseInt(info[0]);
if (plugin.spawns.get("Spawns." + arena) != null) { if (plugin.spawns.get("Spawns." + arena) != null) {

View File

@ -1,24 +1,7 @@
package me.Travja.HungerArena; package me.Travja.HungerArena;
import java.io.File; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import me.Travja.HungerArena.Listeners.BlockStorage; import me.Travja.HungerArena.Listeners.BlockStorage;
import me.Travja.HungerArena.Listeners.WorldChange;
import me.Travja.HungerArena.Listeners.Boundaries; import me.Travja.HungerArena.Listeners.Boundaries;
import me.Travja.HungerArena.Listeners.ChatListener; import me.Travja.HungerArena.Listeners.ChatListener;
import me.Travja.HungerArena.Listeners.DeathListener; import me.Travja.HungerArena.Listeners.DeathListener;
@ -30,9 +13,9 @@ import me.Travja.HungerArena.Listeners.SignsAndBedsOld;
import me.Travja.HungerArena.Listeners.SpectatorListener; import me.Travja.HungerArena.Listeners.SpectatorListener;
import me.Travja.HungerArena.Listeners.SpectatorListenerOld; import me.Travja.HungerArena.Listeners.SpectatorListenerOld;
import me.Travja.HungerArena.Listeners.TeleportListener; import me.Travja.HungerArena.Listeners.TeleportListener;
import me.Travja.HungerArena.Listeners.WorldChange;
import me.Travja.HungerArena.Listeners.spawnsListener; import me.Travja.HungerArena.Listeners.spawnsListener;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Color; import org.bukkit.Color;
@ -42,9 +25,6 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@ -55,7 +35,6 @@ import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta; import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.material.MaterialData; import org.bukkit.material.MaterialData;
import org.bukkit.material.Torch;
import org.bukkit.metadata.MetadataValue; import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
@ -67,55 +46,70 @@ import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Score; import org.bukkit.scoreboard.Score;
import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Scoreboard;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Main extends JavaPlugin { public class Main extends JavaPlugin {
static Logger log; static Logger log;
public HashMap<Integer, List<String>> Playing = new HashMap<Integer, List<String>>(); public final HashMap<Integer, List<String>> Playing = new HashMap<>();
public HashMap<Integer, List<String>> Ready = new HashMap<Integer, List<String>>(); public final HashMap<Integer, List<String>> Ready = new HashMap<>();
public HashMap<Integer, List<String>> Dead = new HashMap<Integer, List<String>>(); public final HashMap<Integer, List<String>> Dead = new HashMap<>();
public HashMap<Integer, String> MatchRunning = new HashMap<Integer, String>(); public final HashMap<Integer, String> MatchRunning = new HashMap<>();
public HashMap<Integer, Boolean> canjoin = new HashMap<Integer, Boolean>(); public final HashMap<Integer, Boolean> canjoin = new HashMap<>();
public HashMap<Integer, Boolean> open = new HashMap<Integer, Boolean>(); public final HashMap<Integer, Boolean> open = new HashMap<>();
private HashMap<Integer, Integer> CountT = new HashMap<Integer, Integer>(); private final HashMap<Integer, Integer> CountT = new HashMap<>();
public HashMap<Integer, List<String>> Quit = new HashMap<Integer, List<String>>(); public final HashMap<Integer, List<String>> Quit = new HashMap<>();
public HashMap<Integer, List<String>> Out = new HashMap<Integer, List<String>>(); public final HashMap<Integer, List<String>> Out = new HashMap<>();
public HashMap<Integer, List<String>> Watching = new HashMap<Integer, List<String>>(); public final HashMap<Integer, List<String>> Watching = new HashMap<>();
public HashMap<String, Integer> Kills = new HashMap<String, Integer>(); public final HashMap<String, Integer> Kills = new HashMap<>();
public HashMap<Integer, List<String>> NeedConfirm = new HashMap<Integer, List<String>>(); public final HashMap<Integer, List<String>> NeedConfirm = new HashMap<>();
public HashMap<Integer, HashMap<Integer, Location>> location = new HashMap<Integer, HashMap<Integer, Location>>(); public final HashMap<Integer, HashMap<Integer, Location>> location = new HashMap<>();
public HashMap<Integer, List<String>> inArena = new HashMap<Integer, List<String>>(); public final HashMap<Integer, List<String>> inArena = new HashMap<>();
public HashMap<Integer, List<String>> Frozen = new HashMap<Integer, List<String>>(); public final HashMap<Integer, List<String>> Frozen = new HashMap<>();
public HashMap<Integer, List<String>> arena = new HashMap<Integer, List<String>>(); public final HashMap<Integer, List<String>> arena = new HashMap<>();
public HashMap<Integer, Integer> maxPlayers = new HashMap<Integer, Integer>(); public final HashMap<Integer, Integer> maxPlayers = new HashMap<>();
public HashMap<String, String> setting = new HashMap<String, String>(); public final HashMap<String, String> setting = new HashMap<>();
public HashMap<Integer, Integer> gp = new HashMap<Integer, Integer>(); public final HashMap<Integer, Integer> gp = new HashMap<>();
public ArrayList<Player> Tele = new ArrayList<Player>(); public final ArrayList<Player> Tele = new ArrayList<>();
public ArrayList<String> needInv = new ArrayList<String>(); public final ArrayList<String> needInv = new ArrayList<>();
public HashMap<Integer, String> worldsNames = new HashMap<Integer, String>(); public final HashMap<Integer, String> worldsNames = new HashMap<>();
public HashMap<String, Scoreboard> scoreboards = new HashMap<String, Scoreboard>(); public final HashMap<String, Scoreboard> scoreboards = new HashMap<>();
Listener DeathListener = new DeathListener(this); final Listener DeathListener = new DeathListener(this);
Listener SpectatorListener = null; Listener SpectatorListener = null;
Listener SpectatorListenerOld = null; Listener SpectatorListenerOld = null;
Listener FreezeListener = new FreezeListener(this); final Listener FreezeListener = new FreezeListener(this);
Listener JoinAndQuitListener = new JoinAndQuitListener(this); final Listener JoinAndQuitListener = new JoinAndQuitListener(this);
Listener ChatListener = new ChatListener(this); final Listener ChatListener = new ChatListener(this);
Listener Chests = new Chests(this); final Listener Chests = new Chests(this);
Listener PvP = new PvP(this); final Listener PvP = new PvP(this);
Listener CommandBlock = new CommandBlock(this); final Listener CommandBlock = new CommandBlock(this);
Listener Teleport = new TeleportListener(this); Listener Teleport = new TeleportListener(this);
SignsAndBeds SignsAndBeds = null; SignsAndBeds SignsAndBeds = null;
SignsAndBedsOld SignsAndBedsOld = null; SignsAndBedsOld SignsAndBedsOld = null;
Listener BlockStorage = new BlockStorage(this); final Listener BlockStorage = new BlockStorage(this);
//Listener WinGames = new WinGamesListener(this); //Listener WinGames = new WinGamesListener(this);
Listener WorldChange = new WorldChange(this); final Listener WorldChange = new WorldChange(this);
Listener Boundaries = new Boundaries(this); final Listener Boundaries = new Boundaries(this);
Listener spawnsListener = new spawnsListener(this); final Listener spawnsListener = new spawnsListener(this);
CommandExecutor HaCommands = new HaCommands(this); final CommandExecutor HaCommands = new HaCommands(this);
CommandExecutor SponsorCommands = new SponsorCommands(this); final CommandExecutor SponsorCommands = new SponsorCommands(this);
CommandExecutor SpawnsCommand = new SpawnsCommand(this); final CommandExecutor SpawnsCommand = new SpawnsCommand(this);
public boolean exists; public boolean exists;
public boolean restricted; public boolean restricted;
@ -131,10 +125,10 @@ public class Main extends JavaPlugin {
public FileConfiguration MyChests = null; public FileConfiguration MyChests = null;
public File ChestsFile = null; public File ChestsFile = null;
public ArrayList<ItemStack> Reward = new ArrayList<ItemStack>(); public final ArrayList<ItemStack> Reward = new ArrayList<>();
public ArrayList<ItemStack> Cost = new ArrayList<ItemStack>(); public final ArrayList<ItemStack> Cost = new ArrayList<>();
public ArrayList<ItemStack> Fee = new ArrayList<ItemStack>(); public final ArrayList<ItemStack> Fee = new ArrayList<>();
public ArrayList<ItemStack> ChestPay = new ArrayList<ItemStack>(); public final ArrayList<ItemStack> ChestPay = new ArrayList<>();
public boolean vault = false; public boolean vault = false;
public boolean eco = false; public boolean eco = false;
@ -144,7 +138,7 @@ public class Main extends JavaPlugin {
int v = 0; int v = 0;
int a = 0; int a = 0;
File PFilePath = new File(getDataFolder(), "/inventories"); final File PFilePath = new File(getDataFolder(), "/inventories");
public void onEnable() { public void onEnable() {
log = this.getLogger(); log = this.getLogger();
@ -208,7 +202,7 @@ public class Main extends JavaPlugin {
for (File file : PFilePath.listFiles()) { for (File file : PFilePath.listFiles()) {
String filename = file.getName(); String filename = file.getName();
int lastIndex = filename.lastIndexOf('.'); int lastIndex = filename.lastIndexOf('.');
filename = filename.substring(0, lastIndex >= 0 ? lastIndex : 0); filename = filename.substring(0, Math.max(lastIndex, 0));
needInv.add(filename); needInv.add(filename);
} }
@ -225,7 +219,7 @@ public class Main extends JavaPlugin {
config.set("rewardEco.reward", 100); config.set("rewardEco.reward", 100);
} }
if (config.getBoolean("rewardEco.enabled", true) || config.getBoolean("sponsorEco.enabled", true) || config.getBoolean("EntryFee.eco", true)) { if (config.getBoolean("rewardEco.enabled", true) || config.getBoolean("sponsorEco.enabled", true) || config.getBoolean("EntryFee.eco", true)) {
if (vault == true) { if (vault) {
log.info("Economy hook deployed."); log.info("Economy hook deployed.");
eco = true; eco = true;
} else { } else {
@ -233,15 +227,15 @@ public class Main extends JavaPlugin {
} }
} }
if (!eco) { if (!eco) {
if (vault == true) { if (vault) {
log.info("We see that you have Vault on your server. To set economy support to true, enable it in the config."); log.info("We see that you have Vault on your server. To set economy support to true, enable it in the config.");
} }
} }
try { try {
List<String> RewardItemList = new ArrayList<String>(); List<String> RewardItemList = new ArrayList<>();
List<String> SponsorItemList = new ArrayList<String>(); List<String> SponsorItemList = new ArrayList<>();
List<String> EntryfeeItemList = new ArrayList<String>(); List<String> EntryfeeItemList = new ArrayList<>();
List<String> PayForChests = new ArrayList<String>(); List<String> PayForChests = new ArrayList<>();
for (String rewards : config.getStringList("Reward")) { for (String rewards : config.getStringList("Reward")) {
String[] rinfo = rewards.split(","); String[] rinfo = rewards.split(",");
@ -287,7 +281,7 @@ public class Main extends JavaPlugin {
config.set("ChestPay.items", PayForChests); config.set("ChestPay.items", PayForChests);
} }
ArrayList<String> newList = new ArrayList<String>(); ArrayList<String> newList = new ArrayList<>();
for (String block : management.getStringList("blocks.whitelist")) { for (String block : management.getStringList("blocks.whitelist")) {
Material NewMat = getNewMaterial(block, 0); Material NewMat = getNewMaterial(block, 0);
if (NewMat != null) { if (NewMat != null) {
@ -358,9 +352,7 @@ public class Main extends JavaPlugin {
if (spawns.getConfigurationSection("Spawns." + entry.getKey()) != null) { if (spawns.getConfigurationSection("Spawns." + entry.getKey()) != null) {
Integer a = Integer.parseInt(entry.getKey()); Integer a = Integer.parseInt(entry.getKey());
worldsNames.put(a, "none_meening_this_is_not_a_map"); worldsNames.put(a, "none_meening_this_is_not_a_map");
if (location.get(a) == null) { location.computeIfAbsent(a, k -> new HashMap<>());
location.put(a, new HashMap<Integer, Location>());
}
Map<String, Object> temp2 = spawns.getConfigurationSection("Spawns." + entry.getKey()).getValues(false); Map<String, Object> temp2 = spawns.getConfigurationSection("Spawns." + entry.getKey()).getValues(false);
for (Map.Entry<String, Object> e : temp2.entrySet()) { for (Map.Entry<String, Object> e : temp2.entrySet()) {
if (spawns.get("Spawns." + entry.getKey() + "" + e.getKey()) != null) { if (spawns.get("Spawns." + entry.getKey() + "" + e.getKey()) != null) {
@ -381,17 +373,17 @@ public class Main extends JavaPlugin {
if (verbose) { if (verbose) {
log.info("Loaded " + location.get(i).size() + " tribute spawns for arena " + i + "!"); log.info("Loaded " + location.get(i).size() + " tribute spawns for arena " + i + "!");
} }
Playing.put(i, new ArrayList<String>()); Playing.put(i, new ArrayList<>());
Ready.put(i, new ArrayList<String>()); Ready.put(i, new ArrayList<>());
Dead.put(i, new ArrayList<String>()); Dead.put(i, new ArrayList<>());
MatchRunning.put(i, null); MatchRunning.put(i, null);
Quit.put(i, new ArrayList<String>()); Quit.put(i, new ArrayList<>());
Out.put(i, new ArrayList<String>()); Out.put(i, new ArrayList<>());
Watching.put(i, new ArrayList<String>()); Watching.put(i, new ArrayList<>());
NeedConfirm.put(i, new ArrayList<String>()); NeedConfirm.put(i, new ArrayList<>());
inArena.put(i, new ArrayList<String>()); inArena.put(i, new ArrayList<>());
Frozen.put(i, new ArrayList<String>()); Frozen.put(i, new ArrayList<>());
arena.put(i, new ArrayList<String>()); arena.put(i, new ArrayList<>());
canjoin.put(i, false); canjoin.put(i, false);
maxPlayers.put(i, location.get(i).size()); maxPlayers.put(i, location.get(i).size());
open.put(i, true); open.put(i, true);
@ -402,7 +394,7 @@ public class Main extends JavaPlugin {
public WorldEditPlugin hookWE() { public WorldEditPlugin hookWE() {
Plugin wPlugin = getServer().getPluginManager().getPlugin("WorldEdit"); Plugin wPlugin = getServer().getPluginManager().getPlugin("WorldEdit");
if ((wPlugin == null) || (!(wPlugin instanceof WorldEditPlugin))) { if ((!(wPlugin instanceof WorldEditPlugin))) {
return null; return null;
} }
@ -610,11 +602,7 @@ public class Main extends JavaPlugin {
Reader defaultConfigReader = null; Reader defaultConfigReader = null;
YamlConfiguration defConfig = null; YamlConfiguration defConfig = null;
if (defConfigStream != null) { if (defConfigStream != null) {
try { defaultConfigReader = new java.io.InputStreamReader(defConfigStream, StandardCharsets.UTF_8);
defaultConfigReader = new java.io.InputStreamReader(defConfigStream, "UTF-8");
} catch (UnsupportedEncodingException e) {
log.info("The embedded resource contained in the plugin jar file has an unsupported encoding.It should be encoded with UTF-8.");
}
} }
if (defaultConfigReader != null) { if (defaultConfigReader != null) {
@ -665,7 +653,7 @@ public class Main extends JavaPlugin {
g.sendMessage(ChatColor.RED + pname + " Quit!"); g.sendMessage(ChatColor.RED + pname + " Quit!");
} }
} }
if (canjoin.get(u) == true) { if (canjoin.get(u)) {
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR); p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
scoreboards.remove(p.getName()); scoreboards.remove(p.getName());
Kills.remove(p.getName()); Kills.remove(p.getName());
@ -674,11 +662,9 @@ public class Main extends JavaPlugin {
} }
} }
if (Ready.get(u) != null) { if (Ready.get(u) != null) {
if (Ready.get(u).contains(pname)) {
Ready.get(u).remove(pname); Ready.get(u).remove(pname);
} }
} }
}
if (new File(PFilePath, pname + ".yml").exists()) { if (new File(PFilePath, pname + ".yml").exists()) {
FileConfiguration pinfo = this.getPConfig(pname); FileConfiguration pinfo = this.getPConfig(pname);
if ((pinfo.getString("player").equals(pname)) && (this.needInv.contains(pname))) { if ((pinfo.getString("player").equals(pname)) && (this.needInv.contains(pname))) {
@ -688,7 +674,7 @@ public class Main extends JavaPlugin {
if (o instanceof ItemStack[]) { if (o instanceof ItemStack[]) {
pinv = (ItemStack[]) o; pinv = (ItemStack[]) o;
} else if (o instanceof List) { } else if (o instanceof List) {
pinv = (ItemStack[]) ((List<ItemStack>) o).toArray(new ItemStack[0]); pinv = ((List<ItemStack>) o).toArray(new ItemStack[0]);
} }
p.getInventory().setContents(pinv); p.getInventory().setContents(pinv);
p.updateInventory(); p.updateInventory();
@ -698,7 +684,7 @@ public class Main extends JavaPlugin {
if (o instanceof ItemStack[]) { if (o instanceof ItemStack[]) {
parmor = (ItemStack[]) o; parmor = (ItemStack[]) o;
} else if (o instanceof List) { } else if (o instanceof List) {
parmor = (ItemStack[]) ((List<ItemStack>) o).toArray(new ItemStack[0]); parmor = ((List<ItemStack>) o).toArray(new ItemStack[0]);
} }
p.getInventory().setArmorContents(parmor); p.getInventory().setArmorContents(parmor);
p.updateInventory(); p.updateInventory();
@ -740,7 +726,7 @@ public class Main extends JavaPlugin {
String winnername = Playing.get(a).get(i); String winnername = Playing.get(a).get(i);
final Player winner = getServer().getPlayerExact(winnername); final Player winner = getServer().getPlayerExact(winnername);
String winnername2 = winner.getName(); String winnername2 = winner.getName();
if (canjoin.get(a) == true) { if (canjoin.get(a)) {
getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!"); getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
} }
winner.getInventory().clear(); winner.getInventory().clear();
@ -760,14 +746,10 @@ public class Main extends JavaPlugin {
this.RestoreInv(winner, winnername2); this.RestoreInv(winner, winnername2);
if (canjoin.get(a) == true) { if (canjoin.get(a)) {
winner.getScoreboard().clearSlot(DisplaySlot.SIDEBAR); winner.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
if (scoreboards.containsKey(winner.getName())) {
scoreboards.remove(winner.getName()); scoreboards.remove(winner.getName());
}
if (Kills.containsKey(winner.getName())) {
Kills.remove(winner.getName()); Kills.remove(winner.getName());
}
//////////////////////////////////////////////////////// ////////////////////////////////////////////////////////
//////////////////// FIREWORKS /////////////////////// //////////////////// FIREWORKS ///////////////////////
@ -775,8 +757,7 @@ public class Main extends JavaPlugin {
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
Bukkit.getScheduler().runTaskLater(this, new Runnable() { Bukkit.getScheduler().runTaskLater(this, () -> {
public void run() {
//Spawn the Fireworks, get the FireworkMeta. //Spawn the Fireworks, get the FireworkMeta.
Firework fw = (Firework) winner.getWorld().spawnEntity(winner.getLocation(), EntityType.FIREWORK); Firework fw = (Firework) winner.getWorld().spawnEntity(winner.getLocation(), EntityType.FIREWORK);
FireworkMeta fwm = fw.getFireworkMeta(); FireworkMeta fwm = fw.getFireworkMeta();
@ -821,7 +802,6 @@ public class Main extends JavaPlugin {
//Then apply this to our rocket //Then apply this to our rocket
fw.setFireworkMeta(fwm); fw.setFireworkMeta(fwm);
}
}, 20 + i * 20L); }, 20 + i * 20L);
} }
@ -869,11 +849,7 @@ public class Main extends JavaPlugin {
} }
} }
if (config.getString("Auto_Restart").equalsIgnoreCase("True")) { if (config.getString("Auto_Restart").equalsIgnoreCase("True")) {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, () -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart " + a), 220L);
public void run() {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart " + a);
}
}, 220L);
} }
MatchRunning.put(a, null); MatchRunning.put(a, null);
} }
@ -918,13 +894,11 @@ public class Main extends JavaPlugin {
} }
private void scoreboardInit() { private void scoreboardInit() {
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> {
public void run() {
Collection<? extends Player> online = getServer().getOnlinePlayers(); Collection<? extends Player> online = getServer().getOnlinePlayers();
for (Player pl : online) { for (Player pl : online) {
updateScoreboard(pl); updateScoreboard(pl);
} }
}
}, 20L, 10L); }, 20L, 10L);
} }
@ -957,9 +931,9 @@ public class Main extends JavaPlugin {
if (config.getInt("DeathMatch") != 0) { if (config.getInt("DeathMatch") != 0) {
if (timetodeath.get(a) != null) { if (timetodeath.get(a) != null) {
if (timetodeath.get(a) > 0) { if (timetodeath.get(a) > 0) {
int ttd = Integer.valueOf(timetodeath.get(a) - timetodeath.get(a) / 60 * 60); int ttd = timetodeath.get(a) - timetodeath.get(a) / 60 * 60;
String secs = String.valueOf((ttd < 10) ? "0" + ttd : ttd); String secs = String.valueOf((ttd < 10) ? "0" + ttd : ttd);
obj.setDisplayName(ChatColor.GREEN + "HA - DMTime: " + ChatColor.AQUA + Integer.valueOf(timetodeath.get(a) / 60) + ":" + secs); obj.setDisplayName(ChatColor.GREEN + "HA - DMTime: " + ChatColor.AQUA + timetodeath.get(a) / 60 + ":" + secs);
} else { } else {
obj.setDisplayName(ChatColor.GREEN + "HA - " + ChatColor.RED + "DEATHMATCH"); obj.setDisplayName(ChatColor.GREEN + "HA - " + ChatColor.RED + "DEATHMATCH");
} }
@ -973,10 +947,10 @@ public class Main extends JavaPlugin {
} }
} }
public HashMap<Integer, Integer> grace = new HashMap<Integer, Integer>(); public final HashMap<Integer, Integer> grace = new HashMap<>();
public HashMap<Integer, Integer> start = new HashMap<Integer, Integer>(); public final HashMap<Integer, Integer> start = new HashMap<>();
public HashMap<Integer, Integer> deathtime = new HashMap<Integer, Integer>(); public final HashMap<Integer, Integer> deathtime = new HashMap<>();
public HashMap<Integer, Integer> timetodeath = new HashMap<Integer, Integer>(); public final HashMap<Integer, Integer> timetodeath = new HashMap<>();
public void startGames(final int a) { public void startGames(final int a) {
if ((MatchRunning.get(a) != null) && (MatchRunning.get(a).equals("true"))) { if ((MatchRunning.get(a) != null) && (MatchRunning.get(a).equals("true"))) {
@ -1012,16 +986,15 @@ public class Main extends JavaPlugin {
} }
if (config.getString("Countdown").equalsIgnoreCase("true")) { if (config.getString("Countdown").equalsIgnoreCase("true")) {
CountT.put(a, (config.getInt("Countdown_Timer") != 0 ? config.getInt("Countdown_Timer") : 10)); CountT.put(a, (config.getInt("Countdown_Timer") != 0 ? config.getInt("Countdown_Timer") : 10));
start.put(a, getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { start.put(a, getServer().getScheduler().scheduleSyncRepeatingTask(this, () -> {
public void run() {
if (CountT.get(a) > 0) { if (CountT.get(a) > 0) {
if (!restricted) { if (!restricted) {
if (config.getBoolean("broadcastAll")) { if (config.getBoolean("broadcastAll")) {
getServer().broadcastMessage(ChatColor.AQUA + "Game " + a + " starting in: " + String.valueOf(CountT.get(a))); getServer().broadcastMessage(ChatColor.AQUA + "Game " + a + " starting in: " + CountT.get(a));
} else { } else {
for (String gn : Playing.get(a)) { for (String gn : Playing.get(a)) {
Player g = getServer().getPlayer(gn); Player g = getServer().getPlayer(gn);
g.sendMessage(ChatColor.AQUA + "Game starting in: " + String.valueOf(CountT.get(a))); g.sendMessage(ChatColor.AQUA + "Game starting in: " + CountT.get(a));
} }
} }
} else { } else {
@ -1077,8 +1050,7 @@ public class Main extends JavaPlugin {
if (config.getInt("Grace_Period") != 0) { if (config.getInt("Grace_Period") != 0) {
gp.put(a, config.getInt("Grace_Period")); gp.put(a, config.getInt("Grace_Period"));
if (grace.get(a) == null) { if (grace.get(a) == null) {
grace.put(a, getServer().getScheduler().scheduleSyncRepeatingTask(Bukkit.getPluginManager().getPlugin("HungerArena"), new Runnable() { grace.put(a, getServer().getScheduler().scheduleSyncRepeatingTask(Bukkit.getPluginManager().getPlugin("HungerArena"), () -> {
public void run() {
gp.put(a, gp.get(a) - 1); gp.put(a, gp.get(a) - 1);
if (gp.get(a) == 30 || gp.get(a) == 15 || (gp.get(a) < 11 && gp.get(a) != 0)) { if (gp.get(a) == 30 || gp.get(a) == 15 || (gp.get(a) < 11 && gp.get(a) != 0)) {
if (config.getBoolean("broadcastAll")) { if (config.getBoolean("broadcastAll")) {
@ -1100,7 +1072,6 @@ public class Main extends JavaPlugin {
getServer().getScheduler().cancelTask(grace.get(a)); getServer().getScheduler().cancelTask(grace.get(a));
grace.put(a, null); grace.put(a, null);
} }
}
}, 20L, 20L)); }, 20L, 20L));
} }
} }
@ -1108,10 +1079,9 @@ public class Main extends JavaPlugin {
int death = config.getInt("DeathMatch"); int death = config.getInt("DeathMatch");
timetodeath.put(a, death * 60); timetodeath.put(a, death * 60);
if (deathtime.get(a) == null) { if (deathtime.get(a) == null) {
deathtime.put(a, getServer().getScheduler().scheduleSyncRepeatingTask(Bukkit.getPluginManager().getPlugin("HungerArena"), new Runnable() { deathtime.put(a, getServer().getScheduler().scheduleSyncRepeatingTask(Bukkit.getPluginManager().getPlugin("HungerArena"), () -> {
public void run() {
timetodeath.put(a, timetodeath.get(a) - 1); timetodeath.put(a, timetodeath.get(a) - 1);
if (Integer.valueOf(timetodeath.get(a)) % 300 == 0) { if (timetodeath.get(a) % 300 == 0) {
if (config.getBoolean("broadcastAll")) { if (config.getBoolean("broadcastAll")) {
for (Player wp : location.get(a).get(1).getWorld().getPlayers()) { for (Player wp : location.get(a).get(1).getWorld().getPlayers()) {
if (timetodeath.get(a) != 0) { if (timetodeath.get(a) != 0) {
@ -1167,14 +1137,12 @@ public class Main extends JavaPlugin {
StopTasksDelayed(deathtime.get(a)); StopTasksDelayed(deathtime.get(a));
deathtime.put(a, null); deathtime.put(a, null);
} }
}
}, 20L, 20L)); }, 20L, 20L));
} }
} }
setTorch(a, true); setTorch(a, true);
StopTasksDelayed(start.get(a)); StopTasksDelayed(start.get(a));
} }
}
}, 20L, 20L)); }, 20L, 20L));
} else { } else {
setTorch(a, true); setTorch(a, true);
@ -1192,11 +1160,7 @@ public class Main extends JavaPlugin {
} }
private void StopTasksDelayed(final int task) { private void StopTasksDelayed(final int task) {
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> Bukkit.getScheduler().cancelTask(task), 10L);
public void run() {
Bukkit.getScheduler().cancelTask(task);
}
}, 10L);
} }
public Integer getArena(Player p) { public Integer getArena(Player p) {

View File

@ -1,8 +1,5 @@
package me.Travja.HungerArena; package me.Travja.HungerArena;
import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
@ -11,8 +8,11 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.HashMap;
public class SpawnsCommand implements CommandExecutor { public class SpawnsCommand implements CommandExecutor {
public Main plugin; public final Main plugin;
int i = 0; int i = 0;
int a = 0; int a = 0;
boolean NoPlayerSpawns; boolean NoPlayerSpawns;
@ -43,8 +43,8 @@ public class SpawnsCommand implements CommandExecutor {
double z; double z;
if (args.length == 6) { if (args.length == 6) {
try { try {
i = Integer.valueOf(args[1]); i = Integer.parseInt(args[1]);
a = Integer.valueOf(args[0]); a = Integer.parseInt(args[0]);
} catch (Exception e) { } catch (Exception e) {
p.sendMessage(ChatColor.RED + "Argument not an integer!"); p.sendMessage(ChatColor.RED + "Argument not an integer!");
return true; return true;
@ -58,18 +58,18 @@ public class SpawnsCommand implements CommandExecutor {
if (plugin.location.get(a) != null) { if (plugin.location.get(a) != null) {
plugin.location.get(a).put(i, loc); plugin.location.get(a).put(i, loc);
} else { } else {
plugin.location.put(a, new HashMap<Integer, Location>()); plugin.location.put(a, new HashMap<>());
plugin.location.get(a).put(i, loc); plugin.location.get(a).put(i, loc);
plugin.Playing.put(a, new ArrayList<String>()); plugin.Playing.put(a, new ArrayList<>());
plugin.Ready.put(a, new ArrayList<String>()); plugin.Ready.put(a, new ArrayList<>());
plugin.Dead.put(a, new ArrayList<String>()); plugin.Dead.put(a, new ArrayList<>());
plugin.Quit.put(a, new ArrayList<String>()); plugin.Quit.put(a, new ArrayList<>());
plugin.Out.put(a, new ArrayList<String>()); plugin.Out.put(a, new ArrayList<>());
plugin.Watching.put(a, new ArrayList<String>()); plugin.Watching.put(a, new ArrayList<>());
plugin.NeedConfirm.put(a, new ArrayList<String>()); plugin.NeedConfirm.put(a, new ArrayList<>());
plugin.inArena.put(a, new ArrayList<String>()); plugin.inArena.put(a, new ArrayList<>());
plugin.Frozen.put(a, new ArrayList<String>()); plugin.Frozen.put(a, new ArrayList<>());
plugin.arena.put(a, new ArrayList<String>()); plugin.arena.put(a, new ArrayList<>());
plugin.canjoin.put(a, false); plugin.canjoin.put(a, false);
plugin.MatchRunning.put(a, null); plugin.MatchRunning.put(a, null);
plugin.open.put(a, true); plugin.open.put(a, true);
@ -86,14 +86,14 @@ public class SpawnsCommand implements CommandExecutor {
} }
if (args.length >= 2) { if (args.length >= 2) {
try { try {
i = Integer.valueOf(args[1]); i = Integer.parseInt(args[1]);
a = Integer.valueOf(args[0]); a = Integer.parseInt(args[0]);
} catch (Exception e) { } catch (Exception e) {
p.sendMessage(ChatColor.RED + "Argument not an integer!"); p.sendMessage(ChatColor.RED + "Argument not an integer!");
return true; return true;
} }
if (i >= 1 && i <= plugin.config.getInt("maxPlayers")) { if (i >= 1 && i <= plugin.config.getInt("maxPlayers")) {
if (!plugin.worldsNames.values().contains(p.getWorld().getName())) { if (!plugin.worldsNames.containsValue(p.getWorld().getName())) {
p.sendMessage(ChatColor.GOLD + "You've added this world to the config ..."); p.sendMessage(ChatColor.GOLD + "You've added this world to the config ...");
} }
loc = p.getLocation().getBlock().getLocation(); loc = p.getLocation().getBlock().getLocation();
@ -104,18 +104,18 @@ public class SpawnsCommand implements CommandExecutor {
if (plugin.location.get(a) != null) { if (plugin.location.get(a) != null) {
plugin.location.get(a).put(i, loc); plugin.location.get(a).put(i, loc);
} else { } else {
plugin.location.put(a, new HashMap<Integer, Location>()); plugin.location.put(a, new HashMap<>());
plugin.location.get(a).put(i, loc); plugin.location.get(a).put(i, loc);
plugin.Playing.put(a, new ArrayList<String>()); plugin.Playing.put(a, new ArrayList<>());
plugin.Ready.put(a, new ArrayList<String>()); plugin.Ready.put(a, new ArrayList<>());
plugin.Dead.put(a, new ArrayList<String>()); plugin.Dead.put(a, new ArrayList<>());
plugin.Quit.put(a, new ArrayList<String>()); plugin.Quit.put(a, new ArrayList<>());
plugin.Out.put(a, new ArrayList<String>()); plugin.Out.put(a, new ArrayList<>());
plugin.Watching.put(a, new ArrayList<String>()); plugin.Watching.put(a, new ArrayList<>());
plugin.NeedConfirm.put(a, new ArrayList<String>()); plugin.NeedConfirm.put(a, new ArrayList<>());
plugin.inArena.put(a, new ArrayList<String>()); plugin.inArena.put(a, new ArrayList<>());
plugin.Frozen.put(a, new ArrayList<String>()); plugin.Frozen.put(a, new ArrayList<>());
plugin.arena.put(a, new ArrayList<String>()); plugin.arena.put(a, new ArrayList<>());
plugin.canjoin.put(a, false); plugin.canjoin.put(a, false);
plugin.MatchRunning.put(a, null); plugin.MatchRunning.put(a, null);
plugin.open.put(a, true); plugin.open.put(a, true);

View File

@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class SponsorCommands implements CommandExecutor { public class SponsorCommands implements CommandExecutor {
public Main plugin; public final Main plugin;
public SponsorCommands(Main m) { public SponsorCommands(Main m) {
this.plugin = m; this.plugin = m;
@ -20,8 +20,7 @@ public class SponsorCommands implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if (cmd.getName().equalsIgnoreCase("Sponsor")) { if (cmd.getName().equalsIgnoreCase("Sponsor")) {
if (sender instanceof Player) { if (sender instanceof Player p) {
Player p = (Player) sender;
if (p.hasPermission("HungerArena.Sponsor")) { if (p.hasPermission("HungerArena.Sponsor")) {
if (plugin.getArena(p) == null) { if (plugin.getArena(p) == null) {
if (args.length == 0) { if (args.length == 0) {