Fixes structure and fixes compilation for 1.19

This commit is contained in:
Kristian Knarvik 2022-07-21 18:15:13 +02:00
parent 7275959de4
commit 38d2efa46f
50 changed files with 4849 additions and 4562 deletions

1
.gitignore vendored
View File

@ -14,3 +14,4 @@ hs_err_pid*
*.classpath
bin
/.classpath
.idea

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>HungerArena_Jeppa</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

53
pom.xml Normal file
View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>HungerArena_Jeppa</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
</repository>
<repository>
<id>engine-hub-repo</id>
<url>https://maven.enginehub.org/repo/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>7.2.7</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,3 +0,0 @@
# Stores all blocks to reset!
Blocks_Destroyed: []
Blocks_Placed: []

View File

@ -0,0 +1,81 @@
package me.Travja.HungerArena;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
public class Chests implements Listener {
public Main plugin;
public Chests(Main m) {
this.plugin = m;
}
@EventHandler(priority = EventPriority.HIGHEST)
public void ChestBreak(BlockBreakEvent event) {
Player p = event.getPlayer();
Block block = event.getBlock();
if (p.hasPermission("HungerArena.Chest.Break")) {
Location blocklocation = block.getLocation();
int blockx = blocklocation.getBlockX();
int blocky = blocklocation.getBlockY();
int blockz = blocklocation.getBlockZ();
if (plugin.getChests().getConfigurationSection("Storage").getKeys(false).contains(blockx + "," + blocky + "," + blockz)) {
if (p.hasPermission("HungerArena.Chest.Break") && plugin.getArena(p) == null) {
plugin.getChests().set("Storage." + blockx + "," + blocky + "," + blockz, null);
plugin.saveChests();
p.sendMessage("[HungerArena] Chest Removed!");
} else {
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "[HungerArena] That's a storage! You don't have permission to break it!");
}
}
}
}
@EventHandler
public void ChestSaves(PlayerInteractEvent event) {
Block block = event.getClickedBlock();
Player p = event.getPlayer();
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 (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();
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);
plugin.getChests().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Z", blockz);
plugin.getChests().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.W", blockw);
plugin.getChests().set("Storage." + blockx + "," + blocky + "," + blockz + ".ItemsInStorage", itemsinchest);
plugin.getChests().set("Storage." + blockx + "," + blocky + "," + blockz + ".Arena", a);
plugin.saveChests();
p.sendMessage(ChatColor.GREEN + "Thank you for finding this undiscovered item Storage, it has been stored!!");
if (plugin.config.getBoolean("ChestPay.enabled")) {
for (ItemStack Rewards : plugin.ChestPay) {
p.getInventory().addItem(Rewards);
}
}
}
plugin.reloadChests();
}
}
}
}
}
}
}

View File

@ -0,0 +1,107 @@
package me.Travja.HungerArena;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
public class CommandBlock implements Listener {
public Main plugin;
public CommandBlock(Main m) {
this.plugin = m;
}
@EventHandler(priority = EventPriority.MONITOR)
public void CatchCommand(PlayerCommandPreprocessEvent event) {
String cmd = event.getMessage();
Player p = event.getPlayer();
String pname = p.getName();
for (int x : plugin.Watching.keySet()) {
if (plugin.Watching.get(x).contains(p.getName())) {
if (handleIngameCommands(p, cmd) == true) {
event.setCancelled(true);
}
}
}
if (plugin.getArena(p) != null) {
if (handleIngameCommands(p, cmd) == true) {
event.setCancelled(true);
}
} else if (cmd.toLowerCase().trim().equals("/back")) {
for (int u : plugin.Dead.keySet()) {
if (plugin.Dead.get(u).contains(pname) && plugin.canjoin.get(u)) {
plugin.Tele.add(p);
}
}
}
if (cmd.startsWith("/tp") || cmd.startsWith("/telep") || cmd.contains(":tp") || cmd.contains(":telep")) {
String[] args = cmd.split(" ");
Player player1 = null;
Player player2 = null;
if (args.length >= 2) {
if (Bukkit.getPlayer(args[1]) != null) {
player1 = Bukkit.getPlayer(args[1]);
if (args.length >= 3 && Bukkit.getPlayer(args[2]) != null) {
player2 = Bukkit.getPlayer(args[2]);
}
if (plugin.isSpectating(p)) {
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "Invalid command for spectating, using /ha tp " + (player2 != null ? player2 : player1));
p.performCommand("/ha tp " + (player2 != null ? player2 : player1));
} else if (plugin.getArena(player1) != null || (args.length == 2 && plugin.getArena(p) != null) || (args.length >= 3 && plugin.getArena(player2) != null)) {
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You can't teleport to other tributes!");
}
}
}
}
}
private boolean handleIngameCommands(Player p, String cmd) {
if (!p.hasPermission("HungerArena.UseCommands")) {
if (!plugin.management.getStringList("commands.whitelist").isEmpty()) {
for (String whitelist : plugin.management.getStringList("commands.whitelist")) {
if (cmd.toLowerCase().startsWith(whitelist.toLowerCase())) {
return false;
}
}
}
if (!cmd.toLowerCase().startsWith("/ha")) {
p.sendMessage(ChatColor.RED + "You are only allowed to perform the following commands:");
for (String whitelistfull : plugin.management.getStringList("commands.whitelist")) {
p.sendMessage(ChatColor.AQUA + whitelistfull);
}
p.sendMessage(ChatColor.AQUA + "/ha");
p.sendMessage(ChatColor.AQUA + "/ha close");
p.sendMessage(ChatColor.AQUA + "/ha help");
p.sendMessage(ChatColor.AQUA + "/ha join");
p.sendMessage(ChatColor.AQUA + "/ha kick [Player]");
p.sendMessage(ChatColor.AQUA + "/ha leave");
p.sendMessage(ChatColor.AQUA + "/ha list");
p.sendMessage(ChatColor.AQUA + "/ha open");
p.sendMessage(ChatColor.AQUA + "/ha ready");
p.sendMessage(ChatColor.AQUA + "/ha refill");
p.sendMessage(ChatColor.AQUA + "/ha reload");
p.sendMessage(ChatColor.AQUA + "/ha restart");
p.sendMessage(ChatColor.AQUA + "/ha rlist");
//p.sendMessage(ChatColor.AQUA + "/ha newarena"); //not during game...
p.sendMessage(ChatColor.AQUA + "/ha setspawn");
p.sendMessage(ChatColor.AQUA + "/ha start");
p.sendMessage(ChatColor.AQUA + "/ha tp");
p.sendMessage(ChatColor.AQUA + "/ha watch");
p.sendMessage(ChatColor.AQUA + "/ha warpall");
return true;
}
} else if (!cmd.toLowerCase().startsWith("/ha")) {
if (cmd.toLowerCase().startsWith("/spawn") || cmd.toLowerCase().startsWith("/back")) {
p.sendMessage("You have perms for all commands except this one!");
return true;
}
}
return false;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,282 @@
package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerBucketFillEvent;
import org.bukkit.material.MaterialData;
import java.util.List;
public class BlockStorage implements Listener {
public Main plugin;
public BlockStorage(Main m) {
this.plugin = m;
}
@EventHandler(priority = EventPriority.MONITOR)
public void BlockBreak(BlockBreakEvent event) {
Block b = event.getBlock();
Player p = event.getPlayer();
String pname = p.getName();
boolean protall = false;
if (!p.hasPermission("HungerArena.arena")) {
protall = protall(); //true = protect allways!!
}
if ((plugin.getArena(p) != null) || (protall)) {
//Jeppa: get a default arena if protall is true... (but use getArena if set...)
int a = 1;
if (protall) {
String ThisWorld = p.getWorld().getName();
for (int z : plugin.worldsNames.keySet()) {
if (plugin.worldsNames.get(z) != null) {
if (plugin.worldsNames.get(z).equals(ThisWorld)) {
a = z;
}
}
}
}
if (plugin.getArena(p) != null) {
a = plugin.getArena(p);
}
if ((!event.isCancelled()) && (((plugin.Playing.get(a)).contains(pname)) || (protall))) {
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"))) {
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "That is an illegal block!");
} else {
String w = b.getWorld().getName();
addDestroyedBlockToList(b, w, a);
}
}
}
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void Explosion(EntityExplodeEvent event) {
List<Block> blocksd = event.blockList();
Entity e = event.getEntity();
if (!event.isCancelled()) {
for (int i : plugin.canjoin.keySet()) {
if (plugin.canjoin.get(i) || protall()) {
String ThisWorld = e.getWorld().getName();
if ((!plugin.restricted) || ((plugin.restricted) && plugin.worldsNames.get(i) != null && plugin.worldsNames.get(i).equalsIgnoreCase(ThisWorld))) {
if (e.getType() == EntityType.PRIMED_TNT) {
e.getLocation().getBlock().setType(Material.TNT);
Block TNT = e.getLocation().getBlock();
addDestroyedBlockToList(TNT, ThisWorld, i);
TNT.setType(Material.AIR);
}
for (Block b : blocksd) {
if (!b.getType().name().equalsIgnoreCase("AIR")) {
addDestroyedBlockToList(b, ThisWorld, i);
}
}
}
}
}
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void burningBlocks(BlockBurnEvent event) {
Block b = event.getBlock();
if (!event.isCancelled()) {
for (int i : plugin.canjoin.keySet()) {
if (plugin.canjoin.get(i) || protall()) {
if ((!plugin.restricted) || ((plugin.restricted) && (plugin.worldsNames.get(i) != null && plugin.worldsNames.get(i).equalsIgnoreCase(b.getWorld().getName())))) {
String w = b.getWorld().getName();
addDestroyedBlockToList(b, w, i);
}
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void blockPlace(BlockPlaceEvent event) {
Block b = event.getBlock();
Player p = event.getPlayer();
boolean protall = false;
if (!p.hasPermission("HungerArena.arena")) {
protall = protall();
}
if ((plugin.getArena(p) != null) || (protall)) {
int a = 1;
if (protall) {
String ThisWorld = p.getWorld().getName();
for (int z : plugin.worldsNames.keySet()) {
if (plugin.worldsNames.get(z) != null) {
if (plugin.worldsNames.get(z).equals(ThisWorld)) {
a = z;
}
}
}
}
if (plugin.getArena(p) != null) {
a = plugin.getArena(p);
}
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 ((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) {
n = n - 1;
event.getPlayer().sendMessage(b.getWorld().getBlockAt(b.getX(), n, b.getZ()).getType().toString().toLowerCase());
if (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) {
int l = n + 1;
Block br = b.getWorld().getBlockAt(b.getX(), l, b.getZ());
String w = br.getWorld().getName();
addPlacedBlockToList(br, w, a);
}
}
} else {
if (b.getType() != Material.SAND && b.getType() != Material.GRAVEL) {
String w = b.getWorld().getName();
addPlacedBlockToList(b, w, a);
}
}
}
}
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void bucketEmpty(PlayerBucketEmptyEvent event) {
if (plugin.getArena(event.getPlayer()) != null) {
int a = plugin.getArena(event.getPlayer());
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())))) {
Block b = event.getBlockClicked().getRelative(event.getBlockFace());
String w = b.getWorld().getName();
addPlacedBlockToList(b, w, a);
}
}
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void bucketFill(PlayerBucketFillEvent event) {
if (plugin.getArena(event.getPlayer()) != null) {
int a = plugin.getArena(event.getPlayer());
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())))) {
Block b = event.getBlockClicked().getRelative(event.getBlockFace());
String w = b.getWorld().getName();
addDestroyedBlockToList(b, w, a);
}
}
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void blockMelt(BlockFadeEvent event) {
if (!event.isCancelled()) {
for (int i : plugin.canjoin.keySet()) {
if (plugin.canjoin.get(i) || protall()) {
if ((!plugin.restricted) || ((plugin.restricted) && (plugin.worldsNames.get(i) != null && plugin.worldsNames.get(i).equalsIgnoreCase(event.getBlock().getWorld().getName())))) {
Block b = event.getBlock();
String w = b.getWorld().getName();
String d = b.getType().name();
if (d.equalsIgnoreCase("FIRE") || d.equalsIgnoreCase("AIR")) {
continue;
}
addDestroyedBlockToList(b, w, i);
}
}
}
}
}
//SubRoutines:
private boolean protall() {
if (plugin.config.getString("Protected_Arena_Always").equalsIgnoreCase("True")) {
return true;
}
return false;
}
private void addDestroyedBlockToList(Block b, String w, int a) {
int x = b.getX();
int y = b.getY();
int z = b.getZ();
String d = b.getType().name();
byte m = 0;
String BlDataString = null;
String sp = ";";
String dir = "";
try {
if (b.getState().getBlockData() instanceof BlockData) {
BlDataString = b.getBlockData().getAsString();
}
} catch (Exception | NoSuchMethodError ex) {
m = b.getData();
sp = ",";
MaterialData mData = b.getState().getData();
if (mData instanceof org.bukkit.material.Directional) {
BlockFace Dir = ((org.bukkit.material.Directional) mData).getFacing();
if (Dir != null) {
dir = sp + (Dir.name());
}
}
}
String data = BlDataString != null ? BlDataString : String.valueOf(m);
String coords = w + sp + x + sp + y + sp + z + sp + d + sp + data + sp + a + dir;
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
if (!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + a)) {
blocks.add(coords);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveData();
}
}
private void addPlacedBlockToList(Block br, String w, int a) {
int x = br.getX();
int y = br.getY();
int z = br.getZ();
String coords = w + "," + x + "," + y + "," + z + "," + a;
List<String> blocks = plugin.data.getStringList("Blocks_Placed");
if (!blocks.contains(coords)) {
blocks.add(coords);
plugin.data.set("Blocks_Placed", blocks);
plugin.saveData();
}
}
}

View File

