Merge branch 'master' of https://github.com/travja/HungerArena into devtest

This commit is contained in:
Jeppa 2013-03-21 20:48:16 +01:00
commit c0447bf3b9
61 changed files with 2949 additions and 5719 deletions

7
README
View File

@ -1 +1,6 @@
Hello World! http://dev.bukkit.org/server-mods/hungerarena
/\
|
|
|
Go there for more info!

View File

@ -2,21 +2,20 @@ package me.Travja.HungerArena;
import java.util.List; import java.util.List;
import org.bukkit.Location; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFadeEvent; 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.BlockPlaceEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerBucketFillEvent; import org.bukkit.event.player.PlayerBucketFillEvent;
@ -26,166 +25,280 @@ public class BlockStorage implements Listener {
public BlockStorage(Main m) { public BlockStorage(Main m) {
this.plugin = m; this.plugin = m;
} }
/*@EventHandler @EventHandler(priority = EventPriority.MONITOR)
public void creeperExplosion(EntityExplodeEvent event){ public void BlockBreak(BlockBreakEvent event){
if(plugin.canjoin== true){ Block b = event.getBlock();
for(Block b:event.blockList()){ Player p = event.getPlayer();
String w = b.getWorld().getName(); String pname = p.getName();
int x = b.getX(); if(plugin.getArena(p)!= null){
int y = b.getY(); int a = plugin.getArena(p);
int z = b.getZ(); if(!event.isCancelled()){
int d = b.getTypeId(); if(plugin.Playing.get(a).contains(pname)){
String coords = w + "," + x + "," + y + "," + z + "," + d; if(plugin.config.getString("Protected_Arena").equalsIgnoreCase("True")){
System.out.println("Explode: " + coords); p.sendMessage(ChatColor.RED + "You can't break blocks while playing!");
List<String> blocks = plugin.config.getStringList("Blocks_Destroyed"); }
blocks.add(coords); if(plugin.canjoin.get(a)){
plugin.config.set("Blocks_Destroyed", blocks); if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(p.getWorld().getName()))){
plugin.saveConfig(); if(!plugin.management.getBoolean("blocks.useWhitelistAsBlacklist")){
} if(!plugin.management.getIntegerList("blocks.whitelist").isEmpty()){
} if(!plugin.management.getIntegerList("blocks.whitelist").contains(b.getTypeId())){
} event.setCancelled(true);
@EventHandler p.sendMessage(ChatColor.RED + "That is an illegal block!");
public void burningBlocks(BlockBurnEvent event){ }else if(plugin.management.getIntegerList("blocks.whitelist").contains(b.getTypeId())){
if(plugin.canjoin== true){ String w = b.getWorld().getName();
Block b = event.getBlock(); int x = b.getX();
String w = b.getWorld().getName(); int y = b.getY();
int x = b.getX(); int z = b.getZ();
int y = b.getY(); int d = b.getTypeId();
int z = b.getZ(); byte m = b.getData();
int d = b.getTypeId(); String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + a;
String coords = w + "," + x + "," + y + "," + z + "," + d; List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
System.out.println("Burn: " + coords); if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + a)){
List<String> blocks = plugin.config.getStringList("Blocks_Destroyed"); blocks.add(coords);
blocks.add(coords); plugin.data.set("Blocks_Destroyed", blocks);
plugin.config.set("Blocks_Destroyed", blocks); plugin.saveData();
plugin.saveConfig(); }
} }
} }else{
@EventHandler event.setCancelled(true);
public void leafDecay(LeavesDecayEvent event){ p.sendMessage(ChatColor.RED + "That is an illegal block!");
if(plugin.canjoin== true){ }
Block b = event.getBlock(); }else{
String w = b.getWorld().getName(); if(!plugin.management.getIntegerList("blocks.whitelist").isEmpty()){
int x = b.getX(); if(!plugin.management.getIntegerList("blocks.whitelist").contains(b.getTypeId())){
int y = b.getY(); String w = b.getWorld().getName();
int z = b.getZ(); int x = b.getX();
int d = b.getTypeId(); int y = b.getY();
String coords = w + "," + x + "," + y + "," + z + "," + d; int z = b.getZ();
System.out.println("Decay: " + coords); int d = b.getTypeId();
List<String> blocks = plugin.config.getStringList("Blocks_Destroyed"); byte m = b.getData();
blocks.add(coords); String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + a;
plugin.config.set("Blocks_Destroyed", blocks); List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
plugin.saveConfig(); if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + a)){
} blocks.add(coords);
} plugin.data.set("Blocks_Destroyed", blocks);
@EventHandler plugin.saveData();
public void blockPlace(BlockPlaceEvent event){ }
if(plugin.canjoin== true){ }else if(plugin.management.getIntegerList("blocks.whitelist").contains(b.getTypeId())){
Block b = event.getBlock(); event.setCancelled(true);
String w = b.getWorld().getName(); p.sendMessage(ChatColor.RED + "That is an illegal block");
int x = b.getX(); }
int y = b.getY(); }else{
int z = b.getZ(); String w = b.getWorld().getName();
int d = b.getTypeId(); int x = b.getX();
String coords = w + "," + x + "," + y + "," + z + "," + d; int y = b.getY();
if(!(d== 51) && !(d==12){ int z = b.getZ();
System.out.println("Place: " + coords); int d = b.getTypeId();
List<String> blocks = plugin.config.getStringList("Blocks_Placed"); byte m = b.getData();
blocks.add(coords); String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + a;
plugin.config.set("Blocks_Placed", blocks); List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
plugin.saveConfig(); if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + a)){
} blocks.add(coords);
Location location = b.getLocation(); plugin.data.set("Blocks_Destroyed", blocks);
if (b.getType() == Material.SAND || b.getType() == Material.GRAVEL) { plugin.saveData();
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 @EventHandler(priority = EventPriority.MONITOR)
public void Explosion(EntityExplodeEvent event){
List<Block> blocksd = event.blockList();
Entity e = event.getEntity();
int i = 0;
if(!event.isCancelled()){
for(i = 1; i <= plugin.canjoin.size(); i++){
if(plugin.canjoin.get(i)){
i = plugin.canjoin.size()+1;
if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(event.getEntity().getWorld().getName()))){
if(e.getType()== EntityType.PRIMED_TNT){
if(!plugin.data.getStringList("Blocks_Placed").contains(e.getLocation().getWorld() + "," + e.getLocation().getX() + "," + e.getLocation().getY() + "," + e.getLocation().getZ()) /*|| !plugin.data.getStringList("Blocks_Destroyed").contains(e.getLocation().getWorld() + "," + e.getLocation().getX() + "," + e.getLocation().getY() + "," + e.getLocation().getZ())*/){
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
blocks.add(e.getLocation().getWorld().getName() + "," + e.getLocation().getX() + "," + e.getLocation().getY() + "," + e.getLocation().getZ() + ",46" + ",0");
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveData();
}
}
for(Block b:blocksd){
String w = event.getEntity().getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
byte m = b.getData();
String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + i;
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + i) || !plugin.data.getStringList("Blocks_Destroyed").contains(w + "," + x + "," + y + "," + z + "," + i)){
blocks.add(coords);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveData();
}
}
}
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void burningBlocks(BlockBurnEvent event){
Block b = event.getBlock();
int i = 0;
if(!event.isCancelled()){
for(i = 1; i <= plugin.canjoin.size(); i++){
if(plugin.canjoin.get(i)){
i = plugin.canjoin.size()+1;
if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(b.getWorld().getName()))){
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
byte m = b.getData();
String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + i;
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + i)){
blocks.add(coords);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveData();
}
}
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void blockPlace(BlockPlaceEvent event){
Block b = event.getBlock();
Player p = event.getPlayer();
if(plugin.getArena(p)!= null){
int a = plugin.getArena(p);
if(!event.isCancelled()){
if(plugin.Playing.get(a).contains(p.getName())){
if(plugin.canjoin.get(a)){
if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").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();
int x = br.getX();
int y = br.getY();
int z = br.getZ();
String coords = w + "," + x + "," + y + "," + z + "," + a;
p.sendMessage(ChatColor.GREEN + "Sand/Gravel will land at " + coords);
List<String> blocks = plugin.data.getStringList("Blocks_Placed");
blocks.add(coords);
plugin.data.set("Blocks_Placed", blocks);
plugin.saveData();
}
}
}else{
if(b.getType()!= Material.SAND || b.getType()!= Material.GRAVEL){
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
String coords = w + "," + x + "," + y + "," + z + "," + a;
List<String> blocks = plugin.data.getStringList("Blocks_Placed");
blocks.add(coords);
plugin.data.set("Blocks_Placed", blocks);
plugin.saveData();
}
}
}
}
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void bucketEmpty(PlayerBucketEmptyEvent event){ public void bucketEmpty(PlayerBucketEmptyEvent event){
if(plugin.canjoin== true){ if(plugin.getArena(event.getPlayer())!= null){
Block clicked = event.getBlockClicked(); int a = plugin.getArena(event.getPlayer());
BlockFace face = event.getBlockFace(); if(!event.isCancelled()){
Block b = clicked.getRelative(face); if(plugin.canjoin.get(a)){
String w = b.getWorld().getName(); if(plugin.Playing.get(a).contains(event.getPlayer().getName())){
int x = b.getX(); if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(event.getPlayer().getWorld().getName()))){
int y = b.getY(); Block b = event.getBlockClicked().getRelative(event.getBlockFace());
int z = b.getZ(); String w = b.getWorld().getName();
int d = b.getTypeId(); int x = b.getX();
String coords = w + "," + x + "," + y + "," + z + "," + d; int y = b.getY();
System.out.println("Bucket Empty: " + coords); int z = b.getZ();
List<String> blocks = plugin.config.getStringList("Blocks_Placed"); String coords = w + "," + x + "," + y + "," + z + "," + a;
blocks.add(coords); List<String> blocks = plugin.data.getStringList("Blocks_Placed");
plugin.config.set("Blocks_Destroyed", blocks); blocks.add(coords);
plugin.saveConfig(); plugin.data.set("Blocks_Placed", blocks);
plugin.saveData();
}
}
}
}
} }
} }
@EventHandler @EventHandler(priority = EventPriority.MONITOR)
public void bucketFill(PlayerBucketFillEvent event){ public void bucketFill(PlayerBucketFillEvent event){
if(plugin.canjoin== true){ if(plugin.getArena(event.getPlayer())!= null){
Block b = event.getBlockClicked(); int a = plugin.getArena(event.getPlayer());
String w = b.getWorld().getName(); if(!event.isCancelled()){
int x = b.getX(); if(plugin.canjoin.get(a)){
int y = b.getY(); if(plugin.Playing.get(a).contains(event.getPlayer().getName())){
int z = b.getZ(); if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(event.getPlayer().getWorld().getName()))){
int d = b.getTypeId(); Block b = event.getBlockClicked().getRelative(event.getBlockFace());
String coords = w + "," + x + "," + y + "," + z + "," + d; String w = b.getWorld().getName();
System.out.println("Bucket Fill: " + coords); int x = b.getX();
List<String> blocks = plugin.config.getStringList("Blocks_Destroyed"); int y = b.getY();
blocks.add(coords); int z = b.getZ();
plugin.config.set("Blocks_Destroyed", blocks); int d = b.getTypeId();
plugin.saveConfig(); byte m = b.getData();
String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + a;
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();
}
}
}
}
}
} }
} }
@EventHandler @EventHandler(priority = EventPriority.MONITOR)
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){ public void blockMelt(BlockFadeEvent event){
if(plugin.canjoin== true){ int i = 0;
Block b = event.getBlock(); if(!event.isCancelled()){
String w = b.getWorld().getName(); for(i = 1; i <= plugin.canjoin.size(); i++){
int x = b.getX(); if(plugin.canjoin.get(i)){
int y = b.getY(); if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(event.getBlock().getWorld().getName()))){
int z = b.getZ(); i = plugin.canjoin.size()+1;
int d = b.getTypeId(); Block b = event.getBlock();
String coords = w + "," + x + "," + y + "," + z + "," + d; String w = b.getWorld().getName();
System.out.println("Fade: " + coords); int x = b.getX();
List<String> blocks = plugin.config.getStringList("Blocks_Destroyed"); int y = b.getY();
blocks.add(coords); int z = b.getZ();
plugin.config.set("Blocks_Destroyed", blocks); int d = b.getTypeId();
plugin.saveConfig(); byte m = b.getData();
String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + i;
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + i)){
blocks.add(coords);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveData();
}
}
}
}
} }
} }
@EventHandler /*@EventHandler
public void blockGrow(BlockGrowEvent event){ public void blockGrow(BlockGrowEvent event){
if(plugin.canjoin== true){ if(plugin.canjoin== true){
Block b = event.getBlock(); Block b = event.getBlock();
@ -196,9 +309,9 @@ public class BlockStorage implements Listener {
int d = b.getTypeId(); int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d; String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Grow: " + coords); System.out.println("Grow: " + coords);
List<String> blocks = plugin.config.getStringList("Blocks_Placed"); List<String> blocks = plugin.data.getStringList("Blocks_Placed");
blocks.add(coords); blocks.add(coords);
plugin.config.set("Blocks_Destroyed", blocks); plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveConfig(); plugin.saveConfig();
} }
} }
@ -213,9 +326,9 @@ public class BlockStorage implements Listener {
int d = b.getTypeId(); int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d; String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Snowfall: " + coords); System.out.println("Snowfall: " + coords);
List<String> blocks = plugin.config.getStringList("Blocks_Placed"); List<String> blocks = plugin.data.getStringList("Blocks_Placed");
blocks.add(coords); blocks.add(coords);
plugin.config.set("Blocks_Destroyed", blocks); plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveConfig(); plugin.saveConfig();
} }
} }
@ -230,9 +343,9 @@ public class BlockStorage implements Listener {
int d = b.getTypeId(); int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d; String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Piston: " + coords); System.out.println("Piston: " + coords);
List<String> blocks = plugin.config.getStringList("Blocks_Destroyed"); List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
blocks.add(coords); blocks.add(coords);
plugin.config.set("Blocks_Destroyed", blocks); plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveConfig(); plugin.saveConfig();
} }
} }
@ -251,9 +364,9 @@ public class BlockStorage implements Listener {
int d = b.getTypeId(); int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d; String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Lava Change: " + coords); System.out.println("Lava Change: " + coords);
List<String> blocks = plugin.config.getStringList("Blocks_Placed"); List<String> blocks = plugin.data.getStringList("Blocks_Placed");
blocks.add(coords); blocks.add(coords);
plugin.config.set("Blocks_Destroyed", blocks); plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveConfig(); plugin.saveConfig();
}else if(changed == Material.WATER){ }else if(changed == Material.WATER){
Block b = event.getBlock(); Block b = event.getBlock();
@ -264,9 +377,9 @@ public class BlockStorage implements Listener {
int d = b.getTypeId(); int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d; String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Water Change: " + coords); System.out.println("Water Change: " + coords);
List<String> blocks = plugin.config.getStringList("Blocks_Placed"); List<String> blocks = plugin.data.getStringList("Blocks_Placed");
blocks.add(coords); blocks.add(coords);
plugin.config.set("Blocks_Destroyed", blocks); plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveConfig(); plugin.saveConfig();
} }
}else if (block.getType() == Material.SAND || block.getType() == Material.GRAVEL) { }else if (block.getType() == Material.SAND || block.getType() == Material.GRAVEL) {
@ -279,9 +392,9 @@ public class BlockStorage implements Listener {
int d = b.getTypeId(); int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d; String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Sand/Gravel Fall: " + coords); System.out.println("Sand/Gravel Fall: " + coords);
List<String> blocks = plugin.config.getStringList("Blocks_Placed"); List<String> blocks = plugin.data.getStringList("Blocks_Placed");
blocks.add(coords); blocks.add(coords);
plugin.config.set("Blocks_Destroyed", blocks); plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveConfig(); plugin.saveConfig();
} }
} }

View File

@ -1,25 +0,0 @@
package me.Travja.HungerArena;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
public class Blocks implements Listener {
public Main plugin;
public Blocks(Main m) {
this.plugin = m;
}
@EventHandler
public void BreakBlock(BlockBreakEvent event){
Player p = event.getPlayer();
String pname = p.getDisplayName();
if(plugin.Playing.contains(pname)){
if(plugin.config.getString("Protected_Arena").equalsIgnoreCase("True")){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You can't break blocks when you're playing!");
}
}
}
}

View File

@ -7,7 +7,7 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
public class ChatListener implements Listener { public class ChatListener implements Listener {
public Main plugin; public Main plugin;
@ -15,11 +15,11 @@ public class ChatListener implements Listener {
this.plugin = m; this.plugin = m;
} }
@EventHandler @EventHandler
public void TributeChat(PlayerChatEvent event){ public void TributeChat(AsyncPlayerChatEvent event){
Player p = event.getPlayer(); Player p = event.getPlayer();
String pname = p.getDisplayName(); String pname = p.getName();
if(plugin.Playing.contains(pname)){ if(plugin.getArena(p)!= null){
String msg = "<" + ChatColor.RED + "[Tribute] " + ChatColor.WHITE + p.getName() + ">" + " " + event.getMessage(); String msg = "<" + ChatColor.RED + "[Tribute] " + ChatColor.WHITE + pname + ">" + " " + event.getMessage();
if(plugin.config.getString("ChatClose").equalsIgnoreCase("True")){ if(plugin.config.getString("ChatClose").equalsIgnoreCase("True")){
double radius = plugin.config.getDouble("ChatClose_Radius"); double radius = plugin.config.getDouble("ChatClose_Radius");
List<Entity> near = p.getNearbyEntities(radius, radius, radius); List<Entity> near = p.getNearbyEntities(radius, radius, radius);
@ -27,9 +27,8 @@ public class ChatListener implements Listener {
if(!(near.size()== 0)){ if(!(near.size()== 0)){
p.sendMessage(msg); p.sendMessage(msg);
for(Entity e:near){ for(Entity e:near){
if(e instanceof Player){ if(e instanceof Player)
((Player) e).sendMessage(msg); ((Player) e).sendMessage(msg);
}
} }
}else if(near.size()== 0){ }else if(near.size()== 0){
p.sendMessage(msg); p.sendMessage(msg);

View File

@ -4,13 +4,12 @@ import java.util.List;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.Chest; import org.bukkit.block.Chest;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -20,60 +19,65 @@ public class Chests implements Listener {
public Chests(Main m) { public Chests(Main m) {
this.plugin = m; this.plugin = m;
} }
@EventHandler @EventHandler(priority = EventPriority.HIGHEST)
public void ChestSaves(PlayerInteractEvent event){ public void ChestBreak(BlockBreakEvent event){
Block block = event.getClickedBlock();
Player p = event.getPlayer(); Player p = event.getPlayer();
if(p.getItemInHand().getType()== Material.BLAZE_ROD && event.getAction() == Action.LEFT_CLICK_BLOCK){
if(block.getState() instanceof Chest){ Block block = event.getBlock();
if(p.hasPermission("HungerArena.Chest.Store")){ if(p.hasPermission("HungerArena.Chest.Break")){
ItemStack[] itemsinchest = ((Chest) block.getState()).getInventory().getContents(); Location blocklocation = block.getLocation();
int blockx = block.getX(); int blockx = blocklocation.getBlockX();
int blocky = block.getY(); int blocky = blocklocation.getBlockY();
int blockz = block.getZ(); int blockz = blocklocation.getBlockZ();
String blockw = block.getWorld().getName().toString(); if (plugin.getConfig().getStringList("StorageXYZ").contains(blockx + "," + blocky + "," + blockz)) {
if(!plugin.getConfig().contains("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X")){ if(p.hasPermission("HungerArena.Chest.Break") && plugin.getArena(p)== null){
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"); List<String> list2 = plugin.getConfig().getStringList("StorageXYZ");
list2.add(blockx + "," + blocky + "," + blockz); list2.remove(blockx + "," + blocky + "," + blockz);
plugin.getConfig().set("Storage." + blockx + "," + blocky+ "," + blockz, null);
plugin.getConfig().set("StorageXYZ", list2); plugin.getConfig().set("StorageXYZ", list2);
plugin.getConfig().options().copyDefaults(true); plugin.getConfig().options().copyDefaults(true);
plugin.saveConfig(); plugin.saveConfig();
p.sendMessage(ChatColor.GREEN + "Chest Stored!"); p.sendMessage("[HungerArena] Chest Removed!");
}else{ } else {
p.sendMessage(ChatColor.RED + "You don't have permission to store chests!"); event.setCancelled(true);
p.sendMessage(ChatColor.RED + "[HungerArena] That's a storage chest! You don't have permission to break it!");
} }
} }
} }
} }
@EventHandler @EventHandler
public void onBlockBreak(BlockBreakEvent event) { public void ChestSaves(PlayerInteractEvent event){
Block block = event.getClickedBlock();
Player p = event.getPlayer(); Player p = event.getPlayer();
Block block = event.getBlock(); if(plugin.getArena(p)!= null){
Location blocklocation = event.getBlock().getLocation(); int a = plugin.getArena(p);
if (block.getState() instanceof Chest && !plugin.Playing.contains(p.getDisplayName())) { if(plugin.Playing.get(a).contains(p.getName()) && plugin.canjoin.get(a)){
int blockx = blocklocation.getBlockX(); if(!plugin.restricted || (plugin.restricted && plugin.worlds.contains(p.getWorld().getName()))){
int blocky = blocklocation.getBlockY(); if(block!= null){
int blockz = blocklocation.getBlockZ(); if(block.getState() instanceof Chest){
if (plugin.getConfig().getStringList("StorageXYZ").contains(blockx + "," + blocky + "," + blockz)) { ItemStack[] itemsinchest = ((Chest) block.getState()).getInventory().getContents();
if(p.hasPermission("HungerArena.Chest.Break")){ int blockx = block.getX();
List<String> list2 = plugin.getConfig().getStringList("StorageXYZ"); int blocky = block.getY();
list2.remove(blockx + "," + blocky + "," + blockz); int blockz = block.getZ();
plugin.getConfig().set("StorageXYZ", list2); String blockw = block.getWorld().getName().toString();
plugin.getConfig().options().copyDefaults(true); if(!plugin.getConfig().contains("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X")){
plugin.saveConfig(); plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X", blockx);
p.sendMessage("Chest Removed!"); 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);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Arena", a);
}
List<String> list2 = plugin.getConfig().getStringList("StorageXYZ");
if(!list2.contains(blockx + "," + blocky + "," + blockz)){
list2.add(blockx + "," + blocky + "," + blockz);
plugin.getConfig().set("StorageXYZ", list2);
plugin.getConfig().options().copyDefaults(true);
plugin.saveConfig();
p.sendMessage(ChatColor.GREEN + "Thank you for finding this undiscovered chest, it has been stored!!");
}
}
}
} }
} }
} }

View File

@ -1,5 +1,6 @@
package me.Travja.HungerArena; package me.Travja.HungerArena;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -12,15 +13,136 @@ public class CommandBlock implements Listener {
public CommandBlock(Main m) { public CommandBlock(Main m) {
this.plugin = m; this.plugin = m;
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.MONITOR)
public void CatchCommand(PlayerCommandPreprocessEvent event){ public void CatchCommand(PlayerCommandPreprocessEvent event){
String cmd = event.getMessage(); String cmd = event.getMessage();
Player p = event.getPlayer(); Player p = event.getPlayer();
String pname = p.getDisplayName(); String pname = p.getName();
if(!cmd.contains("/ha") && plugin.Playing.contains(pname) && plugin.canjoin== true){ int i = 0;
int x = 0;
for(x = 1; x < plugin.Watching.size(); x++){
if(plugin.Watching.get(x).contains(p.getName())){
if(!p.hasPermission("HungerArena.UseCommands")){
if(!plugin.management.getStringList("commands.whitelist").isEmpty()){
for(String whitelist: plugin.management.getStringList("commands.whitelist")){
i = i+1;
if(i== plugin.management.getStringList("commands.whitelist").size()){
if(!cmd.toLowerCase().startsWith(whitelist.toLowerCase()) || !cmd.toLowerCase().startsWith("/ha")){
event.setCancelled(true);
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 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");
}
}
}
}else if(!cmd.toLowerCase().startsWith("/ha")){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are only allowed to perform /ha commands!");
}
}else if(!cmd.toLowerCase().startsWith("/ha")){
if(cmd.toLowerCase().startsWith("/spawn")){
event.setCancelled(true);
p.sendMessage("You have perms for all commands except this one!");
}
}
}
}
if(plugin.getArena(p)!= null){
if(!p.hasPermission("HungerArena.UseCommands")){ if(!p.hasPermission("HungerArena.UseCommands")){
event.setCancelled(true); if(!plugin.management.getStringList("commands.whitelist").isEmpty()){
p.sendMessage(ChatColor.RED + "You are only allowed to use /ha commands!"); for(String whitelist: plugin.management.getStringList("commands.whitelist")){
i = i+1;
if(i== plugin.management.getStringList("commands.whitelist").size()){
if(!cmd.toLowerCase().startsWith(whitelist.toLowerCase()) || !cmd.toLowerCase().startsWith("/ha")){
event.setCancelled(true);
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 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");
}
}
}
}else if(!cmd.toLowerCase().startsWith("/ha")){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are only allowed to perform /ha commands!");
}
}else if(!cmd.toLowerCase().startsWith("/ha")){
if(cmd.toLowerCase().startsWith("/spawn")){
event.setCancelled(true);
p.sendMessage("You have perms for all commands except this one!");
}
}
}else if(cmd.toLowerCase().equals("/back")){
for(i = 1; i < plugin.Dead.size(); i++){
if(plugin.Dead.get(i).contains(pname) && plugin.canjoin.get(i))
plugin.Tele.add(p);
}
}else if(cmd.startsWith("/tp") || cmd.startsWith("/tpa") || cmd.startsWith("/tpo")){
String[] args = cmd.split(" ");
Player arg1 = null;
Player arg2 = null;
if(args.length == 2){
if(Bukkit.getPlayer(args[0]) != null && Bukkit.getPlayer(args[1]) != null){
arg1 = Bukkit.getPlayer(args[0]);
arg2 = Bukkit.getPlayer(args[1]);
if(plugin.isSpectating(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "Invalid command for spectating, using /ha tp " + arg2);
p.performCommand("/ha tp " + arg2);
}else if(plugin.getArena(arg1)!= null || plugin.getArena(arg2)!= null){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You can't teleport to other tributes!");
}
}
}else if(args.length == 1){
if(Bukkit.getPlayer(args[0]) != null){
arg1 = Bukkit.getPlayer(args[0]);
if(plugin.isSpectating(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "Invalid command for spectating, using /ha tp " + arg1);
p.performCommand("/ha tp " + arg1);
}else if(plugin.getArena(arg1)!= null || plugin.getArena(p)!= null){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You can't teleport to other tributes!");
}
}
} }
} }
} }

View File

@ -3,7 +3,6 @@ package me.Travja.HungerArena;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
@ -20,146 +19,131 @@ public class DeathListener implements Listener{
} }
public FileConfiguration config; public FileConfiguration config;
int i = 0; int i = 0;
int a = 0;
@EventHandler @EventHandler
public void onPlayerRespawn(PlayerRespawnEvent event){ public void onPlayerRespawn(PlayerRespawnEvent event){
Player p = event.getPlayer(); final Player p = event.getPlayer();
String pname = p.getDisplayName(); String pname = p.getName();
if(plugin.Dead.contains(pname)){ for(i = 1; i < plugin.Dead.size(); i++){
String[] Spawncoords = plugin.config.getString("Spawn_coords").split(","); if(plugin.Dead.get(i).contains(pname)){
World spawnw = plugin.getServer().getWorld(Spawncoords[3]); String[] Spawncoords = plugin.spawns.getString("Spawn_coords").split(",");
double spawnx = Double.parseDouble(Spawncoords[0]); World spawnw = plugin.getServer().getWorld(Spawncoords[3]);
double spawny = Double.parseDouble(Spawncoords[1]); double spawnx = Double.parseDouble(Spawncoords[0]);
double spawnz = Double.parseDouble(Spawncoords[2]); double spawny = Double.parseDouble(Spawncoords[1]);
Location Spawn = new Location(spawnw, spawnx, spawny, spawnz); double spawnz = Double.parseDouble(Spawncoords[2]);
event.setRespawnLocation(Spawn); final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
p.teleport(Spawn);
}
}, 10L);
}
} }
} }
@EventHandler @EventHandler
public void onPlayerDeath(PlayerDeathEvent event){ public void onPlayerDeath(PlayerDeathEvent event){
Player p = event.getEntity(); Player p = event.getEntity();
Server s = p.getServer(); Server s = p.getServer();
String pname = p.getDisplayName(); String pname = p.getName();
String[] Spawncoords = plugin.config.getString("Spawn_coords").split(","); int players = plugin.Playing.size()-1;
World spawnw = plugin.getServer().getWorld(Spawncoords[3]); String leftmsg = null;
double spawnx = Double.parseDouble(Spawncoords[0]); for(i = 1; i < plugin.Frozen.size(); i++){
double spawny = Double.parseDouble(Spawncoords[1]); if(plugin.Frozen.get(i).contains(pname)){
double spawnz = Double.parseDouble(Spawncoords[2]); if(plugin.getArena(p)!= null){
Location Spawn = new Location(spawnw, spawnx, spawny, spawnz); a = plugin.getArena(p);
if(plugin.Playing.contains(pname)){ players = plugin.Playing.get(a).size()-1;
if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){ leftmsg = ChatColor.BLUE + "There are now " + players + " tributes left!";
double y = p.getLocation().getY(); if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){
double newy = y+200; double y = p.getLocation().getY();
double x = p.getLocation().getX(); double newy = y+200;
double z = p.getLocation().getZ(); double x = p.getLocation().getX();
Location strike = new Location(p.getWorld(), x, newy, z); double z = p.getLocation().getZ();
p.getWorld().strikeLightning(strike); Location strike = new Location(p.getWorld(), x, newy, z);
} p.getWorld().strikeLightning(strike);
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){
Player killer = p.getKiller();
String killername = killer.getName();
event.setDeathMessage(""); event.setDeathMessage("");
s.broadcastMessage(ChatColor.LIGHT_PURPLE + "**BOOM** Tribute " + pname + " was killed by tribute " + killername + " with their FIST!"); if(plugin.config.getBoolean("broadcastAll")){
s.broadcastMessage(leftmsg); p.getServer().broadcastMessage(pname + ChatColor.LIGHT_PURPLE + " Stepped off their pedestal too early!");
if(plugin.Playing.size()== 1 && plugin.canjoin== true){ }else{
//Announce winner for(String gn: plugin.Playing.get(a)){
String winnername = plugin.Playing.get(i++); Player g = plugin.getServer().getPlayer(gn);
Player winner = plugin.getServer().getPlayerExact(winnername); g.sendMessage(pname + ChatColor.LIGHT_PURPLE + " Stepped off their pedestal too early!");
String winnername2 = winner.getName(); }
plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!"); }
winner.getInventory().clear(); plugin.Frozen.get(a).remove(pname);
winner.teleport(Spawn); plugin.Playing.get(a).remove(pname);
winner.getInventory().setBoots(null); plugin.Dead.get(a).add(pname);
winner.getInventory().setChestplate(null); if(plugin.config.getBoolean("broadcastAll")){
winner.getInventory().setHelmet(null); p.getServer().broadcastMessage(leftmsg);
winner.getInventory().setLeggings(null); }else{
winner.getInventory().addItem(plugin.Reward); for(String gn: plugin.Playing.get(a)){
plugin.Playing.clear(); Player g = plugin.getServer().getPlayer(gn);
//Show spectators g.sendMessage(leftmsg);
if(!plugin.Watching.isEmpty()){ }
String s1 = plugin.Watching.get(i++); }
Player spectator = plugin.getServer().getPlayerExact(s1); plugin.winner(a);
spectator.setAllowFlight(false); }
spectator.teleport(Spawn); }else if(plugin.getArena(p)!= null){
for(Player online:plugin.getServer().getOnlinePlayers()){ a = plugin.getArena(p);
online.showPlayer(spectator); 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().getItemInHand().getType().getId()== 0){
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.config.getString("Auto_Restart").equalsIgnoreCase("True")){ plugin.winner(a);
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart"); }else{
Player killer = p.getKiller();
String killername = killer.getName();
String weapon = killer.getItemInHand().getType().toString().replace('_', ' ');
String msg = ChatColor.LIGHT_PURPLE + "**BOOM** Tribute " + pname + " was killed by tribute " + killername + " with a(n) " + 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);
}
} }
plugin.winner(a);
} }
}else{ }else{
Player killer = p.getKiller();
String killername = killer.getName();
Material weapon = killer.getItemInHand().getType();
String msg = ChatColor.LIGHT_PURPLE + "**BOOM** Tribute " + pname + " was killed by tribute " + killername + " with a(n) " + weapon;
event.setDeathMessage(""); event.setDeathMessage("");
s.broadcastMessage(msg); if(plugin.config.getBoolean("broadcastAll")){
s.broadcastMessage(leftmsg); s.broadcastMessage(ChatColor.LIGHT_PURPLE + pname + " died of natural causes!");
if(plugin.Playing.size()== 1 && plugin.canjoin== true){ s.broadcastMessage(leftmsg);
//Announce winner }else{
String winnername = plugin.Playing.get(i++); for(String gn: plugin.Playing.get(a)){
Player winner = plugin.getServer().getPlayerExact(winnername); Player g = plugin.getServer().getPlayer(gn);
String winnername2 = winner.getName(); g.sendMessage(ChatColor.LIGHT_PURPLE + pname + " died of natural causes!");
plugin.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!"); g.sendMessage(leftmsg);
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();
//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()){
online.showPlayer(spectator);
}
}
if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart");
} }
} }
} plugin.winner(a);
}else{
event.setDeathMessage("");
s.broadcastMessage(ChatColor.LIGHT_PURPLE + pname + " died of natural causes!");
s.broadcastMessage(leftmsg);
if(plugin.Playing.size()== 1 && plugin.canjoin== true){
//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();
//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()){
online.showPlayer(spectator);
}
}
if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart");
}
} }
} }
} }

View File

@ -1,5 +1,8 @@
package me.Travja.HungerArena; package me.Travja.HungerArena;
import java.util.HashMap;
import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -10,12 +13,51 @@ public class FreezeListener implements Listener {
public FreezeListener(Main m) { public FreezeListener(Main m) {
this.plugin = m; this.plugin = m;
} }
int i = 0;
int a = 0;
private HashMap<Integer, Boolean> timeUp= new HashMap<Integer, Boolean>();
@EventHandler @EventHandler
public void onPlayerMove(PlayerMoveEvent event){ public void onPlayerMove(PlayerMoveEvent event){
Player p = event.getPlayer(); Player p = event.getPlayer();
String pname = p.getDisplayName(); String pname = p.getName();
if(plugin.Frozen.contains(pname) && plugin.config.getString("Frozen_Teleport").equalsIgnoreCase("True")){ if(plugin.getArena(p)!= null){
event.setCancelled(true); 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")){
for(String players: plugin.Playing.get(a)){
final Player playing = plugin.getServer().getPlayerExact(players);
i = plugin.Playing.get(a).indexOf(players);
if(!timeUp.get(a)){
if(!playing.getLocation().getBlock().getLocation().equals(plugin.location.get(a).get(i))){
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);
}
}
},30L);
}
}else{
if(!playing.getLocation().getBlock().getLocation().equals(plugin.location.get(a).get(i))){
if(!plugin.Dead.get(a).contains(playing.getName())){
World world = playing.getLocation().getWorld();
world.createExplosion(playing.getLocation(), 0.0F, false);
playing.setHealth(0);
}
}
}
}
}else{
for(String players:plugin.Playing.get(a)){
Player playing = plugin.getServer().getPlayerExact(players);
i = plugin.Playing.get(a).indexOf(players)+1;
if(!playing.getLocation().getBlock().getLocation().equals(plugin.location.get(a).get(i))){
playing.teleport(plugin.location.get(a).get(i));
}
}
}
}
} }
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -15,94 +15,142 @@ public class JoinAndQuitListener implements Listener {
public JoinAndQuitListener(Main m) { public JoinAndQuitListener(Main m) {
this.plugin = m; this.plugin = m;
} }
public HaCommands commands;
public JoinAndQuitListener(HaCommands h){
this.commands = h;
}
int i = 0; int i = 0;
int a = 0;
@EventHandler
public void onJoin(PlayerJoinEvent evt) {
Player p = evt.getPlayer();
for(i = 1; i <= plugin.Watching.size(); i++){
for (String s : plugin.Watching.get(i)) {
Player spectator = Bukkit.getServer().getPlayerExact(s);
p.hidePlayer(spectator);
}
}
}
@EventHandler @EventHandler
public void onPlayerJoin(PlayerJoinEvent event){ public void onPlayerJoin(PlayerJoinEvent event){
final Player p = event.getPlayer(); final Player p = event.getPlayer();
String pname = p.getDisplayName(); final String pname = p.getName();
if(!plugin.Watching.isEmpty()){ for(i = 1; i <= plugin.Watching.size(); i++){
String s = plugin.Watching.get(i++); for(String s: plugin.Watching.get(i)){
Player spectator = plugin.getServer().getPlayerExact(s); Player spectator = plugin.getServer().getPlayerExact(s);
p.hidePlayer(spectator); p.hidePlayer(spectator);
}
} }
if(plugin.Out.contains(pname)){ for(i = 1; i <= plugin.Out.size(); i++){
plugin.Playing.add(pname); if(plugin.Out.get(i).contains(pname)){
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){ plugin.Playing.get(i).add(pname);
public void run(){ plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
p.sendMessage(ChatColor.AQUA + "You have saved yourself from being ejected from the arena!"); public void run(){
} p.sendMessage(ChatColor.AQUA + "You have saved yourself from being ejected from the arena!");
}, 40L); }
plugin.Out.remove(pname); }, 40L);
plugin.Out.get(i).remove(pname);
}
} }
if(plugin.Quit.contains(pname) || plugin.Dead.contains(pname)){ for(i = 1; i <= plugin.Quit.size(); i++){
String[] Spawncoords = plugin.config.getString("Spawn_coords").split(","); if(plugin.Quit.get(i).contains(pname)){
String w = Spawncoords[3]; String[] Spawncoords = plugin.spawns.getString("Spawn_coords").split(",");
World spawnw = plugin.getServer().getWorld(w); String w = Spawncoords[3];
double spawnx = Double.parseDouble(Spawncoords[0]); World spawnw = plugin.getServer().getWorld(w);
double spawny = Double.parseDouble(Spawncoords[1]); double spawnx = Double.parseDouble(Spawncoords[0]);
double spawnz = Double.parseDouble(Spawncoords[2]); double spawny = Double.parseDouble(Spawncoords[1]);
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz); double spawnz = Double.parseDouble(Spawncoords[2]);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){ final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
public void run(){ plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
p.teleport(Spawn); public void run(){
p.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/forfeited!");
}
}, 40L);
}
}
for(i = 1; i <= plugin.Dead.size(); i++){
if(plugin.Dead.get(i).contains(pname)){
String[] Spawncoords = plugin.spawns.getString("Spawn_coords").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/forfeited!");
}
}, 40L);
}
}
for(i = 1; i <= plugin.inArena.size(); i++){
if(plugin.inArena.get(i)!= null){
if(plugin.inArena.get(i).contains(pname)){
String[] Spawncoords = plugin.spawns.getString("Spawn_coords").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.");
}
}, 40L);
} }
}, 40L); }
}
}
@EventHandler
public void onQuit(PlayerQuitEvent evt) {
Player p = evt.getPlayer();
String pname = p.getName();
for(i = 1; i <= plugin.Frozen.size(); i++){
if (plugin.Frozen.get(i).contains(pname)) {
plugin.Frozen.remove(pname);
String[] Spawncoords = plugin.spawns.getString("Spawn_coords").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);
}
} }
} }
@EventHandler @EventHandler
public void onPlayerQuit(PlayerQuitEvent event){ public void onPlayerQuit(PlayerQuitEvent event){
final Player p = event.getPlayer(); final Player p = event.getPlayer();
final String pname = p.getDisplayName(); final String pname = p.getName();
String[] Spawncoords = plugin.config.getString("Spawn_coords").split(","); if(plugin.getArena(p)!= null){
String w = Spawncoords[3]; a = plugin.getArena(p);
World spawnw = plugin.getServer().getWorld(w); plugin.Out.get(a).add(pname);
double spawnx = Double.parseDouble(Spawncoords[0]); plugin.Playing.get(a).remove(pname);
double spawny = Double.parseDouble(Spawncoords[1]); plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
double spawnz = Double.parseDouble(Spawncoords[2]); public void run(){
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz); if(plugin.Out.get(a).contains(pname)){
if(plugin.Playing.contains(pname)){ plugin.Quit.get(a).add(pname);
plugin.Out.add(pname);
plugin.Playing.remove(pname);
}
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
if(plugin.Out.contains(pname)){
if(plugin.canjoin== true){
plugin.Quit.add(pname);
plugin.Out.remove(pname); plugin.Out.remove(pname);
if(plugin.Playing.size()== 1){ plugin.winner(a);
//Announce Winner plugin.inArena.get(a).add(pname);
String winnername = plugin.Playing.get(i++); }else if(plugin.getArena(p)== null){
Player winner = plugin.getServer().getPlayerExact(winnername); plugin.Quit.get(a).add(pname);
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")){
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart");
}
}
} }
}else{
plugin.Quit.add(pname);
plugin.Out.remove(pname);
} }
} }, 1200L);
}, 1200L); }
} }
} }

View File

@ -1,25 +1,52 @@
package me.Travja.HungerArena; package me.Travja.HungerArena;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class Main extends JavaPlugin{ public class Main extends JavaPlugin{
Logger log; static Logger log;
public ArrayList<String> Playing = new ArrayList<String>(); public HashMap<Integer, List<String>> Playing = new HashMap<Integer, List<String>>();
public ArrayList<String> Ready = new ArrayList<String>(); public HashMap<Integer, List<String>> Ready = new HashMap<Integer, List<String>>();
public ArrayList<String> Dead = new ArrayList<String>(); public HashMap<Integer, List<String>> Dead = new HashMap<Integer, List<String>>();
public ArrayList<String> Quit = new ArrayList<String>(); public HashMap<Integer, List<String>> Quit = new HashMap<Integer, List<String>>();
public ArrayList<String> Out = new ArrayList<String>(); public HashMap<Integer, List<String>> Out = new HashMap<Integer, List<String>>();
public ArrayList<String> Watching = new ArrayList<String>(); public HashMap<Integer, List<String>> Watching = new HashMap<Integer, List<String>>();
public ArrayList<String> NeedConfirm = new ArrayList<String>(); public HashMap<Integer, List<String>> NeedConfirm = new HashMap<Integer, List<String>>();
public HashSet<String> Frozen = new HashSet<String>(); public HashMap<Integer, HashMap<Integer, Location>> location = new HashMap<Integer, HashMap<Integer, Location>>();
public ArrayList<Player> Tele = new ArrayList<Player>();
public HashMap<Integer, List<String>> inArena = new HashMap<Integer, List<String>>();
public HashMap<Integer, List<String>> Frozen = new HashMap<Integer, List<String>>();
public HashMap<Integer, List<String>> arena = new HashMap<Integer, List<String>>();
public HashMap<Integer, Boolean> canjoin = new HashMap<Integer, Boolean>();
public HashMap<Integer, Integer> maxPlayers = new HashMap<Integer, Integer>();
public HashMap<Integer, Boolean> open = new HashMap<Integer, Boolean>();
public List<String> worlds;
public Listener DeathListener = new DeathListener(this); public Listener DeathListener = new DeathListener(this);
public Listener SpectatorListener = new SpectatorListener(this); public Listener SpectatorListener = new SpectatorListener(this);
public Listener FreezeListener = new FreezeListener(this); public Listener FreezeListener = new FreezeListener(this);
@ -27,24 +54,50 @@ public class Main extends JavaPlugin{
public Listener ChatListener = new ChatListener(this); public Listener ChatListener = new ChatListener(this);
public Listener Chests = new Chests(this); public Listener Chests = new Chests(this);
public Listener PvP = new PvP(this); public Listener PvP = new PvP(this);
public Listener Blocks = new Blocks(this);
public Listener CommandBlock = new CommandBlock(this); public Listener CommandBlock = new CommandBlock(this);
public Listener Damage = new DmgListener(this);
public Listener Teleport = new TeleportListener(this);
public Listener Signs = new Signs(this); public Listener Signs = new Signs(this);
public Listener BlockStorage = new BlockStorage(this); public Listener BlockStorage = new BlockStorage(this);
public Listener WinGames = new WinGamesListener(this);
public CommandExecutor HaCommands = new HaCommands(this); public CommandExecutor HaCommands = new HaCommands(this);
public CommandExecutor SponsorCommands = new SponsorCommands(this); public CommandExecutor SponsorCommands = new SponsorCommands(this);
public CommandExecutor SpawnsCommand = new SpawnsCommand(this); public CommandExecutor SpawnsCommand = new SpawnsCommand(this);
public boolean canjoin;
public boolean exists; public boolean exists;
public boolean restricted;
public FileConfiguration config; public FileConfiguration config;
public ItemStack Reward; public FileConfiguration spawns = null;
public ItemStack Cost; public File spawnsFile = null;
public FileConfiguration data = null;
public File dataFile = null;
public File managementFile = null;
public FileConfiguration management = null;
public ArrayList<ItemStack> Reward = new ArrayList<ItemStack>();
public ArrayList<ItemStack> Cost = new ArrayList<ItemStack>();
public ArrayList<ItemStack> Fee = new ArrayList<ItemStack>();
public boolean vault = false;
public boolean eco = false;
public Economy econ = null;
int i = 0;
int v = 0;
int start = 0;
int deathtime = 0;
int timetodeath = 0;
int a = 0;
public void onEnable(){ public void onEnable(){
log = this.getLogger(); log = this.getLogger();
log.info("HungerArena has been Enabled"); config = this.getConfig();
config = getConfig();
config.options().copyDefaults(true); config.options().copyDefaults(true);
this.saveDefaultConfig(); this.saveDefaultConfig();
spawns = this.getSpawns();
spawns.options().copyDefaults(true);
this.saveSpawns();
data = this.getData();
data.options().copyDefaults(true);
this.saveData();
management = this.getManagement();
management.options().copyDefaults(true);
this.saveManagement();
getServer().getPluginManager().registerEvents(DeathListener, this); getServer().getPluginManager().registerEvents(DeathListener, this);
getServer().getPluginManager().registerEvents(SpectatorListener, this); getServer().getPluginManager().registerEvents(SpectatorListener, this);
getServer().getPluginManager().registerEvents(FreezeListener, this); getServer().getPluginManager().registerEvents(FreezeListener, this);
@ -52,18 +105,407 @@ public class Main extends JavaPlugin{
getServer().getPluginManager().registerEvents(ChatListener, this); getServer().getPluginManager().registerEvents(ChatListener, this);
getServer().getPluginManager().registerEvents(Chests, this); getServer().getPluginManager().registerEvents(Chests, this);
getServer().getPluginManager().registerEvents(PvP, this); getServer().getPluginManager().registerEvents(PvP, this);
getServer().getPluginManager().registerEvents(Blocks, this);
getServer().getPluginManager().registerEvents(CommandBlock, this); getServer().getPluginManager().registerEvents(CommandBlock, this);
getServer().getPluginManager().registerEvents(Signs, this); getServer().getPluginManager().registerEvents(Signs, this);
getServer().getPluginManager().registerEvents(BlockStorage, this); getServer().getPluginManager().registerEvents(BlockStorage, this);
getServer().getPluginManager().registerEvents(WinGames, this);
getServer().getPluginManager().registerEvents(Damage, this);
getCommand("Ha").setExecutor(HaCommands); getCommand("Ha").setExecutor(HaCommands);
getCommand("Sponsor").setExecutor(SponsorCommands); getCommand("Sponsor").setExecutor(SponsorCommands);
getCommand("Startpoint").setExecutor(SpawnsCommand); getCommand("Startpoint").setExecutor(SpawnsCommand);
Reward = new ItemStack(config.getInt("Reward.ID"), config.getInt("Reward.Amount")); i = 1;
Cost = new ItemStack(config.getInt("Sponsor_Cost.ID"), config.getInt("Sponsor_Cost.Amount")); //TODO THIS CRAP
if(spawns.getConfigurationSection("Spawns")!= null){
Map<String, Object> temp = spawns.getConfigurationSection("Spawns").getValues(false);
for(Entry<String, Object> entry: temp.entrySet()){
if(spawns.getConfigurationSection("Spawns." + entry.getKey())!= null){
Map<String, Object> temp2 = spawns.getConfigurationSection("Spawns." + entry.getKey()).getValues(false);
for(Map.Entry<String, Object> e: temp2.entrySet()){
if(spawns.get("Spawns." + entry.getKey() + "." + e.getKey())!= null){
String[] coords = ((String) spawns.get("Spawns." + entry.getKey() + "." + e.getKey())).split(",");
Integer a = Integer.parseInt(entry.getKey());
Integer s = Integer.parseInt(e.getKey());
if(location.get(a)== null)
location.put(a, new HashMap<Integer, Location>());
log.info("Added spawn number " + s + " in arena " + a + "!");
location.get(a).put(s, new Location(getServer().getWorld(coords[0]), Double.parseDouble(coords[1]), Double.parseDouble(coords[2]), Double.parseDouble(coords[3])));
}
}
}
}
}
for(i = 1; i <= location.size(); i++){
log.info("Loaded " + location.get(i).size() + " tribute spawns for arena " + i + "!");
Playing.put(i, new ArrayList<String>());
Ready.put(i, new ArrayList<String>());
Dead.put(i, new ArrayList<String>());
Quit.put(i, new ArrayList<String>());
Out.put(i, new ArrayList<String>());
Watching.put(i, new ArrayList<String>());
NeedConfirm.put(i, new ArrayList<String>());
inArena.put(i, new ArrayList<String>());
Frozen.put(i, new ArrayList<String>());
arena.put(i, new ArrayList<String>());
canjoin.put(i, false);
if(location.get(i).size()== config.getInt("maxPlayers")){
maxPlayers.put(i, location.get(i).size());
}else if(location.size()< config.getInt("maxPlayers")){
maxPlayers.put(i, location.get(i).size());
}else if(location.size()> config.getInt("maxPlayers")){
maxPlayers.put(i, config.getInt("maxPlayers"));
}
log.info("Max players is for arena " + i + " is " + maxPlayers.get(i));
open.put(i, true);
}
if (setupEconomy()) {
log.info("Found Vault! Hooking in for economy!");
}
if (config.getDouble("config.version") != 1.3) {
config.set("config.version", 1.3);
config.set("rewardEco.enabled", false);
config.set("rewardEco.reward", 100);
}
if (config.getBoolean("rewardEco.enabled", true) || config.getBoolean("sponsorEco.enabled", true) || config.getBoolean("EntryFee.eco", true)) {
if (vault == true) {
log.info("Economy hook deployed.");
eco = true;
}else{
log.info("You want economy support... yet you either don't have Vault or don't have an economy plugin. Sorry, can't give you it.");
}
}
if (!eco) {
if (vault == true) {
log.info("We see that you have Vault on your server. To set economy support to true, enable it in the config.");
}
}
try{
for(String rewards: config.getStringList("Reward")){
String[] rinfo = rewards.split(",");
Reward.add(new ItemStack(Integer.parseInt(rinfo[0]), Integer.parseInt(rinfo[1])));
}
for(String scost: config.getStringList("Sponsor_Cost")){
String[] sinfo = scost.split(",");
Cost.add(new ItemStack(Integer.parseInt(sinfo[0]), Integer.parseInt(sinfo[1])));
}
if(config.getBoolean("EntryFee.enabled")){
for(String fee: config.getStringList("EntryFee.fee")){
String[] finfo = fee.split(",");
Fee.add(new ItemStack(Integer.parseInt(finfo[0]), Integer.parseInt(finfo[1])));
}
}
}catch(Exception e){
log.warning("Could not add a reward/sponsor/entry cost! One of the rewards/costs is not a number!");
}
worlds = config.getStringList("worlds");
if(worlds.isEmpty()){
restricted = false;
}else if(!worlds.isEmpty()){
restricted = true;
}
log.info("Enabled v" + getDescription().getVersion());
} }
public void onDisable(){ public void onDisable(){
log = this.getLogger(); log.info("Disabled v" + getDescription().getVersion());
log.info("HungerArena has been Disabled"); }
public boolean setupEconomy() {
if (getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
}
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
return false;
}
econ = rsp.getProvider();
vault = true;
return econ != null;
}
public void reloadSpawns() {
if (spawnsFile == null) {
spawnsFile = new File(getDataFolder(), "spawns.yml");
}
spawns = YamlConfiguration.loadConfiguration(spawnsFile);
// Look for defaults in the jar
InputStream defConfigStream = this.getResource("spawns.yml");
if (defConfigStream != null) {
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
spawns.setDefaults(defConfig);
}
}
public FileConfiguration getSpawns() {
if (spawns == null) {
this.reloadSpawns();
}
return spawns;
}
public void saveSpawns() {
if (spawns == null || spawnsFile == null) {
return;
}
try {
getSpawns().save(spawnsFile);
} catch (IOException ex) {
this.getLogger().log(Level.SEVERE, "Could not save config to " + spawnsFile, ex);
}
}
public void reloadData() {
if (dataFile == null) {
dataFile = new File(getDataFolder(), "Data.yml");
}
data = YamlConfiguration.loadConfiguration(dataFile);
// Look for defaults in the jar
InputStream defConfigStream = this.getResource("Data.yml");
if (defConfigStream != null) {
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
data.setDefaults(defConfig);
}
}
public FileConfiguration getData() {
if (data == null) {
this.reloadData();
}
return data;
}
public void saveData() {
if (data == null || dataFile == null) {
return;
}
try {
getData().save(dataFile);
} catch (IOException ex) {
this.getLogger().log(Level.SEVERE, "Could not save config to " + dataFile, ex);
}
}
public void reloadManagement() {
if (managementFile == null) {
managementFile = new File(getDataFolder(), "commandAndBlockManagement.yml");
}
management = YamlConfiguration.loadConfiguration(managementFile);
// Look for defaults in the jar
InputStream defConfigStream = this.getResource("commandAndBlockManagement.yml");
if (defConfigStream != null) {
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
management.setDefaults(defConfig);
}
}
public FileConfiguration getManagement() {
if (management == null) {
this.reloadManagement();
}
return management;
}
public void saveManagement() {
if (management == null || managementFile == null) {
return;
}
try {
getManagement().save(managementFile);
} catch (IOException ex) {
this.getLogger().log(Level.SEVERE, "Could not save config to " + managementFile, ex);
}
}
public void winner(Integer a){
String[] Spawncoords = spawns.getString("Spawn_coords").split(",");
World spawnw = 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(Playing.get(a).size()== 1 && canjoin.get(a)== true){
//Announce winner
for(i = 0; i < Playing.get(a).size(); i++){
String winnername = Playing.get(a).get(i);
Player winner = getServer().getPlayerExact(winnername);
String winnername2 = winner.getName();
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.setLevel(0);
for(PotionEffect pe: winner.getActivePotionEffects()){
PotionEffectType potion = pe.getType();
winner.removePotionEffect(potion);
}
Tele.add(winner);
final World w = winner.getWorld();
winner.teleport(Spawn);
if(config.getBoolean("reloadWorld")){
getServer().unloadWorld(w, false);
getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
public void run(){
getServer().createWorld(new WorldCreator(w.getName()));
}
},200L);
}
if(!config.getBoolean("rewardEco.enabled")){
for(ItemStack Rewards: Reward){
winner.getInventory().addItem(Rewards);
}
}else{
for(ItemStack Rewards: Reward){
winner.getInventory().addItem(Rewards);
}
econ.depositPlayer(winner.getName(), config.getDouble("rewardEco.reward"));
}
Playing.get(a).clear();
getServer().getScheduler().cancelTask(deathtime);
}
//Show spectators
for(String s1: Watching.get(a)){
Player spectator = getServer().getPlayerExact(s1);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:getServer().getOnlinePlayers()){
online.showPlayer(spectator);
}
}
if(config.getString("Auto_Restart").equalsIgnoreCase("True")){
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
public void run(){
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart");
}
}, 220L);
}
}
}
public void startGames(final Integer a){
String begin = config.getString("Start_Message");
begin = begin.replaceAll("(&([a-f0-9]))", "\u00A7$2");
final String msg = begin;
i = 10;
if(config.getString("Countdown").equalsIgnoreCase("true")){
start = getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
public void run(){
if(i > 0){
if(worlds.isEmpty()){
if(config.getBoolean("broadcastAll")){
getServer().broadcastMessage(String.valueOf(i));
}else{
for(String gn: Playing.get(a)){
Player g = getServer().getPlayer(gn);
g.sendMessage(String.valueOf(i));
}
}
}else{
for(String world: worlds){
World w = getServer().getWorld(world);
if(config.getBoolean("broadcastAll")){
for(Player wp: w.getPlayers()){
wp.sendMessage(String.valueOf(i));
}
}else{
for(String gn: Playing.get(a)){
Player g = getServer().getPlayer(gn);
g.sendMessage(String.valueOf(i));
}
}
}
}
}
i = i-1;
canjoin.put(a, true);
if(i== -1){
if(Frozen.get(a)!= null)
Frozen.get(a).clear();
if(config.getBoolean("broadcastAll")){
getServer().broadcastMessage(msg);
}else{
for(String gn: Playing.get(a)){
Player g = getServer().getPlayer(gn);
g.sendMessage(msg);
}
}
getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha Refill " + a);
getServer().getScheduler().cancelTask(start);
if(config.getInt("DeathMatch")!= 0){
int death = config.getInt("DeathMatch");
timetodeath = death;
deathtime = getServer().getScheduler().scheduleSyncRepeatingTask(Bukkit.getPluginManager().getPlugin("HungerArena"), new Runnable(){
public void run(){
timetodeath = timetodeath-1;
if(config.getBoolean("broadcastAll")){
for(Player wp: location.get(a).get(0).getWorld().getPlayers()){
if(timetodeath!= 0){
wp.sendMessage(ChatColor.RED + String.valueOf(timetodeath) + " mins till the death match!");
}
}
}else{
for(String gn: Playing.get(a)){
Player g = getServer().getPlayer(gn);
g.sendMessage(ChatColor.RED + String.valueOf(timetodeath) + " mins till the death match!");
}
}
if(timetodeath== 0){
for(String playing: Playing.get(a)){
Player tribute = getServer().getPlayerExact(playing);
tribute.teleport(location.get(a).get(i));
i = i+1;
for(PotionEffect pe: tribute.getActivePotionEffects()){
PotionEffectType potion = pe.getType();
tribute.removePotionEffect(potion);
}
if(tribute.getAllowFlight()){
tribute.setAllowFlight(false);
}
}
if(config.getBoolean("broadcastAll")){
for(Player wp: location.get(a).get(0).getWorld().getPlayers()){
wp.sendMessage(ChatColor.RED + "The final battle has begun! " + Playing.size() + " tributes will be facing off!");
}
}else{
for(String gn: Playing.get(a)){
Player g = getServer().getPlayer(gn);
g.sendMessage(ChatColor.RED + "The final battle has begun! " + Playing.size() + " tributes will be facing off!");
}
}
getServer().getScheduler().cancelTask(deathtime);
}
}
}, 1200L, 1200L);
}
}
}
}, 20L, 20L);
}else{
Frozen.get(a).clear();
if(config.getBoolean("broadcastAll")){
getServer().broadcastMessage(msg);
}else{
for(String gn: Playing.get(a)){
Player g = getServer().getPlayer(gn);
g.sendMessage(msg);
}
}
canjoin.put(a, true);
getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha Refill " + a);
}
}
public Integer getArena(Player p){
for (int x: Playing.keySet()) {
if (Playing.get(x).contains(p.getName())){
return x;
}
}
return null;
}
public boolean isSpectating(Player p){
int x = 0;
if(!Watching.isEmpty()){
for(x= 1; x <= Watching.size(); x++){
if(Watching.get(x).contains(p.getName())){
x = Watching.size()+1;
return true;
}else if(Watching.size()== x)
return false;
}
}
return false;
} }
} }

View File

@ -2,7 +2,10 @@ package me.Travja.HungerArena;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.Skeleton;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -11,13 +14,52 @@ public class PvP implements Listener {
public PvP(Main m) { public PvP(Main m) {
this.plugin = m; this.plugin = m;
} }
@EventHandler int a = 0;
@EventHandler(priority= EventPriority.MONITOR)
public void PlayerPvP(EntityDamageByEntityEvent event){ public void PlayerPvP(EntityDamageByEntityEvent event){
Entity p = event.getEntity(); Entity pl = event.getEntity();
if(p instanceof Player){ Entity dl = event.getDamager();
String pname = ((Player) p).getDisplayName(); if(pl instanceof Player && dl instanceof Player){
if(plugin.Playing.contains(pname) && plugin.canjoin== false){ Player p = (Player) pl;
event.setCancelled(true); 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.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){
event.setCancelled(false);
}
}
}else if(projectile.getShooter() instanceof Entity){
Entity e = projectile.getShooter();
if(e instanceof Skeleton){
if(plugin.getArena(p)!= null){
event.setCancelled(false);
}
}
} }
} }
} }

View File

@ -19,28 +19,34 @@ public class Signs implements Listener {
public void Sign(PlayerInteractEvent event){ public void Sign(PlayerInteractEvent event){
Player p = event.getPlayer(); Player p = event.getPlayer();
Block b = event.getClickedBlock(); Block b = event.getClickedBlock();
if (b == null) {
return;
}
if(event.getAction()== Action.RIGHT_CLICK_BLOCK){ if(event.getAction()== Action.RIGHT_CLICK_BLOCK){
if(b.getType()== Material.SIGN || b.getType()==Material.SIGN_POST || b.getType()==Material.WALL_SIGN){ if(b.getType()== Material.SIGN || b.getType()==Material.SIGN_POST || b.getType()==Material.WALL_SIGN){
org.bukkit.block.Sign sign = (org.bukkit.block.Sign) b.getState(); org.bukkit.block.Sign sign = (org.bukkit.block.Sign) b.getState();
String[] lines = sign.getLines(); String line1 = sign.getLine(0);
if(lines[0].equalsIgnoreCase(ChatColor.BLUE + "[HungerArena]")){ String line2 = sign.getLine(1);
if(lines[1].isEmpty()){ String line3 = sign.getLine(2);
String line4 = sign.getLine(3);
if(line1.equalsIgnoreCase(ChatColor.BLUE + "[HungerArena]") || line1.equalsIgnoreCase(ChatColor.BLUE + "[HA]")){
if(!line2.equals(""))
p.performCommand("ha " + line2);
else if(!line3.equals(""))
p.performCommand("ha " + line2 + " " + line3);
else
p.performCommand("ha"); p.performCommand("ha");
}else{
p.performCommand("ha " + lines[1]);
}
} }
if(lines[0].equalsIgnoreCase(ChatColor.BLUE + "[Sponsor]")){ if(line1.equalsIgnoreCase(ChatColor.BLUE + "[Sponsor]")){
p.performCommand("sponsor " + lines[1] + " " + lines[2] + " " + lines[3]); p.performCommand("sponsor " + line2 + " " + line3 + " " + line4);
} }
} }
} }
} }
@EventHandler @EventHandler
public void Create(SignChangeEvent event){ public void Create(SignChangeEvent event){
String[] lines = event.getLines(); String top = event.getLine(0);
String top = lines[0]; if(top.equalsIgnoreCase("[HungerArena]") || top.equalsIgnoreCase("[HA]") || top.equalsIgnoreCase("[Sponsor]")){
if(top.equalsIgnoreCase("[HungerArena]") || top.equalsIgnoreCase("[Sponsor]")){
event.setLine(0, ChatColor.BLUE + top); event.setLine(0, ChatColor.BLUE + top);
} }
} }

View File

@ -1,6 +1,10 @@
package me.Travja.HungerArena; package me.Travja.HungerArena;
import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -8,230 +12,64 @@ import org.bukkit.entity.Player;
public class SpawnsCommand implements CommandExecutor { public class SpawnsCommand implements CommandExecutor {
public Main plugin; public Main plugin;
int i = 0;
int a = 0;
public SpawnsCommand(Main m) { public SpawnsCommand(Main m) {
this.plugin = m; this.plugin = m;
} }
@Override @Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
Player p = (Player) sender; Player p = (Player) sender;
if(cmd.getName().equalsIgnoreCase("StartPoint")){ if(cmd.getName().equalsIgnoreCase("StartPoint")){
if(p.hasPermission("HungerArena.StartPoint")){ if(p.hasPermission("HungerArena.StartPoint")){
if(args[0].equalsIgnoreCase("1")){ if(!plugin.restricted || (plugin.restricted && plugin.worlds.contains(p.getWorld().getName()))){
double x = p.getLocation().getX(); if(args.length>= 2){
double y = p.getLocation().getY(); try{
double z = p.getLocation().getZ(); i = Integer.valueOf(args[1]);
String w = p.getWorld().getName(); a = Integer.valueOf(args[0]);
plugin.config.set("Tribute_one_spawn", x + "," + y + "," + z + "," + w); }catch(Exception e){
plugin.saveConfig(); p.sendMessage(ChatColor.RED + "Argument not an integer!");
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute one!"); }
} if(i >= 1 && i <= plugin.config.getInt("maxPlayers")){
if(args[0].equalsIgnoreCase("2")){ if(plugin.restricted && !plugin.worlds.contains(p.getWorld().getName())){
double x = p.getLocation().getX(); p.sendMessage(ChatColor.GOLD + "We ran the command, however, this isn't a world you defined in the config...");
double y = p.getLocation().getY(); p.sendMessage(ChatColor.GOLD + "If this is the right world, please disregard this message.");
double z = p.getLocation().getZ(); }
String w = p.getWorld().getName(); Location ploc = p.getLocation().getBlock().getLocation();
plugin.config.set("Tribute_two_spawn", x + "," + y + "," + z + "," + w); double x = ploc.getX();
plugin.saveConfig(); double y = ploc.getY();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute two!"); double z = ploc.getZ();
} if(plugin.location.get(a)!= null){
if(args[0].equalsIgnoreCase("3")){ if(plugin.location.get(a).size()>= i){
double x = p.getLocation().getX(); plugin.location.get(a).put(i, new Location(ploc.getWorld(), x, y, z));
double y = p.getLocation().getY(); }else{
double z = p.getLocation().getZ(); plugin.location.get(a).put(i, new Location(ploc.getWorld(), x, y, z));
String w = p.getWorld().getName(); }
plugin.config.set("Tribute_three_spawn", x + "," + y + "," + z + "," + w); }else{
plugin.saveConfig(); plugin.location.put(a, new HashMap<Integer, Location>());
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute three!"); plugin.location.get(a).put(i, new Location(ploc.getWorld(), x, y, z));
} plugin.Playing.put(a, new ArrayList<String>());
if(args[0].equalsIgnoreCase("4")){ plugin.Ready.put(a, new ArrayList<String>());
double x = p.getLocation().getX(); plugin.Dead.put(a, new ArrayList<String>());
double y = p.getLocation().getY(); plugin.Quit.put(a, new ArrayList<String>());
double z = p.getLocation().getZ(); plugin.Out.put(a, new ArrayList<String>());
String w = p.getWorld().getName(); plugin.Watching.put(a, new ArrayList<String>());
plugin.config.set("Tribute_four_spawn", x + "," + y + "," + z + "," + w); plugin.NeedConfirm.put(a, new ArrayList<String>());
plugin.saveConfig(); plugin.inArena.put(a, new ArrayList<String>());
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute four!"); plugin.Frozen.put(a, new ArrayList<String>());
} plugin.arena.put(a, new ArrayList<String>());
if(args[0].equalsIgnoreCase("5")){ plugin.canjoin.put(a, false);
double x = p.getLocation().getX(); plugin.open.put(a, true);
double y = p.getLocation().getY(); }
double z = p.getLocation().getZ(); String coords = plugin.location.get(a).get(i).getWorld().getName() + "," + plugin.location.get(a).get(i).getX() + "," + plugin.location.get(a).get(i).getY() + "," + plugin.location.get(a).get(i).getZ();
String w = p.getWorld().getName(); plugin.spawns.set("Spawns." + a + "." + i, coords);
plugin.config.set("Tribute_five_spawn", x + "," + y + "," + z + "," + w); plugin.saveSpawns();
plugin.saveConfig(); plugin.maxPlayers.put(a, plugin.location.get(a).size());
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute five!"); p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute " + i + " in arena " + a + "!");
} }else{
if(args[0].equalsIgnoreCase("6")){ p.sendMessage(ChatColor.RED + "You can't go past " + plugin.maxPlayers + " players!");
double x = p.getLocation().getX(); }
double y = p.getLocation().getY(); }
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_six_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute six!");
}
if(args[0].equalsIgnoreCase("7")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_seven_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute seven!");
}
if(args[0].equalsIgnoreCase("8")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_eight_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute eight!");
}
if(args[0].equalsIgnoreCase("9")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_nine_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute nine!");
}
if(args[0].equalsIgnoreCase("10")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_ten_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute ten!");
}
if(args[0].equalsIgnoreCase("11")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_eleven_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute eleven!");
}
if(args[0].equalsIgnoreCase("12")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_twelve_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twelve!");
}
if(args[0].equalsIgnoreCase("13")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_thirteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute thirteen!");
}
if(args[0].equalsIgnoreCase("14")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_fourteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute fourteen!");
}
if(args[0].equalsIgnoreCase("15")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_fifteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute fifteen!");
}
if(args[0].equalsIgnoreCase("16")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_sixteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute sixteen!");
}
if(args[0].equalsIgnoreCase("17")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_seventeen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute seventeen!");
}
if(args[0].equalsIgnoreCase("18")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_eighteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute eighteen!");
}
if(args[0].equalsIgnoreCase("19")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_nineteen_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute nineteen!");
}
if(args[0].equalsIgnoreCase("20")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_twenty_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twenty!");
}
if(args[0].equalsIgnoreCase("21")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_twentyone_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twentyone!");
}
if(args[0].equalsIgnoreCase("22")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_twentytwo_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twentytwo!");
}
if(args[0].equalsIgnoreCase("23")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_twentythree_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twentythree!");
}
if(args[0].equalsIgnoreCase("24")){
double x = p.getLocation().getX();
double y = p.getLocation().getY();
double z = p.getLocation().getZ();
String w = p.getWorld().getName();
plugin.config.set("Tribute_twentyfour_spawn", x + "," + y + "," + z + "," + w);
plugin.saveConfig();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twentyfour!");
} }
}else{ }else{
p.sendMessage(ChatColor.RED + "You don't have permission!"); p.sendMessage(ChatColor.RED + "You don't have permission!");

View File

@ -9,43 +9,68 @@ import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.*;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
public class SpectatorListener implements Listener { public class SpectatorListener implements Listener {
public Main plugin; public Main plugin;
public SpectatorListener(Main m){ public SpectatorListener(Main m){
this.plugin = m; this.plugin = m;
} }
int i = 0;
@EventHandler @EventHandler
public void SpectatorDrops(PlayerDropItemEvent event){ public void SpectatorDrops(PlayerDropItemEvent event){
Player p = event.getPlayer(); Player p = event.getPlayer();
String pname = p.getDisplayName(); String pname = p.getName();
if(plugin.Watching.contains(pname)){ for(i = 0; i < plugin.Watching.size(); i++){
event.setCancelled(true); if(plugin.Watching.get(i)!= null){
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!"); if(plugin.Watching.get(i).contains(pname)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
} }
} }
@EventHandler @EventHandler
public void SpectatorInteractions(PlayerInteractEvent event){ public void SpectatorInteractBlock(PlayerInteractEvent event){
Player p = event.getPlayer(); Player p = event.getPlayer();
String pname = p.getDisplayName(); String pname = p.getName();
if(plugin.Watching.contains(pname)){ for(i = 0; i < plugin.Watching.size(); i++){
event.setCancelled(true); if(plugin.Watching.get(i)!= null){
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!"); if(plugin.Watching.get(i).contains(pname)){
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();
String pname = p.getName();
for(i = 0; i < plugin.Watching.size(); i++){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(pname)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
} }
} }
@EventHandler @EventHandler
public void SpectatorItems(PlayerPickupItemEvent event){ public void SpectatorItems(PlayerPickupItemEvent event){
Player p = event.getPlayer(); Player p = event.getPlayer();
String pname = p.getDisplayName(); String pname = p.getName();
if(plugin.Watching.contains(pname)){ for(i = 0; i < plugin.Watching.size(); i++){
event.setCancelled(true); if(plugin.Watching.get(i)!= null){
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!"); if(plugin.Watching.get(i).contains(pname)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
} }
} }
@EventHandler @EventHandler
@ -53,72 +78,93 @@ public class SpectatorListener implements Listener {
Entity offense = event.getDamager(); Entity offense = event.getDamager();
if(offense instanceof Player){ if(offense instanceof Player){
Player Attacker = (Player) event.getDamager(); Player Attacker = (Player) event.getDamager();
String attackerName = Attacker.getDisplayName(); String attackerName = Attacker.getName();
if(plugin.Watching.contains(attackerName)){ for(i = 0; i < plugin.Watching.size(); i++){
event.setCancelled(true); if(plugin.Watching.get(i)!= null){
Attacker.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!"); if(plugin.Watching.get(i).contains(attackerName)){
event.setCancelled(true);
Attacker.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
} }
}else if(event.getDamager() instanceof Projectile){ }else if(event.getDamager() instanceof Projectile){
Projectile arrow = (Projectile) offense; Projectile arrow = (Projectile) offense;
if(arrow.getShooter() instanceof Player){ if(arrow.getShooter() instanceof Player){
Player BowMan = (Player) arrow.getShooter(); Player BowMan = (Player) arrow.getShooter();
String bowManName = BowMan.getDisplayName(); String bowManName = BowMan.getName();
if(plugin.Watching.contains(bowManName)){ for(i = 0; i < plugin.Watching.size(); i++){
event.setCancelled(true); if(plugin.Watching.get(i)!= null){
BowMan.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!"); if(plugin.Watching.get(i).contains(bowManName)){
} event.setCancelled(true);
} BowMan.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
} }
}
@EventHandler
public void SpectatorBlocks(BlockBreakEvent event){
Player p = event.getPlayer();
String pname = p.getDisplayName();
if(plugin.Watching.contains(pname)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorJoin(PlayerJoinEvent event){
Player p = event.getPlayer();
String pname = p.getDisplayName();
final Player player = event.getPlayer();
if(plugin.Watching.contains(pname)){
if(plugin.canjoin== false){
String[] Spawncoords = plugin.config.getString("Spawn_coords").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);
for(Player everyone:plugin.getServer().getOnlinePlayers()){
everyone.showPlayer(p);
}
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
player.teleport(Spawn);
player.sendMessage(ChatColor.RED + "You have been teleported to spawn because the game is over!");
} }
}, 40L);
plugin.Watching.remove(pname);
}else{
p.setAllowFlight(true);
p.setFlying(true);
for(Player everyone:plugin.getServer().getOnlinePlayers()){
everyone.hidePlayer(p);
} }
} }
} }
} }
@EventHandler
public void SpectatorBlockBreak(BlockBreakEvent event){
Player p = event.getPlayer();
String pname = p.getName();
for(i = 0; i < plugin.Watching.size(); i++){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(pname)){
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();
String pname = p.getName();
for(i = 0; i < plugin.Watching.size(); i++){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(pname)){
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(i = 0; i < plugin.Watching.size(); i++){
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").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);
}
}
}
}
@EventHandler @EventHandler
public void MobNerf(EntityTargetEvent event){ public void MobNerf(EntityTargetEvent event){
Entity target = event.getTarget(); Entity target = event.getTarget();
Entity e = event.getEntity();
if (e instanceof Player) {
return;
}
if(target instanceof Player){ if(target instanceof Player){
String targetName = ((Player) target).getDisplayName(); String targetName = ((Player) target).getName();
if(plugin.Watching.contains(targetName)){ for(i = 0; i < plugin.Watching.size(); i++){
event.setCancelled(true); if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(targetName)){
event.setTarget(null);
}
}
} }
} }
} }

View File

@ -19,11 +19,11 @@ public class SponsorCommands implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if(cmd.getName().equalsIgnoreCase("Sponsor")){ if(cmd.getName().equalsIgnoreCase("Sponsor")){
if(sender instanceof Player){ if(sender instanceof Player){
int i = 0;
Player p = (Player) sender; Player p = (Player) sender;
String pname = p.getName(); String pname = p.getName();
String epname = p.getDisplayName();
if(p.hasPermission("HungerArena.Sponsor")){ if(p.hasPermission("HungerArena.Sponsor")){
if(!plugin.Playing.contains(epname)){ if(plugin.getArena(p)== null){
if(args.length== 0){ if(args.length== 0){
p.sendMessage(ChatColor.RED + "You didn't specify a tribute!"); p.sendMessage(ChatColor.RED + "You didn't specify a tribute!");
return false; return false;
@ -35,28 +35,81 @@ public class SponsorCommands implements CommandExecutor {
p.sendMessage(ChatColor.RED + "You didn't specify an amount!"); p.sendMessage(ChatColor.RED + "You didn't specify an amount!");
} }
if(args.length== 3){ if(args.length== 3){
Player target = Bukkit.getPlayer(args[0]); Player target = Bukkit.getServer().getPlayer(args[0]);
if(args[1].equalsIgnoreCase("57") || args[1].equalsIgnoreCase("7")){ if(plugin.getArena(target)== null){
p.sendMessage(ChatColor.RED + "You can't sponsor that item!"); p.sendMessage(ChatColor.RED + "That person isn't playing!");
}else{ }else{
int ID = Integer.parseInt(args[1]); try{
int Amount = Integer.parseInt(args[2]); int ID = Integer.parseInt(args[1]);
ItemStack sponsoritem = new ItemStack(ID, Amount); int Amount = Integer.parseInt(args[2]);
if(p.getInventory().contains(plugin.config.getInt("Sponsor_Cost.ID"), plugin.config.getInt("Sponsor_Cost.Amount")*Amount)){ if((!plugin.management.getStringList("sponsors.blacklist").isEmpty() && !plugin.management.getStringList("sponsors.blacklist").contains(ID)) || plugin.management.getStringList("sponsors.blacklist").isEmpty()){
if(!plugin.Playing.contains(target.getDisplayName())){ ItemStack sponsoritem = new ItemStack(ID, Amount);
p.sendMessage(ChatColor.RED + "That person isn't playing!"); if(!plugin.config.getBoolean("sponsorEco.enabled")){
}else{ for(ItemStack Costs: plugin.Cost){
if(args[0].equalsIgnoreCase(pname)){ if(p.getInventory().contains(Costs)){
p.sendMessage(ChatColor.RED + "You can't sponsor yourself!"); i = i+1;
if(plugin.Cost.size() == i){
if(args[0].equalsIgnoreCase(pname)){
p.sendMessage(ChatColor.RED + "You can't sponsor yourself!");
}else{
target.sendMessage(ChatColor.AQUA + "You have been Sponsored!");
target.getInventory().addItem(sponsoritem);
p.sendMessage("You have sponsored " + target.getName() + "!");
for(ItemStack aCosts: plugin.Cost){
p.getInventory().removeItem(aCosts);
}
}
}
}
}
if(plugin.Cost.size() > i){
p.sendMessage(ChatColor.RED + "You don't have the necessary items to sponsor!");
}
}else{ }else{
target.sendMessage(ChatColor.AQUA + "You have been Sponsored!"); if(args[0].equalsIgnoreCase(pname)){
target.getInventory().addItem(sponsoritem); p.sendMessage(ChatColor.RED + "You can't sponsor yourself!");
p.sendMessage("You have sponsored " + target.getName() + "!"); }else if(!(plugin.econ.getBalance(pname) < plugin.config.getDouble("sponsorEco.cost"))){
p.getInventory().removeItem(plugin.Cost); if(!plugin.Cost.isEmpty()){
for(ItemStack Costs: plugin.Cost){
if(p.getInventory().contains(Costs)){
i = i+1;
if(plugin.Cost.size()== i){
if(args[0].equalsIgnoreCase(pname)){
p.sendMessage(ChatColor.RED + "You can't sponsor yourself!");
}else{
target.sendMessage(ChatColor.AQUA + "You have been Sponsored!");
target.getInventory().addItem(sponsoritem);
p.sendMessage("You have sponsored " + target.getName() + "!");
plugin.econ.withdrawPlayer(pname, plugin.config.getDouble("sponsorEco.cost"));
for(ItemStack aCosts: plugin.Cost){
p.getInventory().removeItem(aCosts);
}
}
}
}
}
if(plugin.Cost.size() > i){
p.sendMessage(ChatColor.RED + "You don't have the necessary items to sponsor!");
}
}else{
target.sendMessage(ChatColor.AQUA + "You have been Sponsored!");
target.getInventory().addItem(sponsoritem);
p.sendMessage("You have sponsored " + target.getName() + "!");
plugin.econ.withdrawPlayer(pname, plugin.config.getDouble("sponsorEco.cost"));
}
}else{
p.sendMessage(ChatColor.RED + "You don't have enough money to do that!");
}
}
}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);
} }
} }
}else{ }catch(Exception e){
p.sendMessage(ChatColor.RED + "You don't have the necessary items to sponsor!"); p.sendMessage(ChatColor.RED + "Something went wrong there... Make sure that you do like this /sponsor [name] [number] [number]");
} }
} }
} }
@ -79,20 +132,28 @@ public class SponsorCommands implements CommandExecutor {
} }
if(args.length== 3){ if(args.length== 3){
Player target = Bukkit.getPlayer(args[0]); Player target = Bukkit.getPlayer(args[0]);
if(args[1].equalsIgnoreCase("57") || args[1].equalsIgnoreCase("7")){ int ID = Integer.parseInt(args[1]);
sender.sendMessage(ChatColor.RED + "You can't sponsor that item!"); int Amount = Integer.parseInt(args[2]);
}else{ try{
int ID = Integer.parseInt(args[1]); if((!plugin.management.getStringList("sponsors.blacklist").isEmpty() && !plugin.management.getStringList("sponsors.blacklist").contains(ID)) || plugin.management.getStringList("sponsors.blacklist").isEmpty()){
int Amount = Integer.parseInt(args[2]); ItemStack sponsoritem = new ItemStack(ID, Amount);
ItemStack sponsoritem = new ItemStack(ID, Amount); if(plugin.getArena(target)== null){
if(!plugin.Playing.contains(target.getDisplayName())){ sender.sendMessage(ChatColor.RED + "That person isn't playing!");
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{ }else{
sender.sendMessage(ChatColor.RED + "You can't sponsor yourself!"); sender.sendMessage(ChatColor.RED + "You can't sponsor that item!");
target.sendMessage(ChatColor.AQUA + "You have been Sponsored!"); sender.sendMessage(ChatColor.GREEN + "Other items you can't sponsor are:");
target.getInventory().addItem(sponsoritem); for(String blacklist: plugin.management.getStringList("sponsors.blacklist")){
sender.sendMessage("You have sponsored " + target.getName() + "!"); 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]");
} }
} }
} }

View File

@ -1,402 +0,0 @@
package me.Travja.HungerArena;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
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;
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();
if(plugin.getArena(p)!= null){
int a = plugin.getArena(p);
if(!event.isCancelled()){
if(plugin.Playing.get(a).contains(pname)){
if(plugin.config.getString("Protected_Arena").equalsIgnoreCase("True")){
p.sendMessage(ChatColor.RED + "You can't break blocks while playing!");
}
if(plugin.canjoin.get(a)){
if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(p.getWorld().getName()))){
if(!plugin.management.getBoolean("blocks.useWhitelistAsBlacklist")){
if(!plugin.management.getIntegerList("blocks.whitelist").isEmpty()){
if(!plugin.management.getIntegerList("blocks.whitelist").contains(b.getTypeId())){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "That is an illegal block!");
}else if(plugin.management.getIntegerList("blocks.whitelist").contains(b.getTypeId())){
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
byte m = b.getData();
String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + a;
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();
}
}
}else{
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "That is an illegal block!");
}
}else{
if(!plugin.management.getIntegerList("blocks.whitelist").isEmpty()){
if(!plugin.management.getIntegerList("blocks.whitelist").contains(b.getTypeId())){
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
byte m = b.getData();
String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + a;
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();
}
}else if(plugin.management.getIntegerList("blocks.whitelist").contains(b.getTypeId())){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "That is an illegal block");
}
}else{
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
byte m = b.getData();
String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + a;
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();
}
}
}
}
}
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void Explosion(EntityExplodeEvent event){
List<Block> blocksd = event.blockList();
Entity e = event.getEntity();
int i = 0;
if(!event.isCancelled()){
for(i = 1; i <= plugin.canjoin.size(); i++){
if(plugin.canjoin.get(i)){
i = plugin.canjoin.size()+1;
if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(event.getEntity().getWorld().getName()))){
if(e.getType()== EntityType.PRIMED_TNT){
if(!plugin.data.getStringList("Blocks_Placed").contains(e.getLocation().getWorld() + "," + e.getLocation().getX() + "," + e.getLocation().getY() + "," + e.getLocation().getZ()) /*|| !plugin.data.getStringList("Blocks_Destroyed").contains(e.getLocation().getWorld() + "," + e.getLocation().getX() + "," + e.getLocation().getY() + "," + e.getLocation().getZ())*/){
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
blocks.add(e.getLocation().getWorld().getName() + "," + e.getLocation().getX() + "," + e.getLocation().getY() + "," + e.getLocation().getZ() + ",46" + ",0");
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveData();
}
}
for(Block b:blocksd){
String w = event.getEntity().getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
byte m = b.getData();
String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + i;
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + i) || !plugin.data.getStringList("Blocks_Destroyed").contains(w + "," + x + "," + y + "," + z + "," + i)){
blocks.add(coords);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveData();
}
}
}
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void burningBlocks(BlockBurnEvent event){
Block b = event.getBlock();
int i = 0;
if(!event.isCancelled()){
for(i = 1; i <= plugin.canjoin.size(); i++){
if(plugin.canjoin.get(i)){
i = plugin.canjoin.size()+1;
if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(b.getWorld().getName()))){
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
byte m = b.getData();
String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + i;
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + i)){
blocks.add(coords);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveData();
}
}
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void blockPlace(BlockPlaceEvent event){
Block b = event.getBlock();
Player p = event.getPlayer();
if(plugin.getArena(p)!= null){
int a = plugin.getArena(p);
if(!event.isCancelled()){
if(plugin.Playing.get(a).contains(p.getName())){
if(plugin.canjoin.get(a)){
if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").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();
int x = br.getX();
int y = br.getY();
int z = br.getZ();
String coords = w + "," + x + "," + y + "," + z + "," + a;
p.sendMessage(ChatColor.GREEN + "Sand/Gravel will land at " + coords);
List<String> blocks = plugin.data.getStringList("Blocks_Placed");
blocks.add(coords);
plugin.data.set("Blocks_Placed", blocks);
plugin.saveData();
}
}
}else{
if(b.getType()!= Material.SAND || b.getType()!= Material.GRAVEL){
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
String coords = w + "," + x + "," + y + "," + z + "," + a;
List<String> blocks = plugin.data.getStringList("Blocks_Placed");
blocks.add(coords);
plugin.data.set("Blocks_Placed", blocks);
plugin.saveData();
}
}
}
}
}
}
}
}
@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.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(event.getPlayer().getWorld().getName()))){
Block b = event.getBlockClicked().getRelative(event.getBlockFace());
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
String coords = w + "," + x + "," + y + "," + z + "," + a;
List<String> blocks = plugin.data.getStringList("Blocks_Placed");
blocks.add(coords);
plugin.data.set("Blocks_Placed", blocks);
plugin.saveData();
}
}
}
}
}
}
@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.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(event.getPlayer().getWorld().getName()))){
Block b = event.getBlockClicked().getRelative(event.getBlockFace());
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
byte m = b.getData();
String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + a;
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();
}
}
}
}
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void blockMelt(BlockFadeEvent event){
int i = 0;
if(!event.isCancelled()){
for(i = 1; i <= plugin.canjoin.size(); i++){
if(plugin.canjoin.get(i)){
if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(event.getBlock().getWorld().getName()))){
i = plugin.canjoin.size()+1;
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();
byte m = b.getData();
String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + i;
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + i)){
blocks.add(coords);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveData();
}
}
}
}
}
}
/*@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.data.getStringList("Blocks_Placed");
blocks.add(coords);
plugin.data.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.data.getStringList("Blocks_Placed");
blocks.add(coords);
plugin.data.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.data.getStringList("Blocks_Destroyed");
blocks.add(coords);
plugin.data.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.data.getStringList("Blocks_Placed");
blocks.add(coords);
plugin.data.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.data.getStringList("Blocks_Placed");
blocks.add(coords);
plugin.data.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.data.getStringList("Blocks_Placed");
blocks.add(coords);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveConfig();
}
}
}*/
}

