Search in sources :

Example 1 with MarkerSet

use of org.dynmap.markers.MarkerSet in project MagicPlugin by elBukkit.

the class DynmapController method removeMarker.

public boolean removeMarker(String id, String group) {
    boolean removed = false;
    if (dynmap != null && dynmap.markerAPIInitialized()) {
        MarkerAPI markers = dynmap.getMarkerAPI();
        MarkerSet markerSet = markers.getMarkerSet(group);
        if (markerSet != null) {
            Marker marker = markerSet.findMarker(id);
            if (marker != null) {
                removed = true;
                marker.deleteMarker();
            }
        }
    }
    return removed;
}
Also used : MarkerSet(org.dynmap.markers.MarkerSet) MarkerAPI(org.dynmap.markers.MarkerAPI) Marker(org.dynmap.markers.Marker) PolyLineMarker(org.dynmap.markers.PolyLineMarker) CircleMarker(org.dynmap.markers.CircleMarker)

Example 2 with MarkerSet

use of org.dynmap.markers.MarkerSet in project MagicPlugin by elBukkit.

the class DynmapController method addMarker.

public boolean addMarker(String id, String group, String title, String world, int x, int y, int z, String description) {
    boolean created = false;
    if (dynmap != null && dynmap.markerAPIInitialized()) {
        MarkerAPI markers = dynmap.getMarkerAPI();
        MarkerSet markerSet = markers.getMarkerSet(group);
        if (markerSet == null) {
            markerSet = markers.createMarkerSet(group, group, null, false);
        }
        MarkerIcon wandIcon = markers.getMarkerIcon("wand");
        if (wandIcon == null) {
            wandIcon = markers.createMarkerIcon("wand", "Wand", plugin.getResource("wand_icon32.png"));
        }
        Marker marker = markerSet.findMarker(id);
        if (marker == null) {
            created = true;
            marker = markerSet.createMarker(id, title, world, x, y, z, wandIcon, false);
        } else {
            marker.setLocation(world, x, y, z);
            marker.setLabel(title);
        }
        if (description != null) {
            marker.setDescription(description);
        }
    }
    return created;
}
Also used : MarkerSet(org.dynmap.markers.MarkerSet) MarkerAPI(org.dynmap.markers.MarkerAPI) MarkerIcon(org.dynmap.markers.MarkerIcon) Marker(org.dynmap.markers.Marker) PolyLineMarker(org.dynmap.markers.PolyLineMarker) CircleMarker(org.dynmap.markers.CircleMarker)

Example 3 with MarkerSet

use of org.dynmap.markers.MarkerSet in project MyMaid2 by jaoafa.

the class Cmd_DT method onCommand.

