Add wither pet, pets are no longer stackable. Enderdragon no longer has his health changed in the hub

This commit is contained in:
libraryaddict 2014-12-17 18:31:51 +13:00
parent 2e7d101850
commit 17ac36d9ae
7 changed files with 66 additions and 6 deletions

View File

@ -126,7 +126,7 @@ public class PetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
itemLore.add(C.cWhite + "You must have an active pet to use this!"); itemLore.add(C.cWhite + "You must have an active pet to use this!");
getInventory().setItem(slot, new ShopItem(petExtra.GetMaterial(), (byte)0, C.cRed + petExtra.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).getHandle()); getInventory().setItem(slot, new ShopItem(petExtra.GetMaterial(), (byte)0, C.cRed + petExtra.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false).getHandle());
} }
else else if (Plugin.getPetManager().getActivePet(Player.getName()).getType() != EntityType.WITHER)
{ {
AddButton(slot, new ShopItem(petExtra.GetMaterial(), (byte)0, "Rename " + Plugin.getPetManager().getActivePet(Player.getName()).getCustomName() + " for " + C.cYellow + petExtra.GetCost(CurrencyType.Coins) + C.cGreen + " Coins", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new RenamePetButton(this)); AddButton(slot, new ShopItem(petExtra.GetMaterial(), (byte)0, "Rename " + Plugin.getPetManager().getActivePet(Player.getName()).getCustomName() + " for " + C.cYellow + petExtra.GetCost(CurrencyType.Coins) + C.cGreen + " Coins", itemLore.toArray(new String[itemLore.size()]), 1, false, false), new RenamePetButton(this));
} }

View File

@ -41,7 +41,7 @@ public class PetFactory
_pets.put(EntityType.WOLF, new Pet("Dog", EntityType.WOLF, 8000)); _pets.put(EntityType.WOLF, new Pet("Dog", EntityType.WOLF, 8000));
_pets.put(EntityType.OCELOT, new Pet("Cat", EntityType.OCELOT, 6000)); _pets.put(EntityType.OCELOT, new Pet("Cat", EntityType.OCELOT, 6000));
_pets.put(EntityType.MUSHROOM_COW, new Pet("Mooshroom", EntityType.MUSHROOM_COW, 5000)); _pets.put(EntityType.MUSHROOM_COW, new Pet("Mooshroom", EntityType.MUSHROOM_COW, 5000));
//_pets.put(EntityType.WITHER, new Pet("Widder", EntityType.SHEEP, 5)); _pets.put(EntityType.WITHER, new Pet("Widder", EntityType.WITHER, -1));
List<PetSalesToken> petTokens = new ArrayList<PetSalesToken>(); List<PetSalesToken> petTokens = new ArrayList<PetSalesToken>();

View File

@ -1,11 +1,13 @@
package mineplex.core.pet; package mineplex.core.pet;
import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map.Entry; import java.util.Map.Entry;
import mineplex.core.MiniClientPlugin; import mineplex.core.MiniClientPlugin;
import mineplex.core.pet.repository.PetRepository; import mineplex.core.pet.repository.PetRepository;
import mineplex.core.pet.repository.token.ClientPetTokenWrapper; import mineplex.core.pet.repository.token.ClientPetTokenWrapper;
import mineplex.core.pet.types.CustomWither;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
@ -17,6 +19,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import net.minecraft.server.v1_7_R4.EntityCreature; import net.minecraft.server.v1_7_R4.EntityCreature;
import net.minecraft.server.v1_7_R4.EntityWither;
import net.minecraft.server.v1_7_R4.Navigation; import net.minecraft.server.v1_7_R4.Navigation;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -24,10 +27,13 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.craftbukkit.libs.com.google.gson.Gson; import org.bukkit.craftbukkit.libs.com.google.gson.Gson;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftCreature; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftCreature;
import org.bukkit.entity.Ageable; import org.bukkit.entity.Ageable;
import org.bukkit.entity.Creature; import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Villager; import org.bukkit.entity.Villager;
import org.bukkit.entity.Zombie; import org.bukkit.entity.Zombie;
@ -35,6 +41,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
@ -140,7 +147,27 @@ public class PetManager extends MiniClientPlugin<PetClient>
return; return;
} }
Creature pet = (Creature)_creatureModule.SpawnEntity(location, entityType); Creature pet;
if (entityType == EntityType.WITHER)
{
_creatureModule.SetForce(true);
EntityWither wither = new CustomWither(((CraftWorld) location.getWorld()).getHandle());
wither.Silent = true;
wither.setLocation(location.getX(), location.getY(), location.getZ(), 0, 0);
((CraftWorld) location.getWorld()).getHandle().addEntity(wither, SpawnReason.CUSTOM);
pet = (Creature) wither.getBukkitEntity();
_creatureModule.SetForce(false);
Entity silverfish = _creatureModule.SpawnEntity(location, EntityType.SILVERFISH);
UtilEnt.Vegetate(silverfish, true);
((LivingEntity) silverfish).addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0));
pet.setPassenger(silverfish);
}
else
{
pet = (Creature)_creatureModule.SpawnEntity(location, entityType);
}
//Named Pet //Named Pet
if (Get(player).GetPets().get(entityType) != null && Get(player).GetPets().get(entityType).length() > 0) if (Get(player).GetPets().get(entityType) != null && Get(player).GetPets().get(entityType).length() > 0)
@ -367,4 +394,9 @@ public class PetManager extends MiniClientPlugin<PetClient>
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
RemovePet(player, true); RemovePet(player, true);
} }
public Collection<Creature> getPets()
{
return _activePetOwners.values();
}
} }

