Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex into alex-compvanilla

This commit is contained in:
AlexTheCoder 2015-12-06 03:51:08 -05:00
commit 4278f3fa99
47 changed files with 1820 additions and 477 deletions

View File

@ -26,7 +26,7 @@ public enum Rank
//Media //Media
YOUTUBE("YouTube", ChatColor.RED), YOUTUBE("YouTube", ChatColor.RED),
YOUTUBE_SMALL("MooTube", ChatColor.DARK_PURPLE), YOUTUBE_SMALL("Tuber", ChatColor.DARK_PURPLE),
TWITCH("Twitch", ChatColor.DARK_PURPLE), TWITCH("Twitch", ChatColor.DARK_PURPLE),
//Player //Player

View File

@ -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.CraftCreature;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftLivingEntity;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Creature; import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -803,6 +804,20 @@ public class UtilEnt
return null; 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) public static boolean inWater(LivingEntity ent)
{ {

View File

@ -19,13 +19,13 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_8_R3.DataWatcher.WatchableObject; 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.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity.EnumEntityUseAction; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity.EnumEntityUseAction;
import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity; import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityMetadata; 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.PacketPlayOutSpawnEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; 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 public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ {
private NautHashMap<String, NautHashMap<Integer, Integer>> _entityMap = new NautHashMap<String, NautHashMap<Integer, Integer>>(); private NautHashMap<String, NautHashMap<Integer, Integer[]>> _entityMap = new NautHashMap<String, NautHashMap<Integer, Integer[]>>();
private NautHashMap<String, NautHashMap<Integer, String>> _entityNameMap = new NautHashMap<String, NautHashMap<Integer, String>>(); private NautHashMap<String, NautHashMap<Integer, String>> _entityNameMap = new NautHashMap<String, NautHashMap<Integer, String>>();
private NautHashMap<String, NautHashMap<Integer, Integer>> _entityRiding = new NautHashMap<String, NautHashMap<Integer, Integer>>();
private HashSet<String> _loggedIn = new HashSet<String>(); private HashSet<String> _loggedIn = new HashSet<String>();
private HashSet<Integer> _ignoreSkulls = new HashSet<Integer>(); private HashSet<Integer> _ignoreSkulls = new HashSet<Integer>();
@ -63,7 +65,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
packetHandler.addPacketHandler(this, true, PacketPlayOutAttachEntity.class, PacketPlayOutEntityDestroy.class, packetHandler.addPacketHandler(this, true, PacketPlayOutAttachEntity.class, PacketPlayOutEntityDestroy.class,
PacketPlayOutEntityMetadata.class, PacketPlayOutSpawnEntity.class, PacketPlayOutSpawnEntityLiving.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_SURVIVALFLY, this);
NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this); NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this);
@ -75,6 +77,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ {
_entityMap.remove(event.getPlayer().getName()); _entityMap.remove(event.getPlayer().getName());
_entityNameMap.remove(event.getPlayer().getName()); _entityNameMap.remove(event.getPlayer().getName());
_entityRiding.remove(event.getPlayer().getName());
_loggedIn.remove(event.getPlayer()); _loggedIn.remove(event.getPlayer());
} }
@ -167,6 +170,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
iterator.remove(); iterator.remove();
_entityMap.remove(player); _entityMap.remove(player);
_entityNameMap.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())) if (owner.isOnline() && !_entityMap.containsKey(owner.getName()))
{ {
_entityMap.put(owner.getName(), new NautHashMap<Integer, Integer>()); _entityMap.put(owner.getName(), new NautHashMap<Integer, Integer[]>());
_entityNameMap.put(owner.getName(), new NautHashMap<Integer, String>()); _entityNameMap.put(owner.getName(), new NautHashMap<Integer, String>());
_loggedIn.add(owner.getName()); _loggedIn.add(owner.getName());
} }
@ -217,10 +221,15 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ {
if (_entityMap.get(owner.getName()).containsKey(spawnPacket.a)) if (_entityMap.get(owner.getName()).containsKey(spawnPacket.a))
{ {
UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(new int[] Integer[] ids = _entityMap.get(owner.getName()).get(spawnPacket.a);
{ int[] newIds = new int[ids.length];
_entityMap.get(owner.getName()).get(spawnPacket.a)
})); 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); _entityNameMap.get(owner.getName()).remove(spawnPacket.a);
_entityMap.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(); int newId = UtilEnt.getNewEntityId();
_entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName); _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<WatchableObject>) 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; break;
} }
} }
@ -247,7 +306,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ {
PacketPlayOutEntityMetadata metaPacket = (PacketPlayOutEntityMetadata) packet; 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); boolean isDisplaying = _entityMap.get(owner.getName()).containsKey(metaPacket.a);
String currentName = _entityNameMap.get(owner.getName()).get(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 name is still being displayed
if (newDisplay) if (newDisplay)
{ {
int newId; Integer[] newId;
if (isDisplaying) // Sending metadata if (isDisplaying) // Sending metadata
{ {
@ -288,22 +347,28 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
else else
// Spawning new entity // Spawning new entity
{ {
newId = UtilEnt.getNewEntityId(); newId = new Integer[]
{
UtilEnt.getNewEntityId()
};
_entityMap.get(owner.getName()).put(metaPacket.a, newId); _entityMap.get(owner.getName()).put(metaPacket.a, newId);
} }
sendProtocolPackets(owner, metaPacket.a, newId, newName, verifier, !isDisplaying);
_entityNameMap.get(owner.getName()).put(metaPacket.a, newName); _entityNameMap.get(owner.getName()).put(metaPacket.a, newName);
sendProtocolPackets(owner, metaPacket.a, newId[0], newName, verifier, !isDisplaying, -1);
} }
else else
{ // Lets delete it { // 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[] for (int a = 0; a < ids.length; a++)
{ {
id newIds[a] = ids[a];
})); }
verifier.bypassProcess(new PacketPlayOutEntityDestroy(newIds));
_entityMap.get(owner.getName()).remove(metaPacket.a); _entityMap.get(owner.getName()).remove(metaPacket.a);
_entityNameMap.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)) if (_entityMap.get(owner.getName()).containsKey(id))
{ {
UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(new int[] Integer[] ids = _entityMap.get(owner.getName()).get(id);
{ int[] newIds = new int[ids.length];
_entityMap.get(owner.getName()).get(id)
})); for (int a = 0; a < ids.length; a++)
{
newIds[a] = ids[a];
}
UtilPlayer.sendPacket(owner, new PacketPlayOutEntityDestroy(newIds));
_entityMap.get(owner.getName()).remove(id); _entityMap.get(owner.getName()).remove(id);
_entityNameMap.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; PacketPlayInUseEntity usePacket = (PacketPlayInUseEntity) packet;
for (Entry<Integer, Integer> entry : _entityMap.get(owner.getName()).entrySet()) loop:
{
if (entry.getValue() == usePacket.a)
{
PacketPlayInUseEntity newPacket = new PacketPlayInUseEntity();
newPacket.a = entry.getKey();
newPacket.action = usePacket.action == EnumEntityUseAction.ATTACK ? EnumEntityUseAction.ATTACK
: EnumEntityUseAction.INTERACT;
for (Entry<Integer, Integer[]> 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<Integer, Integer>());
}
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, 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); CustomTagEvent event = new CustomTagEvent(owner, entityId, entityName);
_plugin.getServer().getPluginManager().callEvent(event); _plugin.getServer().getPluginManager().callEvent(event);
@ -375,82 +505,47 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{ {
public void run() 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(1, Short.valueOf((short) 300));
watcher.a(2, ""); watcher.a(2, finalEntityName);
watcher.a(3, Byte.valueOf((byte) 0)); watcher.a(3, (byte) 1);
watcher.a(4, Byte.valueOf((byte) 0)); watcher.a(4, Byte.valueOf((byte) 0));
watcher.a(7, Integer.valueOf(0)); watcher.a(7, Integer.valueOf(0));
watcher.a(8, Byte.valueOf((byte) 0)); watcher.a(8, Byte.valueOf((byte) 0));
watcher.a(9, Byte.valueOf((byte) 0)); watcher.a(9, Byte.valueOf((byte) 0));
watcher.a(6, Float.valueOf(1.0F)); watcher.a(6, Float.valueOf(1.0F));
watcher.a(10, Byte.valueOf((byte) 0)); watcher.a(10, (byte) (0 | 0x1)); // Small
// 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));
if (newPacket) 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(); final PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving();
spawnPacket.a = newEntityId; spawnPacket.a = newEntityId;
spawnPacket.b = (byte) 30; 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; spawnPacket.l = watcher;
@ -459,7 +554,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity(); PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0; vehiclePacket.a = 0;
vehiclePacket.b = spawnPacket.a; vehiclePacket.b = spawnPacket.a;
vehiclePacket.c = entityId; vehiclePacket.c = squidId >= 0 ? squidId : entityId;
UtilPlayer.sendPacket(owner, vehiclePacket); UtilPlayer.sendPacket(owner, vehiclePacket);
} }

View File

@ -345,7 +345,10 @@ public class AntiHack extends MiniPlugin
} }
//Auto-Kick //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); player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 2f, 0.5f);