public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    Plugin dynmap = plugin.getServer().getPluginManager().getPlugin("dynmap");
    if (dynmap == null || !dynmap.isEnabled()) {
        SendMessage(sender, cmd, "Dynmapプラグインが停止中、もしくは存在しないため、このコマンドを利用できません。");
        return true;
    }
    DynmapAPI dynmapapi = (DynmapAPI) dynmap;
    MarkerAPI markerapi = dynmapapi.getMarkerAPI();
    if (args.length >= 1 && args[0].equalsIgnoreCase("help")) {
        SendUsageMessage(sender, cmd);
        return true;
    }
    if (args.length == 1) {
        if (args[0].equalsIgnoreCase("add")) {
            // 一つではaddは使えない
            SendMessage(sender, cmd, "マーカーの追加には/dt add <MarkerName> <MarkerType>を使用します。");
            return true;
        } else if (args[0].equalsIgnoreCase("del")) {
            // 一つではdelは使えない
            SendMessage(sender, cmd, "マーカーの削除には/dt del <MarkerName>を使用します。");
            return true;
        } else if (args[0].equalsIgnoreCase("list")) {
            Set<Marker> Markers = new HashSet<Marker>();
            for (MarkerSet markerset : markerapi.getMarkerSets()) {
                for (Marker marker : markerset.getMarkers()) {
                    Markers.add(marker);
                }
            }
            int count = 0;
            int page = 1;
            int startcount = (page - 1) * 10;
            int endcount = page * 10;
            int maxpage = Markers.size() / 10;
            SendMessage(sender, cmd, "Marker List: " + page + "page / " + maxpage + "page");
            SendMessage(sender, cmd, "-------------------------");
            for (Marker marker : Markers) {
                if (count <= startcount) {
                    count++;
                    continue;
                }
                if (count > endcount) {
                    break;
                }
                SendMessage(sender, cmd, "[" + count + "|" + marker.getWorld() + "/" + marker.getMarkerSet().getMarkerSetLabel() + "]" + marker.getLabel() + " X:" + marker.getX() + " Y:" + marker.getY() + " Z:" + marker.getY());
                count++;
            }
            SendMessage(sender, cmd, "-------------------------");
            SendMessage(sender, cmd, startcount + " - " + endcount + " / " + Markers.size());
            if (page != maxpage) {
                SendMessage(sender, cmd, "次のページを見るには「/dt list " + (page + 1) + "」を実行します。");
            }
            return true;
        } else if (args[0].equalsIgnoreCase("near")) {
            if (!(sender instanceof Player)) {
                SendMessage(sender, cmd, "このコマンドはサーバ内から実行可能です。");
                return true;
            }
            Player player = (Player) sender;
            Location loc = player.getLocation();
            Marker SelectMarker = null;
            double distance = Double.MAX_VALUE;
            for (MarkerSet markerset : markerapi.getMarkerSets()) {
                for (Marker marker : markerset.getMarkers()) {
                    if (!marker.getWorld().equalsIgnoreCase(player.getWorld().getName())) {
                        continue;
                    }
                    World world = Bukkit.getWorld(marker.getWorld());
                    double nowdistance = loc.distance(new Location(world, marker.getX(), marker.getY(), marker.getZ()));
                    if (distance > nowdistance) {
                        SelectMarker = marker;
                        distance = nowdistance;
                    }
                }
            }
            if (SelectMarker == null) {
                SendMessage(sender, cmd, "マーカーが見つかりませんでした。");
                return true;
            }
            SendMessage(sender, cmd, "あなたから一番近い場所にあるマーカーは「" + SelectMarker.getLabel() + "」というマーカーです。");
            SendMessage(sender, cmd, "約" + (int) distance + "ブロック程度のところにあり、「/dt " + SelectMarker.getLabel() + "」というコマンドでテレポートできます!");
            return true;
        } else if (args[0].equalsIgnoreCase("random")) {
            if (!(sender instanceof Player)) {
                SendMessage(sender, cmd, "このコマンドはサーバ内から実行可能です。");
                return true;
            }
            Player player = (Player) sender;
            List<Marker> markers = new ArrayList<>();
            for (MarkerSet markerset : markerapi.getMarkerSets()) {
                for (Marker marker : markerset.getMarkers()) {
                    if (!marker.getWorld().equalsIgnoreCase(player.getWorld().getName())) {
                        continue;
                    }
                    markers.add(marker);
                }
            }
            Collections.shuffle(markers);
            Marker SelectMarker = markers.get(0);
            Location loc = new Location(player.getWorld(), SelectMarker.getX(), SelectMarker.getY(), SelectMarker.getZ());
            loc.add(0.5f, 0f, 0.5f);
            player.teleport(loc);
            SendMessage(sender, cmd, "あなたはランダムで選ばれた「" + SelectMarker.getLabel() + "」というマーカーにテレポートしました。");
            TitleAPI.sendTitle(player, 2, 5, 2, "", ChatColor.AQUA + "You have been teleported to " + SelectMarker.getLabel() + "!");
            DiscordSend("*[" + player.getName() + ": " + player.getName() + " to " + SelectMarker.getLabel() + "]*");
            Bukkit.broadcastMessage(ChatColor.GRAY + "[" + ChatColor.ITALIC + player.getName() + ChatColor.GRAY + ": " + ChatColor.ITALIC + player.getName() + ChatColor.GRAY + " は " + ChatColor.ITALIC + SelectMarker.getLabel() + ChatColor.GRAY + " にワープしました]");
            return true;
        } else {
            // /dt <MarkerName>
            if (!(sender instanceof Player)) {
                SendMessage(sender, cmd, "このコマンドはサーバ内から実行可能です。");
                return true;
            }
            Player player = (Player) sender;
            String markerlabel = args[0];
            Map<String, Marker> Markers = new HashMap<>();
            for (MarkerSet markerset : markerapi.getMarkerSets()) {
                for (Marker marker : markerset.getMarkers()) {
                    Markers.put(marker.getLabel(), marker);
                }
            }
            if (Markers.containsKey(markerlabel)) {
                Marker marker = Markers.get(markerlabel);
                World world = Bukkit.getWorld(marker.getWorld());
                double x = marker.getX();
                double y = marker.getY();
                double z = marker.getZ();
                Location loc = new Location(world, x, y, z);
                loc.add(0.5f, 0f, 0.5f);
                player.teleport(loc);
                TitleAPI.sendTitle(player, 2, 5, 2, "", ChatColor.AQUA + "You have been teleported to " + markerlabel + "!");
                DiscordSend("*[" + player.getName() + ": " + player.getName() + " to " + markerlabel + "]*");
                Bukkit.broadcastMessage(ChatColor.GRAY + "[" + ChatColor.ITALIC + player.getName() + ChatColor.GRAY + ": " + ChatColor.ITALIC + player.getName() + ChatColor.GRAY + " は " + ChatColor.ITALIC + markerlabel + ChatColor.GRAY + " にワープしました]");
                return true;
            } else {
                // 見つからなかった
                SendMessage(sender, cmd, "指定されたマーカー「" + markerlabel + "」は見つかりませんでした。");
                SendMessage(sender, cmd, "マーカー名は大文字小文字を区別します。もう一度間違っていないか確認してください。");
                // もしかして
                List<String> perhapsMarkers = new ArrayList<>();
                for (Entry<String, Marker> Marker : Markers.entrySet()) {
                    if (Marker.getKey().equalsIgnoreCase(markerlabel)) {
                        perhapsMarkers.add(Marker.getValue().getLabel());
                    } else if (Marker.getKey().startsWith(markerlabel)) {
                        perhapsMarkers.add(Marker.getValue().getLabel());
                    } else if (markerlabel.startsWith(Marker.getKey())) {
                        perhapsMarkers.add(Marker.getValue().getLabel());
                    }
                }
                if (!perhapsMarkers.isEmpty()) {
                    SendMessage(sender, cmd, "もしかして: " + implode(perhapsMarkers, ", "));
                }
                return true;
            }
        }
    } else if (args.length == 2) {
        if (args[0].equalsIgnoreCase("add")) {
            // 二つではaddは使えない
            SendMessage(sender, cmd, "マーカーの追加には/dt add <MarkerName> <MarkerType>を使用します。");
            return true;
        } else if (args[0].equalsIgnoreCase("del")) {
            // マーカーの削除
            // /dt del <MarkerName>
            String markerlabel = args[1];
            Map<String, Marker> Markers = new HashMap<>();
            for (MarkerSet markerset : markerapi.getMarkerSets()) {
                for (Marker marker : markerset.getMarkers()) {
                    Markers.put(marker.getLabel(), marker);
                }
            }
            if (Markers.containsKey(markerlabel)) {
                Marker marker = Markers.get(markerlabel);
                String world = marker.getWorld();
                double x = marker.getX();
                double y = marker.getY();
                double z = marker.getZ();
                marker.deleteMarker();
                SendMessage(sender, cmd, "マーカー「" + markerlabel + "(" + world + ", " + x + ", " + y + ", " + z + ")」を削除しました。");
                return true;
            } else {
                // 見つからなかった
                SendMessage(sender, cmd, "指定されたマーカー「" + markerlabel + "」は見つかりませんでした。");
                SendMessage(sender, cmd, "マーカー名は大文字小文字を区別します。もう一度間違っていないか確認してください。");
                // もしかして
                List<String> perhapsMarkers = new ArrayList<>();
                for (Entry<String, Marker> Marker : Markers.entrySet()) {
                    if (Marker.getKey().equalsIgnoreCase(markerlabel)) {
                        perhapsMarkers.add(Marker.getValue().getLabel());
                    } else if (Marker.getKey().startsWith(markerlabel)) {
                        perhapsMarkers.add(Marker.getValue().getLabel());
                    } else if (markerlabel.startsWith(Marker.getKey())) {
                        perhapsMarkers.add(Marker.getValue().getLabel());
                    }
                }
                if (!perhapsMarkers.isEmpty()) {
                    SendMessage(sender, cmd, "もしかして: " + implode(perhapsMarkers, ", "));
                }
                return true;
            }
        } else if (args[0].equalsIgnoreCase("list")) {
            Set<Marker> Markers = new HashSet<Marker>();
            for (MarkerSet markerset : markerapi.getMarkerSets()) {
                for (Marker marker : markerset.getMarkers()) {
                    Markers.add(marker);
                }
            }
            if (!isNumber(args[1])) {
                SendMessage(sender, cmd, "指定されたページは数値ではありません。");
                return true;
            }
            int count = 0;
            int page = Integer.parseInt(args[1]);
            int startcount = (page - 1) * 10;
            int endcount = page * 10;
            int maxpage = (Markers.size() / 10) + 1;
            if (page < 0) {
                SendMessage(sender, cmd, "表示できるマーカーがありません。");
                return true;
            } else if (startcount >= Markers.size()) {
                SendMessage(sender, cmd, "表示できるマーカーがありません。");
                return true;
            }
            SendMessage(sender, cmd, "Marker List: " + page + "page / " + maxpage + "page");
            SendMessage(sender, cmd, "-------------------------");
            for (Marker marker : Markers) {
                if (count <= startcount) {
                    count++;
                    continue;
                }
                if (count > endcount) {
                    break;
                }
                SendMessage(sender, cmd, "[" + count + "|" + marker.getWorld() + "/" + marker.getMarkerSet().getMarkerSetLabel() + "]" + marker.getLabel() + " X:" + marker.getX() + " Y:" + marker.getY() + " Z:" + marker.getY());
                count++;
            }
            SendMessage(sender, cmd, "-------------------------");
            SendMessage(sender, cmd, startcount + " - " + endcount + " / " + Markers.size());
            if (page != maxpage) {
                SendMessage(sender, cmd, "次のページを見るには「/dt list " + (page + 1) + "」を実行します。");
            }
            return true;
        } else {
            // addとかdelとか以外 => プレイヤー名?
            // /dt <Player> <MarkerName>
            String playername = args[0];
            Player player = Bukkit.getPlayerExact(playername);
            if (player == null) {
                SendMessage(sender, cmd, "指定されたプレイヤー「" + playername + "」は見つかりませんでした。");
                Player any_chance_player = Bukkit.getPlayer(playername);
                if (any_chance_player != null) {
                    SendMessage(sender, cmd, "もしかして: " + any_chance_player.getName());
                }
                return true;
            }
            String markerlabel = args[1];
            Map<String, Marker> Markers = new HashMap<>();
            for (MarkerSet markerset : markerapi.getMarkerSets()) {
                for (Marker marker : markerset.getMarkers()) {
                    Markers.put(marker.getLabel(), marker);
                }
            }
            if (Markers.containsKey(markerlabel)) {
                Marker marker = Markers.get(markerlabel);
                World world = Bukkit.getWorld(marker.getWorld());
                double x = marker.getX();
                double y = marker.getY();
                double z = marker.getZ();
                Location loc = new Location(world, x, y, z);
                loc.add(0.5f, 0f, 0.5f);
                player.teleport(loc);
                TitleAPI.sendTitle(player, 2, 5, 2, "", ChatColor.AQUA + "You have been teleported to " + markerlabel + "!");
                DiscordSend("*[" + sender.getName() + ": " + player.getName() + " to " + markerlabel + "]*");
                Bukkit.broadcastMessage(ChatColor.GRAY + "[" + ChatColor.ITALIC + sender.getName() + ChatColor.GRAY + ": " + ChatColor.ITALIC + player.getName() + ChatColor.GRAY + " は " + ChatColor.ITALIC + markerlabel + ChatColor.GRAY + " にワープしました]");
                return true;
            } else {
                // 見つからなかった
                SendMessage(sender, cmd, "指定されたマーカー「" + markerlabel + "」は見つかりませんでした。");
                SendMessage(sender, cmd, "マーカー名は大文字小文字を区別します。もう一度間違っていないか確認してください。");
                // もしかして
                List<String> perhapsMarkers = new ArrayList<>();
                for (Entry<String, Marker> Marker : Markers.entrySet()) {
                    if (Marker.getKey().equalsIgnoreCase(markerlabel)) {
                        perhapsMarkers.add(Marker.getValue().getLabel());
                    } else if (Marker.getKey().startsWith(markerlabel)) {
                        perhapsMarkers.add(Marker.getValue().getLabel());
                    } else if (markerlabel.startsWith(Marker.getKey())) {
                        perhapsMarkers.add(Marker.getValue().getLabel());
                    }
                }
                if (!perhapsMarkers.isEmpty()) {
                    SendMessage(sender, cmd, "もしかして: " + implode(perhapsMarkers, ", "));
                }
                return true;
            }
        }
    } else if (args.length >= 3) {
        if (args[0].equalsIgnoreCase("add")) {
            // マーカーの追加
            if (!(sender instanceof Player)) {
                SendMessage(sender, cmd, "このコマンドはサーバ内から実行可能です。");
                return true;
            }
            Player player = (Player) sender;
            Location loc = player.getLocation();
            String markerlabel = args[1];
            String markertype = args[2];
            Map<String, MarkerSet> MarkersTypes = new HashMap<>();
            for (MarkerSet markerset : markerapi.getMarkerSets()) {
                MarkersTypes.put(markerset.getMarkerSetLabel(), markerset);
            }
            if (!MarkersTypes.containsKey(markertype)) {
                // マーカータイプが見つからなかった
                SendMessage(sender, cmd, "指定されたマーカータイプ「" + markertype + "」は見つかりませんでした。");
                return true;
            }
            MarkerSet MarkerType = MarkersTypes.get(markertype);
            Map<String, Marker> Markers = new HashMap<>();
            for (MarkerSet markerset : markerapi.getMarkerSets()) {
                for (Marker marker : markerset.getMarkers()) {
                    Markers.put(marker.getLabel(), marker);
                }
            }
            String MarkerIconDef = MarkerIcon.DEFAULT;
            MarkerIcon markericondef = null;
            for (MarkerIcon icon : markerapi.getMarkerIcons()) {
                if (icon.getMarkerIconID().equals(MarkerIconDef)) {
                    markericondef = icon;
                }
            }
            if (markericondef == null) {
                SendMessage(sender, cmd, "デフォルトマーカーアイコンが存在しませんでした。");
                return true;
            }
            MarkerIcon markericon = MarkerType.getDefaultMarkerIcon();
            if (markericon == null) {
                markericon = markericondef;
            }
            Marker marker = MarkerType.createMarker(null, markerlabel, loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), markericon, true);
            if (marker == null) {
                SendMessage(sender, cmd, "指定されたマーカー「" + markerlabel + "」を作成できませんでした。");
                return true;
            }
            SendMessage(sender, cmd, "指定されたマーカー「" + markerlabel + "」を作成しました。");
            if (Markers.containsKey(markerlabel)) {
                SendMessage(sender, cmd, "ヒント: 同じMarkerNameのマーカーが他にもあるようです。");
                SendMessage(sender, cmd, "正常にテレポートできない可能性があります。");
                return true;
            }
            return true;
        } else {
            // addとかdelとか以外 => プレイヤー名?
            // /dt <Player> <MarkerName>
            String playername = args[0];
            Player player = Bukkit.getPlayerExact(playername);
            if (player == null) {
                SendMessage(sender, cmd, "指定されたプレイヤー「" + playername + "」は見つかりませんでした。");
                Player any_chance_player = Bukkit.getPlayer(playername);
                if (any_chance_player != null) {
                    SendMessage(sender, cmd, "もしかして: " + any_chance_player.getName());
                }
                return true;
            }
            String markerlabel = "";
            int c = 1;
            while (args.length > c) {
                markerlabel += args[c];
                if (args.length != (c + 1)) {
                    markerlabel += " ";
                }
                c++;
            }
            Map<String, Marker> Markers = new HashMap<>();
            for (MarkerSet markerset : markerapi.getMarkerSets()) {
                for (Marker marker : markerset.getMarkers()) {
                    Markers.put(marker.getLabel(), marker);
                }
            }
            if (Markers.containsKey(markerlabel)) {
                Marker marker = Markers.get(markerlabel);
                World world = Bukkit.getWorld(marker.getWorld());
                double x = marker.getX();
                double y = marker.getY();
                double z = marker.getZ();
                Location loc = new Location(world, x, y, z);
                loc.add(0.5f, 0f, 0.5f);
                player.teleport(loc);
                TitleAPI.sendTitle(player, 2, 5, 2, "", ChatColor.AQUA + "You have been teleported to " + markerlabel + "!");
                DiscordSend("*[" + sender.getName() + ": " + player.getName() + " to " + markerlabel + "]*");
                Bukkit.broadcastMessage(ChatColor.GRAY + "[" + ChatColor.ITALIC + sender.getName() + ChatColor.GRAY + ": " + ChatColor.ITALIC + player.getName() + ChatColor.GRAY + " は " + ChatColor.ITALIC + markerlabel + ChatColor.GRAY + " にワープしました]");
                return true;
            } else {
                // 見つからなかった
                SendMessage(sender, cmd, "指定されたマーカー「" + markerlabel + "」は見つかりませんでした。");
                SendMessage(sender, cmd, "マーカー名は大文字小文字を区別します。もう一度間違っていないか確認してください。");
                // もしかして
                List<String> perhapsMarkers = new ArrayList<>();
                for (Entry<String, Marker> Marker : Markers.entrySet()) {
                    if (Marker.getKey().equalsIgnoreCase(markerlabel)) {
                        perhapsMarkers.add(Marker.getValue().getLabel());
                    } else if (Marker.getKey().startsWith(markerlabel)) {
                        perhapsMarkers.add(Marker.getValue().getLabel());
                    } else if (markerlabel.startsWith(Marker.getKey())) {
                        perhapsMarkers.add(Marker.getValue().getLabel());
                    }
                }
                if (!perhapsMarkers.isEmpty()) {
                    SendMessage(sender, cmd, "もしかして: " + implode(perhapsMarkers, ", "));
                }
                return true;
            }
        }
    }
    SendUsageMessage(sender, cmd);
    return true;
}
Also used : MarkerSet(org.dynmap.markers.MarkerSet) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) World(org.bukkit.World) Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet) MarkerSet(org.dynmap.markers.MarkerSet) Player(org.bukkit.entity.Player) DynmapAPI(org.dynmap.DynmapAPI) MarkerAPI(org.dynmap.markers.MarkerAPI) Marker(org.dynmap.markers.Marker) MarkerIcon(org.dynmap.markers.MarkerIcon) HashMap(java.util.HashMap) Map(java.util.Map) Plugin(org.bukkit.plugin.Plugin) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) Location(org.bukkit.Location)

