@EventHandler
  public void onPlayerDeath(PlayerDiedEvent event) {
    if (event.getGame() != this.game) return;

    Player player = event.getPlayer();

    if (deadPlayers.containsKey(player)) return;

    DeadPlayer deadPlayer = new DeadPlayer(player, this.game);
    deadPlayers.put(player, deadPlayer);
    deadPlayer.spawn();

    for (PotionEffect effect : player.getActivePotionEffects()) {
      player.removePotionEffect(effect.getType());
    }

    game.broadcast(ChatColor.BOLD.toString() + ChatColor.DARK_RED + event.getDeathMessage());

    for (Player p : game.getPlayers()) {
      plugin.sendActionbarMessage(
          p,
          ChatColor.YELLOW.toString()
              + ChatColor.BOLD.toString()
              + player.getName()
              + " has been downed! Go revive them!");
    }

    if (deadPlayers.size() == game.getPlayers().size()) safelyEndGame();
  }
예제 #2
0
 // sign setup
 @EventHandler
 public void onSignCreation(SignChangeEvent e) {
   Player player = (Player) e.getPlayer();
   if (!player.hasPermission("freezetag.signplace")) {
     player.sendMessage("No permission");
     return;
   }
   if (e.getLine(0).equals("/ftpap")) {
     e.setLine(0, ChatColor.BLUE + ChatColor.BOLD.toString() + "Pack");
     e.setLine(1, ChatColor.YELLOW + ChatColor.BOLD.toString() + "a");
     e.setLine(2, ChatColor.GREEN + ChatColor.BOLD.toString() + "Punch");
     e.setLine(3, ChatColor.MAGIC.toString() + ChatColor.BOLD.toString() + "fresh fish");
   }
 }
예제 #3
0
 public void updateScoreboard() {
   List<String> second = Arrays.asList(toStringArray(getPartyMembers().toArray()));
   Iterator<String> players = getPartyMembers().iterator();
   while (players.hasNext()) {
     String pn = players.next();
     if (Bukkit.getPlayer(pn) == null) continue;
     Player p = Bukkit.getPlayer(pn);
     Objective o = ScoreboardMechanics.getBoard(p).getObjective(DisplaySlot.SIDEBAR);
     if (o == null) {
       o = ScoreboardMechanics.getBoard(p).registerNewObjective("player_data", "dummy");
       o.setDisplayName(ChatColor.RED.toString() + ChatColor.BOLD.toString() + "Party");
       o.setDisplaySlot(DisplaySlot.SIDEBAR);
     }
     for (String tn : second) {
       if (Bukkit.getPlayer(tn) == null) {
         ScoreboardMechanics.getBoard(p).resetScores(Bukkit.getOfflinePlayer(tn));
         continue;
       }
       Player t = Bukkit.getPlayer(tn);
       String name = getPlayerName(t);
       if (name.length() > 16) name = name.substring(0, 16);
       o.getScore(Bukkit.getOfflinePlayer(name))
           .setScore(HealthMechanics.getPlayerHP(t.getName()));
     }
   }
 }
