* Better solid blocks! (It does like the hives right now! ;3)

This commit is contained in:
Steffion 2013-08-10 20:20:47 +02:00
parent ccccacb760
commit adf2c14eb1
6 changed files with 195 additions and 48 deletions

View File

@ -13,6 +13,7 @@ import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -88,7 +89,7 @@ public class ArenaHandler {
player.getLocation());
W.pGameMode.put(player,
player.getGameMode());
player.setGameMode(GameMode.ADVENTURE);
player.setGameMode(GameMode.SURVIVAL);
W.pInventory.put(player, player
.getInventory().getContents());
player.getInventory().clear();
@ -220,8 +221,17 @@ public class ArenaHandler {
player.setFoodLevel(W.pFood.get(player));
W.pFood.remove(player);
if (W.dcAPI.isDisguised(player)) {
W.dcAPI.undisguisePlayer(player);
for (Player pl : Bukkit.getOnlinePlayers()) {
pl.showPlayer(player);
if (W.hiddenLoc.get(player) != null) {
Block pBlock = W.hiddenLoc.get(player).getBlock();
pl.sendBlockChange(pBlock.getLocation(), Material.AIR,
(byte) 0);
}
if (W.dcAPI.isDisguised(player)) {
W.dcAPI.undisguisePlayer(player);
}
}
ScoreboardHandler.removeScoreboard(player);

View File

@ -9,10 +9,10 @@ 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.OnPlayerCommandPreprocessEvent;
import nl.Steffion.BlockHunt.Listeners.OnPlayerDeathEvent;
import nl.Steffion.BlockHunt.Listeners.OnPlayerDropItemEvent;
import nl.Steffion.BlockHunt.Listeners.OnPlayerInteractEvent;
import nl.Steffion.BlockHunt.Listeners.OnPlayerMoveEvent;
@ -22,13 +22,13 @@ 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.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
@ -85,8 +85,7 @@ public class BlockHunt extends JavaPlugin implements Listener {
ConfigurationSerialization.registerClass(LocationSerializable.class,
"Location");
ConfigurationSerialization.registerClass(ArenaSerializable.class,
"Arena");
ConfigurationSerialization.registerClass(Arena.class, "Arena");
W.newFiles();
@ -229,19 +228,37 @@ public class BlockHunt extends JavaPlugin implements Listener {
arenaPlayer.getInventory().setHelmet(
new ItemStack(block));
MessageM.sendFMessage(
arenaPlayer,
ConfigC.normal_ingameBlock,
true,
"block-"
+ block.getType()
.name()
.replaceAll("_", "")
.replaceAll(
"BLOCK", "")
.toLowerCase()
+ ":"
+ block.getDurability());
if (block.getDurability() != 0) {
MessageM.sendFMessage(
arenaPlayer,
ConfigC.normal_ingameBlock,
true,
"block-"
+ block.getType()
.name()
.replaceAll(
"_", "")
.replaceAll(
"BLOCK",
"")
.toLowerCase()
+ ":"
+ block.getDurability());
} else {
MessageM.sendFMessage(
arenaPlayer,
ConfigC.normal_ingameBlock,
true,
"block-"
+ block.getType()
.name()
.replaceAll(
"_", "")
.replaceAll(
"BLOCK",
"")
.toLowerCase());
}
}
}
}
@ -333,38 +350,122 @@ public class BlockHunt extends JavaPlugin implements Listener {
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 pBlock = player.getLocation()
.getBlock();
if (pBlock.getType().equals(
Material.AIR)) {
if (W.dcAPI.isDisguised(player)) {
W.dcAPI.undisguisePlayer(player);
for (Player pl : Bukkit
.getOnlinePlayers()) {
if (!pl.equals(player)) {
// pl.hidePlayer(player);
// W.dcAPI.undisguisePlayer(player);
pl.hidePlayer(player);
pl.sendBlockChange(
pBlock.getLocation(),
block.getType(),
(byte) block
.getDurability());
}
}
block.addUnsafeEnchantment(
Enchantment.DURABILITY,
10);
player.playSound(pLoc,
Sound.ORB_PICKUP,
1, 1);
W.hiddenLoc.put(player,
moveLoc);
if (block.getDurability() != 0) {
MessageM.sendFMessage(
player,
ConfigC.normal_ingameNowSolid,
true,
"block-"
+ block.getType()
.name()
.replaceAll(
"_",
"")
.replaceAll(
"BLOCK",
"")
.toLowerCase()
+ ":"
+ block.getDurability());
} else {
MessageM.sendFMessage(
player,
ConfigC.normal_ingameNowSolid,
true,
"block-"
+ block.getType()
.name()
.replaceAll(
"_",
"")
.replaceAll(
"BLOCK",
"")
.toLowerCase());
}
}
}
}
} 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);
} else {
MessageM.sendFMessage(
player,
ConfigC.warning_ingameNoSolidPlace,
true);
}
}
} else {
Block pBlock = player.getLocation()
.getBlock();
block.setAmount(5);
if (W.hiddenLoc.get(player) != null) {
pBlock = W.hiddenLoc.get(player)
.getBlock();
}
if (!W.dcAPI.isDisguised(player)) {
for (Player pl : Bukkit
.getOnlinePlayers()) {
if (!pl.equals(player)) {
pl.sendBlockChange(pBlock
.getLocation(),
Material.AIR,
(byte) 0);
}
}
player.playSound(pLoc,
Sound.BAT_HURT, 1, 1);
block.removeEnchantment(Enchantment.DURABILITY);
LinkedList<String> data = new LinkedList<String>();
data.add("blockID:"
+ block.getTypeId());
data.add("blockData:"
+ block.getDurability());
Disguise disguise = new Disguise(
W.dcAPI.newEntityID(),
data,
DisguiseType.FallingBlock);
if (W.dcAPI.isDisguised(player)) {
W.dcAPI.changePlayerDisguise(
player, disguise);
} else {
W.dcAPI.disguisePlayer(player,
disguise);
}
MessageM.sendFMessage(
player,
ConfigC.normal_ingameNoMoreSolid,
true);
}
}
}
}

