Minor message changes and variable changes

This commit is contained in:
MattBDev 2019-05-17 14:38:57 -04:00
parent 427504fd7c
commit 6f5cb30734
8 changed files with 50 additions and 53 deletions

View file

@ -40,8 +40,6 @@ import com.github.intellectualsites.plotsquared.plot.util.*;
import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider;
import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.extension.platform.Capability;
import lombok.Getter;
import lombok.NonNull;
import org.bukkit.*;
@ -54,7 +52,6 @@ import org.bukkit.generator.ChunkGenerator;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import javax.annotation.Nullable;
@ -114,22 +111,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
return Bukkit.getVersion();
}
private void init() {
try {
PluginManager manager = Bukkit.getPluginManager();
System.out.println("[P2] Force loading WorldEdit");
Plugin plugin = manager.getPlugin("WorldEdit");
if (!manager.isPluginEnabled("WorldEdit")) {
manager.enablePlugin(WorldEditPlugin.getPlugin(WorldEditPlugin.class));
}
System.out.println("[P2] Testing platform capabilities");
WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS);
} catch (final Throwable throwable) {
throw new IllegalStateException(
"Failed to force load WorldEdit. Road schematics will fail to generate", throwable);
}
}
@Override public void onEnable() {
this.pluginName = getDescription().getName();
PlotPlayer.registerConverter(Player.class, BukkitUtil::getPlayer);
@ -146,7 +127,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
System.out.println("[P2] DOWNLOAD: https://papermc.io/downloads");
System.out.println("[P2] GUIDE: https://www.spigotmc.org/threads/21726/");
System.out.println("[P2] NOTE: This is only a recommendation");
System.out.println("[P2] both Spigot and CraftBukkit are still supported.");
System.out.println("[P2] Spigot is still supported.");
System.out
.println("[P2] ===============================================================");
}
@ -158,6 +139,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
"You can't use this version of PlotSquared on a server less than Minecraft 1.13.2.");
System.out
.println("Please check the download page for the link to the legacy versions.");
System.out.println("The server will now be shutdown to prevent any corruption.");
Bukkit.shutdown();
return;
}

View file

@ -4,6 +4,7 @@ import com.github.intellectualsites.plotsquared.plot.generator.AugmentedUtils;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import org.jetbrains.annotations.NotNull;
import java.util.Random;
@ -24,7 +25,8 @@ public class BukkitAugmentedGenerator extends BlockPopulator {
return generator;
}
@Override public void populate(World world, Random random, Chunk source) {
@Override
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk source) {
AugmentedUtils.generate(world.getName(), source.getX(), source.getZ(), null);
}
}

View file