@ -0,0 +1,84 @@
package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import java.util.Map;
import java.util.Map.Entry;
public class Boundaries implements Listener {
public Main plugin;
public Boundaries(Main m) {
this.plugin = m;
}
@EventHandler
public void boundsCheck(PlayerMoveEvent event) {
Player p = event.getPlayer();
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);
}
}
}
@EventHandler
public void blockBounds(BlockBreakEvent event) {
Player p = event.getPlayer();
if (plugin.getArena(p) == null) {
if (plugin.config.getBoolean("WorldEdit")) {
if (insideBounds(event.getBlock().getLocation())) {
p.sendMessage(ChatColor.RED + "That block is protected by HungerArena!");
event.setCancelled(true);
}
}
}
}
public boolean insideBounds(Location l) {
Location minl = null;
Location maxl = null;
if (plugin.spawns.get("Arena") != null) {
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(",");
try {
World world = Bukkit.getWorld(min[0]);
double x = Double.parseDouble(min[1]);
double y = Double.parseDouble(min[2]);
double z = Double.parseDouble(min[3]);
minl = new Location(world, x, y, z);
World world2 = Bukkit.getWorld(max[0]);
double x2 = Double.parseDouble(max[1]);
double y2 = Double.parseDouble(max[2]);
double z2 = Double.parseDouble(max[3]);
minl = new Location(world2, x2, y2, z2);
} 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;
}
}
}
}
return false;
}
}

View File

@ -0,0 +1,54 @@
package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import java.util.List;
public class ChatListener implements Listener {
public Main plugin;
public ChatListener(Main m) {
this.plugin = m;
}
@EventHandler
public void TributeChat(AsyncPlayerChatEvent event) {
Player p = event.getPlayer();
String pname = p.getName();
if (plugin.getArena(p) != null) {
String msg = "<" + ChatColor.RED + "[Tribute] " + ChatColor.WHITE + pname + ">" + " " + event.getMessage();
if (plugin.config.getString("ChatClose").equalsIgnoreCase("True")) {
double radius = plugin.config.getDouble("ChatClose_Radius");
List<Entity> near = p.getNearbyEntities(radius, radius, radius);
event.setCancelled(true);
if (!(near.size() == 0)) {
p.sendMessage(msg);
for (Entity e : near) {
if (e instanceof Player) {
((Player) e).sendMessage(msg);
}
}
} else if (near.size() == 0) {
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);
plugin.getServer().broadcastMessage(msg);
}
}
}
}

View File

@ -0,0 +1,221 @@
package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
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;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.scoreboard.DisplaySlot;
public class DeathListener implements Listener {
public Main plugin;
public DeathListener(Main m) {
this.plugin = m;
}
public FileConfiguration config;
int i = 0;
int a = 0;
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerRespawn(PlayerRespawnEvent event) {
final Player p = event.getPlayer();
String pname = p.getName();
//get the arena the player has died in... (may be not the one he joined...)
String ThisWorld = p.getWorld().getName();
for (int z : plugin.worldsNames.keySet()) {
if (plugin.worldsNames.get(z) != null) {
if (plugin.worldsNames.get(z).equals(ThisWorld)) {
a = z;
}
}
}
//Jeppa: Fix for lonely players :)
for (int i : plugin.Dead.keySet()) {
if ((plugin.Dead.get(i) != null) && (plugin.Dead.get(i).contains(pname)) && (plugin.MatchRunning.get(i) == null)) {
plugin.Dead.get(i).clear();
}
}
for (int i = 0; i < plugin.needInv.size(); i++) {
if (plugin.needInv.contains(pname)) {
RespawnDeadPlayer(p, a);
}
}
}
private void RespawnDeadPlayer(Player p, int a) {
final Player player = p;
String[] Spawncoords = plugin.spawns.getString("Spawn_coords." + a).split(",");
World spawnw = plugin.getServer().getWorld(Spawncoords[3]);
double spawnx = Double.parseDouble(Spawncoords[0]);
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());
}
}, 10L);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerDeath(PlayerDeathEvent event) {
Player p = event.getEntity();
Server s = p.getServer();
String pname = p.getName();
if (plugin.getArena(p) != null) {
a = plugin.getArena(p);
int players = plugin.Playing.get(a).size() - 1;
String leftmsg = null;
clearInv(p);
event.getDrops().clear();
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
plugin.scoreboards.remove(p.getName());
if (!plugin.Frozen.get(a).isEmpty()) {
if (plugin.Frozen.get(a).contains(pname)) {
if (!(p.getKiller() instanceof Player)) {
players = plugin.Playing.get(a).size() - 1;
leftmsg = ChatColor.BLUE + "There are now " + players + " tributes left!";
if (plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")) {
double y = p.getLocation().getY();
double newy = y + 200;
double x = p.getLocation().getX();
double z = p.getLocation().getZ();
Location strike = new Location(p.getWorld(), x, newy, z);
p.getWorld().strikeLightning(strike);
}
event.setDeathMessage("");
if (plugin.config.getBoolean("broadcastAll")) {
p.getServer().broadcastMessage(pname + ChatColor.LIGHT_PURPLE + " Stepped off their pedestal too early!");
} else {
for (String gn : plugin.Playing.get(a)) {
Player g = plugin.getServer().getPlayer(gn);
g.sendMessage(pname + ChatColor.LIGHT_PURPLE + " Stepped off their pedestal too early!");
}
}
plugin.Frozen.get(a).remove(pname);
plugin.Playing.get(a).remove(pname);
if (plugin.config.getBoolean("broadcastAll")) {
p.getServer().broadcastMessage(leftmsg);
} else {
for (String gn : plugin.Playing.get(a)) {
Player g = plugin.getServer().getPlayer(gn);
g.sendMessage(leftmsg);
}
}
plugin.winner(a);
}
}
} else {
players = plugin.Playing.get(a).size() - 1;
leftmsg = ChatColor.BLUE + "There are now " + players + " tributes left!";
if (plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")) {
double y = p.getLocation().getY();
double newy = y + 200;
double x = p.getLocation().getX();
double z = p.getLocation().getZ();
Location strike = new Location(p.getWorld(), x, newy, z);
p.getWorld().strikeLightning(strike);
}
plugin.Dead.get(a).add(pname);
plugin.Playing.get(a).remove(pname);
if (p.getKiller() instanceof Player) {
if (p.getKiller().getInventory().getItemInMainHand().getType() == Material.AIR) {
Player killer = p.getKiller();
String killername = killer.getName();
event.setDeathMessage("");
if (plugin.config.getBoolean("broadcastAll")) {
s.broadcastMessage(ChatColor.LIGHT_PURPLE + "**BOOM** Tribute " + pname + " was killed by tribute " + killername + " with their FIST!");
s.broadcastMessage(leftmsg);
} else {
for (String gn : plugin.Playing.get(a)) {
Player g = plugin.getServer().getPlayer(gn);
g.sendMessage(ChatColor.LIGHT_PURPLE + "**BOOM** Tribute " + pname + " was killed by tribute " + killername + " with their FIST!");
g.sendMessage(leftmsg);
}
}
if (plugin.Kills.containsKey(killername)) {
plugin.Kills.put(killername, plugin.Kills.get(killername) + 1);
} else {
plugin.Kills.put(killername, 1);
}
if (plugin.Kills.containsKey("__SuM__")) {
plugin.Kills.put("__SuM__", plugin.Kills.get("__SuM__") + 1);
} else {
plugin.Kills.put("__SuM__", 1);
}
plugin.winner(a);
} else {
Player killer = p.getKiller();
String killername = killer.getName();
String weapon = "a(n) " + killer.getInventory().getItemInMainHand().getType().name().replace('_', ' ');
if (killer.getInventory().getItemInMainHand().hasItemMeta()) {
if (killer.getInventory().getItemInMainHand().getItemMeta().hasDisplayName()) {
weapon = killer.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
}
}
String msg = ChatColor.LIGHT_PURPLE + "**BOOM** Tribute " + pname + " was killed by tribute " + killername + " with " + weapon;
event.setDeathMessage("");
if (plugin.config.getBoolean("broadcastAll")) {
s.broadcastMessage(msg);
s.broadcastMessage(leftmsg);
} else {
for (String gn : plugin.Playing.get(a)) {
Player g = plugin.getServer().getPlayer(gn);
g.sendMessage(msg);
g.sendMessage(leftmsg);
}
}
if (plugin.Kills.containsKey(killername)) {
plugin.Kills.put(killername, plugin.Kills.get(killername) + 1);
} else {
plugin.Kills.put(killername, 1);
}
if (plugin.Kills.containsKey("__SuM__")) {
plugin.Kills.put("__SuM__", plugin.Kills.get("__SuM__") + 1);
} else {
plugin.Kills.put("__SuM__", 1);
}
plugin.winner(a);
}
} else {
event.setDeathMessage("");
if (plugin.config.getBoolean("broadcastAll")) {
s.broadcastMessage(ChatColor.LIGHT_PURPLE + pname + " died of natural causes!");
s.broadcastMessage(leftmsg);
} else {
for (String gn : plugin.Playing.get(a)) {
Player g = plugin.getServer().getPlayer(gn);
g.sendMessage(ChatColor.LIGHT_PURPLE + pname + " died of " + ChatColor.ITALIC + " probably " + ChatColor.LIGHT_PURPLE + "natural causes!");
g.sendMessage(leftmsg);
}
}
plugin.winner(a);
}
}
}
}
private void clearInv(Player p) {
p.getInventory().clear();
p.getInventory().setBoots(null);
p.getInventory().setChestplate(null);
p.getInventory().setHelmet(null);
p.getInventory().setLeggings(null);
p.updateInventory();
}
}

View File

@ -0,0 +1,123 @@
package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.metadata.MetadataValue;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class FreezeListener implements Listener {
public Main plugin;
public FreezeListener(Main m) {
this.plugin = m;
}
int i = 0;
int a = 0;
private HashMap<Integer, Boolean> timeUp = new HashMap<Integer, Boolean>();
private ArrayList<Integer> timing = new ArrayList<Integer>();
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
Player p = event.getPlayer();
String pname = p.getName();
if (plugin.getArena(p) != null) {
a = plugin.getArena(p);
if (plugin.Frozen.get(a).contains(pname) && plugin.config.getString("Frozen_Teleport").equalsIgnoreCase("True")) {
if (plugin.config.getString("Explode_on_Move").equalsIgnoreCase("true")) {
timeUp.put(a, false);
for (String players : plugin.Playing.get(a)) {
Player playing = plugin.getServer().getPlayerExact(players);
i = plugin.Playing.get(a).indexOf(players) + 1;
if (!timeUp.get(a) && !timing.contains(a)) {
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);
}
}
}, 30L);
}
} else {
if (!playing.getLocation().getBlock().getLocation().equals(plugin.location.get(a).get(i).getBlock().getLocation())) {
if (!plugin.Dead.get(a).contains(playing.getName())) {
plugin.Dead.get(a).add(playing.getName());
World world = playing.getLocation().getWorld();
world.createExplosion(playing.getLocation(), 0.0F, false);
playing.setHealth(0.0D);
}
}
}
}
if (plugin.Dead.get(a).contains(pname) && plugin.Playing.get(a).contains(pname)) {
int players = plugin.Playing.get(a).size() - 1;
String leftmsg = ChatColor.BLUE + "There are now " + players + " tributes left!";
if (plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")) {
double y = p.getLocation().getY();
double newy = y + 200;
double x = p.getLocation().getX();
double z = p.getLocation().getZ();
Location strike = new Location(p.getWorld(), x, newy, z);
p.getWorld().strikeLightning(strike);
}
if (plugin.config.getBoolean("broadcastAll")) {
p.getServer().broadcastMessage(pname + ChatColor.LIGHT_PURPLE + " Stepped off their pedestal too early!");
} else {
for (String gn : plugin.Playing.get(a)) {
Player g = plugin.getServer().getPlayer(gn);
g.sendMessage(pname + ChatColor.LIGHT_PURPLE + " Stepped off their pedestal too early!");
}
}
plugin.Frozen.get(a).remove(pname);
plugin.Playing.get(a).remove(pname);
if (plugin.config.getBoolean("broadcastAll")) {
p.getServer().broadcastMessage(leftmsg);
} else {
for (String gn : plugin.Playing.get(a)) {
Player g = plugin.getServer().getPlayer(gn);
g.sendMessage(leftmsg);
}
}
plugin.winner(a);
}
} else {
i = plugin.Playing.get(a).indexOf(pname) + 1;
Location pLoc = null;
if (p.hasMetadata("HA-Location")) {
List<MetadataValue> l = p.getMetadata("HA-Location");
if (l != null && l.size() != 0) {
try {
pLoc = (Location) l.get(0).value();
} catch (Exception e) {
}
}
if (pLoc != null) {
if (p.getLocation().getBlockX() != (pLoc.getBlockX()) || p.getLocation().getBlockZ() != (pLoc.getBlockZ())) {
pLoc.setX(pLoc.getBlock().getLocation().getX() + .5);
pLoc.setZ(pLoc.getBlock().getLocation().getZ() + .5);
p.teleport(pLoc);
}
} else {
if (!p.getLocation().getBlock().getLocation().equals(plugin.location.get(a).get(i).getBlock().getLocation())) {
p.teleport(plugin.location.get(a).get(i));
}
}
}
}
}
}
}
}

View File

@ -0,0 +1,204 @@
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;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scoreboard.DisplaySlot;
public class JoinAndQuitListener implements Listener {
public Main plugin;
public JoinAndQuitListener(Main m) {
this.plugin = m;
}
public HaCommands commands;
public JoinAndQuitListener(HaCommands h) {
this.commands = h;
}
int a = 0;
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
final Player p = event.getPlayer();
final String pname = p.getName();
boolean pfound = false;
for (int i : plugin.Watching.keySet()) {
for (String s : plugin.Watching.get(i)) {
Player spectator = plugin.getServer().getPlayerExact(s);
p.hidePlayer(plugin, spectator);
}
}
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.Out.get(i).remove(pname);
pfound = true;
}
}
for (final int i : plugin.Quit.keySet()) {
if (plugin.Quit.get(i).contains(pname)) {
String[] Spawncoords = plugin.spawns.getString("Spawn_coords." + i).split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
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());
}
}
}, 40L);
pfound = true;
}
}
for (final int i : plugin.Dead.keySet()) {
if (plugin.Dead.get(i).contains(pname)) {
String[] Spawncoords = plugin.spawns.getString("Spawn_coords." + i).split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
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());
}
}
}, 40L);
pfound = true;
}
}
for (final int i : plugin.inArena.keySet()) {
if (plugin.inArena.get(i) != null) {
if (plugin.inArena.get(i).contains(pname)) {
String[] Spawncoords = plugin.spawns.getString("Spawn_coords." + i).split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
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());
}
}
}, 40L);
pfound = true;
}
}
}
if ((plugin.restricted && plugin.worldsNames.values().contains(p.getWorld().getName())) || !plugin.restricted) {
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];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
double spawny = Double.parseDouble(Spawncoords[1]);
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!!");
}
}, 40L);
}
}
}
@EventHandler
public void onQuit(PlayerQuitEvent evt) {
Player p = evt.getPlayer();
String pname = p.getName();
for (int i : plugin.Frozen.keySet()) {
if (plugin.Frozen.get(i).contains(pname)) {
plugin.Frozen.remove(pname);
String[] Spawncoords = plugin.spawns.getString("Spawn_coords.0").split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]);
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());
}
}
}
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
final Player p = event.getPlayer();
final String pname = 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);
}
}
}, 1200L);
}
}
}

