2.10, WE blacklist, plot border, string comparison

-
This commit is contained in:
boy0001 2015-05-02 23:58:52 +10:00
parent d61e23d04f
commit b45eaf1c90
6 changed files with 26 additions and 34 deletions

View File

@ -8,7 +8,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<artifactId>PlotSquared</artifactId>
<version>2.10</version>
<version>2.10.1</version>
<name>PlotSquared</name>
<packaging>jar</packaging>
<build>

View File

@ -866,6 +866,7 @@ public class PlotSquared {
options.put("worldedit.require-selection-in-mask", Settings.REQUIRE_SELECTION);
options.put("worldedit.max-volume", Settings.WE_MAX_VOLUME);
options.put("worldedit.max-iterations", Settings.WE_MAX_ITERATIONS);
options.put("worldedit.blacklist", Arrays.asList("cs", ".s", "restore", "snapshot", "delchunks", "listchunks"));
// Chunk processor
options.put("chunk-processor.enabled", Settings.CHUNK_PROCESSOR);
@ -941,6 +942,7 @@ public class PlotSquared {
Settings.REQUIRE_SELECTION = config.getBoolean("worldedit.require-selection-in-mask");
Settings.WE_MAX_VOLUME = config.getLong("worldedit.max-volume");
Settings.WE_MAX_ITERATIONS = config.getLong("worldedit.max-iterations");
Settings.WE_BLACKLIST = config.getStringList("worldedit.blacklist");
// Chunk processor
Settings.CHUNK_PROCESSOR = config.getBoolean("chunk-processor.enabled");

View File

@ -20,6 +20,9 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.config;
import java.util.ArrayList;
import java.util.List;
/**
* Updater and DB settings
*
@ -68,6 +71,7 @@ public class Settings {
public static boolean REQUIRE_SELECTION = true;
public static long WE_MAX_VOLUME = 500000;
public static long WE_MAX_ITERATIONS = 1000;
public static List<String> WE_BLACKLIST = new ArrayList<>();
/**
* Default kill road mobs: true
*/

View File

@ -277,7 +277,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
final PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
for (final PlotId id : plotIds) {
if (!block.equals(unclaim)) {
if (block.id != 0 || !block.equals(unclaim)) {
setWall(plotworld, id, new PlotBlock[] { block });
}
}
@ -298,7 +298,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
public boolean claimPlot(final PlotWorld plotworld, final Plot plot) {
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
if (!claim.equals(unclaim)) {
if (claim.id != 0 || !claim.equals(unclaim)) {
setWall(plotworld, plot.id, new PlotBlock[] { claim });
}
return true;
@ -308,7 +308,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
public boolean unclaimPlot(final PlotWorld plotworld, final Plot plot) {
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
if (!claim.equals(unclaim)) {
if (unclaim.id != 0 || !claim.equals(unclaim)) {
setWall(plotworld, plot.id, new PlotBlock[] { unclaim });
}
MainUtil.removeSign(plot);

View File

@ -36,12 +36,9 @@ public class WEListener implements Listener {
public final HashSet<String> region = new HashSet<>(Arrays.asList("move", "set", "replace", "overlay", "walls", "outline", "deform", "hollow", "smooth", "naturalize", "paste", "count", "distr", "regen", "copy", "cut", "green", "setbiome"));
public final HashSet<String> regionExtend = new HashSet<>(Arrays.asList("stack"));
public final HashSet<String> unregioned = new HashSet<>(Arrays.asList("paste", "redo", "undo", "rotate", "flip", "generate", "schematic", "schem"));
public final HashSet<String> unsafe1 = new HashSet<>(Arrays.asList("cs", ".s", "restore", "snapshot", "delchunks", "listchunks", "sel poly"));
public final HashSet<String> unsafe2 = new HashSet<>(Arrays.asList("sel poly", "worldedit reload"));
public final HashSet<String> unsafe1 = new HashSet<>(Arrays.asList("cs", ".s", "restore", "snapshot", "delchunks", "listchunks"));
public final HashSet<String> restricted = new HashSet<>(Arrays.asList("up"));
// public final HashSet<String> allowSingleSlash = new HashSet<>(Arrays.asList("sel", ".s", "cs", "restore", "brush", "fixwater", "fixlava", "up", "worldedit", "mask", "gmask", "snapshot", "schem", "schematic", "remove", "fill", "pumpkins", "forestgen", "removenear", "ex", "butcher", "size", "snow"));
public boolean checkCommand(List<String> list, String cmd) {
for (String identifier : list) {
if (("/" + identifier).equals(cmd) || ("//" + identifier).equals(cmd) || ("/worldedit:/" + identifier).equals(cmd) || ("/worldedit:" + identifier).equals(cmd)) {
@ -226,20 +223,12 @@ public class WEListener implements Listener {
}
return true;
}
if (unsafe2.contains(reduced)) {
MainUtil.sendMessage(pp, C.WORLDEDIT_UNSAFE);
e.setCancelled(true);
if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) {
MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASS);
}
return true;
}
if (regionExtend.contains(reduced)) {
return checkSelection(p, pp, getInt(split[1]), maxVolume, e);
}
}
String reduced = reduceCmd(split[0], single);
if (unsafe1.contains(reduced)) {
if (Settings.WE_BLACKLIST.contains(reduced)) {
MainUtil.sendMessage(pp, C.WORLDEDIT_UNSAFE);
e.setCancelled(true);
if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) {

View File

@ -23,6 +23,9 @@ package com.intellectualcrafters.plot.util;
import java.util.ArrayList;
import java.util.Collections;
import org.apache.commons.lang.StringUtils;
import org.bukkit.util.StringUtil;
/**
* String comparison library
*
@ -39,7 +42,7 @@ public class StringComparison {
*
* Can be checked for low match (< .25 or something)
*/
private double match = 0;
private double match = Integer.MAX_VALUE;
/**
* The actual object
*/
@ -51,12 +54,13 @@ public class StringComparison {
* @param input Input Base Value
* @param objects Objects to compare
*/
public StringComparison(final String input, final Object[] objects) {
double c;
public StringComparison(String input, final Object[] objects) {
int c;
this.bestMatch = objects[0].toString();
this.bestMatchObject = objects[0];
input = input.toLowerCase();
for (final Object o : objects) {
if ((c = compare(input, o.toString())) > this.match) {
if ((c = compare(input, o.toString().toLowerCase())) < this.match) {
this.match = c;
this.bestMatch = o.toString();
this.bestMatchObject = o;
@ -72,20 +76,13 @@ public class StringComparison {
*
* @return match
*/
public static double compare(final String s1, final String s2) {
final ArrayList p1 = wLetterPair(s1.toUpperCase()), p2 = wLetterPair(s2.toUpperCase());
int intersection = 0;
final int union = p1.size() + p2.size();
for (final Object aP1 : p1) {
for (final Object aP2 : p2) {
if (aP1.equals(aP2)) {
intersection++;
p2.remove(aP2);
break;
public static int compare(final String s1, final String s2) {
int distance = StringUtils.getLevenshteinDistance(s1, s2);
if (s2.contains(s1) || s2.contains(s1)) {
distance -= 4;
}
}
}
return (2.0 * intersection) / union;
// distance += Math.abs(s1.length() - s2.length());
return distance;
}
/**