location garbage

This commit is contained in:
dfsek
2021-06-23 12:03:17 -07:00
parent e34e2dd0b2
commit 686680d731
70 changed files with 488 additions and 341 deletions
@@ -1,6 +1,6 @@
package com.dfsek.terra.bukkit;
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.world.World;
import com.dfsek.terra.bukkit.world.BukkitAdapter;
@@ -18,12 +18,12 @@ public class BukkitEntity implements Entity {
}
@Override
public Location getLocation() {
public LocationImpl getLocation() {
return BukkitAdapter.adapt(entity.getLocation());
}
@Override
public void setLocation(Location location) {
public void setLocation(LocationImpl location) {
entity.teleport(BukkitAdapter.adapt(location));
}
@@ -1,6 +1,6 @@
package com.dfsek.terra.bukkit;
import com.dfsek.terra.api.vector.Location;
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;
@@ -18,13 +18,13 @@ public class BukkitPlayer implements Player {
}
@Override
public Location getLocation() {
public LocationImpl getLocation() {
org.bukkit.Location bukkit = delegate.getLocation();
return new Location(BukkitAdapter.adapt(bukkit.getWorld()), bukkit.getX(), bukkit.getY(), bukkit.getZ());
return new LocationImpl(BukkitAdapter.adapt(bukkit.getWorld()), bukkit.getX(), bukkit.getY(), bukkit.getZ());
}
@Override
public void setLocation(Location location) {
public void setLocation(LocationImpl location) {
delegate.teleport(BukkitAdapter.adapt(location));
}
@@ -15,6 +15,7 @@ import com.dfsek.terra.api.event.EventManagerImpl;
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.world.TerraWorld;
import com.dfsek.terra.api.world.biome.Biome;
import com.dfsek.terra.api.world.World;
import com.dfsek.terra.api.registry.CheckedRegistry;
@@ -45,7 +46,7 @@ import com.dfsek.terra.api.profiler.Profiler;
import com.dfsek.terra.profiler.ProfilerImpl;
import com.dfsek.terra.registry.master.AddonRegistry;
import com.dfsek.terra.registry.master.ConfigRegistry;
import com.dfsek.terra.world.TerraWorld;
import com.dfsek.terra.world.TerraWorldImpl;
import com.dfsek.terra.world.generation.generators.DefaultChunkGenerator3D;
import io.papermc.lib.PaperLib;
import org.bstats.bukkit.Metrics;
@@ -105,7 +106,7 @@ public class TerraBukkitPlugin extends JavaPlugin implements TerraPlugin {
worldMap.forEach((world, tw) -> {
tw.getConfig().getSamplerCache().clear();
String packID = tw.getConfig().getTemplate().getID();
newMap.put(world, new TerraWorld(world, registry.get(packID), this));
newMap.put(world, new TerraWorldImpl(world, registry.get(packID), this));
});
worldMap.clear();
worldMap.putAll(newMap);
@@ -272,9 +273,9 @@ public class TerraBukkitPlugin extends JavaPlugin implements TerraPlugin {
throw new IllegalArgumentException("Not a Terra world! " + w.getGenerator());
if(!worlds.containsKey(w.getName())) {
getLogger().warning("Unexpected world load detected: \"" + w.getName() + "\"");
return new TerraWorld(w, ((TerraChunkGenerator) w.getGenerator().getHandle()).getConfigPack(), this);
return new TerraWorldImpl(w, ((TerraChunkGenerator) w.getGenerator().getHandle()).getConfigPack(), this);
}
return worldMap.computeIfAbsent(w, w2 -> new TerraWorld(w, worlds.get(w.getName()), this));
return worldMap.computeIfAbsent(w, w2 -> new TerraWorldImpl(w, worlds.get(w.getName()), this));
}
@Override
@@ -1,6 +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;
import com.dfsek.terra.api.entity.Player;
@@ -26,7 +26,7 @@ public class BukkitWorldHandle implements WorldHandle {
}
@Override
public Pair<Location, Location> getSelectedLocation(Player player) {
public Pair<LocationImpl, LocationImpl> getSelectedLocation(Player player) {
org.bukkit.Location[] locations = WorldEditUtil.getSelectionLocations(BukkitAdapter.adapt(player));
return Pair.of(BukkitAdapter.adapt(locations[0]), BukkitAdapter.adapt(locations[1]));
}
@@ -1,15 +1,15 @@
package com.dfsek.terra.bukkit.listeners;
import com.dfsek.terra.api.TerraPlugin;
import com.dfsek.terra.api.vector.Location;
import com.dfsek.terra.vector.LocationImpl;
import com.dfsek.terra.api.world.TerraWorld;
import com.dfsek.terra.api.world.Tree;
import com.dfsek.terra.api.world.World;
import com.dfsek.terra.api.transform.MapTransform;
import com.dfsek.terra.api.transform.TransformerImpl;
import com.dfsek.terra.api.util.FastRandom;
import com.dfsek.terra.bukkit.world.BukkitAdapter;
import com.dfsek.terra.config.pack.WorldConfig;
import com.dfsek.terra.world.TerraWorld;
import com.dfsek.terra.config.pack.WorldConfigImpl;
import org.bukkit.Material;
import org.bukkit.TreeType;
import org.bukkit.block.Block;
@@ -46,7 +46,7 @@ public class CommonListener implements Listener {
World bukkit = BukkitAdapter.adapt(e.getWorld());
if(!bukkit.isTerraWorld()) return;
TerraWorld tw = main.getWorld(bukkit);
WorldConfig c = tw.getConfig();
WorldConfigImpl c = tw.getConfig();
if(c.getTemplate().isDisableSaplings()) return;
e.setCancelled(true);
Block block = e.getLocation().getBlock();
@@ -54,6 +54,6 @@ public class CommonListener implements Listener {
block.setType(Material.AIR);
Tree tree = c.getRegistry(Tree.class).get(TREE_TYPE_STRING_TRANSFORMER.translate(e.getSpecies()));
org.bukkit.Location location = e.getLocation();
if(!tree.plant(new Location(bukkit, location.getX(), location.getY(), location.getZ()), new FastRandom())) block.setBlockData(data);
if(!tree.plant(new LocationImpl(bukkit, location.getX(), location.getY(), location.getZ()), new FastRandom())) block.setBlockData(data);
}
}
@@ -1,9 +1,9 @@
package com.dfsek.terra.bukkit.listeners;
import com.dfsek.terra.api.TerraPlugin;
import com.dfsek.terra.api.world.TerraWorld;
import com.dfsek.terra.api.world.locate.AsyncStructureFinder;
import com.dfsek.terra.bukkit.world.BukkitAdapter;
import com.dfsek.terra.world.TerraWorld;
import com.dfsek.terra.world.population.items.TerraStructure;
import io.papermc.paper.event.world.StructureLocateEvent;
import org.bukkit.event.EventHandler;
@@ -1,9 +1,9 @@
package com.dfsek.terra.bukkit.listeners;
import com.dfsek.terra.api.TerraPlugin;
import com.dfsek.terra.api.world.TerraWorld;
import com.dfsek.terra.api.world.locate.AsyncStructureFinder;
import com.dfsek.terra.bukkit.world.BukkitAdapter;
import com.dfsek.terra.world.TerraWorld;
import com.dfsek.terra.world.population.items.TerraStructure;
import org.bukkit.entity.EnderSignal;
import org.bukkit.entity.Entity;
@@ -1,6 +1,7 @@
package com.dfsek.terra.bukkit.world;
import com.dfsek.terra.vector.LocationImpl;
import com.dfsek.terra.api.vector.Vector3;
import com.dfsek.terra.vector.Vector3Impl;
import com.dfsek.terra.api.entity.CommandSender;
@@ -337,12 +338,12 @@ public final class BukkitAdapter {
}
}
public static Location adapt(com.dfsek.terra.api.vector.Location location) {
public static Location adapt(LocationImpl location) {
return new Location(((BukkitWorld) location.getWorld()).getHandle(), location.getX(), location.getY(), location.getZ());
}
public static com.dfsek.terra.api.vector.Location adapt(Location location) {
return new com.dfsek.terra.api.vector.Location(adapt(location.getWorld()), location.getX(), location.getY(), location.getZ());
public static LocationImpl adapt(Location location) {
return new LocationImpl(adapt(location.getWorld()), location.getX(), location.getY(), location.getZ());
}
public static Vector adapt(Vector3 vector3) {
@@ -1,7 +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;
import com.dfsek.terra.api.util.collections.MaterialSet;
@@ -43,7 +43,7 @@ public class BukkitTree implements Tree {
@Override
@SuppressWarnings("try")
public boolean plant(Location l, Random r) {
public boolean plant(LocationImpl 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,6 +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;
import com.dfsek.terra.api.entity.EntityType;
@@ -64,7 +64,7 @@ public class BukkitWorld implements World {
}
@Override
public Entity spawnEntity(Location location, EntityType entityType) {
public Entity spawnEntity(LocationImpl location, EntityType entityType) {
return new BukkitEntity(delegate.spawnEntity(BukkitAdapter.adapt(location), ((BukkitEntityType) entityType).getHandle()));
}
@@ -1,6 +1,6 @@
package com.dfsek.terra.bukkit.world.block;
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.block.BlockData;
import com.dfsek.terra.api.block.BlockFace;
@@ -48,7 +48,7 @@ public class BukkitBlock implements Block {
}
@Override
public Location getLocation() {
public LocationImpl getLocation() {
return BukkitAdapter.adapt(delegate.getLocation());
}