mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-03 06:04:43 +02:00
@ -2,21 +2,13 @@ package com.plotsquared.bukkit.chat;
|
||||
|
||||
import static com.plotsquared.bukkit.chat.TextualComponent.rawText;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.intellectualcrafters.configuration.serialization.ConfigurationSerializable;
|
||||
import com.intellectualcrafters.configuration.serialization.ConfigurationSerialization;
|
||||
import org.bukkit.Achievement;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -28,13 +20,21 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.intellectualcrafters.configuration.serialization.ConfigurationSerializable;
|
||||
import com.intellectualcrafters.configuration.serialization.ConfigurationSerialization;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Represents a formattable message. Such messages can use elements such as colors, formatting codes, hover and click data, and other features provided by the vanilla Minecraft <a href="http://minecraft.gamepedia.com/Tellraw#Raw_JSON_Text">JSON message formatter</a>.
|
||||
@ -61,7 +61,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
@Override
|
||||
public FancyMessage clone() throws CloneNotSupportedException {
|
||||
final FancyMessage instance = (FancyMessage) super.clone();
|
||||
instance.messageParts = new ArrayList<MessagePart>(messageParts.size());
|
||||
instance.messageParts = new ArrayList<>(messageParts.size());
|
||||
for (int i = 0; i < messageParts.size(); i++) {
|
||||
instance.messageParts.add(i, messageParts.get(i).clone());
|
||||
}
|
||||
@ -79,7 +79,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
}
|
||||
|
||||
public FancyMessage(final TextualComponent firstPartText) {
|
||||
messageParts = new ArrayList<MessagePart>();
|
||||
messageParts = new ArrayList<>();
|
||||
messageParts.add(new MessagePart(firstPartText));
|
||||
jsonString = null;
|
||||
dirty = false;
|
||||
@ -503,9 +503,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
* @return This builder instance.
|
||||
*/
|
||||
public FancyMessage translationReplacements(final FancyMessage... replacements) {
|
||||
for (final FancyMessage str : replacements) {
|
||||
latest().translationReplacements.add(str);
|
||||
}
|
||||
Collections.addAll(latest().translationReplacements, replacements);
|
||||
|
||||
dirty = true;
|
||||
|
||||
@ -742,7 +740,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
// Doc copied from interface
|
||||
@Override
|
||||
public Map<String, Object> serialize() {
|
||||
final HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("messageParts", messageParts);
|
||||
// map.put("JSON", toJSONString());
|
||||
return map;
|
||||
@ -791,7 +789,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
// Deserialize text
|
||||
if (TextualComponent.isTextKey(entry.getKey())) {
|
||||
// The map mimics the YAML serialization, which has a "key" field and one or more "value" fields
|
||||
final Map<String, Object> serializedMapForm = new HashMap<String, Object>(); // Must be object due to Bukkit serializer API compliance
|
||||
final Map<String, Object> serializedMapForm = new HashMap<>(); // Must be object due to Bukkit serializer API compliance
|
||||
serializedMapForm.put("key", entry.getKey());
|
||||
if (entry.getValue().isJsonPrimitive()) {
|
||||
// Assume string
|
||||
|
@ -1,18 +1,17 @@
|
||||
package com.plotsquared.bukkit.database.plotme;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
import com.intellectualcrafters.configuration.file.FileConfiguration;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
||||
public abstract class APlotMeConnector {
|
||||
public abstract Connection getPlotMeConnection(final String plugin, final FileConfiguration plotConfig, final String dataFolder);
|
||||
@ -42,15 +41,12 @@ public abstract class APlotMeConnector {
|
||||
final String wallblock = plotConfig.getString("worlds." + world + ".WallBlockId"); //
|
||||
PS.get().config.set("worlds." + actualWorldName + ".wall.block", wallblock);
|
||||
final String floor = plotConfig.getString("worlds." + world + ".PlotFloorBlockId"); //
|
||||
PS.get().config.set("worlds." + actualWorldName + ".plot.floor", Arrays.asList(floor));
|
||||
PS.get().config.set("worlds." + actualWorldName + ".plot.floor", Collections.singletonList(floor));
|
||||
final String filling = plotConfig.getString("worlds." + world + ".PlotFillingBlockId"); //
|
||||
PS.get().config.set("worlds." + actualWorldName + ".plot.filling", Arrays.asList(filling));
|
||||
PS.get().config.set("worlds." + actualWorldName + ".plot.filling", Collections.singletonList(filling));
|
||||
final String road = plotConfig.getString("worlds." + world + ".RoadMainBlockId");
|
||||
PS.get().config.set("worlds." + actualWorldName + ".road.block", road);
|
||||
Integer height = plotConfig.getInt("worlds." + world + ".RoadHeight"); //
|
||||
if (height == null) {
|
||||
height = 64;
|
||||
}
|
||||
PS.get().config.set("worlds." + actualWorldName + ".road.height", height);
|
||||
}
|
||||
|
||||
|
@ -123,9 +123,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
e.printStackTrace();
|
||||
owner = UUID.nameUUIDFromBytes(bytes);
|
||||
}
|
||||
if (owner != null) {
|
||||
UUIDHandler.add(new StringWrapper(name), owner);
|
||||
}
|
||||
UUIDHandler.add(new StringWrapper(name), owner);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -166,13 +164,13 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
|
||||
r.close();
|
||||
stmt.close();
|
||||
|
||||
|
||||
try {
|
||||
|
||||
|
||||
PS.log(" - " + prefix + "Denied");
|
||||
stmt = connection.prepareStatement("SELECT * FROM `" + prefix + "Denied`");
|
||||
r = stmt.executeQuery();
|
||||
|
||||
|
||||
while (r.next()) {
|
||||
final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
||||
final String name = r.getString("player");
|
||||
@ -195,9 +193,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
e.printStackTrace();
|
||||
denied = UUID.nameUUIDFromBytes(bytes);
|
||||
}
|
||||
if (denied != null) {
|
||||
UUIDHandler.add(new StringWrapper(name), denied);
|
||||
}
|
||||
UUIDHandler.add(new StringWrapper(name), denied);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -213,10 +209,10 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
plots.get(world).get(id).getDenied().add(denied);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
stmt = connection.prepareStatement("SELECT * FROM `" + plugin + "Allowed`");
|
||||
r = stmt.executeQuery();
|
||||
|
||||
|
||||
while (r.next()) {
|
||||
final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
||||
final String name = r.getString("player");
|
||||
@ -239,9 +235,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
e.printStackTrace();
|
||||
helper = UUID.nameUUIDFromBytes(bytes);
|
||||
}
|
||||
if (helper != null) {
|
||||
UUIDHandler.add(new StringWrapper(name), helper);
|
||||
}
|
||||
UUIDHandler.add(new StringWrapper(name), helper);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
@ -257,11 +251,12 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
plots.get(world).get(id).getTrusted().add(helper);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
r.close();
|
||||
stmt.close();
|
||||
|
||||
} catch (final Exception e) {}
|
||||
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
return plots;
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ import java.nio.file.Paths;
|
||||
import java.sql.Connection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
@ -51,7 +52,9 @@ import com.plotsquared.bukkit.generator.HybridGen;
|
||||
|
||||
/**
|
||||
* Created 2014-08-17 for PlotSquared
|
||||
*
|
||||
*
|
||||
|
||||
|
||||
*/
|
||||
public class LikePlotMeConverter {
|
||||
private final String plugin;
|
||||
@ -128,7 +131,8 @@ public class LikePlotMeConverter {
|
||||
content = content.replaceAll("PlotMe-DefaultGenerator", "PlotSquared");
|
||||
content = content.replaceAll(plugin, "PlotSquared");
|
||||
Files.write(path, content.getBytes(charset));
|
||||
content = content.replaceAll(plugin, "PlotSquared");
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean run(final APlotMeConnector connector) {
|
||||
@ -210,7 +214,7 @@ public class LikePlotMeConverter {
|
||||
pathwidth = 7;
|
||||
}
|
||||
PS.get().config.set("worlds." + world + ".road.width", pathwidth);
|
||||
}
|
||||
|
||||
Integer pathheight = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||
if ((pathheight == null) || (pathheight == 0)) {
|
||||
pathheight = 64;
|
||||
@ -232,21 +236,21 @@ public class LikePlotMeConverter {
|
||||
if (floor == null) {
|
||||
floor = "2";
|
||||
}
|
||||
floor = "2";
|
||||
PS.get().config.set("worlds." + world + ".plot.floor", Collections.singletonList(floor));
|
||||
String filling = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".FillBlock"); //
|
||||
if (filling == null) {
|
||||
filling = "3";
|
||||
}
|
||||
filling = "3";
|
||||
PS.get().config.set("worlds." + world + ".plot.filling", Collections.singletonList(filling));
|
||||
String road = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".RoadMainBlock");
|
||||
if (road == null) {
|
||||
road = "5";
|
||||
}
|
||||
PS.get().config.set("worlds." + world + ".road.block", road);
|
||||
Integer height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||
PS.get().config.set("worlds." + world + ".road.block", road);
|
||||
if (height == 0) {
|
||||
height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".GroundHeight"); //
|
||||
if ((height == null) || (height == 0)) {
|
||||
if (height == 0) {
|
||||
height = 64;
|
||||
}
|
||||
}
|
||||
@ -255,12 +259,13 @@ public class LikePlotMeConverter {
|
||||
PS.get().config.set("worlds." + actualWorldName + ".wall.height", height);
|
||||
PS.get().config.save(PS.get().configFile);
|
||||
}
|
||||
PS.get().config.save(PS.get().configFile);
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
for (final String world : plots.keySet()) {
|
||||
int duplicate = 0;
|
||||
for (final Plot plot : plots.get(world).values()) {
|
||||
int duplicate = 0;
|
||||
if (PS.get().getPlot(world, plot.getId()) == null) {
|
||||
createdPlots.add(plot);
|
||||
} else {
|
||||
duplicate++;
|
||||
|
@ -136,8 +136,8 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
||||
final Plot plot = entry.getValue();
|
||||
final HashMap<PlotId, boolean[]> mergeMap = merges.get(plot.world);
|
||||
if (mergeMap != null) {
|
||||
if (mergeMap.containsKey(plot.id)) {
|
||||
plot.setMerged(mergeMap.get(plot.id));
|
||||
if (mergeMap.containsKey(plot.getId())) {
|
||||
plot.setMerged(mergeMap.get(plot.getId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -188,7 +188,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
||||
map = new HashMap<>();
|
||||
processed.put(plot.world, map);
|
||||
}
|
||||
map.put(plot.id, plot);
|
||||
map.put(plot.getId(), plot);
|
||||
}
|
||||
return processed;
|
||||
}
|
||||
|
@ -20,15 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.plotsquared.bukkit.generator;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import com.intellectualcrafters.plot.generator.HybridPlotManager;
|
||||
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
||||
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||
@ -36,12 +27,22 @@ import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* The default generator is very messy, as we have decided to try externalize all calculations from within the loop. -
|
||||
* You will see a lot of slower implementations have a single for loop. - This is perfectly fine to do, it will just
|
||||
* mean world generation may take somewhat longer
|
||||
*
|
||||
*
|
||||
|
||||
|
||||
*/
|
||||
public class HybridGen extends BukkitPlotGenerator {
|
||||
|
||||
@ -120,7 +121,7 @@ public class HybridGen extends BukkitPlotGenerator {
|
||||
biome = Biome.valueOf(this.plotworld.PLOT_BIOME);
|
||||
try {
|
||||
maxY = Bukkit.getWorld(plotworld.worldname).getMaxHeight();
|
||||
try {
|
||||
} catch (final NullPointerException ignored) {}
|
||||
if (maxY == 0) {
|
||||
maxY = 256;
|
||||
}
|
||||
@ -176,7 +177,7 @@ public class HybridGen extends BukkitPlotGenerator {
|
||||
public List<BukkitPlotPopulator> getPopulators(final String world) {
|
||||
// You can have as many populators as you would like, e.g. tree
|
||||
// populator, ore populator
|
||||
// You can have as many populators as you would like, e.g. tree
|
||||
return Collections.singletonList((BukkitPlotPopulator) new HybridPop(plotworld));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -292,6 +293,5 @@ public class HybridGen extends BukkitPlotGenerator {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,9 @@ import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
|
||||
/**
|
||||
* Player Events involving plots
|
||||
*
|
||||
*
|
||||
|
||||
|
||||
*/
|
||||
@SuppressWarnings({ "deprecation", "unchecked" })
|
||||
public class PlayerEvents extends com.plotsquared.listener.PlotListener implements Listener {
|
||||
@ -593,7 +595,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
final String message = event.getMessage();
|
||||
String format = C.PLOT_CHAT_FORMAT.s();
|
||||
final String sender = event.getPlayer().getDisplayName();
|
||||
String format = C.PLOT_CHAT_FORMAT.s();
|
||||
final PlotId id = plot.getId();
|
||||
final Set<Player> recipients = event.getRecipients();
|
||||
recipients.clear();
|
||||
for (final Player p : Bukkit.getOnlinePlayers()) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.plotsquared.bukkit.listeners.worldedit;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
@ -35,16 +36,16 @@ public class WEListener implements Listener {
|
||||
public final HashSet<String> rad2 = new HashSet<>(Arrays.asList("fill", "fillr", "removenear", "remove"));
|
||||
public final HashSet<String> rad2_1 = new HashSet<>(Arrays.asList("hcyl", "cyl"));
|
||||
public final HashSet<String> rad2_2 = new HashSet<>(Arrays.asList("sphere", "pyramid"));
|
||||
public final HashSet<String> rad2_3 = new HashSet<>(Arrays.asList("brush smooth"));
|
||||
public final HashSet<String> rad3_1 = new HashSet<>(Arrays.asList("brush gravity"));
|
||||
public final HashSet<String> rad2_3 = new HashSet<>(Collections.singletonList("brush smooth"));
|
||||
public final HashSet<String> rad3_1 = new HashSet<>(Collections.singletonList("brush gravity"));
|
||||
public final HashSet<String> rad3_2 = new HashSet<>(Arrays.asList("brush sphere", "brush cylinder"));
|
||||
|
||||
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> regionExtend = new HashSet<>(Collections.singletonList("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"));
|
||||
public final HashSet<String> restricted = new HashSet<>(Arrays.asList("up"));
|
||||
public final HashSet<String> restricted = new HashSet<>(Collections.singletonList("up"));
|
||||
public final HashSet<String> other = new HashSet<>(Arrays.asList("undo", "redo"));
|
||||
|
||||
public boolean checkCommand(final List<String> list, final String cmd) {
|
||||
@ -137,11 +138,9 @@ public class WEListener implements Listener {
|
||||
final long volume = Math.abs((pos1.getBlockX() - pos2.getBlockX()) * (pos1.getBlockY() - pos2.getBlockY()) * (pos1.getBlockZ() - pos2.getBlockZ())) * modifier;
|
||||
return checkVolume(pp, volume, max, e);
|
||||
}
|
||||
|
||||
private final boolean set = false;
|
||||
|
||||
|
||||
public boolean delay(final Player player, final String command, final boolean delayed) {
|
||||
if (!Settings.QUEUE_COMMANDS || !Settings.EXPERIMENTAL_FAST_ASYNC_WORLDEDIT || set) {
|
||||
if (!Settings.QUEUE_COMMANDS || !Settings.EXPERIMENTAL_FAST_ASYNC_WORLDEDIT) {
|
||||
return false;
|
||||
}
|
||||
final boolean free = SetBlockQueue.addNotify(null);
|
||||
|
@ -1,13 +1,25 @@
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
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.object.PlotLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.BlockUpdateUtil;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SetBlockQueue.ChunkWrapper;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
||||
import com.plotsquared.bukkit.object.entity.EntityWrapper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.DyeColor;
|
||||
@ -43,26 +55,13 @@ import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
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.object.PlotLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.BlockUpdateUtil;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SetBlockQueue.ChunkWrapper;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
||||
import com.plotsquared.bukkit.object.entity.EntityWrapper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
public class BukkitChunkManager extends ChunkManager {
|
||||
@Override
|
||||
@ -83,7 +82,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
// Chunk chunk = worldObj.getChunkAt(loc.x, loc.z);
|
||||
worldObj.regenerateChunk(loc.x, loc.z);
|
||||
if (BlockUpdateUtil.setBlockManager != null) {
|
||||
BlockUpdateUtil.setBlockManager.update(world, Arrays.asList(loc));
|
||||
BlockUpdateUtil.setBlockManager.update(world, Collections.singletonList(loc));
|
||||
}
|
||||
for (final Player player : worldObj.getPlayers()) {
|
||||
final org.bukkit.Location locObj = player.getLocation();
|
||||
@ -854,8 +853,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
|
||||
@Override
|
||||
public boolean loadChunk(final String world, final ChunkLoc loc, final boolean force) {
|
||||
boolean result = BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).load(force);
|
||||
return result;
|
||||
return BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).load(force);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -902,10 +900,8 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
BukkitSetBlockManager.setBlockManager.set(world2, xx, y, zz, 0, (byte) 0);
|
||||
}
|
||||
} else if (id2 == 0) {
|
||||
if (id1 != 0) {
|
||||
BukkitSetBlockManager.setBlockManager.set(world1, x, y, z, 0, (byte) 0);
|
||||
BukkitSetBlockManager.setBlockManager.set(world2, xx, y, zz, id1, data1);
|
||||
}
|
||||
BukkitSetBlockManager.setBlockManager.set(world1, x, y, z, 0, (byte) 0);
|
||||
BukkitSetBlockManager.setBlockManager.set(world2, xx, y, zz, id1, data1);
|
||||
} else if (id1 == id2) {
|
||||
if (data1 != data2) {
|
||||
block1.setData(data2);
|
||||
@ -948,8 +944,8 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
final int[] count = new int[6];
|
||||
final World world = BukkitUtil.getWorld(plot.world);
|
||||
|
||||
final Location bot = MainUtil.getPlotBottomLocAbs(plot.world, plot.id);
|
||||
final Location top = MainUtil.getPlotTopLocAbs(plot.world, plot.id);
|
||||
final Location bot = MainUtil.getPlotBottomLocAbs(plot.world, plot.getId());
|
||||
final Location top = MainUtil.getPlotTopLocAbs(plot.world, plot.getId());
|
||||
final int bx = bot.getX() >> 4;
|
||||
final int bz = bot.getZ() >> 4;
|
||||
|
||||
@ -985,7 +981,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
count(count, entity);
|
||||
} else {
|
||||
final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(loc));
|
||||
if (plot.id.equals(id)) {
|
||||
if (plot.getId().equals(id)) {
|
||||
count(count, entity);
|
||||
}
|
||||
}
|
||||
@ -999,7 +995,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
for (final Entity entity : ents) {
|
||||
if ((X == bx) || (X == tx) || (Z == bz) || (Z == tz)) {
|
||||
final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(entity));
|
||||
if (plot.id.equals(id)) {
|
||||
if (plot.getId().equals(id)) {
|
||||
count(count, entity);
|
||||
}
|
||||
} else {
|
||||
@ -1169,7 +1165,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
restoreEntities(world, 0, 0);
|
||||
}
|
||||
MainUtil.update(world.getName(), chunkLoc);
|
||||
BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk }));
|
||||
BukkitSetBlockManager.setBlockManager.update(Collections.singletonList(chunk));
|
||||
CURRENT_PLOT_CLEAR = null;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
@ -54,19 +55,19 @@ public class BukkitEconHandler extends EconHandler {
|
||||
public double getMoney(final PlotPlayer player) {
|
||||
final double bal = super.getMoney(player);
|
||||
if (Double.isNaN(bal)) {
|
||||
return econ.getBalance(player.getName());
|
||||
return econ.getBalance(((BukkitPlayer)player).player);
|
||||
}
|
||||
return bal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void withdrawMoney(final PlotPlayer player, final double amount) {
|
||||
econ.withdrawPlayer(player.getName(), amount);
|
||||
econ.withdrawPlayer(((BukkitPlayer)player).player, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void depositMoney(final PlotPlayer player, final double amount) {
|
||||
econ.depositPlayer(player.getName(), amount);
|
||||
econ.depositPlayer(((BukkitPlayer)player).player, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,7 +11,7 @@ public class BukkitTaskManager extends TaskManager {
|
||||
return BukkitMain.THIS.getServer().getScheduler().scheduleSyncRepeatingTask(BukkitMain.THIS, r, interval, interval);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation") @Override
|
||||
public int taskRepeatAsync(final Runnable r, final int interval) {
|
||||
return BukkitMain.THIS.getServer().getScheduler().scheduleAsyncRepeatingTask(BukkitMain.THIS, r, interval, interval);
|
||||
}
|
||||
|
@ -24,10 +24,8 @@ public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
|
||||
|
||||
public LowerOfflineUUIDWrapper() {
|
||||
try {
|
||||
getOnline = Server.class.getMethod("getOnlinePlayers", new Class[0]);
|
||||
} catch (final NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (final SecurityException e) {
|
||||
getOnline = Server.class.getMethod("getOnlinePlayers");
|
||||
} catch (final NoSuchMethodException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -73,7 +71,8 @@ public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
|
||||
@Override
|
||||
public Player[] getOnlinePlayers() {
|
||||
if (getOnline == null) {
|
||||
return Bukkit.getOnlinePlayers().toArray(new Player[0]);
|
||||
Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
|
||||
return onlinePlayers.toArray(new Player[onlinePlayers.size()]);
|
||||
}
|
||||
try {
|
||||
final Object players = getOnline.invoke(Bukkit.getServer(), arg);
|
||||
@ -82,12 +81,13 @@ public class LowerOfflineUUIDWrapper extends OfflineUUIDWrapper {
|
||||
} else {
|
||||
@SuppressWarnings("unchecked")
|
||||
final Collection<? extends Player> p = (Collection<? extends Player>) players;
|
||||
return p.toArray(new Player[0]);
|
||||
return p.toArray(new Player[p.size()]);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
PS.debug("Failed to resolve online players");
|
||||
getOnline = null;
|
||||
return Bukkit.getOnlinePlayers().toArray(new Player[0]);
|
||||
Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
|
||||
return onlinePlayers.toArray(new Player[onlinePlayers.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,10 +25,8 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
|
||||
|
||||
public OfflineUUIDWrapper() {
|
||||
try {
|
||||
getOnline = Server.class.getMethod("getOnlinePlayers", new Class[0]);
|
||||
} catch (final NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (final SecurityException e) {
|
||||
getOnline = Server.class.getMethod("getOnlinePlayers");
|
||||
} catch (final NoSuchMethodException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -72,7 +70,8 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
|
||||
|
||||
public Player[] getOnlinePlayers() {
|
||||
if (getOnline == null) {
|
||||
return Bukkit.getOnlinePlayers().toArray(new Player[0]);
|
||||
Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
|
||||
return onlinePlayers.toArray(new Player[onlinePlayers.size()]);
|
||||
}
|
||||
try {
|
||||
final Object players = getOnline.invoke(Bukkit.getServer(), arg);
|
||||
@ -81,12 +80,13 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
|
||||
} else {
|
||||
@SuppressWarnings("unchecked")
|
||||
final Collection<? extends Player> p = (Collection<? extends Player>) players;
|
||||
return p.toArray(new Player[0]);
|
||||
return p.toArray(new Player[p.size()]);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
PS.debug("Failed to resolve online players");
|
||||
getOnline = null;
|
||||
return Bukkit.getOnlinePlayers().toArray(new Player[0]);
|
||||
Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
|
||||
return onlinePlayers.toArray(new Player[onlinePlayers.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,22 +1,5 @@
|
||||
package com.plotsquared.bukkit.uuid;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
@ -29,6 +12,22 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
|
||||
@ -220,7 +219,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
connection.setUseCaches(false);
|
||||
connection.setDoInput(true);
|
||||
connection.setDoOutput(true);
|
||||
String body = JSONArray.toJSONString(Arrays.asList(name));
|
||||
String body = JSONArray.toJSONString(Collections.singletonList(name));
|
||||
OutputStream stream = connection.getOutputStream();
|
||||
stream.write(body.getBytes());
|
||||
stream.flush();
|
||||
|
@ -24,7 +24,6 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
@ -46,7 +45,9 @@ import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
|
||||
/**
|
||||
/**
|
||||
|
||||
|
||||
*/
|
||||
public class PlotListener {
|
||||
|
||||
@ -55,7 +56,7 @@ public class PlotListener {
|
||||
return false;
|
||||
}
|
||||
final Plot last = (Plot) pp.getMeta("lastplot");
|
||||
}
|
||||
if ((last != null) && !last.getId().equals(plot.getId())) {
|
||||
plotExit(pp, last);
|
||||
}
|
||||
pp.setMeta("lastplot", MainUtil.getPlot(plot));
|
||||
@ -103,7 +104,7 @@ public class PlotListener {
|
||||
if (!Permissions.hasPermission(pp, "plots.gamemode.bypass")) {
|
||||
pp.setGamemode((PlotGamemode) gamemodeFlag.getValue());
|
||||
} else {
|
||||
pp.setGamemode((PlotGamemode) gamemodeFlag.getValue());
|
||||
MainUtil.sendMessage(pp, StringMan.replaceAll(C.GAMEMODE_WAS_BYPASSED.s(), "{plot}", plot.getId(), "{gamemode}", gamemodeFlag.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -163,10 +164,10 @@ public class PlotListener {
|
||||
@Override
|
||||
public void run() {
|
||||
final Plot lastPlot = (Plot) pp.getMeta("lastplot");
|
||||
public void run() {
|
||||
if ((lastPlot != null) && plot.getId().equals(lastPlot.getId())) {
|
||||
final Map<String, String> replacements = new HashMap<>();
|
||||
if ((lastPlot != null) && plot.id.equals(lastPlot.id)) {
|
||||
final Map<String, String> replacements = new HashMap<>();
|
||||
replacements.put("%x%", lastPlot.getId().x + "");
|
||||
replacements.put("%z%", lastPlot.getId().y + "");
|
||||
replacements.put("%world%", plot.world);
|
||||
replacements.put("%greeting%", greeting);
|
||||
replacements.put("%alias", plot.toString());
|
||||
@ -188,7 +189,7 @@ public class PlotListener {
|
||||
pp.deleteMeta("lastplot");
|
||||
EventUtil.manager.callLeave(pp, plot);
|
||||
if (plot.hasOwner()) {
|
||||
EventUtil.manager.callLeave(pp, plot);
|
||||
final PlotWorld pw = plot.getWorld();
|
||||
if (pw == null) {
|
||||
return true;
|
||||
}
|
||||
|
@ -399,7 +399,7 @@ public class MainListener {
|
||||
// - Getting displayname currently causes NPE, so wait until sponge fixes that
|
||||
|
||||
final String sender = player.getName();
|
||||
final PlotId id = plot.id;
|
||||
final PlotId id = plot.getId();
|
||||
final String newMessage = StringMan.replaceAll(C.PLOT_CHAT_FORMAT.s(), "%plot_id%", id.x + ";" + id.y, "%sender%", sender);
|
||||
final Text forcedMessage = event.getMessage();
|
||||
// String forcedMessage = StringMan.replaceAll(C.PLOT_CHAT_FORCED.s(), "%plot_id%", id.x + ";" + id.y, "%sender%", sender);
|
||||
@ -811,7 +811,7 @@ public class MainListener {
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else if ((lastPlot != null) && id.equals(lastPlot.id)) {
|
||||
} else if ((lastPlot != null) && id.equals(lastPlot.getId())) {
|
||||
return;
|
||||
} else {
|
||||
final Plot plot = MainUtil.getPlot(worldname, id);
|
||||
@ -873,7 +873,7 @@ public class MainListener {
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else if ((lastPlot != null) && id.equals(lastPlot.id)) {
|
||||
} else if ((lastPlot != null) && id.equals(lastPlot.getId())) {
|
||||
return;
|
||||
} else {
|
||||
final Plot plot = MainUtil.getPlot(worldname, id);
|
||||
|
@ -1,11 +1,9 @@
|
||||
package com.plotsquared.sponge.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.sponge.SpongeMain;
|
||||
import org.spongepowered.api.command.CommandCallable;
|
||||
import org.spongepowered.api.command.CommandException;
|
||||
import org.spongepowered.api.command.CommandResult;
|
||||
@ -14,10 +12,11 @@ import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.text.Text;
|
||||
import org.spongepowered.api.text.Texts;
|
||||
|
||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.sponge.SpongeMain;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SpongeCommand implements CommandCallable {
|
||||
|
||||
@ -42,7 +41,7 @@ public class SpongeCommand implements CommandCallable {
|
||||
@Override
|
||||
public List<String> getSuggestions(final CommandSource cmd, final String string) throws CommandException {
|
||||
// TODO Auto-generated method stub
|
||||
return new ArrayList<>(Arrays.asList("TEST"));
|
||||
return new ArrayList<>(Collections.singletonList("TEST"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,16 +1,16 @@
|
||||
package com.plotsquared.sponge.uuid;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.profile.GameProfile;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import com.plotsquared.sponge.SpongeMain;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.profile.GameProfile;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SpongeLowerOfflineUUIDWrapper extends UUIDWrapper {
|
||||
|
||||
@ -75,7 +75,8 @@ public class SpongeLowerOfflineUUIDWrapper extends UUIDWrapper {
|
||||
}
|
||||
|
||||
public Player[] getOnlinePlayers() {
|
||||
return SpongeMain.THIS.getServer().getOnlinePlayers().toArray(new Player[0]);
|
||||
Collection<Player> onlinePlayers = SpongeMain.THIS.getServer().getOnlinePlayers();
|
||||
return onlinePlayers.toArray(new Player[onlinePlayers.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user