@Override public void execute(CommandExecutor executor, String[] args) { URL u; String[] lines; try { u = new URL("http://server.mcforge.net/gcinfo.txt"); lines = WebUtils.readContentsToArray(u); } catch (MalformedURLException e) { executor.sendMessage("An error occured!"); e.printStackTrace(); return; } catch (IOException e) { executor.sendMessage("An error occured!"); e.printStackTrace(); return; } for (int i = 0; i < lines.length; i++) { executor.sendMessage(lines[i]); } if (executor instanceof Player) { Player p = (Player) executor; if (DataHandler.agreedToRules(p)) p.sendMessage("&2You have agreed to the Global Chat rules!"); else p.sendMessage("&4You haven't agreed to the Global Chat rules!"); if (DataHandler.ignoringGC(p)) p.sendMessage("&4You're ignoring the Global Chat!"); } }
@Override public void execute(CommandExecutor executor, String[] args) { if (args.length == 1) { Player who = executor.getServer().findPlayer(args[0]); if (who != null) { if (executor.getServer().findPlayer(args[0]) == executor) { executor.sendMessage("You can't change your own rank!"); return; } if (who.getGroup().permissionlevel >= executor.getGroup().permissionlevel && (!(executor instanceof Console))) { executor.sendMessage("You can't rank players of the equal or higher rank!"); return; } Group toRank = GroupActions.getPreviousRank(args[0]); if (toRank == null) { executor.sendMessage("No lower ranks exist!"); return; } if (toRank.permissionlevel >= executor.getGroup().permissionlevel && (!(executor instanceof Console))) { executor.sendMessage("You can't rank players to a rank higher than or equal to yours!"); return; } try { if (GroupManagerAPI.demotePlayer(args[0])) { Player pl = executor.getServer().findPlayer(args[0]); executor .getServer() .sendGlobalMessage( pl.getDisplayColor() + pl.username + executor.getServer().defaultColor + " was demoted to " + toRank.color + toRank.name); } else { executor.sendMessage("Failed to set player's rank!"); } } catch (NotSerializableException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } else { Group ranked = Group.getGroup(args[0]); if (ranked == null) { Group.getDefault().addMember(args[0]); ranked = Group.getDefault(); } if (ranked.permissionlevel >= executor.getGroup().permissionlevel && (!(executor instanceof Console))) { executor.sendMessage("You can't rank players of the equal or higher rank!"); return; } Group toRank = GroupActions.getPreviousRank(args[0]); if (toRank == null) { executor.sendMessage("No lower ranks exist!"); return; } if (toRank.permissionlevel >= executor.getGroup().permissionlevel && (!(executor instanceof Console))) { executor.sendMessage("You can't rank players to a rank higher than or equal to yours!"); return; } try { if (GroupManagerAPI.demotePlayer(args[0])) { executor .getServer() .sendGlobalMessage( "&f(Offline)" + args[0] + executor.getServer().defaultColor + " was demoted to " + toRank.color + toRank.name); } else { executor.sendMessage("Failed to set player's rank!"); } } catch (NotSerializableException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } else { help(executor); return; } }