Fix world caching + block interaction

Fixes #608
This commit is contained in:
boy0001
2015-09-05 11:35:43 +10:00
parent 4cc4196487
commit 8606319340
9 changed files with 13 additions and 14 deletions

View File

@ -1096,6 +1096,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
case BEACON:
case BED_BLOCK:
case SIGN:
case WALL_SIGN:
case SIGN_POST:
case ENCHANTMENT_TABLE:
case BREWING_STAND:
@ -1125,7 +1126,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
if (eventType != null && !player.isSneaking()) {
break;
}
if (hand == null) {
if (hand == null || hand.getType() == Material.AIR || hand.getType().isBlock()) {
eventType = PlayerBlockEventType.INTERACT_BLOCK;
lb = new BukkitLazyBlock(block);
break;

View File

@ -8,6 +8,7 @@ import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.WeatherType;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.PluginManager;
@ -130,7 +131,7 @@ public class BukkitPlayer extends PlotPlayer {
if (Math.abs(loc.getX()) >= 30000000 || Math.abs(loc.getZ()) >= 30000000) {
return;
}
this.player.teleport(new org.bukkit.Location(BukkitUtil.getWorld(loc.getWorld()), loc.getX() + 0.5, loc.getY(), loc.getZ() + 0.5, loc.getYaw(), loc.getPitch()));
this.player.teleport(new org.bukkit.Location(BukkitUtil.getWorld(loc.getWorld()), loc.getX() + 0.5, loc.getY(), loc.getZ() + 0.5, loc.getYaw(), loc.getPitch()), TeleportCause.COMMAND);
}
@Override

View File

@ -31,11 +31,11 @@ import com.intellectualcrafters.plot.object.schematic.PlotItem;
import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.StringComparison;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.object.BukkitPlayer;
public class BukkitUtil extends BlockManager {
private static HashMap<String, World> worlds = new HashMap<>();
private static String lastString = null;
private static World lastWorld = null;
@ -145,14 +145,12 @@ public class BukkitUtil extends BlockManager {
}
public static World getWorld(final String string) {
if (string == lastString) {
if (StringMan.isEqual(string,lastString)) {
return lastWorld;
}
World world = worlds.get(string);
if (world == null) {
world = Bukkit.getWorld(string);
worlds.put(string, world);
}
World world = Bukkit.getWorld(string);
lastString = string;
lastWorld = world;
return world;
}