* ALLOT of bug fixes. Can't split them!
This commit is contained in:
parent
4fdbdf6e65
commit
946a20c647
@ -24,6 +24,10 @@ public class ArenaHandler {
|
|||||||
for (String arenaName : W.arenas.getFile().getKeys(false)) {
|
for (String arenaName : W.arenas.getFile().getKeys(false)) {
|
||||||
W.arenaList.add((Arena) W.arenas.getFile().get(arenaName));
|
W.arenaList.add((Arena) W.arenas.getFile().get(arenaName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Arena arena : W.arenaList) {
|
||||||
|
ScoreboardHandler.createScoreboard(arena);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendMessage(Arena arena, String message, Boolean tag,
|
public static void sendMessage(Arena arena, String message, Boolean tag,
|
||||||
@ -86,20 +90,63 @@ public class ArenaHandler {
|
|||||||
}
|
}
|
||||||
arena.playersInArena.add(player);
|
arena.playersInArena.add(player);
|
||||||
|
|
||||||
W.pLocation.put(player,
|
// OLD WAY OF SETTING A PLAYER'S DATA.
|
||||||
player.getLocation());
|
// W.pLocation.put(player,
|
||||||
W.pGameMode.put(player,
|
// player.getLocation());
|
||||||
player.getGameMode());
|
// W.pGameMode.put(player,
|
||||||
|
// player.getGameMode());
|
||||||
|
//
|
||||||
|
// player.teleport(arena.lobbyWarp);
|
||||||
|
// player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
//
|
||||||
|
// W.pInventory.put(player, player
|
||||||
|
// .getInventory().getContents());
|
||||||
|
// player.getInventory().clear();
|
||||||
|
// player.updateInventory();
|
||||||
|
// W.pArmor.put(player,
|
||||||
|
// player.getInventory()
|
||||||
|
// .getArmorContents());
|
||||||
|
// player.getInventory().setHelmet(
|
||||||
|
// new ItemStack(Material.AIR));
|
||||||
|
// player.getInventory().setChestplate(
|
||||||
|
// new ItemStack(Material.AIR));
|
||||||
|
// player.getInventory().setLeggings(
|
||||||
|
// new ItemStack(Material.AIR));
|
||||||
|
// player.getInventory().setBoots(
|
||||||
|
// new ItemStack(Material.AIR));
|
||||||
|
// W.pEXP.put(player, player.getExp());
|
||||||
|
// player.setExp(0);
|
||||||
|
// W.pEXPL.put(player, player.getLevel());
|
||||||
|
// player.setLevel(0);
|
||||||
|
// W.pHealth.put(player,
|
||||||
|
// player.getHealth());
|
||||||
|
// player.setHealth(20);
|
||||||
|
// W.pFood.put(player,
|
||||||
|
// player.getFoodLevel());
|
||||||
|
// player.setFoodLevel(20);
|
||||||
|
|
||||||
|
PlayerArenaData pad = new PlayerArenaData(
|
||||||
|
player.getLocation(),
|
||||||
|
player.getGameMode(), player
|
||||||
|
.getInventory()
|
||||||
|
.getContents(), player
|
||||||
|
.getInventory()
|
||||||
|
.getArmorContents(),
|
||||||
|
player.getExp(), player.getLevel(),
|
||||||
|
player.getHealth(),
|
||||||
|
player.getFoodLevel(),
|
||||||
|
player.getActivePotionEffects());
|
||||||
|
|
||||||
|
W.pData.put(player, pad);
|
||||||
|
|
||||||
player.teleport(arena.lobbyWarp);
|
player.teleport(arena.lobbyWarp);
|
||||||
player.setGameMode(GameMode.SURVIVAL);
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
player.getActivePotionEffects().clear();
|
||||||
W.pInventory.put(player, player
|
player.setFoodLevel(20);
|
||||||
.getInventory().getContents());
|
player.setHealth(20);
|
||||||
|
player.setLevel(arena.timer);
|
||||||
|
player.setExp(0);
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
player.updateInventory();
|
|
||||||
W.pArmor.put(player, player.getInventory()
|
|
||||||
.getArmorContents());
|
|
||||||
player.getInventory().setHelmet(
|
player.getInventory().setHelmet(
|
||||||
new ItemStack(Material.AIR));
|
new ItemStack(Material.AIR));
|
||||||
player.getInventory().setChestplate(
|
player.getInventory().setChestplate(
|
||||||
@ -108,14 +155,11 @@ public class ArenaHandler {
|
|||||||
new ItemStack(Material.AIR));
|
new ItemStack(Material.AIR));
|
||||||
player.getInventory().setBoots(
|
player.getInventory().setBoots(
|
||||||
new ItemStack(Material.AIR));
|
new ItemStack(Material.AIR));
|
||||||
W.pEXP.put(player, player.getExp());
|
player.updateInventory();
|
||||||
player.setExp(0);
|
|
||||||
W.pEXPL.put(player, player.getLevel());
|
if (W.dcAPI.isDisguised(player)) {
|
||||||
player.setLevel(0);
|
W.dcAPI.undisguisePlayer(player);
|
||||||
W.pHealth.put(player, player.getHealth());
|
}
|
||||||
player.setHealth(20);
|
|
||||||
W.pFood.put(player, player.getFoodLevel());
|
|
||||||
player.setFoodLevel(20);
|
|
||||||
|
|
||||||
ArenaHandler.sendFMessage(arena,
|
ArenaHandler.sendFMessage(arena,
|
||||||
ConfigC.normal_joinJoinedArena,
|
ConfigC.normal_joinJoinedArena,
|
||||||
@ -176,18 +220,31 @@ public class ArenaHandler {
|
|||||||
if (arena.seekers.contains(player)) {
|
if (arena.seekers.contains(player)) {
|
||||||
arena.seekers.remove(player);
|
arena.seekers.remove(player);
|
||||||
}
|
}
|
||||||
if (arena.playersInArena.size() <= arena.minPlayers) {
|
|
||||||
if (arena.gameState.equals(ArenaState.STARTING)) {
|
|
||||||
arena.gameState = ArenaState.WAITING;
|
|
||||||
arena.timer = 0;
|
|
||||||
|
|
||||||
ArenaHandler.sendFMessage(arena,
|
if (arena.playersInArena.size() < arena.minPlayers
|
||||||
ConfigC.warning_lobbyNeedAtleast, true, "1-"
|
&& arena.gameState.equals(ArenaState.STARTING)) {
|
||||||
+ arena.minPlayers);
|
arena.gameState = ArenaState.WAITING;
|
||||||
} else {
|
arena.timer = 0;
|
||||||
|
|
||||||
|
ArenaHandler.sendFMessage(arena,
|
||||||
|
ConfigC.warning_lobbyNeedAtleast, true, "1-"
|
||||||
|
+ arena.minPlayers);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arena.playersInArena.size() <= 1
|
||||||
|
&& arena.gameState == ArenaState.INGAME) {
|
||||||
|
if (arena.seekers.size() >= arena.playersInArena.size()) {
|
||||||
ArenaHandler.seekersWin(arena);
|
ArenaHandler.seekersWin(arena);
|
||||||
|
} else {
|
||||||
|
ArenaHandler.hidersWin(arena);
|
||||||
}
|
}
|
||||||
} else if (arena.seekers.size() <= 0
|
}
|
||||||
|
|
||||||
|
if (arena.seekers.size() >= arena.playersInArena.size()) {
|
||||||
|
ArenaHandler.seekersWin(arena);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arena.seekers.size() <= 0
|
||||||
&& arena.gameState == ArenaState.INGAME) {
|
&& arena.gameState == ArenaState.INGAME) {
|
||||||
Player seeker = arena.playersInArena.get(W.random
|
Player seeker = arena.playersInArena.get(W.random
|
||||||
.nextInt(arena.playersInArena.size()));
|
.nextInt(arena.playersInArena.size()));
|
||||||
@ -205,34 +262,63 @@ public class ArenaHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OLD WAY OF RESETTING A PLAYER'S DATA.
|
||||||
|
// player.getInventory().clear();
|
||||||
|
// player.getInventory().setContents(W.pInventory.get(player));
|
||||||
|
// player.updateInventory();
|
||||||
|
// W.pInventory.remove(player);
|
||||||
|
// player.getInventory().setArmorContents(W.pArmor.get(player));
|
||||||
|
// W.pArmor.remove(player);
|
||||||
|
// player.setExp(W.pEXP.get(player));
|
||||||
|
// W.pEXP.remove(player);
|
||||||
|
// player.setLevel(W.pEXPL.get(player));
|
||||||
|
// W.pEXPL.remove(player);
|
||||||
|
// player.setHealth(W.pHealth.get(player));
|
||||||
|
// W.pHealth.remove(player);
|
||||||
|
// player.setFoodLevel(W.pFood.get(player));
|
||||||
|
// W.pFood.remove(player);
|
||||||
|
// W.pBlock.remove(player);
|
||||||
|
//
|
||||||
|
// player.teleport(W.pLocation.get(player));
|
||||||
|
//
|
||||||
|
// player.setGameMode(W.pGameMode.get(player));
|
||||||
|
// W.pGameMode.remove(player);
|
||||||
|
// W.pLocation.remove(player);
|
||||||
|
|
||||||
|
PlayerArenaData pad = new PlayerArenaData(null, null, null, null,
|
||||||
|
null, null, null, null, null);
|
||||||
|
|
||||||
|
if (W.pData.get(player) != null) {
|
||||||
|
pad = W.pData.get(player);
|
||||||
|
}
|
||||||
|
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
player.getInventory().setContents(W.pInventory.get(player));
|
player.getInventory().setContents(pad.pInventory);
|
||||||
|
player.getInventory().setArmorContents(pad.pArmor);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
W.pInventory.remove(player);
|
player.setExp(pad.pEXP);
|
||||||
player.getInventory().setArmorContents(W.pArmor.get(player));
|
player.setLevel(pad.pEXPL);
|
||||||
W.pArmor.remove(player);
|
player.setHealth(pad.pHealth);
|
||||||
player.setExp(W.pEXP.get(player));
|
player.setFoodLevel(pad.pFood);
|
||||||
W.pEXP.remove(player);
|
player.addPotionEffects(pad.pPotionEffects);
|
||||||
player.setLevel(W.pEXPL.get(player));
|
player.teleport(pad.pLocation);
|
||||||
W.pEXPL.remove(player);
|
player.setGameMode(pad.pGameMode);
|
||||||
player.setHealth(W.pHealth.get(player));
|
|
||||||
W.pHealth.remove(player);
|
|
||||||
player.setFoodLevel(W.pFood.get(player));
|
|
||||||
W.pFood.remove(player);
|
|
||||||
W.pBlock.remove(player);
|
|
||||||
|
|
||||||
player.teleport(W.pLocation.get(player));
|
W.pData.remove(player);
|
||||||
|
|
||||||
player.setGameMode(W.pGameMode.get(player));
|
|
||||||
W.pGameMode.remove(player);
|
|
||||||
W.pLocation.remove(player);
|
|
||||||
|
|
||||||
for (Player pl : Bukkit.getOnlinePlayers()) {
|
for (Player pl : Bukkit.getOnlinePlayers()) {
|
||||||
pl.showPlayer(player);
|
pl.showPlayer(player);
|
||||||
if (W.hiddenLoc.get(player) != null) {
|
if (W.hiddenLoc.get(player) != null) {
|
||||||
Block pBlock = W.hiddenLoc.get(player).getBlock();
|
if (W.hiddenLocWater.get(player) != null) {
|
||||||
pl.sendBlockChange(pBlock.getLocation(), Material.AIR,
|
Block pBlock = W.hiddenLoc.get(player).getBlock();
|
||||||
(byte) 0);
|
if (W.hiddenLocWater.get(player)) {
|
||||||
|
pl.sendBlockChange(pBlock.getLocation(),
|
||||||
|
Material.STATIONARY_WATER, (byte) 0);
|
||||||
|
} else {
|
||||||
|
pl.sendBlockChange(pBlock.getLocation(),
|
||||||
|
Material.AIR, (byte) 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (W.dcAPI.isDisguised(player)) {
|
if (W.dcAPI.isDisguised(player)) {
|
||||||
@ -263,8 +349,6 @@ public class ArenaHandler {
|
|||||||
public static void seekersWin(Arena arena) {
|
public static void seekersWin(Arena arena) {
|
||||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_winSeekers, true);
|
ArenaHandler.sendFMessage(arena, ConfigC.normal_winSeekers, true);
|
||||||
for (Player player : arena.playersInArena) {
|
for (Player player : arena.playersInArena) {
|
||||||
playerLeaveArena(player, false, false);
|
|
||||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 1);
|
|
||||||
if (arena.seekersWinCommands != null) {
|
if (arena.seekersWinCommands != null) {
|
||||||
for (String command : arena.seekersWinCommands) {
|
for (String command : arena.seekersWinCommands) {
|
||||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(),
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(),
|
||||||
@ -273,16 +357,21 @@ public class ArenaHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
arena.playersInArena.clear();
|
|
||||||
arena.seekers.clear();
|
arena.seekers.clear();
|
||||||
|
|
||||||
|
for (Player player : arena.playersInArena) {
|
||||||
|
playerLeaveArena(player, false, false);
|
||||||
|
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
arena.gameState = ArenaState.WAITING;
|
arena.gameState = ArenaState.WAITING;
|
||||||
|
arena.timer = 0;
|
||||||
|
arena.playersInArena.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void hidersWin(Arena arena) {
|
public static void hidersWin(Arena arena) {
|
||||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_winHiders, true);
|
ArenaHandler.sendFMessage(arena, ConfigC.normal_winHiders, true);
|
||||||
for (Player player : arena.playersInArena) {
|
for (Player player : arena.playersInArena) {
|
||||||
playerLeaveArena(player, false, false);
|
|
||||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 1);
|
|
||||||
if (!arena.seekers.contains(player)) {
|
if (!arena.seekers.contains(player)) {
|
||||||
if (arena.hidersWinCommands != null) {
|
if (arena.hidersWinCommands != null) {
|
||||||
for (String command : arena.hidersWinCommands) {
|
for (String command : arena.hidersWinCommands) {
|
||||||
@ -294,21 +383,30 @@ public class ArenaHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
arena.playersInArena.clear();
|
|
||||||
arena.seekers.clear();
|
arena.seekers.clear();
|
||||||
|
|
||||||
|
for (Player player : arena.playersInArena) {
|
||||||
|
playerLeaveArena(player, false, false);
|
||||||
|
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
arena.gameState = ArenaState.WAITING;
|
arena.gameState = ArenaState.WAITING;
|
||||||
arena.gameTime = 0;
|
arena.timer = 0;
|
||||||
|
arena.playersInArena.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void stopArena(Arena arena) {
|
public static void stopArena(Arena arena) {
|
||||||
ArenaHandler.sendFMessage(arena, ConfigC.warning_arenaStopped, true);
|
ArenaHandler.sendFMessage(arena, ConfigC.warning_arenaStopped, true);
|
||||||
|
|
||||||
|
arena.seekers.clear();
|
||||||
|
|
||||||
for (Player player : arena.playersInArena) {
|
for (Player player : arena.playersInArena) {
|
||||||
playerLeaveArena(player, false, false);
|
playerLeaveArena(player, false, false);
|
||||||
|
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
arena.playersInArena.clear();
|
|
||||||
arena.seekers.clear();
|
|
||||||
arena.gameState = ArenaState.WAITING;
|
arena.gameState = ArenaState.WAITING;
|
||||||
arena.gameTime = 0;
|
arena.timer = 0;
|
||||||
|
arena.playersInArena.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -451,6 +451,17 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Player pl : Bukkit
|
||||||
|
.getOnlinePlayers()) {
|
||||||
|
if (!pl.equals(player)) {
|
||||||
|
pl.hidePlayer(player);
|
||||||
|
pl.sendBlockChange(
|
||||||
|
pBlock.getLocation(),
|
||||||
|
block.getType(),
|
||||||
|
(byte) block
|
||||||
|
.getDurability());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Block pBlock = player.getLocation()
|
Block pBlock = player.getLocation()
|
||||||
@ -468,7 +479,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
if (W.hiddenLocWater
|
if (W.hiddenLocWater
|
||||||
.get(player) != null) {
|
.get(player) != null) {
|
||||||
if (W.hiddenLocWater
|
if (W.hiddenLocWater
|
||||||
.get(player) == true) {
|
.get(player)) {
|
||||||
pl.sendBlockChange(
|
pl.sendBlockChange(
|
||||||
pBlock.getLocation(),
|
pBlock.getLocation(),
|
||||||
Material.STATIONARY_WATER,
|
Material.STATIONARY_WATER,
|
||||||
@ -528,7 +539,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
|||||||
pl.setGameMode(GameMode.SURVIVAL);
|
pl.setGameMode(GameMode.SURVIVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScoreboardHandler.doScoreboard(arena);
|
ScoreboardHandler.updateScoreboard(arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
SignsHandler.updateSigns();
|
SignsHandler.updateSigns();
|
||||||
|
@ -3,6 +3,7 @@ package nl.Steffion.BlockHunt.Commands;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import nl.Steffion.BlockHunt.Arena;
|
import nl.Steffion.BlockHunt.Arena;
|
||||||
|
import nl.Steffion.BlockHunt.ScoreboardHandler;
|
||||||
import nl.Steffion.BlockHunt.W;
|
import nl.Steffion.BlockHunt.W;
|
||||||
import nl.Steffion.BlockHunt.Arena.ArenaState;
|
import nl.Steffion.BlockHunt.Arena.ArenaState;
|
||||||
import nl.Steffion.BlockHunt.Managers.CommandC;
|
import nl.Steffion.BlockHunt.Managers.CommandC;
|
||||||
@ -11,6 +12,7 @@ import nl.Steffion.BlockHunt.Managers.MessageM;
|
|||||||
import nl.Steffion.BlockHunt.Managers.PlayerM;
|
import nl.Steffion.BlockHunt.Managers.PlayerM;
|
||||||
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
|
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -40,12 +42,15 @@ public class CMDcreate extends DefaultCMD {
|
|||||||
new ArrayList<String>(),
|
new ArrayList<String>(),
|
||||||
new ArrayList<Player>(),
|
new ArrayList<Player>(),
|
||||||
ArenaState.WAITING, 0,
|
ArenaState.WAITING, 0,
|
||||||
new ArrayList<Player>());
|
new ArrayList<Player>(), Bukkit
|
||||||
|
.getScoreboardManager()
|
||||||
|
.getNewScoreboard());
|
||||||
W.arenas.getFile().set(args[1], arena);
|
W.arenas.getFile().set(args[1], arena);
|
||||||
W.arenas.save();
|
W.arenas.save();
|
||||||
W.signs.load();
|
W.signs.load();
|
||||||
|
|
||||||
W.arenaList.add((Arena) arena);
|
W.arenaList.add((Arena) arena);
|
||||||
|
ScoreboardHandler.createScoreboard(arena);
|
||||||
|
|
||||||
MessageM.sendFMessage(player,
|
MessageM.sendFMessage(player,
|
||||||
ConfigC.normal_createCreatedArena, true,
|
ConfigC.normal_createCreatedArena, true,
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
package nl.Steffion.BlockHunt.Listeners;
|
package nl.Steffion.BlockHunt.Listeners;
|
||||||
|
|
||||||
import nl.Steffion.BlockHunt.Arena;
|
import nl.Steffion.BlockHunt.Arena;
|
||||||
import nl.Steffion.BlockHunt.ArenaHandler;
|
|
||||||
import nl.Steffion.BlockHunt.Arena.ArenaState;
|
import nl.Steffion.BlockHunt.Arena.ArenaState;
|
||||||
import nl.Steffion.BlockHunt.Managers.ConfigC;
|
import nl.Steffion.BlockHunt.ArenaHandler;
|
||||||
import nl.Steffion.BlockHunt.W;
|
import nl.Steffion.BlockHunt.W;
|
||||||
|
import nl.Steffion.BlockHunt.Managers.ConfigC;
|
||||||
|
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -43,8 +44,10 @@ public class OnEntityDamageByEntityEvent implements Listener {
|
|||||||
&& !arena.seekers.contains(player)) {
|
&& !arena.seekers.contains(player)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
} else {
|
} else {
|
||||||
|
player.getWorld().playSound(player.getLocation(),
|
||||||
|
Sound.HURT_FLESH, 1, 1);
|
||||||
player.getWorld().playEffect(player.getLocation(),
|
player.getWorld().playEffect(player.getLocation(),
|
||||||
Effect.BOW_FIRE, 0);
|
Effect.ENDER_SIGNAL, 0);
|
||||||
|
|
||||||
if (event.getDamage() >= player.getHealth()) {
|
if (event.getDamage() >= player.getHealth()) {
|
||||||
player.setHealth(20);
|
player.setHealth(20);
|
||||||
|
35
src/nl/Steffion/BlockHunt/PlayerArenaData.java
Normal file
35
src/nl/Steffion/BlockHunt/PlayerArenaData.java
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package nl.Steffion.BlockHunt;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
|
public class PlayerArenaData {
|
||||||
|
public Location pLocation;
|
||||||
|
public GameMode pGameMode;
|
||||||
|
public ItemStack[] pInventory;
|
||||||
|
public ItemStack[] pArmor;
|
||||||
|
public Float pEXP;
|
||||||
|
public Integer pEXPL;
|
||||||
|
public Double pHealth;
|
||||||
|
public Integer pFood;
|
||||||
|
public Collection<PotionEffect> pPotionEffects;
|
||||||
|
|
||||||
|
public PlayerArenaData (Location pLocation, GameMode pGameMode,
|
||||||
|
ItemStack[] pInventory, ItemStack[] pArmor, Float pEXP,
|
||||||
|
Integer pEXPL, Double pHealth, Integer pFood,
|
||||||
|
Collection<PotionEffect> pPotionEffects) {
|
||||||
|
this.pLocation = pLocation;
|
||||||
|
this.pGameMode = pGameMode;
|
||||||
|
this.pInventory = pInventory;
|
||||||
|
this.pArmor = pArmor;
|
||||||
|
this.pEXP = pEXP;
|
||||||
|
this.pEXPL = pEXPL;
|
||||||
|
this.pHealth = pHealth;
|
||||||
|
this.pFood = pFood;
|
||||||
|
this.pPotionEffects = pPotionEffects;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package nl.Steffion.BlockHunt;
|
package nl.Steffion.BlockHunt;
|
||||||
|
|
||||||
|
import nl.Steffion.BlockHunt.Arena.ArenaState;
|
||||||
import nl.Steffion.BlockHunt.Managers.MessageM;
|
import nl.Steffion.BlockHunt.Managers.MessageM;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -10,8 +11,13 @@ import org.bukkit.scoreboard.Score;
|
|||||||
import org.bukkit.scoreboard.Scoreboard;
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
|
||||||
public class ScoreboardHandler {
|
public class ScoreboardHandler {
|
||||||
public static void doScoreboard(Arena arena) {
|
public static void createScoreboard(Arena arena) {
|
||||||
Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
|
Scoreboard board = arena.scoreboard;
|
||||||
|
if (board.getObjective(arena.arenaName) != null) {
|
||||||
|
updateScoreboard(arena);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Objective object = board.registerNewObjective(arena.arenaName, "dummy");
|
Objective object = board.registerNewObjective(arena.arenaName, "dummy");
|
||||||
object.setDisplaySlot(DisplaySlot.SIDEBAR);
|
object.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
object.setDisplayName(MessageM.replaceAll(MessageM.CType.TAG()));
|
object.setDisplayName(MessageM.replaceAll(MessageM.CType.TAG()));
|
||||||
@ -24,9 +30,40 @@ public class ScoreboardHandler {
|
|||||||
Score hiders = object.getScore(Bukkit.getOfflinePlayer(MessageM
|
Score hiders = object.getScore(Bukkit.getOfflinePlayer(MessageM
|
||||||
.replaceAll("%NHiders:")));
|
.replaceAll("%NHiders:")));
|
||||||
hiders.setScore(arena.playersInArena.size() - arena.seekers.size());
|
hiders.setScore(arena.playersInArena.size() - arena.seekers.size());
|
||||||
|
if (arena.gameState == ArenaState.INGAME) {
|
||||||
|
for (Player pl : arena.playersInArena) {
|
||||||
|
pl.setScoreboard(board);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (Player pl : arena.playersInArena) {
|
||||||
|
pl.setScoreboard(Bukkit.getScoreboardManager()
|
||||||
|
.getNewScoreboard());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (Player pl : arena.playersInArena) {
|
public static void updateScoreboard(Arena arena) {
|
||||||
pl.setScoreboard(board);
|
Scoreboard board = arena.scoreboard;
|
||||||
|
Objective object = board.getObjective(DisplaySlot.SIDEBAR);
|
||||||
|
object.setDisplayName(MessageM.replaceAll(MessageM.CType.TAG()));
|
||||||
|
Score timeleft = object.getScore(Bukkit.getOfflinePlayer(MessageM
|
||||||
|
.replaceAll("%ATime left:")));
|
||||||
|
timeleft.setScore(arena.timer);
|
||||||
|
Score seekers = object.getScore(Bukkit.getOfflinePlayer(MessageM
|
||||||
|
.replaceAll("%NSeekers:")));
|
||||||
|
seekers.setScore(arena.seekers.size());
|
||||||
|
Score hiders = object.getScore(Bukkit.getOfflinePlayer(MessageM
|
||||||
|
.replaceAll("%NHiders:")));
|
||||||
|
hiders.setScore(arena.playersInArena.size() - arena.seekers.size());
|
||||||
|
if (arena.gameState == ArenaState.INGAME) {
|
||||||
|
for (Player pl : arena.playersInArena) {
|
||||||
|
pl.setScoreboard(board);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (Player pl : arena.playersInArena) {
|
||||||
|
pl.setScoreboard(Bukkit.getScoreboardManager()
|
||||||
|
.getNewScoreboard());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import nl.Steffion.BlockHunt.Managers.ConfigM;
|
|||||||
import nl.Steffion.BlockHunt.Managers.MessageM;
|
import nl.Steffion.BlockHunt.Managers.MessageM;
|
||||||
import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
|
import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -38,16 +37,25 @@ public class W {
|
|||||||
public static DisguiseCraftAPI dcAPI;
|
public static DisguiseCraftAPI dcAPI;
|
||||||
public static HashMap<Player, Integer> seekertime = new HashMap<Player, Integer>();
|
public static HashMap<Player, Integer> seekertime = new HashMap<Player, Integer>();
|
||||||
|
|
||||||
public static HashMap<Player, Location> pLocation = new HashMap<Player, Location>();
|
public static HashMap<Player, PlayerArenaData> pData = new HashMap<Player, PlayerArenaData>();
|
||||||
public static HashMap<Player, GameMode> pGameMode = new HashMap<Player, GameMode>();
|
|
||||||
public static HashMap<Player, ItemStack[]> pInventory = new HashMap<Player, ItemStack[]>();
|
|
||||||
public static HashMap<Player, ItemStack[]> pArmor = new HashMap<Player, ItemStack[]>();
|
|
||||||
public static HashMap<Player, Float> pEXP = new HashMap<Player, Float>();
|
|
||||||
public static HashMap<Player, Integer> pEXPL = new HashMap<Player, Integer>();
|
|
||||||
public static HashMap<Player, Double> pHealth = new HashMap<Player, Double>();
|
|
||||||
public static HashMap<Player, Integer> pFood = new HashMap<Player, Integer>();
|
|
||||||
public static HashMap<Player, ItemStack> pBlock = new HashMap<Player, ItemStack>();
|
|
||||||
|
|
||||||
|
// public static HashMap<Player, Location> pLocation = new HashMap<Player,
|
||||||
|
// Location>();
|
||||||
|
// public static HashMap<Player, GameMode> pGameMode = new HashMap<Player,
|
||||||
|
// GameMode>();
|
||||||
|
// public static HashMap<Player, ItemStack[]> pInventory = new
|
||||||
|
// HashMap<Player, ItemStack[]>();
|
||||||
|
// public static HashMap<Player, ItemStack[]> pArmor = new HashMap<Player,
|
||||||
|
// ItemStack[]>();
|
||||||
|
// public static HashMap<Player, Float> pEXP = new HashMap<Player, Float>();
|
||||||
|
// public static HashMap<Player, Integer> pEXPL = new HashMap<Player,
|
||||||
|
// Integer>();
|
||||||
|
// public static HashMap<Player, Double> pHealth = new HashMap<Player,
|
||||||
|
// Double>();
|
||||||
|
// public static HashMap<Player, Integer> pFood = new HashMap<Player,
|
||||||
|
// Integer>();
|
||||||
|
|
||||||
|
public static HashMap<Player, ItemStack> pBlock = new HashMap<Player, ItemStack>();
|
||||||
public static HashMap<Player, Location> moveLoc = new HashMap<Player, Location>();
|
public static HashMap<Player, Location> moveLoc = new HashMap<Player, Location>();
|
||||||
public static HashMap<Player, Location> hiddenLoc = new HashMap<Player, Location>();
|
public static HashMap<Player, Location> hiddenLoc = new HashMap<Player, Location>();
|
||||||
public static HashMap<Player, Boolean> hiddenLocWater = new HashMap<Player, Boolean>();
|
public static HashMap<Player, Boolean> hiddenLocWater = new HashMap<Player, Boolean>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user