Fixed merge conflicts

This commit is contained in:
AlexTheCoder 2017-09-23 03:47:05 -04:00
parent 9ad4cd0068
commit a06d2f7212
2 changed files with 119 additions and 14 deletions

View File

@ -6,6 +6,7 @@ import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHorse;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Horse.Color;
import org.bukkit.entity.Horse.Style;
@ -15,16 +16,17 @@ import org.bukkit.inventory.ItemStack;
import mineplex.core.common.TriConsumer;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilEnt;
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.common.util.UtilTime;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseCow;
import mineplex.core.disguise.disguises.DisguiseSheep;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.game.clans.clans.ClansManager;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.GenericAttributes;
public class Mount
@ -117,22 +119,32 @@ public class Mount
RAINBOW_SHEEP(4, "Clans Rainbow Sheep Mount Skin", C.cGreen + "Rainbow " + C.cAqua + "Sheep", new ItemBuilder(Material.WOOL).setData(DyeColor.RED.getWoolData()).build(),Color.WHITE, Variant.HORSE, Style.NONE, horse ->
{
DisguiseSheep disguise = new DisguiseSheep(horse);
disguise.setName(horse.getCustomName());
disguise.setName("jeb_");
ClansManager.getInstance().getDisguiseManager().disguise(disguise);
}, horse ->
{
DisguiseBase base = ClansManager.getInstance().getDisguiseManager().getActiveDisguise(horse);
if (base == null || !(base instanceof DisguiseSheep))
EntityPlayer rider = null;
if (horse.getPassenger() != null && horse.getPassenger() instanceof Player)
{
return;
rider = ((CraftPlayer)horse.getPassenger()).getHandle();
try
{
boolean jumping = MountManager.JumpBooleanField.getBoolean(rider);
if (jumping)
{
rider.i(false);
if (UtilEnt.isGrounded(horse))
{
MountManager.JumpFloatField.setFloat(horse.getHandle(), 1.0f);
}
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
DisguiseSheep sheep = (DisguiseSheep)base;
if (horse.getTicksLived() % 4 == 0) sheep.setColor(DyeColor.RED);
else if (horse.getTicksLived() % 4 == 1) sheep.setColor(DyeColor.YELLOW);
else if (horse.getTicksLived() % 4 == 2) sheep.setColor(DyeColor.GREEN);
else if (horse.getTicksLived() % 4 == 3) sheep.setColor(DyeColor.BLUE);
}, MountType.HORSE),
ROYAL_STEED(5, "Clans Royal Steed Mount Skin", C.cGold + "Royal Steed", Material.DIAMOND_BARDING, Color.WHITE, Variant.HORSE, Style.WHITE, horse ->
{
@ -163,13 +175,61 @@ public class Mount
DisguiseCow disguise = new DisguiseCow(horse);
disguise.setName(horse.getCustomName());
ClansManager.getInstance().getDisguiseManager().disguise(disguise);
}, horse -> {}, MountType.HORSE),
}, horse ->
{
EntityPlayer rider = null;
if (horse.getPassenger() != null && horse.getPassenger() instanceof Player)
{
rider = ((CraftPlayer)horse.getPassenger()).getHandle();
try
{
boolean jumping = MountManager.JumpBooleanField.getBoolean(rider);
if (jumping)
{
rider.i(false);
if (UtilEnt.isGrounded(horse))
{
MountManager.JumpFloatField.setFloat(horse.getHandle(), 1.0f);
}
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}, MountType.HORSE),
SHEEP(9, "Clans Sheep Mount Skin", C.cWhite + "Sheep", Material.WOOL, Color.WHITE, Variant.HORSE, Style.NONE, horse ->
{
DisguiseSheep disguise = new DisguiseSheep(horse);
disguise.setName(horse.getCustomName());
ClansManager.getInstance().getDisguiseManager().disguise(disguise);
}, horse -> {}, MountType.HORSE),
}, horse ->
{
EntityPlayer rider = null;
if (horse.getPassenger() != null && horse.getPassenger() instanceof Player)
{
rider = ((CraftPlayer)horse.getPassenger()).getHandle();
try
{
boolean jumping = MountManager.JumpBooleanField.getBoolean(rider);
if (jumping)
{
rider.i(false);
if (UtilEnt.isGrounded(horse))
{
MountManager.JumpFloatField.setFloat(horse.getHandle(), 1.0f);
}
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}, MountType.HORSE),
TRUSTY_MULE(10, "Clans Trusty Mule Mount Skin", C.cBlue + "Trusty Mule", Material.APPLE, Color.BROWN, Variant.MULE, Style.NONE, horse -> {}, horse -> {}, MountType.DONKEY)
;

View File

@ -1,5 +1,6 @@
package mineplex.game.clans.clans.mounts;
import java.lang.reflect.Field;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
@ -12,11 +13,14 @@ import java.util.WeakHashMap;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHorse;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Horse;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
@ -50,8 +54,11 @@ import mineplex.game.clans.clans.mounts.Mount.SkinType;
import mineplex.game.clans.clans.mounts.gui.MountShop;
import mineplex.game.clans.core.repository.ClanTerritory;
import mineplex.game.clans.spawn.Spawn;
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import mineplex.serverdata.Utility;
import net.minecraft.server.v1_8_R3.EntityHorse;
import net.minecraft.server.v1_8_R3.EntityLiving;
public class MountManager extends MiniDbClientPlugin<MountOwnerData>
{
@ -62,6 +69,9 @@ public class MountManager extends MiniDbClientPlugin<MountOwnerData>
MOUNT_SKIN_UNLOCK,
}
protected static Field JumpBooleanField;
protected static Field JumpFloatField;
private static final double[] JUMP_STARS = {0.8, 1, 1.2};
private static final double[] SPEED_STARS = {0.2, 0.27, 0.33};
private static final int[] STRENGTH_STARS = {1, 2, 3};
@ -84,6 +94,17 @@ public class MountManager extends MiniDbClientPlugin<MountOwnerData>
{
super("Clans Mount Manager", plugin, clientManager);
try
{
JumpBooleanField = EntityLiving.class.getDeclaredField("aY");
JumpBooleanField.setAccessible(true);
JumpFloatField = EntityHorse.class.getDeclaredField("br");
JumpFloatField.setAccessible(true);
}
catch (NoSuchFieldException e)
{
e.printStackTrace();
}
_serverId = ClansManager.getInstance().getServerId();
_repository = new MountRepository(plugin, this, _serverId);
_donationManager = donationManager;
@ -549,6 +570,30 @@ public class MountManager extends MiniDbClientPlugin<MountOwnerData>
}, 1L);
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onShootBow(EntityShootBowEvent event)
{
LivingEntity entity = event.getEntity();
Entity vehicle = entity.getVehicle();
if (entity instanceof Player && vehicle != null && _spawnedMounts.containsKey(vehicle))
{
UtilPlayer.message(entity, F.main(getName(), "You cannot shoot while mounted!"));
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onUseSkill(SkillTriggerEvent event)
{
Player rider = event.GetPlayer();
Entity vehicle = rider.getVehicle();
if (vehicle != null && _spawnedMounts.containsKey(vehicle))
{
UtilPlayer.message(rider, F.main(getName(), "You cannot use skills while mounted!"));
event.SetCancelled(true);
}
}
@Override
public String getQuery(int accountId, String uuid, String name)