Example usage for java.awt.geom Point2D toString

List of usage examples for java.awt.geom Point2D toString

Introduction

In this page you can find the example usage for java.awt.geom Point2D toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:com.wasteofplastic.beaconz.commands.AdminCmdHandler.java

@SuppressWarnings("deprecation")
@Override/* www. j av a 2s.com*/
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (sender instanceof Player) {
        Player player = (Player) sender;
        if (!player.isOp() && !player.hasPermission("beaconz.admin")) {
            senderMsg(sender, ChatColor.RED + Lang.errorYouDoNotHavePermission);
            return true;
        }
    }
    Team team = null;
    Game game = null;
    Player player = null;

    if (args.length == 0 || (args.length == 1 && args[0].toLowerCase().equals("help"))) {
        ChatColor cc1 = ChatColor.GREEN;
        ChatColor cc2 = ChatColor.YELLOW;
        ChatColor cc3 = ChatColor.AQUA;
        senderMsg(sender, cc1 + Lang.helpLine);
        senderMsg(sender, cc2 + Lang.helpAdminTitle);
        senderMsg(sender, cc1 + Lang.helpLine);
        if (sender instanceof Player) {
            senderMsg(sender,
                    cc1 + "/" + label + cc2 + " claim [unowned | <team>]" + cc3 + Lang.helpAdminClaim);
        }
        senderMsg(sender, cc1 + "/" + label + cc2 + " delete <gamename>" + cc3 + Lang.helpAdminDelete);
        //senderMsg(sender, cc1 + "/" + label + cc2 + " distribution <decimal between 0 and 1>" + cc3 + Lang.helpAdminDistribution);
        if (sender instanceof Player) {
            senderMsg(sender, cc1 + "/" + label + cc2 + " join <gamename> <team>" + cc3 + Lang.helpAdminJoin);
        }
        senderMsg(sender, cc1 + "/" + label + cc2 + " games" + cc3 + Lang.helpAdminGames);
        //senderMsg(sender, cc1 + "/" + label + cc2 + " kick <online playername> <gamename>" + cc3 + Lang.helpAdminKick);
        //senderMsg(sender, cc1 + "/" + label + cc2 + " restart <gamename>" + cc3 + Lang.helpAdminRestart);
        //senderMsg(sender, cc1 + "/" + label + cc2 + " regenerate <gamename>" + cc3 + Lang.helpAdminRegenerate);
        //senderMsg(sender, cc1 + "/" + label + cc2 + " pause <gamename>" + cc3 + Lang.helpAdminPause);
        //senderMsg(sender, cc1 + "/" + label + cc2 + " resume <gamename>" + cc3 + Lang.helpAdminResume);
        senderMsg(sender, cc1 + "/" + label + cc2 + " force_end <gamename>" + cc3 + Lang.helpAdminForceEnd);
        /*
        if (sender instanceof Player) {
        senderMsg(sender, cc1 + "/" + label + cc2 + " link <x> <z>" + cc3 + Lang.helpAdminLink);
        }*/
        senderMsg(sender,
                cc1 + "/" + label + cc2 + " list [all |<gamename>] [team]" + cc3 + Lang.helpAdminList);
        senderMsg(sender, cc1 + "/" + label + cc2 + " listparms <gamename>" + cc3 + Lang.helpAdminListParms);
        senderMsg(sender, cc1 + "/" + label + cc2 + " newgame <gamename> [<parm1:value> <parm2:value>...]" + cc3
                + Lang.helpAdminNewGame.replace("[label]", label));
        senderMsg(sender, cc1 + "/" + label + cc2 + " reload" + cc3 + Lang.helpAdminReload);
        //senderMsg(sender, cc1 + "/" + label + cc2 + " setgameparms <gamename> <parm1:value> <parm2:value>... " + cc3 + Lang.helpAdminSetGameParms.replace("[label]", label));
        if (sender instanceof Player) {
            senderMsg(sender, cc1 + "/" + label + cc2 + " setspawn <team>" + cc3 + Lang.helpAdminSetTeamSpawn);
            senderMsg(sender, cc1 + "/" + label + cc2 + " setspawn " + cc3 + Lang.helpAdminSetLobbySpawn);
            senderMsg(sender, cc1 + "/" + label + cc2 + " switch " + cc3 + Lang.helpAdminSwitch);
        }
        senderMsg(sender,
                cc1 + "/" + label + cc2 + " switch <online playername> " + cc3 + Lang.helpAdminSwitch);
        senderMsg(sender, cc1 + "/" + label + cc2 + " teams [all | <gamename>]" + cc3 + Lang.helpAdminTeams);
        //senderMsg(sender, cc1 + "/" + label + cc2 + " timertoggle [all | <gamename>]" + cc3 + Lang.helpAdminTimerToggle);

    } else {
        switch (args[0].toLowerCase()) {
        case "claim":
            if (args.length < 2) {
                senderMsg(sender, ChatColor.RED + "/" + label + " claim [unowned | <team>]");
            } else {
                if (!(sender instanceof Player)) {
                    senderMsg(sender, Lang.errorOnlyPlayers);
                } else {
                    // Check the argument
                    player = (Player) sender;
                    game = getGameMgr().getGame(player.getLocation());
                    team = game.getScorecard().getTeam(args[1]);
                    if (team == null && !args[1].equalsIgnoreCase("unowned")) {
                        senderMsg(sender, ChatColor.RED + "/" + label + " claim [unowned, "
                                + game.getScorecard().getTeamListString() + "]");
                    } else {
                        // See if the player is on a beacon
                        Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
                        if (!getRegister().isBeacon(block)) {
                            senderMsg(sender, Lang.errorYouHaveToBeStandingOnABeacon);
                        } else {
                            Point2D newClaim = new Point2D.Double(block.getX(), block.getZ());
                            player.sendMessage(
                                    Lang.beaconClaimingBeaconAt.replace("[location]", newClaim.toString()));
                            if (!getRegister().getBeaconRegister().containsKey(newClaim)) {
                                player.sendMessage(ChatColor.RED + Lang.errorNotInRegister + newClaim);
                            } else {
                                BeaconObj beacon = getRegister().getBeaconRegister().get(newClaim);
                                if (args[1].equalsIgnoreCase("unowned")) {
                                    getRegister().removeBeaconOwnership(beacon);
                                } else {
                                    // Claim a beacon
                                    //getRegister().getBeaconRegister().get(newClaim).setOwnership(team);
                                    getRegister().setBeaconOwner(beacon, team);
                                    block.setType(game.getScorecard().getBlockID(team).getItemType());
                                    block.setData(game.getScorecard().getBlockID(team).getData());
                                }
                                player.sendMessage(Lang.beaconClaimedForTeam.replace("[team]", args[1]));
                            }
                        }
                    }
                }
            }
            break;

        case "distribution":
            if (args.length < 2) {
                senderMsg(sender, ChatColor.RED + "/" + label + " distribution <fraction between 0 and 1> "
                        + Lang.helpAdminDistribution);
            } else {
                try {
                    double dist = Double.valueOf(args[1]);
                    if (dist > 0D && dist < 1D) {
                        Settings.distribution = dist;
                        senderMsg(sender, ChatColor.GREEN
                                + Lang.actionsDistributionSettingTo.replace("[value]", String.valueOf(dist)));
                        return true;
                    }
                } catch (Exception e) {
                    senderMsg(sender, ChatColor.RED + label + " distribution <fraction> - must be less than 1");
                }
            }
            break;

        case "switch":
            // Switch teams within a game
            if (args.length == 1) {
                if (!(sender instanceof Player)) {
                    senderMsg(sender, Lang.errorOnlyPlayers);
                    return true;
                } else {
                    player = (Player) sender;
                    team = getGameMgr().getPlayerTeam(player);
                    if (team == null) {
                        senderMsg(sender, ChatColor.RED + Lang.errorYouMustBeInATeam);
                        return true;
                    }
                    game = getGameMgr().getGame(team);
                    if (game == null) {
                        senderMsg(sender, ChatColor.RED + Lang.errorYouMustBeInAGame);
                        return true;
                    }

                    // Get the next team in this game
                    for (Team newTeam : game.getScorecard().getTeams()) {
                        if (!newTeam.equals(team)) {
                            // Found an alternative
                            game.getScorecard().addTeamPlayer(newTeam, player);
                            senderMsg(sender, ChatColor.GREEN
                                    + Lang.actionsSwitchedToTeam.replace("[team]", newTeam.getDisplayName()));
                            // Remove any potion effects
                            for (PotionEffect effect : player.getActivePotionEffects())
                                player.removePotionEffect(effect.getType());
                            return true;
                        }
                    }
                    senderMsg(sender, ChatColor.RED + Lang.errorNoSuchTeam);
                    return true;
                }
            } else if (args.length == 2) {
                player = getServer().getPlayer(args[1]);
                if (player == null) {
                    senderMsg(sender, Lang.errorUnknownPlayer);
                    return true;
                } else {
                    team = getGameMgr().getPlayerTeam(player);
                    if (team == null) {
                        senderMsg(sender, ChatColor.RED + Lang.errorNoSuchTeam);
                        return true;
                    }
                    game = getGameMgr().getGame(team);
                    if (game == null) {
                        senderMsg(sender, ChatColor.RED + Lang.errorNoSuchGame);
                        return true;
                    }

                    // Get the next team in this game
                    for (Team newTeam : game.getScorecard().getTeams()) {
                        if (!newTeam.equals(team)) {
                            // Found an alternative
                            game.getScorecard().addTeamPlayer(newTeam, player);
                            senderMsg(sender, ChatColor.GREEN + player.getName() + ": "
                                    + Lang.actionsSwitchedToTeam.replace("[team]", newTeam.getDisplayName()));
                            player.sendMessage(ChatColor.GREEN
                                    + Lang.actionsSwitchedToTeam.replace("[team]", newTeam.getDisplayName()));

                            // Remove any potion effects
                            for (PotionEffect effect : player.getActivePotionEffects())
                                player.removePotionEffect(effect.getType());
                            return true;
                        }
                    }
                    senderMsg(sender, ChatColor.RED + Lang.errorNoSuchTeam);
                    return true;
                }
            }
        case "join":
            if (args.length < 3) {
                senderMsg(sender, ChatColor.RED + "/" + label + " join <gamename> <team>" + Lang.helpAdminJoin);
            } else {
                if (!(sender instanceof Player)) {
                    senderMsg(sender, Lang.errorOnlyPlayers);
                } else {
                    player = (Player) sender;
                    team = null;
                    game = getGameMgr().getGame(args[1]);
                    if (game != null) {
                        if (game.getScorecard().getTeam(args[2]) != null) {
                            team = game.getScorecard().getTeam(args[2]);
                            game.getScorecard().addTeamPlayer(team, player);
                            player.setScoreboard(game.getScorecard().getScoreboard());
                            game.getScorecard().sendPlayersHome(player, false);
                            senderMsg(sender, ChatColor.GREEN
                                    + Lang.actionsYouAreInTeam.replace("[team]", team.getDisplayName()));
                        }
                    } else {
                        senderMsg(sender, "/" + label + " join <gamename> <team> - " + Lang.errorNoSuchGame);
                    }
                }
            }
            break;

        case "games":
            senderMsg(sender, ChatColor.GREEN + Lang.adminGamesDefined);
            senderMsg(sender,
                    ChatColor.AQUA + Lang.adminGamesTheLobby + " - " + getGameMgr().getLobby().displayCoords());
            int cnt = 0;
            for (Game g : getGameMgr().getGames().values()) {
                cnt++;
                senderMsg(sender, ChatColor.AQUA + g.getName() + " - " + g.getRegion().displayCoords());
            }
            if (cnt == 0)
                senderMsg(sender, ChatColor.AQUA + Lang.adminGamesNoOthers);
            break;

        case "kick":
            if (args.length < 3) {
                senderMsg(sender, ChatColor.RED + "/" + label + Lang.helpAdminKick);
            } else {
                player = getServer().getPlayer(args[1]);
                if (player == null && args[1] != "all") {
                    senderMsg(sender, Lang.errorUnknownPlayer);
                } else {
                    game = getGameMgr().getGame(args[2]);
                    if (game == null) {
                        senderMsg(sender, Lang.errorNoSuchGame);
                    } else {
                        if (args[2].equals("all")) {
                            game.kickAll();
                            senderMsg(sender, Lang.adminKickAllPlayers.replace("[name]", game.getName()));
                        } else {
                            game.kick(sender, player);
                            senderMsg(sender, (Lang.adminKickPlayer.replace("[player]", player.getName())
                                    .replace("[name]", game.getName())));
                        }
                    }
                }
            }
            break;

        /*
        case "restart":
        if (args.length < 2) {
            senderMsg(sender, ChatColor.RED + "/" + label + " restart <gamename> - " + Lang.helpAdminRestart);
        } else {
            game = getGameMgr().getGames().get(args[1]);
            if (game == null) {
                senderMsg(sender, ChatColor.RED + Lang.errorNoSuchGame + "'" + args[1] + "'");
            } else {
                game.restart();
                senderMsg(sender, ChatColor.GREEN + Lang.adminRestart.replace("[name]", game.getName()));
            }
        }
        break;
         */
        case "delete":
            if (args.length < 2) {
                senderMsg(sender, ChatColor.RED + "/" + label + " delete <gamename> - " + Lang.helpAdminDelete);
            } else {
                game = getGameMgr().getGames().get(args[1]);
                if (game == null) {
                    senderMsg(sender, ChatColor.RED + Lang.errorNoSuchGame + "'" + args[1] + "'");
                } else {
                    senderMsg(sender,
                            ChatColor.GREEN + Lang.adminDeletingGame.replace("[name]", game.getName()));
                    getGameMgr().delete(sender, game);
                    senderMsg(sender,
                            ChatColor.GREEN + Lang.adminDeletedGame.replace("[name]", game.getName()));
                }
            }
            break;

        /*
        case "pause":
        if (args.length < 2) {
            senderMsg(sender, ChatColor.RED + "/" + label + " pause <gamename> " + Lang.helpAdminPause);
        } else {
            game = getGameMgr().getGames().get(args[1]);
            if (game == null) {
                senderMsg(sender, ChatColor.RED + Lang.errorNoSuchGame + "'" + args[1] + "'");
            } else {
                game.pause();
                senderMsg(sender, ChatColor.GREEN + (Lang.adminPaused.replace("[name]", game.getName()).replace("[label]", label)));
            }
        }
        break;
                
        case "resume":
        if (args.length < 2) {
            senderMsg(sender, ChatColor.RED + "/" + label + " resume <gamename> " + Lang.helpAdminResume);
        } else {
            game = getGameMgr().getGames().get(args[1]);
            if (game == null) {
                senderMsg(sender, ChatColor.RED + Lang.errorNoSuchGame + "'" + args[1] + "'");
            } else {
                game.resume();
                senderMsg(sender, ChatColor.GREEN + Lang.adminResume.replace("[name]", game.getName()));
            }
        }
        break;
         */
        case "force_end":
            if (args.length < 2) {
                senderMsg(sender,
                        ChatColor.RED + "/" + label + " force_end <gamename>" + Lang.helpAdminForceEnd);
            } else {
                game = getGameMgr().getGames().get(args[1]);
                if (game == null) {
                    senderMsg(sender, ChatColor.RED + Lang.errorNoSuchGame + "'" + args[1] + "'");
                } else {
                    game.forceEnd();
                    senderMsg(sender, ChatColor.GREEN + Lang.adminForceEnd.replace("[name]", game.getName()));
                    //senderMsg(sender, ChatColor.GREEN + Lang.adminForceRestart.replace("[label]", label));
                }
            }
            break;
        /*
        case "link":
        if (args.length < 3) {
            senderMsg(sender, ChatColor.RED + "/" + label + " link <x> <z> " + Lang.helpAdminLink);
        } else {
            if (!(sender instanceof Player)) {
                senderMsg(sender, Lang.errorOnlyPlayers);
            } else {
                player = (Player) sender;
                BeaconObj origin = getRegister().getBeaconAt(player.getLocation().getBlockX(), player.getLocation().getBlockZ());
                if (origin == null) {
                    player.sendMessage(ChatColor.RED + Lang.errorYouHaveToBeStandingOnABeacon);
                } else {
                    BeaconObj destination = getRegister().getBeaconAt(Integer.valueOf(args[1]), Integer.valueOf(args[2]));
                    if (destination == null) {
                        player.sendMessage(ChatColor.RED + Lang.errorNoBeaconThere);
                    } else {
                        origin.addOutboundLink(destination);
                    }
                }
            }
        }
        break;
         */
        case "list":
            if (args.length < 2) {
                senderMsg(sender,
                        ChatColor.RED + "/" + label + " list [all |<gamename>] [team] " + Lang.helpAdminList);
            } else if (args.length == 3) {
                listBeacons(sender, args[1], args[2]);
            } else {
                listBeacons(sender, args[1]);
            }
            break;

        case "newgame":
            if (args.length < 2) {
                senderMsg(sender, "/" + label
                        + " newgame <gamename> [<parm1:value> <parm2:value>...] - parameters are optional");
                senderMsg(sender,
                        "/" + label + " do /" + label + " newgame help for a list of the possible parameters");
            } else {
                if (args[1].toLowerCase().equals("help")) {
                    senderMsg(sender, "/" + label + " newgame <gamename> [<parm1:value> <parm2:value>...]");
                    senderMsg(sender, ChatColor.GREEN + "The optional parameters and their values are:");
                    senderMsg(sender, ChatColor.YELLOW + "gamemode -  " + ChatColor.AQUA
                            + " values can be either 'minigame' or 'strategy' - e.g gamemode:strategy");
                    senderMsg(sender, ChatColor.YELLOW + "size -  " + ChatColor.AQUA
                            + " length for the side of the game region - e.g. size:500");
                    senderMsg(sender, ChatColor.YELLOW + "teams -  " + ChatColor.AQUA
                            + " the number of teams in the game - e.g. teams:2");
                    senderMsg(sender, ChatColor.YELLOW + "goal -  " + ChatColor.AQUA
                            + "  one of 'area', 'beacons', 'links', 'triangles' - e.g. goal:links");
                    senderMsg(sender, ChatColor.YELLOW + "goalvalue -  " + ChatColor.AQUA
                            + "  the number objective for the goal - e.g goalvalue:100");
                    senderMsg(sender, ChatColor.YELLOW + "countdown -  " + ChatColor.AQUA
                            + "  the game's timer, in seconds. 0 means the timer runs up, open-ended; any other value meands the timer runs a countdown from that time. - e.g. countdown:600");
                    senderMsg(sender, ChatColor.YELLOW + "scoretypes -  " + ChatColor.AQUA
                            + "  the scores to be displayed on the sidebar. Can be any combination of goal names separated by '-' e.g scoretypes:area-triangles-beacons-links");
                    senderMsg(sender, ChatColor.YELLOW + "distribution -  " + ChatColor.AQUA
                            + "  overrides the system's default beacon distribution - specify a number between 0.01 and 0.99 for the probability of any one chunk containing a beacon.");
                } else {
                    String[] parmargs = new String[args.length - 2];
                    System.arraycopy(args, 2, parmargs, 0, parmargs.length);
                    game = getGameMgr().getGame(args[1]);
                    if (game != null) {
                        senderMsg(sender, Lang.errorAlreadyExists.replace("[name]", game.getName()));
                    } else {
                        //Check the parameters first, if any
                        if (parmargs.length > 0) {
                            String errormsg = setDefaultParms(parmargs); // temporarily set up the given parameters as default
                            if (!errormsg.isEmpty()) {
                                senderMsg(sender, ChatColor.RED + Lang.errorError + errormsg);
                                getGameMgr().setGameDefaultParms(); // restore the default parameters (just in case)
                            } else {
                                senderMsg(sender, ChatColor.GREEN + Lang.adminNewGameBuilding);
                                getGameMgr().newGame(args[1]); // create the new game
                                getGameMgr().setGameDefaultParms(); // restore the default parameters
                                senderMsg(sender, ChatColor.GREEN + Lang.generalSuccess);
                            }
                        } else {
                            senderMsg(sender, ChatColor.GREEN + Lang.adminNewGameBuilding);
                            getGameMgr().newGame(args[1]);
                            senderMsg(sender, ChatColor.GREEN + Lang.generalSuccess);
                        }
                    }
                }
            }
            break;

        case "reload":
            getRegister().saveRegister();
            getGameMgr().saveAllGames();
            this.getBeaconzPlugin().reloadConfig();
            this.getBeaconzPlugin().loadConfig();
            getGameMgr().reload();
            getRegister().loadRegister();
            senderMsg(sender, ChatColor.RED + Lang.adminReload);
            break;

        case "listparms":
            if (args.length < 2) {
                senderMsg(sender, "/" + label + " listparms <gamename> " + Lang.helpAdminListParms);
            } else {
                game = getGameMgr().getGame(args[1]);
                if (game == null) {
                    senderMsg(sender, Lang.errorNoSuchGame + "'" + args[1] + "'");
                } else {
                    senderMsg(sender, ChatColor.YELLOW + Lang.adminParmsMode + ": " + ChatColor.AQUA
                            + game.getGamemode());
                    senderMsg(sender, ChatColor.YELLOW + Lang.adminParmsTeams + ": " + ChatColor.AQUA
                            + game.getNbrTeams());
                    senderMsg(sender, ChatColor.YELLOW + Lang.adminParmsGoal + ": " + ChatColor.AQUA
                            + game.getGamegoal());
                    senderMsg(sender,
                            ChatColor.YELLOW + Lang.adminParmsGoalValue + ": " + ChatColor.AQUA
                                    + (game.getGamegoalvalue() == 0 ? Lang.adminParmsUnlimited
                                            : String.format(Locale.US, "%,d", game.getGamegoalvalue())));
                    //senderMsg(sender, ChatColor.YELLOW + Lang.adminParmsCountdown + ": " + ChatColor.AQUA + (game.getCountdownTimer() == 0 ? Lang.adminParmsUnlimited : game.getCountdownTimer()));
                    senderMsg(sender, ChatColor.YELLOW + Lang.adminParmsScoreTypes + ": " + ChatColor.AQUA
                            + game.getScoretypes());
                }
            }
            return true;
        /*
        case "setgameparms":
        if (args.length < 2) {
            senderMsg(sender, "/" + label + " setgameparms <gamename> <parm1:value> <parm2:value>");
            senderMsg(sender, "setgameparms defines the game parameters, it DOES NOT restart the game");
            senderMsg(sender, "use /" + label + " setgameparms help for a list of the possible parameters");
            senderMsg(sender, "use /" + label + " restart <game> to restart a game using the new parameters");
        } else {
            if (args[1].toLowerCase().equals("help")) {
                senderMsg(sender, ChatColor.RED  + "/" + label + " setgameparms <gamename> <parm1:value> <parm2:value>... ");
                senderMsg(sender, ChatColor.GREEN  + "The possible parameters and their values are:");
                //senderMsg(sender, ChatColor.YELLOW  + "gamemode -  " + ChatColor.AQUA + " values can be either 'minigame' or 'strategy' - e.g gamemode:strategy");
                senderMsg(sender, ChatColor.YELLOW  + "teams -  " + ChatColor.AQUA + " the number of teams in the game - e.g. teams:3");
                senderMsg(sender, ChatColor.YELLOW  + "goal -  " + ChatColor.AQUA + "  one of 'area', 'beacons', 'links', 'triangles' - e.g. goal:links");
                senderMsg(sender, ChatColor.YELLOW  + "goalvalue -  " + ChatColor.AQUA + "  the number objective for the goal - e.g goalvalue:100");
                //senderMsg(sender, ChatColor.YELLOW  + "countdown -  " + ChatColor.AQUA + "  the game's timer, in seconds. 0 means the timer runs up, open-ended; any other value meands the timer runs a countdown from that time. - e.g. countdown:600");
                senderMsg(sender, ChatColor.YELLOW  + "scoretypes -  " + ChatColor.AQUA + "  the scores to be displayed on the sidebar. Can be any combination of goal names separated by '-' e.g scoretypes:area-triangles-beacons-links");
            } else {
                String [] parmargs = new String [args.length-2];
                System.arraycopy(args, 2, parmargs, 0, parmargs.length);
                game = getGameMgr().getGame(args[1]);
                if (game == null) {
                    senderMsg(sender, ChatColor.RED + Lang.errorNoSuchGame + "'" + args[1] + "'");
                } else {
                    String errormsg = this.setGameParms(game, parmargs);
                    if (!errormsg.isEmpty()) {
                        senderMsg(sender, ChatColor.RED + Lang.errorError + errormsg);
                    } else {
                        senderMsg(sender, ChatColor.GREEN + "Game parameters set.");
                        if (!(sender instanceof Player)) {
                            // Console
                            senderMsg(sender, "use " + ChatColor.GREEN + label + " restart " + game.getName() + ChatColor.RESET + " to restart the game using the new parameters");
                        } else {
                            senderMsg(sender, "use " + ChatColor.GREEN + "/" + label + " restart " + game.getName() + ChatColor.RESET +" to restart the game using the new parameters");
                        }
                    }
                }
            }
                
        }
        break;
         */
        case "setspawn":
            if (args.length > 2) {
                //senderMsg(sender, ChatColor.RED + "/" + label + " setspawn <team> " + Lang.helpAdminSetTeamSpawn);
                senderMsg(sender, ChatColor.RED + "/" + label + " setspawn " + Lang.helpAdminSetLobbySpawn);
            } else {
                // Admin set team spawn
                if (!(sender instanceof Player)) {
                    senderMsg(sender, ChatColor.RED + Lang.errorOnlyPlayers);
                    return true;
                }
                // Check if the player is in the lobby
                player = (Player) sender;
                if (args.length == 1 && getGameMgr().getLobby().isPlayerInRegion(player)) {
                    getGameMgr().getLobby().setSpawnPoint(player.getLocation());
                    senderMsg(sender,
                            ChatColor.GREEN + Lang.generalSuccess + " (" + player.getLocation().getBlockX()
                                    + "," + player.getLocation().getBlockY() + ","
                                    + player.getLocation().getBlockZ() + ")");
                    return true;
                } else {
                    senderMsg(sender, ChatColor.RED + Lang.helpAdminSetLobbySpawn);
                    return true;
                }
                // Check team name given exists
                /*
                game = getGameMgr().getGame(player.getLocation());
                if (game == null) {
                senderMsg(sender, Lang.adminSetSpawnNeedToBeInGame);
                } else {
                team = game.getScorecard().getTeam(args[1]);
                if (team == null) {
                    senderMsg(sender, ChatColor.RED + Lang.errorNoSuchTeam + " Use " + game.getScorecard().getTeamListString());
                    return true;
                }
                game.getScorecard().setTeamSpawnPoint(team, (player.getLocation()));
                senderMsg(sender, ChatColor.GREEN + Lang.generalSuccess);
                }*/
            }
            break;

        case "teams":
            if (args.length < 2) {
                senderMsg(sender,
                        ChatColor.RED + "/" + label + " teams [all | <gamename>] " + Lang.helpAdminTeams);
            } else {
                Boolean foundgame = false;
                for (String gname : getGameMgr().getGames().keySet()) {
                    if (args[1].toLowerCase().equals("all") || gname.equals(args[1])) {
                        foundgame = true;
                        game = getGameMgr().getGames().get(gname);
                        senderMsg(sender, ChatColor.GREEN + Lang.generalTeams + " - " + gname);
                        Scoreboard sb = game.getScorecard().getScoreboard();
                        if (sb == null) {
                            senderMsg(sender, ChatColor.RED + Lang.errorNoSuchGame + "'" + args[1] + "'");
                        } else {
                            HashMap<Team, List<String>> teamMembers = game.getScorecard().getTeamMembers();
                            for (Team t : teamMembers.keySet()) {
                                senderMsg(sender, "==== " + t.getDisplayName() + " ====");
                                String memberlist = "";
                                for (String uuid : teamMembers.get(t)) {
                                    memberlist = memberlist + "["
                                            + getServer().getOfflinePlayer(UUID.fromString(uuid)).getName()
                                            + "] ";
                                }
                                senderMsg(sender, ChatColor.WHITE + Lang.generalMembers + ": " + memberlist);
                            }
                        }
                    }
                }
                if (!foundgame) {
                    if (args[1].toLowerCase().equals("all")) {
                        senderMsg(sender, Lang.errorNoGames);
                    } else {
                        senderMsg(sender, ChatColor.RED + Lang.errorNoSuchGame + "'" + args[1] + "'");
                    }
                }
            }
            break;
        /*
        case "timertoggle":
        if (args.length < 2) {
            senderMsg(sender, ChatColor.RED + "/" + label + " timertoggle [all | <gamename>] " + Lang.helpAdminTimerToggle);
        } else {
            if (args[1].toLowerCase().equals("all")) {
                Settings.showTimer = ! Settings.showTimer;
                for (Game g : getGameMgr().getGames().values()) {
                    g.getScorecard().toggleTimer();
                }
                senderMsg(sender, ChatColor.GREEN + Lang.generalSuccess);
            } else {
                game = getGameMgr().getGames().get(args[1]);
                if (game == null) {
                    senderMsg(sender, ChatColor.RED + Lang.errorNoSuchGame + "'" + args[1] + "'");
                } else {
                    game.getScorecard().toggleTimer();
                    senderMsg(sender, ChatColor.GREEN + Lang.generalSuccess);
                }
            }
        }
        break;
         */
        default:
            senderMsg(sender, ChatColor.RED + Lang.errorUnknownCommand);
            break;
        }

    }

    return true;
}

