Added new kits, Changed Compass feature, Fixed a lot of bugs

This commit is contained in:
Morten 2015-07-18 15:10:03 +02:00
parent d46ac59e10
commit b986cf968e
4 changed files with 303 additions and 168 deletions

View File

@ -1,40 +1,28 @@
package nautilus.game.arcade.game.games.wither;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.EntityEffect;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.data.BlockData;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.condition.Condition.ConditionType;
@ -43,13 +31,48 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.paintball.PlayerCopy;
import nautilus.game.arcade.game.games.wither.kit.*;
import nautilus.game.arcade.game.games.wither.events.HumanReviveEvent;
import nautilus.game.arcade.game.games.wither.kit.KitHumanArcher;
import nautilus.game.arcade.game.games.wither.kit.KitHumanMedic;
import nautilus.game.arcade.game.games.wither.kit.KitHumanEditor;
import nautilus.game.arcade.game.games.wither.kit.KitWitherMinion;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.NullKit;
import nautilus.game.arcade.kit.perks.data.IBlockRestorer;
import nautilus.game.arcade.stats.WitherAssaultReviveTracker;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.EntityEffect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.entity.Wither;
import org.bukkit.entity.WitherSkull;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
public class WitherGame extends TeamGame implements IBlockRestorer
{
@ -59,6 +82,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer
private double _witherFactor = 2.5;
private int _yLimit = 0;
private int _maxY;
private long _gameTime = 300000;
@ -69,30 +93,30 @@ public class WitherGame extends TeamGame implements IBlockRestorer
private HashSet<BlockData> _blocks = new HashSet<BlockData>();
private ArrayList<Location> _locationsOfBlocks = new ArrayList<Location>();
public WitherGame(ArcadeManager manager)
{
super(manager, GameType.WitherAssault,
new Kit[]
{
new KitHumanArcher(manager), new NullKit(manager),
new NullKit(manager), new NullKit(manager),
new KitHumanArcher(manager),
new KitHumanMedic(manager),
new KitHumanEditor(manager),
new NullKit(manager),
new KitWitherMinion(manager),
},
new String[]
{
C.cGreen + "Humans" + C.cWhite
+ " Run and hide from the Withers",
C.cGreen + "Humans" + C.cWhite + " Run and hide from the Withers",
C.cGreen + "Humans" + C.cWhite + " Revive your dead allies!",
C.cGreen + "Humans" + C.cWhite
+ " Win by surviving for 5 minutes",
C.cGreen + "Humans" + C.cWhite + " Win by surviving for 5 minutes",
" ",
C.cRed + "Withers" + C.cWhite
+ " Moves very slowly when near ground",
C.cRed + "Withers" + C.cWhite
+ " Kill all the Humans within 5 Minutes",
C.cRed + "Withers" + C.cWhite + " Moves very slowly when near ground",
C.cRed + "Withers" + C.cWhite + " Kill all the Humans within 5 Minutes",
});
this.DeathOut = true;
@ -101,9 +125,12 @@ public class WitherGame extends TeamGame implements IBlockRestorer
this.DeathSpectateSecs = 4;
this.HungerSet = 20;
this.WorldBoundaryKill = false;
this.CompassEnabled = false;
this.CompassEnabled = true;
this.CompassGiveItem = false;
//Customizing for the Editor kit
this.BlockBreak = true;
this.BlockPlace = true;
this.ItemPickup = true;
this.KitRegisterState = GameState.Prepare;
@ -112,9 +139,13 @@ public class WitherGame extends TeamGame implements IBlockRestorer
_help = new String[]
{
C.cRed + C.Bold + "This game is still under development!",
"This game will soon not be under development anymore ;)",
"Blocks placed by an Editor can be passed by other humans by " + C.cDGreen + "Right-clicking the block",
"Withers are too powerful to be killed. Hiding is the only option!",
"Medics are a valuable asset. Stick with them and keep them safe!",
};
}
@Override
@ -177,6 +208,151 @@ public class WitherGame extends TeamGame implements IBlockRestorer
setWither(player, true);
}
// @EventHandler
// public void assignCompassOnStart(GameStateChangeEvent event)
// {
// if (event.GetState() != GameState.Live)
// return;
//
// for (Player players : _withers.GetPlayers(true))
// {
// ItemStack compass = new ItemBuilder(Material.COMPASS, 1).build();
//
// ItemMeta im = compass.getItemMeta();
// im.setLore(new ArrayList<String>(Arrays.asList(
// F.item("A compass that trigger"),
// F.item("your ability to track humans!"))));
// im.setDisplayName(F.name("Scent Trigger"));
//
// compass.setItemMeta(im);
//
// players.getInventory().setItem(7, compass);
// }
// }
// Cancel wither shooting in waiting lobby
@EventHandler
public void onWitherSkullFire(ProjectileLaunchEvent event)
{
if (GetState() == GameState.Recruit || GetState() == GameState.Prepare)
{
Projectile proj = event.getEntity();
WitherSkull ws = (WitherSkull) proj;
if (ws.getShooter() instanceof Wither)
{
event.setCancelled(true);
}
}
}
@EventHandler
public void handleCustomBlockPlace(BlockPlaceEvent event)
{
if(!IsLive())
{
return;
}
if(!GetKit(event.getPlayer()).GetName().contentEquals("Human Editor"))
{
event.setCancelled(true);
return;
}
_maxY = GetTeamList().get(1).GetSpawn().getBlockY() - 5;
if(event.getBlock().getLocation().getBlockY() < _maxY)
{
event.getPlayer().sendMessage(F.main("BlockChecker", "You may not build under this height!"));
event.setCancelled(true);
return;
}
_locationsOfBlocks.add(event.getBlock().getLocation());
}
@EventHandler
public void handleCustomBlockbreak(BlockBreakEvent event)
{
if(!IsLive())
{
return;
}
if(!GetKit(event.getPlayer()).GetName().contentEquals("Human Editor"))
{
event.setCancelled(true);
return;
}
Location blockLocation = event.getBlock().getLocation();
_maxY = GetTeamList().get(1).GetSpawn().getBlockY() - 4;
if(blockLocation.add(0,1,0).getBlock().getType() == Material.AIR)
{
for(Player humans: _runners.GetPlayers(true))
{
if(IsAlive(humans))
{
if(humans.getLocation().add(0,-1,0).getBlock().equals(event.getBlock()))
{
if(humans.getName() != event.getPlayer().getName())
{
event.setCancelled(true);
return;
}
}
}
}
}
if(blockLocation.getBlockY() < _maxY)
{
event.getPlayer().sendMessage(F.main("BlockChecker", "You may not build under this height!"));
event.setCancelled(true);
return;
}
}
@EventHandler
public void handleCustomItemPickup(PlayerPickupItemEvent event)
{
if(!IsLive())
{
return;
}
if(!GetKit(event.getPlayer()).GetName().contentEquals("Human Editor"))
{
event.setCancelled(true);
return;
}
}
//On Player interact with a placed block by Editor
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
if(!IsLive())
{
return;
}
if(!IsAlive(event.getPlayer()))
{
return;
}
if(event.getAction() == Action.RIGHT_CLICK_BLOCK)
{
Block clickedBlock = event.getClickedBlock();
if(_locationsOfBlocks.contains(clickedBlock.getLocation()))
{
if(!(event.getPlayer().getInventory().getItem(event.getPlayer().getInventory().getHeldItemSlot()) instanceof Block))
{
UtilParticle.PlayParticle(ParticleType.FLAME, event.getClickedBlock().getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1, ViewDist.LONG, UtilServer.getPlayers());
event.getClickedBlock().getWorld().playSound(event.getClickedBlock().getLocation(), Sound.NOTE_STICKS, 2f, 1f);
Manager.GetBlockRestore().Add(event.getClickedBlock(), 0, event.getClickedBlock().getData(), 2000);
}
}
}
}
public void setWither(Player player, boolean forced)
{
// _lives.remove(player);
@ -184,7 +360,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer
SetPlayerTeam(player, _withers, true);
// Kit
Kit newKit = GetKits()[4];
Kit newKit = GetKits()[GetKits().length-1];
SetKit(player, newKit, false);
newKit.ApplyKit(player);
@ -245,6 +421,24 @@ public class WitherGame extends TeamGame implements IBlockRestorer
}
}
@EventHandler
public void removeUselessPlayerCopies(UpdateEvent event)
{
if(event.getType() != UpdateType.TWOSEC)
return;
for(Player players: _doubles.keySet())
{
if(!players.isOnline())
{
PlayerCopy pc = _doubles.get(players);
pc.GetEntity().remove();
_doubles.remove(players);
}
}
}
// @EventHandler
// public void playerLivesDisplay(PlayerKitGiveEvent event)
// {
@ -272,9 +466,10 @@ public class WitherGame extends TeamGame implements IBlockRestorer
return;
// Players Quit
if (GetPlayers(true).size() < 2)
if (GetPlayers(true).size() < 1)
{
SetState(GameState.End);
_locationsOfBlocks.clear();
}
GameTeam winner = null;
@ -307,6 +502,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer
// End
SetState(GameState.End);
_locationsOfBlocks.clear();
}
}
@ -390,6 +586,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer
for (Player player : _withers.GetPlayers(true))
{
ArrayList<Location> collisions = new ArrayList<Location>();
_maxY = GetTeamList().get(1).GetSpawn().getBlockY();
// Fly Speed
double speed = 0.09 - (_yLimit - player.getLocation().getY()) * 0.006;
@ -662,6 +859,8 @@ public class WitherGame extends TeamGame implements IBlockRestorer
copyIterator.remove();
AddGems(thrower, 3, "Revived Ally", true, true);
Bukkit.getPluginManager().callEvent(new HumanReviveEvent(thrower, copy.GetPlayer()));
}
// Revive

