mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-04 00:45:57 +00:00
bukkit pass 2
This commit is contained in:
parent
2906a4f891
commit
918ff28ed4
@ -38,4 +38,6 @@ public interface ConfigPack extends LoaderRegistrar {
|
|||||||
Map<String, String> getLocatable();
|
Map<String, String> getLocatable();
|
||||||
|
|
||||||
boolean doBetaCarvers();
|
boolean doBetaCarvers();
|
||||||
|
|
||||||
|
boolean vanillaFlora();
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package com.dfsek.terra.api.config;
|
package com.dfsek.terra.api.config;
|
||||||
|
|
||||||
import com.dfsek.terra.api.registry.Registry;
|
import com.dfsek.terra.api.registry.Registry;
|
||||||
|
import com.dfsek.terra.api.util.ProbabilityCollection;
|
||||||
import com.dfsek.terra.api.world.TerraWorld;
|
import com.dfsek.terra.api.world.TerraWorld;
|
||||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||||
import com.dfsek.terra.api.world.generator.SamplerCache;
|
import com.dfsek.terra.api.world.generator.SamplerCache;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public interface WorldConfig {
|
public interface WorldConfig {
|
||||||
@ -34,4 +36,8 @@ public interface WorldConfig {
|
|||||||
String getAuthor();
|
String getAuthor();
|
||||||
|
|
||||||
String getVersion();
|
String getVersion();
|
||||||
|
|
||||||
|
Map<String, String> getLocatable();
|
||||||
|
|
||||||
|
boolean isDisableSaplings();
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,15 @@ package com.dfsek.terra.api.entity;
|
|||||||
|
|
||||||
import com.dfsek.terra.api.vector.Location;
|
import com.dfsek.terra.api.vector.Location;
|
||||||
import com.dfsek.terra.api.Handle;
|
import com.dfsek.terra.api.Handle;
|
||||||
|
import com.dfsek.terra.api.vector.Vector3;
|
||||||
import com.dfsek.terra.api.world.World;
|
import com.dfsek.terra.api.world.World;
|
||||||
|
|
||||||
public interface Entity extends Handle, CommandSender {
|
public interface Entity extends Handle, CommandSender {
|
||||||
Location getLocation();
|
Vector3 position();
|
||||||
|
|
||||||
void setLocation(Location location);
|
void position(Vector3 position);
|
||||||
|
|
||||||
World getWorld();
|
void world(World world);
|
||||||
|
|
||||||
|
World world();
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import com.dfsek.terra.api.config.ConfigPack;
|
|||||||
import com.dfsek.terra.api.event.events.PackEvent;
|
import com.dfsek.terra.api.event.events.PackEvent;
|
||||||
import com.dfsek.terra.api.entity.Entity;
|
import com.dfsek.terra.api.entity.Entity;
|
||||||
import com.dfsek.terra.api.vector.Location;
|
import com.dfsek.terra.api.vector.Location;
|
||||||
|
import com.dfsek.terra.api.vector.Vector3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when an entity is spawned.
|
* Called when an entity is spawned.
|
||||||
@ -11,12 +12,10 @@ import com.dfsek.terra.api.vector.Location;
|
|||||||
public class EntitySpawnEvent implements PackEvent {
|
public class EntitySpawnEvent implements PackEvent {
|
||||||
private final ConfigPack pack;
|
private final ConfigPack pack;
|
||||||
private final Entity entity;
|
private final Entity entity;
|
||||||
private final Location location;
|
|
||||||
|
|
||||||
public EntitySpawnEvent(ConfigPack pack, Entity entity, Location location) {
|
public EntitySpawnEvent(ConfigPack pack, Entity entity) {
|
||||||
this.pack = pack;
|
this.pack = pack;
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
this.location = location;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -32,13 +31,4 @@ public class EntitySpawnEvent implements PackEvent {
|
|||||||
public Entity getEntity() {
|
public Entity getEntity() {
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the location of the entity.
|
|
||||||
*
|
|
||||||
* @return Location of the entity.
|
|
||||||
*/
|
|
||||||
public Location getLocation() {
|
|
||||||
return location;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ public class TerraCommandManager implements CommandManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(commandClass.isAnnotationPresent(WorldCommand.class) && (!(sender instanceof Player) || !(((Player) sender).getWorld()).isTerraWorld())) {
|
if(commandClass.isAnnotationPresent(WorldCommand.class) && (!(sender instanceof Player) || !(((Player) sender).world()).isTerraWorld())) {
|
||||||
sender.sendMessage("Command must be executed in a Terra world.");
|
sender.sendMessage("Command must be executed in a Terra world.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import com.dfsek.terra.api.TerraPlugin;
|
|||||||
import com.dfsek.terra.api.event.events.world.generation.EntitySpawnEvent;
|
import com.dfsek.terra.api.event.events.world.generation.EntitySpawnEvent;
|
||||||
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
import com.dfsek.terra.api.structure.buffer.BufferedItem;
|
||||||
import com.dfsek.terra.api.vector.Location;
|
import com.dfsek.terra.api.vector.Location;
|
||||||
import com.dfsek.terra.vector.LocationImpl;
|
|
||||||
import com.dfsek.terra.api.entity.Entity;
|
import com.dfsek.terra.api.entity.Entity;
|
||||||
import com.dfsek.terra.api.entity.EntityType;
|
import com.dfsek.terra.api.entity.EntityType;
|
||||||
|
|
||||||
@ -21,6 +20,6 @@ public class BufferedEntity implements BufferedItem {
|
|||||||
@Override
|
@Override
|
||||||
public void paste(Location origin) {
|
public void paste(Location origin) {
|
||||||
Entity entity = origin.clone().add(0.5, 0, 0.5).getWorld().spawnEntity(origin, type);
|
Entity entity = origin.clone().add(0.5, 0, 0.5).getWorld().spawnEntity(origin, type);
|
||||||
main.getEventManager().callEvent(new EntitySpawnEvent(entity.getWorld().getTerraGenerator().getConfigPack(), entity, entity.getLocation()));
|
main.getEventManager().callEvent(new EntitySpawnEvent(entity.world().getTerraGenerator().getConfigPack(), entity));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,6 @@ public class GetBlockCommand implements CommandTemplate {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender) {
|
public void execute(CommandSender sender) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
sender.sendMessage("Block: " + main.getWorld(player.getWorld()).getUngeneratedBlock(player.getLocation()).getAsString());
|
sender.sendMessage("Block: " + main.getWorld(player.world()).getUngeneratedBlock(player.position()).getAsString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,8 @@ public class BiomeCommand implements CommandTemplate {
|
|||||||
public void execute(CommandSender sender) {
|
public void execute(CommandSender sender) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
BiomeProvider provider = main.getWorld(player.getWorld()).getBiomeProvider();
|
BiomeProvider provider = main.getWorld(player.world()).getBiomeProvider();
|
||||||
UserDefinedBiome biome = (UserDefinedBiome) provider.getBiome(player.getLocation());
|
UserDefinedBiome biome = (UserDefinedBiome) provider.getBiome(player.position());
|
||||||
LangUtil.send("command.biome.in", sender, biome.getID());
|
LangUtil.send("command.biome.in", sender, biome.getID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,11 +65,11 @@ public class BiomeLocateCommand implements CommandTemplate {
|
|||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
new Thread(new AsyncBiomeFinder(main.getWorld(player.getWorld()).getBiomeProvider(), biome, player.getLocation().clone().multiply((1D / main.getTerraConfig().getBiomeSearchResolution())), 0, radius, location -> {
|
new Thread(new AsyncBiomeFinder(main.getWorld(player.world()).getBiomeProvider(), biome, player.position().clone().multiply((1D / main.getTerraConfig().getBiomeSearchResolution())).toLocation(player.world()), 0, radius, location -> {
|
||||||
if(location != null) {
|
if(location != null) {
|
||||||
sender.sendMessage(String.format("The nearest %s is at [%d, ~, %d] (%.1f blocks away)", biome.getID().toLowerCase(Locale.ROOT), location.getBlockX(), location.getBlockZ(), location.add(new Vector3Impl(0, player.getLocation().getY(), 0)).distance(player.getLocation().toVector())));
|
sender.sendMessage(String.format("The nearest %s is at [%d, ~, %d] (%.1f blocks away)", biome.getID().toLowerCase(Locale.ROOT), location.getBlockX(), location.getBlockZ(), location.add(new Vector3Impl(0, player.position().getY(), 0)).distance(player.position())));
|
||||||
if(teleport) {
|
if(teleport) {
|
||||||
main.runPossiblyUnsafeTask(() -> player.setLocation(new LocationImpl(player.getWorld(), location.getX(), player.getLocation().getY(), location.getZ())));
|
main.runPossiblyUnsafeTask(() -> player.position(new Vector3Impl(location.getX(), player.position().getY(), location.getZ())));
|
||||||
}
|
}
|
||||||
} else LangUtil.send("command.biome.unable-to-locate", sender);
|
} else LangUtil.send("command.biome.unable-to-locate", sender);
|
||||||
}, main), "Biome Location Thread").start();
|
}, main), "Biome Location Thread").start();
|
||||||
|
@ -14,6 +14,6 @@ public class BiomeArgumentParser implements ArgumentParser<TerraBiome> {
|
|||||||
@Override
|
@Override
|
||||||
public TerraBiome parse(CommandSender sender, String arg) {
|
public TerraBiome parse(CommandSender sender, String arg) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
return main.getWorld(player.getWorld()).getConfig().getRegistry(TerraBiome.class).get(arg);
|
return main.getWorld(player.world()).getConfig().getRegistry(TerraBiome.class).get(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,6 @@ public class BiomeTabCompleter implements TabCompleter {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> complete(CommandSender sender) {
|
public List<String> complete(CommandSender sender) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
return main.getWorld(player.getWorld()).getConfig().getRegistry(TerraBiome.class).entries().stream().map(TerraBiome::getID).collect(Collectors.toList());
|
return main.getWorld(player.world()).getConfig().getRegistry(TerraBiome.class).entries().stream().map(TerraBiome::getID).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import com.dfsek.terra.api.command.annotation.type.PlayerCommand;
|
|||||||
import com.dfsek.terra.api.command.annotation.type.WorldCommand;
|
import com.dfsek.terra.api.command.annotation.type.WorldCommand;
|
||||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||||
import com.dfsek.terra.api.vector.Location;
|
import com.dfsek.terra.api.vector.Location;
|
||||||
|
import com.dfsek.terra.api.vector.Vector3;
|
||||||
import com.dfsek.terra.vector.LocationImpl;
|
import com.dfsek.terra.vector.LocationImpl;
|
||||||
import com.dfsek.terra.api.entity.CommandSender;
|
import com.dfsek.terra.api.entity.CommandSender;
|
||||||
import com.dfsek.terra.api.entity.Player;
|
import com.dfsek.terra.api.entity.Player;
|
||||||
@ -34,14 +35,14 @@ public class SpawnCommand implements CommandTemplate {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender) {
|
public void execute(CommandSender sender) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
Location p = player.getLocation();
|
Vector3 p = player.position();
|
||||||
int x = p.getBlockX();
|
int x = p.getBlockX();
|
||||||
int y = p.getBlockY();
|
int y = p.getBlockY();
|
||||||
int z = p.getBlockZ();
|
int z = p.getBlockZ();
|
||||||
Position dummy = new Position(0, 0);
|
Position dummy = new Position(0, 0);
|
||||||
|
|
||||||
String check = new CheckFunction(main, new NumericConstant(0, dummy), new NumericConstant(0, dummy), new NumericConstant(0, dummy), dummy).apply(new TerraImplementationArguments(new StructureBuffer(
|
String check = new CheckFunction(main, new NumericConstant(0, dummy), new NumericConstant(0, dummy), new NumericConstant(0, dummy), dummy).apply(new TerraImplementationArguments(new StructureBuffer(
|
||||||
new LocationImpl(player.getWorld(), x, y, z)
|
new LocationImpl(player.world(), x, y, z)
|
||||||
), Rotation.NONE, new FastRandom(), 0), new HashMap<>());
|
), Rotation.NONE, new FastRandom(), 0), new HashMap<>());
|
||||||
|
|
||||||
sender.sendMessage("Found: " + check);
|
sender.sendMessage("Found: " + check);
|
||||||
|
@ -79,9 +79,9 @@ public class StructureLoadCommand implements CommandTemplate {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(this.chunk) {
|
if(this.chunk) {
|
||||||
script.generate(player.getLocation(), player.getWorld().getChunkAt(player.getLocation()), random, r);
|
script.generate(player.position().toLocation(player.world()), player.world().getChunkAt(player.position().toLocation(player.world())), random, r);
|
||||||
} else {
|
} else {
|
||||||
script.generate(player.getLocation(), random, r);
|
script.generate(player.position().toLocation(player.world()), random, r);
|
||||||
}
|
}
|
||||||
long l = System.nanoTime() - t;
|
long l = System.nanoTime() - t;
|
||||||
|
|
||||||
|
@ -63,11 +63,11 @@ public class StructureLocateCommand implements CommandTemplate {
|
|||||||
public void execute(CommandSender sender) {
|
public void execute(CommandSender sender) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
new Thread(new AsyncStructureFinder(main.getWorld(player.getWorld()).getBiomeProvider(), structure, player.getLocation().clone().multiply((1D / main.getTerraConfig().getBiomeSearchResolution())), 0, radius, location -> {
|
new Thread(new AsyncStructureFinder(main.getWorld(player.world()).getBiomeProvider(), structure, player.position().clone().multiply((1D / main.getTerraConfig().getBiomeSearchResolution())).toLocation(player.world()), 0, radius, location -> {
|
||||||
if(location != null) {
|
if(location != null) {
|
||||||
sender.sendMessage(String.format("The nearest %s is at [%d, ~, %d] (%.1f blocks away)", structure.getTemplate().getID().toLowerCase(Locale.ROOT), location.getBlockX(), location.getBlockZ(), location.add(new Vector3Impl(0, player.getLocation().getY(), 0)).distance(player.getLocation().toVector())));
|
sender.sendMessage(String.format("The nearest %s is at [%d, ~, %d] (%.1f blocks away)", structure.getTemplate().getID().toLowerCase(Locale.ROOT), location.getBlockX(), location.getBlockZ(), location.add(new Vector3Impl(0, player.position().getY(), 0)).distance(player.position())));
|
||||||
if(teleport) {
|
if(teleport) {
|
||||||
main.runPossiblyUnsafeTask(() -> player.setLocation(new LocationImpl(player.getWorld(), location.getX(), player.getLocation().getY(), location.getZ())));
|
main.runPossiblyUnsafeTask(() -> player.position(new Vector3Impl(location.getX(), player.position().getY(), location.getZ())));
|
||||||
}
|
}
|
||||||
} else LangUtil.send("command.biome.unable-to-locate", sender);
|
} else LangUtil.send("command.biome.unable-to-locate", sender);
|
||||||
}, main), "Biome Location Thread").start();
|
}, main), "Biome Location Thread").start();
|
||||||
|
@ -14,6 +14,6 @@ public class ScriptArgumentParser implements ArgumentParser<Structure> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Structure parse(CommandSender sender, String arg) {
|
public Structure parse(CommandSender sender, String arg) {
|
||||||
return main.getWorld(((Player) sender).getWorld()).getConfig().getRegistry(StructureScript.class).get(arg);
|
return main.getWorld(((Player) sender).world()).getConfig().getRegistry(StructureScript.class).get(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,6 @@ public class StructureArgumentParser implements ArgumentParser<TerraStructure> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TerraStructure parse(CommandSender sender, String arg) {
|
public TerraStructure parse(CommandSender sender, String arg) {
|
||||||
return main.getWorld(((Player) sender).getWorld()).getConfig().getRegistry(TerraStructure.class).get(arg);
|
return main.getWorld(((Player) sender).world()).getConfig().getRegistry(TerraStructure.class).get(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,6 @@ public class ScriptCompleter implements TabCompleter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> complete(CommandSender sender) {
|
public List<String> complete(CommandSender sender) {
|
||||||
return main.getWorld(((Player) sender).getWorld()).getConfig().getRegistry(StructureScript.class).entries().stream().map(Structure::getId).collect(Collectors.toList());
|
return main.getWorld(((Player) sender).world()).getConfig().getRegistry(StructureScript.class).entries().stream().map(Structure::getId).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,6 @@ public class StructureCompleter implements TabCompleter {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> complete(CommandSender sender) {
|
public List<String> complete(CommandSender sender) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
return new ArrayList<>(main.getWorld(player.getWorld()).getConfig().getRegistry(TerraStructure.class).keys());
|
return new ArrayList<>(main.getWorld(player.world()).getConfig().getRegistry(TerraStructure.class).keys());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -368,4 +368,9 @@ public class ConfigPackImpl implements ConfigPack {
|
|||||||
public boolean doBetaCarvers() {
|
public boolean doBetaCarvers() {
|
||||||
return template.doBetaCarvers();
|
return template.doBetaCarvers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean vanillaFlora() {
|
||||||
|
return template.vanillaDecorations();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,6 +109,16 @@ public class WorldConfigImpl implements WorldConfig {
|
|||||||
return pack.getVersion();
|
return pack.getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getLocatable() {
|
||||||
|
return pack.getLocatable();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDisableSaplings() {
|
||||||
|
return getTemplate().isDisableSaplings();
|
||||||
|
}
|
||||||
|
|
||||||
public Set<TerraStructure> getStructures() {
|
public Set<TerraStructure> getStructures() {
|
||||||
return new HashSet<>(getRegistry(TerraStructure.class).entries());
|
return new HashSet<>(getRegistry(TerraStructure.class).entries());
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package com.dfsek.terra.bukkit;
|
package com.dfsek.terra.bukkit;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.vector.Vector3;
|
||||||
import com.dfsek.terra.vector.LocationImpl;
|
import com.dfsek.terra.vector.LocationImpl;
|
||||||
import com.dfsek.terra.api.entity.Entity;
|
import com.dfsek.terra.api.entity.Entity;
|
||||||
import com.dfsek.terra.api.world.World;
|
import com.dfsek.terra.api.world.World;
|
||||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
public class BukkitEntity implements Entity {
|
public class BukkitEntity implements Entity {
|
||||||
private final org.bukkit.entity.Entity entity;
|
private final org.bukkit.entity.Entity entity;
|
||||||
@ -18,17 +20,24 @@ public class BukkitEntity implements Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LocationImpl getLocation() {
|
public Vector3 position() {
|
||||||
return BukkitAdapter.adapt(entity.getLocation());
|
return BukkitAdapter.adapt(entity.getLocation().toVector());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLocation(LocationImpl location) {
|
public void position(Vector3 location) {
|
||||||
entity.teleport(BukkitAdapter.adapt(location));
|
entity.teleport(BukkitAdapter.adapt(location).toLocation(entity.getWorld()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public World getWorld() {
|
public void world(World world) {
|
||||||
|
Location newLoc = entity.getLocation().clone();
|
||||||
|
newLoc.setWorld(BukkitAdapter.adapt(world));
|
||||||
|
entity.teleport(newLoc);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public World world() {
|
||||||
return BukkitAdapter.adapt(entity.getWorld());
|
return BukkitAdapter.adapt(entity.getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package com.dfsek.terra.bukkit;
|
package com.dfsek.terra.bukkit;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.vector.Vector3;
|
||||||
import com.dfsek.terra.vector.LocationImpl;
|
import com.dfsek.terra.vector.LocationImpl;
|
||||||
import com.dfsek.terra.api.entity.Player;
|
import com.dfsek.terra.api.entity.Player;
|
||||||
import com.dfsek.terra.api.world.World;
|
import com.dfsek.terra.api.world.World;
|
||||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||||
|
import com.dfsek.terra.vector.Vector3Impl;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
public class BukkitPlayer implements Player {
|
public class BukkitPlayer implements Player {
|
||||||
private final org.bukkit.entity.Player delegate;
|
private final org.bukkit.entity.Player delegate;
|
||||||
@ -18,18 +21,25 @@ public class BukkitPlayer implements Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LocationImpl getLocation() {
|
public Vector3 position() {
|
||||||
org.bukkit.Location bukkit = delegate.getLocation();
|
org.bukkit.Location bukkit = delegate.getLocation();
|
||||||
return new LocationImpl(BukkitAdapter.adapt(bukkit.getWorld()), bukkit.getX(), bukkit.getY(), bukkit.getZ());
|
return new Vector3Impl(bukkit.getX(), bukkit.getY(), bukkit.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLocation(LocationImpl location) {
|
public void position(Vector3 location) {
|
||||||
delegate.teleport(BukkitAdapter.adapt(location));
|
delegate.teleport(BukkitAdapter.adapt(location).toLocation(delegate.getWorld()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public World getWorld() {
|
public void world(World world) {
|
||||||
|
Location newLoc = delegate.getLocation().clone();
|
||||||
|
newLoc.setWorld(BukkitAdapter.adapt(world));
|
||||||
|
delegate.teleport(newLoc);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public World world() {
|
||||||
return BukkitAdapter.adapt(delegate.getWorld());
|
return BukkitAdapter.adapt(delegate.getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,11 +17,11 @@ import com.dfsek.terra.api.block.BlockData;
|
|||||||
import com.dfsek.terra.api.handle.ItemHandle;
|
import com.dfsek.terra.api.handle.ItemHandle;
|
||||||
import com.dfsek.terra.api.handle.WorldHandle;
|
import com.dfsek.terra.api.handle.WorldHandle;
|
||||||
import com.dfsek.terra.api.lang.Language;
|
import com.dfsek.terra.api.lang.Language;
|
||||||
|
import com.dfsek.terra.api.registry.Registry;
|
||||||
import com.dfsek.terra.api.world.TerraWorld;
|
import com.dfsek.terra.api.world.TerraWorld;
|
||||||
import com.dfsek.terra.api.world.biome.Biome;
|
import com.dfsek.terra.api.world.biome.Biome;
|
||||||
import com.dfsek.terra.api.world.World;
|
import com.dfsek.terra.api.world.World;
|
||||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||||
import com.dfsek.terra.api.registry.LockedRegistry;
|
|
||||||
import com.dfsek.terra.api.util.logging.DebugLogger;
|
import com.dfsek.terra.api.util.logging.DebugLogger;
|
||||||
import com.dfsek.terra.api.util.logging.JavaLogger;
|
import com.dfsek.terra.api.util.logging.JavaLogger;
|
||||||
import com.dfsek.terra.api.Logger;
|
import com.dfsek.terra.api.Logger;
|
||||||
@ -45,6 +45,8 @@ import com.dfsek.terra.config.PluginConfigImpl;
|
|||||||
import com.dfsek.terra.config.lang.LangUtil;
|
import com.dfsek.terra.config.lang.LangUtil;
|
||||||
import com.dfsek.terra.api.profiler.Profiler;
|
import com.dfsek.terra.api.profiler.Profiler;
|
||||||
import com.dfsek.terra.profiler.ProfilerImpl;
|
import com.dfsek.terra.profiler.ProfilerImpl;
|
||||||
|
import com.dfsek.terra.registry.CheckedRegistryImpl;
|
||||||
|
import com.dfsek.terra.registry.LockedRegistryImpl;
|
||||||
import com.dfsek.terra.registry.master.AddonRegistry;
|
import com.dfsek.terra.registry.master.AddonRegistry;
|
||||||
import com.dfsek.terra.registry.master.ConfigRegistry;
|
import com.dfsek.terra.registry.master.ConfigRegistry;
|
||||||
import com.dfsek.terra.world.TerraWorldImpl;
|
import com.dfsek.terra.world.TerraWorldImpl;
|
||||||
@ -72,7 +74,7 @@ public class TerraBukkitPlugin extends JavaPlugin implements TerraPlugin {
|
|||||||
private final Profiler profiler = new ProfilerImpl();
|
private final Profiler profiler = new ProfilerImpl();
|
||||||
|
|
||||||
private final ConfigRegistry registry = new ConfigRegistry();
|
private final ConfigRegistry registry = new ConfigRegistry();
|
||||||
private final CheckedRegistry<ConfigPack> checkedRegistry = new CheckedRegistry<>(registry);
|
private final CheckedRegistry<ConfigPack> checkedRegistry = new CheckedRegistryImpl<>(registry);
|
||||||
|
|
||||||
private final PluginConfig config = new PluginConfigImpl();
|
private final PluginConfig config = new PluginConfigImpl();
|
||||||
private final ItemHandle itemHandle = new BukkitItemHandle();
|
private final ItemHandle itemHandle = new BukkitItemHandle();
|
||||||
@ -95,7 +97,7 @@ public class TerraBukkitPlugin extends JavaPlugin implements TerraPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final AddonRegistry addonRegistry = new AddonRegistry(new BukkitAddon(this), this);
|
private final AddonRegistry addonRegistry = new AddonRegistry(new BukkitAddon(this), this);
|
||||||
private final LockedRegistry<TerraAddon> addonLockedRegistry = new LockedRegistry<>(addonRegistry);
|
private final LockedRegistryImpl<TerraAddon> addonLockedRegistry = new LockedRegistryImpl<>(addonRegistry);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -106,7 +108,7 @@ public class TerraBukkitPlugin extends JavaPlugin implements TerraPlugin {
|
|||||||
Map<World, TerraWorld> newMap = new HashMap<>();
|
Map<World, TerraWorld> newMap = new HashMap<>();
|
||||||
worldMap.forEach((world, tw) -> {
|
worldMap.forEach((world, tw) -> {
|
||||||
tw.getConfig().getSamplerCache().clear();
|
tw.getConfig().getSamplerCache().clear();
|
||||||
String packID = tw.getConfig().getTemplate().getID();
|
String packID = tw.getConfig().getID();
|
||||||
newMap.put(world, new TerraWorldImpl(world, registry.get(packID), this));
|
newMap.put(world, new TerraWorldImpl(world, registry.get(packID), this));
|
||||||
});
|
});
|
||||||
worldMap.clear();
|
worldMap.clear();
|
||||||
@ -306,7 +308,7 @@ public class TerraBukkitPlugin extends JavaPlugin implements TerraPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LockedRegistry<TerraAddon> getAddons() {
|
public Registry<TerraAddon> getAddons() {
|
||||||
return addonLockedRegistry;
|
return addonLockedRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,6 @@ public class FixChunkCommand implements CommandTemplate {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender) {
|
public void execute(CommandSender sender) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
BukkitChunkGeneratorWrapper.fixChunk(player.getWorld().getChunkAt(player.getLocation()));
|
BukkitChunkGeneratorWrapper.fixChunk(player.world().getChunkAt(player.position().toLocation(player.world())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,27 +82,27 @@ public class BukkitChunkGeneratorWrapper extends ChunkGenerator implements Gener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isParallelCapable() {
|
public boolean isParallelCapable() {
|
||||||
return delegate.isParallelCapable();
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldGenerateCaves() {
|
public boolean shouldGenerateCaves() {
|
||||||
return delegate.shouldGenerateCaves();
|
return delegate.getConfigPack().vanillaCaves();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldGenerateDecorations() {
|
public boolean shouldGenerateDecorations() {
|
||||||
return delegate.shouldGenerateDecorations();
|
return delegate.getConfigPack().vanillaFlora();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldGenerateMobs() {
|
public boolean shouldGenerateMobs() {
|
||||||
return delegate.shouldGenerateMobs();
|
return delegate.getConfigPack().vanillaMobs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldGenerateStructures() {
|
public boolean shouldGenerateStructures() {
|
||||||
return delegate.shouldGenerateStructures();
|
return delegate.getConfigPack().vanillaStructures();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.dfsek.terra.bukkit.handles;
|
package com.dfsek.terra.bukkit.handles;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.vector.Location;
|
||||||
import com.dfsek.terra.vector.LocationImpl;
|
import com.dfsek.terra.vector.LocationImpl;
|
||||||
import com.dfsek.terra.api.block.BlockData;
|
import com.dfsek.terra.api.block.BlockData;
|
||||||
import com.dfsek.terra.api.entity.EntityType;
|
import com.dfsek.terra.api.entity.EntityType;
|
||||||
@ -26,7 +27,7 @@ public class BukkitWorldHandle implements WorldHandle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Pair<LocationImpl, LocationImpl> getSelectedLocation(Player player) {
|
public Pair<Location, Location> getSelectedLocation(Player player) {
|
||||||
org.bukkit.Location[] locations = WorldEditUtil.getSelectionLocations(BukkitAdapter.adapt(player));
|
org.bukkit.Location[] locations = WorldEditUtil.getSelectionLocations(BukkitAdapter.adapt(player));
|
||||||
return Pair.of(BukkitAdapter.adapt(locations[0]), BukkitAdapter.adapt(locations[1]));
|
return Pair.of(BukkitAdapter.adapt(locations[0]), BukkitAdapter.adapt(locations[1]));
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.dfsek.terra.bukkit.listeners;
|
package com.dfsek.terra.bukkit.listeners;
|
||||||
|
|
||||||
import com.dfsek.terra.api.TerraPlugin;
|
import com.dfsek.terra.api.TerraPlugin;
|
||||||
|
import com.dfsek.terra.api.config.WorldConfig;
|
||||||
import com.dfsek.terra.vector.LocationImpl;
|
import com.dfsek.terra.vector.LocationImpl;
|
||||||
import com.dfsek.terra.api.world.TerraWorld;
|
import com.dfsek.terra.api.world.TerraWorld;
|
||||||
import com.dfsek.terra.api.world.Tree;
|
import com.dfsek.terra.api.world.Tree;
|
||||||
@ -46,8 +47,8 @@ public class CommonListener implements Listener {
|
|||||||
World bukkit = BukkitAdapter.adapt(e.getWorld());
|
World bukkit = BukkitAdapter.adapt(e.getWorld());
|
||||||
if(!bukkit.isTerraWorld()) return;
|
if(!bukkit.isTerraWorld()) return;
|
||||||
TerraWorld tw = main.getWorld(bukkit);
|
TerraWorld tw = main.getWorld(bukkit);
|
||||||
WorldConfigImpl c = tw.getConfig();
|
WorldConfig c = tw.getConfig();
|
||||||
if(c.getTemplate().isDisableSaplings()) return;
|
if(c.isDisableSaplings()) return;
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
Block block = e.getLocation().getBlock();
|
Block block = e.getLocation().getBlock();
|
||||||
BlockData data = block.getBlockData();
|
BlockData data = block.getBlockData();
|
||||||
|
@ -22,7 +22,7 @@ public class PaperListener implements Listener {
|
|||||||
String name = "minecraft:" + e.getType().getName();
|
String name = "minecraft:" + e.getType().getName();
|
||||||
main.getDebugLogger().info("Overriding structure location for \"" + name + "\"");
|
main.getDebugLogger().info("Overriding structure location for \"" + name + "\"");
|
||||||
TerraWorld tw = main.getWorld(BukkitAdapter.adapt(e.getWorld()));
|
TerraWorld tw = main.getWorld(BukkitAdapter.adapt(e.getWorld()));
|
||||||
TerraStructure config = tw.getConfig().getRegistry(TerraStructure.class).get(tw.getConfig().getTemplate().getLocatable().get(name));
|
TerraStructure config = tw.getConfig().getRegistry(TerraStructure.class).get(tw.getConfig().getLocatable().get(name));
|
||||||
if(config != null) {
|
if(config != null) {
|
||||||
AsyncStructureFinder finder = new AsyncStructureFinder(tw.getBiomeProvider(), config, BukkitAdapter.adapt(e.getOrigin()), 0, 500, location -> {
|
AsyncStructureFinder finder = new AsyncStructureFinder(tw.getBiomeProvider(), config, BukkitAdapter.adapt(e.getOrigin()), 0, 500, location -> {
|
||||||
if(location != null)
|
if(location != null)
|
||||||
|
@ -37,7 +37,7 @@ public class SpigotListener implements Listener {
|
|||||||
if(!BukkitAdapter.adapt(e.getEntity().getWorld()).isTerraWorld()) return;
|
if(!BukkitAdapter.adapt(e.getEntity().getWorld()).isTerraWorld()) return;
|
||||||
TerraWorld tw = main.getWorld(BukkitAdapter.adapt(e.getEntity().getWorld()));
|
TerraWorld tw = main.getWorld(BukkitAdapter.adapt(e.getEntity().getWorld()));
|
||||||
EnderSignal signal = (EnderSignal) entity;
|
EnderSignal signal = (EnderSignal) entity;
|
||||||
TerraStructure config = tw.getConfig().getRegistry(TerraStructure.class).get(tw.getConfig().getTemplate().getLocatable().get("STRONGHOLD"));
|
TerraStructure config = tw.getConfig().getRegistry(TerraStructure.class).get(tw.getConfig().getLocatable().get("STRONGHOLD"));
|
||||||
if(config != null) {
|
if(config != null) {
|
||||||
main.getDebugLogger().info("Overriding Ender Signal...");
|
main.getDebugLogger().info("Overriding Ender Signal...");
|
||||||
AsyncStructureFinder finder = new AsyncStructureFinder(tw.getBiomeProvider(), config, BukkitAdapter.adapt(e.getLocation()), 0, 500, location -> {
|
AsyncStructureFinder finder = new AsyncStructureFinder(tw.getBiomeProvider(), config, BukkitAdapter.adapt(e.getLocation()), 0, 500, location -> {
|
||||||
|
@ -338,7 +338,7 @@ public final class BukkitAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Location adapt(LocationImpl location) {
|
public static Location adapt(com.dfsek.terra.api.vector.Location location) {
|
||||||
return new Location(((BukkitWorld) location.getWorld()).getHandle(), location.getX(), location.getY(), location.getZ());
|
return new Location(((BukkitWorld) location.getWorld()).getHandle(), location.getX(), location.getY(), location.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.dfsek.terra.bukkit.world;
|
package com.dfsek.terra.bukkit.world;
|
||||||
|
|
||||||
import com.dfsek.terra.api.TerraPlugin;
|
import com.dfsek.terra.api.TerraPlugin;
|
||||||
|
import com.dfsek.terra.api.vector.Location;
|
||||||
import com.dfsek.terra.vector.LocationImpl;
|
import com.dfsek.terra.vector.LocationImpl;
|
||||||
import com.dfsek.terra.api.handle.WorldHandle;
|
import com.dfsek.terra.api.handle.WorldHandle;
|
||||||
import com.dfsek.terra.api.world.Tree;
|
import com.dfsek.terra.api.world.Tree;
|
||||||
@ -43,7 +44,7 @@ public class BukkitTree implements Tree {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("try")
|
@SuppressWarnings("try")
|
||||||
public boolean plant(LocationImpl l, Random r) {
|
public boolean plant(Location l, Random r) {
|
||||||
try(ProfileFrame ignore = main.getProfiler().profile("bukkit_tree:" + delegate.toString().toLowerCase(Locale.ROOT))) {
|
try(ProfileFrame ignore = main.getProfiler().profile("bukkit_tree:" + delegate.toString().toLowerCase(Locale.ROOT))) {
|
||||||
return ((BukkitWorld) l.getWorld()).getHandle().generateTree(BukkitAdapter.adapt(l), delegate);
|
return ((BukkitWorld) l.getWorld()).getHandle().generateTree(BukkitAdapter.adapt(l), delegate);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.dfsek.terra.bukkit.world;
|
package com.dfsek.terra.bukkit.world;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.vector.Location;
|
||||||
import com.dfsek.terra.vector.LocationImpl;
|
import com.dfsek.terra.vector.LocationImpl;
|
||||||
import com.dfsek.terra.api.block.Block;
|
import com.dfsek.terra.api.block.Block;
|
||||||
import com.dfsek.terra.api.entity.Entity;
|
import com.dfsek.terra.api.entity.Entity;
|
||||||
@ -64,7 +65,7 @@ public class BukkitWorld implements World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Entity spawnEntity(LocationImpl location, EntityType entityType) {
|
public Entity spawnEntity(Location location, EntityType entityType) {
|
||||||
return new BukkitEntity(delegate.spawnEntity(BukkitAdapter.adapt(location), ((BukkitEntityType) entityType).getHandle()));
|
return new BukkitEntity(delegate.spawnEntity(BukkitAdapter.adapt(location), ((BukkitEntityType) entityType).getHandle()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
|
|||||||
public static final Codec<ConfigPack> PACK_CODEC = RecordCodecBuilder.create(
|
public static final Codec<ConfigPack> PACK_CODEC = RecordCodecBuilder.create(
|
||||||
config -> config.group(
|
config -> config.group(
|
||||||
Codec.STRING.fieldOf("pack")
|
Codec.STRING.fieldOf("pack")
|
||||||
.forGetter(pack -> pack.getID())
|
.forGetter(ConfigPack::getID)
|
||||||
).apply(config, config.stable(TerraFabricPlugin.getInstance().getConfigRegistry()::get)));
|
).apply(config, config.stable(TerraFabricPlugin.getInstance().getConfigRegistry()::get)));
|
||||||
|
|
||||||
public static final Codec<FabricChunkGeneratorWrapper> CODEC = RecordCodecBuilder.create(
|
public static final Codec<FabricChunkGeneratorWrapper> CODEC = RecordCodecBuilder.create(
|
||||||
|
@ -17,11 +17,11 @@ public final class WorldEditUtil {
|
|||||||
try {
|
try {
|
||||||
Region selection = worldEdit.getSessionManager()
|
Region selection = worldEdit.getSessionManager()
|
||||||
.get(com.sk89q.worldedit.fabric.FabricAdapter.adaptPlayer((ServerPlayerEntity) player))
|
.get(com.sk89q.worldedit.fabric.FabricAdapter.adaptPlayer((ServerPlayerEntity) player))
|
||||||
.getSelection(com.sk89q.worldedit.fabric.FabricAdapter.adapt((World) player.getWorld()));
|
.getSelection(com.sk89q.worldedit.fabric.FabricAdapter.adapt((World) player.world()));
|
||||||
BlockVector3 min = selection.getMinimumPoint();
|
BlockVector3 min = selection.getMinimumPoint();
|
||||||
BlockVector3 max = selection.getMaximumPoint();
|
BlockVector3 max = selection.getMaximumPoint();
|
||||||
LocationImpl l1 = new LocationImpl(player.getWorld(), min.getBlockX(), min.getBlockY(), min.getBlockZ());
|
LocationImpl l1 = new LocationImpl(player.world(), min.getBlockX(), min.getBlockY(), min.getBlockZ());
|
||||||
LocationImpl l2 = new LocationImpl(player.getWorld(), max.getBlockX(), max.getBlockY(), max.getBlockZ());
|
LocationImpl l2 = new LocationImpl(player.world(), max.getBlockX(), max.getBlockY(), max.getBlockZ());
|
||||||
return Pair.of(l1, l2);
|
return Pair.of(l1, l2);
|
||||||
} catch(IncompleteRegionException e) {
|
} catch(IncompleteRegionException e) {
|
||||||
throw new IllegalStateException("No selection has been made", e);
|
throw new IllegalStateException("No selection has been made", e);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user