From source file:org.jcurl.core.base.CurveTransformedTest.java

public void testAffineTransformRotate() {
    final Rock v0 = new RockDouble(1, 1.5, 0.3);
    final double[] d = { v0.getY(), -v0.getX(), v0.getX(), v0.getY(), 0, 0 };
    final AffineTransform at = new AffineTransform(d);
    final double v = v0.distance(0, 0);
    at.scale(1 / v, 1 / v);/*  w  w  w.  jav  a2  s. com*/
    assertEquals(AffineTransform.TYPE_GENERAL_ROTATION, at.getType());
    assertEquals("", 1.0, at.getDeterminant(), 1e-9);
    assertEquals("", 0.8320502943378437, at.getScaleX(), 1e-9);
    assertEquals("", at.getScaleX(), at.getScaleY(), 1e-9);
    assertEquals("", 0.5547001962252291, at.getShearX(), 1e-9);
    assertEquals("", -at.getShearX(), at.getShearY(), 1e-9);
    assertEquals("", 0.0, at.getTranslateX(), 1e-9);
    assertEquals("", 0.0, at.getTranslateY(), 1e-9);
    Point2D p = null;
    p = at.transform(new Point2D.Double(1, 0), null);
    assertEquals("Point2D.Double[0.8320502943378437, -0.5547001962252291]", p.toString());
    assertEquals("", 1.0, p.distanceSq(0, 0), 1e-9);
    p = at.transform(new Point2D.Double(0, 1), null);
    assertEquals("Point2D.Double[0.5547001962252291, 0.8320502943378437]", p.toString());
    assertEquals("", 1.0, p.distanceSq(0, 0), 1e-9);
    p = at.transform(new Point2D.Double(0.75, 1.5), null);
    assertEquals("Point2D.Double[1.4560880150912265, 0.8320502943378438]", p.toString());
    p = at.transform(new Point2D.Double(1.5, 3.0), null);
    assertEquals("Point2D.Double[2.912176030182453, 1.6641005886756877]", p.toString());
}