View File

@ -1,26 +0,0 @@
package me.Travja.HungerArena;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
public class Blocks implements Listener {
public Main plugin;
public Blocks(Main m) {
this.plugin = m;
}
@EventHandler
public void BreakBlock(BlockBreakEvent event){
Player p = event.getPlayer();
String pname = p.getDisplayName();
if(plugin.Playing.contains(pname)){
if(plugin.config.getString("Protected_Arena").equalsIgnoreCase("True")){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You can't break blocks when you're playing!");
}
}
}
}

View File

@ -1,50 +0,0 @@
package me.Travja.HungerArena;
import java.util.List;
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,85 +0,0 @@
package me.Travja.HungerArena;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.Chest;
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.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.getConfig().getStringList("StorageXYZ").contains(blockx + "," + blocky + "," + blockz)) {
if(p.hasPermission("HungerArena.Chest.Break") && plugin.getArena(p)== null){
List<String> list2 = plugin.getConfig().getStringList("StorageXYZ");
list2.remove(blockx + "," + blocky + "," + blockz);
plugin.getConfig().set("Storage." + blockx + "," + blocky+ "," + blockz, null);
plugin.getConfig().set("StorageXYZ", list2);
plugin.getConfig().options().copyDefaults(true);
plugin.saveConfig();
p.sendMessage("Chest Removed!");
} else {
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "[HungerArena] That's a storage chest! 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.worlds.contains(p.getWorld().getName()))){
if(block!= null){
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);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Arena", a);
}
List<String> list2 = plugin.getConfig().getStringList("StorageXYZ");
if(!list2.contains(blockx + "," + blocky + "," + blockz)){
list2.add(blockx + "," + blocky + "," + blockz);
plugin.getConfig().set("StorageXYZ", list2);
plugin.getConfig().options().copyDefaults(true);
plugin.saveConfig();
p.sendMessage(ChatColor.GREEN + "Thank you for finding this undiscovered chest, it has been stored!!");
}
}
}
}
}
}
}
}