View File

@ -43,6 +43,14 @@ public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
if (slot == 26) if (slot == 26)
slot = 28; 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) protected void addMount(Mount<?> mount, int slot)
@ -76,12 +84,5 @@ public class MountPage extends ShopPageBase<CosmeticManager, CosmeticShop>
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)); 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));
}
});
} }
} }

View File

@ -14,6 +14,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.disguise.DisguiseManager; import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.event.GadgetActivateEvent;
import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.gadget.event.GadgetCollideEntityEvent;
import mineplex.core.gadget.gadgets.ItemBatGun; import mineplex.core.gadget.gadgets.ItemBatGun;
import mineplex.core.gadget.gadgets.ItemCoinBomb; 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.gadget.types.ParticleGadget;
import mineplex.core.inventory.InventoryManager; import mineplex.core.inventory.InventoryManager;
import mineplex.core.mount.MountManager; import mineplex.core.mount.MountManager;
import mineplex.core.mount.event.MountActivateEvent;
import mineplex.core.pet.PetManager; import mineplex.core.pet.PetManager;
import mineplex.core.preferences.PreferencesManager; import mineplex.core.preferences.PreferencesManager;
import mineplex.core.projectile.ProjectileManager; import mineplex.core.projectile.ProjectileManager;
@ -91,6 +93,7 @@ public class GadgetManager extends MiniPlugin
private BlockRestore _blockRestore; private BlockRestore _blockRestore;
private ProjectileManager _projectileManager; private ProjectileManager _projectileManager;
private AchievementManager _achievementManager; private AchievementManager _achievementManager;
private MountManager _mountManager;
private NautHashMap<GadgetType, List<Gadget>> _gadgets; private NautHashMap<GadgetType, List<Gadget>> _gadgets;
@ -99,6 +102,7 @@ public class GadgetManager extends MiniPlugin
private boolean _hideParticles = false; private boolean _hideParticles = false;
private int _activeItemSlot = 3; private int _activeItemSlot = 3;
private boolean _gadgetsEnabled = true;
public GadgetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, public GadgetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager,
MountManager mountManager, PetManager petManager, PreferencesManager preferencesManager, MountManager mountManager, PetManager petManager, PreferencesManager preferencesManager,
@ -115,6 +119,7 @@ public class GadgetManager extends MiniPlugin
_blockRestore = blockRestore; _blockRestore = blockRestore;
_projectileManager = projectileManager; _projectileManager = projectileManager;
_achievementManager = achievementManager; _achievementManager = achievementManager;
_mountManager = mountManager;
CreateGadgets(); CreateGadgets();
} }
@ -491,6 +496,40 @@ public class GadgetManager extends MiniPlugin
return true; 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 @EventHandler
public void chissMeow(PlayerToggleSneakEvent event) public void chissMeow(PlayerToggleSneakEvent event)

View File

@ -19,10 +19,10 @@ public enum GameDisplay
DragonEscapeTeams("Dragon Escape Teams", Material.DRAGON_EGG, (byte)0, GameCategory.TEAM_VARIANT, 11), DragonEscapeTeams("Dragon Escape Teams", Material.DRAGON_EGG, (byte)0, GameCategory.TEAM_VARIANT, 11),
DragonRiders("Dragon Riders", Material.DRAGON_EGG, (byte)0, GameCategory.ARCADE, 12), DragonRiders("Dragon Riders", Material.DRAGON_EGG, (byte)0, GameCategory.ARCADE, 12),
Dragons("Dragons", Material.ENDER_STONE, (byte)0, GameCategory.ARCADE, 13), 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), Draw("Draw My Thing", Material.BOOK_AND_QUILL, (byte)0, GameCategory.CLASSICS, 15),
Evolution("Evolution", Material.EMERALD, (byte)0, GameCategory.ARCADE, 16), 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), Halloween("Halloween Horror", Material.PUMPKIN, (byte)0, GameCategory.CLASSICS, 19),
HideSeek("Block Hunt", Material.GRASS, (byte)0, GameCategory.CLASSICS, 20), HideSeek("Block Hunt", Material.GRASS, (byte)0, GameCategory.CLASSICS, 20),
HoleInTheWall("Hole in the Wall", Material.STAINED_GLASS, (byte) 2, GameCategory.ARCADE, 52), 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), Skywars("Skywars", Material.FEATHER, (byte) 0, GameCategory.SURVIVAL, 52),
SkywarsTeams("Skywars Teams", "Skywars", Material.FEATHER, (byte)0, GameCategory.TEAM_VARIANT, 53), SkywarsTeams("Skywars Teams", "Skywars", Material.FEATHER, (byte)0, GameCategory.TEAM_VARIANT, 53),
MonsterMaze("Monster Maze", Material.ROTTEN_FLESH, (byte)0, GameCategory.ARCADE, 55), 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), 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), 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); Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999);
String _name; String _name;

View File

@ -67,7 +67,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
MessageHandler messageHandler = new MessageHandler(this); MessageHandler messageHandler = new MessageHandler(this);
ServerCommandManager.getInstance().registerCommandType("AnnouncementCommand", AnnouncementCommand.class, ServerCommandManager.getInstance().registerCommandType("AnnouncementCommand", AnnouncementCommand.class,
new AnnouncementHandler()); new AnnouncementHandler(clientManager));
ServerCommandManager.getInstance().registerCommandType("RedisMessage", RedisMessage.class, messageHandler); ServerCommandManager.getInstance().registerCommandType("RedisMessage", RedisMessage.class, messageHandler);
ServerCommandManager.getInstance() ServerCommandManager.getInstance()

View File