View File

@ -31,6 +31,11 @@ public class OnPlayerCommandPreprocessEvent implements Listener {
|| m.startsWith("/reload")) {
return;
}
if (arena.allowedCommands.contains(m)) {
return;
}
MessageM.sendFMessage(player, ConfigC.warning_unableToCommand,
true);
event.setCancelled(true);

View File

@ -9,7 +9,9 @@ import nl.Steffion.BlockHunt.Managers.PlayerM;
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -107,5 +109,27 @@ public class OnPlayerInteractEvent implements Listener {
}
}
}
if (event.getAction() == Action.LEFT_CLICK_BLOCK
|| event.getAction() == Action.LEFT_CLICK_BLOCK) {
for (Arena arena : W.arenaList) {
if (arena.seekers.contains(player)) {
for (Player pl : arena.playersInArena) {
if (W.hiddenLoc.get(pl) != null) {
Block pLoc = event.getClickedBlock();
Block moveLocBlock = W.hiddenLoc.get(pl).getBlock();
if (moveLocBlock.getX() == pLoc.getX()
&& moveLocBlock.getY() == pLoc.getY()
&& moveLocBlock.getZ() == pLoc.getZ()) {
W.moveLoc.put(pl, player.getLocation());
player.getWorld().playEffect(
player.getLocation(), Effect.BOW_FIRE,
0);
}
}
}
}
}
}
}
}

View File

@ -88,7 +88,7 @@ public enum ConfigC {
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...",
normal_HiderDied ("%NHider %A%playername%%N died! %A%left%%N hider(s) remain...",
W.messages),
normal_SeekerDied ("%NSeeker %A%playername%%N died! He will respawn in %A%secs%%N seconds!",
W.messages),
@ -96,6 +96,9 @@ public enum ConfigC {
normal_winHiders ("%NThe %AHIDERS%N have won!", W.messages),
normal_setwarpWarpSet ("%NSet warp '%A%warp%%N' to your location!",
W.messages),
normal_ingameNowSolid ("%NYou're now a solid '%A%block%%N' block!",
W.messages),
normal_ingameNoMoreSolid ("%NYou're no longer a solid block!", W.messages),
warning_lobbyNeedAtleast ("%WYou need atleast %A%1%%W player(s) to start the game!",
W.messages),
@ -103,6 +106,8 @@ public enum ConfigC {
W.messages),
warning_unableToCommand ("%WSorry but that command is disabled in the arena.",
W.messages),
warning_ingameNoSolidPlace ("%WThat's not a valid place to become solid!",
W.messages),
error_noPermission ("%EYou don't have the permissions to do that!",
W.messages),

View File

@ -4,15 +4,16 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;
import nl.Steffion.BlockHunt.Managers.ConfigM;
import nl.Steffion.BlockHunt.Managers.MessageM;
import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import pgDev.bukkit.DisguiseCraft.api.DisguiseCraftAPI;
import nl.Steffion.BlockHunt.Managers.ConfigM;
import nl.Steffion.BlockHunt.Managers.MessageM;
import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
import pgDev.bukkit.DisguiseCraft.api.DisguiseCraftAPI;
public class W {
/*
@ -47,6 +48,7 @@ public class W {
public static HashMap<Player, Integer> pFood = new HashMap<Player, Integer>();
public static HashMap<Player, Location> moveLoc = new HashMap<Player, Location>();
public static HashMap<Player, Location> hiddenLoc = new HashMap<Player, Location>();
public static void newFiles() {
ConfigM.setDefaults();