Massive update to support 1.9 up to 1.14, and lots of fixes!

This commit is contained in:
Jeppa 2019-12-08 15:29:35 +01:00
parent edfba1aa90
commit 361396aa4a
34 changed files with 2047 additions and 2665 deletions

View File

@ -1,8 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/Documents/Plugins/Vault.jar"/>
<classpathentry kind="lib" path="C:/Users/Travja/Downloads/craftbukkit-1.5.1-R0.1-20130321.220235-8.jar"/>
<classpathentry excluding="me/Travja/HungerArena/ConfigManager.java" kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="lib" path="W:/Java_Dev/workspace/spigot-1.14.4_BT101.jar">
<attributes>
<attribute name="javadoc_location" value="jar:file:/W:/Java_Dev/workspace/spigot-api-1.14.2-R0.1-20190529.100137-6-javadoc!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="W:/Java_Dev/workspace/Vault_1.7.2.jar"/>
<classpathentry kind="lib" path="W:/Java_Dev/workspace/worldedit-bukkit-6.0.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

4
.gitignore vendored
View File

@ -11,4 +11,6 @@ hs_err_pid*
.project.settings
.project
.classpath
bin
*.classpath
bin
/.classpath

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>HungerArena</name>
<name>HungerArena_Jeppa</name>
<comment></comment>
<projects>
</projects>

View File

@ -1,12 +0,0 @@
#Thu Mar 29 22:18:31 MDT 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

40
README
View File

@ -1,6 +1,5 @@
Orig README by Travja:
http://dev.bukkit.org/server-mods/hungerarena
Working on a rewrite :D Going to be EPIC https://github.com/travja/HungerArena-Reloaded
Orig plugin by Travja:
https://dev.bukkit.org/projects/hungerarena
/\
|
|
@ -9,16 +8,27 @@ Go there for more info!
====================================
README by Jeppa:
This version was fixed by Jeppa to have safe maps (block-protection)
and more than one spawnpoint (one spawnpoint per arena!)
This plugin has been heavily improved and fixed by Jeppa !
- autoupdating MaterialIDs to Materials
- improved chest-handling and added more chest-like storages (hopper, furnace, dispenser...)
- pay the player for finding undiscovered chests
- improved handling of placed/destroyed blocks
- added placeable redstone torch to enable redstone stuff at gamestart!
- multi arena support
- improved sign handling: 1 command per line (2nd/3rd) or one combined command in line 2/3 possible
- new command /ha newarena for easier arena creation
- default spawnpoint for lobby possible
- spawn fix
- autoset for player yaw on warp points
- random spawn/warp points
- configurable disabling of bed interaction
- scoreboard improved!
- storing/restoring players inventories
- support for 1.9 to 1.14
- safe maps (block-protection)
- spawnpoints per arena!
- sponsoring improved
- lots of bug fixes !!!
You may have to edit the config.yml!
The worlds order is the corresponding worlds-number !!!
First world ist world #1 etc...
The worlds/arenas numbers should start with #1 and count up...
There are default-values for arenas in the configfile
so you will see up to 20 arenas after first spawns set.
This is just done to avoid some bugs if arenas are not in a row starting by 1 :/
You may have arena numbers like 2,4,6 with this,
but still should count them like 1,2,3,4... !!!
With this in your mind: don't have arena-numbers bigger
than 20 until you realy have that amount!

View File

@ -1,68 +0,0 @@
# This file stores all of the spawns!
Spawn_coords: 100,100,100,world
# If /ha setspawn has been run
Spawns_set: 'false'
Spawns:
1:
1:
2:
2:
1:
2:
3:
1:
2:
4:
1:
2:
5:
1:
2:
6:
1:
2:
7:
1:
2:
8:
1:
2:
9:
1:
2:
10:
1:
2:
11:
1:
2:
12:
1:
2:
13:
1:
2:
14:
1:
2:
15:
1:
2:
16:
1:
2:
17:
1:
2:
17:
1:
2:
18:
1:
2:
19:
1:
2:
20:
1:
2:

View File

@ -2,19 +2,15 @@
#config version for us devs. DONT CHANGE THIS, or it will screw up some things PRETTY badly.
config:
version: 1.3
version: 1.4
######################################
######## Game Configuration #########
######################################
# The world(s) that all HA features are restricted to.
# If left blank all worlds will be allowed.
# ie:
# worlds:
# - world
# - world_nether
worlds: {}
# If all HA features are restricted to the HA-world(s) only .
# If set to 'false' all worlds will be allowed.
Restricted: true
# If left at 0 there will be no death match, fill in a time in minutes
DeathMatch: 0
@ -25,6 +21,9 @@ broadcastAll: true
# The max amount of players that can be in a game, This is also dependent on the amount of startpoints you have set.
maxPlayers: 24
# If the worlds spawn is not the same as your Arena spawn you can set this to true for players spawn at arena
joinTeleport: 'false'
# Message to display when the games start
Start_Message: '&bLet The Games Begin!'
@ -34,6 +33,9 @@ Auto_Restart: 'false'
# If it should automatically start the countdown on warping
Auto_Start: 'false'
# If it should automatically warp players if there are enough (else wait for the command 'warpall')
Auto_Warp: 'true'
# If tributes need to type /ha confirm to join
Need_Confirm: 'true'
@ -64,11 +66,14 @@ Explode_on_Move: 'false'
# Whether or not thunder will sound upon a players death
Cannon_Death: 'true'
# Whether players are allowed to use beds, or not!
DenyBedUsage: 'true'
# Whether or not to have the arena be the world or the WorldEdit selection
WorldEdit: false
# What item should be used to set spawns after /startpoint [arena#]
spawnsTool: 286
spawnsTool: GOLDEN_AXE
######################################
######################################
@ -80,24 +85,29 @@ spawnsTool: 286
# What the reward for winning is
Reward:
- 264,10
- DIAMOND,10
Sponsor_Cost:
- 264,1
- DIAMOND,1
EntryFee:
enabled: false
eco: false
cost: 50
fee:
- 265,1
- IRON_INGOT,1
# True means give money to winner, false means don't.
# How much money to give the winner.
rewardEco:
enabled: false
reward: 100
# What sponsors have to pay to sponsor tributes
sponsorEco:
enabled: false
cost: 50
# How much money to give the winner.
# What sponsors have to pay to sponsor tributes
# Pay the Players for finding chests etc.
ChestPay:
enabled: false
items:
- COOKED_BEEF,2
################################
################################
################################

View File