@ -10,6 +10,7 @@ import mineplex.core.message.MessageManager;
import mineplex.serverdata.commands.AnnouncementCommand; import mineplex.serverdata.commands.AnnouncementCommand;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class AnnounceCommand extends CommandBase<MessageManager> public class AnnounceCommand extends CommandBase<MessageManager>
@ -22,13 +23,25 @@ public class AnnounceCommand extends CommandBase<MessageManager>
@Override @Override
public void Execute(Player caller, String[] args) public void Execute(Player caller, String[] args)
{ {
if (args == null || args.length == 0) if (args == null || args.length <= 1)
{ {
Plugin.Help(caller); Plugin.Help(caller);
} }
else 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();
} }
} }
} }

View File

@ -1,5 +1,7 @@
package mineplex.core.message.redis; 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.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
@ -13,20 +15,41 @@ import org.bukkit.entity.Player;
public class AnnouncementHandler implements CommandCallback public class AnnouncementHandler implements CommandCallback
{ {
private CoreClientManager _clientManager;
public AnnouncementHandler(CoreClientManager clientManager)
{
_clientManager = clientManager;
}
public void run(ServerCommand command) public void run(ServerCommand command)
{ {
if (command instanceof AnnouncementCommand) if (command instanceof AnnouncementCommand)
{ {
AnnouncementCommand announcementCommand = (AnnouncementCommand)command; AnnouncementCommand announcementCommand = (AnnouncementCommand)command;
Rank rank;
try
{
rank = Rank.valueOf(announcementCommand.getRank());
}
catch (Exception e)
{
e.printStackTrace();
return;
}
String message = announcementCommand.getMessage(); String message = announcementCommand.getMessage();
if (announcementCommand.getDisplayTitle())
UtilTextMiddle.display(C.cYellow + "Announcement", message, 10, 120, 10);
for (Player player : Bukkit.getOnlinePlayers()) 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));
}
} }
} }
} }

View File

@ -1,7 +1,7 @@
package mineplex.core.mount; package mineplex.core.mount;
import mineplex.core.common.util.UtilAlg; import java.util.ArrayList;
import mineplex.core.common.util.UtilEnt; import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@ -13,12 +13,14 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; 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; DragonMount Host;
public EnderDragon Dragon; public EnderDragon Dragon;
public Player Rider;
public Entity TargetEntity = null; public Entity TargetEntity = null;
@ -31,9 +33,8 @@ public class DragonData
public DragonData(DragonMount dragonMount, Player rider) public DragonData(DragonMount dragonMount, Player rider)
{ {
Host = dragonMount; super(rider);
Host = dragonMount;
Rider = rider;
Velocity = rider.getLocation().getDirection().setY(0).normalize(); Velocity = rider.getLocation().getDirection().setY(0).normalize();
Pitch = UtilAlg.GetPitch(rider.getLocation().getDirection()); Pitch = UtilAlg.GetPitch(rider.getLocation().getDirection());
@ -51,25 +52,34 @@ public class DragonData
Chicken = rider.getWorld().spawn(rider.getLocation(), Chicken.class); Chicken = rider.getWorld().spawn(rider.getLocation(), Chicken.class);
Dragon.setPassenger(Chicken); Dragon.setPassenger(Chicken);
Chicken.setPassenger(Rider); Chicken.setPassenger(getOwner());
Bukkit.getServer().getScheduler().runTaskLater(Host.Manager.getPlugin(), new Runnable() Bukkit.getServer().getScheduler().runTaskLater(Host.Manager.getPlugin(), new Runnable()
{ {
public void run() public void run()
{ {
Chicken.setPassenger(Rider); Chicken.setPassenger(getOwner());
} }
}, 10L); }, 10L);
} }
public void Move() public void Move()
{ {
Rider.eject(); getOwner().eject();
((CraftEnderDragon)Dragon).getHandle().setTargetBlock(GetTarget().getBlockX(), GetTarget().getBlockY(), GetTarget().getBlockZ()); ((CraftEnderDragon)Dragon).getHandle().setTargetBlock(GetTarget().getBlockX(), GetTarget().getBlockY(), GetTarget().getBlockZ());
} }
public Location GetTarget() public Location GetTarget()
{ {
return Rider.getLocation().add(Rider.getLocation().getDirection().multiply(40)); return getOwner().getLocation().add(getOwner().getLocation().getDirection().multiply(40));
}
@Override
public List<Entity> getEntityParts()
{
List<Entity> list = new ArrayList<Entity>();
list.add(Dragon);
list.add(Chicken);
return list;
} }
} }

View File

@ -5,7 +5,6 @@ import org.bukkit.entity.Player;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguiseChicken;
public class DragonMount extends Mount<DragonData> public class DragonMount extends Mount<DragonData>
{ {

View File

@ -22,7 +22,7 @@ import org.bukkit.entity.Horse.Style;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class HorseMount extends Mount<Horse> public class HorseMount extends Mount<SingleEntityMountData<Horse>>
{ {
protected Color _color; protected Color _color;
protected Style _style; protected Style _style;
@ -53,7 +53,7 @@ public class HorseMount extends Mount<Horse>
while (activeIterator.hasNext()) while (activeIterator.hasNext())
{ {
Player player = activeIterator.next(); Player player = activeIterator.next();
Horse horse = _active.get(player); Horse horse = _active.get(player).getEntity();
//Invalid (dead) //Invalid (dead)
if (!horse.isValid()) if (!horse.isValid())
@ -113,15 +113,16 @@ public class HorseMount extends Mount<Horse>
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + ".")); UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
//Store //Store
_active.put(player, horse); SingleEntityMountData<Horse> mount = new SingleEntityMountData<Horse>(player, horse);
_active.put(player, mount);
} }
public void Disable(Player player) public void Disable(Player player)
{ {
Horse horse = _active.remove(player); SingleEntityMountData<Horse> mount = _active.remove(player);
if (horse != null) if (mount != null)
{ {
horse.remove(); mount.remove();
//Inform //Inform
UtilPlayer.message(player, F.main("Mount", "You despawned " + F.elem(GetName()) + ".")); UtilPlayer.message(player, F.main("Mount", "You despawned " + F.elem(GetName()) + "."));

View File

@ -5,6 +5,7 @@ import java.util.HashSet;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -18,7 +19,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.mount.event.MountActivateEvent; import mineplex.core.mount.event.MountActivateEvent;
import mineplex.core.shop.item.SalesPackageBase; import mineplex.core.shop.item.SalesPackageBase;
public abstract class Mount<T> extends SalesPackageBase implements Listener public abstract class Mount<T extends MountData> extends SalesPackageBase implements Listener
{ {
protected HashSet<Player> _owners = new HashSet<Player>(); protected HashSet<Player> _owners = new HashSet<Player>();
protected HashMap<Player, T> _active = new HashMap<Player, T>(); protected HashMap<Player, T> _active = new HashMap<Player, T>();
@ -51,8 +52,8 @@ public abstract class Mount<T> extends SalesPackageBase implements Listener
return; return;
} }
Manager.setActive(player, this);
EnableCustom(player); EnableCustom(player);
Manager.setActive(player, this);
} }
public abstract void EnableCustom(Player player); public abstract void EnableCustom(Player player);
@ -97,4 +98,13 @@ public abstract class Mount<T> extends SalesPackageBase implements Listener
{ {
return _owners.contains(player); return _owners.contains(player);
} }
public T getMountData(Entity ent)
{
for(T data : GetActive().values())
{
if(data.isPartOfMount(ent)) return data;
}
return null;
}
} }

View File

@ -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<Entity> getEntityParts();
public boolean ownsMount(Player p)
{
return _owner.equals(p);
}
public Player getOwner()
{
return _owner;
}
public void remove()
{
for(Entity e : getEntityParts())
{
e.remove();
}
}
}

View File

@ -3,6 +3,17 @@ package mineplex.core.mount;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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.MiniPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.blockrestore.BlockRestore; 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.MountUndead;
import mineplex.core.mount.types.MountZombie; 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 public class MountManager extends MiniPlugin
{ {
private CoreClientManager _clientManager; private CoreClientManager _clientManager;
@ -84,32 +84,30 @@ public class MountManager extends MiniPlugin
} }
@EventHandler @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)) MountData mount = getMountData(event.getRightClicked());
return;
boolean found = false; if(mount == null) return;
for (Mount mount : _playerActiveMountMap.values())
{
if (mount.GetActive().containsValue(event.getRightClicked()))
{
found = true;
break;
}
}
if (!found) if(mount.ownsMount(event.getPlayer())) return;
return;
UtilPlayer.message(event.getPlayer(), F.main("Mount", "This is not your Mount!"));
Player player = event.getPlayer(); event.setCancelled(true);
Horse horse = (Horse)event.getRightClicked();
if (horse.getOwner() == null || !horse.getOwner().equals(player))
{
UtilPlayer.message(player, F.main("Mount", "This is not your Mount!"));
event.setCancelled(true);
}
} }
@EventHandler @EventHandler
@ -178,16 +176,28 @@ public class MountManager extends MiniPlugin
{ {
return _disguiseManager; return _disguiseManager;
} }
public boolean isMount(Entity ent) public MountData getMountData(Entity ent)
{ {
for (Mount<?> mount : _playerActiveMountMap.values()) for (Mount<?> mount : _playerActiveMountMap.values())
{ {
if (mount.GetActive().values().contains(ent)) MountData data = mount.getMountData(ent);
{ if(data != null) return data;
return true;
}
} }
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;
} }
} }

