public static ChangeType fromName(String str) { str = str.toUpperCase(); ChangeType ct = null; try { ct = ChangeType.valueOf(str); } catch (Exception e) { } if (ct != null) return ct; try { if (Integer.valueOf(str) != null) return SPAWNLOC; } catch (Exception e) { } if (TeamUtil.getTeamIndex(str) != null) { return SPAWNLOC; } if (str.equalsIgnoreCase("wr")) return WAITROOM; if (str.equalsIgnoreCase("v")) return VLOC; return null; }
private static int verifySpawnLocation(CommandSender sender, String value) { if (!(sender instanceof Player)) { sendMessage(sender, "&cYou need to be in game to use this command"); return -1; } Integer locindex = -1; try { locindex = Integer.parseInt(value); } catch (Exception e) { } if (locindex == -1) { locindex = TeamUtil.getTeamIndex(value); if (locindex != null) locindex++; } if (locindex == null || locindex <= 0 || locindex > 100) { sendMessage(sender, "&cspawn number must be in the range [1-100]"); return -1; } return locindex; }