mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-17 22:00:08 +00:00
bukkit pass 2
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package com.dfsek.terra.bukkit;
|
||||
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class BukkitEntity implements Entity {
|
||||
private final org.bukkit.entity.Entity entity;
|
||||
@@ -18,17 +20,24 @@ public class BukkitEntity implements Entity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocationImpl getLocation() {
|
||||
return BukkitAdapter.adapt(entity.getLocation());
|
||||
public Vector3 position() {
|
||||
return BukkitAdapter.adapt(entity.getLocation().toVector());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(LocationImpl location) {
|
||||
entity.teleport(BukkitAdapter.adapt(location));
|
||||
public void position(Vector3 location) {
|
||||
entity.teleport(BukkitAdapter.adapt(location).toLocation(entity.getWorld()));
|
||||
}
|
||||
|
||||
@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());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.dfsek.terra.bukkit;
|
||||
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.entity.Player;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
import com.dfsek.terra.vector.Vector3Impl;
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class BukkitPlayer implements Player {
|
||||
private final org.bukkit.entity.Player delegate;
|
||||
@@ -18,18 +21,25 @@ public class BukkitPlayer implements Player {
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocationImpl getLocation() {
|
||||
public Vector3 position() {
|
||||
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
|
||||
public void setLocation(LocationImpl location) {
|
||||
delegate.teleport(BukkitAdapter.adapt(location));
|
||||
public void position(Vector3 location) {
|
||||
delegate.teleport(BukkitAdapter.adapt(location).toLocation(delegate.getWorld()));
|
||||
}
|
||||
|
||||
@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());
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@ import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.handle.ItemHandle;
|
||||
import com.dfsek.terra.api.handle.WorldHandle;
|
||||
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.biome.Biome;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
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.JavaLogger;
|
||||
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.api.profiler.Profiler;
|
||||
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.ConfigRegistry;
|
||||
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 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 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 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<>();
|
||||
worldMap.forEach((world, tw) -> {
|
||||
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));
|
||||
});
|
||||
worldMap.clear();
|
||||
@@ -306,7 +308,7 @@ public class TerraBukkitPlugin extends JavaPlugin implements TerraPlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public LockedRegistry<TerraAddon> getAddons() {
|
||||
public Registry<TerraAddon> getAddons() {
|
||||
return addonLockedRegistry;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,6 @@ public class FixChunkCommand implements CommandTemplate {
|
||||
@Override
|
||||
public void execute(CommandSender 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
|
||||
public boolean isParallelCapable() {
|
||||
return delegate.isParallelCapable();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldGenerateCaves() {
|
||||
return delegate.shouldGenerateCaves();
|
||||
return delegate.getConfigPack().vanillaCaves();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldGenerateDecorations() {
|
||||
return delegate.shouldGenerateDecorations();
|
||||
return delegate.getConfigPack().vanillaFlora();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldGenerateMobs() {
|
||||
return delegate.shouldGenerateMobs();
|
||||
return delegate.getConfigPack().vanillaMobs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldGenerateStructures() {
|
||||
return delegate.shouldGenerateStructures();
|
||||
return delegate.getConfigPack().vanillaStructures();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.dfsek.terra.bukkit.handles;
|
||||
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
import com.dfsek.terra.api.entity.EntityType;
|
||||
@@ -26,7 +27,7 @@ public class BukkitWorldHandle implements WorldHandle {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<LocationImpl, LocationImpl> getSelectedLocation(Player player) {
|
||||
public Pair<Location, Location> getSelectedLocation(Player player) {
|
||||
org.bukkit.Location[] locations = WorldEditUtil.getSelectionLocations(BukkitAdapter.adapt(player));
|
||||
return Pair.of(BukkitAdapter.adapt(locations[0]), BukkitAdapter.adapt(locations[1]));
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.dfsek.terra.bukkit.listeners;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.config.WorldConfig;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.api.world.Tree;
|
||||
@@ -46,8 +47,8 @@ public class CommonListener implements Listener {
|
||||
World bukkit = BukkitAdapter.adapt(e.getWorld());
|
||||
if(!bukkit.isTerraWorld()) return;
|
||||
TerraWorld tw = main.getWorld(bukkit);
|
||||
WorldConfigImpl c = tw.getConfig();
|
||||
if(c.getTemplate().isDisableSaplings()) return;
|
||||
WorldConfig c = tw.getConfig();
|
||||
if(c.isDisableSaplings()) return;
|
||||
e.setCancelled(true);
|
||||
Block block = e.getLocation().getBlock();
|
||||
BlockData data = block.getBlockData();
|
||||
|
||||
@@ -22,7 +22,7 @@ public class PaperListener implements Listener {
|
||||
String name = "minecraft:" + e.getType().getName();
|
||||
main.getDebugLogger().info("Overriding structure location for \"" + name + "\"");
|
||||
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) {
|
||||
AsyncStructureFinder finder = new AsyncStructureFinder(tw.getBiomeProvider(), config, BukkitAdapter.adapt(e.getOrigin()), 0, 500, location -> {
|
||||
if(location != null)
|
||||
|
||||
@@ -37,7 +37,7 @@ public class SpigotListener implements Listener {
|
||||
if(!BukkitAdapter.adapt(e.getEntity().getWorld()).isTerraWorld()) return;
|
||||
TerraWorld tw = main.getWorld(BukkitAdapter.adapt(e.getEntity().getWorld()));
|
||||
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) {
|
||||
main.getDebugLogger().info("Overriding Ender Signal...");
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.dfsek.terra.bukkit.world;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.world.Tree;
|
||||
@@ -43,7 +44,7 @@ public class BukkitTree implements Tree {
|
||||
|
||||
@Override
|
||||
@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))) {
|
||||
return ((BukkitWorld) l.getWorld()).getHandle().generateTree(BukkitAdapter.adapt(l), delegate);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.dfsek.terra.bukkit.world;
|
||||
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
import com.dfsek.terra.api.entity.Entity;
|
||||
@@ -64,7 +65,7 @@ public class BukkitWorld implements World {
|
||||
}
|
||||
|
||||
@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()));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user