@EventHandler public void HeMan(PlayerChatEvent e) { if (e.isCancelled()) return; if (!e.getMessage().matches("(?i)by the power of gr[a|e]yskull!?")) return; Player p = e.getPlayer(); if (!plugin.isAuthorized(p, "rcmds.heman")) return; ItemStack is = p.getItemInHand(); if (is.getType() != Material.DIAMOND_SWORD) return; if (is.getEnchantments().isEmpty()) return; e.setCancelled(true); p.getWorld().strikeLightningEffect(p.getLocation()); Matcher m = Pattern.compile("(?i)by the power of gr[a|e]yskull!?").matcher(e.getMessage()); StringBuilder sb = new StringBuilder(); int last = 0; while (m.find()) { sb.append(e.getMessage().substring(last, m.start())); sb.append(m.group(0).toUpperCase()); last = m.end(); } sb.append(e.getMessage().substring(last)); plugin .getServer() .broadcastMessage( e.getFormat().replaceAll("(?i)by the power of gr[a|e]yskull!?", sb.toString())); e.setFormat(""); List<PotionEffect> effects = new ArrayList<PotionEffect>(); effects.add(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 1200, 2)); effects.add(new PotionEffect(PotionEffectType.REGENERATION, 1200, 2)); effects.add(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 1200, 2)); effects.add(new PotionEffect(PotionEffectType.SPEED, 1200, 2)); p.addPotionEffects(effects); }
@Override public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("kill")) { if (!plugin.isAuthorized(cs, "rcmds.kill")) { RUtils.dispNoPerms(cs); return true; } if (args.length < 1) { cs.sendMessage(cmd.getDescription()); return false; } Player t = plugin.getServer().getPlayer(args[0].trim()); if (t == null || plugin.isVanished(t, cs)) { cs.sendMessage(ChatColor.RED + "That player does not exist!"); return true; } if (plugin.isAuthorized(t, "rcmds.exempt.kill")) { cs.sendMessage(ChatColor.RED + "You cannot kill that player!"); return true; } t.setHealth(0); cs.sendMessage( ChatColor.BLUE + "You have killed " + ChatColor.GRAY + t.getDisplayName() + ChatColor.BLUE + "."); return true; } return false; }
public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("mobignore")) { if (!plugin.ah.isAuthorized(cs, "rcmds.mobignore")) { RUtils.dispNoPerms(cs); return true; } if (args.length < 1) { if (!(cs instanceof Player)) { cs.sendMessage(cmd.getDescription()); return false; } Player p = (Player) cs; PConfManager pcm = PConfManager.getPConfManager(p); Boolean isHidden = pcm.getBoolean("mobignored"); if (isHidden == null) isHidden = false; pcm.set("mobignored", !isHidden); String status = BooleanUtils.toStringOnOff(isHidden); cs.sendMessage( MessageColor.POSITIVE + "Toggled mob ignore " + MessageColor.NEUTRAL + status + MessageColor.POSITIVE + "."); return true; } Player t = plugin.getServer().getPlayer(args[0]); if (t == null || plugin.isVanished(t, cs)) { cs.sendMessage(MessageColor.NEGATIVE + "That player does not exist."); return true; } PConfManager pcm = PConfManager.getPConfManager(t); Boolean isHidden = pcm.getBoolean("mobignored"); if (isHidden == null) isHidden = false; pcm.set("mobignored", !isHidden); String status = BooleanUtils.toStringOnOff(isHidden); cs.sendMessage( MessageColor.POSITIVE + "Toggled mob ignore " + MessageColor.NEUTRAL + status + MessageColor.POSITIVE + " for " + MessageColor.NEUTRAL + t.getName() + MessageColor.POSITIVE + "."); t.sendMessage( MessageColor.NEUTRAL + cs.getName() + MessageColor.POSITIVE + " toggled mob ignore " + MessageColor.NEUTRAL + status + MessageColor.POSITIVE + " for you."); return true; } return false; }
@Override public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("kits")) { if (!plugin.isAuthorized(cs, "rcmds.kits")) { RUtils.dispNoPerms(cs); return true; } if (!(cs instanceof Player) && args.length < 1) { cs.sendMessage(cmd.getDescription()); return false; } final Map<String, Object> opts = plugin.getConfig().getConfigurationSection("kits").getValues(false); if (opts.keySet().isEmpty()) { cs.sendMessage(ChatColor.RED + "No kits found!"); return true; } String kits = ""; for (String s : opts.keySet()) { if (plugin.kitPerms && plugin.isAuthorized(cs, "rcmds.kit." + s)) kits = (kits.isEmpty()) ? kits + s : kits + ", " + s; else if (!plugin.kitPerms) kits = (kits.isEmpty()) ? kits + s : kits + ", " + s; } cs.sendMessage(ChatColor.BLUE + "Kits:"); if (kits.isEmpty()) return true; cs.sendMessage(kits); return true; } return false; }
@EventHandler public void commandCooldown(PlayerCommandPreprocessEvent e) { if (e.isCancelled()) return; String command = e.getMessage().split(" ")[0].toLowerCase().substring(1); if (plugin.getCommand(command) != null) command = plugin.getCommand(command).getName(); Player p = e.getPlayer(); if (plugin.isAuthorized(p, "rcmds.exempt.cooldown.commands")) return; Long currentcd = PConfManager.getPValLong(p, "command_cooldowns." + command); if (currentcd != null) { if (currentcd <= new Date().getTime()) { setCooldown(command, p); return; } p.sendMessage( ChatColor.RED + "You can't use that command for" + ChatColor.GRAY + RUtils.formatDateDiff(currentcd) + ChatColor.RED + "."); e.setCancelled(true); return; } setCooldown(command, p); }
@Override public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("muteall")) { if (!plugin.isAuthorized(cs, "rcmds.muteall")) { RUtils.dispNoPerms(cs); return true; } Player[] ps = plugin.getServer().getOnlinePlayers(); for (Player p : ps) { if (plugin.isVanished(p) || plugin.isAuthorized(p, "rcmds.exempt.mute")) continue; if (cs instanceof Player) { if (p == cs) continue; } if (!allMuted) { PConfManager.setPValBoolean(p, true, "muted"); p.sendMessage(ChatColor.RED + "You have been muted!"); } else { PConfManager.setPValBoolean(p, false, "muted"); p.sendMessage(ChatColor.BLUE + "You have been unmuted!"); } } if (!allMuted) { cs.sendMessage(ChatColor.BLUE + "You have muted all players."); allMuted = true; } else { cs.sendMessage(ChatColor.BLUE + "You have unmuted all players."); allMuted = false; } return true; } return false; }
@Override public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) { if (cmd.getName().equals("playertime")) { if (!plugin.isAuthorized(cs, "rcmds.playertime")) { RUtils.dispNoPerms(cs); return true; } if (args.length < 1) { cs.sendMessage(cmd.getDescription()); return false; } Player t = plugin.getServer().getPlayer(args[0]); if (t == null || plugin.isVanished(t, cs)) { cs.sendMessage(ChatColor.RED + "That player does not exist!"); return true; } String possessive = (t.getName().toLowerCase().endsWith("s")) ? "'" : "'s"; Integer time = null; if (args.length > 1) { try { time = Integer.valueOf(args[1]); } catch (Exception e) { cs.sendMessage(ChatColor.RED + "That time was invalid!"); return true; } } if (time == null) { t.resetPlayerTime(); cs.sendMessage( ChatColor.BLUE + "Synced " + ChatColor.GRAY + t.getName() + possessive + ChatColor.BLUE + " time with the server's."); return true; } if (plugin.smoothTime) smoothPlayerTimeChange(time, t); t.setPlayerTime(time, true); cs.sendMessage( ChatColor.BLUE + "Set " + ChatColor.GRAY + t.getName() + possessive + ChatColor.BLUE + " time to " + ChatColor.GRAY + time + " ticks" + ChatColor.BLUE + "."); return true; } return false; }
@Override public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("harm")) { if (!plugin.ah.isAuthorized(cs, "rcmds.harm")) { RUtils.dispNoPerms(cs); return true; } if (args.length < 2) { return false; } Player t = plugin.getServer().getPlayer(args[0]); if (t == null || plugin.isVanished(t, cs)) { cs.sendMessage(MessageColor.NEGATIVE + "That person is not online!"); return true; } int toDamage; try { toDamage = Integer.parseInt(args[1]); } catch (NumberFormatException e) { cs.sendMessage(MessageColor.NEGATIVE + "The damage must be a number!"); return false; } if (toDamage > t.getMaxHealth() || toDamage <= 0) { cs.sendMessage( MessageColor.NEGATIVE + "The damage you entered is not within 1 and " + t.getMaxHealth() + "!"); return true; } if (!cs.getName().equalsIgnoreCase(t.getName()) && plugin.ah.isAuthorized(t, "rcmds.exempt.harm")) { cs.sendMessage(MessageColor.NEGATIVE + "You may not harm that player."); return true; } t.damage(toDamage); t.sendMessage( MessageColor.NEGATIVE + "You have just been damaged by " + MessageColor.NEUTRAL + cs.getName() + MessageColor.NEGATIVE + "!"); cs.sendMessage( MessageColor.POSITIVE + "You just damaged " + MessageColor.NEUTRAL + t.getName() + MessageColor.POSITIVE + "!"); return true; } return false; }
@Override public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("banip")) { if (!plugin.ah.isAuthorized(cs, "rcmds.banip")) { RUtils.dispNoPerms(cs); return true; } if (args.length < 1) { cs.sendMessage(cmd.getDescription()); return false; } OfflinePlayer op = plugin.getServer().getOfflinePlayer(args[0]); String ip = (!op.hasPlayedBefore()) ? args[0] : PConfManager.getPConfManager(op).getString("ip"); if (ip == null) ip = args[0]; if (!isValid(ip)) { cs.sendMessage( MessageColor.NEGATIVE + "Invalid IP (" + MessageColor.NEUTRAL + ip + MessageColor.NEGATIVE + ")."); return true; } plugin.getServer().banIP(ip); if (!op.hasPlayedBefore()) { cs.sendMessage( MessageColor.POSITIVE + "Banned IP " + MessageColor.NEUTRAL + ip + MessageColor.POSITIVE + "."); return true; } else { op.setBanned(true); RUtils.writeBanHistory(op); cs.sendMessage( MessageColor.POSITIVE + "Banned IP of " + MessageColor.NEUTRAL + op.getName() + MessageColor.POSITIVE + " (" + MessageColor.NEUTRAL + ip + MessageColor.POSITIVE + ")."); return true; } } return false; }
@EventHandler(priority = EventPriority.HIGH) public void onPlayerJoin(PlayerJoinEvent event) { File datafile = new File( plugin.getDataFolder() + File.separator + "userdata" + File.separator + event.getPlayer().getName().toLowerCase() + ".yml"); if (!datafile.exists()) { log.info("[RoyalCommands] Creating userdata for user " + event.getPlayer().getName() + "."); try { FileConfiguration out = YamlConfiguration.loadConfiguration(datafile); out.set("name", event.getPlayer().getName()); String dispname = event.getPlayer().getDisplayName(); if (dispname == null || dispname.equals("")) dispname = event.getPlayer().getName(); out.set("dispname", dispname); out.set("ip", event.getPlayer().getAddress().getAddress().toString().replace("/", "")); out.set("banreason", ""); out.set("allow-tp", true); out.save(datafile); log.info("[RoyalCommands] Userdata creation finished."); } catch (Exception e) { log.severe( "[RoyalCommands] Could not create userdata for user " + event.getPlayer().getName() + "!"); e.printStackTrace(); } if (plugin.useWelcome) { String welcomemessage = plugin.welcomeMessage; welcomemessage = welcomemessage.replace("{name}", event.getPlayer().getName()); String dispname = event.getPlayer().getDisplayName(); if (dispname == null || dispname.equals("")) dispname = event.getPlayer().getName(); welcomemessage = welcomemessage.replace("{dispname}", dispname); welcomemessage = welcomemessage.replace("{world}", event.getPlayer().getWorld().getName()); plugin.getServer().broadcastMessage(welcomemessage); } if (plugin.stsNew) event.getPlayer().teleport(event.getPlayer().getWorld().getSpawnLocation()); } else { log.info("[RoyalCommands] Updating the IP for " + event.getPlayer().getName() + "."); String playerip = event.getPlayer().getAddress().getAddress().toString(); playerip = playerip.replace("/", ""); PConfManager.setPValString(event.getPlayer(), playerip, "ip"); } if (plugin.motdLogin) CmdMotd.showMotd(event.getPlayer()); if (plugin.sendToSpawn) { if (plugin.stsBack) CmdBack.backdb.put(event.getPlayer(), event.getPlayer().getLocation()); event.getPlayer().teleport(event.getPlayer().getWorld().getSpawnLocation()); } }
@EventHandler() public void onPJoin(PlayerJoinEvent e) { Player p = e.getPlayer(); if (plugin.newVersion == null) return; if (!plugin.newVersion.contains(plugin.version) && !plugin.version.contains("pre") && plugin.isAuthorized(p, "rcmds.updates")) { String newV = plugin.newVersion.split("RoyalCommands")[1].trim().substring(1); p.sendMessage( ChatColor.BLUE + "RoyalCommands " + ChatColor.GRAY + "v" + newV + ChatColor.BLUE + " is out! You are running " + ChatColor.GRAY + "v" + plugin.version + ChatColor.BLUE + "."); p.sendMessage( ChatColor.BLUE + "Get the new version at " + ChatColor.DARK_AQUA + "http://dev.bukkit.org/server-mods/royalcommands" + ChatColor.BLUE + "."); } }
@Override public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("loadplayer")) { if (!plugin.ah.isAuthorized(cs, "rcmds.loadplayer")) { RUtils.dispNoPerms(cs); return true; } if (args.length < 1) { cs.sendMessage(cmd.getDescription()); return false; } final Player t = plugin.getServer().getPlayer(args[0]); if (t == null) { cs.sendMessage(MessageColor.NEGATIVE + "No such player!"); return true; } if (!t.getName().equals(cs.getName()) && !plugin.ah.isAuthorized(cs, "rcmds.others.loadplayer")) { cs.sendMessage(MessageColor.NEGATIVE + "You cannot load other players' data!"); return true; } t.loadData(); cs.sendMessage(MessageColor.POSITIVE + "Data loaded."); return true; } return false; }
public void setCooldown(String command, OfflinePlayer p) { ConfigurationSection cmdCds = plugin.getConfig().getConfigurationSection("command_cooldowns"); if (cmdCds == null) return; boolean contains = cmdCds.getKeys(false).contains(command); if (plugin.cooldownAliases) if (plugin.getCommand(command) != null) for (String alias : plugin.getCommand(command).getAliases()) if (cmdCds.getKeys(false).contains(alias)) { contains = true; break; } if (contains) { long cooldown = cmdCds.getLong(command); PConfManager.setPValLong( p, new Date().getTime() + (cooldown * 1000), "command_cooldowns." + command); } }
@Override public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("ping")) { if (!plugin.ah.isAuthorized(cs, "rcmds.ping")) { RUtils.dispNoPerms(cs); return true; } if (!plugin.getNMSFace().hasSupport() || (!(cs instanceof Player) && args.length < 1)) { cs.sendMessage(MessageColor.POSITIVE + "Pong!"); return true; } if (args.length > 0) { if (!plugin.ah.isAuthorized(cs, "rcmds.others.ping")) { RUtils.dispNoPerms(cs); return true; } Player p = plugin.getServer().getPlayer(args[0]); if (p == null || plugin.isVanished(p, cs)) { cs.sendMessage(MessageColor.NEGATIVE + "That player does not exist!"); return true; } int ping = plugin.getNMSFace().getPing(p); String possessive = (p.getName().endsWith("s")) ? "'" : "'s"; cs.sendMessage( MessageColor.NEUTRAL + p.getName() + possessive + MessageColor.POSITIVE + " ping: " + MessageColor.NEUTRAL + ping + "ms"); return true; } if (!(cs instanceof Player)) { cs.sendMessage(MessageColor.POSITIVE + "Pong!"); return true; } Player p = (Player) cs; int ping = plugin.getNMSFace().getPing(p); p.sendMessage(MessageColor.POSITIVE + "Your ping: " + MessageColor.NEUTRAL + ping + "ms"); return true; } return false; }
@EventHandler(priority = EventPriority.HIGH) public void onPlayerMove(PlayerMoveEvent event) { if (event.isCancelled()) return; if (AFKUtils.isAfk(event.getPlayer())) { AFKUtils.unsetAfk(event.getPlayer()); plugin.getServer().broadcastMessage(event.getPlayer().getName() + " is no longer AFK."); return; } if (PConfManager.getPValBoolean(event.getPlayer(), "frozen")) event.setCancelled(true); }
@Override public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("slap")) { if (!plugin.isAuthorized(cs, "rcmds.slap")) { RUtils.dispNoPerms(cs); return true; } if (args.length < 1) { cs.sendMessage(cmd.getDescription()); return false; } Player victim; victim = plugin.getServer().getPlayer(args[0]); if (victim == null || plugin.isVanished(victim)) { cs.sendMessage(ChatColor.RED + "That person is not online!"); return true; } if (plugin.isAuthorized(victim, "rcmds.exempt.slap")) { cs.sendMessage(ChatColor.RED + "You may not slap that player."); return true; } Vector push = victim.getVelocity(); push.setY(push.getY() + .5); push.setX(push.getX() + .5); push.setZ(push.getZ() + .5); victim.setVelocity(push); plugin .getServer() .broadcastMessage( ChatColor.GOLD + cs.getName() + ChatColor.WHITE + " slaps " + ChatColor.RED + victim.getName() + ChatColor.WHITE + "!"); return true; } return false; }
@Override public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("teleport")) { if (!plugin.ah.isAuthorized(cs, "rcmds.teleport")) { RUtils.dispNoPerms(cs); return true; } if (!(cs instanceof Player)) { cs.sendMessage(MessageColor.NEGATIVE + "This command is only available to players!"); return true; } if (args.length < 1) { cs.sendMessage(cmd.getDescription()); return false; } Player t = plugin.getServer().getPlayer(args[0]); if (t == null || plugin.isVanished(t, cs)) { cs.sendMessage(MessageColor.NEGATIVE + "That player does not exist!"); return true; } if (!RUtils.isTeleportAllowed(t) && !plugin.ah.isAuthorized(cs, "rcmds.tpoverride")) { cs.sendMessage(MessageColor.NEGATIVE + "That player has teleportation off!"); return true; } Player p = (Player) cs; p.sendMessage( MessageColor.POSITIVE + "Teleporting you to " + MessageColor.NEUTRAL + t.getName() + MessageColor.POSITIVE + "."); String error = RUtils.teleport(p, t); if (!error.isEmpty()) { p.sendMessage(MessageColor.NEGATIVE + error); return true; } return true; } return false; }
@Override public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("banned")) { if (!plugin.isAuthorized(cs, "rcmds.banned")) { RUtils.dispNoPerms(cs); return true; } if (args.length < 1) { cs.sendMessage(cmd.getDescription()); return false; } OfflinePlayer t = plugin.getServer().getOfflinePlayer(args[0]); if (!t.isBanned()) { cs.sendMessage(ChatColor.GREEN + t.getName() + ChatColor.WHITE + " is not banned."); return true; } cs.sendMessage(ChatColor.RED + t.getName() + ChatColor.WHITE + " is banned."); return true; } return false; }
@Override public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("vtphere")) { if (!plugin.isAuthorized(cs, "rcmds.vtphere")) { RUtils.dispNoPerms(cs); return true; } if (args.length < 1) { cs.sendMessage(cmd.getDescription()); return false; } Player victim = plugin.getServer().getPlayer(args[0]); if (victim == null) { cs.sendMessage(ChatColor.RED + "That player does not exist!"); return true; } if (!(cs instanceof Player)) { cs.sendMessage(ChatColor.RED + "This command cannot be used in console."); return true; } Player player = (Player) cs; cs.sendMessage( ChatColor.BLUE + "Teleporting player " + ChatColor.GRAY + victim.getName() + ChatColor.BLUE + " to you."); String error = RUtils.teleport(victim, player); if (!error.isEmpty()) { cs.sendMessage(ChatColor.RED + error); return true; } return true; } return false; }
public static void smoothPlayerTimeChange(long time, final Player p) { if (time > 24000) time = time % 24000L; final long ftime = time; final Runnable r = new Runnable() { @Override public void run() { for (long i = p.getPlayerTime() + 1; i != ftime; i++) { if (i == 24001) { i = 0; if (ftime == 0) break; } p.setPlayerTime(i, true); } p.setPlayerTime(ftime, true); } }; plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, r); }
@EventHandler(priority = EventPriority.LOW) public void onPlayerChat(PlayerChatEvent event) { if (event.isCancelled()) return; if (AFKUtils.isAfk(event.getPlayer())) { AFKUtils.unsetAfk(event.getPlayer()); plugin.getServer().broadcastMessage(event.getPlayer().getName() + " is no longer AFK."); } if (PConfManager.getPValBoolean(event.getPlayer(), "muted")) { if (PConfManager.getPVal(event.getPlayer(), "mutetime") != null && !RUtils.isTimeStampValid(event.getPlayer(), "mutetime")) PConfManager.setPValBoolean(event.getPlayer(), false, "muted"); event.setFormat(""); event.setCancelled(true); event.getPlayer().sendMessage(ChatColor.RED + "You are muted."); plugin.log.info( "[RoyalCommands] " + event.getPlayer().getName() + " tried to speak, but has been muted."); } }
@Override public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("spawn")) { if (!plugin.ah.isAuthorized(cs, "rcmds.spawn")) { RUtils.dispNoPerms(cs); return true; } if (!(cs instanceof Player)) { cs.sendMessage(MessageColor.NEGATIVE + "This command is only available to players!"); return true; } Player p = (Player) cs; World w; if (args.length > 0) { if (!plugin.ah.isAuthorized(cs, "rcmds.spawn.other")) { cs.sendMessage( MessageColor.NEGATIVE + "You don't have permission to spawn in other worlds."); return true; } w = plugin.getServer().getWorld(args[0]); if (w == null) { cs.sendMessage(MessageColor.NEGATIVE + "No such world!"); return true; } } else w = p.getWorld(); Location l = getGroupSpawn(p, w); if (l == null) l = getWorldSpawn(w); p.sendMessage( MessageColor.POSITIVE + "Going to spawn in " + MessageColor.NEUTRAL + RUtils.getMVWorldName(w) + MessageColor.POSITIVE + "."); String error = RUtils.teleport(p, l); if (!error.isEmpty()) p.sendMessage(MessageColor.NEGATIVE + error); return true; } return false; }
@EventHandler(priority = EventPriority.LOW) public void teleCooldown(PlayerTeleportEvent e) { if (e.isCancelled()) return; Player p = e.getPlayer(); if (plugin.isAuthorized(p, "rcmds.exempt.cooldown.teleports")) return; Long currentcd = PConfManager.getPValLong(p, "teleport_cooldown"); if (currentcd != null) { if (currentcd <= new Date().getTime()) { setTeleCooldown(p); return; } p.sendMessage( ChatColor.RED + "You can't teleport for" + ChatColor.GRAY + RUtils.formatDateDiff(currentcd) + ChatColor.RED + "."); e.setCancelled(true); return; } setTeleCooldown(p); }
public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("fireball")) { if (!plugin.isAuthorized(cs, "rcmds.fireball")) { RUtils.dispNoPerms(cs); return true; } if (!(cs instanceof Player)) { cs.sendMessage(ChatColor.RED + "This command is only available to players!"); return true; } Player p = (Player) cs; // Fireball fb = p.launchProjectile(Fireball.class); Vector dir = p.getEyeLocation().getDirection().multiply(2); Fireball fb = p.getWorld() .spawn(p.getEyeLocation().add(dir.getX(), dir.getY(), dir.getZ()), Fireball.class); fb.setDirection(dir); // fb.teleport(p.getEyeLocation().add(dir.getX(), dir.getY(), dir.getZ())); fb.setIsIncendiary(true); return true; } return false; }
@Override public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("weather")) { if (!plugin.isAuthorized(cs, "rcmds.weather")) { RUtils.dispNoPerms(cs); return true; } if (args.length < 1) { cs.sendMessage(cmd.getDescription()); return false; } if (!(cs instanceof Player)) { cs.sendMessage(ChatColor.RED + "This command is only available to players!"); return true; } if (args.length == 1) { Player p = (Player) cs; changeWeather(p, args[0].trim()); return true; } else if (args.length == 2) { Player p = (Player) cs; String conds = args[0].trim(); String slength = args[1].trim(); int length; try { length = Integer.parseInt(slength); } catch (Exception e) { p.sendMessage(ChatColor.RED + "The time specified was invalid!"); return true; } changeWeather(p, conds, length); return true; } } return false; }
@Override public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("ragequit")) { if (!plugin.isAuthorized(cs, "rcmds.ragequit")) { RUtils.dispNoPerms(cs); return true; } if (args.length < 1) { if (cs instanceof Player) { plugin .getServer() .broadcastMessage( ChatColor.DARK_RED + cs.getName() + ChatColor.RED + " has ragequit!"); ((Player) cs).kickPlayer(ChatColor.DARK_RED + "RAAAGGGEEEE!!!"); return true; } } if (args.length == 1) { if (!plugin.isAuthorized(cs, "rcmds.others.ragequit")) { cs.sendMessage(ChatColor.RED + "You don't have permission for that!"); return true; } Player victim = plugin.getServer().getPlayer(args[0]); if (victim == null || plugin.isVanished(victim, cs)) { cs.sendMessage(ChatColor.RED + "That player does not exist!"); return true; } plugin .getServer() .broadcastMessage( ChatColor.DARK_RED + victim.getName() + ChatColor.RED + " has ragequit!"); victim.kickPlayer(ChatColor.DARK_RED + "RAAAGGGEEEE!!!"); return true; } } return false; }
@Override public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) { if (cmd.getName().equalsIgnoreCase("message")) { if (!plugin.ah.isAuthorized(cs, "rcmds.message")) { RUtils.dispNoPerms(cs); return true; } if (args.length < 2) { return false; } Player t = plugin.getServer().getPlayer(args[0]); String m = RoyalCommands.getFinalArg(args, 1).trim(); if (t == null || t.getName().trim().equals("")) { cs.sendMessage(MessageColor.NEGATIVE + "That player is not online!"); return true; } if (plugin.isVanished(t, cs)) { cs.sendMessage(MessageColor.NEGATIVE + "That player does not exist!"); return true; } synchronized (replydb) { replydb.put(t.getName(), cs.getName()); replydb.put(cs.getName(), t.getName()); } if (m == null || m.equals("")) { cs.sendMessage(MessageColor.NEGATIVE + "You entered no message!"); return true; } t.sendMessage( MessageColor.NEUTRAL + "[" + MessageColor.POSITIVE + cs.getName() + MessageColor.NEUTRAL + " -> " + MessageColor.POSITIVE + "You" + MessageColor.NEUTRAL + "] " + m); cs.sendMessage( MessageColor.NEUTRAL + "[" + MessageColor.POSITIVE + "You" + MessageColor.NEUTRAL + " -> " + MessageColor.POSITIVE + t.getName() + MessageColor.NEUTRAL + "] " + m); Player[] ps = plugin.getServer().getOnlinePlayers(); for (Player p1 : ps) { if (PConfManager.getPConfManager(p1).getBoolean("spy")) { if (t == p1 || cs == p1) continue; p1.sendMessage( MessageColor.NEUTRAL + "[" + MessageColor.POSITIVE + cs.getName() + MessageColor.NEUTRAL + " -> " + MessageColor.POSITIVE + t.getName() + MessageColor.NEUTRAL + "] " + m); } } return true; } return false; }
@EventHandler public void onPInt(PlayerInteractEvent event) { if (PConfManager.getPValBoolean(event.getPlayer(), "frozen")) event.setCancelled(true); if (plugin.buildPerm) if (!plugin.isAuthorized(event.getPlayer(), "rcmds.build")) event.setCancelled(true); }