Merge branch 'pull/54'
# Conflicts: # pom.xml
This commit is contained in:
commit
f1647babf8
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,6 @@
|
||||
target/
|
||||
lib/
|
||||
/bin/
|
||||
|
||||
.idea/
|
||||
*.iml
|
||||
|
4
pom.xml
4
pom.xml
@ -2,13 +2,13 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>nl.Steffion</groupId>
|
||||
<artifactId>BlockHunt</artifactId>
|
||||
<version>0.4.0-SNAPSHOT</version>
|
||||
<version>0.5.0-SNAPSHOT</version>
|
||||
<name>BlockHunt</name>
|
||||
<properties>
|
||||
<plugin.version>${project.version}-${buildnumber}</plugin.version>
|
||||
<buildnumber />
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spigot.api.version>1.13</spigot.api.version>
|
||||
<spigot.api.version>1.15</spigot.api.version>
|
||||
<spigot.version>${spigot.api.version}.2-R0.1-SNAPSHOT</spigot.version>
|
||||
</properties>
|
||||
<scm>
|
||||
|
@ -5,9 +5,8 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -17,8 +16,8 @@ import org.bukkit.scoreboard.Scoreboard;
|
||||
@SerializableAs("BlockHuntArena")
|
||||
public class Arena implements ConfigurationSerializable {
|
||||
public String arenaName;
|
||||
public LocationSerializable pos1;
|
||||
public LocationSerializable pos2;
|
||||
public Location pos1;
|
||||
public Location pos2;
|
||||
public int maxPlayers;
|
||||
public int minPlayers;
|
||||
public int amountSeekersOnStart;
|
||||
@ -33,10 +32,10 @@ public class Arena implements ConfigurationSerializable {
|
||||
public boolean seekersTakeFallDamage;
|
||||
public boolean hidersTakeFallDamage;
|
||||
public ArrayList<ItemStack> disguiseBlocks;
|
||||
public LocationSerializable lobbyWarp;
|
||||
public LocationSerializable hidersWarp;
|
||||
public LocationSerializable seekersWarp;
|
||||
public LocationSerializable spawnWarp;
|
||||
public Location lobbyWarp;
|
||||
public Location hidersWarp;
|
||||
public Location seekersWarp;
|
||||
public Location spawnWarp;
|
||||
public List<String> seekersWinCommands;
|
||||
public List<String> hidersWinCommands;
|
||||
public List<String> allowedCommands;
|
||||
@ -50,10 +49,10 @@ public class Arena implements ConfigurationSerializable {
|
||||
public List<Player> seekers;
|
||||
public Scoreboard scoreboard;
|
||||
|
||||
public Arena(String arenaName, LocationSerializable pos1, LocationSerializable pos2, int maxPlayers, int minPlayers, int amountSeekersOnStart,
|
||||
public Arena(String arenaName, Location pos1, Location pos2, int maxPlayers, int minPlayers, int amountSeekersOnStart,
|
||||
int timeInLobbyUntilStart, int waitingTimeSeeker, int gameTime, int timeUntilHidersSword, int blockAnnouncerTime,
|
||||
boolean seekersCanHurtSeekers, boolean hidersCanHurtSeekers, boolean hidersCanHurtHiders, boolean seekersTakeFallDamage, boolean hidersTakeFallDamage,
|
||||
ArrayList<ItemStack> disguiseBlocks, LocationSerializable lobbyWarp, LocationSerializable hidersWarp, LocationSerializable seekersWarp, LocationSerializable spawnWarp,
|
||||
ArrayList<ItemStack> disguiseBlocks, Location lobbyWarp, Location hidersWarp, Location seekersWarp, Location spawnWarp,
|
||||
List<String> seekersWinCommands, List<String> hidersWinCommands, List<String> allowedCommands, int seekersTokenWin, int hidersTokenWin, int killTokens,
|
||||
List<Player> playersInArena, ArenaState gameState, int timer, List<Player> seekers, Scoreboard scoreboard) {
|
||||
this.arenaName = arenaName;
|
||||
@ -83,7 +82,6 @@ public class Arena implements ConfigurationSerializable {
|
||||
this.seekersTokenWin = seekersTokenWin;
|
||||
this.hidersTokenWin = hidersTokenWin;
|
||||
this.killTokens = killTokens;
|
||||
|
||||
this.playersInArena = playersInArena;
|
||||
this.gameState = gameState;
|
||||
this.timer = timer;
|
||||
@ -124,9 +122,14 @@ public class Arena implements ConfigurationSerializable {
|
||||
map.put("amountSeekersOnStart", amountSeekersOnStart);
|
||||
map.put("timeInLobbyUntilStart", timeInLobbyUntilStart);
|
||||
map.put("waitingTimeSeeker", waitingTimeSeeker);
|
||||
map.put("blockAnnouncerTime", blockAnnouncerTime);
|
||||
map.put("gameTime", gameTime);
|
||||
map.put("timeUntilHidersSword", timeUntilHidersSword);
|
||||
map.put("blockAnnouncerTime", blockAnnouncerTime);
|
||||
map.put("seekersCanHurtSeekers", seekersCanHurtSeekers);
|
||||
map.put("hidersCanHurtSeekers", hidersCanHurtSeekers);
|
||||
map.put("hidersCanHurtHiders", hidersCanHurtHiders);
|
||||
map.put("seekersTakeFallDamage", seekersTakeFallDamage);
|
||||
map.put("hidersTakeFallDamage", hidersTakeFallDamage);
|
||||
map.put("disguiseBlocks", disguiseBlocks);
|
||||
map.put("lobbyWarp", lobbyWarp);
|
||||
map.put("hidersWarp", hidersWarp);
|
||||
@ -143,15 +146,36 @@ public class Arena implements ConfigurationSerializable {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Arena deserialize(Map<String, Object> map) {
|
||||
LocationSerializable loc = new LocationSerializable(Bukkit.getWorld("world"), 0, 0, 0, 0, 0);
|
||||
return new Arena((String) map.getOrDefault("arenaName", "UNKNOWN_NAME"), (LocationSerializable) map.getOrDefault("pos1", loc), (LocationSerializable) map.getOrDefault( "pos2", loc),
|
||||
(Integer) map.getOrDefault( "maxPlayers", 12), (Integer) map.getOrDefault( "minPlayers", 3), (Integer) map.getOrDefault( "amountSeekersOnStart", 1), (Integer) map.getOrDefault( "timeInLobbyUntilStart", 90),
|
||||
(Integer) map.getOrDefault( "waitingTimeSeeker", 20), (Integer) map.getOrDefault( "gameTime", 200), (Integer) map.getOrDefault( "timeUntilHidersSword", 30),(Integer) map.getOrDefault( "blockAnnouncerTime", 45),
|
||||
(Boolean) map.getOrDefault( "seekersCanHurtSeekers", false),(Boolean) map.getOrDefault( "hidersCanHurtSeekers", false),(Boolean) map.getOrDefault( "hidersCanHurtHiders", false),(Boolean) map.getOrDefault( "seekersTakeFallDamage", false),(Boolean) map.getOrDefault( "hidersTakeFallDamage", false),
|
||||
(ArrayList<ItemStack>) map.getOrDefault( "disguiseBlocks", new ArrayList<ItemStack>()),(LocationSerializable) map.getOrDefault( "lobbyWarp", loc), (LocationSerializable) map.getOrDefault( "hidersWarp", loc), (LocationSerializable) map.getOrDefault( "seekersWarp", loc),
|
||||
(LocationSerializable) map.getOrDefault( "spawnWarp", loc), (ArrayList<String>) map.getOrDefault( "seekersWinCommands", new ArrayList<String>()),
|
||||
(ArrayList<String>) map.getOrDefault("hidersWinCommands", new ArrayList<String>()), (ArrayList<String>) map.getOrDefault( "allowedCommands", new ArrayList<String>()),
|
||||
(Integer) map.getOrDefault( "seekersTokenWin", 10), (Integer) map.getOrDefault( "hidersTokenWin", 50), (Integer) map.getOrDefault( "killTokens", 8), new ArrayList<>(),
|
||||
ArenaState.WAITING, 0, new ArrayList<>(), Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
Location loc = new Location(Bukkit.getWorld("world"), 0, 0, 0, 0, 0);
|
||||
return new Arena(
|
||||
(String) map.getOrDefault("arenaName", "UNKNOWN_NAME"),
|
||||
(Location) map.getOrDefault("pos1", loc),
|
||||
(Location) map.getOrDefault("pos2", loc),
|
||||
(Integer) map.getOrDefault("maxPlayers", 12),
|
||||
(Integer) map.getOrDefault("minPlayers", 3),
|
||||
(Integer) map.getOrDefault("amountSeekersOnStart", 1),
|
||||
(Integer) map.getOrDefault("timeInLobbyUntilStart", 90),
|
||||
(Integer) map.getOrDefault("waitingTimeSeeker", 20),
|
||||
(Integer) map.getOrDefault("gameTime", 200),
|
||||
(Integer) map.getOrDefault("timeUntilHidersSword", 30),
|
||||
(Integer) map.getOrDefault("blockAnnouncerTime", 45),
|
||||
(Boolean) map.getOrDefault("seekersCanHurtSeekers", false),
|
||||
(Boolean) map.getOrDefault("hidersCanHurtSeekers", true),
|
||||
(Boolean) map.getOrDefault("hidersCanHurtHiders", false),
|
||||
(Boolean) map.getOrDefault("seekersTakeFallDamage", false),
|
||||
(Boolean) map.getOrDefault("hidersTakeFallDamage", false),
|
||||
(ArrayList<ItemStack>) map.getOrDefault("disguiseBlocks", new ArrayList<ItemStack>()),
|
||||
(Location) map.getOrDefault("lobbyWarp", loc),
|
||||
(Location) map.getOrDefault("hidersWarp", loc),
|
||||
(Location) map.getOrDefault("seekersWarp", loc),
|
||||
(Location) map.getOrDefault("spawnWarp", loc),
|
||||
(ArrayList<String>) map.getOrDefault("seekersWinCommands", new ArrayList<String>()),
|
||||
(ArrayList<String>) map.getOrDefault("hidersWinCommands", new ArrayList<String>()),
|
||||
(ArrayList<String>) map.getOrDefault("allowedCommands", new ArrayList<String>()),
|
||||
(Integer) map.getOrDefault("seekersTokenWin", 10),
|
||||
(Integer) map.getOrDefault("hidersTokenWin", 50),
|
||||
(Integer) map.getOrDefault("killTokens", 8),
|
||||
new ArrayList<>(), ArenaState.WAITING, 0, new ArrayList<>(), Bukkit.getScoreboardManager().getNewScoreboard()
|
||||
);
|
||||
}
|
||||
}
|
@ -96,6 +96,13 @@ public class ArenaHandler {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
boolean canWarp = PlayerHandler.teleport(player, arena.lobbyWarp);
|
||||
if (!canWarp) {
|
||||
MessageManager.sendFMessage(player, ConfigC.error_teleportFailed);
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println("[BlockHunt] " + player.getName() + " has joined " + arenaname);
|
||||
arena.playersInArena.add(player);
|
||||
JoinArenaEvent event = new JoinArenaEvent(player, arena);
|
||||
@ -107,7 +114,6 @@ public class ArenaHandler {
|
||||
|
||||
MemoryStorage.pData.put(player, pad);
|
||||
|
||||
player.teleport(arena.lobbyWarp);
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
for (PotionEffect pe : player.getActivePotionEffects()) {
|
||||
player.removePotionEffect(pe.getType());
|
||||
@ -130,14 +136,14 @@ public class ArenaHandler {
|
||||
// they join
|
||||
for (Player otherplayer : arena.playersInArena) {
|
||||
if (otherplayer.canSee(player))
|
||||
otherplayer.showPlayer(player); // Make
|
||||
otherplayer.showPlayer(BlockHunt.plugin, player); // Make
|
||||
// new
|
||||
// player
|
||||
// visible
|
||||
// to
|
||||
// others
|
||||
if (player.canSee(otherplayer))
|
||||
player.showPlayer(otherplayer); // Make
|
||||
player.showPlayer(BlockHunt.plugin, otherplayer); // Make
|
||||
// other
|
||||
// players
|
||||
// visible
|
||||
@ -263,21 +269,21 @@ public class ArenaHandler {
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameSeekerChoosen, "seeker-" + seeker.getName());
|
||||
DisguiseAPI.undisguiseToAll(seeker);
|
||||
for (Player pl : Bukkit.getOnlinePlayers()) {
|
||||
pl.showPlayer(seeker);
|
||||
pl.showPlayer(BlockHunt.plugin, seeker);
|
||||
}
|
||||
seeker.getInventory().clear();
|
||||
arena.seekers.add(seeker);
|
||||
seeker.teleport(arena.seekersWarp);
|
||||
PlayerHandler.teleport(seeker, arena.seekersWarp);
|
||||
MemoryStorage.seekertime.put(seeker, arena.waitingTimeSeeker);
|
||||
seeker.setWalkSpeed(0.3F);
|
||||
|
||||
// Fix for client not showing players after they join
|
||||
for (Player otherplayer : arena.playersInArena) {
|
||||
if (otherplayer.canSee(player))
|
||||
otherplayer.showPlayer(player); // Make new player
|
||||
otherplayer.showPlayer(BlockHunt.plugin, player); // Make new player
|
||||
// visible to others
|
||||
if (player.canSee(otherplayer))
|
||||
player.showPlayer(otherplayer); // Make other
|
||||
player.showPlayer(BlockHunt.plugin, otherplayer); // Make other
|
||||
// players visible
|
||||
// to new player
|
||||
}
|
||||
@ -300,7 +306,7 @@ public class ArenaHandler {
|
||||
player.setHealth(pad.pHealth);
|
||||
player.setFoodLevel(pad.pFood);
|
||||
player.addPotionEffects(pad.pPotionEffects);
|
||||
player.teleport(arena.spawnWarp);
|
||||
PlayerHandler.teleport(player, arena.spawnWarp);
|
||||
player.setGameMode(pad.pGameMode);
|
||||
player.setAllowFlight(pad.pFlying);
|
||||
if (player.getAllowFlight()) {
|
||||
@ -309,9 +315,10 @@ public class ArenaHandler {
|
||||
player.setWalkSpeed(0.2F);
|
||||
|
||||
MemoryStorage.pData.remove(player);
|
||||
MemoryStorage.choosenBlock.remove(player);
|
||||
|
||||
for (Player pl : Bukkit.getOnlinePlayers()) {
|
||||
pl.showPlayer(player);
|
||||
pl.showPlayer(BlockHunt.plugin, player);
|
||||
if (MemoryStorage.hiddenLoc.get(player) != null) {
|
||||
if (MemoryStorage.hiddenLocWater.get(player) != null) {
|
||||
Block pBlock = MemoryStorage.hiddenLoc.get(player).getBlock();
|
||||
@ -434,7 +441,7 @@ public class ArenaHandler {
|
||||
arena.timer = 0;
|
||||
arena.playersInArena.clear();
|
||||
}
|
||||
|
||||
|
||||
public static boolean noPlayersInArenas() {
|
||||
// Check if there are any players in any arena (quick way to early exit for event handlers)
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
|
@ -7,6 +7,7 @@ import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import me.libraryaddict.disguise.disguisetypes.MiscDisguise;
|
||||
import nl.Steffion.BlockHunt.Arena.ArenaState;
|
||||
import nl.Steffion.BlockHunt.Listeners.*;
|
||||
import nl.Steffion.BlockHunt.PermissionsC.Permissions;
|
||||
import nl.Steffion.BlockHunt.Commands.CMDcreate;
|
||||
import nl.Steffion.BlockHunt.Commands.CMDhelp;
|
||||
@ -23,23 +24,10 @@ import nl.Steffion.BlockHunt.Commands.CMDshop;
|
||||
import nl.Steffion.BlockHunt.Commands.CMDstart;
|
||||
import nl.Steffion.BlockHunt.Commands.CMDtokens;
|
||||
import nl.Steffion.BlockHunt.Commands.CMDwand;
|
||||
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.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.OnSignChangeEvent;
|
||||
import nl.Steffion.BlockHunt.Managers.CommandManager;
|
||||
import nl.Steffion.BlockHunt.Managers.ConfigManager;
|
||||
import nl.Steffion.BlockHunt.Managers.MessageManager;
|
||||
import nl.Steffion.BlockHunt.Managers.PermissionsManager;
|
||||
import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
@ -49,6 +37,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
@ -121,6 +110,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
getServer().getPluginManager().registerEvents(new OnFoodLevelChangeEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnInventoryClickEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnInventoryCloseEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnPlayerSwapHandItemsEvent(), this);
|
||||
|
||||
// Removed - This is handled by WorldGuard now.
|
||||
// getServer().getPluginManager().registerEvents(
|
||||
@ -129,10 +119,10 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
getServer().getPluginManager().registerEvents(new OnPlayerDropItemEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnPlayerInteractEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnPlayerMoveEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnPlayerTeleportEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnPlayerQuitEvent(), this);
|
||||
getServer().getPluginManager().registerEvents(new OnSignChangeEvent(), this);
|
||||
|
||||
ConfigurationSerialization.registerClass(LocationSerializable.class, "BlockHuntLocation");
|
||||
ConfigurationSerialization.registerClass(Arena.class, "BlockHuntArena");
|
||||
|
||||
pdfFile = getDescription();
|
||||
@ -186,7 +176,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
|
||||
ArenaHandler.loadArenas();
|
||||
|
||||
MessageManager.sendFMessage(null, ConfigC.log_enabledPlugin, "name-" + BlockHunt.pdfFile.getName(), "version-" + BlockHunt.pdfFile.getVersion(), "autors-"
|
||||
MessageManager.sendFMessage(null, ConfigC.log_enabledPlugin, "name-" + BlockHunt.pdfFile.getName(), "version-" + BlockHunt.pdfFile.getVersion(), "authors-"
|
||||
+ BlockHunt.pdfFile.getAuthors().get(0));
|
||||
|
||||
// Welcome to the massive game loop!!
|
||||
@ -250,7 +240,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
if (!arena.seekers.contains(seeker)) {
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameSeekerChoosen, "seeker-" + seeker.getName());
|
||||
arena.seekers.add(seeker);
|
||||
seeker.teleport(arena.seekersWarp);
|
||||
PlayerHandler.teleport(seeker, arena.seekersWarp);
|
||||
seeker.getInventory().clear();
|
||||
seeker.updateInventory();
|
||||
seeker.setWalkSpeed(0.3F);
|
||||
@ -272,24 +262,17 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
MemoryStorage.choosenBlock.remove(arenaPlayer);
|
||||
}
|
||||
|
||||
MiscDisguise disguise = new MiscDisguise(DisguiseType.FALLING_BLOCK, block.getType(),0);
|
||||
MiscDisguise disguise = new MiscDisguise(DisguiseType.FALLING_BLOCK, block.getType());
|
||||
DisguiseAPI.disguiseToAll(arenaPlayer, disguise);
|
||||
|
||||
arenaPlayer.teleport(arena.hidersWarp);
|
||||
|
||||
PlayerHandler.teleport(arenaPlayer, arena.hidersWarp);
|
||||
ItemStack blockCount = new ItemStack(block.getType(), 5);
|
||||
blockCount.setDurability(block.getDurability());
|
||||
arenaPlayer.getInventory().setItem(8, blockCount);
|
||||
arenaPlayer.getInventory().setHelmet(new ItemStack(block));
|
||||
MemoryStorage.pBlock.put(arenaPlayer, block);
|
||||
|
||||
if (block.getDurability() != 0) {
|
||||
MessageManager.sendFMessage(arenaPlayer, ConfigC.normal_ingameBlock,
|
||||
"block-" + block.getType().name().replaceAll("_", "").replaceAll("BLOCK", "").toLowerCase() + ":" + block.getDurability());
|
||||
} else {
|
||||
MessageManager.sendFMessage(arenaPlayer, ConfigC.normal_ingameBlock,
|
||||
"block-" + block.getType().name().replaceAll("_", "").replaceAll("BLOCK", "").toLowerCase());
|
||||
}
|
||||
String blockName = block.getType().name();
|
||||
blockName = WordUtils.capitalizeFully(blockName.replace("_", " "));
|
||||
MessageManager.sendFMessage(arenaPlayer, ConfigC.normal_ingameBlock,
|
||||
"block-" + blockName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -297,6 +280,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
|
||||
for (Player player : arena.seekers) {
|
||||
if (player.getInventory().getItem(0) == null || player.getInventory().getItem(0).getType() != Material.DIAMOND_SWORD) {
|
||||
player.getInventory().clear(); // semi prevent duping infinite swords. TODO: Fix this properly
|
||||
ItemStack i = new ItemStack(Material.DIAMOND_SWORD, 1);
|
||||
i.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 10);
|
||||
player.getInventory().setItem(0, i);
|
||||
@ -314,7 +298,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
if (MemoryStorage.seekertime.get(player) != null) {
|
||||
MemoryStorage.seekertime.put(player, MemoryStorage.seekertime.get(player) - 1);
|
||||
if (MemoryStorage.seekertime.get(player) <= 0) {
|
||||
player.teleport(arena.hidersWarp);
|
||||
PlayerHandler.teleport(player, arena.hidersWarp);
|
||||
MemoryStorage.seekertime.remove(player);
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameSeekerSpawned, "playername-" + player.getName());
|
||||
}
|
||||
@ -326,7 +310,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
if (arena.timer > 0) {
|
||||
if (arena.timer == arena.gameTime - arena.timeUntilHidersSword) {
|
||||
ItemStack sword = new ItemStack(Material.WOODEN_SWORD, 1);
|
||||
sword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1);
|
||||
sword.addUnsafeEnchantment(Enchantment.KNOCKBACK, 2);
|
||||
for (Player arenaPlayer : arena.playersInArena) {
|
||||
if (!arena.seekers.contains(arenaPlayer)) {
|
||||
arenaPlayer.getInventory().addItem(sword);
|
||||
@ -400,9 +384,10 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
block.setAmount(block.getAmount() - 1);
|
||||
} else {
|
||||
Block pBlock = player.getLocation().getBlock();
|
||||
if (pBlock.getType().equals(Material.AIR) || pBlock.getType().equals(Material.WATER)
|
||||
|| pBlock.getType().equals(Material.WATER)) {
|
||||
if (pBlock.getType().equals(Material.WATER) || pBlock.getType().equals(Material.WATER)) {
|
||||
BlockData pBlockData = pBlock.getBlockData();
|
||||
if (pBlockData.getMaterial().equals(Material.AIR) || pBlockData.getMaterial().equals(Material.WATER)
|
||||
|| pBlockData.getMaterial().equals(Material.WATER)) {
|
||||
if (pBlockData.getMaterial().equals(Material.WATER) || pBlockData.getMaterial().equals(Material.WATER)) {
|
||||
MemoryStorage.hiddenLocWater.put(player, true);
|
||||
} else {
|
||||
MemoryStorage.hiddenLocWater.put(player, false);
|
||||
@ -411,29 +396,23 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
DisguiseAPI.undisguiseToAll(player);
|
||||
for (Player pl : Bukkit.getOnlinePlayers()) {
|
||||
if (!pl.equals(player)) {
|
||||
pl.hidePlayer(player);
|
||||
pl.sendBlockChange(pBlock.getLocation(), block.getType(), (byte) block.getDurability());
|
||||
pl.hidePlayer(this, player);
|
||||
pl.sendBlockChange(pBlock.getLocation(), block.getType().createBlockData());
|
||||
}
|
||||
}
|
||||
|
||||
block.addUnsafeEnchantment(Enchantment.DURABILITY, 10);
|
||||
player.playSound(pLoc, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
|
||||
MemoryStorage.hiddenLoc.put(player, moveLoc);
|
||||
if (block.getDurability() != 0) {
|
||||
MessageManager.sendFMessage(
|
||||
player,
|
||||
ConfigC.normal_ingameNowSolid,
|
||||
"block-" + block.getType().name().replaceAll("_", "").replaceAll("BLOCK", "").toLowerCase() + ":"
|
||||
+ block.getDurability());
|
||||
} else {
|
||||
MessageManager.sendFMessage(player, ConfigC.normal_ingameNowSolid, "block-"
|
||||
+ block.getType().name().replaceAll("_", "").replaceAll("BLOCK", "").toLowerCase());
|
||||
}
|
||||
String blockName = block.getType().name();
|
||||
blockName = WordUtils.capitalizeFully(blockName.replace("_", " "));
|
||||
MessageManager.sendFMessage(player, ConfigC.normal_ingameNowSolid, "block-"
|
||||
+ blockName);
|
||||
}
|
||||
for (Player pl : Bukkit.getOnlinePlayers()) {
|
||||
if (!pl.equals(player)) {
|
||||
pl.hidePlayer(player);
|
||||
pl.sendBlockChange(pBlock.getLocation(), block.getType(), (byte) block.getDurability());
|
||||
pl.hidePlayer(this, player);
|
||||
pl.sendBlockChange(pBlock.getLocation(), block.getType().createBlockData());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -454,7 +433,11 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
|
||||
for (Player pl : arena.playersInArena) {
|
||||
pl.setLevel(arena.timer);
|
||||
pl.setGameMode(GameMode.SURVIVAL);
|
||||
if (arena.seekers.contains(pl)) {
|
||||
pl.setGameMode(GameMode.SURVIVAL);
|
||||
} else {
|
||||
pl.setGameMode(GameMode.ADVENTURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
SignsHandler.updateSigns(); //TODO Only do this when needed (gamestate change or player count change)
|
||||
@ -467,18 +450,18 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
ArenaHandler.stopArena(arena, cause, ConfigC.warning_arenaStopped);
|
||||
}
|
||||
|
||||
MessageManager.sendFMessage(null, ConfigC.log_disabledPlugin, "name-" + BlockHunt.pdfFile.getName(), "version-" + BlockHunt.pdfFile.getVersion(), "autors-"
|
||||
MessageManager.sendFMessage(null, ConfigC.log_disabledPlugin, "name-" + BlockHunt.pdfFile.getName(), "version-" + BlockHunt.pdfFile.getVersion(), "authors-"
|
||||
+ BlockHunt.pdfFile.getAuthors().get(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Args to String. Makes 1 string.
|
||||
*
|
||||
*
|
||||
* @param input
|
||||
* String list which should be converted to a string.
|
||||
* @param startArg
|
||||
* Start on this length.
|
||||
*
|
||||
*
|
||||
* @return The converted string.
|
||||
*/
|
||||
public static String stringBuilder(String[] input, int startArg) {
|
||||
@ -539,7 +522,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
new CMDnotfound().execute(player,cmd,label, args);;
|
||||
new CMDnotfound().execute(player,cmd,label, args);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -559,7 +542,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
|
||||
|
||||
/**
|
||||
* Short a String for like the Scoreboard title.
|
||||
*
|
||||
*
|
||||
* @param string
|
||||
* String to be shorten.
|
||||
* @param maxLenght
|
||||
|
@ -7,7 +7,6 @@ import nl.Steffion.BlockHunt.Arena.ArenaState;
|
||||
import nl.Steffion.BlockHunt.MemoryStorage;
|
||||
import nl.Steffion.BlockHunt.Managers.MessageManager;
|
||||
|
||||
import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -22,7 +21,7 @@ public class CMDcreate extends DefaultCMD {
|
||||
} else {
|
||||
if (MemoryStorage.pos1.get(player) != null && MemoryStorage.pos2.get(player) != null) {
|
||||
if (MemoryStorage.pos1.get(player).getWorld().equals(MemoryStorage.pos2.get(player).getWorld())) {
|
||||
Arena arena = new Arena(args[1], new LocationSerializable(MemoryStorage.pos1.get(player)), new LocationSerializable(MemoryStorage.pos2.get(player)), 12, 3, 1, 50, 20, 300, 30, 45, false, false, false, false, false, new ArrayList<>(), null, null, null,
|
||||
Arena arena = new Arena(args[1], MemoryStorage.pos1.get(player), MemoryStorage.pos2.get(player), 12, 3, 1, 50, 20, 300, 30, 45, false, false, false, false, false, new ArrayList<>(), null, null, null,
|
||||
null, new ArrayList<>(), new ArrayList<>(), new ArrayList<>(), 10, 50, 8, new ArrayList<>(), ArenaState.WAITING,
|
||||
0, new ArrayList<>(), Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
MemoryStorage.arenas.getFile().set(args[1], arena);
|
||||
|
@ -23,7 +23,7 @@ public class CMDinfo extends DefaultCMD {
|
||||
@Override
|
||||
public boolean execute(Player player, Command cmd, String label, String[] args) {
|
||||
MessageManager.sendFMessage(player, ConfigC.chat_headerhigh, "header-" + BlockHunt.pdfFile.getName());
|
||||
MessageManager.sendMessage(player, "%A%name%%N made by %A%autors%%N.", "name-" + BlockHunt.pdfFile.getName(), "autors-" + BlockHunt.pdfFile.getAuthors().get(0));
|
||||
MessageManager.sendMessage(player, "%A%name%%N made by %A%authors%%N.", "name-" + BlockHunt.pdfFile.getName(), "authors-" + BlockHunt.pdfFile.getAuthors().get(0));
|
||||
MessageManager.sendMessage(player, "%NVersion: %A%version%%N.", "version-" + BlockHunt.pdfFile.getVersion());
|
||||
MessageManager.sendMessage(player, "%NType %A%helpusage% %Nfor help.", "helpusage-" + BlockHunt.CMDhelp.usage);
|
||||
MessageManager.sendMessage(player, "%NDev-Page: %Ahttp://dev.bukkit.org/bukkit-plugins/blockhunt/");
|
||||
|
@ -4,7 +4,6 @@ import nl.Steffion.BlockHunt.*;
|
||||
import nl.Steffion.BlockHunt.MemoryStorage;
|
||||
import nl.Steffion.BlockHunt.Managers.MessageManager;
|
||||
|
||||
import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -29,19 +28,19 @@ public class CMDsetwarp extends DefaultCMD {
|
||||
if (arena != null) {
|
||||
Location loc = player.getLocation();
|
||||
if (warpname.equalsIgnoreCase("lobby")) {
|
||||
arena.lobbyWarp = new LocationSerializable(loc);
|
||||
arena.lobbyWarp = loc;
|
||||
save(arena);
|
||||
MessageManager.sendFMessage(player, ConfigC.normal_setwarpWarpSet, "warp-" + warpname);
|
||||
} else if (warpname.equalsIgnoreCase("hiders")) {
|
||||
arena.hidersWarp = new LocationSerializable(loc);
|
||||
arena.hidersWarp = loc;
|
||||
save(arena);
|
||||
MessageManager.sendFMessage(player, ConfigC.normal_setwarpWarpSet, "warp-" + warpname);
|
||||
} else if (warpname.equalsIgnoreCase("seekers")) {
|
||||
arena.seekersWarp = new LocationSerializable(loc);
|
||||
arena.seekersWarp = loc;
|
||||
save(arena);
|
||||
MessageManager.sendFMessage(player, ConfigC.normal_setwarpWarpSet, "warp-" + warpname);
|
||||
} else if (warpname.equalsIgnoreCase("spawn")) {
|
||||
arena.spawnWarp = new LocationSerializable(loc);
|
||||
arena.spawnWarp = loc;
|
||||
save(arena);
|
||||
MessageManager.sendFMessage(player, ConfigC.normal_setwarpWarpSet, "warp-" + warpname);
|
||||
} else {
|
||||
|
@ -50,8 +50,8 @@ public enum ConfigC {
|
||||
|
||||
requireInventoryClearOnJoin(false, MemoryStorage.config),
|
||||
|
||||
log_enabledPlugin("%TAG%N%name%&a&k + %N%version% is now Enabled. Made by %A%autors%%N.", MemoryStorage.messages), log_disabledPlugin(
|
||||
"%TAG%N%name%&c&k - %N%version% is now Disabled. Made by %A%autors%%N.", MemoryStorage.messages),
|
||||
log_enabledPlugin("%TAG%N%name%&a&k + %N%version% is now Enabled. Made by %A%authors%%N.", MemoryStorage.messages), log_disabledPlugin(
|
||||
"%TAG%N%name%&c&k - %N%version% is now Disabled. Made by %A%authors%%N.", MemoryStorage.messages),
|
||||
|
||||
help_info("%NDisplays the plugin's info.", MemoryStorage.messages), help_help("%NShows a list of commands.", MemoryStorage.messages), help_reload("%NReloads all configs.", MemoryStorage.messages), help_join(
|
||||
"%NJoins a " + BlockHunt.pdfFile.getName() + " game.", MemoryStorage.messages), help_leave("%NLeave a " + BlockHunt.pdfFile.getName() + " game.", MemoryStorage.messages), help_list(
|
||||
@ -81,7 +81,7 @@ public enum ConfigC {
|
||||
"%TAG%NYou've bought the '%A%itemname%%N' item!", MemoryStorage.messages), normal_shopChoosenBlock("%TAG%NYou've choosen to be a(n) '%A%block%%N' block!", MemoryStorage.messages), normal_shopChoosenSeeker(
|
||||
"%TAG%NYou've choosen to be a %Aseeker%N!", MemoryStorage.messages), normal_shopChoosenHiders("%TAG%NYou've choosen to be a %Ahider%N!", MemoryStorage.messages), normal_ingameBlocksLeft("%TAG%NRemaining blocks: %A%1%%N", MemoryStorage.messages),
|
||||
|
||||
warning_lobbyNeedAtleast("%TAG%WYou need atleast %A%1%%MemoryStorage player(s) to start the game!", MemoryStorage.messages), warning_ingameNEWSeekerChoosen(
|
||||
warning_lobbyNeedAtleast("%TAG%WYou need atleast %A%1% player(s) to start the game!", MemoryStorage.messages), warning_ingameNEWSeekerChoosen(
|
||||
"%TAG%WThe last seeker left and a new seeker has been choosen!", MemoryStorage.messages), warning_unableToCommand(
|
||||
"%TAG%WSorry but that command is disabled in the arena.", MemoryStorage.messages), warning_ingameNoSolidPlace("%TAG%WThat's not a valid place to become solid!",
|
||||
MemoryStorage.messages), warning_arenaStopped("%TAG%WThe arena has been forced to stop!", MemoryStorage.messages),
|
||||
@ -103,7 +103,9 @@ public enum ConfigC {
|
||||
"%TAG%ENo player found with the name '%A%playername%%E'!", MemoryStorage.messages), error_tokensUnknownsetting("%TAG%E'%A%option%%E' is not a known option!", MemoryStorage.messages), error_shopNeedMoreTokens(
|
||||
"%TAG%EYou need more tokens before you can buy this item.", MemoryStorage.messages), error_shopMaxSeekersReached(
|
||||
"%TAG%ESorry, the maximum amount of seekers has been reached!", MemoryStorage.messages), error_shopMaxHidersReached(
|
||||
"%TAG%ESorry, the maximum amount of hiders has been reached!", MemoryStorage.messages);
|
||||
"%TAG%ESorry, the maximum amount of hiders has been reached!", MemoryStorage.messages),
|
||||
error_teleportFailed("%TAG%EUnable to teleport you into the arena.", MemoryStorage.messages),
|
||||
error_teleportBlocked("%TAG%EYou cannot teleport while playing!", MemoryStorage.messages);
|
||||
|
||||
public Object value;
|
||||
public ConfigManager config;
|
||||
@ -111,7 +113,7 @@ public enum ConfigC {
|
||||
|
||||
/**
|
||||
* Makes an object from the list above.
|
||||
*
|
||||
*
|
||||
* @param value
|
||||
* Setting in the config file.
|
||||
* @param config
|
||||
|
@ -5,11 +5,8 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import nl.Steffion.BlockHunt.Arena;
|
||||
import nl.Steffion.BlockHunt.*;
|
||||
import nl.Steffion.BlockHunt.Arena.ArenaState;
|
||||
import nl.Steffion.BlockHunt.ArenaHandler;
|
||||
import nl.Steffion.BlockHunt.ConfigC;
|
||||
import nl.Steffion.BlockHunt.MemoryStorage;
|
||||
import nl.Steffion.BlockHunt.Managers.MessageManager;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -94,71 +91,75 @@ public class OnEntityDamageByEntityEvent implements Listener {
|
||||
player.setHealth(20);
|
||||
event.setCancelled(true);
|
||||
|
||||
DisguiseAPI.undisguiseToAll(player);
|
||||
MemoryStorage.pBlock.remove(player);
|
||||
|
||||
if (!arena.seekers.contains(player)) {
|
||||
if (MemoryStorage.shop.getFile().get(damager.getName() + ".tokens") == null) {
|
||||
MemoryStorage.shop.getFile().set(damager.getName() + ".tokens", 0);
|
||||
MemoryStorage.shop.save();
|
||||
}
|
||||
int damagerTokens = MemoryStorage.shop.getFile().getInt(damager.getName() + ".tokens");
|
||||
MemoryStorage.shop.getFile().set(damager.getName() + ".tokens", damagerTokens + arena.killTokens);
|
||||
MemoryStorage.shop.save();
|
||||
|
||||
MessageManager.sendFMessage(damager, ConfigC.normal_addedToken, "amount-" + arena.killTokens);
|
||||
|
||||
if (MemoryStorage.shop.getFile().get(player.getName() + ".tokens") == null) {
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".tokens", 0);
|
||||
MemoryStorage.shop.save();
|
||||
}
|
||||
int playerTokens = MemoryStorage.shop.getFile().getInt(player.getName() + ".tokens");
|
||||
float addingTokens = ((float) arena.hidersTokenWin - (((float) arena.timer / (float) arena.gameTime) * (float) arena.hidersTokenWin));
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".tokens", playerTokens + (int) addingTokens);
|
||||
MemoryStorage.shop.save();
|
||||
|
||||
MessageManager.sendFMessage(player, ConfigC.normal_addedToken, "amount-" + (int) addingTokens);
|
||||
|
||||
arena.seekers.add(player);
|
||||
player.setWalkSpeed(0.3F);
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameHiderDied, "playername-" + player.getDisplayName(), "killer-" + damager.getDisplayName());
|
||||
|
||||
int hidercount = (arena.playersInArena.size() - arena.seekers.size());
|
||||
if ((hidercount <= 3) && (hidercount > 0)) {
|
||||
List<String> hiders = new ArrayList<>();
|
||||
for (Player p : arena.playersInArena) {
|
||||
if (!arena.seekers.contains(p)) {
|
||||
hiders.add(p.getName());
|
||||
}
|
||||
}
|
||||
Collections.sort(hiders);
|
||||
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameHidersLeft, "left-" + StringUtils.join(hiders.toArray(), ", "));
|
||||
} else {
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameHidersLeft, "left-" + hidercount);
|
||||
}
|
||||
}
|
||||
|
||||
player.getInventory().clear();
|
||||
player.updateInventory();
|
||||
|
||||
if (arena.seekers.size() >= arena.playersInArena.size()) {
|
||||
ArenaHandler.seekersWin(arena);
|
||||
} else {
|
||||
// try moving everything to the next tick to prevent "Removing entity while ticking" errors
|
||||
Player finalDamager = damager;
|
||||
player.getServer().getScheduler().runTask(BlockHunt.plugin, () -> {
|
||||
DisguiseAPI.undisguiseToAll(player);
|
||||
MemoryStorage.seekertime.put(player, arena.waitingTimeSeeker);
|
||||
player.teleport(arena.seekersWarp);
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.setWalkSpeed(0.3F);
|
||||
MemoryStorage.pBlock.remove(player);
|
||||
|
||||
// Fix for client not showing players after they join
|
||||
for (Player otherplayer : arena.playersInArena) {
|
||||
if (otherplayer.canSee(player))
|
||||
otherplayer.showPlayer(player); // Make new player visible to others
|
||||
if (player.canSee(otherplayer))
|
||||
player.showPlayer(otherplayer); // Make other players visible to new player
|
||||
if (!arena.seekers.contains(player)) {
|
||||
if (MemoryStorage.shop.getFile().get(finalDamager.getName() + ".tokens") == null) {
|
||||
MemoryStorage.shop.getFile().set(finalDamager.getName() + ".tokens", 0);
|
||||
MemoryStorage.shop.save();
|
||||
}
|
||||
int damagerTokens = MemoryStorage.shop.getFile().getInt(finalDamager.getName() + ".tokens");
|
||||
MemoryStorage.shop.getFile().set(finalDamager.getName() + ".tokens", damagerTokens + arena.killTokens);
|
||||
MemoryStorage.shop.save();
|
||||
|
||||
MessageManager.sendFMessage(finalDamager, ConfigC.normal_addedToken, "amount-" + arena.killTokens);
|
||||
|
||||
if (MemoryStorage.shop.getFile().get(player.getName() + ".tokens") == null) {
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".tokens", 0);
|
||||
MemoryStorage.shop.save();
|
||||
}
|
||||
int playerTokens = MemoryStorage.shop.getFile().getInt(player.getName() + ".tokens");
|
||||
float addingTokens = ((float) arena.hidersTokenWin - (((float) arena.timer / (float) arena.gameTime) * (float) arena.hidersTokenWin));
|
||||
MemoryStorage.shop.getFile().set(player.getName() + ".tokens", playerTokens + (int) addingTokens);
|
||||
MemoryStorage.shop.save();
|
||||
|
||||
MessageManager.sendFMessage(player, ConfigC.normal_addedToken, "amount-" + (int) addingTokens);
|
||||
|
||||
arena.seekers.add(player);
|
||||
player.setWalkSpeed(0.3F);
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameHiderDied, "playername-" + player.getDisplayName(), "killer-" + finalDamager.getDisplayName());
|
||||
|
||||
int hidercount = (arena.playersInArena.size() - arena.seekers.size());
|
||||
if ((hidercount <= 3) && (hidercount > 0)) {
|
||||
List<String> hiders = new ArrayList<>();
|
||||
for (Player p : arena.playersInArena) {
|
||||
if (!arena.seekers.contains(p)) {
|
||||
hiders.add(p.getName());
|
||||
}
|
||||
}
|
||||
Collections.sort(hiders);
|
||||
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameHidersLeft, "left-" + StringUtils.join(hiders.toArray(), ", "));
|
||||
} else {
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_ingameHidersLeft, "left-" + hidercount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player.getInventory().clear();
|
||||
player.updateInventory();
|
||||
|
||||
if (arena.seekers.size() >= arena.playersInArena.size()) {
|
||||
ArenaHandler.seekersWin(arena);
|
||||
} else {
|
||||
DisguiseAPI.undisguiseToAll(player);
|
||||
MemoryStorage.seekertime.put(player, arena.waitingTimeSeeker);
|
||||
PlayerHandler.teleport(player, arena.seekersWarp);
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.setWalkSpeed(0.3F);
|
||||
|
||||
// Fix for client not showing players after they join
|
||||
for (Player otherplayer : arena.playersInArena) {
|
||||
if (otherplayer.canSee(player))
|
||||
otherplayer.showPlayer(BlockHunt.plugin, player); // Make new player visible to others
|
||||
if (player.canSee(otherplayer))
|
||||
player.showPlayer(BlockHunt.plugin, otherplayer); // Make other players visible to new player
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import nl.Steffion.BlockHunt.Arena.ArenaType;
|
||||
import nl.Steffion.BlockHunt.MemoryStorage;
|
||||
import nl.Steffion.BlockHunt.Managers.MessageManager;
|
||||
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -14,6 +15,7 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class OnInventoryClickEvent implements Listener {
|
||||
@ -23,16 +25,15 @@ public class OnInventoryClickEvent implements Listener {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
if (arena.playersInArena.contains(player) && !arena.seekers.contains(player)) {
|
||||
if (event.getSlot() == 8 || event.getSlot() == 39) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
Inventory inv = event.getInventory();
|
||||
InventoryView invView = event.getView();
|
||||
if (inv.getType().equals(InventoryType.CHEST)) {
|
||||
if (inv.getName().contains("DisguiseBlocks")) {
|
||||
if (invView.getTitle().contains("DisguiseBlocks")) {
|
||||
if (event.getCurrentItem() != null) {
|
||||
if (!event.getCurrentItem().getType().isBlock()) {
|
||||
if (!event.getCurrentItem().getType().equals(Material.FLOWER_POT)) {
|
||||
@ -46,11 +47,11 @@ public class OnInventoryClickEvent implements Listener {
|
||||
}
|
||||
|
||||
// Early exit if this isnt a blockhunt inventory
|
||||
if (!inv.getName().contains("BlockHunt"))
|
||||
if (!invView.getTitle().contains("BlockHunt"))
|
||||
return;
|
||||
|
||||
if (inv.getName().startsWith("\u00A7r")) {
|
||||
if (inv.getName().equals(MessageManager.replaceAll("\u00A7r" + MemoryStorage.config.get(ConfigC.shop_title)))) {
|
||||
if (invView.getTitle().startsWith("\u00A7r")) {
|
||||
if (invView.getTitle().equals(MessageManager.replaceAll("\u00A7r" + MemoryStorage.config.get(ConfigC.shop_title)))) {
|
||||
event.setCancelled(true);
|
||||
ItemStack item = event.getCurrentItem();
|
||||
if (MemoryStorage.shop.getFile().get(player.getName() + ".tokens") == null) {
|
||||
@ -90,20 +91,22 @@ public class OnInventoryClickEvent implements Listener {
|
||||
}
|
||||
|
||||
InventoryHandler.openShop(player);
|
||||
} else if (inv.getName().contains(MessageManager.replaceAll((String) MemoryStorage.config.get(ConfigC.shop_blockChooserv1Name)))) {
|
||||
} else if (invView.getTitle().contains(MessageManager.replaceAll((String) MemoryStorage.config.get(ConfigC.shop_blockChooserv1Name)))) {
|
||||
event.setCancelled(true);
|
||||
if (event.getCurrentItem().getType() != Material.AIR) {
|
||||
if (event.getCurrentItem() != null) {
|
||||
if (event.getCurrentItem().getType().isBlock()) {
|
||||
MemoryStorage.choosenBlock.put(player, event.getCurrentItem());
|
||||
String blockName = event.getCurrentItem().getType().name();
|
||||
blockName = WordUtils.capitalizeFully(blockName.replace("_", " "));
|
||||
MessageManager.sendFMessage(player, ConfigC.normal_shopChoosenBlock, "block-"
|
||||
+ event.getCurrentItem().getType().toString().replaceAll("_", "").replaceAll("BLOCK", "").toLowerCase());
|
||||
+ blockName);
|
||||
} else {
|
||||
MessageManager.sendFMessage(player, ConfigC.error_setNotABlock);
|
||||
}
|
||||
}
|
||||
} else if (inv.getName().contains(MessageManager.replaceAll((String) MemoryStorage.config.get(ConfigC.shop_BlockHuntPassv2Name)))) {
|
||||
} else if (invView.getTitle().contains(MessageManager.replaceAll((String) MemoryStorage.config.get(ConfigC.shop_BlockHuntPassv2Name)))) {
|
||||
event.setCancelled(true);
|
||||
if (event.getCurrentItem().getType() != Material.AIR) {
|
||||
if (event.getCurrentItem() != null) {
|
||||
if (event.getCurrentItem().getType().equals(Material.BLUE_WOOL)) {
|
||||
int i = 0;
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
@ -121,7 +124,7 @@ public class OnInventoryClickEvent implements Listener {
|
||||
MessageManager.sendFMessage(player, ConfigC.error_shopMaxSeekersReached);
|
||||
} else {
|
||||
MemoryStorage.choosenSeeker.put(player, true);
|
||||
player.getInventory().setItemInHand(new ItemStack(Material.AIR));
|
||||
player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||
player.updateInventory();
|
||||
MessageManager.sendFMessage(player, ConfigC.normal_shopChoosenSeeker);
|
||||
inv.clear();
|
||||
@ -152,7 +155,7 @@ public class OnInventoryClickEvent implements Listener {
|
||||
MessageManager.sendFMessage(player, ConfigC.error_shopMaxHidersReached);
|
||||
} else {
|
||||
MemoryStorage.choosenSeeker.put(player, false);
|
||||
player.getInventory().setItemInHand(new ItemStack(Material.AIR));
|
||||
player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||
player.updateInventory();
|
||||
MessageManager.sendFMessage(player, ConfigC.normal_shopChoosenHiders);
|
||||
inv.clear();
|
||||
|
@ -14,6 +14,7 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class OnInventoryCloseEvent implements Listener {
|
||||
@ -21,8 +22,9 @@ public class OnInventoryCloseEvent implements Listener {
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onInventoryCloseEvent(InventoryCloseEvent event) {
|
||||
Inventory inv = event.getInventory();
|
||||
InventoryView invView = event.getView();
|
||||
if (inv.getType().equals(InventoryType.CHEST)) {
|
||||
if (inv.getName().contains("DisguiseBlocks")) {
|
||||
if (invView.getTitle().contains("DisguiseBlocks")) {
|
||||
String arenaname = inv.getItem(0).getItemMeta().getDisplayName().replaceAll(MessageManager.replaceAll("%NDisguiseBlocks of arena: %A"), "");
|
||||
|
||||
Arena arena = null;
|
||||
|
@ -63,7 +63,7 @@ public class OnPlayerInteractEvent implements Listener {
|
||||
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if (event.getClickedBlock() != null) {
|
||||
if (event.getClickedBlock().getType().equals(Material.SIGN) || event.getClickedBlock().getType().equals(Material.WALL_SIGN)) {
|
||||
if (event.getClickedBlock().getState() instanceof Sign) {
|
||||
if (SignsHandler.isSign(event.getClickedBlock().getLocation())) {
|
||||
Sign sign = (Sign) event.getClickedBlock().getState();
|
||||
if (sign.getLine(1) != null) {
|
||||
|
@ -1,10 +1,7 @@
|
||||
package nl.Steffion.BlockHunt.Listeners;
|
||||
|
||||
import nl.Steffion.BlockHunt.Arena;
|
||||
import nl.Steffion.BlockHunt.ArenaHandler;
|
||||
import nl.Steffion.BlockHunt.*;
|
||||
import nl.Steffion.BlockHunt.Arena.ArenaState;
|
||||
import nl.Steffion.BlockHunt.BlockHunt;
|
||||
import nl.Steffion.BlockHunt.MemoryStorage;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
@ -32,11 +29,11 @@ public class OnPlayerMoveEvent implements Listener {
|
||||
((arena.pos1 != null)?arena.pos1.toString():" NULL")+ " Pos2:" +
|
||||
((arena.pos2 != null)?arena.pos2.toString():" NULL"));
|
||||
BlockHunt.plugin.getLogger().info("Player has been returned to hiderswarp due to bad arena state");
|
||||
event.setCancelled(true);
|
||||
//event.setCancelled(true);
|
||||
Location loc = player.getLocation();
|
||||
player.playEffect(loc, Effect.ENDER_SIGNAL, null);
|
||||
player.playSound(loc, Sound.ENTITY_GHAST_SHOOT, 1, 1);
|
||||
player.teleport(arena.hidersWarp);
|
||||
PlayerHandler.teleport(player, arena.hidersWarp);
|
||||
return;
|
||||
}
|
||||
double maxX = Math.max(arena.pos1.getX(), arena.pos2.getX());
|
||||
@ -48,35 +45,35 @@ public class OnPlayerMoveEvent implements Listener {
|
||||
|
||||
Location loc = player.getLocation();
|
||||
if (loc.getBlockX() > maxX) {
|
||||
event.setCancelled(true);
|
||||
//event.setCancelled(true);
|
||||
player.playEffect(loc, Effect.ENDER_SIGNAL, null);
|
||||
player.playSound(loc, Sound.ENTITY_GHAST_SHOOT, 1, 1);
|
||||
player.teleport(arena.hidersWarp);
|
||||
PlayerHandler.teleport(player, arena.hidersWarp);
|
||||
} else if (loc.getBlockX() < minX) {
|
||||
event.setCancelled(true);
|
||||
//event.setCancelled(true);
|
||||
player.playEffect(loc, Effect.ENDER_SIGNAL, null);
|
||||
player.playSound(loc, Sound.ENTITY_GHAST_SHOOT, 1, 1);
|
||||
player.teleport(arena.hidersWarp);
|
||||
PlayerHandler.teleport(player, arena.hidersWarp);
|
||||
} else if (loc.getBlockZ() > maxZ) {
|
||||
event.setCancelled(true);
|
||||
//event.setCancelled(true);
|
||||
player.playEffect(loc, Effect.ENDER_SIGNAL, null);
|
||||
player.playSound(loc, Sound.ENTITY_GHAST_SHOOT, 1, 1);
|
||||
player.teleport(arena.hidersWarp);
|
||||
PlayerHandler.teleport(player, arena.hidersWarp);
|
||||
} else if (loc.getBlockZ() < minZ) {
|
||||
event.setCancelled(true);
|
||||
//event.setCancelled(true);
|
||||
player.playEffect(loc, Effect.ENDER_SIGNAL, null);
|
||||
player.playSound(loc, Sound.ENTITY_GHAST_SHOOT, 1, 1);
|
||||
player.teleport(arena.hidersWarp);
|
||||
PlayerHandler.teleport(player, arena.hidersWarp);
|
||||
} else if (loc.getBlockY() > maxY) {
|
||||
event.setCancelled(true);
|
||||
//event.setCancelled(true);
|
||||
player.playEffect(loc, Effect.ENDER_SIGNAL, null);
|
||||
player.playSound(loc, Sound.ENTITY_GHAST_SHOOT, 1, 1);
|
||||
player.teleport(arena.hidersWarp);
|
||||
PlayerHandler.teleport(player, arena.hidersWarp);
|
||||
} else if (loc.getBlockY() < minY) {
|
||||
event.setCancelled(true);
|
||||
//event.setCancelled(true);
|
||||
player.playEffect(loc, Effect.ENDER_SIGNAL, null);
|
||||
player.playSound(loc, Sound.ENTITY_GHAST_SHOOT, 1, 1);
|
||||
player.teleport(arena.hidersWarp);
|
||||
PlayerHandler.teleport(player, arena.hidersWarp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,9 +24,9 @@ public class OnPlayerQuitEvent implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerJoinEvent(PlayerJoinEvent event) {
|
||||
Player playerJoining = event.getPlayer();
|
||||
playerJoining.teleport(playerJoining.getWorld().getSpawnLocation());
|
||||
}
|
||||
// @EventHandler(priority = EventPriority.HIGHEST)
|
||||
// public void onPlayerJoinEvent(PlayerJoinEvent event) {
|
||||
// Player playerJoining = event.getPlayer();
|
||||
// playerJoining.teleport(playerJoining.getWorld().getSpawnLocation());
|
||||
// }
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
package nl.Steffion.BlockHunt.Listeners;
|
||||
|
||||
import nl.Steffion.BlockHunt.Arena;
|
||||
import nl.Steffion.BlockHunt.ArenaHandler;
|
||||
import nl.Steffion.BlockHunt.MemoryStorage;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
||||
|
||||
public class OnPlayerSwapHandItemsEvent implements Listener {
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerSwapHandItemsEvent(PlayerSwapHandItemsEvent event) {
|
||||
// Early exit if no one is in any arena
|
||||
if (ArenaHandler.noPlayersInArenas()) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package nl.Steffion.BlockHunt.Listeners;
|
||||
|
||||
import nl.Steffion.BlockHunt.ConfigC;
|
||||
import nl.Steffion.BlockHunt.Managers.MessageManager;
|
||||
import nl.Steffion.BlockHunt.MemoryStorage;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
public class OnPlayerTeleportEvent implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerTeleportEvent(PlayerTeleportEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (MemoryStorage.pData.get(player) != null) {
|
||||
handlePlayer(event, player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a player that is in an arena
|
||||
* @param event PlayerTeleportEvent
|
||||
* @param player Player
|
||||
*/
|
||||
private void handlePlayer(PlayerTeleportEvent event, Player player) {
|
||||
Location storedLoc = MemoryStorage.teleportLoc.remove(player);
|
||||
Location to = event.getTo();
|
||||
if (storedLoc == null || storedLoc.getWorld() != to.getWorld() || to.distanceSquared(storedLoc) > 1) {
|
||||
MessageManager.sendFMessage(player, ConfigC.error_teleportBlocked);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -71,7 +71,7 @@ public class ConfigManager {
|
||||
public static void newFiles() {
|
||||
ConfigManager.setDefaults();
|
||||
for (String fileName : MemoryStorage.newFiles) {
|
||||
MessageManager.sendMessage(null, "%TAG%WCouldn't find '%A%fileName%.yml%MemoryStorage' creating new one.", "fileName-" + fileName);
|
||||
MessageManager.sendMessage(null, "%TAG%WCouldn't find '%A%fileName%.yml%W'%A creating new one.", "fileName-" + fileName);
|
||||
}
|
||||
|
||||
MemoryStorage.newFiles.clear();
|
||||
|
@ -14,6 +14,7 @@ package nl.Steffion.BlockHunt;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import nl.Steffion.BlockHunt.Managers.CommandManager;
|
||||
@ -59,4 +60,6 @@ public class MemoryStorage {
|
||||
public static HashMap<Player, Location> moveLoc = new HashMap<>();
|
||||
public static HashMap<Player, Location> hiddenLoc = new HashMap<>();
|
||||
public static HashMap<Player, Boolean> hiddenLocWater = new HashMap<>();
|
||||
|
||||
public static Map<Player, Location> teleportLoc = new HashMap<>();
|
||||
}
|
||||
|
11
src/main/java/nl/Steffion/BlockHunt/PlayerHandler.java
Normal file
11
src/main/java/nl/Steffion/BlockHunt/PlayerHandler.java
Normal file
@ -0,0 +1,11 @@
|
||||
package nl.Steffion.BlockHunt;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlayerHandler {
|
||||
public static boolean teleport(Player player, Location location) {
|
||||
MemoryStorage.teleportLoc.put(player, location);
|
||||
return player.teleport(location);
|
||||
}
|
||||
}
|
@ -19,11 +19,11 @@ public class ScoreboardHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
Objective object = board.registerNewObjective(BlockHunt.cutString(arena.arenaName, 32), "dummy");
|
||||
String displayName = BlockHunt.cutString(MessageManager.replaceAll((String) MemoryStorage.config.get(ConfigC.scoreboard_title)), 32);
|
||||
Objective object = board.registerNewObjective(BlockHunt.cutString(arena.arenaName, 32), "dummy", displayName);
|
||||
|
||||
object.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
object.setDisplayName(BlockHunt.cutString(MessageManager.replaceAll((String) MemoryStorage.config.get(ConfigC.scoreboard_title)), 32));
|
||||
|
||||
|
||||
String temp = BlockHunt.cutString(MessageManager.replaceAll((String) MemoryStorage.config.get(ConfigC.scoreboard_timeleft)), 32);
|
||||
Score timeleft = object.getScore(temp);
|
||||
timeleft.setScore(arena.timer);
|
||||
|
@ -1,66 +0,0 @@
|
||||
package nl.Steffion.BlockHunt.Serializables;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import nl.Steffion.BlockHunt.Managers.MessageManager;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
|
||||
/**
|
||||
* No longer required as a location is already serializable
|
||||
*/
|
||||
|
||||
@SerializableAs("BlockHuntLocation")
|
||||
@Deprecated
|
||||
public class LocationSerializable extends Location {
|
||||
public LocationSerializable(World world, double x, double y, double z, float yaw, float pitch) {
|
||||
super(world, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
public LocationSerializable(Location loc) {
|
||||
super(loc.getWorld(), loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof LocationSerializable || o instanceof Location) {
|
||||
Location loc = (Location) o;
|
||||
return loc.getWorld().getName().equals(getWorld().getName()) && loc.getX() == getX() && loc.getY() == getY() && loc.getZ() == getZ()
|
||||
&& loc.getYaw() == getYaw() && loc.getPitch() == getPitch();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> serialize() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("world", getWorld().getName());
|
||||
map.put("x", getX());
|
||||
map.put("y", getY());
|
||||
map.put("z", getZ());
|
||||
if (getYaw() != 0D)
|
||||
map.put("yaw", getYaw());
|
||||
if (getPitch() != 0D)
|
||||
map.put("pitch", getPitch());
|
||||
return map;
|
||||
}
|
||||
|
||||
public static LocationSerializable deserialize(Map<String, Object> map) {
|
||||
World w = Bukkit.getWorld((String)map.getOrDefault( "w", ""));
|
||||
if (w == null) {
|
||||
MessageManager.sendMessage(null, "%EError deserializing Location - world not found! (%A%w%%E)", "w-" + w);
|
||||
return null;
|
||||
}
|
||||
return new LocationSerializable(w, (Double) map.getOrDefault( "x", 0D), (Double) map.getOrDefault( "y", 0D), (Double) map.getOrDefault( "z", 0D), ((Double) map.getOrDefault( "a", 0D)).floatValue(),
|
||||
((Double) map.getOrDefault( "p", 0D)).floatValue());
|
||||
}
|
||||
|
||||
public static Location getLocation(LocationSerializable ser){
|
||||
return new Location(ser.getWorld(),ser.getX(),ser.getY(),ser.getZ(),ser.getYaw(),ser.getPitch());
|
||||
}
|
||||
}
|
@ -92,89 +92,93 @@ public class SignsHandler {
|
||||
MemoryStorage.signs.load();
|
||||
for (String sign : MemoryStorage.signs.getFile().getKeys(false)) {
|
||||
Location loc = (Location) MemoryStorage.signs.getFile().get(sign + ".location");
|
||||
if (loc.getBlock().getType().equals(Material.SIGN) || 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>) MemoryStorage.config.getFile().getStringList(ConfigC.sign_LEAVE.location);
|
||||
int linecount = 0;
|
||||
for (String line : signLines) {
|
||||
if (linecount <= 3) {
|
||||
signblock.setLine(linecount, MessageManager.replaceAll(line));
|
||||
// check if that area is actually loaded. If not move on.
|
||||
if (loc.getWorld().isChunkLoaded(loc.getBlockX() >> 4, loc.getBlockZ() >> 4)) {
|
||||
if (loc.getBlock().getState() instanceof Sign) {
|
||||
Sign signblock = (Sign) loc.getBlock().getState();
|
||||
String[] lines = signblock.getLines();
|
||||
if (sign.contains("leave")) {
|
||||
|
||||
ArrayList<String> signLines = (ArrayList<String>) MemoryStorage.config.getFile().getStringList(ConfigC.sign_LEAVE.location);
|
||||
int linecount = 0;
|
||||
for (String line : signLines) {
|
||||
if (linecount <= 3) {
|
||||
signblock.setLine(linecount, MessageManager.replaceAll(line));
|
||||
}
|
||||
|
||||
linecount = linecount + 1;
|
||||
}
|
||||
signblock.update();
|
||||
} else if (sign.contains("shop")) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) MemoryStorage.config.getFile().getStringList(ConfigC.sign_SHOP.location);
|
||||
int linecount = 0;
|
||||
for (String line : signLines) {
|
||||
if (linecount <= 3) {
|
||||
signblock.setLine(linecount, MessageManager.replaceAll(line));
|
||||
}
|
||||
|
||||
linecount = linecount + 1;
|
||||
}
|
||||
signblock.update();
|
||||
} else if (sign.contains("shop")) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) MemoryStorage.config.getFile().getStringList(ConfigC.sign_SHOP.location);
|
||||
int linecount = 0;
|
||||
for (String line : signLines) {
|
||||
if (linecount <= 3) {
|
||||
signblock.setLine(linecount, MessageManager.replaceAll(line));
|
||||
linecount = linecount + 1;
|
||||
}
|
||||
signblock.update();
|
||||
} else {
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
if (lines[1].endsWith(arena.arenaName)) {
|
||||
if (arena.gameState.equals(ArenaState.WAITING)) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) MemoryStorage.config.getFile().getStringList(ConfigC.sign_WAITING.location);
|
||||
int linecount = 0;
|
||||
if (signLines != null) {
|
||||
for (String line : signLines) {
|
||||
if (linecount <= 3) {
|
||||
signblock.setLine(
|
||||
linecount,
|
||||
MessageManager.replaceAll(line, "arenaname-" + arena.arenaName, "players-" + arena.playersInArena.size(), "maxplayers-"
|
||||
+ arena.maxPlayers, "timeleft-" + arena.timer));
|
||||
}
|
||||
|
||||
linecount = linecount + 1;
|
||||
}
|
||||
signblock.update();
|
||||
} else {
|
||||
for (Arena arena : MemoryStorage.arenaList) {
|
||||
if (lines[1].endsWith(arena.arenaName)) {
|
||||
if (arena.gameState.equals(ArenaState.WAITING)) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) MemoryStorage.config.getFile().getStringList(ConfigC.sign_WAITING.location);
|
||||
int linecount = 0;
|
||||
if (signLines != null) {
|
||||
for (String line : signLines) {
|
||||
if (linecount <= 3) {
|
||||
signblock.setLine(
|
||||
linecount,
|
||||
MessageManager.replaceAll(line, "arenaname-" + arena.arenaName, "players-" + arena.playersInArena.size(), "maxplayers-"
|
||||
+ arena.maxPlayers, "timeleft-" + arena.timer));
|
||||
linecount = linecount + 1;
|
||||
}
|
||||
|
||||
linecount = linecount + 1;
|
||||
}
|
||||
}
|
||||
signblock.update();
|
||||
} else if (arena.gameState.equals(ArenaState.STARTING)) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) MemoryStorage.config.getFile().getStringList(ConfigC.sign_STARTING.location);
|
||||
int linecount = 0;
|
||||
if (signLines != null) {
|
||||
for (String line : signLines) {
|
||||
if (linecount <= 3) {
|
||||
signblock.setLine(
|
||||
linecount,
|
||||
MessageManager.replaceAll(line, "arenaname-" + arena.arenaName, "players-" + arena.playersInArena.size(), "maxplayers-"
|
||||
+ arena.maxPlayers, "timeleft-" + arena.timer));
|
||||
signblock.update();
|
||||
} else if (arena.gameState.equals(ArenaState.STARTING)) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) MemoryStorage.config.getFile().getStringList(ConfigC.sign_STARTING.location);
|
||||
int linecount = 0;
|
||||
if (signLines != null) {
|
||||
for (String line : signLines) {
|
||||
if (linecount <= 3) {
|
||||
signblock.setLine(
|
||||
linecount,
|
||||
MessageManager.replaceAll(line, "arenaname-" + arena.arenaName, "players-" + arena.playersInArena.size(), "maxplayers-"
|
||||
+ arena.maxPlayers, "timeleft-" + arena.timer));
|
||||
}
|
||||
|
||||
linecount = linecount + 1;
|
||||
}
|
||||
|
||||
linecount = linecount + 1;
|
||||
}
|
||||
}
|
||||
signblock.update();
|
||||
} else if (arena.gameState.equals(ArenaState.INGAME)) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) MemoryStorage.config.getFile().getStringList(ConfigC.sign_INGAME.location);
|
||||
int linecount = 0;
|
||||
if (signLines != null) {
|
||||
for (String line : signLines) {
|
||||
if (linecount <= 3) {
|
||||
signblock.setLine(
|
||||
linecount,
|
||||
MessageManager.replaceAll(line, "arenaname-" + arena.arenaName, "players-" + arena.playersInArena.size(), "maxplayers-"
|
||||
+ arena.maxPlayers, "timeleft-" + arena.timer));
|
||||
signblock.update();
|
||||
} else if (arena.gameState.equals(ArenaState.INGAME)) {
|
||||
ArrayList<String> signLines = (ArrayList<String>) MemoryStorage.config.getFile().getStringList(ConfigC.sign_INGAME.location);
|
||||
int linecount = 0;
|
||||
if (signLines != null) {
|
||||
for (String line : signLines) {
|
||||
if (linecount <= 3) {
|
||||
signblock.setLine(
|
||||
linecount,
|
||||
MessageManager.replaceAll(line, "arenaname-" + arena.arenaName, "players-" + arena.playersInArena.size(), "maxplayers-"
|
||||
+ arena.maxPlayers, "timeleft-" + arena.timer));
|
||||
}
|
||||
|
||||
linecount = linecount + 1;
|
||||
}
|
||||
|
||||
linecount = linecount + 1;
|
||||
}
|
||||
signblock.update();
|
||||
}
|
||||
signblock.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
removeSign(loc);
|
||||
}
|
||||
} else {
|
||||
removeSign(loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,10 +51,10 @@ public class SolidBlockHandler {
|
||||
block.removeEnchantment(Enchantment.DURABILITY);
|
||||
|
||||
for (Player playerShow : Bukkit.getOnlinePlayers()) {
|
||||
playerShow.showPlayer(player);
|
||||
playerShow.showPlayer(BlockHunt.plugin, player);
|
||||
}
|
||||
|
||||
MiscDisguise disguise = new MiscDisguise(DisguiseType.FALLING_BLOCK, block.getType(), 0);
|
||||
MiscDisguise disguise = new MiscDisguise(DisguiseType.FALLING_BLOCK, block.getType());
|
||||
DisguiseAPI.disguiseToAll(player, disguise);
|
||||
|
||||
MessageManager.sendFMessage(player, ConfigC.normal_ingameNoMoreSolid);
|
||||
|
@ -1,5 +1,5 @@
|
||||
log-enabledPlugin: '%TAG%N%name%&a&k + %N%version% is now Enabled. Made by %A%autors%%N.'
|
||||
log-disabledPlugin: '%TAG%N%name%&c&k - %N%version% is now Disabled. Made by %A%autors%%N.'
|
||||
log-enabledPlugin: '%TAG%N%name%&a&k + %N%version% is now Enabled. Made by %A%authors%%N.'
|
||||
log-disabledPlugin: '%TAG%N%name%&c&k - %N%version% is now Disabled. Made by %A%authors%%N.'
|
||||
info: '%NDisplays the plugin''s info.'
|
||||
help: '%NShows a list of commands.'
|
||||
reload: '%NReloads all configs.'
|
||||
@ -87,4 +87,6 @@ error-tokensPlayerNotOnline: '%TAG%ENo player found with the name ''%A%playernam
|
||||
error-tokensUnknownsetting: '%TAG%E''%A%option%%E'' is not a known option!'
|
||||
error-shopNeedMoreTokens: '%TAG%EYou need more tokens before you can buy this item.'
|
||||
error-shopMaxSeekersReached: '%TAG%ESorry, the maximum amount of seekers has been reached!'
|
||||
error-shopMaxHidersReached: '%TAG%ESorry, the maximum amount of hiders has been reached!'
|
||||
error-shopMaxHidersReached: '%TAG%ESorry, the maximum amount of hiders has been reached!'
|
||||
error-teleportFailed: '%TAG%EUnable to teleport you into the arena.'
|
||||
error-teleportBlocked: '%TAG%EYou cannot teleport while playing!'
|
||||
|
@ -1,5 +1,5 @@
|
||||
log-enabledPlugin: '%TAG%N%name%&a&k + %N%version% is now Enabled. Made by %A%autors%%N.'
|
||||
log-disabledPlugin: '%TAG%N%name%&c&k - %N%version% is now Disabled. Made by %A%autors%%N.'
|
||||
log-enabledPlugin: '%TAG%N%name%&a&k + %N%version% is now Enabled. Made by %A%authors%%N.'
|
||||
log-disabledPlugin: '%TAG%N%name%&c&k - %N%version% is now Disabled. Made by %A%authors%%N.'
|
||||
info: '%NDisplays the plugin''s info.'
|
||||
help: '%NShows a list of commands.'
|
||||
reload: '%NReloads all configs.'
|
||||
@ -87,4 +87,6 @@ error-tokensPlayerNotOnline: '%TAG%ENo player found with the name ''%A%playernam
|
||||
error-tokensUnknownsetting: '%TAG%E''%A%option%%E'' is not a known option!'
|
||||
error-shopNeedMoreTokens: '%TAG%EYou need more tokens before you can buy this item.'
|
||||
error-shopMaxSeekersReached: '%TAG%ESorry, the maximum amount of seekers has been reached!'
|
||||
error-shopMaxHidersReached: '%TAG%ESorry, the maximum amount of hiders has been reached!'
|
||||
error-shopMaxHidersReached: '%TAG%ESorry, the maximum amount of hiders has been reached!'
|
||||
error-teleportFailed: '%TAG%EUnable to teleport you into the arena.'
|
||||
error-teleportBlocked: '%TAG%EYou cannot teleport while playing!'
|
||||
|
@ -1,82 +1,92 @@
|
||||
TestArena:
|
||||
==: BlockHuntArena
|
||||
maxPlayers: 40
|
||||
hidersWinCommands: []
|
||||
timeInLobbyUntilStart: 30
|
||||
minPlayers: 5
|
||||
timeUntilHidersSword: 0
|
||||
spawnWarp:
|
||||
==: BlockHuntLocation
|
||||
p: 4.200027
|
||||
a: 41.700073
|
||||
w: games
|
||||
x: -178.5
|
||||
y: 33.0
|
||||
z: -130.5
|
||||
allowedCommands: []
|
||||
hidersCanHurtSeekers: true
|
||||
arenaName: TestArena
|
||||
amountSeekersOnStart: 3
|
||||
pos1:
|
||||
==: BlockHuntLocation
|
||||
w: games
|
||||
x: 576.0
|
||||
y: 2.0
|
||||
z: 503.0
|
||||
pos2:
|
||||
==: BlockHuntLocation
|
||||
w: games
|
||||
x: 428.0
|
||||
y: 66.0
|
||||
z: 342.0
|
||||
waitingTimeSeeker: 20
|
||||
seekersTokenWin: 0
|
||||
seekersCanHurtSeekers: false
|
||||
seekersTokenWin: 10
|
||||
lobbyWarp:
|
||||
==: BlockHuntLocation
|
||||
p: 4.19999
|
||||
a: -182.09694
|
||||
w: games
|
||||
==: org.bukkit.Location
|
||||
world: games
|
||||
x: 500.66289894368725
|
||||
y: 4.0
|
||||
z: 497.83982348350094
|
||||
pitch: 4.19999
|
||||
yaw: -182.09694
|
||||
hidersTakeFallDamage: false
|
||||
seekersWinCommands: []
|
||||
killTokens: 0
|
||||
gameTime: 660
|
||||
disguiseBlocks:
|
||||
- ==: org.bukkit.inventory.ItemStack
|
||||
type: BOOKSHELF
|
||||
- ==: org.bukkit.inventory.ItemStack
|
||||
type: GLOWSTONE
|
||||
meta:
|
||||
==: ItemMeta
|
||||
meta-type: UNSPECIFIC
|
||||
enchants:
|
||||
DURABILITY: 10
|
||||
- ==: org.bukkit.inventory.ItemStack
|
||||
type: EMERALD_BLOCK
|
||||
- ==: org.bukkit.inventory.ItemStack
|
||||
type: WOOL
|
||||
damage: 5
|
||||
- ==: org.bukkit.inventory.ItemStack
|
||||
type: ICE
|
||||
- ==: org.bukkit.inventory.ItemStack
|
||||
type: MYCEL
|
||||
- ==: org.bukkit.inventory.ItemStack
|
||||
type: SAND
|
||||
hidersWarp:
|
||||
==: BlockHuntLocation
|
||||
p: -1.9500121
|
||||
a: 179.85266
|
||||
w: games
|
||||
==: org.bukkit.Location
|
||||
world: games
|
||||
x: 500.52591580497256
|
||||
y: 4.0
|
||||
z: 482.31326505008246
|
||||
pitch: -1.9500121
|
||||
yaw: 179.85266
|
||||
blockAnnouncerTime: 45
|
||||
seekersTakeFallDamage: false
|
||||
hidersCanHurtHiders: false
|
||||
maxPlayers: 40
|
||||
hidersWinCommands: []
|
||||
timeInLobbyUntilStart: 50
|
||||
minPlayers: 5
|
||||
timeUntilHidersSword: 0
|
||||
spawnWarp:
|
||||
==: org.bukkit.Location
|
||||
world: games
|
||||
x: -178.5
|
||||
y: 33.0
|
||||
z: -130.5
|
||||
pitch: 4.200027
|
||||
yaw: 41.700073
|
||||
allowedCommands: []
|
||||
amountSeekersOnStart: 1
|
||||
pos1:
|
||||
==: org.bukkit.Location
|
||||
world: games
|
||||
x: 576.0
|
||||
y: 2.0
|
||||
z: 503.0
|
||||
pitch: 0.0
|
||||
yaw: 0.0
|
||||
pos2:
|
||||
==: org.bukkit.Location
|
||||
world: games
|
||||
x: 428.0
|
||||
y: 66.0
|
||||
z: 342.0
|
||||
pitch: 0.0
|
||||
yaw: 0.0
|
||||
waitingTimeSeeker: 20
|
||||
disguiseBlocks:
|
||||
- ==: org.bukkit.inventory.ItemStack
|
||||
v: 2230
|
||||
type: BOOKSHELF
|
||||
- ==: org.bukkit.inventory.ItemStack
|
||||
v: 2230
|
||||
type: GLOWSTONE
|
||||
- ==: org.bukkit.inventory.ItemStack
|
||||
v: 2230
|
||||
type: EMERALD_BLOCK
|
||||
- ==: org.bukkit.inventory.ItemStack
|
||||
v: 2230
|
||||
type: LIME_WOOL
|
||||
- ==: org.bukkit.inventory.ItemStack
|
||||
v: 2230
|
||||
type: ICE
|
||||
- ==: org.bukkit.inventory.ItemStack
|
||||
v: 2230
|
||||
type: MYCELIUM
|
||||
- ==: org.bukkit.inventory.ItemStack
|
||||
v: 2230
|
||||
type: SAND
|
||||
seekersWarp:
|
||||
==: BlockHuntLocation
|
||||
p: 17.69996
|
||||
a: 90.15417
|
||||
w: games
|
||||
==: org.bukkit.Location
|
||||
world: games
|
||||
x: 519.6272528902401
|
||||
y: 42.0
|
||||
z: 453.4140380016035
|
||||
hidersTokenWin: 0
|
||||
pitch: 17.69996
|
||||
yaw: 90.15417
|
||||
hidersTokenWin: 0
|
||||
|
@ -21,16 +21,16 @@ commandEnabled:
|
||||
setwarp: true
|
||||
remove: true
|
||||
tokens: true
|
||||
autoUpdateCheck: false
|
||||
autoUpdateCheck: true
|
||||
autoDownloadUpdate: false
|
||||
wandIDname: STICK
|
||||
wandName: '%A&lBlockHunt%N''s selection wand'
|
||||
wandDescription:
|
||||
- '%NUse this item to select an arena for your arena.'
|
||||
- '%ALeft-Click%N to select point #1.'
|
||||
- '%ARight-Click%N to select point #2.'
|
||||
- '%NUse the create command to define your arena.'
|
||||
- '%A/BlockHunt <help|h>'
|
||||
- '%NUse this item to select an arena for your arena.'
|
||||
- '%ALeft-Click%N to select point #1.'
|
||||
- '%ARight-Click%N to select point #2.'
|
||||
- '%NUse the create command to define your arena.'
|
||||
- '%A/BlockHunt <help|h>'
|
||||
shop:
|
||||
title: '%H&lBlockHunt %NShop'
|
||||
price: '%NPrice: %A%amount% %Ntokens.'
|
||||
@ -39,45 +39,45 @@ shop:
|
||||
blockChooserv1Price: 3000
|
||||
blockChooserv1Name: '%H&lBlockHunt Chooser'
|
||||
blockChooserv1Description:
|
||||
- '%NUse this item before the arena starts.'
|
||||
- '%ARight-Click%N in the lobby and choose'
|
||||
- '%Nthe block you want to be!'
|
||||
- '&6Unlimited uses.'
|
||||
- '%NUse this item before the arena starts.'
|
||||
- '%ARight-Click%N in the lobby and choose'
|
||||
- '%Nthe block you want to be!'
|
||||
- '&6Unlimited uses.'
|
||||
BlockHuntPassv2Enabled: true
|
||||
BlockHuntPassv2IDName: NAME_TAG
|
||||
BlockHuntPassv2Price: 150
|
||||
BlockHuntPassv2Name: '%H&lBlockHunt Pass'
|
||||
BlockHuntPassv2Description:
|
||||
- '%NUse this item before the arena starts.'
|
||||
- '%ARight-Click%N in the lobby and choose'
|
||||
- '%Nif you want to be a Hider or a Seeker!'
|
||||
- '&61 time use.'
|
||||
- '%NUse this item before the arena starts.'
|
||||
- '%ARight-Click%N in the lobby and choose'
|
||||
- '%Nif you want to be a Hider or a Seeker!'
|
||||
- '&61 time use.'
|
||||
sign:
|
||||
LEAVE:
|
||||
- '%H[BlockHunt%H]'
|
||||
- '&4LEAVE'
|
||||
- '&8Right-Click'
|
||||
- '&8To leave.'
|
||||
- '%H[BlockHunt%H]'
|
||||
- '&4LEAVE'
|
||||
- '&8Right-Click'
|
||||
- '&8To leave.'
|
||||
SHOP:
|
||||
- '%H[BlockHunt%H]'
|
||||
- '&4SHOP'
|
||||
- '&8Right-Click'
|
||||
- '&8To shop.'
|
||||
- '%H[BlockHunt%H]'
|
||||
- '&4SHOP'
|
||||
- '&8Right-Click'
|
||||
- '&8To shop.'
|
||||
WAITING:
|
||||
- '%H[BlockHunt%H]'
|
||||
- '&5%arenaname%'
|
||||
- '&5%players%&6/&5%maxplayers%'
|
||||
- '&8Waiting...'
|
||||
- '%H[BlockHunt%H]'
|
||||
- '%A%arenaname%'
|
||||
- '%A%players%%N/%A%maxplayers%'
|
||||
- '&8Waiting...'
|
||||
STARTING:
|
||||
- '%H[BlockHunt%H]'
|
||||
- '&5%arenaname%'
|
||||
- '&5%players%&6/&5%maxplayers%'
|
||||
- '&2Start: %A%timeleft%'
|
||||
- '%H[BlockHunt%H]'
|
||||
- '%A%arenaname%'
|
||||
- '%A%players%%N/%A%maxplayers%'
|
||||
- '&2Start: %A%timeleft%'
|
||||
INGAME:
|
||||
- '%H[BlockHunt%H]'
|
||||
- '&5%arenaname%'
|
||||
- '&5%players%&6/&5%maxplayers%'
|
||||
- '%EIngame: %A%timeleft%'
|
||||
- '%H[BlockHunt%H]'
|
||||
- '%A%arenaname%'
|
||||
- '%A%players%%N/%A%maxplayers%'
|
||||
- '%EIngame: %A%timeleft%'
|
||||
scoreboard:
|
||||
enabled: true
|
||||
title: '%H[BlockHunt]'
|
||||
|
@ -1,6 +1,6 @@
|
||||
log:
|
||||
enabledPlugin: '%TAG%N%name%&a&k + %N%version% is now Enabled. Made by %A%autors%%N.'
|
||||
disabledPlugin: '%TAG%N%name%&c&k - %N%version% is now Disabled. Made by %A%autors%%N.'
|
||||
enabledPlugin: '%TAG%N%name%&a&k + %N%version% is now Enabled. Made by %A%authors%%N.'
|
||||
disabledPlugin: '%TAG%N%name%&c&k - %N%version% is now Disabled. Made by %A%authors%%N.'
|
||||
help:
|
||||
info: '%NDisplays the plugin''s info.'
|
||||
help: '%NShows a list of commands.'
|
||||
@ -60,7 +60,7 @@ normal:
|
||||
shopChoosenHiders: '%TAG%NYou''ve choosen to be a %Ahider%N!'
|
||||
ingameBlocksLeft: '%TAG%NRemaining blocks: %A%1%%N'
|
||||
warning:
|
||||
lobbyNeedAtleast: '%TAG%WYou need atleast %A%1%%MemoryStorage player(s) to start the game!'
|
||||
lobbyNeedAtleast: '%TAG%WYou need atleast %A%1% player(s) to start the game!'
|
||||
ingameNEWSeekerChoosen: '%TAG%WThe last seeker left and a new seeker has been choosen!'
|
||||
unableToCommand: '%TAG%WSorry but that command is disabled in the arena.'
|
||||
ingameNoSolidPlace: '%TAG%WThat''s not a valid place to become solid!'
|
||||
@ -97,3 +97,5 @@ error:
|
||||
shopNeedMoreTokens: '%TAG%EYou need more tokens before you can buy this item.'
|
||||
shopMaxSeekersReached: '%TAG%ESorry, the maximum amount of seekers has been reached!'
|
||||
shopMaxHidersReached: '%TAG%ESorry, the maximum amount of hiders has been reached!'
|
||||
teleportFailed: '%TAG%EUnable to teleport you into the arena.'
|
||||
teleportBlocked: '%TAG%EYou cannot teleport while playing!'
|
||||
|
Loading…
Reference in New Issue
Block a user