Esempio n. 1
0
 public void log(String msg, Level TYPE) {
   try {
     if (TYPE.equals(Level.WARNING) || TYPE.equals(Level.ERROR)) {
       System.err.println("[" + plugin.getName() + "] " + TYPE.name() + ": " + msg);
       Bukkit.broadcast(
           PrefixColor
               + "["
               + Prefix
               + "]"
               + ChatColor.RED
               + " "
               + TYPE.name()
               + ": "
               + TextColor
               + msg,
           "Paypassage.log");
       if (debugfile) {
         this.log("Error: " + msg);
       }
     } else if (TYPE.equals(Level.DEBUG)) {
       if (debug) {
         System.out.println("[" + Prefix + "]" + " Debug: " + msg);
         Bukkit.broadcast(
             PrefixColor + "[" + Prefix + "]" + " Debug: " + TextColor + msg, "Paypassage.log");
       }
       if (debugfile) {
         this.log("Debug: " + msg);
       }
     } else {
       System.out.println(Prefix + msg);
       Bukkit.broadcast(
           PrefixColor + "[" + Prefix + "]" + " " + TextColor + msg, "Paypassage.log");
       if (debugfile) {
         this.log(msg);
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
     System.out.println("[Paypassage] Error: Uncatch Exeption!");
     if (plugin.getReportHandler() != null) {
       plugin
           .getReportHandler()
           .report(3317, "Logger doesnt work", e.getMessage(), "Paypassage", e);
     }
   }
 }
  @EventHandler(priority = EventPriority.HIGHEST)
  public void limitRedstone(BlockRedstoneEvent event) {
    Block block = event.getBlock();
    if (!materials.contains(block.getType()) || event.getOldCurrent() != 0) {
      return;
    }

    Location loc = block.getLocation();
    BlockPosition blockPos = new BlockPosition(loc);
    AtomicInteger score = scores.putIfAbsent(blockPos, new AtomicInteger());

    if (score == null) {
      score = scores.get(blockPos);
      if (score == null) {
        limitRedstone(event);
        return;
      }
    }

    int newScore = score.incrementAndGet();
    int threshold = getConfig().getInt("threshold");

    if (newScore < threshold) {
      return;
    }

    if (newScore > threshold) {
      score.compareAndSet(newScore, threshold);
    } else {
      Bukkit.broadcast(
          "§cToo much redstone @ §e"
              + loc.getWorld().getName()
              + " §b"
              + loc.getBlockX()
              + " "
              + loc.getBlockY()
              + " "
              + loc.getBlockZ()
              + " §8[§7"
              + block.getType().name()
              + "§8]",
          "redstonelimiter.notify");
    }

    event.setNewCurrent(0);

    for (int i = 0; i < 3; ++i) {
      Location l =
          loc.clone()
              .add(random.nextDouble() * 1.1, random.nextDouble() - 0.5, random.nextDouble() * 1.1);
      loc.getWorld().playEffect(l, Effect.SMOKE, 64);
    }
  }
Esempio n. 3
0
  public void recordCondition(Plugin plugin, boolean shouldPrefix, String condition, Level level) {
    String content = ChatColor.AQUA + condition;
    String message = content;
    String prefix = ChatColor.GRAY + plugin.getName() + ChatColor.GRAY + "] ";

    if (shouldPrefix) {
      message = prefix + content;
    }

    if (level.intValue() <= this.broadcastLevel.intValue()) {
      Bukkit.broadcast(message, "pulse.observe");
    }

    System.out.println(
        "[Pulse] " + level.getLocalizedName() + "] " + plugin.getName() + "] " + condition);
  }
Esempio n. 4
0
 public void autobanPlayer(final Player player, final int minutes, final HackType type) {
   if (!main.getConfig().getBoolean("config.auto")) {
     return;
   }
   if (auto.contains(player.getName())) {
     return;
   }
   if (player.hasPermission(Permission.AUTO_BYPASS)) {
     return;
   }
   for (Player online : Bukkit.getOnlinePlayers()) {
     if (online.hasPermission(Permission.AUTO)) {
       online.playSound(online.getEyeLocation(), Sound.IRONGOLEM_HIT, 1, 1);
     }
   }
   if (minutes > 1) {
     Bukkit.broadcast(
         ChatColor.YELLOW
             + player.getName()
             + " will be auto-banned in 60 seconds for "
             + type.toString().toLowerCase().trim()
             + "! This autoban will last "
             + minutes
             + " minutes!",
         Permission.AUTO);
   } else if (minutes == 1) {
     Bukkit.broadcast(
         ChatColor.YELLOW
             + player.getName()
             + " will be auto-banned in 60 seconds for "
             + type.toString().toLowerCase().trim()
             + "! This autoban will last 1 minute!",
         Permission.AUTO);
   } else {
     return;
   }
   Bukkit.getPluginManager().callEvent(new AutobanTriggerEvent(player, type, minutes));
   auto.add(player.getName());
   Bukkit.getScheduler()
       .runTaskLater(
           Main.getPlugin(),
           new Runnable() {
             @Override
             public void run() {
               if (auto.contains(player.getName())) {
                 auto.remove(player.getName());
                 time.put(player.getUniqueId(), minutes * 60 * 20);
                 Bukkit.getPluginManager()
                     .callEvent(new AutobanExecuteEvent(player, type, minutes));
                 if (minutes > 1) {
                   player.kickPlayer(
                       ChatColor.RED
                           + "You were autobanned for "
                           + minutes
                           + " minutes!\nCheat Detected: "
                           + type.toString().toLowerCase().trim()
                           + "!");
                 } else {
                   player.kickPlayer(
                       ChatColor.RED
                           + "You were autobanned for 1 minute!\nCheat Detected: "
                           + type.toString().toLowerCase().trim()
                           + "!");
                 }
               }
             }
           },
           1200);
 }
Esempio n. 5
0
 public void broadcast(String message, String permission) {
   Bukkit.broadcast(MOD_COLOR + message, permission);
 }
Esempio n. 6
0
 // Handle command "/alerts"
 public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
   Player player = (Player) sender;
   // Define command
   if (commandLabel.equalsIgnoreCase("alert")) {
     // add player to cooldown
     if (Cooldowns.tryCooldown(player, "alert", 15000)) {
       BarAPI.removeBar(player);
       BarAPI.setMessage(player, ChatColor.RED + "[Cooldown]" + ChatColor.GOLD + " /alert", 15);
       // just /alert
       if (args.length == (0)) {
         player.sendMessage(
             ChatColor.DARK_GREEN
                 + "[Alerts] "
                 + ChatColor.GREEN
                 + "For help type "
                 + ChatColor.GOLD
                 + "/jmps alert");
         // /alert help
       } else if (args.length == (1) && args[0].equalsIgnoreCase("help")) {
         player.sendMessage(
             ChatColor.DARK_GREEN
                 + "[Alerts] "
                 + ChatColor.GREEN
                 + "Command usage: "
                 + ChatColor.GOLD
                 + "/alert [admin/<police department name>]");
         // /alert admin
       } else if (args.length == (1) && args[0].equalsIgnoreCase("admin")) {
         player.sendMessage(
             ChatColor.DARK_GREEN
                 + "[Alerts] "
                 + ChatColor.GREEN
                 + "You have alerted department "
                 + ChatColor.GOLD
                 + "admin");
         Bukkit.broadcast(
             ChatColor.DARK_PURPLE
                 + "[Alerts] "
                 + ChatColor.DARK_GREEN
                 + player
                 + ChatColor.GREEN
                 + " has requested your assistance.",
             "jm.alerts.admin");
         // /alert 1 (or dprt1)
       } else if (args.length == (1) && args[0].equalsIgnoreCase("1")) {
         if (getConfig().getString("dprt1").equals(null)) {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[JMPS] "
                   + ChatColor.DARK_RED
                   + "Error: "
                   + ChatColor.RED
                   + "The department you request is misconfigured in the config.yml.");
         } else {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[Alerts] "
                   + ChatColor.GREEN
                   + "You have alerted department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"));
           Bukkit.broadcast(
               ChatColor.DARK_PURPLE
                   + "[Alerts] "
                   + ChatColor.DARK_GREEN
                   + player
                   + ChatColor.GREEN
                   + " has alerted your police department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"),
               "jm.alerts.station");
         }
         // /alert 2 (or dprt2 name)
       } else if (args.length == (1) && args[0].equalsIgnoreCase("2")) {
         if (getConfig().getString("dprt2").equals(null)) {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[JMPS] "
                   + ChatColor.DARK_RED
                   + "Error: "
                   + ChatColor.RED
                   + "The department you request is misconfigured in the config.yml.");
         } else {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[Alerts] "
                   + ChatColor.GREEN
                   + "You have alerted department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"));
           Bukkit.broadcast(
               ChatColor.DARK_PURPLE
                   + "[Alerts] "
                   + ChatColor.DARK_GREEN
                   + player
                   + ChatColor.GREEN
                   + " has alerted your police department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"),
               "jm.alerts.1");
         }
         // /alert 3 (or dprt2 name)
       } else if (args.length == (1) && args[0].equalsIgnoreCase("3")) {
         if (getConfig().getString("dprt3").equals(null)) {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[JMPS] "
                   + ChatColor.DARK_RED
                   + "Error: "
                   + ChatColor.RED
                   + "The department you request is misconfigured in the config.yml.");
         } else {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[Alerts] "
                   + ChatColor.GREEN
                   + "You have alerted department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"));
           Bukkit.broadcast(
               ChatColor.DARK_PURPLE
                   + "[Alerts] "
                   + ChatColor.DARK_GREEN
                   + player
                   + ChatColor.GREEN
                   + " has alerted your police department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"),
               "jm.alerts.1");
         }
         // /alert 4 (or dprt2 name)
       } else if (args.length == (1) && args[0].equalsIgnoreCase("4")) {
         if (getConfig().getString("dprt4").equals(null)) {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[JMPS] "
                   + ChatColor.DARK_RED
                   + "Error: "
                   + ChatColor.RED
                   + "The department you request is misconfigured in the config.yml.");
         } else {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[Alerts] "
                   + ChatColor.GREEN
                   + "You have alerted department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"));
           Bukkit.broadcast(
               ChatColor.DARK_PURPLE
                   + "[Alerts] "
                   + ChatColor.DARK_GREEN
                   + player
                   + ChatColor.GREEN
                   + " has alerted your police department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"),
               "jm.alerts.1");
         }
         // /alert 5 (or dprt2 name)
       } else if (args.length == (1) && args[0].equalsIgnoreCase("5")) {
         if (getConfig().getString("dprt5").equals(null)) {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[JMPS] "
                   + ChatColor.DARK_RED
                   + "Error: "
                   + ChatColor.RED
                   + "The department you request is misconfigured in the config.yml.");
         } else {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[Alerts] "
                   + ChatColor.GREEN
                   + "You have alerted department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"));
           Bukkit.broadcast(
               ChatColor.DARK_PURPLE
                   + "[Alerts] "
                   + ChatColor.DARK_GREEN
                   + player
                   + ChatColor.GREEN
                   + " has alerted your police department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"),
               "jm.alerts.1");
         }
         // /alert 6 (or dprt2 name)
       } else if (args.length == (1) && args[0].equalsIgnoreCase("6")) {
         if (getConfig().getString("dprt6").equals(null)) {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[JMPS] "
                   + ChatColor.DARK_RED
                   + "Error: "
                   + ChatColor.RED
                   + "The department you request is misconfigured in the config.yml.");
         } else {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[Alerts] "
                   + ChatColor.GREEN
                   + "You have alerted department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"));
           Bukkit.broadcast(
               ChatColor.DARK_PURPLE
                   + "[Alerts] "
                   + ChatColor.DARK_GREEN
                   + player
                   + ChatColor.GREEN
                   + " has alerted your police department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"),
               "jm.alerts.1");
         }
         // /alert 7 (or dprt2 name)
       } else if (args.length == (1) && args[0].equalsIgnoreCase("7")) {
         if (getConfig().getString("dprt7").equals(null)) {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[JMPS] "
                   + ChatColor.DARK_RED
                   + "Error: "
                   + ChatColor.RED
                   + "The department you request is misconfigured in the config.yml.");
         } else {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[Alerts] "
                   + ChatColor.GREEN
                   + "You have alerted department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"));
           Bukkit.broadcast(
               ChatColor.DARK_PURPLE
                   + "[Alerts] "
                   + ChatColor.DARK_GREEN
                   + player
                   + ChatColor.GREEN
                   + " has alerted your police department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"),
               "jm.alerts.1");
         }
         // /alert 8 (or dprt2 name)
       } else if (args.length == (1) && args[0].equalsIgnoreCase("8")) {
         if (getConfig().getString("dprt8").equals(null)) {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[JMPS] "
                   + ChatColor.DARK_RED
                   + "Error: "
                   + ChatColor.RED
                   + "The department you request is misconfigured in the config.yml.");
         } else {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[Alerts] "
                   + ChatColor.GREEN
                   + "You have alerted department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"));
           Bukkit.broadcast(
               ChatColor.DARK_PURPLE
                   + "[Alerts] "
                   + ChatColor.DARK_GREEN
                   + player
                   + ChatColor.GREEN
                   + " has alerted your police department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"),
               "jm.alerts.1");
         }
         // /alert 9 (or dprt2 name)
       } else if (args.length == (1) && args[0].equalsIgnoreCase("9")) {
         if (getConfig().getString("dprt9").equals(null)) {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[JMPS] "
                   + ChatColor.DARK_RED
                   + "Error: "
                   + ChatColor.RED
                   + "The department you request is misconfigured in the config.yml.");
         } else {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[Alerts] "
                   + ChatColor.GREEN
                   + "You have alerted department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"));
           Bukkit.broadcast(
               ChatColor.DARK_PURPLE
                   + "[Alerts] "
                   + ChatColor.DARK_GREEN
                   + player
                   + ChatColor.GREEN
                   + " has alerted your police department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"),
               "jm.alerts.1");
         }
         // /alert 10 (or dprt2 name)
       } else if (args.length == (1) && args[0].equalsIgnoreCase("10")) {
         if (getConfig().getString("dprt10").equals(null)) {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[JMPS] "
                   + ChatColor.DARK_RED
                   + "Error: "
                   + ChatColor.RED
                   + "The department you request is misconfigured in the config.yml.");
         } else {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[Alerts] "
                   + ChatColor.GREEN
                   + "You have alerted department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"));
           Bukkit.broadcast(
               ChatColor.DARK_PURPLE
                   + "[Alerts] "
                   + ChatColor.DARK_GREEN
                   + player
                   + ChatColor.GREEN
                   + " has alerted your police department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"),
               "jm.alerts.1");
         }
         // /alert 11 (or dprt2 name)
       } else if (args.length == (1) && args[0].equalsIgnoreCase("11")) {
         if (getConfig().getString("dprt11").equals(null)) {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[JMPS] "
                   + ChatColor.DARK_RED
                   + "Error: "
                   + ChatColor.RED
                   + "The department you request is misconfigured in the config.yml.");
         } else {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[Alerts] "
                   + ChatColor.GREEN
                   + "You have alerted department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"));
           Bukkit.broadcast(
               ChatColor.DARK_PURPLE
                   + "[Alerts] "
                   + ChatColor.DARK_GREEN
                   + player
                   + ChatColor.GREEN
                   + " has alerted your police department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"),
               "jm.alerts.1");
         }
         // /alert 12 (or dprt2 name)
       } else if (args.length == (1) && args[0].equalsIgnoreCase("12")) {
         if (getConfig().getString("dprt12").equals(null)) {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[JMPS] "
                   + ChatColor.DARK_RED
                   + "Error: "
                   + ChatColor.RED
                   + "The department you request is misconfigured in the config.yml.");
         } else {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[Alerts] "
                   + ChatColor.GREEN
                   + "You have alerted department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"));
           Bukkit.broadcast(
               ChatColor.DARK_PURPLE
                   + "[Alerts] "
                   + ChatColor.DARK_GREEN
                   + player
                   + ChatColor.GREEN
                   + " has alerted your police department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"),
               "jm.alerts.1");
         }
         // /alert 13 (or dprt2 name)
       } else if (args.length == (1) && args[0].equalsIgnoreCase("13")) {
         if (getConfig().getString("dprt13").equals(null)) {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[JMPS] "
                   + ChatColor.DARK_RED
                   + "Error: "
                   + ChatColor.RED
                   + "The department you request is misconfigured in the config.yml.");
         } else {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[Alerts] "
                   + ChatColor.GREEN
                   + "You have alerted department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"));
           Bukkit.broadcast(
               ChatColor.DARK_PURPLE
                   + "[Alerts] "
                   + ChatColor.DARK_GREEN
                   + player
                   + ChatColor.GREEN
                   + " has alerted your police department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"),
               "jm.alerts.1");
         }
         // /alert 14 (or dprt2 name)
       } else if (args.length == (1) && args[0].equalsIgnoreCase("14")) {
         if (getConfig().getString("dprt14").equals(null)) {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[JMPS] "
                   + ChatColor.DARK_RED
                   + "Error: "
                   + ChatColor.RED
                   + "The department you request is misconfigured in the config.yml.");
         } else {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[Alerts] "
                   + ChatColor.GREEN
                   + "You have alerted department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"));
           Bukkit.broadcast(
               ChatColor.DARK_PURPLE
                   + "[Alerts] "
                   + ChatColor.DARK_GREEN
                   + player
                   + ChatColor.GREEN
                   + " has alerted your police department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"),
               "jm.alerts.1");
         }
         // /alert 15 (or dprt2 name)
       } else if (args.length == (1) && args[0].equalsIgnoreCase("15")) {
         if (getConfig().getString("dprt15").equals(null)) {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[JMPS] "
                   + ChatColor.DARK_RED
                   + "Error: "
                   + ChatColor.RED
                   + "The department you request is misconfigured in the config.yml.");
         } else {
           player.sendMessage(
               ChatColor.DARK_GREEN
                   + "[Alerts] "
                   + ChatColor.GREEN
                   + "You have alerted department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"));
           Bukkit.broadcast(
               ChatColor.DARK_PURPLE
                   + "[Alerts] "
                   + ChatColor.DARK_GREEN
                   + player
                   + ChatColor.GREEN
                   + " has alerted your police department "
                   + ChatColor.GOLD
                   + getConfig().getString("dprt1"),
               "jm.alerts.1");
         }
       }
     } else {
       BarAPI.removeBar(player);
       BarAPI.setMessage(
           player,
           ChatColor.DARK_RED
               + "[Cooldown] "
               + ChatColor.GREEN
               + "Cooldown is still active for "
               + ChatColor.GOLD
               + "/alert",
           10);
       player.sendMessage(
           ChatColor.DARK_RED
               + "[Cooldown] "
               + ChatColor.RED
               + "You have to wait "
               + ChatColor.GOLD
               + (Cooldowns.getCooldown(player, "alert") / 1000)
               + "s "
               + ChatColor.RED
               + "before you can use "
               + ChatColor.GOLD
               + "/alert"
               + ChatColor.RED
               + " again.");
     }
   }
   return false;
 }