From 293880cee9d71fe06d83f05f4e774e8be2134153 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 24 Jul 2018 18:18:22 +0100 Subject: [PATCH] Fix phasing and mob spawning --- .../mineplex/core/common/util/UtilBlock.java | 31 +++++- .../clans/clans/observer/ObserverManager.java | 10 +- .../src/mineplex/game/clans/spawn/Spawn.java | 20 ++++ .../classcombat/Skill/Mage/ArcticArmor.java | 103 ++++++++++++------ 4 files changed, 125 insertions(+), 39 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java index 341de3aa3..1458c6698 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java @@ -1741,5 +1741,34 @@ public class UtilBlock { return horizontals.get(Math.round(yaw / 90F) & 0x3); } - + + public static boolean isFence(Block block) + { + return isFence(block.getType()); + } + + public static boolean isFence(Material type) + { + switch (type) + { + case FENCE: + case FENCE_GATE: + case ACACIA_FENCE: + case BIRCH_FENCE: + case DARK_OAK_FENCE: + case IRON_FENCE: + case JUNGLE_FENCE: + case NETHER_FENCE: + case SPRUCE_FENCE: + case ACACIA_FENCE_GATE: + case BIRCH_FENCE_GATE: + case DARK_OAK_FENCE_GATE: + case JUNGLE_FENCE_GATE: + case SPRUCE_FENCE_GATE: + return true; + } + + return false; + } + } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java index c1093acf2..fdd3cb87c 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/observer/ObserverManager.java @@ -82,16 +82,16 @@ public class ObserverManager extends MiniPlugin private void restore(Player player, ObserverData data) { + data.getSnapshot().applySnapshot(player); + player.setGameMode(GameMode.SURVIVAL); + ((CraftPlayer) player).getHandle().spectating = false; + Condition condition = _conditionManager.GetActiveCondition(player, ConditionType.CLOAK); if (condition != null) { - condition.Remove(); + condition.Expire(); } - - data.getSnapshot().applySnapshot(player); - player.setGameMode(GameMode.SURVIVAL); - ((CraftPlayer) player).getHandle().spectating = false; } @EventHandler diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java index 9d0da9e62..3917c66d8 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/Spawn.java @@ -31,6 +31,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Monster; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockFromToEvent; @@ -327,6 +328,25 @@ public class Spawn extends MiniPlugin } } } + + String mobsEnabled = getSpawnWorld().getGameRuleValue("doMobSpawning"); + + if (mobsEnabled.equals("true")) + { + if (getSpawnWorld().getTime() < 12000) + { + Bukkit.broadcastMessage("Mob spawning disabled"); + getSpawnWorld().setGameRuleValue("doMobSpawning", "false"); + } + } + else + { + if (getSpawnWorld().getTime() > 12000) + { + Bukkit.broadcastMessage("Mob spawning enabled"); + getSpawnWorld().setGameRuleValue("doMobSpawning", "true"); + } + } } /** diff --git a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/ArcticArmor.java b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/ArcticArmor.java index bbf3b52e6..7524f2835 100644 --- a/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/ArcticArmor.java +++ b/Plugins/Mineplex.Minecraft.Game.ClassCombat/src/mineplex/minecraft/game/classcombat/Skill/Mage/ArcticArmor.java @@ -33,22 +33,23 @@ public class ArcticArmor extends Skill { private static final double DELTA_THETA = Math.PI / 10; + private static final double FENCE_FROM_CENTER_DIST = 0.95; private final Set _active = new HashSet<>(); - public ArcticArmor(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels) + public ArcticArmor(SkillFactory skills, String name, ClassType classType, SkillType skillType, int cost, int levels) { super(skills, name, classType, skillType, cost, levels); - SetDesc(new String[] + SetDesc(new String[] { - "Drop Axe/Sword to Toggle.", - "", - "Create a freezing area around you", - "in a #3#1 Block radius. Allies inside", - "this area receive Protection 2.", - "", - "You receive Protection 2." + "Drop Axe/Sword to Toggle.", + "", + "Create a freezing area around you", + "in a #3#1 Block radius. Allies inside", + "this area receive Protection 2.", + "", + "You receive Protection 2." }); } @@ -63,7 +64,7 @@ public class ArcticArmor extends Skill { Player player = event.getPlayer(); - if (getLevel(player) == 0) + if (getLevel(player) == 0) return; if (!UtilGear.isWeapon(event.getItemDrop().getItemStack())) @@ -79,7 +80,7 @@ public class ArcticArmor extends Skill if (_active.contains(player)) { - Remove(player); + Remove(player); } else { @@ -93,7 +94,7 @@ public class ArcticArmor extends Skill public void Add(Player player) { _active.add(player); - UtilPlayer.message(player, F.main(GetClassType().name(), F.skill(GetName()) + ": " + F.oo("Enabled", true))); + UtilPlayer.message(player, F.main(GetClassType().name(), F.skill(GetName()) + ": " + F.oo("Enabled", true))); } public void Remove(Player player) @@ -109,7 +110,7 @@ public class ArcticArmor extends Skill if (event.getType() != UpdateType.SEC) return; - for (Player cur : _active) + for (Player cur : _active) cur.getWorld().playSound(cur.getLocation(), Sound.AMBIENCE_RAIN, 0.3f, 0f); } @@ -120,7 +121,7 @@ public class ArcticArmor extends Skill return; for (Player cur : GetUsers()) - { + { if (!_active.contains(cur)) continue; @@ -128,10 +129,10 @@ public class ArcticArmor extends Skill int level = getLevel(cur); if (level == 0) { - Remove(cur); + Remove(cur); continue; } - + //Check Allowed SkillTriggerEvent trigger = new SkillTriggerEvent(cur, GetName(), GetClassType()); UtilServer.getServer().getPluginManager().callEvent(trigger); @@ -140,7 +141,7 @@ public class ArcticArmor extends Skill Remove(cur); continue; } - + //Energy if (!Factory.Energy().Use(cur, GetName(), 0.55 - (level * 0.05), true, true)) { @@ -157,18 +158,54 @@ public class ArcticArmor extends Skill { Block up = block.getRelative(BlockFace.UP); - if (block.getType().toString().contains("BANNER") || up.getType().toString().contains("BANNER")) + if (block.getType().toString().contains("BANNER") || up.isLiquid() || block.getLocation().getY() > cur.getLocation().getY()) { return; } //Freeze - if (!up.isLiquid() && block.getLocation().getY() <= cur.getLocation().getY()) + Material type = block.getType(); + + if (UtilBlock.water(type) || type == Material.ICE) { - if (block.getTypeId() == 8 || block.getTypeId() == 9 || block.getTypeId() == 79) + for (Player player : block.getWorld().getPlayers()) { - Factory.BlockRestore().add(block, 79, (byte) 0, (long) (duration * (1 + scale))); + if (UtilPlayer.isSpectator(player)) + { + continue; + } + + Location playerLocation = player.getLocation(); + Block playerBlock = playerLocation.getBlock(); + + // Force players up if they try and get themselves stuck + if (playerBlock.equals(block)) + { + player.teleport(playerLocation.add(0, 1, 0)); + } + else + { + Location blockLocation = block.getLocation().add(0.5, 0, 0.5); + + for (BlockFace face : UtilBlock.horizontals) + { + Block nextBlock = block.getRelative(face); + + if (UtilBlock.isFence(nextBlock) && playerBlock.equals(nextBlock) && Math.abs(playerLocation.getX() - blockLocation.getX()) < FENCE_FROM_CENTER_DIST && Math.abs(playerLocation.getZ() - blockLocation.getZ()) < FENCE_FROM_CENTER_DIST) + { + Location moveTo = block.getLocation().add(0.5, 1, 0.5); + + moveTo.setYaw(playerLocation.getYaw()); + moveTo.setPitch(playerLocation.getPitch()); + + player.teleport(moveTo); + break; + } + } + } } + + Factory.BlockRestore().add(block, 79, (byte) 0, (long) (duration * (1 + scale))); } }); @@ -207,50 +244,50 @@ public class ArcticArmor extends Skill } } } - + @EventHandler public void Damage(UpdateEvent event) { if (event.getType() != UpdateType.FAST) return; - + for (Player cur : UtilServer.getPlayers()) - { + { if (UtilPlayer.isSpectator(cur)) continue; - + if (cur.getEyeLocation().getBlock().getType() == Material.ICE) { if (!Factory.BlockRestore().contains(cur.getEyeLocation().getBlock())) continue; - + Player damager = null; double closest = 0; - + for (Player player : _active) { if (player.equals(cur)) continue; - + double dist = UtilMath.offsetSquared(player, cur); - + if (dist < 25 && (damager == null || dist < closest)) { damager = player; closest = dist; } } - + //Damage Event - Factory.Damage().NewDamageEvent(cur, damager, null, + Factory.Damage().NewDamageEvent(cur, damager, null, DamageCause.CUSTOM, 2, false, true, false, - damager == null ? null : damager.getName(), "Arctic Ice"); + damager == null ? null : damager.getName(), "Arctic Ice"); } } } @Override - public void Reset(Player player) + public void Reset(Player player) { _active.remove(player); }