Eject player on quitting when mounted on an NPC

This commit is contained in:
fullwall 2013-08-10 20:32:30 +08:00
parent 2b0e7af138
commit 4b6191b705
2 changed files with 8 additions and 1 deletions

View File

@ -98,7 +98,8 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
Messaging.logTr(Messages.DATABASE_CONNECTION_FAILED);
}
} else if (type.equalsIgnoreCase("nbt")) {
saves = new NBTStorage(folder + File.separator + Setting.STORAGE_FILE.asString(), "Citizens NPC Storage");
saves = new NBTStorage(new File(folder + File.separator + Setting.STORAGE_FILE.asString()),
"Citizens NPC Storage");
}
if (saves == null)
saves = new YamlStorage(new File(folder, Setting.STORAGE_FILE.asString()), "Citizens NPC Storage");

View File

@ -253,6 +253,12 @@ public class EventListen implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerQuit(PlayerQuitEvent event) {
Editor.leave(event.getPlayer());
if (event.getPlayer().isInsideVehicle()) {
NPC npc = npcRegistry.getNPC(event.getPlayer().getVehicle());
if (npc != null) {
event.getPlayer().leaveVehicle();
}
}
}
@EventHandler(ignoreCancelled = true)