This commit is contained in:
Matt
2016-03-19 14:07:55 -04:00
parent 8074d041b8
commit 19b6df8268
17 changed files with 115 additions and 192 deletions

View File

@ -110,20 +110,15 @@ public class Cookie {
*/
public static String toString(final JSONObject jo) throws JSONException {
final StringBuilder sb = new StringBuilder();
sb.append(escape(jo.getString("name")));
sb.append("=");
sb.append(escape(jo.getString("value")));
sb.append(escape(jo.getString("name"))).append("=").append(escape(jo.getString("value")));
if (jo.has("expires")) {
sb.append(";expires=");
sb.append(jo.getString("expires"));
sb.append(";expires=").append(jo.getString("expires"));
}
if (jo.has("domain")) {
sb.append(";domain=");
sb.append(escape(jo.getString("domain")));
sb.append(";domain=").append(escape(jo.getString("domain")));
}
if (jo.has("path")) {
sb.append(";path=");
sb.append(escape(jo.getString("path")));
sb.append(";path=").append(escape(jo.getString("path")));
}
if (jo.optBoolean("secure")) {
sb.append(";secure");

View File

@ -925,7 +925,6 @@ public class PS {
@Deprecated
public ArrayList<Plot> sortPlotsByTimestamp(final Collection<Plot> plots) {
List<Plot> unknown = new ArrayList<>();
int hardmax = 256000;
int max = 0;
int overflowSize = 0;
@ -1351,25 +1350,21 @@ public class PS {
IndependentPlotGenerator pg;
if (baseGenerator != null && baseGenerator.isFull()) {
pg = baseGenerator.getPlotGenerator();
}
else if (worldSection != null) {
} else if (worldSection != null) {
String secondaryGeneratorName = worldSection.getString("generator.plugin");
GeneratorWrapper<?> secondaryGenerator = IMP.getGenerator(world, secondaryGeneratorName);
if (secondaryGenerator != null && secondaryGenerator.isFull()) {
pg = secondaryGenerator.getPlotGenerator();
}
else {
} else {
String primaryGeneratorName = worldSection.getString("generator.init");
GeneratorWrapper<?> primaryGenerator = IMP.getGenerator(world, primaryGeneratorName);
if (primaryGenerator != null && primaryGenerator.isFull()) {
pg = primaryGenerator.getPlotGenerator();
}
else {
} else {
return;
}
}
}
else {
} else {
return;
}
// Conventional plot generator
@ -1405,10 +1400,7 @@ public class PS {
return;
}
log(C.PREFIX.s() + "&aDetected world load for '" + world + "'");
String gen_string = worldSection.getString("generator.plugin");
if (gen_string == null) {
gen_string = "PlotSquared";
}
String gen_string = worldSection.getString("generator.plugin", "PlotSquared");
if (type == 2) {
Set<PlotCluster> clusters = clusters_tmp != null ? clusters_tmp.get(world) : new HashSet<PlotCluster>();
if (clusters == null) {
@ -1505,10 +1497,7 @@ public class PS {
clone.set(key, worldSection.get(key));
}
}
String gen_string = clone.getString("generator.plugin");
if (gen_string == null) {
gen_string = "PlotSquared";
}
String gen_string = clone.getString("generator.plugin", "PlotSquared");
GeneratorWrapper<?> areaGen = IMP.getGenerator(world, gen_string);
if (areaGen == null) {
throw new IllegalArgumentException("Invalid Generator: " + gen_string);

View File

@ -75,8 +75,7 @@ public class Claim extends SubCommand {
if (grants > 0) {
if (grants == 1) {
plr.removePersistentMeta("grantedPlots");
}
else {
} else {
plr.setPersistentMeta("grantedPlots", ByteArrayUtilities.integerToBytes(grants - 1));
}
sendMessage(plr, C.REMOVED_GRANTED_PLOT, "1", "" + (grants - 1));

View File

@ -464,12 +464,12 @@ public class Cluster extends SubCommand {
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[2]);
return false;
}
if (args[1].toLowerCase().equals("add")) {
if (args[1].equalsIgnoreCase("add")) {
cluster.helpers.add(uuid);
DBFunc.setHelper(cluster, uuid);
return MainUtil.sendMessage(plr, C.CLUSTER_ADDED_HELPER);
}
if (args[1].toLowerCase().equals("remove")) {
if (args[1].equalsIgnoreCase("remove")) {
cluster.helpers.remove(uuid);
DBFunc.removeHelper(cluster, uuid);
return MainUtil.sendMessage(plr, C.CLUSTER_REMOVED_HELPER);

View File

@ -12,15 +12,9 @@ import com.plotsquared.general.commands.CommandDeclaration;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
@CommandDeclaration(
command = "debugpaste",
aliases = { "dp" },
usage = "/plot debugpaste",
description = "Upload settings.yml & latest.log to HasteBin",
permission = "plots.debugpaste",
category = CommandCategory.DEBUG)
@CommandDeclaration(command = "debugpaste", aliases = "dp", usage = "/plot debugpaste", description = "Upload settings.yml & latest.log to HasteBin",
permission = "plots.debugpaste", category = CommandCategory.DEBUG)
public class DebugPaste extends SubCommand {
@Override
@ -39,11 +33,12 @@ public class DebugPaste extends SubCommand {
}
final StringBuilder b = new StringBuilder();
b.append("# Welcome to this paste\n# It is meant to provide us at IntellectualSites with better information about your problem\n\n# We will start with some informational files\n");
b.append("links.settings_yml: '").append(settingsYML).append("'\n");
b.append("links.latest_log: '").append(latestLOG).append("'\n");
b.append("\n# YAAAS! Now let us move on to the server info\n");
b.append("version.server: '").append(Arrays.toString(PS.get().IMP.getServerVersion())).append("'\n");
b.append("online_mode: ").append(UUIDHandler.getUUIDWrapper() + ";" + !Settings.OFFLINE_MODE).append("\n");
b.append("links.settings_yml: ").append(settingsYML).append("\n");
b.append("links.latest_log: ").append(latestLOG).append("\n");
b.append("\n# Server Information\n");
int[] sVersion = PS.get().IMP.getServerVersion();
b.append("version.server: ").append(sVersion[0]).append('.').append(sVersion[1]).append('.').append(sVersion[2]).append("\n");
b.append("online_mode: ").append(UUIDHandler.getUUIDWrapper()).append(";").append(!Settings.OFFLINE_MODE).append("\n");
b.append("plugins:");
for (String id : PS.get().IMP.getPluginIds()) {
String[] split = id.split(":");

View File

@ -1,5 +1,10 @@
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.StringMan;
import com.plotsquared.general.commands.Command;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
@ -11,11 +16,6 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.StringMan;
import com.plotsquared.general.commands.Command;
public class GenerateDocs {
public static void main(final String[] args) {
MainCommand.getInstance().addCommand(new WE_Anywhere());
@ -145,7 +145,7 @@ public class GenerateDocs {
split = Arrays.copyOfRange(split, 1, split.length);
for (String method : split) {
String perm = method.split("[,|)]")[1].trim();
if (!perm.toLowerCase().equals(perm)) {
if (!perm.equalsIgnoreCase(perm)) {
if (perm.startsWith("C.")) {
perm = C.valueOf(perm.split("\\.")[1]).s();
}
@ -178,7 +178,7 @@ public class GenerateDocs {
split = Arrays.copyOfRange(split, 1, split.length);
for (String method : split) {
String perm = method.split("[,|)]")[1].trim();
if (!perm.toLowerCase().equals(perm)) {
if (!perm.equalsIgnoreCase(perm)) {
if (perm.startsWith("C.")) {
perm = C.valueOf(perm.split("\\.")[1]).s();
}

View File

@ -20,16 +20,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
import com.intellectualcrafters.configuration.ConfigurationSection;
import com.intellectualcrafters.configuration.file.YamlConfiguration;
import com.intellectualcrafters.plot.PS;
@ -47,6 +37,16 @@ import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.general.commands.CommandDeclaration;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
@CommandDeclaration(
command = "template",
permission = "plots.admin",
@ -161,19 +161,12 @@ public class Template extends SubCommand {
} catch (final Exception e) {
e.printStackTrace();
}
String manager = worldConfig.getString("generator.plugin");
if (manager == null) {
manager = "PlotSquared";
}
String generator = worldConfig.getString("generator.init");
if (generator == null) {
generator = manager;
}
final int type = worldConfig.getInt("generator.type");
final int terrain = worldConfig.getInt("generator.terrain");
final SetupObject setup = new SetupObject();
String manager = worldConfig.getString("generator.plugin", "PlotSquared");
String generator = worldConfig.getString("generator.init", manager);
int type = worldConfig.getInt("generator.type");
int terrain = worldConfig.getInt("generator.terrain");
SetupObject setup = new SetupObject();
setup.plotManager = manager;
setup.setupGenerator = generator;
setup.type = type;

View File

@ -22,7 +22,6 @@ package com.intellectualcrafters.plot.object;
import com.intellectualcrafters.configuration.ConfigurationSection;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Configuration;
import com.intellectualcrafters.plot.config.ConfigurationNode;
import com.intellectualcrafters.plot.config.Settings;
@ -30,11 +29,24 @@ import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.generator.GridPlotWorld;
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.PlotGamemode;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.intellectualcrafters.plot.util.area.QuadMap;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
/**
@ -128,7 +140,7 @@ public abstract class PlotArea {
/**
* Returns the region for this PlotArea
* @Nullable
*
* @return RegionWrapper or null if no applicable region
*/
public RegionWrapper getRegionAbs() {
@ -160,7 +172,7 @@ public abstract class PlotArea {
/**
* Get the implementation independent generator for this area
* @Nullable
*
* @return
*/
public IndependentPlotGenerator getGenerator() {
@ -230,8 +242,11 @@ public abstract class PlotArea {
SCHEMATICS = config.getStringList("schematic.schematics");
USE_ECONOMY = config.getBoolean("economy.use") && EconHandler.manager != null;
ConfigurationSection priceSection = config.getConfigurationSection("economy.prices");
for (String key : priceSection.getKeys(false)) {
PRICES.put(key, priceSection.getDouble(key));
if (USE_ECONOMY) {
PRICES = new HashMap<>();
for (String key : priceSection.getKeys(false)) {
PRICES.put(key, priceSection.getDouble(key));
}
}
PLOT_CHAT = config.getBoolean("chat.enabled");
WORLD_BORDER = config.getBoolean("world.border");
@ -743,22 +758,7 @@ public abstract class PlotArea {
}
return true;
}
public boolean mergePlots(final PlotPlayer player, final ArrayList<PlotId> plotIds) {
if (EconHandler.manager != null && USE_ECONOMY) {
final double cost = plotIds.size() * (PRICES.containsKey("merge") ? PRICES.get("merge") : 0);
if (cost > 0d) {
if (EconHandler.manager.getMoney(player) < cost) {
MainUtil.sendMessage(player, C.CANNOT_AFFORD_MERGE, "" + cost);
return false;
}
EconHandler.manager.withdrawMoney(player, cost);
MainUtil.sendMessage(player, C.REMOVED_BALANCE, cost + "");
}
}
return mergePlots(plotIds, true, true);
}
public boolean removePlot(PlotId id) {
return plots.remove(id) != null;
}

View File

@ -20,16 +20,16 @@ public abstract class PlotChunk<T> implements Cloneable {
public PlotChunk(final ChunkWrapper chunk) {
this.chunk = chunk;
}
public ChunkWrapper getChunkWrapper() {
return this.chunk;
}
public void setChunkWrapper(final ChunkWrapper loc) {
this.chunk = loc;
this.objChunk = null;
}
public ChunkWrapper getChunkWrapper() {
return this.chunk;
}
public int getX() {
return chunk.x;
}
@ -194,7 +194,7 @@ public abstract class PlotChunk<T> implements Cloneable {
@Override
public boolean equals(Object obj) {
if (obj == null || !(obj instanceof PlotChunk)) {
if (!(obj instanceof PlotChunk)) {
return false;
}
return chunk.equals(((PlotChunk) obj).chunk);

View File

@ -316,7 +316,7 @@ public class ReflectionUtils {
} catch (final NoSuchMethodException ignored) {
return new RefMethod(clazz.getDeclaredMethod(name, classes));
}
} catch (final Exception e) {
} catch (NoSuchMethodException | SecurityException e) {
throw new RuntimeException(e);
}
}
@ -348,7 +348,7 @@ public class ReflectionUtils {
} catch (final NoSuchMethodException ignored) {
return new RefConstructor(clazz.getDeclaredConstructor(classes));
}
} catch (final Exception e) {
} catch (NoSuchMethodException | SecurityException e) {
throw new RuntimeException(e);
}
}