Skip to content
This repository has been archived by the owner on Nov 6, 2018. It is now read-only.

Commit

Permalink
+ Added abillity to become solid in water!
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffion committed Aug 11, 2013
1 parent b5d7019 commit b8e062f
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 20 deletions.
66 changes: 50 additions & 16 deletions src/nl/Steffion/BlockHunt/BlockHunt.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@
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;
import nl.Steffion.BlockHunt.Listeners.OnPlayerQuitEvent;
import nl.Steffion.BlockHunt.Listeners.OnPlayerRespawnEvent;
import nl.Steffion.BlockHunt.Listeners.OnSignChangeEvent;
import nl.Steffion.BlockHunt.Managers.CommandC;
import nl.Steffion.BlockHunt.Managers.ConfigC;
import nl.Steffion.BlockHunt.Managers.MessageM;
import nl.Steffion.BlockHunt.Serializables.LocationSerializable;

import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
Expand Down Expand Up @@ -68,8 +67,6 @@ public void onEnable() {
new OnInventoryCloseEvent(), this);
getServer().getPluginManager().registerEvents(
new OnPlayerCommandPreprocessEvent(), this);
getServer().getPluginManager().registerEvents(new OnPlayerDeathEvent(),
this);
getServer().getPluginManager().registerEvents(
new OnPlayerDropItemEvent(), this);
getServer().getPluginManager().registerEvents(
Expand All @@ -78,14 +75,12 @@ public void onEnable() {
this);
getServer().getPluginManager().registerEvents(new OnPlayerQuitEvent(),
this);
getServer().getPluginManager().registerEvents(
new OnPlayerRespawnEvent(this), this);
getServer().getPluginManager().registerEvents(new OnSignChangeEvent(),
this);

ConfigurationSerialization.registerClass(LocationSerializable.class,
"Location");
ConfigurationSerialization.registerClass(Arena.class, "Arena");
"BlockHuntLocation");
ConfigurationSerialization.registerClass(Arena.class, "BlockHuntArena");

W.newFiles();

Expand Down Expand Up @@ -216,10 +211,13 @@ public void run() {
}

arenaPlayer.teleport(arena.hidersWarp);
ItemStack sword = new ItemStack(
Material.WOOD_SWORD, 1);
sword.addUnsafeEnchantment(
Enchantment.KNOCKBACK, 1);

arenaPlayer.getInventory().addItem(sword);

arenaPlayer.getInventory().addItem(
new ItemStack(Material.GOLD_SWORD,
1));
ItemStack blockCount = new ItemStack(block
.getType(), 5);
blockCount.setDurability(block
Expand Down Expand Up @@ -363,7 +361,23 @@ public void run() {
Block pBlock = player.getLocation()
.getBlock();
if (pBlock.getType().equals(
Material.AIR)) {
Material.AIR)
|| pBlock.getType().equals(
Material.WATER)
|| pBlock
.getType()
.equals(Material.STATIONARY_WATER)) {
if (pBlock.getType().equals(
Material.WATER)
|| pBlock
.getType()
.equals(Material.STATIONARY_WATER)) {
W.hiddenLocWater.put(
player, true);
} else {
W.hiddenLocWater.put(
player, false);
}
if (W.dcAPI.isDisguised(player)) {
W.dcAPI.undisguisePlayer(player);
for (Player pl : Bukkit
Expand Down Expand Up @@ -441,10 +455,29 @@ public void run() {
for (Player pl : Bukkit
.getOnlinePlayers()) {
if (!pl.equals(player)) {
pl.sendBlockChange(pBlock
.getLocation(),
Material.AIR,
(byte) 0);
if (W.hiddenLocWater
.get(player) != null) {
if (W.hiddenLocWater
.get(player) == true) {
pl.sendBlockChange(
pBlock.getLocation(),
Material.STATIONARY_WATER,
(byte) 0);
} else {
pl.sendBlockChange(
pBlock.getLocation(),
Material.AIR,
(byte) 0);
}
} else {
pl.sendBlockChange(
pBlock.getLocation(),
Material.AIR,
(byte) 0);
}

W.hiddenLocWater
.remove(player);
}
}

Expand Down Expand Up @@ -482,6 +515,7 @@ public void run() {

for (Player pl : arena.playersInArena) {
pl.setLevel(arena.timer);
pl.setGameMode(GameMode.SURVIVAL);
}

ScoreboardHandler.doScoreboard(arena);
Expand Down
8 changes: 4 additions & 4 deletions src/nl/Steffion/BlockHunt/Listeners/OnEntityDamageEvent.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package nl.Steffion.BlockHunt.Listeners;

import nl.Steffion.BlockHunt.Arena;
import nl.Steffion.BlockHunt.Arena.ArenaState;
import nl.Steffion.BlockHunt.W;

import org.bukkit.entity.Entity;
Expand All @@ -10,6 +9,7 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;

public class OnEntityDamageEvent implements Listener {

Expand All @@ -20,9 +20,9 @@ public void onEntityDamageEvent(EntityDamageEvent event) {
if (ent instanceof Player) {
Player player = (Player) event.getEntity();
for (Arena arena : W.arenaList) {
if (arena.gameState.equals(ArenaState.WAITING)
|| arena.gameState.equals(ArenaState.STARTING)) {
if (arena.playersInArena.contains(player)) {
if (arena.playersInArena.contains(player)) {
if (event.getCause().equals(DamageCause.FALL)
|| event.getCause().equals(DamageCause.DROWNING)) {
event.setCancelled(true);
}
}
Expand Down

0 comments on commit b8e062f

Please sign in to comment.