@ -123,19 +123,19 @@ public class BukkitPlotGenerator extends ChunkGenerator
GenChunk result = new GenChunk();
if (this.getPlotGenerator() instanceof SingleWorldGenerator) {
if (result.getCd() != null) {
if (result.getChunkData() != null) {
for (int cx = 0; cx < 16; cx++) {
for (int cz = 0; cz < 16; cz++) {
biome.setBiome(cx, cz, Biome.PLAINS);
}
}
return result.getCd();
return result.getChunkData();
}
}
// Set the chunk location
result.setChunk(new ChunkWrapper(world.getName(), x, z));
// Set the result data
result.setCd(createChunkData(world));
result.setChunkData(createChunkData(world));
result.biomeGrid = biome;
result.result = null;
@ -151,7 +151,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
e.printStackTrace();
}
// Return the result data
return result.getCd();
return result.getChunkData();
}
private void generate(ChunkLoc loc, World world, ScopedLocalBlockQueue result) {

View file

@ -4,7 +4,12 @@ import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotWorld;
import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator;
import com.github.intellectualsites.plotsquared.plot.object.*;
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
import lombok.RequiredArgsConstructor;
@ -61,27 +66,27 @@ import java.util.Random;
}
@Override public void generateChunk(final ScopedLocalBlockQueue result, PlotArea settings) {
World w = BukkitUtil.getWorld(world);
World world = BukkitUtil.getWorld(this.world);
Location min = result.getMin();
int cx = min.getX() >> 4;
int cz = min.getZ() >> 4;
Random r = new Random(MathMan.pair((short) cx, (short) cz));
ChunkGenerator.BiomeGrid grid = new ChunkGenerator.BiomeGrid() {
@Override public void setBiome(int x, int z, Biome biome) {
result.setBiome(x, z, biome.name());
}
@Override @NotNull public Biome getBiome(int x, int z) {
return Biome.FOREST;
}
};
int chunkX = min.getX() >> 4;
int chunkZ = min.getZ() >> 4;
Random random = new Random(MathMan.pair((short) chunkX, (short) chunkZ));
try {
chunkGenerator.generateChunkData(w, r, cx, cz, grid);
ChunkGenerator.BiomeGrid grid = new ChunkGenerator.BiomeGrid() {
@Override public void setBiome(int x, int z, Biome biome) {
result.setBiome(x, z, biome.name());
}
@Override @NotNull public Biome getBiome(int x, int z) {
return Biome.FOREST;
}
};
chunkGenerator.generateChunkData(world, random, chunkX, chunkZ, grid);
return;
} catch (Throwable ignored) {
}
for (BlockPopulator populator : chunkGenerator.getDefaultPopulators(w)) {
populator.populate(w, r, w.getChunkAt(cx, cz));
for (BlockPopulator populator : chunkGenerator.getDefaultPopulators(world)) {
populator.populate(world, random, world.getChunkAt(chunkX, chunkZ));
}
}

View file

@ -11,6 +11,7 @@ import lombok.RequiredArgsConstructor;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import org.jetbrains.annotations.NotNull;
import java.util.Random;
@ -19,7 +20,8 @@ import java.util.Random;
private final IndependentPlotGenerator plotGenerator;
private LocalBlockQueue queue;
@Override public void populate(final World world, final Random random, final Chunk source) {
@Override public void populate(@NotNull final World world, @NotNull final Random random,
@NotNull final Chunk source) {
if (this.queue == null) {
this.queue = GlobalBlockQueue.IMP.getNewQueue(world.getName(), false);
}

View file

@ -28,7 +28,7 @@ public class GenChunk extends ScopedLocalBlockQueue {
public String world;
public int chunkX;
public int chunkZ;
@Getter @Setter private ChunkData cd = null;
@Getter @Setter private ChunkData chunkData = null;
public GenChunk() {
super(null, new Location(null, 0, 0, 0), new Location(null, 15, 255, 15));
@ -88,7 +88,8 @@ public class GenChunk extends ScopedLocalBlockQueue {
int maxX = Math.max(pos1.getX(), pos2.getX());
int maxY = Math.max(pos1.getY(), pos2.getY());
int maxZ = Math.max(pos1.getZ(), pos2.getZ());
cd.setRegion(minX, minY, minZ, maxX + 1, maxY + 1, maxZ + 1, block.to(Material.class));
chunkData
.setRegion(minX, minY, minZ, maxX + 1, maxY + 1, maxZ + 1, block.to(Material.class));
}
@Override public boolean setBiome(int x, int z, String biome) {
@ -105,10 +106,10 @@ public class GenChunk extends ScopedLocalBlockQueue {
@Override public boolean setBlock(int x, int y, int z, PlotBlock id) {
if (this.result == null) {
this.cd.setBlock(x, y, z, id.to(Material.class));
this.chunkData.setBlock(x, y, z, id.to(Material.class));
return true;
}
this.cd.setBlock(x, y, z, id.to(Material.class));
this.chunkData.setBlock(x, y, z, id.to(Material.class));
this.storeCache(x, y, z, id);
return true;
}
@ -125,10 +126,10 @@ public class GenChunk extends ScopedLocalBlockQueue {
@Override public boolean setBlock(int x, int y, int z, BaseBlock id) {
if (this.result == null) {
this.cd.setBlock(x, y, z, BukkitAdapter.adapt(id));
this.chunkData.setBlock(x, y, z, BukkitAdapter.adapt(id));
return true;
}
this.cd.setBlock(x, y, z, BukkitAdapter.adapt(id));
this.chunkData.setBlock(x, y, z, BukkitAdapter.adapt(id));
this.storeCache(x, y, z, PlotBlock.get(id.getBlockType().getId()));
return true;
}
@ -136,7 +137,7 @@ public class GenChunk extends ScopedLocalBlockQueue {
@Override public PlotBlock getBlock(int x, int y, int z) {
int i = MainUtil.CACHE_I[y][x][z];
if (result == null) {
return PlotBlock.get(cd.getType(x, y, z));
return PlotBlock.get(chunkData.getType(x, y, z));
}
PlotBlock[] array = result[i];
if (array == null) {
@ -177,7 +178,7 @@ public class GenChunk extends ScopedLocalBlockQueue {
}
}
}
toReturn.cd = this.cd;
toReturn.chunkData = this.chunkData;
return toReturn;
}
}

View file

@ -11,6 +11,7 @@ import com.github.intellectualsites.plotsquared.plot.util.block.DelegateLocalBlo
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.ScopedLocalBlockQueue;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
@ -24,7 +25,7 @@ public class AugmentedUtils {
enabled = true;
}
public static boolean generate(final String world, final int cx, final int cz,
public static boolean generate(@NotNull final String world, final int cx, final int cz,
LocalBlockQueue queue) {
if (!enabled) {
return false;

View file

@ -139,7 +139,11 @@ public class DefaultPlotAreaManager implements PlotAreaManager {
return null;
case 1:
PlotArea pa = this.plotAreas[0];
return pa.contains(location) ? pa : null;
if (pa.contains(location)) {
return pa;
} else {
return null;
}
case 2:
case 3:
case 4: