Remove FaweLocation

it was a leftover from when WE didn't have Location
This commit is contained in:
Jesse Boyd 2019-06-29 00:13:30 +10:00
parent 7b9a03a9ec
commit c773a1e278
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
7 changed files with 32 additions and 120 deletions

View File

@ -2,20 +2,15 @@ package com.boydti.fawe.bukkit;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FaweLocation;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.wrappers.PlayerWrapper;
import java.lang.reflect.Method;
import java.util.UUID;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.ConsoleCommandSender; import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.UUID;
public class BukkitPlayer extends FawePlayer<Player> { public class BukkitPlayer extends FawePlayer<Player> {
private static ConsoleCommandSender console; private static ConsoleCommandSender console;
@ -94,12 +89,6 @@ public class BukkitPlayer extends FawePlayer<Player> {
Bukkit.getServer().dispatchCommand(this.parent, cmd); Bukkit.getServer().dispatchCommand(this.parent, cmd);
} }
@Override
public FaweLocation getLocation() {
final Location loc = this.parent.getLocation();
return new FaweLocation(loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
}
@Override @Override
public com.sk89q.worldedit.entity.Player toWorldEditPlayer() { public com.sk89q.worldedit.entity.Player toWorldEditPlayer() {
return WorldEditPlugin.getInstance().wrapPlayer(this.parent); return WorldEditPlugin.getInstance().wrapPlayer(this.parent);

View File

@ -4,7 +4,6 @@ import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.example.NMSMappedFaweQueue; import com.boydti.fawe.example.NMSMappedFaweQueue;
import com.boydti.fawe.example.NMSRelighter; import com.boydti.fawe.example.NMSRelighter;
import com.boydti.fawe.object.FaweLocation;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.object.FaweQueue;
import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RegionWrapper;
@ -36,6 +35,7 @@ import com.sk89q.worldedit.internal.registry.AbstractFactory;
import com.sk89q.worldedit.internal.registry.InputParser; import com.sk89q.worldedit.internal.registry.InputParser;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.AbstractWorld; import com.sk89q.worldedit.world.AbstractWorld;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -319,8 +319,13 @@ public class FaweAPI {
* Reading only part of the file will result in unreliable bounds info for large edits * Reading only part of the file will result in unreliable bounds info for large edits
* @return * @return
*/ */
public static List<DiskStorageHistory> getBDFiles(FaweLocation origin, UUID user, int radius, long timediff, boolean shallow) { public static List<DiskStorageHistory> getBDFiles(Location origin, UUID user, int radius, long timediff, boolean shallow) {
File history = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + origin.world); Extent extent = origin.getExtent();
if (!(extent instanceof World)) {
throw new IllegalArgumentException("Origin is not a valid world");
}
World world = (World) extent;
File history = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HISTORY + File.separator + Fawe.imp().getWorldName(world));
if (!history.exists()) { if (!history.exists()) {
return new ArrayList<>(); return new ArrayList<>();
} }
@ -351,7 +356,6 @@ public class FaweAPI {
} }
} }
} }
World world = origin.getWorld();
files.sort((a, b) -> { files.sort((a, b) -> {
String aName = a.getName(); String aName = a.getName();
String bName = b.getName(); String bName = b.getName();
@ -360,7 +364,7 @@ public class FaweAPI {
long value = aI - bI; long value = aI - bI;
return value == 0 ? 0 : value < 0 ? -1 : 1; return value == 0 ? 0 : value < 0 ? -1 : 1;
}); });
RegionWrapper bounds = new RegionWrapper(origin.getX() - radius, origin.getX() + radius, origin.getZ() - radius, origin.getZ() + radius); RegionWrapper bounds = new RegionWrapper(origin.getBlockX() - radius, origin.getBlockX() + radius, origin.getBlockZ() - radius, origin.getBlockZ() + radius);
RegionWrapper boundsPlus = new RegionWrapper(bounds.minX - 64, bounds.maxX + 512, bounds.minZ - 64, bounds.maxZ + 512); RegionWrapper boundsPlus = new RegionWrapper(bounds.minX - 64, bounds.maxX + 512, bounds.minZ - 64, bounds.maxZ + 512);
HashSet<RegionWrapper> regionSet = Sets.<RegionWrapper>newHashSet(bounds); HashSet<RegionWrapper> regionSet = Sets.<RegionWrapper>newHashSet(bounds);
ArrayList<DiskStorageHistory> result = new ArrayList<>(); ArrayList<DiskStorageHistory> result = new ArrayList<>();

View File

@ -9,6 +9,7 @@ import com.boydti.fawe.object.changeset.DiskStorageHistory;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
@ -60,16 +61,16 @@ public class Rollback extends FaweCommand {
return false; return false;
} }
player.deleteMeta(FawePlayer.METADATA_KEYS.ROLLBACK); player.deleteMeta(FawePlayer.METADATA_KEYS.ROLLBACK);
final FaweLocation origin = player.getLocation(); Location origin = player.getPlayer().getLocation();
rollback(player, !player.hasPermission("fawe.rollback.deep"), Arrays.copyOfRange(args, 1, args.length), new RunnableVal<List<DiskStorageHistory>>() { rollback(player, !player.hasPermission("fawe.rollback.deep"), Arrays.copyOfRange(args, 1, args.length), new RunnableVal<List<DiskStorageHistory>>() {
@Override @Override
public void run(List<DiskStorageHistory> edits) { public void run(List<DiskStorageHistory> edits) {
long total = 0; long total = 0;
player.sendMessage("&d=| Username | Bounds | Distance | Changes | Age |="); player.sendMessage("&d=| Username | Bounds | Distance | Changes | Age |=");
for (DiskStorageHistory edit : edits) { for (DiskStorageHistory edit : edits) {
DiskStorageHistory.DiskStorageSummary summary = edit.summarize(new RegionWrapper(origin.getX(), origin.getX(), origin.getZ(), origin.getZ()), !player.hasPermission("fawe.rollback.deep")); DiskStorageHistory.DiskStorageSummary summary = edit.summarize(new RegionWrapper(origin.getBlockX(), origin.getBlockX(), origin.getBlockZ(), origin.getBlockZ()), !player.hasPermission("fawe.rollback.deep"));
RegionWrapper region = new RegionWrapper(summary.minX, summary.maxX, summary.minZ, summary.maxZ); RegionWrapper region = new RegionWrapper(summary.minX, summary.maxX, summary.minZ, summary.maxZ);
int distance = region.distance(origin.getX(), origin.getZ()); int distance = region.distance(origin.getBlockX(), origin.getBlockZ());
String name = Fawe.imp().getName(edit.getUUID()); String name = Fawe.imp().getName(edit.getUUID());
long seconds = (System.currentTimeMillis() - edit.getBDFile().lastModified()) / 1000; long seconds = (System.currentTimeMillis() - edit.getBDFile().lastModified()) / 1000;
total += edit.getBDFile().length(); total += edit.getBDFile().length();
@ -176,7 +177,7 @@ public class Rollback extends FaweCommand {
} }
} }
} }
FaweLocation origin = player.getLocation(); Location origin = player.getLocation();
List<DiskStorageHistory> edits = FaweAPI.getBDFiles(origin, user, radius, time, shallow); List<DiskStorageHistory> edits = FaweAPI.getBDFiles(origin, user, radius, time, shallow);
if (edits == null) { if (edits == null) {
player.sendMessage("&cToo broad, try refining your search!"); player.sendMessage("&cToo broad, try refining your search!");

View File

@ -21,6 +21,7 @@ import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.*; import com.sk89q.worldedit.*;
import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.registry.state.PropertyKey; import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BlockID; import com.sk89q.worldedit.world.block.BlockID;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
@ -249,8 +250,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
public void setPacketViewer(FawePlayer player) { public void setPacketViewer(FawePlayer player) {
this.player = player; this.player = player;
if (player != null) { if (player != null) {
FaweLocation pos = player.getLocation(); Location pos = player.getLocation();
this.chunkOffset = BlockVector2.at(1 + (pos.getX() >> 4), 1 + (pos.getZ() >> 4)); this.chunkOffset = BlockVector2.at(1 + (pos.getBlockX() >> 4), 1 + (pos.getBlockZ() >> 4));
} }
} }
@ -291,9 +292,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
int OX = chunkOffset.getBlockX(); int OX = chunkOffset.getBlockX();
int OZ = chunkOffset.getBlockZ(); int OZ = chunkOffset.getBlockZ();
FaweLocation position = player.getLocation(); Location position = player.getLocation();
int pcx = (position.getX() >> 4) - OX; int pcx = (position.getBlockX() >> 4) - OX;
int pcz = (position.getZ() >> 4) - OZ; int pcz = (position.getBlockZ() >> 4) - OZ;
int scx = Math.max(0, pcx - 15); int scx = Math.max(0, pcx - 15);
int scz = Math.max(0, pcz - 15); int scz = Math.max(0, pcz - 15);
@ -901,9 +902,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
int OX = chunkOffset.getBlockX(); int OX = chunkOffset.getBlockX();
int OZ = chunkOffset.getBlockZ(); int OZ = chunkOffset.getBlockZ();
FaweLocation position = player.getLocation(); Location position = player.getLocation();
int pcx = (position.getX() >> 4) - OX; int pcx = (position.getBlockX() >> 4) - OX;
int pcz = (position.getZ() >> 4) - OZ; int pcz = (position.getBlockZ() >> 4) - OZ;
int scx = Math.max(0, pcx - 10); int scx = Math.max(0, pcx - 10);
int scz = Math.max(0, pcz - 10); int scz = Math.max(0, pcz - 10);

View File

@ -1,86 +0,0 @@
package com.boydti.fawe.object;
import com.boydti.fawe.FaweAPI;
import com.sk89q.worldedit.math.*;
import com.sk89q.worldedit.world.World;
import jdk.nashorn.internal.ir.Block;
/**
* @deprecated This is likely to be removed in favor of {@link com.sk89q.worldedit.util.Location}.
*/
@Deprecated
public class FaweLocation {
public final BlockVector3 vector;
@Deprecated
public final int x;
@Deprecated
public final int z;
@Deprecated
public final int y;
public final String world;
public FaweLocation(final String world, final int x, final int y, final int z) {
this.world = world;
this.vector = BlockVector3.at(x,y,z);
this.x = vector.getX();
this.y = vector.getY();
this.z = vector.getZ();
}
/**
* Get the X coordinate.
*
* @return the x coordinate
*/
public int getX() {
return vector.getX();
}
/**
* Get the Y coordinate.
*
* @return the y coordinate
*/
public int getY() {
return vector.getY();
}
/**
* Get the Z coordinate.
*
* @return the z coordinate
*/
public int getZ() {
return vector.getZ();
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (this.getClass() != obj.getClass()) {
return false;
}
final FaweLocation other = (FaweLocation) obj;
return ((this.x == other.x) && (this.y == other.y) && (this.z == other.z) && (this.world.equals(other.world)));
}
public World getWorld() {
return FaweAPI.getWorld(world);
}
@Override
public String toString() {
return world + "," + x + "," + y + "," + z;
}
@Override
public int hashCode() {
return this.x << (8 + this.z) << (4 + this.y);
}
}

View File

@ -44,6 +44,7 @@ import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
import com.sk89q.worldedit.regions.selector.CylinderRegionSelector; import com.sk89q.worldedit.regions.selector.CylinderRegionSelector;
import com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector; import com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -489,7 +490,9 @@ public abstract class FawePlayer<T> extends Metadatable {
* *
* @return * @return
*/ */
public abstract FaweLocation getLocation(); public Location getLocation() {
return getPlayer().getLocation();
}
/** /**
* Get the WorldEdit player object * Get the WorldEdit player object

View File

@ -2,7 +2,6 @@ package com.boydti.fawe.util;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweLocation;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
@ -14,6 +13,7 @@ import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.*; import java.util.*;
@ -89,7 +89,7 @@ public class WEManager {
if (!Settings.IMP.REGION_RESTRICTIONS || player.hasPermission("fawe.bypass") || player.hasPermission("fawe.bypass.regions")) { if (!Settings.IMP.REGION_RESTRICTIONS || player.hasPermission("fawe.bypass") || player.hasPermission("fawe.bypass.regions")) {
return new Region[]{RegionWrapper.GLOBAL()}; return new Region[]{RegionWrapper.GLOBAL()};
} }
FaweLocation loc = player.getLocation(); Location loc = player.getLocation();
String world = player.getWorld().getName(); String world = player.getWorld().getName();
if (!world.equals(player.getMeta("lastMaskWorld"))) { if (!world.equals(player.getMeta("lastMaskWorld"))) {
player.deleteMeta("lastMaskWorld"); player.deleteMeta("lastMaskWorld");
@ -112,7 +112,7 @@ public class WEManager {
FaweMask mask = iter.next(); FaweMask mask = iter.next();
if (mask.isValid(player, type)) { if (mask.isValid(player, type)) {
Region region = mask.getRegion(); Region region = mask.getRegion();
if (region.contains(loc.vector)) { if (region.contains(loc.toBlockPoint())) {
regions.add(region); regions.add(region);
} else { } else {
removed = true; removed = true;