+ Added a delay on getting a sword as hider.

This commit is contained in:
Steffion 2013-08-28 14:36:03 +02:00
parent 6d695775c1
commit 7fa828e4b2
6 changed files with 55 additions and 16 deletions

View File

@ -26,6 +26,7 @@ public class Arena implements ConfigurationSerializable {
public int timeInLobbyUntilStart; public int timeInLobbyUntilStart;
public int waitingTimeSeeker; public int waitingTimeSeeker;
public int gameTime; public int gameTime;
public int timeUntilHidersSword;
public ArrayList<ItemStack> disguiseBlocks; public ArrayList<ItemStack> disguiseBlocks;
public LocationSerializable lobbyWarp; public LocationSerializable lobbyWarp;
public LocationSerializable hidersWarp; public LocationSerializable hidersWarp;
@ -43,7 +44,7 @@ public class Arena implements ConfigurationSerializable {
public Arena (String arenaName, LocationSerializable pos1, public Arena (String arenaName, LocationSerializable pos1,
LocationSerializable pos2, int maxPlayers, int minPlayers, LocationSerializable pos2, int maxPlayers, int minPlayers,
int amountSeekersOnStart, int timeInLobbyUntilStart, int amountSeekersOnStart, int timeInLobbyUntilStart,
int waitingTimeSeeker, int gameTime, int waitingTimeSeeker, int gameTime, int timeUntilHidersSword,
ArrayList<ItemStack> disguiseBlocks, ArrayList<ItemStack> disguiseBlocks,
LocationSerializable lobbyWarp, LocationSerializable hidersWarp, LocationSerializable lobbyWarp, LocationSerializable hidersWarp,
LocationSerializable seekersWarp, List<String> seekersWinCommands, LocationSerializable seekersWarp, List<String> seekersWinCommands,
@ -59,6 +60,7 @@ public class Arena implements ConfigurationSerializable {
this.timeInLobbyUntilStart = timeInLobbyUntilStart; this.timeInLobbyUntilStart = timeInLobbyUntilStart;
this.waitingTimeSeeker = waitingTimeSeeker; this.waitingTimeSeeker = waitingTimeSeeker;
this.gameTime = gameTime; this.gameTime = gameTime;
this.timeUntilHidersSword = timeUntilHidersSword;
this.disguiseBlocks = disguiseBlocks; this.disguiseBlocks = disguiseBlocks;
this.lobbyWarp = lobbyWarp; this.lobbyWarp = lobbyWarp;
this.hidersWarp = hidersWarp; this.hidersWarp = hidersWarp;
@ -80,7 +82,8 @@ public class Arena implements ConfigurationSerializable {
amountSeekersOnStart, amountSeekersOnStart,
timeInLobbyUntilStart, timeInLobbyUntilStart,
waitingTimeSeeker, waitingTimeSeeker,
gameTime; gameTime,
timeUntilHidersSword;
} }
public enum ArenaState { public enum ArenaState {
@ -99,6 +102,7 @@ public class Arena implements ConfigurationSerializable {
map.put("timeInLobbyUntilStart", timeInLobbyUntilStart); map.put("timeInLobbyUntilStart", timeInLobbyUntilStart);
map.put("waitingTimeSeeker", waitingTimeSeeker); map.put("waitingTimeSeeker", waitingTimeSeeker);
map.put("gameTime", gameTime); map.put("gameTime", gameTime);
map.put("timeUntilHidersSword", timeUntilHidersSword);
map.put("disguiseBlocks", disguiseBlocks); map.put("disguiseBlocks", disguiseBlocks);
map.put("lobbyWarp", lobbyWarp); map.put("lobbyWarp", lobbyWarp);
map.put("hidersWarp", hidersWarp); map.put("hidersWarp", hidersWarp);
@ -121,8 +125,10 @@ public class Arena implements ConfigurationSerializable {
"amountSeekersOnStart", 1), (Integer) M.g(map, "amountSeekersOnStart", 1), (Integer) M.g(map,
"timeInLobbyUntilStart", 90), (Integer) M.g(map, "timeInLobbyUntilStart", 90), (Integer) M.g(map,
"waitingTimeSeeker", 20), (Integer) M.g(map, "waitingTimeSeeker", 20), (Integer) M.g(map,
"gameTime", 200), (ArrayList<ItemStack>) M.g(map, "gameTime", 200), (Integer) M.g(map,
"disguiseBlocks", new ArrayList<ItemStack>()), "timeUntilHidersSword", 30),
(ArrayList<ItemStack>) M.g(map, "disguiseBlocks",
new ArrayList<ItemStack>()),
(LocationSerializable) M.g(map, "lobbyWarp", loc), (LocationSerializable) M.g(map, "lobbyWarp", loc),
(LocationSerializable) M.g(map, "hidersWarp", loc), (LocationSerializable) M.g(map, "hidersWarp", loc),
(LocationSerializable) M.g(map, "seekersWarp", loc), (LocationSerializable) M.g(map, "seekersWarp", loc),

View File

@ -251,12 +251,6 @@ public class BlockHunt extends JavaPlugin implements Listener {
} }
arenaPlayer.teleport(arena.hidersWarp); arenaPlayer.teleport(arena.hidersWarp);
ItemStack sword = new ItemStack(
Material.WOOD_SWORD, 1);
sword.addUnsafeEnchantment(
Enchantment.KNOCKBACK, 1);
arenaPlayer.getInventory().addItem(sword);
ItemStack blockCount = new ItemStack(block ItemStack blockCount = new ItemStack(block
.getType(), 5); .getType(), 5);
@ -334,6 +328,23 @@ public class BlockHunt extends JavaPlugin implements Listener {
if (arena.gameState == ArenaState.INGAME) { if (arena.gameState == ArenaState.INGAME) {
arena.timer = arena.timer - 1; arena.timer = arena.timer - 1;
if (arena.timer > 0) { if (arena.timer > 0) {
if (arena.timer == arena.gameTime
- arena.timeUntilHidersSword) {
ItemStack sword = new ItemStack(
Material.WOOD_SWORD, 1);
sword.addUnsafeEnchantment(
Enchantment.KNOCKBACK, 1);
for (Player arenaPlayer : arena.playersInArena) {
if (!arena.seekers.contains(arenaPlayer)) {
arenaPlayer.getInventory().addItem(
sword);
MessageM.sendFMessage(
arenaPlayer,
ConfigC.normal_ingameGivenSword,
true);
}
}
}
if (arena.timer == 190) { if (arena.timer == 190) {
ArenaHandler.sendFMessage(arena, ArenaHandler.sendFMessage(arena,
ConfigC.normal_ingameArenaEnd, true, ConfigC.normal_ingameArenaEnd, true,

View File

@ -35,7 +35,7 @@ public class CMDcreate extends DefaultCMD {
.equals(W.pos2.get(player).getWorld())) { .equals(W.pos2.get(player).getWorld())) {
Arena arena = new Arena(args[1], Arena arena = new Arena(args[1],
W.pos1.get(player), W.pos2.get(player), 12, W.pos1.get(player), W.pos2.get(player), 12,
3, 1, 50, 20, 300, 3, 1, 50, 20, 300, 30,
new ArrayList<ItemStack>(), null, null, new ArrayList<ItemStack>(), null, null,
null, new ArrayList<String>(), null, new ArrayList<String>(),
new ArrayList<String>(), new ArrayList<String>(),

View File

@ -88,6 +88,13 @@ public class InventoryHandler {
disguiseBlocks_NOTE.setItemMeta(disguiseBlocks_NOTE_IM); disguiseBlocks_NOTE.setItemMeta(disguiseBlocks_NOTE_IM);
panel.setItem(37, disguiseBlocks_NOTE); panel.setItem(37, disguiseBlocks_NOTE);
ItemStack timeUntilHidersSword_UP = new ItemStack(
Material.GOLD_NUGGET, 1);
ItemStack timeUntilHidersSword = new ItemStack(
Material.PISTON_MOVING_PIECE, arena.timeUntilHidersSword);
ItemStack timeUntilHidersSword_DOWN = new ItemStack(
Material.GOLD_NUGGET, 1);
// //
updownButton(panel, arena, ArenaType.maxPlayers, "maxPlayers", "1", updownButton(panel, arena, ArenaType.maxPlayers, "maxPlayers", "1",
@ -113,6 +120,11 @@ public class InventoryHandler {
"1 %Nsecond", gameTime_UP, gameTime, gameTime_DOWN, 8, 17, "1 %Nsecond", gameTime_UP, gameTime, gameTime_DOWN, 8, 17,
26); 26);
updownButton(panel, arena, ArenaType.timeUntilHidersSword,
"timeUntilHidersSword", "1 %Nsecond",
timeUntilHidersSword_UP, timeUntilHidersSword,
timeUntilHidersSword_DOWN, 30, 39, 48);
player.openInventory(panel); player.openInventory(panel);
} else { } else {
MessageM.sendFMessage(player, ConfigC.error_noArena, true, "name-" MessageM.sendFMessage(player, ConfigC.error_noArena, true, "name-"
@ -149,6 +161,9 @@ public class InventoryHandler {
case gameTime: case gameTime:
setting = arena.gameTime; setting = arena.gameTime;
break; break;
case timeUntilHidersSword:
setting = arena.timeUntilHidersSword;
break;
} }
ItemMeta BUTTON_IM = BUTTON.getItemMeta(); ItemMeta BUTTON_IM = BUTTON.getItemMeta();

View File

@ -98,6 +98,11 @@ public class OnInventoryClickEvent implements Listener {
.contains("gameTime")) { .contains("gameTime")) {
updownButton(player, item, arena, ArenaType.gameTime, updownButton(player, item, arena, ArenaType.gameTime,
arena.gameTime, 1000, 5, 1, 1); arena.gameTime, 1000, 5, 1, 1);
} else if (item.getItemMeta().getDisplayName()
.contains("timeUntilHidersSword")) {
updownButton(player, item, arena,
ArenaType.timeUntilHidersSword,
arena.timeUntilHidersSword, 1000, 0, 1, 1);
} }
save(arena); save(arena);
@ -124,9 +129,6 @@ public class OnInventoryClickEvent implements Listener {
if (item.getItemMeta().getDisplayName() if (item.getItemMeta().getDisplayName()
.contains((String) W.messages.get(ConfigC.button_add2))) { .contains((String) W.messages.get(ConfigC.button_add2))) {
if (option < max) { if (option < max) {
// W.arenas.getFile().set(arenaname + "." + option, option +
// add);
switch (at) { switch (at) {
case maxPlayers: case maxPlayers:
arena.maxPlayers = option + add; arena.maxPlayers = option + add;
@ -146,6 +148,9 @@ public class OnInventoryClickEvent implements Listener {
case gameTime: case gameTime:
arena.gameTime = option + add; arena.gameTime = option + add;
break; break;
case timeUntilHidersSword:
arena.timeUntilHidersSword = option + add;
break;
} }
} else { } else {
MessageM.sendFMessage(player, ConfigC.error_setTooHighNumber, MessageM.sendFMessage(player, ConfigC.error_setTooHighNumber,
@ -154,8 +159,6 @@ public class OnInventoryClickEvent implements Listener {
} else if (item.getItemMeta().getDisplayName() } else if (item.getItemMeta().getDisplayName()
.contains((String) W.messages.get(ConfigC.button_remove2))) { .contains((String) W.messages.get(ConfigC.button_remove2))) {
if (option > min) { if (option > min) {
// W.arenas.getFile().set(arenaname + "." + option,
// option - remove);
switch (at) { switch (at) {
case maxPlayers: case maxPlayers:
arena.maxPlayers = option - remove; arena.maxPlayers = option - remove;
@ -175,6 +178,9 @@ public class OnInventoryClickEvent implements Listener {
case gameTime: case gameTime:
arena.gameTime = option - remove; arena.gameTime = option - remove;
break; break;
case timeUntilHidersSword:
arena.timeUntilHidersSword = option - remove;
break;
} }
} else { } else {
MessageM.sendFMessage(player, ConfigC.error_setTooLowNumber, MessageM.sendFMessage(player, ConfigC.error_setTooLowNumber,

View File

@ -104,6 +104,7 @@ public enum ConfigC {
W.messages), W.messages),
normal_ingameArenaEnd ("%NThe arena will end in %A%1%%N second(s)!", normal_ingameArenaEnd ("%NThe arena will end in %A%1%%N second(s)!",
W.messages), W.messages),
normal_ingameGivenSword ("%NYou were given a sword!", W.messages),
normal_HiderDied ("%NHider %A%playername%%N died! %A%left%%N hider(s) remain...", normal_HiderDied ("%NHider %A%playername%%N died! %A%left%%N hider(s) remain...",
W.messages), W.messages),
normal_SeekerDied ("%NSeeker %A%playername%%N died! He will respawn in %A%secs%%N seconds!", normal_SeekerDied ("%NSeeker %A%playername%%N died! He will respawn in %A%secs%%N seconds!",