private void colorPlayer(Player player, ChatColor color) {
    uncolorPlayer(player);

    playerColors.put(player.getUniqueId(), color);

    player.setDisplayName(color + player.getName() + ChatColor.RESET);

    Team team = scoreboard.registerNewTeam(player.getName());
    team.setDisplayName(player.getName());
    team.setPrefix(color.toString());
    team.setSuffix(ChatColor.RESET.toString());
    team.addEntry(player.getName());
    player.setScoreboard(scoreboard);
  }
예제 #2
0
public final class WeaponShop {

  private static final String prefix =
      ChatColor.RESET.toString() + ChatColor.GOLD.toString() + "$ ";

  private WeaponShop() {}

  public static void open(Player p) {
    Inventory inv = Bukkit.createInventory(p, 54, getName());
    addItems(inv, 0, Items.SHOP_PISTOLS);
    addItems(inv, 1, Items.SHOP_SMGS);
    addItems(inv, 2, Items.SHOP_HEAVY_WEAPONS);
    addItems(inv, 3, Items.SHOP_RIFLES);
    addItems(inv, 4, Items.SHOP_EQUIPMENT);
    addItems(inv, 5, Items.SHOP_GRENADES);
    p.openInventory(inv);
  }

  public static String getName() {
    return "Weapon Shop";
  }

  public static ItemStack getItemStack() {
    ItemStack is = new ItemStack(Material.EMERALD);
    ItemMeta im = is.getItemMeta();
    im.setDisplayName(ChatColor.BOLD + getName());
    is.setItemMeta(im);
    return is;
  }

  private static void addItems(Inventory inv, int offset, Buyable[] items) {
    for (int i = 0; i < items.length; i++) {
      ItemStack is = items[i].getItemStack();
      ItemMeta im = is.getItemMeta();
      List<String> lore = im.getLore();
      lore.add("");
      lore.add(prefix + String.valueOf(items[i].getPrice()));
      im.setLore(lore);
      is.setItemMeta(im);
      inv.setItem(offset + 9 * i, is);
    }
  }
}
 @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;
 }