View File

@ -1,149 +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();
int i = 0;
int x = 0;
for(x = 1; x < plugin.Watching.size(); x++){
if(plugin.Watching.get(x).contains(p.getName())){
if(!p.hasPermission("HungerArena.UseCommands")){
if(!plugin.management.getStringList("commands.whitelist").isEmpty()){
for(String whitelist: plugin.management.getStringList("commands.whitelist")){
i = i+1;
if(i== plugin.management.getStringList("commands.whitelist").size()){
if(!cmd.toLowerCase().startsWith(whitelist.toLowerCase()) || !cmd.toLowerCase().startsWith("/ha")){
event.setCancelled(true);
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 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");
}
}
}
}else if(!cmd.toLowerCase().startsWith("/ha")){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are only allowed to perform /ha commands!");
}
}else if(!cmd.toLowerCase().startsWith("/ha")){
if(cmd.toLowerCase().startsWith("/spawn")){
event.setCancelled(true);
p.sendMessage("You have perms for all commands except this one!");
}
}
}
}
if(plugin.getArena(p)!= null){
if(!p.hasPermission("HungerArena.UseCommands")){
if(!plugin.management.getStringList("commands.whitelist").isEmpty()){
for(String whitelist: plugin.management.getStringList("commands.whitelist")){
i = i+1;
if(i== plugin.management.getStringList("commands.whitelist").size()){
if(!cmd.toLowerCase().startsWith(whitelist.toLowerCase()) || !cmd.toLowerCase().startsWith("/ha")){
event.setCancelled(true);
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 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");
}
}
}
}else if(!cmd.toLowerCase().startsWith("/ha")){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are only allowed to perform /ha commands!");
}
}else if(!cmd.toLowerCase().startsWith("/ha")){
if(cmd.toLowerCase().startsWith("/spawn")){
event.setCancelled(true);
p.sendMessage("You have perms for all commands except this one!");
}
}
}else if(cmd.toLowerCase().equals("/back")){
for(i = 1; i < plugin.Dead.size(); i++){
if(plugin.Dead.get(i).contains(pname) && plugin.canjoin.get(i))
plugin.Tele.add(p);
}
}else if(cmd.startsWith("/tp") || cmd.startsWith("/tpa") || cmd.startsWith("/tpo")){
String[] args = cmd.split(" ");
Player arg1 = null;
Player arg2 = null;
if(args.length == 2){
if(Bukkit.getPlayer(args[0]) != null && Bukkit.getPlayer(args[1]) != null){
arg1 = Bukkit.getPlayer(args[0]);
arg2 = Bukkit.getPlayer(args[1]);
if(plugin.isSpectating(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "Invalid command for spectating, using /ha tp " + arg2);
p.performCommand("/ha tp " + arg2);
}else if(plugin.getArena(arg1)!= null || plugin.getArena(arg2)!= null){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You can't teleport to other tributes!");
}
}
}else if(args.length == 1){
if(Bukkit.getPlayer(args[0]) != null){
arg1 = Bukkit.getPlayer(args[0]);
if(plugin.isSpectating(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "Invalid command for spectating, using /ha tp " + arg1);
p.performCommand("/ha tp " + arg1);
}else if(plugin.getArena(arg1)!= null || plugin.getArena(p)!= null){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You can't teleport to other tributes!");
}
}
}
}
}
}

