Apply improvements and bug fixes

This commit is contained in:
Thanos paravantis 2016-04-19 10:00:06 +03:00
parent cb4e25fb0a
commit 09fb1842b6
16 changed files with 137 additions and 72 deletions

View File

@ -167,12 +167,11 @@ public class BawkBawkBattles extends TeamGame implements IThrown
*
* - Do not trigger chicken attack on game end (eg. 3 players killed at once).
* - Make players spawn with equal distance from a target.
* - Do not spawn grass on spawn locations.
* - Team Challenges: Define team properly.
* - When timer runs out, challenge does not end.
* - Chicken attack does not trigger sometimes.
* - Pick a Side: Does not work with 3 players.
* - Fix rest of the challenges.
* - Apply TNT knockback on Deadly TNT challenge
* - Stats menu does not open.
*/
@SuppressWarnings("unchecked")
@ -183,7 +182,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
new Kit[] { new KitBawksFood(manager) },
new String[] {
"Follow the orders given in chat!",
"First half to follow it win the round.",
"First half to follow it wins the round.",
"Other players lose one life.",
"Last player with lives wins!"
});
@ -308,10 +307,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
int minCount = settings.getMinPlayers();
int maxCount = settings.getMaxPlayers();
System.out.println("Participants: " + participants);
System.out.println("Min: " + minCount);
System.out.println("Max: " + maxCount);
// TODO: Add player team size check.
return participants >= minCount && participants <= maxCount;
}
@ -393,6 +389,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
_deathEffect.removeSpawnedEntities();
setupChallengeSpawnLocations();
System.out.println("Spawns: " + _challenge.getData().getDefinedSpawns().size());
_challenge.createMap();
if (_settings.canMarkSpawnLocations())
@ -446,28 +443,44 @@ public class BawkBawkBattles extends TeamGame implements IThrown
{
if (_challenge.canFinish())
{
if (hasCrumbleSetting())
{
if (canStartCrumbling())
{
_settings.setCrumbling(true);
announceCrumbling();
}
else if (canEndChallengeFromCrumble())
{
_settings.setCrumbling(false);
endCurrentChallenge();
}
}
else
{
endCurrentChallenge();
}
endCurrentChallenge();
return;
}
else
{
updateChallengeTimer();
}
if (hasCrumbleSetting() && canStartCrumbling())
{
_settings.setCrumbling(true);
announceCrumbling();
}
// if (_challenge.canFinish())
// {
// if (hasCrumbleSetting())
// {
// if (canStartCrumbling())
// {
// _settings.setCrumbling(true);
// announceCrumbling();
// }
// else
// {
// _settings.setCrumbling(false);
// endCurrentChallenge();
// }
// }
// else
// {
// endCurrentChallenge();
// }
// }
// else
// {
// updateChallengeTimer();
// }
}
private void announceCrumbling()
@ -511,13 +524,13 @@ public class BawkBawkBattles extends TeamGame implements IThrown
private ArrayList<Location> setupChallengeSpawnLocations()
{
ArrayList<Location> spawns = _challenge.createSpawns();
ArrayList<Location> selected = _challenge.createSpawns();
_challenge.getData().setSpawns(spawns);
_playersTeam.SetSpawns(spawns);
SpectatorSpawn = UtilWorld.averageLocation(spawns).add(0, 7, 0);
_challenge.getData().setSpawns(selected);
_playersTeam.SetSpawns(selected);
SpectatorSpawn = UtilWorld.averageLocation(selected).add(0, 7, 0);
return spawns;
return selected;
}
private void teleportSpectatorsToSpawn()
@ -616,6 +629,7 @@ public class BawkBawkBattles extends TeamGame implements IThrown
_challenge.end();
_settings.setChallengeStarted(false);
_settings.setCrumbling(false);
sortLastChallengeBlocks();
@ -942,6 +956,8 @@ public class BawkBawkBattles extends TeamGame implements IThrown
_deathEffect.playDeath(player, death);
_challenge.getData().addLostPlayer(player);
handleDeath(player);
EndCheck();
}
@EventHandler
@ -1374,14 +1390,11 @@ public class BawkBawkBattles extends TeamGame implements IThrown
for (Player player : GetPlayers(true))
{
if (player.hasPotionEffect(PotionEffectType.BLINDNESS) && player.hasPotionEffect(PotionEffectType.NIGHT_VISION))
{
player.removePotionEffect(PotionEffectType.BLINDNESS);
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
}
UtilPlayer.clearPotionEffects(player);
UtilTextMiddle.display(null, null, player);
}
_deathEffect.removeSpawnedEntities();
}
@SuppressWarnings("deprecation")
@ -1476,7 +1489,10 @@ public class BawkBawkBattles extends TeamGame implements IThrown
if (getPlayersWithRemainingLives() <= 1)
{
_winners.add(0, getPlayersAlive().get(0));
if (getPlayersAlive().get(0) != null)
{
_winners.add(0, getPlayersAlive().get(0));
}
if (_winners.size() > 2)
{
@ -1630,7 +1646,9 @@ public class BawkBawkBattles extends TeamGame implements IThrown
player.damage(4.0D);
if (UtilMath.random.nextBoolean())
{
UtilTextBottom.display(C.cRed + C.Bold + "bawk bawk!", player);
}
}
}
}
@ -1639,10 +1657,12 @@ public class BawkBawkBattles extends TeamGame implements IThrown
@Override
public void Idle(ProjectileUser data)
{
}
@Override
public void Expire(ProjectileUser data)
{
}
}