예제 #4
0
  @Override
  public final boolean onCommand(
      final CommandSender sender, final Command cmd, final String label, final String[] args) {
    if (!cmd.getName().equalsIgnoreCase("giveall")) return false;
    if (!(sender instanceof Player)) {
      sender.sendMessage(
          ChatColor.BOLD.toString() + ChatColor.DARK_RED + "Du musst ein Spieler sein");
      return true;
    }
    if (args.length != 1) {
      sender.sendMessage(
          ChatColor.BOLD
              + "Verwendung: "
              + ChatColor.RESET
              + ChatColor.DARK_RED
              + "/Giveall <Menge>");
      return true;
    }
    try {
      if (Integer.parseInt(args[0]) < 1) {
        sender.sendMessage(ChatColor.DARK_RED + "Menge muss über 0 sein");
        return true;
      }
    } catch (NumberFormatException ex) {
      sender.sendMessage(
          ChatColor.BOLD
              + "Verwendung: "
              + ChatColor.RESET
              + ChatColor.DARK_RED
              + "/Giveall <Menge>");
      return true;
    }
    final Player p = (Player) sender;
    if (p.getItemInHand() == null || p.getItemInHand().getType() == Material.AIR) {
      p.sendMessage(
          ChatColor.BOLD.toString() + ChatColor.DARK_RED + "Du musst ein Item in der Hand halten!");
      return true;
    }
    final ItemStack is = p.getItemInHand().clone();
    is.setAmount(Integer.parseInt(args[0]));

    final BaseComponent[] broadcastMessage = getBaseComponentMessage(p, is);
    if (broadcastMessage != null) Bukkit.spigot().broadcast(broadcastMessage);

    for (final Player player : Bukkit.getOnlinePlayers()) player.getInventory().addItem(is);
    return true;
  }
예제 #5
0
 @EventHandler
 public void onSec(SecondEvent event) {
   if (HG.HG.gameTime % 240 == 0)
     for (Gamer g : Gamer.getGamers())
       if (g.getKit() == this) {
         g.getPlayer().getInventory().addItem(getItemss());
         g.getPlayer()
             .sendMessage(
                 ChatColor.GREEN + ChatColor.BOLD.toString() + "You got a new batch of pots!");
       }
 }
예제 #6
0
 private void onLobbyCommandIssued() {
   player.setMetadata(
       "lobbyCommandTriggered", new FixedMetadataValue(PluginLoader.getInstance(), true));
   LobbyTeleporter lobbyTeleporter = new LobbyTeleporter(player, fileConfiguration);
   if (!lobbyTeleporter.isLobbySet()) {
     player.sendMessage(
         ChatColor.BLUE
             + "The lobby was not set yet! Set the lobby with "
             + ChatColor.DARK_RED
             + "/setlobby");
   } else {
     lobbyTeleporter.teleportToLobby();
     player.sendMessage(
         ChatColor.GREEN + ChatColor.BOLD.toString() + "-------Welcome to the Lobby-------");
   }
 }
 @Override
 public String getReplacement(String inPattern) {
   // some formatting
   if (inPattern.contains("&bo")) {
     inPattern = inPattern.replace("&bo", ChatColor.BOLD.toString());
   }
   if (inPattern.contains("&it")) {
     inPattern = inPattern.replace("&it", ChatColor.ITALIC.toString());
   }
   if (inPattern.contains("&str")) {
     inPattern = inPattern.replace("&str", ChatColor.STRIKETHROUGH.toString());
   }
   if (inPattern.contains("&ran")) {
     inPattern = inPattern.replace("&ran", ChatColor.MAGIC.toString());
   }
   if (inPattern.contains("&un")) {
     inPattern = inPattern.replace("&un", ChatColor.UNDERLINE.toString());
   }
   if (inPattern.contains("&no")) {
     inPattern = inPattern.replace("&no", ChatColor.RESET.toString());
   }
   return inPattern;
 }