View File

@ -0,0 +1,106 @@
package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.Skeleton;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
public class PvP implements Listener {
public Main plugin;
public PvP(Main m) {
this.plugin = m;
}
int a = 0;
@EventHandler(priority = EventPriority.MONITOR)
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 (plugin.getArena(p) != null && plugin.getArena(d) != null) {
a = plugin.getArena(p);
if (plugin.canjoin.get(a)) {
if (event.isCancelled()) {
event.setCancelled(false);
}
if (plugin.gp.get(plugin.getArena(p)) != null) {
if (plugin.gp.get(plugin.getArena(p)) != 0) {
event.setCancelled(true);
}
}
}
}
if (plugin.getArena(p) != null) {
a = plugin.getArena(p);
if (!plugin.canjoin.get(a)) {
if (!event.isCancelled()) {
event.setCancelled(true);
}
}
}
if (plugin.getArena(p) == null && plugin.getArena(d) != null) {
if (!event.isCancelled()) {
event.setCancelled(true);
}
}
} else if (pl instanceof Player && dl instanceof Projectile) {
Projectile projectile = (Projectile) dl;
Player p = (Player) pl;
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);
}
}
}
}
} else if (projectile.getShooter() instanceof Entity) {
Entity e = (Entity) projectile.getShooter();
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);
}
}
}
}
}
}
}
@EventHandler
public void PlayerDamage(EntityDamageEvent event) {
Entity e = event.getEntity();
if (e instanceof Player) {
Player p = (Player) e;
if (plugin.getArena(p) != null) {
a = plugin.getArena(p);
if (plugin.gp.get(a) != null && plugin.gp.get(a) != 0) {
event.setCancelled(true);
}
if (plugin.Frozen.get(a) != null && plugin.Frozen.get(a).contains(p.getName())) {
event.setCancelled(true);
}
}
}
}
}

View File

@ -0,0 +1,94 @@
package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor;
import org.bukkit.Tag;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
public class SignsAndBeds implements Listener {
public Main plugin;
public SignsAndBeds(Main m) {
this.plugin = m;
}
@EventHandler
public void Sign(PlayerInteractEvent event) {
Player p = event.getPlayer();
Block b = event.getClickedBlock();
if (b == null) {
return;
}
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
//2019 1.14 Translate Materials:
boolean foundSign = false;
try {
if (b.getState() instanceof org.bukkit.block.Sign) {
foundSign = true;
}
} catch (Exception e) {
if (!foundSign) {
foundSign = Tag.SIGNS.isTagged(b.getType());
}
}
if (foundSign) {
org.bukkit.block.Sign sign = (org.bukkit.block.Sign) b.getState();
String line1 = sign.getLine(0);
String line2 = sign.getLine(1);
String line3 = sign.getLine(2);
String line4 = sign.getLine(3);
if (line1.trim().equalsIgnoreCase(ChatColor.BLUE + "[HungerArena]") || line1.trim().equalsIgnoreCase(ChatColor.BLUE + "[HA]")) {
if (!line2.equals("") && line3.equals("")) {
p.performCommand("ha " + line2);
} else if (line2.equals("") && !line3.equals("")) {
p.performCommand("ha " + line3);
} else if (!line2.equals("") && !line3.equals("")) {
String commands = "close,join,kick,leave,list,open,ready,refill,reload,restart,rlist,tp,start,watch,warpall";
if (commands.contains(line3.trim().toLowerCase())) {
p.performCommand("ha " + line2);
p.performCommand("ha " + line3);
} else {
p.performCommand("ha " + line2 + " " + line3);
}
} else {
p.performCommand("ha");
}
}
if (line1.trim().equalsIgnoreCase(ChatColor.BLUE + "[Sponsor]")) {
p.performCommand("sponsor " + line2 + " " + line3 + " " + line4);
}
}
if (plugin.config.getString("DenyBedUsage").equalsIgnoreCase("True")) {
boolean foundBed = false;
try {
if (b.getState() instanceof org.bukkit.block.Bed) {
foundBed = true;
}
} catch (Exception e) {
if (!foundBed) {
foundBed = Tag.BEDS.isTagged(b.getType());
}
}
if (foundBed) {
event.setCancelled(true);
}
}
}
}
@EventHandler
public void Create(SignChangeEvent event) {
String top = event.getLine(0);
if (top.equalsIgnoreCase("[HungerArena]") || top.equalsIgnoreCase("[HA]") || top.equalsIgnoreCase("[Sponsor]")) {
event.setLine(0, ChatColor.BLUE + top);
}
}
}

View File

@ -0,0 +1,72 @@
package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
public class SignsAndBedsOld implements Listener {
public Main plugin;
public SignsAndBedsOld(Main m) {
this.plugin = m;
}
@SuppressWarnings("deprecation")
@EventHandler
public void Sign(PlayerInteractEvent event) {
Player p = event.getPlayer();
Block b = event.getClickedBlock();
if (b == null) {
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();
String line1 = sign.getLine(0);
String line2 = sign.getLine(1);
String line3 = sign.getLine(2);
String line4 = sign.getLine(3);
if (line1.trim().equalsIgnoreCase(ChatColor.BLUE + "[HungerArena]") || line1.trim().equalsIgnoreCase(ChatColor.BLUE + "[HA]")) {
if (!line2.equals("") && line3.equals("")) {
p.performCommand("ha " + line2);
} else if (line2.equals("") && !line3.equals("")) {
p.performCommand("ha " + line3);
} else if (!line2.equals("") && !line3.equals("")) {
String commands = "close,join,kick,leave,list,open,ready,refill,reload,restart,rlist,tp,start,watch,warpall";
if (commands.contains(line3.trim().toLowerCase())) {
p.performCommand("ha " + line2);
p.performCommand("ha " + line3);
} else {
p.performCommand("ha " + line2 + " " + line3);
}
} else {
p.performCommand("ha");
}
}
if (line1.trim().equalsIgnoreCase(ChatColor.BLUE + "[Sponsor]")) {
p.performCommand("sponsor " + line2 + " " + line3 + " " + line4);
}
}
if (plugin.config.getString("DenyBedUsage").trim().equalsIgnoreCase("true")) {
if (b.getState().getData() instanceof org.bukkit.material.Bed) {
event.setCancelled(true);
}
}
}
}
@EventHandler
public void Create(SignChangeEvent event) {
String top = event.getLine(0);
if (top.equalsIgnoreCase("[HungerArena]") || top.equalsIgnoreCase("[HA]") || top.equalsIgnoreCase("[Sponsor]")) {
event.setLine(0, ChatColor.BLUE + top);
}
}
}

View File

