mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 16:35:50 +00:00
remove unused WorldEditUtil
This commit is contained in:
parent
42ea10f72c
commit
c29dac9847
@ -1,98 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of Terra.
|
|
||||||
*
|
|
||||||
* Terra is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Terra is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Terra. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.dfsek.terra.bukkit.structure;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.sk89q.worldedit.regions.Region;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
|
|
||||||
public final class WorldEditUtil {
|
|
||||||
public static Location[] getSelectionLocations(Player sender) {
|
|
||||||
WorldEditPlugin we;
|
|
||||||
try {
|
|
||||||
we = WorldEditUtil.getWorldEdit();
|
|
||||||
} catch(WorldEditNotFoundException e) {
|
|
||||||
sender.sendMessage("WorldEdit is not installed! Please install WorldEdit before attempting to export structures.");
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
Region selection;
|
|
||||||
try {
|
|
||||||
selection = we.getSession(sender).getSelection(BukkitAdapter.adapt(sender.getWorld()));
|
|
||||||
} catch(IncompleteRegionException | ClassCastException e) {
|
|
||||||
throw new IllegalStateException("Invalid/incomplete selection!");
|
|
||||||
}
|
|
||||||
if(selection == null) {
|
|
||||||
throw new IllegalStateException("Please make a selection before attempting to export!");
|
|
||||||
}
|
|
||||||
BlockVector3 min = selection.getMinimumPoint();
|
|
||||||
BlockVector3 max = selection.getMaximumPoint();
|
|
||||||
Location l1 = new Location(sender.getWorld(), min.getBlockX(), min.getBlockY(), min.getBlockZ());
|
|
||||||
Location l2 = new Location(sender.getWorld(), max.getBlockX(), max.getBlockY(), max.getBlockZ());
|
|
||||||
return new Location[]{ l1, l2 };
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets an instance of the WorldEditPlugin class.
|
|
||||||
*
|
|
||||||
* @return The world edit plugin instance.
|
|
||||||
*
|
|
||||||
* @throws WorldEditNotFoundException Thrown when worldedit cannot be found.
|
|
||||||
*/
|
|
||||||
@NotNull
|
|
||||||
public static WorldEditPlugin getWorldEdit() {
|
|
||||||
Plugin p = Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
|
|
||||||
if(p instanceof WorldEditPlugin) return (WorldEditPlugin) p;
|
|
||||||
Bukkit.getLogger().severe("[Terra] a command requiring WorldEdit was executed, but WorldEdit was not detected!");
|
|
||||||
throw new WorldEditNotFoundException("Could not find World Edit!");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Location[] getSelectionPositions(Player sender) {
|
|
||||||
WorldEditPlugin we;
|
|
||||||
try {
|
|
||||||
we = WorldEditUtil.getWorldEdit();
|
|
||||||
} catch(WorldEditNotFoundException e) {
|
|
||||||
sender.sendMessage("WorldEdit is not installed! Please install WorldEdit before attempting to export structures.");
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
CuboidRegion selection;
|
|
||||||
try {
|
|
||||||
selection = (CuboidRegion) we.getSession(sender).getSelection(BukkitAdapter.adapt(sender.getWorld()));
|
|
||||||
} catch(IncompleteRegionException | ClassCastException e) {
|
|
||||||
sender.sendMessage("Invalid/incomplete selection!");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if(selection == null) {
|
|
||||||
sender.sendMessage("Please make a selection before attempting to export!");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
BlockVector3 min = selection.getPos1();
|
|
||||||
BlockVector3 max = selection.getPos2();
|
|
||||||
Location l1 = new Location(sender.getWorld(), min.getBlockX(), min.getBlockY(), min.getBlockZ());
|
|
||||||
Location l2 = new Location(sender.getWorld(), max.getBlockX(), max.getBlockY(), max.getBlockZ());
|
|
||||||
return new Location[]{ l1, l2 };
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user