No known bugs

This commit is contained in:
travja 2012-10-08 17:55:42 -06:00
parent 6b1a6b3c30
commit b0d29cd907
39 changed files with 939 additions and 1400 deletions

View File

@ -2,7 +2,7 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="lib" path="C:/Users/Travja/Downloads/bukkit-1.3.1-R1.1-20120809.005103-3.jar"/>
<classpathentry kind="lib" path="C:/Users/Travja/Documents/Plugins/Vault.jar"/>
<classpathentry kind="lib" path="C:/Users/Travja/Downloads/bukkit-1.3.2-R1.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

3
Data.yml Normal file
View File

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,15 @@
# Make like this to whitelist/blacklist
# whitelist:
# - /broadcast
# - /pm
# Anything not in the whitelist will be counted as blacklist!
commands:
whitelist: []
##### Not implemented! #####
blocks:
whitelist: []
blacklist: []
sponsors:
blacklist: []
############################

View File

@ -77,41 +77,4 @@ ChatClose: 'true'
ChatClose_Radius: 10
#############################
#############################
#############################
########################
####### Spawns #########
########################
Spawn_coords: 100,100,100,world
# If /ha setspawn has been run
Spawns_set: 'false'
Tribute_one_spawn: 100,100,100
Tribute_two_spawn: 100,100,100
Tribute_three_spawn: 100,100,100
Tribute_four_spawn: 100,100,100
Tribute_five_spawn: 100,100,100
Tribute_six_spawn: 100,100,100
Tribute_seven_spawn: 100,100,100
Tribute_eight_spawn: 100,100,100
Tribute_nine_spawn: 100,100,100
Tribute_ten_spawn: 100,100,100
Tribute_eleven_spawn: 100,100,100
Tribute_twelve_spawn: 100,100,100
Tribute_thirteen_spawn: 100,100,100
Tribute_fourteen_spawn: 100,100,100
Tribute_fifteen_spawn: 100,100,100
Tribute_sixteen_spawn: 100,100,100
Tribute_seventeen_spawn: 100,100,100
Tribute_eighteen_spawn: 100,100,100
Tribute_nineteen_spawn: 100,100,100
Tribute_twenty_spawn: 100,100,100
Tribute_twentyone_spawn: 100,100,100
Tribute_twentytwo_spawn: 100,100,100
Tribute_twentythree_spawn: 100,100,100
Tribute_twentyfour_spawn: 100,100,100
########################
########################
########################
# Leave this. :)
Blocks_Destroyed:
#############################

View File

@ -2,27 +2,28 @@
Spawn_coords: 100,100,100,world
# If /ha setspawn has been run
Spawns_set: 'false'
Tribute_one_spawn: 100,100,100
Tribute_two_spawn: 100,100,100
Tribute_three_spawn: 100,100,100
Tribute_four_spawn: 100,100,100
Tribute_five_spawn: 100,100,100
Tribute_six_spawn: 100,100,100
Tribute_seven_spawn: 100,100,100
Tribute_eight_spawn: 100,100,100
Tribute_nine_spawn: 100,100,100
Tribute_ten_spawn: 100,100,100
Tribute_eleven_spawn: 100,100,100
Tribute_twelve_spawn: 100,100,100
Tribute_thirteen_spawn: 100,100,100
Tribute_fourteen_spawn: 100,100,100
Tribute_fifteen_spawn: 100,100,100
Tribute_sixteen_spawn: 100,100,100
Tribute_seventeen_spawn: 100,100,100
Tribute_eighteen_spawn: 100,100,100
Tribute_nineteen_spawn: 100,100,100
Tribute_twenty_spawn: 100,100,100
Tribute_twentyone_spawn: 100,100,100
Tribute_twentytwo_spawn: 100,100,100
Tribute_twentythree_spawn: 100,100,100
Tribute_twentyfour_spawn: 100,100,100
Spawns:
- 100,100,100,world,false
- 100,100,100,world,false
- 100,100,100,world,false
- 100,100,100,world,false
- 100,100,100,world,false
- 100,100,100,world,false
- 100,100,100,world,false
- 100,100,100,world,false
- 100,100,100,world,false
- 100,100,100,world,false
- 100,100,100,world,false
- 100,100,100,world,false
- 100,100,100,world,false
- 100,100,100,world,false
- 100,100,100,world,false
- 100,100,100,world,false
- 100,100,100,world,false
- 100,100,100,world,false
- 100,100,100,world,false
- 100,100,100,world,false
- 100,100,100,world,false
- 100,100,100,world,false
- 100,100,100,world,false
- 100,100,100,world,false