@ -0,0 +1,195 @@
package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.scoreboard.DisplaySlot;
public class SpectatorListener implements Listener {
public Main plugin;
public SpectatorListener(Main m) {
this.plugin = m;
}
int i = 0;
@EventHandler
public void SpectatorDrops(PlayerDropItemEvent event) {
Player p = event.getPlayer();
if (denyInteraction(p)) {
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorInteractBlock(PlayerInteractEvent event) {
Player p = event.getPlayer();
if (denyInteraction(p)) {
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorInteractEntity(PlayerInteractEntityEvent event) {
Player p = event.getPlayer();
if (denyInteraction(p)) {
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorItems(EntityPickupItemEvent event) {
if (event.getEntity() instanceof Player) {
Player p = (Player) event.getEntity();
if (denyInteraction(p)) {
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
}
@EventHandler
public void SpectatorPvP(EntityDamageByEntityEvent event) {
Entity offense = event.getDamager();
if (offense instanceof Player) {
Player Attacker = (Player) event.getDamager();
String attackerName = Attacker.getName();
for (int i : plugin.Watching.keySet()) {
if (plugin.Watching.get(i) != null) {
if (plugin.Watching.get(i).contains(attackerName)) {
event.setCancelled(true);
Attacker.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
return;
}
}
}
for (int i : plugin.Playing.keySet()) {
if (plugin.Playing.get(i) != null) {
if (plugin.Playing.get(i).contains(attackerName)) {
event.setCancelled(true);
}
}
}
} else if (event.getDamager() instanceof Projectile) {
Projectile arrow = (Projectile) offense;
ProjectileSource shooter = arrow.getShooter();
if (shooter instanceof Player) {
Player BowMan = (Player) shooter;
String bowManName = BowMan.getName();
for (int i : plugin.Watching.keySet()) {
if (plugin.Watching.get(i) != null) {
if (plugin.Watching.get(i).contains(bowManName)) {
event.setCancelled(true);
BowMan.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
return;
}
}
}
for (int i : plugin.Playing.keySet()) {
if (plugin.Playing.get(i) != null) {
if (plugin.Playing.get(i).contains(bowManName)) {
event.setCancelled(true);
}
}
}
}
}
}
@EventHandler
public void SpectatorBlockBreak(BlockBreakEvent event) {
Player p = event.getPlayer();
if (denyInteraction(p)) {
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorBlockPlace(BlockPlaceEvent event) {
Player p = event.getPlayer();
if (denyInteraction(p)) {
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorQuit(PlayerQuitEvent event) {
Player p = event.getPlayer();
String pname = p.getName();
for (int i : plugin.Watching.keySet()) {
if (plugin.Watching.get(i) != null) {
if (plugin.Watching.get(i).contains(pname)) {
plugin.Watching.get(i).remove(pname);
String[] Spawncoords = plugin.spawns.getString("Spawn_coords.0").split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]);
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());
}
}
}
}
}
@EventHandler
public void MobNerf(EntityTargetEvent event) {
Entity target = event.getTarget();
Entity e = event.getEntity();
if (e instanceof Player) {
return;
}
if (target instanceof Player) {
String targetName = ((Player) target).getName();
for (int i : plugin.Watching.keySet()) {
if (plugin.Watching.get(i) != null) {
if (plugin.Watching.get(i).contains(targetName)) {
event.setTarget(null);
}
}
}
}
}
private boolean denyInteraction(Player p) {
String pname = p.getName();
for (int i : plugin.Watching.keySet()) {
if (plugin.Watching.get(i) != null) {
if (plugin.Watching.get(i).contains(pname)) {
return true;
}
}
}
return false;
}
}

View File

@ -0,0 +1,193 @@
package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
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.projectiles.ProjectileSource;
import org.bukkit.scoreboard.DisplaySlot;
public class SpectatorListenerOld implements Listener {
public Main plugin;
public SpectatorListenerOld(Main m) {
this.plugin = m;
}
int i = 0;
@EventHandler
public void SpectatorDrops(PlayerDropItemEvent event) {
Player p = event.getPlayer();
if (denyInteraction(p)) {
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorInteractBlock(PlayerInteractEvent event) {
Player p = event.getPlayer();
if (denyInteraction(p)) {
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorInteractEntity(PlayerInteractEntityEvent event) {
Player p = event.getPlayer();
if (denyInteraction(p)) {
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@SuppressWarnings("deprecation")
@EventHandler
public void SpectatorItems(PlayerPickupItemEvent event) {
Player p = event.getPlayer();
if (denyInteraction(p)) {
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
private boolean denyInteraction(Player p) {
String pname = p.getName();
for (int i : plugin.Watching.keySet()) {
if (plugin.Watching.get(i) != null) {
if (plugin.Watching.get(i).contains(pname)) {
return true;
}
}
}
return false;
}
@EventHandler
public void SpectatorPvP(EntityDamageByEntityEvent event) {
Entity offense = event.getDamager();
if (offense instanceof Player) {
Player Attacker = (Player) event.getDamager();
String attackerName = Attacker.getName();
for (int i : plugin.Watching.keySet()) {
if (plugin.Watching.get(i) != null) {
if (plugin.Watching.get(i).contains(attackerName)) {
event.setCancelled(true);
Attacker.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
return;
}
}
}
for (int i : plugin.Playing.keySet()) {
if (plugin.Playing.get(i) != null) {
if (plugin.Playing.get(i).contains(attackerName)) {
event.setCancelled(true);
}
}
}
} else if (event.getDamager() instanceof Projectile) {
Projectile arrow = (Projectile) offense;
ProjectileSource shooter = arrow.getShooter();
if (shooter instanceof Player) {
Player BowMan = (Player) shooter;
String bowManName = BowMan.getName();
for (int i : plugin.Watching.keySet()) {
if (plugin.Watching.get(i) != null) {
if (plugin.Watching.get(i).contains(bowManName)) {
event.setCancelled(true);
BowMan.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
return;
}
}
}
for (int i : plugin.Playing.keySet()) {
if (plugin.Playing.get(i) != null) {
if (plugin.Playing.get(i).contains(bowManName)) {
event.setCancelled(true);
}
}
}
}
}
}
@EventHandler
public void SpectatorBlockBreak(BlockBreakEvent event) {
Player p = event.getPlayer();
if (denyInteraction(p)) {
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorBlockPlace(BlockPlaceEvent event) {
Player p = event.getPlayer();
if (denyInteraction(p)) {
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorQuit(PlayerQuitEvent event) {
Player p = event.getPlayer();
String pname = p.getName();
for (int i : plugin.Watching.keySet()) {
if (plugin.Watching.get(i) != null) {
if (plugin.Watching.get(i).contains(pname)) {
plugin.Watching.get(i).remove(pname);
String[] Spawncoords = plugin.spawns.getString("Spawn_coords.0").split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]);
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());
}
}
}
}
}
@EventHandler
public void MobNerf(EntityTargetEvent event) {
Entity target = event.getTarget();
Entity e = event.getEntity();
if (e instanceof Player) {
return;
}
if (target instanceof Player) {
String targetName = ((Player) target).getName();
for (int i : plugin.Watching.keySet()) {
if (plugin.Watching.get(i) != null) {
if (plugin.Watching.get(i).contains(targetName)) {
event.setTarget(null);
}
}
}
}
}
}

View File

@ -0,0 +1,33 @@
package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerTeleportEvent;
public class TeleportListener implements Listener {
public Main plugin;
public TeleportListener(Main m) {
this.plugin = m;
}
@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)) {
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);
} else if (plugin.Tele.contains(p)) {
if (event.isCancelled()) {
event.setCancelled(false);
plugin.Tele.remove(p);
}
}
}
}

View File

@ -0,0 +1,58 @@
package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChangedWorldEvent;
public class WorldChange implements Listener {
public Main plugin;
public WorldChange(Main m) {
plugin = m;
}
@EventHandler(priority = EventPriority.LOWEST)
public void worldChangeLow(PlayerChangedWorldEvent event) {
Player p = event.getPlayer();
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)) {
plugin.RestoreInv(p, pname);
}
}
@EventHandler(priority = EventPriority.HIGH)
public void worldChangeHigh(PlayerChangedWorldEvent event) {
Player p = event.getPlayer();
String pname = p.getName();
String ThisWorld = p.getWorld().getName();
int a = 0;
for (int i : plugin.worldsNames.keySet()) {
if (plugin.worldsNames.get(i) != null) {
if (plugin.worldsNames.get(i).equals(ThisWorld)) {
a = i;
if (plugin.Frozen.get(a) != null && plugin.Frozen.get(a).contains(pname)) {
return;
} else {
plugin.RestoreInv(p, pname);
if (plugin.config.getString("joinTeleport").equalsIgnoreCase("true")) {
String[] Spawncoords = plugin.spawns.getString("Spawn_coords." + a).split(",");
double spawnx = Double.parseDouble(Spawncoords[0]);
double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]);
Location Spawn = new Location(p.getWorld(), spawnx, spawny, spawnz);
if (!p.getLocation().getBlock().equals(Spawn.getBlock())) {
p.teleport(Spawn);
}
}
}
}
}
}
}
}

View File

@ -0,0 +1,61 @@
package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import java.util.Collection;
public class spawnsListener implements Listener {
public Main plugin;
public spawnsListener(Main m) {
this.plugin = m;
}
@EventHandler
public void interact(PlayerInteractEvent event) {
Player p = event.getPlayer();
if (plugin.setting.containsKey(p.getName())) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
Location l = event.getClickedBlock().getLocation();
String HandItem;
try {
HandItem = p.getInventory().getItemInMainHand().getType().name();
} catch (Exception e) {
HandItem = p.getItemInHand().getType().name();
}
if (HandItem == 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);
int arena = Integer.parseInt(info[0]);
if (plugin.spawns.get("Spawns." + arena) != null) {
Collection<Object> temp = plugin.spawns.getConfigurationSection("Spawns." + arena).getValues(false).values();
if (temp.contains(coords.trim().replace(' ', ','))) {
event.setCancelled(true);
return;
}
}
p.performCommand("startpoint " + info[0] + " " + info[1] + " " + coords);
if (Integer.parseInt(info[1]) >= plugin.config.getInt("maxPlayers")) {
p.sendMessage(ChatColor.DARK_AQUA + "[HungerArena] " + ChatColor.RED + "All spawns set!");
plugin.setting.remove(p.getName());
} else {
plugin.setting.put(p.getName(), info[0] + "-" + (Integer.parseInt(info[1]) + 1));
p.sendMessage(ChatColor.DARK_AQUA + "[HungerArena] " + ChatColor.RED + "Next starting point: " + (Integer.parseInt(info[1]) + 1));
}
}
}
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,180 @@
package me.Travja.HungerArena;
import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class SpawnsCommand implements CommandExecutor {
public Main plugin;
int i = 0;
int a = 0;
boolean NoPlayerSpawns;
public SpawnsCommand(Main m) {
this.plugin = m;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
Player p = (Player) sender;
String ThisWorld = p.getWorld().getName();
NoPlayerSpawns = true;
for (int i : plugin.worldsNames.keySet()) {
if (plugin.worldsNames.get(i) != null) {
if (plugin.worldsNames.get(i).equals(ThisWorld)) {
a = i;
NoPlayerSpawns = false;
break;
}
}
}
if (cmd.getName().equalsIgnoreCase("StartPoint")) {
if (p.hasPermission("HungerArena.StartPoint")) {
Location loc = null;
double x;
double y;
double z;
if (args.length == 6) {
try {
i = Integer.valueOf(args[1]);
a = Integer.valueOf(args[0]);
} catch (Exception e) {
p.sendMessage(ChatColor.RED + "Argument not an integer!");
return true;
}
String world = args[2];
x = Double.parseDouble(args[3]);
y = Double.parseDouble(args[4]);
z = Double.parseDouble(args[5]);
loc = new Location(Bukkit.getWorld(world), x, y, z);
if (plugin.location.get(a) != null) {
plugin.location.get(a).put(i, loc);
} else {
plugin.location.put(a, new HashMap<Integer, Location>());
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.canjoin.put(a, false);
plugin.MatchRunning.put(a, null);
plugin.open.put(a, true);
}
String coords = loc.getWorld().getName() + "," + (loc.getX()) + "," + loc.getY() + "," + (loc.getZ());
p.sendMessage(coords);
plugin.spawns.set("Spawns." + a + "" + i, coords);
plugin.worldsNames.put(a, loc.getWorld().getName());
plugin.saveSpawns();
plugin.maxPlayers.put(a, plugin.location.get(a).size());
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute " + i + " in arena " + a + "!");
this.plugin.reloadSpawnpoints(false);
return true;
}
if (args.length >= 2) {
try {
i = Integer.valueOf(args[1]);
a = Integer.valueOf(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())) {
p.sendMessage(ChatColor.GOLD + "You've added this world to the config ...");
}
loc = p.getLocation().getBlock().getLocation();
x = loc.getX() + .5;
y = loc.getY();
z = loc.getZ() + .5;
loc = new Location(loc.getWorld(), x, y, z);
if (plugin.location.get(a) != null) {
plugin.location.get(a).put(i, loc);
} else {
plugin.location.put(a, new HashMap<Integer, Location>());
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.canjoin.put(a, false);
plugin.MatchRunning.put(a, null);
plugin.open.put(a, true);
}
String coords = loc.getWorld().getName() + "," + (loc.getX()) + "," + loc.getY() + "," + (loc.getZ());
p.sendMessage(coords);
plugin.spawns.set("Spawns." + a + "" + i, coords);
plugin.worldsNames.put(a, loc.getWorld().getName());
plugin.saveSpawns();
plugin.maxPlayers.put(a, plugin.location.get(a).size());
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute " + i + " in arena " + a + "!");
this.plugin.reloadSpawnpoints(false);
} else {
p.sendMessage(ChatColor.RED + "You can't go past " + plugin.config.getInt("maxPlayers") + " players!");
}
} else if (args.length == 1) {
if (sender instanceof Player) {
p = (Player) sender;
if (NoPlayerSpawns) {
try {
a = Integer.parseInt(args[0]);
} catch (Exception e) {
p.sendMessage(ChatColor.RED + "Argument not an integer!");
return true;
}
}
if (plugin.spawns.get("Spawns." + a) != null) {
int start = 1;
while (start < plugin.config.getInt("maxPlayers") + 2) {
if (plugin.spawns.get("Spawns." + a + "" + start) != null) {
start = start + 1;
if (start == plugin.config.getInt("maxPlayers") + 1) {
p.sendMessage(ChatColor.DARK_AQUA + "[HungerArena] " + ChatColor.GREEN + "All spawns set, type /startpoint [Arena #] [Spawn #] to over-ride previous points!");
return true;
}
} else {
int sloc = start;
start = plugin.config.getInt("maxPlayers") + 1;
p.sendMessage(ChatColor.DARK_AQUA + "[HungerArena] " + ChatColor.RED + "Begin Setting For Arena " + a + " Starting From Point " + sloc);
plugin.setting.put(p.getName(), a + "-" + sloc);
return true;
}
}
}
p.sendMessage(ChatColor.DARK_AQUA + "[HungerArena] " + ChatColor.RED + "Begin Setting For Arena " + a + " Starting From Point " + 1);
plugin.setting.put(p.getName(), a + "-" + 1);
return true;
} else {
sender.sendMessage(ChatColor.BLUE + "This Can Only Be Sent As A Player");
}
} else {
p.sendMessage(ChatColor.RED + "No argument given! \nUse command like this:\n/startpoint [Arena #] [Startpoint #] for setting your position as a startpoint.\n/startpoint [Arena #] [Startpoint #] [Mapname] [x] [y] [z] \nOr you can use /startpoint [Arena #] to use the 'spawntool': ID" + plugin.config.getInt("spawnsTool") + " for setting the startpoints!");
return false;
}
} else {
p.sendMessage(ChatColor.RED + "You don't have permission!");
}
}
return false;
}
}

View File

@ -0,0 +1,152 @@
package me.Travja.HungerArena;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class SponsorCommands implements CommandExecutor {
public Main plugin;
public SponsorCommands(Main m) {
this.plugin = m;
}
@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 (p.hasPermission("HungerArena.Sponsor")) {
if (plugin.getArena(p) == null) {
if (args.length == 0) {
p.sendMessage(ChatColor.RED + "You didn't specify a tribute!");
return false;
}
if (args.length == 1) {
p.sendMessage(ChatColor.RED + "You didn't specify an item!");
}
if (args.length == 2) {
p.sendMessage(ChatColor.RED + "You didn't specify an amount!");
}
if (args.length >= 3) {
Player target = Bukkit.getServer().getPlayer(args[0]);
if (target == null || (target != null && plugin.getArena(target) == null)) {
p.sendMessage(ChatColor.RED + "That person isn't playing!");
} else {
try {
String ID = args[1].toUpperCase().trim();
int amount = Integer.parseInt(args[2]);
if ((!plugin.management.getStringList("sponsors.blacklist").isEmpty() && !plugin.management.getStringList("sponsors.blacklist").contains(ID)) || plugin.management.getStringList("sponsors.blacklist").isEmpty()) {
handleItemsAndEco(p, args, ID, amount, target);
} else {
p.sendMessage(ChatColor.RED + "You can't sponsor that item!");
p.sendMessage(ChatColor.GREEN + "Other items you can't sponsor are:");
for (String blacklist : plugin.management.getStringList("sponsors.blacklist")) {
p.sendMessage(ChatColor.AQUA + blacklist);
}
}
} catch (Exception e) {
p.sendMessage(ChatColor.RED + "Something went wrong there... Make sure that you do like this /sponsor [name] [item] [number]");
}
}
}
} else {
p.sendMessage(ChatColor.RED + "You are playing, you can't sponsor yourself!");
}
} else {
p.sendMessage(ChatColor.RED + "You don't have permission!");
}
} else if (sender instanceof ConsoleCommandSender) {
if (args.length == 0) {
sender.sendMessage(ChatColor.RED + "You didn't specify a tribute!");
return false;
}
if (args.length == 1) {
sender.sendMessage(ChatColor.RED + "You didn't specify an item!");
}
if (args.length == 2) {
sender.sendMessage(ChatColor.RED + "You didn't specify an amount!");
}
if (args.length >= 3) {
Player target = Bukkit.getPlayer(args[0]);
String ID = args[1].toUpperCase().trim();
int Amount = Integer.parseInt(args[2]);
try {
if ((!plugin.management.getStringList("sponsors.blacklist").isEmpty() && !plugin.management.getStringList("sponsors.blacklist").contains(ID)) || plugin.management.getStringList("sponsors.blacklist").isEmpty()) {
ItemStack sponsoritem = new ItemStack(org.bukkit.Material.getMaterial(ID), Amount);
if (plugin.getArena(target) == null) {
sender.sendMessage(ChatColor.RED + "That person isn't playing!");
} else {
sender.sendMessage(ChatColor.RED + "You can't sponsor yourself!");
target.sendMessage(ChatColor.AQUA + "You have been Sponsored!");
target.getInventory().addItem(sponsoritem);
sender.sendMessage("You have sponsored " + target.getName() + "!");
}
} else {
sender.sendMessage(ChatColor.RED + "You can't sponsor that item!");
sender.sendMessage(ChatColor.GREEN + "Other items you can't sponsor are:");
for (String blacklist : plugin.management.getStringList("sponsors.blacklist")) {
sender.sendMessage(ChatColor.AQUA + blacklist);
}
}
} catch (Exception e) {
sender.sendMessage(ChatColor.RED + "Something went wrong there... Make sure that you do like this /sponsor [name] [number] [number]");
}
}
}
}
return false;
}
private void handleItemsAndEco(Player p, String[] args, String ID, int amount, Player target) {
Material sponsMat = plugin.getNewMaterial(ID, 0);
ItemStack sponsoritem;
boolean done = false;
if (sponsMat != null) {
sponsoritem = new ItemStack(sponsMat, amount);
} else {
p.sendMessage(ChatColor.RED + "That item does not exist !!");
return;
}
for (ItemStack Costs : plugin.Cost) {
if (!p.getInventory().containsAtLeast(Costs, Costs.getAmount() * amount)) {
p.sendMessage(ChatColor.RED + "You don't have the necessary items to sponsor!");
return;
}
}
if (args[0].equalsIgnoreCase(p.getName())) {
p.sendMessage(ChatColor.RED + "You can't sponsor yourself!");
} else {
if (plugin.config.getBoolean("sponsorEco.enabled")) {
if (!(plugin.econ.getBalance(p) < (plugin.config.getDouble("sponsorEco.cost") * amount))) {
plugin.econ.withdrawPlayer(p, plugin.config.getDouble("sponsorEco.cost") * amount);
done = true;
} else {
p.sendMessage(ChatColor.RED + "You don't have enough money to do that!");
return;
}
}
if (!plugin.Cost.isEmpty()) {
for (ItemStack aCosts : plugin.Cost) {
for (int x = 1; x <= amount; x++) {
p.getInventory().removeItem(aCosts);
done = true;
}
}
}
if (done) {
target.getInventory().addItem(sponsoritem);
target.sendMessage(ChatColor.AQUA + "You have been Sponsored!");
p.sendMessage("You have sponsored " + target.getName() + "!");
} else {
p.sendMessage(ChatColor.RED + "Sponsoring is disabled!");
}
}
}
}

View File

@ -0,0 +1,3 @@
# Stores all blocks to reset!
Blocks_Destroyed: [ ]
Blocks_Placed: [ ]

View File

@ -1,6 +1,6 @@
# This is the default inventory file for storing players inventory during matches !
# DO not Edit anything in here!!!
inv: []
armor: []
inv: [ ]
armor: [ ]
world: world

View File

@ -5,9 +5,9 @@
# Anything not in the whitelist will be counted as blacklist!
commands:
whitelist: []
whitelist: [ ]
blocks:
useWhitelistAsBlacklist: false
whitelist: []
whitelist: [ ]
sponsors:
blacklist: []
blacklist: [ ]

View File

@ -85,15 +85,15 @@ spawnsTool: GOLDEN_AXE
# What the reward for winning is
Reward:
- DIAMOND,10
- DIAMOND,10
Sponsor_Cost:
- DIAMOND,1
- DIAMOND,1
EntryFee:
enabled: false
eco: false
cost: 50
fee:
- IRON_INGOT,1
- IRON_INGOT,1
# True means give money to winner, false means don't.
# How much money to give the winner.
rewardEco:
@ -107,7 +107,7 @@ sponsorEco:
ChestPay:
enabled: false
items:
- COOKED_BEEF,2
- COOKED_BEEF,2
################################
################################
################################

View File

@ -1,9 +1,9 @@
name: HungerArena
main: me.Travja.HungerArena.Main
version: 1.6_Jeppa
api-version: 1.13
api-version: 1.18
description: A lightweight and powerful plugin to help with playing The Hunger Games!
softdepend: [Vault, WorldEdit, Multiverse-Core]
softdepend: [ Vault, WorldEdit, Multiverse-Core ]
commands:
Ha:
description: Makes you join a game or start the game!

View File

@ -1,5 +1,5 @@
# This file stores all of the spawns!
Spawn_coords: []
Spawn_coords: [ ]
# If /ha setspawn has been run
Spawns_set:
0: 'false'

View File

@ -1,78 +0,0 @@
package me.Travja.HungerArena;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
public class Chests implements Listener {
public Main plugin;
public Chests(Main m) {
this.plugin = m;
}
@EventHandler(priority = EventPriority.HIGHEST)
public void ChestBreak(BlockBreakEvent event){
Player p = event.getPlayer();
Block block = event.getBlock();
if(p.hasPermission("HungerArena.Chest.Break")){
Location blocklocation = block.getLocation();
int blockx = blocklocation.getBlockX();
int blocky = blocklocation.getBlockY();
int blockz = blocklocation.getBlockZ();
if (plugin.getChests().getConfigurationSection("Storage").getKeys(false).contains(blockx + "," + blocky + "," + blockz)) {
if(p.hasPermission("HungerArena.Chest.Break") && plugin.getArena(p)== null){
plugin.getChests().set("Storage." + blockx + "," + blocky+ "," + blockz, null);
plugin.saveChests();
p.sendMessage("[HungerArena] Chest Removed!");
} else {
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "[HungerArena] That's a storage! You don't have permission to break it!");
}
}
}
}
@EventHandler
public void ChestSaves(PlayerInteractEvent event){
Block block = event.getClickedBlock();
Player p = event.getPlayer();
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(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();
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);
plugin.getChests().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Z",blockz);
plugin.getChests().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.W", blockw);
plugin.getChests().set("Storage." + blockx + "," + blocky + "," + blockz + ".ItemsInStorage", itemsinchest);
plugin.getChests().set("Storage." + blockx + "," + blocky + "," + blockz + ".Arena", a);
plugin.saveChests();
p.sendMessage(ChatColor.GREEN + "Thank you for finding this undiscovered item Storage, it has been stored!!");
if (plugin.config.getBoolean("ChestPay.enabled")){
for(ItemStack Rewards: plugin.ChestPay){
p.getInventory().addItem(Rewards);
}
}
}
plugin.reloadChests();
}
}
}
}
}
}
}

