mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-09-03 00:20:38 +02:00
Formatting fixes and minor performance improvement
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
This commit is contained in:
parent
1d327ec346
commit
ed3cadd439
|
@ -111,7 +111,7 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
|
||||||
}
|
}
|
||||||
Object c = this.methodGetHandleChunk.of(chunk).call();
|
Object c = this.methodGetHandleChunk.of(chunk).call();
|
||||||
RefField.RefExecutor field = this.mustSave.of(c);
|
RefField.RefExecutor field = this.mustSave.of(c);
|
||||||
if ((Boolean) field.get() == true) {
|
if ((Boolean) field.get()) {
|
||||||
field.set(false);
|
field.set(false);
|
||||||
if (chunk.isLoaded()) {
|
if (chunk.isLoaded()) {
|
||||||
ignoreUnload = true;
|
ignoreUnload = true;
|
||||||
|
@ -122,9 +122,9 @@ import static com.github.intellectualsites.plotsquared.plot.util.ReflectionUtils
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldSave(String world, int X, int Z) {
|
public boolean shouldSave(String world, int chunkX, int chunkZ) {
|
||||||
int x = X << 4;
|
int x = chunkX << 4;
|
||||||
int z = Z << 4;
|
int z = chunkZ << 4;
|
||||||
int x2 = x + 15;
|
int x2 = x + 15;
|
||||||
int z2 = z + 15;
|
int z2 = z + 15;
|
||||||
Plot plot = new Location(world, x, 1, z).getOwnedPlotAbs();
|
Plot plot = new Location(world, x, 1, z).getOwnedPlotAbs();
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class EntitySpawnListener implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void vehicleMove(VehicleMoveEvent event) throws IllegalAccessException {
|
public void vehicleMove(VehicleMoveEvent event) {
|
||||||
test(event.getVehicle());
|
test(event.getVehicle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,26 +21,26 @@ public class Auto extends SubCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean checkAllowedPlots(PlotPlayer player, PlotArea plotarea,
|
private static boolean checkAllowedPlots(PlotPlayer player, PlotArea plotarea,
|
||||||
@Nullable Integer allowed_plots, int size_x, int size_z) {
|
@Nullable Integer allowedPlots, int sizeX, int sizeZ) {
|
||||||
if (allowed_plots == null) {
|
if (allowedPlots == null) {
|
||||||
allowed_plots = player.getAllowedPlots();
|
allowedPlots = player.getAllowedPlots();
|
||||||
}
|
}
|
||||||
int currentPlots =
|
int currentPlots =
|
||||||
Settings.Limit.GLOBAL ? player.getPlotCount() : player.getPlotCount(plotarea.worldname);
|
Settings.Limit.GLOBAL ? player.getPlotCount() : player.getPlotCount(plotarea.worldname);
|
||||||
int diff = currentPlots - allowed_plots;
|
int diff = currentPlots - allowedPlots;
|
||||||
if (diff + size_x * size_z > 0) {
|
if (diff + sizeX * sizeZ > 0) {
|
||||||
if (diff < 0) {
|
if (diff < 0) {
|
||||||
MainUtil.sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS_NUM, -diff + "");
|
MainUtil.sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS_NUM, -diff + "");
|
||||||
return false;
|
return false;
|
||||||
} else if (player.hasPersistentMeta("grantedPlots")) {
|
} else if (player.hasPersistentMeta("grantedPlots")) {
|
||||||
int grantedPlots =
|
int grantedPlots =
|
||||||
ByteArrayUtilities.bytesToInteger(player.getPersistentMeta("grantedPlots"));
|
ByteArrayUtilities.bytesToInteger(player.getPersistentMeta("grantedPlots"));
|
||||||
if (grantedPlots - diff < size_x * size_z) {
|
if (grantedPlots - diff < sizeX * sizeZ) {
|
||||||
player.removePersistentMeta("grantedPlots");
|
player.removePersistentMeta("grantedPlots");
|
||||||
MainUtil.sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS);
|
MainUtil.sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
int left = grantedPlots - diff - size_x * size_z;
|
int left = grantedPlots - diff - sizeX * sizeZ;
|
||||||
if (left == 0) {
|
if (left == 0) {
|
||||||
player.removePersistentMeta("grantedPlots");
|
player.removePersistentMeta("grantedPlots");
|
||||||
} else {
|
} else {
|
||||||
|
@ -98,7 +98,7 @@ public class Auto extends SubCommand {
|
||||||
* @param schem
|
* @param schem
|
||||||
*/
|
*/
|
||||||
public static void autoClaimSafe(final PlotPlayer player, final PlotArea area, PlotId start,
|
public static void autoClaimSafe(final PlotPlayer player, final PlotArea area, PlotId start,
|
||||||
final String schem, @Nullable final Integer allowed_plots) {
|
final String schem, @Nullable final Integer allowedPlots) {
|
||||||
player.setMeta(Auto.class.getName(), true);
|
player.setMeta(Auto.class.getName(), true);
|
||||||
autoClaimFromDatabase(player, area, start, new RunnableVal<Plot>() {
|
autoClaimFromDatabase(player, area, start, new RunnableVal<Plot>() {
|
||||||
@Override public void run(final Plot plot) {
|
@Override public void run(final Plot plot) {
|
||||||
|
@ -107,7 +107,7 @@ public class Auto extends SubCommand {
|
||||||
player.deleteMeta(Auto.class.getName());
|
player.deleteMeta(Auto.class.getName());
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
MainUtil.sendMessage(player, Captions.NO_FREE_PLOTS);
|
MainUtil.sendMessage(player, Captions.NO_FREE_PLOTS);
|
||||||
} else if (checkAllowedPlots(player, area, allowed_plots, 1, 1)) {
|
} else if (checkAllowedPlots(player, area, allowedPlots, 1, 1)) {
|
||||||
plot.claim(player, true, schem, false);
|
plot.claim(player, true, schem, false);
|
||||||
if (area.AUTO_MERGE) {
|
if (area.AUTO_MERGE) {
|
||||||
plot.autoMerge(-1, Integer.MAX_VALUE, player.getUUID(), true);
|
plot.autoMerge(-1, Integer.MAX_VALUE, player.getUUID(), true);
|
||||||
|
|
|
@ -9,12 +9,12 @@ 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.block.GlobalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
public class HybridPlotManager extends ClassicPlotManager {
|
public class HybridPlotManager extends ClassicPlotManager {
|
||||||
|
@ -22,9 +22,8 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||||
public static boolean REGENERATIVE_CLEAR = true;
|
public static boolean REGENERATIVE_CLEAR = true;
|
||||||
|
|
||||||
@Override public void exportTemplate(PlotArea plotArea) throws IOException {
|
@Override public void exportTemplate(PlotArea plotArea) throws IOException {
|
||||||
HashSet<FileBytes> files = new HashSet<>(Collections.singletonList(
|
HashSet<FileBytes> files = Sets.newHashSet(
|
||||||
new FileBytes(Settings.Paths.TEMPLATES + "/tmp-data.yml",
|
new FileBytes(Settings.Paths.TEMPLATES + "/tmp-data.yml", Template.getBytes(plotArea)));
|
||||||
Template.getBytes(plotArea))));
|
|
||||||
String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator
|
String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator
|
||||||
+ plotArea.worldname + File.separator;
|
+ plotArea.worldname + File.separator;
|
||||||
String newDir =
|
String newDir =
|
||||||
|
|
|
@ -19,6 +19,7 @@ import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis;
|
import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis;
|
||||||
import com.google.common.collect.BiMap;
|
import com.google.common.collect.BiMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
@ -607,8 +608,17 @@ public class Plot {
|
||||||
*/
|
*/
|
||||||
public void setDenied(Set<UUID> uuids) {
|
public void setDenied(Set<UUID> uuids) {
|
||||||
boolean larger = uuids.size() > getDenied().size();
|
boolean larger = uuids.size() > getDenied().size();
|
||||||
HashSet<UUID> intersection = new HashSet<>(larger ? getDenied() : uuids);
|
HashSet<UUID> intersection;
|
||||||
intersection.retainAll(larger ? uuids : getDenied());
|
if (larger) {
|
||||||
|
intersection = new HashSet<>(getDenied());
|
||||||
|
} else {
|
||||||
|
intersection = new HashSet<>(uuids);
|
||||||
|
}
|
||||||
|
if (larger) {
|
||||||
|
intersection.retainAll(uuids);
|
||||||
|
} else {
|
||||||
|
intersection.retainAll(getDenied());
|
||||||
|
}
|
||||||
uuids.removeAll(intersection);
|
uuids.removeAll(intersection);
|
||||||
HashSet<UUID> toRemove = new HashSet<>(getDenied());
|
HashSet<UUID> toRemove = new HashSet<>(getDenied());
|
||||||
toRemove.removeAll(intersection);
|
toRemove.removeAll(intersection);
|
||||||
|
@ -2500,16 +2510,15 @@ public class Plot {
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public HashSet<RegionWrapper> getRegions() {
|
@Nonnull public HashSet<RegionWrapper> getRegions() {
|
||||||
if (regions_cache != null && connected_cache != null && connected_cache.contains(this)) {
|
if (regions_cache != null && connected_cache != null && connected_cache.contains(this)) {
|
||||||
return regions_cache;
|
return regions_cache;
|
||||||
}
|
}
|
||||||
if (!this.isMerged()) {
|
if (!this.isMerged()) {
|
||||||
Location pos1 = this.getBottomAbs();
|
Location pos1 = this.getBottomAbs();
|
||||||
Location pos2 = this.getTopAbs();
|
Location pos2 = this.getTopAbs();
|
||||||
connected_cache = new HashSet<>(Collections.singletonList(this));
|
connected_cache = Sets.newHashSet(this);
|
||||||
regions_cache = new HashSet<>(1);
|
regions_cache = Sets.newHashSet(
|
||||||
regions_cache.add(
|
|
||||||
new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getY(), pos2.getY(), pos1.getZ(),
|
new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getY(), pos2.getY(), pos1.getZ(),
|
||||||
pos2.getZ()));
|
pos2.getZ()));
|
||||||
return regions_cache;
|
return regions_cache;
|
||||||
|
|
|
@ -3,19 +3,17 @@ package com.github.intellectualsites.plotsquared.plot.object.worlds;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class SinglePlot extends Plot {
|
public class SinglePlot extends Plot {
|
||||||
private HashSet<RegionWrapper> regions;
|
private HashSet<RegionWrapper> regions = Sets.newHashSet(
|
||||||
|
new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE,
|
||||||
{
|
|
||||||
regions = new HashSet<>();
|
|
||||||
regions.add(new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE,
|
|
||||||
Integer.MAX_VALUE));
|
Integer.MAX_VALUE));
|
||||||
}
|
|
||||||
|
|
||||||
public SinglePlot(PlotArea area, PlotId id, UUID owner) {
|
public SinglePlot(PlotArea area, PlotId id, UUID owner) {
|
||||||
super(area, id, owner);
|
super(area, id, owner);
|
||||||
|
@ -62,7 +60,7 @@ public class SinglePlot extends Plot {
|
||||||
return super.isLoaded();
|
return super.isLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public HashSet<RegionWrapper> getRegions() {
|
@Nonnull @Override public HashSet<RegionWrapper> getRegions() {
|
||||||
return regions;
|
return regions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user