Fix a bug with teleporting

Added messages when teleporting automatically changes to teleporting to
a sign instead of to the region or other way around.
This commit is contained in:
Thijs Wiefferink 2015-03-13 14:41:54 +01:00
parent 5094d39a96
commit 1395afffe9
5 changed files with 29 additions and 14 deletions

View File

@ -240,6 +240,8 @@ teleport-success: "You teleported to %0%."
teleport-successSign: "You teleported to the sign of %0%."
teleport-noSafe: "No safe position found in region %0%, no spots in region left or maximum tries exceeded (%1%/%2%)."
teleport-blocked: "You can't teleport because the position is outside the region, and you are forced to teleport inside."
teleport-changedToSign: "You only have permission to teleport to the sign and not inside the region, teleporting to sign."
teleport-changedToNoSign: "No sign available to teleport to, trying to teleport inside the region instead."
setteleport-help: "/as settp [region] [reset], the region you stand in will be used if not specified."
setteleport-noPermission: "You don't have permission to set the teleport location."

View File

@ -9,6 +9,7 @@ import java.util.logging.Level;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
@ -668,7 +669,7 @@ public class Updater {
this.plugin.getLogger().severe("If you have not recently modified your configuration and this is the first time you are seeing this message, the site may be experiencing temporary downtime.");
this.result = UpdateResult.FAIL_DBO;
}
this.plugin.getLogger().log(Level.SEVERE, null, e);
AreaShop.debug(ExceptionUtils.getStackTrace(e));
return false;
}
}

View File

@ -423,9 +423,10 @@ public class BuyRegion extends GeneralRegion {
if(inactiveSetting <= 0 || player.isOp()) {
return false;
}
//AreaShop.debug("inactivetimemillis: " + inactiveSetting * 60 * 1000);
//AreaShop.debug("currentTime=" + Calendar.getInstance().getTimeInMillis() + ", getLastPlayed()=" + player.getLastPlayed() + ", timeInactive=" + (Calendar.getInstance().getTimeInMillis()-player.getLastPlayed()) + ", inactiveSetting*60*1000=" + inactiveSetting * 60 * 1000);
if(Calendar.getInstance().getTimeInMillis() > (player.getLastPlayed() + inactiveSetting * 60 * 1000)) {
plugin.getLogger().info("Region " + getName() + " sold because of inactivity for player " + getPlayerName());
AreaShop.debug("currentTime=" + Calendar.getInstance().getTimeInMillis() + ", getLastPlayed()=" + player.getLastPlayed() + ", timeInactive=" + (Calendar.getInstance().getTimeInMillis()-player.getLastPlayed()) + ", inactiveSetting*60*1000=" + inactiveSetting * 60 * 1000);
this.sell(true);
return true;
}

View File

@ -1292,11 +1292,28 @@ public abstract class GeneralRegion {
owner = player.getUniqueId().equals(((BuyRegion)this).getBuyer());
}
List<Location> signs = getSignLocations();
boolean signAvailable = !signs.isEmpty();
if(toSign) {
if(signAvailable) {
// Use the location 1 below the sign to prevent weird spawing above the sign
startLocation = signs.get(0).subtract(0.0, 1.0, 0.0);
startLocation.setPitch(player.getLocation().getPitch());
startLocation.setYaw(player.getLocation().getYaw());
} else {
// No sign available
plugin.message(player, "teleport-changedToNoSign");
toSign = false;
}
}
if(checkPermissions) {
// Teleport to sign instead if they dont have permission for teleporting to region
if(!toSign && owner && !player.hasPermission("areashop.teleport") && player.hasPermission("areashop.teleportsign")
if(signAvailable &&
(!toSign && owner && !player.hasPermission("areashop.teleport") && player.hasPermission("areashop.teleportsign")
|| !toSign && !owner && !friend && !player.hasPermission("areashop.teleportall") && player.hasPermission("areashop.teleportsignall")
|| !toSign && !owner && friend && !player.hasPermission("areashop.teleportfriend") && player.hasPermission("areashop.teleportfriendsign")) {
|| !toSign && !owner && friend && !player.hasPermission("areashop.teleportfriend") && player.hasPermission("areashop.teleportfriendsign"))) {
plugin.message(player, "teleport-changedToSign");
toSign = true;
}
// Check permissions
@ -1321,15 +1338,7 @@ public abstract class GeneralRegion {
}
}
if(toSign) {
List<Location> signs = getSignLocations();
if(!signs.isEmpty()) {
// Use the location 1 below the sign to prevent weird spawing above the sign
startLocation = signs.get(0).subtract(0.0, 1.0, 0.0);
startLocation.setPitch(player.getLocation().getPitch());
startLocation.setYaw(player.getLocation().getYaw());
}
}
if(startLocation == null && this.hasTeleportLocation()) {
startLocation = getTeleportLocation();
}
@ -2089,6 +2098,7 @@ public abstract class GeneralRegion {
*/
public void handleSchematicEvent(RegionEvent type) {
// Check for the general killswitch
// TODO remove
if(!plugin.getConfig().getBoolean("enableSchematics")) {
return;
}

View File

@ -619,9 +619,10 @@ public class RentRegion extends GeneralRegion {
if(inactiveSetting <= 0 || player.isOp()) {
return false;
}
//AreaShop.debug("inactivetimemillis: " + inactiveSetting * 60 * 1000);
//AreaShop.debug("currentTime=" + Calendar.getInstance().getTimeInMillis() + ", getLastPlayed()=" + player.getLastPlayed() + ", timeInactive=" + (Calendar.getInstance().getTimeInMillis()-player.getLastPlayed()) + ", inactiveSetting*60*1000=" + inactiveSetting * 60 * 1000);
if(Calendar.getInstance().getTimeInMillis() > (player.getLastPlayed() + inactiveSetting * 60 * 1000)) {
plugin.getLogger().info("Region " + getName() + " unrented because of inactivity for player " + getPlayerName());
AreaShop.debug("currentTime=" + Calendar.getInstance().getTimeInMillis() + ", getLastPlayed()=" + player.getLastPlayed() + ", timeInactive=" + (Calendar.getInstance().getTimeInMillis()-player.getLastPlayed()) + ", inactiveSetting*60*1000=" + inactiveSetting * 60 * 1000);
this.unRent(true);
return true;
}