View File

@ -1,98 +0,0 @@
package me.Travja.HungerArena;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
public class CommandBlock implements Listener {
public Main plugin;
public CommandBlock(Main m) {
this.plugin = m;
}
@EventHandler(priority = EventPriority.MONITOR)
public void CatchCommand(PlayerCommandPreprocessEvent event){
String cmd = event.getMessage();
Player p = event.getPlayer();
String pname = p.getName();
for(int x : plugin.Watching.keySet()){
if(plugin.Watching.get(x).contains(p.getName())){
if (handleIngameCommands(p, cmd)==true) event.setCancelled(true);
}
}
if(plugin.getArena(p)!= null){
if (handleIngameCommands(p, cmd)==true) event.setCancelled(true);
}else if(cmd.toLowerCase().trim().equals("/back")){
for(int u : plugin.Dead.keySet()){
if(plugin.Dead.get(u).contains(pname) && plugin.canjoin.get(u))
plugin.Tele.add(p);
}
}
if(cmd.startsWith("/tp") || cmd.startsWith("/telep") || cmd.contains(":tp") || cmd.contains(":telep")){
String[] args = cmd.split(" ");
Player player1 = null;
Player player2 = null;
if(args.length >= 2){
if(Bukkit.getPlayer(args[1]) != null){
player1 = Bukkit.getPlayer(args[1]);
if (args.length >= 3 && Bukkit.getPlayer(args[2]) != null) player2 = Bukkit.getPlayer(args[2]);
if(plugin.isSpectating(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "Invalid command for spectating, using /ha tp " + (player2!=null?player2:player1));
p.performCommand("/ha tp " + (player2!=null?player2:player1));
}else if(plugin.getArena(player1)!=null || (args.length == 2 && plugin.getArena(p)!=null) || (args.length >= 3 && plugin.getArena(player2)!= null)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You can't teleport to other tributes!");
}
}
}
}
}
private boolean handleIngameCommands(Player p, String cmd){
if(!p.hasPermission("HungerArena.UseCommands")){
if(!plugin.management.getStringList("commands.whitelist").isEmpty()){
for(String whitelist: plugin.management.getStringList("commands.whitelist")){
if(cmd.toLowerCase().startsWith(whitelist.toLowerCase())){
return false;
}
}
}
if(!cmd.toLowerCase().startsWith("/ha")){
p.sendMessage(ChatColor.RED + "You are only allowed to perform the following commands:");
for(String whitelistfull: plugin.management.getStringList("commands.whitelist")){
p.sendMessage(ChatColor.AQUA + whitelistfull);
}
p.sendMessage(ChatColor.AQUA + "/ha");
p.sendMessage(ChatColor.AQUA + "/ha close");
p.sendMessage(ChatColor.AQUA + "/ha help");
p.sendMessage(ChatColor.AQUA + "/ha join");
p.sendMessage(ChatColor.AQUA + "/ha kick [Player]");
p.sendMessage(ChatColor.AQUA + "/ha leave");
p.sendMessage(ChatColor.AQUA + "/ha list");
p.sendMessage(ChatColor.AQUA + "/ha open");
p.sendMessage(ChatColor.AQUA + "/ha ready");
p.sendMessage(ChatColor.AQUA + "/ha refill");
p.sendMessage(ChatColor.AQUA + "/ha reload");
p.sendMessage(ChatColor.AQUA + "/ha restart");
p.sendMessage(ChatColor.AQUA + "/ha rlist");
//p.sendMessage(ChatColor.AQUA + "/ha newarena"); //not during game...
p.sendMessage(ChatColor.AQUA + "/ha setspawn");
p.sendMessage(ChatColor.AQUA + "/ha start");
p.sendMessage(ChatColor.AQUA + "/ha tp");
p.sendMessage(ChatColor.AQUA + "/ha watch");
p.sendMessage(ChatColor.AQUA + "/ha warpall");
return true;
}
}else if(!cmd.toLowerCase().startsWith("/ha")){
if(cmd.toLowerCase().startsWith("/spawn") || cmd.toLowerCase().startsWith("/back")){
p.sendMessage("You have perms for all commands except this one!");
return true;
}
}
return false;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,274 +0,0 @@
package me.Travja.HungerArena.Listeners;
import java.util.List;
import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerBucketFillEvent;
import org.bukkit.material.MaterialData;
public class BlockStorage implements Listener {
public Main plugin;
public BlockStorage(Main m) {
this.plugin = m;
}
@EventHandler(priority=EventPriority.MONITOR)
public void BlockBreak(BlockBreakEvent event) {
Block b = event.getBlock();
Player p = event.getPlayer();
String pname = p.getName();
boolean protall = false;
if(!p.hasPermission("HungerArena.arena")){
protall = protall(); //true = protect allways!!
}
if ((plugin.getArena(p) != null) || (protall)) {
//Jeppa: get a default arena if protall is true... (but use getArena if set...)
int a = 1;
if (protall) {
String ThisWorld = p.getWorld().getName();
for(int z : plugin.worldsNames.keySet()){
if(plugin.worldsNames.get(z)!= null){
if (plugin.worldsNames.get(z).equals(ThisWorld)){
a=z;
}
}
}
}
if (plugin.getArena(p) != null) a = plugin.getArena(p);
if ((!event.isCancelled()) && (((plugin.Playing.get(a)).contains(pname)) || (protall)))
{
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"))) {
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "That is an illegal block!");
} else {
String w = b.getWorld().getName();
addDestroyedBlockToList(b, w, a);
}
}
}
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void Explosion(EntityExplodeEvent event){
List<Block> blocksd = event.blockList();
Entity e = event.getEntity();
if(!event.isCancelled()){
for(int i : plugin.canjoin.keySet()){
if(plugin.canjoin.get(i) || protall()){
String ThisWorld = e.getWorld().getName();
if ((!plugin.restricted) || ((plugin.restricted) && plugin.worldsNames.get(i)!=null && plugin.worldsNames.get(i).equalsIgnoreCase(ThisWorld))) {
if(e.getType()== EntityType.PRIMED_TNT){
e.getLocation().getBlock().setType(Material.TNT);
Block TNT = e.getLocation().getBlock();
addDestroyedBlockToList(TNT, ThisWorld, i);
TNT.setType(Material.AIR);
}
for(Block b:blocksd){
if (!b.getType().name().equalsIgnoreCase("AIR")){
addDestroyedBlockToList(b, ThisWorld, i);
}
}
}
}
}
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void burningBlocks(BlockBurnEvent event){
Block b = event.getBlock();
if(!event.isCancelled()){
for(int i : plugin.canjoin.keySet()){
if(plugin.canjoin.get(i) || protall()){
if ((!plugin.restricted) || ((plugin.restricted) && (plugin.worldsNames.get(i)!=null && plugin.worldsNames.get(i).equalsIgnoreCase(b.getWorld().getName())))) {
String w = b.getWorld().getName();
addDestroyedBlockToList(b, w, i);
}
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void blockPlace(BlockPlaceEvent event){
Block b = event.getBlock();
Player p = event.getPlayer();
boolean protall = false;
if(!p.hasPermission("HungerArena.arena")){
protall = protall();
}
if ((plugin.getArena(p) != null) || (protall)) {
int a = 1;
if (protall) {
String ThisWorld = p.getWorld().getName();
for(int z : plugin.worldsNames.keySet()){
if(plugin.worldsNames.get(z)!= null){
if (plugin.worldsNames.get(z).equals(ThisWorld)){
a=z;
}
}
}
}
if (plugin.getArena(p) != null) a = plugin.getArena(p);
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((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){
n = n -1;
event.getPlayer().sendMessage(b.getWorld().getBlockAt(b.getX(), n, b.getZ()).getType().toString().toLowerCase());
if(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){
int l = n +1;
Block br = b.getWorld().getBlockAt(b.getX(), l, b.getZ());
String w = br.getWorld().getName();
addPlacedBlockToList(br, w, a);
}
}
}else{
if(b.getType()!= Material.SAND && b.getType()!= Material.GRAVEL){
String w = b.getWorld().getName();
addPlacedBlockToList(b, w, a);
}
}
}
}
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void bucketEmpty(PlayerBucketEmptyEvent event){
if(plugin.getArena(event.getPlayer())!= null){
int a = plugin.getArena(event.getPlayer());
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())))) {
Block b = event.getBlockClicked().getRelative(event.getBlockFace());
String w = b.getWorld().getName();
addPlacedBlockToList(b, w, a);
}
}
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void bucketFill(PlayerBucketFillEvent event){
if(plugin.getArena(event.getPlayer())!= null){
int a = plugin.getArena(event.getPlayer());
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())))) {
Block b = event.getBlockClicked().getRelative(event.getBlockFace());
String w = b.getWorld().getName();
addDestroyedBlockToList(b, w, a);
}
}
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void blockMelt(BlockFadeEvent event){
if(!event.isCancelled()){
for(int i:plugin.canjoin.keySet()){
if(plugin.canjoin.get(i) || protall()){
if ( (!plugin.restricted) || ((plugin.restricted) && (plugin.worldsNames.get(i)!=null && plugin.worldsNames.get(i).equalsIgnoreCase(event.getBlock().getWorld().getName())))) {
Block b = event.getBlock();
String w = b.getWorld().getName();
String d = b.getType().name();
if (d.equalsIgnoreCase("FIRE") || d.equalsIgnoreCase("AIR")) continue;
addDestroyedBlockToList(b, w, i);
}
}
}
}
}
//SubRoutines:
private boolean protall(){
if (plugin.config.getString("Protected_Arena_Always").equalsIgnoreCase("True")) {
return true;
}
return false;
}
private void addDestroyedBlockToList(Block b, String w, int a){
int x = b.getX();
int y = b.getY();
int z = b.getZ();
String d = b.getType().name();
byte m=0;
String BlDataString=null;
String sp = ";";
String dir="";
try {
if (b.getState().getBlockData() instanceof BlockData){
BlDataString = b.getBlockData().getAsString();
}
} catch (Exception | NoSuchMethodError ex){
m = b.getData();
sp=",";
MaterialData mData = b.getState().getData();
if (mData instanceof org.bukkit.material.Directional) {
BlockFace Dir = ((org.bukkit.material.Directional)mData).getFacing();
if (Dir !=null) {
dir=sp+(Dir.name());
}
}
}
String data = BlDataString!=null?BlDataString:String.valueOf(m);
String coords = w + sp + x + sp + y + sp + z + sp + d + sp + data + sp + a + dir;
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
if (!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + a)) {
blocks.add(coords);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveData();
}
}
private void addPlacedBlockToList(Block br, String w, int a){
int x = br.getX();
int y = br.getY();
int z = br.getZ();
String coords = w + "," + x + "," + y + "," + z + "," + a;
List<String> blocks = plugin.data.getStringList("Blocks_Placed");
if (!blocks.contains(coords)){
blocks.add(coords);
plugin.data.set("Blocks_Placed", blocks);
plugin.saveData();
}
}
}

