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

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

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,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<Player> _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);
}