Fix phasing and mob spawning

This commit is contained in:
Sam 2018-07-24 18:18:22 +01:00 committed by Alexander Meech
parent 55e01b3259
commit 293880cee9
4 changed files with 125 additions and 39 deletions

View File

@ -1742,4 +1742,33 @@ 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;
}
}

View File

@ -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

View File

@ -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");
}
}
}
/**

View File

@ -33,6 +33,7 @@ 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<Player> _active = new HashSet<>();
@ -42,13 +43,13 @@ public class ArcticArmor extends Skill
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."
});
}
@ -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)
@ -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)));
}
});