View File

@ -1,151 +0,0 @@
package me.Travja.HungerArena;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
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.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
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
public void onPlayerRespawn(PlayerRespawnEvent event){
final Player p = event.getPlayer();
String pname = p.getName();
for(i = 1; i < plugin.Dead.size(); i++){
if(plugin.Dead.get(i).contains(pname)){
String[] Spawncoords = plugin.spawns.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]);
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
p.teleport(Spawn);
}
}, 10L);
}
}
}
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event){
Player p = event.getEntity();
Server s = p.getServer();
String pname = p.getName();
int players = plugin.Playing.size()-1;
String leftmsg = null;
for(i = 1; i < plugin.Frozen.size(); i++){
if(plugin.Frozen.get(i).contains(pname)){
if(plugin.getArena(p)!= null){
a = plugin.getArena(p);
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);
plugin.Dead.get(a).add(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 if(plugin.getArena(p)!= null){
a = plugin.getArena(p);
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().getItemInHand().getType().getId()== 0){
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);
}
}
plugin.winner(a);
}else{
Player killer = p.getKiller();
String killername = killer.getName();
String weapon = killer.getItemInHand().getType().toString().replace('_', ' ');
String msg = ChatColor.LIGHT_PURPLE + "**BOOM** Tribute " + pname + " was killed by tribute " + killername + " with a(n) " + 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);
}
}
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 natural causes!");
g.sendMessage(leftmsg);
}
}
plugin.winner(a);
}
}
}
}
}