View File

@ -37,9 +37,7 @@ public class KitHumanArcher extends Kit
new PerkWitherArrowBlind(6),
new PerkFletcher(4, 4, true),
},
EntityType.ZOMBIE,
null);
}, EntityType.ZOMBIE, null);
}
@ -49,8 +47,8 @@ public class KitHumanArcher extends Kit
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW));
ItemStack potion = new ItemStack(Material.POTION, 2, (short)16429); // 16422
PotionMeta potionMeta = (PotionMeta)potion.getItemMeta();
ItemStack potion = new ItemStack(Material.POTION, 2, (short) 16429); // 16422
PotionMeta potionMeta = (PotionMeta) potion.getItemMeta();
potionMeta.setDisplayName(ChatColor.RESET + "Revival Potion");
potion.setItemMeta(potionMeta);
player.getInventory().addItem(potion);

View File

@ -1,65 +0,0 @@
package nautilus.game.arcade.game.games.wither.kit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
import nautilus.game.arcade.kit.Perk;
import nautilus.game.arcade.kit.perks.PerkBlockRestorer;
import nautilus.game.arcade.kit.perks.PerkDoubleJump;
import nautilus.game.arcade.kit.perks.PerkIronShell;
public class KitHumanBuilder extends Kit
{
public KitHumanBuilder(ArcadeManager manager)
{
super(manager, "Human Builder", KitAvailability.Free,
new String[]
{
""
},
new Perk[]
{
new PerkDoubleJump("Double Jump", 1, 0.8, true, 6000, true),
new PerkIronShell(),
new PerkBlockRestorer()
},
EntityType.ZOMBIE,
null);
}
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SPADE));
ItemStack potion = new ItemStack(Material.POTION, 2, (short)16429); // 16422
PotionMeta potionMeta = (PotionMeta)potion.getItemMeta();
potionMeta.setDisplayName(ChatColor.RESET + "Revival Potion");
potion.setItemMeta(potionMeta);
player.getInventory().addItem(potion);
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.MUSHROOM_SOUP));
}
@Override
public void SpawnCustom(LivingEntity ent)
{
}
}

