Search in sources :

Example 1 with Polygonal2DSelection

use of com.sk89q.worldedit.bukkit.selections.Polygonal2DSelection in project MyMaid2 by jaoafa.

the class Cmd_Protector method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    if (!(sender instanceof Player)) {
        SendMessage(sender, cmd, "このコマンドはプレイヤーからのみ実行できます。");
        return true;
    }
    Player player = (Player) sender;
    WorldGuardPlugin wg = MyMaid2.getWorldGuard();
    WorldEditPlugin we = MyMaid2.getWorldEdit();
    Location loc = player.getLocation();
    Vector v = new Vector(loc.getX(), loc.getY(), loc.getZ());
    RegionManager rm = wg.getRegionManager(player.getWorld());
    List<String> regionlist = rm.getApplicableRegionsIDs(v);
    if (regionlist.size() == 0) {
        SendMessage(sender, cmd, "この場所は登録されていません。");
        return true;
    }
    String last_ID = regionlist.get(0);
    ProtectedRegion region = rm.getRegion(last_ID);
    Polygonal2DSelection selection = new Polygonal2DSelection(player.getWorld(), region.getPoints(), region.getMinimumPoint().getBlockY(), region.getMaximumPoint().getBlockY());
    we.setSelection(player, selection);
    SendMessage(sender, cmd, "リージョン「" + last_ID + "」の範囲をWorldEditにセットしました。");
    SendMessage(sender, cmd, "WorldEditCUI等で確認してください。");
    return true;
}
Also used : Player(org.bukkit.entity.Player) WorldEditPlugin(com.sk89q.worldedit.bukkit.WorldEditPlugin) Polygonal2DSelection(com.sk89q.worldedit.bukkit.selections.Polygonal2DSelection) WorldGuardPlugin(com.sk89q.worldguard.bukkit.WorldGuardPlugin) ProtectedRegion(com.sk89q.worldguard.protection.regions.ProtectedRegion) RegionManager(com.sk89q.worldguard.protection.managers.RegionManager) Vector(com.sk89q.worldedit.Vector) Location(org.bukkit.Location)

Aggregations

Vector (com.sk89q.worldedit.Vector)1 WorldEditPlugin (com.sk89q.worldedit.bukkit.WorldEditPlugin)1 Polygonal2DSelection (com.sk89q.worldedit.bukkit.selections.Polygonal2DSelection)1 WorldGuardPlugin (com.sk89q.worldguard.bukkit.WorldGuardPlugin)1 RegionManager (com.sk89q.worldguard.protection.managers.RegionManager)1 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)1 Location (org.bukkit.Location)1 Player (org.bukkit.entity.Player)1