Bacon Brawl refactor
This commit is contained in:
parent
bca212a544
commit
9ebf96cfd5
@ -1,17 +1,25 @@
|
||||
package nautilus.game.arcade.game.games.baconbrawl;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.SoloGame;
|
||||
import nautilus.game.arcade.game.games.baconbrawl.kits.KitMamaPig;
|
||||
import nautilus.game.arcade.game.games.baconbrawl.kits.KitPig;
|
||||
@ -21,26 +29,31 @@ import nautilus.game.arcade.kit.Kit;
|
||||
|
||||
public class BaconBrawl extends SoloGame
|
||||
{
|
||||
|
||||
private static final String[] DESCRIPTION =
|
||||
{
|
||||
"Knock other pigs out of the arena!",
|
||||
"Last pig in the arena wins!",
|
||||
"Knockback increases over time!"
|
||||
};
|
||||
|
||||
private double _knockbackMagnitude = 1.5;
|
||||
private long _increaseLast, _increaseTime = TimeUnit.SECONDS.toMillis(50);
|
||||
|
||||
public BaconBrawl(ArcadeManager manager)
|
||||
{
|
||||
super(manager, GameType.BaconBrawl,
|
||||
|
||||
new Kit[]
|
||||
super(manager, GameType.BaconBrawl, new Kit[]
|
||||
{
|
||||
new KitPig(manager),
|
||||
new KitMamaPig(manager),
|
||||
new KitSheepPig(manager)
|
||||
},
|
||||
|
||||
new String[]
|
||||
{
|
||||
"Knock other pigs out of the arena!",
|
||||
"Last pig in the arena wins!"
|
||||
});
|
||||
}, DESCRIPTION);
|
||||
|
||||
DamageTeamSelf = true;
|
||||
HungerSet = 20;
|
||||
PrepareFreeze = false;
|
||||
StrictAntiHack = true;
|
||||
PlayerGameMode = GameMode.ADVENTURE;
|
||||
|
||||
registerChatStats(
|
||||
Kills,
|
||||
@ -53,53 +66,81 @@ public class BaconBrawl extends SoloGame
|
||||
);
|
||||
|
||||
new CompassModule()
|
||||
.setGiveCompass(true)
|
||||
.setGiveCompassToSpecs(true)
|
||||
.setGiveCompassToAlive(false)
|
||||
.register(this);
|
||||
|
||||
StrictAntiHack = true;
|
||||
|
||||
PlayerGameMode = GameMode.ADVENTURE;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Hunger(UpdateEvent event)
|
||||
public void live(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() != GameState.Live)
|
||||
{
|
||||
if (event.getType() != UpdateType.SLOW)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsLive())
|
||||
_increaseLast = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void update(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SLOW || !IsLive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : GetPlayers(true))
|
||||
{
|
||||
if (player.getFoodLevel() <= 0)
|
||||
{
|
||||
Manager.GetDamage().NewDamageEvent(player, null, null,
|
||||
DamageCause.STARVATION, 4, false, true, false,
|
||||
"Starvation", GetName());
|
||||
Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.STARVATION, 4, false, true, false, GetName(), "Starvation");
|
||||
}
|
||||
|
||||
UtilPlayer.hunger(player, -1);
|
||||
}
|
||||
|
||||
if (_increaseTime > 0 && UtilTime.elapsed(_increaseLast, _increaseTime))
|
||||
{
|
||||
_increaseLast = System.currentTimeMillis();
|
||||
_increaseTime -= TimeUnit.SECONDS.toMillis(5);
|
||||
_knockbackMagnitude *= 1.2;
|
||||
|
||||
String message = C.cGreenB + "The ground begins to tremble... All pigs now take more knockback!";
|
||||
|
||||
for (Player player : UtilServer.getPlayersCollection())
|
||||
{
|
||||
player.sendMessage(message);
|
||||
player.playSound(player.getLocation(), Sound.ENDERDRAGON_WINGS, 1, 0.5F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void HungerRestore(CustomDamageEvent event)
|
||||
public void hungerRestore(CustomDamageEvent event)
|
||||
{
|
||||
Player damager = event.GetDamagerPlayer(true);
|
||||
|
||||
if (damager != null)
|
||||
{
|
||||
UtilPlayer.hunger(damager, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void DamageEvent(CustomDamageEvent event)
|
||||
public void knockback(CustomDamageEvent event)
|
||||
{
|
||||
if (event.GetCause() == DamageCause.ENTITY_ATTACK || event.GetCause() == DamageCause.CUSTOM || event.GetCause() == DamageCause.PROJECTILE)
|
||||
if (!IsLive())
|
||||
{
|
||||
event.GetDamageeEntity().setHealth(event.GetDamageeEntity().getMaxHealth());
|
||||
event.AddKnockback("Pig Wrestle", 1.5 + ((System.currentTimeMillis() - GetStateTime()) / 120000d));
|
||||
return;
|
||||
}
|
||||
|
||||
DamageCause cause = event.GetCause();
|
||||
|
||||
if (cause == DamageCause.ENTITY_ATTACK || cause == DamageCause.CUSTOM || cause == DamageCause.PROJECTILE)
|
||||
{
|
||||
LivingEntity entity = event.GetDamageeEntity();
|
||||
|
||||
entity.setHealth(entity.getMaxHealth());
|
||||
event.AddKnockback("Pig Wrestle", _knockbackMagnitude);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user