mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-17 22:00:08 +00:00
clean up WorldHandle, add generic utility classes
This commit is contained in:
@@ -1,23 +1,18 @@
|
||||
package com.dfsek.terra.bukkit.handles;
|
||||
|
||||
import com.dfsek.terra.api.platform.block.Block;
|
||||
import com.dfsek.terra.api.math.vector.Location;
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.platform.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.entity.Player;
|
||||
import com.dfsek.terra.api.platform.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.util.generic.pair.Pair;
|
||||
import com.dfsek.terra.bukkit.structure.WorldEditUtil;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
import com.dfsek.terra.bukkit.world.block.data.BukkitBlockData;
|
||||
import com.dfsek.terra.bukkit.world.entity.BukkitEntityType;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class BukkitWorldHandle implements WorldHandle {
|
||||
@Override
|
||||
public void setBlockData(Block block, BlockData data, boolean physics) {
|
||||
block.setBlockData(data, physics);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getBlockData(Block block) {
|
||||
return block.getBlockData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData createBlockData(String data) {
|
||||
@@ -29,4 +24,10 @@ public class BukkitWorldHandle implements WorldHandle {
|
||||
public EntityType getEntity(String id) {
|
||||
return new BukkitEntityType(org.bukkit.entity.EntityType.valueOf(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<Location, Location> getSelectedLocation(Player player) {
|
||||
org.bukkit.Location[] locations = WorldEditUtil.getSelectionLocations(BukkitAdapter.adapt(player));
|
||||
return new Pair<>(BukkitAdapter.adapt(locations[0]), BukkitAdapter.adapt(locations[1]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,12 +25,10 @@ public final class WorldEditUtil {
|
||||
try {
|
||||
selection = we.getSession(sender).getSelection(BukkitAdapter.adapt(sender.getWorld()));
|
||||
} catch(IncompleteRegionException | ClassCastException e) {
|
||||
sender.sendMessage("Invalid/incomplete selection!");
|
||||
return null;
|
||||
throw new IllegalStateException("Invalid/incomplete selection!");
|
||||
}
|
||||
if(selection == null) {
|
||||
sender.sendMessage("Please make a selection before attempting to export!");
|
||||
return null;
|
||||
throw new IllegalStateException("Please make a selection before attempting to export!");
|
||||
}
|
||||
BlockVector3 min = selection.getMinimumPoint();
|
||||
BlockVector3 max = selection.getMaximumPoint();
|
||||
|
||||
Reference in New Issue
Block a user