Fixed some in-game stuff.
This commit is contained in:
parent
d1c10ebbf6
commit
8043eb4e6e
24
src/nl/Steffion/BlockHunt/Listeners/OnBlockBreakEvent.java
Normal file
24
src/nl/Steffion/BlockHunt/Listeners/OnBlockBreakEvent.java
Normal file
@ -0,0 +1,24 @@
|
||||
package nl.Steffion.BlockHunt.Listeners;
|
||||
|
||||
import nl.Steffion.BlockHunt.Arena;
|
||||
import nl.Steffion.BlockHunt.W;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
public class OnBlockBreakEvent implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onBlockBreakEvent(BlockBreakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
24
src/nl/Steffion/BlockHunt/Listeners/OnBlockPlaceEvent.java
Normal file
24
src/nl/Steffion/BlockHunt/Listeners/OnBlockPlaceEvent.java
Normal file
@ -0,0 +1,24 @@
|
||||
package nl.Steffion.BlockHunt.Listeners;
|
||||
|
||||
import nl.Steffion.BlockHunt.Arena;
|
||||
import nl.Steffion.BlockHunt.W;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
public class OnBlockPlaceEvent implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onBlockPlaceEvent(BlockPlaceEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package nl.Steffion.BlockHunt.Listeners;
|
||||
|
||||
import nl.Steffion.BlockHunt.Arena;
|
||||
import nl.Steffion.BlockHunt.Arena.ArenaState;
|
||||
import nl.Steffion.BlockHunt.W;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
public class OnEntityDamageByEntityEvent implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) {
|
||||
Entity ent = event.getEntity();
|
||||
Player player = null;
|
||||
if (ent instanceof Player) {
|
||||
player = (Player) ent;
|
||||
}
|
||||
|
||||
if (player != null) {
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
if (arena.gameState == ArenaState.WAITING
|
||||
|| arena.gameState == ArenaState.STARTING) {
|
||||
event.setCancelled(true);
|
||||
} else {
|
||||
if (arena.seekers.contains(player)
|
||||
&& arena.seekers.contains(event.getDamager())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -24,6 +24,13 @@ public class OnInventoryClickEvent implements Listener {
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onInventoryClickEvent(InventoryClickEvent event) {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
Inventory inv = event.getInventory();
|
||||
if (inv.getType().equals(InventoryType.CHEST)) {
|
||||
if (inv.getName().startsWith("\u00A7r")) {
|
||||
|
@ -0,0 +1,40 @@
|
||||
package nl.Steffion.BlockHunt.Listeners;
|
||||
|
||||
import nl.Steffion.BlockHunt.Arena;
|
||||
import nl.Steffion.BlockHunt.W;
|
||||
import nl.Steffion.BlockHunt.Managers.ConfigC;
|
||||
import nl.Steffion.BlockHunt.Managers.MessageM;
|
||||
|
||||
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.PlayerCommandPreprocessEvent;
|
||||
|
||||
public class OnPlayerCommandPreprocessEvent implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerCommandPreprocessEvent(
|
||||
PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
String m = event.getMessage();
|
||||
if (m.startsWith("/blockhunt") || m.startsWith("/bh")
|
||||
|| m.startsWith("/seekandfind")
|
||||
|| m.startsWith("/seekandfind") || m.startsWith("/saf")
|
||||
|| m.startsWith("/sf") || m.startsWith("/hideandseek")
|
||||
|| m.startsWith("/has") || m.startsWith("/hs")
|
||||
|| m.startsWith("/ban") || m.startsWith("/kick")
|
||||
|| m.startsWith("/tempban") || m.startsWith("/mute")
|
||||
|| m.startsWith("/reload")) {
|
||||
return;
|
||||
}
|
||||
MessageM.sendFMessage(player, ConfigC.warning_unableToCommand,
|
||||
true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
45
src/nl/Steffion/BlockHunt/Listeners/OnPlayerDeathEvent.java
Normal file
45
src/nl/Steffion/BlockHunt/Listeners/OnPlayerDeathEvent.java
Normal file
@ -0,0 +1,45 @@
|
||||
package nl.Steffion.BlockHunt.Listeners;
|
||||
|
||||
import nl.Steffion.BlockHunt.Arena;
|
||||
import nl.Steffion.BlockHunt.ArenaHandler;
|
||||
import nl.Steffion.BlockHunt.W;
|
||||
import nl.Steffion.BlockHunt.Managers.ConfigC;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
|
||||
public class OnPlayerDeathEvent implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerDeathEvent(PlayerDeathEvent event) {
|
||||
Player player = event.getEntity();
|
||||
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
event.setDeathMessage(null);
|
||||
event.getDrops().clear();
|
||||
W.dcAPI.undisguisePlayer(player);
|
||||
|
||||
if (!arena.seekers.contains(player)) {
|
||||
arena.seekers.add(player);
|
||||
ArenaHandler
|
||||
.sendFMessage(
|
||||
arena,
|
||||
ConfigC.normal_HiderDied,
|
||||
true,
|
||||
"playername-" + player.getName(),
|
||||
"left-"
|
||||
+ (arena.playersInArena.size() - arena.seekers
|
||||
.size()));
|
||||
} else {
|
||||
ArenaHandler.sendFMessage(arena, ConfigC.normal_SeekerDied,
|
||||
true, "playername-" + player.getName(), "secs-"
|
||||
+ arena.waitingTimeSeeker);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -22,6 +22,7 @@ public class OnPlayerMoveEvent implements Listener {
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
if (arena.gameState == ArenaState.INGAME) {
|
||||
W.pLocation.put(player, player.getLocation());
|
||||
double maxX = Math
|
||||
.max(arena.pos1.getX(), arena.pos2.getX());
|
||||
double minX = Math
|
||||
@ -40,10 +41,12 @@ public class OnPlayerMoveEvent implements Listener {
|
||||
event.setCancelled(true);
|
||||
player.playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
player.playSound(loc, Sound.GHAST_FIREBALL, 1, 1);
|
||||
player.teleport(loc.add(0, 2, 0));
|
||||
} else if (loc.getBlockZ() > maxZ || loc.getBlockZ() < minZ) {
|
||||
event.setCancelled(true);
|
||||
player.playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
player.playSound(loc, Sound.GHAST_FIREBALL, 1, 1);
|
||||
player.teleport(loc.add(0, 2, 0));
|
||||
} else if (loc.getBlockY() > maxY) {
|
||||
event.setCancelled(true);
|
||||
player.playEffect(loc, Effect.ENDER_SIGNAL, 0);
|
||||
@ -55,6 +58,30 @@ public class OnPlayerMoveEvent implements Listener {
|
||||
player.playSound(loc, Sound.GHAST_FIREBALL, 1, 1);
|
||||
player.teleport(loc.add(0, 5, 0));
|
||||
}
|
||||
|
||||
// Location pLocation = W.pLocation.get(player);
|
||||
// ItemStack block = player.getInventory().getItem(8);
|
||||
//
|
||||
// if (pLocation.getX() == pLoc.getX()
|
||||
// && pLocation.getY() == pLoc.getY()
|
||||
// && pLocation.getZ() == pLoc.getZ()) {
|
||||
// if (block.getAmount() > 1) {
|
||||
// block.setAmount(block.getAmount() - 1);
|
||||
// } else {
|
||||
// Disguise dis = W.dcAPI.getDisguise(player);
|
||||
// dis.addSingleData("blocklock");
|
||||
// W.dcAPI.changePlayerDisguise(player, dis);
|
||||
// block.addEnchantment(Enchantment.DURABILITY, 10);
|
||||
// player.playSound(pLoc, Sound.ORB_PICKUP, 1, 1);
|
||||
// }
|
||||
// } else {
|
||||
// Disguise dis = W.dcAPI.getDisguise(player);
|
||||
// dis.data.remove("blocklock");
|
||||
// W.dcAPI.changePlayerDisguise(player, dis);
|
||||
// player.playSound(pLoc, Sound.BAT_HURT, 1, 1);
|
||||
// block.removeEnchantment(Enchantment.DURABILITY);
|
||||
// block.setAmount(5);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
25
src/nl/Steffion/BlockHunt/Listeners/OnPlayerQuitEvent.java
Normal file
25
src/nl/Steffion/BlockHunt/Listeners/OnPlayerQuitEvent.java
Normal file
@ -0,0 +1,25 @@
|
||||
package nl.Steffion.BlockHunt.Listeners;
|
||||
|
||||
import nl.Steffion.BlockHunt.Arena;
|
||||
import nl.Steffion.BlockHunt.ArenaHandler;
|
||||
import nl.Steffion.BlockHunt.W;
|
||||
|
||||
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.PlayerQuitEvent;
|
||||
|
||||
public class OnPlayerQuitEvent implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerQuitEvent(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.playersInArena.contains(player)) {
|
||||
ArenaHandler.playerLeaveArena(player, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package nl.Steffion.BlockHunt.Listeners;
|
||||
|
||||
import nl.Steffion.BlockHunt.Arena;
|
||||
import nl.Steffion.BlockHunt.ArenaHandler;
|
||||
import nl.Steffion.BlockHunt.BlockHunt;
|
||||
import nl.Steffion.BlockHunt.W;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
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.PlayerRespawnEvent;
|
||||
|
||||
public class OnPlayerRespawnEvent implements Listener {
|
||||
|
||||
public static BlockHunt plugin;
|
||||
|
||||
public OnPlayerRespawnEvent (BlockHunt plugin) {
|
||||
OnPlayerRespawnEvent.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerRespawnEvent(final PlayerRespawnEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.seekers.contains(player)) {
|
||||
if (arena.seekers.size() >= arena.playersInArena.size()) {
|
||||
player.teleport(W.pLocation.get(player));
|
||||
ArenaHandler.seekersWin(arena);
|
||||
} else {
|
||||
W.dcAPI.undisguisePlayer(player);
|
||||
W.seekertime.put(player, arena.waitingTimeSeeker);
|
||||
player.teleport(arena.seekersWarp);
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 20);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user