mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
commit
dcefa95278
@ -13,12 +13,12 @@ is to provide a lag-free and smooth experience.
|
||||
* [Spigot Page](https://www.spigotmc.org/resources/plotsquared.1177/)
|
||||
* [WebChat/IRC](http://webchat.esper.net/?nick=&channels=IntellectualCrafters&fg_color=000&fg_sec_color=000&bg_color=FFF)
|
||||
* [Wiki](https://github.com/intellectualcrafters/plotsquared/wiki)
|
||||
* [Website](http://plotsquared.com)
|
||||
* [~~Website~~](http://plotsquared.com)
|
||||
|
||||
### Developer Resources
|
||||
* *Outdated* [JavaDocs](http://empcraft.com/plotsquared/doc/)
|
||||
* [Build Server](http://ci.intellectualsites.com/job/PlotSquared/)
|
||||
* [Maven Repo](http://mvn.intellectualsites.com/content/repositories/intellectualsites/)
|
||||
* [~~Build Server~~](http://ci.intellectualsites.com/job/PlotSquared/)
|
||||
* [~~Maven Repo~~](http://mvn.intellectualsites.com/content/repositories/intellectualsites/)
|
||||
|
||||
|
||||
# Maven
|
||||
|
2
pom.xml
2
pom.xml
@ -8,7 +8,7 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<artifactId>PlotSquared</artifactId>
|
||||
<version>3.2.17</version>
|
||||
<version>3.2.21</version>
|
||||
<name>PlotSquared</name>
|
||||
<packaging>jar</packaging>
|
||||
<build>
|
||||
|
@ -90,7 +90,7 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
public class PS {
|
||||
|
||||
// protected static:
|
||||
public static PS instance;
|
||||
private static PS instance;
|
||||
|
||||
// private final:
|
||||
private final HashMap<String, PlotWorld> plotworlds = new HashMap<>();
|
||||
@ -699,7 +699,7 @@ public class PS {
|
||||
try {
|
||||
final ArrayList<Plot> overflow = new ArrayList<>();
|
||||
if ((range > limit) && (size > 1024)) {
|
||||
plots = new Plot[Math.min((int) range, limit)];
|
||||
plots = new Plot[limit];
|
||||
final int factor = (int) ((range / limit));
|
||||
for (int i = 0; i < size; i++) {
|
||||
Plot plot = list.get(i);
|
||||
@ -846,7 +846,7 @@ public class PS {
|
||||
*/
|
||||
@Deprecated
|
||||
public void sortPlotsByHash(final Plot[] input) {
|
||||
final List<Plot>[] bucket = new ArrayList[64];
|
||||
final List<Plot>[] bucket = new ArrayList[32];
|
||||
for (int i = 0; i < bucket.length; i++) {
|
||||
bucket[i] = new ArrayList<Plot>();
|
||||
}
|
||||
@ -856,19 +856,19 @@ public class PS {
|
||||
maxLength = true;
|
||||
for (final Plot i : input) {
|
||||
tmp = MathMan.getPositiveId(i.hashCode()) / placement;
|
||||
bucket[tmp & 63].add(i);
|
||||
bucket[tmp & 31].add(i);
|
||||
if (maxLength && (tmp > 0)) {
|
||||
maxLength = false;
|
||||
}
|
||||
}
|
||||
int a = 0;
|
||||
for (int b = 0; b < 64; b++) {
|
||||
for (int b = 0; b < 32; b++) {
|
||||
for (final Plot i : bucket[b]) {
|
||||
input[a++] = i;
|
||||
}
|
||||
bucket[b].clear();
|
||||
}
|
||||
placement *= 64;
|
||||
placement *= 32;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1068,8 +1068,8 @@ public class PS {
|
||||
return strings.toArray(new String[strings.size()]);
|
||||
}
|
||||
|
||||
private String lastWorld;
|
||||
private Map<PlotId, Plot> lastMap;
|
||||
private volatile String lastWorld;
|
||||
private volatile Map<PlotId, Plot> lastMap;
|
||||
|
||||
/**
|
||||
* Get a map of the plots for a world
|
||||
@ -1112,15 +1112,12 @@ public class PS {
|
||||
return null;
|
||||
}
|
||||
lastWorld = world;
|
||||
if (plots.containsKey(world)) {
|
||||
lastMap = plots.get(world);
|
||||
if (lastMap != null) {
|
||||
return lastMap.get(id);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plots for a PlotPlayer
|
||||
|
@ -67,7 +67,7 @@ public class Copy extends SubCommand {
|
||||
C.COMMAND_SYNTAX.send(plr, getUsage());
|
||||
return false;
|
||||
}
|
||||
if (!plot1.getWorld().equals(plot2.getWorld())) {
|
||||
if (!plot1.getWorld().isCompatible(plot2.getWorld())) {
|
||||
C.PLOTWORLD_INCOMPATIBLE.send(plr);
|
||||
return false;
|
||||
}
|
||||
|
@ -53,7 +53,6 @@ public class Debug extends SubCommand {
|
||||
worlds.append(world).append(" ");
|
||||
}
|
||||
information.append(header);
|
||||
information.append(getSection(section, "Lag / TPS"));
|
||||
information.append(getSection(section, "PlotWorld"));
|
||||
information.append(getLine(line, "Plot Worlds", worlds));
|
||||
information.append(getLine(line, "Owned Plots", PS.get().getPlots().size()));
|
||||
|
@ -4,6 +4,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
@ -34,7 +35,7 @@ public class DebugPaste extends SubCommand {
|
||||
try {
|
||||
latestLOG = HastebinUtility.upload(new File(BukkitMain.THIS.getDirectory(), "../../logs/latest.log"));
|
||||
} catch (final Exception e) {
|
||||
plr.sendMessage("&clatest.log is too big to be pasted, will ignore");
|
||||
plr.sendMessage(ChatColor.RED + "latest.log is too big to be pasted, will ignore");
|
||||
latestLOG = "too big :(";
|
||||
}
|
||||
final StringBuilder b = new StringBuilder();
|
||||
|
@ -34,7 +34,6 @@ import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
|
@ -158,6 +158,10 @@ public class FlagCmd extends SubCommand {
|
||||
}
|
||||
final Flag flag = FlagManager.getPlotFlagAbs(plot, args[1].toLowerCase());
|
||||
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) {
|
||||
if (args.length != 2) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
|
||||
return false;
|
||||
}
|
||||
for (final String entry : args[2].split(",")) {
|
||||
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + "." + entry)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + "." + entry);
|
||||
|
@ -134,12 +134,9 @@ public class Info extends SubCommand {
|
||||
full = false;
|
||||
}
|
||||
MainUtil.format(info, plot, player, full, new RunnableVal<String>() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(player, C.PLOT_INFO_HEADER);
|
||||
MainUtil.sendMessage(player, value, false);
|
||||
MainUtil.sendMessage(player, C.PLOT_INFO_FOOTER);
|
||||
MainUtil.sendMessage(player, C.PLOT_INFO_HEADER.s() + '\n' + value + '\n' + C.PLOT_INFO_FOOTER.s(), false);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
@ -320,6 +320,9 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
|
||||
@Override
|
||||
public int handle(final PlotPlayer plr, final String input) {
|
||||
// Clear perm caching //
|
||||
plr.deleteMeta("perm");
|
||||
////////////////////////
|
||||
final String[] parts = input.split(" ");
|
||||
String[] args;
|
||||
String label;
|
||||
@ -333,7 +336,7 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
}
|
||||
Command<PlotPlayer> cmd;
|
||||
if (label != null) {
|
||||
cmd = getInstance().commands.get(label);
|
||||
cmd = getInstance().commands.get(label.toLowerCase());
|
||||
} else {
|
||||
cmd = null;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class Move extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy <X;Z>");
|
||||
return false;
|
||||
}
|
||||
if (!plot1.getWorld().equals(plot2.getWorld())) {
|
||||
if (!plot1.getWorld().isCompatible(plot2.getWorld())) {
|
||||
C.PLOTWORLD_INCOMPATIBLE.send(plr);
|
||||
return false;
|
||||
}
|
||||
|
@ -45,19 +45,32 @@ public class Owner extends SetCommand {
|
||||
@Override
|
||||
public boolean set(PlotPlayer plr, Plot plot, String value) {
|
||||
HashSet<Plot> plots = MainUtil.getConnectedPlots(plot);
|
||||
final PlotPlayer other = UUIDHandler.getPlayer(value);
|
||||
UUID uuid;
|
||||
uuid = other == null ? (Permissions.hasPermission(plr, "plots.admin.command.setowner") ? UUIDHandler.getUUID(value, null) : null) : other.getUUID();
|
||||
UUID uuid = null;
|
||||
String name = null;
|
||||
if (value.length() == 36) {
|
||||
try {
|
||||
uuid = UUID.fromString(value);
|
||||
name = MainUtil.getName(uuid);
|
||||
} catch (Exception e) {}
|
||||
} else {
|
||||
uuid = UUIDHandler.getUUID(value, null);
|
||||
name = UUIDHandler.getName(uuid);
|
||||
name = name == null ? value : name;
|
||||
}
|
||||
if (uuid == null) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, value);
|
||||
C.INVALID_PLAYER.send(plr, value);
|
||||
return false;
|
||||
}
|
||||
String name = other == null ? UUIDHandler.getName(uuid) : other.getName();
|
||||
if (plot.isOwner(uuid)) {
|
||||
C.ALREADY_OWNER.send(plr);
|
||||
return false;
|
||||
}
|
||||
PlotPlayer other = UUIDHandler.getPlayer(uuid);
|
||||
if (!Permissions.hasPermission(plr, "plots.admin.command.setowner")) {
|
||||
if (other == null) {
|
||||
C.INVALID_PLAYER_OFFLINE.send(plr, value);
|
||||
return false;
|
||||
}
|
||||
final int size = plots.size();
|
||||
final int currentPlots = (Settings.GLOBAL_LIMIT ? MainUtil.getPlayerPlotCount(other) : MainUtil.getPlayerPlotCount(plot.world, other)) + size;
|
||||
if (currentPlots > MainUtil.getAllowedPlots(other)) {
|
||||
@ -65,6 +78,7 @@ public class Owner extends SetCommand {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
plot.setOwner(uuid);
|
||||
MainUtil.setSign(name, plot);
|
||||
MainUtil.sendMessage(plr, C.SET_OWNER);
|
||||
|
@ -77,6 +77,9 @@ public class Rate extends SubCommand {
|
||||
v2 -= 11 - entry.getValue().getAverageRating();
|
||||
}
|
||||
}
|
||||
if (v1 == v2) {
|
||||
return -0;
|
||||
}
|
||||
return v2 > v1 ? 1 : -1;
|
||||
}
|
||||
});
|
||||
@ -184,7 +187,7 @@ public class Rate extends SubCommand {
|
||||
final int rating;
|
||||
if (MathMan.isInteger(arg) && (arg.length() < 3) && (arg.length() > 0)) {
|
||||
rating = Integer.parseInt(arg);
|
||||
if (rating > 10) {
|
||||
if (rating > 10 || rating < 1) {
|
||||
sendMessage(player, C.RATING_NOT_VALID);
|
||||
return false;
|
||||
}
|
||||
|
@ -20,7 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
@ -32,23 +31,18 @@ import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.plotsquared.general.commands.Argument;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "regenallroads",
|
||||
description = "Regenerate all roads in the map using the set road schematic",
|
||||
aliases = { "rgar" },
|
||||
usage = "/plot regenallroads <world>",
|
||||
usage = "/plot regenallroads <world> [height]",
|
||||
category = CommandCategory.DEBUG,
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
permission = "plots.regenallroads")
|
||||
public class RegenAllRoads extends SubCommand {
|
||||
|
||||
public RegenAllRoads() {
|
||||
requiredArguments = new Argument[] { Argument.String };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
int height = 0;
|
||||
@ -60,6 +54,9 @@ public class RegenAllRoads extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]");
|
||||
return false;
|
||||
}
|
||||
final String name = args[0];
|
||||
final PlotManager manager = PS.get().getPlotManager(name);
|
||||
|
@ -59,6 +59,12 @@ public class Set extends SubCommand {
|
||||
|
||||
public Set() {
|
||||
component = new SetCommand() {
|
||||
|
||||
@Override
|
||||
public String getCommand() {
|
||||
return "set.component";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean set(PlotPlayer plr, final Plot plot, String value) {
|
||||
final String world = plr.getLocation().getWorld();
|
||||
@ -171,7 +177,7 @@ public class Set extends SubCommand {
|
||||
// components
|
||||
HashSet<String> components = new HashSet<String>(Arrays.asList(plot.getManager().getPlotComponents(plot.getWorld(), plot.id)));
|
||||
if (components.contains(args[0].toLowerCase())) {
|
||||
return component.set(plr, plot, StringMan.join(args, " "));
|
||||
return component.onCommand(plr, Arrays.copyOfRange(args, 0, args.length));
|
||||
}
|
||||
// flag
|
||||
{
|
||||
|
@ -55,7 +55,7 @@ public class Swap extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy <X;Z>");
|
||||
return false;
|
||||
}
|
||||
if (!plot1.getWorld().equals(plot2.getWorld())) {
|
||||
if (!plot1.getWorld().isCompatible(plot2.getWorld())) {
|
||||
C.PLOTWORLD_INCOMPATIBLE.send(plr);
|
||||
return false;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "update",
|
||||
permission = "plots.admin",
|
||||
permission = "plots.admin.command.update",
|
||||
description = "Update PlotSquared",
|
||||
usage = "/plot update",
|
||||
requiredType = RequiredType.NONE,
|
||||
|
@ -331,7 +331,7 @@ public class list extends SubCommand {
|
||||
}
|
||||
}
|
||||
if (sort) {
|
||||
plots = PS.get().sortPlots(plots, SortType.DISTANCE_FROM_ORIGIN, world);
|
||||
plots = PS.get().sortPlots(plots, SortType.CREATION_DATE, world);
|
||||
}
|
||||
if (page < 0) {
|
||||
page = 0;
|
||||
|
@ -34,7 +34,6 @@ public class plugin extends SubCommand {
|
||||
MainUtil.sendMessage(plr, String.format("$2>> $1&lPlotSquared $2($1Version$2: $1%s$2)", StringMan.join(PS.get().IMP.getPluginVersion(), ".")));
|
||||
MainUtil.sendMessage(plr, String.format("$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92"));
|
||||
MainUtil.sendMessage(plr, String.format("$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki"));
|
||||
MainUtil.sendMessage(plr, String.format("$2>> $1&lWebsite$2: $1http://plotsquared.com"));
|
||||
MainUtil.sendMessage(plr, String.format("$2>> $1&lNewest Version$2: $1" + (PS.get().update == null ? StringMan.join(PS.get().IMP.getPluginVersion(), ".") : PS.get().update)));
|
||||
return true;
|
||||
}
|
||||
|
@ -90,6 +90,7 @@ public enum C {
|
||||
PERMISSION_ADMIN_INTERACT_UNOWNED("plots.admin.interact.unowned", "static.permissions"),
|
||||
PERMISSION_ADMIN_INTERACT_OTHER("plots.admin.interact.other", "static.permissions"),
|
||||
PERMISSION_ADMIN_BUILD_HEIGHTLIMIT("plots.admin.build.heightlimit", "static.permissions"),
|
||||
PERMISSION_ADMIN_UPDATE("plots.admin.command.update", "static.permissions"),
|
||||
/*
|
||||
* Static console
|
||||
*/
|
||||
@ -373,7 +374,8 @@ public enum C {
|
||||
* Player not found
|
||||
*/
|
||||
INVALID_PLAYER_WAIT("$2Player not found: $1%s$2, fetching it. Try again soon.", "Errors"),
|
||||
INVALID_PLAYER("$2Player not found: $1%s.", "Errors"),
|
||||
INVALID_PLAYER("$2Player not found: $1%s$2.", "Errors"),
|
||||
INVALID_PLAYER_OFFLINE("$2The player must be online: $1%s.", "Errors"),
|
||||
// SETTINGS_PASTE_UPLOADED("$2settings.yml was uploaded to: $1%url%", "Paste"),
|
||||
// LATEST_LOG_UPLOADED("$2latest.log was uploaded to: $1%url%", "Paste"),
|
||||
DEBUG_REPORT_CREATED("$1Uploaded a full debug to: $1%url%", "Paste"),
|
||||
@ -673,14 +675,18 @@ public enum C {
|
||||
final Map<String, String> map = new LinkedHashMap<String, String>();
|
||||
if (args.length > 0) {
|
||||
for (int i = args.length - 1; i >= 0; i--) {
|
||||
if (args[i] == null) {
|
||||
args[i] = "";
|
||||
String arg = args[i].toString();
|
||||
if (arg == null || arg.length() == 0) {
|
||||
map.put("%s" + i, "");
|
||||
} else {
|
||||
arg = C.color(arg);
|
||||
map.put("%s" + i, arg);
|
||||
}
|
||||
if (i == 0) {
|
||||
map.put("%s", arg);
|
||||
}
|
||||
map.put("%s" + i, args[i].toString());
|
||||
}
|
||||
map.put("%s", args[0].toString());
|
||||
}
|
||||
map.putAll(replacements);
|
||||
m = StringMan.replaceFromMap(m, map);
|
||||
return m;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class Settings {
|
||||
/**
|
||||
* Default UUID_FECTHING: false
|
||||
*/
|
||||
public static boolean PERMISSION_CACHING = false;
|
||||
public static boolean PERMISSION_CACHING = true;
|
||||
public static boolean CACHE_RATINGS = true;
|
||||
public static boolean UUID_FROM_DISK = false;
|
||||
|
||||
|
@ -575,9 +575,9 @@ public class SQLManager implements AbstractDB {
|
||||
stmt.setInt((i * 5) + 1, plot.id.x);
|
||||
stmt.setInt((i * 5) + 2, plot.id.y);
|
||||
try {
|
||||
stmt.setString((i * 4) + 3, plot.owner.toString());
|
||||
stmt.setString((i * 5) + 3, plot.owner.toString());
|
||||
} catch (final Exception e) {
|
||||
stmt.setString((i * 4) + 3, everyone.toString());
|
||||
stmt.setString((i * 5) + 3, everyone.toString());
|
||||
}
|
||||
stmt.setString((i * 5) + 4, plot.world);
|
||||
stmt.setTimestamp((i * 5) + 5, new Timestamp(plot.getTimestamp()));
|
||||
@ -1193,6 +1193,9 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
@Override
|
||||
public void deleteSettings(final Plot plot) {
|
||||
if (plot.settings == null) {
|
||||
return;
|
||||
}
|
||||
addPlotTask(plot, new UniqueStatement("delete_plot_settings") {
|
||||
@Override
|
||||
public void set(final PreparedStatement stmt) throws SQLException {
|
||||
@ -1301,7 +1304,6 @@ public class SQLManager implements AbstractDB {
|
||||
*/
|
||||
@Override
|
||||
public void delete(final Plot plot) {
|
||||
PS.get().removePlot(plot.world, plot.id, false);
|
||||
deleteSettings(plot);
|
||||
deleteDenied(plot);
|
||||
deleteHelpers(plot);
|
||||
@ -1736,7 +1738,7 @@ public class SQLManager implements AbstractDB {
|
||||
map = new ConcurrentHashMap<PlotId, Plot>();
|
||||
newplots.put(plot.world, map);
|
||||
}
|
||||
newplots.get(plot.world).put(plot.id, plot);
|
||||
map.put(plot.id, plot);
|
||||
}
|
||||
}
|
||||
boolean invalidPlot = false;
|
||||
@ -2817,7 +2819,7 @@ public class SQLManager implements AbstractDB {
|
||||
final ConcurrentHashMap<PlotId, Plot> map = entry.getValue();
|
||||
if (map.size() > 0) {
|
||||
for (final Entry<PlotId, Plot> entry2 : map.entrySet()) {
|
||||
PS.debug("$1Plot was deleted: " + entry.getValue() + "// TODO implement this when sure safe");
|
||||
PS.debug("$1Plot was deleted: " + entry2.getValue() + "// TODO implement this when sure safe");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -157,8 +157,16 @@ public class FlagManager {
|
||||
return result == null ? null : (Flag) result.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw flag<br>
|
||||
* - Faster
|
||||
* - You should not modify the flag
|
||||
* @param plot
|
||||
* @param flag
|
||||
* @return
|
||||
*/
|
||||
public static Flag getPlotFlagRaw(final Plot plot, final String flag) {
|
||||
if (!plot.hasOwner()) {
|
||||
if (plot.owner == null) {
|
||||
return null;
|
||||
}
|
||||
return getSettingFlag(plot.world, plot.getSettings(), flag);
|
||||
|
@ -28,9 +28,21 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
return true;
|
||||
}
|
||||
case "all": {
|
||||
setAll(plotworld, plotid, blocks);
|
||||
return true;
|
||||
}
|
||||
case "air": {
|
||||
setAir(plotworld, plotid, blocks);
|
||||
return true;
|
||||
}
|
||||
case "main": {
|
||||
setMain(plotworld, plotid, blocks);
|
||||
return true;
|
||||
}
|
||||
case "middle": {
|
||||
setMiddle(plotworld, plotid, blocks);
|
||||
return true;
|
||||
}
|
||||
case "outline": {
|
||||
setOutline(plotworld, plotid, blocks);
|
||||
return true;
|
||||
@ -67,6 +79,20 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setAll(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
||||
Plot plot = MainUtil.getPlotAbs(plotworld.worldname, plotid);
|
||||
if (!plot.isBasePlot()) {
|
||||
return false;
|
||||
}
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
for (RegionWrapper region : MainUtil.getRegions(plot)) {
|
||||
Location pos1 = new Location(plot.world, region.minX, 1, region.minZ);
|
||||
Location pos2 = new Location(plot.world, region.maxX, 255, region.maxZ);
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, pos1, pos2, blocks);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setAir(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
||||
Plot plot = MainUtil.getPlotAbs(plotworld.worldname, plotid);
|
||||
if (!plot.isBasePlot()) {
|
||||
@ -81,6 +107,31 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setMain(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
||||
Plot plot = MainUtil.getPlotAbs(plotworld.worldname, plotid);
|
||||
if (!plot.isBasePlot()) {
|
||||
return false;
|
||||
}
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
for (RegionWrapper region : MainUtil.getRegions(plot)) {
|
||||
Location pos1 = new Location(plot.world, region.minX, 1, region.minZ);
|
||||
Location pos2 = new Location(plot.world, region.maxX, dpw.PLOT_HEIGHT - 1, region.maxZ);
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, pos1, pos2, blocks);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setMiddle(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
||||
Plot plot = MainUtil.getPlotAbs(plotworld.worldname, plotid);
|
||||
if (!plot.isBasePlot()) {
|
||||
return false;
|
||||
}
|
||||
Location[] corners = plot.getCorners();
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
SetBlockQueue.setBlock(plotworld.worldname, (corners[0].getX() + corners[1].getX()) / 2, dpw.PLOT_HEIGHT, (corners[0].getZ() + corners[1].getZ()) / 2, blocks[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setOutline(final PlotWorld plotworld, final PlotId plotid, final PlotBlock[] blocks) {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
if (dpw.ROAD_WIDTH == 0) {
|
||||
@ -227,7 +278,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
final int sz = pos1.getZ() - 2;
|
||||
final int ez = pos2.getZ() + 2;
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(plotworld.worldname, ex, 255, ez - 1), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz + 1), new Location(plotworld.worldname, ex, dpw.PLOT_HEIGHT, ez - 1), new PlotBlock((short) 7,
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 0, sz + 1), new Location(plotworld.worldname, ex, 0, ez - 1), new PlotBlock((short) 7,
|
||||
(byte) 0));
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz + 1), new Location(plotworld.worldname, sx, dpw.WALL_HEIGHT, ez - 1), dpw.WALL_FILLING);
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.WALL_HEIGHT + 1, sz + 1), new Location(plotworld.worldname, sx, dpw.WALL_HEIGHT + 1, ez - 1),
|
||||
@ -368,7 +419,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
|
||||
@Override
|
||||
public String[] getPlotComponents(final PlotWorld plotworld, final PlotId plotid) {
|
||||
return new String[] { "floor", "wall", "border", "all", "outline" };
|
||||
return new String[] { "main", "floor", "air", "all", "border", "wall", "outline", "middle" };
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,6 +28,7 @@ import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.Dimension;
|
||||
@ -72,6 +73,14 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompatible(PlotWorld plotworld) {
|
||||
if (plotworld == null || !(plotworld instanceof SquarePlotWorld)) {
|
||||
return false;
|
||||
}
|
||||
return ((ClassicPlotWorld) plotworld).PLOT_WIDTH == PLOT_WIDTH;
|
||||
}
|
||||
|
||||
public void setupSchematics() {
|
||||
G_SCH_DATA = new HashMap<>();
|
||||
G_SCH = new HashMap<>();
|
||||
|
@ -11,7 +11,6 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
|
||||
/**
|
||||
* A plot manager with a square grid layout, with square shaped plots
|
||||
@ -93,6 +92,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
|
||||
@Override
|
||||
public PlotId getPlotId(final PlotWorld plotworld, int x, final int y, int z) {
|
||||
try {
|
||||
final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld);
|
||||
if (plotworld == null) {
|
||||
return null;
|
||||
@ -132,7 +132,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
rz = (z % size);
|
||||
}
|
||||
PlotId id = new PlotId(dx, dz);
|
||||
boolean[] merged = new boolean[] {(rz <= pathWidthLower), (rx > end), (rz > end), (rx <= pathWidthLower)};
|
||||
boolean[] merged = new boolean[] { (rz <= pathWidthLower), (rx > end), (rz > end), (rx <= pathWidthLower) };
|
||||
int hash = MainUtil.hash(merged);
|
||||
// Not merged, and no need to check if it is
|
||||
if (hash == 0) {
|
||||
@ -170,6 +170,9 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
return plot.getMerged(7) ? id : null;
|
||||
}
|
||||
PS.debug("invalid location: " + merged);
|
||||
} catch (Exception e) {
|
||||
PS.debug("Invalid plot / road width in settings.yml for world: " + plotworld.worldname);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -129,8 +129,8 @@ public class ConsolePlayer extends PlotPlayer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteMeta(final String key) {
|
||||
meta.remove(key);
|
||||
public Object deleteMeta(final String key) {
|
||||
return meta.remove(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -85,6 +85,10 @@ public class Location implements Cloneable, Comparable<Location> {
|
||||
return MainUtil.getPlot(this);
|
||||
}
|
||||
|
||||
public ChunkLoc getChunkLoc() {
|
||||
return new ChunkLoc(x >> 4, z >> 4);
|
||||
}
|
||||
|
||||
public void setWorld(final String world) {
|
||||
this.world = world;
|
||||
built = false;
|
||||
|
@ -416,7 +416,6 @@ public class Plot {
|
||||
*/
|
||||
private Plot origin;
|
||||
|
||||
|
||||
/**
|
||||
* The base plot is an arbitrary but specific connected plot. It is useful for the following:<br>
|
||||
* - Merged plots need to be treated as a single plot for most purposes<br>
|
||||
@ -721,7 +720,7 @@ public class Plot {
|
||||
*/
|
||||
public double getAverageRating() {
|
||||
double sum = 0;
|
||||
final Collection<Rating> ratings = getBasePlot(false).getRatings().values();
|
||||
final Collection<Rating> ratings = getRatings().values();
|
||||
for (final Rating rating : ratings) {
|
||||
sum += rating.getAverageRating();
|
||||
}
|
||||
@ -1013,7 +1012,7 @@ public class Plot {
|
||||
public boolean removeDenied(final UUID uuid) {
|
||||
if (uuid == DBFunc.everyone) {
|
||||
boolean result = false;
|
||||
for (UUID other : getDenied()) {
|
||||
for (UUID other : new HashSet<>(getDenied())) {
|
||||
result = result || PlotHandler.removeDenied(this, other);
|
||||
}
|
||||
return result;
|
||||
@ -1029,7 +1028,7 @@ public class Plot {
|
||||
public boolean removeTrusted(final UUID uuid) {
|
||||
if (uuid == DBFunc.everyone) {
|
||||
boolean result = false;
|
||||
for (UUID other : getTrusted()) {
|
||||
for (UUID other : new HashSet<>(getTrusted())) {
|
||||
result = result || PlotHandler.removeTrusted(this, other);
|
||||
}
|
||||
return result;
|
||||
@ -1045,7 +1044,7 @@ public class Plot {
|
||||
public boolean removeMember(final UUID uuid) {
|
||||
if (uuid == DBFunc.everyone) {
|
||||
boolean result = false;
|
||||
for (UUID other : getMembers()) {
|
||||
for (UUID other : new HashSet<>(getMembers())) {
|
||||
result = result || PlotHandler.removeMember(this, other);
|
||||
}
|
||||
return result;
|
||||
|
@ -237,9 +237,9 @@ public class PlotHandler {
|
||||
return false;
|
||||
}
|
||||
for (Plot current : MainUtil.getConnectedPlots(plot)) {
|
||||
current.settings = null;
|
||||
PS.get().removePlot(current.world, current.id, true);
|
||||
DBFunc.delete(current);
|
||||
current.settings = null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -80,10 +80,8 @@ public abstract class PlotPlayer implements CommandCaller {
|
||||
* - deleting other plugin's metadata may cause issues
|
||||
* @param key
|
||||
*/
|
||||
public void deleteMeta(final String key) {
|
||||
if (meta != null) {
|
||||
meta.remove(key);
|
||||
}
|
||||
public Object deleteMeta(final String key) {
|
||||
return meta == null ? null : meta.remove(key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,6 +126,10 @@ public abstract class PlotWorld {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isCompatible(PlotWorld plotworld) {
|
||||
return equals(plotworld);
|
||||
}
|
||||
|
||||
/**
|
||||
* When a world is created, the following method will be called for each
|
||||
*
|
||||
@ -275,6 +279,9 @@ public abstract class PlotWorld {
|
||||
config.set(option, options.get(option));
|
||||
}
|
||||
}
|
||||
if (!config.contains("flags")) {
|
||||
config.set("flags.use", "63,64,68,69,71,77,96,143,167,193,194,195,196,197,77,143,69,70,72,147,148,107,183,184,185,186,187,132");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -107,12 +107,11 @@ public abstract class ChunkManager {
|
||||
public abstract void unloadChunk(final String world, final ChunkLoc loc, final boolean save, final boolean safe);
|
||||
|
||||
public Set<ChunkLoc> getChunkChunks(final String world) {
|
||||
final String directory = PS.get().IMP.getWorldContainer() + File.separator + world + File.separator + "region";
|
||||
final File folder = new File(directory);
|
||||
final File folder = new File(PS.get().IMP.getWorldContainer(), world + File.separator + "region");
|
||||
final File[] regionFiles = folder.listFiles();
|
||||
final HashSet<ChunkLoc> chunks = new HashSet<>();
|
||||
if (regionFiles == null) {
|
||||
throw new RuntimeException("Could not find worlds folder.");
|
||||
throw new RuntimeException("Could not find worlds folder: " + folder + " ? (no read access?)");
|
||||
}
|
||||
for (final File file : regionFiles) {
|
||||
final String name = file.getName();
|
||||
|
@ -63,12 +63,11 @@ public abstract class EventUtil {
|
||||
|
||||
public boolean checkPlayerBlockEvent(final PlotPlayer pp, final PlayerBlockEventType type, final Location loc, final LazyBlock block, boolean notifyPerms) {
|
||||
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||
final UUID uuid = pp.getUUID();
|
||||
if (plot == null) {
|
||||
if (!MainUtil.isPlotAreaAbs(loc)) {
|
||||
return true;
|
||||
}
|
||||
} else if (plot.isAdded(uuid)) {
|
||||
} else if (plot.isAdded(pp.getUUID())) {
|
||||
return true;
|
||||
}
|
||||
switch (type) {
|
||||
@ -83,7 +82,7 @@ public abstract class EventUtil {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
if (plot.owner == null) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
|
||||
}
|
||||
final Flag use = FlagManager.getPlotFlagRaw(plot, "use");
|
||||
@ -151,7 +150,7 @@ public abstract class EventUtil {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
if (plot.owner == null) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
|
||||
}
|
||||
final Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
|
||||
@ -168,7 +167,7 @@ public abstract class EventUtil {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD.s(), notifyPerms);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
if (plot.owner == null) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED.s(), notifyPerms);
|
||||
}
|
||||
final Flag flag = FlagManager.getPlotFlagRaw(plot, "place");
|
||||
@ -185,7 +184,7 @@ public abstract class EventUtil {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), false);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
if (plot.owner == null) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), false);
|
||||
}
|
||||
if (FlagManager.isPlotFlagTrue(plot, "device-interact")) {
|
||||
@ -194,12 +193,10 @@ public abstract class EventUtil {
|
||||
final Flag flag = FlagManager.getPlotFlagRaw(plot, "use");
|
||||
final HashSet<PlotBlock> value = flag == null ? null : (HashSet<PlotBlock>) flag.getValue();
|
||||
if ((value == null) || (!value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock()))) {
|
||||
long time = System.currentTimeMillis();
|
||||
notifyPerms = notifyPerms && (31 * (time / 31) == time);
|
||||
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms)) {
|
||||
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) {
|
||||
return true;
|
||||
}
|
||||
return !(!notifyPerms || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + "/" + C.FLAG_DEVICE_INTERACT.s()));
|
||||
return !(!false || MainUtil.sendMessage(pp, C.FLAG_TUTORIAL_USAGE, C.FLAG_USE.s() + "/" + C.FLAG_DEVICE_INTERACT.s()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -207,7 +204,7 @@ public abstract class EventUtil {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
if (plot.owner == null) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
|
||||
}
|
||||
if (FlagManager.isPlotFlagTrue(plot, "hanging-interact")) {
|
||||
@ -227,7 +224,7 @@ public abstract class EventUtil {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
if (plot.owner == null) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
|
||||
}
|
||||
if (FlagManager.isPlotFlagTrue(plot, "misc-interact")) {
|
||||
@ -247,7 +244,7 @@ public abstract class EventUtil {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD.s(), notifyPerms);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
if (plot.owner == null) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
|
||||
}
|
||||
if (FlagManager.isPlotFlagTrue(plot, "vehicle-use")) {
|
||||
@ -267,7 +264,7 @@ public abstract class EventUtil {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
if (plot.owner == null) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
|
||||
}
|
||||
|
||||
@ -288,7 +285,7 @@ public abstract class EventUtil {
|
||||
// if (plot == null) {
|
||||
// return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
|
||||
// }
|
||||
// if (!plot.hasOwner()) {
|
||||
// if (plot.owner == null) {
|
||||
// return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
|
||||
// }
|
||||
//
|
||||
@ -306,7 +303,7 @@ public abstract class EventUtil {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
if (plot.owner == null) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
|
||||
}
|
||||
|
||||
@ -327,7 +324,7 @@ public abstract class EventUtil {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), notifyPerms);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
if (plot.owner == null) {
|
||||
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -36,6 +37,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -56,6 +58,7 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.plotsquared.listener.PlotListener;
|
||||
|
||||
/**
|
||||
@ -563,6 +566,9 @@ public class MainUtil {
|
||||
}
|
||||
|
||||
public static boolean isPlotAreaAbs(final Location location) {
|
||||
if (!Settings.ENABLE_CLUSTERS) {
|
||||
return true;
|
||||
}
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(location.getWorld());
|
||||
if (plotworld == null) {
|
||||
return false;
|
||||
@ -586,6 +592,9 @@ public class MainUtil {
|
||||
}
|
||||
|
||||
public static boolean isPlotArea(final Plot plot) {
|
||||
if (!Settings.ENABLE_CLUSTERS) {
|
||||
return true;
|
||||
}
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
|
||||
if (plotworld.TYPE == 2) {
|
||||
return plot.getCluster() != null;
|
||||
@ -1421,7 +1430,9 @@ public class MainUtil {
|
||||
final HashSet<RegionWrapper> regions = getRegions(plot);
|
||||
final HashSet<Plot> plots = getConnectedPlots(plot);
|
||||
final ArrayDeque<Plot> queue = new ArrayDeque<>(plots);
|
||||
if (isDelete) {
|
||||
removeSign(plot);
|
||||
}
|
||||
MainUtil.unlinkPlot(plot, true, !isDelete);
|
||||
final PlotManager manager = PS.get().getPlotManager(plot.world);
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
|
||||
@ -1718,6 +1729,12 @@ public class MainUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a plot can be claimed
|
||||
* @param player
|
||||
* @param plot
|
||||
* @return
|
||||
*/
|
||||
public static boolean canClaim(final PlotPlayer player, final Plot plot) {
|
||||
if (plot == null) {
|
||||
return false;
|
||||
@ -1730,7 +1747,66 @@ public class MainUtil {
|
||||
}
|
||||
}
|
||||
}
|
||||
return plot.owner == null;
|
||||
return guessOwner(plot) == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to guess who the plot owner is:
|
||||
* - Checks cache
|
||||
* - Checks sign text
|
||||
* @param plot
|
||||
* @return
|
||||
*/
|
||||
public static UUID guessOwner(Plot plot) {
|
||||
if (plot.owner != null) {
|
||||
return plot.owner;
|
||||
}
|
||||
PlotWorld pw = plot.getWorld();
|
||||
if (!pw.ALLOW_SIGNS) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
Location loc = plot.getManager().getSignLoc(pw, plot);
|
||||
ChunkManager.manager.loadChunk(loc.getWorld(), loc.getChunkLoc(), false);
|
||||
String[] lines = BlockManager.manager.getSign(loc);
|
||||
if (lines == null) {
|
||||
return null;
|
||||
}
|
||||
loop: for (int i = 4; i > 0; i--) {
|
||||
String caption = C.valueOf("OWNER_SIGN_LINE_" + i).s();
|
||||
int index = caption.indexOf("%plr%");
|
||||
if (index == -1) {
|
||||
continue;
|
||||
}
|
||||
String name = lines[i - 1].substring(index);
|
||||
if (name.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
UUID owner = UUIDHandler.getUUID(name, null);
|
||||
if (owner != null) {
|
||||
plot.owner = owner;
|
||||
break;
|
||||
}
|
||||
if (lines[i - 1].length() == 15) {
|
||||
BiMap<StringWrapper, UUID> map = UUIDHandler.getUuidMap();
|
||||
for (Entry<StringWrapper, UUID> entry : map.entrySet()) {
|
||||
String key = entry.getKey().value;
|
||||
if (key.length() > name.length() && key.startsWith(name)) {
|
||||
plot.owner = entry.getValue();
|
||||
break loop;
|
||||
}
|
||||
}
|
||||
}
|
||||
plot.owner = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(StandardCharsets.UTF_8));
|
||||
break;
|
||||
}
|
||||
if (plot.owner != null) {
|
||||
plot.create();
|
||||
}
|
||||
return plot.owner;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isUnowned(final String world, final PlotId pos1, final PlotId pos2) {
|
||||
@ -2104,18 +2180,7 @@ public class MainUtil {
|
||||
* @return boolean success
|
||||
*/
|
||||
public static boolean sendMessage(final PlotPlayer plr, final C c, final String... args) {
|
||||
if (c.s().length() > 1) {
|
||||
String msg = c.s();
|
||||
if ((args != null) && (args.length > 0)) {
|
||||
msg = C.format(c, args);
|
||||
}
|
||||
if (plr == null) {
|
||||
ConsolePlayer.getConsole().sendMessage(msg);
|
||||
} else {
|
||||
sendMessage(plr, msg, c.usePrefix());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return sendMessage(plr, c, (Object[]) args);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2127,17 +2192,23 @@ public class MainUtil {
|
||||
* @return boolean success
|
||||
*/
|
||||
public static boolean sendMessage(final PlotPlayer plr, final C c, final Object... args) {
|
||||
if (c.s().length() > 1) {
|
||||
if (c.s().length() == 0) {
|
||||
return true;
|
||||
}
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String msg = c.s();
|
||||
if ((args != null) && (args.length > 0)) {
|
||||
msg = C.format(c, args);
|
||||
if (args.length != 0) {
|
||||
msg = c.format(c, args);
|
||||
}
|
||||
if (plr == null) {
|
||||
ConsolePlayer.getConsole().sendMessage(msg);
|
||||
if (plr != null) {
|
||||
plr.sendMessage((c.usePrefix() ? C.PREFIX.s() + msg : msg));
|
||||
} else {
|
||||
sendMessage(plr, msg, c.usePrefix());
|
||||
ConsolePlayer.getConsole().sendMessage((c.usePrefix() ? C.PREFIX.s() : "") + msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.general.commands.CommandCaller;
|
||||
|
||||
@ -10,8 +13,23 @@ public class Permissions {
|
||||
}
|
||||
|
||||
public static boolean hasPermission(final PlotPlayer player, final String perm) {
|
||||
if (!Settings.PERMISSION_CACHING) {
|
||||
return hasPermission((CommandCaller) player, perm);
|
||||
}
|
||||
HashMap<String, Boolean> map = (HashMap<String, Boolean>) player.getMeta("perm");
|
||||
if (map != null) {
|
||||
Boolean result = map.get(perm);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
} else {
|
||||
map = new HashMap<>();
|
||||
player.setMeta("perm", map);
|
||||
}
|
||||
boolean result = hasPermission((CommandCaller) player, perm);
|
||||
map.put(perm, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static boolean hasPermission(final CommandCaller player, String perm) {
|
||||
if (player.hasPermission(perm) || player.hasPermission(C.PERMISSION_ADMIN.s())) {
|
||||
|
@ -519,6 +519,7 @@ public abstract class SchematicHandler {
|
||||
}
|
||||
|
||||
public List<String> getSaves(final UUID uuid) {
|
||||
final StringBuilder rawJSON = new StringBuilder();
|
||||
try {
|
||||
final String website = Settings.WEB_URL + "list.php?" + uuid.toString();
|
||||
final URL url = new URL(website);
|
||||
@ -526,7 +527,6 @@ public abstract class SchematicHandler {
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String line;
|
||||
final StringBuilder rawJSON = new StringBuilder();
|
||||
while ((line = reader.readLine()) != null) {
|
||||
rawJSON.append(line);
|
||||
}
|
||||
@ -540,6 +540,7 @@ public abstract class SchematicHandler {
|
||||
return Lists.reverse(schematics);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
PS.debug("ERROR PARSING: " + rawJSON);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -116,11 +116,11 @@ public abstract class UUIDHandlerImplementation {
|
||||
offline = null;
|
||||
}
|
||||
}
|
||||
if (offline != null) {
|
||||
if (offline != null && !offline.equals(uuid)) {
|
||||
unknown.remove(offline);
|
||||
final Set<Plot> plots = PS.get().getPlots(offline);
|
||||
if (plots.size() > 0) {
|
||||
for (final Plot plot : PS.get().getPlots(offline)) {
|
||||
for (final Plot plot : plots) {
|
||||
plot.owner = uuid;
|
||||
}
|
||||
DBFunc.replaceUUID(offline, uuid);
|
||||
@ -132,10 +132,11 @@ public abstract class UUIDHandlerImplementation {
|
||||
}
|
||||
try {
|
||||
final UUID offline = uuidMap.put(name, uuid);
|
||||
if ((offline != null) && !offline.equals(uuid)) {
|
||||
if (offline != null) {
|
||||
if (!offline.equals(uuid)) {
|
||||
final Set<Plot> plots = PS.get().getPlots(offline);
|
||||
if (plots.size() > 0) {
|
||||
for (final Plot plot : PS.get().getPlots(offline)) {
|
||||
for (final Plot plot : plots) {
|
||||
plot.owner = uuid;
|
||||
}
|
||||
DBFunc.replaceUUID(offline, uuid);
|
||||
@ -143,6 +144,9 @@ public abstract class UUIDHandlerImplementation {
|
||||
PS.debug("&7 - Did you recently switch to online-mode storage without running `uuidconvert`?");
|
||||
PS.debug("&6PlotSquared will update incorrect entries when the user logs in, or you can reconstruct your database.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
final BiMap<UUID, StringWrapper> inverse = uuidMap.inverse();
|
||||
|
@ -0,0 +1,44 @@
|
||||
package com.intellectualcrafters.plot.uuid;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
|
||||
public class NameFetcher implements Callable<Map<UUID, String>> {
|
||||
private static final String PROFILE_URL = "https://sessionserver.mojang.com/session/minecraft/profile/";
|
||||
private final JSONParser jsonParser = new JSONParser();
|
||||
private final ArrayDeque<UUID> uuids;
|
||||
|
||||
public NameFetcher(List<UUID> uuids) {
|
||||
this.uuids = new ArrayDeque<>(uuids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<UUID, String> call() throws Exception {
|
||||
Map<UUID, String> uuidStringMap = new HashMap<UUID, String>();
|
||||
for (UUID uuid : uuids) {
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(PROFILE_URL + uuid.toString().replace("-", "")).openConnection();
|
||||
JSONObject response = (JSONObject) jsonParser.parse(new InputStreamReader(connection.getInputStream()));
|
||||
String name = (String) response.get("name");
|
||||
if (name == null) {
|
||||
continue;
|
||||
}
|
||||
String cause = (String) response.get("cause");
|
||||
String errorMessage = (String) response.get("errorMessage");
|
||||
if (cause != null && cause.length() > 0) {
|
||||
throw new IllegalStateException(errorMessage);
|
||||
}
|
||||
uuidStringMap.put(uuid, name);
|
||||
}
|
||||
return uuidStringMap;
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package com.intellectualcrafters.plot.uuid;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class UUIDFetcher implements Callable<Map<String, UUID>> {
|
||||
private static final double PROFILES_PER_REQUEST = 100;
|
||||
private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft";
|
||||
private final JSONParser jsonParser = new JSONParser();
|
||||
private final List<String> names;
|
||||
private final boolean rateLimiting;
|
||||
|
||||
public UUIDFetcher(List<String> names, boolean rateLimiting) {
|
||||
this.names = ImmutableList.copyOf(names);
|
||||
this.rateLimiting = rateLimiting;
|
||||
}
|
||||
|
||||
public UUIDFetcher(List<String> names) {
|
||||
this(names, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, UUID> call() throws Exception {
|
||||
Map<String, UUID> uuidMap = new HashMap<String, UUID>();
|
||||
int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST);
|
||||
for (int i = 0; i < requests; i++) {
|
||||
HttpURLConnection connection = createConnection();
|
||||
String body = JSONArray.toJSONString(names.subList(i * 100, Math.min((i + 1) * 100, names.size())));
|
||||
writeBody(connection, body);
|
||||
JSONArray array = (JSONArray) jsonParser.parse(new InputStreamReader(connection.getInputStream()));
|
||||
for (Object profile : array) {
|
||||
JSONObject jsonProfile = (JSONObject) profile;
|
||||
String id = (String) jsonProfile.get("id");
|
||||
String name = (String) jsonProfile.get("name");
|
||||
UUID uuid = UUIDFetcher.getUUID(id);
|
||||
uuidMap.put(name, uuid);
|
||||
}
|
||||
if (rateLimiting && i != requests - 1) {
|
||||
Thread.sleep(100L);
|
||||
}
|
||||
}
|
||||
return uuidMap;
|
||||
}
|
||||
|
||||
private static void writeBody(HttpURLConnection connection, String body) throws Exception {
|
||||
OutputStream stream = connection.getOutputStream();
|
||||
stream.write(body.getBytes());
|
||||
stream.flush();
|
||||
stream.close();
|
||||
}
|
||||
|
||||
private static HttpURLConnection createConnection() throws Exception {
|
||||
URL url = new URL(PROFILE_URL);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
connection.setUseCaches(false);
|
||||
connection.setDoInput(true);
|
||||
connection.setDoOutput(true);
|
||||
return connection;
|
||||
}
|
||||
|
||||
private static UUID getUUID(String id) {
|
||||
return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" + id.substring(20, 32));
|
||||
}
|
||||
|
||||
public static byte[] toBytes(UUID uuid) {
|
||||
ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]);
|
||||
byteBuffer.putLong(uuid.getMostSignificantBits());
|
||||
byteBuffer.putLong(uuid.getLeastSignificantBits());
|
||||
return byteBuffer.array();
|
||||
}
|
||||
|
||||
public static UUID fromBytes(byte[] array) {
|
||||
if (array.length != 16) {
|
||||
throw new IllegalArgumentException("Illegal byte array length: " + array.length);
|
||||
}
|
||||
ByteBuffer byteBuffer = ByteBuffer.wrap(array);
|
||||
long mostSignificant = byteBuffer.getLong();
|
||||
long leastSignificant = byteBuffer.getLong();
|
||||
return new UUID(mostSignificant, leastSignificant);
|
||||
}
|
||||
|
||||
public static UUID getUUIDOf(String name) throws Exception {
|
||||
return new UUIDFetcher(Arrays.asList(name)).call().get(name);
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ package com.plotsquared.bukkit;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -122,7 +123,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
THIS = this;
|
||||
PS.instance = new PS(this, "Bukkit");
|
||||
new PS(this, "Bukkit");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -191,23 +192,19 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
public void runEntityTask() {
|
||||
log(C.PREFIX.s() + "KillAllEntities started.");
|
||||
TaskManager.runTaskRepeat(new Runnable() {
|
||||
long ticked = 0l;
|
||||
long error = 0l;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (ticked > 36_000L) {
|
||||
ticked = 0l;
|
||||
if (error > 0) {
|
||||
log(C.PREFIX.s() + "KillAllEntities has been running for 6 hours. Errors: " + error);
|
||||
}
|
||||
error = 0l;
|
||||
}
|
||||
World world;
|
||||
for (final PlotWorld pw : PS.get().getPlotWorldObjects()) {
|
||||
world = Bukkit.getWorld(pw.worldname);
|
||||
try {
|
||||
for (final Entity entity : world.getEntities()) {
|
||||
if (world == null) {
|
||||
continue;
|
||||
}
|
||||
List<Entity> entities = world.getEntities();
|
||||
Iterator<Entity> iter = entities.iterator();
|
||||
while (iter.hasNext()) {
|
||||
Entity entity = iter.next();
|
||||
switch (entity.getType()) {
|
||||
case EGG:
|
||||
case ENDER_CRYSTAL:
|
||||
@ -251,19 +248,21 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
Plot plot = loc.getPlot();
|
||||
if (plot == null) {
|
||||
if (MainUtil.isPlotAreaAbs(loc)) {
|
||||
iter.remove();
|
||||
entity.remove();
|
||||
}
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
List<MetadataValue> meta = entity.getMetadata("plot");
|
||||
if (meta.size() == 0) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
Plot origin = (Plot) meta.get(0).value();
|
||||
if (!plot.equals(origin.getBasePlot(false))) {
|
||||
iter.remove();
|
||||
entity.remove();
|
||||
}
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
case SMALL_FIREBALL:
|
||||
case FIREBALL:
|
||||
@ -317,18 +316,17 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
final Entity passenger = entity.getPassenger();
|
||||
if (!(passenger instanceof Player)) {
|
||||
if (entity.getMetadata("keep").size() == 0) {
|
||||
iter.remove();
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final Throwable e) {
|
||||
++error;
|
||||
} finally {
|
||||
++ticked;
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,8 +55,17 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
||||
final HashMap<String, Integer> roadWidth = new HashMap<>();
|
||||
final HashMap<Integer, Plot> plots = new HashMap<>();
|
||||
final HashMap<String, HashMap<PlotId, boolean[]>> merges = new HashMap<>();
|
||||
try {
|
||||
stmt = connection.prepareStatement("SELECT * FROM `" + plugin + "core_plots`");
|
||||
r = stmt.executeQuery();
|
||||
} catch (Exception e) {
|
||||
PS.debug("========= Table does not exist =========");
|
||||
e.printStackTrace();
|
||||
PS.debug("=======================================");
|
||||
PS.debug("&8 - &7The database does not match the version specified in the PlotMe config");
|
||||
PS.debug("&8 - &7Please correct this, or if you are unsure, the most common is 0.16.3");
|
||||
return null;
|
||||
}
|
||||
final boolean checkUUID = DBFunc.hasColumn(r, "ownerID");
|
||||
final boolean merge = !plugin.equals("plotme") && Settings.CONVERT_PLOTME;
|
||||
while (r.next()) {
|
||||
|
@ -49,7 +49,7 @@ public abstract class BukkitPlotGenerator extends ChunkGenerator {
|
||||
public int Z;
|
||||
private boolean loaded = false;
|
||||
private short[][] result;
|
||||
private final PseudoRandom random = new PseudoRandom();
|
||||
public final PseudoRandom random = new PseudoRandom();
|
||||
|
||||
public BukkitPlotGenerator(final String world) {
|
||||
WorldEvents.lastWorld = world;
|
||||
|
@ -17,7 +17,7 @@ import com.intellectualcrafters.plot.util.SetBlockQueue;
|
||||
|
||||
public abstract class BukkitPlotPopulator extends BlockPopulator {
|
||||
|
||||
private final PseudoRandom random = new PseudoRandom();
|
||||
public final PseudoRandom random = new PseudoRandom();
|
||||
|
||||
public int X;
|
||||
public int Z;
|
||||
@ -29,8 +29,15 @@ public abstract class BukkitPlotPopulator extends BlockPopulator {
|
||||
try {
|
||||
this.chunk = chunk;
|
||||
worldname = world.getName();
|
||||
X = this.chunk.getX() << 4;
|
||||
Z = this.chunk.getZ() << 4;
|
||||
int cx = this.chunk.getX();
|
||||
int cz = this.chunk.getZ();
|
||||
X = cx << 4;
|
||||
Z = cz << 4;
|
||||
final int prime = 13;
|
||||
int h = 1;
|
||||
h = (prime * h) + cx;
|
||||
h = (prime * h) + cz;
|
||||
random.state = h;
|
||||
if (ChunkManager.FORCE_PASTE) {
|
||||
for (short x = 0; x < 16; x++) {
|
||||
for (short z = 0; z < 16; z++) {
|
||||
@ -43,7 +50,7 @@ public abstract class BukkitPlotPopulator extends BlockPopulator {
|
||||
}
|
||||
return;
|
||||
}
|
||||
populate(world, ChunkManager.CURRENT_PLOT_CLEAR, random, X, Z);
|
||||
populate(world, ChunkManager.CURRENT_PLOT_CLEAR, random, cx, cz);
|
||||
if (ChunkManager.CURRENT_PLOT_CLEAR != null) {
|
||||
PlotLoc loc;
|
||||
for (final Entry<PlotLoc, HashMap<Short, Byte>> entry : ChunkManager.GENERATE_DATA.entrySet()) {
|
||||
@ -96,6 +103,14 @@ public abstract class BukkitPlotPopulator extends BlockPopulator {
|
||||
}
|
||||
}
|
||||
|
||||
public void setBlock(final short x, final short y, final short z, final byte[] datas) {
|
||||
if (datas.length == 1) {
|
||||
setBlock(x, y, z, datas[0]);
|
||||
} else {
|
||||
setBlock(x, y, z, datas[random.random(datas.length)]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Like setblock, but lacks the data != 0 check
|
||||
* @param x
|
||||
|
@ -131,7 +131,7 @@ public class HybridGen extends BukkitPlotGenerator {
|
||||
for (int i = 0; i < cached.length; i++) {
|
||||
cached[i] = new short[4096];
|
||||
}
|
||||
final PseudoRandom random = new PseudoRandom();
|
||||
random.state = 7919;
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
cached[CACHE_I[plotheight][x][z]][CACHE_J[plotheight][x][z]] = plotfloors[random.random(plotfloors.length)];
|
||||
@ -209,22 +209,16 @@ public class HybridGen extends BukkitPlotGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
if (plotworld.PLOT_BEDROCK) {
|
||||
for (short x = 0; x < 16; x++) {
|
||||
for (short z = 0; z < 16; z++) {
|
||||
setBlock(x, 0, z, (short) 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (region != null) {
|
||||
for (short x = 0; x < 16; x++) {
|
||||
final int absX = ((sx + x) % size);
|
||||
for (short z = 0; z < 16; z++) {
|
||||
if (contains(region, x, z)) {
|
||||
setBlock(x, 0, z, (short) 7);
|
||||
setBlock(x, plotheight, z, plotfloors);
|
||||
for (short y = 1; y < plotheight; y++) {
|
||||
setBlock(x, y, z, filling);
|
||||
}
|
||||
setBlock(x, plotheight, z, plotfloors);
|
||||
final int absZ = ((sz + z) % size);
|
||||
final PlotLoc loc = new PlotLoc(absX, absZ);
|
||||
final HashMap<Short, Short> blocks = plotworld.G_SCH.get(loc);
|
||||
@ -239,6 +233,14 @@ public class HybridGen extends BukkitPlotGenerator {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plotworld.PLOT_BEDROCK) {
|
||||
for (short x = 0; x < 16; x++) {
|
||||
for (short z = 0; z < 16; z++) {
|
||||
setBlock(x, 0, z, (short) 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (short x = 0; x < 16; x++) {
|
||||
final int absX = ((sx + x) % size);
|
||||
final boolean gx = absX > pathWidthLower;
|
||||
@ -249,10 +251,10 @@ public class HybridGen extends BukkitPlotGenerator {
|
||||
final boolean lz = absZ < pathWidthUpper;
|
||||
// inside plot
|
||||
if (gx && gz && lx && lz) {
|
||||
setBlock(x, plotheight, z, plotfloors);
|
||||
for (short y = 1; y < plotheight; y++) {
|
||||
setBlock(x, y, z, filling);
|
||||
}
|
||||
setBlock(x, plotheight, z, plotfloors);
|
||||
if (plotworld.PLOT_SCHEMATIC) {
|
||||
final PlotLoc loc = new PlotLoc(absX, absZ);
|
||||
final HashMap<Short, Short> blocks = plotworld.G_SCH.get(loc);
|
||||
|
@ -38,9 +38,9 @@ public class HybridPop extends BukkitPlotPopulator {
|
||||
final short pathWidthUpper;
|
||||
private final HybridPlotWorld plotworld;
|
||||
Biome biome;
|
||||
private long state;
|
||||
private boolean doFilling = false;
|
||||
private boolean doFloor = false;
|
||||
private boolean cached;
|
||||
|
||||
public HybridPop(final PlotWorld pw) {
|
||||
plotworld = (HybridPlotWorld) pw;
|
||||
@ -84,24 +84,10 @@ public class HybridPop extends BukkitPlotPopulator {
|
||||
}
|
||||
pathWidthUpper = (short) (pathWidthLower + plotsize + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public final long nextLong() {
|
||||
final long a = state;
|
||||
state = xorShift64(a);
|
||||
return a;
|
||||
if (!this.plotworld.PLOT_SCHEMATIC) {
|
||||
this.cached = true;
|
||||
}
|
||||
|
||||
public final long xorShift64(long a) {
|
||||
a ^= (a << 21);
|
||||
a ^= (a >>> 35);
|
||||
a ^= (a << 4);
|
||||
return a;
|
||||
}
|
||||
|
||||
public final int random(final int n) {
|
||||
final long result = ((nextLong() >>> 32) * n) >> 32;
|
||||
return (int) result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -116,18 +102,25 @@ public class HybridPop extends BukkitPlotPopulator {
|
||||
sz += size;
|
||||
}
|
||||
|
||||
if (cached) {
|
||||
if ((sx > pathWidthLower) && (sz > pathWidthLower) && ((sx + 15) < pathWidthUpper) && ((sz + 15) < pathWidthUpper)) {
|
||||
random.state = 7919;
|
||||
}
|
||||
}
|
||||
|
||||
if (requiredRegion != null) {
|
||||
if (!doFloor && !doFilling && plotworld.G_SCH_STATE == null) {
|
||||
return;
|
||||
}
|
||||
for (short x = 0; x < 16; x++) {
|
||||
for (short z = 0; z < 16; z++) {
|
||||
if (contains(requiredRegion, x, z)) {
|
||||
setBlock(x, (short) plotheight, z, plotfloors);
|
||||
if (doFilling) {
|
||||
for (short y = 1; y < plotheight; y++) {
|
||||
setBlock(x, y, z, filling);
|
||||
}
|
||||
}
|
||||
if (doFloor) {
|
||||
setBlock(x, (short) plotheight, z, plotfloors);
|
||||
}
|
||||
if (plotworld.PLOT_SCHEMATIC) {
|
||||
final int absX = ((sx + x) % size);
|
||||
final int absZ = ((sz + z) % size);
|
||||
@ -154,19 +147,19 @@ public class HybridPop extends BukkitPlotPopulator {
|
||||
}
|
||||
|
||||
for (short x = 0; x < 16; x++) {
|
||||
for (short z = 0; z < 16; z++) {
|
||||
final int absX = ((sx + x) % size);
|
||||
final int absZ = ((sz + z) % size);
|
||||
final boolean gx = absX > pathWidthLower;
|
||||
final boolean gz = absZ > pathWidthLower;
|
||||
final boolean lx = absX < pathWidthUpper;
|
||||
for (short z = 0; z < 16; z++) {
|
||||
final int absZ = ((sz + z) % size);
|
||||
final boolean gz = absZ > pathWidthLower;
|
||||
final boolean lz = absZ < pathWidthUpper;
|
||||
// inside plot
|
||||
if (gx && gz && lx && lz) {
|
||||
setBlock(x, (short) plotheight, z, plotfloors);
|
||||
for (short y = 1; y < plotheight; y++) {
|
||||
setBlock(x, y, z, filling);
|
||||
}
|
||||
setBlock(x, (short) plotheight, z, plotfloors);
|
||||
if (plotworld.PLOT_SCHEMATIC) {
|
||||
final PlotLoc loc = new PlotLoc(absX, absZ);
|
||||
final HashMap<Short, Byte> blocks = plotworld.G_SCH_DATA.get(loc);
|
||||
@ -215,13 +208,4 @@ public class HybridPop extends BukkitPlotPopulator {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setBlock(final short x, final short y, final short z, final byte[] blkids) {
|
||||
if (blkids.length == 1) {
|
||||
setBlock(x, y, z, blkids[0]);
|
||||
} else {
|
||||
final int i = random(blkids.length);
|
||||
setBlock(x, y, z, blkids[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +92,6 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.projectiles.BlockProjectileSource;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.spongepowered.api.entity.living.animal.Animal;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
@ -129,7 +128,7 @@ import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
* Player Events involving plots
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings({ "unused", "deprecation", "unchecked" })
|
||||
@SuppressWarnings({ "deprecation", "unchecked" })
|
||||
public class PlayerEvents extends com.plotsquared.listener.PlotListener implements Listener {
|
||||
|
||||
private boolean pistonBlocks = true;
|
||||
@ -284,18 +283,9 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
if (!MainUtil.isPlotArea(loc)) {
|
||||
return;
|
||||
}
|
||||
//
|
||||
final ProjectileSource shooter = entity.getShooter();
|
||||
if (shooter instanceof BlockProjectileSource) {
|
||||
if (plot == null) {
|
||||
entity.remove();
|
||||
return;
|
||||
}
|
||||
final Location sLoc = BukkitUtil.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation());
|
||||
final Plot sPlot = MainUtil.getPlot(sLoc);
|
||||
if ((sPlot == null) || !PlotHandler.sameOwners(plot, sPlot)) {
|
||||
entity.remove();
|
||||
}
|
||||
} else if ((shooter instanceof Player)) {
|
||||
if ((shooter instanceof Player)) {
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter);
|
||||
if (plot == null) {
|
||||
if (!Permissions.hasPermission(pp, C.PERMISSION_PROJECTILE_UNOWNED)) {
|
||||
@ -310,16 +300,26 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
return;
|
||||
}
|
||||
entity.remove();
|
||||
} else if (!(shooter instanceof Entity) && shooter != null) {
|
||||
if (plot == null) {
|
||||
entity.remove();
|
||||
return;
|
||||
}
|
||||
final Location sLoc = BukkitUtil.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation());
|
||||
final Plot sPlot = MainUtil.getPlot(sLoc);
|
||||
if ((sPlot == null) || !PlotHandler.sameOwners(plot, sPlot)) {
|
||||
entity.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void PlayerCommand(final PlayerCommandPreprocessEvent event) {
|
||||
final String message = event.getMessage().toLowerCase().replaceAll("/", "").trim();
|
||||
if (message.length() == 0) {
|
||||
String msg = event.getMessage().toLowerCase().replaceAll("/", "").trim();
|
||||
if (msg.length() == 0) {
|
||||
return;
|
||||
}
|
||||
final String[] split = message.split(" ");
|
||||
final String[] split = msg.split(" ");
|
||||
final PluginCommand cmd = Bukkit.getServer().getPluginCommand(split[0]);
|
||||
if (cmd == null) {
|
||||
if (split[0].equals("plotme") || split[0].equals("ap")) {
|
||||
@ -330,38 +330,28 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_USING_PLOTME);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
pp.getLocation();
|
||||
if (!PS.get().isPlotWorld(BukkitUtil.getWorld(player))) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(player));
|
||||
}
|
||||
final Player player = event.getPlayer();
|
||||
final BukkitPlayer pp = (BukkitPlayer) BukkitUtil.getPlayer(player);
|
||||
Plot plot = pp.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Flag flag;
|
||||
if (((flag = FlagManager.getPlotFlagRaw(plot, "blocked-cmds")) != null) && !Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
|
||||
Flag flag = FlagManager.getPlotFlagRaw(plot, "blocked-cmds");
|
||||
if (flag == null || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
|
||||
return;
|
||||
}
|
||||
final List<String> v = (List<String>) flag.getValue();
|
||||
|
||||
String msg = event.getMessage().toLowerCase().replaceFirst("/", "");
|
||||
|
||||
final String[] parts = msg.split(" ");
|
||||
String c = parts[0];
|
||||
if (parts[0].contains(":")) {
|
||||
c = parts[0].split(":")[1];
|
||||
msg = msg.replace(parts[0].split(":")[0] + ":", "");
|
||||
}
|
||||
|
||||
final String l = c;
|
||||
|
||||
final List<String> aliases = new ArrayList<>();
|
||||
|
||||
for (final HelpTopic cmdLabel : Bukkit.getServer().getHelpMap().getHelpTopics()) {
|
||||
if (c.equals(cmdLabel.getName())) {
|
||||
break;
|
||||
@ -385,11 +375,9 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!l.equals(c)) {
|
||||
msg = msg.replace(l, c);
|
||||
}
|
||||
|
||||
for (final String s : v) {
|
||||
Pattern pattern;
|
||||
if (!RegExUtil.compiledPatterns.containsKey(s)) {
|
||||
@ -404,7 +392,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onChunkLoad(final ChunkLoadEvent event) {
|
||||
@ -453,7 +440,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASSED);
|
||||
}
|
||||
}
|
||||
if ((PS.get().update != null) && Permissions.hasPermission(pp, C.PERMISSION_ADMIN) && Settings.UPDATE_NOTIFICATIONS) {
|
||||
if ((PS.get().update != null) && Permissions.hasPermission(pp, C.PERMISSION_ADMIN_UPDATE) && Settings.UPDATE_NOTIFICATIONS) {
|
||||
TaskManager.runTaskLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -737,9 +724,13 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
final Player player = event.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
|
||||
|
||||
// Delete last location
|
||||
pp.deleteMeta("location");
|
||||
pp.deleteMeta("lastplot");
|
||||
Plot plot = (Plot) pp.deleteMeta("lastplot");
|
||||
if (plot != null) {
|
||||
plotExit(pp, plot);
|
||||
}
|
||||
|
||||
if (BukkitMain.worldEdit != null) {
|
||||
if (!Permissions.hasPermission(pp, C.PERMISSION_WORLDEDIT_BYPASS)) {
|
||||
@ -1025,13 +1016,16 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
if (blocks.size() == 0) {
|
||||
return;
|
||||
}
|
||||
final Plot origin = MainUtil.getPlot(BukkitUtil.getLocation(blocks.get(0).getLocation()));
|
||||
Location loc = BukkitUtil.getLocation(blocks.get(0).getLocation());
|
||||
final Plot origin = MainUtil.getPlot(loc);
|
||||
if (origin == null) {
|
||||
if (MainUtil.isPlotAreaAbs(loc)) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (int i = blocks.size() - 1; i >= 0; i--) {
|
||||
final Location loc = BukkitUtil.getLocation(blocks.get(i).getLocation());
|
||||
loc = BukkitUtil.getLocation(blocks.get(i).getLocation());
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (!Objects.equals(plot, origin)) {
|
||||
e.getBlocks().remove(i);
|
||||
@ -1041,27 +1035,26 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onInteract(final PlayerInteractEvent event) {
|
||||
final Action action = event.getAction();
|
||||
final Block block = event.getClickedBlock();
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
final Player player = event.getPlayer();
|
||||
final String world = player.getWorld().getName();
|
||||
if (!PS.get().isPlotWorld(world)) {
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
if (pp.getPlotWorld() == null) {
|
||||
return;
|
||||
}
|
||||
final Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
PlayerBlockEventType eventType = null;
|
||||
BukkitLazyBlock lb;
|
||||
Location loc;
|
||||
final Action action = event.getAction();
|
||||
switch (action) {
|
||||
case PHYSICAL: {
|
||||
eventType = PlayerBlockEventType.TRIGGER_PHYSICAL;
|
||||
Block block = event.getClickedBlock();
|
||||
lb = new BukkitLazyBlock(block);
|
||||
loc = BukkitUtil.getLocation(block.getLocation());
|
||||
break;
|
||||
}
|
||||
case RIGHT_CLICK_BLOCK: {
|
||||
Block block = event.getClickedBlock();
|
||||
loc = BukkitUtil.getLocation(block.getLocation());
|
||||
final Material blockType = block.getType();
|
||||
final int blockId = blockType.getId();
|
||||
switch (blockType) {
|
||||
@ -1143,8 +1136,9 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
lb = new BukkitLazyBlock(id, block);
|
||||
break;
|
||||
}
|
||||
lb = new BukkitLazyBlock(new PlotBlock((short) hand.getTypeId(), (byte) hand.getDurability()));
|
||||
switch (hand.getType()) {
|
||||
Material handType = hand.getType();
|
||||
lb = new BukkitLazyBlock(new PlotBlock((short) handType.getId(), (byte) 0));
|
||||
switch (handType) {
|
||||
case MONSTER_EGG:
|
||||
case MONSTER_EGGS: {
|
||||
eventType = PlayerBlockEventType.SPAWN_MOB;
|
||||
@ -1187,7 +1181,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
eventType = PlayerBlockEventType.EAT;
|
||||
break;
|
||||
}
|
||||
|
||||
case MINECART:
|
||||
case STORAGE_MINECART:
|
||||
case POWERED_MINECART:
|
||||
@ -1211,6 +1204,8 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
break;
|
||||
}
|
||||
case LEFT_CLICK_BLOCK: {
|
||||
Block block = event.getClickedBlock();
|
||||
loc = BukkitUtil.getLocation(block.getLocation());
|
||||
eventType = PlayerBlockEventType.BREAK_BLOCK;
|
||||
lb = new BukkitLazyBlock(block);
|
||||
break;
|
||||
@ -1438,7 +1433,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
default: {
|
||||
String[] types;
|
||||
if (entity instanceof LivingEntity) {
|
||||
if (entity instanceof Animal) {
|
||||
if (entity instanceof Animals) {
|
||||
types = new String[] { "entity-cap", "mob-cap", "animal-cap" };
|
||||
} else if (entity instanceof Monster) {
|
||||
types = new String[] { "entity-cap", "mob-cap", "hostile-cap" };
|
||||
|
@ -7,7 +7,7 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
|
||||
public class BukkitLazyBlock extends LazyBlock {
|
||||
|
||||
private int id = -1;
|
||||
private int id;
|
||||
private Block block;
|
||||
private PlotBlock pb;
|
||||
|
||||
@ -30,7 +30,7 @@ public class BukkitLazyBlock extends LazyBlock {
|
||||
if (pb != null) {
|
||||
return pb;
|
||||
}
|
||||
if (id == -1) {
|
||||
if (id == 0) {
|
||||
id = block.getTypeId();
|
||||
}
|
||||
byte data;
|
||||
@ -121,8 +121,10 @@ public class BukkitLazyBlock extends LazyBlock {
|
||||
case 191:
|
||||
case 192:
|
||||
data = 0;
|
||||
break;
|
||||
default:
|
||||
data = block.getData();
|
||||
break;
|
||||
}
|
||||
pb = new PlotBlock((short) id, data);
|
||||
return pb;
|
||||
@ -131,7 +133,7 @@ public class BukkitLazyBlock extends LazyBlock {
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
if (id == -1) {
|
||||
if (id == 0) {
|
||||
id = block.getTypeId();
|
||||
}
|
||||
return id;
|
||||
|
@ -14,7 +14,6 @@ import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
@ -71,26 +70,10 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final String node) {
|
||||
if (Settings.PERMISSION_CACHING) {
|
||||
if (noPerm.contains(node)) {
|
||||
return false;
|
||||
}
|
||||
if (hasPerm.contains(node)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (offline && (EconHandler.manager != null)) {
|
||||
return EconHandler.manager.hasPermission(getName(), node);
|
||||
}
|
||||
final boolean value = player.hasPermission(node);
|
||||
if (Settings.PERMISSION_CACHING) {
|
||||
if (value) {
|
||||
hasPerm.add(node);
|
||||
} else {
|
||||
noPerm.add(node);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
return player.hasPermission(node);
|
||||
}
|
||||
|
||||
public Permission getPermission(final String node) {
|
||||
@ -262,7 +245,11 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
|
||||
@Override
|
||||
public void setTime(final long time) {
|
||||
if (time != Long.MAX_VALUE) {
|
||||
player.setPlayerTime(time, false);
|
||||
} else {
|
||||
player.resetPlayerTime();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1012,10 +1012,10 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
}
|
||||
|
||||
private void count(final int[] count, final Entity entity) {
|
||||
count[0]++;
|
||||
switch (entity.getType()) {
|
||||
case PLAYER: {
|
||||
// not valid
|
||||
return;
|
||||
}
|
||||
case SMALL_FIREBALL:
|
||||
case FIREBALL:
|
||||
@ -1118,6 +1118,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
count[0]++;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,22 +1,23 @@
|
||||
package com.plotsquared.bukkit.uuid;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
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.ArrayList;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
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.json.JSONObject;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
@ -31,6 +32,11 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
|
||||
public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
|
||||
final String PROFILE_URL = "https://sessionserver.mojang.com/session/minecraft/profile/";
|
||||
final int MAX_REQUESTS = 500;
|
||||
final int INTERVAL = 12000;
|
||||
final JSONParser jsonParser = new JSONParser();
|
||||
|
||||
public SQLUUIDHandler(final UUIDWrapper wrapper) {
|
||||
super(wrapper);
|
||||
_sqLite = new SQLite("./plugins/PlotSquared/usercache.db");
|
||||
@ -89,7 +95,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
add(new StringWrapper("*"), DBFunc.everyone);
|
||||
|
||||
// This should be called as long as there are some unknown plots
|
||||
final List<UUID> toFetch = new ArrayList<>();
|
||||
final ArrayDeque<UUID> toFetch = new ArrayDeque<>();
|
||||
for (final UUID u : UUIDHandler.getAllUUIDS()) {
|
||||
if (!uuidExists(u)) {
|
||||
toFetch.add(u);
|
||||
@ -113,49 +119,80 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!Settings.OFFLINE_MODE) {
|
||||
PS.debug(C.PREFIX.s() + "&cWill fetch &6" + toFetch.size() + "&c from mojang!");
|
||||
int i = 0;
|
||||
final Iterator<UUID> iterator = toFetch.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
final StringBuilder url = new StringBuilder("http://api.intellectualsites.com/uuid/?user=");
|
||||
final List<UUID> currentIteration = new ArrayList<>();
|
||||
while ((i++ <= 15) && iterator.hasNext()) {
|
||||
final UUID _uuid = iterator.next();
|
||||
url.append(_uuid.toString());
|
||||
if (iterator.hasNext()) {
|
||||
url.append(",");
|
||||
}
|
||||
currentIteration.add(_uuid);
|
||||
}
|
||||
PS.debug(C.PREFIX.s() + "&cWill attempt to fetch &6" + currentIteration.size() + "&c uuids from: &6" + url.toString());
|
||||
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
final HttpURLConnection connection = (HttpURLConnection) new URL(url.toString()).openConnection();
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String line;
|
||||
final StringBuilder rawJSON = new StringBuilder();
|
||||
while ((line = reader.readLine()) != null) {
|
||||
rawJSON.append(line);
|
||||
}
|
||||
reader.close();
|
||||
final JSONObject object = new JSONObject(rawJSON.toString());
|
||||
for (final UUID _u : currentIteration) {
|
||||
final Object o = object.getJSONObject(_u.toString().replace("-", "")).get("username");
|
||||
if ((o == null) || !(o instanceof String)) {
|
||||
continue;
|
||||
}
|
||||
add(new StringWrapper(o.toString()), _u);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
if (toFetch.size() == 0) {
|
||||
if (whenDone != null) {
|
||||
whenDone.run();
|
||||
}
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < Math.min(500, toFetch.size()); i++) {
|
||||
UUID uuid = toFetch.pop();
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(PROFILE_URL + uuid.toString().replace("-", "")).openConnection();
|
||||
InputStreamReader reader = new InputStreamReader(connection.getInputStream());
|
||||
JSONObject response = (JSONObject) jsonParser.parse(reader);
|
||||
String name = (String) response.get("name");
|
||||
if (name != null) {
|
||||
add(new StringWrapper(name), uuid);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
TaskManager.runTaskLaterAsync(this, INTERVAL);
|
||||
}
|
||||
});
|
||||
/*
|
||||
* This API is no longer accessible.
|
||||
*/
|
||||
// if (!Settings.OFFLINE_MODE) {
|
||||
// PS.debug(C.PREFIX.s() + "&cWill fetch &6" + toFetch.size() + "&c from mojang!");
|
||||
//
|
||||
// int i = 0;
|
||||
// final Iterator<UUID> iterator = toFetch.iterator();
|
||||
// while (iterator.hasNext()) {
|
||||
// final StringBuilder url = new StringBuilder("http://api.intellectualsites.com/uuid/?user=");
|
||||
// final List<UUID> currentIteration = new ArrayList<>();
|
||||
// while ((i++ <= 15) && iterator.hasNext()) {
|
||||
// final UUID _uuid = iterator.next();
|
||||
// url.append(_uuid.toString());
|
||||
// if (iterator.hasNext()) {
|
||||
// url.append(",");
|
||||
// }
|
||||
// currentIteration.add(_uuid);
|
||||
// }
|
||||
// PS.debug(C.PREFIX.s() + "&cWill attempt to fetch &6" + currentIteration.size() + "&c uuids from: &6" + url.toString());
|
||||
// try {
|
||||
// final HttpURLConnection connection = (HttpURLConnection) new URL(url.toString()).openConnection();
|
||||
// connection.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||
// final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
// String line;
|
||||
// final StringBuilder rawJSON = new StringBuilder();
|
||||
// while ((line = reader.readLine()) != null) {
|
||||
// rawJSON.append(line);
|
||||
// }
|
||||
// reader.close();
|
||||
// final JSONObject object = new JSONObject(rawJSON.toString());
|
||||
// for (final UUID _u : currentIteration) {
|
||||
// final Object o = object.getJSONObject(_u.toString().replace("-", "")).get("username");
|
||||
// if ((o == null) || !(o instanceof String)) {
|
||||
// continue;
|
||||
// }
|
||||
// add(new StringWrapper(o.toString()), _u);
|
||||
// }
|
||||
// } catch (final Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// i = 0;
|
||||
// }
|
||||
// }
|
||||
// if (whenDone != null) {
|
||||
// whenDone.run();
|
||||
// }
|
||||
}
|
||||
});
|
||||
} catch (final SQLException e) {
|
||||
@ -169,24 +206,31 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
@Override
|
||||
public void fetchUUID(final String name, final RunnableVal<UUID> ifFetch) {
|
||||
PS.debug(C.PREFIX.s() + "UUID for '" + name + "' was null. We'll cache this from the mojang servers!");
|
||||
if (ifFetch == null) {
|
||||
return;
|
||||
}
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final String url = "http://api.intellectualsites.com/uuid/?user=" + name;
|
||||
try {
|
||||
final HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String line;
|
||||
final StringBuilder rawJSON = new StringBuilder();
|
||||
while ((line = reader.readLine()) != null) {
|
||||
rawJSON.append(line);
|
||||
}
|
||||
reader.close();
|
||||
final JSONObject object = new JSONObject(rawJSON.toString());
|
||||
ifFetch.value = UUID.fromString(object.getJSONObject(name).getString("dashed"));
|
||||
add(new StringWrapper(name), ifFetch.value);
|
||||
} catch (final IOException e) {
|
||||
URL url = new URL(PROFILE_URL);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
connection.setUseCaches(false);
|
||||
connection.setDoInput(true);
|
||||
connection.setDoOutput(true);
|
||||
String body = JSONArray.toJSONString(Arrays.asList(name));
|
||||
OutputStream stream = connection.getOutputStream();
|
||||
stream.write(body.getBytes());
|
||||
stream.flush();
|
||||
stream.close();
|
||||
JSONArray array = (JSONArray) jsonParser.parse(new InputStreamReader(connection.getInputStream()));
|
||||
JSONObject jsonProfile = (JSONObject) array.get(0);
|
||||
String id = (String) jsonProfile.get("id");
|
||||
String name = (String) jsonProfile.get("name");
|
||||
ifFetch.value = UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" + id.substring(20, 32));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
TaskManager.runTask(ifFetch);
|
||||
@ -212,7 +256,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
final PreparedStatement statement = getConnection().prepareStatement("INSERT INTO usercache (`uuid`, `username`) VALUES(?, ?)");
|
||||
final PreparedStatement statement = getConnection().prepareStatement("REPLACE INTO usercache (`uuid`, `username`) VALUES(?, ?)");
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setString(2, name.toString());
|
||||
statement.execute();
|
||||
@ -228,38 +272,8 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
}
|
||||
|
||||
/**
|
||||
* This isn't used as any UUID that is unknown is bulk cached (in lots of 16)
|
||||
* @param uuid
|
||||
* @return
|
||||
* This is useful for name changes
|
||||
*/
|
||||
@Deprecated
|
||||
public String getName__unused__(final UUID uuid) {
|
||||
PS.debug(C.PREFIX.s() + "Name for '" + uuid + "' was null. We'll cache this from the mojang servers!");
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final String url = "http://api.intellectualsites.com/uuid/?user=" + uuid;
|
||||
try {
|
||||
final HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String line;
|
||||
final StringBuilder rawJSON = new StringBuilder();
|
||||
while ((line = reader.readLine()) != null) {
|
||||
rawJSON.append(line);
|
||||
}
|
||||
reader.close();
|
||||
final JSONObject object = new JSONObject(rawJSON.toString());
|
||||
final String username = object.getJSONObject(uuid.toString().replace("-", "")).getString("username");
|
||||
add(new StringWrapper(username), uuid);
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rename(final UUID uuid, final StringWrapper name) {
|
||||
super.rename(uuid, name);
|
||||
|
@ -70,11 +70,11 @@ public abstract class Command<E extends CommandCaller> extends CommandManager {
|
||||
this.requiredType = requiredType;
|
||||
}
|
||||
|
||||
final public RequiredType getRequiredType() {
|
||||
public RequiredType getRequiredType() {
|
||||
return this.requiredType;
|
||||
}
|
||||
|
||||
final public void create() {
|
||||
public void create() {
|
||||
final Annotation annotation = getClass().getAnnotation(CommandDeclaration.class);
|
||||
if (annotation == null) {
|
||||
throw new RuntimeException("Command does not have a CommandDeclaration");
|
||||
@ -91,13 +91,13 @@ public abstract class Command<E extends CommandCaller> extends CommandManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
final public String toString() {
|
||||
public String toString() {
|
||||
return this.command;
|
||||
}
|
||||
|
||||
public abstract boolean onCommand(final E plr, final String[] arguments);
|
||||
|
||||
final public int handle(final E plr, final String[] args) {
|
||||
public int handle(final E plr, final String[] args) {
|
||||
if (args.length == 0) {
|
||||
return super.handle(plr, "");
|
||||
}
|
||||
@ -109,7 +109,7 @@ public abstract class Command<E extends CommandCaller> extends CommandManager {
|
||||
return super.handle(plr, s);
|
||||
}
|
||||
|
||||
final public String getCommand() {
|
||||
public String getCommand() {
|
||||
return this.command;
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ public abstract class Command<E extends CommandCaller> extends CommandManager {
|
||||
return this.usage;
|
||||
}
|
||||
|
||||
final public String getPermission() {
|
||||
public String getPermission() {
|
||||
if ((this.permission == null) || (this.permission.length() == 0)) {
|
||||
this.permission = "plots." + command.toLowerCase();
|
||||
}
|
||||
@ -131,18 +131,18 @@ public abstract class Command<E extends CommandCaller> extends CommandManager {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
final public Set<String> getAliases() {
|
||||
public Set<String> getAliases() {
|
||||
return this.aliases;
|
||||
}
|
||||
|
||||
final public Argument<?>[] getRequiredArguments() {
|
||||
public Argument<?>[] getRequiredArguments() {
|
||||
if (this.requiredArguments == null) {
|
||||
return new Argument<?>[0];
|
||||
}
|
||||
return this.requiredArguments;
|
||||
}
|
||||
|
||||
final public CommandCategory getCategory() {
|
||||
public CommandCategory getCategory() {
|
||||
if (category == null) {
|
||||
return CommandCategory.DEBUG;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class CommandManager<T extends CommandCaller> {
|
||||
}
|
||||
|
||||
final public Command<T> getCommand(final String command) {
|
||||
return commands.get(command);
|
||||
return commands.get(command.toLowerCase());
|
||||
}
|
||||
|
||||
final public boolean createCommand(final Command<T> command) {
|
||||
|
@ -20,7 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.plotsquared.listener;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@ -242,8 +241,4 @@ public class PlotListener {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean getFlagValue(final String value) {
|
||||
return Arrays.asList("true", "on", "enabled", "yes").contains(value.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
@ -80,6 +80,7 @@ import com.plotsquared.sponge.util.SpongeUtil;
|
||||
import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper;
|
||||
import com.plotsquared.sponge.uuid.SpongeOnlineUUIDWrapper;
|
||||
import com.plotsquared.sponge.uuid.SpongeUUIDHandler;
|
||||
import org.spongepowered.api.world.WorldBuilder;
|
||||
|
||||
/**
|
||||
* Created by robin on 01/11/2014
|
||||
@ -236,7 +237,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
||||
server = game.getServer();
|
||||
//
|
||||
|
||||
PS.instance = new PS(this, "Sponge");
|
||||
new PS(this, "Sponge");
|
||||
|
||||
registerBlocks();
|
||||
|
||||
@ -263,7 +264,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
||||
case 0: {
|
||||
modify = new WorldModify(generator, false);
|
||||
game.getRegistry().registerWorldGeneratorModifier(modify);
|
||||
final Optional<World> builder = game.getRegistry().createWorldBuilder().name(world).enabled(true).loadsOnStartup(true).keepsSpawnLoaded(true).dimensionType(DimensionTypes.OVERWORLD)
|
||||
final Optional<World> builder = game.getRegistry().createBuilder(WorldBuilder.class).name(world).enabled(true).loadsOnStartup(true).keepsSpawnLoaded(true).dimensionType(DimensionTypes.OVERWORLD)
|
||||
.generator(GeneratorTypes.FLAT).usesMapFeatures(false).generatorModifiers(modify).build();
|
||||
return builder.get();
|
||||
}
|
||||
@ -271,7 +272,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
||||
default: {
|
||||
modify = new WorldModify(generator, true);
|
||||
game.getRegistry().registerWorldGeneratorModifier(modify);
|
||||
final Optional<World> builder = game.getRegistry().createWorldBuilder().name(world).enabled(true).loadsOnStartup(true).keepsSpawnLoaded(true).dimensionType(DimensionTypes.OVERWORLD)
|
||||
final Optional<World> builder = game.getRegistry().createBuilder(WorldBuilder.class).name(world).enabled(true).loadsOnStartup(true).keepsSpawnLoaded(true).dimensionType(DimensionTypes.OVERWORLD)
|
||||
.generator(GeneratorTypes.OVERWORLD).usesMapFeatures(false).generatorModifiers(modify).build();
|
||||
return builder.get();
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import java.util.function.Predicate;
|
||||
import org.spongepowered.api.GameProfile;
|
||||
import org.spongepowered.api.block.BlockSnapshot;
|
||||
import org.spongepowered.api.block.BlockState;
|
||||
import org.spongepowered.api.block.BlockTransaction;
|
||||
import org.spongepowered.api.data.Transaction;
|
||||
import org.spongepowered.api.entity.Entity;
|
||||
import org.spongepowered.api.entity.EntityTypes;
|
||||
import org.spongepowered.api.entity.Transform;
|
||||
@ -182,57 +182,57 @@ public class MainListener {
|
||||
|
||||
@Listener
|
||||
public void onMobSpawn(final SpawnEntityEvent event) {
|
||||
final Entity entity = event.getTargetEntity();
|
||||
if (entity instanceof Player) {
|
||||
return;
|
||||
}
|
||||
final Location loc = SpongeUtil.getLocation(entity);
|
||||
final String world = loc.getWorld();
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(world);
|
||||
World world = event.getTargetWorld();
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(world.getName());
|
||||
if (plotworld == null) {
|
||||
return;
|
||||
}
|
||||
List<Entity> entities = event.getEntities();
|
||||
event.filterEntities(new Predicate<Entity>() {
|
||||
|
||||
@Override
|
||||
public boolean test(Entity entity) {
|
||||
if (entity instanceof Player) {
|
||||
return true;
|
||||
}
|
||||
final Location loc = SpongeUtil.getLocation(entity);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot == null) {
|
||||
if (MainUtil.isPlotRoad(loc)) {
|
||||
event.setCancelled(true);
|
||||
return false;
|
||||
}
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
PS.get().getPlotWorld(world);
|
||||
// Player player = this.<Player> getCause(event.getCause());
|
||||
// TODO selectively cancel depending on spawn reason
|
||||
// - Not sure if possible to get spawn reason (since there are no callbacks)
|
||||
// if (player != null && !plotworld.SPAWN_EGGS) {
|
||||
// event.setCancelled(true);
|
||||
// return;
|
||||
// return false;
|
||||
// return true;
|
||||
// }
|
||||
|
||||
if (entity.getType() == EntityTypes.ITEM) {
|
||||
if (FlagManager.isPlotFlagFalse(plot, "item-drop")) {
|
||||
event.setCancelled(true);
|
||||
return false;
|
||||
}
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
int[] mobs = null;
|
||||
if (entity instanceof Living) {
|
||||
if (!plotworld.MOB_SPAWNING) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
final Flag mobCap = FlagManager.getPlotFlagRaw(plot, "mob-cap");
|
||||
if (mobCap != null) {
|
||||
final Integer cap = (Integer) mobCap.getValue();
|
||||
if (cap == 0) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (mobs == null) {
|
||||
mobs = MainUtil.countEntities(plot);
|
||||
}
|
||||
if (mobs[3] >= cap) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ((entity instanceof Ambient) || (entity instanceof Animal)) {
|
||||
@ -240,15 +240,13 @@ public class MainListener {
|
||||
if (animalFlag != null) {
|
||||
final int cap = ((Integer) animalFlag.getValue());
|
||||
if (cap == 0) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (mobs == null) {
|
||||
mobs = MainUtil.countEntities(plot);
|
||||
}
|
||||
if (mobs[1] >= cap) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -257,34 +255,30 @@ public class MainListener {
|
||||
if (monsterFlag != null) {
|
||||
final int cap = ((Integer) monsterFlag.getValue());
|
||||
if (cap == 0) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (mobs == null) {
|
||||
mobs = MainUtil.countEntities(plot);
|
||||
}
|
||||
if (mobs[2] >= cap) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
if ((entity instanceof Minecart) || (entity instanceof Boat)) {
|
||||
final Flag vehicleFlag = FlagManager.getPlotFlagRaw(plot, "vehicle-cap");
|
||||
if (vehicleFlag != null) {
|
||||
final int cap = ((Integer) vehicleFlag.getValue());
|
||||
if (cap == 0) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (mobs == null) {
|
||||
mobs = MainUtil.countEntities(plot);
|
||||
}
|
||||
if (mobs[4] >= cap) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -292,21 +286,22 @@ public class MainListener {
|
||||
if (entityCap != null) {
|
||||
final Integer cap = (Integer) entityCap.getValue();
|
||||
if (cap == 0) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (mobs == null) {
|
||||
mobs = MainUtil.countEntities(plot);
|
||||
}
|
||||
if (mobs[0] >= cap) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (entity instanceof PrimedTNT) {
|
||||
Vector3d pos = entity.getLocation().getPosition();
|
||||
entity.setRotation(new Vector3d(MathMan.roundInt(pos.getX()), MathMan.roundInt(pos.getY()), MathMan.roundInt(pos.getZ())));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Listener
|
||||
@ -333,8 +328,8 @@ public class MainListener {
|
||||
if (!PS.get().isPlotWorld(worldname)) {
|
||||
return;
|
||||
}
|
||||
List<BlockTransaction> transactions = event.getTransactions();
|
||||
BlockTransaction first = transactions.get(0);
|
||||
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
|
||||
Transaction<BlockSnapshot> first = transactions.get(0);
|
||||
Location loc = SpongeUtil.getLocation(worldname, first.getOriginal().getPosition());
|
||||
Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot == null) {
|
||||
@ -371,7 +366,6 @@ public class MainListener {
|
||||
onBlockChange(event);
|
||||
}
|
||||
|
||||
|
||||
public void printCause(String method, Cause cause) {
|
||||
System.out.println(method + ": " + cause.toString());
|
||||
System.out.println(method + ": " + cause.getClass());
|
||||
@ -433,8 +427,7 @@ public class MainListener {
|
||||
}
|
||||
((SpongePlayer) user).player.sendMessage(Texts.join(components));
|
||||
}
|
||||
event.setMessage(Texts.of());
|
||||
event.setCancelled(true);
|
||||
event.setMessage(null);
|
||||
}
|
||||
|
||||
@Listener
|
||||
@ -529,8 +522,8 @@ public class MainListener {
|
||||
if (!PS.get().isPlotWorld(worldname)) {
|
||||
return;
|
||||
}
|
||||
List<BlockTransaction> transactions = event.getTransactions();
|
||||
BlockTransaction first = transactions.get(0);
|
||||
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
|
||||
Transaction<BlockSnapshot> first = transactions.get(0);
|
||||
BlockSnapshot pos = first.getOriginal();
|
||||
Location loc = SpongeUtil.getLocation(worldname, pos.getPosition());
|
||||
Plot plot = MainUtil.getPlot(loc);
|
||||
@ -613,8 +606,8 @@ public class MainListener {
|
||||
if (!PS.get().isPlotWorld(worldname)) {
|
||||
return;
|
||||
}
|
||||
List<BlockTransaction> transactions = event.getTransactions();
|
||||
BlockTransaction first = transactions.get(0);
|
||||
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
|
||||
Transaction<BlockSnapshot> first = transactions.get(0);
|
||||
BlockSnapshot pos = first.getOriginal();
|
||||
Location loc = SpongeUtil.getLocation(worldname, pos.getPosition());
|
||||
Plot plot = MainUtil.getPlot(loc);
|
||||
|
@ -225,6 +225,7 @@ public class SpongePlayer extends PlotPlayer {
|
||||
@Override
|
||||
public void setTime(final long time) {
|
||||
// TODO Auto-generated method stub
|
||||
if (time != Long.MAX_VALUE) {} else {}
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,12 @@
|
||||
package com.plotsquared.sponge.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.item.ItemType;
|
||||
import org.spongepowered.api.item.ItemTypes;
|
||||
import org.spongepowered.api.item.inventory.Carrier;
|
||||
import org.spongepowered.api.item.inventory.Inventories;
|
||||
import org.spongepowered.api.item.inventory.ItemStack;
|
||||
import org.spongepowered.api.item.inventory.ItemStackBuilder;
|
||||
import org.spongepowered.api.item.inventory.custom.CustomInventory;
|
||||
import org.spongepowered.api.item.inventory.property.SlotIndex;
|
||||
import org.spongepowered.api.item.inventory.type.CarriedInventory;
|
||||
@ -23,10 +20,10 @@ import com.plotsquared.sponge.object.SpongePlayer;
|
||||
|
||||
public class SpongeInventoryUtil extends InventoryUtil {
|
||||
|
||||
public ItemStackBuilder builder;
|
||||
public ItemStack.Builder builder;
|
||||
|
||||
public SpongeInventoryUtil() {
|
||||
builder = SpongeMain.THIS.getGame().getRegistry().createItemBuilder();
|
||||
builder = SpongeMain.THIS.getGame().getRegistry().createBuilder(ItemStack.Builder.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -35,7 +32,7 @@ public class SpongeInventoryUtil extends InventoryUtil {
|
||||
final SpongePlayer sp = (SpongePlayer) inv.player;
|
||||
final Player player = sp.player;
|
||||
|
||||
final CustomInventory inventory = Inventories.customInventoryBuilder().name(SpongeMain.THIS.getTranslation(inv.getTitle())).size(inv.size).build();
|
||||
final CustomInventory inventory = SpongeMain.THIS.getGame().getRegistry().createBuilder(CustomInventory.Builder.class).name(SpongeMain.THIS.getTranslation(inv.getTitle()).getTranslation()).size(inv.size).build();
|
||||
final PlotItemStack[] items = inv.getItems();
|
||||
for (int i = 0; i < (inv.size * 9); i++) {
|
||||
final PlotItemStack item = items[i];
|
||||
@ -105,7 +102,7 @@ public class SpongeInventoryUtil extends InventoryUtil {
|
||||
final Player player = sp.player;
|
||||
if (player.isViewingInventory()) {
|
||||
final CarriedInventory<? extends Carrier> inventory = player.getInventory();
|
||||
return inv.getTitle().equals(inventory.getName().getTranslation().get(Locale.ENGLISH));
|
||||
return inv.getTitle().equals(inventory.getName().getId()); // TODO getId()
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -52,7 +52,6 @@ import ninja.leaping.configurate.loader.ConfigurationLoader;
|
||||
import org.spongepowered.api.Game;
|
||||
import org.spongepowered.api.plugin.PluginContainer;
|
||||
import org.spongepowered.api.service.scheduler.Task;
|
||||
import org.spongepowered.api.service.scheduler.TaskBuilder;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
|
||||
@ -184,8 +183,8 @@ public class SpongeMetrics {
|
||||
}
|
||||
|
||||
// Begin hitting the server with glorious data
|
||||
final TaskBuilder builder = game.getScheduler().createTaskBuilder();
|
||||
builder.async().interval(TimeUnit.MINUTES.toMillis(PING_INTERVAL)).execute(new Runnable() {
|
||||
final Task.Builder builder = game.getScheduler().createTaskBuilder();
|
||||
builder.async().interval(PING_INTERVAL, TimeUnit.MINUTES).execute(new Runnable() {
|
||||
|
||||
private boolean firstPost = true;
|
||||
|
||||
|
@ -4,7 +4,6 @@ import java.util.HashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.spongepowered.api.service.scheduler.Task;
|
||||
import org.spongepowered.api.service.scheduler.TaskBuilder;
|
||||
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.sponge.SpongeMain;
|
||||
@ -18,8 +17,8 @@ public class SpongeTaskManager extends TaskManager {
|
||||
@Override
|
||||
public int taskRepeat(final Runnable r, final int interval) {
|
||||
final int val = i.incrementAndGet();
|
||||
final TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
||||
final TaskBuilder built = builder.delay(interval).interval(interval).execute(r);
|
||||
final Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
||||
final Task.Builder built = builder.delayTicks(interval).intervalTicks(interval).execute(r);
|
||||
final Task task = built.submit(SpongeMain.THIS.getPlugin());
|
||||
tasks.put(val, task);
|
||||
return val;
|
||||
@ -28,8 +27,8 @@ public class SpongeTaskManager extends TaskManager {
|
||||
@Override
|
||||
public int taskRepeatAsync(final Runnable r, final int interval) {
|
||||
final int val = i.incrementAndGet();
|
||||
final TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
||||
final TaskBuilder built = builder.delay(interval).async().interval(interval).execute(r);
|
||||
final Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
||||
final Task.Builder built = builder.delayTicks(interval).async().intervalTicks(interval).execute(r);
|
||||
final Task task = built.submit(SpongeMain.THIS.getPlugin());
|
||||
tasks.put(val, task);
|
||||
return val;
|
||||
@ -37,26 +36,26 @@ public class SpongeTaskManager extends TaskManager {
|
||||
|
||||
@Override
|
||||
public void taskAsync(final Runnable r) {
|
||||
final TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
||||
final Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
||||
builder.async().execute(r).submit(SpongeMain.THIS.getPlugin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void task(final Runnable r) {
|
||||
final TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
||||
final Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
||||
builder.execute(r).submit(SpongeMain.THIS.getPlugin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void taskLater(final Runnable r, final int delay) {
|
||||
final TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
||||
builder.delay(delay).execute(r).submit(SpongeMain.THIS.getPlugin());
|
||||
final Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
||||
builder.delayTicks(delay).execute(r).submit(SpongeMain.THIS.getPlugin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void taskLaterAsync(final Runnable r, final int delay) {
|
||||
final TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
||||
builder.async().delay(delay).execute(r).submit(SpongeMain.THIS.getPlugin());
|
||||
final Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
||||
builder.async().delayTicks(delay).execute(r).submit(SpongeMain.THIS.getPlugin());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -138,7 +138,7 @@ NAME_LITTLE: "$2%s Name ist zu kurz, $1%s$2<$1%s"
|
||||
NO_COMMANDS: "$2Du hast für keinen Befehl eine Berechtigung."
|
||||
SUBCOMMAND_SET_OPTIONS_HEADER: "$2Mögliche Werte: "
|
||||
COMMAND_SYNTAX: "$1Verwendung: $2%s"
|
||||
INVALID_PLAYER: "$2Spieler nicht gefunden: $1%s."
|
||||
INVALID_PLAYER: "$2Spieler nicht gefunden: $1%s$2."
|
||||
COMMAND_WENT_WRONG: "$2Beim ausführen des Befehls ging etwas schief..."
|
||||
PURGE_SYNTAX: "Verwende /plot purge <x;z|player|unowned|unknown|all> <world>"
|
||||
PURGE_SUCCESS: "$4%s Plots erfolgreich gelöscht."
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user