View File

@ -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<T extends Entity> extends MountData
{
protected T Entity;
public SingleEntityMountData(Player player, T ent)
{
super(player);
Entity = ent;
}
@Override
public List<Entity> getEntityParts()
{
List<Entity> list = new ArrayList<Entity>();
list.add(Entity);
return list;
}
public T getEntity()
{
return Entity;
}
}

View File

@ -1,5 +1,6 @@
package mineplex.core.mount.types; package mineplex.core.mount.types;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -18,23 +19,12 @@ import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.mount.Mount; import mineplex.core.mount.Mount;
import mineplex.core.mount.MountManager; import mineplex.core.mount.MountManager;
import mineplex.core.mount.SingleEntityMountData;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
public class MountCart extends Mount<SingleEntityMountData<Minecart>>
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<Minecart>
{ {
public MountCart(MountManager manager) public MountCart(MountManager manager)
{ {
@ -56,7 +46,7 @@ public class MountCart extends Mount<Minecart>
//Remove other mounts //Remove other mounts
Manager.DeregisterAll(player); Manager.DeregisterAll(player);
Minecart mount = player.getWorld().spawn(player.getLocation().add(0, 2, 0), Minecart.class); SingleEntityMountData<Minecart> mount = new SingleEntityMountData<Minecart>(player, player.getWorld().spawn(player.getLocation().add(0, 2, 0), Minecart.class));
//Inform //Inform
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + ".")); UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
@ -67,7 +57,7 @@ public class MountCart extends Mount<Minecart>
public void Disable(Player player) public void Disable(Player player)
{ {
Minecart mount = _active.remove(player); SingleEntityMountData<Minecart> mount = _active.remove(player);
if (mount != null) if (mount != null)
{ {
mount.remove(); mount.remove();
@ -85,14 +75,11 @@ public class MountCart extends Mount<Minecart>
if (event.getRightClicked() == null) if (event.getRightClicked() == null)
return; return;
if (!GetActive().containsKey(event.getPlayer())) SingleEntityMountData<Minecart> mount = GetActive().get(event.getPlayer());
return;
if (!GetActive().get(event.getPlayer()).equals(event.getRightClicked())) if(mount == null) return;
{
UtilPlayer.message(event.getPlayer(), F.main("Mount", "This is not your Mount!")); if(!mount.ownsMount(event.getPlayer())) return;
return;
}
event.getPlayer().leaveVehicle(); event.getPlayer().leaveVehicle();
event.getPlayer().eject(); event.getPlayer().eject();
@ -117,8 +104,10 @@ public class MountCart extends Mount<Minecart>
return; return;
//Bounce //Bounce
for (Minecart cart : GetActive().values()) for (SingleEntityMountData<Minecart> cartData : GetActive().values())
{ {
Minecart cart = cartData.getEntity();
if (cart.getPassenger() == null) if (cart.getPassenger() == null)
continue; continue;
@ -137,8 +126,10 @@ public class MountCart extends Mount<Minecart>
} }
//Collide //Collide
for (Minecart cart : GetActive().values()) for (SingleEntityMountData<Minecart> cartData : GetActive().values())
{ {
Minecart cart = cartData.getEntity();
if (cart.getPassenger() == null) if (cart.getPassenger() == null)
continue; continue;
@ -150,8 +141,9 @@ public class MountCart extends Mount<Minecart>
if (!Recharge.Instance.usable(player, GetName() + " Collide")) if (!Recharge.Instance.usable(player, GetName() + " Collide"))
continue; continue;
for (Minecart other : GetActive().values()) for (SingleEntityMountData<Minecart> otherData : GetActive().values())
{ {
Minecart other = otherData.getEntity();
if (other.equals(cart)) if (other.equals(cart))
continue; continue;

View File

@ -9,11 +9,11 @@ import org.bukkit.event.EventHandler;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilParticle; 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.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist; import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.mount.HorseMount; import mineplex.core.mount.HorseMount;
import mineplex.core.mount.MountManager; import mineplex.core.mount.MountManager;
import mineplex.core.mount.SingleEntityMountData;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
@ -38,10 +38,12 @@ public class MountFrost extends HorseMount
public void Trail(UpdateEvent event) public void Trail(UpdateEvent event)
{ {
if (event.getType() == UpdateType.TICK) if (event.getType() == UpdateType.TICK)
for (Horse horse : GetActive().values()) for (SingleEntityMountData<Horse> horseData : GetActive().values())
UtilParticle.PlayParticle(ParticleType.SNOW_SHOVEL, horse.getLocation().add(0, 1, 0), {
0.25f, 0.25f, 0.25f, 0.1f, 4, Horse horse = horseData.getEntity();
ViewDist.NORMAL, UtilServer.getPlayers()); UtilParticle.PlayParticleToAll(ParticleType.SNOW_SHOVEL, horse.getLocation().add(0, 1, 0),
0.25f, 0.25f, 0.25f, 0.1f, 4, ViewDist.NORMAL);
}
} }
// @EventHandler // @EventHandler

View File

@ -5,19 +5,19 @@ import org.bukkit.DyeColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Horse; import org.bukkit.entity.Horse;
import org.bukkit.entity.Horse.Color; import org.bukkit.entity.Horse.Color;
import org.bukkit.entity.Player;
import org.bukkit.entity.Horse.Style; import org.bukkit.entity.Horse.Style;
import org.bukkit.entity.Horse.Variant; import org.bukkit.entity.Horse.Variant;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguisePig;
import mineplex.core.disguise.disguises.DisguiseSheep; import mineplex.core.disguise.disguises.DisguiseSheep;
import mineplex.core.mount.HorseMount; import mineplex.core.mount.HorseMount;
import mineplex.core.mount.MountManager; import mineplex.core.mount.MountManager;
import mineplex.core.mount.SingleEntityMountData;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
@ -45,6 +45,7 @@ public class MountSheep extends HorseMount
Manager.DeregisterAll(player); Manager.DeregisterAll(player);
Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class); Horse horse = player.getWorld().spawn(player.getLocation(), Horse.class);
SingleEntityMountData<Horse> mount = new SingleEntityMountData<Horse>(player, horse);
horse.setOwner(player); horse.setOwner(player);
horse.setMaxDomestication(1); horse.setMaxDomestication(1);
@ -59,7 +60,7 @@ public class MountSheep extends HorseMount
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + ".")); UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
//Store //Store
_active.put(player, horse); _active.put(player, mount);
} }
@EventHandler @EventHandler
@ -68,8 +69,10 @@ public class MountSheep extends HorseMount
if (event.getType() != UpdateType.TICK) if (event.getType() != UpdateType.TICK)
return; return;
for (Horse horse : GetActive().values()) for (SingleEntityMountData<Horse> horseData : GetActive().values())
{ {
Horse horse = horseData.getEntity();
DisguiseBase base = Manager.getDisguiseManager().getDisguise(horse); DisguiseBase base = Manager.getDisguiseManager().getDisguise(horse);
if (base == null || !(base instanceof DisguiseSheep)) if (base == null || !(base instanceof DisguiseSheep))
continue; continue;

View File

@ -9,6 +9,7 @@ import org.bukkit.entity.Slime;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction; 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.common.util.UtilPlayer;
import mineplex.core.mount.Mount; import mineplex.core.mount.Mount;
import mineplex.core.mount.MountManager; import mineplex.core.mount.MountManager;
import mineplex.core.mount.SingleEntityMountData;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
public class MountSlime extends Mount<Slime> public class MountSlime extends Mount<SingleEntityMountData<Slime>>
{ {
public MountSlime(MountManager manager) public MountSlime(MountManager manager)
{ {
@ -44,10 +46,10 @@ public class MountSlime extends Mount<Slime>
//Remove other mounts //Remove other mounts
Manager.DeregisterAll(player); Manager.DeregisterAll(player);
Slime mount = player.getWorld().spawn(player.getLocation(), Slime.class); SingleEntityMountData<Slime> mount = new SingleEntityMountData<Slime>(player, player.getWorld().spawn(player.getLocation(), Slime.class));
mount.setSize(2); mount.getEntity().setSize(2);
mount.setCustomName(player.getName() + "'s " + GetName()); mount.getEntity().setCustomName(player.getName() + "'s " + GetName());
//Inform //Inform
UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + ".")); UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
@ -58,7 +60,7 @@ public class MountSlime extends Mount<Slime>
public void Disable(Player player) public void Disable(Player player)
{ {
Slime mount = _active.remove(player); SingleEntityMountData<Slime> mount = _active.remove(player);
if (mount != null) if (mount != null)
{ {
mount.remove(); mount.remove();
@ -79,11 +81,8 @@ public class MountSlime extends Mount<Slime>
if (!GetActive().containsKey(event.getPlayer())) if (!GetActive().containsKey(event.getPlayer()))
return; return;
if (!GetActive().get(event.getPlayer()).equals(event.getRightClicked())) if(!GetActive().get(event.getPlayer()).ownsMount(event.getPlayer()))
{
UtilPlayer.message(event.getPlayer(), F.main("Mount", "This is not your Mount!"));
return; return;
}
event.getPlayer().leaveVehicle(); event.getPlayer().leaveVehicle();
event.getPlayer().eject(); event.getPlayer().eject();
@ -108,10 +107,15 @@ public class MountSlime extends Mount<Slime>
return; return;
//Bounce //Bounce
for (Slime slime : GetActive().values()) for (SingleEntityMountData<Slime> slimeData : GetActive().values())
{ {
Slime slime = slimeData.getEntity();
if (slime.getPassenger() == null) if (slime.getPassenger() == null)
{
UtilEnt.setFakeHead(slime, false);
continue; continue;
}
if (!UtilEnt.isGrounded(slime)) if (!UtilEnt.isGrounded(slime))
continue; continue;
@ -124,14 +128,19 @@ public class MountSlime extends Mount<Slime>
if (!Recharge.Instance.use(player, GetName(), 200, false, false)) if (!Recharge.Instance.use(player, GetName(), 200, false, false))
continue; 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); slime.getWorld().playSound(slime.getLocation(), Sound.SLIME_WALK, 1f, 0.75f);
} }
//Collide //Collide
for (Slime slime : GetActive().values()) for (SingleEntityMountData<Slime> slimeData : GetActive().values())
{ {
Slime slime = slimeData.getEntity();
if (slime.getPassenger() == null) if (slime.getPassenger() == null)
continue; continue;
@ -143,8 +152,10 @@ public class MountSlime extends Mount<Slime>
if (!Recharge.Instance.usable(player, GetName() + " Collide")) if (!Recharge.Instance.usable(player, GetName() + " Collide"))
continue; continue;
for (Slime other : GetActive().values()) for (SingleEntityMountData<Slime> otherSlime : GetActive().values())
{ {
Slime other = otherSlime.getEntity();
if (other.equals(slime)) if (other.equals(slime))
continue; continue;

View File

@ -4,21 +4,6 @@ import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Map.Entry; 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.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -32,6 +17,22 @@ import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector; 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 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()) + ".")); UtilPlayer.message(player, F.main("Mount", "You spawned " + F.elem(GetName()) + "."));
//Store //Store
_active.put(player, horse); SingleEntityMountData<Horse> mount = new SingleEntityMountData<Horse>(player, horse);
_active.put(player, mount);
DisguiseSpider spider = new DisguiseSpider(horse); DisguiseSpider spider = new DisguiseSpider(horse);
spider.setName(player.getName() + "'s Spider Mount"); spider.setName(player.getName() + "'s Spider Mount");
@ -105,7 +107,7 @@ public class MountSpider extends HorseMount
ArrayList<Horse> used = new ArrayList<Horse>(); ArrayList<Horse> used = new ArrayList<Horse>();
for (Player player : GetActive().keySet()) for (Player player : GetActive().keySet())
{ {
Horse horse = GetActive().get(player); Horse horse = GetActive().get(player).getEntity();
used.add(horse); used.add(horse);
@ -126,21 +128,24 @@ public class MountSpider extends HorseMount
if (event.getType() != UpdateType.TICK) if (event.getType() != UpdateType.TICK)
return; return;
for (Entry<Player, Horse> horse : GetActive().entrySet()) for (Entry<Player, SingleEntityMountData<Horse>> entry : GetActive().entrySet())
{ {
if (horse.getValue().getPassenger() != horse.getKey()) Player player = entry.getKey();
Horse horse = entry.getValue().getEntity();
if (horse.getPassenger() != player)
continue; continue;
//If player is looking up //If player is looking up
if (horse.getKey().getEyeLocation().getPitch() > -45) if (player.getEyeLocation().getPitch() > -45)
continue; 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()) if (UtilBlock.airFoliage(block) || block.isLiquid())
continue; 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; continue;
} }
} }
@ -191,7 +196,7 @@ public class MountSpider extends HorseMount
for (Player player : GetActive().keySet()) for (Player player : GetActive().keySet())
{ {
final Horse horse = GetActive().get(player); final Horse horse = GetActive().get(player).getEntity();
if (horse.getPassenger() != player) if (horse.getPassenger() != player)
continue; continue;

View File

@ -1,27 +1,19 @@
package mineplex.core.mount.types; package mineplex.core.mount.types;
import java.util.HashMap;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.EntityType;
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.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.mount.HorseMount;
import mineplex.core.mount.Mount; import mineplex.core.mount.Mount;
import mineplex.core.mount.MountManager; import mineplex.core.mount.MountManager;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
@ -85,11 +77,20 @@ public class MountTitan extends Mount<MountTitanData>
} }
@EventHandler @EventHandler
public void interactMount(PlayerInteractEntityEvent event) public void interactMount(PlayerInteractAtEntityEvent event)
{ {
if (event.getRightClicked() == null) if (event.getRightClicked() == null)
return; 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())) if (!GetActive().containsKey(event.getPlayer()))
return; return;
@ -123,7 +124,7 @@ public class MountTitan extends Mount<MountTitanData>
{ {
for (MountTitanData data : _active.values()) for (MountTitanData data : _active.values())
{ {
if (data.ownsEntity(event.getEntity())) if (data.isPartOfMount(event.getEntity()))
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -3,11 +3,7 @@
package mineplex.core.mount.types; package mineplex.core.mount.types;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
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 org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -20,9 +16,13 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle; import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector; 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; private Slime _head;
@ -30,7 +30,7 @@ public class MountTitanData
public MountTitanData(Player player, String name) public MountTitanData(Player player, String name)
{ {
_owner = player.getName(); super(player);
Location loc = player.getLocation(); Location loc = player.getLocation();
loc.setPitch(0); loc.setPitch(0);
@ -72,7 +72,11 @@ public class MountTitanData
{ {
//Head //Head
if (_head.getPassenger() != null) 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); Location infront = _head.getLocation().add(0, -1.5, 0);
@ -133,14 +137,13 @@ public class MountTitanData
for (ArmorStand stand : _nodes) for (ArmorStand stand : _nodes)
stand.remove(); stand.remove();
} }
public boolean ownsMount(Player player)
{
return _owner.equals(player.getName());
}
public boolean ownsEntity(Entity ent) @Override
public List<Entity> getEntityParts()
{ {
return (_head.equals(ent) || _nodes.contains(ent)); List<Entity> entities = new ArrayList<Entity>();
entities.addAll(_nodes);
entities.add(_head);
return entities;
} }
} }

View File

@ -1,15 +1,5 @@
package mineplex.core.mount.types; 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.Material;
import org.bukkit.entity.Horse; import org.bukkit.entity.Horse;
import org.bukkit.entity.Horse.Color; 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.entity.Horse.Variant;
import org.bukkit.event.EventHandler; 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 class MountUndead extends HorseMount
{ {
public MountUndead(MountManager manager) public MountUndead(MountManager manager)
@ -37,16 +37,20 @@ public class MountUndead extends HorseMount
public void Trail(UpdateEvent event) public void Trail(UpdateEvent event)
{ {
if (event.getType() == UpdateType.TICK) if (event.getType() == UpdateType.TICK)
for (Horse horse : GetActive().values()) for (SingleEntityMountData<Horse> horseData : GetActive().values())
UtilParticle.PlayParticle(ParticleType.FLAME, horse.getLocation().add(0, 1, 0), {
0.25f, 0.25f, 0.25f, 0, 2, Horse horse = horseData.getEntity();
ViewDist.NORMAL, UtilServer.getPlayers()); 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) if (event.getType() == UpdateType.FAST)
for (Horse horse : GetActive().values()) for (SingleEntityMountData<Horse> horseData : GetActive().values())
UtilParticle.PlayParticle(ParticleType.LAVA, horse.getLocation().add(0, 1, 0), {
0.25f, 0.25f, 0.25f, 0, 1, Horse horse = horseData.getEntity();
ViewDist.NORMAL, UtilServer.getPlayers()); UtilParticle.PlayParticleToAll(ParticleType.LAVA, horse.getLocation().add(0, 1, 0),
0.25f, 0.25f, 0.25f, 0, 1, ViewDist.NORMAL);
}
} }
} }

View File

@ -28,14 +28,12 @@ import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguiseSlime; import mineplex.core.disguise.disguises.DisguiseSlime;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetActivateEvent;
import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.gadget.event.GadgetCollideEntityEvent;
import mineplex.core.giveaway.GiveawayManager; import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.hologram.HologramManager; import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager; import mineplex.core.inventory.InventoryManager;
import mineplex.core.message.PrivateMessageEvent; import mineplex.core.message.PrivateMessageEvent;
import mineplex.core.mount.MountManager; import mineplex.core.mount.MountManager;
import mineplex.core.mount.event.MountActivateEvent;
import mineplex.core.notifier.NotificationManager; import mineplex.core.notifier.NotificationManager;
import mineplex.core.npc.NpcManager; import mineplex.core.npc.NpcManager;
import mineplex.core.packethandler.PacketHandler; import mineplex.core.packethandler.PacketHandler;
@ -119,7 +117,7 @@ import org.bukkit.scoreboard.Scoreboard;
public class HubManager extends MiniClientPlugin<HubClient> public class HubManager extends MiniClientPlugin<HubClient>
{ {
// Snowman! // Snowman!
public HubType Type = HubType.Normal; public HubType Type = HubType.Christmas;
private BlockRestore _blockRestore; private BlockRestore _blockRestore;
private CoreClientManager _clientManager; private CoreClientManager _clientManager;
@ -161,9 +159,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
private HashMap<String, ArrayList<String>> _creativeAdmin = new HashMap<String, ArrayList<String>>(); private HashMap<String, ArrayList<String>> _creativeAdmin = new HashMap<String, ArrayList<String>>();
//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) 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); super("Hub Manager", plugin);
@ -267,50 +262,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
return true; 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 @EventHandler
public void redirectStopCommand(PlayerCommandPreprocessEvent event) public void redirectStopCommand(PlayerCommandPreprocessEvent event)
{ {
@ -663,39 +614,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
if (_scoreboardTick != 0) if (_scoreboardTick != 0)
return; 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()) for (Player player : UtilServer.getPlayers())
{ {
//Dont Waste Time //Dont Waste Time
@ -913,12 +831,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
event.SetCancelled(true); event.SetCancelled(true);
} }
public boolean IsGadgetEnabled()
{
return _gadgetsEnabled;
}
public NewsManager GetNewsManager() public NewsManager GetNewsManager()
{ {
return _news; return _news;
@ -935,30 +847,15 @@ public class HubManager extends MiniClientPlugin<HubClient>
public void ToggleGadget(Player caller) public void ToggleGadget(Player caller)
{ {
_gadgetsEnabled = !_gadgetsEnabled; toggleGadget();
}
if (!_gadgetsEnabled) public void toggleGadget()
{ {
GetMount().DisableAll(); GetGadget().toggleGadgetEnabled();
GetGadget().DisableAll();
}
for (Player player : UtilServer.getPlayers()) 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")); player.sendMessage(C.cWhite + C.Bold + "Gadgets/Mounts are now " + F.elem(GetGadget().isGadgetEnabled() ? 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);
} }
public void addGameMode(Player caller, Player target) public void addGameMode(Player caller, Player target)

View File

@ -238,7 +238,6 @@ public class SoccerManager extends MiniPlugin
if (UtilAlg.inBoundingBox(_ball.getLocation(), _cornerRedGoalA, _cornerRedGoalB) && if (UtilAlg.inBoundingBox(_ball.getLocation(), _cornerRedGoalA, _cornerRedGoalB) &&
!UtilAlg.inBoundingBox(_ball.getLocation(), _cornerFieldA, _cornerFieldB)) !UtilAlg.inBoundingBox(_ball.getLocation(), _cornerFieldA, _cornerFieldB))
{ {
_insideGoalTicks++; _insideGoalTicks++;
if (_insideGoalTicks > 3) if (_insideGoalTicks > 3)

View File

@ -14,7 +14,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Wither; import org.bukkit.entity.Wither;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.Vector; 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.UtilAlg;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.event.StackerEvent; import mineplex.core.event.StackerEvent;
import mineplex.core.gadget.gadgets.MorphBlock; import mineplex.core.gadget.gadgets.MorphBlock;
import mineplex.core.gadget.types.GadgetType; import mineplex.core.gadget.types.GadgetType;
@ -54,7 +54,7 @@ public class StackerManager extends MiniPlugin implements IThrown
} }
@EventHandler @EventHandler
public void GrabEntity(PlayerInteractEntityEvent event) public void GrabEntity(PlayerInteractAtEntityEvent event)
{ {
if (event.isCancelled()) if (event.isCancelled())
return; return;
@ -62,7 +62,10 @@ public class StackerManager extends MiniPlugin implements IThrown
Entity stackee = event.getRightClicked(); Entity stackee = event.getRightClicked();
if (stackee == null) if (stackee == null)
return; return;
if(Manager.GetMount().isMount(stackee))
return;
if (!(stackee instanceof LivingEntity)) if (!(stackee instanceof LivingEntity))
return; return;

View File

@ -39,6 +39,7 @@ public enum GameType
MineStrike("MineStrike"), MineStrike("MineStrike"),
MineWare("MineWare"), MineWare("MineWare"),
MilkCow("Milk the Cow"), MilkCow("Milk the Cow"),
MonsterLeague("MonsterLeague"),
MonsterMaze("Monster Maze"), MonsterMaze("Monster Maze"),
Paintball("Super Paintball"), Paintball("Super Paintball"),
Quiver("One in the Quiver"), Quiver("One in the Quiver"),

View File

@ -378,7 +378,7 @@ public class DamageManager extends MiniPlugin
event.GetDamageeEntity().playEffect(EntityEffect.HURT); event.GetDamageeEntity().playEffect(EntityEffect.HURT);
//Sticky Arrow //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); ((CraftLivingEntity)event.GetDamageeEntity()).getHandle().o(((CraftLivingEntity)event.GetDamageeEntity()).getHandle().bv() + 1);
//Knockback //Knockback

View File

@ -4,14 +4,17 @@ package mineplex.serverdata.commands;
public class AnnouncementCommand extends ServerCommand public class AnnouncementCommand extends ServerCommand
{ {
private boolean _displayTitle; private boolean _displayTitle;
private String _rank;
private String _message; private String _message;
public boolean getDisplayTitle() { return _displayTitle; } public boolean getDisplayTitle() { return _displayTitle; }
public String getRank() { return _rank; }
public String getMessage() { return _message; } public String getMessage() { return _message; }
public AnnouncementCommand(boolean displayTitle, String message) public AnnouncementCommand(boolean displayTitle, String rank, String message)
{ {
_displayTitle = displayTitle; _displayTitle = displayTitle;
_rank = rank;
_message = message; _message = message;
} }

View File

@ -24,6 +24,7 @@ import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.creature.Creature; 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) /*public void saveBasicStats(final Game game)
{ {
if (!IsTournamentServer()) if (!IsTournamentServer())

View File

@ -8,6 +8,7 @@ import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.games.baconbrawl.BaconBrawl; import nautilus.game.arcade.game.games.baconbrawl.BaconBrawl;
import nautilus.game.arcade.game.games.barbarians.Barbarians; import nautilus.game.arcade.game.games.barbarians.Barbarians;
import nautilus.game.arcade.game.games.bossbattles.BossBattles; 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.bridge.Bridge;
import nautilus.game.arcade.game.games.build.Build; import nautilus.game.arcade.game.games.build.Build;
import nautilus.game.arcade.game.games.cards.Cards; 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.minecraftleague.MinecraftLeague;
import nautilus.game.arcade.game.games.minestrike.MineStrike; import nautilus.game.arcade.game.games.minestrike.MineStrike;
import nautilus.game.arcade.game.games.mineware.MineWare; 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.monstermaze.MonsterMaze;
import nautilus.game.arcade.game.games.oldmineware.OldMineWare; import nautilus.game.arcade.game.games.oldmineware.OldMineWare;
import nautilus.game.arcade.game.games.paintball.Paintball; import nautilus.game.arcade.game.games.paintball.Paintball;
@ -127,6 +129,9 @@ public enum GameType
Skywars(SoloSkywars.class, GameDisplay.Skywars), Skywars(SoloSkywars.class, GameDisplay.Skywars),
SkywarsTeams(TeamSkywars.class, GameDisplay.SkywarsTeams, new GameType[]{GameType.Skywars}, false), SkywarsTeams(TeamSkywars.class, GameDisplay.SkywarsTeams, new GameType[]{GameType.Skywars}, false),
MonsterMaze(MonsterMaze.class, GameDisplay.MonsterMaze), MonsterMaze(MonsterMaze.class, GameDisplay.MonsterMaze),
MonsterLeague(MonsterLeague.class, GameDisplay.MonsterLeague),
BouncyBalls(BouncyBalls.class, GameDisplay.BouncyBalls),
Event(EventGame.class, GameDisplay.Event, new GameType[]{ Event(EventGame.class, GameDisplay.Event, new GameType[]{
GameType.BaconBrawl, GameType.Barbarians, GameType.Bridge, GameType.Build, GameType.Build, GameType.BaconBrawl, GameType.Barbarians, GameType.Bridge, GameType.Build, GameType.Build,

View File

@ -10,7 +10,7 @@ public class KitUnlockCommand extends CommandBase<ArcadeManager>
{ {
public KitUnlockCommand(ArcadeManager plugin) 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 @Override

View File

@ -302,6 +302,8 @@ public abstract class Game implements Listener
public boolean DeadBodiesDeath = true; public boolean DeadBodiesDeath = true;
public int DeadBodiesExpire = -1; public int DeadBodiesExpire = -1;
public boolean FixSpawnFacing = true;
private IPacketHandler _useEntityPacketHandler; private IPacketHandler _useEntityPacketHandler;
private int _deadBodyCount; private int _deadBodyCount;
private NautHashMap<String, Entity> _deadBodies = new NautHashMap<String, Entity>(); private NautHashMap<String, Entity> _deadBodies = new NautHashMap<String, Entity>();

View File

@ -113,12 +113,15 @@ public class GameTeam
private Location fixFacing(Location loc) private Location fixFacing(Location loc)
{ {
float yaw = UtilAlg.GetYaw(UtilAlg.getTrajectory2d(loc, Host.GetSpectatorLocation())); if (Host.FixSpawnFacing)
{
yaw = (int) (yaw / 90) * 90; float yaw = UtilAlg.GetYaw(UtilAlg.getTrajectory2d(loc, Host.GetSpectatorLocation()));
loc = loc.clone(); yaw = (int) (yaw / 90) * 90;
loc.setYaw(yaw);
loc = loc.clone();
loc.setYaw(yaw);
}
return loc; return loc;
} }

View File

@ -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<KickLog> _kickHistory = new ArrayList<KickLog>();
//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;
}
}
}

View File

@ -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();
}
}

View File

@ -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<GameTeam, ArrayList<Block>> _teamGoalRegions = new HashMap<GameTeam, ArrayList<Block>>();
private HashMap<GameTeam, Integer> _teamScores = new HashMap<GameTeam, Integer>();
private ArrayList<Ball> _balls = new ArrayList<Ball>();
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<Block> goalBlocks = new ArrayList<Block>();
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<Block> goalBlocks = new ArrayList<Block>();
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<Block> goalBlocks = new ArrayList<Block>();
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<Block> goalBlocks = new ArrayList<Block>();
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<GameTeam, ArrayList<Block>> 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());
}
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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()) + "."));
}
}

View File

@ -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<IcePathData> _data = new HashSet<IcePathData>();
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()) + "."));
}
}

View File

@ -13,15 +13,11 @@ import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilSound;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilWorld;
import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist; 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.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; 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.KitMedic;
import nautilus.game.arcade.game.games.snowfight.kits.KitSportsman; import nautilus.game.arcade.game.games.snowfight.kits.KitSportsman;
import nautilus.game.arcade.kit.Kit; 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.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -48,10 +42,7 @@ import org.bukkit.World;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; 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.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.FallingBlock; import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Fireball; import org.bukkit.entity.Fireball;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -59,31 +50,23 @@ import org.bukkit.entity.Projectile;
import org.bukkit.entity.Snowball; import org.bukkit.entity.Snowball;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue; 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.scheduler.BukkitRunnable;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader.Array;
public class SnowFight extends TeamGame public class SnowFight extends TeamGame
{ {
private HashMap<Player, Integer> _tiles; private HashMap<Player, Integer> _tiles;
private boolean _meteoroids; private boolean _meteors;
private boolean _peace; private boolean _peace;
public SnowFight(ArcadeManager manager) public SnowFight(ArcadeManager manager)
@ -99,8 +82,8 @@ public class SnowFight extends TeamGame
new String[] new String[]
{ {
"Just like... kill your enemies. with snow.", "Defeat your foes with Snowballs",
"Be careful if you are on Ice your body will freeze" "Last team alive wins!"
}); });
this.HungerSet = 20; this.HungerSet = 20;
@ -111,7 +94,7 @@ public class SnowFight extends TeamGame
this.BlockPlace = true; this.BlockPlace = true;
this.BlockBreakAllow = new HashSet<>(Arrays.asList(Material.FENCE.getId())); this.BlockBreakAllow = new HashSet<>(Arrays.asList(Material.FENCE.getId()));
this._tiles = new HashMap<Player, Integer>(); this._tiles = new HashMap<Player, Integer>();
this._meteoroids = false; this._meteors = false;
this._peace = false; this._peace = false;
} }
@ -160,39 +143,42 @@ public class SnowFight extends TeamGame
} }
@EventHandler @EventHandler
public void Meteor(UpdateEvent event) { public void Meteor(UpdateEvent event)
if(event.getType() != UpdateType.TWOSEC) {
if(event.getType() != UpdateType.FAST)
return; return;
if(!IsLive()) if (!IsLive())
return; 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; return;
}
if(!_peace) if (!_peace)
{ {
for(Player player : GetPlayers(false)) for(Player player : GetPlayers(false))
{
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1F, 1F); player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1F, 1F);
UtilTextMiddle.display(C.cGold + C.Bold + "Peace Phase ended", "Kill your enemies", player);
} UtilTextMiddle.display(C.cRed + "FIGHT", "Throw your Snowballs!", 0, 60, 20, UtilServer.getPlayers());
this.Announce(C.cRed + C.Bold + "ALERT: " + ChatColor.RESET + C.Bold + "Peace Phase ended");
_peace = true; _peace = true;
} }
if(System.currentTimeMillis() <= getGameLiveTime() + (195 * 1000)) if(System.currentTimeMillis() <= getGameLiveTime() + (195 * 1000))
return; return;
if(!_meteoroids) if(!_meteors)
{ {
for(Player player : GetPlayers(false)) for(Player player : GetPlayers(false))
{ {
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1F, 1F); 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(); makeMeteor();
} }
@ -345,12 +331,12 @@ public class SnowFight extends TeamGame
// Lower // Lower
if (height >= snowLevel) if (height >= snowLevel)
{ {
block.setTypeIdAndData(0, (byte) 0, true); block.setTypeIdAndData(0, (byte) 0, false);
SnowDecrease(block.getRelative(BlockFace.DOWN), height - snowLevel); SnowDecrease(block.getRelative(BlockFace.DOWN), height - snowLevel);
} }
else 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) 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 else
@ -498,10 +484,11 @@ public class SnowFight extends TeamGame
explosion.setDropItems(false); explosion.setDropItems(false);
explosion.setBlocksDamagedEqually(true); explosion.setBlocksDamagedEqually(true);
UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, projectile.getLocation(), 1.0F, 1.0F, 1.0F, 1, 3, ViewDist.MAX, UtilServer.getPlayers()); //Effect
for(Player player : UtilServer.getPlayers()) { 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); player.playSound(projectile.getLocation(), Sound.EXPLODE, 1, 1);
}
boolean fall = true; boolean fall = true;
@ -510,7 +497,7 @@ public class SnowFight extends TeamGame
if(player instanceof Player) if(player instanceof Player)
{ {
Player damagee = (Player) 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) if(block.getType() != Material.AIR)
{ {
block.setType(Material.ICE); block.setType(Material.ICE);
if(block.getRelative(BlockFace.DOWN).getType() == Material.AIR) if(block.getRelative(BlockFace.DOWN).getType() == Material.AIR)
{ {
// to reduce lag // to reduce lag
@ -611,7 +599,7 @@ public class SnowFight extends TeamGame
for (GameTeam team : this.GetTeamList()) for (GameTeam team : this.GetTeamList())
{ {
Scoreboard.Write(team.GetColor() + C.Bold + team.GetName()); 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(); Scoreboard.WriteBlank();
} }
} }
@ -620,16 +608,16 @@ public class SnowFight extends TeamGame
if (time > 0) if (time > 0)
{ {
Scoreboard.Write(C.cYellow + C.Bold + "Meteoroids:"); Scoreboard.Write(C.cYellow + C.Bold + "Meteors");
if(IsLive()) if(IsLive())
Scoreboard.Write(UtilTime.MakeStr(time, 0)); Scoreboard.Write(UtilTime.MakeStr(time, 0));
} }
else else
{ {
Scoreboard.Write(C.cGold + C.Bold + "Meteoroids!"); Scoreboard.Write(C.cGold + C.Bold + "Meteors!");
} }
Scoreboard.Draw(); Scoreboard.Draw();
} }
} }

View File

@ -19,9 +19,9 @@ import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge; 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 String _name = "";
private double _range; private double _range;
@ -29,7 +29,7 @@ public class PerkBlink extends SmashPerk
public PerkBlink(String name, double range, long recharge) 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 C.cYellow + "Right-Click" + C.cGray + " with Axe to " + C.cGreen + name
}); });
@ -45,23 +45,15 @@ public class PerkBlink extends SmashPerk
if (event.isCancelled()) if (event.isCancelled())
return; return;
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) if (event.getAction() != Action.LEFT_CLICK_AIR && event.getAction() != Action.LEFT_CLICK_BLOCK &&
return; event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if (UtilBlock.usable(event.getClickedBlock())) if (UtilBlock.usable(event.getClickedBlock()))
return; return;
if (event.getPlayer().getItemInHand() == null)
return;
if (!event.getPlayer().getItemInHand().getType().toString().contains("_AXE"))
return;
Player player = event.getPlayer(); Player player = event.getPlayer();
if (isSuperActive(player))
return;
if (!Kit.HasKit(player)) if (!Kit.HasKit(player))
return; return;