Merge remote-tracking branch 'origin/master'

This commit is contained in:
Shaun Bennett 2014-08-03 23:32:37 -05:00
commit 34dfe8dacd
13 changed files with 166 additions and 36 deletions

View File

@ -1,13 +1,63 @@
package mineplex.core.disguise; package mineplex.core.disguise;
import org.bukkit.entity.Entity; import org.bukkit.entity.*;
import mineplex.core.disguise.disguises.*; import mineplex.core.disguise.disguises.*;
public class DisguiseFactory public class DisguiseFactory
{ {
protected DisguiseZombie DisguiseZombie(Entity entity) public static DisguiseBase createDisguise(Entity disguised, EntityType disguiseType)
{ {
return new DisguiseZombie(entity); switch (disguiseType)
{
case BAT:
return new DisguiseBat(disguised);
case BLAZE:
return new DisguiseBlaze(disguised);
case OCELOT:
return new DisguiseCat(disguised);
case CHICKEN:
return new DisguiseChicken(disguised);
case COW:
return new DisguiseCow(disguised);
case CREEPER:
return new DisguiseCreeper(disguised);
case ENDERMAN:
return new DisguiseEnderman(disguised);
case HORSE:
return new DisguiseHorse(disguised);
case IRON_GOLEM:
return new DisguiseIronGolem(disguised);
case MAGMA_CUBE:
return new DisguiseMagmaCube(disguised);
case PIG:
return new DisguisePig(disguised);
case PIG_ZOMBIE:
return new DisguisePigZombie(disguised);
case PLAYER:
return new DisguisePlayer(disguised);
case SHEEP:
return new DisguiseSheep(disguised);
case SKELETON:
return new DisguiseSkeleton(disguised);
case SLIME:
return new DisguiseSlime(disguised);
case SNOWMAN:
return new DisguiseSnowman(disguised);
case SPIDER:
return new DisguiseSpider(disguised);
case SQUID:
return new DisguiseSquid(disguised);
case VILLAGER:
return new DisguiseVillager(disguised);
case WITCH:
return new DisguiseWitch(disguised);
case WOLF:
return new DisguiseWolf(disguised);
case ZOMBIE:
return new DisguiseZombie(disguised);
default:
return null;
}
} }
} }

View File

@ -31,11 +31,6 @@ public abstract class DisguiseBase
{ {
DataWatcher.watch(0, Entity.getDataWatcher().getByte(0)); DataWatcher.watch(0, Entity.getDataWatcher().getByte(0));
DataWatcher.watch(1, Entity.getDataWatcher().getShort(1)); DataWatcher.watch(1, Entity.getDataWatcher().getShort(1));
if (this instanceof DisguiseEnderman)
{
DataWatcher.watch(0, Byte.valueOf((byte)(DataWatcher.getByte(0) & ~(1 << 0))));
}
} }
public abstract Packet GetSpawnPacket(); public abstract Packet GetSpawnPacket();

View File

