Fixed issues that arrised in testing

This commit is contained in:
Sam 2018-01-10 22:00:19 +00:00 committed by Alexander Meech
parent 46b859ae8f
commit 3ac5c230c0
2 changed files with 34 additions and 32 deletions

View File

@ -5,7 +5,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.bukkit.Location;
import org.bukkit.Sound;
@ -17,10 +16,10 @@ import org.bukkit.event.player.PlayerQuitEvent;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -33,9 +32,9 @@ import nautilus.game.arcade.game.games.cakewars.CakeWars;
public class CakeBatModule extends CakeModule
{
private static final long DAMAGE_TIME = TimeUnit.SECONDS.toMillis(30);
private static final int DAMAGE_SECONDS = 30;
private final Map<Player, Long> _lastSafe;
private final Map<Player, Integer> _unsafeSeconds;
private final Set<Bat> _bats;
private int _minY;
@ -43,7 +42,7 @@ public class CakeBatModule extends CakeModule
{
super(game);
_lastSafe = new HashMap<>();
_unsafeSeconds = new HashMap<>();
_bats = new HashSet<>();
}
@ -66,7 +65,7 @@ public class CakeBatModule extends CakeModule
@EventHandler
public void updateBats(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC || _minY == 0)
if (event.getType() != UpdateType.SEC || !_game.IsLive() || _minY == 0)
{
return;
}
@ -93,51 +92,54 @@ public class CakeBatModule extends CakeModule
if (location.getY() >= _minY)
{
_lastSafe.put(player, System.currentTimeMillis());
continue;
}
Long last = _lastSafe.get(player);
Integer ticks = _unsafeSeconds.get(player);
if (last == null)
if (ticks == null)
{
_unsafeSeconds.put(player, 0);
continue;
}
if (!UtilTime.elapsed(last, DAMAGE_TIME))
_unsafeSeconds.put(player, ticks + 1);
if (ticks < DAMAGE_SECONDS)
{
if (Recharge.Instance.use(player, "Bat Warn", 8000, false, false))
if (UtilEnt.onBlock(player) && ticks % 8 == 0)
{
player.sendMessage(F.main("Game", "Return to the surface. Staying under the map for too long and bats will start attacking you."));
player.sendMessage(F.main("Game", "Return to the surface! If you don't bats will begin to attack you!"));
UtilTextBottom.display(C.cRedB + "Return to the surface!", player);
player.playSound(location, Sound.NOTE_STICKS, 1, 0.5F);
}
}
else
{
if (Recharge.Instance.use(player, "Bat Inform", 8000, false, false))
{
UtilTextMiddle.display(C.cRedB + "STOP CAMPING", "Bats are attacking you!", 0, 20, 10, player);
player.sendMessage(F.main("Game", "Get back to the surface, bats are attacking you!"));
player.playSound(location, Sound.NOTE_PLING, 1, 0.5F);
}
continue;
_game.CreatureAllowOverride = true;
Bat bat = location.getWorld().spawn(location.add(0, 1.2, 0), Bat.class);
bat.setAwake(true);
_bats.add(bat);
_game.getArcadeManager().GetDamage().NewDamageEvent(player, bat, null, DamageCause.ENTITY_ATTACK, 1 + (ticks - DAMAGE_SECONDS) / 5, false, true, true, bat.getName(), "Camping");
_game.CreatureAllowOverride = false;
}
if (Recharge.Instance.use(player, "Bat Inform", 8000, false, false))
{
UtilTextMiddle.display(C.cRedB + "STOP CAMPING", "Bats are attacking you!", 0, 20, 10, player);
player.sendMessage(F.main("Game", "Get back to the surface, bats are attacking you!"));
player.playSound(location, Sound.NOTE_PLING, 1, 0.5F);
}
_game.CreatureAllowOverride = true;
Bat bat = location.getWorld().spawn(location.add(0, 1.8, 0), Bat.class);
bat.setAwake(true);
_bats.add(bat);
_game.getArcadeManager().GetDamage().NewDamageEvent(player, bat, null, DamageCause.ENTITY_ATTACK, (System.currentTimeMillis() - last - DAMAGE_TIME) / 5000D, false, true, true, bat.getName(), "Camping");
_game.CreatureAllowOverride = false;
}
}
@EventHandler
public void playerQuit(PlayerQuitEvent event)
{
_lastSafe.remove(event.getPlayer());
_unsafeSeconds.remove(event.getPlayer());
}
}

View File

@ -68,7 +68,7 @@ public class PerkSlowSnowball extends Perk
Manager.GetCondition().Factory().Slow(GetName(), damagee, damager, 3, 1, false, true, false, false);
event.AddMod(damager.getName(), GetName(), 1, true);
event.AddKnockback(GetName(), -0.5);
event.AddKnockback(GetName(), 0.5);
}
@EventHandler