Prevent mounted players from unmounting.

This commit is contained in:
garbagemule 2014-05-03 22:32:24 +02:00
parent 021b43179f
commit 2d4b6f20f2
3 changed files with 25 additions and 1 deletions

View File

@ -1,7 +1,7 @@
name: MobArena
author: garbagemule
main: com.garbagemule.MobArena.MobArena
version: 0.96.4.4
version: 0.96.4.5
softdepend: [Multiverse-Core,Towny,Heroes,MagicSpells,Vault]
commands:
ma:

View File

@ -51,6 +51,7 @@ import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.vehicle.VehicleExitEvent;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
@ -1176,4 +1177,19 @@ public class ArenaListener
arena.playerLeave(p);
}
public void onVehicleExit(VehicleExitEvent event) {
LivingEntity entity = event.getExited();
if (!(entity instanceof Player)) return;
Player p = (Player) entity;
if (!arena.inArena(p)) return;
Vehicle vehicle = event.getVehicle();
if (!(vehicle instanceof Horse)) return;
if (monsters.hasMount(vehicle)) {
event.setCancelled(true);
}
}
}

View File

@ -8,6 +8,7 @@ import org.bukkit.event.block.*;
import org.bukkit.event.entity.*;
import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.player.*;
import org.bukkit.event.vehicle.VehicleExitEvent;
import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.event.world.WorldUnloadEvent;
@ -309,6 +310,13 @@ public class MAGlobalListener implements Listener
arena.getEventListener().onPlayerPreLogin(event);
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void vehicleExit(VehicleExitEvent event) {
for (Arena arena : am.getArenas()) {
arena.getEventListener().onVehicleExit(event);
}
}