View File

@ -35,48 +35,51 @@ public class KitWitherMinion extends Kit
new Perk[]
{
new PerkWitherArrows(),
new PerkWitherAttack(),
new PerkWitherMinion()
},
EntityType.WITHER,
null);
new PerkWitherArrows(), new PerkWitherAttack(),
new PerkWitherMinion(), new PerkWitherCompassScent()
}, EntityType.WITHER, null);
}
// @Override
// public void SpawnCustom(LivingEntity ent)
// {
// ent.setMaxHealth(300);
// ent.setHealth(300);
//
// DisguiseWither disguise = new DisguiseWither(ent);
// disguise.SetName(C.cYellow + "Wither");
// disguise.SetCustomNameVisible(true);
// Manager.GetDisguise().disguise(disguise);
// }
// @Override
// public void SpawnCustom(LivingEntity ent)
// {
// ent.setMaxHealth(300);
// ent.setHealth(300);
//
// DisguiseWither disguise = new DisguiseWither(ent);
// disguise.SetName(C.cYellow + "Wither");
// disguise.SetCustomNameVisible(true);
// Manager.GetDisguise().disguise(disguise);
// }
@Override
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, (byte)0, 1,
C.cYellow + C.Bold + "Left-Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Wither Skull"));
player.getInventory().addItem(
ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD,
(byte) 0, 1, C.cYellow + C.Bold + "Left-Click"
+ C.cWhite + C.Bold + " - " + C.cGreen + C.Bold
+ "Wither Skull"));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, (byte)0, 1,
C.cYellow + C.Bold + "Right-Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Skeletal Minions"));
player.getInventory().addItem(
ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD,
(byte) 0, 1, C.cYellow + C.Bold + "Right-Click"
+ C.cWhite + C.Bold + " - " + C.cGreen + C.Bold
+ "Skeletal Minions"));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.COMPASS, (byte)0, 1,
C.cYellow + C.Bold + "Human Finder X-9000"));
player.getInventory().addItem(
ItemStackFactory.Instance
.CreateStack(Material.COMPASS, (byte) 0, 1, C.cYellow
+ C.Bold + "Human Finder X-9000"));
//Disguise
// Disguise
DisguiseWither disguise = new DisguiseWither(player);
if (Manager.GetGame().GetTeam(player) != null)
disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName());
else
disguise.setName(player.getName());
disguise.setName(Manager.GetGame().GetTeam(player).GetColor()
+ player.getName());
else disguise.setName(player.getName());
disguise.setCustomNameVisible(true);
Manager.GetDisguise().disguise(disguise);