View File

@ -1,78 +0,0 @@
package me.Travja.HungerArena.Listeners;
import java.util.Map;
import java.util.Map.Entry;
import me.Travja.HungerArena.Main;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerMoveEvent;
public class Boundaries implements Listener{
public Main plugin;
public Boundaries(Main m){
this.plugin = m;
}
@EventHandler
public void boundsCheck(PlayerMoveEvent event){
Player p = event.getPlayer();
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);
}
@EventHandler
public void blockBounds(BlockBreakEvent event){
Player p = event.getPlayer();
if(plugin.getArena(p)== null)
if(plugin.config.getBoolean("WorldEdit"))
if(insideBounds(event.getBlock().getLocation())){
p.sendMessage(ChatColor.RED + "That block is protected by HungerArena!");
event.setCancelled(true);
}
}
public boolean insideBounds(Location l){
Location minl = null;
Location maxl = null;
if(plugin.spawns.get("Arena")!= null){
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(",");
try{
World world = Bukkit.getWorld(min[0]);
double x = Double.parseDouble(min[1]);
double y = Double.parseDouble(min[2]);
double z = Double.parseDouble(min[3]);
minl = new Location(world, x, y, z);
World world2 = Bukkit.getWorld(max[0]);
double x2 = Double.parseDouble(max[1]);
double y2 = Double.parseDouble(max[2]);
double z2 = Double.parseDouble(max[3]);
minl = new Location(world2, x2, y2, z2);
}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;
}
}
}
}
return false;
}
}

View File

@ -1,52 +0,0 @@
package me.Travja.HungerArena.Listeners;
import java.util.List;
import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
public class ChatListener implements Listener {
public Main plugin;
public ChatListener(Main m) {
this.plugin = m;
}
@EventHandler
public void TributeChat(AsyncPlayerChatEvent event){
Player p = event.getPlayer();
String pname = p.getName();
if(plugin.getArena(p)!= null){
String msg = "<" + ChatColor.RED + "[Tribute] " + ChatColor.WHITE + pname + ">" + " " + event.getMessage();
if(plugin.config.getString("ChatClose").equalsIgnoreCase("True")){
double radius = plugin.config.getDouble("ChatClose_Radius");
List<Entity> near = p.getNearbyEntities(radius, radius, radius);
event.setCancelled(true);
if(!(near.size()== 0)){
p.sendMessage(msg);
for(Entity e:near){
if(e instanceof Player)
((Player) e).sendMessage(msg);
}
}else if(near.size()== 0){
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);
plugin.getServer().broadcastMessage(msg);
}
}
}
}

View File

@ -1,207 +0,0 @@
package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
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;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.scoreboard.DisplaySlot;
public class DeathListener implements Listener{
public Main plugin;
public DeathListener(Main m){
this.plugin = m;
}
public FileConfiguration config;
int i = 0;
int a = 0;
@EventHandler (priority = EventPriority.HIGHEST)
public void onPlayerRespawn(PlayerRespawnEvent event){
final Player p = event.getPlayer();
String pname = p.getName();
//get the arena the player has died in... (may be not the one he joined...)
String ThisWorld = p.getWorld().getName();
for(int z : plugin.worldsNames.keySet()){
if(plugin.worldsNames.get(z)!= null){
if (plugin.worldsNames.get(z).equals(ThisWorld)){
a=z;
}
}
}
//Jeppa: Fix for lonely players :)
for(int i : plugin.Dead.keySet()){
if ((plugin.Dead.get(i) != null) && (plugin.Dead.get(i).contains(pname)) && (plugin.MatchRunning.get(i) == null)) {
plugin.Dead.get(i).clear();
}
}
for(int i = 0; i < plugin.needInv.size(); i++){
if(plugin.needInv.contains(pname)){
RespawnDeadPlayer(p,a);
}
}
}
private void RespawnDeadPlayer(Player p, int a){
final Player player = p;
String[] Spawncoords = plugin.spawns.getString("Spawn_coords."+a).split(",");
World spawnw = plugin.getServer().getWorld(Spawncoords[3]);
double spawnx = Double.parseDouble(Spawncoords[0]);
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());
}
}, 10L);
}
@EventHandler (priority = EventPriority.HIGHEST)
public void onPlayerDeath(PlayerDeathEvent event){
Player p = event.getEntity();
Server s = p.getServer();
String pname = p.getName();
if(plugin.getArena(p)!= null){
a = plugin.getArena(p);
int players = plugin.Playing.get(a).size()-1;
String leftmsg = null;
clearInv(p);
event.getDrops().clear();
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
plugin.scoreboards.remove(p.getName());
if(!plugin.Frozen.get(a).isEmpty()){
if(plugin.Frozen.get(a).contains(pname)){
if(!(p.getKiller() instanceof Player)){
players = plugin.Playing.get(a).size()-1;
leftmsg = ChatColor.BLUE + "There are now " + players + " tributes left!";
if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){
double y = p.getLocation().getY();
double newy = y+200;
double x = p.getLocation().getX();
double z = p.getLocation().getZ();
Location strike = new Location(p.getWorld(), x, newy, z);
p.getWorld().strikeLightning(strike);
}
event.setDeathMessage("");
if(plugin.config.getBoolean("broadcastAll")){
p.getServer().broadcastMessage(pname + ChatColor.LIGHT_PURPLE + " Stepped off their pedestal too early!");
}else{
for(String gn: plugin.Playing.get(a)){
Player g = plugin.getServer().getPlayer(gn);
g.sendMessage(pname + ChatColor.LIGHT_PURPLE + " Stepped off their pedestal too early!");
}
}
plugin.Frozen.get(a).remove(pname);
plugin.Playing.get(a).remove(pname);
if(plugin.config.getBoolean("broadcastAll")){
p.getServer().broadcastMessage(leftmsg);
}else{
for(String gn: plugin.Playing.get(a)){
Player g = plugin.getServer().getPlayer(gn);
g.sendMessage(leftmsg);
}
}
plugin.winner(a);
}
}
}else{
players = plugin.Playing.get(a).size()-1;
leftmsg = ChatColor.BLUE + "There are now " + players + " tributes left!";
if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){
double y = p.getLocation().getY();
double newy = y+200;
double x = p.getLocation().getX();
double z = p.getLocation().getZ();
Location strike = new Location(p.getWorld(), x, newy, z);
p.getWorld().strikeLightning(strike);
}
plugin.Dead.get(a).add(pname);
plugin.Playing.get(a).remove(pname);
if(p.getKiller() instanceof Player){
if(p.getKiller().getInventory().getItemInMainHand().getType()== Material.AIR){
Player killer = p.getKiller();
String killername = killer.getName();
event.setDeathMessage("");
if(plugin.config.getBoolean("broadcastAll")){
s.broadcastMessage(ChatColor.LIGHT_PURPLE + "**BOOM** Tribute " + pname + " was killed by tribute " + killername + " with their FIST!");
s.broadcastMessage(leftmsg);
}else{
for(String gn: plugin.Playing.get(a)){
Player g = plugin.getServer().getPlayer(gn);
g.sendMessage(ChatColor.LIGHT_PURPLE + "**BOOM** Tribute " + pname + " was killed by tribute " + killername + " with their FIST!");
g.sendMessage(leftmsg);
}
}
if(plugin.Kills.containsKey(killername))
plugin.Kills.put(killername, plugin.Kills.get(killername)+1);
else plugin.Kills.put(killername, 1);
if(plugin.Kills.containsKey("__SuM__"))
plugin.Kills.put("__SuM__", plugin.Kills.get("__SuM__")+1);
else plugin.Kills.put("__SuM__", 1);
plugin.winner(a);
}else{
Player killer = p.getKiller();
String killername = killer.getName();
String weapon = "a(n) " + killer.getInventory().getItemInMainHand().getType().name().replace('_', ' ');
if(killer.getInventory().getItemInMainHand().hasItemMeta())
if(killer.getInventory().getItemInMainHand().getItemMeta().hasDisplayName())
weapon = killer.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
String msg = ChatColor.LIGHT_PURPLE + "**BOOM** Tribute " + pname + " was killed by tribute " + killername + " with " + weapon;
event.setDeathMessage("");
if(plugin.config.getBoolean("broadcastAll")){
s.broadcastMessage(msg);
s.broadcastMessage(leftmsg);
}else{
for(String gn: plugin.Playing.get(a)){
Player g = plugin.getServer().getPlayer(gn);
g.sendMessage(msg);
g.sendMessage(leftmsg);
}
}
if(plugin.Kills.containsKey(killername))
plugin.Kills.put(killername, plugin.Kills.get(killername)+1);
else plugin.Kills.put(killername, 1);
if(plugin.Kills.containsKey("__SuM__"))
plugin.Kills.put("__SuM__", plugin.Kills.get("__SuM__")+1);
else plugin.Kills.put("__SuM__", 1);
plugin.winner(a);
}
}else{
event.setDeathMessage("");
if(plugin.config.getBoolean("broadcastAll")){
s.broadcastMessage(ChatColor.LIGHT_PURPLE + pname + " died of natural causes!");
s.broadcastMessage(leftmsg);
}else{
for(String gn: plugin.Playing.get(a)){
Player g = plugin.getServer().getPlayer(gn);
g.sendMessage(ChatColor.LIGHT_PURPLE + pname + " died of " + ChatColor.ITALIC + " probably " + ChatColor.LIGHT_PURPLE + "natural causes!");
g.sendMessage(leftmsg);
}
}
plugin.winner(a);
}
}
}
}
private void clearInv(Player p){
p.getInventory().clear();
p.getInventory().setBoots(null);
p.getInventory().setChestplate(null);
p.getInventory().setHelmet(null);
p.getInventory().setLeggings(null);
p.updateInventory();
}
}

View File

@ -1,121 +0,0 @@
package me.Travja.HungerArena.Listeners;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.metadata.MetadataValue;
public class FreezeListener implements Listener {
public Main plugin;
public FreezeListener(Main m) {
this.plugin = m;
}
int i = 0;
int a = 0;
private HashMap<Integer, Boolean> timeUp= new HashMap<Integer, Boolean>();
private ArrayList<Integer> timing = new ArrayList<Integer>();
@EventHandler
public void onPlayerMove(PlayerMoveEvent event){
Player p = event.getPlayer();
String pname = p.getName();
if(plugin.getArena(p)!= null){
a = plugin.getArena(p);
if(plugin.Frozen.get(a).contains(pname) && plugin.config.getString("Frozen_Teleport").equalsIgnoreCase("True")){
if(plugin.config.getString("Explode_on_Move").equalsIgnoreCase("true")){
timeUp.put(a, false);
for(String players: plugin.Playing.get(a)){
Player playing = plugin.getServer().getPlayerExact(players);
i = plugin.Playing.get(a).indexOf(players)+1;
if(!timeUp.get(a) && !timing.contains(a)){
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);
}
}
},30L);
}
}else{
if(!playing.getLocation().getBlock().getLocation().equals(plugin.location.get(a).get(i).getBlock().getLocation())){
if(!plugin.Dead.get(a).contains(playing.getName())){
plugin.Dead.get(a).add(playing.getName());
World world = playing.getLocation().getWorld();
world.createExplosion(playing.getLocation(), 0.0F, false);
playing.setHealth(0.0D);
}
}
}
}
if(plugin.Dead.get(a).contains(pname) && plugin.Playing.get(a).contains(pname)){
int players = plugin.Playing.get(a).size()-1;
String leftmsg = ChatColor.BLUE + "There are now " + players + " tributes left!";
if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){
double y = p.getLocation().getY();
double newy = y+200;
double x = p.getLocation().getX();
double z = p.getLocation().getZ();
Location strike = new Location(p.getWorld(), x, newy, z);
p.getWorld().strikeLightning(strike);
}
if(plugin.config.getBoolean("broadcastAll")){
p.getServer().broadcastMessage(pname + ChatColor.LIGHT_PURPLE + " Stepped off their pedestal too early!");
}else{
for(String gn: plugin.Playing.get(a)){
Player g = plugin.getServer().getPlayer(gn);
g.sendMessage(pname + ChatColor.LIGHT_PURPLE + " Stepped off their pedestal too early!");
}
}
plugin.Frozen.get(a).remove(pname);
plugin.Playing.get(a).remove(pname);
if(plugin.config.getBoolean("broadcastAll")){
p.getServer().broadcastMessage(leftmsg);
}else{
for(String gn: plugin.Playing.get(a)){
Player g = plugin.getServer().getPlayer(gn);
g.sendMessage(leftmsg);
}
}
plugin.winner(a);
}
}else{
i = plugin.Playing.get(a).indexOf(pname)+1;
Location pLoc=null;
if (p.hasMetadata("HA-Location")){
List<MetadataValue> l=p.getMetadata("HA-Location");
if (l !=null && l.size()!=0 ){
try {
pLoc=(Location) l.get(0).value();
} catch (Exception e){}
}
if (pLoc!=null) {
if(p.getLocation().getBlockX()!=(pLoc.getBlockX()) || p.getLocation().getBlockZ()!=(pLoc.getBlockZ())){
pLoc.setX(pLoc.getBlock().getLocation().getX()+.5);
pLoc.setZ(pLoc.getBlock().getLocation().getZ()+.5);
p.teleport(pLoc);
}
} else {
if(!p.getLocation().getBlock().getLocation().equals(plugin.location.get(a).get(i).getBlock().getLocation())){
p.teleport(plugin.location.get(a).get(i));
}
}
}
}
}
}
}
}

View File

