130 lines
3.0 KiB
Java
130 lines
3.0 KiB
Java
package eu.univento.teamvento.plot;
|
|
|
|
import eu.univento.core.api.player.CustomPlayer;
|
|
import eu.univento.core.api.schematic.Cuboid;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.Chunk;
|
|
import org.bukkit.Location;
|
|
import org.bukkit.WeatherType;
|
|
import org.bukkit.block.Biome;
|
|
import org.bukkit.block.Block;
|
|
import org.bukkit.entity.LivingEntity;
|
|
|
|
import java.util.UUID;
|
|
|
|
/**
|
|
* @author joethei
|
|
* @version 1.0
|
|
*/
|
|
|
|
public class Plot {
|
|
|
|
private final Cuboid area;
|
|
private final UUID owner;
|
|
private final Location spawn;
|
|
|
|
public Plot(Cuboid area, UUID owner, Location spawn) {
|
|
this.area = area;
|
|
this.owner = owner;
|
|
this.spawn = spawn;
|
|
}
|
|
|
|
public boolean isInPlot(Location location) {
|
|
return area.containsLocation(location);
|
|
}
|
|
|
|
public boolean isOwner(CustomPlayer p) {
|
|
return p.getUniqueId().equals(owner);
|
|
}
|
|
|
|
public Cuboid getArea() {
|
|
return area;
|
|
}
|
|
|
|
public UUID getOwner() {
|
|
return owner;
|
|
}
|
|
|
|
public Location getSpawn() {
|
|
return spawn;
|
|
}
|
|
|
|
public void setBiome(Biome biome) {
|
|
setInDatabase("biome", biome.name());
|
|
for(Block blocks : getArea())
|
|
blocks.setBiome(biome);
|
|
for(Chunk chunk : Bukkit.getWorld("plots").getLoadedChunks())
|
|
Bukkit.getWorld("plots").refreshChunk(chunk.getX(), chunk.getZ());
|
|
for(LivingEntity entity : Bukkit.getWorld("plots").getLivingEntities())
|
|
entity.teleport(entity);
|
|
}
|
|
|
|
public Biome getBiome() {
|
|
return Biome.valueOf(getStringFromDatabase("biome"));
|
|
}
|
|
|
|
public String getName() {
|
|
return getStringFromDatabase("name");
|
|
}
|
|
|
|
public void setName(String name) {
|
|
setInDatabase("name", name);
|
|
}
|
|
|
|
public boolean hasName() {
|
|
return !getName().equals("");
|
|
}
|
|
|
|
public void setTime(Time time) {
|
|
setInDatabase("time", time.name());
|
|
}
|
|
|
|
public Time getTime() {
|
|
return Time.valueOf(getStringFromDatabase("time"));
|
|
}
|
|
|
|
public void setWeather(Weather weather) {
|
|
setInDatabase("weather", weather.name());
|
|
}
|
|
|
|
public Weather getWeather() {
|
|
return Weather.valueOf(getStringFromDatabase("weather"));
|
|
}
|
|
|
|
public void setContact(String contact) {
|
|
setInDatabase("contact", contact);
|
|
}
|
|
|
|
public String getContact() {
|
|
return getStringFromDatabase("contact");
|
|
}
|
|
|
|
public boolean hasContact() {
|
|
return !getContact().equals("");
|
|
}
|
|
|
|
public void setReady() {
|
|
setInDatabase("ready", true);
|
|
}
|
|
|
|
public boolean isReady() {
|
|
return (boolean) getObjectFromDatbase("ready");
|
|
}
|
|
|
|
public WeatherType getWeatherType() {
|
|
if(getWeather() == Weather.THUNDER) return WeatherType.DOWNFALL;
|
|
return WeatherType.valueOf(getWeather().name());
|
|
}
|
|
|
|
private Object getObjectFromDatbase(String name) {
|
|
return null;
|
|
}
|
|
|
|
private String getStringFromDatabase(String name) {
|
|
return "";
|
|
}
|
|
|
|
private void setInDatabase(String name, Object obj) {
|
|
|
|
}
|
|
} |