merged from 2nd branch to master
BIG Update!!! 1st: changed to latest source from Travja 2nd: lots of updates and fixes: - MultiArena working and multispawns! (now 20 default worlds in no order possible, if more are needed keep them in correct order!) - the defaultspawnpoint always is the last spawnpoint set, or edit the configfile (spawns.yml). - setting spawnpoint working now. - HA commands extended, fixed and with help..., some commands now have default worldrecognition - saving and restore of player inventories !!!! - fixed join/leave/dead-behaviour - fixed gracetimer and made each map have its own timer! 3rd: merged branch
This commit is contained in:
commit
534a12684e
14
.gitignore
vendored
Normal file
14
.gitignore
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
*.class
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
#Travja
|
||||
.project.settings
|
||||
.project
|
||||
.classpath
|
||||
bin
|
6
Player.yml
Normal file
6
Player.yml
Normal file
@ -0,0 +1,6 @@
|
||||
# This is the default inventory file for storing players inventory during matches !
|
||||
# DO not Edit anything in here!!!
|
||||
|
||||
inv: []
|
||||
armor: []
|
||||
world: world
|
20
README
20
README
@ -1,6 +1,24 @@
|
||||
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
|
||||
/\
|
||||
|
|
||||
|
|
||||
|
|
||||
Go there for more info!
|
||||
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!)
|
||||
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!
|
||||
|
13
config.yml
13
config.yml
@ -14,7 +14,7 @@ config:
|
||||
# worlds:
|
||||
# - world
|
||||
# - world_nether
|
||||
worlds:
|
||||
worlds: {}
|
||||
|
||||
# If left at 0 there will be no death match, fill in a time in minutes
|
||||
DeathMatch: 0
|
||||
@ -50,10 +50,10 @@ Grace_Period: 60
|
||||
Protected_Arena: 'true'
|
||||
|
||||
# Whether or not players (not playing) can break blocks while waiting
|
||||
Protected_Arena_Always: 'false'
|
||||
Protected_Arena_Always: 'true'
|
||||
|
||||
# Whether new or unknown players on HA-maps should be forced to the spawn or not.
|
||||
Force_Players_toSpawn: 'false'
|
||||
Force_Players_toSpawn: 'true'
|
||||
|
||||
# Whether or not players will be frozen when they are teleported to their positions
|
||||
Frozen_Teleport: 'true'
|
||||
@ -63,6 +63,13 @@ Explode_on_Move: 'false'
|
||||
|
||||
# Whether or not thunder will sound upon a players death
|
||||
Cannon_Death: '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
|
||||
|
||||
######################################
|
||||
######################################
|
||||
######################################
|
||||
|
12
plugin.yml
12
plugin.yml
@ -1,12 +1,18 @@
|
||||
name: HungerArena
|
||||
main: me.Travja.HungerArena.Main
|
||||
version: 1.4Dev
|
||||
version: 1.5C_Jeppa
|
||||
description: A lightweight and powerful plugin to help with playing The Hunger Games!
|
||||
softdepend: [Vault]
|
||||
softdepend: [Vault, WorldEdit]
|
||||
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]
|
||||
permission: HungerArena.StartPoint
|
||||
permission-message: §4[HungerArena]§rYou don't have permission!!!!
|
||||
Sponsor:
|
||||
description: Sponsors a Tribute
|
||||
description: Sponsors a Tribute
|
||||
usage: /sponsor [tribute] [item] [amount]
|
||||
permission: HungerArena.Sponsor
|
||||
permission-message: §4[HungerArena]§rYou don't have permission!!!!
|
||||
|
57
spawns.yml
57
spawns.yml
@ -7,5 +7,62 @@ Spawns:
|
||||
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:
|
@ -4,6 +4,7 @@ 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;
|
||||
@ -22,7 +23,6 @@ public class Chests implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void ChestBreak(BlockBreakEvent event){
|
||||
Player p = event.getPlayer();
|
||||
|
||||
Block block = event.getBlock();
|
||||
if(p.hasPermission("HungerArena.Chest.Break")){
|
||||
Location blocklocation = block.getLocation();
|
||||
@ -35,7 +35,6 @@ public class Chests implements Listener {
|
||||
list2.remove(blockx + "," + blocky + "," + blockz);
|
||||
plugin.getChests().set("Storage." + blockx + "," + blocky+ "," + blockz, null);
|
||||
plugin.getChests().set("StorageXYZ", list2);
|
||||
plugin.getChests().options().copyDefaults(true);
|
||||
plugin.saveChests();
|
||||
p.sendMessage("[HungerArena] Chest Removed!");
|
||||
} else {
|
||||
@ -54,28 +53,29 @@ public class Chests implements Listener {
|
||||
if(plugin.Playing.get(a).contains(p.getName()) && plugin.canjoin.get(a)){
|
||||
if(!plugin.restricted || (plugin.restricted && plugin.worlds.contains(p.getWorld().getName()))){
|
||||
if(block!= null){
|
||||
if(block.getState() instanceof Chest){
|
||||
ItemStack[] itemsinchest = ((Chest) block.getState()).getInventory().getContents();
|
||||
if(block.getType()== Material.CHEST){
|
||||
ItemStack[] itemsinchest = ((Chest) block.getState()).getInventory().getContents().clone();
|
||||
int blockx = block.getX();
|
||||
int blocky = block.getY();
|
||||
int blockz = block.getZ();
|
||||
String blockw = block.getWorld().getName().toString();
|
||||
if(!plugin.getChests().contains("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X")){ //getConfig greift auf normale cfg zu.. -> eigene Routine
|
||||
plugin.getChests().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X", blockx);
|
||||
plugin.getChests().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Y", blocky);
|
||||
plugin.getChests().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Z",blockz);
|
||||
plugin.getChests().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Location.W", blockw);
|
||||
plugin.getChests().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".ItemsInStorage", itemsinchest);
|
||||
plugin.getChests().addDefault("Storage." + blockx + "," + blocky + "," + blockz + ".Arena", a);
|
||||
if(!plugin.getChests().contains("Storage." + blockx + "," + blocky + "," + blockz)){
|
||||
plugin.getChests().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.X", blockx);
|
||||
plugin.getChests().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Y", blocky);
|
||||
plugin.getChests().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.Z",blockz);
|
||||
plugin.getChests().set("Storage." + blockx + "," + blocky + "," + blockz + ".Location.W", blockw);
|
||||
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.getChests().options().copyDefaults(true);
|
||||
plugin.saveChests();
|
||||
p.sendMessage(ChatColor.GREEN + "Thank you for finding this undiscovered chest, it has been stored!!");
|
||||
}
|
||||
plugin.reloadChests();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ 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();
|
||||
|
92
src/me/Travja/HungerArena/ConfigManager.java
Normal file
92
src/me/Travja/HungerArena/ConfigManager.java
Normal file
@ -0,0 +1,92 @@
|
||||
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();
|
||||
}
|
||||
}
|
@ -1,151 +0,0 @@
|
||||
package me.Travja.HungerArena;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
|
||||
public class DeathListener implements Listener{
|
||||
public Main plugin;
|
||||
public DeathListener(Main m){
|
||||
this.plugin = m;
|
||||
}
|
||||
public FileConfiguration config;
|
||||
int i = 0;
|
||||
int a = 0;
|
||||
@EventHandler
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event){
|
||||
final Player p = event.getPlayer();
|
||||
String pname = p.getName();
|
||||
for(i = 1; i < plugin.Dead.size(); i++){
|
||||
if(plugin.Dead.get(i).contains(pname)){
|
||||
String[] Spawncoords = plugin.spawns.getString("Spawn_coords").split(",");
|
||||
World spawnw = plugin.getServer().getWorld(Spawncoords[3]);
|
||||
double spawnx = Double.parseDouble(Spawncoords[0]);
|
||||
double spawny = Double.parseDouble(Spawncoords[1]);
|
||||
double spawnz = Double.parseDouble(Spawncoords[2]);
|
||||
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||
public void run(){
|
||||
p.teleport(Spawn);
|
||||
}
|
||||
}, 10L);
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void onPlayerDeath(PlayerDeathEvent event){
|
||||
Player p = event.getEntity();
|
||||
Server s = p.getServer();
|
||||
String pname = p.getName();
|
||||
int players = plugin.Playing.size()-1;
|
||||
String leftmsg = null;
|
||||
for(i = 1; i < plugin.Frozen.size(); i++){
|
||||
if(plugin.Frozen.get(i).contains(pname)){
|
||||
if(plugin.getArena(p)!= null){
|
||||
a = plugin.getArena(p);
|
||||
players = plugin.Playing.get(a).size()-1;
|
||||
leftmsg = ChatColor.BLUE + "There are now " + players + " tributes left!";
|
||||
if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){
|
||||
double y = p.getLocation().getY();
|
||||
double newy = y+200;
|
||||
double x = p.getLocation().getX();
|
||||
double z = p.getLocation().getZ();
|
||||
Location strike = new Location(p.getWorld(), x, newy, z);
|
||||
p.getWorld().strikeLightning(strike);
|
||||
}
|
||||
event.setDeathMessage("");
|
||||
if(plugin.config.getBoolean("broadcastAll")){
|
||||
p.getServer().broadcastMessage(pname + ChatColor.LIGHT_PURPLE + " Stepped off their pedestal too early!");
|
||||
}else{
|
||||
for(String gn: plugin.Playing.get(a)){
|
||||
Player g = plugin.getServer().getPlayer(gn);
|
||||
g.sendMessage(pname + ChatColor.LIGHT_PURPLE + " Stepped off their pedestal too early!");
|
||||
}
|
||||
}
|
||||
plugin.Frozen.get(a).remove(pname);
|
||||
plugin.Playing.get(a).remove(pname);
|
||||
plugin.Dead.get(a).add(pname);
|
||||
if(plugin.config.getBoolean("broadcastAll")){
|
||||
p.getServer().broadcastMessage(leftmsg);
|
||||
}else{
|
||||
for(String gn: plugin.Playing.get(a)){
|
||||
Player g = plugin.getServer().getPlayer(gn);
|
||||
g.sendMessage(leftmsg);
|
||||
}
|
||||
}
|
||||
plugin.winner(a);
|
||||
}
|
||||
}else if(plugin.getArena(p)!= null){
|
||||
a = plugin.getArena(p);
|
||||
players = plugin.Playing.get(a).size()-1;
|
||||
leftmsg = ChatColor.BLUE + "There are now " + players + " tributes left!";
|
||||
if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){
|
||||
double y = p.getLocation().getY();
|
||||
double newy = y+200;
|
||||
double x = p.getLocation().getX();
|
||||
double z = p.getLocation().getZ();
|
||||
Location strike = new Location(p.getWorld(), x, newy, z);
|
||||
p.getWorld().strikeLightning(strike);
|
||||
}
|
||||
plugin.Dead.get(a).add(pname);
|
||||
plugin.Playing.get(a).remove(pname);
|
||||
if(p.getKiller() instanceof Player){
|
||||
if(p.getKiller().getItemInHand().getType().getId()== 0){
|
||||
Player killer = p.getKiller();
|
||||
String killername = killer.getName();
|
||||
event.setDeathMessage("");
|
||||
if(plugin.config.getBoolean("broadcastAll")){
|
||||
s.broadcastMessage(ChatColor.LIGHT_PURPLE + "**BOOM** Tribute " + pname + " was killed by tribute " + killername + " with their FIST!");
|
||||
s.broadcastMessage(leftmsg);
|
||||
}else{
|
||||
for(String gn: plugin.Playing.get(a)){
|
||||
Player g = plugin.getServer().getPlayer(gn);
|
||||
g.sendMessage(ChatColor.LIGHT_PURPLE + "**BOOM** Tribute " + pname + " was killed by tribute " + killername + " with their FIST!");
|
||||
g.sendMessage(leftmsg);
|
||||
}
|
||||
}
|
||||
plugin.winner(a);
|
||||
}else{
|
||||
Player killer = p.getKiller();
|
||||
String killername = killer.getName();
|
||||
String weapon = killer.getItemInHand().getType().toString().replace('_', ' ');
|
||||
String msg = ChatColor.LIGHT_PURPLE + "**BOOM** Tribute " + pname + " was killed by tribute " + killername + " with a(n) " + weapon;
|
||||
event.setDeathMessage("");
|
||||
if(plugin.config.getBoolean("broadcastAll")){
|
||||
s.broadcastMessage(msg);
|
||||
s.broadcastMessage(leftmsg);
|
||||
}else{
|
||||
for(String gn: plugin.Playing.get(a)){
|
||||
Player g = plugin.getServer().getPlayer(gn);
|
||||
g.sendMessage(msg);
|
||||
g.sendMessage(leftmsg);
|
||||
}
|
||||
}
|
||||
plugin.winner(a);
|
||||
}
|
||||
}else{
|
||||
event.setDeathMessage("");
|
||||
if(plugin.config.getBoolean("broadcastAll")){
|
||||
s.broadcastMessage(ChatColor.LIGHT_PURPLE + pname + " died of natural causes!");
|
||||
s.broadcastMessage(leftmsg);
|
||||
}else{
|
||||
for(String gn: plugin.Playing.get(a)){
|
||||
Player g = plugin.getServer().getPlayer(gn);
|
||||
g.sendMessage(ChatColor.LIGHT_PURPLE + pname + " died of natural causes!");
|
||||
g.sendMessage(leftmsg);
|
||||
}
|
||||
}
|
||||
plugin.winner(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
package me.Travja.HungerArena;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class FreezeListener implements Listener {
|
||||
public Main plugin;
|
||||
public FreezeListener(Main m) {
|
||||
this.plugin = m;
|
||||
}
|
||||
int i = 0;
|
||||
int a = 0;
|
||||
private HashMap<Integer, Boolean> timeUp= new HashMap<Integer, Boolean>();
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event){
|
||||
Player p = event.getPlayer();
|
||||
String pname = p.getName();
|
||||
if(plugin.getArena(p)!= null){
|
||||
a = plugin.getArena(p);
|
||||
if(plugin.Frozen.get(a).contains(pname) && plugin.config.getString("Frozen_Teleport").equalsIgnoreCase("True")){
|
||||
if(plugin.config.getString("Explode_on_Move").equalsIgnoreCase("true")){
|
||||
for(String players: plugin.Playing.get(a)){
|
||||
final Player playing = plugin.getServer().getPlayerExact(players);
|
||||
i = plugin.Playing.get(a).indexOf(players);
|
||||
if(!timeUp.get(a)){
|
||||
if(!playing.getLocation().getBlock().getLocation().equals(plugin.location.get(a).get(i))){
|
||||
playing.teleport(plugin.location.get(a).get(i));
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||
public void run(){
|
||||
if(!timeUp.get(a)){
|
||||
timeUp.put(a, true);
|
||||
}
|
||||
}
|
||||
},30L);
|
||||
}
|
||||
}else{
|
||||
if(!playing.getLocation().getBlock().getLocation().equals(plugin.location.get(a).get(i))){
|
||||
if(!plugin.Dead.get(a).contains(playing.getName())){
|
||||
World world = playing.getLocation().getWorld();
|
||||
world.createExplosion(playing.getLocation(), 0.0F, false);
|
||||
playing.setHealth(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
for(String players:plugin.Playing.get(a)){
|
||||
Player playing = plugin.getServer().getPlayerExact(players);
|
||||
i = plugin.Playing.get(a).indexOf(players)+1;
|
||||
if(!playing.getLocation().getBlock().getLocation().equals(plugin.location.get(a).get(i))){
|
||||
playing.teleport(plugin.location.get(a).get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,9 @@
|
||||
package me.Travja.HungerArena;
|
||||
package me.Travja.HungerArena.Listeners;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import me.Travja.HungerArena.Main;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -25,6 +27,7 @@ public class BlockStorage implements Listener {
|
||||
public BlockStorage(Main m) {
|
||||
this.plugin = m;
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void BlockBreak(BlockBreakEvent event) {
|
||||
Block b = event.getBlock();
|
||||
@ -32,45 +35,55 @@ public class BlockStorage implements Listener {
|
||||
String pname = p.getName();
|
||||
boolean protall = false;
|
||||
if (plugin.config.getString("Protected_Arena_Always").equalsIgnoreCase("True")) { /* Jeppa Fix/Add */
|
||||
protall = true;
|
||||
if(!p.hasPermission("HungerArena.arena")){
|
||||
event.setCancelled(true);
|
||||
p.sendMessage("You can't break blocks, at all, if you feel this should change, talk to the server owner.");
|
||||
if(!p.hasPermission("HungerArena.arena")){ // Admins frei...
|
||||
protall = true;
|
||||
}
|
||||
}
|
||||
if (plugin.getArena(p) != null || !protall) {
|
||||
if ((plugin.getArena(p) != null) || (protall)) { /* Bug1a */
|
||||
//int a = this.plugin.getArena(p).intValue();
|
||||
int a = 1; //Jeppa: define a default (may be needed if protall is true)
|
||||
if (plugin.getArena(p) != null){
|
||||
a = plugin.getArena(p);
|
||||
if (!event.isCancelled() && plugin.Playing.get(a).contains(pname)){
|
||||
if (plugin.config.getString("Protected_Arena").equalsIgnoreCase("True")) {
|
||||
//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++){
|
||||
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...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plugin.getArena(p) != null) a = plugin.getArena(p);
|
||||
if ((!event.isCancelled()) && (((plugin.Playing.get(a)).contains(pname)) || (protall))) /* Bug1a */
|
||||
{
|
||||
if (plugin.config.getString("Protected_Arena").equalsIgnoreCase("True")) {
|
||||
event.setCancelled(true); /* Jeppa fix Bug1 */
|
||||
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"))) {
|
||||
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"))) {
|
||||
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();
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void Explosion(EntityExplodeEvent event){
|
||||
List<Block> blocksd = event.blockList();
|
||||
@ -109,6 +122,7 @@ public class BlockStorage implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void burningBlocks(BlockBurnEvent event){
|
||||
Block b = event.getBlock();
|
||||
@ -140,11 +154,30 @@ public class BlockStorage implements Listener {
|
||||
public void blockPlace(BlockPlaceEvent event){
|
||||
Block b = event.getBlock();
|
||||
Player p = event.getPlayer();
|
||||
if(plugin.getArena(p)!= null){
|
||||
int a = plugin.getArena(p);
|
||||
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 ((plugin.getArena(p) != null) || (protall)) { /* Bug1a */
|
||||
//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++){
|
||||
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...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plugin.getArena(p) != null) a = plugin.getArena(p);
|
||||
if(!event.isCancelled()){
|
||||
if(plugin.Playing.get(a).contains(p.getName())){
|
||||
if(plugin.canjoin.get(a)){
|
||||
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((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;
|
||||
@ -208,6 +241,7 @@ public class BlockStorage implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void bucketFill(PlayerBucketFillEvent event){
|
||||
if(plugin.getArena(event.getPlayer())!= null){
|
||||
@ -236,6 +270,7 @@ public class BlockStorage implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void blockMelt(BlockFadeEvent event){
|
||||
int i = 0;
|
78
src/me/Travja/HungerArena/Listeners/Boundaries.java
Normal file
78
src/me/Travja/HungerArena/Listeners/Boundaries.java
Normal file
@ -0,0 +1,78 @@
|
||||
package me.Travja.HungerArena.Listeners;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import me.Travja.HungerArena.Main;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class Boundaries implements Listener{
|
||||
public Main plugin;
|
||||
public Boundaries(Main m){
|
||||
this.plugin = m;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void boundsCheck(PlayerMoveEvent event){
|
||||
Player p = event.getPlayer();
|
||||
Boolean inGame = plugin.getArena(p) != null;
|
||||
Boolean spectating = plugin.isSpectating(p);
|
||||
if(plugin.config.getBoolean("WorldEdit"))
|
||||
if(insideBounds(p.getLocation()) && (inGame || spectating) || (!insideBounds(p.getLocation()) && inGame))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@EventHandler
|
||||
public void blockBounds(BlockBreakEvent event){
|
||||
Player p = event.getPlayer();
|
||||
if(plugin.getArena(p)== null)
|
||||
if(plugin.config.getBoolean("WorldEdit"))
|
||||
if(insideBounds(event.getBlock().getLocation())){
|
||||
p.sendMessage(ChatColor.RED + "That block is protected by HungerArena!");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
public boolean insideBounds(Location l){
|
||||
Location minl = null;
|
||||
Location maxl = null;
|
||||
if(plugin.spawns.get("Arena")!= null){
|
||||
Map<String, Object> temp = plugin.spawns.getConfigurationSection("Arena").getValues(false);
|
||||
for(Entry<String, Object> entry: temp.entrySet()){
|
||||
if(plugin.spawns.getConfigurationSection("Arena." + entry.getKey())!= null){
|
||||
String[] min = ((String) plugin.spawns.get("Arena." + entry.getKey()) + ".Min").split(",");
|
||||
String[] max = ((String) plugin.spawns.get("Arena." + entry.getKey()) + ".Max").split(",");
|
||||
try{
|
||||
World world = Bukkit.getWorld(min[0]);
|
||||
double x = Double.parseDouble(min[1]);
|
||||
double y = Double.parseDouble(min[2]);
|
||||
double z = Double.parseDouble(min[3]);
|
||||
minl = new Location(world, x, y, z);
|
||||
World world2 = Bukkit.getWorld(max[0]);
|
||||
double x2 = Double.parseDouble(max[1]);
|
||||
double y2 = Double.parseDouble(max[2]);
|
||||
double z2 = Double.parseDouble(max[3]);
|
||||
minl = new Location(world2, x2, y2, z2);
|
||||
}catch(Exception e){
|
||||
System.out.println(e);
|
||||
return false;
|
||||
}
|
||||
if(minl!= null && maxl!= null){
|
||||
return l.getX() >= minl.getBlockX()
|
||||
&& l.getX() < maxl.getBlockX() + 1 && l.getY() >= minl.getBlockY()
|
||||
&& l.getY() < maxl.getBlockY() + 1 && l.getZ() >= minl.getBlockZ()
|
||||
&& l.getZ() < maxl.getBlockZ() + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
package me.Travja.HungerArena;
|
||||
package me.Travja.HungerArena.Listeners;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import me.Travja.HungerArena.Main;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
282
src/me/Travja/HungerArena/Listeners/DeathListener.java
Normal file
282
src/me/Travja/HungerArena/Listeners/DeathListener.java
Normal file
@ -0,0 +1,282 @@
|
||||
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.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;
|
||||
|
||||
public class DeathListener implements Listener{
|
||||
public Main plugin;
|
||||
public DeathListener(Main m){
|
||||
this.plugin = m;
|
||||
}
|
||||
public FileConfiguration config;
|
||||
int i = 0;
|
||||
int a = 0;
|
||||
@EventHandler (priority = EventPriority.HIGHEST)
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event){
|
||||
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...)
|
||||
String ThisWorld = p.getWorld().getName();
|
||||
int z=0;
|
||||
for(z = 1; z <= plugin.worldsNames.size(); z++){
|
||||
if(plugin.worldsNames.get(z)!= null){
|
||||
if (plugin.worldsNames.get(z).equals(ThisWorld)){
|
||||
a=z; // now 'a' is the arenanumber of THIS(current) map
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//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
|
||||
plugin.Dead.get(i).clear();
|
||||
}
|
||||
}
|
||||
|
||||
//Jeppa: respawn per needInv!
|
||||
for(i = 0; i < plugin.needInv.size(); i++){
|
||||
if(plugin.needInv.contains(pname)){
|
||||
RespawnDeadPlayer(p,a);
|
||||
}
|
||||
}
|
||||
}
|
||||
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...???
|
||||
World spawnw = plugin.getServer().getWorld(Spawncoords[3]);
|
||||
double spawnx = Double.parseDouble(Spawncoords[0]);
|
||||
double spawny = Double.parseDouble(Spawncoords[1]);
|
||||
double spawnz = Double.parseDouble(Spawncoords[2]);
|
||||
final Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||
public void run(){
|
||||
player.teleport(Spawn);
|
||||
//Jeppa: restore inv
|
||||
plugin.RestoreInv(player, player.getName()); // Jeppa: call for restore inventory of leaving player!!
|
||||
}
|
||||
}, 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)
|
||||
public void onPlayerDeath(PlayerDeathEvent event){
|
||||
Player p = event.getEntity();
|
||||
Server s = p.getServer();
|
||||
String pname = p.getName();
|
||||
if(plugin.getArena(p)!= null){
|
||||
a = plugin.getArena(p);
|
||||
int players = plugin.Playing.get(a).size()-1;
|
||||
String leftmsg = null;
|
||||
clearInv(p);
|
||||
p.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
|
||||
plugin.scoreboards.remove(p.getName());
|
||||
if(!plugin.Frozen.get(a).isEmpty()){
|
||||
if(plugin.Frozen.get(a).contains(pname)){
|
||||
if(!(p.getKiller() instanceof Player)){
|
||||
players = plugin.Playing.get(a).size()-1;
|
||||
leftmsg = ChatColor.BLUE + "There are now " + players + " tributes left!";
|
||||
if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){
|
||||
double y = p.getLocation().getY();
|
||||
double newy = y+200;
|
||||
double x = p.getLocation().getX();
|
||||
double z = p.getLocation().getZ();
|
||||
Location strike = new Location(p.getWorld(), x, newy, z);
|
||||
p.getWorld().strikeLightning(strike);
|
||||
}
|
||||
event.setDeathMessage("");
|
||||
if(plugin.config.getBoolean("broadcastAll")){
|
||||
p.getServer().broadcastMessage(pname + ChatColor.LIGHT_PURPLE + " Stepped off their pedestal too early!");
|
||||
}else{
|
||||
for(String gn: plugin.Playing.get(a)){
|
||||
Player g = plugin.getServer().getPlayer(gn);
|
||||
g.sendMessage(pname + ChatColor.LIGHT_PURPLE + " Stepped off their pedestal too early!");
|
||||
}
|
||||
}
|
||||
plugin.Frozen.get(a).remove(pname);
|
||||
plugin.Playing.get(a).remove(pname);
|
||||
if(plugin.config.getBoolean("broadcastAll")){
|
||||
p.getServer().broadcastMessage(leftmsg);
|
||||
}else{
|
||||
for(String gn: plugin.Playing.get(a)){
|
||||
Player g = plugin.getServer().getPlayer(gn);
|
||||
g.sendMessage(leftmsg);
|
||||
}
|
||||
}
|
||||
plugin.winner(a);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
players = plugin.Playing.get(a).size()-1;
|
||||
leftmsg = ChatColor.BLUE + "There are now " + players + " tributes left!";
|
||||
if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){
|
||||
double y = p.getLocation().getY();
|
||||
double newy = y+200;
|
||||
double x = p.getLocation().getX();
|
||||
double z = p.getLocation().getZ();
|
||||
Location strike = new Location(p.getWorld(), x, newy, z);
|
||||
p.getWorld().strikeLightning(strike);
|
||||
}
|
||||
plugin.Dead.get(a).add(pname);
|
||||
plugin.Playing.get(a).remove(pname);
|
||||
if(p.getKiller() instanceof Player){
|
||||
if(p.getKiller().getItemInHand().getType().getId()== 0){
|
||||
Player killer = p.getKiller();
|
||||
String killername = killer.getName();
|
||||
event.setDeathMessage("");
|
||||
if(plugin.config.getBoolean("broadcastAll")){
|
||||
s.broadcastMessage(ChatColor.LIGHT_PURPLE + "**BOOM** Tribute " + pname + " was killed by tribute " + killername + " with their FIST!");
|
||||
s.broadcastMessage(leftmsg);
|
||||
}else{
|
||||
for(String gn: plugin.Playing.get(a)){
|
||||
Player g = plugin.getServer().getPlayer(gn);
|
||||
g.sendMessage(ChatColor.LIGHT_PURPLE + "**BOOM** Tribute " + pname + " was killed by tribute " + killername + " with their FIST!");
|
||||
g.sendMessage(leftmsg);
|
||||
}
|
||||
}
|
||||
if(plugin.Kills.containsKey(killername))
|
||||
plugin.Kills.put(killername, plugin.Kills.get(killername)+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 msg = ChatColor.LIGHT_PURPLE + "**BOOM** Tribute " + pname + " was killed by tribute " + killername + " with " + weapon;
|
||||
event.setDeathMessage("");
|
||||
if(plugin.config.getBoolean("broadcastAll")){
|
||||
s.broadcastMessage(msg);
|
||||
s.broadcastMessage(leftmsg);
|
||||
}else{
|
||||
for(String gn: plugin.Playing.get(a)){
|
||||
Player g = plugin.getServer().getPlayer(gn);
|
||||
g.sendMessage(msg);
|
||||
g.sendMessage(leftmsg);
|
||||
}
|
||||
}
|
||||
if(plugin.Kills.containsKey(killername))
|
||||
plugin.Kills.put(killername, plugin.Kills.get(killername)+1);
|
||||
plugin.winner(a);
|
||||
}
|
||||
}else{
|
||||
event.setDeathMessage("");
|
||||
if(plugin.config.getBoolean("broadcastAll")){
|
||||
s.broadcastMessage(ChatColor.LIGHT_PURPLE + pname + " died of natural causes!");
|
||||
s.broadcastMessage(leftmsg);
|
||||
}else{
|
||||
for(String gn: plugin.Playing.get(a)){
|
||||
Player g = plugin.getServer().getPlayer(gn);
|
||||
g.sendMessage(ChatColor.LIGHT_PURPLE + pname + " died of " + ChatColor.ITALIC + " probably " + ChatColor.LIGHT_PURPLE + "natural causes!");
|
||||
g.sendMessage(leftmsg);
|
||||
}
|
||||
}
|
||||
plugin.winner(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
private void clearInv(Player p){
|
||||
p.getInventory().clear();
|
||||
p.getInventory().setBoots(null);
|
||||
p.getInventory().setChestplate(null);
|
||||
p.getInventory().setHelmet(null);
|
||||
p.getInventory().setLeggings(null);
|
||||
p.updateInventory();
|
||||
}
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
package me.Travja.HungerArena;
|
||||
package me.Travja.HungerArena.Listeners;
|
||||
|
||||
import me.Travja.HungerArena.Main;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
105
src/me/Travja/HungerArena/Listeners/FreezeListener.java
Normal file
105
src/me/Travja/HungerArena/Listeners/FreezeListener.java
Normal file
@ -0,0 +1,105 @@
|
||||
package me.Travja.HungerArena.Listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import me.Travja.HungerArena.Main;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class FreezeListener implements Listener {
|
||||
public Main plugin;
|
||||
public FreezeListener(Main m) {
|
||||
this.plugin = m;
|
||||
}
|
||||
int i = 0;
|
||||
int a = 0;
|
||||
private HashMap<Integer, Boolean> timeUp= new HashMap<Integer, Boolean>();
|
||||
private ArrayList<Integer> timing = new ArrayList<Integer>();
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event){
|
||||
Player p = event.getPlayer();
|
||||
String pname = p.getName();
|
||||
if(plugin.getArena(p)!= null){
|
||||
a = plugin.getArena(p);
|
||||
if(plugin.Frozen.get(a).contains(pname) && plugin.config.getString("Frozen_Teleport").equalsIgnoreCase("True")){
|
||||
if(plugin.config.getString("Explode_on_Move").equalsIgnoreCase("true")){
|
||||
timeUp.put(a, false);
|
||||
for(String players: plugin.Playing.get(a)){
|
||||
Player playing = plugin.getServer().getPlayerExact(players);
|
||||
i = plugin.Playing.get(a).indexOf(players)+1;
|
||||
if(!timeUp.get(a) && !timing.contains(a)){
|
||||
timing.add(a);
|
||||
if(!playing.getLocation().getBlock().getLocation().equals(plugin.location.get(a).get(i).getBlock().getLocation())){
|
||||
playing.teleport(plugin.location.get(a).get(i));
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||
public void run(){
|
||||
if(!timeUp.get(a)){
|
||||
timeUp.put(a, true);
|
||||
timing.remove(a);
|
||||
}
|
||||
}
|
||||
},30L);
|
||||
}
|
||||
}else{
|
||||
if(!playing.getLocation().getBlock().getLocation().equals(plugin.location.get(a).get(i).getBlock().getLocation())){
|
||||
if(!plugin.Dead.get(a).contains(playing.getName())){
|
||||
plugin.Dead.get(a).add(playing.getName());
|
||||
World world = playing.getLocation().getWorld();
|
||||
world.createExplosion(playing.getLocation(), 0.0F, false);
|
||||
playing.setHealth(0.0D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(plugin.Dead.get(a).contains(pname) && plugin.Playing.get(a).contains(pname)){
|
||||
int players = plugin.Playing.get(a).size()-1;
|
||||
String leftmsg = ChatColor.BLUE + "There are now " + players + " tributes left!";
|
||||
if(plugin.config.getString("Cannon_Death").equalsIgnoreCase("True")){
|
||||
double y = p.getLocation().getY();
|
||||
double newy = y+200;
|
||||
double x = p.getLocation().getX();
|
||||
double z = p.getLocation().getZ();
|
||||
Location strike = new Location(p.getWorld(), x, newy, z);
|
||||
p.getWorld().strikeLightning(strike);
|
||||
}
|
||||
if(plugin.config.getBoolean("broadcastAll")){
|
||||
p.getServer().broadcastMessage(pname + ChatColor.LIGHT_PURPLE + " Stepped off their pedestal too early!");
|
||||
}else{
|
||||
for(String gn: plugin.Playing.get(a)){
|
||||
Player g = plugin.getServer().getPlayer(gn);
|
||||
g.sendMessage(pname + ChatColor.LIGHT_PURPLE + " Stepped off their pedestal too early!");
|
||||
}
|
||||
}
|
||||
plugin.Frozen.get(a).remove(pname);
|
||||
plugin.Playing.get(a).remove(pname);
|
||||
if(plugin.config.getBoolean("broadcastAll")){
|
||||
p.getServer().broadcastMessage(leftmsg);
|
||||
}else{
|
||||
for(String gn: plugin.Playing.get(a)){
|
||||
Player g = plugin.getServer().getPlayer(gn);
|
||||
g.sendMessage(leftmsg);
|
||||
}
|
||||
}
|
||||
plugin.winner(a);
|
||||
}
|
||||
}else{
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,7 @@
|
||||
package me.Travja.HungerArena;
|
||||
package me.Travja.HungerArena.Listeners;
|
||||
|
||||
import me.Travja.HungerArena.HaCommands;
|
||||
import me.Travja.HungerArena.Main;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -9,6 +12,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
|
||||
public class JoinAndQuitListener implements Listener {
|
||||
public Main plugin;
|
||||
@ -21,6 +25,7 @@ public class JoinAndQuitListener implements Listener {
|
||||
}
|
||||
int i = 0;
|
||||
int a = 0;
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent evt) {
|
||||
Player p = evt.getPlayer();
|
||||
@ -32,6 +37,7 @@ public class JoinAndQuitListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event){
|
||||
final Player p = event.getPlayer();
|
||||
@ -57,7 +63,7 @@ public class JoinAndQuitListener implements Listener {
|
||||
}
|
||||
for(i = 1; i <= plugin.Quit.size(); i++){
|
||||
if(plugin.Quit.get(i).contains(pname)){
|
||||
String[] Spawncoords = plugin.spawns.getString("Spawn_coords").split(",");
|
||||
String[] Spawncoords = plugin.spawns.getString("Spawn_coords_"+i).split(","); // Jeppa: move the player where he belongs....
|
||||
String w = Spawncoords[3];
|
||||
World spawnw = plugin.getServer().getWorld(w);
|
||||
double spawnx = Double.parseDouble(Spawncoords[0]);
|
||||
@ -67,16 +73,17 @@ public class JoinAndQuitListener implements Listener {
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||
public void run(){
|
||||
p.teleport(Spawn);
|
||||
p.sendMessage(ChatColor.RED + "You have been teleported to spawn because you quit/forfeited!");
|
||||
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
|
||||
}
|
||||
}, 40L);
|
||||
plugin.Quit.get(i).remove(pname); //Jeppa: fix
|
||||
pfound = true;
|
||||
}
|
||||
}
|
||||
for(i = 1; i <= plugin.Dead.size(); i++){
|
||||
if(plugin.Dead.get(i).contains(pname)){
|
||||
String[] Spawncoords = plugin.spawns.getString("Spawn_coords").split(",");
|
||||
String[] Spawncoords = plugin.spawns.getString("Spawn_coords_"+i).split(","); // Jeppa: move the player where he belongs....
|
||||
String w = Spawncoords[3];
|
||||
World spawnw = plugin.getServer().getWorld(w);
|
||||
double spawnx = Double.parseDouble(Spawncoords[0]);
|
||||
@ -86,17 +93,18 @@ public class JoinAndQuitListener implements Listener {
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||
public void run(){
|
||||
p.teleport(Spawn);
|
||||
p.sendMessage(ChatColor.RED + "You have been teleported to spawn because you quit/forfeited!!");
|
||||
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...
|
||||
}
|
||||
}, 40L);
|
||||
plugin.Dead.get(i).remove(pname); //Jeppa: fix
|
||||
pfound = true;
|
||||
}
|
||||
}
|
||||
for(i = 1; i <= plugin.inArena.size(); i++){
|
||||
if(plugin.inArena.get(i)!= null){
|
||||
if(plugin.inArena.get(i).contains(pname)){
|
||||
String[] Spawncoords = plugin.spawns.getString("Spawn_coords").split(",");
|
||||
String[] Spawncoords = plugin.spawns.getString("Spawn_coords_"+i).split(","); // Jeppa: move the player where he belongs....
|
||||
String w = Spawncoords[3];
|
||||
World spawnw = plugin.getServer().getWorld(w);
|
||||
double spawnx = Double.parseDouble(Spawncoords[0]);
|
||||
@ -113,32 +121,34 @@ 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
|
||||
}
|
||||
}, 40L);
|
||||
plugin.inArena.get(i).remove(pname); //Jeppa: fix
|
||||
pfound = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
//Jeppa: New routine to check if the player reconnected and is unknown to the server!
|
||||
//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(",");
|
||||
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...)
|
||||
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.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||
public void run(){
|
||||
p.teleport(Spawn);
|
||||
p.sendMessage(ChatColor.RED + "You have been teleported to spawn !!");
|
||||
p.sendMessage(ChatColor.RED + "You have been teleported to spawn!!");
|
||||
}
|
||||
}, 40L);
|
||||
}
|
||||
}
|
||||
//^^
|
||||
//^^
|
||||
|
||||
}
|
||||
@EventHandler
|
||||
@ -148,7 +158,7 @@ public class JoinAndQuitListener implements Listener {
|
||||
for(i = 1; i <= plugin.Frozen.size(); i++){
|
||||
if (plugin.Frozen.get(i).contains(pname)) {
|
||||
plugin.Frozen.remove(pname);
|
||||
String[] Spawncoords = plugin.spawns.getString("Spawn_coords").split(",");
|
||||
String[] Spawncoords = plugin.spawns.getString("Spawn_coords").split(",");
|
||||
String w = Spawncoords[3];
|
||||
World spawnw = plugin.getServer().getWorld(w);
|
||||
double spawnx = Double.parseDouble(Spawncoords[0]);
|
||||
@ -156,24 +166,34 @@ public class JoinAndQuitListener implements Listener {
|
||||
double spawnz = Double.parseDouble(Spawncoords[2]);
|
||||
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 onPlayerQuit(PlayerQuitEvent event){
|
||||
public void onPlayerQuit(PlayerQuitEvent event){ // delay zum setzen ob Player in der Arena bleibt oder fliegt bei disconnect...
|
||||
final Player p = event.getPlayer();
|
||||
final String pname = p.getName();
|
||||
if(plugin.getArena(p)!= null){
|
||||
a = plugin.getArena(p);
|
||||
plugin.Out.get(a).add(pname);
|
||||
plugin.Playing.get(a).remove(pname);
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){ // Jeppa: how long is this delay?
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||
public void run(){
|
||||
if(plugin.Out.get(a).contains(pname)){
|
||||
plugin.Quit.get(a).add(pname);
|
||||
plugin.Out.get(a).remove(pname); //Jeppa: fix
|
||||
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());
|
||||
plugin.winner(a);
|
||||
plugin.inArena.get(a).add(pname); //Jeppa: add him to Quit and to inArena ?
|
||||
plugin.inArena.get(a).add(pname);
|
||||
}else if(plugin.getArena(p)== null){
|
||||
plugin.Quit.get(a).add(pname);
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
package me.Travja.HungerArena;
|
||||
package me.Travja.HungerArena.Listeners;
|
||||
|
||||
import me.Travja.HungerArena.Main;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -29,6 +31,11 @@ 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){
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(plugin.getArena(p)!= null){
|
||||
@ -51,14 +58,23 @@ public class PvP implements Listener {
|
||||
if(plugin.getArena(p) != null){
|
||||
Player shooter = (Player) projectile.getShooter();
|
||||
if(plugin.getArena(shooter)!= null){
|
||||
event.setCancelled(false);
|
||||
if(plugin.gp.get(plugin.getArena(p))!= null)
|
||||
if(plugin.gp.get(plugin.getArena(p))!= 0)
|
||||
event.setCancelled(true);
|
||||
else
|
||||
event.setCancelled(false);
|
||||
}
|
||||
}
|
||||
}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???
|
||||
if(e instanceof Skeleton){
|
||||
if(plugin.getArena(p)!= null){
|
||||
event.setCancelled(false);
|
||||
if(plugin.gp.get(plugin.getArena((Player) e))!= null)
|
||||
if(plugin.gp.get(plugin.getArena(p))!= 0)
|
||||
event.setCancelled(true);
|
||||
else
|
||||
event.setCancelled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -67,9 +83,10 @@ public class PvP implements Listener {
|
||||
@EventHandler
|
||||
public void PlayerDamage(EntityDamageEvent event){
|
||||
Entity e = event.getEntity();
|
||||
if(e instanceof Player){
|
||||
if(plugin.gp!= 0)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
package me.Travja.HungerArena;
|
||||
package me.Travja.HungerArena.Listeners;
|
||||
|
||||
import me.Travja.HungerArena.Main;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
@ -1,4 +1,6 @@
|
||||
package me.Travja.HungerArena;
|
||||
package me.Travja.HungerArena.Listeners;
|
||||
|
||||
import me.Travja.HungerArena.Main;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -13,6 +15,7 @@ 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.scoreboard.DisplaySlot;
|
||||
|
||||
public class SpectatorListener implements Listener {
|
||||
public Main plugin;
|
||||
@ -84,6 +87,14 @@ public class SpectatorListener implements Listener {
|
||||
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(i = 0; i < plugin.Playing.size(); i++){
|
||||
if(plugin.Playing.get(i)!= null){
|
||||
if(plugin.Playing.get(i).contains(attackerName)){
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -97,6 +108,14 @@ public class SpectatorListener implements Listener {
|
||||
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(i = 0; i < plugin.Playing.size(); i++){
|
||||
if(plugin.Playing.get(i)!= null){
|
||||
if(plugin.Playing.get(i).contains(bowManName)){
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -145,6 +164,11 @@ public class SpectatorListener implements Listener {
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
package me.Travja.HungerArena;
|
||||
package me.Travja.HungerArena.Listeners;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import me.Travja.HungerArena.Main;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
49
src/me/Travja/HungerArena/Listeners/spawnsListener.java
Normal file
49
src/me/Travja/HungerArena/Listeners/spawnsListener.java
Normal file
@ -0,0 +1,49 @@
|
||||
package me.Travja.HungerArena.Listeners;
|
||||
|
||||
import me.Travja.HungerArena.Main;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
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.player.PlayerInteractEvent;
|
||||
|
||||
public class spawnsListener implements Listener{
|
||||
public Main plugin;
|
||||
public spawnsListener(Main m){
|
||||
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[] 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()
|
||||
|
||||
//Jeppa: Hier das Command anpassen!!!??? oder die Daten vorher bearbeiten die übergeben werden? ->done
|
||||
//p.sendMessage(ChatColor.DARK_AQUA + "[ÜbergebeneWerte:] " + ChatColor.RED + "Setting For Arena " + info[0] + " Starting From Point " + info[1]);
|
||||
//p.sendMessage(ChatColor.DARK_AQUA + "[ÜbergebeneWerte:] " + ChatColor.RED + "Coords: " + coords);
|
||||
|
||||
p.performCommand("startpoint " + info[0] + " " + info[1] + " " + coords);
|
||||
|
||||
if(Integer.parseInt(info[1])>= plugin.config.getInt("maxPlayers")){
|
||||
p.sendMessage(ChatColor.DARK_AQUA + "[HungerArena] " + ChatColor.RED + "All spawns set!");
|
||||
plugin.setting.remove(p.getName());
|
||||
}else{
|
||||
plugin.setting.put(p.getName(), info[0] + "-" + (Integer.parseInt(info[1])+1));
|
||||
p.sendMessage(ChatColor.DARK_AQUA + "[HungerArena] " + ChatColor.RED + "Next starting point: " + (Integer.parseInt(info[1])+1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -8,45 +8,79 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import me.Travja.HungerArena.Listeners.BlockStorage;
|
||||
import me.Travja.HungerArena.Listeners.Boundaries;
|
||||
import me.Travja.HungerArena.Listeners.ChatListener;
|
||||
import me.Travja.HungerArena.Listeners.DeathListener;
|
||||
import me.Travja.HungerArena.Listeners.DmgListener;
|
||||
import me.Travja.HungerArena.Listeners.FreezeListener;
|
||||
import me.Travja.HungerArena.Listeners.JoinAndQuitListener;
|
||||
import me.Travja.HungerArena.Listeners.PvP;
|
||||
import me.Travja.HungerArena.Listeners.Signs;
|
||||
import me.Travja.HungerArena.Listeners.SpectatorListener;
|
||||
import me.Travja.HungerArena.Listeners.TeleportListener;
|
||||
import me.Travja.HungerArena.Listeners.spawnsListener;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Firework;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.FireworkMeta;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Score;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
|
||||
public class Main extends JavaPlugin{
|
||||
static Logger log;
|
||||
public HashMap<Integer, List<String>> Playing = new HashMap<Integer, List<String>>();
|
||||
public HashMap<Integer, List<String>> Ready = new HashMap<Integer, List<String>>();
|
||||
public HashMap<Integer, List<String>> Dead = new HashMap<Integer, List<String>>();
|
||||
public HashMap<Integer, String> MatchRunning = new HashMap<Integer, String>(); // Jeppa: Marker for the running arenas
|
||||
public HashMap<Integer, List<String>> Quit = new HashMap<Integer, List<String>>();
|
||||
public HashMap<Integer, List<String>> Out = new HashMap<Integer, List<String>>();
|
||||
public HashMap<Integer, List<String>> Watching = new HashMap<Integer, List<String>>();
|
||||
public HashMap<String, Integer> Kills = new HashMap<String, Integer>();
|
||||
public HashMap<Integer, List<String>> NeedConfirm = new HashMap<Integer, List<String>>();
|
||||
public HashMap<Integer, HashMap<Integer, Location>> location = new HashMap<Integer, HashMap<Integer, Location>>();
|
||||
public ArrayList<Player> Tele = new ArrayList<Player>();
|
||||
public HashMap<Integer, List<String>> inArena = new HashMap<Integer, List<String>>();
|
||||
public HashMap<Integer, List<String>> Frozen = new HashMap<Integer, List<String>>();
|
||||
public HashMap<Integer, List<String>> arena = new HashMap<Integer, List<String>>();
|
||||
public HashMap<Integer, Boolean> canjoin = new HashMap<Integer, Boolean>();
|
||||
public HashMap<Integer, Integer> maxPlayers = new HashMap<Integer, Integer>();
|
||||
public HashMap<Integer, Boolean> open = new HashMap<Integer, Boolean>();
|
||||
public List<String> worlds;
|
||||
public HashMap<String, String> setting = new HashMap<String, String>();
|
||||
public HashMap<Integer, Integer> gp = new HashMap<Integer, Integer>();
|
||||
public ArrayList<Player> Tele = new ArrayList<Player>();
|
||||
public ArrayList<String> needInv = new ArrayList<String>();// Jeppa: this is used as a marker now for players that joined an arena (for respawning and restoring inv)
|
||||
public List<String> worlds = new ArrayList<String>();
|
||||
public HashMap<Integer, String> worldsNames = new HashMap<Integer, String>(); //Jeppa: for storing the worlds names ...
|
||||
|
||||
public HashMap<String, Scoreboard> scoreboards = new HashMap<String, Scoreboard>();
|
||||
|
||||
public Listener DeathListener = new DeathListener(this);
|
||||
public Listener SpectatorListener = new SpectatorListener(this);
|
||||
public Listener FreezeListener = new FreezeListener(this);
|
||||
@ -60,11 +94,18 @@ public class Main extends JavaPlugin{
|
||||
public Listener Signs = new Signs(this);
|
||||
public Listener BlockStorage = new BlockStorage(this);
|
||||
public Listener WinGames = new WinGamesListener(this);
|
||||
public Listener WorldChange = new WorldChange(this);
|
||||
public Listener Boundaries = new Boundaries(this);
|
||||
public Listener spawnsListener = new spawnsListener(this);
|
||||
public CommandExecutor HaCommands = new HaCommands(this);
|
||||
public CommandExecutor SponsorCommands = new SponsorCommands(this);
|
||||
public CommandExecutor SpawnsCommand = new SpawnsCommand(this);
|
||||
|
||||
public me.Travja.HungerArena.ConfigManager ConfigManager = new ConfigManager(this);
|
||||
|
||||
public boolean exists;
|
||||
public boolean restricted;
|
||||
|
||||
public FileConfiguration config;
|
||||
public FileConfiguration spawns = null;
|
||||
public File spawnsFile = null;
|
||||
@ -79,34 +120,42 @@ public class Main extends JavaPlugin{
|
||||
public ArrayList<ItemStack> Reward = new ArrayList<ItemStack>();
|
||||
public ArrayList<ItemStack> Cost = new ArrayList<ItemStack>();
|
||||
public ArrayList<ItemStack> Fee = new ArrayList<ItemStack>();
|
||||
|
||||
public boolean vault = false;
|
||||
public boolean eco = false;
|
||||
public Economy econ = null;
|
||||
|
||||
int i = 0;
|
||||
int v = 0;
|
||||
int start = 0;
|
||||
int deathtime = 0;
|
||||
int timetodeath = 0;
|
||||
int a = 0;
|
||||
public int gp = 0;
|
||||
int grace = 0;
|
||||
//int grace = 0; //Jeppa: it's no int anymore
|
||||
//int start = 0; //Jeppa: it's not int anymore...
|
||||
File PFilePath = new File(getDataFolder(), "/inventories");
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onEnable(){
|
||||
log = this.getLogger();
|
||||
|
||||
config = this.getConfig();
|
||||
config.options().copyDefaults(true);
|
||||
this.saveDefaultConfig();
|
||||
if(!new File(this.getDataFolder(), "config.yml").exists())
|
||||
this.saveDefaultConfig();
|
||||
spawns = this.getSpawns();
|
||||
spawns.options().copyDefaults(true);
|
||||
this.saveSpawns();
|
||||
if(!new File(this.getDataFolder(), "spawns.yml").exists())
|
||||
this.saveSpawns();
|
||||
data = this.getData();
|
||||
data.options().copyDefaults(true);
|
||||
this.saveData();
|
||||
if(!new File(this.getDataFolder(), "Data.yml").exists())
|
||||
this.saveData();
|
||||
management = this.getManagement();
|
||||
management.options().copyDefaults(true);
|
||||
this.saveManagement();
|
||||
if(!new File(this.getDataFolder(), "commandAndBlockManagement.yml").exists())
|
||||
this.saveManagement();
|
||||
MyChests = this.getChests();
|
||||
MyChests.options().copyDefaults(true);
|
||||
this.saveChests();
|
||||
if(!new File(this.getDataFolder(), "Chests.yml").exists())
|
||||
this.saveChests();
|
||||
getServer().getPluginManager().registerEvents(DeathListener, this);
|
||||
getServer().getPluginManager().registerEvents(SpectatorListener, this);
|
||||
getServer().getPluginManager().registerEvents(FreezeListener, this);
|
||||
@ -119,52 +168,29 @@ public class Main extends JavaPlugin{
|
||||
getServer().getPluginManager().registerEvents(BlockStorage, this);
|
||||
getServer().getPluginManager().registerEvents(WinGames, this);
|
||||
getServer().getPluginManager().registerEvents(Damage, this);
|
||||
getServer().getPluginManager().registerEvents(WorldChange, this);
|
||||
getServer().getPluginManager().registerEvents(Boundaries, this);
|
||||
getServer().getPluginManager().registerEvents(spawnsListener, this);
|
||||
|
||||
getCommand("Ha").setExecutor(HaCommands);
|
||||
getCommand("Sponsor").setExecutor(SponsorCommands);
|
||||
getCommand("Startpoint").setExecutor(SpawnsCommand);
|
||||
|
||||
// Jeppa: create path if not exists
|
||||
if (!PFilePath.exists()) {
|
||||
PFilePath.mkdirs();
|
||||
}
|
||||
for(File file: PFilePath.listFiles()){ // Jeppa: use changed path
|
||||
String filename = file.getName();
|
||||
int lastIndex = filename.lastIndexOf('.');
|
||||
filename = filename.substring(0, lastIndex >= 0 ? lastIndex : 0); //Jeppa: remove .yml from filename
|
||||
needInv.add(filename); // Mark player as "lost child" :)
|
||||
}
|
||||
|
||||
i = 1;
|
||||
if(spawns.getConfigurationSection("Spawns")!= null){
|
||||
Map<String, Object> temp = spawns.getConfigurationSection("Spawns").getValues(false);
|
||||
for(Entry<String, Object> entry: temp.entrySet()){
|
||||
if(spawns.getConfigurationSection("Spawns." + entry.getKey())!= null){
|
||||
Map<String, Object> temp2 = spawns.getConfigurationSection("Spawns." + entry.getKey()).getValues(false);
|
||||
for(Map.Entry<String, Object> e: temp2.entrySet()){
|
||||
if(spawns.get("Spawns." + entry.getKey() + "." + e.getKey())!= null){
|
||||
String[] coords = ((String) spawns.get("Spawns." + entry.getKey() + "." + e.getKey())).split(",");
|
||||
Integer a = Integer.parseInt(entry.getKey());
|
||||
Integer s = Integer.parseInt(e.getKey());
|
||||
if(location.get(a)== null)
|
||||
location.put(a, new HashMap<Integer, Location>());
|
||||
log.info("Added spawn number " + s + " in arena " + a + "!");
|
||||
location.get(a).put(s, new Location(getServer().getWorld(coords[0]), Double.parseDouble(coords[1]), Double.parseDouble(coords[2]), Double.parseDouble(coords[3])));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(i = 1; i <= location.size(); i++){
|
||||
log.info("Loaded " + location.get(i).size() + " tribute spawns for arena " + i + "!");
|
||||
Playing.put(i, new ArrayList<String>());
|
||||
Ready.put(i, new ArrayList<String>());
|
||||
Dead.put(i, new ArrayList<String>());
|
||||
Quit.put(i, new ArrayList<String>());
|
||||
Out.put(i, new ArrayList<String>());
|
||||
Watching.put(i, new ArrayList<String>());
|
||||
NeedConfirm.put(i, new ArrayList<String>());
|
||||
inArena.put(i, new ArrayList<String>());
|
||||
Frozen.put(i, new ArrayList<String>());
|
||||
arena.put(i, new ArrayList<String>());
|
||||
canjoin.put(i, false);
|
||||
if(location.get(i).size()== config.getInt("maxPlayers")){
|
||||
maxPlayers.put(i, location.get(i).size());
|
||||
}else if(location.size()< config.getInt("maxPlayers")){
|
||||
maxPlayers.put(i, location.get(i).size());
|
||||
}else if(location.size()> config.getInt("maxPlayers")){
|
||||
maxPlayers.put(i, config.getInt("maxPlayers"));
|
||||
}
|
||||
log.info("Max players is for arena " + i + " is " + maxPlayers.get(i));
|
||||
open.put(i, true);
|
||||
}
|
||||
|
||||
this.reloadSpawnpoints(); //Jeppa: loading of spawnpoints and fill of areas now moved to subroutine...
|
||||
|
||||
if (setupEconomy()) {
|
||||
log.info("Found Vault! Hooking in for economy!");
|
||||
}
|
||||
@ -210,6 +236,8 @@ public class Main extends JavaPlugin{
|
||||
}else if(!worlds.isEmpty()){
|
||||
restricted = true;
|
||||
}
|
||||
ConfigManager.setup();
|
||||
scoreboardInit();
|
||||
log.info("Enabled v" + getDescription().getVersion());
|
||||
}
|
||||
|
||||
@ -217,6 +245,85 @@ public class Main extends JavaPlugin{
|
||||
log.info("Disabled v" + getDescription().getVersion());
|
||||
}
|
||||
|
||||
//Jeppa: routine to reload the spawns and fill arrays as subroutine... will be needed elsewhere...
|
||||
public void reloadSpawnpoints(){
|
||||
if(spawns.getConfigurationSection("Spawns")!= null){
|
||||
Map<String, Object> temp = spawns.getConfigurationSection("Spawns").getValues(false);
|
||||
for(Entry<String, Object> entry: temp.entrySet()){
|
||||
if(spawns.getConfigurationSection("Spawns." + entry.getKey())!= null){
|
||||
Integer a = Integer.parseInt(entry.getKey());
|
||||
worldsNames.put(a, "none_meening_this_is_not_a_map"); // Jeppa: placeholder
|
||||
if(location.get(a)== null) location.put(a, new HashMap<Integer, Location>()); // Jeppa: this was only set when real spawnpoints were found.. now we need it to get things work...
|
||||
Map<String, Object> temp2 = spawns.getConfigurationSection("Spawns." + entry.getKey()).getValues(false);
|
||||
for(Map.Entry<String, Object> e: temp2.entrySet()){
|
||||
if(spawns.get("Spawns." + entry.getKey() + "." + e.getKey())!= null){
|
||||
if(!e.getKey().equals("Max") || !e.getKey().equals("Min")){
|
||||
String[] coords = ((String) spawns.get("Spawns." + entry.getKey() + "." + e.getKey())).split(",");
|
||||
Integer s = Integer.parseInt(e.getKey());
|
||||
log.info("Added spawn number " + s + " in arena " + a + "!");
|
||||
location.get(a).put(s, new Location(getServer().getWorld(coords[0]), Double.parseDouble(coords[1]), Double.parseDouble(coords[2]), Double.parseDouble(coords[3])));
|
||||
worldsNames.put(a, coords[0]); // Jeppa: remember arena# and name...!
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(i = 1; i <= location.size(); i++){ //Jeppa: location is arenanumber now!! Count can be changed in defaultconfig !!
|
||||
if(location.get(i).size()!= 0){
|
||||
log.info("Loaded " + location.get(i).size() + " tribute spawns for arena " + i + "!");
|
||||
Playing.put(i, new ArrayList<String>());
|
||||
Ready.put(i, new ArrayList<String>());
|
||||
Dead.put(i, new ArrayList<String>());
|
||||
MatchRunning.put(i, null);
|
||||
Quit.put(i, new ArrayList<String>());
|
||||
Out.put(i, new ArrayList<String>());
|
||||
Watching.put(i, new ArrayList<String>());
|
||||
NeedConfirm.put(i, new ArrayList<String>());
|
||||
inArena.put(i, new ArrayList<String>());
|
||||
Frozen.put(i, new ArrayList<String>());
|
||||
arena.put(i, new ArrayList<String>());
|
||||
canjoin.put(i, false);
|
||||
if(location.get(i).size()== config.getInt("maxPlayers")){
|
||||
maxPlayers.put(i, location.get(i).size());
|
||||
}else if(location.size()< config.getInt("maxPlayers")){
|
||||
maxPlayers.put(i, location.get(i).size());
|
||||
}else if(location.size()> config.getInt("maxPlayers")){
|
||||
maxPlayers.put(i, config.getInt("maxPlayers"));
|
||||
}
|
||||
log.info("Max players is for arena " + i + " is " + maxPlayers.get(i));
|
||||
open.put(i, true);
|
||||
}else{ // Jeppa: this maps/arenas are unused... but still they need some values :( (it's a bugfix for some 'for'-loops..) -> usable arenas 1 - 20 with the new default configuration-file! if more are needed they must count up.. 21 22...
|
||||
//log.info("If you miss some arenas, f.e. arena #" + i + " make sure arenas are numbered 1 to n !");
|
||||
log.info("Arena #" + i + " is unused and has no spawns !");
|
||||
Playing.put(i, new ArrayList<String>());
|
||||
Ready.put(i, new ArrayList<String>());
|
||||
Dead.put(i, new ArrayList<String>());
|
||||
MatchRunning.put(i, null);
|
||||
Quit.put(i, new ArrayList<String>());
|
||||
Out.put(i, new ArrayList<String>());
|
||||
Watching.put(i, new ArrayList<String>());
|
||||
NeedConfirm.put(i, new ArrayList<String>());
|
||||
inArena.put(i, new ArrayList<String>());
|
||||
Frozen.put(i, new ArrayList<String>());
|
||||
arena.put(i, new ArrayList<String>());
|
||||
canjoin.put(i, false); // false = free, true = game in action..
|
||||
maxPlayers.put(i, 0);
|
||||
open.put(i, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public WorldEditPlugin hookWE() {
|
||||
Plugin wPlugin = getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
|
||||
if ((wPlugin == null) || (!(wPlugin instanceof WorldEditPlugin)))
|
||||
return null;
|
||||
|
||||
return (WorldEditPlugin) wPlugin;
|
||||
}
|
||||
|
||||
public boolean setupEconomy() {
|
||||
if (getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||
return false;
|
||||
@ -235,7 +342,6 @@ public class Main extends JavaPlugin{
|
||||
}
|
||||
spawns = YamlConfiguration.loadConfiguration(spawnsFile);
|
||||
|
||||
// Look for defaults in the jar
|
||||
InputStream defConfigStream = this.getResource("spawns.yml");
|
||||
if (defConfigStream != null) {
|
||||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
|
||||
@ -264,7 +370,6 @@ public class Main extends JavaPlugin{
|
||||
}
|
||||
data = YamlConfiguration.loadConfiguration(dataFile);
|
||||
|
||||
// Look for defaults in the jar
|
||||
InputStream defConfigStream = this.getResource("Data.yml");
|
||||
if (defConfigStream != null) {
|
||||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
|
||||
@ -293,7 +398,6 @@ public class Main extends JavaPlugin{
|
||||
}
|
||||
management = YamlConfiguration.loadConfiguration(managementFile);
|
||||
|
||||
// Look for defaults in the jar
|
||||
InputStream defConfigStream = this.getResource("commandAndBlockManagement.yml");
|
||||
if (defConfigStream != null) {
|
||||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
|
||||
@ -316,19 +420,11 @@ public class Main extends JavaPlugin{
|
||||
this.getLogger().log(Level.SEVERE, "Could not save config to " + managementFile, ex);
|
||||
}
|
||||
}
|
||||
//Jeppa: Add routine like the others for loading Chests with their very own file..
|
||||
public void reloadChests() {
|
||||
if (ChestsFile == null) {
|
||||
ChestsFile = new File(getDataFolder(), "Chests.yml");
|
||||
}
|
||||
MyChests = YamlConfiguration.loadConfiguration(ChestsFile);
|
||||
|
||||
// Look for defaults in the jar
|
||||
InputStream defConfigStream = this.getResource("Chests.yml");
|
||||
if (defConfigStream != null) {
|
||||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
|
||||
MyChests.setDefaults(defConfig);
|
||||
}
|
||||
}
|
||||
public FileConfiguration getChests() {
|
||||
if (MyChests == null) {
|
||||
@ -346,95 +442,438 @@ public class Main extends JavaPlugin{
|
||||
this.getLogger().log(Level.SEVERE, "Could not save config to " + ChestsFile, ex);
|
||||
}
|
||||
}
|
||||
//^^
|
||||
public void winner(final Integer a){
|
||||
String[] Spawncoords = spawns.getString("Spawn_coords").split(",");
|
||||
World spawnw = getServer().getWorld(Spawncoords[3]);
|
||||
double spawnx = Double.parseDouble(Spawncoords[0]);
|
||||
double spawny = Double.parseDouble(Spawncoords[1]);
|
||||
double spawnz = Double.parseDouble(Spawncoords[2]);
|
||||
Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
|
||||
//final String a2 = String.valueOf(a); // Jeppa Test
|
||||
if(Playing.get(a).size()== 1 && canjoin.get(a)== true){
|
||||
//Announce winner
|
||||
for(i = 0; i < Playing.get(a).size(); i++){
|
||||
String winnername = Playing.get(a).get(i);
|
||||
Player winner = getServer().getPlayerExact(winnername);
|
||||
String winnername2 = winner.getName();
|
||||
getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
|
||||
winner.getInventory().clear();
|
||||
winner.getInventory().setBoots(null);
|
||||
winner.getInventory().setChestplate(null);
|
||||
winner.getInventory().setHelmet(null);
|
||||
winner.getInventory().setLeggings(null);
|
||||
winner.setLevel(0);
|
||||
for(PotionEffect pe: winner.getActivePotionEffects()){
|
||||
PotionEffectType potion = pe.getType();
|
||||
winner.removePotionEffect(potion);
|
||||
File PFile = null;
|
||||
FileConfiguration PConfig= null;
|
||||
public void reloadPFile(String pname) {
|
||||
if (PFile == null) {
|
||||
PFile = new File(PFilePath, pname + ".yml"); // Jeppa: set the new playerfile... or the existing one...
|
||||
}
|
||||
PConfig = YamlConfiguration.loadConfiguration(PFile);
|
||||
InputStream defConfigStream = this.getResource("Player.yml");
|
||||
if (defConfigStream != null) {
|
||||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
|
||||
PConfig.setDefaults(defConfig);
|
||||
}
|
||||
}
|
||||
public FileConfiguration getPConfig(String pname) {
|
||||
PFile = null; //Jeppa: must get cleared , else a file from another player could (will) be used at save..!!!
|
||||
this.reloadPFile(pname); //Jeppa: load/set file
|
||||
return PConfig;
|
||||
}
|
||||
public void savePFile(String pname) {
|
||||
if (PConfig.getString("player").equals(pname)){ // Jeppa: check if the 'calling' player still is the one who started this...
|
||||
try {
|
||||
this.PConfig.save(PFile);
|
||||
} catch (IOException ex) {
|
||||
this.getLogger().log(Level.SEVERE, "Could not save config to " + PFile, ex);
|
||||
}
|
||||
}else this.getLogger().log(Level.SEVERE, "Could not save config to " + pname + ".yml ! It's not this players inventory!?");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void RestoreInv(Player p, String pname){ // Jeppa: moved here from 'WorldChange' to make it available for calls from other routines... and lots of changes...
|
||||
int u=0;
|
||||
for(u=1;u<Playing.size(); u++){ // do a check thru all available arenas and remove the player from the lists as he is NOT playing anymore...
|
||||
if(Playing.get(u)!=null){
|
||||
if(Playing.get(u).contains(pname)){
|
||||
//Jeppa: player is changing map but not 'Frozen' or he is leaving with /ha leave !!!
|
||||
Playing.get(u).remove(pname);
|
||||
if(config.getBoolean("broadcastAll")){
|
||||
p.getServer().broadcastMessage(ChatColor.RED + pname + " Left Arena " + u + "!");
|
||||
}
|
||||
p.sendMessage(ChatColor.AQUA + "You have left the game!");
|
||||
}
|
||||
Tele.add(winner);
|
||||
final World w = winner.getWorld();
|
||||
winner.teleport(Spawn);
|
||||
if(config.getBoolean("reloadWorld")){
|
||||
}
|
||||
if(Ready.get(u)!=null){
|
||||
if(Ready.get(u).contains(pname)) Ready.get(u).remove(pname); //Jeppa: if ready is set it can be removed now... maybe this player is just changing worlds without /ha leave ...
|
||||
//when he comes back he has to /ha join again anyway!
|
||||
}
|
||||
}
|
||||
|
||||
if(new File(PFilePath, pname + ".yml").exists()){ //Jeppa: the new path...
|
||||
FileConfiguration pinfo = this.getPConfig(pname);
|
||||
if((pinfo.getString("player").equals(pname)) && (this.needInv.contains(pname))){ //Jeppa: as waitingroom and playground may be different worlds it will not work checking for the world ... :( but let's check for the player...
|
||||
try{
|
||||
ItemStack[] pinv = null;
|
||||
Object o = pinfo.get("inv");
|
||||
if(o instanceof ItemStack[]){
|
||||
pinv = (ItemStack[]) o;
|
||||
}else if(o instanceof List){
|
||||
pinv = (ItemStack[]) ((List<ItemStack>) o).toArray(new ItemStack[0]);
|
||||
}
|
||||
p.getInventory().setContents(pinv);
|
||||
p.updateInventory(); //Jeppa: is this still necessary ??? seems to work without.. but...
|
||||
|
||||
ItemStack[] parmor = null;
|
||||
o = pinfo.get("armor");
|
||||
if(o instanceof ItemStack[]){
|
||||
parmor = (ItemStack[]) o;
|
||||
}else if(o instanceof List){
|
||||
parmor = (ItemStack[]) ((List<ItemStack>) o).toArray(new ItemStack[0]);
|
||||
}
|
||||
p.getInventory().setArmorContents(parmor);
|
||||
p.updateInventory();
|
||||
|
||||
p.sendMessage(ChatColor.GOLD + "[HA] " + ChatColor.GREEN + "Your inventory has been restored!");
|
||||
new File(PFilePath, pname + ".yml").delete();
|
||||
|
||||
//Jeppa: maybe there is more than one entry in needInv from disconnection or whatever ... remove them all!
|
||||
for(i = 0; i < needInv.size(); i++){
|
||||
String name2 = needInv.get(i);{
|
||||
if (name2.equals(pname)) needInv.remove(pname);
|
||||
}
|
||||
}
|
||||
}catch(Exception e){
|
||||
p.sendMessage(ChatColor.RED + "Something went wrong when trying to restore your inv, please contact an administrator.");
|
||||
System.out.println("Error occured when trying to restore the inv of " + pname + ":");
|
||||
System.out.println(e);
|
||||
}
|
||||
}//else p.sendMessage(ChatColor.RED + "This is not your inventory! :)..."); //DEBUG
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void winner(final Integer a){
|
||||
if(Playing.get(a).size()== 1){
|
||||
//Jeppa: check if the Arena-respawn is available.
|
||||
String[] Spawncoords;
|
||||
if (spawns.getString("Spawn_coords_" + a) != null){
|
||||
Spawncoords = spawns.getString("Spawn_coords_"+ a).split(",");
|
||||
} else {
|
||||
Spawncoords = spawns.getString("Spawn_coords").split(",");
|
||||
}
|
||||
World spawnw = getServer().getWorld(Spawncoords[3]);
|
||||
double spawnx = Double.parseDouble(Spawncoords[0]);
|
||||
double spawny = Double.parseDouble(Spawncoords[1]);
|
||||
double spawnz = Double.parseDouble(Spawncoords[2]);
|
||||
Location Spawn = new Location(spawnw, spawnx, spawny, spawnz);
|
||||
|
||||
if(canjoin.get(a)== true){
|
||||
//Announce winner
|
||||
for(i = 0; i < Playing.get(a).size(); i++){
|
||||
String winnername = Playing.get(a).get(i);
|
||||
final Player winner = getServer().getPlayerExact(winnername);
|
||||
String winnername2 = winner.getName();
|
||||
getServer().broadcastMessage(ChatColor.GREEN + winnername2 + " is the victor of this Hunger Games!");
|
||||
winner.getInventory().clear();
|
||||
winner.getInventory().setBoots(null);
|
||||
winner.getInventory().setChestplate(null);
|
||||
winner.getInventory().setHelmet(null);
|
||||
winner.getInventory().setLeggings(null);
|
||||
winner.setLevel(0);
|
||||
for(PotionEffect pe: winner.getActivePotionEffects()){
|
||||
PotionEffectType potion = pe.getType();
|
||||
winner.removePotionEffect(potion);
|
||||
}
|
||||
Tele.add(winner);
|
||||
needInv.add(winnername2);
|
||||
winner.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
|
||||
if(scoreboards.containsKey(winner.getName()))
|
||||
scoreboards.remove(winner.getName());
|
||||
if(Kills.containsKey(winner.getName()))
|
||||
Kills.remove(winner.getName());
|
||||
//final World w = winner.getWorld();
|
||||
winner.teleport(Spawn);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
//////////////////// FIREWORKS ///////////////////////
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
for(i = 0; i < 10; i++){
|
||||
Bukkit.getScheduler().runTaskLater(this, new Runnable(){
|
||||
public void run(){
|
||||
//Spawn the Fireworks, get the FireworkMeta.
|
||||
Firework fw = (Firework) winner.getWorld().spawnEntity(winner.getLocation(), EntityType.FIREWORK);
|
||||
FireworkMeta fwm = fw.getFireworkMeta();
|
||||
|
||||
//Our random generator
|
||||
Random r = new Random();
|
||||
|
||||
//Get the type
|
||||
int rt = r.nextInt(4) + 1;
|
||||
Type type = Type.BALL;
|
||||
if (rt == 1) type = Type.BALL;
|
||||
if (rt == 2) type = Type.BALL_LARGE;
|
||||
if (rt == 3) type = Type.BURST;
|
||||
if (rt == 4) type = Type.CREEPER;
|
||||
if (rt == 5) type = Type.STAR;
|
||||
|
||||
//Get our random colours
|
||||
int r1i = r.nextInt(17) + 1;
|
||||
int r2i = r.nextInt(17) + 1;
|
||||
Color c1 = getColor(r1i);
|
||||
Color c2 = getColor(r2i);
|
||||
|
||||
//Create our effect with this
|
||||
FireworkEffect effect = FireworkEffect.builder().flicker(r.nextBoolean()).withColor(c1).withFade(c2).with(type).trail(r.nextBoolean()).build();
|
||||
|
||||
//Then apply the effect to the meta
|
||||
fwm.addEffect(effect);
|
||||
|
||||
//Generate some random power and set it
|
||||
int rp = r.nextInt(2) + 1;
|
||||
fwm.setPower(rp);
|
||||
|
||||
//Then apply this to our rocket
|
||||
fw.setFireworkMeta(fwm);
|
||||
}
|
||||
},20 + i*20L);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/*if(config.getBoolean("reloadWorld")){
|
||||
getServer().unloadWorld(w, false);
|
||||
getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
|
||||
public void run(){
|
||||
getServer().createWorld(new WorldCreator(w.getName()));
|
||||
}
|
||||
},200L);
|
||||
}
|
||||
if(!config.getBoolean("rewardEco.enabled")){
|
||||
for(ItemStack Rewards: Reward){
|
||||
winner.getInventory().addItem(Rewards);
|
||||
}*/
|
||||
|
||||
//Jeppa: restore the winners inventory
|
||||
this.RestoreInv(winner, winnername2);
|
||||
|
||||
if(!config.getBoolean("rewardEco.enabled")){
|
||||
for(ItemStack Rewards: Reward){
|
||||
winner.getInventory().addItem(Rewards);
|
||||
}
|
||||
}else{
|
||||
for(ItemStack Rewards: Reward){
|
||||
winner.getInventory().addItem(Rewards);
|
||||
}
|
||||
econ.depositPlayer(winner.getName(), config.getDouble("rewardEco.reward"));
|
||||
}
|
||||
}else{
|
||||
for(ItemStack Rewards: Reward){
|
||||
winner.getInventory().addItem(Rewards);
|
||||
if(deathtime.get(a)!= null){
|
||||
getServer().getScheduler().cancelTask(deathtime.get(a));
|
||||
deathtime.put(a, null);
|
||||
}
|
||||
if(grace.get(a)!= null){
|
||||
getServer().getScheduler().cancelTask(grace.get(a));
|
||||
grace.put(a, null);
|
||||
}
|
||||
if(start.get(a)!= null){
|
||||
getServer().getScheduler().cancelTask(start.get(a));
|
||||
start.put(a, null);
|
||||
}
|
||||
econ.depositPlayer(winner.getName(), config.getDouble("rewardEco.reward"));
|
||||
}
|
||||
Playing.get(a).clear();
|
||||
getServer().getScheduler().cancelTask(deathtime);
|
||||
}
|
||||
//Show spectators
|
||||
for(String s1: Watching.get(a)){
|
||||
Player spectator = getServer().getPlayerExact(s1);
|
||||
spectator.setAllowFlight(false);
|
||||
spectator.teleport(Spawn);
|
||||
for(Player online:getServer().getOnlinePlayers()){
|
||||
online.showPlayer(spectator);
|
||||
}
|
||||
}
|
||||
if(config.getString("Auto_Restart").equalsIgnoreCase("True")){
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
|
||||
public void run(){
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart " + a);
|
||||
//Jeppa: clear the other Lists , too! Game is over!
|
||||
Quit.get(a).clear();
|
||||
Dead.get(a).clear();
|
||||
|
||||
//Show spectators
|
||||
for(String s1: Watching.get(a)){
|
||||
Player spectator = getServer().getPlayerExact(s1);
|
||||
spectator.setAllowFlight(false);
|
||||
spectator.teleport(Spawn);
|
||||
for(Player online:getServer().getOnlinePlayers()){
|
||||
online.showPlayer(spectator);
|
||||
}
|
||||
}, 220L);
|
||||
}
|
||||
if(config.getString("Auto_Restart").equalsIgnoreCase("True")){
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
|
||||
public void run(){
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart " + a);
|
||||
}
|
||||
}, 220L);
|
||||
}
|
||||
//Jeppa: new List that marks arenas as started!
|
||||
MatchRunning.put(a, null);//Jeppa: no, i'm not using boolean ;) this is the marker for the arenas
|
||||
}else{
|
||||
//no real winner
|
||||
for(i = 0; i < Playing.get(a).size(); i++){
|
||||
String winnername = Playing.get(a).get(i);
|
||||
Player winner = getServer().getPlayerExact(winnername);
|
||||
String winnername2 = winner.getName();
|
||||
winner.getInventory().clear();
|
||||
winner.getInventory().setBoots(null);
|
||||
winner.getInventory().setChestplate(null);
|
||||
winner.getInventory().setHelmet(null);
|
||||
winner.getInventory().setLeggings(null);
|
||||
winner.setLevel(0);
|
||||
for(PotionEffect pe: winner.getActivePotionEffects()){
|
||||
PotionEffectType potion = pe.getType();
|
||||
winner.removePotionEffect(potion);
|
||||
}
|
||||
Tele.add(winner);
|
||||
needInv.add(winnername2);
|
||||
//final World w = winner.getWorld();
|
||||
winner.teleport(Spawn);
|
||||
/*if(config.getBoolean("reloadWorld")){
|
||||
getServer().unloadWorld(w, false);
|
||||
getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
|
||||
public void run(){
|
||||
getServer().createWorld(new WorldCreator(w.getName()));
|
||||
}
|
||||
},200L);
|
||||
}*/
|
||||
|
||||
//Jeppa: restore the winners inventory
|
||||
this.RestoreInv(winner, winnername2);
|
||||
|
||||
Playing.get(a).clear();
|
||||
//Jeppa :Fix
|
||||
if(deathtime.get(a)!= null){
|
||||
getServer().getScheduler().cancelTask(deathtime.get(a));
|
||||
deathtime.put(a, null);
|
||||
}
|
||||
//Jeppa: clear the other lists too! Game is over!
|
||||
Quit.get(a).clear();
|
||||
Dead.get(a).clear();
|
||||
}
|
||||
//Show spectators
|
||||
for(String s1: Watching.get(a)){
|
||||
Player spectator = getServer().getPlayerExact(s1);
|
||||
spectator.setAllowFlight(false);
|
||||
spectator.teleport(Spawn);
|
||||
for(Player online:getServer().getOnlinePlayers()){
|
||||
online.showPlayer(spectator);
|
||||
}
|
||||
}
|
||||
if(config.getString("Auto_Restart").equalsIgnoreCase("True")){
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
|
||||
public void run(){
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha restart " + a);
|
||||
}
|
||||
}, 220L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Color getColor(int i) {
|
||||
if(i==1)
|
||||
return Color.AQUA;
|
||||
else if(i==2)
|
||||
return Color.BLACK;
|
||||
else if(i==3)
|
||||
return Color.BLUE;
|
||||
else if(i==4)
|
||||
return Color.FUCHSIA;
|
||||
else if(i==5)
|
||||
return Color.GRAY;
|
||||
else if(i==6)
|
||||
return Color.GREEN;
|
||||
else if(i==7)
|
||||
return Color.LIME;
|
||||
else if(i==8)
|
||||
return Color.MAROON;
|
||||
else if(i==9)
|
||||
return Color.NAVY;
|
||||
else if(i==10)
|
||||
return Color.OLIVE;
|
||||
else if(i==11)
|
||||
return Color.ORANGE;
|
||||
else if(i==12)
|
||||
return Color.PURPLE;
|
||||
else if(i==13)
|
||||
return Color.RED;
|
||||
else if(i==14)
|
||||
return Color.SILVER;
|
||||
else if(i==15)
|
||||
return Color.TEAL;
|
||||
else if(i==16)
|
||||
return Color.WHITE;
|
||||
else
|
||||
return Color.YELLOW;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void scoreboardInit(){
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
|
||||
public void run(){
|
||||
for(Player pl: getServer().getOnlinePlayers()){
|
||||
updateScoreboard(pl);
|
||||
}
|
||||
}
|
||||
}, 20L, 10L);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void updateScoreboard(Player p){
|
||||
if(getArena(p)!= null){
|
||||
a = getArena(p);
|
||||
if(scoreboards.get(p.getName())!= null && scoreboards.get(p.getName()).getObjective("HA")!= null){
|
||||
Scoreboard sb = scoreboards.get(p.getName());
|
||||
Objective obj = sb.getObjective("HA");
|
||||
if(obj!= null){
|
||||
Score kills = obj.getScore(Bukkit.getOfflinePlayer(ChatColor.RED + "Kills"));
|
||||
Score players = obj.getScore(Bukkit.getOfflinePlayer(ChatColor.RED + "Players"));
|
||||
Score spectators = obj.getScore(Bukkit.getOfflinePlayer(ChatColor.RED + "Spectators"));
|
||||
players.setScore(Playing.get(a).size());
|
||||
if(Kills.containsKey(p.getName()))
|
||||
kills.setScore(Kills.get(p.getName()));
|
||||
if(Watching.get(a)!= null)
|
||||
spectators.setScore(Watching.get(a).size());
|
||||
if(config.getInt("DeathMatch")!= 0){
|
||||
if(timetodeath.get(a)!= null){
|
||||
if(timetodeath.get(a)> 0){
|
||||
String secs = String.valueOf((Integer.valueOf(timetodeath.get(a)-timetodeath.get(a)/60*60)< 10) ? "0" + Integer.valueOf(timetodeath.get(a)-timetodeath.get(a)/60*60) : Integer.valueOf(timetodeath.get(a)-timetodeath.get(a)/60*60));
|
||||
obj.setDisplayName(ChatColor.GREEN + "HA - DMTime: " + ChatColor.AQUA + Integer.valueOf(timetodeath.get(a)/60) + ":" + secs);
|
||||
}else{
|
||||
obj.setDisplayName(ChatColor.GREEN + "HA - " + ChatColor.RED + "DEATHMATCH");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
obj.setDisplayName(ChatColor.GREEN + "HungerArena");
|
||||
}
|
||||
p.setScoreboard(sb);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public HashMap<Integer, Integer> grace = new HashMap<Integer, Integer>();
|
||||
public HashMap<Integer, Integer> start = new HashMap<Integer, Integer>();
|
||||
public HashMap<Integer, Integer> deathtime = new HashMap<Integer, Integer>();
|
||||
public HashMap<Integer, Integer> timetodeath = new HashMap<Integer, Integer>();
|
||||
@SuppressWarnings("deprecation")
|
||||
public void startGames(final Integer a){
|
||||
String begin = config.getString("Start_Message");
|
||||
begin = begin.replaceAll("(&([a-f0-9]))", "\u00A7$2");
|
||||
String begin = ChatColor.translateAlternateColorCodes('&', config.getString("Start_Message"));
|
||||
final String msg = begin;
|
||||
/* Jeppa add : */
|
||||
if(config.getInt("Countdown_Timer") != 0) {
|
||||
i = config.getInt("Countdown_Timer") ;
|
||||
} else {
|
||||
i = 10;
|
||||
}
|
||||
for(String gn: Playing.get(a)){
|
||||
Scoreboard scoreboard = getServer().getScoreboardManager().getNewScoreboard();
|
||||
Objective sobj = scoreboard.registerNewObjective("HA", "HAData");
|
||||
sobj.setDisplayName(ChatColor.GREEN + "HA - Starting");
|
||||
Score skills = sobj.getScore(Bukkit.getOfflinePlayer(ChatColor.RED + "Kills"));
|
||||
skills.setScore(0);
|
||||
Score sdeaths = sobj.getScore(Bukkit.getOfflinePlayer(ChatColor.RED + "Spectators"));
|
||||
sdeaths.setScore(0);
|
||||
Score splayers = sobj.getScore(Bukkit.getOfflinePlayer(ChatColor.RED + "Players"));
|
||||
splayers.setScore(0);
|
||||
sobj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
Bukkit.getPlayer(gn).setScoreboard(scoreboard);
|
||||
scoreboards.put(Bukkit.getPlayer(gn).getName(), Bukkit.getPlayer(gn).getScoreboard());
|
||||
}
|
||||
getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha Refill " + a);
|
||||
//Jeppa: new List that marks the arenas as started!
|
||||
MatchRunning.put(a, "true");//Jeppa: no, i'm not using boolean ;)
|
||||
if(start.get(a)!= null) getServer().getScheduler().cancelTask(start.get(a));
|
||||
//start.put(a, null);
|
||||
if(config.getString("Countdown").equalsIgnoreCase("true")){
|
||||
start = getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
|
||||
start.put(a, getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
|
||||
public void run(){
|
||||
if(i > 0){
|
||||
if(worlds.isEmpty()){
|
||||
if(config.getBoolean("broadcastAll")){
|
||||
getServer().broadcastMessage(String.valueOf(i));
|
||||
getServer().broadcastMessage(ChatColor.AQUA + "Game " + a + " starting in: " + String.valueOf(i));
|
||||
}else{
|
||||
for(String gn: Playing.get(a)){
|
||||
Player g = getServer().getPlayer(gn);
|
||||
g.sendMessage(String.valueOf(i));
|
||||
g.sendMessage(ChatColor.AQUA + "Game starting in: " + String.valueOf(i));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
@ -454,8 +893,22 @@ public class Main extends JavaPlugin{
|
||||
}
|
||||
}
|
||||
i = i-1;
|
||||
canjoin.put(a, true);
|
||||
canjoin.put(a, true); // Jeppa: this was the reason for players not being able to join when the timer task was broken (counting below 0)...
|
||||
if(i== -1){
|
||||
for(String gn: Playing.get(a)){
|
||||
Scoreboard scoreboard = getServer().getScoreboardManager().getNewScoreboard();
|
||||
Objective sobj = scoreboard.registerNewObjective("HA", "HAData");
|
||||
sobj.setDisplayName(ChatColor.GREEN + "HA - Starting");
|
||||
Score skills = sobj.getScore(Bukkit.getOfflinePlayer(ChatColor.RED + "Kills"));
|
||||
skills.setScore(0);
|
||||
Score sdeaths = sobj.getScore(Bukkit.getOfflinePlayer(ChatColor.RED + "Spectators"));
|
||||
sdeaths.setScore(0);
|
||||
Score splayers = sobj.getScore(Bukkit.getOfflinePlayer(ChatColor.RED + "Players"));
|
||||
splayers.setScore(0);
|
||||
sobj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
Bukkit.getPlayer(gn).setScoreboard(scoreboard);
|
||||
scoreboards.put(Bukkit.getPlayer(gn).getName(), Bukkit.getPlayer(gn).getScoreboard());
|
||||
}
|
||||
if(Frozen.get(a)!= null)
|
||||
Frozen.get(a).clear();
|
||||
if(config.getBoolean("broadcastAll")){
|
||||
@ -466,52 +919,54 @@ public class Main extends JavaPlugin{
|
||||
g.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
getServer().dispatchCommand(Bukkit.getConsoleSender(), "ha Refill " + a);
|
||||
getServer().getScheduler().cancelTask(start);
|
||||
if(config.getInt("Grace_Period")!= 0){
|
||||
gp = config.getInt("Grace_Period");
|
||||
grace = getServer().getScheduler().scheduleSyncRepeatingTask(Bukkit.getPluginManager().getPlugin("HungerArena"), new Runnable(){
|
||||
gp.put(a, config.getInt("Grace_Period"));
|
||||
if(grace.get(a)== null) grace.put(a, getServer().getScheduler().scheduleSyncRepeatingTask(Bukkit.getPluginManager().getPlugin("HungerArena"), new Runnable(){
|
||||
public void run(){
|
||||
gp = gp-1;
|
||||
if(gp == 30 || gp == 15 || (gp < 11 && gp != 0)){
|
||||
gp.put(a, gp.get(a)-1);
|
||||
if(gp.get(a) == 30 || gp.get(a) == 15 || (gp.get(a) < 11 && gp.get(a) != 0)){
|
||||
if(config.getBoolean("broadcastAll")){
|
||||
for(Player wp: location.get(a).get(1).getWorld().getPlayers()){
|
||||
wp.sendMessage(ChatColor.GREEN + "Grace period ends in " + gp + " seconds!");
|
||||
wp.sendMessage(ChatColor.GREEN + "Grace period ends in " + gp.get(a) + " seconds!");
|
||||
}
|
||||
}else
|
||||
getServer().broadcastMessage(ChatColor.GREEN + "Grace period ends in " + gp + " seconds!");
|
||||
getServer().broadcastMessage(ChatColor.GREEN + "Grace period ends in " + gp.get(a) + " seconds!");
|
||||
}
|
||||
if(gp == 0){
|
||||
if(gp.get(a) <= 0){
|
||||
if(config.getBoolean("broadcastAll")){
|
||||
for(Player wp: location.get(a).get(1).getWorld().getPlayers()){
|
||||
wp.sendMessage(ChatColor.GREEN + "Grace period is over, FIGHT!");
|
||||
}
|
||||
}else
|
||||
getServer().broadcastMessage(ChatColor.GREEN + "Grace period is over, FIGHT!");
|
||||
getServer().getScheduler().cancelTask(grace);
|
||||
getServer().getScheduler().cancelTask(grace.get(a));
|
||||
grace.put(a, null);
|
||||
}
|
||||
}
|
||||
},20L, 20L);
|
||||
},20L, 20L));
|
||||
}
|
||||
if(config.getInt("DeathMatch")!= 0){
|
||||
int death = config.getInt("DeathMatch");
|
||||
timetodeath = death;
|
||||
deathtime = getServer().getScheduler().scheduleSyncRepeatingTask(Bukkit.getPluginManager().getPlugin("HungerArena"), new Runnable(){
|
||||
timetodeath.put(a, death*60);
|
||||
if(deathtime.get(a)== null) deathtime.put(a, getServer().getScheduler().scheduleSyncRepeatingTask(Bukkit.getPluginManager().getPlugin("HungerArena"), new Runnable(){
|
||||
public void run(){
|
||||
timetodeath = timetodeath-1;
|
||||
if(config.getBoolean("broadcastAll")){
|
||||
for(Player wp: location.get(a).get(1).getWorld().getPlayers()){
|
||||
if(timetodeath!= 0){
|
||||
wp.sendMessage(ChatColor.RED + String.valueOf(timetodeath) + " mins till the death match!");
|
||||
timetodeath.put(a, timetodeath.get(a)-1);
|
||||
if(Integer.valueOf(timetodeath.get(a))%300== 0){
|
||||
if(config.getBoolean("broadcastAll")){
|
||||
for(Player wp: location.get(a).get(1).getWorld().getPlayers()){
|
||||
if(timetodeath.get(a)!= 0){
|
||||
wp.sendMessage(ChatColor.YELLOW + String.valueOf(timetodeath.get(a)/60) + ChatColor.RED + " mins till the death match!");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
for(String gn: Playing.get(a)){
|
||||
Player g = getServer().getPlayer(gn);
|
||||
g.sendMessage(ChatColor.YELLOW + String.valueOf(timetodeath.get(a)) + ChatColor.RED + " mins till the death match!");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
for(String gn: Playing.get(a)){
|
||||
Player g = getServer().getPlayer(gn);
|
||||
g.sendMessage(ChatColor.RED + String.valueOf(timetodeath) + " mins till the death match!");
|
||||
}
|
||||
}
|
||||
if(timetodeath== 0){
|
||||
if(timetodeath.get(a)<= 0){
|
||||
i = 1;
|
||||
for(String playing: Playing.get(a)){
|
||||
Player tribute = getServer().getPlayerExact(playing);
|
||||
tribute.teleport(location.get(a).get(i));
|
||||
@ -525,23 +980,24 @@ public class Main extends JavaPlugin{
|
||||
}
|
||||
}
|
||||
if(config.getBoolean("broadcastAll")){
|
||||
for(Player wp: location.get(a).get(0).getWorld().getPlayers()){
|
||||
wp.sendMessage(ChatColor.RED + "The final battle has begun! " + Playing.size() + " tributes will be facing off!");
|
||||
for(Player wp: location.get(a).get(1).getWorld().getPlayers()){
|
||||
wp.sendMessage(ChatColor.RED + "The final battle has begun! " + Playing.get(a).size() + " tributes will be facing off!");
|
||||
}
|
||||
}else{
|
||||
for(String gn: Playing.get(a)){
|
||||
Player g = getServer().getPlayer(gn);
|
||||
g.sendMessage(ChatColor.RED + "The final battle has begun! " + Playing.size() + " tributes will be facing off!");
|
||||
g.sendMessage(ChatColor.RED + "The final battle has begun! " + Playing.get(a).size() + " tributes will be facing off!");
|
||||
}
|
||||
}
|
||||
getServer().getScheduler().cancelTask(deathtime);
|
||||
getServer().getScheduler().cancelTask(deathtime.get(a));
|
||||
deathtime.put(a, null);
|
||||
}
|
||||
}
|
||||
}, 1200L, 1200L);
|
||||
}, 20L, 20L));
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 20L, 20L);
|
||||
}, 20L, 20L));
|
||||
}else{
|
||||
Frozen.get(a).clear();
|
||||
if(config.getBoolean("broadcastAll")){
|
||||
|
@ -3,6 +3,7 @@ package me.Travja.HungerArena;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
@ -14,40 +15,101 @@ public class SpawnsCommand implements CommandExecutor {
|
||||
public Main plugin;
|
||||
int i = 0;
|
||||
int a = 0;
|
||||
boolean NoPlayerSpawns = true; // Jeppa : default
|
||||
public SpawnsCommand(Main m) {
|
||||
this.plugin = m;
|
||||
}
|
||||
@Override
|
||||
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++){ //worldsNames-Inhalt (integer) entspricht der Arenanummer !!
|
||||
if(plugin.worldsNames.get(i)!= null){ //Jeppa: damit das so geht müssen die Arenen aber wirklich durchgezählt sein!!
|
||||
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!
|
||||
//p.sendMessage(ChatColor.GREEN + "[HungerArena]: Diese Map[KurzeAbfrage!! in startpoint]: "+ ThisWorld + " ist nummer: "+ a);
|
||||
NoPlayerSpawns = false; // mapname found -> there are PlayerSpawns...--> map seems playable
|
||||
}
|
||||
}
|
||||
}
|
||||
if(cmd.getName().equalsIgnoreCase("StartPoint")){
|
||||
if(p.hasPermission("HungerArena.StartPoint")){
|
||||
if(!plugin.restricted || (plugin.restricted && plugin.worlds.contains(p.getWorld().getName()))){
|
||||
if(args.length>= 2){
|
||||
Location loc = null;
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
if(args.length == 6){
|
||||
try{ // was missing.....
|
||||
i = Integer.valueOf(args[1]);
|
||||
a = Integer.valueOf(args[0]);
|
||||
}catch(Exception e){
|
||||
p.sendMessage(ChatColor.RED + "Argument not an integer!");
|
||||
return true; //Jeppa: true??? false ???
|
||||
}
|
||||
|
||||
String world = args[2];
|
||||
x = Double.parseDouble(args[3]);
|
||||
y = Double.parseDouble(args[4]);
|
||||
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));
|
||||
}
|
||||
}else{
|
||||
plugin.location.put(a, new HashMap<Integer, Location>());
|
||||
plugin.location.get(a).put(i, new Location(loc.getWorld(), x, y, z));
|
||||
plugin.Playing.put(a, new ArrayList<String>());
|
||||
plugin.Ready.put(a, new ArrayList<String>());
|
||||
plugin.Dead.put(a, new ArrayList<String>());
|
||||
plugin.Quit.put(a, new ArrayList<String>());
|
||||
plugin.Out.put(a, new ArrayList<String>());
|
||||
plugin.Watching.put(a, new ArrayList<String>());
|
||||
plugin.NeedConfirm.put(a, new ArrayList<String>());
|
||||
plugin.inArena.put(a, new ArrayList<String>());
|
||||
plugin.Frozen.put(a, new ArrayList<String>());
|
||||
plugin.arena.put(a, new ArrayList<String>());
|
||||
plugin.canjoin.put(a, false);
|
||||
plugin.open.put(a, true);
|
||||
}
|
||||
String coords = plugin.location.get(a).get(i).getWorld().getName() + "," + (plugin.location.get(a).get(i).getX()+.5) + "," + plugin.location.get(a).get(i).getY() + "," + (plugin.location.get(a).get(i).getZ()+.5);
|
||||
p.sendMessage(coords);
|
||||
plugin.spawns.set("Spawns." + a + "." + i, coords);
|
||||
plugin.saveSpawns();
|
||||
plugin.maxPlayers.put(a, plugin.location.get(a).size());
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute " + i + " in arena " + a + "!");
|
||||
this.plugin.reloadSpawnpoints(); // Jeppa: fix the check-routines looking for arenas in the HashMaps... -> muss in jede routine vor den return!!!
|
||||
return true;
|
||||
}
|
||||
if(args.length>= 2){ // Welt und Pos Startummer angegeben
|
||||
try{
|
||||
i = Integer.valueOf(args[1]);
|
||||
a = Integer.valueOf(args[0]);
|
||||
}catch(Exception e){
|
||||
p.sendMessage(ChatColor.RED + "Argument not an integer!");
|
||||
return true; //Jeppa: wieso 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.");
|
||||
}
|
||||
Location ploc = p.getLocation().getBlock().getLocation();
|
||||
double x = ploc.getX();
|
||||
double y = ploc.getY();
|
||||
double z = ploc.getZ();
|
||||
loc = p.getLocation().getBlock().getLocation();
|
||||
x = loc.getX();
|
||||
y = loc.getY();
|
||||
z = loc.getZ();
|
||||
if(plugin.location.get(a)!= null){
|
||||
if(plugin.location.get(a).size()>= i){
|
||||
plugin.location.get(a).put(i, new Location(ploc.getWorld(), x, y, z));
|
||||
plugin.location.get(a).put(i, new Location(loc.getWorld(), x, y, z));
|
||||
}else{
|
||||
plugin.location.get(a).put(i, new Location(ploc.getWorld(), x, y, z));
|
||||
plugin.location.get(a).put(i, new Location(loc.getWorld(), x, y, z));
|
||||
}
|
||||
}else{
|
||||
plugin.location.put(a, new HashMap<Integer, Location>());
|
||||
plugin.location.get(a).put(i, new Location(ploc.getWorld(), x, y, z));
|
||||
plugin.location.get(a).put(i, new Location(loc.getWorld(), x, y, z));
|
||||
plugin.Playing.put(a, new ArrayList<String>());
|
||||
plugin.Ready.put(a, new ArrayList<String>());
|
||||
plugin.Dead.put(a, new ArrayList<String>());
|
||||
@ -61,14 +123,57 @@ public class SpawnsCommand implements CommandExecutor {
|
||||
plugin.canjoin.put(a, false);
|
||||
plugin.open.put(a, true);
|
||||
}
|
||||
String coords = plugin.location.get(a).get(i).getWorld().getName() + "," + plugin.location.get(a).get(i).getX() + "," + plugin.location.get(a).get(i).getY() + "," + plugin.location.get(a).get(i).getZ();
|
||||
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);
|
||||
p.sendMessage(coords);
|
||||
plugin.spawns.set("Spawns." + a + "." + i, coords);
|
||||
plugin.saveSpawns();
|
||||
plugin.maxPlayers.put(a, plugin.location.get(a).size());
|
||||
p.sendMessage(ChatColor.AQUA + "You have set the spawn location of Tribute " + i + " in arena " + a + "!");
|
||||
this.plugin.reloadSpawnpoints(); // Jeppa: fix for the check-routines looking for arenas in the HashMaps... -> muss in jede routine vor den return!!!
|
||||
}else{
|
||||
p.sendMessage(ChatColor.RED + "You can't go past " + plugin.maxPlayers + " players!");
|
||||
p.sendMessage(ChatColor.RED + "You can't go past " + plugin.config.getInt("maxPlayers") + " players!");
|
||||
}
|
||||
}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
|
||||
try{
|
||||
a = Integer.parseInt(args[0]); // kein Int = Fehler, Nicht vorhanden = Fehler
|
||||
}catch(Exception e){
|
||||
p.sendMessage(ChatColor.RED + "Argument not an integer!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (plugin.spawns.get("Spawns." + a) != null){
|
||||
int start = 1;
|
||||
while(start<plugin.config.getInt("maxPlayers")+2){
|
||||
if (plugin.spawns.get("Spawns." + a + "." + start) != null){
|
||||
start = start+1;
|
||||
if(start== plugin.config.getInt("maxPlayers")+1){
|
||||
p.sendMessage(ChatColor.DARK_AQUA + "[HungerArena] " + ChatColor.GREEN + "All spawns set, type /startpoint [Arena #] [Spawn #] to over-ride previous points!");
|
||||
return true;
|
||||
}
|
||||
}else{
|
||||
int sloc = start;
|
||||
start = plugin.config.getInt("maxPlayers")+1;
|
||||
p.sendMessage(ChatColor.DARK_AQUA + "[HungerArena] " + ChatColor.RED + "Begin Setting For Arena " + a + " Starting From Point " + sloc);
|
||||
plugin.setting.put(p.getName(), a + "-" + sloc);
|
||||
//--> Mit angabe der Arena wird NICHT der erste punkt gesetzt oder weitergemacht, sondern das Wekzeug aktiviert!
|
||||
//dem player hier noch das "Werkzeug" per Befehl in die Hand drücken??? TODO
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
p.sendMessage(ChatColor.DARK_AQUA + "[HungerArena] " + ChatColor.RED + "Begin Setting For Arena " + a + " Starting From Point " + 1);
|
||||
plugin.setting.put(p.getName(), a + "-" + 1);
|
||||
//dem player hier noch das "Werkzeug" per Befehl in die Hand drücken??? TODO
|
||||
return true;
|
||||
}else{
|
||||
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 !");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
@ -15,6 +15,7 @@ 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")){
|
||||
|
44
src/me/Travja/HungerArena/WorldChange.java
Normal file
44
src/me/Travja/HungerArena/WorldChange.java
Normal file
@ -0,0 +1,44 @@
|
||||
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...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user