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