Updates for R3+ and worked on Logging for Arena Resets
This commit is contained in:
289
src/me/Travja/HungerArena/BlockStorage.java
Normal file
289
src/me/Travja/HungerArena/BlockStorage.java
Normal file
@@ -0,0 +1,289 @@
|
||||
package me.Travja.HungerArena;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.event.EventHandler;
|
||||
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.BlockFormEvent;
|
||||
import org.bukkit.event.block.BlockGrowEvent;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.LeavesDecayEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||
|
||||
public class BlockStorage implements Listener {
|
||||
public Main plugin;
|
||||
public BlockStorage(Main m) {
|
||||
this.plugin = m;
|
||||
}
|
||||
/*@EventHandler
|
||||
public void creeperExplosion(EntityExplodeEvent event){
|
||||
if(plugin.canjoin== true){
|
||||
for(Block b:event.blockList()){
|
||||
String w = b.getWorld().getName();
|
||||
int x = b.getX();
|
||||
int y = b.getY();
|
||||
int z = b.getZ();
|
||||
int d = b.getTypeId();
|
||||
String coords = w + "," + x + "," + y + "," + z + "," + d;
|
||||
System.out.println("Explode: " + coords);
|
||||
List<String> blocks = plugin.config.getStringList("Blocks_Destroyed");
|
||||
blocks.add(coords);
|
||||
plugin.config.set("Blocks_Destroyed", blocks);
|
||||
plugin.saveConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void burningBlocks(BlockBurnEvent event){
|
||||
if(plugin.canjoin== true){
|
||||
Block b = event.getBlock();
|
||||
String w = b.getWorld().getName();
|
||||
int x = b.getX();
|
||||
int y = b.getY();
|
||||
int z = b.getZ();
|
||||
int d = b.getTypeId();
|
||||
String coords = w + "," + x + "," + y + "," + z + "," + d;
|
||||
System.out.println("Burn: " + coords);
|
||||
List<String> blocks = plugin.config.getStringList("Blocks_Destroyed");
|
||||
blocks.add(coords);
|
||||
plugin.config.set("Blocks_Destroyed", blocks);
|
||||
plugin.saveConfig();
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void leafDecay(LeavesDecayEvent event){
|
||||
if(plugin.canjoin== true){
|
||||
Block b = event.getBlock();
|
||||
String w = b.getWorld().getName();
|
||||
int x = b.getX();
|
||||
int y = b.getY();
|
||||
int z = b.getZ();
|
||||
int d = b.getTypeId();
|
||||
String coords = w + "," + x + "," + y + "," + z + "," + d;
|
||||
System.out.println("Decay: " + coords);
|
||||
List<String> blocks = plugin.config.getStringList("Blocks_Destroyed");
|
||||
blocks.add(coords);
|
||||
plugin.config.set("Blocks_Destroyed", blocks);
|
||||
plugin.saveConfig();
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void blockPlace(BlockPlaceEvent event){
|
||||
if(plugin.canjoin== true){
|
||||
Block b = event.getBlock();
|
||||
String w = b.getWorld().getName();
|
||||
int x = b.getX();
|
||||
int y = b.getY();
|
||||
int z = b.getZ();
|
||||
int d = b.getTypeId();
|
||||
String coords = w + "," + x + "," + y + "," + z + "," + d;
|
||||
if(!(d== 51) && !(d==12){
|
||||
System.out.println("Place: " + coords);
|
||||
List<String> blocks = plugin.config.getStringList("Blocks_Placed");
|
||||
blocks.add(coords);
|
||||
plugin.config.set("Blocks_Placed", blocks);
|
||||
plugin.saveConfig();
|
||||
}
|
||||
Location location = b.getLocation();
|
||||
if (b.getType() == Material.SAND || b.getType() == Material.GRAVEL) {
|
||||
if (location.getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR) {
|
||||
int i = 0;
|
||||
for (i = location.getBlockY(); i > -1; i --) {
|
||||
location = new Location(location.getWorld(), location.getBlockX(), i, location.getBlockZ());
|
||||
if (location.getBlock().getType() != Material.AIR && location.getBlock().getType() != Material.WATER && location.getBlock().getType() != Material.LAVA) {
|
||||
break;
|
||||
}
|
||||
event.getPlayer().sendMessage("Block will land at: " + location);
|
||||
System.out.println("Sand Place: " + coords);
|
||||
List<String> blocks = plugin.config.getStringList("Blocks_Destroyed");
|
||||
blocks.add(coords);
|
||||
plugin.config.set("Blocks_Destroyed", blocks);
|
||||
plugin.saveConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void bucketEmpty(PlayerBucketEmptyEvent event){
|
||||
if(plugin.canjoin== true){
|
||||
Block clicked = event.getBlockClicked();
|
||||
BlockFace face = event.getBlockFace();
|
||||
Block b = clicked.getRelative(face);
|
||||
String w = b.getWorld().getName();
|
||||
int x = b.getX();
|
||||
int y = b.getY();
|
||||
int z = b.getZ();
|
||||
int d = b.getTypeId();
|
||||
String coords = w + "," + x + "," + y + "," + z + "," + d;
|
||||
System.out.println("Bucket Empty: " + coords);
|
||||
List<String> blocks = plugin.config.getStringList("Blocks_Placed");
|
||||
blocks.add(coords);
|
||||
plugin.config.set("Blocks_Destroyed", blocks);
|
||||
plugin.saveConfig();
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void bucketFill(PlayerBucketFillEvent event){
|
||||
if(plugin.canjoin== true){
|
||||
Block b = event.getBlockClicked();
|
||||
String w = b.getWorld().getName();
|
||||
int x = b.getX();
|
||||
int y = b.getY();
|
||||
int z = b.getZ();
|
||||
int d = b.getTypeId();
|
||||
String coords = w + "," + x + "," + y + "," + z + "," + d;
|
||||
System.out.println("Bucket Fill: " + coords);
|
||||
List<String> blocks = plugin.config.getStringList("Blocks_Destroyed");
|
||||
blocks.add(coords);
|
||||
plugin.config.set("Blocks_Destroyed", blocks);
|
||||
plugin.saveConfig();
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void blockBreak(BlockBreakEvent event){
|
||||
if(plugin.canjoin== true){
|
||||
Block b = event.getBlock();
|
||||
String w = b.getWorld().getName();
|
||||
int x = b.getX();
|
||||
int y = b.getY();
|
||||
int z = b.getZ();
|
||||
int d = b.getTypeId();
|
||||
String coords = w + "," + x + "," + y + "," + z + "," + d;
|
||||
System.out.println("Break: " + coords);
|
||||
List<String> blocks = plugin.config.getStringList("Blocks_Destroyed");
|
||||
blocks.add(coords);
|
||||
plugin.config.set("Blocks_Destroyed", blocks);
|
||||
plugin.saveConfig();
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void blockMelt(BlockFadeEvent event){
|
||||
if(plugin.canjoin== true){
|
||||
Block b = event.getBlock();
|
||||
String w = b.getWorld().getName();
|
||||
int x = b.getX();
|
||||
int y = b.getY();
|
||||
int z = b.getZ();
|
||||
int d = b.getTypeId();
|
||||
String coords = w + "," + x + "," + y + "," + z + "," + d;
|
||||
System.out.println("Fade: " + coords);
|
||||
List<String> blocks = plugin.config.getStringList("Blocks_Destroyed");
|
||||
blocks.add(coords);
|
||||
plugin.config.set("Blocks_Destroyed", blocks);
|
||||
plugin.saveConfig();
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void blockGrow(BlockGrowEvent event){
|
||||
if(plugin.canjoin== true){
|
||||
Block b = event.getBlock();
|
||||
String w = b.getWorld().getName();
|
||||
int x = b.getX();
|
||||
int y = b.getY();
|
||||
int z = b.getZ();
|
||||
int d = b.getTypeId();
|
||||
String coords = w + "," + x + "," + y + "," + z + "," + d;
|
||||
System.out.println("Grow: " + coords);
|
||||
List<String> blocks = plugin.config.getStringList("Blocks_Placed");
|
||||
blocks.add(coords);
|
||||
plugin.config.set("Blocks_Destroyed", blocks);
|
||||
plugin.saveConfig();
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void blockForm(BlockFormEvent event){
|
||||
if(plugin.canjoin== true){
|
||||
Block b = event.getBlock();
|
||||
String w = b.getWorld().getName();
|
||||
int x = b.getX();
|
||||
int y = b.getY();
|
||||
int z = b.getZ();
|
||||
int d = b.getTypeId();
|
||||
String coords = w + "," + x + "," + y + "," + z + "," + d;
|
||||
System.out.println("Snowfall: " + coords);
|
||||
List<String> blocks = plugin.config.getStringList("Blocks_Placed");
|
||||
blocks.add(coords);
|
||||
plugin.config.set("Blocks_Destroyed", blocks);
|
||||
plugin.saveConfig();
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void pistonPush(BlockPistonExtendEvent event){
|
||||
if(plugin.canjoin== true){
|
||||
for(Block b:event.getBlocks()){
|
||||
String w = b.getWorld().getName();
|
||||
int x = b.getX();
|
||||
int y = b.getY();
|
||||
int z = b.getZ();
|
||||
int d = b.getTypeId();
|
||||
String coords = w + "," + x + "," + y + "," + z + "," + d;
|
||||
System.out.println("Piston: " + coords);
|
||||
List<String> blocks = plugin.config.getStringList("Blocks_Destroyed");
|
||||
blocks.add(coords);
|
||||
plugin.config.set("Blocks_Destroyed", blocks);
|
||||
plugin.saveConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void onChange(BlockPhysicsEvent event){
|
||||
Block block = event.getBlock();
|
||||
Material changed = event.getChangedType();
|
||||
if (block.getType() == Material.LAVA){
|
||||
if (changed == Material.LAVA){
|
||||
Block b = event.getBlock();
|
||||
String w = b.getWorld().getName();
|
||||
int x = b.getX();
|
||||
int y = b.getY();
|
||||
int z = b.getZ();
|
||||
int d = b.getTypeId();
|
||||
String coords = w + "," + x + "," + y + "," + z + "," + d;
|
||||
System.out.println("Lava Change: " + coords);
|
||||
List<String> blocks = plugin.config.getStringList("Blocks_Placed");
|
||||
blocks.add(coords);
|
||||
plugin.config.set("Blocks_Destroyed", blocks);
|
||||
plugin.saveConfig();
|
||||
}else if(changed == Material.WATER){
|
||||
Block b = event.getBlock();
|
||||
String w = b.getWorld().getName();
|
||||
int x = b.getX();
|
||||
int y = b.getY();
|
||||
int z = b.getZ();
|
||||
int d = b.getTypeId();
|
||||
String coords = w + "," + x + "," + y + "," + z + "," + d;
|
||||
System.out.println("Water Change: " + coords);
|
||||
List<String> blocks = plugin.config.getStringList("Blocks_Placed");
|
||||
blocks.add(coords);
|
||||
plugin.config.set("Blocks_Destroyed", blocks);
|
||||
plugin.saveConfig();
|
||||
}
|
||||
}else if (block.getType() == Material.SAND || block.getType() == Material.GRAVEL) {
|
||||
if (changed == Material.AIR) {
|
||||
Block b = event.getBlock();
|
||||
String w = b.getWorld().getName();
|
||||
int x = b.getX();
|
||||
int y = b.getY();
|
||||
int z = b.getZ();
|
||||
int d = b.getTypeId();
|
||||
String coords = w + "," + x + "," + y + "," + z + "," + d;
|
||||
System.out.println("Sand/Gravel Fall: " + coords);
|
||||
List<String> blocks = plugin.config.getStringList("Blocks_Placed");
|
||||
blocks.add(coords);
|
||||
plugin.config.set("Blocks_Destroyed", blocks);
|
||||
plugin.saveConfig();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
@@ -3,6 +3,7 @@ package me.Travja.HungerArena;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Chest;
|
||||
@@ -10,6 +11,7 @@ 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.BlockBreakEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -24,30 +26,55 @@ public class Chests implements Listener {
|
||||
Player p = event.getPlayer();
|
||||
if(p.getItemInHand().getType()== Material.BLAZE_ROD && event.getAction() == Action.LEFT_CLICK_BLOCK){
|
||||
if(block.getState() instanceof Chest){
|
||||
ItemStack[] itemsinchest = ((Chest) block.getState()).getInventory().getContents();
|
||||
int blockx = block.getX();
|
||||
int blocky = block.getY();
|
||||
int blockz = block.getZ();
|
||||
String blockw = block.getWorld().getName().toString();
|
||||
if(!plugin.getConfig().contains("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X")){
|
||||
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X", blockx);
|
||||
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Y", blocky);
|
||||
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Z",blockz);
|
||||
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.W", blockw);
|
||||
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".ItemsInStorage", itemsinchest);
|
||||
if(p.hasPermission("HungerArena.Chest.Store")){
|
||||
ItemStack[] itemsinchest = ((Chest) block.getState()).getInventory().getContents();
|
||||
int blockx = block.getX();
|
||||
int blocky = block.getY();
|
||||
int blockz = block.getZ();
|
||||
String blockw = block.getWorld().getName().toString();
|
||||
if(!plugin.getConfig().contains("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X")){
|
||||
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X", blockx);
|
||||
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Y", blocky);
|
||||
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Z",blockz);
|
||||
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.W", blockw);
|
||||
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".ItemsInStorage", itemsinchest);
|
||||
}else{
|
||||
plugin.getConfig().set("Storage." + blockx + "," + blocky+ "," + blockz + ".Location.X",blockx);
|
||||
plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Y", blocky);
|
||||
plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Z", blockz);
|
||||
plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.W", blockw);
|
||||
plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".ItemsInStorage", itemsinchest);
|
||||
}
|
||||
List<String> list2 = plugin.getConfig().getStringList("StorageXYZ");
|
||||
list2.add(blockx + "," + blocky + "," + blockz);
|
||||
plugin.getConfig().set("StorageXYZ", list2);
|
||||
plugin.getConfig().options().copyDefaults(true);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.GREEN + "Chest Stored!");
|
||||
}else{
|
||||
plugin.getConfig().set("Storage." + blockx + "," + blocky+ "," + blockz + ".Location.X",blockx);
|
||||
plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Y", blocky);
|
||||
plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Z", blockz);
|
||||
plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.W", blockw);
|
||||
plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".ItemsInStorage", itemsinchest);
|
||||
p.sendMessage(ChatColor.RED + "You don't have permission to store chests!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
Player p = event.getPlayer();
|
||||
Block block = event.getBlock();
|
||||
Location blocklocation = event.getBlock().getLocation();
|
||||
if (block.getState() instanceof Chest) {
|
||||
int blockx = blocklocation.getBlockX();
|
||||
int blocky = blocklocation.getBlockY();
|
||||
int blockz = blocklocation.getBlockZ();
|
||||
if (plugin.getConfig().getStringList("StorageXYZ").contains(blockx + "," + blocky + "," + blockz)) {
|
||||
if(p.hasPermission("HungerArena.Chest.Break")){
|
||||
List<String> list2 = plugin.getConfig().getStringList("StorageXYZ");
|
||||
list2.remove(blockx + "," + blocky + "," + blockz);
|
||||
plugin.getConfig().set("StorageXYZ", list2);
|
||||
plugin.getConfig().options().copyDefaults(true);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage("Chest Removed!");
|
||||
}
|
||||
List<String> list2 = plugin.getConfig().getStringList("StorageXYZ");
|
||||
list2.add(blockx + "," + blocky + "," + blockz);
|
||||
plugin.getConfig().set("StorageXYZ", list2);
|
||||
plugin.getConfig().options().copyDefaults(true);
|
||||
plugin.saveConfig();
|
||||
p.sendMessage(ChatColor.GREEN + "Chest Stored!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -17,8 +17,10 @@ public class CommandBlock implements Listener {
|
||||
String cmd = event.getMessage();
|
||||
Player p = event.getPlayer();
|
||||
if(!cmd.contains("/ha") && plugin.Playing.contains(p) && plugin.canjoin== true){
|
||||
event.setCancelled(true);
|
||||
p.sendMessage(ChatColor.RED + "You are only allowed to use /ha commands!");
|
||||
if(!p.hasPermission("HungerArena.UseCommands")){
|
||||
event.setCancelled(true);
|
||||
p.sendMessage(ChatColor.RED + "You are only allowed to use /ha commands!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -19,10 +19,12 @@ public class DeathListener implements Listener{
|
||||
this.plugin = m;
|
||||
}
|
||||
public FileConfiguration config;
|
||||
int i = 0;
|
||||
@EventHandler
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event){
|
||||
Player p = event.getPlayer();
|
||||
if(plugin.Dead.contains(p)){
|
||||
String pname = p.getDisplayName();
|
||||
if(plugin.Dead.contains(pname)){
|
||||
String[] Spawncoords = plugin.config.getString("Spawn_coords").split(",");
|
||||
World spawnw = plugin.getServer().getWorld(Spawncoords[3]);
|
||||
double spawnx = Double.parseDouble(Spawncoords[0]);
|
||||
@@ -36,14 +38,14 @@ public class DeathListener implements Listener{
|
||||
public void onPlayerDeath(PlayerDeathEvent event){
|
||||
Player p = event.getEntity();
|
||||
Server s = p.getServer();
|
||||
String pname = p.getName();
|
||||
String pname = p.getDisplayName();
|
||||
String[] Spawncoords = plugin.config.getString("Spawn_coords").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]);
|
||||
Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
|
||||
if(plugin.Playing.contains(p)){
|
||||
if(plugin.Playing.contains(pname)){
|
||||
if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){
|
||||
double y = p.getLocation().getY();
|
||||
double newy = y+200;
|
||||
@@ -52,8 +54,8 @@ public class DeathListener implements Listener{
|
||||
Location strike = new Location(p.getWorld(), x, newy, z);
|
||||
p.getWorld().strikeLightning(strike);
|
||||
}
|
||||
plugin.Dead.add(p);
|
||||
plugin.Playing.remove(p);
|
||||
plugin.Dead.add(pname);
|
||||
plugin.Playing.remove(pname);
|
||||
String leftmsg = ChatColor.BLUE + "There are now " + plugin.Playing.size() + " tributes left!";
|
||||
if(p.getKiller() instanceof Player){
|
||||
if(p.getKiller().getItemInHand().getType().getId()== 0){
|
||||
@@ -63,19 +65,23 @@ public class DeathListener implements Listener{
|
||||
s.broadcastMessage(ChatColor.LIGHT_PURPLE + "**BOOM** Tribute " + pname + " was killed by tribute " + killername + " with their FIST!");
|
||||
s.broadcastMessage(leftmsg);
|
||||
if(plugin.Playing.size()== 1 && plugin.canjoin== true){
|
||||
for(Player winner:plugin.Playing){
|
||||
String winnername = winner.getName();
|
||||
plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername + " is the victor of this Hunger Games!");
|
||||
winner.getInventory().clear();
|
||||
winner.teleport(Spawn);
|
||||
winner.getInventory().setBoots(null);
|
||||
winner.getInventory().setChestplate(null);
|
||||
winner.getInventory().setHelmet(null);
|
||||
winner.getInventory().setLeggings(null);
|
||||
winner.getInventory().addItem(plugin.Reward);
|
||||
}
|
||||
//Announce winner
|
||||
String winnername = plugin.Playing.get(i++);
|
||||
Player winner = plugin.getServer().getPlayerExact(winnername);
|
||||
String winnername2 = winner.getName();
|
||||
plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
|
||||
winner.getInventory().clear();
|
||||
winner.teleport(Spawn);
|
||||
winner.getInventory().setBoots(null);
|
||||
winner.getInventory().setChestplate(null);
|
||||
winner.getInventory().setHelmet(null);
|
||||
winner.getInventory().setLeggings(null);
|
||||
winner.getInventory().addItem(plugin.Reward);
|
||||
plugin.Playing.clear();
|
||||
for(Player spectator:plugin.Watching){
|
||||
//Show spectators
|
||||
if(!plugin.Watching.isEmpty()){
|
||||
String s1 = plugin.Watching.get(i++);
|
||||
Player spectator = plugin.getServer().getPlayerExact(s1);
|
||||
spectator.setAllowFlight(false);
|
||||
spectator.teleport(Spawn);
|
||||
for(Player online:plugin.getServer().getOnlinePlayers()){
|
||||
@@ -95,19 +101,23 @@ public class DeathListener implements Listener{
|
||||
s.broadcastMessage(msg);
|
||||
s.broadcastMessage(leftmsg);
|
||||
if(plugin.Playing.size()== 1 && plugin.canjoin== true){
|
||||
for(Player winner:plugin.Playing){
|
||||
String winnername = winner.getName();
|
||||
plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername + " is the victor of this Hunger Games!");
|
||||
winner.getInventory().clear();
|
||||
winner.teleport(Spawn);
|
||||
winner.getInventory().setBoots(null);
|
||||
winner.getInventory().setChestplate(null);
|
||||
winner.getInventory().setHelmet(null);
|
||||
winner.getInventory().setLeggings(null);
|
||||
winner.getInventory().addItem(plugin.Reward);
|
||||
}
|
||||
//Announce winner
|
||||
String winnername = plugin.Playing.get(i++);
|
||||
Player winner = plugin.getServer().getPlayerExact(winnername);
|
||||
String winnername2 = winner.getName();
|
||||
plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
|
||||
winner.getInventory().clear();
|
||||
winner.teleport(Spawn);
|
||||
winner.getInventory().setBoots(null);
|
||||
winner.getInventory().setChestplate(null);
|
||||
winner.getInventory().setHelmet(null);
|
||||
winner.getInventory().setLeggings(null);
|
||||
winner.getInventory().addItem(plugin.Reward);
|
||||
plugin.Playing.clear();
|
||||
for(Player spectator:plugin.Watching){
|
||||
//Show spectators
|
||||
if(!plugin.Watching.isEmpty()){
|
||||
String s1 = plugin.Watching.get(i++);
|
||||
Player spectator = plugin.getServer().getPlayerExact(s1);
|
||||
spectator.setAllowFlight(false);
|
||||
spectator.teleport(Spawn);
|
||||
for(Player online:plugin.getServer().getOnlinePlayers()){
|
||||
@@ -124,19 +134,23 @@ public class DeathListener implements Listener{
|
||||
s.broadcastMessage(ChatColor.LIGHT_PURPLE + pname + " died of natural causes!");
|
||||
s.broadcastMessage(leftmsg);
|
||||
if(plugin.Playing.size()== 1 && plugin.canjoin== true){
|
||||
for(Player winner:plugin.Playing){
|
||||
String winnername = winner.getName();
|
||||
plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername + " is the victor of this Hunger Games!");
|
||||
winner.getInventory().clear();
|
||||
winner.teleport(Spawn);
|
||||
winner.getInventory().setBoots(null);
|
||||
winner.getInventory().setChestplate(null);
|
||||
winner.getInventory().setHelmet(null);
|
||||
winner.getInventory().setLeggings(null);
|
||||
winner.getInventory().addItem(plugin.Reward);
|
||||
}
|
||||
//Announce winner
|
||||
String winnername = plugin.Playing.get(i++);
|
||||
Player winner = plugin.getServer().getPlayerExact(winnername);
|
||||
String winnername2 = winner.getName();
|
||||
plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
|
||||
winner.getInventory().clear();
|
||||
winner.teleport(Spawn);
|
||||
winner.getInventory().setBoots(null);
|
||||
winner.getInventory().setChestplate(null);
|
||||
winner.getInventory().setHelmet(null);
|
||||
winner.getInventory().setLeggings(null);
|
||||
winner.getInventory().addItem(plugin.Reward);
|
||||
plugin.Playing.clear();
|
||||
for(Player spectator:plugin.Watching){
|
||||
//Show spectators
|
||||
if(!plugin.Watching.isEmpty()){
|
||||
String s1 = plugin.Watching.get(i++);
|
||||
Player spectator = plugin.getServer().getPlayerExact(s1);
|
||||
spectator.setAllowFlight(false);
|
||||
spectator.teleport(Spawn);
|
||||
for(Player online:plugin.getServer().getOnlinePlayers()){
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
||||
package me.Travja.HungerArena;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@@ -14,22 +15,26 @@ public class JoinAndQuitListener implements Listener {
|
||||
public JoinAndQuitListener(Main m) {
|
||||
this.plugin = m;
|
||||
}
|
||||
int i = 0;
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event){
|
||||
Player p = event.getPlayer();
|
||||
final Player player = event.getPlayer();
|
||||
for(Player spectator:plugin.Watching){
|
||||
final Player p = event.getPlayer();
|
||||
String pname = p.getDisplayName();
|
||||
if(!plugin.Watching.isEmpty()){
|
||||
String s = plugin.Watching.get(i++);
|
||||
Player spectator = plugin.getServer().getPlayerExact(s);
|
||||
p.hidePlayer(spectator);
|
||||
}
|
||||
if(plugin.Out.contains(p)){
|
||||
if(plugin.Out.contains(pname)){
|
||||
plugin.Playing.add(pname);
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||
public void run(){
|
||||
player.sendMessage(ChatColor.AQUA + "You have saved yourself from being ejected from the arena!");
|
||||
p.sendMessage(ChatColor.AQUA + "You have saved yourself from being ejected from the arena!");
|
||||
}
|
||||
}, 40L);
|
||||
plugin.Out.remove(p);
|
||||
}
|
||||
if(plugin.Quit.contains(p) || plugin.Dead.contains(p)){
|
||||
if(plugin.Quit.contains(pname) || plugin.Dead.contains(pname)){
|
||||
String[] Spawncoords = plugin.config.getString("Spawn_coords").split(",");
|
||||
String w = Spawncoords[3];
|
||||
World spawnw = plugin.getServer().getWorld(w);
|
||||
@@ -39,8 +44,8 @@ public class JoinAndQuitListener implements Listener {
|
||||
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||
public void run(){
|
||||
player.teleport(Spawn);
|
||||
player.sendMessage(ChatColor.RED + "You have been teleported to spawn because you quit/forfieted!");
|
||||
p.teleport(Spawn);
|
||||
p.sendMessage(ChatColor.RED + "You have been teleported to spawn because you quit/forfieted!");
|
||||
}
|
||||
}, 40L);
|
||||
}
|
||||
@@ -48,6 +53,7 @@ public class JoinAndQuitListener implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event){
|
||||
final Player p = event.getPlayer();
|
||||
final String pname = p.getDisplayName();
|
||||
String[] Spawncoords = plugin.config.getString("Spawn_coords").split(",");
|
||||
String w = Spawncoords[3];
|
||||
World spawnw = plugin.getServer().getWorld(w);
|
||||
@@ -55,45 +61,46 @@ public class JoinAndQuitListener implements Listener {
|
||||
double spawny = Double.parseDouble(Spawncoords[1]);
|
||||
double spawnz = Double.parseDouble(Spawncoords[2]);
|
||||
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
|
||||
if(plugin.Playing.contains(p)){
|
||||
plugin.Out.add(p);
|
||||
if(plugin.Playing.contains(pname)){
|
||||
plugin.Out.add(pname);
|
||||
plugin.Playing.remove(pname);
|
||||
}
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||
public void run(){
|
||||
if(plugin.Playing.contains(p) && plugin.Out.contains(p)){
|
||||
if(plugin.Out.contains(pname)){
|
||||
if(plugin.canjoin== true){
|
||||
plugin.Playing.remove(p);
|
||||
plugin.Quit.add(p);
|
||||
plugin.Out.remove(p);
|
||||
plugin.Quit.add(pname);
|
||||
plugin.Out.remove(pname);
|
||||
if(plugin.Playing.size()== 1){
|
||||
for(Player winner:plugin.Playing){
|
||||
String winnername = winner.getName();
|
||||
p.getServer().broadcastMessage(ChatColor.GREEN + winnername + " is the victor of this Hunger Games!");
|
||||
winner.getInventory().clear();
|
||||
winner.getInventory().setBoots(null);
|
||||
winner.getInventory().setChestplate(null);
|
||||
winner.getInventory().setHelmet(null);
|
||||
winner.getInventory().setLeggings(null);
|
||||
winner.getInventory().addItem(plugin.Reward);
|
||||
}
|
||||
for(Player spectator:plugin.Watching){
|
||||
//Announce Winner
|
||||
String winnername = plugin.Playing.get(i++);
|
||||
Player winner = plugin.getServer().getPlayerExact(winnername);
|
||||
String winnername2 = winner.getName();
|
||||
p.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
|
||||
winner.getInventory().clear();
|
||||
winner.getInventory().setBoots(null);
|
||||
winner.getInventory().setChestplate(null);
|
||||
winner.getInventory().setHelmet(null);
|
||||
winner.getInventory().setLeggings(null);
|
||||
winner.getInventory().addItem(plugin.Reward);
|
||||
//Make spectators visible
|
||||
if(!plugin.Watching.isEmpty()){
|
||||
String s = plugin.Watching.get(i++);
|
||||
Player spectator = plugin.getServer().getPlayerExact(s);
|
||||
spectator.setAllowFlight(false);
|
||||
spectator.teleport(Spawn);
|
||||
for(Player online:plugin.getServer().getOnlinePlayers()){
|
||||
online.showPlayer(spectator);
|
||||
}
|
||||
}
|
||||
if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
|
||||
plugin.Dead.clear();
|
||||
plugin.Playing.clear();
|
||||
plugin.Quit.clear();
|
||||
plugin.Watching.clear();
|
||||
plugin.Frozen.clear();
|
||||
plugin.canjoin = false;
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart");
|
||||
}
|
||||
}
|
||||
}else if(plugin.canjoin== false){
|
||||
plugin.Playing.remove(p);
|
||||
plugin.Quit.add(p);
|
||||
plugin.Out.remove(p);
|
||||
}
|
||||
}else{
|
||||
plugin.Quit.add(pname);
|
||||
plugin.Out.remove(pname);
|
||||
}
|
||||
}
|
||||
}, 1200L);
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,6 @@ import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class SpectatorListener implements Listener {
|
||||
public Main plugin;
|
||||
@@ -87,7 +86,6 @@ public class SpectatorListener implements Listener {
|
||||
double spawny = Double.parseDouble(Spawncoords[1]);
|
||||
double spawnz = Double.parseDouble(Spawncoords[2]);
|
||||
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
|
||||
plugin.Watching.remove(p);
|
||||
for(Player everyone:plugin.getServer().getOnlinePlayers()){
|
||||
everyone.showPlayer(p);
|
||||
}
|
||||
@@ -97,6 +95,7 @@ public class SpectatorListener implements Listener {
|
||||
player.sendMessage(ChatColor.RED + "You have been teleported to spawn because the game is over!");
|
||||
}
|
||||
}, 40L);
|
||||
plugin.Watching.remove(p);
|
||||
}else{
|
||||
p.setAllowFlight(true);
|
||||
p.setFlying(true);
|
||||
@@ -107,13 +106,6 @@ public class SpectatorListener implements Listener {
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void SpectatorQuit(PlayerQuitEvent event){
|
||||
Player p = event.getPlayer();
|
||||
if(plugin.Watching.contains(p)){
|
||||
System.out.println(p.getName() + " quit while spectating!");
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void MobNerf(EntityTargetEvent event){
|
||||
Entity target = event.getTarget();
|
||||
if(target instanceof Player){
|
||||
|
Reference in New Issue
Block a user