Modifications to the generator code

This commit is contained in:
MattBDev
2019-05-17 16:21:03 -04:00
parent 595a68ecba
commit 4e3a927323
16 changed files with 57 additions and 112 deletions

View File

@ -8,6 +8,7 @@ import com.github.intellectualsites.plotsquared.plot.object.BlockRegistry;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.*;
import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.List;
@ -246,7 +247,7 @@ public interface IPlotMain extends ILogger {
*
* @return Default implementation generator
*/
IndependentPlotGenerator getDefaultGenerator();
@NotNull IndependentPlotGenerator getDefaultGenerator();
/**
* Gets the class that will manage player titles.

View File

@ -1333,8 +1333,8 @@ import java.util.zip.ZipInputStream;
}
String key = pair[0].toLowerCase();
String value = pair[1];
String base = "worlds." + world + ".";
try {
String base = "worlds." + world + ".";
switch (key) {
case "s":
case "size":

View File

@ -36,25 +36,25 @@ import java.util.UUID;
checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage());
final Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
checkTrue(!uuids.isEmpty(), Captions.INVALID_PLAYER, args[0]);
Iterator<UUID> iter = uuids.iterator();
Iterator<UUID> iterator = uuids.iterator();
int size = plot.getTrusted().size() + plot.getMembers().size();
while (iter.hasNext()) {
UUID uuid = iter.next();
while (iterator.hasNext()) {
UUID uuid = iterator.next();
if (uuid == DBFunc.EVERYONE && !(
Permissions.hasPermission(player, Captions.PERMISSION_TRUST_EVERYONE) || Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST))) {
MainUtil.sendMessage(player, Captions.INVALID_PLAYER, MainUtil.getName(uuid));
iter.remove();
iterator.remove();
continue;
}
if (plot.isOwner(uuid)) {
MainUtil.sendMessage(player, Captions.ALREADY_OWNER, MainUtil.getName(uuid));
iter.remove();
iterator.remove();
continue;
}
if (plot.getMembers().contains(uuid)) {
MainUtil.sendMessage(player, Captions.ALREADY_ADDED, MainUtil.getName(uuid));
iter.remove();
iterator.remove();
continue;
}
size += plot.getTrusted().contains(uuid) ? 0 : 1;

View File

@ -143,7 +143,6 @@ import java.util.Set;
return true;
}
default: // Start creation
final SetupObject object = new SetupObject();
String[] split = args[1].split(":");
String id;
if (split.length == 2) {
@ -151,6 +150,7 @@ import java.util.Set;
} else {
id = null;
}
final SetupObject object = new SetupObject();
object.world = split[0];
final HybridPlotWorld pa = new HybridPlotWorld(object.world, id,
PlotSquared.get().IMP.getDefaultGenerator(), null, null);

View File

@ -197,11 +197,9 @@ import java.util.Set;
}
};
} else {
regenTask = new Runnable() {
@Override public void run() {
Trim.TASK = false;
player.sendMessage("Trim done!");
}
regenTask = () -> {
Trim.TASK = false;
player.sendMessage("Trim done!");
};
}
ChunkManager.manager.deleteRegionFiles(world, viable, regenTask);

View File

@ -8,6 +8,7 @@ import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import java.lang.reflect.Field;
@ -32,7 +33,8 @@ import java.util.Locale;
// PlotBlock.get((short) 155, (byte) 0);
public boolean PLOT_BEDROCK = true;
public ClassicPlotWorld(String worldName, String id, IndependentPlotGenerator generator,
public ClassicPlotWorld(String worldName, String id,
@NotNull IndependentPlotGenerator generator,
PlotId min, PlotId max) {
super(worldName, id, generator, min, max);
}

View File

@ -2,12 +2,13 @@ package com.github.intellectualsites.plotsquared.plot.generator;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import org.jetbrains.annotations.NotNull;
public abstract class GridPlotWorld extends PlotArea {
public short SIZE;
public GridPlotWorld(String worldName, String id, IndependentPlotGenerator generator,
public GridPlotWorld(String worldName, String id, @NotNull IndependentPlotGenerator generator,
PlotId min, PlotId max) {
super(worldName, id, generator, min, max);
}

View File

@ -21,6 +21,7 @@ import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.world.block.BaseBlock;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.HashMap;
@ -37,7 +38,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
public int SCHEM_Y;
private Location SIGN_LOCATION;
public HybridPlotWorld(String worldName, String id, IndependentPlotGenerator generator,
public HybridPlotWorld(String worldName, String id, @NotNull IndependentPlotGenerator generator,
PlotId min, PlotId max) {
super(worldName, id, generator, min, max);
}
@ -119,8 +120,8 @@ public class HybridPlotWorld extends ClassicPlotWorld {
}
try {
setupSchematics();
} catch (Exception ignored) {
ignored.printStackTrace();
} catch (Exception event) {
event.printStackTrace();
PlotSquared.debug("&c - road schematics are disabled for this world.");
}
}

View File

@ -3,6 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.generator;
import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import org.jetbrains.annotations.NotNull;
public abstract class SquarePlotWorld extends GridPlotWorld {
@ -11,7 +12,7 @@ public abstract class SquarePlotWorld extends GridPlotWorld {
public int ROAD_OFFSET_X = 0;
public int ROAD_OFFSET_Z = 0;
public SquarePlotWorld(String worldName, String id, IndependentPlotGenerator generator,
public SquarePlotWorld(String worldName, String id, @NotNull IndependentPlotGenerator generator,
PlotId min, PlotId max) {
super(worldName, id, generator, min, max);
}

View File

@ -8,6 +8,7 @@ import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import org.jetbrains.annotations.NotNull;
import java.util.*;
import java.util.Map.Entry;
@ -135,7 +136,7 @@ import java.util.Map.Entry;
}
}
@Override public Iterator<PlotBlock> iterator() {
@NotNull @Override public Iterator<PlotBlock> iterator() {
return this.bucketIterator;
}

View File

@ -21,6 +21,7 @@ import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -76,11 +77,11 @@ public abstract class PlotArea {
private QuadMap<PlotCluster> clusters;
public PlotArea(@Nonnull final String worldName, @Nullable final String id,
@Nullable IndependentPlotGenerator generator, @Nullable final PlotId min,
@NotNull IndependentPlotGenerator generator, @Nullable final PlotId min,
@Nullable final PlotId max) {
this.worldname = worldName;
this.id = id;
this.manager = generator != null ? generator.getNewPlotManager() : null;
this.manager = generator.getNewPlotManager();
this.generator = generator;
if (min == null || max == null) {
if (min != max) {
@ -94,28 +95,13 @@ public abstract class PlotArea {
this.max = max;
}
this.worldhash = worldName.hashCode();
if (Settings.Enabled_Components.PLOT_EXPIRY && generator != null) {
if (Settings.Enabled_Components.PLOT_EXPIRY) {
blockBucketChunk = generator.generateBlockBucketChunk(this);
} else {
blockBucketChunk = null;
}
}
/**
* Create a new PlotArea object with no functionality/information.
* - Mainly used during startup before worlds are created as a temporary object
*/
public static PlotArea createGeneric(@Nonnull final String world) {
return new PlotArea(world, null, null, null, null) {
@Override public void loadConfiguration(ConfigurationSection config) {
}
@Override public ConfigurationNode[] getSettingNodes() {
return null;
}
};
}
public LocalBlockQueue getQueue(final boolean autoQueue) {
return GlobalBlockQueue.IMP.getNewQueue(worldname, autoQueue);
}

View File

@ -181,16 +181,16 @@ public abstract class BasicLocalBlockQueue<T> extends LocalBlockQueue {
}
public abstract class LocalChunk<T> {
public abstract class LocalChunk<B> {
public final BasicLocalBlockQueue parent;
public final int z;
public final int x;
public T[] blocks;
public B[] blocks;
public BaseBlock[][] baseblocks;
public String[][] biomes;
public LocalChunk(BasicLocalBlockQueue<T> parent, int x, int z) {
public LocalChunk(BasicLocalBlockQueue<B> parent, int x, int z) {
this.parent = parent;
this.x = x;
this.z = z;

View File

@ -1,7 +1,12 @@
package com.github.intellectualsites.plotsquared.plot.util.block;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.*;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
import com.sk89q.worldedit.world.block.BaseBlock;
public class ScopedLocalBlockQueue extends DelegateLocalBlockQueue {