Fixed Minecart Dupe Bug due to Intersection switching.

This commit is contained in:
sigonasr2 2016-09-02 01:06:45 -05:00
parent b649c9cd43
commit 06ab897e43
2 changed files with 26 additions and 17 deletions

Binary file not shown.

View File

@ -5771,22 +5771,28 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ev.setCancelled(true); ev.setCancelled(true);
if (ev.getVehicle().isValid()) { if (ev.getVehicle().isValid()) {
ev.getVehicle().remove(); ev.getVehicle().remove();
switch (ev.getVehicle().getType()) {
case MINECART:{ Bukkit.getScheduler().runTaskLater(this, () -> {
ev.getVehicle().getLocation().getWorld().dropItemNaturally(ev.getVehicle().getLocation().add(0,1,0), new ItemStack(Material.MINECART)); if (ev.getAttacker().getVehicle()==null) {
}break; switch (ev.getVehicle().getType()) {
case MINECART_FURNACE:{ case MINECART:{
ev.getVehicle().getLocation().getWorld().dropItemNaturally(ev.getVehicle().getLocation().add(0,1,0), new ItemStack(Material.MINECART)); ev.getVehicle().getLocation().getWorld().dropItemNaturally(ev.getVehicle().getLocation().add(0,1,0), new ItemStack(Material.MINECART));
ev.getVehicle().getLocation().getWorld().dropItemNaturally(ev.getVehicle().getLocation().add(0,1,0), new ItemStack(Material.FURNACE)); }break;
}break; case MINECART_FURNACE:{
case MINECART_TNT:{ ev.getVehicle().getLocation().getWorld().dropItemNaturally(ev.getVehicle().getLocation().add(0,1,0), new ItemStack(Material.MINECART));
ev.getVehicle().getLocation().getWorld().dropItemNaturally(ev.getVehicle().getLocation().add(0,1,0), new ItemStack(Material.MINECART)); ev.getVehicle().getLocation().getWorld().dropItemNaturally(ev.getVehicle().getLocation().add(0,1,0), new ItemStack(Material.FURNACE));
ev.getVehicle().getLocation().getWorld().dropItemNaturally(ev.getVehicle().getLocation().add(0,1,0), new ItemStack(Material.TNT)); }break;
}break; case MINECART_TNT:{
default:{ ev.getVehicle().getLocation().getWorld().dropItemNaturally(ev.getVehicle().getLocation().add(0,1,0), new ItemStack(Material.MINECART));
ev.getVehicle().getLocation().getWorld().dropItemNaturally(ev.getVehicle().getLocation().add(0,1,0), new ItemStack(Material.TNT));
} }break;
} default:{
}
}
}
}, 1);
} }
} }
} }
@ -5800,7 +5806,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
//Drop a minecart at the position. //Drop a minecart at the position.
if (ev.getVehicle().isValid()) { if (ev.getVehicle().isValid()) {
ev.getVehicle().remove(); ev.getVehicle().remove();
ev.getVehicle().getWorld().dropItemNaturally(ev.getExited().getLocation().add(0,1,0), new ItemStack(Material.MINECART)); Bukkit.getScheduler().runTaskLater(this, () -> {
if (ev.getExited().getVehicle()==null) {
ev.getVehicle().getWorld().dropItemNaturally(ev.getExited().getLocation().add(0,1,0), new ItemStack(Material.MINECART));
}},1);
} }
} }
} }