}
public void handleNewLocation(Player player, Location loc, boolean move) {
String pname = player.getName();
ClaimedResidence res = Residence.getResidenceManager().getByLoc(loc);
String areaname = null;
boolean chatchange = false;
String subzone = null;
if (res != null) {
areaname = Residence.getResidenceManager().getNameByLoc(loc);
while (res.getSubzoneByLoc(player.getLocation()) != null) {
subzone = res.getSubzoneNameByLoc(player.getLocation());
res = res.getSubzoneByLoc(player.getLocation());
areaname = areaname + "." + subzone;
}
}
ClaimedResidence ResOld = null;
if (currentRes.containsKey(pname)) {
ResOld = Residence.getResidenceManager().getByName(currentRes.get(pname));
if (ResOld == null) {
currentRes.remove(pname);
}
}
if (res == null) {
lastOutsideLoc.put(pname, loc);
if (ResOld != null) {
String leave = ResOld.getLeaveMessage();
/*
* TODO - ResidenceLeaveEvent is deprecated as of 21-MAY-2013. Its functionality is replaced by
* ResidenceChangedEvent. For now, this event is still supported until it is removed at a
* suitable time in the future.
*/
ResidenceLeaveEvent leaveevent = new ResidenceLeaveEvent(ResOld, player);
Residence.getServ().getPluginManager().callEvent(leaveevent);
// New ResidenceChangeEvent
ResidenceChangedEvent chgEvent = new ResidenceChangedEvent(ResOld, null, player);
Residence.getServ().getPluginManager().callEvent(chgEvent);
if (leave != null && !leave.equals("")) {
player.sendMessage(ChatColor.YELLOW + this.insertMessages(player, ResOld.getName(), ResOld, leave));
}
currentRes.remove(pname);
Residence.getChatManager().removeFromChannel(pname);
}
return;
}
if (move) {
if (!res.getPermissions().playerHas(pname, "move", true) && !Residence.isResAdminOn(player) && !player.hasPermission("residence.admin.move")) {
Location lastLoc = lastOutsideLoc.get(pname);
if (lastLoc != null) {
player.teleport(lastLoc);
} else {
player.teleport(res.getOutsideFreeLoc(loc));
}
player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("ResidenceMoveDeny", res.getName().split("\\.")[res.getName().split("\\.").length - 1]));
return;
}
}
lastOutsideLoc.put(pname, loc);
if (!currentRes.containsKey(pname) || ResOld != res) {
currentRes.put(pname, areaname);
if (subzone == null) {
chatchange = true;
}
// "from" residence for ResidenceChangedEvent
ClaimedResidence chgFrom = null;
if (ResOld != res && ResOld != null) {
String leave = ResOld.getLeaveMessage();
chgFrom = ResOld;
/*