mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking
This commit is contained in:
commit
d0a4465985
@ -19,6 +19,7 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
|||||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||||
import org.bukkit.plugin.RegisteredListener;
|
import org.bukkit.plugin.RegisteredListener;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -53,7 +54,7 @@ public class BukkitPlayer extends PlotPlayer {
|
|||||||
return location == null ? BukkitUtil.getLocation(this.player) : location;
|
return location == null ? BukkitUtil.getLocation(this.player) : location;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public UUID getUUID() {
|
@Nonnull @Override public UUID getUUID() {
|
||||||
if (this.uuid == null) {
|
if (this.uuid == null) {
|
||||||
this.uuid = UUIDHandler.getUUID(this);
|
this.uuid = UUIDHandler.getUUID(this);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@ package com.github.intellectualsites.plotsquared.commands;
|
|||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
|
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public abstract class Argument<T> {
|
public abstract class Argument<T> {
|
||||||
|
|
||||||
public static final Argument<Integer> Integer = new Argument<Integer>("int", 16) {
|
public static final Argument<Integer> Integer = new Argument<Integer>("int", 16) {
|
||||||
@ -17,11 +19,9 @@ public abstract class Argument<T> {
|
|||||||
public static final Argument<Boolean> Boolean = new Argument<Boolean>("boolean", true) {
|
public static final Argument<Boolean> Boolean = new Argument<Boolean>("boolean", true) {
|
||||||
@Override public Boolean parse(String in) {
|
@Override public Boolean parse(String in) {
|
||||||
Boolean value = null;
|
Boolean value = null;
|
||||||
if (in.equalsIgnoreCase("true") || in.equalsIgnoreCase("Yes") || in
|
if (Stream.of("true", "Yes", "1").anyMatch(in::equalsIgnoreCase)) {
|
||||||
.equalsIgnoreCase("1")) {
|
|
||||||
value = true;
|
value = true;
|
||||||
} else if (in.equalsIgnoreCase("false") || in.equalsIgnoreCase("No") || in
|
} else if (Stream.of("false", "No", "0").anyMatch(in::equalsIgnoreCase)) {
|
||||||
.equalsIgnoreCase("0")) {
|
|
||||||
value = false;
|
value = false;
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
@ -30,7 +30,6 @@ import lombok.Getter;
|
|||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
@ -342,12 +341,10 @@ import java.util.zip.ZipInputStream;
|
|||||||
debug("Starting UUID caching");
|
debug("Starting UUID caching");
|
||||||
UUIDHandler.startCaching(() -> {
|
UUIDHandler.startCaching(() -> {
|
||||||
UUIDHandler.add(new StringWrapper("*"), DBFunc.EVERYONE);
|
UUIDHandler.add(new StringWrapper("*"), DBFunc.EVERYONE);
|
||||||
foreachPlotRaw(new RunnableVal<Plot>() {
|
forEachPlotRaw(plot -> {
|
||||||
@Override public void run(Plot plot) {
|
if (plot.hasOwner() && plot.temp != -1) {
|
||||||
if (plot.hasOwner() && plot.temp != -1) {
|
if (UUIDHandler.getName(plot.owner) == null) {
|
||||||
if (UUIDHandler.getName(plot.owner) == null) {
|
UUIDHandler.implementation.unknown.add(plot.owner);
|
||||||
UUIDHandler.implementation.unknown.add(plot.owner);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -516,14 +513,12 @@ import java.util.zip.ZipInputStream;
|
|||||||
public Set<Plot> getBasePlots() {
|
public Set<Plot> getBasePlots() {
|
||||||
int size = getPlotCount();
|
int size = getPlotCount();
|
||||||
final Set<Plot> result = new HashSet<>(size);
|
final Set<Plot> result = new HashSet<>(size);
|
||||||
foreachPlotArea(new RunnableVal<PlotArea>() {
|
forEachPlotArea(value -> {
|
||||||
@Override public void run(PlotArea value) {
|
for (Plot plot : value.getPlots()) {
|
||||||
for (Plot plot : value.getPlots()) {
|
if (!plot.isBasePlot()) {
|
||||||
if (!plot.isBasePlot()) {
|
continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
result.add(plot);
|
|
||||||
}
|
}
|
||||||
|
result.add(plot);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return Collections.unmodifiableSet(result);
|
return Collections.unmodifiableSet(result);
|
||||||
@ -784,23 +779,21 @@ import java.util.zip.ZipInputStream;
|
|||||||
*/
|
*/
|
||||||
public Set<Plot> getPlots(final PlotFilter... filters) {
|
public Set<Plot> getPlots(final PlotFilter... filters) {
|
||||||
final HashSet<Plot> set = new HashSet<>();
|
final HashSet<Plot> set = new HashSet<>();
|
||||||
foreachPlotArea(new RunnableVal<PlotArea>() {
|
forEachPlotArea(value -> {
|
||||||
@Override public void run(PlotArea value) {
|
for (PlotFilter filter : filters) {
|
||||||
|
if (!filter.allowsArea(value)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
loop:
|
||||||
|
for (Entry<PlotId, Plot> entry2 : value.getPlotEntries()) {
|
||||||
|
Plot plot = entry2.getValue();
|
||||||
for (PlotFilter filter : filters) {
|
for (PlotFilter filter : filters) {
|
||||||
if (!filter.allowsArea(value)) {
|
if (!filter.allowsPlot(plot)) {
|
||||||
return;
|
continue loop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loop:
|
set.add(plot);
|
||||||
for (Entry<PlotId, Plot> entry2 : value.getPlotEntries()) {
|
|
||||||
Plot plot = entry2.getValue();
|
|
||||||
for (PlotFilter filter : filters) {
|
|
||||||
if (!filter.allowsPlot(plot)) {
|
|
||||||
continue loop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
set.add(plot);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return set;
|
return set;
|
||||||
@ -814,11 +807,7 @@ import java.util.zip.ZipInputStream;
|
|||||||
public Set<Plot> getPlots() {
|
public Set<Plot> getPlots() {
|
||||||
int size = getPlotCount();
|
int size = getPlotCount();
|
||||||
final Set<Plot> result = new HashSet<>(size);
|
final Set<Plot> result = new HashSet<>(size);
|
||||||
foreachPlotArea(new RunnableVal<PlotArea>() {
|
forEachPlotArea(value -> result.addAll(value.getPlots()));
|
||||||
@Override public void run(PlotArea value) {
|
|
||||||
result.addAll(value.getPlots());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -935,11 +924,7 @@ import java.util.zip.ZipInputStream;
|
|||||||
|
|
||||||
public Collection<Plot> getPlots(String world) {
|
public Collection<Plot> getPlots(String world) {
|
||||||
final Set<Plot> set = new HashSet<>();
|
final Set<Plot> set = new HashSet<>();
|
||||||
foreachPlotArea(world, new RunnableVal<PlotArea>() {
|
forEachPlotArea(world, value -> set.addAll(value.getPlots()));
|
||||||
@Override public void run(PlotArea value) {
|
|
||||||
set.addAll(value.getPlots());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -973,11 +958,9 @@ import java.util.zip.ZipInputStream;
|
|||||||
*/
|
*/
|
||||||
public Set<Plot> getPlots(final UUID uuid) {
|
public Set<Plot> getPlots(final UUID uuid) {
|
||||||
final Set<Plot> plots = new HashSet<>();
|
final Set<Plot> plots = new HashSet<>();
|
||||||
foreachPlot(new RunnableVal<Plot>() {
|
forEachPlot(value -> {
|
||||||
@Override public void run(Plot value) {
|
if (value.isOwnerAbs(uuid)) {
|
||||||
if (value.isOwnerAbs(uuid)) {
|
plots.add(value);
|
||||||
plots.add(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return Collections.unmodifiableSet(plots);
|
return Collections.unmodifiableSet(plots);
|
||||||
@ -990,11 +973,9 @@ import java.util.zip.ZipInputStream;
|
|||||||
|
|
||||||
public Set<Plot> getBasePlots(final UUID uuid) {
|
public Set<Plot> getBasePlots(final UUID uuid) {
|
||||||
final Set<Plot> plots = new HashSet<>();
|
final Set<Plot> plots = new HashSet<>();
|
||||||
foreachBasePlot(new RunnableVal<Plot>() {
|
forEachBasePlot(value -> {
|
||||||
@Override public void run(Plot value) {
|
if (value.isOwner(uuid)) {
|
||||||
if (value.isOwner(uuid)) {
|
plots.add(value);
|
||||||
plots.add(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return Collections.unmodifiableSet(plots);
|
return Collections.unmodifiableSet(plots);
|
||||||
@ -1008,11 +989,9 @@ import java.util.zip.ZipInputStream;
|
|||||||
*/
|
*/
|
||||||
public Set<Plot> getPlotsAbs(final UUID uuid) {
|
public Set<Plot> getPlotsAbs(final UUID uuid) {
|
||||||
final Set<Plot> plots = new HashSet<>();
|
final Set<Plot> plots = new HashSet<>();
|
||||||
foreachPlot(new RunnableVal<Plot>() {
|
forEachPlot(value -> {
|
||||||
@Override public void run(Plot value) {
|
if (value.isOwnerAbs(uuid)) {
|
||||||
if (value.isOwnerAbs(uuid)) {
|
plots.add(value);
|
||||||
plots.add(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return Collections.unmodifiableSet(plots);
|
return Collections.unmodifiableSet(plots);
|
||||||
@ -1538,11 +1517,7 @@ import java.util.zip.ZipInputStream;
|
|||||||
// Validate that all data in the db is correct
|
// Validate that all data in the db is correct
|
||||||
final HashSet<Plot> plots = new HashSet<>();
|
final HashSet<Plot> plots = new HashSet<>();
|
||||||
try {
|
try {
|
||||||
foreachPlotRaw(new RunnableVal<Plot>() {
|
forEachPlotRaw(plots::add);
|
||||||
@Override public void run(Plot value) {
|
|
||||||
plots.add(value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (final Exception ignored) {
|
} catch (final Exception ignored) {
|
||||||
}
|
}
|
||||||
DBFunc.validatePlots(plots);
|
DBFunc.validatePlots(plots);
|
||||||
@ -1824,43 +1799,36 @@ import java.util.zip.ZipInputStream;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void foreachPlotArea(@Nonnull final RunnableVal<PlotArea> runnable) {
|
public void forEachPlotArea(@NonNull final String world, Consumer<PlotArea> runnable) {
|
||||||
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
|
|
||||||
runnable.run(area);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void foreachPlotArea(@NonNull final String world,
|
|
||||||
@NonNull final RunnableVal<PlotArea> runnable) {
|
|
||||||
final PlotArea[] array = this.plotAreaManager.getPlotAreas(world, null);
|
final PlotArea[] array = this.plotAreaManager.getPlotAreas(world, null);
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (final PlotArea area : array) {
|
for (final PlotArea area : array) {
|
||||||
runnable.run(area);
|
runnable.accept(area);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void foreachPlot(@NonNull final RunnableVal<Plot> runnable) {
|
public void forEachPlot(Consumer<Plot> runnable) {
|
||||||
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
|
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
|
||||||
area.getPlots().forEach(runnable::run);
|
area.getPlots().forEach(runnable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void foreachPlotRaw(@NonNull final RunnableVal<Plot> runnable) {
|
public void forEachPlotRaw(Consumer<Plot> runnable) {
|
||||||
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
|
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
|
||||||
area.getPlots().forEach(runnable::run);
|
area.getPlots().forEach(runnable);
|
||||||
}
|
}
|
||||||
if (this.plots_tmp != null) {
|
if (this.plots_tmp != null) {
|
||||||
for (final HashMap<PlotId, Plot> entry : this.plots_tmp.values()) {
|
for (final HashMap<PlotId, Plot> entry : this.plots_tmp.values()) {
|
||||||
entry.values().forEach(runnable::run);
|
entry.values().forEach(runnable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void foreachBasePlot(@NonNull final RunnableVal<Plot> run) {
|
public void forEachBasePlot(Consumer<Plot> run) {
|
||||||
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
|
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
|
||||||
area.foreachBasePlot(run);
|
area.forEachBasePlot(run);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,27 +46,23 @@ import java.util.Set;
|
|||||||
final double price = flag.get();
|
final double price = flag.get();
|
||||||
checkTrue(player.getMoney() >= price, C.CANNOT_AFFORD_PLOT);
|
checkTrue(player.getMoney() >= price, C.CANNOT_AFFORD_PLOT);
|
||||||
player.withdraw(price);
|
player.withdraw(price);
|
||||||
confirm.run(this, new Runnable() {
|
// Failure
|
||||||
@Override // Success
|
// Success
|
||||||
public void run() {
|
confirm.run(this, () -> {
|
||||||
C.REMOVED_BALANCE.send(player, price);
|
C.REMOVED_BALANCE.send(player, price);
|
||||||
EconHandler.manager
|
EconHandler.manager
|
||||||
.depositMoney(UUIDHandler.getUUIDWrapper().getOfflinePlayer(plot.owner), price);
|
.depositMoney(UUIDHandler.getUUIDWrapper().getOfflinePlayer(plot.owner), price);
|
||||||
PlotPlayer owner = UUIDHandler.getPlayer(plot.owner);
|
PlotPlayer owner = UUIDHandler.getPlayer(plot.owner);
|
||||||
if (owner != null) {
|
if (owner != null) {
|
||||||
C.PLOT_SOLD.send(owner, plot.getId(), player.getName(), price);
|
C.PLOT_SOLD.send(owner, plot.getId(), player.getName(), price);
|
||||||
}
|
|
||||||
plot.removeFlag(Flags.PRICE);
|
|
||||||
plot.setOwner(player.getUUID());
|
|
||||||
C.CLAIMED.send(player);
|
|
||||||
whenDone.run(Buy.this, CommandResult.SUCCESS);
|
|
||||||
}
|
|
||||||
}, new Runnable() {
|
|
||||||
@Override // Failure
|
|
||||||
public void run() {
|
|
||||||
player.deposit(price);
|
|
||||||
whenDone.run(Buy.this, CommandResult.FAILURE);
|
|
||||||
}
|
}
|
||||||
|
plot.removeFlag(Flags.PRICE);
|
||||||
|
plot.setOwner(player.getUUID());
|
||||||
|
C.CLAIMED.send(player);
|
||||||
|
whenDone.run(Buy.this, CommandResult.SUCCESS);
|
||||||
|
}, () -> {
|
||||||
|
player.deposit(price);
|
||||||
|
whenDone.run(Buy.this, CommandResult.FAILURE);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import com.github.intellectualsites.plotsquared.plot.util.*;
|
|||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@CommandDeclaration(command = "setowner", permission = "plots.set.owner",
|
@CommandDeclaration(command = "setowner", permission = "plots.set.owner",
|
||||||
description = "Set the plot owner", usage = "/plot setowner <player>",
|
description = "Set the plot owner", usage = "/plot setowner <player>",
|
||||||
@ -31,8 +32,7 @@ import java.util.UUID;
|
|||||||
name = name == null ? value : name;
|
name = name == null ? value : name;
|
||||||
}
|
}
|
||||||
if (uuid == null || value.equalsIgnoreCase("-")) {
|
if (uuid == null || value.equalsIgnoreCase("-")) {
|
||||||
if (value.equalsIgnoreCase("none") || value.equalsIgnoreCase("null") || value
|
if (Stream.of("none", "null", "-").anyMatch(value::equalsIgnoreCase)) {
|
||||||
.equalsIgnoreCase("-")) {
|
|
||||||
if (!Permissions
|
if (!Permissions
|
||||||
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_SETOWNER.s(), true)) {
|
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_SETOWNER.s(), true)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -6,9 +6,7 @@ import com.github.intellectualsites.plotsquared.configuration.MemorySection;
|
|||||||
import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration;
|
import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration;
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -24,53 +22,51 @@ import java.util.Objects;
|
|||||||
// loaded during startup unfortunately.
|
// loaded during startup unfortunately.
|
||||||
PlotSquared.get().setupConfigs();
|
PlotSquared.get().setupConfigs();
|
||||||
C.load(PlotSquared.get().translationFile);
|
C.load(PlotSquared.get().translationFile);
|
||||||
PlotSquared.get().foreachPlotArea(new RunnableVal<PlotArea>() {
|
PlotSquared.get().forEachPlotArea(area -> {
|
||||||
@Override public void run(PlotArea area) {
|
ConfigurationSection worldSection =
|
||||||
ConfigurationSection worldSection = PlotSquared.get().worlds
|
PlotSquared.get().worlds.getConfigurationSection("worlds." + area.worldname);
|
||||||
.getConfigurationSection("worlds." + area.worldname);
|
if (worldSection == null) {
|
||||||
if (worldSection == null) {
|
return;
|
||||||
return;
|
}
|
||||||
|
if (area.TYPE != 2 || !worldSection.contains("areas")) {
|
||||||
|
area.saveConfiguration(worldSection);
|
||||||
|
area.loadDefaultConfiguration(worldSection);
|
||||||
|
} else {
|
||||||
|
ConfigurationSection areaSection = worldSection.getConfigurationSection(
|
||||||
|
"areas." + area.id + "-" + area.getMin() + "-" + area.getMax());
|
||||||
|
YamlConfiguration clone = new YamlConfiguration();
|
||||||
|
for (String key : areaSection.getKeys(true)) {
|
||||||
|
if (areaSection.get(key) instanceof MemorySection) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!clone.contains(key)) {
|
||||||
|
clone.set(key, areaSection.get(key));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (area.TYPE != 2 || !worldSection.contains("areas")) {
|
for (String key : worldSection.getKeys(true)) {
|
||||||
area.saveConfiguration(worldSection);
|
if (worldSection.get(key) instanceof MemorySection) {
|
||||||
area.loadDefaultConfiguration(worldSection);
|
continue;
|
||||||
} else {
|
|
||||||
ConfigurationSection areaSection = worldSection.getConfigurationSection(
|
|
||||||
"areas." + area.id + "-" + area.getMin() + "-" + area.getMax());
|
|
||||||
YamlConfiguration clone = new YamlConfiguration();
|
|
||||||
for (String key : areaSection.getKeys(true)) {
|
|
||||||
if (areaSection.get(key) instanceof MemorySection) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!clone.contains(key)) {
|
|
||||||
clone.set(key, areaSection.get(key));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for (String key : worldSection.getKeys(true)) {
|
if (!key.startsWith("areas") && !clone.contains(key)) {
|
||||||
if (worldSection.get(key) instanceof MemorySection) {
|
clone.set(key, worldSection.get(key));
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!key.startsWith("areas") && !clone.contains(key)) {
|
|
||||||
clone.set(key, worldSection.get(key));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
area.saveConfiguration(clone);
|
|
||||||
// netSections is the combination of
|
|
||||||
for (String key : clone.getKeys(true)) {
|
|
||||||
if (clone.get(key) instanceof MemorySection) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!worldSection.contains(key)) {
|
|
||||||
worldSection.set(key, clone.get(key));
|
|
||||||
} else {
|
|
||||||
Object value = worldSection.get(key);
|
|
||||||
if (Objects.equals(value, clone.get(key))) {
|
|
||||||
areaSection.set(key, clone.get(key));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
area.loadDefaultConfiguration(clone);
|
|
||||||
}
|
}
|
||||||
|
area.saveConfiguration(clone);
|
||||||
|
// netSections is the combination of
|
||||||
|
for (String key : clone.getKeys(true)) {
|
||||||
|
if (clone.get(key) instanceof MemorySection) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!worldSection.contains(key)) {
|
||||||
|
worldSection.set(key, clone.get(key));
|
||||||
|
} else {
|
||||||
|
Object value = worldSection.get(key);
|
||||||
|
if (Objects.equals(value, clone.get(key))) {
|
||||||
|
areaSection.set(key, clone.get(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
area.loadDefaultConfiguration(clone);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
PlotSquared.get().worlds.save(PlotSquared.get().worldsFile);
|
PlotSquared.get().worlds.save(PlotSquared.get().worldsFile);
|
||||||
|
@ -61,21 +61,19 @@ import java.util.UUID;
|
|||||||
checkTrue(!uuids.isEmpty(), null);
|
checkTrue(!uuids.isEmpty(), null);
|
||||||
checkTrue(size <= plot.getArea().MAX_PLOT_MEMBERS || Permissions
|
checkTrue(size <= plot.getArea().MAX_PLOT_MEMBERS || Permissions
|
||||||
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_TRUST), C.PLOT_MAX_MEMBERS);
|
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_TRUST), C.PLOT_MAX_MEMBERS);
|
||||||
confirm.run(this, new Runnable() {
|
// Success
|
||||||
@Override // Success
|
confirm.run(this, () -> {
|
||||||
public void run() {
|
for (UUID uuid : uuids) {
|
||||||
for (UUID uuid : uuids) {
|
if (uuid != DBFunc.EVERYONE) {
|
||||||
if (uuid != DBFunc.EVERYONE) {
|
if (!plot.removeMember(uuid)) {
|
||||||
if (!plot.removeMember(uuid)) {
|
if (plot.getDenied().contains(uuid)) {
|
||||||
if (plot.getDenied().contains(uuid)) {
|
plot.removeDenied(uuid);
|
||||||
plot.removeDenied(uuid);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plot.addTrusted(uuid);
|
|
||||||
EventUtil.manager.callTrusted(player, plot, uuid, true);
|
|
||||||
MainUtil.sendMessage(player, C.TRUSTED_ADDED);
|
|
||||||
}
|
}
|
||||||
|
plot.addTrusted(uuid);
|
||||||
|
EventUtil.manager.callTrusted(player, plot, uuid, true);
|
||||||
|
MainUtil.sendMessage(player, C.TRUSTED_ADDED);
|
||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
|
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public interface AbstractDB {
|
public interface AbstractDB {
|
||||||
@ -300,7 +301,7 @@ public interface AbstractDB {
|
|||||||
*
|
*
|
||||||
* @param plot The Plot to get comments from
|
* @param plot The Plot to get comments from
|
||||||
*/
|
*/
|
||||||
void getComments(Plot plot, String inbox, RunnableVal<List<PlotComment>> whenDone);
|
void getComments(@Nonnull Plot plot, String inbox, RunnableVal<List<PlotComment>> whenDone);
|
||||||
|
|
||||||
void createPlotAndSettings(Plot plot, Runnable whenDone);
|
void createPlotAndSettings(Plot plot, Runnable whenDone);
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@ -2168,7 +2169,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void getComments(final Plot plot, final String inbox,
|
@Override public void getComments(@Nonnull Plot plot, final String inbox,
|
||||||
final RunnableVal<List<PlotComment>> whenDone) {
|
final RunnableVal<List<PlotComment>> whenDone) {
|
||||||
addPlotTask(plot, new UniqueStatement("getComments_" + plot) {
|
addPlotTask(plot, new UniqueStatement("getComments_" + plot) {
|
||||||
@Override public void set(PreparedStatement statement) throws SQLException {
|
@Override public void set(PreparedStatement statement) throws SQLException {
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.flag;
|
package com.github.intellectualsites.plotsquared.plot.flag;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||||
@ -163,42 +160,37 @@ public final class Flags {
|
|||||||
public static void registerFlag(final Flag<?> flag) {
|
public static void registerFlag(final Flag<?> flag) {
|
||||||
final Flag<?> duplicate = flags.put(flag.getName(), flag);
|
final Flag<?> duplicate = flags.put(flag.getName(), flag);
|
||||||
if (duplicate != null) {
|
if (duplicate != null) {
|
||||||
PlotSquared.get().foreachPlotArea(new RunnableVal<PlotArea>() {
|
PlotSquared.get().forEachPlotArea(value -> {
|
||||||
@Override public void run(PlotArea value) {
|
if (value.DEFAULT_FLAGS.containsKey(duplicate)) {
|
||||||
Object remove;
|
Object remove = value.DEFAULT_FLAGS.remove(duplicate);
|
||||||
if (value.DEFAULT_FLAGS.containsKey(duplicate)) {
|
try {
|
||||||
remove = value.DEFAULT_FLAGS.remove(duplicate);
|
if (remove instanceof Collection
|
||||||
try {
|
&& remove.getClass().getMethod("toString").getDeclaringClass()
|
||||||
if (remove instanceof Collection
|
== Object.class) {
|
||||||
&& remove.getClass().getMethod("toString").getDeclaringClass()
|
value.DEFAULT_FLAGS.put(flag,
|
||||||
== Object.class) {
|
flag.parseValue(StringMan.join((Collection) remove, ',')));
|
||||||
value.DEFAULT_FLAGS.put(flag,
|
} else {
|
||||||
flag.parseValue(StringMan.join((Collection) remove, ',')));
|
value.DEFAULT_FLAGS.put(flag, flag.parseValue("" + remove));
|
||||||
} else {
|
|
||||||
value.DEFAULT_FLAGS.put(flag, flag.parseValue("" + remove));
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException neverHappens) {
|
|
||||||
neverHappens.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
} catch (NoSuchMethodException neverHappens) {
|
||||||
|
neverHappens.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
PlotSquared.get().foreachPlotRaw(new RunnableVal<Plot>() {
|
PlotSquared.get().forEachPlotRaw(value -> {
|
||||||
@Override public void run(Plot value) {
|
if (value.getFlags().containsKey(duplicate)) {
|
||||||
if (value.getFlags().containsKey(duplicate)) {
|
Object remove = value.getFlags().remove(duplicate);
|
||||||
Object remove = value.getFlags().remove(duplicate);
|
try {
|
||||||
try {
|
if (remove instanceof Collection
|
||||||
if (remove instanceof Collection
|
&& remove.getClass().getMethod("toString").getDeclaringClass()
|
||||||
&& remove.getClass().getMethod("toString").getDeclaringClass()
|
== Object.class) {
|
||||||
== Object.class) {
|
value.getFlags().put(flag,
|
||||||
value.getFlags().put(flag,
|
flag.parseValue(StringMan.join((Collection) remove, ',')));
|
||||||
flag.parseValue(StringMan.join((Collection) remove, ',')));
|
} else {
|
||||||
} else {
|
value.getFlags().put(flag, flag.parseValue("" + remove));
|
||||||
value.getFlags().put(flag, flag.parseValue("" + remove));
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException neverHappens) {
|
|
||||||
neverHappens.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
} catch (NoSuchMethodException neverHappens) {
|
||||||
|
neverHappens.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -6,6 +6,7 @@ import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
|
import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ConsolePlayer extends PlotPlayer {
|
public class ConsolePlayer extends PlotPlayer {
|
||||||
@ -45,7 +46,7 @@ public class ConsolePlayer extends PlotPlayer {
|
|||||||
return getLocation();
|
return getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public UUID getUUID() {
|
@Nonnull @Override public UUID getUUID() {
|
||||||
return DBFunc.EVERYONE;
|
return DBFunc.EVERYONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.object;
|
||||||
|
|
||||||
|
public enum Direction {
|
||||||
|
NORTH(0, "north"), EAST(1, "east"), SOUTH(2, "south"), WEST(3, "west"), NORTHEAST(4,
|
||||||
|
"northeast"), SOUTHEAST(5, "southeast"), SOUTHWEST(6, "southwest"), NORTHWEST(7,
|
||||||
|
"northwest"),
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
private int index;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
Direction(int index, String name) {
|
||||||
|
|
||||||
|
this.index = index;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIndex() {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
@ -21,6 +21,7 @@ import com.google.common.collect.BiMap;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.awt.geom.Area;
|
import java.awt.geom.Area;
|
||||||
import java.awt.geom.PathIterator;
|
import java.awt.geom.PathIterator;
|
||||||
@ -32,6 +33,7 @@ import java.util.*;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The plot class<br>
|
* The plot class<br>
|
||||||
@ -307,7 +309,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the plot has an owner.
|
* Checks if the plot has an owner.
|
||||||
*
|
*
|
||||||
* @return false if there is no owner
|
* @return false if there is no owner
|
||||||
*/
|
*/
|
||||||
@ -316,12 +318,12 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a UUID is a plot owner (merged plots may have multiple owners)
|
* Checks if a UUID is a plot owner (merged plots may have multiple owners)
|
||||||
*
|
*
|
||||||
* @param uuid the player uuid
|
* @param uuid the player uuid
|
||||||
* @return if the provided uuid is the owner of the plot
|
* @return if the provided uuid is the owner of the plot
|
||||||
*/
|
*/
|
||||||
public boolean isOwner(UUID uuid) {
|
public boolean isOwner(@Nonnull UUID uuid) {
|
||||||
if (uuid.equals(this.owner)) {
|
if (uuid.equals(this.owner)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -338,6 +340,9 @@ public class Plot {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a immutable set of owner UUIDs for a plot (supports multi-owner mega-plots).
|
* Gets a immutable set of owner UUIDs for a plot (supports multi-owner mega-plots).
|
||||||
|
* <p>
|
||||||
|
* This method cannot be used to add or remove owners from a plot.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @return the plot owners
|
* @return the plot owners
|
||||||
*/
|
*/
|
||||||
@ -364,7 +369,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the player is either the owner or on the trusted/added list.
|
* Checks if the player is either the owner or on the trusted/added list.
|
||||||
*
|
*
|
||||||
* @param uuid uuid to check
|
* @param uuid uuid to check
|
||||||
* @return true if the player is added/trusted or is the owner
|
* @return true if the player is added/trusted or is the owner
|
||||||
@ -389,7 +394,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should the player be denied from entering.
|
* Checks if the player is not permitted on this plot.
|
||||||
*
|
*
|
||||||
* @param uuid uuid to check
|
* @param uuid uuid to check
|
||||||
* @return boolean false if the player is allowed to enter
|
* @return boolean false if the player is allowed to enter
|
||||||
@ -419,9 +424,11 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign this plot to a plot area.<br>
|
* Assigns this plot to a plot area.<br>
|
||||||
* (Mostly used during startup when worlds are being created)<br>
|
* (Mostly used during startup when worlds are being created)<br>
|
||||||
* Note: Using this when it doesn't make sense will result in strange behavior
|
* <p>
|
||||||
|
* Do not use this unless you absolutely know what you are doing.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param area area to assign to
|
* @param area area to assign to
|
||||||
*/
|
*/
|
||||||
@ -504,13 +511,12 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the plot is merged in any direction.
|
* Checks if this plot is merged in any direction.
|
||||||
*
|
*
|
||||||
* @return is the plot merged or not
|
* @return true if this plot is merged, otherwise false
|
||||||
*/
|
*/
|
||||||
public boolean isMerged() {
|
public boolean isMerged() {
|
||||||
return getSettings().getMerged(0) || getSettings().getMerged(2) || getSettings()
|
return IntStream.of(0, 2, 1, 3).anyMatch(i -> getSettings().getMerged(i));
|
||||||
.getMerged(1) || getSettings().getMerged(3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -540,23 +546,24 @@ public class Plot {
|
|||||||
* 6 = south-west<br>
|
* 6 = south-west<br>
|
||||||
* 7 = north-west<br>
|
* 7 = north-west<br>
|
||||||
* ----------<br>
|
* ----------<br>
|
||||||
|
* //todo these artificial values are way too confusing.
|
||||||
* Note: A plot that is merged north and east will not be merged northeast if the northeast plot is not part of the same group<br>
|
* Note: A plot that is merged north and east will not be merged northeast if the northeast plot is not part of the same group<br>
|
||||||
*
|
*
|
||||||
* @param direction direction to check for merged plot
|
* @param dir direction to check for merged plot
|
||||||
* @return true if merged in that direction
|
* @return true if merged in that direction
|
||||||
*/
|
*/
|
||||||
public boolean getMerged(int direction) {
|
public boolean getMerged(int dir) {
|
||||||
if (this.settings == null) {
|
if (this.settings == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch (direction) {
|
switch (dir) {
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
return this.getSettings().getMerged(direction);
|
return this.getSettings().getMerged(dir);
|
||||||
case 7:
|
case 7:
|
||||||
int i = direction - 4;
|
int i = dir - 4;
|
||||||
int i2 = 0;
|
int i2 = 0;
|
||||||
if (this.getSettings().getMerged(i2)) {
|
if (this.getSettings().getMerged(i2)) {
|
||||||
if (this.getSettings().getMerged(i)) {
|
if (this.getSettings().getMerged(i)) {
|
||||||
@ -571,8 +578,8 @@ public class Plot {
|
|||||||
case 4:
|
case 4:
|
||||||
case 5:
|
case 5:
|
||||||
case 6:
|
case 6:
|
||||||
i = direction - 4;
|
i = dir - 4;
|
||||||
i2 = direction - 3;
|
i2 = dir - 3;
|
||||||
return this.getSettings().getMerged(i2) && this.getSettings().getMerged(i)
|
return this.getSettings().getMerged(i2) && this.getSettings().getMerged(i)
|
||||||
&& this.area.getPlotAbs(this.id.getRelative(i)).getMerged(i2) && this.area
|
&& this.area.getPlotAbs(this.id.getRelative(i)).getMerged(i2) && this.area
|
||||||
.getPlotAbs(this.id.getRelative(i2)).getMerged(i);
|
.getPlotAbs(this.id.getRelative(i2)).getMerged(i);
|
||||||
@ -678,7 +685,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deny someone (updates database as well)
|
* Denies a player from this plot. (updates database as well)
|
||||||
*
|
*
|
||||||
* @param uuid the uuid of the player to deny.
|
* @param uuid the uuid of the player to deny.
|
||||||
*/
|
*/
|
||||||
@ -752,8 +759,9 @@ public class Plot {
|
|||||||
public boolean setOwner(UUID owner, PlotPlayer initiator) {
|
public boolean setOwner(UUID owner, PlotPlayer initiator) {
|
||||||
boolean result = EventUtil.manager
|
boolean result = EventUtil.manager
|
||||||
.callOwnerChange(initiator, this, owner, hasOwner() ? this.owner : null, hasOwner());
|
.callOwnerChange(initiator, this, owner, hasOwner() ? this.owner : null, hasOwner());
|
||||||
if (!result)
|
if (!result) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
if (!hasOwner()) {
|
if (!hasOwner()) {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
create();
|
create();
|
||||||
@ -947,15 +955,12 @@ public class Plot {
|
|||||||
*
|
*
|
||||||
* @param name name
|
* @param name name
|
||||||
*/
|
*/
|
||||||
public void setSign(final String name) {
|
public void setSign(@Nonnull String name) {
|
||||||
if (!isLoaded())
|
if (!isLoaded()) {
|
||||||
return;
|
|
||||||
if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
|
|
||||||
TaskManager.runTask(() -> Plot.this.setSign(name));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (name == null) {
|
if (!PlotSquared.get().isMainThread(Thread.currentThread())) {
|
||||||
PlotSquared.log("Attempted to add null name to sign at plot: " + getId());
|
TaskManager.runTask(() -> Plot.this.setSign(name));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlotManager manager = this.area.getPlotManager();
|
PlotManager manager = this.area.getPlotManager();
|
||||||
@ -1165,8 +1170,9 @@ public class Plot {
|
|||||||
Location bot = corners[1];
|
Location bot = corners[1];
|
||||||
Location loc = new Location(this.getWorldName(), MathMan.average(bot.getX(), top.getX()),
|
Location loc = new Location(this.getWorldName(), MathMan.average(bot.getX(), top.getX()),
|
||||||
MathMan.average(bot.getY(), top.getY()), MathMan.average(bot.getZ(), top.getZ()));
|
MathMan.average(bot.getY(), top.getY()), MathMan.average(bot.getZ(), top.getZ()));
|
||||||
if (!isLoaded())
|
if (!isLoaded()) {
|
||||||
return loc;
|
return loc;
|
||||||
|
}
|
||||||
int y =
|
int y =
|
||||||
isLoaded() ? WorldUtil.IMP.getHighestBlock(getWorldName(), loc.getX(), loc.getZ()) : 62;
|
isLoaded() ? WorldUtil.IMP.getHighestBlock(getWorldName(), loc.getX(), loc.getZ()) : 62;
|
||||||
if (area.ALLOW_SIGNS) {
|
if (area.ALLOW_SIGNS) {
|
||||||
@ -1201,8 +1207,9 @@ public class Plot {
|
|||||||
Location bot = this.getBottomAbs();
|
Location bot = this.getBottomAbs();
|
||||||
Location loc = new Location(bot.getWorld(), bot.getX() + home.x, bot.getY() + home.y,
|
Location loc = new Location(bot.getWorld(), bot.getX() + home.x, bot.getY() + home.y,
|
||||||
bot.getZ() + home.z, home.yaw, home.pitch);
|
bot.getZ() + home.z, home.yaw, home.pitch);
|
||||||
if (!isLoaded())
|
if (!isLoaded()) {
|
||||||
return loc;
|
return loc;
|
||||||
|
}
|
||||||
if (!WorldUtil.IMP.getBlock(loc).isAir()) {
|
if (!WorldUtil.IMP.getBlock(loc).isAir()) {
|
||||||
loc.setY(Math.max(
|
loc.setY(Math.max(
|
||||||
1 + WorldUtil.IMP.getHighestBlock(this.getWorldName(), loc.getX(), loc.getZ()),
|
1 + WorldUtil.IMP.getHighestBlock(this.getWorldName(), loc.getX(), loc.getZ()),
|
||||||
@ -1383,7 +1390,12 @@ public class Plot {
|
|||||||
this.setSign("unknown");
|
this.setSign("unknown");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.setSign(UUIDHandler.getName(this.owner));
|
String name = UUIDHandler.getName(this.owner);
|
||||||
|
if (name == null) {
|
||||||
|
this.setSign("unknown");
|
||||||
|
} else {
|
||||||
|
this.setSign(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1461,10 +1473,7 @@ public class Plot {
|
|||||||
* @param notify notify
|
* @param notify notify
|
||||||
* @return true if plot was created successfully
|
* @return true if plot was created successfully
|
||||||
*/
|
*/
|
||||||
public boolean create(final UUID uuid, final boolean notify) {
|
public boolean create(@Nonnull UUID uuid, final boolean notify) {
|
||||||
if (uuid == null) {
|
|
||||||
throw new IllegalArgumentException("UUID cannot be null");
|
|
||||||
}
|
|
||||||
this.owner = uuid;
|
this.owner = uuid;
|
||||||
Plot existing = this.area.getOwnedPlotAbs(this.id);
|
Plot existing = this.area.getOwnedPlotAbs(this.id);
|
||||||
if (existing != null) {
|
if (existing != null) {
|
||||||
@ -1514,10 +1523,9 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO Better documentation needed.
|
//TODO Better documentation needed.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the top location for the plot.
|
* Returns the top location for the plot.
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public Location getTopAbs() {
|
public Location getTopAbs() {
|
||||||
Location top = this.area.getPlotManager().getPlotTopLocAbs(this.area, this.id);
|
Location top = this.area.getPlotManager().getPlotTopLocAbs(this.area, this.id);
|
||||||
@ -1526,8 +1534,9 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO Better documentation needed.
|
//TODO Better documentation needed.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the bottom location for the plot.
|
* Returns the bottom location for the plot.
|
||||||
*/
|
*/
|
||||||
public Location getBottomAbs() {
|
public Location getBottomAbs() {
|
||||||
Location loc = this.area.getPlotManager().getPlotBottomLocAbs(this.area, this.id);
|
Location loc = this.area.getPlotManager().getPlotBottomLocAbs(this.area, this.id);
|
||||||
@ -1611,11 +1620,11 @@ public class Plot {
|
|||||||
if (!this.isMerged()) {
|
if (!this.isMerged()) {
|
||||||
return top;
|
return top;
|
||||||
}
|
}
|
||||||
if (this.getMerged(2)) {
|
if (this.getMerged(Direction.SOUTH.getIndex())) {
|
||||||
top.setZ(this.getRelative(2).getBottomAbs().getZ() - 1);
|
top.setZ(this.getRelative(Direction.SOUTH.getIndex()).getBottomAbs().getZ() - 1);
|
||||||
}
|
}
|
||||||
if (this.getMerged(1)) {
|
if (this.getMerged(Direction.EAST.getIndex())) {
|
||||||
top.setX(this.getRelative(1).getBottomAbs().getX() - 1);
|
top.setX(this.getRelative(Direction.SOUTH.getIndex()).getBottomAbs().getX() - 1);
|
||||||
}
|
}
|
||||||
return top;
|
return top;
|
||||||
}
|
}
|
||||||
@ -1632,11 +1641,11 @@ public class Plot {
|
|||||||
if (!this.isMerged()) {
|
if (!this.isMerged()) {
|
||||||
return bot;
|
return bot;
|
||||||
}
|
}
|
||||||
if (this.getMerged(0)) {
|
if (this.getMerged(Direction.NORTH.getIndex())) {
|
||||||
bot.setZ(this.getRelative(0).getTopAbs().getZ() + 1);
|
bot.setZ(this.getRelative(Direction.NORTH.getIndex()).getTopAbs().getZ() + 1);
|
||||||
}
|
}
|
||||||
if (this.getMerged(3)) {
|
if (this.getMerged(Direction.WEST.getIndex())) {
|
||||||
bot.setX(this.getRelative(3).getTopAbs().getX() + 1);
|
bot.setX(this.getRelative(Direction.WEST.getIndex()).getTopAbs().getX() + 1);
|
||||||
}
|
}
|
||||||
return bot;
|
return bot;
|
||||||
}
|
}
|
||||||
@ -1665,7 +1674,7 @@ public class Plot {
|
|||||||
if (this.area.TERRAIN == 3) {
|
if (this.area.TERRAIN == 3) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot other = this.getRelative(1);
|
Plot other = this.getRelative(Direction.EAST.getIndex());
|
||||||
Location bot = other.getBottomAbs();
|
Location bot = other.getBottomAbs();
|
||||||
Location top = this.getTopAbs();
|
Location top = this.getTopAbs();
|
||||||
Location pos1 = new Location(this.getWorldName(), top.getX(), 0, bot.getZ());
|
Location pos1 = new Location(this.getWorldName(), top.getX(), 0, bot.getZ());
|
||||||
@ -2616,7 +2625,6 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Do the plot entry tasks for each player in the plot<br>
|
* Do the plot entry tasks for each player in the plot<br>
|
||||||
* - Usually called when the plot state changes (unclaimed/claimed/flag change etc)
|
* - Usually called when the plot state changes (unclaimed/claimed/flag change etc)
|
||||||
*/
|
*/
|
||||||
|
@ -22,6 +22,7 @@ import javax.annotation.Nullable;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jesse Boyd, Alexander Söderberg
|
* @author Jesse Boyd, Alexander Söderberg
|
||||||
@ -516,11 +517,9 @@ public abstract class PlotArea {
|
|||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
final HashSet<Plot> myPlots = new HashSet<>();
|
final HashSet<Plot> myPlots = new HashSet<>();
|
||||||
foreachPlotAbs(new RunnableVal<Plot>() {
|
forEachPlotAbs(value -> {
|
||||||
@Override public void run(Plot value) {
|
if (uuid.equals(value.owner)) {
|
||||||
if (uuid.equals(value.owner)) {
|
myPlots.add(value);
|
||||||
myPlots.add(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return myPlots;
|
return myPlots;
|
||||||
@ -664,16 +663,16 @@ public abstract class PlotArea {
|
|||||||
return myPlots;
|
return myPlots;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void foreachPlotAbs(@Nonnull final RunnableVal<Plot> run) {
|
private void forEachPlotAbs(Consumer<Plot> run) {
|
||||||
for (final Entry<PlotId, Plot> entry : this.plots.entrySet()) {
|
for (final Entry<PlotId, Plot> entry : this.plots.entrySet()) {
|
||||||
run.run(entry.getValue());
|
run.accept(entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void foreachBasePlot(@Nonnull final RunnableVal<Plot> run) {
|
public void forEachBasePlot(Consumer<Plot> run) {
|
||||||
for (final Plot plot : getPlots()) {
|
for (final Plot plot : getPlots()) {
|
||||||
if (plot.isBasePlot()) {
|
if (plot.isBasePlot()) {
|
||||||
run.run(plot);
|
run.accept(plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import com.github.intellectualsites.plotsquared.plot.util.*;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@ -202,17 +203,15 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
}
|
}
|
||||||
final AtomicInteger count = new AtomicInteger(0);
|
final AtomicInteger count = new AtomicInteger(0);
|
||||||
final UUID uuid = getUUID();
|
final UUID uuid = getUUID();
|
||||||
PlotSquared.get().foreachPlotArea(new RunnableVal<PlotArea>() {
|
PlotSquared.get().forEachPlotArea(value -> {
|
||||||
@Override public void run(PlotArea value) {
|
if (!Settings.Done.COUNTS_TOWARDS_LIMIT) {
|
||||||
if (!Settings.Done.COUNTS_TOWARDS_LIMIT) {
|
for (Plot plot : value.getPlotsAbs(uuid)) {
|
||||||
for (Plot plot : value.getPlotsAbs(uuid)) {
|
if (!plot.hasFlag(Flags.DONE)) {
|
||||||
if (!plot.hasFlag(Flags.DONE)) {
|
count.incrementAndGet();
|
||||||
count.incrementAndGet();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
count.addAndGet(value.getPlotsAbs(uuid).size());
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
count.addAndGet(value.getPlotsAbs(uuid).size());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return count.get();
|
return count.get();
|
||||||
@ -223,12 +222,10 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
return getClusterCount(getLocation().getWorld());
|
return getClusterCount(getLocation().getWorld());
|
||||||
}
|
}
|
||||||
final AtomicInteger count = new AtomicInteger(0);
|
final AtomicInteger count = new AtomicInteger(0);
|
||||||
PlotSquared.get().foreachPlotArea(new RunnableVal<PlotArea>() {
|
PlotSquared.get().forEachPlotArea(value -> {
|
||||||
@Override public void run(PlotArea value) {
|
for (PlotCluster cluster : value.getClusters()) {
|
||||||
for (PlotCluster cluster : value.getClusters()) {
|
if (cluster.isOwner(getUUID())) {
|
||||||
if (cluster.isOwner(getUUID())) {
|
count.incrementAndGet();
|
||||||
count.incrementAndGet();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -330,7 +327,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
*
|
*
|
||||||
* @return UUID
|
* @return UUID
|
||||||
*/
|
*/
|
||||||
@Override public abstract UUID getUUID();
|
@Override @Nonnull public abstract UUID getUUID();
|
||||||
|
|
||||||
public boolean canTeleport(Location loc) {
|
public boolean canTeleport(Location loc) {
|
||||||
Location current = getLocationFull();
|
Location current = getLocationFull();
|
||||||
@ -519,11 +516,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
*/
|
*/
|
||||||
public int getPlayerClusterCount() {
|
public int getPlayerClusterCount() {
|
||||||
final AtomicInteger count = new AtomicInteger();
|
final AtomicInteger count = new AtomicInteger();
|
||||||
PlotSquared.get().foreachPlotArea(new RunnableVal<PlotArea>() {
|
PlotSquared.get().forEachPlotArea(value -> count.addAndGet(value.getClusters().size()));
|
||||||
@Override public void run(PlotArea value) {
|
|
||||||
count.addAndGet(value.getClusters().size());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return count.get();
|
return count.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,9 +5,7 @@ import java.util.Arrays;
|
|||||||
public class ArrayUtil {
|
public class ArrayUtil {
|
||||||
public static final <T> T[] concatAll(T[] first, T[]... rest) {
|
public static final <T> T[] concatAll(T[] first, T[]... rest) {
|
||||||
int totalLength = first.length;
|
int totalLength = first.length;
|
||||||
for (T[] array : rest) {
|
totalLength += Arrays.stream(rest).mapToInt(array -> array.length).sum();
|
||||||
totalLength += array.length;
|
|
||||||
}
|
|
||||||
T[] result = Arrays.copyOf(first, totalLength);
|
T[] result = Arrays.copyOf(first, totalLength);
|
||||||
int offset = first.length;
|
int offset = first.length;
|
||||||
for (T[] array : rest) {
|
for (T[] array : rest) {
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.util;
|
package com.github.intellectualsites.plotsquared.plot.util;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
import com.github.intellectualsites.plotsquared.plot.object.OfflinePlotPlayer;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.StringWrapper;
|
||||||
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
|
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
|
||||||
import com.google.common.collect.BiMap;
|
import com.google.common.collect.BiMap;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -52,14 +56,12 @@ public class UUIDHandler {
|
|||||||
|
|
||||||
public static HashSet<UUID> getAllUUIDS() {
|
public static HashSet<UUID> getAllUUIDS() {
|
||||||
final HashSet<UUID> uuids = new HashSet<>();
|
final HashSet<UUID> uuids = new HashSet<>();
|
||||||
PlotSquared.get().foreachPlotRaw(new RunnableVal<Plot>() {
|
PlotSquared.get().forEachPlotRaw(plot -> {
|
||||||
@Override public void run(Plot plot) {
|
if (plot.hasOwner()) {
|
||||||
if (plot.hasOwner()) {
|
uuids.add(plot.owner);
|
||||||
uuids.add(plot.owner);
|
uuids.addAll(plot.getTrusted());
|
||||||
uuids.addAll(plot.getTrusted());
|
uuids.addAll(plot.getMembers());
|
||||||
uuids.addAll(plot.getMembers());
|
uuids.addAll(plot.getDenied());
|
||||||
uuids.addAll(plot.getDenied());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return uuids;
|
return uuids;
|
||||||
@ -81,10 +83,7 @@ public class UUIDHandler {
|
|||||||
implementation.add(toAdd);
|
implementation.add(toAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UUID getUUID(PlotPlayer player) {
|
@Nonnull public static UUID getUUID(PlotPlayer player) {
|
||||||
if (implementation == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return implementation.getUUID(player);
|
return implementation.getUUID(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
|
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class AbstractDBTest implements AbstractDB {
|
public class AbstractDBTest implements AbstractDB {
|
||||||
@ -148,8 +149,8 @@ public class AbstractDBTest implements AbstractDB {
|
|||||||
@Override public void setComment(Plot plot, PlotComment comment) {
|
@Override public void setComment(Plot plot, PlotComment comment) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public void getComments(@Nonnull Plot plot, String inbox,
|
||||||
public void getComments(Plot plot, String inbox, RunnableVal<List<PlotComment>> whenDone) {
|
RunnableVal<List<PlotComment>> whenDone) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void createPlotAndSettings(Plot plot, Runnable whenDone) {
|
@Override public void createPlotAndSettings(Plot plot, Runnable whenDone) {
|
||||||
|
Loading…
Reference in New Issue
Block a user