2020-04-16 04:52:39 +02:00
|
|
|
|
/*
|
|
|
|
|
* _____ _ _ _____ _
|
|
|
|
|
* | __ \| | | | / ____| | |
|
|
|
|
|
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
|
|
|
|
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
|
|
|
|
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
|
|
|
|
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
|
|
|
|
* | |
|
|
|
|
|
* |_|
|
|
|
|
|
* PlotSquared plot management system for Minecraft
|
|
|
|
|
* Copyright (C) 2020 IntellectualSites
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
2020-04-15 21:26:54 +02:00
|
|
|
|
package com.plotsquared.core.util;
|
2016-02-10 19:59:51 +01:00
|
|
|
|
|
2020-04-15 21:26:54 +02:00
|
|
|
|
import com.plotsquared.core.PlotSquared;
|
2020-07-09 12:58:28 +02:00
|
|
|
|
import com.plotsquared.core.configuration.Caption;
|
2020-04-15 21:26:54 +02:00
|
|
|
|
import com.plotsquared.core.location.Location;
|
|
|
|
|
import com.plotsquared.core.player.PlotPlayer;
|
2020-04-30 12:01:52 +02:00
|
|
|
|
import com.plotsquared.core.plot.Plot;
|
2020-04-15 21:26:54 +02:00
|
|
|
|
import com.plotsquared.core.util.task.RunnableVal;
|
2019-05-14 03:57:41 +02:00
|
|
|
|
import com.sk89q.jnbt.CompoundTag;
|
|
|
|
|
import com.sk89q.jnbt.IntTag;
|
|
|
|
|
import com.sk89q.jnbt.NBTInputStream;
|
|
|
|
|
import com.sk89q.jnbt.NBTOutputStream;
|
|
|
|
|
import com.sk89q.jnbt.Tag;
|
2019-11-04 18:44:23 +01:00
|
|
|
|
import com.sk89q.worldedit.math.BlockVector2;
|
2020-07-19 14:23:55 +02:00
|
|
|
|
import com.sk89q.worldedit.math.BlockVector3;
|
2019-11-10 18:47:37 +01:00
|
|
|
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
|
|
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
2019-11-04 20:58:24 +01:00
|
|
|
|
import com.sk89q.worldedit.world.block.BlockState;
|
2020-05-13 14:11:17 +02:00
|
|
|
|
import com.sk89q.worldedit.world.block.BlockType;
|
2020-04-11 22:26:31 +02:00
|
|
|
|
import com.sk89q.worldedit.world.entity.EntityType;
|
2020-07-09 12:58:28 +02:00
|
|
|
|
import net.kyori.adventure.text.minimessage.Template;
|
2019-05-14 03:57:41 +02:00
|
|
|
|
|
|
|
|
|
|
2020-07-17 22:58:10 +02:00
|
|
|
|
import javax.annotation.Nonnegative;
|
2020-07-17 17:24:45 +02:00
|
|
|
|
import javax.annotation.Nonnull;
|
2020-07-17 22:58:10 +02:00
|
|
|
|
import javax.annotation.Nullable;
|
2019-05-14 03:57:41 +02:00
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.OutputStream;
|
2016-03-17 10:11:07 +01:00
|
|
|
|
import java.net.URL;
|
2020-05-13 14:11:17 +02:00
|
|
|
|
import java.util.Collection;
|
2017-09-19 16:33:29 +02:00
|
|
|
|
import java.util.Map;
|
2017-03-23 01:10:29 +01:00
|
|
|
|
import java.util.Set;
|
2016-03-17 10:11:07 +01:00
|
|
|
|
import java.util.UUID;
|
2020-04-07 20:19:39 +02:00
|
|
|
|
import java.util.function.Consumer;
|
2020-04-09 11:23:39 +02:00
|
|
|
|
import java.util.function.IntConsumer;
|
2017-09-19 16:33:29 +02:00
|
|
|
|
import java.util.zip.GZIPInputStream;
|
|
|
|
|
import java.util.zip.GZIPOutputStream;
|
2016-03-17 10:11:07 +01:00
|
|
|
|
import java.util.zip.ZipEntry;
|
|
|
|
|
import java.util.zip.ZipOutputStream;
|
2016-02-10 19:59:51 +01:00
|
|
|
|
|
|
|
|
|
public abstract class WorldUtil {
|
2020-07-10 22:12:37 +02:00
|
|
|
|
|
|
|
|
|
private final RegionManager regionManager;
|
|
|
|
|
|
2020-07-14 18:49:40 +02:00
|
|
|
|
public WorldUtil(@Nonnull final RegionManager regionManager) {
|
2020-07-10 22:12:37 +02:00
|
|
|
|
this.regionManager = regionManager;
|
|
|
|
|
}
|
2018-08-10 17:01:10 +02:00
|
|
|
|
|
2020-07-19 14:23:55 +02:00
|
|
|
|
/**
|
|
|
|
|
* Set the biome in a region
|
|
|
|
|
*
|
|
|
|
|
* @param world World name
|
|
|
|
|
* @param p1x Min X
|
|
|
|
|
* @param p1z Min Z
|
|
|
|
|
* @param p2x Max X
|
|
|
|
|
* @param p2z Max Z
|
|
|
|
|
* @param biome Biome
|
|
|
|
|
*/
|
|
|
|
|
public static void setBiome(String world, int p1x, int p1z, int p2x, int p2z, BiomeType biome) {
|
|
|
|
|
BlockVector3 pos1 = BlockVector2.at(p1x, p1z).toBlockVector3();
|
|
|
|
|
BlockVector3 pos2 = BlockVector2.at(p2x, p2z).toBlockVector3(Plot.MAX_HEIGHT - 1);
|
|
|
|
|
CuboidRegion region = new CuboidRegion(pos1, pos2);
|
|
|
|
|
PlotSquared.platform().getWorldUtil().setBiomes(world, region, biome);
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-07 20:19:39 +02:00
|
|
|
|
/**
|
2020-07-17 22:58:10 +02:00
|
|
|
|
* Check if a given world name corresponds to a real world
|
|
|
|
|
*
|
|
|
|
|
* @param worldName World name
|
|
|
|
|
* @return {@code true} if there exists a world with the given world name,
|
|
|
|
|
* {@code false} if not
|
2020-04-07 20:19:39 +02:00
|
|
|
|
*/
|
2020-07-17 22:58:10 +02:00
|
|
|
|
public abstract boolean isWorld(@Nonnull String worldName);
|
2020-04-07 20:19:39 +02:00
|
|
|
|
|
|
|
|
|
/**
|
2020-07-17 22:58:10 +02:00
|
|
|
|
* @param location Sign location
|
|
|
|
|
* @return Sign content (or an empty string array if the block is not a sign)
|
2020-04-07 20:19:39 +02:00
|
|
|
|
* @deprecated May result in synchronous chunk loading
|
|
|
|
|
*/
|
2020-07-17 22:58:10 +02:00
|
|
|
|
@Deprecated @Nonnull public abstract String[] getSignSynchronous(@Nonnull Location location);
|
2020-04-07 20:19:39 +02:00
|
|
|
|
|
2020-07-17 22:58:10 +02:00
|
|
|
|
/**
|
|
|
|
|
* Get the world spawn location
|
|
|
|
|
*
|
|
|
|
|
* @param world World name
|
|
|
|
|
* @return World spawn location
|
|
|
|
|
*/
|
|
|
|
|
@Nonnull public abstract Location getSpawn(@Nonnull String world);
|
2018-08-10 17:01:10 +02:00
|
|
|
|
|
2020-04-07 20:19:39 +02:00
|
|
|
|
/**
|
2020-07-17 22:58:10 +02:00
|
|
|
|
* Set the world spawn location
|
|
|
|
|
*
|
|
|
|
|
* @param location New spawn
|
2020-04-07 20:19:39 +02:00
|
|
|
|
*/
|
2020-07-17 22:58:10 +02:00
|
|
|
|
public abstract void setSpawn(@Nonnull Location location);
|
2018-08-10 17:01:10 +02:00
|
|
|
|
|
2020-07-17 22:58:10 +02:00
|
|
|
|
/**
|
|
|
|
|
* Save a world
|
|
|
|
|
*
|
|
|
|
|
* @param world World name
|
|
|
|
|
*/
|
|
|
|
|
public abstract void saveWorld(@Nonnull String world);
|
2018-08-10 17:01:10 +02:00
|
|
|
|
|
2020-04-07 20:19:39 +02:00
|
|
|
|
/**
|
2020-07-17 22:58:10 +02:00
|
|
|
|
* Get a string comparison with the closets block state matching a given string
|
|
|
|
|
*
|
|
|
|
|
* @param name Block name
|
|
|
|
|
* @return Comparison result containing the closets matching block
|
2020-04-07 20:19:39 +02:00
|
|
|
|
*/
|
2020-07-17 22:58:10 +02:00
|
|
|
|
@Nonnull public abstract StringComparison<BlockState>.ComparisonResult getClosestBlock(
|
|
|
|
|
@Nonnull String name);
|
2018-08-10 17:01:10 +02:00
|
|
|
|
|
2020-07-09 12:58:28 +02:00
|
|
|
|
/**
|
|
|
|
|
* Set the block at the specified location to a sign, with given text
|
|
|
|
|
*
|
|
|
|
|
* @param location Block location
|
|
|
|
|
* @param lines Sign text
|
|
|
|
|
* @param replacements Text replacements
|
|
|
|
|
*/
|
2020-07-14 19:34:44 +02:00
|
|
|
|
public abstract void setSign(@Nonnull Location location,
|
|
|
|
|
@Nonnull Caption[] lines,
|
|
|
|
|
@Nonnull Template ... replacements);
|
2020-07-17 22:58:10 +02:00
|
|
|
|
/**
|
|
|
|
|
* Get the biome in a given chunk, asynchronously
|
|
|
|
|
*
|
|
|
|
|
* @param world World
|
|
|
|
|
* @param x Chunk X coordinate
|
|
|
|
|
* @param z Chunk Z coordinate
|
|
|
|
|
* @param result Result consumer
|
|
|
|
|
*/
|
|
|
|
|
public abstract void getBiome(@Nonnull String world, int x, int z,
|
|
|
|
|
@Nonnull Consumer<BiomeType> result);
|
2018-08-10 17:01:10 +02:00
|
|
|
|
|
2020-07-17 22:58:10 +02:00
|
|
|
|
/**
|
|
|
|
|
* Get the biome in a given chunk, asynchronously
|
|
|
|
|
*
|
|
|
|
|
* @param world World
|
|
|
|
|
* @param x Chunk X coordinate
|
|
|
|
|
* @param z Chunk Z coordinate
|
|
|
|
|
* @return Biome
|
|
|
|
|
* @deprecated Use {@link #getBiome(String, int, int, Consumer)}
|
|
|
|
|
*/
|
|
|
|
|
@Deprecated @Nonnull public abstract BiomeType getBiomeSynchronous(@Nonnull String world, int x,
|
|
|
|
|
int z);
|
2020-04-07 20:19:39 +02:00
|
|
|
|
|
|
|
|
|
/**
|
2020-07-17 22:58:10 +02:00
|
|
|
|
* Get the block at a given location (asynchronously)
|
|
|
|
|
*
|
|
|
|
|
* @param location Block location
|
|
|
|
|
* @param result Result consumer
|
2020-04-07 20:19:39 +02:00
|
|
|
|
*/
|
2020-07-17 22:58:10 +02:00
|
|
|
|
public abstract void getBlock(@Nonnull Location location, @Nonnull Consumer<BlockState> result);
|
2020-04-07 20:19:39 +02:00
|
|
|
|
|
2020-07-17 22:58:10 +02:00
|
|
|
|
/**
|
|
|
|
|
* Get the block at a given location (synchronously)
|
|
|
|
|
*
|
|
|
|
|
* @param location Block location
|
|
|
|
|
* @return Result
|
|
|
|
|
* @deprecated Use {@link #getBlock(Location, Consumer)}
|
|
|
|
|
*/
|
|
|
|
|
@Deprecated @Nonnull public abstract BlockState getBlockSynchronous(@Nonnull Location location);
|
2018-08-10 17:01:10 +02:00
|
|
|
|
|
2020-04-07 20:19:39 +02:00
|
|
|
|
/**
|
2020-07-17 22:58:10 +02:00
|
|
|
|
* Get the Y coordinate of the highest non-air block in the world, asynchronously
|
|
|
|
|
*
|
|
|
|
|
* @param world World name
|
|
|
|
|
* @param x X coordinate
|
|
|
|
|
* @param z Z coordinate
|
|
|
|
|
* @param result Result consumer
|
2020-04-07 20:19:39 +02:00
|
|
|
|
*/
|
2020-07-17 22:58:10 +02:00
|
|
|
|
public abstract void getHighestBlock(@Nonnull String world, int x, int z,
|
|
|
|
|
@Nonnull IntConsumer result);
|
2018-08-10 17:01:10 +02:00
|
|
|
|
|
2016-03-17 10:11:07 +01:00
|
|
|
|
|
2020-04-07 20:19:39 +02:00
|
|
|
|
/**
|
2020-07-17 22:58:10 +02:00
|
|
|
|
* Get the Y coordinate of the highest non-air block in the world, synchronously
|
|
|
|
|
*
|
|
|
|
|
* @param world World name
|
|
|
|
|
* @param x X coordinate
|
|
|
|
|
* @param z Z coordinate
|
|
|
|
|
* @return Result
|
|
|
|
|
* @deprecated Use {@link #getHighestBlock(String, int, int, IntConsumer)}
|
2020-04-07 20:19:39 +02:00
|
|
|
|
*/
|
2020-07-17 22:58:10 +02:00
|
|
|
|
@Deprecated @Nonnegative
|
|
|
|
|
public abstract int getHighestBlockSynchronous(@Nonnull String world, int x, int z);
|
2018-08-10 17:01:10 +02:00
|
|
|
|
|
2020-07-17 22:58:10 +02:00
|
|
|
|
/**
|
|
|
|
|
* Set the biome in a region
|
|
|
|
|
*
|
|
|
|
|
* @param world World name
|
|
|
|
|
* @param region Region
|
|
|
|
|
* @param biome New biome
|
|
|
|
|
*/
|
|
|
|
|
public abstract void setBiomes(@Nonnull String world, @Nonnull CuboidRegion region,
|
|
|
|
|
@Nonnull BiomeType biome);
|
2018-12-20 00:18:57 +01:00
|
|
|
|
|
2020-07-17 22:58:10 +02:00
|
|
|
|
/**
|
|
|
|
|
* Get the WorldEdit {@link com.sk89q.worldedit.world.World} corresponding to a world name
|
|
|
|
|
*
|
|
|
|
|
* @param world World name
|
|
|
|
|
* @return World object
|
|
|
|
|
*/
|
|
|
|
|
@Nonnull public abstract com.sk89q.worldedit.world.World getWeWorld(@Nonnull String world);
|
2018-12-20 00:18:57 +01:00
|
|
|
|
|
2020-07-17 22:58:10 +02:00
|
|
|
|
public void upload(@Nonnull final Plot plot, @Nullable final UUID uuid,
|
|
|
|
|
@Nullable final String file, @Nonnull final RunnableVal<URL> whenDone) {
|
2020-07-19 14:23:55 +02:00
|
|
|
|
plot.getHome(home -> SchematicHandler.upload(uuid, file, "zip", new RunnableVal<OutputStream>() {
|
2018-08-10 17:01:10 +02:00
|
|
|
|
@Override public void run(OutputStream output) {
|
2016-03-17 10:11:07 +01:00
|
|
|
|
try (final ZipOutputStream zos = new ZipOutputStream(output)) {
|
2017-03-23 01:10:29 +01:00
|
|
|
|
File dat = getDat(plot.getWorldName());
|
|
|
|
|
Location spawn = getSpawn(plot.getWorldName());
|
2016-03-17 10:11:07 +01:00
|
|
|
|
if (dat != null) {
|
2016-03-23 02:41:37 +01:00
|
|
|
|
ZipEntry ze = new ZipEntry("world" + File.separator + dat.getName());
|
2016-03-17 10:11:07 +01:00
|
|
|
|
zos.putNextEntry(ze);
|
2018-08-10 17:01:10 +02:00
|
|
|
|
try (NBTInputStream nis = new NBTInputStream(
|
|
|
|
|
new GZIPInputStream(new FileInputStream(dat)))) {
|
2018-12-20 00:18:57 +01:00
|
|
|
|
CompoundTag tag = (CompoundTag) nis.readNamedTag().getTag();
|
2017-09-19 16:33:29 +02:00
|
|
|
|
CompoundTag data = (CompoundTag) tag.getValue().get("Data");
|
|
|
|
|
Map<String, Tag> map = ReflectionUtils.getMap(data.getValue());
|
2018-12-20 00:18:57 +01:00
|
|
|
|
map.put("SpawnX", new IntTag(home.getX()));
|
|
|
|
|
map.put("SpawnY", new IntTag(home.getY()));
|
|
|
|
|
map.put("SpawnZ", new IntTag(home.getZ()));
|
2019-02-15 18:50:43 +01:00
|
|
|
|
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
|
|
|
|
try (NBTOutputStream out = new NBTOutputStream(
|
|
|
|
|
new GZIPOutputStream(baos, true))) {
|
|
|
|
|
//TODO Find what this should be called
|
|
|
|
|
out.writeNamedTag("Schematic????", tag);
|
|
|
|
|
}
|
|
|
|
|
zos.write(baos.toByteArray());
|
2017-09-19 16:33:29 +02:00
|
|
|
|
}
|
2016-03-17 10:11:07 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
setSpawn(spawn);
|
2019-05-14 03:57:41 +02:00
|
|
|
|
byte[] buffer = new byte[1024];
|
2016-03-17 10:11:07 +01:00
|
|
|
|
for (Plot current : plot.getConnectedPlots()) {
|
2016-03-23 02:41:37 +01:00
|
|
|
|
Location bot = current.getBottomAbs();
|
|
|
|
|
Location top = current.getTopAbs();
|
|
|
|
|
int brx = bot.getX() >> 9;
|
|
|
|
|
int brz = bot.getZ() >> 9;
|
|
|
|
|
int trx = top.getX() >> 9;
|
|
|
|
|
int trz = top.getZ() >> 9;
|
2020-07-10 22:12:37 +02:00
|
|
|
|
Set<BlockVector2> files = regionManager.getChunkChunks(bot.getWorldName());
|
2019-11-04 18:44:23 +01:00
|
|
|
|
for (BlockVector2 mca : files) {
|
2020-02-24 18:42:02 +01:00
|
|
|
|
if (mca.getX() >= brx && mca.getX() <= trx && mca.getZ() >= brz
|
|
|
|
|
&& mca.getZ() <= trz) {
|
|
|
|
|
final File file =
|
|
|
|
|
getMcr(plot.getWorldName(), mca.getX(), mca.getZ());
|
2016-03-17 10:11:07 +01:00
|
|
|
|
if (file != null) {
|
|
|
|
|
//final String name = "r." + (x - cx) + "." + (z - cz) + ".mca";
|
|
|
|
|
String name = file.getName();
|
2018-08-10 17:01:10 +02:00
|
|
|
|
final ZipEntry ze = new ZipEntry(
|
|
|
|
|
"world" + File.separator + "region" + File.separator
|
|
|
|
|
+ name);
|
2016-03-17 10:11:07 +01:00
|
|
|
|
zos.putNextEntry(ze);
|
2019-05-14 03:57:41 +02:00
|
|
|
|
try (FileInputStream in = new FileInputStream(file)) {
|
|
|
|
|
int len;
|
|
|
|
|
while ((len = in.read(buffer)) > 0) {
|
|
|
|
|
zos.write(buffer, 0, len);
|
|
|
|
|
}
|
2016-03-17 10:11:07 +01:00
|
|
|
|
}
|
2017-03-23 01:10:29 +01:00
|
|
|
|
zos.closeEntry();
|
2016-03-17 10:11:07 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
zos.closeEntry();
|
|
|
|
|
zos.flush();
|
|
|
|
|
zos.finish();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-07 20:19:39 +02:00
|
|
|
|
}, whenDone));
|
2016-03-17 10:11:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-17 22:58:10 +02:00
|
|
|
|
@Nullable final File getDat(@Nonnull final String world) {
|
2018-08-10 17:01:10 +02:00
|
|
|
|
File file = new File(
|
2020-07-07 12:56:43 +02:00
|
|
|
|
PlotSquared.platform().getWorldContainer() + File.separator + world + File.separator
|
2018-08-10 17:01:10 +02:00
|
|
|
|
+ "level.dat");
|
2016-03-17 10:11:07 +01:00
|
|
|
|
if (file.exists()) {
|
|
|
|
|
return file;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-17 22:58:10 +02:00
|
|
|
|
@Nullable private File getMcr(@Nonnull final String world, final int x, final int z) {
|
|
|
|
|
final File file = new File(PlotSquared.platform().getWorldContainer(),
|
2018-08-10 17:01:10 +02:00
|
|
|
|
world + File.separator + "region" + File.separator + "r." + x + '.' + z + ".mca");
|
2016-03-17 10:11:07 +01:00
|
|
|
|
if (file.exists()) {
|
|
|
|
|
return file;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2018-12-17 20:57:21 +01:00
|
|
|
|
|
2020-07-17 22:58:10 +02:00
|
|
|
|
/**
|
|
|
|
|
* Check if two blocks are the same type)
|
|
|
|
|
*
|
|
|
|
|
* @param block1 First block
|
|
|
|
|
* @param block2 Second block
|
|
|
|
|
* @return {@code true} if the blocks have the same type, {@code false} if not
|
|
|
|
|
*/
|
|
|
|
|
public abstract boolean isBlockSame(@Nonnull BlockState block1, @Nonnull BlockState block2);
|
2020-03-15 12:22:49 +01:00
|
|
|
|
|
2020-07-17 22:58:10 +02:00
|
|
|
|
/**
|
|
|
|
|
* Get a player object for the player with the given UUID
|
|
|
|
|
*
|
|
|
|
|
* @param uuid Player UUID
|
|
|
|
|
* @return Player object
|
|
|
|
|
*/
|
|
|
|
|
@Nonnull public abstract PlotPlayer<?> getPlayer(@Nonnull UUID uuid);
|
2020-03-15 12:22:49 +01:00
|
|
|
|
|
2020-07-17 22:58:10 +02:00
|
|
|
|
/**
|
|
|
|
|
* Get the player health
|
|
|
|
|
*
|
|
|
|
|
* @param player Player
|
|
|
|
|
* @return Non-negative health
|
|
|
|
|
*/
|
|
|
|
|
@Nonnegative public abstract double getHealth(@Nonnull PlotPlayer<?> player);
|
2020-03-15 12:22:49 +01:00
|
|
|
|
|
2020-07-17 22:58:10 +02:00
|
|
|
|
/**
|
|
|
|
|
* Set the player health
|
|
|
|
|
*
|
|
|
|
|
* @param player Player health
|
|
|
|
|
* @param health Non-negative health
|
|
|
|
|
*/
|
|
|
|
|
public abstract void setHealth(@Nonnull PlotPlayer<?> player, @Nonnegative double health);
|
2020-03-15 12:22:49 +01:00
|
|
|
|
|
2020-07-17 22:58:10 +02:00
|
|
|
|
/**
|
|
|
|
|
* Get the player food level
|
|
|
|
|
*
|
|
|
|
|
* @param player Player
|
|
|
|
|
* @return Non-negative food level
|
|
|
|
|
*/
|
|
|
|
|
@Nonnegative public abstract int getFoodLevel(@Nonnull PlotPlayer<?> player);
|
2020-03-15 12:22:49 +01:00
|
|
|
|
|
2020-07-17 22:58:10 +02:00
|
|
|
|
/**
|
|
|
|
|
* Set the player food level
|
|
|
|
|
*
|
|
|
|
|
* @param player Player food level
|
|
|
|
|
* @param foodLevel Non-negative food level
|
|
|
|
|
*/
|
|
|
|
|
public abstract void setFoodLevel(@Nonnull PlotPlayer<?> player, @Nonnegative int foodLevel);
|
2020-04-11 22:26:31 +02:00
|
|
|
|
|
2020-07-17 22:58:10 +02:00
|
|
|
|
/**
|
|
|
|
|
* Get all entity types belonging to an entity category
|
|
|
|
|
*
|
|
|
|
|
* @param category Entity category
|
|
|
|
|
* @return Set containing all entities belonging to the given category
|
|
|
|
|
*/
|
|
|
|
|
@Nonnull public abstract Set<EntityType> getTypesInCategory(@Nonnull String category);
|
2020-04-11 22:26:31 +02:00
|
|
|
|
|
2020-07-17 22:58:10 +02:00
|
|
|
|
/**
|
|
|
|
|
* Get all recognized tile entity types
|
|
|
|
|
*
|
|
|
|
|
* @return Collection containing all known tile entity types
|
|
|
|
|
*/
|
|
|
|
|
@Nonnull public abstract Collection<BlockType> getTileEntityTypes();
|
2020-05-13 14:11:17 +02:00
|
|
|
|
|
2020-07-17 22:58:10 +02:00
|
|
|
|
/**
|
|
|
|
|
* Get the tile entity count in a chunk
|
|
|
|
|
*
|
|
|
|
|
* @param world World
|
|
|
|
|
* @param chunk Chunk coordinates
|
|
|
|
|
* @return Tile entity count
|
|
|
|
|
*/
|
|
|
|
|
@Nonnegative public abstract int getTileEntityCount(@Nonnull String world,
|
|
|
|
|
@Nonnull BlockVector2 chunk);
|
2020-05-13 14:54:54 +02:00
|
|
|
|
|
2016-02-10 19:59:51 +01:00
|
|
|
|
}
|