View File

@ -3,22 +3,18 @@ package me.Travja.HungerArena;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.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.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockGrowEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerBucketFillEvent;
@ -32,8 +28,13 @@ public class BlockStorage implements Listener {
public void BlockBreak(BlockBreakEvent event){
Block b = event.getBlock();
Player p = event.getPlayer();
if(plugin.canjoin){
if(plugin.Playing.contains(p.getName())){
String pname = p.getName();
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!");
}
if(plugin.canjoin){
if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(p.getWorld().getName()))){
String w = b.getWorld().getName();
int x = b.getX();
@ -42,118 +43,110 @@ public class BlockStorage implements Listener {
int d = b.getTypeId();
byte m = b.getData();
String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m;
System.out.println("Leaf Break: " + coords);
List<String> blocks = plugin.config.getStringList("Blocks_Destroyed");
blocks.add(coords);
plugin.config.set("Blocks_Destroyed", blocks);
plugin.saveConfig();
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 creeperExplosion(EntityExplodeEvent event){
@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){
for(Block b:event.blockList()){
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();
String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Explode: " + coords);
List<String> blocks = plugin.config.getStringList("Blocks_Destroyed");
blocks.add(coords);
plugin.config.set("Blocks_Destroyed", blocks);
plugin.saveConfig();
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 burningBlocks(BlockBurnEvent event){
if(plugin.canjoin== true){
Block b = event.getBlock();
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Burn: " + coords);
List<String> blocks = plugin.config.getStringList("Blocks_Destroyed");
blocks.add(coords);
plugin.config.set("Blocks_Destroyed", blocks);
plugin.saveConfig();
}
}
@EventHandler
public void leafDecay(LeavesDecayEvent event){
if(plugin.canjoin== true){
Block b = event.getBlock();
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Decay: " + coords);
List<String> blocks = plugin.config.getStringList("Blocks_Destroyed");
blocks.add(coords);
plugin.config.set("Blocks_Destroyed", blocks);
plugin.saveConfig();
}
}
@EventHandler
public void blockPlace(BlockPlaceEvent event){
if(plugin.canjoin== true){
Block b = event.getBlock();
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d;
if(!(d== 51) && !(d==12) && !(d==13)){
System.out.println("Place: " + coords);
List<String> blocks = plugin.config.getStringList("Blocks_Placed");
blocks.add(coords);
plugin.config.set("Blocks_Placed", blocks);
plugin.saveConfig();
}else if (d == 12 || d == 13) {
System.out.println("Sand/Gravel");
int newy = y;
int replaced = 0;
Location l = b.getLocation();
while(l.getBlock().getRelative(BlockFace.DOWN).getType()== Material.AIR){
newy = newy-1;
replaced = 0;
System.out.println(newy);
}
while(l.getBlock().getRelative(BlockFace.DOWN).getType()== Material.WATER){
newy = newy-1;
replaced = 8;
}
while(l.getBlock().getRelative(BlockFace.DOWN).getType()== Material.LAVA){
newy = newy-1;
replaced = 10;
}
if(l.getBlock().getRelative(BlockFace.DOWN).getType()!= Material.AIR || l.getBlock().getRelative(BlockFace.DOWN).getType()!= Material.WATER || l.getBlock().getRelative(BlockFace.DOWN).getType()!= Material.LAVA){
event.getPlayer().sendMessage(ChatColor.GREEN + "Block will land at " + x + ", " + newy + ", " + z + " and replaced " + replaced);
}
Location location = b.getLocation();
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;
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{
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();
}
event.getPlayer().sendMessage("Block will land at: " + location);
System.out.println("Sand/Gravel Place: " + coords);
List<String> blocks = plugin.config.getStringList("Blocks_Destroyed");
blocks.add(coords);
plugin.config.set("Blocks_Destroyed", blocks);
plugin.saveConfig();
}
}
}
@ -161,77 +154,68 @@ public class BlockStorage implements Listener {
}
@EventHandler
public void bucketEmpty(PlayerBucketEmptyEvent event){
if(plugin.canjoin== true){
Block clicked = event.getBlockClicked();
BlockFace face = event.getBlockFace();
Block b = clicked.getRelative(face);
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Bucket Empty: " + coords);
List<String> blocks = plugin.config.getStringList("Blocks_Placed");
blocks.add(coords);
plugin.config.set("Blocks_Destroyed", blocks);
plugin.saveConfig();
}
}
@EventHandler
public void bucketFill(PlayerBucketFillEvent event){
if(plugin.canjoin== true){
Block b = event.getBlockClicked();
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Bucket Fill: " + coords);
List<String> blocks = plugin.config.getStringList("Blocks_Destroyed");
blocks.add(coords);
plugin.config.set("Blocks_Destroyed", blocks);
plugin.saveConfig();
}
}
@EventHandler
public void blockBreak(BlockBreakEvent event){
if(plugin.canjoin== true){
Block b = event.getBlock();
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Break: " + coords);
List<String> blocks = plugin.config.getStringList("Blocks_Destroyed");
blocks.add(coords);
plugin.config.set("Blocks_Destroyed", blocks);
plugin.saveConfig();
}
}
@EventHandler
public void blockMelt(BlockFadeEvent event){
if(plugin.canjoin== true){
Block b = event.getBlock();
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d;
if(d != 51 && d != 2){
System.out.println("Fade: " + coords);
List<String> blocks = plugin.config.getStringList("Blocks_Destroyed");
blocks.add(coords);
plugin.config.set("Blocks_Destroyed", blocks);
plugin.saveConfig();
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
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();
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 blockMelt(BlockFadeEvent event){
if(plugin.canjoin){
if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(event.getBlock().getWorld().getName()))){
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;
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 blockGrow(BlockGrowEvent event){
if(plugin.canjoin== true){
Block b = event.getBlock();
@ -242,9 +226,9 @@ public class BlockStorage implements Listener {
int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Grow: " + coords);
List<String> blocks = plugin.config.getStringList("Blocks_Placed");
List<String> blocks = plugin.data.getStringList("Blocks_Placed");
blocks.add(coords);
plugin.config.set("Blocks_Destroyed", blocks);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveConfig();
}
}
@ -259,9 +243,9 @@ public class BlockStorage implements Listener {
int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Snowfall: " + coords);
List<String> blocks = plugin.config.getStringList("Blocks_Placed");
List<String> blocks = plugin.data.getStringList("Blocks_Placed");
blocks.add(coords);
plugin.config.set("Blocks_Destroyed", blocks);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveConfig();
}
}
@ -276,9 +260,9 @@ public class BlockStorage implements Listener {
int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Piston: " + coords);
List<String> blocks = plugin.config.getStringList("Blocks_Destroyed");
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
blocks.add(coords);
plugin.config.set("Blocks_Destroyed", blocks);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveConfig();
}
}
@ -297,9 +281,9 @@ public class BlockStorage implements Listener {
int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Lava Change: " + coords);
List<String> blocks = plugin.config.getStringList("Blocks_Placed");
List<String> blocks = plugin.data.getStringList("Blocks_Placed");
blocks.add(coords);
plugin.config.set("Blocks_Destroyed", blocks);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveConfig();
}else if(changed == Material.WATER){
Block b = event.getBlock();
@ -310,9 +294,9 @@ public class BlockStorage implements Listener {
int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Water Change: " + coords);
List<String> blocks = plugin.config.getStringList("Blocks_Placed");
List<String> blocks = plugin.data.getStringList("Blocks_Placed");
blocks.add(coords);
plugin.config.set("Blocks_Destroyed", blocks);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveConfig();
}
}else if (block.getType() == Material.SAND || block.getType() == Material.GRAVEL) {
@ -325,9 +309,9 @@ public class BlockStorage implements Listener {
int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Sand/Gravel Fall: " + coords);
List<String> blocks = plugin.config.getStringList("Blocks_Placed");
List<String> blocks = plugin.data.getStringList("Blocks_Placed");
blocks.add(coords);
plugin.config.set("Blocks_Destroyed", blocks);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveConfig();
}
}

View File

@ -3,6 +3,7 @@ package me.Travja.HungerArena;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -27,82 +28,35 @@ public class Chests implements Listener {
Block block = event.getBlock();
if(p.getItemInHand().getType()== Material.BLAZE_ROD && p.hasPermission("HungerArena.Chest.Store")){
if(block.getState() instanceof Chest){
event.setCancelled(true);
ItemStack[] itemsinchest = ((Chest) block.getState()).getInventory().getContents();
int blockx = block.getX();
int blocky = block.getY();
int blockz = block.getZ();
String blockw = block.getWorld().getName().toString();
if(!plugin.getConfig().contains("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X")){
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X", blockx);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Y", blocky);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Z",blockz);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.W", blockw);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".ItemsInStorage", itemsinchest);
}else{
plugin.getConfig().set("Storage." + blockx + "," + blocky+ "," + blockz + ".Location.X",blockx);
plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Y", blocky);
plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Z", blockz);
plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.W", blockw);
plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".ItemsInStorage", itemsinchest);
}
List<String> list2 = plugin.getConfig().getStringList("StorageXYZ");
list2.add(blockx + "," + blocky + "," + blockz);
plugin.getConfig().set("StorageXYZ", list2);
plugin.getConfig().options().copyDefaults(true);
plugin.saveConfig();
p.sendMessage(ChatColor.GREEN + "Chest Stored!");
event.setCancelled(true);
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);
}
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 + "Chest Stored!");
}else{
p.sendMessage(ChatColor.GREEN + "Chest already stored!");
}
}
}else if(p.getItemInHand().getType()== Material.BLAZE_ROD && !p.hasPermission("HungerArena.Chest.Store") && block.getState() instanceof Chest){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You can't store chests!!");
}
}
@EventHandler
public void ChestSaves(PlayerInteractEvent event){
Block block = event.getClickedBlock();
Player p = event.getPlayer();
if(p.getItemInHand().getType()== Material.BLAZE_ROD && event.getAction() == Action.LEFT_CLICK_BLOCK){
if(!plugin.restricted || (plugin.restricted && plugin.worlds.contains(p.getWorld().getName()))){
if(block.getState() instanceof Chest){
if(p.hasPermission("HungerArena.Chest.Store")){
ItemStack[] itemsinchest = ((Chest) block.getState()).getInventory().getContents();
int blockx = block.getX();
int blocky = block.getY();
int blockz = block.getZ();
String blockw = block.getWorld().getName().toString();
if(!plugin.getConfig().contains("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X")){
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X", blockx);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Y", blocky);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Z",blockz);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.W", blockw);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".ItemsInStorage", itemsinchest);
}else{
plugin.getConfig().set("Storage." + blockx + "," + blocky+ "," + blockz + ".Location.X",blockx);
plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Y", blocky);
plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Z", blockz);
plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.W", blockw);
plugin.getConfig().set("Storage." + blockx + "," + blocky + "," + blockz + ".ItemsInStorage", itemsinchest);
}
List<String> list2 = plugin.getConfig().getStringList("StorageXYZ");
list2.add(blockx + "," + blocky + "," + blockz);
plugin.getConfig().set("StorageXYZ", list2);
plugin.getConfig().options().copyDefaults(true);
plugin.saveConfig();
p.sendMessage(ChatColor.GREEN + "Chest Stored!");
}else{
p.sendMessage(ChatColor.RED + "You don't have permission to store chests!");
}
}
}
}
}
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
Player p = event.getPlayer();
Block block = event.getBlock();
Location blocklocation = event.getBlock().getLocation();
if (block.getState() instanceof Chest && !plugin.Playing.contains(p.getDisplayName())) {
}else if(p.hasPermission("HungerArena.Chest.Break")){
Location blocklocation = event.getBlock().getLocation();
int blockx = blocklocation.getBlockX();
int blocky = blocklocation.getBlockY();
int blockz = blocklocation.getBlockZ();
@ -110,6 +64,7 @@ public class Chests implements Listener {
if(p.hasPermission("HungerArena.Chest.Break")){
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();
@ -121,4 +76,71 @@ public class Chests implements Listener {
}
}
}
@EventHandler
public void ChestSaves(PlayerInteractEvent event){
Block block = event.getClickedBlock();
Player p = event.getPlayer();
if(event.getAction()== Action.LEFT_CLICK_BLOCK || event.getAction()== Action.RIGHT_CLICK_BLOCK){
if(p.getItemInHand().getType()== Material.BLAZE_ROD && event.getAction() == Action.LEFT_CLICK_BLOCK){
if(!plugin.restricted || (plugin.restricted && plugin.worlds.contains(p.getWorld().getName()))){
if(p.getGameMode().equals(GameMode.SURVIVAL)){
if(block.getState() instanceof Chest){
if(p.hasPermission("HungerArena.Chest.Store")){
ItemStack[] itemsinchest = ((Chest) block.getState()).getInventory().getContents();
List<String> list2 = plugin.getConfig().getStringList("StorageXYZ");
int blockx = block.getX();
int blocky = block.getY();
int blockz = block.getZ();
String blockw = block.getWorld().getName().toString();
if(!plugin.getConfig().contains("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X")){
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X", blockx);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Y", blocky);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Z",blockz);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.W", blockw);
plugin.getConfig().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".ItemsInStorage", itemsinchest);
}
if(!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 + "Chest Stored!");
}else{
p.sendMessage(ChatColor.GREEN + "Chest already stored!");
}
}else{
p.sendMessage(ChatColor.RED + "You don't have permission to store chests!");
}
}
}
}
}
if(plugin.Playing.contains(p.getName()) && plugin.canjoin){
if(!plugin.restricted || (plugin.restricted && plugin.worlds.contains(p.getWorld().getName()))){
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);
}
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

