+ Made an insta respawn system.
This commit is contained in:
parent
7fde4abbc3
commit
f3d5dad54b
@ -1,10 +1,13 @@
|
||||
package nl.Steffion.BlockHunt.Listeners;
|
||||
|
||||
import nl.Steffion.BlockHunt.Arena;
|
||||
import nl.Steffion.BlockHunt.ArenaHandler;
|
||||
import nl.Steffion.BlockHunt.Arena.ArenaState;
|
||||
import nl.Steffion.BlockHunt.Managers.ConfigC;
|
||||
import nl.Steffion.BlockHunt.W;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -41,6 +44,46 @@ public class OnEntityDamageByEntityEvent implements Listener {
|
||||
} else {
|
||||
player.getWorld().playEffect(player.getLocation(),
|
||||
Effect.BOW_FIRE, 0);
|
||||
|
||||
if (event.getDamage() >= player.getHealth()) {
|
||||
player.setHealth(20);
|
||||
event.setCancelled(true);
|
||||
|
||||
W.dcAPI.undisguisePlayer(player);
|
||||
W.pBlock.remove(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);
|
||||
}
|
||||
|
||||
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.SURVIVAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,47 +0,0 @@
|
||||
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();
|
||||
event.setDroppedExp(0);
|
||||
W.dcAPI.undisguisePlayer(player);
|
||||
W.pBlock.remove(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
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();
|
||||
|
||||
for (Arena arena : W.arenaList) {
|
||||
if (arena.seekers.contains(player)) {
|
||||
if (arena.seekers.size() >= arena.playersInArena.size()) {
|
||||
event.setRespawnLocation(W.pLocation.get(player));
|
||||
ArenaHandler.seekersWin(arena);
|
||||
} else {
|
||||
W.dcAPI.undisguisePlayer(player);
|
||||
W.seekertime.put(player, arena.waitingTimeSeeker);
|
||||
event.setRespawnLocation(arena.seekersWarp);
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user