mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
New API method, more 1.13 entity support, and cleanup.
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
This commit is contained in:
parent
4f27abb4a0
commit
a64d764cc1
@ -30,6 +30,7 @@ import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
|||||||
import com.sk89q.worldedit.extension.platform.Capability;
|
import com.sk89q.worldedit.extension.platform.Capability;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
@ -287,9 +288,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
|
|
||||||
@Override @SuppressWarnings("deprecation") public void runEntityTask() {
|
@Override @SuppressWarnings("deprecation") public void runEntityTask() {
|
||||||
PlotSquared.log(C.PREFIX + "KillAllEntities started.");
|
PlotSquared.log(C.PREFIX + "KillAllEntities started.");
|
||||||
TaskManager
|
TaskManager.runTaskRepeat(() -> PlotSquared.get().forEachPlotArea(plotArea -> {
|
||||||
.runTaskRepeat(() -> PlotSquared.get().foreachPlotArea(new RunnableVal<PlotArea>() {
|
|
||||||
@Override public void run(PlotArea plotArea) {
|
|
||||||
final World world = Bukkit.getWorld(plotArea.worldname);
|
final World world = Bukkit.getWorld(plotArea.worldname);
|
||||||
try {
|
try {
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
@ -376,8 +375,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
case DRAGON_FIREBALL:
|
case DRAGON_FIREBALL:
|
||||||
case DROPPED_ITEM:
|
case DROPPED_ITEM:
|
||||||
if (Settings.Enabled_Components.KILL_ROAD_ITEMS && plotArea
|
if (Settings.Enabled_Components.KILL_ROAD_ITEMS && plotArea
|
||||||
.getOwnedPlotAbs(
|
.getOwnedPlotAbs(BukkitUtil.getLocation(entity.getLocation()))
|
||||||
BukkitUtil.getLocation(entity.getLocation())) == null) {
|
== null) {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
}
|
}
|
||||||
// dropped item
|
// dropped item
|
||||||
@ -391,21 +390,21 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
LivingEntity livingEntity = (LivingEntity) entity;
|
LivingEntity livingEntity = (LivingEntity) entity;
|
||||||
List<MetadataValue> meta = entity.getMetadata("plot");
|
List<MetadataValue> meta = entity.getMetadata("plot");
|
||||||
if (meta != null && !meta.isEmpty()) {
|
if (meta != null && !meta.isEmpty()) {
|
||||||
if (livingEntity.isLeashed())
|
if (livingEntity.isLeashed()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
List<MetadataValue> keep = entity.getMetadata("keep");
|
List<MetadataValue> keep = entity.getMetadata("keep");
|
||||||
if (keep != null && !keep.isEmpty())
|
if (keep != null && !keep.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
PlotId originalPlotId = (PlotId) meta.get(0).value();
|
PlotId originalPlotId = (PlotId) meta.get(0).value();
|
||||||
if (originalPlotId != null) {
|
if (originalPlotId != null) {
|
||||||
com.github.intellectualsites.plotsquared.plot.object.Location
|
com.github.intellectualsites.plotsquared.plot.object.Location
|
||||||
pLoc =
|
pLoc = BukkitUtil.getLocation(entity.getLocation());
|
||||||
BukkitUtil.getLocation(entity.getLocation());
|
|
||||||
PlotArea area = pLoc.getPlotArea();
|
PlotArea area = pLoc.getPlotArea();
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
PlotId currentPlotId =
|
PlotId currentPlotId = PlotId.of(area.getPlotAbs(pLoc));
|
||||||
PlotId.of(area.getPlotAbs(pLoc));
|
|
||||||
if (!originalPlotId.equals(currentPlotId) && (
|
if (!originalPlotId.equals(currentPlotId) && (
|
||||||
currentPlotId == null || !area
|
currentPlotId == null || !area
|
||||||
.getPlot(originalPlotId)
|
.getPlot(originalPlotId)
|
||||||
@ -424,13 +423,10 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
pLoc = BukkitUtil.getLocation(entity.getLocation());
|
pLoc = BukkitUtil.getLocation(entity.getLocation());
|
||||||
PlotArea area = pLoc.getPlotArea();
|
PlotArea area = pLoc.getPlotArea();
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
PlotId currentPlotId =
|
PlotId currentPlotId = PlotId.of(area.getPlotAbs(pLoc));
|
||||||
PlotId.of(area.getPlotAbs(pLoc));
|
|
||||||
if (currentPlotId != null) {
|
if (currentPlotId != null) {
|
||||||
entity.setMetadata("plot",
|
entity.setMetadata("plot", new FixedMetadataValue(
|
||||||
new FixedMetadataValue(
|
(Plugin) PlotSquared.get().IMP, currentPlotId));
|
||||||
(Plugin) PlotSquared.get().IMP,
|
|
||||||
currentPlotId));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -483,6 +479,16 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
case WITHER:
|
case WITHER:
|
||||||
case WOLF:
|
case WOLF:
|
||||||
case ZOMBIE:
|
case ZOMBIE:
|
||||||
|
case PARROT:
|
||||||
|
case SALMON:
|
||||||
|
case DOLPHIN:
|
||||||
|
case TROPICAL_FISH:
|
||||||
|
case DROWNED:
|
||||||
|
case COD:
|
||||||
|
case TURTLE:
|
||||||
|
case PUFFERFISH:
|
||||||
|
case PHANTOM:
|
||||||
|
case ILLUSIONER:
|
||||||
default: {
|
default: {
|
||||||
if (Settings.Enabled_Components.KILL_ROAD_MOBS) {
|
if (Settings.Enabled_Components.KILL_ROAD_MOBS) {
|
||||||
Location location = entity.getLocation();
|
Location location = entity.getLocation();
|
||||||
@ -523,7 +529,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}), 20);
|
}), 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -701,7 +706,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
}
|
}
|
||||||
System.setProperty("bstats.relocatecheck",
|
System.setProperty("bstats.relocatecheck",
|
||||||
"false"); // We do not want to relocate the package...
|
"false"); // We do not want to relocate the package...
|
||||||
new org.bstats.bukkit.Metrics(this); // bstats
|
Metrics metrics = new Metrics(this);// bstats
|
||||||
PlotSquared.log(C.PREFIX + "&6Metrics enabled.");
|
PlotSquared.log(C.PREFIX + "&6Metrics enabled.");
|
||||||
this.metricsStarted = true;
|
this.metricsStarted = true;
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
|||||||
result.setBiome(x, z, biome.name());
|
result.setBiome(x, z, biome.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Biome getBiome(int arg0, int arg1) {
|
@Override public Biome getBiome(int x, int z) {
|
||||||
return Biome.FOREST;
|
return Biome.FOREST;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -142,7 +142,7 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
|||||||
}
|
}
|
||||||
/* TODO: Redo this
|
/* TODO: Redo this
|
||||||
// Populator spillage
|
// Populator spillage
|
||||||
short[][] tmp = cg.generateExtBlockSections(w, r, cx, cz, grid);
|
short[][] tmp = cg.generateExtBlockSections(w, r, cx, cz, biomeGrid);
|
||||||
if (tmp != null) {
|
if (tmp != null) {
|
||||||
for (int i = 0; i < tmp.length; i++) {
|
for (int i = 0; i < tmp.length; i++) {
|
||||||
short[] section = tmp[i];
|
short[] section = tmp[i];
|
||||||
@ -235,30 +235,30 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChunkData generateChunkData(World world, Random random, int cx, int cz, BiomeGrid grid) {
|
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome) {
|
||||||
GenChunk result = this.chunkSetter;
|
GenChunk result = this.chunkSetter;
|
||||||
if (this.getPlotGenerator() instanceof SingleWorldGenerator) {
|
if (this.getPlotGenerator() instanceof SingleWorldGenerator) {
|
||||||
if (result.getCd() != null) {
|
if (result.getCd() != null) {
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int cx = 0; cx < 16; cx++) {
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int cz = 0; cz < 16; cz++) {
|
||||||
grid.setBiome(x, z, Biome.PLAINS);
|
biome.setBiome(cx, cz, Biome.PLAINS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result.getCd();
|
return result.getCd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Set the chunk location
|
// Set the chunk location
|
||||||
result.setChunk(new ChunkWrapper(world.getName(), cx, cz));
|
result.setChunk(new ChunkWrapper(world.getName(), x, z));
|
||||||
// Set the result data
|
// Set the result data
|
||||||
result.setCd(createChunkData(world));
|
result.setCd(createChunkData(world));
|
||||||
result.grid = grid;
|
result.biomeGrid = biome;
|
||||||
result.result = null;
|
result.result = null;
|
||||||
|
|
||||||
// Catch any exceptions (as exceptions usually thrown)
|
// Catch any exceptions (as exceptions usually thrown)
|
||||||
try {
|
try {
|
||||||
// Fill the result data if necessary
|
// Fill the result data if necessary
|
||||||
if (this.platformGenerator != this) {
|
if (this.platformGenerator != this) {
|
||||||
return this.platformGenerator.generateChunkData(world, random, cx, cz, grid);
|
return this.platformGenerator.generateChunkData(world, random, x, z, biome);
|
||||||
} else {
|
} else {
|
||||||
generate(world, result);
|
generate(world, result);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
|||||||
private final int hash;
|
private final int hash;
|
||||||
private final EntityBaseStats base = new EntityBaseStats();
|
private final EntityBaseStats base = new EntityBaseStats();
|
||||||
|
|
||||||
public ItemStack[] inventory;
|
private ItemStack[] inventory;
|
||||||
// Extended
|
// Extended
|
||||||
private ItemStack stack;
|
private ItemStack stack;
|
||||||
private byte dataByte;
|
private byte dataByte;
|
||||||
@ -94,6 +94,8 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
|||||||
case DRAGON_FIREBALL:
|
case DRAGON_FIREBALL:
|
||||||
case LINGERING_POTION:
|
case LINGERING_POTION:
|
||||||
case AREA_EFFECT_CLOUD:
|
case AREA_EFFECT_CLOUD:
|
||||||
|
case TRIDENT:
|
||||||
|
case LLAMA_SPIT:
|
||||||
// Do this stuff later
|
// Do this stuff later
|
||||||
return;
|
return;
|
||||||
// MISC //
|
// MISC //
|
||||||
@ -132,13 +134,21 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
|||||||
// START AGEABLE //
|
// START AGEABLE //
|
||||||
// START TAMEABLE //
|
// START TAMEABLE //
|
||||||
case HORSE:
|
case HORSE:
|
||||||
Horse horse = (Horse) entity;
|
case DONKEY:
|
||||||
|
case LLAMA:
|
||||||
|
case MULE:
|
||||||
|
case SKELETON_HORSE:
|
||||||
|
AbstractHorse horse = (AbstractHorse) entity;
|
||||||
this.horse = new HorseStats();
|
this.horse = new HorseStats();
|
||||||
this.horse.jump = horse.getJumpStrength();
|
this.horse.jump = horse.getJumpStrength();
|
||||||
this.horse.chest = horse.isCarryingChest();
|
if (horse instanceof ChestedHorse) {
|
||||||
this.horse.variant = horse.getVariant();
|
ChestedHorse horse1 = (ChestedHorse) horse;
|
||||||
this.horse.style = horse.getStyle();
|
this.horse.chest = horse1.isCarryingChest();
|
||||||
this.horse.color = horse.getColor();
|
}
|
||||||
|
//todo these horse feeatures need fixing
|
||||||
|
//this.horse.variant = horse.getVariant();
|
||||||
|
//this.horse.style = horse.getStyle();
|
||||||
|
//this.horse.color = horse.getColor();
|
||||||
storeTameable(horse);
|
storeTameable(horse);
|
||||||
storeAgeable(horse);
|
storeAgeable(horse);
|
||||||
storeLiving(horse);
|
storeLiving(horse);
|
||||||
@ -164,6 +174,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
|||||||
case COW:
|
case COW:
|
||||||
case MUSHROOM_COW:
|
case MUSHROOM_COW:
|
||||||
case PIG:
|
case PIG:
|
||||||
|
case TURTLE:
|
||||||
case POLAR_BEAR:
|
case POLAR_BEAR:
|
||||||
storeAgeable((Ageable) entity);
|
storeAgeable((Ageable) entity);
|
||||||
storeLiving((LivingEntity) entity);
|
storeLiving((LivingEntity) entity);
|
||||||
@ -174,16 +185,6 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
|||||||
storeLiving((LivingEntity) entity);
|
storeLiving((LivingEntity) entity);
|
||||||
return;
|
return;
|
||||||
// END AGEABLE //
|
// END AGEABLE //
|
||||||
//todo this needs to be fixed
|
|
||||||
case GUARDIAN:
|
|
||||||
case ELDER_GUARDIAN:
|
|
||||||
storeLiving((LivingEntity) entity);
|
|
||||||
return;
|
|
||||||
//todo this needs to be fixed
|
|
||||||
case SKELETON:
|
|
||||||
case WITHER_SKELETON:
|
|
||||||
storeLiving((LivingEntity) entity);
|
|
||||||
return;
|
|
||||||
case ARMOR_STAND:
|
case ARMOR_STAND:
|
||||||
ArmorStand stand = (ArmorStand) entity;
|
ArmorStand stand = (ArmorStand) entity;
|
||||||
this.inventory =
|
this.inventory =
|
||||||
@ -249,6 +250,10 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
|||||||
EnderDragon entity1 = (EnderDragon) entity;
|
EnderDragon entity1 = (EnderDragon) entity;
|
||||||
this.dataByte = (byte) entity1.getPhase().ordinal();
|
this.dataByte = (byte) entity1.getPhase().ordinal();
|
||||||
return;
|
return;
|
||||||
|
case SKELETON:
|
||||||
|
case WITHER_SKELETON:
|
||||||
|
case GUARDIAN:
|
||||||
|
case ELDER_GUARDIAN:
|
||||||
case GHAST:
|
case GHAST:
|
||||||
case MAGMA_CUBE:
|
case MAGMA_CUBE:
|
||||||
case SQUID:
|
case SQUID:
|
||||||
@ -487,6 +492,8 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
|||||||
case DRAGON_FIREBALL:
|
case DRAGON_FIREBALL:
|
||||||
case WITHER_SKULL:
|
case WITHER_SKULL:
|
||||||
case MINECART_FURNACE:
|
case MINECART_FURNACE:
|
||||||
|
case LLAMA_SPIT:
|
||||||
|
case TRIDENT:
|
||||||
case UNKNOWN:
|
case UNKNOWN:
|
||||||
// Do this stuff later
|
// Do this stuff later
|
||||||
return entity;
|
return entity;
|
||||||
@ -510,14 +517,20 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
|||||||
// START LIVING ENTITY //
|
// START LIVING ENTITY //
|
||||||
// START AGEABLE //
|
// START AGEABLE //
|
||||||
// START TAMEABLE //
|
// START TAMEABLE //
|
||||||
//todo this needs to be fixed
|
|
||||||
case HORSE:
|
case HORSE:
|
||||||
Horse horse = (Horse) entity;
|
case LLAMA:
|
||||||
|
case SKELETON_HORSE:
|
||||||
|
case DONKEY:
|
||||||
|
case MULE:
|
||||||
|
AbstractHorse horse = (AbstractHorse) entity;
|
||||||
horse.setJumpStrength(this.horse.jump);
|
horse.setJumpStrength(this.horse.jump);
|
||||||
horse.setCarryingChest(this.horse.chest);
|
if (horse instanceof ChestedHorse) {
|
||||||
horse.setVariant(this.horse.variant);
|
((ChestedHorse) horse).setCarryingChest(this.horse.chest);
|
||||||
horse.setStyle(this.horse.style);
|
}
|
||||||
horse.setColor(this.horse.color);
|
//todo broken as of 1.13
|
||||||
|
//horse.setVariant(this.horse.variant);
|
||||||
|
//horse.setStyle(this.horse.style);
|
||||||
|
//horse.setColor(this.horse.color);
|
||||||
restoreTameable(horse);
|
restoreTameable(horse);
|
||||||
restoreAgeable(horse);
|
restoreAgeable(horse);
|
||||||
restoreLiving(horse);
|
restoreLiving(horse);
|
||||||
@ -545,6 +558,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
|
|||||||
case VILLAGER:
|
case VILLAGER:
|
||||||
case CHICKEN:
|
case CHICKEN:
|
||||||
case COW:
|
case COW:
|
||||||
|
case TURTLE:
|
||||||
case POLAR_BEAR:
|
case POLAR_BEAR:
|
||||||
case MUSHROOM_COW:
|
case MUSHROOM_COW:
|
||||||
case PIG:
|
case PIG:
|
||||||
|
@ -154,7 +154,7 @@ public class NbtFactory {
|
|||||||
* @return The decoded NBT compound.
|
* @return The decoded NBT compound.
|
||||||
* @throws IOException If anything went wrong.
|
* @throws IOException If anything went wrong.
|
||||||
*/
|
*/
|
||||||
public static NbtCompound fromStream(InputStream input, StreamOptions option)
|
@SuppressWarnings({"IOResourceOpenedButNotSafelyClosed", "resource"}) public static NbtCompound fromStream(InputStream input, StreamOptions option)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
DataInputStream data = null;
|
DataInputStream data = null;
|
||||||
boolean suppress = true;
|
boolean suppress = true;
|
||||||
@ -189,24 +189,11 @@ public class NbtFactory {
|
|||||||
*/
|
*/
|
||||||
public static void saveStream(NbtCompound source, ByteSink stream, StreamOptions option)
|
public static void saveStream(NbtCompound source, ByteSink stream, StreamOptions option)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
OutputStream output = null;
|
|
||||||
DataOutputStream data = null;
|
|
||||||
boolean suppress = true;
|
|
||||||
|
|
||||||
try {
|
|
||||||
output = stream.openStream();
|
|
||||||
data = new DataOutputStream(
|
|
||||||
option == StreamOptions.GZIP_COMPRESSION ? new GZIPOutputStream(output) : output);
|
|
||||||
|
|
||||||
|
try (OutputStream output = stream.openStream();
|
||||||
|
DataOutputStream data = new DataOutputStream(
|
||||||
|
option == StreamOptions.GZIP_COMPRESSION ? new GZIPOutputStream(output) : output)) {
|
||||||
invokeMethod(get().SAVE_COMPOUND, null, source.getHandle(), data);
|
invokeMethod(get().SAVE_COMPOUND, null, source.getHandle(), data);
|
||||||
suppress = false;
|
|
||||||
|
|
||||||
} finally {
|
|
||||||
if (data != null) {
|
|
||||||
Closeables.close(data, suppress);
|
|
||||||
} else if (output != null) {
|
|
||||||
Closeables.close(output, suppress);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,9 +527,7 @@ public class NbtFactory {
|
|||||||
*
|
*
|
||||||
* @author Kristian
|
* @author Kristian
|
||||||
*/
|
*/
|
||||||
public enum StreamOptions {
|
public enum StreamOptions {NO_COMPRESSION, GZIP_COMPRESSION,}
|
||||||
NO_COMPRESSION, GZIP_COMPRESSION,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private enum NbtType {
|
private enum NbtType {
|
||||||
|
@ -23,7 +23,7 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
|||||||
|
|
||||||
public final Biome[] biomes;
|
public final Biome[] biomes;
|
||||||
public PlotBlock[][] result;
|
public PlotBlock[][] result;
|
||||||
public BiomeGrid grid;
|
public BiomeGrid biomeGrid;
|
||||||
public Chunk chunk;
|
public Chunk chunk;
|
||||||
public String world;
|
public String world;
|
||||||
public int cx;
|
public int cx;
|
||||||
@ -57,13 +57,13 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public void fillBiome(String biomeName) {
|
@Override public void fillBiome(String biomeName) {
|
||||||
if (grid == null) {
|
if (biomeGrid == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Biome biome = Biome.valueOf(biomeName.toUpperCase());
|
Biome biome = Biome.valueOf(biomeName.toUpperCase());
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int x = 0; x < 16; x++) {
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
this.grid.setBiome(x, z, biome);
|
this.biomeGrid.setBiome(x, z, biome);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,8 +96,8 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean setBiome(int x, int z, Biome biome) {
|
public boolean setBiome(int x, int z, Biome biome) {
|
||||||
if (this.grid != null) {
|
if (this.biomeGrid != null) {
|
||||||
this.grid.setBiome(x, z, biome);
|
this.biomeGrid.setBiome(x, z, biome);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -15,13 +15,13 @@ import java.util.stream.Collectors;
|
|||||||
public abstract class FileConfiguration extends MemoryConfiguration {
|
public abstract class FileConfiguration extends MemoryConfiguration {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an empty {@link FileConfiguration} with no default values.
|
* Creates an empty FileConfiguration with no default values.
|
||||||
*/
|
*/
|
||||||
FileConfiguration() {
|
FileConfiguration() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an empty {@link FileConfiguration} using the specified {@link
|
* Creates an empty FileConfiguration using the specified {@link
|
||||||
* Configuration} as a source for all default values.
|
* Configuration} as a source for all default values.
|
||||||
*
|
*
|
||||||
* @param defaults Default value provider
|
* @param defaults Default value provider
|
||||||
@ -31,7 +31,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves this {@link FileConfiguration} to the specified location.
|
* Saves this FileConfiguration to the specified location.
|
||||||
*
|
*
|
||||||
* <p>If the file does not exist, it will be created. If already exists, it
|
* <p>If the file does not exist, it will be created. If already exists, it
|
||||||
* will be overwritten. If it cannot be overwritten or created, an
|
* will be overwritten. If it cannot be overwritten or created, an
|
||||||
@ -59,14 +59,14 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves this {@link FileConfiguration} to a string, and returns it.
|
* Saves this FileConfiguration to a string, and returns it.
|
||||||
*
|
*
|
||||||
* @return String containing this configuration.
|
* @return String containing this configuration.
|
||||||
*/
|
*/
|
||||||
public abstract String saveToString();
|
public abstract String saveToString();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads this {@link FileConfiguration} from the specified location.
|
* Loads this FileConfiguration from the specified location.
|
||||||
*
|
*
|
||||||
* <p>All the values contained within this configuration will be removed,
|
* <p>All the values contained within this configuration will be removed,
|
||||||
* leaving only settings and defaults, and the new values will be loaded
|
* leaving only settings and defaults, and the new values will be loaded
|
||||||
@ -85,13 +85,13 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
*/
|
*/
|
||||||
public void load(File file) throws IOException, InvalidConfigurationException {
|
public void load(File file) throws IOException, InvalidConfigurationException {
|
||||||
|
|
||||||
FileInputStream stream = new FileInputStream(file);
|
try (FileInputStream stream = new FileInputStream(file)) {
|
||||||
|
|
||||||
load(new InputStreamReader(stream, StandardCharsets.UTF_8));
|
load(new InputStreamReader(stream, StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads this {@link FileConfiguration} from the specified reader.
|
* Loads this FileConfiguration from the specified reader.
|
||||||
*
|
*
|
||||||
* <p>All the values contained within this configuration will be removed,
|
* <p>All the values contained within this configuration will be removed,
|
||||||
* leaving only settings and defaults, and the new values will be loaded
|
* leaving only settings and defaults, and the new values will be loaded
|
||||||
@ -117,7 +117,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads this {@link FileConfiguration} from the specified string, as
|
* Loads this FileConfiguration from the specified string, as
|
||||||
* opposed to from file.
|
* opposed to from file.
|
||||||
*
|
*
|
||||||
* <p>All the values contained within this configuration will be removed,
|
* <p>All the values contained within this configuration will be removed,
|
||||||
@ -133,7 +133,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
public abstract void loadFromString(String contents) throws InvalidConfigurationException;
|
public abstract void loadFromString(String contents) throws InvalidConfigurationException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles the header for this {@link FileConfiguration} and returns the
|
* Compiles the header for this FileConfiguration and returns the
|
||||||
* result.
|
* result.
|
||||||
*
|
*
|
||||||
* <p>This will use the header from {@link #options()} -> {@link
|
* <p>This will use the header from {@link #options()} -> {@link
|
||||||
|
@ -41,6 +41,7 @@ import java.nio.file.Files;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
@ -1817,6 +1818,12 @@ import java.util.zip.ZipInputStream;
|
|||||||
return Double.parseDouble(System.getProperty("java.specification.version"));
|
return Double.parseDouble(System.getProperty("java.specification.version"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void forEachPlotArea(Consumer<? super PlotArea> action) {
|
||||||
|
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
|
||||||
|
action.accept(area);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void foreachPlotArea(@Nonnull final RunnableVal<PlotArea> runnable) {
|
public void foreachPlotArea(@Nonnull final RunnableVal<PlotArea> runnable) {
|
||||||
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
|
for (final PlotArea area : this.plotAreaManager.getAllPlotAreas()) {
|
||||||
runnable.run(area);
|
runnable.run(area);
|
||||||
|
@ -1513,6 +1513,7 @@ public class Plot {
|
|||||||
return WorldUtil.IMP.getBiome(loc.getWorld(), loc.getX(), loc.getZ());
|
return WorldUtil.IMP.getBiome(loc.getWorld(), loc.getX(), loc.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO Better documentation needed.
|
||||||
/**
|
/**
|
||||||
* Return the top location for the plot.
|
* Return the top location for the plot.
|
||||||
*
|
*
|
||||||
@ -1525,7 +1526,6 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO Better documentation needed.
|
//TODO Better documentation needed.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the bottom location for the plot.
|
* Return the bottom location for the plot.
|
||||||
*/
|
*/
|
||||||
@ -1573,7 +1573,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move the settings for a plot.
|
* Moves the settings for a plot.
|
||||||
*
|
*
|
||||||
* @param plot the plot to move
|
* @param plot the plot to move
|
||||||
* @param whenDone
|
* @param whenDone
|
||||||
@ -1710,7 +1710,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move the plot to an empty location<br>
|
* Moves the plot to an empty location<br>
|
||||||
* - The location must be empty
|
* - The location must be empty
|
||||||
*
|
*
|
||||||
* @param destination Where to move the plot
|
* @param destination Where to move the plot
|
||||||
@ -2616,6 +2616,7 @@ 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)
|
||||||
*/
|
*/
|
||||||
@ -2735,12 +2736,9 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expand the world border to include the provided plot (if applicable).
|
* Expands the world border to include this plot if it is beyond the current border.
|
||||||
*/
|
*/
|
||||||
public void updateWorldBorder() {
|
public void updateWorldBorder() {
|
||||||
if (this.owner == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int border = this.area.getBorder();
|
int border = this.area.getBorder();
|
||||||
if (border == Integer.MAX_VALUE) {
|
if (border == Integer.MAX_VALUE) {
|
||||||
return;
|
return;
|
||||||
@ -2811,7 +2809,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move a plot physically, as well as the corresponding settings.
|
* Moves a plot physically, as well as the corresponding settings.
|
||||||
*
|
*
|
||||||
* @param destination Plot moved to
|
* @param destination Plot moved to
|
||||||
* @param whenDone task when done
|
* @param whenDone task when done
|
||||||
|
@ -655,7 +655,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface PlotPlayerConverter<BaseObject> {
|
@FunctionalInterface public interface PlotPlayerConverter<BaseObject> {
|
||||||
PlotPlayer convert(BaseObject object);
|
PlotPlayer convert(BaseObject object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,9 +39,9 @@ public class Schematic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void save(File file) throws IOException {
|
public void save(File file) throws IOException {
|
||||||
SpongeSchematicWriter ssw =
|
try (SpongeSchematicWriter ssw = new SpongeSchematicWriter(
|
||||||
new SpongeSchematicWriter(new NBTOutputStream(new FileOutputStream(file)));
|
new NBTOutputStream(new FileOutputStream(file)))) {
|
||||||
ssw.write(clipboard);
|
ssw.write(clipboard);
|
||||||
ssw.close();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ public abstract class SchematicHandler {
|
|||||||
} else {
|
} else {
|
||||||
MainUtil.sendMessage(null, "&7 - &a success: " + plot.getId());
|
MainUtil.sendMessage(null, "&7 - &a success: " + plot.getId());
|
||||||
}
|
}
|
||||||
TaskManager.runTask(THIS::run);
|
TaskManager.runTask(THIS);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,7 +104,6 @@ public abstract class SchematicHandler {
|
|||||||
* @param plot plot to paste in
|
* @param plot plot to paste in
|
||||||
* @param xOffset offset x to paste it from plot origin
|
* @param xOffset offset x to paste it from plot origin
|
||||||
* @param zOffset offset z to paste it from plot origin
|
* @param zOffset offset z to paste it from plot origin
|
||||||
* @return boolean true if succeeded
|
|
||||||
*/
|
*/
|
||||||
public void paste(final Schematic schematic, final Plot plot, final int xOffset,
|
public void paste(final Schematic schematic, final Plot plot, final int xOffset,
|
||||||
final int yOffset, final int zOffset, final boolean autoHeight,
|
final int yOffset, final int zOffset, final boolean autoHeight,
|
||||||
@ -126,7 +125,7 @@ public abstract class SchematicHandler {
|
|||||||
if (!flags.isEmpty()) {
|
if (!flags.isEmpty()) {
|
||||||
for (Map.Entry<String, Tag> entry : flags.entrySet()) {
|
for (Map.Entry<String, Tag> entry : flags.entrySet()) {
|
||||||
plot.setFlag(Flags.getFlag(entry.getKey()),
|
plot.setFlag(Flags.getFlag(entry.getKey()),
|
||||||
StringTag.class.cast(entry.getValue()).getValue());
|
((StringTag) entry.getValue()).getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -341,20 +340,17 @@ public abstract class SchematicHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getSaves(UUID uuid) {
|
public List<String> getSaves(UUID uuid) {
|
||||||
StringBuilder rawJSON = new StringBuilder();
|
String rawJSON = "";
|
||||||
try {
|
try {
|
||||||
String website = Settings.Web.URL + "list.php?" + uuid.toString();
|
String website = Settings.Web.URL + "list.php?" + uuid.toString();
|
||||||
URL url = new URL(website);
|
URL url = new URL(website);
|
||||||
URLConnection connection = new URL(url.toString()).openConnection();
|
URLConnection connection = new URL(url.toString()).openConnection();
|
||||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
|
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||||
BufferedReader reader =
|
try (BufferedReader reader = new BufferedReader(
|
||||||
new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
new InputStreamReader(connection.getInputStream()))) {
|
||||||
String line;
|
rawJSON = reader.lines().collect(Collectors.joining());
|
||||||
while ((line = reader.readLine()) != null) {
|
|
||||||
rawJSON.append(line);
|
|
||||||
}
|
}
|
||||||
reader.close();
|
JSONArray array = new JSONArray(rawJSON);
|
||||||
JSONArray array = new JSONArray(rawJSON.toString());
|
|
||||||
List<String> schematics = new ArrayList<>();
|
List<String> schematics = new ArrayList<>();
|
||||||
for (int i = 0; i < array.length(); i++) {
|
for (int i = 0; i < array.length(); i++) {
|
||||||
String schematic = array.getString(i);
|
String schematic = array.getString(i);
|
||||||
|
@ -78,7 +78,7 @@ public abstract class WorldUtil {
|
|||||||
map.put("SpawnX", new IntTag(home.getX()));
|
map.put("SpawnX", new IntTag(home.getX()));
|
||||||
map.put("SpawnY", new IntTag(home.getY()));
|
map.put("SpawnY", new IntTag(home.getY()));
|
||||||
map.put("SpawnZ", new IntTag(home.getZ()));
|
map.put("SpawnZ", new IntTag(home.getZ()));
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
||||||
try (NBTOutputStream out = new NBTOutputStream(
|
try (NBTOutputStream out = new NBTOutputStream(
|
||||||
new GZIPOutputStream(baos, true))) {
|
new GZIPOutputStream(baos, true))) {
|
||||||
//TODO Find what this should be called
|
//TODO Find what this should be called
|
||||||
@ -87,6 +87,7 @@ public abstract class WorldUtil {
|
|||||||
zos.write(baos.toByteArray());
|
zos.write(baos.toByteArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
setSpawn(spawn);
|
setSpawn(spawn);
|
||||||
for (Plot current : plot.getConnectedPlots()) {
|
for (Plot current : plot.getConnectedPlots()) {
|
||||||
Location bot = current.getBottomAbs();
|
Location bot = current.getBottomAbs();
|
||||||
|
Loading…
Reference in New Issue
Block a user