Added lots of things, this is the last update for the first version!
This commit is contained in:
parent
5d2e0b7372
commit
a871b648c4
@ -22,6 +22,9 @@ public class Arena {
|
||||
public LocationSerializable lobbyWarp;
|
||||
public LocationSerializable hidersWarp;
|
||||
public LocationSerializable seekersWarp;
|
||||
public List<String> seekersWinCommands;
|
||||
public List<String> hidersWinCommands;
|
||||
|
||||
public List<Player> playersInArena;
|
||||
public ArenaState gameState;
|
||||
public int timer;
|
||||
@ -33,7 +36,8 @@ public class Arena {
|
||||
int waitingTimeSeeker, int gameTime,
|
||||
ArrayList<ItemStack> disguiseBlocks,
|
||||
LocationSerializable lobbyWarp, LocationSerializable hidersWarp,
|
||||
LocationSerializable seekersWarp, List<Player> playersInArena,
|
||||
LocationSerializable seekersWarp, List<String> seekersWinCommands,
|
||||
List<String> hidersWinCommands, List<Player> playersInArena,
|
||||
ArenaState gameState, int timer, List<Player> seekers) {
|
||||
this.arenaName = arenaName;
|
||||
this.pos1 = pos1;
|
||||
@ -52,6 +56,8 @@ public class Arena {
|
||||
this.lobbyWarp = lobbyWarp;
|
||||
this.hidersWarp = hidersWarp;
|
||||
this.seekersWarp = seekersWarp;
|
||||
this.seekersWinCommands = seekersWinCommands;
|
||||
this.hidersWinCommands = hidersWinCommands;
|
||||
}
|
||||
|
||||
public enum ArenaType {
|
||||
|
@ -1,17 +1,22 @@
|
||||
package nl.Steffion.BlockHunt;
|
||||
|
||||
import nl.Steffion.BlockHunt.Arena.ArenaState;
|
||||
|
||||
import nl.Steffion.BlockHunt.Managers.ConfigC;
|
||||
import nl.Steffion.BlockHunt.Managers.MessageM;
|
||||
import nl.Steffion.BlockHunt.Managers.MessageM.CType;
|
||||
import nl.Steffion.BlockHunt.Managers.PlayerM;
|
||||
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
|
||||
import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ArenaHandler {
|
||||
public static void loadArenas() {
|
||||
W.arenaList.clear();
|
||||
@ -61,52 +66,74 @@ public class ArenaHandler {
|
||||
} else {
|
||||
LocationSerializable zero = new LocationSerializable(
|
||||
Bukkit.getWorld("world"), 0, 0, 0, 0, 0);
|
||||
if (!arena.lobbyWarp.equals(zero)
|
||||
&& !arena.hidersWarp.equals(zero)
|
||||
&& !arena.seekersWarp.equals(zero)) {
|
||||
if (arena.gameState == ArenaState.WAITING
|
||||
|| arena.gameState == ArenaState.STARTING) {
|
||||
arena.playersInArena.add(player);
|
||||
if (arena.lobbyWarp != null && arena.hidersWarp != null
|
||||
&& arena.seekersWarp != null) {
|
||||
if (!arena.lobbyWarp.equals(zero)
|
||||
&& !arena.hidersWarp.equals(zero)
|
||||
&& !arena.seekersWarp.equals(zero)) {
|
||||
if (arena.gameState == ArenaState.WAITING
|
||||
|| arena.gameState == ArenaState.STARTING) {
|
||||
if (arena.playersInArena.size() >= arena.maxPlayers) {
|
||||
if (!PlayerM.hasPerm(player,
|
||||
PermsC.joinfull, false)) {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_joinFull,
|
||||
true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
arena.playersInArena.add(player);
|
||||
|
||||
W.pLocation.put(player, player.getLocation());
|
||||
W.pGameMode.put(player, player.getGameMode());
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
W.pInventory.put(player, player.getInventory()
|
||||
.getContents());
|
||||
player.getInventory().clear();
|
||||
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);
|
||||
W.pLocation.put(player,
|
||||
player.getLocation());
|
||||
W.pGameMode.put(player,
|
||||
player.getGameMode());
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
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);
|
||||
|
||||
player.teleport(arena.lobbyWarp);
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_joinJoinedArena, true,
|
||||
"playername-" + player.getName(), "1-"
|
||||
+ arena.playersInArena.size(),
|
||||
"2-" + arena.maxPlayers);
|
||||
if (arena.playersInArena.size() < arena.minPlayers) {
|
||||
player.teleport(arena.lobbyWarp);
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.warning_lobbyNeedAtleast,
|
||||
true, "1-" + arena.minPlayers);
|
||||
ConfigC.normal_joinJoinedArena,
|
||||
true,
|
||||
"playername-" + player.getName(),
|
||||
"1-" + arena.playersInArena.size(),
|
||||
"2-" + arena.maxPlayers);
|
||||
if (arena.playersInArena.size() < arena.minPlayers) {
|
||||
ArenaHandler
|
||||
.sendFMessage(
|
||||
arena,
|
||||
ConfigC.warning_lobbyNeedAtleast,
|
||||
true,
|
||||
"1-" + arena.minPlayers);
|
||||
}
|
||||
} else {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_joinArenaIngame, true);
|
||||
}
|
||||
} else {
|
||||
MessageM.sendFMessage(player,
|
||||
ConfigC.error_joinArenaIngame, true);
|
||||
ConfigC.error_joinWarpsNotSet, true);
|
||||
}
|
||||
} else {
|
||||
MessageM.sendFMessage(player,
|
||||
@ -124,9 +151,12 @@ public class ArenaHandler {
|
||||
MessageM.sendFMessage(player, ConfigC.error_noArena, true, "name-"
|
||||
+ arenaname);
|
||||
}
|
||||
|
||||
SignsHandler.updateSigns();
|
||||
}
|
||||
|
||||
public static void playerLeaveArena(Player player) {
|
||||
public static void playerLeaveArena(Player player, boolean message,
|
||||
boolean cleanup) {
|
||||
Arena arena = null;
|
||||
for (Arena arena2 : W.arenaList) {
|
||||
if (arena2.playersInArena != null) {
|
||||
@ -137,9 +167,35 @@ public class ArenaHandler {
|
||||
}
|
||||
|
||||
if (arena != null) {
|
||||
arena.playersInArena.remove(player);
|
||||
if (arena.seekers.contains(player)) {
|
||||
arena.seekers.remove(player);
|
||||
if (cleanup) {
|
||||
arena.playersInArena.remove(player);
|
||||
if (arena.seekers.contains(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,
|
||||
ConfigC.warning_lobbyNeedAtleast, true, "1-"
|
||||
+ arena.minPlayers);
|
||||
} else {
|
||||
ArenaHandler.seekersWin(arena);
|
||||
}
|
||||
} else if (arena.seekers.size() <= 0
|
||||
&& arena.gameState == ArenaState.INGAME) {
|
||||
Player seeker = arena.playersInArena.get(W.random
|
||||
.nextInt(arena.playersInArena.size()));
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.warning_ingameNEWSeekerChoosen, true,
|
||||
"seeker-" + seeker.getName());
|
||||
W.dcAPI.undisguisePlayer(player);
|
||||
player.getInventory().clear();
|
||||
arena.seekers.add(seeker);
|
||||
seeker.teleport(arena.seekersWarp);
|
||||
W.seekertime.put(seeker, arena.waitingTimeSeeker);
|
||||
}
|
||||
}
|
||||
|
||||
player.teleport(W.pLocation.get(player));
|
||||
@ -147,6 +203,7 @@ public class ArenaHandler {
|
||||
player.setGameMode(W.pGameMode.get(player));
|
||||
W.pGameMode.remove(player);
|
||||
player.getInventory().setContents(W.pInventory.get(player));
|
||||
player.updateInventory();
|
||||
W.pInventory.remove(player);
|
||||
player.getInventory().setArmorContents(W.pArmor.get(player));
|
||||
W.pArmor.remove(player);
|
||||
@ -164,13 +221,59 @@ public class ArenaHandler {
|
||||
}
|
||||
|
||||
MessageM.sendFMessage(player, ConfigC.normal_leaveYouLeft, true);
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_leaveLeftArena,
|
||||
true, "playername-" + player.getName(), "1-"
|
||||
+ arena.playersInArena.size(), "2-"
|
||||
+ arena.maxPlayers);
|
||||
if (message) {
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_leaveLeftArena,
|
||||
true, "playername-" + player.getName(), "1-"
|
||||
+ arena.playersInArena.size(), "2-"
|
||||
+ arena.maxPlayers);
|
||||
}
|
||||
} else {
|
||||
MessageM.sendFMessage(player, ConfigC.error_leaveNotInArena, true);
|
||||
if (message) {
|
||||
MessageM.sendFMessage(player, ConfigC.error_leaveNotInArena,
|
||||
true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
SignsHandler.updateSigns();
|
||||
}
|
||||
|
||||
public static void seekersWin(Arena arena) {
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_winSeekers, true);
|
||||
for (Player player : arena.playersInArena) {
|
||||
playerLeaveArena(player, false, false);
|
||||
player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 1);
|
||||
if (arena.seekersWinCommands != null) {
|
||||
for (String command : arena.seekersWinCommands) {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(),
|
||||
command.replaceAll("%player%", player.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
arena.playersInArena.clear();
|
||||
arena.seekers.clear();
|
||||
arena.gameState = ArenaState.WAITING;
|
||||
}
|
||||
|
||||
public static void hidersWin(Arena arena) {
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_winHiders, true);
|
||||
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.hidersWinCommands != null) {
|
||||
for (String command : arena.hidersWinCommands) {
|
||||
Bukkit.dispatchCommand(
|
||||
Bukkit.getConsoleSender(),
|
||||
command.replaceAll("%player%", player.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
arena.playersInArena.clear();
|
||||
arena.seekers.clear();
|
||||
arena.gameState = ArenaState.WAITING;
|
||||
}
|
||||
}
|
||||
|
@ -3,22 +3,35 @@ package nl.Steffion.BlockHunt;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import nl.Steffion.BlockHunt.Arena.ArenaState;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnBlockBreakEvent;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnBlockPlaceEvent;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnEntityDamageByEntityEvent;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnEntityDamageEvent;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnFoodLevelChangeEvent;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnPlayerCommandPreprocessEvent;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnPlayerDeathEvent;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnInventoryClickEvent;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnInventoryCloseEvent;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnPlayerDropItemEvent;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnPlayerInteractEvent;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnPlayerMoveEvent;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnPlayerQuitEvent;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnPlayerRespawnEvent;
|
||||
import nl.Steffion.BlockHunt.Listeners.OnSignChangeEvent;
|
||||
import nl.Steffion.BlockHunt.Managers.CommandC;
|
||||
import nl.Steffion.BlockHunt.Managers.ConfigC;
|
||||
import nl.Steffion.BlockHunt.Managers.MessageM;
|
||||
import nl.Steffion.BlockHunt.Serializables.ArenaSerializable;
|
||||
import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -34,17 +47,39 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
*/
|
||||
|
||||
public void onEnable() {
|
||||
|
||||
getServer().getPluginManager().registerEvents(this, this);
|
||||
|
||||
getServer().getPluginManager().registerEvents(new OnBlockBreakEvent(),
|
||||
this);
|
||||
getServer().getPluginManager().registerEvents(new OnBlockPlaceEvent(),
|
||||
this);
|
||||
getServer().getPluginManager().registerEvents(
|
||||
new OnPlayerInteractEvent(), this);
|
||||
new OnEntityDamageByEntityEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(
|
||||
new OnEntityDamageEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(
|
||||
new OnFoodLevelChangeEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(
|
||||
new OnInventoryClickEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(
|
||||
new OnInventoryCloseEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(
|
||||
new OnPlayerCommandPreprocessEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnPlayerDeathEvent(),
|
||||
this);
|
||||
getServer().getPluginManager().registerEvents(
|
||||
new OnPlayerDropItemEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(
|
||||
new OnPlayerInteractEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnPlayerMoveEvent(),
|
||||
this);
|
||||
getServer().getPluginManager().registerEvents(new OnPlayerQuitEvent(),
|
||||
this);
|
||||
getServer().getPluginManager().registerEvents(
|
||||
new OnPlayerRespawnEvent(this), this);
|
||||
getServer().getPluginManager().registerEvents(new OnSignChangeEvent(),
|
||||
this);
|
||||
|
||||
ConfigurationSerialization.registerClass(LocationSerializable.class,
|
||||
"Location");
|
||||
@ -55,6 +90,11 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
|
||||
ArenaHandler.loadArenas();
|
||||
|
||||
if (!getServer().getPluginManager().isPluginEnabled("DisguiseCraft")) {
|
||||
MessageM.broadcastFMessage(ConfigC.error_disguiseCraftNotInstalled,
|
||||
true);
|
||||
}
|
||||
|
||||
W.dcAPI = DisguiseCraft.getAPI();
|
||||
|
||||
MessageM.sendFMessage(null, ConfigC.log_Enabled, true, "name-"
|
||||
@ -74,8 +114,8 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
"1-" + arena.timeInLobbyUntilStart);
|
||||
}
|
||||
} else if (arena.gameState == ArenaState.STARTING) {
|
||||
arena.timer = arena.timer - 1;
|
||||
if (arena.timer > 0) {
|
||||
arena.timer = arena.timer - 1;
|
||||
if (arena.timer == 60) {
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_lobbyArenaIsStarting,
|
||||
@ -156,6 +196,18 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
|
||||
arenaPlayer.teleport(arena.hidersWarp);
|
||||
|
||||
arenaPlayer.getInventory().addItem(
|
||||
new ItemStack(Material.GOLD_SWORD,
|
||||
1));
|
||||
ItemStack blockCount = new ItemStack(block
|
||||
.getType(), 5);
|
||||
blockCount.setDurability(block
|
||||
.getDurability());
|
||||
arenaPlayer.getInventory().setItem(8,
|
||||
blockCount);
|
||||
arenaPlayer.getInventory().setHelmet(
|
||||
new ItemStack(block));
|
||||
|
||||
MessageM.sendFMessage(
|
||||
arenaPlayer,
|
||||
ConfigC.normal_ingameBlock,
|
||||
@ -200,18 +252,117 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (arena.gameState == ArenaState.INGAME) {
|
||||
arena.timer = arena.timer - 1;
|
||||
if (arena.timer > 0) {
|
||||
if (arena.timer == 190) {
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_ingameArenaEnd, true,
|
||||
"1-190");
|
||||
} else if (arena.timer == 60) {
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_ingameArenaEnd, true,
|
||||
"1-60");
|
||||
} else if (arena.timer == 30) {
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_ingameArenaEnd, true,
|
||||
"1-30");
|
||||
} else if (arena.timer == 10) {
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_ingameArenaEnd, true,
|
||||
"1-10");
|
||||
} else if (arena.timer == 5) {
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_ingameArenaEnd, true,
|
||||
"1-5");
|
||||
} else if (arena.timer == 4) {
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_ingameArenaEnd, true,
|
||||
"1-4");
|
||||
} else if (arena.timer == 3) {
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_ingameArenaEnd, true,
|
||||
"1-3");
|
||||
} else if (arena.timer == 2) {
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_ingameArenaEnd, true,
|
||||
"1-2");
|
||||
} else if (arena.timer == 1) {
|
||||
ArenaHandler.sendFMessage(arena,
|
||||
ConfigC.normal_ingameArenaEnd, true,
|
||||
"1-1");
|
||||
}
|
||||
} else {
|
||||
ArenaHandler.hidersWin(arena);
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : arena.playersInArena) {
|
||||
if (!arena.seekers.contains(player)) {
|
||||
Location pLoc = player.getLocation();
|
||||
Location moveLoc = W.moveLoc.get(player);
|
||||
ItemStack block = player.getInventory()
|
||||
.getItem(8);
|
||||
|
||||
if (moveLoc != null) {
|
||||
if (moveLoc.getX() == pLoc.getX()
|
||||
&& moveLoc.getY() == pLoc.getY()
|
||||
&& moveLoc.getZ() == pLoc.getZ()) {
|
||||
if (block.getAmount() > 1) {
|
||||
block.setAmount(block.getAmount() - 1);
|
||||
} else {
|
||||
Disguise dis = W.dcAPI
|
||||
.getDisguise(player);
|
||||
if (!dis.data.isEmpty()) {
|
||||
if (!dis.data
|
||||
.contains("blocklock")) {
|
||||
dis.addSingleData("blocklock");
|
||||
W.dcAPI.disguisePlayer(
|
||||
player, dis);
|
||||
block.addUnsafeEnchantment(
|
||||
Enchantment.DURABILITY,
|
||||
10);
|
||||
player.playSound(pLoc,
|
||||
Sound.ORB_PICKUP,
|
||||
1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Disguise dis = W.dcAPI
|
||||
.getDisguise(player);
|
||||
block.setAmount(5);
|
||||
if (!dis.data.isEmpty()) {
|
||||
if (dis.data.contains("blocklock")) {
|
||||
dis.data.remove("blocklock");
|
||||
W.dcAPI.disguisePlayer(player,
|
||||
dis);
|
||||
player.playSound(pLoc,
|
||||
Sound.BAT_HURT, 1, 1);
|
||||
block.removeEnchantment(Enchantment.DURABILITY);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Player pl : arena.playersInArena) {
|
||||
pl.setLevel(arena.timer);
|
||||
}
|
||||
}
|
||||
|
||||
SignsHandler.updateSigns();
|
||||
}
|
||||
}, 0, 20);
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.playersInArena != null) {
|
||||
for (Player player : arena.playersInArena) {
|
||||
ArenaHandler.playerLeaveArena(player);
|
||||
}
|
||||
}
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
ArenaHandler.playerLeaveArena(player, false, true);
|
||||
}
|
||||
|
||||
MessageM.sendFMessage(null, ConfigC.log_Disabled, true, "name-"
|
||||
|
@ -1,5 +1,7 @@
|
||||
package nl.Steffion.BlockHunt.Commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import nl.Steffion.BlockHunt.ArenaHandler;
|
||||
import nl.Steffion.BlockHunt.W;
|
||||
import nl.Steffion.BlockHunt.Managers.CommandC;
|
||||
@ -11,6 +13,7 @@ import nl.Steffion.BlockHunt.Serializables.ArenaSerializable;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class CMDcreate extends DefaultCMD {
|
||||
|
||||
@ -28,13 +31,17 @@ public class CMDcreate extends DefaultCMD {
|
||||
&& W.pos2.get(player) != null) {
|
||||
if (W.pos1.get(player).getWorld()
|
||||
.equals(W.pos2.get(player).getWorld())) {
|
||||
|
||||
ArenaSerializable arena = new ArenaSerializable(
|
||||
args[1], W.pos1.get(player),
|
||||
W.pos2.get(player), 12, 3, 1, 90, 20, 300,
|
||||
null, null, null, null, null, null, 0, null);
|
||||
new ArrayList<ItemStack>(), null, null,
|
||||
null, new ArrayList<String>(),
|
||||
new ArrayList<String>(), null, null, 0,
|
||||
null);
|
||||
W.arenas.getFile().set(args[1], arena);
|
||||
W.arenas.save();
|
||||
W.arenas.load();
|
||||
|
||||
ArenaHandler.loadArenas();
|
||||
|
||||
MessageM.sendFMessage(player,
|
||||
|
@ -24,6 +24,13 @@ public class CMDinfo extends DefaultCMD {
|
||||
"version-" + W.pluginVersion);
|
||||
MessageM.sendMessage(player, "%NType %A/%helpusage% %Nfor help.",
|
||||
false, "helpusage-" + CommandC.HELP.usage);
|
||||
MessageM.sendMessage(
|
||||
player,
|
||||
"%NDev-Page: %Ahttp://dev.bukkit.org/bukkit-plugins/blockhunt/",
|
||||
false);
|
||||
MessageM.sendMessage(player, "%NDonations are welcome!", false);
|
||||
MessageM.sendMessage(player,
|
||||
"%NMade by help from some friends &c<3%N!", false);
|
||||
MessageM.sendFMessage(player, ConfigC.chat_headerhigh, false,
|
||||
"header-&oInfo Page");
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ public class CMDleave extends DefaultCMD {
|
||||
String[] args) {
|
||||
if (PlayerM.hasPerm(player, PermsC.leave, true)) {
|
||||
if (player != null) {
|
||||
ArenaHandler.playerLeaveArena(player);
|
||||
ArenaHandler.playerLeaveArena(player, true, true);
|
||||
} else {
|
||||
MessageM.sendFMessage(player, ConfigC.error_onlyIngame, true);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ public class CMDreload extends DefaultCMD {
|
||||
W.config.load();
|
||||
W.messages.load();
|
||||
W.arenas.load();
|
||||
W.signs.load();
|
||||
ArenaHandler.loadArenas();
|
||||
W.newFiles();
|
||||
MessageM.sendFMessage(player, ConfigC.normal_reloadedConfigs, true);
|
||||
|
@ -2,7 +2,9 @@ package nl.Steffion.BlockHunt.Listeners;
|
||||
|
||||
import nl.Steffion.BlockHunt.Arena;
|
||||
import nl.Steffion.BlockHunt.W;
|
||||
|
||||
import nl.Steffion.BlockHunt.Managers.PlayerM;
|
||||
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -20,5 +22,12 @@ public class OnBlockBreakEvent implements Listener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getBlock().equals(Material.SIGN_POST)
|
||||
|| event.getBlock().equals(Material.WALL_SIGN)) {
|
||||
if (!PlayerM.hasPerm(player, PermsC.signcreate, true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import nl.Steffion.BlockHunt.Arena;
|
||||
import nl.Steffion.BlockHunt.Arena.ArenaState;
|
||||
import nl.Steffion.BlockHunt.W;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -33,6 +34,8 @@ public class OnEntityDamageByEntityEvent implements Listener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
player.playEffect(player.getLocation(), Effect.BOW_FIRE, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
32
src/nl/Steffion/BlockHunt/Listeners/OnEntityDamageEvent.java
Normal file
32
src/nl/Steffion/BlockHunt/Listeners/OnEntityDamageEvent.java
Normal file
@ -0,0 +1,32 @@
|
||||
package nl.Steffion.BlockHunt.Listeners;
|
||||
|
||||
import nl.Steffion.BlockHunt.Arena;
|
||||
import nl.Steffion.BlockHunt.Arena.ArenaState;
|
||||
import nl.Steffion.BlockHunt.W;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
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.EntityDamageEvent;
|
||||
|
||||
public class OnEntityDamageEvent implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onEntityDamageEvent(EntityDamageEvent event) {
|
||||
Entity ent = event.getEntity();
|
||||
|
||||
if (ent instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.gameState.equals(ArenaState.WAITING)
|
||||
|| arena.gameState.equals(ArenaState.STARTING)) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package nl.Steffion.BlockHunt.Listeners;
|
||||
|
||||
import nl.Steffion.BlockHunt.Arena;
|
||||
import nl.Steffion.BlockHunt.ArenaHandler;
|
||||
import nl.Steffion.BlockHunt.W;
|
||||
import nl.Steffion.BlockHunt.Managers.ConfigC;
|
||||
import nl.Steffion.BlockHunt.Managers.MessageM;
|
||||
@ -8,6 +10,7 @@ import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
|
||||
import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -74,5 +77,35 @@ public class OnPlayerInteractEvent implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if (event.getClickedBlock() != null) {
|
||||
if (event.getClickedBlock().getType()
|
||||
.equals(Material.SIGN_POST)
|
||||
|| event.getClickedBlock().getType()
|
||||
.equals(Material.WALL_SIGN)) {
|
||||
Sign sign = (Sign) event.getClickedBlock().getState();
|
||||
if (sign.getLine(1) != null) {
|
||||
if (sign.getLine(1).contains("LEAVE")) {
|
||||
if (PlayerM.hasPerm(player, PermsC.joinsign, true)) {
|
||||
ArenaHandler.playerLeaveArena(player, true,
|
||||
true);
|
||||
}
|
||||
} else {
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (sign.getLines()[1]
|
||||
.contains(arena.arenaName)) {
|
||||
if (PlayerM.hasPerm(player,
|
||||
PermsC.joinsign, true)) {
|
||||
ArenaHandler.playerJoinArena(player,
|
||||
arena.arenaName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package nl.Steffion.BlockHunt.Listeners;
|
||||
|
||||
import nl.Steffion.BlockHunt.Arena;
|
||||
import nl.Steffion.BlockHunt.W;
|
||||
import nl.Steffion.BlockHunt.Arena.ArenaState;
|
||||
import nl.Steffion.BlockHunt.W;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
@ -22,7 +22,7 @@ public class OnPlayerMoveEvent implements Listener {
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
if (arena.gameState == ArenaState.INGAME) {
|
||||
W.pLocation.put(player, player.getLocation());
|
||||
W.moveLoc.put(player, player.getLocation());
|
||||
double maxX = Math
|
||||
.max(arena.pos1.getX(), arena.pos2.getX());
|
||||
double minX = Math
|
||||
@ -37,51 +37,37 @@ public class OnPlayerMoveEvent implements Listener {
|
||||
.min(arena.pos1.getZ(), arena.pos2.getZ());
|
||||
|
||||
Location loc = player.getLocation();
|
||||
if (loc.getBlockX() > maxX || loc.getBlockX() < minX) {
|
||||
if (loc.getBlockX() > maxX) {
|
||||
event.setCancelled(true);
|
||||
player.playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
player.playSound(loc, Sound.GHAST_FIREBALL, 1, 1);
|
||||
player.teleport(loc.add(0, 2, 0));
|
||||
} else if (loc.getBlockZ() > maxZ || loc.getBlockZ() < minZ) {
|
||||
player.teleport(arena.hidersWarp);
|
||||
} else if (loc.getBlockX() < minX) {
|
||||
event.setCancelled(true);
|
||||
player.playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
player.playSound(loc, Sound.GHAST_FIREBALL, 1, 1);
|
||||
player.teleport(loc.add(0, 2, 0));
|
||||
player.teleport(arena.hidersWarp);
|
||||
} else if (loc.getBlockZ() > maxZ) {
|
||||
event.setCancelled(true);
|
||||
player.playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
player.playSound(loc, Sound.GHAST_FIREBALL, 1, 1);
|
||||
player.teleport(arena.hidersWarp);
|
||||
} else if (loc.getBlockZ() < minZ) {
|
||||
event.setCancelled(true);
|
||||
player.playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
player.playSound(loc, Sound.GHAST_FIREBALL, 1, 1);
|
||||
player.teleport(arena.hidersWarp);
|
||||
} else if (loc.getBlockY() > maxY) {
|
||||
event.setCancelled(true);
|
||||
player.playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
player.playSound(loc, Sound.GHAST_FIREBALL, 1, 1);
|
||||
player.teleport(loc.subtract(0, 1, 0));
|
||||
player.teleport(arena.hidersWarp);
|
||||
} else if (loc.getBlockY() < minY) {
|
||||
event.setCancelled(true);
|
||||
player.playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
player.playSound(loc, Sound.GHAST_FIREBALL, 1, 1);
|
||||
player.teleport(loc.add(0, 5, 0));
|
||||
player.teleport(arena.hidersWarp);
|
||||
}
|
||||
|
||||
// Location pLocation = W.pLocation.get(player);
|
||||
// ItemStack block = player.getInventory().getItem(8);
|
||||
//
|
||||
// if (pLocation.getX() == pLoc.getX()
|
||||
// && pLocation.getY() == pLoc.getY()
|
||||
// && pLocation.getZ() == pLoc.getZ()) {
|
||||
// if (block.getAmount() > 1) {
|
||||
// block.setAmount(block.getAmount() - 1);
|
||||
// } else {
|
||||
// Disguise dis = W.dcAPI.getDisguise(player);
|
||||
// dis.addSingleData("blocklock");
|
||||
// W.dcAPI.changePlayerDisguise(player, dis);
|
||||
// block.addEnchantment(Enchantment.DURABILITY, 10);
|
||||
// player.playSound(pLoc, Sound.ORB_PICKUP, 1, 1);
|
||||
// }
|
||||
// } else {
|
||||
// Disguise dis = W.dcAPI.getDisguise(player);
|
||||
// dis.data.remove("blocklock");
|
||||
// W.dcAPI.changePlayerDisguise(player, dis);
|
||||
// player.playSound(pLoc, Sound.BAT_HURT, 1, 1);
|
||||
// block.removeEnchantment(Enchantment.DURABILITY);
|
||||
// block.setAmount(5);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,24 +24,18 @@ public class OnPlayerRespawnEvent implements Listener {
|
||||
public void onPlayerRespawnEvent(final PlayerRespawnEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.seekers.contains(player)) {
|
||||
if (arena.seekers.size() >= arena.playersInArena.size()) {
|
||||
player.teleport(W.pLocation.get(player));
|
||||
ArenaHandler.seekersWin(arena);
|
||||
} else {
|
||||
W.dcAPI.undisguisePlayer(player);
|
||||
W.seekertime.put(player, arena.waitingTimeSeeker);
|
||||
player.teleport(arena.seekersWarp);
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
}
|
||||
}
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.seekers.contains(player)) {
|
||||
if (arena.seekers.size() >= arena.playersInArena.size()) {
|
||||
event.setRespawnLocation(W.pLocation.get(player));
|
||||
ArenaHandler.seekersWin(arena);
|
||||
} else {
|
||||
W.dcAPI.undisguisePlayer(player);
|
||||
W.seekertime.put(player, arena.waitingTimeSeeker);
|
||||
event.setRespawnLocation(arena.seekersWarp);
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
}
|
||||
}
|
||||
}, 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
30
src/nl/Steffion/BlockHunt/Listeners/OnSignChangeEvent.java
Normal file
30
src/nl/Steffion/BlockHunt/Listeners/OnSignChangeEvent.java
Normal file
@ -0,0 +1,30 @@
|
||||
package nl.Steffion.BlockHunt.Listeners;
|
||||
|
||||
import nl.Steffion.BlockHunt.SignsHandler;
|
||||
import nl.Steffion.BlockHunt.W;
|
||||
import nl.Steffion.BlockHunt.Managers.PlayerM;
|
||||
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
|
||||
import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
public class OnSignChangeEvent implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onSignChangeEvent(SignChangeEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
String[] lines = event.getLines();
|
||||
if (lines[0] != null) {
|
||||
if (lines[0].equalsIgnoreCase("[" + W.pluginName + "]")) {
|
||||
if (PlayerM.hasPerm(player, PermsC.signcreate, true)) {
|
||||
SignsHandler.createSign(lines, new LocationSerializable(
|
||||
event.getBlock().getLocation()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -34,6 +34,16 @@ public enum ConfigC {
|
||||
"%NUse the create command to define your arena.",
|
||||
"%A/" + W.pluginName + " <help|h>" }, W.config),
|
||||
|
||||
sign_LEAVE (new String[] { "%H[" + W.pluginName + "%H]", "&4LEAVE",
|
||||
"&8Right-Click", "&8To leave." }, W.config),
|
||||
sign_WAITING (new String[] { "%H[" + W.pluginName + "%H]", "%A%arenaname%",
|
||||
"%A%players%%N/%A%maxplayers%", "&8Waiting..." }, W.config),
|
||||
sign_STARTING (new String[] { "%H[" + W.pluginName + "%H]",
|
||||
"%A%arenaname%", "%A%players%%N/%A%maxplayers%",
|
||||
"&2Starting! %A%timeleft%" }, W.config),
|
||||
sign_INGAME (new String[] { "%H[" + W.pluginName + "%H]", "%A%arenaname%",
|
||||
"%A%players%%N/%A%maxplayers%", "%EIn-game." }, W.config),
|
||||
|
||||
log_Enabled ("%N%name%&a&k + %N%version% is now Enabled. Made by %A%autors%%N.",
|
||||
W.messages),
|
||||
log_Disabled ("%N%name%&c&k - %N%version% is now Disabled. Made by %A%autors%%N.",
|
||||
@ -70,17 +80,29 @@ public enum ConfigC {
|
||||
W.messages),
|
||||
normal_lobbyArenaIsStarting ("%NThe arena will start in %A%1%%N second(s)!",
|
||||
W.messages),
|
||||
normal_lobbyArenaStarted ("%NThe arena has been started! The seeker is comming to find you in %A%secs%%N second(s)!",
|
||||
normal_lobbyArenaStarted ("%NThe arena has been started! The seeker is coming to find you in %A%secs%%N seconds!",
|
||||
W.messages),
|
||||
normal_ingameSeekerChoosen ("%NPlayer %A%seeker%%N has been choosen as seeker!",
|
||||
W.messages),
|
||||
normal_ingameBlock ("%NYou're disguised as a(n) '%A%block%%N' block.",
|
||||
W.messages),
|
||||
normal_ingameArenaEnd ("%NThe arena will end in %A%1%%N second(s)!",
|
||||
W.messages),
|
||||
normal_HiderDied ("%NHider %A%playername%%N died! %A%left%%N hiders remain...",
|
||||
W.messages),
|
||||
normal_SeekerDied ("%NSeeker %A%playername%%N died! He will respawn in %A%secs%%N seconds!",
|
||||
W.messages),
|
||||
normal_winSeekers ("%NThe %ASEEKERS%N have won!", W.messages),
|
||||
normal_winHiders ("%NThe %AHIDERS%N have won!", W.messages),
|
||||
normal_setwarpWarpSet ("%NSet warp '%A%warp%%N' to your location!",
|
||||
W.messages),
|
||||
|
||||
warning_lobbyNeedAtleast ("%WYou need atleast %A%1%%W player(s) to start the game!",
|
||||
W.messages),
|
||||
warning_ingameNEWSeekerChoosen ("%WThe last seeker left and a new seeker has been choosen!",
|
||||
W.messages),
|
||||
warning_unableToCommand ("%WSorry but that command is disabled in the arena.",
|
||||
W.messages),
|
||||
|
||||
error_noPermission ("%EYou don't have the permissions to do that!",
|
||||
W.messages),
|
||||
@ -89,6 +111,8 @@ public enum ConfigC {
|
||||
+ W.pluginName + " help %Efor more info.", W.messages),
|
||||
error_notEnoughArguments ("%EYou're missing arguments, correct syntax: %A/%syntax%",
|
||||
W.messages),
|
||||
error_disguiseCraftNotInstalled ("%EThe plugin '%ADisguiseCraft%E' is required to run this plugin! Intall it or it won't work!",
|
||||
W.messages),
|
||||
error_noArena ("%ENo arena found with the name '%A%name%%E'.", W.messages),
|
||||
error_onlyIngame ("%EThis is an only in-game command!", W.messages),
|
||||
error_joinAlreadyJoined ("%EYou've already joined an arena!", W.messages),
|
||||
@ -97,6 +121,7 @@ public enum ConfigC {
|
||||
error_joinWarpsNotSet ("%EThere are no warps set for this arena. Notify the administrator.",
|
||||
W.messages),
|
||||
error_joinArenaIngame ("%EThis game has already started.", W.messages),
|
||||
error_joinFull ("%EUnable to join this arena. It's full!", W.messages),
|
||||
error_leaveNotInArena ("%EYou're not in an arena!", W.messages),
|
||||
error_createSelectionFirst ("%EMake a selection first. Use the wand command: %A/"
|
||||
+ W.pluginName + " <wand|w>%E.",
|
||||
|
@ -18,13 +18,15 @@ public class PlayerM {
|
||||
public enum PermsC {
|
||||
info (main + "info", PType.ALL),
|
||||
help (main + "help", PType.ALL),
|
||||
reload (main + "reload", PType.MODERATOR),
|
||||
reload (main + "reload", PType.ADMIN),
|
||||
join (main + "join", PType.PLAYER),
|
||||
joinfull (main + "joinfull", PType.MODERATOR),
|
||||
joinsign (main + "joinsign", PType.PLAYER),
|
||||
leave (main + "leave", PType.PLAYER),
|
||||
create (main + "create", PType.ADMIN),
|
||||
set (main + "set", PType.MODERATOR),
|
||||
setwarp (main + "setwarp", PType.MODERATOR);
|
||||
setwarp (main + "setwarp", PType.MODERATOR),
|
||||
signcreate (main + "signcreate", PType.MODERATOR);
|
||||
|
||||
public String perm;
|
||||
public PType type;
|
||||
|
192
src/nl/Steffion/BlockHunt/SignsHandler.java
Normal file
192
src/nl/Steffion/BlockHunt/SignsHandler.java
Normal file
@ -0,0 +1,192 @@
|
||||
package nl.Steffion.BlockHunt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import nl.Steffion.BlockHunt.Arena.ArenaState;
|
||||
import nl.Steffion.BlockHunt.Managers.ConfigC;
|
||||
import nl.Steffion.BlockHunt.Managers.MessageM;
|
||||
import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Sign;
|
||||
|
||||
public class SignsHandler {
|
||||
|
||||
public static void createSign(String[] lines, LocationSerializable location) {
|
||||
if (lines[1] != null) {
|
||||
if (lines[1].equalsIgnoreCase("leave")) {
|
||||
boolean saved = false;
|
||||
int number = 1;
|
||||
while (!saved) {
|
||||
if (W.signs.getFile().get("leave_" + number) == null) {
|
||||
W.signs.getFile().set("leave_" + number + ".arenaName",
|
||||
"leave");
|
||||
W.signs.getFile().set("leave_" + number + ".location",
|
||||
location);
|
||||
W.signs.save();
|
||||
|
||||
saved = true;
|
||||
} else {
|
||||
number = number + 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (lines[1].equalsIgnoreCase(arena.arenaName)) {
|
||||
boolean saved = false;
|
||||
int number = 1;
|
||||
while (!saved) {
|
||||
if (W.signs.getFile().get(
|
||||
arena.arenaName + "_" + number) == null) {
|
||||
W.signs.getFile().set(
|
||||
arena.arenaName + "_" + number
|
||||
+ ".arenaName", lines[1]);
|
||||
W.signs.getFile().set(
|
||||
arena.arenaName + "_" + number
|
||||
+ ".location", location);
|
||||
W.signs.save();
|
||||
|
||||
saved = true;
|
||||
} else {
|
||||
number = number + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeSign(LocationSerializable location) {
|
||||
for (String sign : W.signs.getFile().getKeys(false)) {
|
||||
LocationSerializable loc = new LocationSerializable(
|
||||
(LocationSerializable) W.signs.getFile().get(
|
||||
sign + ".location"));
|
||||
if (loc.equals(location)) {
|
||||
W.signs.getFile().set(sign, null);
|
||||
W.signs.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void updateSigns() {
|
||||
W.signs.load();
|
||||
for (String sign : W.signs.getFile().getKeys(false)) {
|
||||
LocationSerializable loc = new LocationSerializable(
|
||||
(LocationSerializable) W.signs.getFile().get(
|
||||
sign + ".location"));
|
||||
if (loc.getBlock().getType().equals(Material.SIGN_POST)
|
||||
|| loc.getBlock().getType().equals(Material.WALL_SIGN)) {
|
||||
Sign signblock = (Sign) loc.getBlock().getState();
|
||||
String[] lines = signblock.getLines();
|
||||
if (sign.contains("leave")) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config
|
||||
.getFile()
|
||||
.getList(ConfigC.sign_LEAVE.getLocation());
|
||||
int linecount = 0;
|
||||
for (String line : signLines) {
|
||||
if (linecount <= 3) {
|
||||
signblock.setLine(linecount,
|
||||
MessageM.replaceAll(line));
|
||||
}
|
||||
|
||||
linecount = linecount + 1;
|
||||
}
|
||||
signblock.update();
|
||||
} else {
|
||||
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (lines[1].contains(arena.arenaName)) {
|
||||
if (arena.gameState.equals(ArenaState.WAITING)) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config
|
||||
.getFile().getList(
|
||||
ConfigC.sign_WAITING
|
||||
.getLocation());
|
||||
int linecount = 0;
|
||||
for (String line : signLines) {
|
||||
if (linecount <= 3) {
|
||||
signblock
|
||||
.setLine(
|
||||
linecount,
|
||||
MessageM.replaceAll(
|
||||
line,
|
||||
"arenaname-"
|
||||
+ arena.arenaName,
|
||||
"players-"
|
||||
+ arena.playersInArena
|
||||
.size(),
|
||||
"maxplayers-"
|
||||
+ arena.maxPlayers,
|
||||
"timeleft-"
|
||||
+ arena.gameTime));
|
||||
}
|
||||
|
||||
linecount = linecount + 1;
|
||||
}
|
||||
signblock.update();
|
||||
} else if (arena.gameState
|
||||
.equals(ArenaState.STARTING)) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config
|
||||
.getFile().getList(
|
||||
ConfigC.sign_STARTING
|
||||
.getLocation());
|
||||
int linecount = 0;
|
||||
for (String line : signLines) {
|
||||
if (linecount <= 3) {
|
||||
signblock
|
||||
.setLine(
|
||||
linecount,
|
||||
MessageM.replaceAll(
|
||||
line,
|
||||
"arenaname-"
|
||||
+ arena.arenaName,
|
||||
"players-"
|
||||
+ arena.playersInArena
|
||||
.size(),
|
||||
"maxplayers-"
|
||||
+ arena.maxPlayers,
|
||||
"timeleft-"
|
||||
+ arena.gameTime));
|
||||
}
|
||||
|
||||
linecount = linecount + 1;
|
||||
}
|
||||
signblock.update();
|
||||
} else if (arena.gameState
|
||||
.equals(ArenaState.INGAME)) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) W.config
|
||||
.getFile().getList(
|
||||
ConfigC.sign_INGAME
|
||||
.getLocation());
|
||||
int linecount = 0;
|
||||
for (String line : signLines) {
|
||||
if (linecount <= 3) {
|
||||
signblock
|
||||
.setLine(
|
||||
linecount,
|
||||
MessageM.replaceAll(
|
||||
line,
|
||||
"arenaname-"
|
||||
+ arena.arenaName,
|
||||
"players-"
|
||||
+ arena.playersInArena
|
||||
.size(),
|
||||
"maxplayers-"
|
||||
+ arena.maxPlayers,
|
||||
"timeleft-"
|
||||
+ arena.gameTime));
|
||||
}
|
||||
|
||||
linecount = linecount + 1;
|
||||
}
|
||||
signblock.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
removeSign(loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -31,6 +31,7 @@ public class W {
|
||||
public static ConfigM config = new ConfigM("config", "");
|
||||
public static ConfigM messages = new ConfigM("messages", "");
|
||||
public static ConfigM arenas = new ConfigM("arenas", "");
|
||||
public static ConfigM signs = new ConfigM("signs", "");
|
||||
public static ArrayList<Arena> arenaList = new ArrayList<Arena>();
|
||||
public static Random random = new Random();
|
||||
public static DisguiseCraftAPI dcAPI;
|
||||
@ -44,7 +45,7 @@ public class W {
|
||||
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, Location> moveLoc = new HashMap<Player, Location>();
|
||||
|
||||
public static void newFiles() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user