@ -1,188 +0,0 @@
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;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scoreboard.DisplaySlot;
public class JoinAndQuitListener implements Listener {
public Main plugin;
public JoinAndQuitListener(Main m) {
this.plugin = m;
}
public HaCommands commands;
public JoinAndQuitListener(HaCommands h){
this.commands = h;
}
int a = 0;
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event){
final Player p = event.getPlayer();
final String pname = p.getName();
boolean pfound = false;
for(int i : plugin.Watching.keySet()){
for(String s: plugin.Watching.get(i)){
Player spectator = plugin.getServer().getPlayerExact(s);
p.hidePlayer(plugin,spectator);
}
}
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.Out.get(i).remove(pname);
pfound = true;
}
}
for(final int i : plugin.Quit.keySet()){
if(plugin.Quit.get(i).contains(pname)){
String[] Spawncoords = plugin.spawns.getString("Spawn_coords."+i).split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
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());
}
}, 40L);
pfound = true;
}
}
for(final int i : plugin.Dead.keySet()){
if(plugin.Dead.get(i).contains(pname)){
String[] Spawncoords = plugin.spawns.getString("Spawn_coords."+i).split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
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());
}
}, 40L);
pfound = true;
}
}
for(final int i : plugin.inArena.keySet()){
if(plugin.inArena.get(i)!= null){
if(plugin.inArena.get(i).contains(pname)){
String[] Spawncoords = plugin.spawns.getString("Spawn_coords."+i).split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
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());
}
}, 40L);
pfound = true;
}
}
}
if((plugin.restricted && plugin.worldsNames.values().contains(p.getWorld().getName())) || !plugin.restricted){
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];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
double spawny = Double.parseDouble(Spawncoords[1]);
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!!");
}
}, 40L);
}
}
}
@EventHandler
public void onQuit(PlayerQuitEvent evt) {
Player p = evt.getPlayer();
String pname = p.getName();
for(int i : plugin.Frozen.keySet()){
if (plugin.Frozen.get(i).contains(pname)) {
plugin.Frozen.remove(pname);
String[] Spawncoords = plugin.spawns.getString("Spawn_coords.0").split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]);
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());
}
}
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event){
final Player p = event.getPlayer();
final String pname = 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);
}
}
}, 1200L);
}
}
}

View File

@ -1,97 +0,0 @@
package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.Skeleton;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
public class PvP implements Listener {
public Main plugin;
public PvP(Main m) {
this.plugin = m;
}
int a = 0;
@EventHandler(priority= EventPriority.MONITOR)
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(plugin.getArena(p)!= null && plugin.getArena(d)!= null){
a = plugin.getArena(p);
if(plugin.canjoin.get(a)){
if(event.isCancelled()){
event.setCancelled(false);
}
if(plugin.gp.get(plugin.getArena(p))!= null){
if(plugin.gp.get(plugin.getArena(p))!= 0){
event.setCancelled(true);
}
}
}
}
if(plugin.getArena(p)!= null){
a = plugin.getArena(p);
if(!plugin.canjoin.get(a)){
if(!event.isCancelled()){
event.setCancelled(true);
}
}
}
if(plugin.getArena(p)== null && plugin.getArena(d)!= null){
if(!event.isCancelled()){
event.setCancelled(true);
}
}
}else if(pl instanceof Player && dl instanceof Projectile){
Projectile projectile = (Projectile) dl;
Player p = (Player) pl;
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);
}
}
}else if(projectile.getShooter() instanceof Entity){
Entity e = (Entity) projectile.getShooter();
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);
}
}
}
}
}
@EventHandler
public void PlayerDamage(EntityDamageEvent event){
Entity e = event.getEntity();
if(e instanceof Player) {
Player p = (Player)e;
if(plugin.getArena(p)!=null){
a = plugin.getArena(p);
if(plugin.gp.get(a)!= null && plugin.gp.get(a)!= 0)
event.setCancelled(true);
if (plugin.Frozen.get(a)!=null && plugin.Frozen.get(a).contains(p.getName())){
event.setCancelled(true);
}
}
}
}
}

View File

@ -1,87 +0,0 @@
package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor;
import org.bukkit.Tag;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
public class SignsAndBeds implements Listener {
public Main plugin;
public SignsAndBeds(Main m) {
this.plugin = m;
}
@EventHandler
public void Sign(PlayerInteractEvent event){
Player p = event.getPlayer();
Block b = event.getClickedBlock();
if (b == null) {
return;
}
if(event.getAction()== Action.RIGHT_CLICK_BLOCK){
//2019 1.14 Translate Materials:
boolean foundSign=false;
try {
if (b.getState() instanceof org.bukkit.block.Sign){
foundSign=true;
}
} catch (Exception e){
if (!foundSign) {
foundSign = Tag.SIGNS.isTagged(b.getType());
}
}
if (foundSign) {
org.bukkit.block.Sign sign = (org.bukkit.block.Sign) b.getState();
String line1 = sign.getLine(0);
String line2 = sign.getLine(1);
String line3 = sign.getLine(2);
String line4 = sign.getLine(3);
if(line1.trim().equalsIgnoreCase(ChatColor.BLUE + "[HungerArena]") || line1.trim().equalsIgnoreCase(ChatColor.BLUE + "[HA]")){
if(!line2.equals("") && line3.equals(""))
p.performCommand("ha " + line2);
else if(line2.equals("") && !line3.equals(""))
p.performCommand("ha " + line3);
else if(!line2.equals("") && !line3.equals("")) {
String commands = "close,join,kick,leave,list,open,ready,refill,reload,restart,rlist,tp,start,watch,warpall";
if (commands.contains(line3.trim().toLowerCase())) {
p.performCommand("ha " + line2);
p.performCommand("ha " + line3);
} else p.performCommand("ha " + line2 + " " + line3);
}
else
p.performCommand("ha");
}
if(line1.trim().equalsIgnoreCase(ChatColor.BLUE + "[Sponsor]")){
p.performCommand("sponsor " + line2 + " " + line3 + " " + line4);
}
}
if (plugin.config.getString("DenyBedUsage").equalsIgnoreCase("True")){
boolean foundBed=false;
try {
if (b.getState() instanceof org.bukkit.block.Bed) {
foundBed=true;
}
} catch (Exception e){
if (!foundBed) foundBed = Tag.BEDS.isTagged(b.getType());
}
if (foundBed) {
event.setCancelled(true);
}
}
}
}
@EventHandler
public void Create(SignChangeEvent event){
String top = event.getLine(0);
if(top.equalsIgnoreCase("[HungerArena]") || top.equalsIgnoreCase("[HA]") || top.equalsIgnoreCase("[Sponsor]")){
event.setLine(0, ChatColor.BLUE + top);
}
}
}

View File

@ -1,67 +0,0 @@
package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
public class SignsAndBedsOld implements Listener {
public Main plugin;
public SignsAndBedsOld(Main m) {
this.plugin = m;
}
@SuppressWarnings("deprecation")
@EventHandler
public void Sign(PlayerInteractEvent event){
Player p = event.getPlayer();
Block b = event.getClickedBlock();
if (b == null) {
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();
String line1 = sign.getLine(0);
String line2 = sign.getLine(1);
String line3 = sign.getLine(2);
String line4 = sign.getLine(3);
if(line1.trim().equalsIgnoreCase(ChatColor.BLUE + "[HungerArena]") || line1.trim().equalsIgnoreCase(ChatColor.BLUE + "[HA]")){
if(!line2.equals("") && line3.equals(""))
p.performCommand("ha " + line2);
else if(line2.equals("") && !line3.equals(""))
p.performCommand("ha " + line3);
else if(!line2.equals("") && !line3.equals("")) {
String commands = "close,join,kick,leave,list,open,ready,refill,reload,restart,rlist,tp,start,watch,warpall";
if (commands.contains(line3.trim().toLowerCase())) {
p.performCommand("ha " + line2);
p.performCommand("ha " + line3);
} else p.performCommand("ha " + line2 + " " + line3);
}
else
p.performCommand("ha");
}
if(line1.trim().equalsIgnoreCase(ChatColor.BLUE + "[Sponsor]")){
p.performCommand("sponsor " + line2 + " " + line3 + " " + line4);
}
}
if (plugin.config.getString("DenyBedUsage").trim().equalsIgnoreCase("true")){
if (b.getState().getData() instanceof org.bukkit.material.Bed) {
event.setCancelled(true);
}
}
}
}
@EventHandler
public void Create(SignChangeEvent event){
String top = event.getLine(0);
if(top.equalsIgnoreCase("[HungerArena]") || top.equalsIgnoreCase("[HA]") || top.equalsIgnoreCase("[Sponsor]")){
event.setLine(0, ChatColor.BLUE + top);
}
}
}

View File