예제 #8
0
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    Player p = null;

    if (sender instanceof Player) {
      p = (Player) sender;
    }

    if (p != null) {
      if (!(p.isOp())) {
        return true;
      }
    }

    if (args.length == 0) {
      if (p != null) {
        if (!(p.isOp())) {
          return true;
        }
        p.sendMessage(
            ChatColor.RED
                + "Invalid Syntax. Please use /isay <msg> to send a local world messsage.");
        return true;
      }
    }

    String msg = "";
    for (String s : args) {
      msg += s + " ";
    }
    msg = msg.substring(0, msg.lastIndexOf(" "));

    msg = msg.replaceAll("&0", ChatColor.BLACK.toString());
    msg = msg.replaceAll("&1", ChatColor.DARK_BLUE.toString());
    msg = msg.replaceAll("&2", ChatColor.DARK_GREEN.toString());
    msg = msg.replaceAll("&3", ChatColor.DARK_AQUA.toString());
    msg = msg.replaceAll("&4", ChatColor.DARK_RED.toString());
    msg = msg.replaceAll("&5", ChatColor.DARK_PURPLE.toString());
    msg = msg.replaceAll("&6", ChatColor.GOLD.toString());
    msg = msg.replaceAll("&7", ChatColor.GRAY.toString());
    msg = msg.replaceAll("&8", ChatColor.DARK_GRAY.toString());
    msg = msg.replaceAll("&9", ChatColor.BLUE.toString());
    msg = msg.replaceAll("&a", ChatColor.GREEN.toString());
    msg = msg.replaceAll("&b", ChatColor.AQUA.toString());
    msg = msg.replaceAll("&c", ChatColor.RED.toString());
    msg = msg.replaceAll("&d", ChatColor.LIGHT_PURPLE.toString());
    msg = msg.replaceAll("&e", ChatColor.YELLOW.toString());
    msg = msg.replaceAll("&f", ChatColor.WHITE.toString());

    msg = msg.replaceAll("&u", ChatColor.UNDERLINE.toString());
    msg = msg.replaceAll("&s", ChatColor.BOLD.toString());
    msg = msg.replaceAll("&i", ChatColor.ITALIC.toString());
    msg = msg.replaceAll("&m", ChatColor.MAGIC.toString());

    if (sender instanceof BlockCommandSender) {
      BlockCommandSender cb = (BlockCommandSender) sender;
      for (Player pl : cb.getBlock().getWorld().getPlayers()) {
        pl.sendMessage(msg);
      }
    } else if (sender instanceof Player) {
      for (Player pl : p.getWorld().getPlayers()) {
        pl.sendMessage(msg);
      }
    }
    return true;
  }
예제 #9
0
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    final Player p = (Player) sender;
    if (!(GuildMechanics.inGuild(p.getName()))) {
      p.sendMessage(
          ChatColor.RED
              + "You must be in a "
              + ChatColor.BOLD
              + "GUILD"
              + ChatColor.RED
              + " to use "
              + ChatColor.BOLD
              + "/gquit.");
      return true;
    }

    if (args.length != 0) {
      p.sendMessage(
          ChatColor.RED + "" + ChatColor.BOLD + "Invalid Syntax. " + ChatColor.RED + "/gquit");
      return true;
    }

    String g_name = GuildMechanics.getGuild(p.getName());
    p.sendMessage(
        ChatColor.GRAY
            + "Are you sure you want to QUIT the guild '"
            + ChatColor.DARK_AQUA
            + g_name
            + ChatColor.GRAY
            + "' - This cannot be undone. "
            + "("
            + ChatColor.GREEN.toString()
            + ChatColor.BOLD
            + "Y"
            + ChatColor.GRAY
            + " / "
            + ChatColor.RED.toString()
            + ChatColor.BOLD
            + "N"
            + ChatColor.GRAY
            + ")");
    if (GuildMechanics.isGuildLeader(p.getName())) {
      p.sendMessage(
          ChatColor.RED.toString()
              + ChatColor.BOLD.toString()
              + "WARNING: "
              + ChatColor.GRAY
              + "You are the "
              + ChatColor.UNDERLINE
              + "GUILD LEADER"
              + ChatColor.GRAY
              + ", if you leave this guild it will be "
              + ChatColor.BOLD
              + "PERMENANTLY DELETED"
              + ChatColor.GRAY
              + ". All members will be kicked, and you will lose your 5,000g deposit.");
    }

    GuildMechanics.guild_quit_confirm.add(p.getName());
    return true;
  }
예제 #10
0
 public String getPlayerName(Player p) {
   return ChatColor.WHITE.toString()
       + (getLeader().getName().equalsIgnoreCase(p.getName())
           ? ChatColor.BOLD.toString() + p.getName()
           : p.getName());
 }