Refactor project classes

This commit is contained in:
Thanos Paravantis 2016-07-09 12:00:06 +03:00
parent 331c1bcf91
commit a9f41ab269
7 changed files with 159 additions and 100 deletions

View File

@ -138,6 +138,7 @@ import nautilus.game.arcade.kit.Kit;
*/
public class BawkBawkBattles extends TeamGame implements IThrown
{
public static final int MAX_LIVES = 5;
private static final double SPAWN_CENTER_ADD = 0.5;
private static final double SPECTATOR_SPAWN_HEIGHT = 7;
@ -192,7 +193,6 @@ public class BawkBawkBattles extends TeamGame implements IThrown
private static final int MIN_PLAYERS_BLOCK_ATTEMPT = 1;
private static final int GENERIC_SCOREBOARD_PLAYER_COUNT = 15;
private static final int MAX_LIVES = 5;
private static final int LOST_ONE_LIFE = MAX_LIVES - 1;
private static final int LOST_TWO_LIVES = MAX_LIVES - 2;
private static final int LOST_THREE_LIVES = MAX_LIVES - 3;
@ -383,7 +383,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
{
for (Player player : GetPlayers(true))
{
_lives.put(player, _settings.getMaxLives());
_lives.put(player, MAX_LIVES);
}
}

View File

@ -5,7 +5,6 @@ package nautilus.game.arcade.game.games.mineware;
*/
public class BawkBawkBattlesSettings
{
private int _maxLives = 5;
private boolean _crumbling = false;
private boolean _waiting = true;
private boolean _messagesSent = false;
@ -15,16 +14,6 @@ public class BawkBawkBattlesSettings
// Debug
private boolean _markSpawnLocations = false;
public void setMaxLives(int maxLives)
{
_maxLives = maxLives;
}
public int getMaxLives()
{
return _maxLives;
}
public void setCrumbling(boolean flag)
{
_crumbling = flag;

View File

@ -66,19 +66,61 @@ import nautilus.game.arcade.world.WorldData;
*/
public abstract class Challenge implements Listener
{
protected BawkBawkBattles Host;
private ChallengeType _type;
private String _name;
private String[] _description;
protected ChallengeSettings Settings;
protected ChallengeData Data;
protected static final int TICK_MULTIPLIER = 20;
private static final int TITLE_FADE_IN_TICKS = 5;
private static final int TITLE_STAY_TICKS = 40;
private static final int TITLE_FADE_OUT_TICKS = 5;
private static final int BORDER_MIN_X = -100;
private static final int BORDER_MAX_X = 100;
private static final int BORDER_MIN_Y = 0;
private static final int BORDER_MAX_Y = 256;
private static final int BORDER_MIN_Z = -100;
private static final int BORDER_MAX_Z = 100;
private static final int COMPLETE_COUNT_DIVIDER = 2;
private static final int WINNER_ADD_CRITERIA = 3; // players
private static final int CHICKEN_ATTACK_CRITERIA = 2; // players
private static final int CHALLENGE_CLOAK_DURATION = 7777;
private static final int COMPLETION_GEMS = 3;
private static final int STARTING_SOON_MESSAGE_CRITERIA = 2; // players
private static final double BLOCK_CENTER_ADD = 0.5;
private static final int CRUMBLE_CHANCE = 4;
private static final int PLAYER_COUNT_FOR_EFFECTS = 2;
private static final int COMPLETION_TITLE_STAY_TICKS = 30;
private static final float COMPLETION_SOUND_VOLUME = 2.0F;
private static final float COMPLETION_SOUND_PITCH = 1.0F;
private static final float LOST_SOUND_VOLUME = 2.0F;
private static final float LOST_SOUND_PITCH = 1.0F;
protected static final int INVENTORY_HOTBAR_SLOTS = 8;
private static final int BLOCK_BREAK_PARTICLE_COUNT = 10;
private static final int GRASS_SPAWN_CHANCE = 4;
private static final int FLOWER_SPAWN_CHANCE = 8;
private static final int DOUBLE_PLANT_CHANCE = 3;
private static final int DOUBLE_PLANT_DATA_RANGE = 5;
private static final byte DOUBLE_PLANT_PART_DATA = 8;
private static final int DISPLAY_COUNT_EXPIRE_AFTER = 1000;
private static final int DEFAULT_ARENA_SIZE = 8;
private static final int ARENA_SIZE_DIVIDER = 2;
private static final int ARENA_SIZE_LIMIT = 40;
protected final BawkBawkBattles Host;
protected final ChallengeSettings Settings;
protected final ChallengeData Data;
private ChallengeType _type;
private String _name;
private String[] _description;
public Challenge(BawkBawkBattles host, ChallengeType type, String name, String... description)
{
Host = host;
@ -159,10 +201,10 @@ public abstract class Challenge implements Listener
public void start()
{
setBorder(-100, 100, 0, 256, -100, 100);
setBorder(BORDER_MIN_X, BORDER_MAX_X, BORDER_MIN_Y, BORDER_MAX_Y, BORDER_MIN_Z, BORDER_MAX_Z);
Settings.setStartTime(System.currentTimeMillis());
Settings.setMaxCompletedCount((int) Math.ceil(getPlayersAlive().size() / 2));
Settings.setMaxCompletedCount((int) Math.ceil(getPlayersAlive().size() / COMPLETE_COUNT_DIVIDER));
if (Settings.isInventoryLocked())
{
@ -286,12 +328,12 @@ public abstract class Challenge implements Listener
int alive = Host.getPlayersWithRemainingLives();
int lives = loseLife(player);
if (lives <= 0 && alive <= 3)
if (lives <= 0 && alive <= WINNER_ADD_CRITERIA)
{
Host.getWinners().add(player);
}
if (lives <= 0 && alive > 2)
if (lives <= 0 && alive > CHICKEN_ATTACK_CRITERIA)
{
Host.GetScoreboard().ResetScore(player.getName());
Host.getChickenAttack().start(player);
@ -320,7 +362,7 @@ public abstract class Challenge implements Listener
UtilPlayer.message(player, F.main("Game", C.cRed + "You failed to complete the task."));
Host.showLivesLeft(player);
Host.Manager.addSpectator(player, true);
Host.Manager.GetCondition().Factory().Cloak("Challenge Death", player, player, 7777, true, true);
Host.Manager.GetCondition().Factory().Cloak("Challenge Death", player, player, CHALLENGE_CLOAK_DURATION, true, true);
}
private void handleRemainingPlayers()
@ -349,14 +391,14 @@ public abstract class Challenge implements Listener
{
if (Data.isCompleted(player))
{
Host.AddGems(player, 3, "Completed Challenge", true, true);
Host.AddGems(player, COMPLETION_GEMS, "Completed Challenge", true, true);
}
}
@EventHandler
public void startingSoon(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC || !Host.IsLive() || Host.getPlayersWithRemainingLives() <= 2)
if (event.getType() != UpdateType.SEC || !Host.IsLive() || Host.getPlayersWithRemainingLives() <= STARTING_SOON_MESSAGE_CRITERIA)
return;
HashSet<Player> players = new HashSet<Player>();
@ -365,7 +407,7 @@ public abstract class Challenge implements Listener
for (Player player : players)
{
if (!Host.getChickenTeam().HasPlayer(player))
if (!Host.getChickenTeam().HasPlayer(player) && Host.lives(player) > 0)
{
UtilTextBottom.display(C.Bold + "Next challenge will begin shortly.", player);
}
@ -405,7 +447,7 @@ public abstract class Challenge implements Listener
for (Block currentBlock : Data.getModifiedBlocks())
{
double theBlocksDistance = UtilMath.offset2d(Host.GetSpectatorLocation(), currentBlock.getLocation().add(0.5, 0.5, 0.5));
double theBlocksDistance = UtilMath.offset2d(Host.GetSpectatorLocation(), currentBlock.getLocation().add(BLOCK_CENTER_ADD, BLOCK_CENTER_ADD, BLOCK_CENTER_ADD));
if (qualifiedBlock == null || furthestDistance < theBlocksDistance)
{
@ -421,9 +463,9 @@ public abstract class Challenge implements Listener
Data.removeModifiedBlock(qualifiedBlock);
if (UtilMath.r(4) == 0)
if (UtilMath.r(CRUMBLE_CHANCE) == 0)
{
qualifiedBlock.getWorld().spawnFallingBlock(qualifiedBlock.getLocation().add(0.5, 0.5, 0.5), qualifiedBlock.getType(), qualifiedBlock.getData());
qualifiedBlock.getWorld().spawnFallingBlock(qualifiedBlock.getLocation().add(BLOCK_CENTER_ADD, BLOCK_CENTER_ADD, BLOCK_CENTER_ADD), qualifiedBlock.getType(), qualifiedBlock.getData());
}
resetBlock(qualifiedBlock);
@ -443,9 +485,7 @@ public abstract class Challenge implements Listener
if (Data.isDone(player))
return;
System.out.println("Completed, remaining: " + Host.getPlayersWithRemainingLives());
if (Host.getPlayersWithRemainingLives() > 1) // Check if the game is not about to end.
if (Host.getPlayersWithRemainingLives() >= PLAYER_COUNT_FOR_EFFECTS) // Check if the game is not about to end.
{
if (cloak)
{
@ -457,8 +497,8 @@ public abstract class Challenge implements Listener
FireworkEffect.builder().with(Type.BALL_LARGE).withColor(Color.GREEN).build(),
player);
UtilTextMiddle.display(null, C.cGreen + "You have completed the challenge!", 5, 30, 5, player);
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2.0F, 1.0F);
alert(player, "You have completed the challenge!", COMPLETION_TITLE_STAY_TICKS);
player.playSound(player.getLocation(), Sound.LEVEL_UP, COMPLETION_SOUND_VOLUME, COMPLETION_SOUND_PITCH);
}
Data.addCompletedPlayer(player);
@ -477,12 +517,10 @@ public abstract class Challenge implements Listener
if (Data.isDone(player))
return;
System.out.println("Lost, remaining: " + Host.getPlayersWithRemainingLives());
Data.addLostPlayer(player);
loseLife(player);
if (Host.getPlayersWithRemainingLives() > 1) // Check if the game is not about to end.
if (Host.getPlayersWithRemainingLives() >= PLAYER_COUNT_FOR_EFFECTS) // Check if the game is not about to end.
{
if (cloak)
{
@ -491,7 +529,7 @@ public abstract class Challenge implements Listener
UtilPlayer.message(player, F.main("Game", C.cRed + "You failed to complete the task."));
Host.showLivesLeft(player);
player.playSound(player.getLocation(), Sound.NOTE_BASS, 2.0F, 1.0F);
player.playSound(player.getLocation(), Sound.NOTE_BASS, LOST_SOUND_VOLUME, LOST_SOUND_PITCH);
}
Host.Manager.GetDisguise().undisguise(player);
@ -514,7 +552,7 @@ public abstract class Challenge implements Listener
reason = "Completed";
}
Host.Manager.GetCondition().Factory().Cloak(reason, player, player, 7777, true, false);
Host.Manager.GetCondition().Factory().Cloak(reason, player, player, CHALLENGE_CLOAK_DURATION, true, false);
}
protected void alert(Player player, String message)
@ -582,7 +620,7 @@ public abstract class Challenge implements Listener
{
for (Player player : getPlayersAlive())
{
for (int i = 0; i < 9; i++)
for (int i = 0; i <= INVENTORY_HOTBAR_SLOTS; i++)
{
player.getInventory().setItem(i, item);
}
@ -600,7 +638,7 @@ public abstract class Challenge implements Listener
@SuppressWarnings("deprecation")
protected void blockBreakEffect(Block block, boolean resetBlock)
{
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(block.getType(), block.getData()), block.getLocation(), 0, 0, 0, 0, 10, ViewDist.NORMAL, UtilServer.getPlayers());
UtilParticle.PlayParticle(ParticleType.BLOCK_DUST.getParticle(block.getType(), block.getData()), block.getLocation(), 0, 0, 0, 0, BLOCK_BREAK_PARTICLE_COUNT, ViewDist.NORMAL, UtilServer.getPlayers());
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
if (resetBlock)
@ -648,9 +686,9 @@ public abstract class Challenge implements Listener
protected Block generateGrass(Block block, boolean bushes)
{
if (UtilMath.r(4) == 0)
if (UtilMath.r(GRASS_SPAWN_CHANCE) == 0)
{
if (UtilMath.r(8) == 0)
if (UtilMath.r(FLOWER_SPAWN_CHANCE) == 0)
{
makeFlower(block);
}
@ -663,6 +701,8 @@ public abstract class Challenge implements Listener
return block;
}
private static final int FLOWER_DATA_RANGE = 7;
private void makeFlower(Block block)
{
Material flower = Material.YELLOW_FLOWER;
@ -674,7 +714,7 @@ public abstract class Challenge implements Listener
if (UtilMath.random.nextBoolean())
{
data = (byte) (UtilMath.r(7) + 1);
data = (byte) (UtilMath.r(FLOWER_DATA_RANGE) + 1);
}
}
@ -684,13 +724,13 @@ public abstract class Challenge implements Listener
@SuppressWarnings("deprecation")
private void makeGrass(Block block, boolean bushes)
{
if (bushes && UtilMath.r(3) == 0)
if (bushes && UtilMath.r(DOUBLE_PLANT_CHANCE) == 0)
{
Block above = block.getRelative(BlockFace.UP);
byte plantData = (byte) UtilMath.r(5);
byte plantData = (byte) UtilMath.r(DOUBLE_PLANT_DATA_RANGE);
setBlock(block, Material.DOUBLE_PLANT, plantData);
setBlock(above, Material.DOUBLE_PLANT, (byte) 8);
setBlock(above, Material.DOUBLE_PLANT, DOUBLE_PLANT_PART_DATA);
addBlock(above);
}
@ -721,20 +761,12 @@ public abstract class Challenge implements Listener
data.MaxY = (int) (maxY + Settings.getMapCenter().getY());
data.MinZ = minZ;
data.MaxZ = (int) (maxZ + Settings.getMapCenter().getZ());
Block min = Host.WorldData.World.getBlockAt(data.MinX, data.MinY, data.MinZ);
min.setType(Material.STONE);
addBlock(min);
Block max = Host.WorldData.World.getBlockAt(data.MaxX, data.MaxY, data.MaxZ);
max.setType(Material.COBBLESTONE);
addBlock(max);
}
protected void displayCount(Player player, Location loc, String text)
{
Hologram hologram = createHologram(player, loc, text);
long expiry = System.currentTimeMillis() + 1000;
long expiry = System.currentTimeMillis() + DISPLAY_COUNT_EXPIRE_AFTER;
new BukkitRunnable()
{
@ -773,9 +805,11 @@ public abstract class Challenge implements Listener
return Host.isInsideMap(player.getLocation());
}
private static final int TIME_LEFT_DIVIDER = 1000;
public int getTimeLeft()
{
return (int) ((Settings.getDuration() - (System.currentTimeMillis() - Settings.getStartTime())) / 1000);
return (int) ((Settings.getDuration() - (System.currentTimeMillis() - Settings.getStartTime())) / TIME_LEFT_DIVIDER);
}
public ArrayList<Player> getPlayersAlive()
@ -819,13 +853,13 @@ public abstract class Challenge implements Listener
public int getArenaSize()
{
return getArenaSize(8);
return getArenaSize(DEFAULT_ARENA_SIZE);
}
public int getArenaSize(int minBlocks)
{
int size = (int) (minBlocks + Math.ceil(Host.getPlayersWithRemainingLives() / 2));
return size > 40 ? 40 : size;
int size = (int) (minBlocks + Math.ceil(Host.getPlayersWithRemainingLives() / ARENA_SIZE_DIVIDER));
return size > ARENA_SIZE_LIMIT ? ARENA_SIZE_LIMIT : size;
}
public BawkBawkBattles getHost()

View File

@ -28,6 +28,9 @@ import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
*/
public abstract class TeamChallenge extends Challenge
{
private static final int TEAM_EVEN_NUMBER = 2;
private static final int TEAM_SEPERATOR = 2;
private ChallengeTeam _firstTeam;
private ChallengeTeam _secondTeam;
private boolean _teamSpawn;
@ -75,8 +78,6 @@ public abstract class TeamChallenge extends Challenge
while (teleported < players)
{
System.out.println("Selecting spawns");
for (Location spawn : randomSpawns)
{
Block block = spawn.getBlock().getRelative(BlockFace.DOWN);
@ -143,11 +144,11 @@ public abstract class TeamChallenge extends Challenge
Collections.shuffle(players);
int size = 0;
if (players.size() % 2 == 0)
if (players.size() % TEAM_EVEN_NUMBER == 0)
{
for (Player player : players)
{
if (size < players.size() / 2)
if (size < players.size() / TEAM_SEPERATOR)
{
_firstTeam.add(player);
}
@ -178,7 +179,7 @@ public abstract class TeamChallenge extends Challenge
}
else
{
if (size < (int) players.size() / 2)
if (size < (int) players.size() / TEAM_SEPERATOR)
{
_firstTeam.add(player);
}

View File

@ -34,6 +34,15 @@ import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
*/
public class ChickenAttack
{
private static final int CHICKEN_SPAWN_AMOUNT = 12;
private static final int INFORM_TITLTE_FADE_IN_TICKS = 5;
private static final int INFORM_TITLTE_STAY_TICKS = 40;
private static final int INFORM_TITLTE_FADE_OUT_TICKS = 5;
private static final int ATTACK_EXPIRE_TICKS = 400;
private static final float FLY_SPEED_RESET = 0.1F;
private static final double CHICKEN_BABY_SPAWN_CHANCE = 0.1;
private static final int CHICKEN_LOOK_AT_PLAYER_DISTANCE = 4;
private BawkBawkBattles _host;
private JavaPlugin _plugin;
@ -41,7 +50,6 @@ public class ChickenAttack
private Location[] _spawnpoints = new Location[4];
private List<Chicken> _chickens = new ArrayList<>();
private int _chickenSpawnAmount = 12;
public ChickenAttack(BawkBawkBattles host, Location center)
{
@ -60,6 +68,7 @@ public class ChickenAttack
spawnChickens();
}
public void start(Player player)
{
@ -73,7 +82,7 @@ public class ChickenAttack
player.teleport(_center);
UtilTextMiddle.display(C.cRed + "Chicken Attack!", "You ran out of lives.", 5, 40, 5, player);
UtilTextMiddle.display(C.cRed + "Chicken Attack!", "You ran out of lives.", INFORM_TITLTE_FADE_IN_TICKS, INFORM_TITLTE_STAY_TICKS, INFORM_TITLTE_FADE_OUT_TICKS, player);
UtilPlayer.message(player, F.main("Game", "You failed to follow bawk bawk's instructions and you ran out of lives. His minions are now attacking you."));
player.playSound(player.getLocation(), Sound.WITHER_SPAWN, 1.0F, 1.0F);
@ -81,6 +90,7 @@ public class ChickenAttack
ensurePlayerKill(player);
}
private void ensurePlayerKill(Player player)
{
@ -99,8 +109,9 @@ public class ChickenAttack
cancel();
}
}
}.runTaskLater(_plugin, 400L);
}.runTaskLater(_plugin, ATTACK_EXPIRE_TICKS);
}
public void kill(Player player, boolean inform)
{
@ -127,7 +138,7 @@ public class ChickenAttack
UtilAction.velocity(player, new Vector(0, 1, 0));
player.setAllowFlight(true);
player.setFlying(true);
player.setFlySpeed(0.1f);
player.setFlySpeed(FLY_SPEED_RESET);
player.playSound(player.getLocation(), Sound.BAT_TAKEOFF, 1.0F, 1.0F);
}
@ -138,7 +149,7 @@ public class ChickenAttack
{
_host.CreatureAllow = true;
int spawnAmount = _chickenSpawnAmount / _spawnpoints.length;
int spawnAmount = CHICKEN_SPAWN_AMOUNT / _spawnpoints.length;
for (int i = 0; i < _spawnpoints.length; i++)
{
@ -154,17 +165,18 @@ public class ChickenAttack
_host.CreatureAllow = false;
}
private void setupChicken(Chicken chicken)
{
_chickens.add(chicken);
if (Math.random() < 0.1)
if (Math.random() < CHICKEN_BABY_SPAWN_CHANCE)
{
chicken.setBaby();
}
UtilEnt.addLookAtPlayerAI(chicken, 4);
UtilEnt.addLookAtPlayerAI(chicken, CHICKEN_LOOK_AT_PLAYER_DISTANCE);
Location loc = chicken.getLocation().add(0, 1, 0).clone();
Hologram holo = new Hologram(_host.Manager.getHologramManager(), loc, "Chicken Minion");

View File

@ -35,15 +35,38 @@ import nautilus.game.arcade.game.games.mineware.BawkBawkBattles;
*/
public class DeathEffect
{
private static final double FOOD_DROP_HEIGHT = 0.5;
private static final double HOLOGRAM_HEIGHT = 2.2;
private static final double CLOUD_PARTICLES_HEIGHT = 1.7;
private static final int FOOD_SPAWN_AMOUNT = 14;
private static final int FOOD_MERGE_RANDOM_SEED = 999999;
private static final String FOOD_ITEM_TITLE = "Food";
private static final double FOOD_VELOCITY_SUBTRACT = 0.5;
private static final double FOOD_VELOCITY_MULTIPLIER = 0.5;
private static final int FOOD_REMOVE_AFTER_TICKS = 60;
private static final byte CHICKEN_HEAD_DATA = 3;
private static final int CHICKEN_HEAD_ROTATION_ADD = 12;
private static final int CHICKEN_HEAD_ROTATION_LIMIT = 360;
private static final float CHICKEN_HEAD_REMOVE_PARTICLE_OFFSET = 0.2F;
private static final int CHICKEN_HEAD_REMOVE_PARTICLE_AMOUNT = 10;
private static final int CHICKEN_HEAD_REMOVE_AFTER_TICKS = 60;
private static final float CHICKEN_SOUND_VOLUME = 1.5F;
private static final float CHICKEN_SOUND_PITCH = 1.0F;
private static final float EAT_SOUND_VOLUME = 1.5F;
private static final float EAT_SOUND_PITCH = 1.0F;
private static final float BURP_SOUND_VOLUME = 1.5F;
private static final float BURP_SOUND_PITCH = 1.0F;
private static final int EAT_BURP_SOUND_EMIT_AFTER_TICKS = 10;
private BawkBawkBattles _host;
private JavaPlugin _plugin;
private DeathText _deathText = new DeathText();
private ArrayList<DeathEffectData> _data = new ArrayList<DeathEffectData>();
private double _foodDropHeight = 0.5;
private double _hologramHeight = 2.2;
private double _cloudParticleHeight = 1.7;
public DeathEffect(BawkBawkBattles host)
{
_host = host;
@ -62,17 +85,17 @@ public class DeathEffect
playChickenSounds(data);
if (!belowFirst.isEmpty() || !belowSecond.isEmpty())
{
startFoodSpawnTask(data);
System.out.println("Death effect triggered for " + player.getName() + ".");
}
}
private void startFoodSpawnTask(DeathEffectData data)
{
Location dropsite = data.getLocation().clone().add(0, _foodDropHeight, 0);
Location dropsite = data.getLocation().clone().add(0, FOOD_DROP_HEIGHT, 0);
List<Item> foodItems = new ArrayList<>();
for (int i = 0; i < 15; i++)
for (int i = 0; i <= FOOD_SPAWN_AMOUNT; i++)
{
Material material = Material.EGG;
@ -80,10 +103,10 @@ public class DeathEffect
material = Material.COOKED_CHICKEN;
ItemBuilder builder = new ItemBuilder(material);
builder.setTitle(UtilMath.r(999999) + "Food");
builder.setTitle(UtilMath.r(FOOD_MERGE_RANDOM_SEED) + FOOD_ITEM_TITLE);
Item food = dropsite.getWorld().dropItem(dropsite, builder.build());
Vector velocity = new Vector((Math.random() - 0.5) * 0.5, 0, (Math.random() - 0.5) * 0.5);
Vector velocity = new Vector((Math.random() - FOOD_VELOCITY_SUBTRACT) * FOOD_VELOCITY_MULTIPLIER, 0, (Math.random() - FOOD_VELOCITY_SUBTRACT) * FOOD_VELOCITY_MULTIPLIER);
food.setVelocity(velocity);
foodItems.add(food);
@ -111,7 +134,7 @@ public class DeathEffect
data.getFoodItems().clear();
}
}.runTaskLater(_plugin, 60L);
}.runTaskLater(_plugin, FOOD_REMOVE_AFTER_TICKS);
}
@SuppressWarnings("deprecation")
@ -129,7 +152,7 @@ public class DeathEffect
chickenHead.setGravity(false);
chickenHead.setBasePlate(false);
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 0, (byte) 3);
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 0, CHICKEN_HEAD_DATA);
SkullMeta meta = (SkullMeta) skull.getItemMeta();
meta.setOwner(UtilSkull.getPlayerHeadName(EntityType.CHICKEN));
skull.setItemMeta(meta);
@ -139,8 +162,6 @@ public class DeathEffect
data.setChickenHead(chickenHead);
playHeadRotation(data);
System.out.println(chickenHead.isValid());
Hologram hologram = getRandomHologram(dropsite);
hologram.start();
data.setHologram(hologram);
@ -150,7 +171,7 @@ public class DeathEffect
{
Hologram hologram = new Hologram(
_host.getArcadeManager().getHologramManager(),
loc.clone().add(0, _hologramHeight, 0),
loc.clone().add(0, HOLOGRAM_HEIGHT, 0),
C.cAqua + C.Bold + _deathText.getRandom() + C.Reset);
return hologram;
@ -173,9 +194,9 @@ public class DeathEffect
return;
}
i += 12;
i += CHICKEN_HEAD_ROTATION_ADD;
if (i <= 360)
if (i <= CHICKEN_HEAD_ROTATION_LIMIT)
{
chickenHead.setHeadPose(new EulerAngle(0, Math.toRadians(i), 0));
}
@ -202,28 +223,28 @@ public class DeathEffect
return;
}
UtilParticle.PlayParticleToAll(ParticleType.CLOUD, data.getLocation().clone().add(0, _cloudParticleHeight, 0), 0.2F, 0.2F, 0.2F, 0.0F, 10, ViewDist.NORMAL);
UtilParticle.PlayParticleToAll(ParticleType.CLOUD, data.getLocation().clone().add(0, CLOUD_PARTICLES_HEIGHT, 0), CHICKEN_HEAD_REMOVE_PARTICLE_OFFSET, CHICKEN_HEAD_REMOVE_PARTICLE_OFFSET, CHICKEN_HEAD_REMOVE_PARTICLE_OFFSET, 0.0F, CHICKEN_HEAD_REMOVE_PARTICLE_AMOUNT, ViewDist.NORMAL);
chickenHead.remove();
data.getHologram().stop();
}
}.runTaskLater(_plugin, 60L);
}.runTaskLater(_plugin, CHICKEN_HEAD_REMOVE_AFTER_TICKS);
}
private void playChickenSounds(DeathEffectData data)
{
Location loc = data.getLocation();
loc.getWorld().playSound(loc, Sound.CHICKEN_HURT, 1.5F, 1.0F);
loc.getWorld().playSound(loc, Sound.CHICKEN_HURT, CHICKEN_SOUND_VOLUME, CHICKEN_SOUND_PITCH);
new BukkitRunnable()
{
@Override
public void run()
{
loc.getWorld().playSound(loc, Sound.EAT, 1.5F, 1.0F);
loc.getWorld().playSound(loc, Sound.BURP, 1.5F, 1.0F);
loc.getWorld().playSound(loc, Sound.EAT, EAT_SOUND_VOLUME, EAT_SOUND_PITCH);
loc.getWorld().playSound(loc, Sound.BURP, BURP_SOUND_VOLUME, BURP_SOUND_PITCH);
}
}.runTaskLater(_plugin, 10L);
}.runTaskLater(_plugin, EAT_BURP_SOUND_EMIT_AFTER_TICKS);
}
public void removeSpawnedEntities()
@ -258,7 +279,7 @@ public class DeathEffect
if (itemStack.getItemMeta().hasDisplayName())
{
String name = itemStack.getItemMeta().getDisplayName();
return name.contains("Food");
return name.contains(FOOD_ITEM_TITLE);
}
}
}

View File

@ -21,6 +21,8 @@ import nautilus.game.arcade.kit.Perk;
*/
public class KitBawksFood extends Kit
{
private static final byte SKULL_DATA = 3;
public KitBawksFood(ArcadeManager manager)
{
super(manager,
@ -48,7 +50,7 @@ public class KitBawksFood extends Kit
{
EntityEquipment equipment = ent.getEquipment();
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 0, (byte) 3);
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 0, SKULL_DATA);
SkullMeta meta = (SkullMeta) skull.getItemMeta();
meta.setOwner(UtilSkull.getPlayerHeadName(EntityType.CHICKEN));
skull.setItemMeta(meta);