From 17ac36d9ae9ac76a742cf43759502605ca6c95e0 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Wed, 17 Dec 2014 18:31:51 +1300 Subject: [PATCH] Add wither pet, pets are no longer stackable. Enderdragon no longer has his health changed in the hub --- .../core/cosmetic/ui/page/PetPage.java | 2 +- .../src/mineplex/core/pet/PetFactory.java | 2 +- .../src/mineplex/core/pet/PetManager.java | 34 ++++++++++++++++++- .../src/mineplex/hub/HubManager.java | 7 ++++ .../src/mineplex/hub/modules/NewsManager.java | 13 +++++-- .../mineplex/hub/modules/StackerManager.java | 3 +- .../game/arcade/managers/GameManager.java | 11 ++++++ 7 files changed, 66 insertions(+), 6 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java index e358e2c39..d4aa35e82 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/PetPage.java @@ -126,7 +126,7 @@ public class PetPage extends ShopPageBase 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()); } - 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)); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetFactory.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetFactory.java index 391fb18fe..40f7815f0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetFactory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetFactory.java @@ -41,7 +41,7 @@ public class PetFactory _pets.put(EntityType.WOLF, new Pet("Dog", EntityType.WOLF, 8000)); _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.WITHER, new Pet("Widder", EntityType.SHEEP, 5)); + _pets.put(EntityType.WITHER, new Pet("Widder", EntityType.WITHER, -1)); List petTokens = new ArrayList(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java index 824bf1f32..c95ec8712 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/pet/PetManager.java @@ -1,11 +1,13 @@ package mineplex.core.pet; +import java.util.Collection; import java.util.Iterator; import java.util.Map.Entry; import mineplex.core.MiniClientPlugin; import mineplex.core.pet.repository.PetRepository; import mineplex.core.pet.repository.token.ClientPetTokenWrapper; +import mineplex.core.pet.types.CustomWither; import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.UpdateType; import mineplex.core.account.CoreClientManager; @@ -17,6 +19,7 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; 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 org.bukkit.Bukkit; @@ -24,10 +27,13 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; 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.entity.Ageable; import org.bukkit.entity.Creature; +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Villager; import org.bukkit.entity.Zombie; @@ -35,6 +41,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -140,7 +147,27 @@ public class PetManager extends MiniClientPlugin 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 if (Get(player).GetPets().get(entityType) != null && Get(player).GetPets().get(entityType).length() > 0) @@ -367,4 +394,9 @@ public class PetManager extends MiniClientPlugin for (Player player : UtilServer.getPlayers()) RemovePet(player, true); } + + public Collection getPets() + { + return _activePetOwners.values(); + } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 8d5a1bed1..99f6109b7 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -127,6 +127,7 @@ public class HubManager extends MiniClientPlugin private NewsManager _news; private AchievementManager _achievementManager; private TreasureManager _treasureManager; + private PetManager _petManager; private Location _spawn; private int _scoreboardTick = 0; @@ -180,6 +181,7 @@ public class HubManager extends MiniClientPlugin _treasureManager = new TreasureManager(_plugin, donationManager, _inventoryManager, petManager, _blockRestore, hologramManager); new CosmeticManager(_plugin, clientManager, donationManager, _inventoryManager, _gadgetManager, _mountManager, petManager, _treasureManager); + _petManager = petManager; _partyManager = partyManager; _preferences = preferences; _tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator); @@ -888,6 +890,11 @@ public class HubManager extends MiniClientPlugin { return _spawn.clone(); } + + public PetManager getPetManager() + { + return _petManager; + } public TutorialManager GetTutorial() { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java index 7ab131db7..ed5609539 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/NewsManager.java @@ -5,7 +5,9 @@ import java.util.Iterator; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.entity.Creature; import org.bukkit.entity.Player; +import org.bukkit.entity.Wither; import org.bukkit.event.EventHandler; 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.Callback; import mineplex.core.common.util.F; - import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextTop; @@ -256,12 +257,20 @@ public class NewsManager extends MiniPlugin UtilTextTop.display(text, UtilServer.getPlayers()); + for (Creature pet : Manager.getPetManager().getPets()) + { + if (pet instanceof Wither) + { + pet.setCustomName(text); + } + } + for (Mount mount : Manager.GetMount().getMounts()) { if (mount instanceof MountDragon) { ((MountDragon)mount).SetName(text); - ((MountDragon)mount).setHealthPercent(healthPercent); + //((MountDragon)mount).setHealthPercent(healthPercent); } } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java index ddbe36297..69afd0a49 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java @@ -12,6 +12,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Horse; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.entity.Wither; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -117,7 +118,7 @@ public class StackerManager extends MiniPlugin implements IThrown 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.")); return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java index 1ed54fcdf..bf77902ec 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java @@ -39,7 +39,9 @@ import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.FireworkEffect.Type; +import org.bukkit.entity.Creature; import org.bukkit.entity.Player; +import org.bukkit.entity.Wither; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; @@ -84,6 +86,15 @@ public class GameManager implements Listener //Display IP 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 for (Mount mount : Manager.getCosmeticManager().getMountManager().getMounts()) {