Search in sources :

Example 6 with WorldGuardPlugin

use of com.sk89q.worldguard.bukkit.WorldGuardPlugin 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

WorldGuardPlugin (com.sk89q.worldguard.bukkit.WorldGuardPlugin)6 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)4 Player (org.bukkit.entity.Player)4 Vector (com.sk89q.worldedit.Vector)3 RegionManager (com.sk89q.worldguard.protection.managers.RegionManager)3 Location (org.bukkit.Location)3 Plugin (org.bukkit.plugin.Plugin)3 WorldEditPlugin (com.sk89q.worldedit.bukkit.WorldEditPlugin)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 JavaPlugin (org.bukkit.plugin.java.JavaPlugin)2 Polygonal2DSelection (com.sk89q.worldedit.bukkit.selections.Polygonal2DSelection)1 Flag (com.sk89q.worldguard.protection.flags.Flag)1 InvalidFlagFormat (com.sk89q.worldguard.protection.flags.InvalidFlagFormat)1 RegionGroupFlag (com.sk89q.worldguard.protection.flags.RegionGroupFlag)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1