From source file:org.jcurl.core.base.CurveTransformedTest.java

/**
 * Test the transformation from a Rock Coordinates (rc) System at wc(3,3.5)
 * with positive y axis along wc(2,4.2) into World Coordinates (wc). Uses a
 * Point rc(5,1.3) = wc(8,2.5).//www .ja  v  a  2s  .c  o m
 */
public void testAffineTransformRotateShift() {
    final Point2D p0_wc = new Point2D.Double(3, 3.5);
    final Rock v0_wc = new RockDouble(2, 4.2, 0.3);
    final double v = v0_wc.distance(0, 0);
    final double[] d = { v0_wc.getY(), -v0_wc.getX(), v0_wc.getX(), v0_wc.getY(), 0, 0 };
    final AffineTransform at = new AffineTransform(d);
    at.scale(1 / v, 1 / v);
    assertEquals(AffineTransform.TYPE_GENERAL_ROTATION + AffineTransform.TYPE_UNIFORM_SCALE, at.getType());
    assertEquals(1.0, at.getDeterminant());
    assertEquals(0.9028605188239303, at.getScaleX());
    assertEquals(at.getScaleX(), at.getScaleY());
    assertEquals(0.42993358039234775, at.getShearX());
    assertEquals(-at.getShearX(), at.getShearY());
    assertEquals(0, at.getTranslateX());
    assertEquals(0, at.getTranslateY());
    Point2D p = null;
    p = at.transform(new Point2D.Double(5, 1.3), null);
    assertEquals("Point2D.Double[5.073216248629703, -0.9759492274906292]", p.toString());

    at.preConcatenate(AffineTransform.getTranslateInstance(p0_wc.getX(), p0_wc.getY()));
    assertEquals(AffineTransform.TYPE_GENERAL_ROTATION + AffineTransform.TYPE_TRANSLATION
            + AffineTransform.TYPE_UNIFORM_SCALE, at.getType());
    assertEquals(1.0, at.getDeterminant());
    assertEquals(0.9028605188239303, at.getScaleX());
    assertEquals(at.getScaleX(), at.getScaleY());
    assertEquals(0.42993358039234775, at.getShearX());
    assertEquals(-at.getShearX(), at.getShearY());
    assertEquals(p0_wc.getX(), at.getTranslateX());
    assertEquals(p0_wc.getY(), at.getTranslateY());

    p = at.transform(new Point2D.Double(5, 1.3), null);
    assertEquals("Point2D.Double[8.073216248629702, 2.524050772509371]", p.toString());
}