@ -1,18 +1,15 @@
package me.Travja.HungerArena;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Chest;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
public class Chests implements Listener {
@ -29,17 +26,14 @@ public class Chests implements Listener {
int blockx = blocklocation.getBlockX();
int blocky = blocklocation.getBlockY();
int blockz = blocklocation.getBlockZ();
if (plugin.getChests().getStringList("StorageXYZ").contains(blockx + "," + blocky + "," + blockz)) {
if (plugin.getChests().getConfigurationSection("Storage").getKeys(false).contains(blockx + "," + blocky + "," + blockz)) {
if(p.hasPermission("HungerArena.Chest.Break") && plugin.getArena(p)== null){
List<String> list2 = plugin.getChests().getStringList("StorageXYZ");
list2.remove(blockx + "," + blocky + "," + blockz);
plugin.getChests().set("Storage." + blockx + "," + blocky+ "," + blockz, null);
plugin.getChests().set("StorageXYZ", list2);
plugin.saveChests();
p.sendMessage("[HungerArena] Chest Removed!");
} else {
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "[HungerArena] That's a storage chest! You don't have permission to break it!");
p.sendMessage(ChatColor.RED + "[HungerArena] That's a storage! You don't have permission to break it!");
}
}
}
@ -51,10 +45,10 @@ public class Chests implements Listener {
if(plugin.getArena(p)!= null){
int a = plugin.getArena(p);
if(plugin.Playing.get(a).contains(p.getName()) && plugin.canjoin.get(a)){
if(!plugin.restricted || (plugin.restricted && plugin.worlds.contains(p.getWorld().getName()))){
if(!plugin.restricted || (plugin.restricted && plugin.worldsNames.values().contains(p.getWorld().getName()))){
if(block!= null){
if(block.getType()== Material.CHEST){
ItemStack[] itemsinchest = ((Chest) block.getState()).getInventory().getContents().clone();
if(block.getState() instanceof InventoryHolder){
ItemStack[] itemsinchest = ((InventoryHolder) block.getState()).getInventory().getContents().clone();
int blockx = block.getX();
int blocky = block.getY();
int blockz = block.getZ();
@ -67,13 +61,12 @@ public class Chests implements Listener {
plugin.getChests().set("Storage." + blockx + "," + blocky + "," + blockz + ".ItemsInStorage", itemsinchest);
plugin.getChests().set("Storage." + blockx + "," + blocky + "," + blockz + ".Arena", a);
plugin.saveChests();
}
List<String> list2 = plugin.getChests().getStringList("StorageXYZ");
if(!list2.contains(blockx + "," + blocky + "," + blockz)){
list2.add(blockx + "," + blocky + "," + blockz);
plugin.getChests().set("StorageXYZ", list2);
plugin.saveChests();
p.sendMessage(ChatColor.GREEN + "Thank you for finding this undiscovered chest, it has been stored!!");
p.sendMessage(ChatColor.GREEN + "Thank you for finding this undiscovered item Storage, it has been stored!!");
if (plugin.config.getBoolean("ChestPay.enabled")){
for(ItemStack Rewards: plugin.ChestPay){
p.getInventory().addItem(Rewards);
}
}
}
plugin.reloadChests();
}

View File

@ -13,143 +13,38 @@ public class CommandBlock implements Listener {
public CommandBlock(Main m) {
this.plugin = m;
}
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.MONITOR)
public void CatchCommand(PlayerCommandPreprocessEvent event){
String cmd = event.getMessage();
Player p = event.getPlayer();
String pname = p.getName();
int i = 0;
int x = 0;
boolean found = false;
for(x = 1; x < plugin.Watching.size(); x++){
for(int x : plugin.Watching.keySet()){
if(plugin.Watching.get(x).contains(p.getName())){
if(!p.hasPermission("HungerArena.UseCommands")){
if(!plugin.management.getStringList("commands.whitelist").isEmpty()){
for(String whitelist: plugin.management.getStringList("commands.whitelist")){
if(cmd.toLowerCase().startsWith(whitelist.toLowerCase())){ // Jeppa: check for ALL whitelist commands
found = true;
i = plugin.management.getStringList("commands.whitelist").size()-1;
}
i = i+1;
if(i== plugin.management.getStringList("commands.whitelist").size()){
if(!found && !cmd.toLowerCase().startsWith("/ha")){ //Jeppa: must be && ;)
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are only allowed to perform the following commands:");
for(String whitelistfull: plugin.management.getStringList("commands.whitelist")){
p.sendMessage(ChatColor.AQUA + whitelistfull);
}
p.sendMessage(ChatColor.AQUA + "/ha");
p.sendMessage(ChatColor.AQUA + "/ha close");
p.sendMessage(ChatColor.AQUA + "/ha help");
p.sendMessage(ChatColor.AQUA + "/ha join");
p.sendMessage(ChatColor.AQUA + "/ha kick [Player]");
p.sendMessage(ChatColor.AQUA + "/ha leave");
p.sendMessage(ChatColor.AQUA + "/ha list");
p.sendMessage(ChatColor.AQUA + "/ha open");
p.sendMessage(ChatColor.AQUA + "/ha ready");
p.sendMessage(ChatColor.AQUA + "/ha refill");
p.sendMessage(ChatColor.AQUA + "/ha reload");
p.sendMessage(ChatColor.AQUA + "/ha restart");
p.sendMessage(ChatColor.AQUA + "/ha rlist");
p.sendMessage(ChatColor.AQUA + "/ha setspawn");
p.sendMessage(ChatColor.AQUA + "/ha start");
p.sendMessage(ChatColor.AQUA + "/ha tp");
p.sendMessage(ChatColor.AQUA + "/ha watch");
p.sendMessage(ChatColor.AQUA + "/ha warpall");
}
}
}
}else if(!cmd.toLowerCase().startsWith("/ha")){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are only allowed to perform /ha commands!");
}
}else if(!cmd.toLowerCase().startsWith("/ha")){
if(cmd.toLowerCase().startsWith("/spawn")){
event.setCancelled(true);
p.sendMessage("You have perms for all commands except this one!");
}
}
if (handleIngameCommands(p, cmd)==true) event.setCancelled(true);
}
}
if(plugin.getArena(p)!= null){
if(!p.hasPermission("HungerArena.UseCommands")){
if(!plugin.management.getStringList("commands.whitelist").isEmpty()){
for(String whitelist: plugin.management.getStringList("commands.whitelist")){
if(cmd.toLowerCase().startsWith(whitelist.toLowerCase())){
found = true;
i = plugin.management.getStringList("commands.whitelist").size()-1;
}
i = i+1;
if(i== plugin.management.getStringList("commands.whitelist").size()){ // Abbruch bei max. Anzahl
if(!found && !cmd.toLowerCase().startsWith("/ha")){ // with the two invertet forms it must be && ;)
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are only allowed to perform the following commands:");
for(String whitelistfull: plugin.management.getStringList("commands.whitelist")){
p.sendMessage(ChatColor.AQUA + whitelistfull);
}
p.sendMessage(ChatColor.AQUA + "/ha");
p.sendMessage(ChatColor.AQUA + "/ha close");
p.sendMessage(ChatColor.AQUA + "/ha help");
p.sendMessage(ChatColor.AQUA + "/ha join");
p.sendMessage(ChatColor.AQUA + "/ha kick [Player]");
p.sendMessage(ChatColor.AQUA + "/ha leave");
p.sendMessage(ChatColor.AQUA + "/ha list");
p.sendMessage(ChatColor.AQUA + "/ha open");
p.sendMessage(ChatColor.AQUA + "/ha ready");
p.sendMessage(ChatColor.AQUA + "/ha refill");
p.sendMessage(ChatColor.AQUA + "/ha reload");
p.sendMessage(ChatColor.AQUA + "/ha restart");
p.sendMessage(ChatColor.AQUA + "/ha rlist");
p.sendMessage(ChatColor.AQUA + "/ha setspawn");
p.sendMessage(ChatColor.AQUA + "/ha start");
p.sendMessage(ChatColor.AQUA + "/ha tp");
p.sendMessage(ChatColor.AQUA + "/ha watch");
p.sendMessage(ChatColor.AQUA + "/ha warpall");
}
}
}
}else if(!cmd.toLowerCase().startsWith("/ha")){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are only allowed to perform /ha commands!");
}
}else if(!cmd.toLowerCase().startsWith("/ha")){
if(cmd.toLowerCase().startsWith("/spawn")){
event.setCancelled(true);
p.sendMessage("You have perms for all commands except this one!");
}
}
//commands while not playing...
}else if(cmd.toLowerCase().equals("/back")){
for(i = 1; i < plugin.Dead.size(); i++){
if(plugin.Dead.get(i).contains(pname) && plugin.canjoin.get(i))
if (handleIngameCommands(p, cmd)==true) event.setCancelled(true);
}else if(cmd.toLowerCase().trim().equals("/back")){
for(int u : plugin.Dead.keySet()){
if(plugin.Dead.get(u).contains(pname) && plugin.canjoin.get(u))
plugin.Tele.add(p);
}
}else if(cmd.startsWith("/tp") || cmd.startsWith("/tpa") || cmd.startsWith("/tpo")){
String[] args = cmd.split(" ");
Player arg1 = null;
Player arg2 = null;
if(args.length == 2){
if(Bukkit.getPlayer(args[0]) != null && Bukkit.getPlayer(args[1]) != null){
arg1 = Bukkit.getPlayer(args[0]);
arg2 = Bukkit.getPlayer(args[1]);
}
if(cmd.startsWith("/tp") || cmd.startsWith("/telep") || cmd.contains(":tp") || cmd.contains(":telep")){
String[] args = cmd.split(" ");
Player player1 = null;
Player player2 = null;
if(args.length >= 2){
if(Bukkit.getPlayer(args[1]) != null){
player1 = Bukkit.getPlayer(args[1]);
if (args.length >= 3 && Bukkit.getPlayer(args[2]) != null) player2 = Bukkit.getPlayer(args[2]);
if(plugin.isSpectating(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "Invalid command for spectating, using /ha tp " + arg2);
p.performCommand("/ha tp " + arg2);
}else if(plugin.getArena(arg1)!= null || plugin.getArena(arg2)!= null){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You can't teleport to other tributes!");
}
}
}else if(args.length == 1){
if(Bukkit.getPlayer(args[0]) != null){
arg1 = Bukkit.getPlayer(args[0]);
if(plugin.isSpectating(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "Invalid command for spectating, using /ha tp " + arg1);
p.performCommand("/ha tp " + arg1);
}else if(plugin.getArena(arg1)!= null || plugin.getArena(p)!= null){
p.sendMessage(ChatColor.RED + "Invalid command for spectating, using /ha tp " + (player2!=null?player2:player1));
p.performCommand("/ha tp " + (player2!=null?player2:player1));
}else if(plugin.getArena(player1)!=null || (args.length == 2 && plugin.getArena(p)!=null) || (args.length >= 3 && plugin.getArena(player2)!= null)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You can't teleport to other tributes!");
}
@ -157,4 +52,47 @@ public class CommandBlock implements Listener {
}
}
}
private boolean handleIngameCommands(Player p, String cmd){
if(!p.hasPermission("HungerArena.UseCommands")){
if(!plugin.management.getStringList("commands.whitelist").isEmpty()){
for(String whitelist: plugin.management.getStringList("commands.whitelist")){
if(cmd.toLowerCase().startsWith(whitelist.toLowerCase())){
return false;
}
}
}
if(!cmd.toLowerCase().startsWith("/ha")){
p.sendMessage(ChatColor.RED + "You are only allowed to perform the following commands:");
for(String whitelistfull: plugin.management.getStringList("commands.whitelist")){
p.sendMessage(ChatColor.AQUA + whitelistfull);
}
p.sendMessage(ChatColor.AQUA + "/ha");
p.sendMessage(ChatColor.AQUA + "/ha close");
p.sendMessage(ChatColor.AQUA + "/ha help");
p.sendMessage(ChatColor.AQUA + "/ha join");
p.sendMessage(ChatColor.AQUA + "/ha kick [Player]");
p.sendMessage(ChatColor.AQUA + "/ha leave");
p.sendMessage(ChatColor.AQUA + "/ha list");
p.sendMessage(ChatColor.AQUA + "/ha open");
p.sendMessage(ChatColor.AQUA + "/ha ready");
p.sendMessage(ChatColor.AQUA + "/ha refill");
p.sendMessage(ChatColor.AQUA + "/ha reload");
p.sendMessage(ChatColor.AQUA + "/ha restart");
p.sendMessage(ChatColor.AQUA + "/ha rlist");
//p.sendMessage(ChatColor.AQUA + "/ha newarena"); //not during game...
p.sendMessage(ChatColor.AQUA + "/ha setspawn");
p.sendMessage(ChatColor.AQUA + "/ha start");
p.sendMessage(ChatColor.AQUA + "/ha tp");
p.sendMessage(ChatColor.AQUA + "/ha watch");
p.sendMessage(ChatColor.AQUA + "/ha warpall");
return true;
}
}else if(!cmd.toLowerCase().startsWith("/ha")){
if(cmd.toLowerCase().startsWith("/spawn") || cmd.toLowerCase().startsWith("/back")){
p.sendMessage("You have perms for all commands except this one!");
return true;
}
}
return false;
}
}

View File

@ -1,92 +0,0 @@
package me.Travja.HungerArena;
public class ConfigManager {
public static Main plugin;
public ConfigManager(Main m){
ConfigManager.plugin = m;
}
public void setup(){
System.out.println("Setting up!");
if(!plugin.config.contains("worlds"))
plugin.config.addDefault("worlds", "{}");
if(!plugin.config.contains("DeathMatch"))
plugin.config.addDefault("DeathMatch", "0");
if(!plugin.config.contains("broadcastAll"))
plugin.config.addDefault("broadcastAll", true);
if(!plugin.config.contains("maxPlayers"))
plugin.config.addDefault("maxPlayers", "24");
if(!plugin.config.contains("Start_Message"))
plugin.config.addDefault("Start_Message", "&bLet The Games Begin!");
if(!plugin.config.contains("Auto_Restart"))
plugin.config.addDefault("Auto_Restart", false);
if(!plugin.config.contains("Auto_Start"))
plugin.config.addDefault("Auto_Start", false);
if(!plugin.config.contains("Need_Confirm"))
plugin.config.addDefault("Need_Confirm", true);
if(!plugin.config.contains("Countdown"))
plugin.config.addDefault("Countdown", true);
if(!plugin.config.contains("Countdown_Timer"))
plugin.config.addDefault("Countdown_Timer", "15");
if(!plugin.config.contains("Grace_Period"))
plugin.config.addDefault("Grace_Period", "60");
if(!plugin.config.contains("Protected_Arena"))
plugin.config.addDefault("Protected_Arena", true);
if(!plugin.config.contains("Protected_Arena_Always"))
plugin.config.addDefault("Protected_Arena_Always", true);
if(!plugin.config.contains("Force_Players_toSpawn"))
plugin.config.addDefault("Force_Players_toSpawn", true);
if(!plugin.config.contains("Frozen_Teleport"))
plugin.config.addDefault("Frozen_Teleport", true);
if(!plugin.config.contains("Explode_on_Move"))
plugin.config.addDefault("Explode_on_Move", false);
if(!plugin.config.contains("Cannon_Death"))
plugin.config.addDefault("Cannon_Death", true);
if(!plugin.config.contains("Reward"))
plugin.config.addDefault("Reward", "- 264,10");
if(!plugin.config.contains("Sponsor_Cost"))
plugin.config.addDefault("Sponsor_Cost", "- 264,1");
if(!plugin.config.contains("EntryFee")){
plugin.config.addDefault("EntryFee.enabled", false);
plugin.config.addDefault("EntryFee.eco", false);
plugin.config.addDefault("EntryFee.cost", "50");
plugin.config.addDefault("EntryFee.fee", "- 265,1");
}else{
if(!plugin.config.contains("EntryFee.enabled"))
plugin.config.addDefault("EntryFee.enabled", false);
if(!plugin.config.contains("EntryFee.eco"))
plugin.config.addDefault("EntryFee.eco", false);
if(!plugin.config.contains("EntryFee.cost"))
plugin.config.addDefault("EntryFee.cost", "50");
if(!plugin.config.contains("EntryFee.fee"))
plugin.config.addDefault("EntryFee.fee", "- 265,1");
}
if(!plugin.config.contains("rewardEco")){
plugin.config.addDefault("rewardEco.enabled", false);
plugin.config.addDefault("rewardEco.reward", "100");
}else{
if(!plugin.config.contains("rewardEco.enabled"))
plugin.config.addDefault("rewardEco.enabled", false);
if(!plugin.config.contains("rewardEco.reward"))
plugin.config.addDefault("rewardEco.reward", "100");
}
if(!plugin.config.contains("sponsorEco")){
plugin.config.addDefault("sponsorEco.enabled", false);
plugin.config.addDefault("sponsorEco.cost", "50");
}else{
if(!plugin.config.contains("sponsorEco.enabled"))
plugin.config.addDefault("sponsorEco.enabled", false);
if(!plugin.config.contains("sponsorEco.cost"))
plugin.config.addDefault("sponsorEco.cost", "50");
}
if(!plugin.config.contains("ChatClose"))
plugin.config.addDefault("ChatClose", true);
if(!plugin.config.contains("ChatClose_Radius"))
plugin.config.addDefault("ChatClose_Radius", "10");
if(!plugin.config.contains("WorldEdit"))
plugin.config.addDefault("WorldEdit", false);
if(!plugin.config.contains("spawnsTool"))
plugin.config.addDefault("spawnsTool", "286");
plugin.saveConfig();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,7 @@ import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@ -21,100 +22,73 @@ import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerBucketFillEvent;
import org.bukkit.material.MaterialData;
public class BlockStorage implements Listener {
public Main plugin;
public BlockStorage(Main m) {
this.plugin = m;
}
@SuppressWarnings("deprecation")
@EventHandler(priority=EventPriority.MONITOR)
public void BlockBreak(BlockBreakEvent event) {
Block b = event.getBlock();
Player p = event.getPlayer();
String pname = p.getName();
boolean protall = false;
if (plugin.config.getString("Protected_Arena_Always").equalsIgnoreCase("True")) { /* Jeppa Fix/Add */
if(!p.hasPermission("HungerArena.arena")){ // Admins frei...
protall = true;
if(!p.hasPermission("HungerArena.arena")){
protall = protall(); //true = protect allways!!
}
}
if ((plugin.getArena(p) != null) || (protall)) { /* Bug1a */
//int a = this.plugin.getArena(p).intValue();
if ((plugin.getArena(p) != null) || (protall)) {
//Jeppa: get a default arena if protall is true... (but use getArena if set...)
int a = 1;
if (protall) {
String ThisWorld = p.getWorld().getName();
int z=0;
for(z = 1; z <= plugin.worldsNames.size(); z++){
for(int z : plugin.worldsNames.keySet()){
if(plugin.worldsNames.get(z)!= null){
if (plugin.worldsNames.get(z).equals(ThisWorld)){
a=z; // now 'a' is the arenanumber of THIS(current) map -->may still be wrong if there are more than one arena on this map...
a=z;
}
}
}
}
if (plugin.getArena(p) != null) a = plugin.getArena(p);
if ((!event.isCancelled()) && (((plugin.Playing.get(a)).contains(pname)) || (protall))) /* Bug1a */
if ((!event.isCancelled()) && (((plugin.Playing.get(a)).contains(pname)) || (protall)))
{
if (plugin.config.getString("Protected_Arena").equalsIgnoreCase("True")) {
event.setCancelled(true); /* Jeppa fix Bug1 */
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You can't break blocks while playing!");
} else if ((((plugin.canjoin.get(a))) || (protall)) && ((plugin.config.getStringList("worlds").isEmpty()) || ((!plugin.config.getStringList("worlds").isEmpty()) && (plugin.config.getStringList("worlds").contains(p.getWorld().getName()))))) {
if (((plugin.management.getIntegerList("blocks.whitelist").isEmpty()) || ((!plugin.management.getIntegerList("blocks.whitelist").isEmpty()) && (!plugin.management.getIntegerList("blocks.whitelist").contains(Integer.valueOf(b.getTypeId()))))) ^ (plugin.management.getBoolean("blocks.useWhitelistAsBlacklist"))) {
} else if ( (plugin.canjoin.get(a) || protall) && ((!plugin.restricted) || ((plugin.restricted) && (plugin.worldsNames.values().contains(p.getWorld().getName()))))) {
if (((plugin.management.getStringList("blocks.whitelist").isEmpty()) || ((!plugin.management.getStringList("blocks.whitelist").isEmpty()) && (!plugin.management.getStringList("blocks.whitelist").contains(String.valueOf(b.getType().name()))))) ^ (plugin.management.getBoolean("blocks.useWhitelistAsBlacklist"))) {
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "That is an illegal block!");
} else {
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
byte m = b.getData();
String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + a;
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
if (!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + a)) {
blocks.add(coords);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveData();
}
addDestroyedBlockToList(b, w, a);
}
}
}
}
}
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.MONITOR)
public void Explosion(EntityExplodeEvent event){
@EventHandler(priority = EventPriority.LOWEST)
public void Explosion(EntityExplodeEvent event){
List<Block> blocksd = event.blockList();
Entity e = event.getEntity();
int i = 0;
if(!event.isCancelled()){
for(i = 1; i <= plugin.canjoin.size(); i++){
if(plugin.canjoin.get(i)){
i = plugin.canjoin.size()+1;
if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(event.getEntity().getWorld().getName()))){
if(e.getType()== EntityType.PRIMED_TNT){
if(!plugin.data.getStringList("Blocks_Placed").contains(e.getLocation().getWorld() + "," + e.getLocation().getX() + "," + e.getLocation().getY() + "," + e.getLocation().getZ()) /*|| !plugin.data.getStringList("Blocks_Destroyed").contains(e.getLocation().getWorld() + "," + e.getLocation().getX() + "," + e.getLocation().getY() + "," + e.getLocation().getZ())*/){
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
blocks.add(e.getLocation().getWorld().getName() + "," + e.getLocation().getX() + "," + e.getLocation().getY() + "," + e.getLocation().getZ() + ",46" + ",0");
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveData();
}
for(int i : plugin.canjoin.keySet()){
if(plugin.canjoin.get(i) || protall()){
String ThisWorld = e.getWorld().getName();
if ((!plugin.restricted) || ((plugin.restricted) && plugin.worldsNames.get(i)!=null && plugin.worldsNames.get(i).equalsIgnoreCase(ThisWorld))) {
if(e.getType()== EntityType.PRIMED_TNT){
e.getLocation().getBlock().setType(Material.TNT);
Block TNT = e.getLocation().getBlock();
addDestroyedBlockToList(TNT, ThisWorld, i);
TNT.setType(Material.AIR);
}
for(Block b:blocksd){
String w = event.getEntity().getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
byte m = b.getData();
String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + i;
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + i) || !plugin.data.getStringList("Blocks_Destroyed").contains(w + "," + x + "," + y + "," + z + "," + i)){
blocks.add(coords);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveData();
if (!b.getType().name().equalsIgnoreCase("AIR")){
addDestroyedBlockToList(b, ThisWorld, i);
}
}
}
@ -122,29 +96,16 @@ public class BlockStorage implements Listener {
}
}
}
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.MONITOR)
public void burningBlocks(BlockBurnEvent event){
@EventHandler(priority = EventPriority.LOWEST)
public void burningBlocks(BlockBurnEvent event){
Block b = event.getBlock();
int i = 0;
if(!event.isCancelled()){
for(i = 1; i <= plugin.canjoin.size(); i++){
if(plugin.canjoin.get(i)){
i = plugin.canjoin.size()+1;
if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(b.getWorld().getName()))){
for(int i : plugin.canjoin.keySet()){
if(plugin.canjoin.get(i) || protall()){
if ((!plugin.restricted) || ((plugin.restricted) && (plugin.worldsNames.get(i)!=null && plugin.worldsNames.get(i).equalsIgnoreCase(b.getWorld().getName())))) {
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
byte m = b.getData();
String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + i;
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + i)){
blocks.add(coords);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveData();
}
addDestroyedBlockToList(b, w, i);
}
}
}
@ -155,21 +116,17 @@ public class BlockStorage implements Listener {
Block b = event.getBlock();
Player p = event.getPlayer();
boolean protall = false;
if (plugin.config.getString("Protected_Arena_Always").equalsIgnoreCase("True")) { /* Jeppa Fix/Add */
if(!p.hasPermission("HungerArena.arena")){ // Admins or with permission : free...
protall = true;
if(!p.hasPermission("HungerArena.arena")){
protall = protall();
}
}
if ((plugin.getArena(p) != null) || (protall)) { /* Bug1a */
//Jeppa: get a default arena if protall is true... (but use getArena if set...)
if ((plugin.getArena(p) != null) || (protall)) {
int a = 1;
if (protall) {
String ThisWorld = p.getWorld().getName();
int z=0;
for(z = 1; z <= plugin.worldsNames.size(); z++){
for(int z : plugin.worldsNames.keySet()){
if(plugin.worldsNames.get(z)!= null){
if (plugin.worldsNames.get(z).equals(ThisWorld)){
a=z; // now 'a' is the arenanumber of THIS(current) map -->may still be wrong if there are more than one arena on this map...
a=z;
}
}
}
@ -178,7 +135,7 @@ public class BlockStorage implements Listener {
if(!event.isCancelled()){
if (((plugin.Playing.get(a)).contains(p.getName())) || (protall)) {
if((plugin.canjoin.get(a)) || (protall)){
if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(b.getWorld().getName()))){
if ( (!plugin.restricted) || ((plugin.restricted) && (plugin.worldsNames.values().contains(b.getWorld().getName())))) {
if((b.getType()== Material.SAND || b.getType()== Material.GRAVEL) && (b.getRelative(BlockFace.DOWN).getType()== Material.AIR || b.getRelative(BlockFace.DOWN).getType()== Material.WATER || b.getRelative(BlockFace.DOWN).getType()== Material.LAVA)){
int n = b.getY() -1;
while(b.getWorld().getBlockAt(b.getX(), n, b.getZ()).getType()== Material.AIR || b.getWorld().getBlockAt(b.getX(), n, b.getZ()).getType()== Material.WATER || b.getWorld().getBlockAt(b.getX(), n, b.getZ()).getType()== Material.LAVA){
@ -188,27 +145,15 @@ public class BlockStorage implements Listener {
int l = n +1;
Block br = b.getWorld().getBlockAt(b.getX(), l, b.getZ());
String w = br.getWorld().getName();
int x = br.getX();
int y = br.getY();
int z = br.getZ();
String coords = w + "," + x + "," + y + "," + z + "," + a;
List<String> blocks = plugin.data.getStringList("Blocks_Placed");
blocks.add(coords);
plugin.data.set("Blocks_Placed", blocks);
plugin.saveData();
addPlacedBlockToList(br, w, a);
}
}
}else{
if(b.getType()!= Material.SAND || b.getType()!= Material.GRAVEL){
if(b.getType()!= Material.SAND && b.getType()!= Material.GRAVEL){
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
String coords = w + "," + x + "," + y + "," + z + "," + a;
List<String> blocks = plugin.data.getStringList("Blocks_Placed");
blocks.add(coords);
plugin.data.set("Blocks_Placed", blocks);
plugin.saveData();
addPlacedBlockToList(b, w, a);
}
}
}
@ -224,24 +169,17 @@ public class BlockStorage implements Listener {
if(!event.isCancelled()){
if(plugin.canjoin.get(a)){
if(plugin.Playing.get(a).contains(event.getPlayer().getName())){
if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(event.getPlayer().getWorld().getName()))){
if ( (!plugin.restricted) || ((plugin.restricted) && (plugin.worldsNames.values().contains(event.getPlayer().getWorld().getName())))) {
Block b = event.getBlockClicked().getRelative(event.getBlockFace());
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
String coords = w + "," + x + "," + y + "," + z + "," + a;
List<String> blocks = plugin.data.getStringList("Blocks_Placed");
blocks.add(coords);
plugin.data.set("Blocks_Placed", blocks);
plugin.saveData();
addPlacedBlockToList(b, w, a);
}
}
}
}
}
}
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.MONITOR)
public void bucketFill(PlayerBucketFillEvent event){
if(plugin.getArena(event.getPlayer())!= null){
@ -249,154 +187,88 @@ public class BlockStorage implements Listener {
if(!event.isCancelled()){
if(plugin.canjoin.get(a)){
if(plugin.Playing.get(a).contains(event.getPlayer().getName())){
if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(event.getPlayer().getWorld().getName()))){
if ( (!plugin.restricted) || ((plugin.restricted) && (plugin.worldsNames.values().contains(event.getPlayer().getWorld().getName())))) {
Block b = event.getBlockClicked().getRelative(event.getBlockFace());
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
byte m = b.getData();
String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + a;
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + a)){
blocks.add(coords);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveData();
}
addDestroyedBlockToList(b, w, a);
}
}
}
}
}
}
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.MONITOR)
@EventHandler(priority = EventPriority.MONITOR)
public void blockMelt(BlockFadeEvent event){
int i = 0;
if(!event.isCancelled()){
for(i = 1; i <= plugin.canjoin.size(); i++){
if(plugin.canjoin.get(i)){
if(plugin.config.getStringList("worlds").isEmpty() || (!plugin.config.getStringList("worlds").isEmpty() && plugin.config.getStringList("worlds").contains(event.getBlock().getWorld().getName()))){
i = plugin.canjoin.size()+1;
for(int i:plugin.canjoin.keySet()){
if(plugin.canjoin.get(i) || protall()){
if ( (!plugin.restricted) || ((plugin.restricted) && (plugin.worldsNames.get(i)!=null && plugin.worldsNames.get(i).equalsIgnoreCase(event.getBlock().getWorld().getName())))) {
Block b = event.getBlock();
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
byte m = b.getData();
String coords = w + "," + x + "," + y + "," + z + "," + d + "," + m + "," + i;
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
if(!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + i)){
blocks.add(coords);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveData();
}
String d = b.getType().name();
if (d.equalsIgnoreCase("FIRE") || d.equalsIgnoreCase("AIR")) continue;
addDestroyedBlockToList(b, w, i);
}
}
}
}
}
/*@EventHandler
public void blockGrow(BlockGrowEvent event){
if(plugin.canjoin== true){
Block b = event.getBlock();
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Grow: " + coords);
List<String> blocks = plugin.data.getStringList("Blocks_Placed");
//SubRoutines:
private boolean protall(){
if (plugin.config.getString("Protected_Arena_Always").equalsIgnoreCase("True")) {
return true;
}
return false;
}
private void addDestroyedBlockToList(Block b, String w, int a){
int x = b.getX();
int y = b.getY();
int z = b.getZ();
String d = b.getType().name();
byte m=0;
String BlDataString=null;
String sp = ";";
String dir="";
try {
if (b.getState().getBlockData() instanceof BlockData){
BlDataString = b.getBlockData().getAsString();
}
} catch (Exception | NoSuchMethodError ex){
m = b.getData();
sp=",";
MaterialData mData = b.getState().getData();
if (mData instanceof org.bukkit.material.Directional) {
BlockFace Dir = ((org.bukkit.material.Directional)mData).getFacing();
if (Dir !=null) {
dir=sp+(Dir.name());
}
}
}
String data = BlDataString!=null?BlDataString:String.valueOf(m);
String coords = w + sp + x + sp + y + sp + z + sp + d + sp + data + sp + a + dir;
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
if (!plugin.data.getStringList("Blocks_Placed").contains(w + "," + x + "," + y + "," + z + "," + a)) {
blocks.add(coords);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveConfig();
plugin.saveData();
}
}
@EventHandler
public void blockForm(BlockFormEvent event){
if(plugin.canjoin== true){
Block b = event.getBlock();
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Snowfall: " + coords);
List<String> blocks = plugin.data.getStringList("Blocks_Placed");
private void addPlacedBlockToList(Block br, String w, int a){
int x = br.getX();
int y = br.getY();
int z = br.getZ();
String coords = w + "," + x + "," + y + "," + z + "," + a;
List<String> blocks = plugin.data.getStringList("Blocks_Placed");
if (!blocks.contains(coords)){
blocks.add(coords);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveConfig();
plugin.data.set("Blocks_Placed", blocks);
plugin.saveData();
}
}
@EventHandler
public void pistonPush(BlockPistonExtendEvent event){
if(plugin.canjoin== true){
for(Block b:event.getBlocks()){
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Piston: " + coords);
List<String> blocks = plugin.data.getStringList("Blocks_Destroyed");
blocks.add(coords);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveConfig();
}
}
}
@EventHandler
public void onChange(BlockPhysicsEvent event){
Block block = event.getBlock();
Material changed = event.getChangedType();
if (block.getType() == Material.LAVA){
if (changed == Material.LAVA){
Block b = event.getBlock();
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Lava Change: " + coords);
List<String> blocks = plugin.data.getStringList("Blocks_Placed");
blocks.add(coords);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveConfig();
}else if(changed == Material.WATER){
Block b = event.getBlock();
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Water Change: " + coords);
List<String> blocks = plugin.data.getStringList("Blocks_Placed");
blocks.add(coords);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveConfig();
}
}else if (block.getType() == Material.SAND || block.getType() == Material.GRAVEL) {
if (changed == Material.AIR) {
Block b = event.getBlock();
String w = b.getWorld().getName();
int x = b.getX();
int y = b.getY();
int z = b.getZ();
int d = b.getTypeId();
String coords = w + "," + x + "," + y + "," + z + "," + d;
System.out.println("Sand/Gravel Fall: " + coords);
List<String> blocks = plugin.data.getStringList("Blocks_Placed");
blocks.add(coords);
plugin.data.set("Blocks_Destroyed", blocks);
plugin.saveConfig();
}
}
}*/
}

View File

@ -1,23 +1,18 @@
package me.Travja.HungerArena.Listeners;
//import java.util.ArrayList;
import me.Travja.HungerArena.Main;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
//import org.bukkit.entity.Entity;
//import org.bukkit.entity.Damageable;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
//import org.bukkit.event.entity.EntityDamageByEntityEvent;
//import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.scoreboard.DisplaySlot;
@ -35,26 +30,24 @@ public class DeathListener implements Listener{
final Player p = event.getPlayer();
String pname = p.getName();
//Jeppa: get the arena the player has died in... (may be not the one he joined...)
//get the arena the player has died in... (may be not the one he joined...)
String ThisWorld = p.getWorld().getName();
int z=0;
for(z = 1; z <= plugin.worldsNames.size(); z++){
for(int z : plugin.worldsNames.keySet()){
if(plugin.worldsNames.get(z)!= null){
if (plugin.worldsNames.get(z).equals(ThisWorld)){
a=z; // now 'a' is the arenanumber of THIS(current) map
a=z;
}
}
}
//Jeppa: Fix for lonely players :)
for(i = 1; i < plugin.Dead.size(); i++){ // find the dead player and the arena he has joined(if any)
if ((plugin.Dead.get(i) != null) && (plugin.Dead.get(i).contains(pname)) && (plugin.MatchRunning.get(i) == null)) { // Jeppa: the match has not started yet ! if someone joined a game and suicided before any game started ;) -> reset the dead-list
for(int i : plugin.Dead.keySet()){
if ((plugin.Dead.get(i) != null) && (plugin.Dead.get(i).contains(pname)) && (plugin.MatchRunning.get(i) == null)) {
plugin.Dead.get(i).clear();
}
}
//Jeppa: respawn per needInv!
for(i = 0; i < plugin.needInv.size(); i++){
for(int i = 0; i < plugin.needInv.size(); i++){
if(plugin.needInv.contains(pname)){
RespawnDeadPlayer(p,a);
}
@ -62,7 +55,7 @@ public class DeathListener implements Listener{
}
private void RespawnDeadPlayer(Player p, int a){
final Player player = p;
String[] Spawncoords = plugin.spawns.getString("Spawn_coords_"+a).split(","); //Jeppa: spawn to correct respawn! Dies ist der Respawn nach "Natural causes"... -> erst HIER Inv wiedergeben...???
String[] Spawncoords = plugin.spawns.getString("Spawn_coords."+a).split(",");
World spawnw = plugin.getServer().getWorld(Spawncoords[3]);
double spawnx = Double.parseDouble(Spawncoords[0]);
double spawny = Double.parseDouble(Spawncoords[1]);
@ -71,88 +64,12 @@ public class DeathListener implements Listener{
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
player.teleport(Spawn);
//Jeppa: restore inv
plugin.RestoreInv(player, player.getName()); // Jeppa: call for restore inventory of leaving player!!
plugin.RestoreInv(player, player.getName());
}
}, 10L);
}
/* //Jeppa: theese routines are not used anymore... (obsolete!!!?!)
@EventHandler (priority = EventPriority.HIGHEST)
public void damage(EntityDamageEvent event){
Entity e = event.getEntity();
if(e instanceof Player){
Player p = (Player) e;
if(plugin.getArena(p)!= null){
a = plugin.getArena(p);
if(plugin.Playing.get(a).size()== 2){
if(event.getDamage()>= ((Damageable)p).getHealth()){
event.setCancelled(true);
String[] Spawncoords = plugin.spawns.getString("Spawn_coords_"+a).split(",");
World spawnw = plugin.getServer().getWorld(Spawncoords[3]);
double spawnx = Double.parseDouble(Spawncoords[0]);
double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]);
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
p.setHealth((double) 20);
p.setFoodLevel(20);
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
plugin.scoreboards.remove(p.getName());
plugin.Kills.remove(p.getName());
clearInv(p);
p.teleport(Spawn);
plugin.Frozen.get(a).remove(p.getName());
plugin.Playing.get(a).remove(p.getName());
plugin.winner(a);
}
}
}
}
}
@EventHandler (priority = EventPriority.HIGHEST)
public void damage(EntityDamageByEntityEvent event){
Entity e = event.getEntity();
Entity d = event.getEntity();
if(e instanceof Player){
Player p = (Player) e;
if(plugin.getArena(p)!= null){
a = plugin.getArena(p);
if(plugin.Playing.get(a).size()== 2){
if(event.getDamage()>= ((Damageable)p).getHealth()){
event.setCancelled(true);
String[] Spawncoords = plugin.spawns.getString("Spawn_coords_"+a).split(",");
World spawnw = plugin.getServer().getWorld(Spawncoords[3]);
double spawnx = Double.parseDouble(Spawncoords[0]);
double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]);
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
plugin.scoreboards.remove(p.getName());
plugin.Kills.remove(p.getName());
clearInv(p);
p.setHealth((double) 20);
p.setFoodLevel(20);
p.teleport(Spawn);
if(d instanceof Player){
Player k = (Player) d;
if(plugin.getArena(k)!= null){
if(plugin.Kills.containsKey(k.getName()))
plugin.Kills.put(k.getName(), plugin.Kills.get(k.getName())+1);
}
}
plugin.Frozen.get(a).remove(p.getName());
plugin.Playing.get(a).remove(p.getName());
plugin.winner(a);
}
}
}
}
}
*/
@SuppressWarnings("deprecation")
@EventHandler (priority = EventPriority.HIGHEST)
@EventHandler (priority = EventPriority.HIGHEST)
public void onPlayerDeath(PlayerDeathEvent event){
Player p = event.getEntity();
Server s = p.getServer();
@ -162,6 +79,7 @@ public class DeathListener implements Listener{
int players = plugin.Playing.get(a).size()-1;
String leftmsg = null;
clearInv(p);
event.getDrops().clear();
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
plugin.scoreboards.remove(p.getName());
if(!plugin.Frozen.get(a).isEmpty()){
@ -213,7 +131,7 @@ public class DeathListener implements Listener{
plugin.Dead.get(a).add(pname);
plugin.Playing.get(a).remove(pname);
if(p.getKiller() instanceof Player){
if(p.getKiller().getItemInHand().getType().getId()== 0){
if(p.getKiller().getInventory().getItemInMainHand().getType()== Material.AIR){
Player killer = p.getKiller();
String killername = killer.getName();
event.setDeathMessage("");
@ -229,14 +147,18 @@ public class DeathListener implements Listener{
}
if(plugin.Kills.containsKey(killername))
plugin.Kills.put(killername, plugin.Kills.get(killername)+1);
else plugin.Kills.put(killername, 1);
if(plugin.Kills.containsKey("__SuM__"))
plugin.Kills.put("__SuM__", plugin.Kills.get("__SuM__")+1);
else plugin.Kills.put("__SuM__", 1);
plugin.winner(a);
}else{
Player killer = p.getKiller();
String killername = killer.getName();
String weapon = "a(n) " + killer.getItemInHand().getType().toString().replace('_', ' ');
if(killer.getItemInHand().hasItemMeta())
if(killer.getItemInHand().getItemMeta().hasDisplayName())
weapon = killer.getItemInHand().getItemMeta().getDisplayName();
String weapon = "a(n) " + killer.getInventory().getItemInMainHand().getType().name().replace('_', ' ');
if(killer.getInventory().getItemInMainHand().hasItemMeta())
if(killer.getInventory().getItemInMainHand().getItemMeta().hasDisplayName())
weapon = killer.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
String msg = ChatColor.LIGHT_PURPLE + "**BOOM** Tribute " + pname + " was killed by tribute " + killername + " with " + weapon;
event.setDeathMessage("");
if(plugin.config.getBoolean("broadcastAll")){
@ -251,6 +173,10 @@ public class DeathListener implements Listener{
}
if(plugin.Kills.containsKey(killername))
plugin.Kills.put(killername, plugin.Kills.get(killername)+1);
else plugin.Kills.put(killername, 1);
if(plugin.Kills.containsKey("__SuM__"))
plugin.Kills.put("__SuM__", plugin.Kills.get("__SuM__")+1);
else plugin.Kills.put("__SuM__", 1);
plugin.winner(a);
}
}else{
@ -270,7 +196,6 @@ public class DeathListener implements Listener{
}
}
}
@SuppressWarnings("deprecation")
private void clearInv(Player p){
p.getInventory().clear();
p.getInventory().setBoots(null);

View File

@ -1,35 +0,0 @@
package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
/**
*
* @author YoshiGenius
*/
public class DmgListener implements Listener {
public Main plugin;
public DmgListener(Main m) {
this.plugin = m;
}
int i = 0;
@EventHandler
public void onDmg(EntityDamageEvent evt) {
Entity e = evt.getEntity();
if (e instanceof Player) {
Player p = (Player) e;
String pn = p.getName();
for(i= 1; i < plugin.Frozen.size(); i++){
if (plugin.Frozen.get(i).contains(pn))
evt.setCancelled(true);
}
}
}
}

View File

@ -2,6 +2,7 @@ package me.Travja.HungerArena.Listeners;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import me.Travja.HungerArena.Main;
@ -12,6 +13,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.metadata.MetadataValue;
public class FreezeListener implements Listener {
public Main plugin;
@ -22,7 +24,7 @@ public class FreezeListener implements Listener {
int a = 0;
private HashMap<Integer, Boolean> timeUp= new HashMap<Integer, Boolean>();
private ArrayList<Integer> timing = new ArrayList<Integer>();
@SuppressWarnings("deprecation")
@EventHandler
public void onPlayerMove(PlayerMoveEvent event){
Player p = event.getPlayer();
@ -90,12 +92,26 @@ public class FreezeListener implements Listener {
}
plugin.winner(a);
}
}else{
for(String players:plugin.Playing.get(a)){
Player playing = plugin.getServer().getPlayerExact(players);
i = plugin.Playing.get(a).indexOf(players)+1;
if(!playing.getLocation().getBlock().getLocation().equals(plugin.location.get(a).get(i).getBlock().getLocation())){
playing.teleport(plugin.location.get(a).get(i));
}else{
i = plugin.Playing.get(a).indexOf(pname)+1;
Location pLoc=null;
if (p.hasMetadata("HA-Location")){
List<MetadataValue> l=p.getMetadata("HA-Location");
if (l !=null && l.size()!=0 ){
try {
pLoc=(Location) l.get(0).value();
} catch (Exception e){}
}
if (pLoc!=null) {
if(p.getLocation().getBlockX()!=(pLoc.getBlockX()) || p.getLocation().getBlockZ()!=(pLoc.getBlockZ())){
pLoc.setX(pLoc.getBlock().getLocation().getX()+.5);
pLoc.setZ(pLoc.getBlock().getLocation().getZ()+.5);
p.teleport(pLoc);
}
} else {
if(!p.getLocation().getBlock().getLocation().equals(plugin.location.get(a).get(i).getBlock().getLocation())){
p.teleport(plugin.location.get(a).get(i));
}
}
}
}

View File

@ -3,7 +3,6 @@ package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.HaCommands;
import me.Travja.HungerArena.Main;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
@ -23,33 +22,20 @@ public class JoinAndQuitListener implements Listener {
public JoinAndQuitListener(HaCommands h){
this.commands = h;
}
int i = 0;
int a = 0;
@SuppressWarnings("deprecation")
@EventHandler
public void onJoin(PlayerJoinEvent evt) {
Player p = evt.getPlayer();
for(i = 1; i <= plugin.Watching.size(); i++){
for (String s : plugin.Watching.get(i)) {
Player spectator = Bukkit.getServer().getPlayerExact(s);
p.hidePlayer(spectator);
}
}
}
@SuppressWarnings("deprecation")
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event){
final Player p = event.getPlayer();
final String pname = p.getName();
boolean pfound = false;
for(i = 1; i <= plugin.Watching.size(); i++){
for(int i : plugin.Watching.keySet()){
for(String s: plugin.Watching.get(i)){
Player spectator = plugin.getServer().getPlayerExact(s);
p.hidePlayer(spectator);
p.hidePlayer(plugin,spectator);
}
}
for(i = 1; i <= plugin.Out.size(); i++){
for(int i : plugin.Out.keySet()){
if(plugin.Out.get(i).contains(pname)){
plugin.Playing.get(i).add(pname);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
@ -61,9 +47,10 @@ public class JoinAndQuitListener implements Listener {
pfound = true;
}
}
for(i = 1; i <= plugin.Quit.size(); i++){
for(final int i : plugin.Quit.keySet()){
if(plugin.Quit.get(i).contains(pname)){
String[] Spawncoords = plugin.spawns.getString("Spawn_coords_"+i).split(","); // Jeppa: move the player where he belongs....
String[] Spawncoords = plugin.spawns.getString("Spawn_coords."+i).split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
@ -74,16 +61,16 @@ public class JoinAndQuitListener implements Listener {
public void run(){
p.teleport(Spawn);
p.sendMessage(ChatColor.RED + "You have been teleported to last spawn because you quit/forfeited!");
plugin.RestoreInv(p, p.getName()); // Jeppa: call for restore inventory of leaving player!!
if (plugin.Quit.get(i)!= null) plugin.Quit.get(i).remove(p.getName()); //Jeppa: fix
plugin.RestoreInv(p, p.getName());
if (plugin.Quit.get(i)!= null) plugin.Quit.get(i).remove(p.getName());
}
}, 40L);
pfound = true;
}
}
for(i = 1; i <= plugin.Dead.size(); i++){
for(final int i : plugin.Dead.keySet()){
if(plugin.Dead.get(i).contains(pname)){
String[] Spawncoords = plugin.spawns.getString("Spawn_coords_"+i).split(","); // Jeppa: move the player where he belongs....
String[] Spawncoords = plugin.spawns.getString("Spawn_coords."+i).split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
@ -94,17 +81,17 @@ public class JoinAndQuitListener implements Listener {
public void run(){
p.teleport(Spawn);
p.sendMessage(ChatColor.RED + "You have been teleported to spawn because you quit/died/forfeited!!");
plugin.RestoreInv(p, p.getName()); // Jeppa: call for restore inventory of leaving player!!
if (plugin.Dead.get(i)!= null) plugin.Dead.get(i).remove(p.getName()); //Jeppa: fix //This may throw an error as it is cleared meanwhile...
plugin.RestoreInv(p, p.getName());
if (plugin.Dead.get(i)!= null) plugin.Dead.get(i).remove(p.getName());
}
}, 40L);
pfound = true;
}
}
for(i = 1; i <= plugin.inArena.size(); i++){
for(final int i : plugin.inArena.keySet()){
if(plugin.inArena.get(i)!= null){
if(plugin.inArena.get(i).contains(pname)){
String[] Spawncoords = plugin.spawns.getString("Spawn_coords_"+i).split(","); // Jeppa: move the player where he belongs....
String[] Spawncoords = plugin.spawns.getString("Spawn_coords."+i).split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
@ -121,25 +108,24 @@ public class JoinAndQuitListener implements Listener {
p.getInventory().setHelmet(null);
plugin.inArena.remove(pname);
p.sendMessage(ChatColor.RED + "You were still in the arena when you left and now the games are over.");
plugin.RestoreInv(p, p.getName()); // Jeppa: call for restore inventory of leaving player!!
if (plugin.inArena.get(i)!= null) plugin.inArena.get(i).remove(p.getName()); //Jeppa: fix
plugin.RestoreInv(p, p.getName());
if (plugin.inArena.get(i)!= null) plugin.inArena.get(i).remove(p.getName());
}
}, 40L);
pfound = true;
}
}
}
//Jeppa: New routine to check if the player reconnected and is unknown to the server!
if((plugin.restricted && plugin.worlds.contains(p.getWorld().getName())) || !plugin.restricted){
if (!pfound && plugin.config.getString("Force_Players_toSpawn").equalsIgnoreCase("True")) { //Jeppa: Player is in non of the obove lists.. so he is new to the server due to restart of the server and reconnect of the player...(something like that...)
String[] Spawncoords = plugin.spawns.getString("Spawn_coords").split(","); //Jeppa: Spawn_coords_# may be used .. but default-spawn seems to be more usable ! (can be used as default waitingroom...)
if((plugin.restricted && plugin.worldsNames.values().contains(p.getWorld().getName())) || !plugin.restricted){
if (!pfound && plugin.config.getString("Force_Players_toSpawn").equalsIgnoreCase("True") && (plugin.spawns.getString("Spawn_coords.0")!=null)) {
String[] Spawncoords = plugin.spawns.getString("Spawn_coords.0").split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
double spawny = Double.parseDouble(Spawncoords[1]);
double spawnz = Double.parseDouble(Spawncoords[2]);
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
plugin.RestoreInv(p, p.getName()); // Jeppa: call for restore inventory of leaving player!! -> this is restore inv by restart of server ...
plugin.RestoreInv(p, p.getName());
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
public void run(){
p.teleport(Spawn);
@ -148,17 +134,15 @@ public class JoinAndQuitListener implements Listener {
}, 40L);
}
}
//^^
}
@EventHandler
public void onQuit(PlayerQuitEvent evt) {
Player p = evt.getPlayer();
String pname = p.getName();
for(i = 1; i <= plugin.Frozen.size(); i++){
for(int i : plugin.Frozen.keySet()){
if (plugin.Frozen.get(i).contains(pname)) {
plugin.Frozen.remove(pname);
String[] Spawncoords = plugin.spawns.getString("Spawn_coords").split(",");
String[] Spawncoords = plugin.spawns.getString("Spawn_coords.0").split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
@ -175,7 +159,7 @@ public class JoinAndQuitListener implements Listener {
}
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event){ // delay zum setzen ob Player in der Arena bleibt oder fliegt bei disconnect...
public void onPlayerQuit(PlayerQuitEvent event){
final Player p = event.getPlayer();
final String pname = p.getName();
if(plugin.getArena(p)!= null){
@ -186,7 +170,7 @@ public class JoinAndQuitListener implements Listener {
public void run(){
if(plugin.Out.get(a).contains(pname)){
plugin.Quit.get(a).add(pname);
plugin.Out.get(a).remove(pname); //Jeppa: fix
plugin.Out.get(a).remove(pname);
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
if(plugin.scoreboards.containsKey(p.getName()))
plugin.scoreboards.remove(p.getName());

View File

@ -11,7 +11,6 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
public class PvP implements Listener {
public Main plugin;
public PvP(Main m) {
@ -31,8 +30,8 @@ public class PvP implements Listener {
if(event.isCancelled()){
event.setCancelled(false);
}
if(plugin.gp.get(plugin.getArena(p))!= null){
if(plugin.gp.get(plugin.getArena(p))!= 0){
if(plugin.gp.get(plugin.getArena(p))!= null){
if(plugin.gp.get(plugin.getArena(p))!= 0){
event.setCancelled(true);
}
}
@ -66,8 +65,7 @@ public class PvP implements Listener {
}
}
}else if(projectile.getShooter() instanceof Entity){
Entity e = projectile.getShooter();
// Entity e = (Entity) projectile.getShooter(); // war in 1.5 zuvor so, ursprünglich aber ohne (Entity), in 1.5.1 wieder ohne???
Entity e = (Entity) projectile.getShooter();
if(e instanceof Skeleton){
if(plugin.getArena(p)!= null){
if(plugin.gp.get(plugin.getArena((Player) e))!= null)
@ -83,10 +81,17 @@ public class PvP implements Listener {
@EventHandler
public void PlayerDamage(EntityDamageEvent event){
Entity e = event.getEntity();
if(e instanceof Player)
if(plugin.getArena((Player) e)!= null)
if(plugin.gp.get(plugin.getArena((Player) e))!= null)
if(plugin.gp.get(plugin.getArena((Player) e))!= 0)
event.setCancelled(true);
if(e instanceof Player) {
Player p = (Player)e;
if(plugin.getArena(p)!=null){
a = plugin.getArena(p);
if(plugin.gp.get(a)!= null && plugin.gp.get(a)!= 0)
event.setCancelled(true);
if (plugin.Frozen.get(a)!=null && plugin.Frozen.get(a).contains(p.getName())){
event.setCancelled(true);
}
}
}
}
}

View File

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

View File

@ -3,7 +3,6 @@ package me.Travja.HungerArena.Listeners;
import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -11,12 +10,12 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
public class Signs implements Listener {
public class SignsAndBedsOld implements Listener {
public Main plugin;
public Signs(Main m) {
public SignsAndBedsOld(Main m) {
this.plugin = m;
}
@SuppressWarnings("deprecation")
@EventHandler
public void Sign(PlayerInteractEvent event){
Player p = event.getPlayer();
@ -25,24 +24,37 @@ public class Signs implements Listener {
return;
}
if(event.getAction()== Action.RIGHT_CLICK_BLOCK){
if(b.getType()== Material.SIGN || b.getType()==Material.SIGN_POST || b.getType()==Material.WALL_SIGN){
if (b.getState() instanceof org.bukkit.block.Sign){
org.bukkit.block.Sign sign = (org.bukkit.block.Sign) b.getState();
String line1 = sign.getLine(0);
String line2 = sign.getLine(1);
String line3 = sign.getLine(2);
String line4 = sign.getLine(3);
if(line1.equalsIgnoreCase(ChatColor.BLUE + "[HungerArena]") || line1.equalsIgnoreCase(ChatColor.BLUE + "[HA]")){
if(!line2.equals(""))
p.performCommand("ha " + line2);
else if(!line3.equals(""))
p.performCommand("ha " + line2 + " " + line3);
if(line1.trim().equalsIgnoreCase(ChatColor.BLUE + "[HungerArena]") || line1.trim().equalsIgnoreCase(ChatColor.BLUE + "[HA]")){
if(!line2.equals("") && line3.equals(""))
p.performCommand("ha " + line2);
else if(line2.equals("") && !line3.equals(""))
p.performCommand("ha " + line3);
else if(!line2.equals("") && !line3.equals("")) {
String commands = "close,join,kick,leave,list,open,ready,refill,reload,restart,rlist,tp,start,watch,warpall";
if (commands.contains(line3.trim().toLowerCase())) {
p.performCommand("ha " + line2);
p.performCommand("ha " + line3);
} else p.performCommand("ha " + line2 + " " + line3);
}
else
p.performCommand("ha");
}
if(line1.equalsIgnoreCase(ChatColor.BLUE + "[Sponsor]")){
if(line1.trim().equalsIgnoreCase(ChatColor.BLUE + "[Sponsor]")){
p.performCommand("sponsor " + line2 + " " + line3 + " " + line4);
}
}
if (plugin.config.getString("DenyBedUsage").trim().equalsIgnoreCase("true")){
if (b.getState().getData() instanceof org.bukkit.material.Bed) {
event.setCancelled(true);
}
}
}
}
@EventHandler

View File

@ -13,8 +13,10 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.*;
import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.scoreboard.DisplaySlot;
public class SpectatorListener implements Listener {
@ -26,63 +28,46 @@ public class SpectatorListener implements Listener {
@EventHandler
public void SpectatorDrops(PlayerDropItemEvent event){
Player p = event.getPlayer();
String pname = p.getName();
for(i = 0; i < plugin.Watching.size(); i++){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(pname)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
if (denyInteraction(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorInteractBlock(PlayerInteractEvent event){
Player p = event.getPlayer();
String pname = p.getName();
for(i = 0; i < plugin.Watching.size(); i++){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(pname)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
if (denyInteraction(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorInteractEntity(PlayerInteractEntityEvent event){
Player p = event.getPlayer();
String pname = p.getName();
for(i = 0; i < plugin.Watching.size(); i++){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(pname)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
if (denyInteraction(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorItems(PlayerPickupItemEvent event){
Player p = event.getPlayer();
String pname = p.getName();
for(i = 0; i < plugin.Watching.size(); i++){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(pname)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
public void SpectatorItems(EntityPickupItemEvent event){
if (event.getEntity() instanceof Player) {
Player p = (Player)event.getEntity();
if (denyInteraction(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
}
@EventHandler
public void SpectatorPvP(EntityDamageByEntityEvent event){
Entity offense = event.getDamager();
if(offense instanceof Player){
Player Attacker = (Player) event.getDamager();
String attackerName = Attacker.getName();
for(i = 0; i < plugin.Watching.size(); i++){
for(int i : plugin.Watching.keySet()){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(attackerName)){
event.setCancelled(true);
@ -91,7 +76,7 @@ public class SpectatorListener implements Listener {
}
}
}
for(i = 0; i < plugin.Playing.size(); i++){
for(int i : plugin.Playing.keySet()){
if(plugin.Playing.get(i)!= null){
if(plugin.Playing.get(i).contains(attackerName)){
event.setCancelled(true);
@ -100,10 +85,11 @@ public class SpectatorListener implements Listener {
}
}else if(event.getDamager() instanceof Projectile){
Projectile arrow = (Projectile) offense;
if(arrow.getShooter() instanceof Player){
Player BowMan = (Player) arrow.getShooter();
ProjectileSource shooter = arrow.getShooter();
if(shooter instanceof Player){
Player BowMan = (Player) shooter;
String bowManName = BowMan.getName();
for(i = 0; i < plugin.Watching.size(); i++){
for(int i : plugin.Watching.keySet()){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(bowManName)){
event.setCancelled(true);
@ -112,7 +98,7 @@ public class SpectatorListener implements Listener {
}
}
}
for(i = 0; i < plugin.Playing.size(); i++){
for(int i : plugin.Playing.keySet()){
if(plugin.Playing.get(i)!= null){
if(plugin.Playing.get(i).contains(bowManName)){
event.setCancelled(true);
@ -125,38 +111,28 @@ public class SpectatorListener implements Listener {
@EventHandler
public void SpectatorBlockBreak(BlockBreakEvent event){
Player p = event.getPlayer();
String pname = p.getName();
for(i = 0; i < plugin.Watching.size(); i++){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(pname)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
if (denyInteraction(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorBlockPlace(BlockPlaceEvent event){
Player p = event.getPlayer();
String pname = p.getName();
for(i = 0; i < plugin.Watching.size(); i++){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(pname)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
if (denyInteraction(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are spectating, you can't interfere with the game!");
}
}
@EventHandler
public void SpectatorQuit(PlayerQuitEvent event){
Player p = event.getPlayer();
String pname = p.getName();
for(i = 0; i < plugin.Watching.size(); i++){
for(int i : plugin.Watching.keySet()){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(pname)){
plugin.Watching.get(i).remove(pname);
String[] Spawncoords = plugin.spawns.getString("Spawn_coords").split(",");
String[] Spawncoords = plugin.spawns.getString("Spawn_coords.0").split(",");
String w = Spawncoords[3];
World spawnw = plugin.getServer().getWorld(w);
double spawnx = Double.parseDouble(Spawncoords[0]);
@ -183,7 +159,7 @@ public class SpectatorListener implements Listener {
}
if(target instanceof Player){
String targetName = ((Player) target).getName();
for(i = 0; i < plugin.Watching.size(); i++){
for(int i : plugin.Watching.keySet()){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(targetName)){
event.setTarget(null);
@ -192,4 +168,16 @@ public class SpectatorListener implements Listener {
}
}
}
private boolean denyInteraction(Player p){
String pname = p.getName();
for(int i : plugin.Watching.keySet()){
if(plugin.Watching.get(i)!= null){
if(plugin.Watching.get(i).contains(pname)){
return true;
}
}
}
return false;
}
}

View File

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

View File

@ -1,7 +1,5 @@
package me.Travja.HungerArena.Listeners;
import java.util.List;
import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor;
@ -20,8 +18,7 @@ public class TeleportListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
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)){
if(plugin.worldsNames.values().contains(event.getTo().getWorld().getName()) && plugin.Tele.contains(p)){
event.setCancelled(true);
p.sendMessage(ChatColor.RED + "You are a dead tribute... How are you supposed to get back into the arena....");
plugin.Tele.remove(p);
@ -32,21 +29,4 @@ public class TeleportListener implements Listener {
}
}
}
/*@EventHandler Unwanted right now...
public void onTP(PlayerTeleportEvent evt) {
@SuppressWarnings("unused")
Player p = evt.getPlayer();
TeleportCause tc = evt.getCause();
if (tc == TeleportCause.ENDER_PEARL) {
return;
}
if (tc == TeleportCause.END_PORTAL) {
return;
}
if (tc == TeleportCause.NETHER_PORTAL) {
return;
}
evt.setCancelled(true);
}*/
}

View File

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

View File

@ -1,5 +1,7 @@
package me.Travja.HungerArena.Listeners;
import java.util.Collection;
import me.Travja.HungerArena.Main;
import org.bukkit.ChatColor;
@ -16,18 +18,32 @@ public class spawnsListener implements Listener{
this.plugin = m;
}
@SuppressWarnings("deprecation")
@EventHandler
public void interact(PlayerInteractEvent event){
Player p = event.getPlayer();
if(plugin.setting.containsKey(p.getName())){
if(event.getAction()==Action.RIGHT_CLICK_BLOCK){
Location l = event.getClickedBlock().getLocation();
if(p.getItemInHand().getTypeId()== plugin.config.getInt("spawnsTool")){
String HandItem;
try {
HandItem=p.getInventory().getItemInMainHand().getType().name();
} catch (Exception e){
HandItem=p.getItemInHand().getType().name();
}
if(HandItem == plugin.config.getString("spawnsTool")){
String[] info = plugin.setting.get(p.getName()).split("-");
if(Integer.parseInt(info[1])!= plugin.config.getInt("maxPlayers")+1){
String coords = l.getWorld().getName() + " " + (l.getX()+.5) + " " + (l.getY()+1) + " " + (l.getZ()+.5); // fixed (.getName()
String coords = l.getWorld().getName() + " " + ((double)l.getX()+.5) + " " + ((double)l.getY()+1) + " " + ((double)l.getZ()+.5);
int arena = Integer.parseInt(info[0]);
if (plugin.spawns.get("Spawns." + arena) != null){
Collection<Object> temp = plugin.spawns.getConfigurationSection("Spawns."+arena).getValues(false).values();
if (temp.contains(coords.trim().replace(' ', ','))){
event.setCancelled(true);
return;
}
}
p.performCommand("startpoint " + info[0] + " " + info[1] + " " + coords);
if(Integer.parseInt(info[1])>= plugin.config.getInt("maxPlayers")){

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@ public class SpawnsCommand implements CommandExecutor {
public Main plugin;
int i = 0;
int a = 0;
boolean NoPlayerSpawns = true; // Jeppa : default
boolean NoPlayerSpawns;
public SpawnsCommand(Main m) {
this.plugin = m;
}
@ -23,23 +23,24 @@ public class SpawnsCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
Player p = (Player) sender;
String ThisWorld = p.getWorld().getName();
for(i = 1; i <= plugin.worldsNames.size(); i++){
if(plugin.worldsNames.get(i)!= null){
NoPlayerSpawns = true;
for(int i : plugin.worldsNames.keySet()){
if(plugin.worldsNames.get(i)!= null){
if (plugin.worldsNames.get(i).equals(ThisWorld)){
a=i; // now 'a' is the arenanumber of THIS(current) map , only available if this map already has min. one startpoint!
NoPlayerSpawns = false; // mapname found -> there are PlayerSpawns...--> map seems playable
a=i;
NoPlayerSpawns = false;
break;
}
}
}
if(cmd.getName().equalsIgnoreCase("StartPoint")){
if(p.hasPermission("HungerArena.StartPoint")){
if(!plugin.restricted || (plugin.restricted && plugin.worlds.contains(p.getWorld().getName()))){
Location loc = null;
double x;
double y;
double z;
if(args.length == 6){
try{ // was missing.....
try{
i = Integer.valueOf(args[1]);
a = Integer.valueOf(args[0]);
}catch(Exception e){
@ -53,14 +54,10 @@ public class SpawnsCommand implements CommandExecutor {
z = Double.parseDouble(args[5]);
loc = new Location(Bukkit.getWorld(world), x, y, z);
if(plugin.location.get(a)!= null){
if(plugin.location.get(a).size()>= i){
plugin.location.get(a).put(i, new Location(loc.getWorld(), x, y, z));
}else{
plugin.location.get(a).put(i, new Location(loc.getWorld(), x, y, z));
}
plugin.location.get(a).put(i, loc);
}else{
plugin.location.put(a, new HashMap<Integer, Location>());
plugin.location.get(a).put(i, new Location(loc.getWorld(), x, y, z));
plugin.location.get(a).put(i, loc);
plugin.Playing.put(a, new ArrayList<String>());
plugin.Ready.put(a, new ArrayList<String>());
plugin.Dead.put(a, new ArrayList<String>());
@ -72,18 +69,20 @@ public class SpawnsCommand implements CommandExecutor {
plugin.Frozen.put(a, new ArrayList<String>());
plugin.arena.put(a, new ArrayList<String>());
plugin.canjoin.put(a, false);
plugin.MatchRunning.put(a, null);
plugin.open.put(a, true);
}
String coords = plugin.location.get(a).get(i).getWorld().getName() + "," + (plugin.location.get(a).get(i).getX()+.5) + "," + plugin.location.get(a).get(i).getY() + "," + (plugin.location.get(a).get(i).getZ()+.5);
String coords = loc.getWorld().getName() + "," + (loc.getX()) + "," + loc.getY() + "," + (loc.getZ());
p.sendMessage(coords);
plugin.spawns.set("Spawns." + a + "." + i, coords);
plugin.worldsNames.put(a, loc.getWorld().getName());
plugin.saveSpawns();
plugin.maxPlayers.put(a, plugin.location.get(a).size());
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute " + i + " in arena " + a + "!");
this.plugin.reloadSpawnpoints(); // Jeppa: fix the check-routines looking for arenas in the HashMaps... -> muss in jede routine vor den return!!!
this.plugin.reloadSpawnpoints(false);
return true;
}
if(args.length>= 2){ // Welt und Pos Startummer angegeben
if(args.length>= 2){
try{
i = Integer.valueOf(args[1]);
a = Integer.valueOf(args[0]);
@ -92,23 +91,19 @@ public class SpawnsCommand implements CommandExecutor {
return true;
}
if(i >= 1 && i <= plugin.config.getInt("maxPlayers")){
if(plugin.restricted && !plugin.worlds.contains(p.getWorld().getName())){
p.sendMessage(ChatColor.GOLD + "We ran the command, however, this isn't a world you defined in the config...");
p.sendMessage(ChatColor.GOLD + "If this is the right world, please disregard this message.");
if(!plugin.worldsNames.values().contains(p.getWorld().getName())){
p.sendMessage(ChatColor.GOLD + "You've added this world to the config ...");
}
loc = p.getLocation().getBlock().getLocation();
x = loc.getX();
x = loc.getX()+.5;
y = loc.getY();
z = loc.getZ();
z = loc.getZ()+.5;
loc = new Location(loc.getWorld(), x, y, z);
if(plugin.location.get(a)!= null){
if(plugin.location.get(a).size()>= i){
plugin.location.get(a).put(i, new Location(loc.getWorld(), x, y, z));
}else{
plugin.location.get(a).put(i, new Location(loc.getWorld(), x, y, z));
}
plugin.location.get(a).put(i, loc);
}else{
plugin.location.put(a, new HashMap<Integer, Location>());
plugin.location.get(a).put(i, new Location(loc.getWorld(), x, y, z));
plugin.location.get(a).put(i, loc);
plugin.Playing.put(a, new ArrayList<String>());
plugin.Ready.put(a, new ArrayList<String>());
plugin.Dead.put(a, new ArrayList<String>());
@ -120,24 +115,26 @@ public class SpawnsCommand implements CommandExecutor {
plugin.Frozen.put(a, new ArrayList<String>());
plugin.arena.put(a, new ArrayList<String>());
plugin.canjoin.put(a, false);
plugin.MatchRunning.put(a, null);
plugin.open.put(a, true);
}
String coords = plugin.location.get(a).get(i).getWorld().getName() + "," + (plugin.location.get(a).get(i).getX()+.5) + "," + plugin.location.get(a).get(i).getY() + "," + (plugin.location.get(a).get(i).getZ()+.5);
String coords = loc.getWorld().getName() + "," + (loc.getX()) + "," + loc.getY() + "," + (loc.getZ());
p.sendMessage(coords);
plugin.spawns.set("Spawns." + a + "." + i, coords);
plugin.worldsNames.put(a, loc.getWorld().getName());
plugin.saveSpawns();
plugin.maxPlayers.put(a, plugin.location.get(a).size());
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute " + i + " in arena " + a + "!");
this.plugin.reloadSpawnpoints(); // Jeppa: fix for the check-routines looking for arenas in the HashMaps... -> muss in jede routine vor den return!!!
this.plugin.reloadSpawnpoints(false);
}else{
p.sendMessage(ChatColor.RED + "You can't go past " + plugin.config.getInt("maxPlayers") + " players!");
}
}else if(args.length == 1){
}else if(args.length == 1){
if (sender instanceof Player){
p = (Player) sender;
if(NoPlayerSpawns){ // oben wurde keine Welt gefunden! --> this is for changing the arenanumber to correct value ! If this arena already has playerspawns use that arenanumber , ignore the given number
if(NoPlayerSpawns){
try{
a = Integer.parseInt(args[0]); // kein Int = Fehler, Nicht vorhanden = Fehler
a = Integer.parseInt(args[0]);
}catch(Exception e){
p.sendMessage(ChatColor.RED + "Argument not an integer!");
return true;
@ -168,10 +165,9 @@ public class SpawnsCommand implements CommandExecutor {
sender.sendMessage(ChatColor.BLUE + "This Can Only Be Sent As A Player");
}
} else {
p.sendMessage(ChatColor.RED + "No argument given! \nUse command like this:\n/startpoint [Arena #] [Startpoint #] for setting your position as a startpoint.\n/startpoint [Arena #] [Startpoint #] [Mapname] [x] [y] [z] \nOr you can use /startpoint [Arena #] to use the 'spawntool': ID"+ plugin.config.getInt("spawnsTool") +" for setting the startpoints!"); // \n If this map already has startpoints you can use /startpoint without any arguments !");
p.sendMessage(ChatColor.RED + "No argument given! \nUse command like this:\n/startpoint [Arena #] [Startpoint #] for setting your position as a startpoint.\n/startpoint [Arena #] [Startpoint #] [Mapname] [x] [y] [z] \nOr you can use /startpoint [Arena #] to use the 'spawntool': ID"+ plugin.config.getInt("spawnsTool") +" for setting the startpoints!");
return false;
}
}
}else{
p.sendMessage(ChatColor.RED + "You don't have permission!");
}

View File

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

View File

@ -6,7 +6,7 @@ import org.bukkit.event.Listener;
/**
*
* @author YoshiGenius
* based on YoshiGenius
*/
public class WinGamesListener implements Listener {
@ -18,7 +18,7 @@ public class WinGamesListener implements Listener {
@EventHandler
public void onWin(PlayerWinGamesEvent evt) {
Player p = evt.getPlayer();
plugin.econ.depositPlayer(p.getName(), plugin.config.getDouble("EcoReward"));
plugin.econ.depositPlayer(p, plugin.config.getDouble("EcoReward"));
}
}

View File

@ -1,44 +0,0 @@
package me.Travja.HungerArena;
//import java.io.File;
//import java.util.List;
//import org.bukkit.ChatColor;
//import org.bukkit.configuration.file.FileConfiguration;
//import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChangedWorldEvent;
//import org.bukkit.inventory.ItemStack;
public class WorldChange implements Listener {
public Main plugin;
public WorldChange(Main m) {
plugin = m;
}
//@SuppressWarnings({ "deprecation", "unchecked" })
@EventHandler
public void worldChange(PlayerChangedWorldEvent event){
Player p = event.getPlayer();
String pname = p.getName();
String ThisWorld = p.getWorld().getName();
int i=0;
int a=0;
for(i = 1; i <= plugin.worldsNames.size(); i++){ //Jeppa: get the number of arena the player is moving in!
if(plugin.worldsNames.get(i)!= null){
if (plugin.worldsNames.get(i).equals(ThisWorld)){
a=i; //now 'a' is the HA-arena the player has moved in now --> can be (or not) the one he joined, !!
}
}
}
//Jeppa:
if(plugin.Frozen.get(a)!=null){ //Dont't call it when changing to non-HA-map!
if(!plugin.Frozen.get(a).contains(pname)){ //Only give back the players inventory at mapchange if this mapchange is NOT a teleport from waitingarea to playgroud!! And don't remove him from "Playing" and "Ready" in this case!!!
//Jeppa : This may collide with other tools like MultiInv oder Multiverse Inv !!!???? but shouldn't !
plugin.RestoreInv(p, pname); //Jeppa: This will also do a check thru all available arenas and remove the player from the lists as he is NOT playing...
}
}
}
}

View File

@ -1,18 +1,18 @@
name: HungerArena
main: me.Travja.HungerArena.Main
version: 1.5C_Jeppa
version: 1.6_Jeppa
api-version: 1.13
description: A lightweight and powerful plugin to help with playing The Hunger Games!
softdepend: [Vault, WorldEdit]
softdepend: [Vault, WorldEdit, Multiverse-Core]
commands:
Ha:
description: Makes you join a game or start the game!
StartPoint:
description: Sets the starting point of a tribute.
usage: /startpoint [arenanumber] [startpointnumber]
usage: /<command> [arenanumber] [startpointnumber]
permission: HungerArena.StartPoint
permission-message: §4[HungerArena]§rYou don't have permission!!!!
Sponsor:
description: Sponsors a Tribute
usage: /sponsor [tribute] [item] [amount]
permission: HungerArena.Sponsor
permission-message: §4[HungerArena]§rYou don't have permission!!!!

9
src/spawns.yml Normal file
View File

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