View File

@ -1,63 +0,0 @@
package me.Travja.HungerArena;
import java.util.HashMap;
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;
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>();
@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")){
for(String players: plugin.Playing.get(a)){
final Player playing = plugin.getServer().getPlayerExact(players);
i = plugin.Playing.get(a).indexOf(players);
if(!timeUp.get(a)){
if(!playing.getLocation().getBlock().getLocation().equals(plugin.location.get(a).get(i))){
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);
}
}
},30L);
}
}else{
if(!playing.getLocation().getBlock().getLocation().equals(plugin.location.get(a).get(i))){
if(!plugin.Dead.get(a).contains(playing.getName())){
World world = playing.getLocation().getWorld();
world.createExplosion(playing.getLocation(), 0.0F, false);
playing.setHealth(0);
}
}
}
}
}else{
for(String players:plugin.Playing.get(a)){
Player playing = plugin.getServer().getPlayerExact(players);
i = plugin.Playing.get(a).indexOf(players)+1;
if(!playing.getLocation().getBlock().getLocation().equals(plugin.location.get(a).get(i))){
playing.teleport(plugin.location.get(a).get(i));
}
}
}
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,156 +0,0 @@
package me.Travja.HungerArena;
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.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
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 i = 0;
int a = 0;
@EventHandler
public void onJoin(PlayerJoinEvent evt) {
Player p = evt.getPlayer();
for(i = 1; i <= plugin.Watching.size(); i++){
for (String s : plugin.Watching.get(i)) {
Player spectator = Bukkit.getServer().getPlayerExact(s);
p.hidePlayer(spectator);
}
}
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event){
final Player p = event.getPlayer();
final String pname = p.getName();
for(i = 1; i <= plugin.Watching.size(); i++){
for(String s: plugin.Watching.get(i)){
Player spectator = plugin.getServer().getPlayerExact(s);
p.hidePlayer(spectator);
}
}
for(i = 1; i <= plugin.Out.size(); i++){
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);
}
}
for(i = 1; i <= plugin.Quit.size(); i++){
if(plugin.Quit.get(i).contains(pname)){
String[] Spawncoords = plugin.spawns.getString("Spawn_coords").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/forfeited!");
}
}, 40L);
}
}
for(i = 1; i <= plugin.Dead.size(); i++){
if(plugin.Dead.get(i).contains(pname)){
String[] Spawncoords = plugin.spawns.getString("Spawn_coords").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/forfeited!");
}
}, 40L);
}
}
for(i = 1; i <= plugin.inArena.size(); i++){
if(plugin.inArena.get(i)!= null){
if(plugin.inArena.get(i).contains(pname)){
String[] Spawncoords = plugin.spawns.getString("Spawn_coords").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.");
}
}, 40L);
}
}
}
}
@EventHandler
public void onQuit(PlayerQuitEvent evt) {
Player p = evt.getPlayer();
String pname = p.getName();
for(i = 1; i <= plugin.Frozen.size(); i++){
if (plugin.Frozen.get(i).contains(pname)) {
plugin.Frozen.remove(pname);
String[] Spawncoords = plugin.spawns.getString("Spawn_coords").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);
}
}
}
@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.remove(pname);
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,511 +0,0 @@
package me.Travja.HungerArena;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.command.CommandExecutor;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class Main extends JavaPlugin{
static Logger log;
public HashMap<Integer, List<String>> Playing = new HashMap<Integer, List<String>>();
public HashMap<Integer, List<String>> Ready = new HashMap<Integer, List<String>>();
public HashMap<Integer, List<String>> Dead = new HashMap<Integer, List<String>>();
public HashMap<Integer, List<String>> Quit = new HashMap<Integer, List<String>>();
public HashMap<Integer, List<String>> Out = new HashMap<Integer, List<String>>();
public HashMap<Integer, List<String>> Watching = new HashMap<Integer, List<String>>();
public HashMap<Integer, List<String>> NeedConfirm = new HashMap<Integer, List<String>>();
public HashMap<Integer, HashMap<Integer, Location>> location = new HashMap<Integer, HashMap<Integer, Location>>();
public ArrayList<Player> Tele = new ArrayList<Player>();
public HashMap<Integer, List<String>> inArena = new HashMap<Integer, List<String>>();
public HashMap<Integer, List<String>> Frozen = new HashMap<Integer, List<String>>();
public HashMap<Integer, List<String>> arena = new HashMap<Integer, List<String>>();
public HashMap<Integer, Boolean> canjoin = new HashMap<Integer, Boolean>();
public HashMap<Integer, Integer> maxPlayers = new HashMap<Integer, Integer>();
public HashMap<Integer, Boolean> open = new HashMap<Integer, Boolean>();
public List<String> worlds;
public Listener DeathListener = new DeathListener(this);
public Listener SpectatorListener = new SpectatorListener(this);
public Listener FreezeListener = new FreezeListener(this);
public Listener JoinAndQuitListener = new JoinAndQuitListener(this);
public Listener ChatListener = new ChatListener(this);
public Listener Chests = new Chests(this);
public Listener PvP = new PvP(this);
public Listener CommandBlock = new CommandBlock(this);
public Listener Damage = new DmgListener(this);
public Listener Teleport = new TeleportListener(this);
public Listener Signs = new Signs(this);
public Listener BlockStorage = new BlockStorage(this);
public Listener WinGames = new WinGamesListener(this);
public CommandExecutor HaCommands = new HaCommands(this);
public CommandExecutor SponsorCommands = new SponsorCommands(this);
public CommandExecutor SpawnsCommand = new SpawnsCommand(this);
public boolean exists;
public boolean restricted;
public FileConfiguration config;
public FileConfiguration spawns = null;
public File spawnsFile = null;
public FileConfiguration data = null;
public File dataFile = null;
public File managementFile = null;
public FileConfiguration management = null;
public ArrayList<ItemStack> Reward = new ArrayList<ItemStack>();
public ArrayList<ItemStack> Cost = new ArrayList<ItemStack>();
public ArrayList<ItemStack> Fee = new ArrayList<ItemStack>();
public boolean vault = false;
public boolean eco = false;
public Economy econ = null;
int i = 0;
int v = 0;
int start = 0;
int deathtime = 0;
int timetodeath = 0;
int a = 0;
public void onEnable(){
log = this.getLogger();
config = this.getConfig();
config.options().copyDefaults(true);
this.saveDefaultConfig();
spawns = this.getSpawns();
spawns.options().copyDefaults(true);
this.saveSpawns();
data = this.getData();
data.options().copyDefaults(true);
this.saveData();
management = this.getManagement();
management.options().copyDefaults(true);
this.saveManagement();
getServer().getPluginManager().registerEvents(DeathListener, this);
getServer().getPluginManager().registerEvents(SpectatorListener, this);
getServer().getPluginManager().registerEvents(FreezeListener, this);
getServer().getPluginManager().registerEvents(JoinAndQuitListener, this);
getServer().getPluginManager().registerEvents(ChatListener, this);
getServer().getPluginManager().registerEvents(Chests, this);
getServer().getPluginManager().registerEvents(PvP, this);
getServer().getPluginManager().registerEvents(CommandBlock, this);
getServer().getPluginManager().registerEvents(Signs, this);
getServer().getPluginManager().registerEvents(BlockStorage, this);
getServer().getPluginManager().registerEvents(WinGames, this);
getServer().getPluginManager().registerEvents(Damage, this);
getCommand("Ha").setExecutor(HaCommands);
getCommand("Sponsor").setExecutor(SponsorCommands);
getCommand("Startpoint").setExecutor(SpawnsCommand);
i = 1;
//TODO THIS CRAP
if(spawns.getConfigurationSection("Spawns")!= null){
Map<String, Object> temp = spawns.getConfigurationSection("Spawns").getValues(false);
for(Entry<String, Object> entry: temp.entrySet()){
if(spawns.getConfigurationSection("Spawns." + entry.getKey())!= null){
Map<String, Object> temp2 = spawns.getConfigurationSection("Spawns." + entry.getKey()).getValues(false);
for(Map.Entry<String, Object> e: temp2.entrySet()){
if(spawns.get("Spawns." + entry.getKey() + "." + e.getKey())!= null){
String[] coords = ((String) spawns.get("Spawns." + entry.getKey() + "." + e.getKey())).split(",");
Integer a = Integer.parseInt(entry.getKey());
Integer s = Integer.parseInt(e.getKey());
if(location.get(a)== null)
location.put(a, new HashMap<Integer, Location>());
log.info("Added spawn number " + s + " in arena " + a + "!");
location.get(a).put(s, new Location(getServer().getWorld(coords[0]), Double.parseDouble(coords[1]), Double.parseDouble(coords[2]), Double.parseDouble(coords[3])));
}
}
}
}
}
for(i = 1; i <= location.size(); i++){
log.info("Loaded " + location.get(i).size() + " tribute spawns for arena " + i + "!");
Playing.put(i, new ArrayList<String>());
Ready.put(i, new ArrayList<String>());
Dead.put(i, new ArrayList<String>());
Quit.put(i, new ArrayList<String>());
Out.put(i, new ArrayList<String>());
Watching.put(i, new ArrayList<String>());
NeedConfirm.put(i, new ArrayList<String>());
inArena.put(i, new ArrayList<String>());
Frozen.put(i, new ArrayList<String>());
arena.put(i, new ArrayList<String>());
canjoin.put(i, false);
if(location.get(i).size()== config.getInt("maxPlayers")){
maxPlayers.put(i, location.get(i).size());
}else if(location.size()< config.getInt("maxPlayers")){
maxPlayers.put(i, location.get(i).size());
}else if(location.size()> config.getInt("maxPlayers")){
maxPlayers.put(i, config.getInt("maxPlayers"));
}
log.info("Max players is for arena " + i + " is " + maxPlayers.get(i));
open.put(i, true);
}
if (setupEconomy()) {
log.info("Found Vault! Hooking in for economy!");
}
if (config.getDouble("config.version") != 1.3) {
config.set("config.version", 1.3);
config.set("rewardEco.enabled", false);
config.set("rewardEco.reward", 100);
}
if (config.getBoolean("rewardEco.enabled", true) || config.getBoolean("sponsorEco.enabled", true) || config.getBoolean("EntryFee.eco", true)) {
if (vault == true) {
log.info("Economy hook deployed.");
eco = true;
}else{
log.info("You want economy support... yet you either don't have Vault or don't have an economy plugin. Sorry, can't give you it.");
}
}
if (!eco) {
if (vault == true) {
log.info("We see that you have Vault on your server. To set economy support to true, enable it in the config.");
}
}
try{
for(String rewards: config.getStringList("Reward")){
String[] rinfo = rewards.split(",");
Reward.add(new ItemStack(Integer.parseInt(rinfo[0]), Integer.parseInt(rinfo[1])));
}
for(String scost: config.getStringList("Sponsor_Cost")){
String[] sinfo = scost.split(",");
Cost.add(new ItemStack(Integer.parseInt(sinfo[0]), Integer.parseInt(sinfo[1])));
}
if(config.getBoolean("EntryFee.enabled")){
for(String fee: config.getStringList("EntryFee.fee")){
String[] finfo = fee.split(",");
Fee.add(new ItemStack(Integer.parseInt(finfo[0]), Integer.parseInt(finfo[1])));
}
}
}catch(Exception e){
log.warning("Could not add a reward/sponsor/entry cost! One of the rewards/costs is not a number!");
}
worlds = config.getStringList("worlds");
if(worlds.isEmpty()){
restricted = false;
}else if(!worlds.isEmpty()){
restricted = true;
}
log.info("Enabled v" + getDescription().getVersion());
}
public void onDisable(){
log.info("Disabled v" + getDescription().getVersion());
}
public boolean setupEconomy() {
if (getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
}
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
return false;
}
econ = rsp.getProvider();
vault = true;
return econ != null;
}
public void reloadSpawns() {
if (spawnsFile == null) {
spawnsFile = new File(getDataFolder(), "spawns.yml");
}
spawns = YamlConfiguration.loadConfiguration(spawnsFile);
// Look for defaults in the jar
InputStream defConfigStream = this.getResource("spawns.yml");
if (defConfigStream != null) {
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
spawns.setDefaults(defConfig);
}
}
public FileConfiguration getSpawns() {
if (spawns == null) {
this.reloadSpawns();
}
return spawns;
}
public void saveSpawns() {
if (spawns == null || spawnsFile == null) {
return;
}
try {
getSpawns().save(spawnsFile);
} catch (IOException ex) {
this.getLogger().log(Level.SEVERE, "Could not save config to " + spawnsFile, ex);
}
}
public void reloadData() {
if (dataFile == null) {
dataFile = new File(getDataFolder(), "Data.yml");
}
data = YamlConfiguration.loadConfiguration(dataFile);
// Look for defaults in the jar
InputStream defConfigStream = this.getResource("Data.yml");
if (defConfigStream != null) {
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
data.setDefaults(defConfig);
}
}
public FileConfiguration getData() {
if (data == null) {
this.reloadData();
}
return data;
}
public void saveData() {
if (data == null || dataFile == null) {
return;
}
try {
getData().save(dataFile);
} catch (IOException ex) {
this.getLogger().log(Level.SEVERE, "Could not save config to " + dataFile, ex);
}
}
public void reloadManagement() {
if (managementFile == null) {
managementFile = new File(getDataFolder(), "commandAndBlockManagement.yml");
}
management = YamlConfiguration.loadConfiguration(managementFile);
// Look for defaults in the jar
InputStream defConfigStream = this.getResource("commandAndBlockManagement.yml");
if (defConfigStream != null) {
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
management.setDefaults(defConfig);
}
}
public FileConfiguration getManagement() {
if (management == null) {
this.reloadManagement();
}
return management;
}
public void saveManagement() {
if (management == null || managementFile == null) {
return;
}
try {
getManagement().save(managementFile);
} catch (IOException ex) {
this.getLogger().log(Level.SEVERE, "Could not save config to " + managementFile, ex);
}
}
public void winner(Integer a){
String[] Spawncoords = spawns.getString("Spawn_coords").split(",");
World spawnw = 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(Playing.get(a).size()== 1 && canjoin.get(a)== true){
//Announce winner
for(i = 0; i < Playing.get(a).size(); i++){
String winnername = Playing.get(a).get(i);
Player winner = getServer().getPlayerExact(winnername);
String winnername2 = winner.getName();
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.setLevel(0);
for(PotionEffect pe: winner.getActivePotionEffects()){
PotionEffectType potion = pe.getType();
winner.removePotionEffect(potion);
}
Tele.add(winner);
final World w = winner.getWorld();
winner.teleport(Spawn);
if(config.getBoolean("reloadWorld")){
getServer().unloadWorld(w, false);
getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
public void run(){
getServer().createWorld(new WorldCreator(w.getName()));
}
},200L);
}
if(!config.getBoolean("rewardEco.enabled")){
for(ItemStack Rewards: Reward){
winner.getInventory().addItem(Rewards);
}
}else{
for(ItemStack Rewards: Reward){
winner.getInventory().addItem(Rewards);
}
econ.depositPlayer(winner.getName(), config.getDouble("rewardEco.reward"));
}
Playing.get(a).clear();
getServer().getScheduler().cancelTask(deathtime);
}
//Show spectators
for(String s1: Watching.get(a)){
Player spectator = getServer().getPlayerExact(s1);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
for(Player online:getServer().getOnlinePlayers()){
online.showPlayer(spectator);
}
}
if(config.getString("Auto_Restart").equalsIgnoreCase("True")){
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
public void run(){
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart");
}
}, 220L);
}
}
}
public void startGames(final Integer a){
String begin = config.getString("Start_Message");
begin = begin.replaceAll("(&([a-f0-9]))", "\u00A7$2");
final String msg = begin;
i = 10;
if(config.getString("Countdown").equalsIgnoreCase("true")){
start = getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
public void run(){
if(i > 0){
if(worlds.isEmpty()){
if(config.getBoolean("broadcastAll")){
getServer().broadcastMessage(String.valueOf(i));
}else{
for(String gn: Playing.get(a)){
Player g = getServer().getPlayer(gn);
g.sendMessage(String.valueOf(i));
}
}
}else{
for(String world: worlds){
World w = getServer().getWorld(world);
if(config.getBoolean("broadcastAll")){
for(Player wp: w.getPlayers()){
wp.sendMessage(String.valueOf(i));
}
}else{
for(String gn: Playing.get(a)){
Player g = getServer().getPlayer(gn);
g.sendMessage(String.valueOf(i));
}
}
}
}
}
i = i-1;
canjoin.put(a, true);
if(i== -1){
if(Frozen.get(a)!= null)
Frozen.get(a).clear();
if(config.getBoolean("broadcastAll")){
getServer().broadcastMessage(msg);
}else{
for(String gn: Playing.get(a)){
Player g = getServer().getPlayer(gn);
g.sendMessage(msg);
}
}
getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha Refill " + a);
getServer().getScheduler().cancelTask(start);
if(config.getInt("DeathMatch")!= 0){
int death = config.getInt("DeathMatch");
timetodeath = death;
deathtime = getServer().getScheduler().scheduleSyncRepeatingTask(Bukkit.getPluginManager().getPlugin("HungerArena"), new Runnable(){
public void run(){
timetodeath = timetodeath-1;
if(config.getBoolean("broadcastAll")){
for(Player wp: location.get(a).get(0).getWorld().getPlayers()){
if(timetodeath!= 0){
wp.sendMessage(ChatColor.RED + String.valueOf(timetodeath) + " mins till the death match!");
}
}
}else{
for(String gn: Playing.get(a)){
Player g = getServer().getPlayer(gn);
g.sendMessage(ChatColor.RED + String.valueOf(timetodeath) + " mins till the death match!");
}
}
if(timetodeath== 0){
for(String playing: Playing.get(a)){
Player tribute = getServer().getPlayerExact(playing);
tribute.teleport(location.get(a).get(i));
i = i+1;
for(PotionEffect pe: tribute.getActivePotionEffects()){
PotionEffectType potion = pe.getType();
tribute.removePotionEffect(potion);
}
if(tribute.getAllowFlight()){
tribute.setAllowFlight(false);
}
}
if(config.getBoolean("broadcastAll")){
for(Player wp: location.get(a).get(0).getWorld().getPlayers()){
wp.sendMessage(ChatColor.RED + "The final battle has begun! " + Playing.size() + " tributes will be facing off!");
}
}else{
for(String gn: Playing.get(a)){
Player g = getServer().getPlayer(gn);
g.sendMessage(ChatColor.RED + "The final battle has begun! " + Playing.size() + " tributes will be facing off!");
}
}
getServer().getScheduler().cancelTask(deathtime);
}
}
}, 1200L, 1200L);
}
}
}
}, 20L, 20L);
}else{
Frozen.get(a).clear();
if(config.getBoolean("broadcastAll")){
getServer().broadcastMessage(msg);
}else{
for(String gn: Playing.get(a)){
Player g = getServer().getPlayer(gn);
g.sendMessage(msg);
}
}
canjoin.put(a, true);
getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha Refill " + a);
}
}
public Integer getArena(Player p){
for (int x: Playing.keySet()) {
if (Playing.get(x).contains(p.getName())){
return x;
}
}
return null;
}
public boolean isSpectating(Player p){
int x = 0;
if(!Watching.isEmpty()){
for(x= 1; x <= Watching.size(); x++){
if(Watching.get(x).contains(p.getName())){
x = Watching.size()+1;
return true;
}else if(Watching.size()== x)
return false;
}
}
return false;
}
}