@ -22,6 +22,13 @@ public class DisguiseEnderman extends DisguiseMonster
DataWatcher.watch(7, Integer.valueOf(i)); DataWatcher.watch(7, Integer.valueOf(i));
} }
public void UpdateDataWatcher()
{
super.UpdateDataWatcher();
DataWatcher.watch(0, Byte.valueOf((byte)(DataWatcher.getByte(0) & ~(1 << 0))));
}
public void SetCarriedId(int i) public void SetCarriedId(int i)
{ {
DataWatcher.watch(16, Byte.valueOf((byte)(i & 0xFF))); DataWatcher.watch(16, Byte.valueOf((byte)(i & 0xFF)));

View File

@ -11,16 +11,24 @@ public class DisguisePlayer extends DisguiseHuman
{ {
private String _name; private String _name;
public DisguisePlayer(org.bukkit.entity.Entity entity, String name) public DisguisePlayer(org.bukkit.entity.Entity entity)
{ {
super(entity); super(entity);
}
public DisguisePlayer(org.bukkit.entity.Entity entity, String name)
{
this(entity);
setName(name);
}
public void setName(String name)
{
if (name.length() > 16) if (name.length() > 16)
{ _name = name.substring(0, 16);
name = name.substring(0, 16); else
} _name = name;
_name = name;
} }
@Override @Override

View File

@ -246,6 +246,11 @@ public abstract class Game implements Listener
System.out.println("Loading " + GetName() + "..."); System.out.println("Loading " + GetName() + "...");
} }
public void setKits(Kit[] kits)
{
_kits = kits;
}
public ArrayList<String> GetFiles() public ArrayList<String> GetFiles()
{ {
return _files; return _files;

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.game.games.sneakyassassins; package nautilus.game.arcade.game.games.sneakyassassins;
import mineplex.core.common.util.*; import mineplex.core.common.util.*;
import mineplex.core.disguise.*;
import mineplex.core.updater.*; import mineplex.core.updater.*;
import mineplex.core.updater.event.*; import mineplex.core.updater.event.*;
import mineplex.minecraft.game.core.damage.*; import mineplex.minecraft.game.core.damage.*;
@ -14,6 +15,8 @@ import nautilus.game.arcade.kit.*;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.event.*; import org.bukkit.event.*;
import org.bukkit.event.entity.*;
import org.bukkit.event.hanging.*;
import org.bukkit.event.player.*; import org.bukkit.event.player.*;
import java.util.*; import java.util.*;
@ -33,6 +36,7 @@ public class SneakyAssassins extends SoloGame
private final NpcManager _npcManager; private final NpcManager _npcManager;
private PowerUpManager _powerUpManager; private PowerUpManager _powerUpManager;
private EntityType _disguiseType = EntityType.VILLAGER;
public SneakyAssassins(ArcadeManager manager) public SneakyAssassins(ArcadeManager manager)
{ {
@ -40,9 +44,9 @@ public class SneakyAssassins extends SoloGame
manager, manager,
GameType.SneakyAssassins, GameType.SneakyAssassins,
new Kit[]{ new Kit[]{
new KitEscapeArtist(manager), new KitEscapeArtist(manager, EntityType.VILLAGER),
new KitAssassin(manager), new KitAssassin(manager, EntityType.VILLAGER),
new KitRevealer(manager) new KitRevealer(manager, EntityType.VILLAGER)
}, },
new String[]{ new String[]{
"Sneaky Assassins" "Sneaky Assassins"
@ -62,6 +66,15 @@ public class SneakyAssassins extends SoloGame
Collections.shuffle(GetTeamList().get(0).GetSpawns()); Collections.shuffle(GetTeamList().get(0).GetSpawns());
_powerUpManager = new PowerUpManager(this, UtilMath.random, WorldData.GetDataLocs("RED")); _powerUpManager = new PowerUpManager(this, UtilMath.random, WorldData.GetDataLocs("RED"));
String disguiseTypeName = WorldData.get("DISGUISE_TYPE");
if (disguiseTypeName != null)
_disguiseType = EntityType.valueOf(disguiseTypeName.toUpperCase());
_npcManager.setDisguiseType(_disguiseType);
for (Kit kit : GetKits())
kit.setEntityType(_disguiseType);
} }
public PowerUpManager getPowerUpManager() public PowerUpManager getPowerUpManager()
@ -129,7 +142,32 @@ public class SneakyAssassins extends SoloGame
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) public void onPlayerInteractEntity(PlayerInteractEntityEvent event)
{ {
if(event.getRightClicked() instanceof Villager) if (event.getRightClicked() instanceof Villager)
event.setCancelled(true);
}
@EventHandler(ignoreCancelled = true)
public void onEntityCombust(EntityCombustEvent event)
{
event.setCancelled(true);
}
@EventHandler(ignoreCancelled = true)
public void onHangingBreak(HangingBreakEvent event)
{
event.setCancelled(true);
}
@EventHandler(ignoreCancelled = true)
public void onHangingPlace(HangingPlaceEvent event)
{
event.setCancelled(true);
}
@EventHandler(ignoreCancelled = true)
public void onPlayerInteractHanging(PlayerInteractEntityEvent event)
{
if(event.getRightClicked() instanceof Hanging)
event.setCancelled(true); event.setCancelled(true);
} }

View File

@ -10,7 +10,7 @@ import org.bukkit.inventory.*;
public class KitAssassin extends SneakyAssassinKit public class KitAssassin extends SneakyAssassinKit
{ {
public KitAssassin(ArcadeManager manager) public KitAssassin(ArcadeManager manager, EntityType disguiseType)
{ {
super(manager, "Ranged Assassin", KitAvailability.Green, super(manager, "Ranged Assassin", KitAvailability.Green,
new String[] new String[]
@ -21,7 +21,8 @@ public class KitAssassin extends SneakyAssassinKit
{ {
new PerkSmokebomb(Material.INK_SACK, 5, true) new PerkSmokebomb(Material.INK_SACK, 5, true)
}, },
new ItemStack(Material.BOW)); new ItemStack(Material.BOW),
disguiseType);
} }
@Override @Override

View File

@ -9,7 +9,7 @@ import org.bukkit.inventory.*;
public class KitEscapeArtist extends SneakyAssassinKit public class KitEscapeArtist extends SneakyAssassinKit
{ {
public KitEscapeArtist(ArcadeManager manager) public KitEscapeArtist(ArcadeManager manager, EntityType disguiseType)
{ {
super(manager, "Escape Artist", KitAvailability.Free, super(manager, "Escape Artist", KitAvailability.Free,
new String[] new String[]
@ -20,7 +20,8 @@ public class KitEscapeArtist extends SneakyAssassinKit
{ {
new PerkSmokebomb(Material.INK_SACK, 5, true) new PerkSmokebomb(Material.INK_SACK, 5, true)
}, },
new ItemStack(Material.INK_SACK)); new ItemStack(Material.INK_SACK),
disguiseType);
} }
@Override @Override

View File

@ -12,7 +12,7 @@ import org.bukkit.inventory.*;
public class KitRevealer extends SneakyAssassinKit public class KitRevealer extends SneakyAssassinKit
{ {
public KitRevealer(ArcadeManager manager) public KitRevealer(ArcadeManager manager, EntityType disguiseType)
{ {
super(manager, "Revealer", KitAvailability.Green, 5000, super(manager, "Revealer", KitAvailability.Green, 5000,
new String[] new String[]
@ -24,7 +24,8 @@ public class KitRevealer extends SneakyAssassinKit
new PerkSmokebomb(Material.INK_SACK, 5, true), new PerkSmokebomb(Material.INK_SACK, 5, true),
new PerkRevealer() new PerkRevealer()
}, },
new ItemStack(Material.INK_SACK)); new ItemStack(Material.INK_SACK),
disguiseType);
} }
@Override @Override

View File

@ -1,6 +1,7 @@
package nautilus.game.arcade.game.games.sneakyassassins.kits; package nautilus.game.arcade.game.games.sneakyassassins.kits;
import mineplex.core.common.util.*; import mineplex.core.common.util.*;
import mineplex.core.disguise.*;
import mineplex.core.disguise.disguises.*; import mineplex.core.disguise.disguises.*;
import mineplex.core.itemstack.*; import mineplex.core.itemstack.*;
import nautilus.game.arcade.*; import nautilus.game.arcade.*;
@ -11,9 +12,9 @@ import org.bukkit.inventory.*;
public abstract class SneakyAssassinKit extends Kit public abstract class SneakyAssassinKit extends Kit
{ {
public SneakyAssassinKit(ArcadeManager manager, String name, KitAvailability kitAvailability, String[] kitDesc, Perk[] kitPerks, ItemStack itemInHand) public SneakyAssassinKit(ArcadeManager manager, String name, KitAvailability kitAvailability, String[] kitDesc, Perk[] kitPerks, ItemStack itemInHand, EntityType disguiseType)
{ {
super(manager, name, kitAvailability, kitDesc, kitPerks, EntityType.VILLAGER, itemInHand); super(manager, name, kitAvailability, kitDesc, kitPerks, disguiseType, itemInHand);
} }
public SneakyAssassinKit(ArcadeManager manager, String name, KitAvailability kitAvailability, int cost, String[] kitDesc, Perk[] kitPerks, ItemStack itemInHand) public SneakyAssassinKit(ArcadeManager manager, String name, KitAvailability kitAvailability, int cost, String[] kitDesc, Perk[] kitPerks, ItemStack itemInHand)
@ -24,7 +25,7 @@ public abstract class SneakyAssassinKit extends Kit
@Override @Override
public void GiveItems(Player player) public void GiveItems(Player player)
{ {
Manager.GetDisguise().disguise(new DisguiseVillager(player)); Manager.GetDisguise().disguise(DisguiseFactory.createDisguise(player, _entityType));
player.getInventory().addItem(new ItemStack(Material.WOOD_SWORD)); player.getInventory().addItem(new ItemStack(Material.WOOD_SWORD));
player.getInventory().setArmorContents(new ItemStack[]{ player.getInventory().setArmorContents(new ItemStack[]{

View File

@ -19,6 +19,7 @@ public class NpcManager implements Listener
{ {
private final SneakyAssassins _sneakyAssassins; private final SneakyAssassins _sneakyAssassins;
private final Random _random; private final Random _random;
private EntityType _disguiseType = EntityType.VILLAGER;
public NpcManager(SneakyAssassins sneakyAssassins, Random random) public NpcManager(SneakyAssassins sneakyAssassins, Random random)
{ {
@ -33,17 +34,17 @@ public class NpcManager implements Listener
return _sneakyAssassins; return _sneakyAssassins;
} }
public Collection<Villager> getNpcs() public Collection<? extends Entity> getNpcs()
{ {
return getGame().WorldData.World.getEntitiesByClass(Villager.class); return getGame().WorldData.World.getEntitiesByClass(getDisguiseType().getEntityClass());
} }
public Villager spawnNpc() public Entity spawnNpc()
{ {
Location spawn = getNpcSpawn(); Location spawn = getNpcSpawn();
getGame().CreatureAllowOverride = true; getGame().CreatureAllowOverride = true;
Villager npc = spawn.getWorld().spawn(spawn, Villager.class); LivingEntity npc = (LivingEntity) spawn.getWorld().spawn(spawn, getDisguiseType().getEntityClass());
npc.setCanPickupItems(false); npc.setCanPickupItems(false);
npc.setRemoveWhenFarAway(false); npc.setRemoveWhenFarAway(false);
UtilEnt.Vegetate(npc); UtilEnt.Vegetate(npc);
@ -86,7 +87,7 @@ public class NpcManager implements Listener
public void bustle() public void bustle()
{ {
for (Villager npc : getNpcs()) for (Entity npc : getNpcs())
{ {
if (getRandom().nextInt(40) == 0) if (getRandom().nextInt(40) == 0)
{ {
@ -109,4 +110,14 @@ public class NpcManager implements Listener
{ {
return getGame().Manager.GetPlugin(); return getGame().Manager.GetPlugin();
} }
public EntityType getDisguiseType()
{
return _disguiseType;
}
public void setDisguiseType(EntityType disguiseType)
{
_disguiseType = disguiseType;
}
} }

View File

@ -203,5 +203,8 @@ public abstract class Kit implements Listener
public void Selected(Player player) { } public void Selected(Player player) { }
public void setEntityType(EntityType entityType)
{
_entityType = entityType;
}
} }

View File

@ -7,8 +7,7 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import mineplex.core.common.util.FileUtil; import mineplex.core.common.util.FileUtil;
import mineplex.core.common.util.MapUtil; import mineplex.core.common.util.MapUtil;
@ -52,6 +51,7 @@ public class WorldData
public HashMap<String, ArrayList<Location>> SpawnLocs = new HashMap<String, ArrayList<Location>>(); public HashMap<String, ArrayList<Location>> SpawnLocs = new HashMap<String, ArrayList<Location>>();
private HashMap<String, ArrayList<Location>> DataLocs = new HashMap<String, ArrayList<Location>>(); private HashMap<String, ArrayList<Location>> DataLocs = new HashMap<String, ArrayList<Location>>();
private HashMap<String, ArrayList<Location>> CustomLocs = new HashMap<String, ArrayList<Location>>(); private HashMap<String, ArrayList<Location>> CustomLocs = new HashMap<String, ArrayList<Location>>();
private final Map<String, String> _dataEntries = new HashMap<>();
public WorldData(Game game) public WorldData(Game game)
{ {
@ -302,6 +302,10 @@ public class WorldData
System.out.println("World Data Read Error: Invalid MaxY [" + tokens[1] + "]"); System.out.println("World Data Read Error: Invalid MaxY [" + tokens[1] + "]");
} }
} }
else
{
_dataEntries.put(tokens[0], tokens[1]);
}
} }
in.close(); in.close();
@ -488,4 +492,9 @@ public class WorldData
return loc; return loc;
} }
public String get(String key)
{
return _dataEntries.get(key);
}
} }