diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java index 9eeda0347..94cc31e8f 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/Rank.java @@ -26,7 +26,7 @@ public enum Rank //Media YOUTUBE("YouTube", ChatColor.RED), - YOUTUBE_SMALL("MooTube", ChatColor.DARK_PURPLE), + YOUTUBE_SMALL("Tuber", ChatColor.DARK_PURPLE), TWITCH("Twitch", ChatColor.DARK_PURPLE), //Player diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java index f6299ff38..566be1092 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilEnt.java @@ -33,6 +33,7 @@ import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftCreature; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; +import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Creature; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; @@ -803,6 +804,20 @@ public class UtilEnt return null; } + + public static void setAI(LivingEntity entity, boolean ai) + { + if(entity instanceof ArmorStand) + { + ((ArmorStand)entity).setGravity(ai); + return; + } + CraftEntity e = (CraftEntity)entity; + if(e.getHandle() instanceof EntityInsentient) + { + ((EntityInsentient)e.getHandle()).k(!ai); + } + } public static boolean inWater(LivingEntity ent) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java index 5db2cfd80..790df2c43 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/CustomTagFix.java @@ -19,13 +19,13 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject; -import net.minecraft.server.v1_8_R3.MathHelper; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity.EnumEntityUseAction; import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; +import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; @@ -49,8 +49,10 @@ import fr.neatmonster.nocheatplus.hooks.NCPHookManager; public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook { - private NautHashMap> _entityMap = new NautHashMap>(); + private NautHashMap> _entityMap = new NautHashMap>(); private NautHashMap> _entityNameMap = new NautHashMap>(); + private NautHashMap> _entityRiding = new NautHashMap>(); + private HashSet _loggedIn = new HashSet(); private HashSet _ignoreSkulls = new HashSet(); @@ -63,7 +65,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook packetHandler.addPacketHandler(this, true, PacketPlayOutAttachEntity.class, PacketPlayOutEntityDestroy.class, PacketPlayOutEntityMetadata.class, PacketPlayOutSpawnEntity.class, PacketPlayOutSpawnEntityLiving.class, - PacketPlayInUseEntity.class); + PacketPlayOutNamedEntitySpawn.class, PacketPlayInUseEntity.class, PacketPlayOutAttachEntity.class); NCPHookManager.addHook(CheckType.MOVING_SURVIVALFLY, this); NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this); @@ -75,6 +77,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook { _entityMap.remove(event.getPlayer().getName()); _entityNameMap.remove(event.getPlayer().getName()); + _entityRiding.remove(event.getPlayer().getName()); _loggedIn.remove(event.getPlayer()); } @@ -167,6 +170,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook iterator.remove(); _entityMap.remove(player); _entityNameMap.remove(player); + _entityRiding.remove(player); } } @@ -190,7 +194,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook { if (owner.isOnline() && !_entityMap.containsKey(owner.getName())) { - _entityMap.put(owner.getName(), new NautHashMap()); + _entityMap.put(owner.getName(), new NautHashMap()); _entityNameMap.put(owner.getName(), new NautHashMap()); _loggedIn.add(owner.getName()); } @@ -217,10 +221,15 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook { if (_entityMap.get(owner.getName()).containsKey(spawnPacket.a)) { - UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(new int[] - { - _entityMap.get(owner.getName()).get(spawnPacket.a) - })); + Integer[] ids = _entityMap.get(owner.getName()).get(spawnPacket.a); + int[] newIds = new int[ids.length]; + + for (int a = 0; a < ids.length; a++) + { + newIds[a] = ids[a]; + } + + UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds)); _entityNameMap.get(owner.getName()).remove(spawnPacket.a); _entityMap.get(owner.getName()).remove(spawnPacket.a); @@ -236,9 +245,59 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook int newId = UtilEnt.getNewEntityId(); _entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName); - _entityMap.get(owner.getName()).put(spawnPacket.a, newId); + _entityMap.get(owner.getName()).put(spawnPacket.a, new Integer[] + { + newId + }); - sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier, true); + sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier, true, -1); + break; + } + } + } + else if (packet instanceof PacketPlayOutNamedEntitySpawn) + { + PacketPlayOutNamedEntitySpawn spawnPacket = (PacketPlayOutNamedEntitySpawn) packet; + + for (WatchableObject watchable : (List) spawnPacket.i.c()) + { + if (watchable.a() == 3 && watchable.b() instanceof Byte && ((Byte) watchable.b()) == 1) + { + if (_entityMap.get(owner.getName()).containsKey(spawnPacket.a)) + { + Integer[] ids = _entityMap.get(owner.getName()).get(spawnPacket.a); + + int[] newIds = new int[ids.length]; + + for (int a = 0; a < ids.length; a++) + { + newIds[a] = ids[a]; + } + + UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds)); + + _entityNameMap.get(owner.getName()).remove(spawnPacket.a); + _entityMap.get(owner.getName()).remove(spawnPacket.a); + } + + final String entityName = spawnPacket.i.getString(2); + + if (entityName.isEmpty()) + { + return; + } + + int newId = UtilEnt.getNewEntityId(); + int newId2 = UtilEnt.getNewEntityId(); + + _entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName); + _entityMap.get(owner.getName()).put(spawnPacket.a, new Integer[] + { + newId, + newId2 + }); + + sendProtocolPackets(owner, spawnPacket.a, newId2, entityName, verifier, true, newId); break; } } @@ -247,7 +306,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook { PacketPlayOutEntityMetadata metaPacket = (PacketPlayOutEntityMetadata) packet; - if (metaPacket.a != 777777 && !_ignoreSkulls.contains(metaPacket.a)) + if (metaPacket.a != 777777 && !_ignoreSkulls.contains(metaPacket.a) && metaPacket.a != owner.getEntityId()) { boolean isDisplaying = _entityMap.get(owner.getName()).containsKey(metaPacket.a); String currentName = _entityNameMap.get(owner.getName()).get(metaPacket.a); @@ -279,7 +338,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook // If name is still being displayed if (newDisplay) { - int newId; + Integer[] newId; if (isDisplaying) // Sending metadata { @@ -288,22 +347,28 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook else // Spawning new entity { - newId = UtilEnt.getNewEntityId(); + newId = new Integer[] + { + UtilEnt.getNewEntityId() + }; + _entityMap.get(owner.getName()).put(metaPacket.a, newId); } - sendProtocolPackets(owner, metaPacket.a, newId, newName, verifier, !isDisplaying); - _entityNameMap.get(owner.getName()).put(metaPacket.a, newName); + sendProtocolPackets(owner, metaPacket.a, newId[0], newName, verifier, !isDisplaying, -1); } else { // Lets delete it - int id = _entityMap.get(owner.getName()).get(metaPacket.a); + Integer[] ids = _entityMap.get(owner.getName()).get(metaPacket.a); + int[] newIds = new int[ids.length]; - verifier.bypassProcess(new PacketPlayOutEntityDestroy(new int[] - { - id - })); + for (int a = 0; a < ids.length; a++) + { + newIds[a] = ids[a]; + } + + verifier.bypassProcess(new PacketPlayOutEntityDestroy(newIds)); _entityMap.get(owner.getName()).remove(metaPacket.a); _entityNameMap.get(owner.getName()).remove(metaPacket.a); @@ -319,10 +384,15 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook { if (_entityMap.get(owner.getName()).containsKey(id)) { - UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(new int[] - { - _entityMap.get(owner.getName()).get(id) - })); + Integer[] ids = _entityMap.get(owner.getName()).get(id); + int[] newIds = new int[ids.length]; + + for (int a = 0; a < ids.length; a++) + { + newIds[a] = ids[a]; + } + + UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds)); _entityMap.get(owner.getName()).remove(id); _entityNameMap.get(owner.getName()).remove(id); } @@ -345,19 +415,79 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook { PacketPlayInUseEntity usePacket = (PacketPlayInUseEntity) packet; - for (Entry entry : _entityMap.get(owner.getName()).entrySet()) - { - if (entry.getValue() == usePacket.a) - { - PacketPlayInUseEntity newPacket = new PacketPlayInUseEntity(); - newPacket.a = entry.getKey(); - newPacket.action = usePacket.action == EnumEntityUseAction.ATTACK ? EnumEntityUseAction.ATTACK - : EnumEntityUseAction.INTERACT; + loop: + for (Entry entry : _entityMap.get(owner.getName()).entrySet()) + { + for (int id : entry.getValue()) + { + if (id == usePacket.a) { - ((CraftPlayer) owner).getHandle().playerConnection.a(newPacket); + PacketPlayInUseEntity newPacket = new PacketPlayInUseEntity(); + newPacket.a = entry.getKey(); + newPacket.action = usePacket.action == EnumEntityUseAction.ATTACK ? EnumEntityUseAction.ATTACK + : EnumEntityUseAction.INTERACT; + + { + ((CraftPlayer) owner).getHandle().playerConnection.a(newPacket); + } + + break loop; } - break; + } + } + } + else if (packet instanceof PacketPlayOutAttachEntity) + { + PacketPlayOutAttachEntity attachPacket = (PacketPlayOutAttachEntity) packet; + + // c = rider, b = ridden + // When detaching, c is sent, b is -1 + + // If this attach packet is for a player that has the fix + // If the attach packet isn't ordained by me + if (!_entityMap.containsKey(owner.getName())) + { + return; + } + + if (!_entityRiding.containsKey(owner.getName())) + { + _entityRiding.put(owner.getName(), new NautHashMap()); + } + + int vehicleId = -1; + + if (_entityRiding.get(owner.getName()).containsKey(attachPacket.b)) + { + vehicleId = _entityRiding.get(owner.getName()).get(attachPacket.b); + } + + if (attachPacket.c == -1 && _entityMap.get(owner.getName()).containsKey(vehicleId)) + { + Integer[] ids = _entityMap.get(owner.getName()).get(vehicleId); + + _entityRiding.get(owner.getName()).remove(attachPacket.b); + + sendProtocolPackets(owner, vehicleId, ids[ids.length - 1], + _entityNameMap.get(owner.getName()).get(vehicleId), verifier, true, ids.length > 1 ? ids[0] : -1); + } + else + { + Integer[] ids = _entityMap.get(owner.getName()).get(attachPacket.c); + + if (ids != null && ids[0] != attachPacket.b) + { + _entityRiding.get(owner.getName()).put(attachPacket.b, attachPacket.c); + + int[] newIds = new int[ids.length]; + + for (int a = 0; a < ids.length; a++) + { + newIds[a] = ids[a]; + } + + UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds)); } } } @@ -365,7 +495,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook } private void sendProtocolPackets(final Player owner, final int entityId, final int newEntityId, String entityName, - final PacketVerifier packetList, final boolean newPacket) + final PacketVerifier packetList, final boolean newPacket, final int squidId) { CustomTagEvent event = new CustomTagEvent(owner, entityId, entityName); _plugin.getServer().getPluginManager().callEvent(event); @@ -375,82 +505,47 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook { public void run() { - final DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld) owner.getWorld()).getHandle())); + DataWatcher watcher = new DataWatcher(new DummyEntity(((CraftWorld) owner.getWorld()).getHandle())); - watcher.a(0, Byte.valueOf((byte) 0)); + watcher.a(0, (byte) (0 | 1 << 5)); // Invisible watcher.a(1, Short.valueOf((short) 300)); - watcher.a(2, ""); - watcher.a(3, Byte.valueOf((byte) 0)); + watcher.a(2, finalEntityName); + watcher.a(3, (byte) 1); watcher.a(4, Byte.valueOf((byte) 0)); watcher.a(7, Integer.valueOf(0)); watcher.a(8, Byte.valueOf((byte) 0)); watcher.a(9, Byte.valueOf((byte) 0)); watcher.a(6, Float.valueOf(1.0F)); - watcher.a(10, Byte.valueOf((byte) 0)); - - // Set invisible - int i1 = watcher.getByte(0); - watcher.watch(0, Byte.valueOf((byte) (i1 | 1 << 5))); - - // Set small - byte b1 = watcher.getByte(10); - b1 = (byte) (b1 | 0x1); - - watcher.watch(10, Byte.valueOf(b1)); - - watcher.watch(2, finalEntityName); - watcher.watch(3, Byte.valueOf((byte) 1)); + watcher.a(10, (byte) (0 | 0x1)); // Small if (newPacket) { + if (squidId >= 0) + { + watcher.watch(10, (byte) 16); + + DataWatcher squidWatcher = new DataWatcher(new DummyEntity(((CraftWorld) owner.getWorld()).getHandle())); + squidWatcher.a(0, (byte) (0 | 1 << 5)); + + final PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving(); + spawnPacket.a = squidId; + spawnPacket.b = (byte) EntityType.SQUID.getTypeId(); + + spawnPacket.l = squidWatcher; + + UtilPlayer.sendPacket(owner, spawnPacket); + + PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity(); + vehiclePacket.a = 0; + vehiclePacket.b = spawnPacket.a; + vehiclePacket.c = entityId; + + UtilPlayer.sendPacket(owner, vehiclePacket); + } + final PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving(); spawnPacket.a = newEntityId; spawnPacket.b = (byte) 30; - spawnPacket.c = (int) MathHelper.floor(100 * 32); - spawnPacket.d = (int) MathHelper.floor(64 * 32.0D); - spawnPacket.e = (int) MathHelper.floor(100 * 32); - spawnPacket.i = (byte) ((int) (0 * 256.0F / 360.0F)); - spawnPacket.j = (byte) ((int) (0 * 256.0F / 360.0F)); - spawnPacket.k = (byte) ((int) (0 * 256.0F / 360.0F)); - - double var2 = 3.9D; - double var4 = 0; - double var6 = 0; - double var8 = 0; - - if (var4 < -var2) - { - var4 = -var2; - } - - if (var6 < -var2) - { - var6 = -var2; - } - - if (var8 < -var2) - { - var8 = -var2; - } - - if (var4 > var2) - { - var4 = var2; - } - - if (var6 > var2) - { - var6 = var2; - } - - if (var8 > var2) - { - var8 = var2; - } - - spawnPacket.f = (int) (var4 * 8000.0D); - spawnPacket.g = (int) (var6 * 8000.0D); - spawnPacket.h = (int) (var8 * 8000.0D); spawnPacket.l = watcher; @@ -459,7 +554,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity(); vehiclePacket.a = 0; vehiclePacket.b = spawnPacket.a; - vehiclePacket.c = entityId; + vehiclePacket.c = squidId >= 0 ? squidId : entityId; UtilPlayer.sendPacket(owner, vehiclePacket); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 7719eca3f..17c4200be 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -345,7 +345,10 @@ public class AntiHack extends MiniPlugin } //Auto-Kick - if (!handled && _clientManager.Get(player).GetRank() != Rank.YOUTUBE && _clientManager.Get(player).GetRank() != Rank.TWITCH) + if (!handled && + _clientManager.Get(player).GetRank() != Rank.YOUTUBE && + _clientManager.Get(player).GetRank() != Rank.YOUTUBE_SMALL && + _clientManager.Get(player).GetRank() != Rank.TWITCH) { player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 2f, 0.5f); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java index 3b24248d9..2ed930507 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/MountPage.java @@ -43,6 +43,14 @@ public class MountPage extends ShopPageBase if (slot == 26) slot = 28; } + + addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() + { + public void onClick(Player player, ClickType clickType) + { + getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); + } + }); } protected void addMount(Mount mount, int slot) @@ -76,12 +84,5 @@ public class MountPage extends ShopPageBase setItem(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), (mount.GetCost(CurrencyType.Coins) < 0 ? "" : "Purchase ") + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false)); } - addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() - { - public void onClick(Player player, ClickType clickType) - { - getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); - } - }); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 7494e9fa6..bb17d1e2f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -14,6 +14,7 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.disguise.DisguiseManager; import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.event.GadgetActivateEvent; import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.gadget.gadgets.ItemBatGun; import mineplex.core.gadget.gadgets.ItemCoinBomb; @@ -63,6 +64,7 @@ import mineplex.core.gadget.types.OutfitGadget.ArmorSlot; import mineplex.core.gadget.types.ParticleGadget; import mineplex.core.inventory.InventoryManager; import mineplex.core.mount.MountManager; +import mineplex.core.mount.event.MountActivateEvent; import mineplex.core.pet.PetManager; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; @@ -91,6 +93,7 @@ public class GadgetManager extends MiniPlugin private BlockRestore _blockRestore; private ProjectileManager _projectileManager; private AchievementManager _achievementManager; + private MountManager _mountManager; private NautHashMap> _gadgets; @@ -99,6 +102,7 @@ public class GadgetManager extends MiniPlugin private boolean _hideParticles = false; private int _activeItemSlot = 3; + private boolean _gadgetsEnabled = true; public GadgetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, MountManager mountManager, PetManager petManager, PreferencesManager preferencesManager, @@ -115,6 +119,7 @@ public class GadgetManager extends MiniPlugin _blockRestore = blockRestore; _projectileManager = projectileManager; _achievementManager = achievementManager; + _mountManager = mountManager; CreateGadgets(); } @@ -491,6 +496,40 @@ public class GadgetManager extends MiniPlugin return true; } + + public boolean isGadgetEnabled() + { + return _gadgetsEnabled; + } + + public void toggleGadgetEnabled() + { + setGadgetEnabled(!_gadgetsEnabled); + } + + public void setGadgetEnabled(boolean enabled) + { + if (_gadgetsEnabled != enabled) + { + _gadgetsEnabled = enabled; + DisableAll(); + _mountManager.DisableAll(); + } + } + + @EventHandler + public void GadgetActivate(GadgetActivateEvent event) + { + if (!_gadgetsEnabled) + event.setCancelled(true); + } + + @EventHandler + public void MountActivate(MountActivateEvent event) + { + if (!_gadgetsEnabled) + event.setCancelled(true); + } @EventHandler public void chissMeow(PlayerToggleSneakEvent event) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index 2253850cf..4b9d64684 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -19,10 +19,10 @@ public enum GameDisplay DragonEscapeTeams("Dragon Escape Teams", Material.DRAGON_EGG, (byte)0, GameCategory.TEAM_VARIANT, 11), DragonRiders("Dragon Riders", Material.DRAGON_EGG, (byte)0, GameCategory.ARCADE, 12), Dragons("Dragons", Material.ENDER_STONE, (byte)0, GameCategory.ARCADE, 13), - DragonsTeams("Dragons Teams", Material.ENDER_STONE, (byte)0, GameCategory.TEAM_VARIANT, 14), + DragonsTeams("Dragons Teams", Material.DRAGON_EGG, (byte)0, GameCategory.TEAM_VARIANT, 14), Draw("Draw My Thing", Material.BOOK_AND_QUILL, (byte)0, GameCategory.CLASSICS, 15), Evolution("Evolution", Material.EMERALD, (byte)0, GameCategory.ARCADE, 16), - Gravity("Gravity", Material.ENDER_PORTAL, (byte)0, GameCategory.EXTRA, 18), + Gravity("Gravity", Material.ENDER_PORTAL_FRAME, (byte)0, GameCategory.EXTRA, 18), Halloween("Halloween Horror", Material.PUMPKIN, (byte)0, GameCategory.CLASSICS, 19), HideSeek("Block Hunt", Material.GRASS, (byte)0, GameCategory.CLASSICS, 20), HoleInTheWall("Hole in the Wall", Material.STAINED_GLASS, (byte) 2, GameCategory.ARCADE, 52), @@ -64,6 +64,7 @@ public enum GameDisplay Skywars("Skywars", Material.FEATHER, (byte) 0, GameCategory.SURVIVAL, 52), SkywarsTeams("Skywars Teams", "Skywars", Material.FEATHER, (byte)0, GameCategory.TEAM_VARIANT, 53), MonsterMaze("Monster Maze", Material.ROTTEN_FLESH, (byte)0, GameCategory.ARCADE, 55), + MonsterLeague("Monster League", Material.MINECART, (byte)0, GameCategory.ARCADE, 56), Lobbers("Bomb Lobbers", Material.FIREBALL, (byte) 0, GameCategory.ARCADE, 54), @@ -71,6 +72,8 @@ public enum GameDisplay Minecraft_League("Minecraft League", Material.DIAMOND_SWORD, (byte)0, GameCategory.SURVIVAL, 57), + BouncyBalls("Bouncy Balls", Material.SLIME_BALL, (byte)0, GameCategory.ARCADE, 58), + Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999); String _name; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index 0936a669e..11887cd53 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -67,7 +67,7 @@ public class MessageManager extends MiniClientPlugin MessageHandler messageHandler = new MessageHandler(this); ServerCommandManager.getInstance().registerCommandType("AnnouncementCommand", AnnouncementCommand.class, - new AnnouncementHandler()); + new AnnouncementHandler(clientManager)); ServerCommandManager.getInstance().registerCommandType("RedisMessage", RedisMessage.class, messageHandler); ServerCommandManager.getInstance() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AnnounceCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AnnounceCommand.java index c82cdd800..cbdddc228 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AnnounceCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/commands/AnnounceCommand.java @@ -10,6 +10,7 @@ import mineplex.core.message.MessageManager; import mineplex.serverdata.commands.AnnouncementCommand; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.entity.Player; public class AnnounceCommand extends CommandBase @@ -22,13 +23,25 @@ public class AnnounceCommand extends CommandBase @Override public void Execute(Player caller, String[] args) { - if (args == null || args.length == 0) + if (args == null || args.length <= 1) { Plugin.Help(caller); } else { - new AnnouncementCommand(true, F.combine(args, 0, null, false)).publish(); + Rank rank = Rank.ALL; + + try + { + rank = Rank.valueOf(args[0]); + } + catch (IllegalArgumentException ex) + { + UtilPlayer.message(caller, F.main(Plugin.getName(), ChatColor.RED + "" + ChatColor.BOLD + "Invalid rank!")); + return; + } + + new AnnouncementCommand(true, rank.toString(), F.combine(args, 1, null, false)).publish(); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/redis/AnnouncementHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/message/redis/AnnouncementHandler.java index 81972dd76..6901ad162 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/redis/AnnouncementHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/redis/AnnouncementHandler.java @@ -1,5 +1,7 @@ package mineplex.core.message.redis; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -13,20 +15,41 @@ import org.bukkit.entity.Player; public class AnnouncementHandler implements CommandCallback { + private CoreClientManager _clientManager; + + public AnnouncementHandler(CoreClientManager clientManager) + { + _clientManager = clientManager; + } + public void run(ServerCommand command) { if (command instanceof AnnouncementCommand) { AnnouncementCommand announcementCommand = (AnnouncementCommand)command; - + + Rank rank; + try + { + rank = Rank.valueOf(announcementCommand.getRank()); + } + catch (Exception e) + { + e.printStackTrace(); + return; + } + String message = announcementCommand.getMessage(); - if (announcementCommand.getDisplayTitle()) - UtilTextMiddle.display(C.cYellow + "Announcement", message, 10, 120, 10); - for (Player player : Bukkit.getOnlinePlayers()) { - UtilPlayer.message(player, F.main("Announcement", C.cAqua + message)); + if (_clientManager.hasRank(player, rank)) + { + if (announcementCommand.getDisplayTitle()) + UtilTextMiddle.display(C.cYellow + "Announcement", message, 10, 120, 10, player); + + UtilPlayer.message(player, F.main("Announcement", C.cAqua + message)); + } } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonData.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonData.java index 8335ef029..1203bad95 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonData.java @@ -1,7 +1,7 @@ package mineplex.core.mount; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; +import java.util.ArrayList; +import java.util.List; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -13,12 +13,14 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.util.Vector; -public class DragonData +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; + +public class DragonData extends MountData { DragonMount Host; public EnderDragon Dragon; - public Player Rider; public Entity TargetEntity = null; @@ -31,9 +33,8 @@ public class DragonData public DragonData(DragonMount dragonMount, Player rider) { - Host = dragonMount; - - Rider = rider; + super(rider); + Host = dragonMount; Velocity = rider.getLocation().getDirection().setY(0).normalize(); Pitch = UtilAlg.GetPitch(rider.getLocation().getDirection()); @@ -51,25 +52,34 @@ public class DragonData Chicken = rider.getWorld().spawn(rider.getLocation(), Chicken.class); Dragon.setPassenger(Chicken); - Chicken.setPassenger(Rider); + Chicken.setPassenger(getOwner()); Bukkit.getServer().getScheduler().runTaskLater(Host.Manager.getPlugin(), new Runnable() { public void run() { - Chicken.setPassenger(Rider); + Chicken.setPassenger(getOwner()); } }, 10L); } public void Move() { - Rider.eject(); + getOwner().eject(); ((CraftEnderDragon)Dragon).getHandle().setTargetBlock(GetTarget().getBlockX(), GetTarget().getBlockY(), GetTarget().getBlockZ()); } public Location GetTarget() { - return Rider.getLocation().add(Rider.getLocation().getDirection().multiply(40)); + return getOwner().getLocation().add(getOwner().getLocation().getDirection().multiply(40)); + } + + @Override + public List getEntityParts() + { + List list = new ArrayList(); + list.add(Dragon); + list.add(Chicken); + return list; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonMount.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonMount.java index af1c1831e..9cf933aac 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonMount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/DragonMount.java @@ -5,7 +5,6 @@ import org.bukkit.entity.Player; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.disguise.disguises.DisguiseChicken; public class DragonMount extends Mount { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java index d8ec72939..d4267beec 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/HorseMount.java @@ -22,7 +22,7 @@ import org.bukkit.entity.Horse.Style; import org.bukkit.event.EventHandler; import org.bukkit.inventory.ItemStack; -public class HorseMount extends Mount +public class HorseMount extends Mount> { protected Color _color; protected Style _style; @@ -53,7 +53,7 @@ public class HorseMount extends Mount while (activeIterator.hasNext()) { Player player = activeIterator.next(); - Horse horse = _active.get(player); + Horse horse = _active.get(player).getEntity(); //Invalid (dead) if (!horse.isValid()) @@ -113,15 +113,16 @@ public class HorseMount extends Mount UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + ".")); //Store - _active.put(player, horse); + SingleEntityMountData mount = new SingleEntityMountData(player, horse); + _active.put(player, mount); } public void Disable(Player player) { - Horse horse = _active.remove(player); - if (horse != null) + SingleEntityMountData mount = _active.remove(player); + if (mount != null) { - horse.remove(); + mount.remove(); //Inform UtilPlayer.message(player, F.main("Mount", "You despawned " + F.elem(GetName()) + ".")); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/Mount.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/Mount.java index f9731fe6c..ad18c3cc8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/Mount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/Mount.java @@ -5,6 +5,7 @@ import java.util.HashSet; import org.bukkit.Bukkit; import org.bukkit.Material; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -18,7 +19,7 @@ import mineplex.core.common.util.UtilServer; import mineplex.core.mount.event.MountActivateEvent; import mineplex.core.shop.item.SalesPackageBase; -public abstract class Mount extends SalesPackageBase implements Listener +public abstract class Mount extends SalesPackageBase implements Listener { protected HashSet _owners = new HashSet(); protected HashMap _active = new HashMap(); @@ -51,8 +52,8 @@ public abstract class Mount extends SalesPackageBase implements Listener return; } - Manager.setActive(player, this); EnableCustom(player); + Manager.setActive(player, this); } public abstract void EnableCustom(Player player); @@ -97,4 +98,13 @@ public abstract class Mount extends SalesPackageBase implements Listener { return _owners.contains(player); } + + public T getMountData(Entity ent) + { + for(T data : GetActive().values()) + { + if(data.isPartOfMount(ent)) return data; + } + return null; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/MountData.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountData.java new file mode 100644 index 000000000..6c025dc0e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountData.java @@ -0,0 +1,43 @@ +package mineplex.core.mount; + +import java.util.List; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + +public abstract class MountData +{ + + protected Player _owner; + + public MountData(Player player) + { + _owner = player; + } + + public boolean isPartOfMount(Entity ent) + { + return getEntityParts().contains(ent); + } + + public abstract List getEntityParts(); + + public boolean ownsMount(Player p) + { + return _owner.equals(p); + } + + public Player getOwner() + { + return _owner; + } + + public void remove() + { + for(Entity e : getEntityParts()) + { + e.remove(); + } + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java index 78d19c59a..4de2d6666 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/MountManager.java @@ -3,6 +3,17 @@ package mineplex.core.mount; import java.util.ArrayList; import java.util.List; +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.plugin.java.JavaPlugin; + import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.blockrestore.BlockRestore; @@ -22,17 +33,6 @@ import mineplex.core.mount.types.MountTitan; import mineplex.core.mount.types.MountUndead; import mineplex.core.mount.types.MountZombie; -import org.bukkit.Material; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Horse; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.ItemSpawnEvent; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.plugin.java.JavaPlugin; - public class MountManager extends MiniPlugin { private CoreClientManager _clientManager; @@ -84,32 +84,30 @@ public class MountManager extends MiniPlugin } @EventHandler - public void HorseInteract(PlayerInteractEntityEvent event) + public void mountInteract(PlayerInteractAtEntityEvent event) + { + MountData mount = getMountData(event.getRightClicked()); + + if(mount == null) return; + + if(mount.ownsMount(event.getPlayer())) return; + + event.setCancelled(true); + + } + + @EventHandler + public void mountInteract(PlayerInteractEntityEvent event) { - if (!(event.getRightClicked() instanceof Horse)) - return; + MountData mount = getMountData(event.getRightClicked()); - boolean found = false; - for (Mount mount : _playerActiveMountMap.values()) - { - if (mount.GetActive().containsValue(event.getRightClicked())) - { - found = true; - break; - } - } + if(mount == null) return; - if (!found) - return; - - Player player = event.getPlayer(); - Horse horse = (Horse)event.getRightClicked(); + if(mount.ownsMount(event.getPlayer())) return; + + UtilPlayer.message(event.getPlayer(), F.main("Mount", "This is not your Mount!")); + event.setCancelled(true); - if (horse.getOwner() == null || !horse.getOwner().equals(player)) - { - UtilPlayer.message(player, F.main("Mount", "This is not your Mount!")); - event.setCancelled(true); - } } @EventHandler @@ -178,16 +176,28 @@ public class MountManager extends MiniPlugin { return _disguiseManager; } - - public boolean isMount(Entity ent) + + public MountData getMountData(Entity ent) { for (Mount mount : _playerActiveMountMap.values()) { - if (mount.GetActive().values().contains(ent)) - { - return true; - } + MountData data = mount.getMountData(ent); + if(data != null) return data; } - return false; + return null; + } + + public Mount getMount(Entity ent) + { + for (Mount mount : _playerActiveMountMap.values()) + { + if(mount.getMountData(ent) != null) return mount; + } + return null; + } + + public boolean isMount(Entity ent) + { + return getMount(ent) != null; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/SingleEntityMountData.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/SingleEntityMountData.java new file mode 100644 index 000000000..eab47b74c --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/SingleEntityMountData.java @@ -0,0 +1,35 @@ +package mineplex.core.mount; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + +public class SingleEntityMountData extends MountData +{ + + protected T Entity; + + public SingleEntityMountData(Player player, T ent) + { + super(player); + Entity = ent; + } + + @Override + public List getEntityParts() + { + List list = new ArrayList(); + list.add(Entity); + return list; + } + + public T getEntity() + { + return Entity; + } + + + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountCart.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountCart.java index c524acb9d..3abbf00e0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountCart.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountCart.java @@ -1,5 +1,6 @@ package mineplex.core.mount.types; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.Sound; @@ -18,23 +19,12 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.mount.Mount; import mineplex.core.mount.MountManager; +import mineplex.core.mount.SingleEntityMountData; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; - -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftMinecart; -import org.bukkit.entity.Minecart; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.vehicle.VehicleDamageEvent; - -public class MountCart extends Mount +public class MountCart extends Mount> { public MountCart(MountManager manager) { @@ -56,7 +46,7 @@ public class MountCart extends Mount //Remove other mounts Manager.DeregisterAll(player); - Minecart mount = player.getWorld().spawn(player.getLocation().add(0, 2, 0), Minecart.class); + SingleEntityMountData mount = new SingleEntityMountData(player, player.getWorld().spawn(player.getLocation().add(0, 2, 0), Minecart.class)); //Inform UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + ".")); @@ -67,7 +57,7 @@ public class MountCart extends Mount public void Disable(Player player) { - Minecart mount = _active.remove(player); + SingleEntityMountData mount = _active.remove(player); if (mount != null) { mount.remove(); @@ -85,14 +75,11 @@ public class MountCart extends Mount if (event.getRightClicked() == null) return; - if (!GetActive().containsKey(event.getPlayer())) - return; + SingleEntityMountData mount = GetActive().get(event.getPlayer()); - if (!GetActive().get(event.getPlayer()).equals(event.getRightClicked())) - { - UtilPlayer.message(event.getPlayer(), F.main("Mount", "This is not your Mount!")); - return; - } + if(mount == null) return; + + if(!mount.ownsMount(event.getPlayer())) return; event.getPlayer().leaveVehicle(); event.getPlayer().eject(); @@ -117,8 +104,10 @@ public class MountCart extends Mount return; //Bounce - for (Minecart cart : GetActive().values()) + for (SingleEntityMountData cartData : GetActive().values()) { + Minecart cart = cartData.getEntity(); + if (cart.getPassenger() == null) continue; @@ -137,8 +126,10 @@ public class MountCart extends Mount } //Collide - for (Minecart cart : GetActive().values()) + for (SingleEntityMountData cartData : GetActive().values()) { + Minecart cart = cartData.getEntity(); + if (cart.getPassenger() == null) continue; @@ -150,8 +141,9 @@ public class MountCart extends Mount if (!Recharge.Instance.usable(player, GetName() + " Collide")) continue; - for (Minecart other : GetActive().values()) + for (SingleEntityMountData otherData : GetActive().values()) { + Minecart other = otherData.getEntity(); if (other.equals(cart)) continue; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountFrost.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountFrost.java index e5b2d2bf8..e948ca9e3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountFrost.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountFrost.java @@ -9,11 +9,11 @@ import org.bukkit.event.EventHandler; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.mount.HorseMount; import mineplex.core.mount.MountManager; +import mineplex.core.mount.SingleEntityMountData; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -38,10 +38,12 @@ public class MountFrost extends HorseMount public void Trail(UpdateEvent event) { if (event.getType() == UpdateType.TICK) - for (Horse horse : GetActive().values()) - UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, horse.getLocation().add(0, 1, 0), - 0.25f, 0.25f, 0.25f, 0.1f, 4, - ViewDist.NORMAL, UtilServer.getPlayers()); + for (SingleEntityMountData horseData : GetActive().values()) + { + Horse horse = horseData.getEntity(); + UtilParticle.PlayParticleToAll(ParticleType.SNOW_SHOVEL, horse.getLocation().add(0, 1, 0), + 0.25f, 0.25f, 0.25f, 0.1f, 4, ViewDist.NORMAL); + } } // @EventHandler diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSheep.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSheep.java index e2982d6ab..c2697c771 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSheep.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSheep.java @@ -5,19 +5,19 @@ import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.entity.Horse; import org.bukkit.entity.Horse.Color; -import org.bukkit.entity.Player; import org.bukkit.entity.Horse.Style; import org.bukkit.entity.Horse.Variant; +import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.disguise.disguises.DisguiseBase; -import mineplex.core.disguise.disguises.DisguisePig; import mineplex.core.disguise.disguises.DisguiseSheep; import mineplex.core.mount.HorseMount; import mineplex.core.mount.MountManager; +import mineplex.core.mount.SingleEntityMountData; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; @@ -45,6 +45,7 @@ public class MountSheep extends HorseMount Manager.DeregisterAll(player); Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class); + SingleEntityMountData mount = new SingleEntityMountData(player, horse); horse.setOwner(player); horse.setMaxDomestication(1); @@ -59,7 +60,7 @@ public class MountSheep extends HorseMount UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + ".")); //Store - _active.put(player, horse); + _active.put(player, mount); } @EventHandler @@ -68,8 +69,10 @@ public class MountSheep extends HorseMount if (event.getType() != UpdateType.TICK) return; - for (Horse horse : GetActive().values()) + for (SingleEntityMountData horseData : GetActive().values()) { + Horse horse = horseData.getEntity(); + DisguiseBase base = Manager.getDisguiseManager().getDisguise(horse); if (base == null || !(base instanceof DisguiseSheep)) continue; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSlime.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSlime.java index 1dccbdad5..2a0b3831a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSlime.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSlime.java @@ -9,6 +9,7 @@ import org.bukkit.entity.Slime; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.util.Vector; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -18,11 +19,12 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.mount.Mount; import mineplex.core.mount.MountManager; +import mineplex.core.mount.SingleEntityMountData; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -public class MountSlime extends Mount +public class MountSlime extends Mount> { public MountSlime(MountManager manager) { @@ -44,10 +46,10 @@ public class MountSlime extends Mount //Remove other mounts Manager.DeregisterAll(player); - Slime mount = player.getWorld().spawn(player.getLocation(), Slime.class); - mount.setSize(2); + SingleEntityMountData mount = new SingleEntityMountData(player, player.getWorld().spawn(player.getLocation(), Slime.class)); + mount.getEntity().setSize(2); - mount.setCustomName(player.getName() + "'s " + GetName()); + mount.getEntity().setCustomName(player.getName() + "'s " + GetName()); //Inform UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + ".")); @@ -58,7 +60,7 @@ public class MountSlime extends Mount public void Disable(Player player) { - Slime mount = _active.remove(player); + SingleEntityMountData mount = _active.remove(player); if (mount != null) { mount.remove(); @@ -79,11 +81,8 @@ public class MountSlime extends Mount if (!GetActive().containsKey(event.getPlayer())) return; - if (!GetActive().get(event.getPlayer()).equals(event.getRightClicked())) - { - UtilPlayer.message(event.getPlayer(), F.main("Mount", "This is not your Mount!")); + if(!GetActive().get(event.getPlayer()).ownsMount(event.getPlayer())) return; - } event.getPlayer().leaveVehicle(); event.getPlayer().eject(); @@ -108,10 +107,15 @@ public class MountSlime extends Mount return; //Bounce - for (Slime slime : GetActive().values()) + for (SingleEntityMountData slimeData : GetActive().values()) { + Slime slime = slimeData.getEntity(); + if (slime.getPassenger() == null) + { + UtilEnt.setFakeHead(slime, false); continue; + } if (!UtilEnt.isGrounded(slime)) continue; @@ -124,14 +128,19 @@ public class MountSlime extends Mount if (!Recharge.Instance.use(player, GetName(), 200, false, false)) continue; - UtilAction.velocity(slime, slime.getPassenger().getLocation().getDirection(), 1, true, 0, 0.4, 1, true); + Vector dir = slime.getPassenger().getLocation().getDirection(); + + UtilAction.velocity(slime, dir, 1, true, 0, 0.4, 1, true); + + UtilEnt.CreatureForceLook(slime, 0, UtilAlg.GetYaw(dir)); slime.getWorld().playSound(slime.getLocation(), Sound.SLIME_WALK, 1f, 0.75f); } //Collide - for (Slime slime : GetActive().values()) + for (SingleEntityMountData slimeData : GetActive().values()) { + Slime slime = slimeData.getEntity(); if (slime.getPassenger() == null) continue; @@ -143,8 +152,10 @@ public class MountSlime extends Mount if (!Recharge.Instance.usable(player, GetName() + " Collide")) continue; - for (Slime other : GetActive().values()) + for (SingleEntityMountData otherSlime : GetActive().values()) { + Slime other = otherSlime.getEntity(); + if (other.equals(slime)) continue; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSpider.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSpider.java index 3667a10d1..57ca4045b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSpider.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountSpider.java @@ -4,21 +4,6 @@ import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Map.Entry; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.disguise.disguises.DisguiseSpider; -import mineplex.core.mount.HorseMount; -import mineplex.core.mount.MountManager; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import net.minecraft.server.v1_8_R3.EntityLiving; - import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.block.Block; @@ -32,6 +17,22 @@ import org.bukkit.event.EventHandler; import org.bukkit.inventory.ItemStack; 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.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.disguise.disguises.DisguiseSpider; +import mineplex.core.mount.HorseMount; +import mineplex.core.mount.MountManager; +import mineplex.core.mount.SingleEntityMountData; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import net.minecraft.server.v1_8_R3.EntityLiving; + public class MountSpider extends HorseMount { /** @@ -87,7 +88,8 @@ public class MountSpider extends HorseMount UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + ".")); //Store - _active.put(player, horse); + SingleEntityMountData mount = new SingleEntityMountData(player, horse); + _active.put(player, mount); DisguiseSpider spider = new DisguiseSpider(horse); spider.setName(player.getName() + "'s Spider Mount"); @@ -105,7 +107,7 @@ public class MountSpider extends HorseMount ArrayList used = new ArrayList(); for (Player player : GetActive().keySet()) { - Horse horse = GetActive().get(player); + Horse horse = GetActive().get(player).getEntity(); used.add(horse); @@ -126,21 +128,24 @@ public class MountSpider extends HorseMount if (event.getType() != UpdateType.TICK) return; - for (Entry horse : GetActive().entrySet()) + for (Entry> entry : GetActive().entrySet()) { - if (horse.getValue().getPassenger() != horse.getKey()) + Player player = entry.getKey(); + Horse horse = entry.getValue().getEntity(); + + if (horse.getPassenger() != player) continue; //If player is looking up - if (horse.getKey().getEyeLocation().getPitch() > -45) + if (player.getEyeLocation().getPitch() > -45) continue; - for (Block block : UtilBlock.getSurrounding(horse.getValue().getLocation().getBlock(), true)) + for (Block block : UtilBlock.getSurrounding(horse.getLocation().getBlock(), true)) { if (UtilBlock.airFoliage(block) || block.isLiquid()) continue; - UtilAction.velocity(horse.getValue(), new Vector(horse.getValue().getVelocity().getX(), 0.2, horse.getValue().getVelocity().getZ())); + UtilAction.velocity(horse, new Vector(horse.getVelocity().getX(), 0.2, horse.getVelocity().getZ())); continue; } } @@ -191,7 +196,7 @@ public class MountSpider extends HorseMount for (Player player : GetActive().keySet()) { - final Horse horse = GetActive().get(player); + final Horse horse = GetActive().get(player).getEntity(); if (horse.getPassenger() != player) continue; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitan.java index 3611754a7..4001f5184 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitan.java @@ -1,27 +1,19 @@ package mineplex.core.mount.types; -import java.util.HashMap; - import org.bukkit.Material; -import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.Slime; -import org.bukkit.entity.Horse.Color; -import org.bukkit.entity.Horse.Style; -import org.bukkit.entity.Horse.Variant; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; 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.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerJoinEvent; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.mount.HorseMount; import mineplex.core.mount.Mount; import mineplex.core.mount.MountManager; import mineplex.core.updater.UpdateType; @@ -85,11 +77,20 @@ public class MountTitan extends Mount } @EventHandler - public void interactMount(PlayerInteractEntityEvent event) + public void interactMount(PlayerInteractAtEntityEvent event) { if (event.getRightClicked() == null) return; + for(MountTitanData mount : GetActive().values()) + { + if(mount.isPartOfMount(event.getRightClicked())) + { + event.setCancelled(true); + if(event.getRightClicked().getType() == EntityType.ARMOR_STAND) return; + } + } + if (!GetActive().containsKey(event.getPlayer())) return; @@ -123,7 +124,7 @@ public class MountTitan extends Mount { for (MountTitanData data : _active.values()) { - if (data.ownsEntity(event.getEntity())) + if (data.isPartOfMount(event.getEntity())) event.setCancelled(true); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java index 13868ca4d..137ae9bbe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountTitanData.java @@ -3,11 +3,7 @@ package mineplex.core.mount.types; import java.util.ArrayList; - -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; +import java.util.List; import org.bukkit.Location; import org.bukkit.Material; @@ -20,9 +16,13 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.util.EulerAngle; import org.bukkit.util.Vector; -public class MountTitanData +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.mount.MountData; + +public class MountTitanData extends MountData { - private String _owner; private Slime _head; @@ -30,7 +30,7 @@ public class MountTitanData public MountTitanData(Player player, String name) { - _owner = player.getName(); + super(player); Location loc = player.getLocation(); loc.setPitch(0); @@ -72,7 +72,11 @@ public class MountTitanData { //Head if (_head.getPassenger() != null) - _head.setVelocity(_head.getPassenger().getLocation().getDirection().multiply(0.8).add(new Vector(0,0.2,0))); + { + Vector dir = _head.getPassenger().getLocation().getDirection().multiply(0.8).add(new Vector(0,0.2,0)); + _head.setVelocity(dir); + UtilEnt.CreatureLook(_head, dir); + } Location infront = _head.getLocation().add(0, -1.5, 0); @@ -133,14 +137,13 @@ public class MountTitanData for (ArmorStand stand : _nodes) stand.remove(); } - - public boolean ownsMount(Player player) - { - return _owner.equals(player.getName()); - } - public boolean ownsEntity(Entity ent) + @Override + public List getEntityParts() { - return (_head.equals(ent) || _nodes.contains(ent)); + List entities = new ArrayList(); + entities.addAll(_nodes); + entities.add(_head); + return entities; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountUndead.java b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountUndead.java index ebe2216c5..3bf4bb80e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountUndead.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/mount/types/MountUndead.java @@ -1,15 +1,5 @@ package mineplex.core.mount.types; -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilParticle.ParticleType; -import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.common.util.UtilServer; -import mineplex.core.mount.HorseMount; -import mineplex.core.mount.MountManager; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; - import org.bukkit.Material; import org.bukkit.entity.Horse; import org.bukkit.entity.Horse.Color; @@ -17,6 +7,16 @@ import org.bukkit.entity.Horse.Style; import org.bukkit.entity.Horse.Variant; import org.bukkit.event.EventHandler; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.mount.HorseMount; +import mineplex.core.mount.MountManager; +import mineplex.core.mount.SingleEntityMountData; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; + public class MountUndead extends HorseMount { public MountUndead(MountManager manager) @@ -37,16 +37,20 @@ public class MountUndead extends HorseMount public void Trail(UpdateEvent event) { if (event.getType() == UpdateType.TICK) - for (Horse horse : GetActive().values()) - UtilParticle.PlayParticle(ParticleType.FLAME, horse.getLocation().add(0, 1, 0), - 0.25f, 0.25f, 0.25f, 0, 2, - ViewDist.NORMAL, UtilServer.getPlayers()); + for (SingleEntityMountData horseData : GetActive().values()) + { + Horse horse = horseData.getEntity(); + UtilParticle.PlayParticleToAll(ParticleType.FLAME, horse.getLocation().add(0, 1, 0), + 0.25f, 0.25f, 0.25f, 0, 2,ViewDist.NORMAL); + } if (event.getType() == UpdateType.FAST) - for (Horse horse : GetActive().values()) - UtilParticle.PlayParticle(ParticleType.LAVA, horse.getLocation().add(0, 1, 0), - 0.25f, 0.25f, 0.25f, 0, 1, - ViewDist.NORMAL, UtilServer.getPlayers()); + for (SingleEntityMountData horseData : GetActive().values()) + { + Horse horse = horseData.getEntity(); + UtilParticle.PlayParticleToAll(ParticleType.LAVA, horse.getLocation().add(0, 1, 0), + 0.25f, 0.25f, 0.25f, 0, 1, ViewDist.NORMAL); + } } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 4ae6eea74..4e16d3376 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -28,14 +28,12 @@ import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.disguises.DisguiseSlime; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.event.GadgetActivateEvent; import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.giveaway.GiveawayManager; import mineplex.core.hologram.HologramManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.message.PrivateMessageEvent; import mineplex.core.mount.MountManager; -import mineplex.core.mount.event.MountActivateEvent; import mineplex.core.notifier.NotificationManager; import mineplex.core.npc.NpcManager; import mineplex.core.packethandler.PacketHandler; @@ -119,7 +117,7 @@ import org.bukkit.scoreboard.Scoreboard; public class HubManager extends MiniClientPlugin { // ☃❅ Snowman! - public HubType Type = HubType.Normal; + public HubType Type = HubType.Christmas; private BlockRestore _blockRestore; private CoreClientManager _clientManager; @@ -161,9 +159,6 @@ public class HubManager extends MiniClientPlugin private HashMap> _creativeAdmin = new HashMap>(); - //Admin - private boolean _gadgetsEnabled = true; - public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, GiveawayManager giveawayManager) { super("Hub Manager", plugin); @@ -267,50 +262,6 @@ public class HubManager extends MiniClientPlugin return true; } - - @EventHandler - public void SnowballPickup(BlockDamageEvent event) - { - if (Type != HubType.Christmas) - return; - - if (event.getBlock().getType() != Material.SNOW) - return; - - Player player = event.getPlayer(); - - _gadgetManager.RemoveItem(player); - - player.getInventory().setItem(3, new ItemStack(Material.SNOW_BALL, 16)); - } - - @EventHandler - public void SnowballHit(CustomDamageEvent event) - { - if (Type != HubType.Christmas) - return; - - Projectile proj = event.GetProjectile(); - if (proj == null) return; - - if (!(proj instanceof Snowball)) - return; - - event.SetCancelled("Snowball Cancel"); - - if (BumpDisabled(event.GetDamageeEntity())) - return; - - if (BumpDisabled(event.GetDamagerEntity(true))) - return; - - UtilAction.velocity(event.GetDamageeEntity(), UtilAlg.getTrajectory2d(event.GetDamagerEntity(true), event.GetDamageeEntity()), - 0.4, false, 0, 0.2, 1, false); - - //No Portal - SetPortalDelay(event.GetDamageeEntity()); - } - @EventHandler public void redirectStopCommand(PlayerCommandPreprocessEvent event) { @@ -663,39 +614,6 @@ public class HubManager extends MiniClientPlugin if (_scoreboardTick != 0) return; -// int bestPig = 0; -// for (Player player : UtilServer.getPlayers()) -// { -// if (player.getVehicle() != null) -// continue; -// -// int count = 0; -// -// Entity ent = player; -// while (ent.getPassenger() != null) -// { -// ent = ent.getPassenger(); -// count++; -// } -// -// if (count > bestPig) -// { -// _pigStacker = player.getName(); -// bestPig = count; -// } -// } -// if (bestPig == 0) -// { -// _pigStacker = "0 - Nobody"; -// } -// else -// { -// _pigStacker = bestPig + " - " + _pigStacker; -// -// if (_pigStacker.length() > 16) -// _pigStacker = _pigStacker.substring(0, 16); -// } - for (Player player : UtilServer.getPlayers()) { //Dont Waste Time @@ -913,12 +831,6 @@ public class HubManager extends MiniClientPlugin event.SetCancelled(true); } - public boolean IsGadgetEnabled() - { - return _gadgetsEnabled; - } - - public NewsManager GetNewsManager() { return _news; @@ -935,30 +847,15 @@ public class HubManager extends MiniClientPlugin public void ToggleGadget(Player caller) { - _gadgetsEnabled = !_gadgetsEnabled; + toggleGadget(); + } - if (!_gadgetsEnabled) - { - GetMount().DisableAll(); - GetGadget().DisableAll(); - } + public void toggleGadget() + { + GetGadget().toggleGadgetEnabled(); for (Player player : UtilServer.getPlayers()) - player.sendMessage(C.cWhite + C.Bold + "Gadgets/Mounts are now " + F.elem(_gadgetsEnabled ? C.cGreen + C.Bold + "Enabled" : C.cRed + C.Bold + "Disabled")); - } - - @EventHandler - public void GadgetActivate(GadgetActivateEvent event) - { - if (!_gadgetsEnabled) - event.setCancelled(true); - } - - @EventHandler - public void MountActivate(MountActivateEvent event) - { - if (!_gadgetsEnabled) - event.setCancelled(true); + player.sendMessage(C.cWhite + C.Bold + "Gadgets/Mounts are now " + F.elem(GetGadget().isGadgetEnabled() ? C.cGreen + C.Bold + "Enabled" : C.cRed + C.Bold + "Disabled")); } public void addGameMode(Player caller, Player target) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java index 1d55d9f03..6fbe6ccec 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java @@ -238,7 +238,6 @@ public class SoccerManager extends MiniPlugin if (UtilAlg.inBoundingBox(_ball.getLocation(), _cornerRedGoalA, _cornerRedGoalB) && !UtilAlg.inBoundingBox(_ball.getLocation(), _cornerFieldA, _cornerFieldB)) { - _insideGoalTicks++; if (_insideGoalTicks > 3) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java index 094c43bec..bf5b654ea 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java @@ -14,7 +14,7 @@ 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.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.util.Vector; @@ -24,9 +24,9 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.event.StackerEvent; import mineplex.core.gadget.gadgets.MorphBlock; import mineplex.core.gadget.types.GadgetType; @@ -54,7 +54,7 @@ public class StackerManager extends MiniPlugin implements IThrown } @EventHandler - public void GrabEntity(PlayerInteractEntityEvent event) + public void GrabEntity(PlayerInteractAtEntityEvent event) { if (event.isCancelled()) return; @@ -62,7 +62,10 @@ public class StackerManager extends MiniPlugin implements IThrown Entity stackee = event.getRightClicked(); if (stackee == null) return; - + + if(Manager.GetMount().isMount(stackee)) + return; + if (!(stackee instanceof LivingEntity)) return; diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java index b8181bf50..a6a4c2880 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/GameType.java @@ -39,6 +39,7 @@ public enum GameType MineStrike("MineStrike"), MineWare("MineWare"), MilkCow("Milk the Cow"), + MonsterLeague("MonsterLeague"), MonsterMaze("Monster Maze"), Paintball("Super Paintball"), Quiver("One in the Quiver"), diff --git a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java index d60c22a9a..af1525e2a 100644 --- a/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java +++ b/Plugins/Mineplex.Minecraft.Game.Core/src/mineplex/minecraft/game/core/damage/DamageManager.java @@ -378,7 +378,7 @@ public class DamageManager extends MiniPlugin event.GetDamageeEntity().playEffect(EntityEffect.HURT); //Sticky Arrow - if (event.GetCause() == DamageCause.PROJECTILE) + if (event.GetCause() == DamageCause.PROJECTILE && event.GetProjectile() != null && event.GetProjectile() instanceof Arrow) ((CraftLivingEntity)event.GetDamageeEntity()).getHandle().o(((CraftLivingEntity)event.GetDamageeEntity()).getHandle().bv() + 1); //Knockback diff --git a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/AnnouncementCommand.java b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/AnnouncementCommand.java index d7c8d87d6..ebb8804ac 100644 --- a/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/AnnouncementCommand.java +++ b/Plugins/Mineplex.ServerData/src/mineplex/serverdata/commands/AnnouncementCommand.java @@ -4,14 +4,17 @@ package mineplex.serverdata.commands; public class AnnouncementCommand extends ServerCommand { private boolean _displayTitle; + private String _rank; private String _message; public boolean getDisplayTitle() { return _displayTitle; } + public String getRank() { return _rank; } public String getMessage() { return _message; } - public AnnouncementCommand(boolean displayTitle, String message) + public AnnouncementCommand(boolean displayTitle, String rank, String message) { _displayTitle = displayTitle; + _rank = rank; _message = message; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 531df19d4..a29c226fe 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -24,6 +24,7 @@ import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.creature.Creature; @@ -1236,6 +1237,25 @@ public class ArcadeManager extends MiniPlugin implements IRelation } } + @EventHandler + public void disableGadget(PlayerJoinEvent event) + { + updateGadgetEnabled(); + } + + @EventHandler + public void disableGadget(PlayerQuitEvent event) + { + updateGadgetEnabled(); + } + + private void updateGadgetEnabled() + { + // Disables gadgets if player count is greater than 40 + int playerCount = UtilServer.getPlayers().length; + getCosmeticManager().getGadgetManager().setGadgetEnabled(playerCount <= 40); + } + /*public void saveBasicStats(final Game game) { if (!IsTournamentServer()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index 330b5f5eb..89c420812 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -8,6 +8,7 @@ import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.games.baconbrawl.BaconBrawl; import nautilus.game.arcade.game.games.barbarians.Barbarians; import nautilus.game.arcade.game.games.bossbattles.BossBattles; +import nautilus.game.arcade.game.games.bouncyballs.BouncyBalls; import nautilus.game.arcade.game.games.bridge.Bridge; import nautilus.game.arcade.game.games.build.Build; import nautilus.game.arcade.game.games.cards.Cards; @@ -36,6 +37,7 @@ import nautilus.game.arcade.game.games.milkcow.MilkCow; import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague; import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.mineware.MineWare; +import nautilus.game.arcade.game.games.monsterleague.MonsterLeague; import nautilus.game.arcade.game.games.monstermaze.MonsterMaze; import nautilus.game.arcade.game.games.oldmineware.OldMineWare; import nautilus.game.arcade.game.games.paintball.Paintball; @@ -127,6 +129,9 @@ public enum GameType Skywars(SoloSkywars.class, GameDisplay.Skywars), SkywarsTeams(TeamSkywars.class, GameDisplay.SkywarsTeams, new GameType[]{GameType.Skywars}, false), MonsterMaze(MonsterMaze.class, GameDisplay.MonsterMaze), + MonsterLeague(MonsterLeague.class, GameDisplay.MonsterLeague), + + BouncyBalls(BouncyBalls.class, GameDisplay.BouncyBalls), Event(EventGame.class, GameDisplay.Event, new GameType[]{ GameType.BaconBrawl, GameType.Barbarians, GameType.Bridge, GameType.Build, GameType.Build, diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/KitUnlockCommand.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/KitUnlockCommand.java index cae387d71..443ae6bb9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/KitUnlockCommand.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/command/KitUnlockCommand.java @@ -10,7 +10,7 @@ public class KitUnlockCommand extends CommandBase { public KitUnlockCommand(ArcadeManager plugin) { - super(plugin, Rank.OWNER, new Rank[] {Rank.YOUTUBE, Rank.TWITCH, Rank.JNR_DEV}, new String[] {"youtube", "twitch", "kits"}); + super(plugin, Rank.OWNER, new Rank[] {Rank.YOUTUBE, Rank.YOUTUBE_SMALL, Rank.TWITCH, Rank.JNR_DEV}, new String[] {"youtube", "twitch", "kits"}); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index b04923415..c89ac87cd 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -302,6 +302,8 @@ public abstract class Game implements Listener public boolean DeadBodiesDeath = true; public int DeadBodiesExpire = -1; + public boolean FixSpawnFacing = true; + private IPacketHandler _useEntityPacketHandler; private int _deadBodyCount; private NautHashMap _deadBodies = new NautHashMap(); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java index 6527ec0ea..ddbd4f68c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/GameTeam.java @@ -113,12 +113,15 @@ public class GameTeam private Location fixFacing(Location loc) { - float yaw = UtilAlg.GetYaw(UtilAlg.getTrajectory2d(loc, Host.GetSpectatorLocation())); - - yaw = (int) (yaw / 90) * 90; - - loc = loc.clone(); - loc.setYaw(yaw); + if (Host.FixSpawnFacing) + { + float yaw = UtilAlg.GetYaw(UtilAlg.getTrajectory2d(loc, Host.GetSpectatorLocation())); + + yaw = (int) (yaw / 90) * 90; + + loc = loc.clone(); + loc.setYaw(yaw); + } return loc; } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/Ball.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/Ball.java new file mode 100644 index 000000000..5b901bc62 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/Ball.java @@ -0,0 +1,418 @@ +package nautilus.game.arcade.game.games.monsterleague; + +import java.util.ArrayList; +import java.util.HashMap; + +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.recharge.Recharge; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.monsterleague.kits.LeagueKit; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.EntityEffect; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.entity.Slime; +import org.bukkit.util.Vector; + +import sun.rmi.runtime.Log; + +public class Ball +{ + private MonsterLeague _host; + + private Location _ballSpawn; + + private Slime _ball; + private Vector _ballVel; + + private boolean _firstSpawn = true; + + private long _ballDeadTime = -1; + + private GameTeam _lastKickTeam = null; + private ArrayList _kickHistory = new ArrayList(); + + //Kick + protected int _kickTickDelay = 0; + + //Particle + protected Location _lastParticle = null; + + //Ball Rebound + protected boolean _ignoreReboundForTick = false; + protected Location _lastLoc = null; + + protected int _reboundX = 0; + protected int _reboundY = 0; + protected int _reboundZ = 0; + + public Ball(MonsterLeague monsterLeague, Location ballSpawn) + { + _host = monsterLeague; + + _ballSpawn = ballSpawn; + } + + private void changeBallVelocity(Vector vel, boolean canGoNegativeY) + { + _ballVel = vel; + + if (!canGoNegativeY && UtilEnt.isGrounded(_ball) && _ballVel.getY() <= 0) + _ballVel.setY(0); + + _ballVel.setY(Math.min(_ballVel.getY(), 1)); + + //Rebound Data + _lastLoc = _ball.getLocation(); + } + + public void update() + { + //New Ball Needed + checkNewBallNeeded(); + + //Spawn Ball + spawnBallUpdate(); + + if (_ball == null) + return; + + //Particles + displayParticles(); + + //Kick + kickBallUpdate(); + + //Movement/Rebounds/etc + ballPhysics(); + + //Goal + scoreGoalUpdate(); + } + + private void checkNewBallNeeded() + { + if (_ballDeadTime == -1 && (_ball == null || !_ball.isValid())) + { + if (_ball != null) + _ball.remove(); + + _ballDeadTime = System.currentTimeMillis(); + } + } + + private void displayParticles() + { + if (_lastKickTeam == null) + { + _lastParticle = _ball.getLocation(); + return; + } + + while (UtilMath.offset(_ball.getLocation().add(0, 0.5, 0), _lastParticle) > 0.15) + { + _lastParticle.add(UtilAlg.getTrajectory(_lastParticle, _ball.getLocation().add(0,0.5,0)).multiply(0.15)); + + if (_lastKickTeam.GetColor() == ChatColor.AQUA) + { + UtilParticle.PlayParticle(ParticleType.RED_DUST, _lastParticle, -1, 1, 1, 1, 0, + ViewDist.MAX, UtilServer.getPlayers()); + } + else if (_lastKickTeam.GetColor() == ChatColor.RED) + { + UtilParticle.PlayParticle(ParticleType.RED_DUST, _lastParticle, 0, 0, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); + } + else if (_lastKickTeam.GetColor() == ChatColor.GREEN) + { + UtilParticle.PlayParticle(ParticleType.RED_DUST, _lastParticle, 0, 1, 0, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); + } + else if (_lastKickTeam.GetColor() == ChatColor.YELLOW) + { + UtilParticle.PlayParticle(ParticleType.RED_DUST, _lastParticle, -1, 1, -1, 0, 1, + ViewDist.MAX, UtilServer.getPlayers()); + } + } + } + + private void spawnBallUpdate() + { + if (_ballDeadTime > 0 && (_firstSpawn || UtilTime.elapsed(_ballDeadTime, 6000))) + { + //Spawn + _host.CreatureAllowOverride = true; + _ball = _ballSpawn.getWorld().spawn(_ballSpawn, Slime.class); + _ball.setSize(2); + + UtilEnt.Vegetate(_ball); + UtilEnt.ghost(_ball, false, false); + _host.CreatureAllowOverride = false; + + _lastParticle = _ball.getLocation(); + + //Set Ball to Alive + _ballDeadTime = -1; + + //Velocity Downwards + changeBallVelocity(new Vector(0,-0.1,0), true); + + //Effect + UtilFirework.playFirework(_ballSpawn, Type.BALL, Color.WHITE, true, true); + + _firstSpawn = false; + } + } + + private void kickBallUpdate() + { + if (_kickTickDelay > 0) + { + _kickTickDelay--; + return; + } + + for (Player player : _host.GetPlayers(true)) + { + if (UtilMath.offset(player, _ball) < 1.5 || + UtilMath.offset(player.getEyeLocation(), _ball.getLocation()) < 1.25) + { + if (Recharge.Instance.use(player, "Football Kick", 600, false, false)) + { + //Kick Power + LeagueKit kit = (LeagueKit)_host.GetKit(player); + + //Set Ball Velocity + changeBallVelocity(player.getLocation().getDirection().multiply(kit.getKickPower()).add(new Vector(0, 0.4, 0)), false); + + //Sound + _ball.getWorld().playSound(_ball.getLocation(), Sound.ZOMBIE_WOOD, 0.5f, 1.5f); + + //Effect + UtilParticle.PlayParticle(ParticleType.SLIME, + _ball.getLocation(), + 0, 0, 0, 0, 5, ViewDist.NORMAL, UtilServer.getPlayers()); + + //Flash Ball + _ball.playEffect(EntityEffect.HURT); + + //Zero Player Vel + UtilAction.zeroVelocity(player); + + //Record + _lastKickTeam = _host.GetTeam(player); + _kickHistory.add(0, new KickLog(player, _lastKickTeam)); + + //Ignore Rebound + _ignoreReboundForTick = true; + + //This creates a small delay that no one else can kick it. + _kickTickDelay = 2; + + return; + } + } + } + } + + private void ballPhysics() + { + //Wind Drag + _ballVel = _ballVel.multiply(0.99); + + //Ground Drag + if (UtilEnt.isGrounded(_ball)) + _ballVel = _ballVel.multiply(0.97); + + if (!_ignoreReboundForTick) + { + double lenience = 0.1; + + //Rebound Y + if (_ballVel.getY() > 0.15 && _ball.getLocation().getY() <= _lastLoc.getY() || + _ballVel.getY() < -lenience && _ball.getLocation().getY() >= _lastLoc.getY()) + { + _reboundY++; + + if (_reboundY > 1) + { + _ballVel.setY(_ballVel.getY() * -1); + + _ballVel = _ballVel.multiply(_ballVel.getY() > 0 ? 0.9 : 0.75); //Lose extra when bouncing on ground. + + //Sound + _ball.getWorld().playSound(_ball.getLocation(), Sound.ZOMBIE_WOOD, 0.5f, 1.5f); + + //Effect + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, _ball.getLocation(), 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); + + _reboundY = 0; + } + } + else + { + _reboundY = 0; + } + + + if (UtilEnt.isGrounded(_ball)) + { + //lenience = 0.1; + } + + //Rebound X + if (_ballVel.getX() > lenience && _ball.getLocation().getX() <= _lastLoc.getX() || + _ballVel.getX() < -lenience && _ball.getLocation().getX() >= _lastLoc.getX()) + { + _reboundX++; + + if (_reboundX > 1) + { + _ballVel.setX(_ballVel.getX() * -1); + _ballVel = _ballVel.multiply(0.9); + + //Sound + _ball.getWorld().playSound(_ball.getLocation(), Sound.ZOMBIE_WOOD, 0.5f, 1.5f); + + //Effect + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, _ball.getLocation(), 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); + + _reboundX = 0; + } + } + else + { + _reboundX = 0; + } + + //Rebound Z + if (_ballVel.getZ() > lenience && _ball.getLocation().getZ() <= _lastLoc.getZ() || + _ballVel.getZ() < -lenience && _ball.getLocation().getZ() >= _lastLoc.getZ()) + { + _reboundZ++; + + if (_reboundZ > 1) + { + _ballVel.setZ(_ballVel.getZ() * -1); + _ballVel = _ballVel.multiply(0.9); + + //Sound + _ball.getWorld().playSound(_ball.getLocation(), Sound.ZOMBIE_WOOD, 0.5f, 1.5f); + + //Effect + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, _ball.getLocation(), 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); + + _reboundZ = 0; + } + } + else + { + _reboundZ = 0; + } + } + + //Gravity + if (!UtilEnt.isGrounded(_ball)) + _ballVel.setY(_ballVel.getY() - 0.04); + + //Store Current Location + _lastLoc = _ball.getLocation(); + + _ignoreReboundForTick = false; + + //Move Ball + _ball.setVelocity(_ballVel); + } + + private boolean scoreGoalUpdate() + { + for (GameTeam team : _host.GetTeamList()) + { + if (!_host.getGoalRegions().containsKey(team)) + continue; + + if (_host.getGoalRegions().get(team).contains(_ball.getLocation().getBlock())) + { + //Score + if (!_host.scoreGoal(team, this)) + return false; + + //Effect + UtilFirework.playFirework(_ball.getLocation(), Type.BALL, team.GetColorBase(), true, true); + + //Clean + _ball.remove(); + _ball = null; + + _lastLoc = null; + + _lastKickTeam = null; + _kickHistory.clear(); + + return true; + } + } + + return false; + } + + public Player getLastKickerNotOnTeam(GameTeam goalTeam) + { + for (KickLog log : _kickHistory) + { + if (log.Team.equals(goalTeam)) + continue; + + return log.Player; + } + + return _kickHistory.get(0).Player; + } + + public void arrowHit(LivingEntity ent, Projectile proj) + { + if (_ball != null && _ball.equals(ent)) + { + Player player = (Player)proj.getShooter(); + + changeBallVelocity(proj.getVelocity().multiply(0.6), true); + + //Sound + _ball.getWorld().playSound(_ball.getLocation(), Sound.ZOMBIE_WOOD, 0.5f, 1.5f); + + //Effect + UtilParticle.PlayParticle(ParticleType.SLIME, + _ball.getLocation(), + 0, 0, 0, 0, 5, ViewDist.NORMAL, UtilServer.getPlayers()); + + //Flash Ball + _ball.playEffect(EntityEffect.HURT); + + //Zero Player Vel + UtilAction.zeroVelocity(player); + + //Record + _lastKickTeam = _host.GetTeam(player); + _kickHistory.add(0, new KickLog(player, _lastKickTeam)); + + //Ignore Rebound + _ignoreReboundForTick = true; + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/KickLog.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/KickLog.java new file mode 100644 index 000000000..192590c20 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/KickLog.java @@ -0,0 +1,18 @@ +package nautilus.game.arcade.game.games.monsterleague; + +import nautilus.game.arcade.game.GameTeam; +import org.bukkit.entity.Player; + +public class KickLog +{ + Player Player; + GameTeam Team; + long Time; + + public KickLog(Player player, GameTeam team) + { + Player = player; + Team = team; + Time = System.currentTimeMillis(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/MonsterLeague.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/MonsterLeague.java new file mode 100644 index 000000000..adc100bb1 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/MonsterLeague.java @@ -0,0 +1,248 @@ +package nautilus.game.arcade.game.games.monsterleague; + +import java.util.ArrayList; +import java.util.HashMap; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Player; +import org.bukkit.entity.Slime; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.ProjectileHitEvent; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.monsterleague.kits.*; +import nautilus.game.arcade.kit.Kit; + +public class MonsterLeague extends TeamGame +{ + private HashMap> _teamGoalRegions = new HashMap>(); + private HashMap _teamScores = new HashMap(); + + private ArrayList _balls = new ArrayList(); + + private int _scoreToWin = 5; + + public MonsterLeague(ArcadeManager manager) + { + super(manager, GameType.MonsterLeague, + + new Kit[] + { + new KitSkeleton(manager), + new KitGolem(manager), + new KitEnderman(manager), + }, + + new String[] + { + "CHEESE IZ DELISH" + }); + + this.PrepareFreeze = false; + this.DamagePvP = false; + this.HungerSet = 20; + this.HealthSet = 20; + + this.DeathOut = false; + + this.TeamArmor = true; + this.TeamArmorHotbar = true; + } + + //Supports anywhere from 2-4 teams on a map + @Override + public void ParseData() + { + //parse200 56 73 14 129 + + //Scores + for (GameTeam team : GetTeamList()) + { + _teamScores.put(team, 0); + } + + //Red + if (GetTeam(ChatColor.RED) != null) + { + ArrayList goalBlocks = new ArrayList(); + + for (Location loc : WorldData.GetCustomLocs("" + Material.REDSTONE_ORE.getId())) + { + goalBlocks.add(loc.getBlock()); + loc.getBlock().setType(Material.AIR); + } + + _teamGoalRegions.put(GetTeam(ChatColor.RED), goalBlocks); + } + + //Blue + if (GetTeam(ChatColor.AQUA) != null) + { + ArrayList goalBlocks = new ArrayList(); + + for (Location loc : WorldData.GetCustomLocs("" + Material.DIAMOND_ORE.getId())) + { + goalBlocks.add(loc.getBlock()); + loc.getBlock().setType(Material.AIR); + } + + _teamGoalRegions.put(GetTeam(ChatColor.AQUA), goalBlocks); + } + + //Yellow + if (GetTeam(ChatColor.YELLOW) != null) + { + ArrayList goalBlocks = new ArrayList(); + + for (Location loc : WorldData.GetCustomLocs("" + Material.GOLD_ORE.getId())) + { + goalBlocks.add(loc.getBlock()); + loc.getBlock().setType(Material.AIR); + } + + _teamGoalRegions.put(GetTeam(ChatColor.YELLOW), goalBlocks); + } + + //Green + if (GetTeam(ChatColor.GREEN) != null) + { + ArrayList goalBlocks = new ArrayList(); + + for (Location loc : WorldData.GetCustomLocs("" + Material.EMERALD_ORE.getId())) + { + goalBlocks.add(loc.getBlock()); + loc.getBlock().setType(Material.AIR); + } + + _teamGoalRegions.put(GetTeam(ChatColor.GREEN), goalBlocks); + } + + //Support for multiple balls + _balls.add(new Ball(this, WorldData.GetDataLocs("GREEN").get(0))); + } + + @EventHandler + public void ballUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if(GetState() != GameState.Live) + return; + + for (Ball ball : _balls) + ball.update(); + } + + public boolean scoreGoal(final GameTeam goalOwnerTeam, final Ball ball) + { + Player lastKicker = ball.getLastKickerNotOnTeam(goalOwnerTeam); + GameTeam kickerTeam = GetTeam(lastKicker); + + //Dont allow self score (will only happen if NO ONE else kicked it) + if (kickerTeam.equals(goalOwnerTeam)) + return false; + + //Add Score + _teamScores.put(kickerTeam, 1 + _teamScores.get(kickerTeam)); + + //Against for 3+ teams + String against = ""; + if (GetTeamList().size() >= 3) + { + against = "against " + goalOwnerTeam.GetColor() + goalOwnerTeam.GetName() + ChatColor.RESET + " "; + } + + //Check Win + if (_teamScores.get(kickerTeam) > _scoreToWin) + { + SetCustomWinLine(kickerTeam.GetColor() + lastKicker.getName() + ChatColor.RESET + " scored the final goal " + against + "for " + kickerTeam.GetColor() + kickerTeam.GetName()); + + //Announce + AnnounceEnd(kickerTeam); + + for (GameTeam curTeam : GetTeamList()) + { + if (WinnerTeam != null && curTeam.equals(WinnerTeam)) + { + for (Player player : curTeam.GetPlayers(false)) + AddGems(player, 10, "Winning Team", false, false); + } + + for (Player player : curTeam.GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false, false); + } + + //End + SetState(GameState.End); + + return true; + } + + UtilTextMiddle.display("GOAL", + kickerTeam.GetColor() + lastKicker.getName() + C.cWhite + " scored " + against + "for " + kickerTeam.GetColor() + kickerTeam.GetName(), + 0, 80, 20, UtilServer.getPlayers()); + + Bukkit.getScheduler().runTaskLater(Manager.getPlugin(), new Runnable() + { + @Override + public void run() + { + String scores = ""; + + for (GameTeam team : GetTeamList()) + { + scores += "" + team.GetColor() + _teamScores.get(team) + ChatColor.RESET + " : "; + } + + if (scores.length() > 0) + scores = scores.substring(0, scores.length()-3); + + UtilTextMiddle.display("SCORES", + scores, + 0, 40, 20, UtilServer.getPlayers()); + } + }, 80); + + return true; + } + + public HashMap> getGoalRegions() + { + return _teamGoalRegions; + } + + @EventHandler + public void arrowDeflect(CustomDamageEvent event) + { + event.SetCancelled("NO DAMAGE"); + + if (!(event.GetDamageeEntity() instanceof Slime)) + return; + + if (event.GetProjectile() == null || !(event.GetProjectile() instanceof Arrow) || event.GetProjectile().getShooter() == null) + return; + + for (Ball ball : _balls) + { + ball.arrowHit(event.GetDamageeEntity(), event.GetProjectile()); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/kits/KitEnderman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/kits/KitEnderman.java new file mode 100644 index 000000000..20796f801 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/kits/KitEnderman.java @@ -0,0 +1,55 @@ +package nautilus.game.arcade.game.games.monsterleague.kits; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.disguise.disguises.DisguiseEnderman; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkBlink; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; + +public class KitEnderman extends LeagueKit +{ + public KitEnderman(ArcadeManager manager) + { + super(manager, "Enderman", KitAvailability.Free, 5000, + + new String[] + { + "Kick Power: 1.4", + }, + + new Perk[] + { + new PerkDoubleJump("Double Jump", 1, 1, true), + new PerkBlink("Blink", 32, 16000), + }, + EntityType.ENDERMAN, + new ItemStack(Material.AIR), 1.4); + + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.EYE_OF_ENDER, (byte)0, 1, + C.cYellow + C.Bold + "Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Blink")); +// +// //Disguise +// DisguiseEnderman disguise = new DisguiseEnderman(player); +// +// if (Manager.GetGame().GetTeam(player) != null) +// disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); +// else +// disguise.setName(player.getName()); +// +// disguise.setCustomNameVisible(true); +// Manager.GetDisguise().disguise(disguise); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/kits/KitGolem.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/kits/KitGolem.java new file mode 100644 index 000000000..9427e6ef2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/kits/KitGolem.java @@ -0,0 +1,57 @@ +package nautilus.game.arcade.game.games.monsterleague.kits; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.disguise.disguises.DisguiseIronGolem; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.monsterleague.perks.PerkStoneWall; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; +import nautilus.game.arcade.kit.perks.PerkSlow; + +public class KitGolem extends LeagueKit +{ + public KitGolem(ArcadeManager manager) + { + super(manager, "Golem", KitAvailability.Free, 5000, + + new String[] + { + "Kick Power: 1.8", + }, + + new Perk[] + { + new PerkDoubleJump("Double Jump", 0.8, 0.8, true), + new PerkStoneWall(), + new PerkSlow(0) + }, + EntityType.IRON_GOLEM, + new ItemStack(Material.AIR), 1.8); + + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_INGOT, (byte)0, 1, + C.cYellow + C.Bold + "Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Iron Wall")); +// +// //Disguise +// DisguiseIronGolem disguise = new DisguiseIronGolem(player); +// +// if (Manager.GetGame().GetTeam(player) != null) +// disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); +// else +// disguise.setName(player.getName()); +// +// disguise.setCustomNameVisible(true); +// Manager.GetDisguise().disguise(disguise); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/kits/KitSkeleton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/kits/KitSkeleton.java new file mode 100644 index 000000000..461cc10ad --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/kits/KitSkeleton.java @@ -0,0 +1,54 @@ +package nautilus.game.arcade.game.games.monsterleague.kits; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.disguise.disguises.DisguiseSkeleton; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkDoubleJump; +import nautilus.game.arcade.kit.perks.PerkFletcher; + +public class KitSkeleton extends LeagueKit +{ + public KitSkeleton(ArcadeManager manager) + { + super(manager, "Skeleton", KitAvailability.Free, 5000, + + new String[] + { + "Kick Power: 1", + }, + + new Perk[] + { + new PerkDoubleJump("Double Jump", 1.1, 1.1, true), + new PerkFletcher(12, 2, true), + }, + EntityType.SKELETON, + new ItemStack(Material.BOW), 1); + + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW, (byte)0, 1, C.cGreen + C.Bold + "Ball Shooter")); + +// //Disguise +// DisguiseSkeleton disguise = new DisguiseSkeleton(player); +// +// if (Manager.GetGame().GetTeam(player) != null) +// disguise.setName(Manager.GetGame().GetTeam(player).GetColor() + player.getName()); +// else +// disguise.setName(player.getName()); +// +// disguise.setCustomNameVisible(true); +// Manager.GetDisguise().disguise(disguise); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/kits/LeagueKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/kits/LeagueKit.java new file mode 100644 index 000000000..fdd6030d9 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/kits/LeagueKit.java @@ -0,0 +1,29 @@ +package nautilus.game.arcade.game.games.monsterleague.kits; + +import org.bukkit.entity.EntityType; +import org.bukkit.inventory.ItemStack; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +public abstract class LeagueKit extends Kit +{ + private double _kickPower; + + public LeagueKit(ArcadeManager manager, String name, + KitAvailability kitAvailability, int cost, String[] kitDesc, + Perk[] kitPerks, EntityType entityType, ItemStack itemInHand, + double kickPower) + { + super(manager, name, kitAvailability, cost, kitDesc, kitPerks, entityType, itemInHand); + + _kickPower = kickPower; + } + + public double getKickPower() + { + return _kickPower; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/perks/PerkBlink.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/perks/PerkBlink.java new file mode 100644 index 000000000..75e0654a9 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/perks/PerkBlink.java @@ -0,0 +1,119 @@ +package nautilus.game.arcade.game.games.monsterleague.perks; + +import org.bukkit.Color; +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.recharge.Recharge; +import nautilus.game.arcade.kit.SmashPerk; + +public class PerkBlink extends SmashPerk +{ + private double _range = 32; + private long _recharge = 24000; + + public PerkBlink(String name, double range, long recharge) + { + super("Blink", new String[] + { + C.cYellow + "Click" + C.cGray + " to use " + C.cGreen + "Blink" + }); + + _range = range; + _recharge = recharge; + } + + @EventHandler + public void Blink(PlayerInteractEvent event) + { + if (event.isCancelled()) + return; + + if (event.getAction() != Action.LEFT_CLICK_AIR && event.getAction() != Action.LEFT_CLICK_BLOCK && + event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + if (UtilBlock.usable(event.getClickedBlock())) + return; + + Player player = event.getPlayer(); + + if (isSuperActive(player)) + return; + + if (!Kit.HasKit(player)) + return; + + if (!Recharge.Instance.use(player, GetName(), _recharge, true, true)) + return; + + Recharge.Instance.setDisplayForce(player, GetName(), true); + + //Smoke Trail + Block lastSmoke = player.getLocation().getBlock(); + + double curRange = 0; + while (curRange <= _range) + { + Location newTarget = player.getLocation().add(new Vector(0,0.2,0)).add(player.getLocation().getDirection().multiply(curRange)); + + if (!UtilBlock.airFoliage(newTarget.getBlock()) || + !UtilBlock.airFoliage(newTarget.getBlock().getRelative(BlockFace.UP))) + break; + + //Progress Forwards + curRange += 0.2; + + //Smoke Trail + if (!lastSmoke.equals(newTarget.getBlock())) + { + lastSmoke.getWorld().playEffect(lastSmoke.getLocation(), Effect.SMOKE, 4); + } + + lastSmoke = newTarget.getBlock(); + } + + //Modify Range + curRange -= 0.4; + if (curRange < 0) + curRange = 0; + + //Destination + Location loc = player.getLocation().add(player.getLocation().getDirection().multiply(curRange).add(new Vector(0, 0.4, 0))); + + if (curRange > 0) + { + //Firework + UtilFirework.playFirework(player.getEyeLocation(), Type.BALL, Color.BLACK, false, false); + + player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1f, 1f); + player.teleport(loc); + player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1f, 1f); + + //Firework + UtilFirework.playFirework(player.getEyeLocation(), Type.BALL, Color.BLACK, false, false); + } + + + player.setFallDistance(0); + + //Inform + UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); + } +} + + diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/perks/PerkStoneWall.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/perks/PerkStoneWall.java new file mode 100644 index 000000000..90a678c6a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/monsterleague/perks/PerkStoneWall.java @@ -0,0 +1,111 @@ +package nautilus.game.arcade.game.games.monsterleague.perks; + +import java.util.HashSet; +import java.util.Iterator; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +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.UtilPlayer; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.data.IcePathData; + +public class PerkStoneWall extends Perk +{ + private HashSet _data = new HashSet(); + + public PerkStoneWall() + { + super("Iron Wall", new String[] + { + C.cYellow + "Click" + C.cGray + " to use " + C.cGreen + "Iron Wall" + }); + } + + @EventHandler + public void Skill(PlayerInteractEvent event) + { + if (event.isCancelled()) + return; + + if (event.getAction() != Action.LEFT_CLICK_AIR && event.getAction() != Action.LEFT_CLICK_BLOCK && + event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; + + if (UtilBlock.usable(event.getClickedBlock())) + return; + + Player player = event.getPlayer(); + + if (!Kit.HasKit(player)) + return; + + if (!Recharge.Instance.use(player, GetName(), 24000, true, true)) + return; + + Recharge.Instance.setDisplayForce(player, GetName(), true); + + //Get Player Direction + Vector dir = null; + + if (Math.abs(player.getLocation().getDirection().getX()) > Math.abs(player.getLocation().getDirection().getZ())) + { + if (player.getLocation().getDirection().getX() > 0) + { + dir = new Vector(1,0,0); + } + else + { + dir = new Vector(-1,0,0); + } + } + else + { + if (player.getLocation().getDirection().getZ() > 0) + { + dir = new Vector(0,0,1); + } + else + { + dir = new Vector(0,0,-1); + } + } + + for (int i=-2 ; i<=2 ; i++) + for (int j=-2 ; j<=2 ; j++) + { + if (Math.abs(i) == 2 && Math.abs(j) == 2) + continue; + + Location loc = player.getEyeLocation().add(player.getLocation().getDirection().multiply(3)); + loc.add(UtilAlg.getLeft(dir).multiply(i)); + loc.add(UtilAlg.getUp(dir).multiply(j)); + + Manager.GetBlockRestore().add(loc.getBlock(), Material.IRON_BLOCK.getId(), (byte)0, 4000); + + loc.getWorld().playEffect(loc, Effect.STEP_SOUND, Material.IRON_BLOCK); + } + + player.getWorld().playSound(player.getLocation(), Sound.IRONGOLEM_DEATH, 2f, 1f); + + //Inform + UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + ".")); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java index bf1e6ce2f..492f82da9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/snowfight/SnowFight.java @@ -13,15 +13,11 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilSound; -import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; -import mineplex.core.explosion.ExplosionEvent; -import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; @@ -35,8 +31,6 @@ import nautilus.game.arcade.game.games.snowfight.kits.KitTactician; import nautilus.game.arcade.game.games.snowfight.kits.KitMedic; import nautilus.game.arcade.game.games.snowfight.kits.KitSportsman; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.SmashKit; -import net.minecraft.server.v1_8_R3.EntityFireball; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -48,10 +42,7 @@ import org.bukkit.World; import org.bukkit.World.Environment; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftFireball; -import org.bukkit.entity.Egg; import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; import org.bukkit.entity.FallingBlock; import org.bukkit.entity.Fireball; import org.bukkit.entity.Player; @@ -59,31 +50,23 @@ import org.bukkit.entity.Projectile; import org.bukkit.entity.Snowball; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityRegainHealthEvent; -import org.bukkit.event.entity.ProjectileHitEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; -import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.potion.Potion; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -import org.bukkit.potion.PotionType; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.util.Vector; -import com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader.Array; public class SnowFight extends TeamGame { private HashMap _tiles; - private boolean _meteoroids; + private boolean _meteors; private boolean _peace; public SnowFight(ArcadeManager manager) @@ -99,8 +82,8 @@ public class SnowFight extends TeamGame new String[] { - "Just like... kill your enemies. with snow.", - "Be careful if you are on Ice your body will freeze" + "Defeat your foes with Snowballs", + "Last team alive wins!" }); this.HungerSet = 20; @@ -111,7 +94,7 @@ public class SnowFight extends TeamGame this.BlockPlace = true; this.BlockBreakAllow = new HashSet<>(Arrays.asList(Material.FENCE.getId())); this._tiles = new HashMap(); - this._meteoroids = false; + this._meteors = false; this._peace = false; } @@ -160,39 +143,42 @@ public class SnowFight extends TeamGame } @EventHandler - public void Meteor(UpdateEvent event) { - if(event.getType() != UpdateType.TWOSEC) + public void Meteor(UpdateEvent event) + { + if(event.getType() != UpdateType.FAST) return; - if(!IsLive()) + if (!IsLive()) return; - if(System.currentTimeMillis() <= getGameLiveTime() + (15 * 1000)) + if (System.currentTimeMillis() <= getGameLiveTime() + 10000) + { + UtilTextMiddle.display(C.cGreen + "Prepare", "Battle in " + UtilTime.MakeStr((getGameLiveTime() + 10000) - System.currentTimeMillis()), 0, 60, 20, UtilServer.getPlayers()); return; + } - if(!_peace) + if (!_peace) { for(Player player : GetPlayers(false)) - { player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1F, 1F); - UtilTextMiddle.display(C.cGold + C.Bold + "Peace Phase ended", "Kill your enemies", player); - } - this.Announce(C.cRed + C.Bold + "ALERT: " + ChatColor.RESET + C.Bold + "Peace Phase ended"); + + UtilTextMiddle.display(C.cRed + "FIGHT", "Throw your Snowballs!", 0, 60, 20, UtilServer.getPlayers()); + _peace = true; } if(System.currentTimeMillis() <= getGameLiveTime() + (195 * 1000)) return; - if(!_meteoroids) + if(!_meteors) { for(Player player : GetPlayers(false)) { player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1F, 1F); - UtilTextMiddle.display(C.cGold + C.Bold + "ICE METEOROIDS!!!", "Avoid the Ice Fields", player); + UtilTextMiddle.display(C.cAqua + C.Bold + "Ice Meteors", "Avoid the Ice Fields!", player); } - this.Announce(C.cRed + C.Bold + "ALERT: " + ChatColor.RESET + C.Bold + "METEOROIDS START FALLING!"); - _meteoroids = true; + + _meteors = true; } makeMeteor(); } @@ -345,12 +331,12 @@ public class SnowFight extends TeamGame // Lower if (height >= snowLevel) { - block.setTypeIdAndData(0, (byte) 0, true); + block.setTypeIdAndData(0, (byte) 0, false); SnowDecrease(block.getRelative(BlockFace.DOWN), height - snowLevel); } else { - block.setTypeIdAndData(78, (byte) (snowLevel - height - 1), true); + block.setTypeIdAndData(78, (byte) (snowLevel - height - 1), false); } } @@ -456,7 +442,7 @@ public class SnowFight extends TeamGame if (i++ % 6 == 0) { - fallingblock.getWorld().playSound(fallingblock.getLocation(), Sound.CAT_HISS, 1.3F, 0F); + fallingblock.getWorld().playSound(fallingblock.getLocation(), Sound.CAT_HISS, 0.7F, 0F); } } else @@ -498,10 +484,11 @@ public class SnowFight extends TeamGame explosion.setDropItems(false); explosion.setBlocksDamagedEqually(true); - UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, projectile.getLocation(), 1.0F, 1.0F, 1.0F, 1, 3, ViewDist.MAX, UtilServer.getPlayers()); - for(Player player : UtilServer.getPlayers()) { + //Effect + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, projectile.getLocation(), 0.5f, 0.5f, 0.5f, 0, 5, ViewDist.MAX, UtilServer.getPlayers()); + for(Player player : UtilServer.getPlayers()) player.playSound(projectile.getLocation(), Sound.EXPLODE, 1, 1); - } + boolean fall = true; @@ -510,7 +497,7 @@ public class SnowFight extends TeamGame if(player instanceof Player) { Player damagee = (Player) player; - Bukkit.getPluginManager().callEvent(new CustomDamageEvent(damagee, null, null, null, DamageCause.CUSTOM, damage, false, true, true, "Ice Meteoroid", "Ice Meteoroid", false)); + Bukkit.getPluginManager().callEvent(new CustomDamageEvent(damagee, null, null, null, DamageCause.CUSTOM, damage, false, true, true, "Ice Meteor", "Ice Meteor", false)); } } @@ -519,6 +506,7 @@ public class SnowFight extends TeamGame if(block.getType() != Material.AIR) { block.setType(Material.ICE); + if(block.getRelative(BlockFace.DOWN).getType() == Material.AIR) { // to reduce lag @@ -611,7 +599,7 @@ public class SnowFight extends TeamGame for (GameTeam team : this.GetTeamList()) { Scoreboard.Write(team.GetColor() + C.Bold + team.GetName()); - Scoreboard.Write(team.GetColor() + "Alive " + team.GetPlayers(true).size()); + Scoreboard.Write(team.GetColor() + "" + team.GetPlayers(true).size() + " Alive"); Scoreboard.WriteBlank(); } } @@ -620,16 +608,16 @@ public class SnowFight extends TeamGame if (time > 0) { - Scoreboard.Write(C.cYellow + C.Bold + "Meteoroids:"); + Scoreboard.Write(C.cYellow + C.Bold + "Meteors"); if(IsLive()) Scoreboard.Write(UtilTime.MakeStr(time, 0)); } else { - Scoreboard.Write(C.cGold + C.Bold + "Meteoroids!"); + Scoreboard.Write(C.cGold + C.Bold + "Meteors!"); } Scoreboard.Draw(); } - + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlink.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlink.java index 8d6e783c8..4890bc63e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlink.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBlink.java @@ -19,9 +19,9 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilPlayer; import mineplex.core.recharge.Recharge; -import nautilus.game.arcade.kit.SmashPerk; +import nautilus.game.arcade.kit.Perk; -public class PerkBlink extends SmashPerk +public class PerkBlink extends Perk { private String _name = ""; private double _range; @@ -29,7 +29,7 @@ public class PerkBlink extends SmashPerk public PerkBlink(String name, double range, long recharge) { - super("Leaper", new String[] + super("name", new String[] { C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + name }); @@ -45,23 +45,15 @@ public class PerkBlink extends SmashPerk if (event.isCancelled()) return; - if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) - return; + if (event.getAction() != Action.LEFT_CLICK_AIR && event.getAction() != Action.LEFT_CLICK_BLOCK && + event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) + return; if (UtilBlock.usable(event.getClickedBlock())) return; - if (event.getPlayer().getItemInHand() == null) - return; - - if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE")) - return; - Player player = event.getPlayer(); - if (isSuperActive(player)) - return; - if (!Kit.HasKit(player)) return;