View File

@ -1,66 +0,0 @@
package me.Travja.HungerArena;
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;
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.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){
event.setCancelled(false);
}
}
}else if(projectile.getShooter() instanceof Entity){
Entity e = projectile.getShooter();
if(e instanceof Skeleton){
if(plugin.getArena(p)!= null){
event.setCancelled(false);
}
}
}
}
}
}

View File

@ -1,53 +0,0 @@
package me.Travja.HungerArena;
import org.bukkit.ChatColor;
import org.bukkit.Material;
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 Signs implements Listener {
public Main plugin;
public Signs(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){
if(b.getType()== Material.SIGN || b.getType()==Material.SIGN_POST || b.getType()==Material.WALL_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.equalsIgnoreCase(ChatColor.BLUE + "[HungerArena]") || line1.equalsIgnoreCase(ChatColor.BLUE + "[HA]")){
if(!line2.equals(""))
p.performCommand("ha " + line2);
else if(!line3.equals(""))
p.performCommand("ha " + line2 + " " + line3);
else
p.performCommand("ha");
}
if(line1.equalsIgnoreCase(ChatColor.BLUE + "[Sponsor]")){
p.performCommand("sponsor " + line2 + " " + line3 + " " + line4);
}
}
}
}
@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,81 +0,0 @@
package me.Travja.HungerArena;
import java.util.ArrayList;
import java.util.HashMap;
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;
public SpawnsCommand(Main m) {
this.plugin = m;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
Player p = (Player) sender;
if(cmd.getName().equalsIgnoreCase("StartPoint")){
if(p.hasPermission("HungerArena.StartPoint")){
if(!plugin.restricted || (plugin.restricted && plugin.worlds.contains(p.getWorld().getName()))){
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!");
}
if(i >= 1 && i <= plugin.config.getInt("maxPlayers")){
if(plugin.restricted && !plugin.worlds.contains(p.getWorld().getName())){
p.sendMessage(ChatColor.GOLD + "We ran the command, however, this isn't a world you defined in the config...");
p.sendMessage(ChatColor.GOLD + "If this is the right world, please disregard this message.");
}
Location ploc = p.getLocation().getBlock().getLocation();
double x = ploc.getX();
double y = ploc.getY();
double z = ploc.getZ();
if(plugin.location.get(a)!= null){
if(plugin.location.get(a).size()>= i){
plugin.location.get(a).put(i, new Location(ploc.getWorld(), x, y, z));
}else{
plugin.location.get(a).put(i, new Location(ploc.getWorld(), x, y, z));
}
}else{
plugin.location.put(a, new HashMap<Integer, Location>());
plugin.location.get(a).put(i, new Location(ploc.getWorld(), x, y, z));
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.open.put(a, true);
}
String coords = plugin.location.get(a).get(i).getWorld().getName() + "," + plugin.location.get(a).get(i).getX() + "," + plugin.location.get(a).get(i).getY() + "," + plugin.location.get(a).get(i).getZ();
plugin.spawns.set("Spawns." + a + "." + i, coords);
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 + "!");
}else{
p.sendMessage(ChatColor.RED + "You can't go past " + plugin.maxPlayers + " players!");
}
}
}
}else{
p.sendMessage(ChatColor.RED + "You don't have permission!");
}
}
return false;
}
}

