mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-23 11:06:14 +01:00
Implement mounts.
This commit is contained in:
parent
24caeab24f
commit
56a616ee76
@ -1,7 +1,7 @@
|
||||
name: MobArena
|
||||
author: garbagemule
|
||||
main: com.garbagemule.MobArena.MobArena
|
||||
version: 0.95.5.35
|
||||
version: 0.95.5.36
|
||||
softdepend: [Multiverse-Core,Towny,Heroes,MagicSpells,Vault]
|
||||
commands:
|
||||
ma:
|
||||
|
@ -624,8 +624,9 @@ public class ArenaImpl implements Arena
|
||||
return false;
|
||||
}
|
||||
|
||||
// Clear inventory if player is an arena player
|
||||
// Clear inventory if player is an arena player, and unmount
|
||||
if (arenaPlayers.contains(p)) {
|
||||
unmount(p);
|
||||
clearInv(p);
|
||||
}
|
||||
|
||||
@ -667,8 +668,9 @@ public class ArenaImpl implements Arena
|
||||
ArenaPlayerDeathEvent event = new ArenaPlayerDeathEvent(p, this, last);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
// Clear the player's inventory
|
||||
// Clear the player's inventory, and unmount
|
||||
if (arenaPlayers.remove(p)) {
|
||||
unmount(p);
|
||||
clearInv(p);
|
||||
}
|
||||
|
||||
@ -692,6 +694,15 @@ public class ArenaImpl implements Arena
|
||||
}
|
||||
}
|
||||
|
||||
private void unmount(Player p) {
|
||||
Entity v = p.getVehicle();
|
||||
if (v != null) {
|
||||
monsterManager.removeMount(v);
|
||||
v.eject();
|
||||
v.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playerRespawn(Player p) {
|
||||
if (settings.getBoolean("auto-respawn", true)) {
|
||||
@ -774,21 +785,60 @@ public class ArenaImpl implements Arena
|
||||
}
|
||||
|
||||
private void spawnMounts() {
|
||||
/* TODO: Uncomment for 1.6
|
||||
for (Map.Entry<Player,ArenaPlayer> entry : arenaPlayerMap.entrySet()) {
|
||||
ArenaClass arenaClass = entry.getValue().getArenaClass();
|
||||
if (!arenaClass.hasMount()) continue;
|
||||
for (Player p : arenaPlayers) {
|
||||
// Skip players who are either null or offline
|
||||
if (p == null || !p.isOnline()) continue;
|
||||
|
||||
// Remove the hay bale
|
||||
Player p = entry.getKey();
|
||||
p.getInventory().removeItem(new ItemStack(Material.HAY_BLOCK, 1));
|
||||
// Grab the inventory
|
||||
PlayerInventory inv = p.getInventory();
|
||||
if (inv == null) continue;
|
||||
|
||||
// Spawn the horse
|
||||
// Find the first slot containing a haybale
|
||||
int hay = inv.first(Material.HAY_BLOCK);
|
||||
if (hay == -1) continue;
|
||||
|
||||
// Grab the amount and calculate the configuration
|
||||
int amount = inv.getItem(hay).getAmount();
|
||||
|
||||
// Variant
|
||||
Horse.Variant variant = Horse.Variant.HORSE;
|
||||
switch (amount % 8) {
|
||||
case 2: variant = Horse.Variant.DONKEY; break;
|
||||
case 3: variant = Horse.Variant.MULE; break;
|
||||
case 4: variant = Horse.Variant.SKELETON_HORSE; break;
|
||||
case 5: variant = Horse.Variant.UNDEAD_HORSE; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
// Barding
|
||||
Material barding = null;
|
||||
switch ((amount >> 3) % 4) {
|
||||
case 1: barding = Material.IRON_BARDING; break;
|
||||
case 2: barding = Material.GOLD_BARDING; break;
|
||||
case 3: barding = Material.DIAMOND_BARDING; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
// Spawn the horse, set its variant, tame it, etc.
|
||||
Horse horse = (Horse) world.spawnEntity(p.getLocation(), EntityType.HORSE);
|
||||
horse.setVariant(variant);
|
||||
horse.setTamed(true);
|
||||
horse.setOwner(p);
|
||||
horse.setPassenger(p);
|
||||
horse.setHealth(horse.getMaxHealth());
|
||||
|
||||
// Give it a saddle and possibly barding
|
||||
horse.getInventory().setSaddle(new ItemStack(Material.SADDLE));
|
||||
if (barding != null) {
|
||||
horse.getInventory().setArmor(new ItemStack(barding));
|
||||
}
|
||||
|
||||
// Add to monster manager
|
||||
monsterManager.addMount(horse);
|
||||
}*/
|
||||
|
||||
// Remove the hay
|
||||
inv.setItem(hay, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void removePotionEffects(Player p) {
|
||||
|
@ -457,7 +457,7 @@ public class ArenaListener
|
||||
}
|
||||
|
||||
private void onMountDeath(EntityDeathEvent event) {
|
||||
|
||||
// Shouldn't ever happen
|
||||
}
|
||||
|
||||
private void onMonsterDeath(EntityDeathEvent event) {
|
||||
@ -566,10 +566,9 @@ public class ArenaListener
|
||||
onPetDamage(event, (Wolf) damagee, damager);
|
||||
}
|
||||
// Mount
|
||||
/* TODO: Uncomment for 1.6
|
||||
else if (damagee instanceof Horse && monsters.hasMount(damagee)) {
|
||||
onMountDamage(event, (Horse) damagee, damager);
|
||||
}*/
|
||||
}
|
||||
// Player
|
||||
else if (damagee instanceof Player) {
|
||||
onPlayerDamage(event, (Player) damagee, damager);
|
||||
@ -613,11 +612,10 @@ public class ArenaListener
|
||||
private void onPetDamage(EntityDamageEvent event, Wolf pet, Entity damager) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
/* TODO: Uncomment for 1.6
|
||||
private void onMountDamage(EntityDamageEvent event, Horse mount, Entity damager) {
|
||||
|
||||
}*/
|
||||
private void onMountDamage(EntityDamageEvent event, Horse mount, Entity damager) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
private void onMonsterDamage(EntityDamageEvent event, Entity monster, Entity damager) {
|
||||
if (damager instanceof Player) {
|
||||
|
Loading…
Reference in New Issue
Block a user