From aefd148bcd99dc44db0ba8675a4fd2925f79af85 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Thu, 19 Feb 2015 22:35:45 +1100 Subject: [PATCH] PWE --- .../com/intellectualcrafters/plot/BukkitMain.java | 7 +++---- .../com/intellectualcrafters/plot/PlotSquared.java | 2 ++ .../com/intellectualcrafters/plot/util/PWE.java | 12 ++++++------ .../plot/util/PlayerFunctions.java | 6 +++--- .../plot/util/SchematicHandler.java | 14 +++++++------- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 15ffc7715..33e4ae233 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -127,7 +127,7 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { public static void worldLoad(WorldLoadEvent event) { UUIDHandler.cacheAll(); } - + @EventHandler public void PlayerCommand(PlayerCommandPreprocessEvent event) { String message = event.getMessage(); @@ -308,9 +308,8 @@ public class BukkitMain extends JavaPlugin implements Listener,IPlotMain { @Override public void registerWorldEditEvents() { if (getServer().getPluginManager().getPlugin("WorldEdit") != null) { - WorldEditPlugin worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit"); - - final String version = worldEdit.getDescription().getVersion(); + PlotSquared.worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit"); + final String version = PlotSquared.worldEdit.getDescription().getVersion(); if ((version != null) && version.startsWith("5.")) { log("&cThis version of WorldEdit does not support PlotSquared."); log("&cPlease use WorldEdit 6+ for masking support"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 877eeaac6..037d343a0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -53,6 +53,7 @@ import com.intellectualcrafters.plot.util.Logger.LogLevel; import com.intellectualcrafters.plot.util.PlotHelper; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.UUIDHandler; +import com.sk89q.worldedit.bukkit.WorldEditPlugin; public class PlotSquared { @@ -74,6 +75,7 @@ public class PlotSquared { public static TaskManager TASK = null; private static boolean LOADING_WORLD = false; public static Economy economy = null; + public static WorldEditPlugin worldEdit = null; private final static HashMap plotworlds = new HashMap<>(); private final static HashMap plotmanagers = new HashMap<>(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java index 683e1b19e..309e19d2a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PWE.java @@ -21,7 +21,6 @@ package com.intellectualcrafters.plot.util; -import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; @@ -29,6 +28,7 @@ import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.FlagManager; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.sk89q.worldedit.LocalSession; @@ -44,7 +44,7 @@ import com.sk89q.worldedit.regions.CuboidRegion; * @author Citymonstret * @author Empire92 */ -@SuppressWarnings("ALL") public class PWE { +public class PWE { public static void setMask(final Player p, final Location l, boolean force) { try { @@ -54,7 +54,7 @@ import com.sk89q.worldedit.regions.CuboidRegion; } else { s = PlotSquared.worldEdit.getSession(p); } - if (!PlotSquared.isPlotWorld(p.getWorld())) { + if (!PlotSquared.isPlotWorld(p.getWorld().getName())) { removeMask(p); } final PlotId id = PlayerFunctions.getPlot(l); @@ -66,13 +66,13 @@ import com.sk89q.worldedit.regions.CuboidRegion; } boolean r = ((plot.getOwner() != null) && plot.getOwner().equals(UUIDHandler.getUUID(p))) || plot.helpers.contains(DBFunc.everyone) || plot.helpers.contains(UUIDHandler.getUUID(p)); if (r) { - final World w = l.getWorld(); + final String w = l.getWorld(); final Location bloc = PlotHelper.getPlotBottomLoc(w, plot.id); final Location tloc = PlotHelper.getPlotTopLoc(w, plot.id); - final Vector bvec = new Vector(bloc.getBlockX() + 1, bloc.getBlockY(), bloc.getBlockZ() + 1); - final Vector tvec = new Vector(tloc.getBlockX(), tloc.getBlockY(), tloc.getBlockZ()); + final Vector bvec = new Vector(bloc.getX() + 1, bloc.getY(), bloc.getZ() + 1); + final Vector tvec = new Vector(tloc.getX(), tloc.getY(), tloc.getZ()); final LocalWorld lw = PlotSquared.worldEdit.wrapPlayer(p).getWorld(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java index c0a66ccb8..c33eb0fa1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/PlayerFunctions.java @@ -24,13 +24,13 @@ package com.intellectualcrafters.plot.util; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import org.bukkit.ChatColor; -import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.util.ChatPaginator; @@ -133,7 +133,7 @@ import java.util.UUID; return null; } final PlotWorld plotworld = PlotSquared.getWorldSettings(world); - return manager.getPlotIdAbs(plotworld, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); + return manager.getPlotIdAbs(plotworld, loc.getX(), loc.getY(), loc.getZ()); } @@ -151,7 +151,7 @@ import java.util.UUID; return null; } final PlotWorld plotworld = PlotSquared.getWorldSettings(world); - PlotId id = manager.getPlotId(plotworld, loc.getBlockX(),loc.getBlockY(), loc.getBlockZ()); + PlotId id = manager.getPlotId(plotworld, loc.getX(),loc.getY(), loc.getZ()); if (id!=null && plotworld.TYPE == 2) { if (ClusterManager.getCluster(world, id) == null) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java index 20fff2e99..82e21b601 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -49,6 +49,7 @@ import com.intellectualcrafters.jnbt.Tag; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; @@ -231,7 +232,7 @@ public class SchematicHandler { * * @return tag */ - public static CompoundTag getCompoundTag(final World world, PlotId id) { + public static CompoundTag getCompoundTag(final String world, PlotId id) { if (!PlotSquared.getPlots(world).containsKey(id)) { return null; } @@ -297,19 +298,18 @@ public class SchematicHandler { for (int y = 0; y < height; y++) { final int index = (y * width * length) + (z * width) + x; - block = BukkitUtil.getBlock(new Location(world, sx + x, sy + y, sz + z)); - @SuppressWarnings("deprecation") final int id2 = block.getTypeId(); + PlotBlock block = BukkitUtil.getBlock(new Location(world, sx + x, sy + y, sz + z)); - if (id2 > 255) { + if (block.id > 255) { if (addBlocks == null) { addBlocks = new byte[(blocks.length >> 1) + 1]; } - addBlocks[index >> 1] = (byte) (((index & 1) == 0) ? (addBlocks[index >> 1] & 0xF0) | ((id2 >> 8) & 0xF) : (addBlocks[index >> 1] & 0xF) | (((id2 >> 8) & 0xF) << 4)); + addBlocks[index >> 1] = (byte) (((index & 1) == 0) ? (addBlocks[index >> 1] & 0xF0) | ((block.id >> 8) & 0xF) : (addBlocks[index >> 1] & 0xF) | (((block.id >> 8) & 0xF) << 4)); } - blocks[index] = (byte) id2; - blockData[index] = block.getData(); + blocks[index] = (byte) block.id; + blockData[index] = block.data; // We need worldedit to save tileentity data or entities // - it uses NMS and CB internal code, which changes every