View File

@ -1,171 +0,0 @@
package me.Travja.HungerArena;
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.*;
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();
String pname = p.getName();
for(i = 0; i < plugin.Watching.size(); i++){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(pname)){
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();
String pname = p.getName();
for(i = 0; i < plugin.Watching.size(); i++){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(pname)){
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();
String pname = p.getName();
for(i = 0; i < plugin.Watching.size(); i++){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(pname)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
}
}
@EventHandler
public void SpectatorItems(PlayerPickupItemEvent event){
Player p = event.getPlayer();
String pname = p.getName();
for(i = 0; i < plugin.Watching.size(); i++){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(pname)){
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(i = 0; i < plugin.Watching.size(); i++){
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!");
}
}
}
}else if(event.getDamager() instanceof Projectile){
Projectile arrow = (Projectile) offense;
if(arrow.getShooter() instanceof Player){
Player BowMan = (Player) arrow.getShooter();
String bowManName = BowMan.getName();
for(i = 0; i < plugin.Watching.size(); i++){
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!");
}
}
}
}
}
}
@EventHandler
public void SpectatorBlockBreak(BlockBreakEvent event){
Player p = event.getPlayer();
String pname = p.getName();
for(i = 0; i < plugin.Watching.size(); i++){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(pname)){
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();
String pname = p.getName();
for(i = 0; i < plugin.Watching.size(); i++){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(pname)){
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(i = 0; i < plugin.Watching.size(); i++){
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").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);
}
}
}
}
@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(i = 0; i < plugin.Watching.size(); i++){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(targetName)){
event.setTarget(null);
}
}
}
}
}
}