View File

@ -127,6 +127,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
private NewsManager _news; private NewsManager _news;
private AchievementManager _achievementManager; private AchievementManager _achievementManager;
private TreasureManager _treasureManager; private TreasureManager _treasureManager;
private PetManager _petManager;
private Location _spawn; private Location _spawn;
private int _scoreboardTick = 0; private int _scoreboardTick = 0;
@ -180,6 +181,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
_treasureManager = new TreasureManager(_plugin, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager); _treasureManager = new TreasureManager(_plugin, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager);
new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager); new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager);
_petManager = petManager;
_partyManager = partyManager; _partyManager = partyManager;
_preferences = preferences; _preferences = preferences;
_tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator); _tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator);
@ -888,6 +890,11 @@ public class HubManager extends MiniClientPlugin<HubClient>
{ {
return _spawn.clone(); return _spawn.clone();
} }
public PetManager getPetManager()
{
return _petManager;
}
public TutorialManager GetTutorial() public TutorialManager GetTutorial()
{ {

View File

@ -5,7 +5,9 @@ import java.util.Iterator;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Wither;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
@ -14,7 +16,6 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback; import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextTop; import mineplex.core.common.util.UtilTextTop;
@ -256,12 +257,20 @@ public class NewsManager extends MiniPlugin
UtilTextTop.display(text, UtilServer.getPlayers()); UtilTextTop.display(text, UtilServer.getPlayers());
for (Creature pet : Manager.getPetManager().getPets())
{
if (pet instanceof Wither)
{
pet.setCustomName(text);
}
}
for (Mount mount : Manager.GetMount().getMounts()) for (Mount mount : Manager.GetMount().getMounts())
{ {
if (mount instanceof MountDragon) if (mount instanceof MountDragon)
{ {
((MountDragon)mount).SetName(text); ((MountDragon)mount).SetName(text);
((MountDragon)mount).setHealthPercent(healthPercent); //((MountDragon)mount).setHealthPercent(healthPercent);
} }
} }
} }

View File

@ -12,6 +12,7 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Horse; import org.bukkit.entity.Horse;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Wither;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
@ -117,7 +118,7 @@ public class StackerManager extends MiniPlugin implements IThrown
if (stackee instanceof LivingEntity) if (stackee instanceof LivingEntity)
{ {
if (((LivingEntity)stackee).isCustomNameVisible()) if (Manager.getPetManager().getPets().contains(stackee) || stackee instanceof Wither || stackee instanceof EnderDragon || ((LivingEntity)stackee).isCustomNameVisible())
{ {
UtilPlayer.message(stacker, F.main("Stacker", "You cannot stack this entity.")); UtilPlayer.message(stacker, F.main("Stacker", "You cannot stack this entity."));
return; return;

View File

@ -39,7 +39,9 @@ import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type; import org.bukkit.FireworkEffect.Type;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Wither;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -84,6 +86,15 @@ public class GameManager implements Listener
//Display IP //Display IP
UtilTextTop.displayProgress(text, health, UtilServer.getPlayers()); UtilTextTop.displayProgress(text, health, UtilServer.getPlayers());
for (Creature pet : Manager.getCosmeticManager().getPetManager().getPets())
{
if (pet instanceof Wither)
{
pet.setCustomName(text);
pet.setHealth(Math.max(0.1, 300 * health));
}
}
//Name Dragons Appropriately //Name Dragons Appropriately
for (Mount mount : Manager.getCosmeticManager().getMountManager().getMounts()) for (Mount mount : Manager.getCosmeticManager().getMountManager().getMounts())
{ {