Example 4 with MarkerSet

use of org.dynmap.markers.MarkerSet in project MyMaid2 by jaoafa.

the class Cmd_DT method onTabComplete.

public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
    if (args.length == 1) {
        if (args[0].length() == 0) {
            // /dtまで
            Plugin dynmap = plugin.getServer().getPluginManager().getPlugin("dynmap");
            if (dynmap == null || !dynmap.isEnabled()) {
                SendMessage(sender, cmd, "Dynmapプラグインが停止中、もしくは存在しないため、このコマンドを利用できません。");
                return plugin.onTabComplete(sender, cmd, alias, args);
            }
            List<String> tablist = new ArrayList<>();
            tablist.add("add");
            tablist.add("del");
            tablist.add("list");
            DynmapAPI dynmapapi = (DynmapAPI) dynmap;
            MarkerAPI markerapi = dynmapapi.getMarkerAPI();
            for (MarkerSet markerset : markerapi.getMarkerSets()) {
                for (Marker marker : markerset.getMarkers()) {
                    tablist.add(marker.getLabel());
                }
            }
            return tablist;
        } else {
            Plugin dynmap = plugin.getServer().getPluginManager().getPlugin("dynmap");
            if (dynmap == null || !dynmap.isEnabled()) {
                SendMessage(sender, cmd, "Dynmapプラグインが停止中、もしくは存在しないため、このコマンドを利用できません。");
                return plugin.onTabComplete(sender, cmd, alias, args);
            }
            List<String> tablist = new ArrayList<>();
            tablist.add("add");
            tablist.add("del");
            tablist.add("list");
            DynmapAPI dynmapapi = (DynmapAPI) dynmap;
            MarkerAPI markerapi = dynmapapi.getMarkerAPI();
            for (MarkerSet markerset : markerapi.getMarkerSets()) {
                for (Marker marker : markerset.getMarkers()) {
                    tablist.add(marker.getLabel());
                }
            }
            List<String> tablistFor = new ArrayList<>();
            tablistFor.addAll(tablist);
            for (String tab : tablistFor) {
                if (!tab.toLowerCase().startsWith(args[0].toLowerCase())) {
                    tablist.remove(tab);
                }
            }
            if (tablist.size() == 0) {
                return plugin.onTabComplete(sender, cmd, alias, args);
            }
            return tablist;
        }
    } else if (args.length == 2) {
        if (args[1].length() == 0) {
            // /dt ~まで
            if (args[0].equalsIgnoreCase("del")) {
                Plugin dynmap = plugin.getServer().getPluginManager().getPlugin("dynmap");
                if (dynmap == null || !dynmap.isEnabled()) {
                    SendMessage(sender, cmd, "Dynmapプラグインが停止中、もしくは存在しないため、このコマンドを利用できません。");
                    return plugin.onTabComplete(sender, cmd, alias, args);
                }
                List<String> tablist = new ArrayList<>();
                DynmapAPI dynmapapi = (DynmapAPI) dynmap;
                MarkerAPI markerapi = dynmapapi.getMarkerAPI();
                for (MarkerSet markerset : markerapi.getMarkerSets()) {
                    for (Marker marker : markerset.getMarkers()) {
                        tablist.add(marker.getLabel());
                    }
                }
                return tablist;
            } else {
                Plugin dynmap = plugin.getServer().getPluginManager().getPlugin("dynmap");
                if (dynmap == null || !dynmap.isEnabled()) {
                    SendMessage(sender, cmd, "Dynmapプラグインが停止中、もしくは存在しないため、このコマンドを利用できません。");
                    return plugin.onTabComplete(sender, cmd, alias, args);
                }
                Player player = Bukkit.getPlayerExact(args[0]);
                if (player == null) {
                    SendMessage(sender, cmd, "入力されているプレイヤー「" + args[0] + "」は見つかりません。");
                    Player any_chance_player = Bukkit.getPlayer(args[0]);
                    if (any_chance_player != null) {
                        SendMessage(sender, cmd, "もしかして: " + any_chance_player.getName());
                    }
                    return plugin.onTabComplete(sender, cmd, alias, args);
                }
                List<String> tablist = new ArrayList<>();
                DynmapAPI dynmapapi = (DynmapAPI) dynmap;
                MarkerAPI markerapi = dynmapapi.getMarkerAPI();
                for (MarkerSet markerset : markerapi.getMarkerSets()) {
                    for (Marker marker : markerset.getMarkers()) {
                        tablist.add(marker.getLabel());
                    }
                }
                List<String> tablistFor = new ArrayList<>();
                tablistFor.addAll(tablist);
                for (String tab : tablistFor) {
                    if (!tab.toLowerCase().startsWith(args[1].toLowerCase())) {
                        tablist.remove(tab);
                    }
                }
                if (tablist.size() == 0) {
                    return plugin.onTabComplete(sender, cmd, alias, args);
                }
                return tablist;
            }
        } else {
            if (args[0].equalsIgnoreCase("del")) {
                Plugin dynmap = plugin.getServer().getPluginManager().getPlugin("dynmap");
                if (dynmap == null || !dynmap.isEnabled()) {
                    SendMessage(sender, cmd, "Dynmapプラグインが停止中、もしくは存在しないため、このコマンドを利用できません。");
                    return plugin.onTabComplete(sender, cmd, alias, args);
                }
                List<String> tablist = new ArrayList<>();
                DynmapAPI dynmapapi = (DynmapAPI) dynmap;
                MarkerAPI markerapi = dynmapapi.getMarkerAPI();
                for (MarkerSet markerset : markerapi.getMarkerSets()) {
                    for (Marker marker : markerset.getMarkers()) {
                        tablist.add(marker.getLabel());
                    }
                }
                List<String> tablistFor = new ArrayList<>();
                tablistFor.addAll(tablist);
                for (String tab : tablistFor) {
                    if (!tab.startsWith(args[1])) {
                        tablist.remove(tab);
                    }
                }
                if (tablist.size() == 0) {
                    return plugin.onTabComplete(sender, cmd, alias, args);
                }
                return tablist;
            } else {
                Plugin dynmap = plugin.getServer().getPluginManager().getPlugin("dynmap");
                if (dynmap == null || !dynmap.isEnabled()) {
                    SendMessage(sender, cmd, "Dynmapプラグインが停止中、もしくは存在しないため、このコマンドを利用できません。");
                    return plugin.onTabComplete(sender, cmd, alias, args);
                }
                Player player = Bukkit.getPlayerExact(args[0]);
                if (player == null) {
                    SendMessage(sender, cmd, "入力されているプレイヤー「" + args[0] + "」は見つかりません。");
                    Player any_chance_player = Bukkit.getPlayer(args[0]);
                    if (any_chance_player != null) {
                        SendMessage(sender, cmd, "もしかして: " + any_chance_player.getName());
                    }
                    return plugin.onTabComplete(sender, cmd, alias, args);
                }
                List<String> tablist = new ArrayList<>();
                DynmapAPI dynmapapi = (DynmapAPI) dynmap;
                MarkerAPI markerapi = dynmapapi.getMarkerAPI();
                for (MarkerSet markerset : markerapi.getMarkerSets()) {
                    for (Marker marker : markerset.getMarkers()) {
                        tablist.add(marker.getLabel());
                    }
                }
                List<String> tablistFor = new ArrayList<>();
                tablistFor.addAll(tablist);
                for (String tab : tablistFor) {
                    if (!tab.toLowerCase().startsWith(args[1].toLowerCase())) {
                        tablist.remove(tab);
                    }
                }
                if (tablist.size() == 0) {
                    return plugin.onTabComplete(sender, cmd, alias, args);
                }
                return tablist;
            }
        }
    } else if (args.length == 3) {
        if (args[2].length() == 0) {
            // /dt ~ ~まで
            if (args[0].equalsIgnoreCase("add")) {
                // <MarkerType>を出す
                Plugin dynmap = plugin.getServer().getPluginManager().getPlugin("dynmap");
                if (dynmap == null || !dynmap.isEnabled()) {
                    SendMessage(sender, cmd, "Dynmapプラグインが停止中、もしくは存在しないため、このコマンドを利用できません。");
                    return plugin.onTabComplete(sender, cmd, alias, args);
                }
                List<String> tablist = new ArrayList<>();
                DynmapAPI dynmapapi = (DynmapAPI) dynmap;
                MarkerAPI markerapi = dynmapapi.getMarkerAPI();
                for (MarkerSet markerset : markerapi.getMarkerSets()) {
                    tablist.add(markerset.getMarkerSetLabel());
                }
                return tablist;
            }
        } else {
            if (args[0].equalsIgnoreCase("add")) {
                Plugin dynmap = plugin.getServer().getPluginManager().getPlugin("dynmap");
                if (dynmap == null || !dynmap.isEnabled()) {
                    SendMessage(sender, cmd, "Dynmapプラグインが停止中、もしくは存在しないため、このコマンドを利用できません。");
                    return plugin.onTabComplete(sender, cmd, alias, args);
                }
                List<String> tablist = new ArrayList<>();
                DynmapAPI dynmapapi = (DynmapAPI) dynmap;
                MarkerAPI markerapi = dynmapapi.getMarkerAPI();
                for (MarkerSet markerset : markerapi.getMarkerSets()) {
                    tablist.add(markerset.getMarkerSetLabel());
                }
                List<String> tablistFor = new ArrayList<>();
                tablistFor.addAll(tablist);
                for (String tab : tablistFor) {
                    if (!tab.toLowerCase().startsWith(args[2].toLowerCase())) {
                        tablist.remove(tab);
                    }
                }
                if (tablist.size() == 0) {
                    return plugin.onTabComplete(sender, cmd, alias, args);
                }
                return tablist;
            }
        }
    }
    // JavaPlugin#onTabComplete()を呼び出す
    return plugin.onTabComplete(sender, cmd, alias, args);
}
Also used : MarkerSet(org.dynmap.markers.MarkerSet) Player(org.bukkit.entity.Player) DynmapAPI(org.dynmap.DynmapAPI) ArrayList(java.util.ArrayList) MarkerAPI(org.dynmap.markers.MarkerAPI) ArrayList(java.util.ArrayList) List(java.util.List) Marker(org.dynmap.markers.Marker) Plugin(org.bukkit.plugin.Plugin) JavaPlugin(org.bukkit.plugin.java.JavaPlugin)