View File

@ -1,163 +0,0 @@
package me.Travja.HungerArena;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
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){
int i = 0;
Player p = (Player) sender;
String pname = p.getName();
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(plugin.getArena(target)== null){
p.sendMessage(ChatColor.RED + "That person isn't playing!");
}else{
try{
int ID = Integer.parseInt(args[1]);
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()){
ItemStack sponsoritem = new ItemStack(ID, Amount);
if(!plugin.config.getBoolean("sponsorEco.enabled")){
for(ItemStack Costs: plugin.Cost){
if(p.getInventory().contains(Costs)){
i = i+1;
if(plugin.Cost.size() == i){
if(args[0].equalsIgnoreCase(pname)){
p.sendMessage(ChatColor.RED + "You can't sponsor yourself!");
}else{
target.sendMessage(ChatColor.AQUA + "You have been Sponsored!");
target.getInventory().addItem(sponsoritem);
p.sendMessage("You have sponsored " + target.getName() + "!");
for(ItemStack aCosts: plugin.Cost){
p.getInventory().removeItem(aCosts);
}
}
}
}
}
if(plugin.Cost.size() > i){
p.sendMessage(ChatColor.RED + "You don't have the necessary items to sponsor!");
}
}else{
if(args[0].equalsIgnoreCase(pname)){
p.sendMessage(ChatColor.RED + "You can't sponsor yourself!");
}else if(!(plugin.econ.getBalance(pname) < plugin.config.getDouble("sponsorEco.cost"))){
if(!plugin.Cost.isEmpty()){
for(ItemStack Costs: plugin.Cost){
if(p.getInventory().contains(Costs)){
i = i+1;
if(plugin.Cost.size()== i){
if(args[0].equalsIgnoreCase(pname)){
p.sendMessage(ChatColor.RED + "You can't sponsor yourself!");
}else{
target.sendMessage(ChatColor.AQUA + "You have been Sponsored!");
target.getInventory().addItem(sponsoritem);
p.sendMessage("You have sponsored " + target.getName() + "!");
plugin.econ.withdrawPlayer(pname, plugin.config.getDouble("sponsorEco.cost"));
for(ItemStack aCosts: plugin.Cost){
p.getInventory().removeItem(aCosts);
}
}
}
}
}
if(plugin.Cost.size() > i){
p.sendMessage(ChatColor.RED + "You don't have the necessary items to sponsor!");
}
}else{
target.sendMessage(ChatColor.AQUA + "You have been Sponsored!");
target.getInventory().addItem(sponsoritem);
p.sendMessage("You have sponsored " + target.getName() + "!");
plugin.econ.withdrawPlayer(pname, plugin.config.getDouble("sponsorEco.cost"));
}
}else{
p.sendMessage(ChatColor.RED + "You don't have enough money to do that!");
}
}
}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] [number] [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]);
int ID = Integer.parseInt(args[1]);
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(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;
}
}