View File

@ -551,7 +551,7 @@ public abstract class Challenge implements Listener
public int getArenaSize(int minBlocks)
{
int size = (int) (minBlocks + Math.ceil(getPlayersAlive().size() / 2));
int size = (int) (minBlocks + Math.ceil(Host.getPlayersWithRemainingLives() / 2));
return size > 40 ? 40 : size;
}

View File

@ -35,7 +35,7 @@ public class ChallengeData
{
for (Location spawn : _spawns)
{
if (UtilAlg.isSimilar(spawn, location))
if ((int) spawn.getX() == (int) location.getX() && (int) spawn.getY() == (int) location.getY() && (int) spawn.getZ() == (int) location.getZ())
{
return true;
}

View File

@ -54,6 +54,8 @@ public class ChallengeAnvilDance extends Challenge
private HashSet<FallingBlock> _fallingAnvils = new HashSet<FallingBlock>();
private BukkitTask _fireworkTask;
private int _arenaStartSize;
public ChallengeAnvilDance(BawkBawkBattles host)
{
@ -85,7 +87,9 @@ public class ChallengeAnvilDance extends Challenge
@Override
public void createMap()
{
for (Location location : UtilShapes.getCircle(getCenter(), false, getArenaSize()))
_arenaStartSize = getArenaSize();
for (Location location : UtilShapes.getCircle(getCenter(), false, _arenaStartSize))
{
Block block = location.getBlock();
block.setType(Material.SMOOTH_BRICK);
@ -254,12 +258,12 @@ public class ChallengeAnvilDance extends Challenge
private void createAnvil()
{
Location center = getCenter().add(0, UtilMath.r(3) + _waveHeight, 0);
ArrayList<Location> locations = UtilShapes.getCircle(center, false, getArenaSize());
ArrayList<Location> locations = UtilShapes.getCircle(center, false, _arenaStartSize);
Location random = locations.get(UtilMath.r(locations.size()));
World world = random.getWorld();
final FallingBlock block = world.spawnFallingBlock(random, Material.ANVIL, (byte) UtilMath.r(3));
FallingBlock block = world.spawnFallingBlock(random, Material.ANVIL, (byte) UtilMath.r(3));
block.setDropItem(false);
_fallingAnvils.add(block);

View File

@ -109,8 +109,15 @@ public class ChallengeArrowRampage extends Challenge
@Override
public void onStart()
{
setItem(Settings.getLockedSlot(), new ItemBuilder(Material.BOW).setUnbreakable(true).addEnchantment(Enchantment.ARROW_INFINITE, 1).addItemFlags(ItemFlag.HIDE_ENCHANTS).build());
ItemStack bow = new ItemBuilder(Material.BOW)
.setUnbreakable(true)
.addEnchantment(Enchantment.ARROW_INFINITE, 1)
.addItemFlags(ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_UNBREAKABLE)
.build();
setItem(Settings.getLockedSlot(), bow);
setItem(31, new ItemStack(Material.ARROW)); // Place arrow above bow, not visible in the hotbar.
addEffect(PotionEffectType.JUMP, 2);
Host.StrictAntiHack = false;

View File

@ -37,7 +37,7 @@ public class ChallengeDeadlyTnt extends Challenge
host,
ChallengeType.LastStanding,
"Deadly TNT",
"Throw TNT to other players.",
"Throw TNT at other players.",
"Do not get knocked off!");
Settings.setUseMapHeight();

View File

@ -13,6 +13,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
@ -70,7 +71,10 @@ public class ChallengeDragonEgg extends Challenge
{
setBorder(-18, 18, 0, 20, -18, 18);
ItemStack axe = new ItemBuilder(Material.IRON_AXE).setUnbreakable(true).build();
ItemStack axe = new ItemBuilder(Material.IRON_AXE)
.setUnbreakable(true)
.setItemFlags(ItemFlag.HIDE_UNBREAKABLE)
.build();
for (Player player : getPlayersAlive())
{

View File

@ -40,7 +40,7 @@ public class ChallengeFallingBlocks extends Challenge
private double _incrementRate = 5.0;
// The map height where all blocks will spawn.
private double _waveHeight = 10.0;
private double _waveHeight = 13.0;
// The amount of seconds until the next anvil wave appears.
private long _nextWave = 5;
@ -80,6 +80,8 @@ public class ChallengeFallingBlocks extends Challenge
// The array of sounds used to play when a new wave is being deployed.
private Sound[] _sounds = { Sound.DIG_GRASS, Sound.DIG_GRAVEL, Sound.DIG_SAND, Sound.DIG_SNOW, Sound.DIG_STONE, Sound.DIG_WOOD, Sound.DIG_WOOL };
private int _arenaStartSize;
public ChallengeFallingBlocks(BawkBawkBattles host)
{
super(
@ -112,7 +114,9 @@ public class ChallengeFallingBlocks extends Challenge
@Override
public void createMap()
{
for (Location location : UtilShapes.getCircle(getCenter(), false, getArenaSize()))
_arenaStartSize = getArenaSize();
for (Location location : UtilShapes.getCircle(getCenter(), false, _arenaStartSize))
{
Material material = _floor[UtilMath.r(_floor.length)];
Block block = location.getBlock();
@ -276,7 +280,7 @@ public class ChallengeFallingBlocks extends Challenge
Location center = getCenter().add(0, _waveHeight, 0);
for (Location location : UtilShapes.getCircle(center, false, getArenaSize()))
for (Location location : UtilShapes.getCircle(center, false, _arenaStartSize))
{
if (Math.random() * 100 <= _modifiedSpawnChance)
{
@ -305,9 +309,10 @@ public class ChallengeFallingBlocks extends Challenge
FallingBlock block = world.spawnFallingBlock(location, material, (byte) 0);
block.setDropItem(false);
if (material == Material.SMOOTH_BRICK || material == Material.DIRT)
if (UtilMath.random.nextBoolean())
block = world.spawnFallingBlock(location, material, (byte) 2);
if ((material == Material.SMOOTH_BRICK || material == Material.DIRT) && UtilMath.random.nextBoolean())
{
block = world.spawnFallingBlock(location, material, (byte) 2);
}
Host.Manager.GetProjectile().AddThrow(block, null, Host, -1, true, false, false, true, 0.7F);
}

View File

@ -23,7 +23,6 @@ import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAction;
@ -175,16 +174,13 @@ public class ChallengeFishingDay extends Challenge
Host.ItemPickup = true;
Host.WorldWaterDamage = 1;
ItemBuilder item = new ItemBuilder(Material.FISHING_ROD);
item.addEnchantment(Enchantment.LURE, _startingLureLevel);
item.setUnbreakable(true);
ItemStack fishingRod = new ItemBuilder(Material.FISHING_ROD)
.addEnchantment(Enchantment.LURE, _startingLureLevel)
.setUnbreakable(true)
.addItemFlags(ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_UNBREAKABLE)
.build();
ItemStack itemStack = item.build();
ItemMeta meta = itemStack.getItemMeta();
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
itemStack.setItemMeta(meta);
setItem(Settings.getLockedSlot(), itemStack);
setItem(Settings.getLockedSlot(), fishingRod);
}
@Override

View File

@ -96,7 +96,10 @@ public class ChallengeInfestation extends Challenge
Host.DamageEvP = false;
Host.DamagePvP = false;
_zombie.remove();
if (_zombie.getEntity() != null)
{
_zombie.remove();
}
}
@EventHandler

View File

@ -200,8 +200,6 @@ public class ChallengeKangarooJump extends Challenge
{
if (i < (sortedList.size() / 2))
setCompleted(player);
else
setLost(player);
}
}
}

View File

@ -12,6 +12,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
@ -124,7 +125,12 @@ public class ChallengeKingOfTheLadder extends Challenge
@Override
public void onStart()
{
setItem(Settings.getLockedSlot(), new ItemBuilder(Material.STICK).addEnchantment(Enchantment.KNOCKBACK, 5).addItemFlags(ItemFlag.HIDE_ENCHANTS).build());
ItemStack stick = new ItemBuilder(Material.STICK)
.addEnchantment(Enchantment.KNOCKBACK, 5)
.addItemFlags(ItemFlag.HIDE_ENCHANTS)
.build();
setItem(Settings.getLockedSlot(), stick);
Host.DamagePvP = true;
}

View File

@ -11,6 +11,8 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.UtilMath;
import mineplex.core.itemstack.ItemBuilder;
@ -132,7 +134,12 @@ public class ChallengeMineADiamond extends Challenge
@Override
public void onStart()
{
setItem(Settings.getLockedSlot(), new ItemBuilder(Material.DIAMOND_PICKAXE).setUnbreakable(true).build());
ItemStack pickaxe = new ItemBuilder(Material.DIAMOND_PICKAXE)
.setUnbreakable(true)
.setItemFlags(ItemFlag.HIDE_UNBREAKABLE)
.build();
setItem(Settings.getLockedSlot(), pickaxe);
for (Block diamond : _diamonds)
{

View File

@ -12,6 +12,7 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.UtilInv;
@ -87,8 +88,8 @@ public class ChallengeMiniOneInTheQuiver extends Challenge
else if (absX == getArenaSize() - 2 || absZ == getArenaSize() - 2)
{
Location location = block.getLocation();
if (UtilMath.r(8) == 0 && !Data.isSpawnLocation(location) && !Data.isNearSpawnLocation(location))
if (UtilMath.r(8) == 0)
{
block.setType(Material.STAINED_CLAY);
block.getRelative(BlockFace.UP).setType(Material.STAINED_CLAY);
@ -117,7 +118,12 @@ public class ChallengeMiniOneInTheQuiver extends Challenge
Host.DamagePvP = true;
Host.DamagePvE = true;
addItem(new ItemBuilder(Material.BOW).setUnbreakable(true).build(), new ItemStack(Material.ARROW));
ItemStack bow = new ItemBuilder(Material.BOW)
.setUnbreakable(true)
.setItemFlags(ItemFlag.HIDE_UNBREAKABLE)
.build();
addItem(bow, new ItemStack(Material.ARROW));
}
@Override
@ -144,7 +150,7 @@ public class ChallengeMiniOneInTheQuiver extends Challenge
continue;
player.getInventory().addItem(new ItemStack(Material.ARROW));
player.playSound(player.getLocation(), Sound.ITEM_PICKUP, 0.2f, 0.2f);
player.playSound(player.getLocation(), Sound.ITEM_PICKUP, 1.0F, 1.0F);
}
}

View File

@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
@ -143,7 +144,10 @@ public class ChallengeRushPush extends Challenge
@SuppressWarnings("deprecation")
private void addPlayersOnTeam()
{
ItemStack sword = new ItemBuilder(Material.DIAMOND_SWORD).setUnbreakable(true).build();
ItemStack sword = new ItemBuilder(Material.DIAMOND_SWORD)
.setUnbreakable(true)
.setItemFlags(ItemFlag.HIDE_UNBREAKABLE)
.build();
for (Player player : getPlayersAlive())
{

View File

@ -110,7 +110,12 @@ public class ChallengeShootChickens extends Challenge
Host.DamagePvE = true;
ItemStack bow = new ItemBuilder(Material.BOW).setUnbreakable(true).addEnchantment(Enchantment.ARROW_INFINITE, 1).addItemFlags(ItemFlag.HIDE_ENCHANTS).build();
ItemStack bow = new ItemBuilder(Material.BOW)
.setUnbreakable(true)
.addEnchantment(Enchantment.ARROW_INFINITE, 1)
.addItemFlags(ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_UNBREAKABLE)
.build();
ItemStack arrow = new ItemStack(Material.ARROW);
for (Player player : getPlayersAlive())