Slight UI improvements and made fall damage no longer count towards mount despawn hits

This commit is contained in:
AlexTheCoder 2017-04-15 17:31:12 -04:00
parent 3c4eee910f
commit 8c911426fd
4 changed files with 63 additions and 6 deletions

View File

@ -183,6 +183,10 @@ public class Mount
{
horse.setVariant(skin.getVariant());
}
else
{
horse.setVariant(Variant.DONKEY);
}
horse.setTamed(true);
horse.getInventory().setSaddle(new ItemStack(Material.SADDLE));
horse.setOwner(owner);

View File

@ -16,6 +16,7 @@ import org.bukkit.entity.Horse;
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.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
@ -38,6 +39,7 @@ import mineplex.core.donation.DonationManager;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.mounts.Mount.MountType;
import mineplex.game.clans.clans.mounts.Mount.SkinType;
import mineplex.game.clans.clans.mounts.gui.MountShop;
@ -157,14 +159,22 @@ public class MountManager extends MiniDbClientPlugin<MountOwnerData>
{
if (_summoning.containsKey(player))
{
UtilPlayer.message(player, F.main(getName(), "You are already summoning a mount!"));
return false;
}
if (Spawn.getInstance().isSafe(player.getLocation()))
{
UtilPlayer.message(player, F.main(getName(), "You cannot summon a mount in safezones!"));
return false;
}
if (ClansManager.getInstance().getNetherManager().isInNether(player))
{
UtilPlayer.message(player, F.main(getName(), "You cannot summon a mount in the Nether!"));
return false;
}
if (!Recharge.Instance.usable(player, "Mount Spawn Delay"))
{
UtilPlayer.message(player, F.main(getName(), "You cannot summon a mount so soon after your last one was forcibly despawned!"));
return false;
}
_spawnedMounts.values().stream().filter(mount -> mount.getOwner().getEntityId() == player.getEntityId()).findFirst().ifPresent(mount -> mount.despawn(false));
@ -200,6 +210,12 @@ public class MountManager extends MiniDbClientPlugin<MountOwnerData>
entry.getValue().despawn(false);
continue;
}
if (entry.getValue().getOwner().isDead() || !entry.getValue().getOwner().isValid() || !entry.getValue().getOwner().isOnline())
{
mountIterator.remove();
entry.getValue().despawn(false);
continue;
}
if (Spawn.getInstance().isSafe(entry.getKey().getLocation()))
{
mountIterator.remove();
@ -244,6 +260,7 @@ public class MountManager extends MiniDbClientPlugin<MountOwnerData>
{
summoningIterator.remove();
UtilEnt.removeFlag(entry.getKey(), "MOVED_WHILE_SUMMONING_MOUNT");
UtilPlayer.message(entry.getKey(), F.main(getName(), "You have stopped summoning your mount as you have moved!"));
continue;
}
}
@ -334,12 +351,18 @@ public class MountManager extends MiniDbClientPlugin<MountOwnerData>
return;
}
event.setDamagee(mount.getOwner());
mount.handleHit();
if (event.GetCause() != DamageCause.FALL)
{
mount.handleHit();
}
return;
}
if (mount.getOwner().getEntityId() == event.GetDamageeEntity().getEntityId())
{
mount.handleHit();
if (event.GetCause() != DamageCause.FALL)
{
mount.handleHit();
}
return;
}
}

View File

@ -112,6 +112,7 @@ public class MountOverviewPage extends ShopPageBase<MountManager, MountShop>
getPlugin().getRepository().deleteMount(tokens.getLeft(), id ->
{
getPlugin().Get(getPlayer()).removeMount(id.intValue());
MountOverviewPage.this.refresh();
callback.resolve("Mount successfully deleted!");
});
}
@ -138,15 +139,34 @@ public class MountOverviewPage extends ShopPageBase<MountManager, MountShop>
{
if (clickType == ClickType.LEFT)
{
if (!getPlugin().summonMount(player, tokens.getLeft()))
{
playDenySound(player);
}
}
else if (clickType == ClickType.RIGHT)
{
playDenySound(player);
//getShop().openPageForPlayer(player, page);
}
else if (clickType == ClickType.SHIFT_RIGHT)
{
getShop().openPageForPlayer(player, new ConfirmationPage<MountManager, MountShop>(player, new MountOverviewPage(getPlugin(), getShop(), getName(), getPlayer()), new ConfirmationProcessor()
{
@Override
public void init(Inventory inventory) {}
@Override
public void process(ConfirmationCallback callback)
{
getPlugin().getRepository().deleteMount(tokens.getLeft(), id ->
{
getPlugin().Get(getPlayer()).removeMount(id.intValue());
MountOverviewPage.this.refresh();
callback.resolve("Mount successfully deleted!");
});
}
}, toItem(tokens.getLeft(), tokens.getRight(), false)));
}
}
};

View File

@ -151,7 +151,17 @@ public class NetherManager extends MiniPlugin
*/
public boolean isInNether(Player player)
{
return player.getWorld().equals(_netherWorld);
return isInNether(player.getLocation());
}
/**
* Checks if a location is in the nether
* @param location The location to check
* @return Whether the player is in the nether
*/
public boolean isInNether(Location location)
{
return location.getWorld().equals(_netherWorld);
}
/**