From source file:org.jcurl.core.base.CurveTransformedTest.java

/**
 * Test the transformation from a Rock Coordinates (rc) System at wc(3,3.5)
 * with positive y axis along wc(2,4.2) into World Coordinates (wc). Uses a
 * Point rc(5,1.3) = wc(8,2.5)./*w  w w  .j a  v  a 2  s .  c om*/
 * 
 * @see CurveTransformed#createRc2Wc(AffineTransform, Point2D, Point2D)
 */
public void testCreateRc2Wc() {
    final Point2D p0_wc = new Point2D.Double(3, 3.5);
    final Rock v0_wc = new RockDouble(2, 4.2, 0.3);
    final AffineTransform at = CurveTransformed.createRc2Wc(null, p0_wc, v0_wc);
    assertEquals(AffineTransform.TYPE_GENERAL_ROTATION + AffineTransform.TYPE_TRANSLATION, at.getType());
    assertEquals(1.0, at.getDeterminant());
    assertEquals(0.9028605188239303, at.getScaleX());
    assertEquals(at.getScaleX(), at.getScaleY());
    assertEquals(0.42993358039234775, at.getShearX());
    assertEquals(-at.getShearX(), at.getShearY());
    assertEquals(p0_wc.getX(), at.getTranslateX());
    assertEquals(p0_wc.getY(), at.getTranslateY());

    final Point2D rc = new Point2D.Double(5, 1.3);
    final Point2D wc = at.transform(rc, null);
    assertEquals("Point2D.Double[8.073216248629704, 2.524050772509371]", wc.toString());

    // angle in rc:
    double ang = Math.atan2(rc.getY(), rc.getX());
    assertEquals(14.574216198038739, rad2deg(ang));

    // wc rotation:
    ang = Math.atan2(at.getShearY(), at.getScaleY());
    assertEquals(-25.463345061871614, rad2deg(ang));
    final double[] d = new double[6];
    at.getMatrix(d);
    ang = Math.atan2(-d[2], d[3]);
    assertEquals(-25.463345061871614, rad2deg(ang));

    // angle in wc:
    ang = Math.atan2(wc.getY(), wc.getX());
    assertEquals(17.36159358309492, rad2deg(ang));
}