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;
public class Chests implements Listener {
public Main plugin;
public final Main plugin;
public Chests(Main m) {
this.plugin = m;
@ -48,14 +48,14 @@ public class Chests implements Listener {
if (plugin.getArena(p) != null) {
int a = plugin.getArena(p);
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.getState() instanceof InventoryHolder) {
ItemStack[] itemsinchest = ((InventoryHolder) block.getState()).getInventory().getContents().clone();
int blockx = block.getX();
int blocky = block.getY();
int blockz = block.getZ();
String blockw = block.getWorld().getName().toString();
String blockw = block.getWorld().getName();
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.Y", blocky);

View File

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

View File

@ -1,12 +1,5 @@
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.LocalSession;
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.regions.Region;
import com.sk89q.worldedit.session.SessionManager;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@ -29,7 +21,6 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Damageable;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.InventoryHolder;
@ -43,8 +34,15 @@ import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Score;
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 Main plugin;
public final Main plugin;
public HaCommands(Main m) {
this.plugin = m;
@ -75,8 +73,7 @@ public class HaCommands implements CommandExecutor {
double spawnz = Double.parseDouble(Spawncoords[2]);
String spawnworld = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(spawnworld);
Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
return Spawn;
return new Location(spawnw, spawnx, spawny, spawnz);
}
@Override
@ -123,7 +120,7 @@ public class HaCommands implements CommandExecutor {
p.sendMessage(ChatColor.RED + "Argument not an integer!");
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!)");
return false;
}
@ -187,9 +184,9 @@ public class HaCommands implements CommandExecutor {
} else if (args[0].equalsIgnoreCase("Help")) {
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!");
} else if (!plugin.restricted || plugin.restricted && plugin.worldsNames.values().contains(ThisWorld)) {
} else if (!plugin.restricted || plugin.restricted && plugin.worldsNames.containsValue(ThisWorld)) {
//////////////////////////////////////// LISTING ///////////////////////////////////////////////
if (args[0].equalsIgnoreCase("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).contains(pname)) {
p.sendMessage(ChatColor.RED + "You are already playing!");
} 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!");
} 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!");
} else if (plugin.canjoin.get(a) == true) {
} else if (plugin.canjoin.get(a)) {
p.sendMessage(ChatColor.RED + "That game is in progress!");
} else if (!plugin.open.get(a)) {
p.sendMessage(ChatColor.RED + "That game is closed!");
@ -327,7 +323,7 @@ public class HaCommands implements CommandExecutor {
} else {
plugin.Ready.get(a).add(pname);
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 {
for (String gn : plugin.Playing.get(a)) {
Player g = plugin.getServer().getPlayer(gn);
@ -348,12 +344,10 @@ public class HaCommands implements CommandExecutor {
} else if (args[0].equalsIgnoreCase("Leave")) {
if (plugin.getArena(p) != null) {
a = plugin.getArena(p);
if (plugin.canjoin.get(a) == true) {
if (plugin.canjoin.get(a)) {
clearInv(p);
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) {
plugin.RestoreInv(p, pname);
@ -393,7 +387,7 @@ public class HaCommands implements CommandExecutor {
if (args.length >= 2) {
if (checkarena(args[1], sender)) {
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);
p.teleport(Bukkit.getPlayer(plugin.Playing.get(a).get(0)));
for (Player online : plugin.getServer().getOnlinePlayers()) {
@ -416,7 +410,7 @@ public class HaCommands implements CommandExecutor {
sobj.setDisplaySlot(DisplaySlot.SIDEBAR);
p.setScoreboard(scoreboard);
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!");
} else if (plugin.Playing.get(a).contains(pname)) {
p.sendMessage(ChatColor.RED + "You can't watch while you're playing!");
@ -665,9 +659,9 @@ public class HaCommands implements CommandExecutor {
try {
maxh = players.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
} 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"))) {
sender.sendMessage(ChatColor.GREEN + playernames);
}
@ -715,7 +709,7 @@ public class HaCommands implements CommandExecutor {
sender.sendMessage(ChatColor.RED + "Use playername !");
return false;
}
if (console || (playr && ((Player) sender).hasPermission("HungerArena.Kick"))) {
if (console || (playr && sender.hasPermission("HungerArena.Kick"))) {
if (plugin.getArena(target) != null) {
a = plugin.getArena(target);
plugin.Playing.get(a).remove(target.getName());
@ -834,9 +828,7 @@ public class HaCommands implements CommandExecutor {
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) {
for (String sname : plugin.Watching.get(a)) {
Player spectators = plugin.getServer().getPlayerExact(sname);
@ -875,8 +867,8 @@ public class HaCommands implements CommandExecutor {
plugin.MatchRunning.put(a, null);
List<String> blocksbroken = plugin.data.getStringList("Blocks_Destroyed");
List<String> blocksplaced = plugin.data.getStringList("Blocks_Placed");
ArrayList<String> toremove = new ArrayList<String>();
ArrayList<String> toremove2 = new ArrayList<String>();
ArrayList<String> toremove = new ArrayList<>();
ArrayList<String> toremove2 = new ArrayList<>();
for (String blocks : blocksplaced) {
String[] coords = blocks.split(",");
World w = plugin.getServer().getWorld(coords[0]);
@ -944,7 +936,7 @@ public class HaCommands implements CommandExecutor {
}
}
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) {
Set<Integer> list = plugin.open.keySet();
if (args.length >= 2) {
list = new HashSet<Integer>();
list = new HashSet<>();
if (checkarena(args[1], sender)) {
list.add(Integer.parseInt(args[1]));
}
@ -1045,20 +1037,16 @@ public class HaCommands implements CommandExecutor {
if (plugin.Playing.get(a).size() <= 1) {
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!");
} else {
plugin.setTorch(a, false);
if (plugin.config.getString("Auto_Start").equalsIgnoreCase("true")) {
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha start " + a);
}
}, 20L);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha start " + a), 20L);
}
List<Integer> shuffle = new ArrayList<Integer>();
List<Integer> shuffle = new ArrayList<>();
for (i = 1; i <= plugin.location.get(a).size(); shuffle.add(i++)) {
}
Collections.shuffle(shuffle);
@ -1095,11 +1083,9 @@ public class HaCommands implements CommandExecutor {
tribute.teleport(toLoc);
i += 1;
}
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
sender.sendMessage(ChatColor.AQUA + "All Tributes warped!");
plugin.MatchRunning.put(a, "warped");
}
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
sender.sendMessage(ChatColor.AQUA + "All Tributes warped!");
plugin.MatchRunning.put(a, "warped");
}, 10L);
}
}
@ -1116,7 +1102,7 @@ public class HaCommands implements CommandExecutor {
} else {
if (checkarena(args[1], sender)) {
a = Integer.parseInt(args[1]);
if (plugin.canjoin.get(a) == true) {
if (plugin.canjoin.get(a)) {
sender.sendMessage(ChatColor.RED + "Game already in progress!");
} else if (plugin.Playing.get(a).size() == 1) {
sender.sendMessage(ChatColor.RED + "There are not enough players!");

View File

@ -24,7 +24,7 @@ import org.bukkit.material.MaterialData;
import java.util.List;
public class BlockStorage implements Listener {
public Main plugin;
public final Main plugin;
public BlockStorage(Main m) {
this.plugin = m;
@ -59,8 +59,8 @@ public class BlockStorage implements Listener {
if (plugin.config.getString("Protected_Arena").equalsIgnoreCase("True")) {
event.setCancelled(true);
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()))))) {
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"))) {
} 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(b.getType().name())))) ^ (plugin.management.getBoolean("blocks.useWhitelistAsBlacklist"))) {
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "That is an illegal block!");
} else {
@ -139,7 +139,7 @@ public class BlockStorage implements Listener {
if (!event.isCancelled()) {
if (((plugin.Playing.get(a)).contains(p.getName())) || (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)) {
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) {
@ -174,7 +174,7 @@ public class BlockStorage implements Listener {
if (!event.isCancelled()) {
if (plugin.canjoin.get(a)) {
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());
String w = b.getWorld().getName();
addPlacedBlockToList(b, w, a);
@ -192,7 +192,7 @@ public class BlockStorage implements Listener {
if (!event.isCancelled()) {
if (plugin.canjoin.get(a)) {
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());
String w = b.getWorld().getName();
addDestroyedBlockToList(b, w, a);
@ -224,10 +224,7 @@ public class BlockStorage implements Listener {
//SubRoutines:
private boolean protall() {
if (plugin.config.getString("Protected_Arena_Always").equalsIgnoreCase("True")) {
return true;
}
return false;
return plugin.config.getString("Protected_Arena_Always").equalsIgnoreCase("True");
}

View File

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

View File

@ -11,7 +11,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
import java.util.List;
public class ChatListener implements Listener {
public Main plugin;
public final Main plugin;
public ChatListener(Main m) {
this.plugin = m;
@ -31,19 +31,12 @@ public class ChatListener implements Listener {
p.sendMessage(msg);
for (Entity e : near) {
if (e instanceof Player) {
((Player) e).sendMessage(msg);
e.sendMessage(msg);
}
}
} else if (near.size() == 0) {
} else {
p.sendMessage(msg);
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 {
event.setCancelled(true);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -22,7 +22,7 @@ import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.scoreboard.DisplaySlot;
public class SpectatorListener implements Listener {
public Main plugin;
public final Main plugin;
public SpectatorListener(Main m) {
this.plugin = m;
@ -59,8 +59,7 @@ public class SpectatorListener implements Listener {
@EventHandler
public void SpectatorItems(EntityPickupItemEvent event) {
if (event.getEntity() instanceof Player) {
Player p = (Player) event.getEntity();
if (event.getEntity() instanceof Player p) {
if (denyInteraction(p)) {
event.setCancelled(true);
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) {
Projectile arrow = (Projectile) offense;
ProjectileSource shooter = arrow.getShooter();
if (shooter instanceof Player) {
Player BowMan = (Player) shooter;
if (shooter instanceof Player BowMan) {
String bowManName = BowMan.getName();
for (int i : plugin.Watching.keySet()) {
if (plugin.Watching.get(i) != null) {
@ -151,12 +149,8 @@ public class SpectatorListener implements Listener {
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
p.teleport(Spawn);
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
if (plugin.scoreboards.containsKey(p.getName())) {
plugin.scoreboards.remove(p.getName());
}
if (plugin.Kills.containsKey(p.getName())) {
plugin.Kills.remove(p.getName());
}
plugin.scoreboards.remove(p.getName());
plugin.Kills.remove(p.getName());
}
}
}
@ -170,7 +164,7 @@ public class SpectatorListener implements Listener {
return;
}
if (target instanceof Player) {
String targetName = ((Player) target).getName();
String targetName = target.getName();
for (int i : plugin.Watching.keySet()) {
if (plugin.Watching.get(i) != null) {
if (plugin.Watching.get(i).contains(targetName)) {

View File

@ -1,7 +1,6 @@
package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
@ -14,12 +13,16 @@ import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
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.scoreboard.DisplaySlot;
public class SpectatorListenerOld implements Listener {
public Main plugin;
public final Main plugin;
public SpectatorListenerOld(Main m) {
this.plugin = m;
@ -103,8 +106,7 @@ public class SpectatorListenerOld implements Listener {
} else if (event.getDamager() instanceof Projectile) {
Projectile arrow = (Projectile) offense;
ProjectileSource shooter = arrow.getShooter();
if (shooter instanceof Player) {
Player BowMan = (Player) shooter;
if (shooter instanceof Player BowMan) {
String bowManName = BowMan.getName();
for (int i : plugin.Watching.keySet()) {
if (plugin.Watching.get(i) != null) {
@ -161,12 +163,8 @@ public class SpectatorListenerOld implements Listener {
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
p.teleport(Spawn);
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
if (plugin.scoreboards.containsKey(p.getName())) {
plugin.scoreboards.remove(p.getName());
}
if (plugin.Kills.containsKey(p.getName())) {
plugin.Kills.remove(p.getName());
}
plugin.scoreboards.remove(p.getName());
plugin.Kills.remove(p.getName());
}
}
}
@ -180,7 +178,7 @@ public class SpectatorListenerOld implements Listener {
return;
}
if (target instanceof Player) {
String targetName = ((Player) target).getName();
String targetName = target.getName();
for (int i : plugin.Watching.keySet()) {
if (plugin.Watching.get(i) != null) {
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 Main plugin;
public final Main plugin;
public TeleportListener(Main m) {
this.plugin = m;
@ -19,7 +19,7 @@ public class TeleportListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void onTP(PlayerTeleportEvent event) {
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);
p.sendMessage(ChatColor.RED + "You are a dead tribute... How are you supposed to get back into the arena....");
plugin.Tele.remove(p);

View File

@ -9,7 +9,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChangedWorldEvent;
public class WorldChange implements Listener {
public Main plugin;
public final Main plugin;
public WorldChange(Main m) {
plugin = m;
@ -21,7 +21,7 @@ public class WorldChange implements Listener {
String pname = p.getName();
String ThisWorld = p.getWorld().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);
}
}

View File

@ -12,7 +12,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
import java.util.Collection;
public class spawnsListener implements Listener {
public Main plugin;
public final Main plugin;
public spawnsListener(Main m) {
this.plugin = m;
@ -30,10 +30,10 @@ public class spawnsListener implements Listener {
} catch (Exception e) {
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("-");
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]);
if (plugin.spawns.get("Spawns." + arena) != null) {

View File

@ -1,24 +1,7 @@
package me.Travja.HungerArena;
import java.io.File;
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 com.sk89q.worldedit.bukkit.WorldEditPlugin;
import me.Travja.HungerArena.Listeners.BlockStorage;
import me.Travja.HungerArena.Listeners.WorldChange;
import me.Travja.HungerArena.Listeners.Boundaries;
import me.Travja.HungerArena.Listeners.ChatListener;
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.SpectatorListenerOld;
import me.Travja.HungerArena.Listeners.TeleportListener;
import me.Travja.HungerArena.Listeners.WorldChange;
import me.Travja.HungerArena.Listeners.spawnsListener;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
@ -42,9 +25,6 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
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.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
@ -55,7 +35,6 @@ import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.material.MaterialData;
import org.bukkit.material.Torch;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
@ -67,55 +46,70 @@ import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Score;
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 {
static Logger log;
public HashMap<Integer, List<String>> Playing = new HashMap<Integer, List<String>>();
public HashMap<Integer, List<String>> Ready = new HashMap<Integer, List<String>>();
public HashMap<Integer, List<String>> Dead = new HashMap<Integer, List<String>>();
public HashMap<Integer, String> MatchRunning = new HashMap<Integer, String>();
public HashMap<Integer, Boolean> canjoin = new HashMap<Integer, Boolean>();
public HashMap<Integer, Boolean> open = new HashMap<Integer, Boolean>();
private HashMap<Integer, Integer> CountT = new HashMap<Integer, Integer>();
public HashMap<Integer, List<String>> Quit = new HashMap<Integer, List<String>>();
public HashMap<Integer, List<String>> Out = new HashMap<Integer, List<String>>();
public HashMap<Integer, List<String>> Watching = new HashMap<Integer, List<String>>();
public HashMap<String, Integer> Kills = new HashMap<String, Integer>();
public HashMap<Integer, List<String>> NeedConfirm = new HashMap<Integer, List<String>>();
public HashMap<Integer, HashMap<Integer, Location>> location = new HashMap<Integer, HashMap<Integer, Location>>();
public HashMap<Integer, List<String>> inArena = new HashMap<Integer, List<String>>();
public HashMap<Integer, List<String>> Frozen = new HashMap<Integer, List<String>>();
public HashMap<Integer, List<String>> arena = new HashMap<Integer, List<String>>();
public HashMap<Integer, Integer> maxPlayers = new HashMap<Integer, Integer>();
public HashMap<String, String> setting = new HashMap<String, String>();
public HashMap<Integer, Integer> gp = new HashMap<Integer, Integer>();
public ArrayList<Player> Tele = new ArrayList<Player>();
public ArrayList<String> needInv = new ArrayList<String>();
public HashMap<Integer, String> worldsNames = new HashMap<Integer, String>();
public final HashMap<Integer, List<String>> Playing = new HashMap<>();
public final HashMap<Integer, List<String>> Ready = new HashMap<>();
public final HashMap<Integer, List<String>> Dead = new HashMap<>();
public final HashMap<Integer, String> MatchRunning = new HashMap<>();
public final HashMap<Integer, Boolean> canjoin = new HashMap<>();
public final HashMap<Integer, Boolean> open = new HashMap<>();
private final HashMap<Integer, Integer> CountT = new HashMap<>();
public final HashMap<Integer, List<String>> Quit = new HashMap<>();
public final HashMap<Integer, List<String>> Out = new HashMap<>();
public final HashMap<Integer, List<String>> Watching = new HashMap<>();
public final HashMap<String, Integer> Kills = new HashMap<>();
public final HashMap<Integer, List<String>> NeedConfirm = new HashMap<>();
public final HashMap<Integer, HashMap<Integer, Location>> location = new HashMap<>();
public final HashMap<Integer, List<String>> inArena = new HashMap<>();
public final HashMap<Integer, List<String>> Frozen = new HashMap<>();
public final HashMap<Integer, List<String>> arena = new HashMap<>();
public final HashMap<Integer, Integer> maxPlayers = new HashMap<>();
public final HashMap<String, String> setting = new HashMap<>();
public final HashMap<Integer, Integer> gp = new HashMap<>();
public final ArrayList<Player> Tele = new ArrayList<>();
public final ArrayList<String> needInv = new ArrayList<>();
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 SpectatorListenerOld = null;
Listener FreezeListener = new FreezeListener(this);
Listener JoinAndQuitListener = new JoinAndQuitListener(this);
Listener ChatListener = new ChatListener(this);
Listener Chests = new Chests(this);
Listener PvP = new PvP(this);
Listener CommandBlock = new CommandBlock(this);
final Listener FreezeListener = new FreezeListener(this);
final Listener JoinAndQuitListener = new JoinAndQuitListener(this);
final Listener ChatListener = new ChatListener(this);
final Listener Chests = new Chests(this);
final Listener PvP = new PvP(this);
final Listener CommandBlock = new CommandBlock(this);
Listener Teleport = new TeleportListener(this);
SignsAndBeds SignsAndBeds = null;
SignsAndBedsOld SignsAndBedsOld = null;
Listener BlockStorage = new BlockStorage(this);
final Listener BlockStorage = new BlockStorage(this);
//Listener WinGames = new WinGamesListener(this);
Listener WorldChange = new WorldChange(this);
Listener Boundaries = new Boundaries(this);
Listener spawnsListener = new spawnsListener(this);
CommandExecutor HaCommands = new HaCommands(this);
CommandExecutor SponsorCommands = new SponsorCommands(this);
CommandExecutor SpawnsCommand = new SpawnsCommand(this);
final Listener WorldChange = new WorldChange(this);
final Listener Boundaries = new Boundaries(this);
final Listener spawnsListener = new spawnsListener(this);
final CommandExecutor HaCommands = new HaCommands(this);
final CommandExecutor SponsorCommands = new SponsorCommands(this);
final CommandExecutor SpawnsCommand = new SpawnsCommand(this);
public boolean exists;
public boolean restricted;
@ -131,10 +125,10 @@ public class Main extends JavaPlugin {
public FileConfiguration MyChests = null;
public File ChestsFile = null;
public ArrayList<ItemStack> Reward = new ArrayList<ItemStack>();
public ArrayList<ItemStack> Cost = new ArrayList<ItemStack>();
public ArrayList<ItemStack> Fee = new ArrayList<ItemStack>();
public ArrayList<ItemStack> ChestPay = new ArrayList<ItemStack>();
public final ArrayList<ItemStack> Reward = new ArrayList<>();
public final ArrayList<ItemStack> Cost = new ArrayList<>();
public final ArrayList<ItemStack> Fee = new ArrayList<>();
public final ArrayList<ItemStack> ChestPay = new ArrayList<>();
public boolean vault = false;
public boolean eco = false;
@ -144,7 +138,7 @@ public class Main extends JavaPlugin {
int v = 0;
int a = 0;
File PFilePath = new File(getDataFolder(), "/inventories");
final File PFilePath = new File(getDataFolder(), "/inventories");
public void onEnable() {
log = this.getLogger();
@ -208,7 +202,7 @@ public class Main extends JavaPlugin {
for (File file : PFilePath.listFiles()) {
String filename = file.getName();
int lastIndex = filename.lastIndexOf('.');
filename = filename.substring(0, lastIndex >= 0 ? lastIndex : 0);
filename = filename.substring(0, Math.max(lastIndex, 0));
needInv.add(filename);
}
@ -225,7 +219,7 @@ public class Main extends JavaPlugin {
config.set("rewardEco.reward", 100);
}
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.");
eco = true;
} else {
@ -233,15 +227,15 @@ public class Main extends JavaPlugin {
}
}
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.");
}
}
try {
List<String> RewardItemList = new ArrayList<String>();
List<String> SponsorItemList = new ArrayList<String>();
List<String> EntryfeeItemList = new ArrayList<String>();
List<String> PayForChests = new ArrayList<String>();
List<String> RewardItemList = new ArrayList<>();
List<String> SponsorItemList = new ArrayList<>();
List<String> EntryfeeItemList = new ArrayList<>();
List<String> PayForChests = new ArrayList<>();
for (String rewards : config.getStringList("Reward")) {
String[] rinfo = rewards.split(",");
@ -287,7 +281,7 @@ public class Main extends JavaPlugin {
config.set("ChestPay.items", PayForChests);
}
ArrayList<String> newList = new ArrayList<String>();
ArrayList<String> newList = new ArrayList<>();
for (String block : management.getStringList("blocks.whitelist")) {
Material NewMat = getNewMaterial(block, 0);
if (NewMat != null) {
@ -358,9 +352,7 @@ public class Main extends JavaPlugin {
if (spawns.getConfigurationSection("Spawns." + entry.getKey()) != null) {
Integer a = Integer.parseInt(entry.getKey());
worldsNames.put(a, "none_meening_this_is_not_a_map");
if (location.get(a) == null) {
location.put(a, new HashMap<Integer, Location>());
}
location.computeIfAbsent(a, k -> new HashMap<>());
Map<String, Object> temp2 = spawns.getConfigurationSection("Spawns." + entry.getKey()).getValues(false);
for (Map.Entry<String, Object> e : temp2.entrySet()) {
if (spawns.get("Spawns." + entry.getKey() + "" + e.getKey()) != null) {
@ -381,17 +373,17 @@ public class Main extends JavaPlugin {
if (verbose) {
log.info("Loaded " + location.get(i).size() + " tribute spawns for arena " + i + "!");
}
Playing.put(i, new ArrayList<String>());
Ready.put(i, new ArrayList<String>());
Dead.put(i, new ArrayList<String>());
Playing.put(i, new ArrayList<>());
Ready.put(i, new ArrayList<>());
Dead.put(i, new ArrayList<>());
MatchRunning.put(i, null);
Quit.put(i, new ArrayList<String>());
Out.put(i, new ArrayList<String>());
Watching.put(i, new ArrayList<String>());
NeedConfirm.put(i, new ArrayList<String>());
inArena.put(i, new ArrayList<String>());
Frozen.put(i, new ArrayList<String>());
arena.put(i, new ArrayList<String>());
Quit.put(i, new ArrayList<>());
Out.put(i, new ArrayList<>());
Watching.put(i, new ArrayList<>());
NeedConfirm.put(i, new ArrayList<>());
inArena.put(i, new ArrayList<>());
Frozen.put(i, new ArrayList<>());
arena.put(i, new ArrayList<>());
canjoin.put(i, false);
maxPlayers.put(i, location.get(i).size());
open.put(i, true);
@ -402,7 +394,7 @@ public class Main extends JavaPlugin {
public WorldEditPlugin hookWE() {
Plugin wPlugin = getServer().getPluginManager().getPlugin("WorldEdit");
if ((wPlugin == null) || (!(wPlugin instanceof WorldEditPlugin))) {
if ((!(wPlugin instanceof WorldEditPlugin))) {
return null;
}
@ -610,11 +602,7 @@ public class Main extends JavaPlugin {
Reader defaultConfigReader = null;
YamlConfiguration defConfig = null;
if (defConfigStream != null) {
try {
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.");
}
defaultConfigReader = new java.io.InputStreamReader(defConfigStream, StandardCharsets.UTF_8);
}
if (defaultConfigReader != null) {
@ -665,7 +653,7 @@ public class Main extends JavaPlugin {
g.sendMessage(ChatColor.RED + pname + " Quit!");
}
}
if (canjoin.get(u) == true) {
if (canjoin.get(u)) {
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
scoreboards.remove(p.getName());
Kills.remove(p.getName());
@ -674,9 +662,7 @@ public class Main extends JavaPlugin {
}
}
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()) {
@ -688,7 +674,7 @@ public class Main extends JavaPlugin {
if (o instanceof ItemStack[]) {
pinv = (ItemStack[]) o;
} 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.updateInventory();
@ -698,7 +684,7 @@ public class Main extends JavaPlugin {
if (o instanceof ItemStack[]) {
parmor = (ItemStack[]) o;
} 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.updateInventory();
@ -740,7 +726,7 @@ public class Main extends JavaPlugin {
String winnername = Playing.get(a).get(i);
final Player winner = getServer().getPlayerExact(winnername);
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!");
}
winner.getInventory().clear();
@ -760,14 +746,10 @@ public class Main extends JavaPlugin {
this.RestoreInv(winner, winnername2);
if (canjoin.get(a) == true) {
if (canjoin.get(a)) {
winner.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
if (scoreboards.containsKey(winner.getName())) {
scoreboards.remove(winner.getName());
}
if (Kills.containsKey(winner.getName())) {
Kills.remove(winner.getName());
}
scoreboards.remove(winner.getName());
Kills.remove(winner.getName());
////////////////////////////////////////////////////////
//////////////////// FIREWORKS ///////////////////////
@ -775,53 +757,51 @@ public class Main extends JavaPlugin {
for (i = 0; i < 10; i++) {
Bukkit.getScheduler().runTaskLater(this, new Runnable() {
public void run() {
//Spawn the Fireworks, get the FireworkMeta.
Firework fw = (Firework) winner.getWorld().spawnEntity(winner.getLocation(), EntityType.FIREWORK);
FireworkMeta fwm = fw.getFireworkMeta();
Bukkit.getScheduler().runTaskLater(this, () -> {
//Spawn the Fireworks, get the FireworkMeta.
Firework fw = (Firework) winner.getWorld().spawnEntity(winner.getLocation(), EntityType.FIREWORK);
FireworkMeta fwm = fw.getFireworkMeta();
//Our random generator
Random r = new Random();
//Our random generator
Random r = new Random();
//Get the type
int rt = r.nextInt(4) + 1;
Type type = Type.BALL;
if (rt == 1) {
type = Type.BALL;
}
if (rt == 2) {
type = Type.BALL_LARGE;
}
if (rt == 3) {
type = Type.BURST;
}
if (rt == 4) {
type = Type.CREEPER;
}
if (rt == 5) {
type = Type.STAR;
}
//Get our random colours
int r1i = r.nextInt(17) + 1;
int r2i = r.nextInt(17) + 1;
Color c1 = getColor(r1i);
Color c2 = getColor(r2i);
//Create our effect with this
FireworkEffect effect = FireworkEffect.builder().flicker(r.nextBoolean()).withColor(c1).withFade(c2).with(type).trail(r.nextBoolean()).build();
//Then apply the effect to the meta
fwm.addEffect(effect);
//Generate some random power and set it
int rp = r.nextInt(2) + 1;
fwm.setPower(rp);
//Then apply this to our rocket
fw.setFireworkMeta(fwm);
//Get the type
int rt = r.nextInt(4) + 1;
Type type = Type.BALL;
if (rt == 1) {
type = Type.BALL;
}
if (rt == 2) {
type = Type.BALL_LARGE;
}
if (rt == 3) {
type = Type.BURST;
}
if (rt == 4) {
type = Type.CREEPER;
}
if (rt == 5) {
type = Type.STAR;
}
//Get our random colours
int r1i = r.nextInt(17) + 1;
int r2i = r.nextInt(17) + 1;
Color c1 = getColor(r1i);
Color c2 = getColor(r2i);
//Create our effect with this
FireworkEffect effect = FireworkEffect.builder().flicker(r.nextBoolean()).withColor(c1).withFade(c2).with(type).trail(r.nextBoolean()).build();
//Then apply the effect to the meta
fwm.addEffect(effect);
//Generate some random power and set it
int rp = r.nextInt(2) + 1;
fwm.setPower(rp);
//Then apply this to our rocket
fw.setFireworkMeta(fwm);
}, 20 + i * 20L);
}
@ -869,11 +849,7 @@ public class Main extends JavaPlugin {
}
}
if (config.getString("Auto_Restart").equalsIgnoreCase("True")) {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
public void run() {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart " + a);
}
}, 220L);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, () -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart " + a), 220L);
}
MatchRunning.put(a, null);
}
@ -918,12 +894,10 @@ public class Main extends JavaPlugin {
}
private void scoreboardInit() {
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
public void run() {
Collection<? extends Player> online = getServer().getOnlinePlayers();
for (Player pl : online) {
updateScoreboard(pl);
}
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> {
Collection<? extends Player> online = getServer().getOnlinePlayers();
for (Player pl : online) {
updateScoreboard(pl);
}
}, 20L, 10L);
}
@ -957,9 +931,9 @@ public class Main extends JavaPlugin {
if (config.getInt("DeathMatch") != 0) {
if (timetodeath.get(a) != null) {
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);
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 {
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 HashMap<Integer, Integer> start = new HashMap<Integer, Integer>();
public HashMap<Integer, Integer> deathtime = new HashMap<Integer, Integer>();
public HashMap<Integer, Integer> timetodeath = new HashMap<Integer, Integer>();
public final HashMap<Integer, Integer> grace = new HashMap<>();
public final HashMap<Integer, Integer> start = new HashMap<>();
public final HashMap<Integer, Integer> deathtime = new HashMap<>();
public final HashMap<Integer, Integer> timetodeath = new HashMap<>();
public void startGames(final int a) {
if ((MatchRunning.get(a) != null) && (MatchRunning.get(a).equals("true"))) {
@ -1012,169 +986,163 @@ public class Main extends JavaPlugin {
}
if (config.getString("Countdown").equalsIgnoreCase("true")) {
CountT.put(a, (config.getInt("Countdown_Timer") != 0 ? config.getInt("Countdown_Timer") : 10));
start.put(a, getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
public void run() {
if (CountT.get(a) > 0) {
if (!restricted) {
if (config.getBoolean("broadcastAll")) {
getServer().broadcastMessage(ChatColor.AQUA + "Game " + a + " starting in: " + String.valueOf(CountT.get(a)));
} else {
for (String gn : Playing.get(a)) {
Player g = getServer().getPlayer(gn);
g.sendMessage(ChatColor.AQUA + "Game starting in: " + String.valueOf(CountT.get(a)));
}
}
} else {
if (config.getBoolean("broadcastAll")) {
for (String world : worldsNames.values()) {
World w = getServer().getWorld(world);
for (Player wp : w.getPlayers()) {
wp.sendMessage(String.valueOf(CountT.get(a)));
}
}
} else {
for (String gn : Playing.get(a)) {
Player g = getServer().getPlayer(gn);
g.sendMessage(String.valueOf(CountT.get(a)));
}
}
}
}
CountT.put(a, CountT.get(a) - 1);
if (CountT.get(a) == -1) {
for (String gn : Playing.get(a)) {
Scoreboard scoreboard = getServer().getScoreboardManager().getNewScoreboard();
Objective sobj;
try {
sobj = scoreboard.registerNewObjective("HA", "HAData", ChatColor.GREEN + "HA - Starting");
} catch (NoSuchMethodError e) {
sobj = scoreboard.registerNewObjective("HA", "HAData");
sobj.setDisplayName(ChatColor.GREEN + "HA - Starting");
}
Score skills = sobj.getScore(ChatColor.RED + "Kills");
skills.setScore(0);
Score sdeaths = sobj.getScore(ChatColor.RED + "Spectators");
sdeaths.setScore(0);
Score splayers = sobj.getScore(ChatColor.RED + "Players");
splayers.setScore(0);
Score allkills = sobj.getScore(ChatColor.RED + "Deaths");
allkills.setScore(0);
sobj.setDisplaySlot(DisplaySlot.SIDEBAR);
Bukkit.getPlayer(gn).setScoreboard(scoreboard);
scoreboards.put(Bukkit.getPlayer(gn).getName(), Bukkit.getPlayer(gn).getScoreboard());
}
if (Frozen.get(a) != null) {
Frozen.get(a).clear();
}
start.put(a, getServer().getScheduler().scheduleSyncRepeatingTask(this, () -> {
if (CountT.get(a) > 0) {
if (!restricted) {
if (config.getBoolean("broadcastAll")) {
getServer().broadcastMessage(msg);
getServer().broadcastMessage(ChatColor.AQUA + "Game " + a + " starting in: " + CountT.get(a));
} else {
for (String gn : Playing.get(a)) {
Player g = getServer().getPlayer(gn);
g.sendMessage(msg);
g.sendMessage(ChatColor.AQUA + "Game starting in: " + CountT.get(a));
}
}
if (config.getInt("Grace_Period") != 0) {
gp.put(a, config.getInt("Grace_Period"));
if (grace.get(a) == null) {
grace.put(a, getServer().getScheduler().scheduleSyncRepeatingTask(Bukkit.getPluginManager().getPlugin("HungerArena"), new Runnable() {
public void run() {
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 (config.getBoolean("broadcastAll")) {
for (Player wp : location.get(a).get(1).getWorld().getPlayers()) {
wp.sendMessage(ChatColor.GREEN + "Grace period ends in " + gp.get(a) + " seconds!");
}
} else {
getServer().broadcastMessage(ChatColor.GREEN + "Grace period ends in " + gp.get(a) + " seconds!");
}
}
if (gp.get(a) <= 0) {
if (config.getBoolean("broadcastAll")) {
for (Player wp : location.get(a).get(1).getWorld().getPlayers()) {
wp.sendMessage(ChatColor.GREEN + "Grace period is over, FIGHT!");
}
} else {
getServer().broadcastMessage(ChatColor.GREEN + "Grace period is over, FIGHT!");
}
getServer().getScheduler().cancelTask(grace.get(a));
grace.put(a, null);
}
}
}, 20L, 20L));
} else {
if (config.getBoolean("broadcastAll")) {
for (String world : worldsNames.values()) {
World w = getServer().getWorld(world);
for (Player wp : w.getPlayers()) {
wp.sendMessage(String.valueOf(CountT.get(a)));
}
}
} else {
for (String gn : Playing.get(a)) {
Player g = getServer().getPlayer(gn);
g.sendMessage(String.valueOf(CountT.get(a)));
}
}
if (config.getInt("DeathMatch") != 0) {
int death = config.getInt("DeathMatch");
timetodeath.put(a, death * 60);
if (deathtime.get(a) == null) {
deathtime.put(a, getServer().getScheduler().scheduleSyncRepeatingTask(Bukkit.getPluginManager().getPlugin("HungerArena"), new Runnable() {
public void run() {
timetodeath.put(a, timetodeath.get(a) - 1);
if (Integer.valueOf(timetodeath.get(a)) % 300 == 0) {
if (config.getBoolean("broadcastAll")) {
for (Player wp : location.get(a).get(1).getWorld().getPlayers()) {
if (timetodeath.get(a) != 0) {
wp.sendMessage(ChatColor.YELLOW + String.valueOf(timetodeath.get(a) / 60) + ChatColor.RED + " mins till the death match!");
}
}
} else {
for (String gn : Playing.get(a)) {
Player g = getServer().getPlayer(gn);
g.sendMessage(ChatColor.YELLOW + String.valueOf(timetodeath.get(a)) + ChatColor.RED + " mins till the death match!");
}
}
}
if (timetodeath.get(a) <= 0) {
int i = 1;
for (String playing : Playing.get(a)) {
Player tribute = getServer().getPlayerExact(playing);
Location pLoc = null;
if (tribute.hasMetadata("HA-Location")) {
List<MetadataValue> l = tribute.getMetadata("HA-Location");
if (l != null && l.size() != 0) {
try {
pLoc = (Location) l.get(0).value();
} catch (Exception e) {
}
}
if (pLoc != null) {
tribute.teleport(pLoc); //random
} else {
tribute.teleport(location.get(a).get(i)); //row
}
}
i += 1;
for (PotionEffect pe : tribute.getActivePotionEffects()) {
PotionEffectType potion = pe.getType();
tribute.removePotionEffect(potion);
}
if (tribute.getAllowFlight()) {
tribute.setAllowFlight(false);
}
}
if (config.getBoolean("broadcastAll")) {
for (Player wp : location.get(a).get(1).getWorld().getPlayers()) {
wp.sendMessage(ChatColor.RED + "The final battle has begun! " + Playing.get(a).size() + " tributes will be facing off!");
}
} else {
for (String gn : Playing.get(a)) {
Player g = getServer().getPlayer(gn);
g.sendMessage(ChatColor.RED + "The final battle has begun! " + Playing.get(a).size() + " tributes will be facing off!");
}
}
StopTasksDelayed(deathtime.get(a));
deathtime.put(a, null);
}
}
}, 20L, 20L));
}
}
setTorch(a, true);
StopTasksDelayed(start.get(a));
}
}
CountT.put(a, CountT.get(a) - 1);
if (CountT.get(a) == -1) {
for (String gn : Playing.get(a)) {
Scoreboard scoreboard = getServer().getScoreboardManager().getNewScoreboard();
Objective sobj;
try {
sobj = scoreboard.registerNewObjective("HA", "HAData", ChatColor.GREEN + "HA - Starting");
} catch (NoSuchMethodError e) {
sobj = scoreboard.registerNewObjective("HA", "HAData");
sobj.setDisplayName(ChatColor.GREEN + "HA - Starting");
}
Score skills = sobj.getScore(ChatColor.RED + "Kills");
skills.setScore(0);
Score sdeaths = sobj.getScore(ChatColor.RED + "Spectators");
sdeaths.setScore(0);
Score splayers = sobj.getScore(ChatColor.RED + "Players");
splayers.setScore(0);
Score allkills = sobj.getScore(ChatColor.RED + "Deaths");
allkills.setScore(0);
sobj.setDisplaySlot(DisplaySlot.SIDEBAR);
Bukkit.getPlayer(gn).setScoreboard(scoreboard);
scoreboards.put(Bukkit.getPlayer(gn).getName(), Bukkit.getPlayer(gn).getScoreboard());
}
if (Frozen.get(a) != null) {
Frozen.get(a).clear();
}
if (config.getBoolean("broadcastAll")) {
getServer().broadcastMessage(msg);
} else {
for (String gn : Playing.get(a)) {
Player g = getServer().getPlayer(gn);
g.sendMessage(msg);
}
}
if (config.getInt("Grace_Period") != 0) {
gp.put(a, config.getInt("Grace_Period"));
if (grace.get(a) == null) {
grace.put(a, getServer().getScheduler().scheduleSyncRepeatingTask(Bukkit.getPluginManager().getPlugin("HungerArena"), () -> {
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 (config.getBoolean("broadcastAll")) {
for (Player wp : location.get(a).get(1).getWorld().getPlayers()) {
wp.sendMessage(ChatColor.GREEN + "Grace period ends in " + gp.get(a) + " seconds!");
}
} else {
getServer().broadcastMessage(ChatColor.GREEN + "Grace period ends in " + gp.get(a) + " seconds!");
}
}
if (gp.get(a) <= 0) {
if (config.getBoolean("broadcastAll")) {
for (Player wp : location.get(a).get(1).getWorld().getPlayers()) {
wp.sendMessage(ChatColor.GREEN + "Grace period is over, FIGHT!");
}
} else {
getServer().broadcastMessage(ChatColor.GREEN + "Grace period is over, FIGHT!");
}
getServer().getScheduler().cancelTask(grace.get(a));
grace.put(a, null);
}
}, 20L, 20L));
}
}
if (config.getInt("DeathMatch") != 0) {
int death = config.getInt("DeathMatch");
timetodeath.put(a, death * 60);
if (deathtime.get(a) == null) {
deathtime.put(a, getServer().getScheduler().scheduleSyncRepeatingTask(Bukkit.getPluginManager().getPlugin("HungerArena"), () -> {
timetodeath.put(a, timetodeath.get(a) - 1);
if (timetodeath.get(a) % 300 == 0) {
if (config.getBoolean("broadcastAll")) {
for (Player wp : location.get(a).get(1).getWorld().getPlayers()) {
if (timetodeath.get(a) != 0) {
wp.sendMessage(ChatColor.YELLOW + String.valueOf(timetodeath.get(a) / 60) + ChatColor.RED + " mins till the death match!");
}
}
} else {
for (String gn : Playing.get(a)) {
Player g = getServer().getPlayer(gn);
g.sendMessage(ChatColor.YELLOW + String.valueOf(timetodeath.get(a)) + ChatColor.RED + " mins till the death match!");
}
}
}
if (timetodeath.get(a) <= 0) {
int i = 1;
for (String playing : Playing.get(a)) {
Player tribute = getServer().getPlayerExact(playing);
Location pLoc = null;
if (tribute.hasMetadata("HA-Location")) {
List<MetadataValue> l = tribute.getMetadata("HA-Location");
if (l != null && l.size() != 0) {
try {
pLoc = (Location) l.get(0).value();
} catch (Exception e) {
}
}
if (pLoc != null) {
tribute.teleport(pLoc); //random
} else {
tribute.teleport(location.get(a).get(i)); //row
}
}
i += 1;
for (PotionEffect pe : tribute.getActivePotionEffects()) {
PotionEffectType potion = pe.getType();
tribute.removePotionEffect(potion);
}
if (tribute.getAllowFlight()) {
tribute.setAllowFlight(false);
}
}
if (config.getBoolean("broadcastAll")) {
for (Player wp : location.get(a).get(1).getWorld().getPlayers()) {
wp.sendMessage(ChatColor.RED + "The final battle has begun! " + Playing.get(a).size() + " tributes will be facing off!");
}
} else {
for (String gn : Playing.get(a)) {
Player g = getServer().getPlayer(gn);
g.sendMessage(ChatColor.RED + "The final battle has begun! " + Playing.get(a).size() + " tributes will be facing off!");
}
}
StopTasksDelayed(deathtime.get(a));
deathtime.put(a, null);
}
}, 20L, 20L));
}
}
setTorch(a, true);
StopTasksDelayed(start.get(a));
}
}, 20L, 20L));
} else {
setTorch(a, true);
@ -1192,11 +1160,7 @@ public class Main extends JavaPlugin {
}
private void StopTasksDelayed(final int task) {
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
public void run() {
Bukkit.getScheduler().cancelTask(task);
}
}, 10L);
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> Bukkit.getScheduler().cancelTask(task), 10L);
}
public Integer getArena(Player p) {

View File

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

View File

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