Adding block whitelist/blacklist
This commit is contained in:
parent
b0d29cd907
commit
a9ff18163d
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bin/me/Travja/HungerArena/Main$1.class
Normal file
BIN
bin/me/Travja/HungerArena/Main$1.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -10,6 +10,6 @@ commands:
|
|||||||
blocks:
|
blocks:
|
||||||
whitelist: []
|
whitelist: []
|
||||||
blacklist: []
|
blacklist: []
|
||||||
|
############################
|
||||||
sponsors:
|
sponsors:
|
||||||
blacklist: []
|
blacklist: []
|
||||||
############################
|
|
19
config.yml
19
config.yml
@ -51,17 +51,24 @@ Cannon_Death: 'true'
|
|||||||
|
|
||||||
# What the reward for winning is
|
# What the reward for winning is
|
||||||
Reward:
|
Reward:
|
||||||
ID: 264
|
- 264,10
|
||||||
Amount: 10
|
Sponsor_Cost:
|
||||||
|
- 264,1
|
||||||
|
EntryFee:
|
||||||
|
enabled: false
|
||||||
|
eco: false
|
||||||
|
cost: 50
|
||||||
|
fee:
|
||||||
|
- 265,1
|
||||||
# True means give money to winner, false means don't.
|
# True means give money to winner, false means don't.
|
||||||
eco:
|
rewardEco:
|
||||||
enabled: false
|
enabled: false
|
||||||
reward: 100
|
reward: 100
|
||||||
|
sponsorEco:
|
||||||
|
enabled: false
|
||||||
|
cost: 50
|
||||||
# How much money to give the winner.
|
# How much money to give the winner.
|
||||||
# What sponsors have to pay to sponsor tributes
|
# What sponsors have to pay to sponsor tributes
|
||||||
Sponsor_Cost:
|
|
||||||
ID: 264
|
|
||||||
Amount: 1
|
|
||||||
################################
|
################################
|
||||||
################################
|
################################
|
||||||
################################
|
################################
|
||||||
|
@ -10,6 +10,7 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
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.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockBurnEvent;
|
import org.bukkit.event.block.BlockBurnEvent;
|
||||||
@ -24,127 +25,96 @@ 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 BlockBreak(BlockBreakEvent event){
|
public void BlockBreak(BlockBreakEvent event){
|
||||||
Block b = event.getBlock();
|
Block b = event.getBlock();
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
String pname = p.getName();
|
String pname = p.getName();
|
||||||
if(plugin.Playing.contains(pname)){
|
if(!event.isCancelled()){
|
||||||
if(plugin.config.getString("Protected_Arena").equalsIgnoreCase("True")){
|
if(plugin.Playing.contains(pname)){
|
||||||
event.setCancelled(true);
|
if(plugin.config.getString("Protected_Arena").equalsIgnoreCase("True")){
|
||||||
p.sendMessage(ChatColor.RED + "You can't break blocks when you're playing!");
|
if(!plugin.management.getStringList("blocks.blacklist").isEmpty() && plugin.management.getStringList("blocks.blacklist").contains(b.getData())){
|
||||||
}
|
event.setCancelled(true);
|
||||||
if(plugin.canjoin){
|
p.sendMessage(ChatColor.RED + "That is an illegal block!");
|
||||||
if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(p.getWorld().getName()))){
|
}else if(!plugin.management.getStringList("blocks.whitelist").isEmpty() && !plugin.management.getStringList("blocks.whitelist").contains(b.getData())){
|
||||||
String w = b.getWorld().getName();
|
if(!plugin.management.getStringList("blocks.blacklist").isEmpty() && !plugin.management.getStringList("blocks.blacklist").contains(b.getData())){
|
||||||
int x = b.getX();
|
event.setCancelled(true);
|
||||||
int y = b.getY();
|
p.sendMessage(ChatColor.RED + "That is an illegal block!");
|
||||||
int z = b.getZ();
|
}
|
||||||
int d = b.getTypeId();
|
}else if(!plugin.management.getStringList("blocks.blacklist").isEmpty() && !plugin.management.getStringList("blocks.blacklist").contains(b.getData())){
|
||||||
byte m = b.getData();
|
if(!plugin.management.getStringList("blocks.whitelist").isEmpty() && !plugin.management.getStringList("blocks.whitelist").contains(b.getData())){
|
||||||
String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m;
|
event.setCancelled(true);
|
||||||
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
|
p.sendMessage(ChatColor.RED + "That is an illegal block!");
|
||||||
if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z)){
|
|
||||||
blocks.add(coords);
|
|
||||||
plugin.data.set("Blocks_Destroyed", blocks);
|
|
||||||
plugin.saveData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@EventHandler
|
|
||||||
public void Explosion(EntityExplodeEvent event){
|
|
||||||
List<Block> blocksd = event.blockList();
|
|
||||||
Entity e = event.getEntity();
|
|
||||||
if(plugin.canjoin){
|
|
||||||
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();
|
|
||||||
plugin.getServer().broadcastMessage("TNT blew up!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
|
|
||||||
if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z) || !plugin.data.getStringList("Blocks_Destroyed").contains(w + "," + x + "," + y + "," + z)){
|
|
||||||
blocks.add(coords);
|
|
||||||
plugin.data.set("Blocks_Destroyed", blocks);
|
|
||||||
plugin.saveData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@EventHandler
|
|
||||||
public void burningBlocks(BlockBurnEvent event){
|
|
||||||
Block b = event.getBlock();
|
|
||||||
if(plugin.canjoin== true){
|
|
||||||
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;
|
|
||||||
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
|
|
||||||
if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z)){
|
|
||||||
blocks.add(coords);
|
|
||||||
plugin.data.set("Blocks_Destroyed", blocks);
|
|
||||||
plugin.saveData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@EventHandler
|
|
||||||
public void blockPlace(BlockPlaceEvent event){
|
|
||||||
Block b = event.getBlock();
|
|
||||||
Player p = event.getPlayer();
|
|
||||||
if(plugin.Playing.contains(p.getName())){
|
|
||||||
if(plugin.canjoin){
|
|
||||||
if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(b.getWorld().getName()))){
|
|
||||||
//TODO
|
|
||||||
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;
|
|
||||||
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{
|
}else{
|
||||||
if(b.getType()!= Material.SAND || b.getType()!= Material.GRAVEL){
|
event.setCancelled(true);
|
||||||
|
p.sendMessage(ChatColor.RED + "That is an illegal block!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if(plugin.canjoin){
|
||||||
|
if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(p.getWorld().getName()))){
|
||||||
|
if(!plugin.management.getStringList("blocks.blacklist").isEmpty() && plugin.management.getStringList("blocks.blacklist").contains(b.getData())){
|
||||||
|
event.setCancelled(true);
|
||||||
|
p.sendMessage(ChatColor.RED + "That is an illegal block!");
|
||||||
|
}else if(!plugin.management.getStringList("blocks.whitelist").isEmpty() && !plugin.management.getStringList("blocks.whitelist").contains(b.getData())){
|
||||||
|
if(!plugin.management.getStringList("blocks.blacklist").isEmpty() && !plugin.management.getStringList("blocks.blacklist").contains(b.getData())){
|
||||||
|
event.setCancelled(true);
|
||||||
|
p.sendMessage(ChatColor.RED + "That is an illegal block!");
|
||||||
|
}
|
||||||
|
}else if(!plugin.management.getStringList("blocks.blacklist").isEmpty() && !plugin.management.getStringList("blocks.blacklist").contains(b.getData())){
|
||||||
|
if(!plugin.management.getStringList("blocks.whitelist").isEmpty() && !plugin.management.getStringList("blocks.whitelist").contains(b.getData())){
|
||||||
|
event.setCancelled(true);
|
||||||
|
p.sendMessage(ChatColor.RED + "That is an illegal block!");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
String w = b.getWorld().getName();
|
String w = b.getWorld().getName();
|
||||||
int x = b.getX();
|
int x = b.getX();
|
||||||
int y = b.getY();
|
int y = b.getY();
|
||||||
int z = b.getZ();
|
int z = b.getZ();
|
||||||
String coords = w + "," + x + "," + y + "," + z;
|
int d = b.getTypeId();
|
||||||
List<String> blocks = plugin.data.getStringList("Blocks_Placed");
|
byte m = b.getData();
|
||||||
|
String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m;
|
||||||
|
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
|
||||||
|
if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z)){
|
||||||
|
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();
|
||||||
|
if(!event.isCancelled()){
|
||||||
|
if(plugin.canjoin){
|
||||||
|
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();
|
||||||
|
plugin.getServer().broadcastMessage("TNT blew up!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
|
||||||
|
if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z) || !plugin.data.getStringList("Blocks_Destroyed").contains(w + "," + x + "," + y + "," + z)){
|
||||||
blocks.add(coords);
|
blocks.add(coords);
|
||||||
plugin.data.set("Blocks_Placed", blocks);
|
plugin.data.set("Blocks_Destroyed", blocks);
|
||||||
plugin.saveData();
|
plugin.saveData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,31 +122,12 @@ public class BlockStorage implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void bucketEmpty(PlayerBucketEmptyEvent event){
|
public void burningBlocks(BlockBurnEvent event){
|
||||||
if(plugin.canjoin){
|
Block b = event.getBlock();
|
||||||
if(plugin.Playing.contains(event.getPlayer().getName())){
|
if(!event.isCancelled()){
|
||||||
if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(event.getPlayer().getWorld().getName()))){
|
if(plugin.canjoin){
|
||||||
Block b = event.getBlockClicked().getRelative(event.getBlockFace());
|
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();
|
|
||||||
String coords = w + "," + x + "," + y + "," + z;
|
|
||||||
List<String> blocks = plugin.data.getStringList("Blocks_Placed");
|
|
||||||
blocks.add(coords);
|
|
||||||
plugin.data.set("Blocks_Placed", blocks);
|
|
||||||
plugin.saveData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@EventHandler
|
|
||||||
public void bucketFill(PlayerBucketFillEvent event){
|
|
||||||
if(plugin.canjoin){
|
|
||||||
if(plugin.Playing.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();
|
String w = b.getWorld().getName();
|
||||||
int x = b.getX();
|
int x = b.getX();
|
||||||
int y = b.getY();
|
int y = b.getY();
|
||||||
@ -194,23 +145,117 @@ public class BlockStorage implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void blockPlace(BlockPlaceEvent event){
|
||||||
|
Block b = event.getBlock();
|
||||||
|
Player p = event.getPlayer();
|
||||||
|
if(!event.isCancelled()){
|
||||||
|
if(plugin.Playing.contains(p.getName())){
|
||||||
|
if(plugin.canjoin){
|
||||||
|
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;
|
||||||
|
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;
|
||||||
|
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(!event.isCancelled()){
|
||||||
|
if(plugin.canjoin){
|
||||||
|
if(plugin.Playing.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;
|
||||||
|
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(!event.isCancelled()){
|
||||||
|
if(plugin.canjoin){
|
||||||
|
if(plugin.Playing.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;
|
||||||
|
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
|
||||||
|
if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z)){
|
||||||
|
blocks.add(coords);
|
||||||
|
plugin.data.set("Blocks_Destroyed", blocks);
|
||||||
|
plugin.saveData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void blockMelt(BlockFadeEvent event){
|
public void blockMelt(BlockFadeEvent event){
|
||||||
if(plugin.canjoin){
|
if(!event.isCancelled()){
|
||||||
if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(event.getBlock().getWorld().getName()))){
|
if(plugin.canjoin){
|
||||||
Block b = event.getBlock();
|
if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(event.getBlock().getWorld().getName()))){
|
||||||
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;
|
byte m = b.getData();
|
||||||
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
|
String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m;
|
||||||
if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z)){
|
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
|
||||||
blocks.add(coords);
|
if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z)){
|
||||||
plugin.data.set("Blocks_Destroyed", blocks);
|
blocks.add(coords);
|
||||||
plugin.saveData();
|
plugin.data.set("Blocks_Destroyed", blocks);
|
||||||
|
plugin.saveData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,36 +12,42 @@ 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.getName();
|
String pname = p.getName();
|
||||||
if(plugin.Playing.contains(pname)){
|
if(plugin.Playing.contains(pname) || plugin.Watching.contains(pname)){
|
||||||
if(!p.hasPermission("HungerArena.UseCommands")){
|
if(!p.hasPermission("HungerArena.UseCommands")){
|
||||||
for(String whitelist: plugin.management.getStringList("commands.whitelist")){
|
if(!plugin.management.getStringList("commands.whitelist").isEmpty() && !cmd.toLowerCase().contains("/ha")){
|
||||||
if(!cmd.toLowerCase().contains(whitelist.toLowerCase()) && !cmd.toLowerCase().contains("/ha")){
|
for(String whitelist: plugin.management.getStringList("commands.whitelist")){
|
||||||
event.setCancelled(true);
|
if(!cmd.toLowerCase().contains(whitelist.toLowerCase()) && !cmd.toLowerCase().contains("/ha")){
|
||||||
p.sendMessage(ChatColor.RED + "You are only allowed to perform the following commands:");
|
event.setCancelled(true);
|
||||||
p.sendMessage(ChatColor.AQUA + whitelist);
|
p.sendMessage(ChatColor.RED + "You are only allowed to perform the following commands:");
|
||||||
p.sendMessage(ChatColor.AQUA + "/ha");
|
p.sendMessage(ChatColor.AQUA + whitelist);
|
||||||
p.sendMessage(ChatColor.AQUA + "/ha close");
|
p.sendMessage(ChatColor.AQUA + "/ha");
|
||||||
p.sendMessage(ChatColor.AQUA + "/ha help");
|
p.sendMessage(ChatColor.AQUA + "/ha close");
|
||||||
p.sendMessage(ChatColor.AQUA + "/ha join");
|
p.sendMessage(ChatColor.AQUA + "/ha help");
|
||||||
p.sendMessage(ChatColor.AQUA + "/ha kick [Player]");
|
p.sendMessage(ChatColor.AQUA + "/ha join");
|
||||||
p.sendMessage(ChatColor.AQUA + "/ha leave");
|
p.sendMessage(ChatColor.AQUA + "/ha kick [Player]");
|
||||||
p.sendMessage(ChatColor.AQUA + "/ha list");
|
p.sendMessage(ChatColor.AQUA + "/ha leave");
|
||||||
p.sendMessage(ChatColor.AQUA + "/ha open");
|
p.sendMessage(ChatColor.AQUA + "/ha list");
|
||||||
p.sendMessage(ChatColor.AQUA + "/ha ready");
|
p.sendMessage(ChatColor.AQUA + "/ha open");
|
||||||
p.sendMessage(ChatColor.AQUA + "/ha refill");
|
p.sendMessage(ChatColor.AQUA + "/ha ready");
|
||||||
p.sendMessage(ChatColor.AQUA + "/ha reload");
|
p.sendMessage(ChatColor.AQUA + "/ha refill");
|
||||||
p.sendMessage(ChatColor.AQUA + "/ha restart");
|
p.sendMessage(ChatColor.AQUA + "/ha reload");
|
||||||
p.sendMessage(ChatColor.AQUA + "/ha rlist");
|
p.sendMessage(ChatColor.AQUA + "/ha restart");
|
||||||
p.sendMessage(ChatColor.AQUA + "/ha setspawn");
|
p.sendMessage(ChatColor.AQUA + "/ha rlist");
|
||||||
p.sendMessage(ChatColor.AQUA + "/ha start");
|
p.sendMessage(ChatColor.AQUA + "/ha setspawn");
|
||||||
p.sendMessage(ChatColor.AQUA + "/ha watch");
|
p.sendMessage(ChatColor.AQUA + "/ha start");
|
||||||
p.sendMessage(ChatColor.AQUA + "/ha warpall");
|
p.sendMessage(ChatColor.AQUA + "/ha tp");
|
||||||
|
p.sendMessage(ChatColor.AQUA + "/ha watch");
|
||||||
|
p.sendMessage(ChatColor.AQUA + "/ha warpall");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}else if(!cmd.toLowerCase().contains("/ha")){
|
||||||
|
event.setCancelled(true);
|
||||||
|
p.sendMessage(ChatColor.RED + "You are only allowed to perform /ha commands!");
|
||||||
}
|
}
|
||||||
}else if(!cmd.toLowerCase().contains("/ha")){
|
}else if(!cmd.toLowerCase().contains("/ha")){
|
||||||
if(cmd.toLowerCase().contains("/spawn")){
|
if(cmd.toLowerCase().contains("/spawn")){
|
||||||
@ -51,6 +57,21 @@ public class CommandBlock implements Listener {
|
|||||||
}
|
}
|
||||||
}else if(cmd.toLowerCase().equals("/back") && plugin.Dead.contains(pname) && plugin.canjoin== true){
|
}else if(cmd.toLowerCase().equals("/back") && plugin.Dead.contains(pname) && plugin.canjoin== true){
|
||||||
plugin.Tele.add(p);
|
plugin.Tele.add(p);
|
||||||
|
}else if(!plugin.Playing.contains(pname) || !plugin.Watching.contains(pname)){
|
||||||
|
if(cmd.contains("/tp") || cmd.contains("/tpa") || cmd.contains("/tpo")){
|
||||||
|
String[] args = cmd.split(" ");
|
||||||
|
if(args.length == 3){
|
||||||
|
if(plugin.Playing.contains(plugin.getServer().getPlayer(args[1]).getName()) || plugin.Playing.contains(plugin.getServer().getPlayer(args[2]).getName())){
|
||||||
|
event.setCancelled(true);
|
||||||
|
p.sendMessage(ChatColor.RED + "You can't teleport to tributes unless you've run /ha watch!");
|
||||||
|
}
|
||||||
|
}else if(args.length == 2){
|
||||||
|
if(plugin.Playing.contains(plugin.getServer().getPlayer(args[1]).getName())){
|
||||||
|
event.setCancelled(true);
|
||||||
|
p.sendMessage(ChatColor.RED + "You can't teleport to tributes unless you've run /ha watch!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
package me.Travja.HungerArena;
|
package me.Travja.HungerArena;
|
||||||
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
public class DeathListener implements Listener{
|
public class DeathListener implements Listener{
|
||||||
public Main plugin;
|
public Main plugin;
|
||||||
@ -42,12 +45,6 @@ public class DeathListener implements Listener{
|
|||||||
String pname = p.getName();
|
String pname = p.getName();
|
||||||
int players = plugin.Playing.size()-1;
|
int players = plugin.Playing.size()-1;
|
||||||
String leftmsg = ChatColor.BLUE + "There are now " + players + " tributes left!";
|
String leftmsg = ChatColor.BLUE + "There are now " + players + " tributes left!";
|
||||||
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]);
|
|
||||||
Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
|
|
||||||
if(plugin.Frozen.contains(pname) && plugin.Playing.contains(pname)){
|
if(plugin.Frozen.contains(pname) && plugin.Playing.contains(pname)){
|
||||||
if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){
|
if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){
|
||||||
double y = p.getLocation().getY();
|
double y = p.getLocation().getY();
|
||||||
@ -63,44 +60,7 @@ public class DeathListener implements Listener{
|
|||||||
plugin.Playing.remove(pname);
|
plugin.Playing.remove(pname);
|
||||||
plugin.Dead.add(pname);
|
plugin.Dead.add(pname);
|
||||||
s.broadcastMessage(leftmsg);
|
s.broadcastMessage(leftmsg);
|
||||||
if(plugin.Playing.size()== 1 && plugin.canjoin== false){
|
plugin.winner();
|
||||||
//Announce winner
|
|
||||||
for(i = 0; i < plugin.Playing.size(); i++){
|
|
||||||
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.getInventory().setBoots(null);
|
|
||||||
winner.getInventory().setChestplate(null);
|
|
||||||
winner.getInventory().setHelmet(null);
|
|
||||||
winner.getInventory().setLeggings(null);
|
|
||||||
for(PotionEffect pe: winner.getActivePotionEffects()){
|
|
||||||
PotionEffectType potion = pe.getType();
|
|
||||||
winner.removePotionEffect(potion);
|
|
||||||
}
|
|
||||||
winner.teleport(Spawn);
|
|
||||||
winner.getInventory().addItem(plugin.Reward);
|
|
||||||
plugin.Playing.clear();
|
|
||||||
}
|
|
||||||
//Show spectators
|
|
||||||
for(String s1: plugin.Watching){
|
|
||||||
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().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
|
||||||
public void run(){
|
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart");
|
|
||||||
|
|
||||||
}
|
|
||||||
}, 220L);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else if(plugin.Playing.contains(pname)){
|
}else if(plugin.Playing.contains(pname)){
|
||||||
if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){
|
if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){
|
||||||
double y = p.getLocation().getY();
|
double y = p.getLocation().getY();
|
||||||
@ -119,39 +79,7 @@ public class DeathListener implements Listener{
|
|||||||
event.setDeathMessage("");
|
event.setDeathMessage("");
|
||||||
s.broadcastMessage(ChatColor.LIGHT_PURPLE + "**BOOM** Tribute " + pname + " was killed by tribute " + killername + " with their FIST!");
|
s.broadcastMessage(ChatColor.LIGHT_PURPLE + "**BOOM** Tribute " + pname + " was killed by tribute " + killername + " with their FIST!");
|
||||||
s.broadcastMessage(leftmsg);
|
s.broadcastMessage(leftmsg);
|
||||||
if(plugin.Playing.size()== 1 && plugin.canjoin== true){
|
plugin.winner();
|
||||||
//Announce winner
|
|
||||||
for(i = 0; i < plugin.Playing.size(); i++){
|
|
||||||
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.getInventory().setBoots(null);
|
|
||||||
winner.getInventory().setChestplate(null);
|
|
||||||
winner.getInventory().setHelmet(null);
|
|
||||||
winner.getInventory().setLeggings(null);
|
|
||||||
for(PotionEffect pe: winner.getActivePotionEffects()){
|
|
||||||
PotionEffectType potion = pe.getType();
|
|
||||||
winner.removePotionEffect(potion);
|
|
||||||
}
|
|
||||||
winner.teleport(Spawn);
|
|
||||||
winner.getInventory().addItem(plugin.Reward);
|
|
||||||
}
|
|
||||||
plugin.Playing.clear();
|
|
||||||
//Show spectators
|
|
||||||
for(String s1: plugin.Watching){
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
Player killer = p.getKiller();
|
Player killer = p.getKiller();
|
||||||
String killername = killer.getName();
|
String killername = killer.getName();
|
||||||
@ -160,81 +88,13 @@ public class DeathListener implements Listener{
|
|||||||
event.setDeathMessage("");
|
event.setDeathMessage("");
|
||||||
s.broadcastMessage(msg);
|
s.broadcastMessage(msg);
|
||||||
s.broadcastMessage(leftmsg);
|
s.broadcastMessage(leftmsg);
|
||||||
if(plugin.Playing.size()== 1 && plugin.canjoin== true){
|
plugin.winner();
|
||||||
//Announce winner
|
|
||||||
for(i = 0; i < plugin.Playing.size(); i++){
|
|
||||||
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.getInventory().setBoots(null);
|
|
||||||
winner.getInventory().setChestplate(null);
|
|
||||||
winner.getInventory().setHelmet(null);
|
|
||||||
winner.getInventory().setLeggings(null);
|
|
||||||
for(PotionEffect pe: winner.getActivePotionEffects()){
|
|
||||||
PotionEffectType potion = pe.getType();
|
|
||||||
winner.removePotionEffect(potion);
|
|
||||||
}
|
|
||||||
winner.teleport(Spawn);
|
|
||||||
winner.getInventory().addItem(plugin.Reward);
|
|
||||||
}
|
|
||||||
plugin.Playing.clear();
|
|
||||||
//Show spectators
|
|
||||||
for(String s1: plugin.Watching){
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
event.setDeathMessage("");
|
event.setDeathMessage("");
|
||||||
s.broadcastMessage(ChatColor.LIGHT_PURPLE + pname + " died of natural causes!");
|
s.broadcastMessage(ChatColor.LIGHT_PURPLE + pname + " died of natural causes!");
|
||||||
s.broadcastMessage(leftmsg);
|
s.broadcastMessage(leftmsg);
|
||||||
if(plugin.Playing.size()== 1 && plugin.canjoin== true){
|
plugin.winner();
|
||||||
//Announce winner
|
|
||||||
for(i = 0; i < plugin.Playing.size(); i++){
|
|
||||||
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.getInventory().setBoots(null);
|
|
||||||
winner.getInventory().setChestplate(null);
|
|
||||||
winner.getInventory().setHelmet(null);
|
|
||||||
winner.getInventory().setLeggings(null);
|
|
||||||
for(PotionEffect pe: winner.getActivePotionEffects()){
|
|
||||||
PotionEffectType potion = pe.getType();
|
|
||||||
winner.removePotionEffect(potion);
|
|
||||||
}
|
|
||||||
winner.teleport(Spawn);
|
|
||||||
winner.getInventory().addItem(plugin.Reward);
|
|
||||||
}
|
|
||||||
// Create the event here
|
|
||||||
//PlayerWinGamesEvent winevent = new PlayerWinGamesEvent(winner);
|
|
||||||
// Call the event
|
|
||||||
//Bukkit.getServer().getPluginManager().callEvent(winevent);
|
|
||||||
plugin.Playing.clear();
|
|
||||||
//Show spectators
|
|
||||||
for(String s1: plugin.Watching){
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,7 @@ public class HaCommands implements CommandExecutor {
|
|||||||
sender.sendMessage(c + "/ha restart - Makes it so dead tributes can join again!");
|
sender.sendMessage(c + "/ha restart - Makes it so dead tributes can join again!");
|
||||||
sender.sendMessage(c + "/ha rlist - See who's ready!");
|
sender.sendMessage(c + "/ha rlist - See who's ready!");
|
||||||
sender.sendMessage(c + "/ha setspawn - Sets the spawn for dead tributes!");
|
sender.sendMessage(c + "/ha setspawn - Sets the spawn for dead tributes!");
|
||||||
|
sender.sendMessage(c + "/ha tp [player] - Teleports you to a tribute!");
|
||||||
sender.sendMessage(c + "/ha start - Unfreezes tributes allowing them to fight!");
|
sender.sendMessage(c + "/ha start - Unfreezes tributes allowing them to fight!");
|
||||||
sender.sendMessage(c + "/ha watch - Lets you watch the tributes!");
|
sender.sendMessage(c + "/ha watch - Lets you watch the tributes!");
|
||||||
sender.sendMessage(c + "/ha warpall - Warps all tribute into position!");
|
sender.sendMessage(c + "/ha warpall - Warps all tribute into position!");
|
||||||
@ -92,7 +93,7 @@ public class HaCommands implements CommandExecutor {
|
|||||||
}else if((plugin.restricted && plugin.worlds.contains(p.getWorld().getName())) || !plugin.restricted){
|
}else if((plugin.restricted && plugin.worlds.contains(p.getWorld().getName())) || !plugin.restricted){
|
||||||
//////////////////////////////////////// LISTING ///////////////////////////////////////////////
|
//////////////////////////////////////// LISTING ///////////////////////////////////////////////
|
||||||
if(args[0].equalsIgnoreCase("List")){
|
if(args[0].equalsIgnoreCase("List")){
|
||||||
if(p.hasPermission("HungerArena.GameMaker")){
|
if(p.hasPermission("HungerArena.GameMaker") || plugin.Watching.contains(pname)){
|
||||||
sender.sendMessage(ChatColor.AQUA + "-----People Playing-----");
|
sender.sendMessage(ChatColor.AQUA + "-----People Playing-----");
|
||||||
if(!plugin.Playing.isEmpty()){
|
if(!plugin.Playing.isEmpty()){
|
||||||
for(String playernames: plugin.Playing){
|
for(String playernames: plugin.Playing){
|
||||||
@ -103,6 +104,16 @@ public class HaCommands implements CommandExecutor {
|
|||||||
p.sendMessage(ChatColor.GRAY + "No one is playing!");
|
p.sendMessage(ChatColor.GRAY + "No one is playing!");
|
||||||
}
|
}
|
||||||
p.sendMessage(ChatColor.AQUA + "----------------------");
|
p.sendMessage(ChatColor.AQUA + "----------------------");
|
||||||
|
}else if(p.hasPermission("HungerArena.List")){
|
||||||
|
sender.sendMessage(ChatColor.AQUA + "-----People Playing-----");
|
||||||
|
if(!plugin.Playing.isEmpty()){
|
||||||
|
for(String playernames: plugin.Playing){
|
||||||
|
sender.sendMessage(ChatColor.GREEN + playernames);
|
||||||
|
}
|
||||||
|
}else if(plugin.Playing.isEmpty()){
|
||||||
|
p.sendMessage(ChatColor.GRAY + "No one is playing!");
|
||||||
|
}
|
||||||
|
p.sendMessage(ChatColor.AQUA + "----------------------");
|
||||||
}else{
|
}else{
|
||||||
p.sendMessage(ChatColor.RED + "You don't have permission!");
|
p.sendMessage(ChatColor.RED + "You don't have permission!");
|
||||||
}
|
}
|
||||||
@ -140,14 +151,130 @@ public class HaCommands implements CommandExecutor {
|
|||||||
}else if(plugin.NeedConfirm.contains(pname)){
|
}else if(plugin.NeedConfirm.contains(pname)){
|
||||||
p.sendMessage(ChatColor.RED + "You need to do /ha confirm");
|
p.sendMessage(ChatColor.RED + "You need to do /ha confirm");
|
||||||
}else if(plugin.config.getString("Need_Confirm").equalsIgnoreCase("true")){
|
}else if(plugin.config.getString("Need_Confirm").equalsIgnoreCase("true")){
|
||||||
plugin.NeedConfirm.add(pname);
|
if(plugin.vault){
|
||||||
p.sendMessage(ChatColor.GOLD + "You're inventory will be cleared! Type /ha confirm to procede");
|
if(plugin.config.getBoolean("EntryFee.enabled") && plugin.config.getBoolean("EntryFee.eco")){
|
||||||
|
if(!(plugin.econ.getBalance(pname) < plugin.config.getDouble("EntryFee.cost"))){
|
||||||
|
i = 0;
|
||||||
|
for(ItemStack fee: plugin.Fee){
|
||||||
|
int total = plugin.Fee.size();
|
||||||
|
if(p.getInventory().contains(fee)){
|
||||||
|
i = i+1;
|
||||||
|
if(total == i){
|
||||||
|
plugin.NeedConfirm.add(pname);
|
||||||
|
p.sendMessage(ChatColor.GOLD + "You're inventory will be cleared! Type /ha confirm to procede");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(plugin.Fee.size() > i){
|
||||||
|
p.sendMessage(ChatColor.RED + "You are missing some items and can't join the games...");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
p.sendMessage(ChatColor.RED + "You don't have enough money to join!");
|
||||||
|
}
|
||||||
|
}else if(plugin.config.getBoolean("EntryFee.enabled") && !plugin.config.getBoolean("EntryFee.eco")){
|
||||||
|
i = 0;
|
||||||
|
for(ItemStack fee: plugin.Fee){
|
||||||
|
int total = plugin.Fee.size();
|
||||||
|
if(p.getInventory().contains(fee)){
|
||||||
|
i = i+1;
|
||||||
|
if(total == i){
|
||||||
|
plugin.NeedConfirm.add(pname);
|
||||||
|
p.sendMessage(ChatColor.GOLD + "You're inventory will be cleared! Type /ha confirm to procede");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(plugin.Fee.size() > i){
|
||||||
|
p.sendMessage(ChatColor.RED + "You are missing some items and can't join the games...");
|
||||||
|
}
|
||||||
|
}else if(!plugin.config.getBoolean("EntryFee.enabled") && plugin.config.getBoolean("EntryFee.eco")){
|
||||||
|
if(!(plugin.econ.getBalance(pname) < plugin.config.getDouble("EntryFee.cost"))){
|
||||||
|
plugin.NeedConfirm.add(pname);
|
||||||
|
p.sendMessage(ChatColor.GOLD + "You're inventory will be cleared! Type /ha confirm to procede");
|
||||||
|
}else{
|
||||||
|
p.sendMessage(ChatColor.RED + "You don't have enough money to join!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
plugin.NeedConfirm.add(pname);
|
||||||
|
p.sendMessage(ChatColor.GOLD + "You're inventory will be cleared! Type /ha confirm to procede");
|
||||||
|
}
|
||||||
|
}else if(plugin.config.getString("Need_Confirm").equalsIgnoreCase("false")){
|
||||||
|
if(plugin.vault){
|
||||||
|
if(plugin.config.getBoolean("EntryFee.enabled") && plugin.config.getBoolean("EntryFee.eco")){
|
||||||
|
if(!(plugin.econ.getBalance(pname) < plugin.config.getDouble("EntryFee.cost"))){
|
||||||
|
i = 0;
|
||||||
|
for(ItemStack fee: plugin.Fee){
|
||||||
|
int total = plugin.Fee.size();
|
||||||
|
if(p.getInventory().contains(fee)){
|
||||||
|
i = i+1;
|
||||||
|
if(total == i){
|
||||||
|
plugin.econ.withdrawPlayer(pname, plugin.config.getDouble("EntryFee.cost"));
|
||||||
|
plugin.Playing.add(pname);
|
||||||
|
clearInv(p);
|
||||||
|
p.sendMessage(ChatColor.GOLD + "Do /ha ready to vote to start the games!");
|
||||||
|
plugin.getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined the Game!");
|
||||||
|
if(plugin.Playing.size()== 24){
|
||||||
|
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha warpall");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(plugin.Fee.size() > i){
|
||||||
|
p.sendMessage(ChatColor.RED + "You are missing some items and can't join the games...");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
p.sendMessage(ChatColor.RED + "You don't have enough money to join!");
|
||||||
|
}
|
||||||
|
}else if(plugin.config.getBoolean("EntryFee.enabled") && !plugin.config.getBoolean("EntryFee.eco")){
|
||||||
|
i = 0;
|
||||||
|
for(ItemStack fee: plugin.Fee){
|
||||||
|
int total = plugin.Fee.size();
|
||||||
|
if(p.getInventory().contains(fee)){
|
||||||
|
i = i+1;
|
||||||
|
if(total == i){
|
||||||
|
plugin.Playing.add(pname);
|
||||||
|
clearInv(p);
|
||||||
|
p.sendMessage(ChatColor.GOLD + "Do /ha ready to vote to start the games!");
|
||||||
|
plugin.getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined the Game!");
|
||||||
|
if(plugin.Playing.size()== 24){
|
||||||
|
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha warpall");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(plugin.Fee.size() > i){
|
||||||
|
p.sendMessage(ChatColor.RED + "You are missing some items and can't join the games...");
|
||||||
|
}
|
||||||
|
}else if(!plugin.config.getBoolean("EntryFee.enabled") && plugin.config.getBoolean("EntryFee.eco")){
|
||||||
|
if(!(plugin.econ.getBalance(pname) < plugin.config.getDouble("EntryFee.cost"))){
|
||||||
|
plugin.econ.withdrawPlayer(pname, plugin.config.getDouble("EntryFee.cost"));
|
||||||
|
plugin.Playing.add(pname);
|
||||||
|
p.sendMessage(ChatColor.GREEN + "Do /ha ready to vote to start the games!");
|
||||||
|
clearInv(p);
|
||||||
|
plugin.getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined the Game!");
|
||||||
|
if(plugin.Playing.size()== 24){
|
||||||
|
p.performCommand("ha warpall");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
p.sendMessage(ChatColor.RED + "You don't have enough money to join!");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
plugin.Playing.add(pname);
|
||||||
|
p.sendMessage(ChatColor.GREEN + "Do /ha ready to vote to start the games!");
|
||||||
|
clearInv(p);
|
||||||
|
plugin.getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined the Game!");
|
||||||
|
if(plugin.Playing.size()== 24){
|
||||||
|
p.performCommand("ha warpall");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
plugin.Playing.add(pname);
|
plugin.Playing.add(pname);
|
||||||
|
p.sendMessage(ChatColor.GREEN + "Do /ha ready to vote to start the games!");
|
||||||
clearInv(p);
|
clearInv(p);
|
||||||
plugin.getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined the Game!");
|
plugin.getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined the Game!");
|
||||||
if(plugin.Playing.size()== 24){
|
if(plugin.Playing.size()== 24){
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha warpall");
|
p.performCommand("ha warpall");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@ -155,13 +282,76 @@ public class HaCommands implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}else if(args[0].equalsIgnoreCase("Confirm")){
|
}else if(args[0].equalsIgnoreCase("Confirm")){
|
||||||
if(plugin.NeedConfirm.contains(pname)){
|
if(plugin.NeedConfirm.contains(pname)){
|
||||||
plugin.Playing.add(pname);
|
if(plugin.config.getBoolean("EntryFee.enabled") && plugin.config.getBoolean("EntryFee.eco")){
|
||||||
plugin.NeedConfirm.remove(pname);
|
if(!(plugin.econ.getBalance(pname) < plugin.config.getDouble("EntryFee.cost"))){
|
||||||
p.sendMessage(ChatColor.GREEN + "Do /ha ready to vote to start the games!");
|
i = 0;
|
||||||
clearInv(p);
|
for(ItemStack fee: plugin.Fee){
|
||||||
plugin.getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined the Game!");
|
int total = plugin.Fee.size();
|
||||||
if(plugin.Playing.size()== 24){
|
if(p.getInventory().contains(fee)){
|
||||||
p.performCommand("ha warpall");
|
i = i+1;
|
||||||
|
if(total == i){
|
||||||
|
plugin.econ.withdrawPlayer(pname, plugin.config.getDouble("EntryFee.cost"));
|
||||||
|
plugin.Playing.add(pname);
|
||||||
|
plugin.NeedConfirm.remove(pname);
|
||||||
|
p.sendMessage(ChatColor.GREEN + "Do /ha ready to vote to start the games!");
|
||||||
|
clearInv(p);
|
||||||
|
plugin.getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined the Game!");
|
||||||
|
if(plugin.Playing.size()== 24){
|
||||||
|
p.performCommand("ha warpall");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(plugin.Fee.size() > i){
|
||||||
|
p.sendMessage(ChatColor.RED + "You are missing some items and can't join the games...");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
p.sendMessage(ChatColor.RED + "You don't have enough money to join!");
|
||||||
|
}
|
||||||
|
}else if(plugin.config.getBoolean("EntryFee.enabled") && !plugin.config.getBoolean("EntryFee.eco")){
|
||||||
|
i = 0;
|
||||||
|
for(ItemStack fee: plugin.Fee){
|
||||||
|
int total = plugin.Fee.size();
|
||||||
|
if(p.getInventory().contains(fee)){
|
||||||
|
i = i+1;
|
||||||
|
if(total == i){
|
||||||
|
plugin.Playing.add(pname);
|
||||||
|
plugin.NeedConfirm.remove(pname);
|
||||||
|
p.sendMessage(ChatColor.GREEN + "Do /ha ready to vote to start the games!");
|
||||||
|
clearInv(p);
|
||||||
|
plugin.getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined the Game!");
|
||||||
|
if(plugin.Playing.size()== 24){
|
||||||
|
p.performCommand("ha warpall");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(plugin.Fee.size() > i){
|
||||||
|
p.sendMessage(ChatColor.RED + "You are missing some items and can't join the games...");
|
||||||
|
}
|
||||||
|
}else if(!plugin.config.getBoolean("EntryFee.enabled") && plugin.config.getBoolean("EntryFee.eco")){
|
||||||
|
if(!(plugin.econ.getBalance(pname) < plugin.config.getDouble("EntryFee.cost"))){
|
||||||
|
plugin.econ.withdrawPlayer(pname, plugin.config.getDouble("EntryFee.cost"));
|
||||||
|
plugin.Playing.add(pname);
|
||||||
|
plugin.NeedConfirm.remove(pname);
|
||||||
|
p.sendMessage(ChatColor.GREEN + "Do /ha ready to vote to start the games!");
|
||||||
|
clearInv(p);
|
||||||
|
plugin.getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined the Game!");
|
||||||
|
if(plugin.Playing.size()== 24){
|
||||||
|
p.performCommand("ha warpall");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
p.sendMessage(ChatColor.RED + "You don't have enough money to join!");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
plugin.Playing.add(pname);
|
||||||
|
plugin.NeedConfirm.remove(pname);
|
||||||
|
p.sendMessage(ChatColor.GREEN + "Do /ha ready to vote to start the games!");
|
||||||
|
clearInv(p);
|
||||||
|
plugin.getServer().broadcastMessage(ChatColor.AQUA + pname + " has Joined the Game!");
|
||||||
|
if(plugin.Playing.size()== 24){
|
||||||
|
p.performCommand("ha warpall");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if(args[0].equalsIgnoreCase("Ready")){
|
}else if(args[0].equalsIgnoreCase("Ready")){
|
||||||
@ -192,6 +382,7 @@ public class HaCommands implements CommandExecutor {
|
|||||||
if(plugin.Frozen.contains(pname)){
|
if(plugin.Frozen.contains(pname)){
|
||||||
plugin.Frozen.remove(pname);
|
plugin.Frozen.remove(pname);
|
||||||
}
|
}
|
||||||
|
plugin.winner();
|
||||||
}else{
|
}else{
|
||||||
plugin.Playing.remove(pname);
|
plugin.Playing.remove(pname);
|
||||||
plugin.Quit.add(pname);
|
plugin.Quit.add(pname);
|
||||||
@ -202,35 +393,9 @@ public class HaCommands implements CommandExecutor {
|
|||||||
if(plugin.Frozen.contains(pname)){
|
if(plugin.Frozen.contains(pname)){
|
||||||
plugin.Frozen.remove(pname);
|
plugin.Frozen.remove(pname);
|
||||||
}
|
}
|
||||||
if(plugin.Playing.size()== 1){
|
|
||||||
//Announce the Winner
|
|
||||||
for(i = 0; i < plugin.Playing.size(); i++){
|
|
||||||
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!");
|
|
||||||
clearInv(winner);
|
|
||||||
winner.teleport(Spawn);
|
|
||||||
winner.getInventory().addItem(plugin.Reward);
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerWinGamesEvent(winner));
|
|
||||||
}
|
|
||||||
plugin.Playing.clear();
|
|
||||||
//Show spectators
|
|
||||||
for(i = 0; i < plugin.Watching.size(); i++){
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//////////////////////////////// SPECTATOR RELATED //////////////////////////////////
|
||||||
}else if(args[0].equalsIgnoreCase("Watch")){
|
}else if(args[0].equalsIgnoreCase("Watch")){
|
||||||
if(sender.hasPermission("HungerArena.Watch")){
|
if(sender.hasPermission("HungerArena.Watch")){
|
||||||
if(!plugin.Watching.contains(pname) && !plugin.Playing.contains(pname) && plugin.canjoin== true){
|
if(!plugin.Watching.contains(pname) && !plugin.Playing.contains(pname) && plugin.canjoin== true){
|
||||||
@ -256,6 +421,19 @@ public class HaCommands implements CommandExecutor {
|
|||||||
}else{
|
}else{
|
||||||
p.sendMessage(ChatColor.RED + "You don't have permission!");
|
p.sendMessage(ChatColor.RED + "You don't have permission!");
|
||||||
}
|
}
|
||||||
|
}else if(args[0].equalsIgnoreCase("tp")){
|
||||||
|
if(plugin.Watching.contains(pname)){
|
||||||
|
if(plugin.Playing.contains(plugin.getServer().getPlayer(args[1]).getName())){
|
||||||
|
Player target = plugin.getServer().getPlayerExact(args[1]);
|
||||||
|
p.teleport(target);
|
||||||
|
p.sendMessage(ChatColor.AQUA + "You've been teleported to " + target.getName());
|
||||||
|
}else{
|
||||||
|
p.sendMessage(ChatColor.RED + "That person isn't in game!");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
p.sendMessage(ChatColor.RED + "You have to be spectating to teleport to tributes!");
|
||||||
|
}
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
}else if(args[0].equalsIgnoreCase("Kick")){
|
}else if(args[0].equalsIgnoreCase("Kick")){
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
return false;
|
return false;
|
||||||
@ -268,31 +446,7 @@ public class HaCommands implements CommandExecutor {
|
|||||||
clearInv(target);
|
clearInv(target);
|
||||||
target.teleport(Spawn);
|
target.teleport(Spawn);
|
||||||
plugin.Quit.add(target.getName());
|
plugin.Quit.add(target.getName());
|
||||||
if(plugin.Playing.size()== 1 && plugin.canjoin== true){
|
plugin.winner();
|
||||||
//Announce winner
|
|
||||||
for(i = 0; i < plugin.Playing.size(); i++){
|
|
||||||
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!");
|
|
||||||
clearInv(winner);
|
|
||||||
winner.teleport(Spawn);
|
|
||||||
winner.getInventory().addItem(plugin.Reward);
|
|
||||||
plugin.Playing.clear();
|
|
||||||
}
|
|
||||||
//Show spectators
|
|
||||||
for(String s1: plugin.Watching){
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
sender.sendMessage(ChatColor.RED + "That player isn't in the game!");
|
sender.sendMessage(ChatColor.RED + "That player isn't in the game!");
|
||||||
}
|
}
|
||||||
@ -547,6 +701,7 @@ public class HaCommands implements CommandExecutor {
|
|||||||
sender.sendMessage(c + "/ha rlist - See who's ready!");
|
sender.sendMessage(c + "/ha rlist - See who's ready!");
|
||||||
sender.sendMessage(c + "/ha setspawn - Sets the spawn for dead tributes!");
|
sender.sendMessage(c + "/ha setspawn - Sets the spawn for dead tributes!");
|
||||||
sender.sendMessage(c + "/ha start - Unfreezes tributes allowing them to fight!");
|
sender.sendMessage(c + "/ha start - Unfreezes tributes allowing them to fight!");
|
||||||
|
sender.sendMessage(c + "/ha tp [player] - Teleports you to a tribute!");
|
||||||
sender.sendMessage(c + "/ha watch - Lets you watch the tributes!");
|
sender.sendMessage(c + "/ha watch - Lets you watch the tributes!");
|
||||||
sender.sendMessage(c + "/ha warpall - Warps all tribute into position!");
|
sender.sendMessage(c + "/ha warpall - Warps all tribute into position!");
|
||||||
sender.sendMessage(ChatColor.GREEN + "----------------------");
|
sender.sendMessage(ChatColor.GREEN + "----------------------");
|
||||||
@ -583,31 +738,7 @@ public class HaCommands implements CommandExecutor {
|
|||||||
clearInv(target);
|
clearInv(target);
|
||||||
target.teleport(Spawn);
|
target.teleport(Spawn);
|
||||||
plugin.Quit.add(target.getName());
|
plugin.Quit.add(target.getName());
|
||||||
if(plugin.Playing.size()== 1 && plugin.canjoin== true){
|
plugin.winner();
|
||||||
//Announce winner
|
|
||||||
for(i = 0; i < plugin.Playing.size(); i++){
|
|
||||||
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!");
|
|
||||||
clearInv(winner);
|
|
||||||
winner.teleport(Spawn);
|
|
||||||
winner.getInventory().addItem(plugin.Reward);
|
|
||||||
plugin.Playing.clear();
|
|
||||||
}
|
|
||||||
//Show spectators
|
|
||||||
for(String s1: plugin.Watching){
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
sender.sendMessage(ChatColor.RED + "That player isn't in the game!");
|
sender.sendMessage(ChatColor.RED + "That player isn't in the game!");
|
||||||
}
|
}
|
||||||
|
@ -79,57 +79,19 @@ public class JoinAndQuitListener implements Listener {
|
|||||||
p.teleport(Spawn);
|
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.getName();
|
final String pname = p.getName();
|
||||||
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);
|
|
||||||
if(plugin.Playing.contains(pname)){
|
if(plugin.Playing.contains(pname)){
|
||||||
plugin.Out.add(pname);
|
plugin.Out.add(pname);
|
||||||
plugin.Playing.remove(pname);
|
plugin.Playing.remove(pname);
|
||||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||||
public void run(){
|
public void run(){
|
||||||
if(plugin.Out.contains(pname)){
|
if(plugin.Out.contains(pname)){
|
||||||
if(plugin.canjoin== true){
|
|
||||||
plugin.Quit.add(pname);
|
plugin.Quit.add(pname);
|
||||||
plugin.Out.remove(pname);
|
plugin.Out.remove(pname);
|
||||||
if(plugin.Playing.size()== 1){
|
plugin.winner();
|
||||||
//Announce Winner
|
|
||||||
for(i = 0; i < plugin.Playing.size(); i++){
|
|
||||||
String winnername = plugin.Playing.get(i++);
|
|
||||||
Player winner = plugin.getServer().getPlayerExact(winnername);
|
|
||||||
String winnername2 = winner.getName();
|
|
||||||
p.getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
|
|
||||||
winner.getInventory().clear();
|
|
||||||
winner.getInventory().setBoots(null);
|
|
||||||
winner.getInventory().setChestplate(null);
|
|
||||||
winner.getInventory().setHelmet(null);
|
|
||||||
winner.getInventory().setLeggings(null);
|
|
||||||
winner.getInventory().addItem(plugin.Reward);
|
|
||||||
PlayerWinGamesEvent evt = new PlayerWinGamesEvent(winner);
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(evt);
|
|
||||||
}
|
|
||||||
//Make spectators visible
|
|
||||||
for(String s: plugin.Watching){
|
|
||||||
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{
|
}else{
|
||||||
plugin.Quit.add(pname);
|
plugin.Quit.add(pname);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -22,6 +23,8 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
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{
|
||||||
static final Logger log = Logger.getLogger("Minecraft");
|
static final Logger log = Logger.getLogger("Minecraft");
|
||||||
@ -63,10 +66,13 @@ public class Main extends JavaPlugin{
|
|||||||
public File dataFile = null;
|
public File dataFile = null;
|
||||||
public File managementFile = null;
|
public File managementFile = null;
|
||||||
public FileConfiguration management = null;
|
public FileConfiguration management = null;
|
||||||
public ItemStack Reward;
|
public ArrayList<ItemStack> Reward = new ArrayList<ItemStack>();
|
||||||
public ItemStack Cost;
|
public ArrayList<ItemStack> Cost = new ArrayList<ItemStack>();
|
||||||
|
public ArrayList<ItemStack> Fee = new ArrayList<ItemStack>();
|
||||||
public boolean vault = false;
|
public boolean vault = false;
|
||||||
|
public boolean eco = false;
|
||||||
public Economy econ = null;
|
public Economy econ = null;
|
||||||
|
int i = 0;
|
||||||
public void onEnable(){
|
public void onEnable(){
|
||||||
config = this.getConfig();
|
config = this.getConfig();
|
||||||
config.options().copyDefaults(true);
|
config.options().copyDefaults(true);
|
||||||
@ -110,27 +116,44 @@ public class Main extends JavaPlugin{
|
|||||||
}
|
}
|
||||||
System.out.println("[HungerArena] Loaded " + location.size() + " tribute spawns!");
|
System.out.println("[HungerArena] Loaded " + location.size() + " tribute spawns!");
|
||||||
if (setupEconomy()) {
|
if (setupEconomy()) {
|
||||||
log.info(ChatColor.AQUA + "[HungerArena] Found Vault! Hooking in for economy!");
|
log.info("[HungerArena] Found Vault! Hooking in for economy!");
|
||||||
}
|
}
|
||||||
if (config.getDouble("config.version") != 1.3) {
|
if (config.getDouble("config.version") != 1.3) {
|
||||||
config.set("config.version", 1.3);
|
config.set("config.version", 1.3);
|
||||||
config.set("eco.enabled", false);
|
config.set("rewardEco.enabled", false);
|
||||||
config.set("eco.reward", 100);
|
config.set("rewardEco.reward", 100);
|
||||||
}
|
}
|
||||||
if (config.getBoolean("eco.enabled", true)) {
|
if (config.getBoolean("rewardEco.enabled", true) || config.getBoolean("sponsorEco.enabled", true) || config.getBoolean("EntryFee.eco", true)) {
|
||||||
if (vault == true) {
|
if (vault == true) {
|
||||||
log.info(ChatColor.AQUA + "Economy hook deployed.");
|
log.info("Economy hook deployed.");
|
||||||
} else {
|
eco = true;
|
||||||
log.info(ChatColor.RED + "You want economy support... yet you don't have Vault. Sorry, can't give you it.");
|
}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 (config.getBoolean("eco.enabled", false)) {
|
if (!eco) {
|
||||||
if (vault == true) {
|
if (vault == true) {
|
||||||
log.info(ChatColor.GREEN + "We see that you have Vault on your server. To set economy support to true, enable it in the config.");
|
log.info(ChatColor.GREEN + "We see that you have Vault on your server. To set economy support to true, enable it in the config.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reward = new ItemStack(config.getInt("Reward.ID"), config.getInt("Reward.Amount"));
|
try{
|
||||||
Cost = new ItemStack(config.getInt("Sponsor_Cost.ID"), config.getInt("Sponsor_Cost.Amount"));
|
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");
|
worlds = config.getStringList("worlds");
|
||||||
if(worlds.isEmpty()){
|
if(worlds.isEmpty()){
|
||||||
restricted = false;
|
restricted = false;
|
||||||
@ -242,4 +265,57 @@ public class Main extends JavaPlugin{
|
|||||||
this.getLogger().log(Level.SEVERE, "Could not save config to " + managementFile, ex);
|
this.getLogger().log(Level.SEVERE, "Could not save config to " + managementFile, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void winner(){
|
||||||
|
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.size()== 1 && canjoin== false){
|
||||||
|
//Announce winner
|
||||||
|
for(i = 0; i < Playing.size(); i++){
|
||||||
|
String winnername = Playing.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);
|
||||||
|
for(PotionEffect pe: winner.getActivePotionEffects()){
|
||||||
|
PotionEffectType potion = pe.getType();
|
||||||
|
winner.removePotionEffect(potion);
|
||||||
|
}
|
||||||
|
Tele.add(winner);
|
||||||
|
winner.teleport(Spawn);
|
||||||
|
if(!config.getBoolean("rewardEco.enabled")){
|
||||||
|
for(ItemStack Rewards: Reward){
|
||||||
|
winner.getInventory().addItem(Rewards);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
econ.depositPlayer(winner.getName(), config.getDouble("eco.reward"));
|
||||||
|
}
|
||||||
|
Playing.clear();
|
||||||
|
}
|
||||||
|
//Show spectators
|
||||||
|
for(String s1: Watching){
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ 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.getName();
|
String epname = p.getName();
|
||||||
@ -36,36 +37,57 @@ public class SponsorCommands implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
if(args.length== 3){
|
if(args.length== 3){
|
||||||
Player target = Bukkit.getServer().getPlayer(args[0]);
|
Player target = Bukkit.getServer().getPlayer(args[0]);
|
||||||
try{
|
if(!plugin.Playing.contains(target.getName())){
|
||||||
int ID = Integer.parseInt(args[1]);
|
p.sendMessage(ChatColor.RED + "That person isn't playing!");
|
||||||
int Amount = Integer.parseInt(args[2]);
|
}else{
|
||||||
if((!plugin.management.getStringList("sponsors.blacklist").isEmpty() && !plugin.management.getStringList("sponsors.blacklist").contains(ID)) || plugin.management.getStringList("sponsors.blacklist").isEmpty()){
|
try{
|
||||||
ItemStack sponsoritem = new ItemStack(ID, Amount);
|
int ID = Integer.parseInt(args[1]);
|
||||||
if(p.getInventory().contains(plugin.config.getInt("Sponsor_Cost.ID"), plugin.config.getInt("Sponsor_Cost.Amount")*Amount)){
|
int Amount = Integer.parseInt(args[2]);
|
||||||
if(!plugin.Playing.contains(target.getName())){
|
if((!plugin.management.getStringList("sponsors.blacklist").isEmpty() && !plugin.management.getStringList("sponsors.blacklist").contains(ID)) || plugin.management.getStringList("sponsors.blacklist").isEmpty()){
|
||||||
p.sendMessage(ChatColor.RED + "That person isn't playing!");
|
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{
|
}else{
|
||||||
if(args[0].equalsIgnoreCase(pname)){
|
if(args[0].equalsIgnoreCase(pname)){
|
||||||
p.sendMessage(ChatColor.RED + "You can't sponsor yourself!");
|
p.sendMessage(ChatColor.RED + "You can't sponsor yourself!");
|
||||||
}else{
|
}else if(!(plugin.econ.getBalance(pname) < plugin.config.getDouble("sponsorEco.cost"))){
|
||||||
target.sendMessage(ChatColor.AQUA + "You have been Sponsored!");
|
target.sendMessage(ChatColor.AQUA + "You have been Sponsored!");
|
||||||
target.getInventory().addItem(sponsoritem);
|
target.getInventory().addItem(sponsoritem);
|
||||||
p.sendMessage("You have sponsored " + target.getName() + "!");
|
p.sendMessage("You have sponsored " + target.getName() + "!");
|
||||||
p.getInventory().removeItem(plugin.Cost);
|
plugin.econ.withdrawPlayer(pname, plugin.config.getDouble("sponsorEco.cost"));
|
||||||
|
}else{
|
||||||
|
p.sendMessage(ChatColor.RED + "You don't have enough money to do that!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
p.sendMessage(ChatColor.RED + "You don't have the necessary items to sponsor!");
|
p.sendMessage(ChatColor.RED + "You can't sponsor that item!");
|
||||||
}
|
p.sendMessage(ChatColor.GREEN + "Other items you can't sponsor are:");
|
||||||
}else{
|
for(String blacklist: plugin.management.getStringList("sponsors.blacklist")){
|
||||||
p.sendMessage(ChatColor.RED + "You can't sponsor that item!");
|
p.sendMessage(ChatColor.AQUA + blacklist);
|
||||||
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]");
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
|
||||||
p.sendMessage(ChatColor.RED + "Something went wrong there... Make sure that you do like this /sponsor [name] [number] [number]");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||||||
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;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ public class TeleportListener implements Listener {
|
|||||||
public TeleportListener(Main m) {
|
public TeleportListener(Main m) {
|
||||||
this.plugin = m;
|
this.plugin = m;
|
||||||
}
|
}
|
||||||
@EventHandler
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onTP(PlayerTeleportEvent event){
|
public void onTP(PlayerTeleportEvent event){
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
List<String> worlds = plugin.config.getStringList("worlds");
|
List<String> worlds = plugin.config.getStringList("worlds");
|
||||||
@ -22,6 +23,11 @@ public class TeleportListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
p.sendMessage(ChatColor.RED + "You are a dead tribute... How are you supposed to get back into the arena....");
|
p.sendMessage(ChatColor.RED + "You are a dead tribute... How are you supposed to get back into the arena....");
|
||||||
plugin.Tele.remove(p);
|
plugin.Tele.remove(p);
|
||||||
|
}else if(plugin.Tele.contains(p)){
|
||||||
|
if(event.isCancelled()){
|
||||||
|
event.setCancelled(false);
|
||||||
|
plugin.Tele.remove(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*@EventHandler Unwanted right now...
|
/*@EventHandler Unwanted right now...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user