@ -17,13 +17,40 @@ public class CommandBlock implements Listener {
String cmd = event.getMessage();
Player p = event.getPlayer();
String pname = p.getName();
if(!cmd.contains("/ha") && plugin.Playing.contains(pname) && plugin.canjoin== true){
if(!cmd.contains("/login")){
if(!p.hasPermission("HungerArena.UseCommands")){
if(plugin.Playing.contains(pname)){
if(!p.hasPermission("HungerArena.UseCommands")){
for(String whitelist: plugin.management.getStringList("commands.whitelist")){
if(!cmd.toLowerCase().contains(whitelist.toLowerCase()) && !cmd.toLowerCase().contains("/ha")){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are only allowed to perform the following commands:");
p.sendMessage(ChatColor.AQUA + whitelist);
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 watch");
p.sendMessage(ChatColor.AQUA + "/ha warpall");
}
}
}else if(!cmd.toLowerCase().contains("/ha")){
if(cmd.toLowerCase().contains("/spawn")){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are only allowed to use /ha commands!");
p.sendMessage("You have perms for all commands except this one!");
}
}
}else if(cmd.toLowerCase().equals("/back") && plugin.Dead.contains(pname) && plugin.canjoin== true){
plugin.Tele.add(p);
}
}
}

View File

@ -7,6 +7,8 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class DeathListener implements Listener{
public Main plugin;
@ -17,7 +19,7 @@ public class DeathListener implements Listener{
int i = 0;
@EventHandler
public void onPlayerRespawn(PlayerRespawnEvent event){
Player p = event.getPlayer();
final Player p = event.getPlayer();
String pname = p.getName();
if(plugin.Dead.contains(pname)){
String[] Spawncoords = plugin.spawns.getString("Spawn_coords").split(",");
@ -25,8 +27,12 @@ public class DeathListener implements Listener{
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);
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
@ -42,7 +48,6 @@ public class DeathListener implements Listener{
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.config.getString("Cannon_Death").equalsIgnoreCase("True")){
double y = p.getLocation().getY();
@ -66,23 +71,27 @@ public class DeathListener implements Listener{
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);
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 sname: plugin.Watching){
Player spectator = plugin.getServer().getPlayerExact(sname);
spectator.setAllowFlight(false);
spectator.teleport(spectator.getWorld().getSpawnLocation());
for(Player online:plugin.getServer().getOnlinePlayers()){
online.showPlayer(spectator);
}
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(){
@ -118,24 +127,25 @@ public class DeathListener implements Listener{
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);
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
if(!plugin.Watching.isEmpty()){
for(i = 0; i < plugin.Watching.size(); i++){
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);
}
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")){
@ -158,24 +168,25 @@ public class DeathListener implements Listener{
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);
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
if(plugin.Watching.size() != 0){
for(i = 0; i < plugin.Watching.size(); i++){
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);
}
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")){
@ -195,11 +206,15 @@ public class DeathListener implements Listener{
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);
for(PotionEffect pe: winner.getActivePotionEffects()){
PotionEffectType potion = pe.getType();
winner.removePotionEffect(potion);
}
winner.teleport(Spawn);
winner.getInventory().addItem(plugin.Reward);
}
// Create the event here
@ -208,15 +223,12 @@ public class DeathListener implements Listener{
//Bukkit.getServer().getPluginManager().callEvent(winevent);
plugin.Playing.clear();
//Show spectators
if(!plugin.Watching.isEmpty()){
for(i = 0; i < plugin.Watching.size(); i++){
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);
}
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")){

View File

@ -1,6 +1,5 @@
package me.Travja.HungerArena;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -12,13 +11,39 @@ public class FreezeListener implements Listener {
public FreezeListener(Main m) {
this.plugin = m;
}
int i = 0;
private boolean timeUp;
@EventHandler
public void onPlayerMove(PlayerMoveEvent event){
Player p = event.getPlayer();
String pname = p.getName();
if(plugin.Frozen.contains(pname) && plugin.config.getString("Frozen_Teleport").equalsIgnoreCase("True")){
if(plugin.config.getString("Explode_on_Move").equalsIgnoreCase("true")){
if(plugin.Playing.size()>=1){
for(String players:plugin.Playing){
final Player playing = plugin.getServer().getPlayerExact(players);
i = plugin.Playing.indexOf(players);
if(!timeUp){
if(!playing.getLocation().getBlock().getLocation().equals(plugin.location.get(i))){
playing.teleport(plugin.location.get(i));
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
if(!timeUp){
timeUp = true;
}
}
},30L);
}
}else{
if(!playing.getLocation().getBlock().getLocation().equals(plugin.location.get(i))){
if(!plugin.Dead.contains(playing.getName())){
World world = playing.getLocation().getWorld();
world.createExplosion(playing.getLocation(), 0.0F, false);
playing.setHealth(0);
}
}
}
}
/*if(plugin.Playing.size()>=1){
String one = plugin.Playing.get(0);
if(pname==one){
Player tone = plugin.getServer().getPlayerExact(one);
@ -473,9 +498,16 @@ public class FreezeListener implements Listener {
}
}
}
}
}*/
}else{
if(plugin.Playing.size()>=1){
for(String players:plugin.Playing){
Player playing = plugin.getServer().getPlayerExact(players);
i = plugin.Playing.indexOf(players);
if(!playing.getLocation().getBlock().getLocation().equals(plugin.location.get(i))){
playing.teleport(plugin.location.get(i));
}
}
/*if(plugin.Playing.size()>=1){
String one = plugin.Playing.get(0);
if(pname==one){
Player tone = plugin.getServer().getPlayerExact(one);
@ -834,7 +866,7 @@ public class FreezeListener implements Listener {
ttwentyfour.teleport(twentyfourspwn);
}
}
}
}*/
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -117,9 +117,7 @@ public class JoinAndQuitListener implements Listener {
Bukkit.getServer().getPluginManager().callEvent(evt);
}
//Make spectators visible
if(!plugin.Watching.isEmpty()){
for(i = 0; i < plugin.Playing.size(); i++){
String s = plugin.Watching.get(i++);
for(String s: plugin.Watching){
Player spectator = plugin.getServer().getPlayerExact(s);
spectator.setAllowFlight(false);
spectator.teleport(Spawn);
@ -127,7 +125,6 @@ public class JoinAndQuitListener implements Listener {
online.showPlayer(spectator);
}
}
}
if(plugin.config.getString("Auto_Restart").equalsIgnoreCase("True")){
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart");
}

View File

@ -8,11 +8,16 @@ import java.util.HashSet;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
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;
@ -27,6 +32,8 @@ public class Main extends JavaPlugin{
public ArrayList<String> Out = new ArrayList<String>();
public ArrayList<String> Watching = new ArrayList<String>();
public ArrayList<String> NeedConfirm = new ArrayList<String>();
public ArrayList<Location> location = new ArrayList<Location>();
public ArrayList<Player> Tele = new ArrayList<Player>();
public HashSet<String> Frozen = new HashSet<String>();
public List<String> worlds;
public Listener DeathListener = new DeathListener(this);
@ -36,7 +43,6 @@ public class Main extends JavaPlugin{
public Listener ChatListener = new ChatListener(this);
public Listener Chests = new Chests(this);
public Listener PvP = new PvP(this);
public Listener Blocks = new Blocks(this);
public Listener CommandBlock = new CommandBlock(this);
public Listener Damage = new DmgListener(this);
public Listener Teleport = new TeleportListener(this);
@ -53,6 +59,10 @@ public class Main extends JavaPlugin{
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 ItemStack Reward;
public ItemStack Cost;
public boolean vault = false;
@ -61,9 +71,15 @@ public class Main extends JavaPlugin{
config = this.getConfig();
config.options().copyDefaults(true);
this.saveDefaultConfig();
this.getSpawns();
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();
log.info("[HungerArena] enabled v" + getDescription().getVersion());
getServer().getPluginManager().registerEvents(DeathListener, this);
getServer().getPluginManager().registerEvents(SpectatorListener, this);
@ -72,7 +88,6 @@ public class Main extends JavaPlugin{
getServer().getPluginManager().registerEvents(ChatListener, this);
getServer().getPluginManager().registerEvents(Chests, this);
getServer().getPluginManager().registerEvents(PvP, this);
getServer().getPluginManager().registerEvents(Blocks, this);
getServer().getPluginManager().registerEvents(CommandBlock, this);
getServer().getPluginManager().registerEvents(Signs, this);
getServer().getPluginManager().registerEvents(BlockStorage, this);
@ -81,6 +96,19 @@ public class Main extends JavaPlugin{
getCommand("Ha").setExecutor(HaCommands);
getCommand("Sponsor").setExecutor(SponsorCommands);
getCommand("Startpoint").setExecutor(SpawnsCommand);
for(String spawnlocations:spawns.getStringList("Spawns")){
String[] coords = spawnlocations.split(",");
if(coords[4].equalsIgnoreCase("true")){
double x = Double.parseDouble(coords[0]);
double y = Double.parseDouble(coords[1]);
double z = Double.parseDouble(coords[2]);
String world = coords[3];
World w = getServer().getWorld(world);
Location loc = new Location(w, x, y, z);
location.add(loc);
}
}
System.out.println("[HungerArena] Loaded " + location.size() + " tribute spawns!");
if (setupEconomy()) {
log.info(ChatColor.AQUA + "[HungerArena] Found Vault! Hooking in for economy!");
}
@ -127,33 +155,91 @@ public class Main extends JavaPlugin{
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 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);
}
}
}

View File

@ -2,7 +2,10 @@ 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;
@ -11,13 +14,47 @@ public class PvP implements Listener {
public PvP(Main m) {
this.plugin = m;
}
@EventHandler
@EventHandler(priority= EventPriority.MONITOR)
public void PlayerPvP(EntityDamageByEntityEvent event){
Entity p = event.getEntity();
if(p instanceof Player){
Entity d = event.getDamager();
if(p instanceof Player && d instanceof Player){
String pname = ((Player) p).getName();
if(plugin.Playing.contains(pname) && plugin.canjoin== false){
event.setCancelled(true);
String dname = ((Player) d).getName();
if(plugin.Playing.contains(pname) && plugin.Playing.contains(dname)){
if(plugin.canjoin){
if(event.isCancelled()){
event.setCancelled(false);
}
}
}else if(plugin.Playing.contains(pname)){
if(!plugin.canjoin){
if(!event.isCancelled()){
event.setCancelled(true);
}
}
}else if(!plugin.Playing.contains(pname) && plugin.Playing.contains(dname)){
if(!event.isCancelled()){
event.setCancelled(true);
}
}
}else if(p instanceof Player && d instanceof Projectile){
Projectile projectile = (Projectile) d;
String pname = ((Player) p).getName();
if(projectile.getShooter() instanceof Player){
if(plugin.Playing.contains(pname)){
Player shooter = (Player) projectile.getShooter();
if(plugin.Playing.contains(shooter.getName())){
event.setCancelled(false);
}
}
}else if(projectile.getShooter() instanceof Entity){
Entity e = projectile.getShooter();
if(e instanceof Skeleton){
if(plugin.Playing.contains(pname)){
event.setCancelled(false);
}
}
}
}
}

View File

@ -1,5 +1,7 @@
package me.Travja.HungerArena;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.Command;
@ -12,19 +14,42 @@ public class SpawnsCommand implements CommandExecutor {
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(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.");
try{
int i = Integer.parseInt(args[0]);
if(i >= 1 && i <= 24){
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();
List<String> locations = plugin.spawns.getStringList("Spawns");
double x = ploc.getX();
double y = ploc.getY();
double z = ploc.getZ();
String w = ploc.getWorld().getName();
String coords = x + "," + y + "," + z + "," + w + ",true";
locations.set(i-1, coords);
plugin.spawns.set("Spawns", locations);
plugin.saveSpawns();
plugin.location.add(new Location(ploc.getWorld(), x, y, z));
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute " + i);
}else{
p.sendMessage(ChatColor.RED + "You can't go past 24 or below 1!");
}
}catch(Exception e){
p.sendMessage(ChatColor.RED + "Argument not an integer!");
}
Location ploc = p.getLocation().getBlock().getLocation();
if(args[0].equalsIgnoreCase("1")){
}
}else{
p.sendMessage(ChatColor.RED + "You don't have permission!");
}
/*if(args[0].equalsIgnoreCase("1")){
double x = ploc.getX();
double y = ploc.getY();
double z = ploc.getZ();
@ -239,11 +264,7 @@ public class SpawnsCommand implements CommandExecutor {
plugin.spawns.set("Tribute_twentyfour_spawn", x + "," + y + "," + z + "," + w);
plugin.saveSpawns();
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute twentyfour!");
}
}
}else{
p.sendMessage(ChatColor.RED + "You don't have permission!");
}
}*/
}
return false;
}

View File

@ -36,28 +36,36 @@ public class SponsorCommands implements CommandExecutor {
}
if(args.length== 3){
Player target = Bukkit.getServer().getPlayer(args[0]);
if(args[1].equalsIgnoreCase("57") || args[1].equalsIgnoreCase("7")){
p.sendMessage(ChatColor.RED + "You can't sponsor that item!");
}else{
try{
int ID = Integer.parseInt(args[1]);
int Amount = Integer.parseInt(args[2]);
ItemStack sponsoritem = new ItemStack(ID, Amount);
if(p.getInventory().contains(plugin.config.getInt("Sponsor_Cost.ID"), plugin.config.getInt("Sponsor_Cost.Amount")*Amount)){
if(!plugin.Playing.contains(target.getName())){
p.sendMessage(ChatColor.RED + "That person isn't playing!");
}else{
if(args[0].equalsIgnoreCase(pname)){
p.sendMessage(ChatColor.RED + "You can't sponsor yourself!");
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(p.getInventory().contains(plugin.config.getInt("Sponsor_Cost.ID"), plugin.config.getInt("Sponsor_Cost.Amount")*Amount)){
if(!plugin.Playing.contains(target.getName())){
p.sendMessage(ChatColor.RED + "That person isn't playing!");
}else{
target.sendMessage(ChatColor.AQUA + "You have been Sponsored!");
target.getInventory().addItem(sponsoritem);
p.sendMessage("You have sponsored " + target.getName() + "!");
p.getInventory().removeItem(plugin.Cost);
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() + "!");
p.getInventory().removeItem(plugin.Cost);
}
}
}else{
p.sendMessage(ChatColor.RED + "You don't have the necessary items to sponsor!");
}
}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:");
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{
@ -79,20 +87,28 @@ public class SponsorCommands implements CommandExecutor {
}
if(args.length== 3){
Player target = Bukkit.getPlayer(args[0]);
if(args[1].equalsIgnoreCase("57") || args[1].equalsIgnoreCase("7")){
sender.sendMessage(ChatColor.RED + "You can't sponsor that item!");
}else{
int ID = Integer.parseInt(args[1]);
int Amount = Integer.parseInt(args[2]);
ItemStack sponsoritem = new ItemStack(ID, Amount);
if(!plugin.Playing.contains(target.getName())){
sender.sendMessage(ChatColor.RED + "That person isn't playing!");
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.Playing.contains(target.getName())){
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 yourself!");
target.sendMessage(ChatColor.AQUA + "You have been Sponsored!");
target.getInventory().addItem(sponsoritem);
sender.sendMessage("You have sponsored " + target.getName() + "!");
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]");
}
}
}

View File

@ -1,22 +1,29 @@
package me.Travja.HungerArena;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
/**
*
* @author YoshiGenius
*/
public class TeleportListener implements Listener {
public Main plugin;
public TeleportListener(Main m) {
this.plugin = m;
}
@EventHandler
public void onTP(PlayerTeleportEvent event){
Player p = event.getPlayer();
List<String> worlds = plugin.config.getStringList("worlds");
if(worlds.contains(event.getTo().getWorld().getName()) && plugin.Tele.contains(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are a dead tribute... How are you supposed to get back into the arena....");
plugin.Tele.remove(p);
}
}
/*@EventHandler Unwanted right now...
public void onTP(PlayerTeleportEvent evt) {
@SuppressWarnings("unused")