Example 5 with MarkerSet

use of org.dynmap.markers.MarkerSet in project MagicPlugin by elBukkit.

the class DynmapController method showCastMarker.

public void showCastMarker(Mage mage, Spell spell, SpellResult result) {
    if (dynmap != null && dynmap.markerAPIInitialized()) {
        MarkerAPI markers = dynmap.getMarkerAPI();
        MarkerSet spellSet = markers.getMarkerSet("Spells");
        if (spellSet == null) {
            spellSet = markers.createMarkerSet("Spells", "Spell Casts", null, false);
        }
        final String markerId = "Spell-" + mage.getId();
        final String targetId = "SpellTarget-" + mage.getId();
        int range = 32;
        double radius = 3.0 * mage.getPower() + 3;
        int width = (int) (2.0 * mage.getPower()) + 2;
        radius = Math.min(64, radius);
        width = Math.min(8, width);
        final Location location = spell.getLocation();
        if (location == null)
            return;
        Color mageColor = mage.getEffectColor();
        mageColor = mageColor == null ? Color.PURPLE : mageColor;
        Color spellColor = spell.getColor();
        spellColor = spellColor == null ? mageColor : spellColor;
        final String worldName = location.getWorld().getName();
        Date now = new Date();
        String label = spell.getName() + " : " + mage.getName() + " @ " + dateFormatter.format(now);
        // Create a circular disc for a spell cast
        CircleMarker marker = spellSet.findCircleMarker(markerId);
        if (marker != null) {
            marker.setCenter(worldName, location.getX(), location.getY(), location.getZ());
            marker.setLabel(label);
        } else {
            marker = spellSet.createCircleMarker(markerId, label, false, worldName, location.getX(), location.getY(), location.getZ(), radius, radius, false);
        }
        marker.setRadius(radius, radius);
        marker.setLineStyle(1, 0.9, spellColor.asRGB());
        marker.setFillStyle(0.5, mageColor.asRGB());
        // Create a targeting indicator line
        Location target = spell.getTargetLocation();
        if (target == null) {
            target = location.clone();
            Vector direction = location.getDirection();
            direction.normalize().multiply(range);
            target.add(direction);
        }
        PolyLineMarker targetMarker = spellSet.findPolyLineMarker(targetId);
        if (targetMarker != null) {
            targetMarker.setCornerLocation(0, location.getX(), location.getY(), location.getZ());
            targetMarker.setCornerLocation(1, target.getX(), target.getY(), target.getZ());
            targetMarker.setLabel(label);
        } else {
            double[] x = { location.getX(), target.getX() };
            double[] y = { location.getY(), target.getY() };
            double[] z = { location.getZ(), target.getZ() };
            targetMarker = spellSet.createPolyLineMarker(targetId, label, false, worldName, x, y, z, false);
        }
        targetMarker.setLineStyle(width, 0.8, spellColor.asRGB());
    }
}
Also used : MarkerSet(org.dynmap.markers.MarkerSet) CircleMarker(org.dynmap.markers.CircleMarker) Color(org.bukkit.Color) MarkerAPI(org.dynmap.markers.MarkerAPI) PolyLineMarker(org.dynmap.markers.PolyLineMarker) Vector(org.bukkit.util.Vector) Date(java.util.Date) Location(org.bukkit.Location)

Aggregations

MarkerAPI (org.dynmap.markers.MarkerAPI)6 MarkerSet (org.dynmap.markers.MarkerSet)6 Marker (org.dynmap.markers.Marker)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Location (org.bukkit.Location)3 Player (org.bukkit.entity.Player)3 Plugin (org.bukkit.plugin.Plugin)3 JavaPlugin (org.bukkit.plugin.java.JavaPlugin)3 DynmapAPI (org.dynmap.DynmapAPI)3 CircleMarker (org.dynmap.markers.CircleMarker)3 PolyLineMarker (org.dynmap.markers.PolyLineMarker)3 Date (java.util.Date)2 MarkerIcon (org.dynmap.markers.MarkerIcon)2 Vector (com.sk89q.worldedit.Vector)1 WorldGuardPlugin (com.sk89q.worldguard.bukkit.WorldGuardPlugin)1 RegionManager (com.sk89q.worldguard.protection.managers.RegionManager)1 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)1 SimpleDateFormat (java.text.SimpleDateFormat)1 HashMap (java.util.HashMap)1