@ -1,183 +0,0 @@
package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.*;
import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.scoreboard.DisplaySlot;
public class SpectatorListener implements Listener {
public Main plugin;
public SpectatorListener(Main m){
this.plugin = m;
}
int i = 0;
@EventHandler
public void SpectatorDrops(PlayerDropItemEvent event){
Player p = event.getPlayer();
if (denyInteraction(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorInteractBlock(PlayerInteractEvent event){
Player p = event.getPlayer();
if (denyInteraction(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorInteractEntity(PlayerInteractEntityEvent event){
Player p = event.getPlayer();
if (denyInteraction(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorItems(EntityPickupItemEvent event){
if (event.getEntity() instanceof Player) {
Player p = (Player)event.getEntity();
if (denyInteraction(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
}
@EventHandler
public void SpectatorPvP(EntityDamageByEntityEvent event){
Entity offense = event.getDamager();
if(offense instanceof Player){
Player Attacker = (Player) event.getDamager();
String attackerName = Attacker.getName();
for(int i : plugin.Watching.keySet()){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(attackerName)){
event.setCancelled(true);
Attacker.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
return;
}
}
}
for(int i : plugin.Playing.keySet()){
if(plugin.Playing.get(i)!= null){
if(plugin.Playing.get(i).contains(attackerName)){
event.setCancelled(true);
}
}
}
}else if(event.getDamager() instanceof Projectile){
Projectile arrow = (Projectile) offense;
ProjectileSource shooter = arrow.getShooter();
if(shooter instanceof Player){
Player BowMan = (Player) shooter;
String bowManName = BowMan.getName();
for(int i : plugin.Watching.keySet()){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(bowManName)){
event.setCancelled(true);
BowMan.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
return;
}
}
}
for(int i : plugin.Playing.keySet()){
if(plugin.Playing.get(i)!= null){
if(plugin.Playing.get(i).contains(bowManName)){
event.setCancelled(true);
}
}
}
}
}
}
@EventHandler
public void SpectatorBlockBreak(BlockBreakEvent event){
Player p = event.getPlayer();
if (denyInteraction(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorBlockPlace(BlockPlaceEvent event){
Player p = event.getPlayer();
if (denyInteraction(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorQuit(PlayerQuitEvent event){
Player p = event.getPlayer();
String pname = p.getName();
for(int i : plugin.Watching.keySet()){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(pname)){
plugin.Watching.get(i).remove(pname);
String[] Spawncoords = plugin.spawns.getString("Spawn_coords.0").split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]);
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());
}
}
}
}
@EventHandler
public void MobNerf(EntityTargetEvent event){
Entity target = event.getTarget();
Entity e = event.getEntity();
if (e instanceof Player) {
return;
}
if(target instanceof Player){
String targetName = ((Player) target).getName();
for(int i : plugin.Watching.keySet()){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(targetName)){
event.setTarget(null);
}
}
}
}
}
private boolean denyInteraction(Player p){
String pname = p.getName();
for(int i : plugin.Watching.keySet()){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(pname)){
return true;
}
}
}
return false;
}
}

View File

@ -1,182 +0,0 @@
package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
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.projectiles.ProjectileSource;
import org.bukkit.scoreboard.DisplaySlot;
public class SpectatorListenerOld implements Listener {
public Main plugin;
public SpectatorListenerOld(Main m){
this.plugin = m;
}
int i = 0;
@EventHandler
public void SpectatorDrops(PlayerDropItemEvent event){
Player p = event.getPlayer();
if (denyInteraction(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorInteractBlock(PlayerInteractEvent event){
Player p = event.getPlayer();
if (denyInteraction(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorInteractEntity(PlayerInteractEntityEvent event){
Player p = event.getPlayer();
if (denyInteraction(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@SuppressWarnings("deprecation")
@EventHandler
public void SpectatorItems(PlayerPickupItemEvent event){
Player p = event.getPlayer();
if (denyInteraction(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
private boolean denyInteraction(Player p){
String pname = p.getName();
for(int i : plugin.Watching.keySet()){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(pname)){
return true;
}
}
}
return false;
}
@EventHandler
public void SpectatorPvP(EntityDamageByEntityEvent event){
Entity offense = event.getDamager();
if(offense instanceof Player){
Player Attacker = (Player) event.getDamager();
String attackerName = Attacker.getName();
for(int i : plugin.Watching.keySet()){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(attackerName)){
event.setCancelled(true);
Attacker.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
return;
}
}
}
for(int i : plugin.Playing.keySet()){
if(plugin.Playing.get(i)!= null){
if(plugin.Playing.get(i).contains(attackerName)){
event.setCancelled(true);
}
}
}
}else if(event.getDamager() instanceof Projectile){
Projectile arrow = (Projectile) offense;
ProjectileSource shooter = arrow.getShooter();
if(shooter instanceof Player){
Player BowMan = (Player) shooter;
String bowManName = BowMan.getName();
for(int i : plugin.Watching.keySet()){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(bowManName)){
event.setCancelled(true);
BowMan.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
return;
}
}
}
for(int i : plugin.Playing.keySet()){
if(plugin.Playing.get(i)!= null){
if(plugin.Playing.get(i).contains(bowManName)){
event.setCancelled(true);
}
}
}
}
}
}
@EventHandler
public void SpectatorBlockBreak(BlockBreakEvent event){
Player p = event.getPlayer();
if (denyInteraction(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorBlockPlace(BlockPlaceEvent event){
Player p = event.getPlayer();
if (denyInteraction(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorQuit(PlayerQuitEvent event){
Player p = event.getPlayer();
String pname = p.getName();
for(int i : plugin.Watching.keySet()){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(pname)){
plugin.Watching.get(i).remove(pname);
String[] Spawncoords = plugin.spawns.getString("Spawn_coords.0").split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]);
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());
}
}
}
}
@EventHandler
public void MobNerf(EntityTargetEvent event){
Entity target = event.getTarget();
Entity e = event.getEntity();
if (e instanceof Player) {
return;
}
if(target instanceof Player){
String targetName = ((Player) target).getName();
for(int i : plugin.Watching.keySet()){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(targetName)){
event.setTarget(null);
}
}
}
}
}
}

View File

@ -1,32 +0,0 @@
package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerTeleportEvent;
public class TeleportListener implements Listener {
public Main plugin;
public TeleportListener(Main m) {
this.plugin = m;
}
@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)){
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);
}else if(plugin.Tele.contains(p)){
if(event.isCancelled()){
event.setCancelled(false);
plugin.Tele.remove(p);
}
}
}
}

View File

@ -1,58 +0,0 @@
package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChangedWorldEvent;
public class WorldChange implements Listener {
public Main plugin;
public WorldChange(Main m) {
plugin = m;
}
@EventHandler(priority = EventPriority.LOWEST)
public void worldChangeLow(PlayerChangedWorldEvent event){
Player p = event.getPlayer();
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)) {
plugin.RestoreInv(p, pname);
}
}
@EventHandler(priority = EventPriority.HIGH)
public void worldChangeHigh(PlayerChangedWorldEvent event){
Player p = event.getPlayer();
String pname = p.getName();
String ThisWorld = p.getWorld().getName();
int a=0;
for(int i : plugin.worldsNames.keySet()){
if(plugin.worldsNames.get(i)!= null){
if (plugin.worldsNames.get(i).equals(ThisWorld)){
a=i;
if(plugin.Frozen.get(a)!=null && plugin.Frozen.get(a).contains(pname)){
return;
}else{
plugin.RestoreInv(p, pname);
if (plugin.config.getString("joinTeleport").equalsIgnoreCase("true")) {
String[] Spawncoords = plugin.spawns.getString("Spawn_coords."+a).split(",");
double spawnx = Double.parseDouble(Spawncoords[0]);
double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]);
Location Spawn = new Location(p.getWorld(), spawnx, spawny, spawnz);
if (!p.getLocation().getBlock().equals(Spawn.getBlock())){
p.teleport(Spawn);
}
}
}
}
}
}
}
}

View File

@ -1,61 +0,0 @@
package me.Travja.HungerArena.Listeners;
import java.util.Collection;
import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
public class spawnsListener implements Listener{
public Main plugin;
public spawnsListener(Main m){
this.plugin = m;
}
@EventHandler
public void interact(PlayerInteractEvent event){
Player p = event.getPlayer();
if(plugin.setting.containsKey(p.getName())){
if(event.getAction()==Action.RIGHT_CLICK_BLOCK){
Location l = event.getClickedBlock().getLocation();
String HandItem;
try {
HandItem=p.getInventory().getItemInMainHand().getType().name();
} catch (Exception e){
HandItem=p.getItemInHand().getType().name();
}
if(HandItem == 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);
int arena = Integer.parseInt(info[0]);
if (plugin.spawns.get("Spawns." + arena) != null){
Collection<Object> temp = plugin.spawns.getConfigurationSection("Spawns."+arena).getValues(false).values();
if (temp.contains(coords.trim().replace(' ', ','))){
event.setCancelled(true);
return;
}
}
p.performCommand("startpoint " + info[0] + " " + info[1] + " " + coords);
if(Integer.parseInt(info[1])>= plugin.config.getInt("maxPlayers")){
p.sendMessage(ChatColor.DARK_AQUA + "[HungerArena] " + ChatColor.RED + "All spawns set!");
plugin.setting.remove(p.getName());
}else{
plugin.setting.put(p.getName(), info[0] + "-" + (Integer.parseInt(info[1])+1));
p.sendMessage(ChatColor.DARK_AQUA + "[HungerArena] " + ChatColor.RED + "Next starting point: " + (Integer.parseInt(info[1])+1));
}
}
}
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,178 +0,0 @@
package me.Travja.HungerArena;
import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class SpawnsCommand implements CommandExecutor {
public Main plugin;
int i = 0;
int a = 0;
boolean NoPlayerSpawns;
public SpawnsCommand(Main m) {
this.plugin = m;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
Player p = (Player) sender;
String ThisWorld = p.getWorld().getName();
NoPlayerSpawns = true;
for(int i : plugin.worldsNames.keySet()){
if(plugin.worldsNames.get(i)!= null){
if (plugin.worldsNames.get(i).equals(ThisWorld)){
a=i;
NoPlayerSpawns = false;
break;
}
}
}
if(cmd.getName().equalsIgnoreCase("StartPoint")){
if(p.hasPermission("HungerArena.StartPoint")){
Location loc = null;
double x;
double y;
double z;
if(args.length == 6){
try{
i = Integer.valueOf(args[1]);
a = Integer.valueOf(args[0]);
}catch(Exception e){
p.sendMessage(ChatColor.RED + "Argument not an integer!");
return true;
}
String world = args[2];
x = Double.parseDouble(args[3]);
y = Double.parseDouble(args[4]);
z = Double.parseDouble(args[5]);
loc = new Location(Bukkit.getWorld(world), x, y, z);
if(plugin.location.get(a)!= null){
plugin.location.get(a).put(i, loc);
}else{
plugin.location.put(a, new HashMap<Integer, Location>());
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.canjoin.put(a, false);
plugin.MatchRunning.put(a, null);
plugin.open.put(a, true);
}
String coords = loc.getWorld().getName() + "," + (loc.getX()) + "," + loc.getY() + "," + (loc.getZ());
p.sendMessage(coords);
plugin.spawns.set("Spawns." + a + "." + i, coords);
plugin.worldsNames.put(a, loc.getWorld().getName());
plugin.saveSpawns();
plugin.maxPlayers.put(a, plugin.location.get(a).size());
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute " + i + " in arena " + a + "!");
this.plugin.reloadSpawnpoints(false);
return true;
}
if(args.length>= 2){
try{
i = Integer.valueOf(args[1]);
a = Integer.valueOf(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())){
p.sendMessage(ChatColor.GOLD + "You've added this world to the config ...");
}
loc = p.getLocation().getBlock().getLocation();
x = loc.getX()+.5;
y = loc.getY();
z = loc.getZ()+.5;
loc = new Location(loc.getWorld(), x, y, z);
if(plugin.location.get(a)!= null){
plugin.location.get(a).put(i, loc);
}else{
plugin.location.put(a, new HashMap<Integer, Location>());
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.canjoin.put(a, false);
plugin.MatchRunning.put(a, null);
plugin.open.put(a, true);
}
String coords = loc.getWorld().getName() + "," + (loc.getX()) + "," + loc.getY() + "," + (loc.getZ());
p.sendMessage(coords);
plugin.spawns.set("Spawns." + a + "." + i, coords);
plugin.worldsNames.put(a, loc.getWorld().getName());
plugin.saveSpawns();
plugin.maxPlayers.put(a, plugin.location.get(a).size());
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute " + i + " in arena " + a + "!");
this.plugin.reloadSpawnpoints(false);
}else{
p.sendMessage(ChatColor.RED + "You can't go past " + plugin.config.getInt("maxPlayers") + " players!");
}
}else if(args.length == 1){
if (sender instanceof Player){
p = (Player) sender;
if(NoPlayerSpawns){
try{
a = Integer.parseInt(args[0]);
}catch(Exception e){
p.sendMessage(ChatColor.RED + "Argument not an integer!");
return true;
}
}
if (plugin.spawns.get("Spawns." + a) != null){
int start = 1;
while(start<plugin.config.getInt("maxPlayers")+2){
if (plugin.spawns.get("Spawns." + a + "." + start) != null){
start = start+1;
if(start== plugin.config.getInt("maxPlayers")+1){
p.sendMessage(ChatColor.DARK_AQUA + "[HungerArena] " + ChatColor.GREEN + "All spawns set, type /startpoint [Arena #] [Spawn #] to over-ride previous points!");
return true;
}
}else{
int sloc = start;
start = plugin.config.getInt("maxPlayers")+1;
p.sendMessage(ChatColor.DARK_AQUA + "[HungerArena] " + ChatColor.RED + "Begin Setting For Arena " + a + " Starting From Point " + sloc);
plugin.setting.put(p.getName(), a + "-" + sloc);
return true;
}
}
}
p.sendMessage(ChatColor.DARK_AQUA + "[HungerArena] " + ChatColor.RED + "Begin Setting For Arena " + a + " Starting From Point " + 1);
plugin.setting.put(p.getName(), a + "-" + 1);
return true;
}else{
sender.sendMessage(ChatColor.BLUE + "This Can Only Be Sent As A Player");
}
} else {
p.sendMessage(ChatColor.RED + "No argument given! \nUse command like this:\n/startpoint [Arena #] [Startpoint #] for setting your position as a startpoint.\n/startpoint [Arena #] [Startpoint #] [Mapname] [x] [y] [z] \nOr you can use /startpoint [Arena #] to use the 'spawntool': ID"+ plugin.config.getInt("spawnsTool") +" for setting the startpoints!");
return false;
}
}else{
p.sendMessage(ChatColor.RED + "You don't have permission!");
}
}
return false;
}
}

View File

@ -1,148 +0,0 @@
package me.Travja.HungerArena;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class SponsorCommands implements CommandExecutor {
public Main plugin;
public SponsorCommands(Main m) {
this.plugin = m;
}
@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(p.hasPermission("HungerArena.Sponsor")){
if(plugin.getArena(p)== null){
if(args.length== 0){
p.sendMessage(ChatColor.RED + "You didn't specify a tribute!");
return false;
}
if(args.length== 1){
p.sendMessage(ChatColor.RED + "You didn't specify an item!");
}
if(args.length== 2){
p.sendMessage(ChatColor.RED + "You didn't specify an amount!");
}
if(args.length>= 3){
Player target = Bukkit.getServer().getPlayer(args[0]);
if(target==null || (target!=null && plugin.getArena(target)== null)){
p.sendMessage(ChatColor.RED + "That person isn't playing!");
}else{
try{
String ID = args[1].toUpperCase().trim();
int amount = Integer.parseInt(args[2]);
if((!plugin.management.getStringList("sponsors.blacklist").isEmpty() && !plugin.management.getStringList("sponsors.blacklist").contains(ID)) || plugin.management.getStringList("sponsors.blacklist").isEmpty()){
handleItemsAndEco(p,args,ID,amount,target);
}else{
p.sendMessage(ChatColor.RED + "You can't sponsor that item!");
p.sendMessage(ChatColor.GREEN + "Other items you can't sponsor are:");
for(String blacklist: plugin.management.getStringList("sponsors.blacklist")){
p.sendMessage(ChatColor.AQUA + blacklist);
}
}
}catch(Exception e){
p.sendMessage(ChatColor.RED + "Something went wrong there... Make sure that you do like this /sponsor [name] [item] [number]");
}
}
}
}else{
p.sendMessage(ChatColor.RED + "You are playing, you can't sponsor yourself!");
}
}else{
p.sendMessage(ChatColor.RED + "You don't have permission!");
}
}else if(sender instanceof ConsoleCommandSender){
if(args.length== 0){
sender.sendMessage(ChatColor.RED + "You didn't specify a tribute!");
return false;
}
if(args.length== 1){
sender.sendMessage(ChatColor.RED + "You didn't specify an item!");
}
if(args.length== 2){
sender.sendMessage(ChatColor.RED + "You didn't specify an amount!");
}
if(args.length>= 3){
Player target = Bukkit.getPlayer(args[0]);
String ID = args[1].toUpperCase().trim();
int Amount = Integer.parseInt(args[2]);
try{
if((!plugin.management.getStringList("sponsors.blacklist").isEmpty() && !plugin.management.getStringList("sponsors.blacklist").contains(ID)) || plugin.management.getStringList("sponsors.blacklist").isEmpty()){
ItemStack sponsoritem = new ItemStack(org.bukkit.Material.getMaterial(ID), Amount);
if(plugin.getArena(target)== null){
sender.sendMessage(ChatColor.RED + "That person isn't playing!");
}else{
sender.sendMessage(ChatColor.RED + "You can't sponsor yourself!");
target.sendMessage(ChatColor.AQUA + "You have been Sponsored!");
target.getInventory().addItem(sponsoritem);
sender.sendMessage("You have sponsored " + target.getName() + "!");
}
}else{
sender.sendMessage(ChatColor.RED + "You can't sponsor that item!");
sender.sendMessage(ChatColor.GREEN + "Other items you can't sponsor are:");
for(String blacklist: plugin.management.getStringList("sponsors.blacklist")){
sender.sendMessage(ChatColor.AQUA + blacklist);
}
}
}catch(Exception e){
sender.sendMessage(ChatColor.RED + "Something went wrong there... Make sure that you do like this /sponsor [name] [number] [number]");
}
}
}
}
return false;
}
private void handleItemsAndEco(Player p,String[] args,String ID,int amount,Player target){
Material sponsMat = plugin.getNewMaterial(ID,0);
ItemStack sponsoritem;
boolean done = false;
if (sponsMat !=null) {
sponsoritem = new ItemStack(sponsMat,amount);
} else {
p.sendMessage(ChatColor.RED + "That item does not exist !!");
return;
}
for(ItemStack Costs: plugin.Cost){
if(!p.getInventory().containsAtLeast(Costs, Costs.getAmount()*amount)){
p.sendMessage(ChatColor.RED + "You don't have the necessary items to sponsor!");
return;
}
}
if(args[0].equalsIgnoreCase(p.getName())){
p.sendMessage(ChatColor.RED + "You can't sponsor yourself!");
}else{
if(plugin.config.getBoolean("sponsorEco.enabled")) {
if(!(plugin.econ.getBalance(p) < (plugin.config.getDouble("sponsorEco.cost")*amount))){
plugin.econ.withdrawPlayer(p, plugin.config.getDouble("sponsorEco.cost")*amount);
done = true;
} else {
p.sendMessage(ChatColor.RED + "You don't have enough money to do that!");
return;
}
}
if(!plugin.Cost.isEmpty()){
for(ItemStack aCosts: plugin.Cost){
for (int x=1;x<=amount;x++){
p.getInventory().removeItem(aCosts);
done = true;
}
}
}
if (done){
target.getInventory().addItem(sponsoritem);
target.sendMessage(ChatColor.AQUA + "You have been Sponsored!");
p.sendMessage("You have sponsored " + target.getName() + "!");
} else p.sendMessage(ChatColor.RED + "Sponsoring is disabled!");
}
}
}