mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-06 20:56:41 +00:00
Remove a tonne of code from WorldEdit. This breaks backwards compatibility. More will be removed. Sorry :)
This commit is contained in:
@ -19,14 +19,15 @@
|
||||
|
||||
package com.sk89q.worldedit.function.block;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.function.LayerFunction;
|
||||
import com.sk89q.worldedit.masks.BlockMask;
|
||||
import com.sk89q.worldedit.masks.Mask;
|
||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -37,11 +38,12 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*/
|
||||
public class Naturalizer implements LayerFunction {
|
||||
|
||||
private static final BaseBlock grass = new BaseBlock(BlockTypes.GRASS_BLOCK);
|
||||
private static final BaseBlock dirt = new BaseBlock(BlockTypes.DIRT);
|
||||
private static final BaseBlock stone = new BaseBlock(BlockTypes.STONE);
|
||||
|
||||
private final EditSession editSession;
|
||||
private final BaseBlock grass = new BaseBlock(BlockTypes.GRASS_BLOCK);
|
||||
private final BaseBlock dirt = new BaseBlock(BlockTypes.DIRT);
|
||||
private final BaseBlock stone = new BaseBlock(BlockTypes.STONE);
|
||||
private final Mask mask = new BlockMask(grass, dirt, stone);
|
||||
private final Mask mask;
|
||||
private int affected = 0;
|
||||
|
||||
/**
|
||||
@ -52,6 +54,7 @@ public class Naturalizer implements LayerFunction {
|
||||
public Naturalizer(EditSession editSession) {
|
||||
checkNotNull(editSession);
|
||||
this.editSession = editSession;
|
||||
this.mask = new BlockMask(editSession, Sets.newHashSet(grass, dirt, stone));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,12 +68,12 @@ public class Naturalizer implements LayerFunction {
|
||||
|
||||
@Override
|
||||
public boolean isGround(Vector position) {
|
||||
return mask.matches(editSession, position);
|
||||
return mask.test(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position, int depth) throws WorldEditException {
|
||||
if (mask.matches(editSession, position)) {
|
||||
if (mask.test(position)) {
|
||||
affected++;
|
||||
switch (depth) {
|
||||
case 0:
|
||||
|
@ -131,82 +131,6 @@ public final class Masks {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap an old-style mask and convert it to a new mask.
|
||||
*
|
||||
* <p>Note, however, that this is strongly not recommended because
|
||||
* {@link com.sk89q.worldedit.masks.Mask#prepare(LocalSession, LocalPlayer, Vector)}
|
||||
* is not called.</p>
|
||||
*
|
||||
* @param mask the old-style mask
|
||||
* @param editSession the edit session to bind to
|
||||
* @return a new-style mask
|
||||
* @deprecated Please avoid if possible
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Mask wrap(final com.sk89q.worldedit.masks.Mask mask, final EditSession editSession) {
|
||||
checkNotNull(mask);
|
||||
return new AbstractMask() {
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
return mask.matches(editSession, vector);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap an old-style mask and convert it to a new mask.
|
||||
*
|
||||
* <p>As an {@link EditSession} is not provided in this case, one will be
|
||||
* taken from the {@link Request}, if possible. If not possible, then the
|
||||
* mask will return false.</p>
|
||||
*
|
||||
* @param mask the old-style mask
|
||||
* @return a new-style mask
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Mask wrap(final com.sk89q.worldedit.masks.Mask mask) {
|
||||
checkNotNull(mask);
|
||||
return new AbstractMask() {
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
EditSession editSession = Request.request().getEditSession();
|
||||
return editSession != null && mask.matches(editSession, vector);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a new-style mask to an old-style mask.
|
||||
*
|
||||
* @param mask the new-style mask
|
||||
* @return an old-style mask
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static com.sk89q.worldedit.masks.Mask wrap(final Mask mask) {
|
||||
checkNotNull(mask);
|
||||
return new com.sk89q.worldedit.masks.AbstractMask() {
|
||||
@Override
|
||||
public boolean matches(EditSession editSession, Vector position) {
|
||||
Request.request().setEditSession(editSession);
|
||||
return mask.test(position);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static class AlwaysTrue implements Mask, Mask2D {
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
|
@ -1,72 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.function.pattern;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Utility methods related to {@link Pattern}s.
|
||||
*/
|
||||
public final class Patterns {
|
||||
|
||||
private Patterns() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap an old-style pattern and return a new pattern.
|
||||
*
|
||||
* @param pattern the pattern
|
||||
* @return a new-style pattern
|
||||
*/
|
||||
public static Pattern wrap(final com.sk89q.worldedit.patterns.Pattern pattern) {
|
||||
checkNotNull(pattern);
|
||||
return new Pattern() {
|
||||
@Override
|
||||
public BaseBlock apply(Vector position) {
|
||||
return pattern.next(position);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap a new-style pattern and return an old-style pattern.
|
||||
*
|
||||
* @param pattern the pattern
|
||||
* @return an old-style pattern
|
||||
*/
|
||||
public static com.sk89q.worldedit.patterns.Pattern wrap(final Pattern pattern) {
|
||||
checkNotNull(pattern);
|
||||
return new com.sk89q.worldedit.patterns.Pattern() {
|
||||
@Override
|
||||
public BaseBlock next(Vector position) {
|
||||
return pattern.apply(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock next(int x, int y, int z) {
|
||||
return next(new Vector(x, y, z));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user