Java Code Examples for org.bukkit.ChatColor

The following examples show how to use org.bukkit.ChatColor. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: BedwarsRel   Source File: SetLobbyCommand.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean execute(CommandSender sender, ArrayList<String> args) {
  if (!super.hasPermission(sender)) {
    return false;
  }

  Player player = (Player) sender;

  Game game = this.getPlugin().getGameManager().getGame(args.get(0));
  if (game == null) {
    player.sendMessage(ChatWriter.pluginMessage(ChatColor.RED
        + BedwarsRel
        ._l(player, "errors.gamenotfound", ImmutableMap.of("game", args.get(0).toString()))));
    return false;
  }

  if (game.getState() != GameState.STOPPED) {
    sender.sendMessage(
        ChatWriter.pluginMessage(ChatColor.RED + BedwarsRel
            ._l(sender, "errors.notwhilegamerunning")));
    return false;
  }

  game.setLobby(player);
  return true;
}
 
Example 2
Source Project: SkyWarsReloaded   Source File: MatchManager.java    License: GNU General Public License v3.0 6 votes vote down vote up
public void start(final GameMap gameMap) {
	debug = SkyWarsReloaded.getCfg().debugEnabled();
	if (debug) {
     	debugName = ChatColor.RED + "SWR[" + gameMap.getName() + "] ";
    }
    if (gameMap == null) {
        return;
    }
	gameMap.removeDMSpawnBlocks();
    this.setWaitTime(SkyWarsReloaded.getCfg().getWaitTimer());
    this.setGameTime();
    gameMap.setMatchState(MatchState.WAITINGSTART);
    gameMap.update();
    gameMap.getGameBoard().updateScoreboard();
    this.waitStart(gameMap);
}
 
Example 3
Source Project: MineTinker   Source File: TinkerListener.java    License: GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onModifierApply(ModifierApplyEvent event) {
	Player player = event.getPlayer();
	ItemStack tool = event.getTool();
	Modifier mod = event.getMod();

	if (MineTinker.getPlugin().getConfig().getBoolean("Sound.OnModding")) {
		player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_USE, 1.0F, 0.5F);
	}

	ChatWriter.sendActionBar(player,
			LanguageManager.getString("TinkerListener.ModifierApply", player)
					.replace("%tool", ChatWriter.getDisplayName(tool) + ChatColor.WHITE)
					.replace("%mod", mod.getColor() + mod.getName() + ChatColor.WHITE)
					.replace("%slots", String.valueOf(event.getSlotsRemaining())));
	ChatWriter.log(false, player.getDisplayName() + " modded " + ChatWriter.getDisplayName(tool)
			+ ChatColor.GRAY + " (" + tool.getType().toString() + ") with " + mod.getColor() + mod.getName()
			+ ChatColor.GRAY + " " + modManager.getModLevel(tool, mod) + "!");
}
 
Example 4
Source Project: ProRecipes   Source File: RecipeBuilder.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void openShaped(final Player p) {
	final ItemStack i = p.getOpenInventory().getItem(0).clone();
	
	ItemBuilder.close(p);
	p.setMetadata("closed", new FixedMetadataValue(ProRecipes.getPlugin(), ""));
	ItemBuilder.sendMessage(p, m.getMessage("Recipe_Builder_Title", ChatColor.GOLD + "Recipe Builder") ,  m.getMessage("Recipe_Builder_Add", ChatColor.DARK_GREEN + "Add your ingredients! Close to save recipe."));
	ProRecipes.getPlugin().getServer().getScheduler().runTaskLater(ProRecipes.getPlugin(), new Runnable(){

		@Override
		public void run() {
			p.setMetadata("recipeBuilder", new FixedMetadataValue(ProRecipes.getPlugin(), "craftRecipeShaped"));
			p.openWorkbench(null, true);
			//p.removeMetadata("closed", RPGRecipes.getPlugin());
			p.getOpenInventory().setItem(0, i);
			//Inventory i = RPGRecipes.getPlugin().getServer().createInventory(p, InventoryType.WORKBENCH, "ItemBuilder");
			//p.openInventory(i);
		}
		
	}, ProRecipes.getPlugin().wait);
	
}
 
Example 5
@Override
public String update() {
	boolean[] thought = tickAndThink();
	float accuracy = 0;

	// If it isprime:

	boolean[] booleanBase = new boolean[10];
	for (int i = 0; i < 10; i++) {
		booleanBase[i] = binary.getNumberAt(0, i) != 0;
	}
	int number = binaryBooleansToNumber(booleanBase);
	boolean result = ifNumberIsPrime.get(number);

	return ((thought[0] ? ChatColor.DARK_GREEN : ChatColor.DARK_RED) + "|=" + number + "|WasPrime-Score "
			+ ((int) (100 * (ai.getNeuronFromId(0).getTriggeredStength()))));

}
 
Example 6
@Override
public void executeCommand(CommandSender sender, List<String> args) {
    if (sender instanceof Player) {
        // Send the pretty version
        sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------------------------------------------");
        sender.sendMessage(ChatColor.DARK_GRAY + "                [ " + ChatColor.BLUE + "PerWorldInventory Commands" + ChatColor.DARK_GRAY + " ]");
        sender.sendMessage(ChatColor.GRAY + "Commands may be run using either " + ChatColor.WHITE + "/perworldinventory" + ChatColor.GRAY + " or " + ChatColor.WHITE + "/pwi");
        sender.sendMessage("");
        sender.sendMessage(ChatColor.BLUE + "» " + ChatColor.WHITE + "/perworldinventory convert multiverse" + ChatColor.BLUE + " - " + ChatColor.GRAY + "Convert data from Multiverse-Inventories");
        sender.sendMessage(ChatColor.BLUE + "» " + ChatColor.WHITE + "/perworldinventory help" + ChatColor.BLUE + " - " + ChatColor.GRAY + "Shows this help page");
        sender.sendMessage(ChatColor.BLUE + "» " + ChatColor.WHITE + "/perworldinventory reload" + ChatColor.BLUE + " - " + ChatColor.GRAY + "Reloads all configuration files");
        sender.sendMessage(ChatColor.BLUE + "» " + ChatColor.WHITE + "/perworldinventory version" + ChatColor.BLUE + " - " + ChatColor.GRAY + "Shows the version and authors of the server");
        sender.sendMessage(ChatColor.BLUE + "» " + ChatColor.WHITE + "/perworldinventory setworlddefault [group|serverDefault]" + ChatColor.BLUE + " - " + ChatColor.GRAY + "Set the default inventory loadout for a world, or the server default." + '\n' + ChatColor.YELLOW + "The group you are standing in will be used if no group is specified.");
        sender.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "-----------------------------------------------------");
    } else {
        // Sender is the console, no pretty stuff for you!
        sender.sendMessage("-----------------------------------------------------");
        sender.sendMessage("PerWorldInventory commands:");
        sender.sendMessage("/perworldinventory convert - Convert MultiVerse-Inventories data");
        sender.sendMessage("/perworldinventory help - Displays this help");
        sender.sendMessage("/perworldinventory version - Shows the version of the server");
        sender.sendMessage("/perworldinventory reload - Reload config and world files");
        sender.sendMessage("-----------------------------------------------------");
    }
}
 
Example 7
Source Project: Survival-Games   Source File: BandageUse.java    License: GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@EventHandler
public void onBandageUse(PlayerInteractEvent e) {
	   Player p = e.getPlayer();
	   Boolean active = GameManager.getInstance().isPlayerActive(p);
	   if (!active) {
	      return;
	   }
	   
	if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
		if (e.getPlayer().getItemInHand().getType() == Material.PAPER) {
			e.getPlayer().getInventory().removeItem(new ItemStack(Material.PAPER, 1));
			double newhealth = e.getPlayer().getHealth() + 10;
			if((newhealth > 20.0) || (newhealth < 0 )) { newhealth = 20.0; }
			e.getPlayer().setHealth(newhealth);
			e.getPlayer().sendMessage(ChatColor.GREEN + "You used a bandage and got 5 hearts.");
	        }
		}
	}
 
Example 8
Source Project: civcraft   Source File: CivTutorial.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static ItemStack getInfoBookForItem(String matID) {
	LoreCraftableMaterial loreMat = LoreCraftableMaterial.getCraftMaterialFromId(matID);
	ItemStack stack = LoreMaterial.spawn(loreMat);
						
	if (!loreMat.isCraftable()) {
		return null;
	}
	
	AttributeUtil attrs = new AttributeUtil(stack);
	attrs.removeAll(); /* Remove all attribute modifiers to prevent them from displaying */
	LinkedList<String> lore = new LinkedList<String>();
	
	lore.add(""+ChatColor.RESET+ChatColor.BOLD+ChatColor.GOLD+"Click For Recipe");
	
	attrs.setLore(lore);				
	stack = attrs.getStack();
	return stack;
}
 
Example 9
Source Project: Civs   Source File: FallEffect.java    License: GNU General Public License v3.0 6 votes vote down vote up
public boolean meetsRequirement() {
    Object target = getTarget();
    Entity origin = getOrigin();
    if (!(target instanceof LivingEntity)) {
        return false;
    }

    LivingEntity livingEntity = (LivingEntity) target;

    if (livingEntity.getFallDistance() < this.distance) {
        if (!this.silent && origin instanceof Player) {
            ((Player) origin).sendMessage(ChatColor.RED + Civs.getPrefix() + " target isn't hasn't fallen " + this.distance + " blocks.");
        }
        return false;
    }
    return true;
}
 
Example 10
Source Project: EchoPet   Source File: SpawnUtil.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public EntityPet spawn(IPet pet, Player owner) {
    Location l = owner.getLocation();
    PetPreSpawnEvent spawnEvent = new PetPreSpawnEvent(pet, l);
    EchoPet.getPlugin().getServer().getPluginManager().callEvent(spawnEvent);
    if (spawnEvent.isCancelled()) {
        owner.sendMessage(EchoPet.getPrefix() + ChatColor.YELLOW + "Pet spawn was cancelled externally.");
        EchoPet.getManager().removePet(pet, true);
        return null;
    }
    l = spawnEvent.getSpawnLocation();
    World mcWorld = ((CraftWorld) l.getWorld()).getHandle();
    EntityPet entityPet = (EntityPet) pet.getPetType().getNewEntityPetInstance(mcWorld, pet);

    entityPet.setLocation(new Location(mcWorld.getWorld(), l.getX(), l.getY(), l.getZ(), l.getYaw(), l.getPitch()));
    if (!l.getChunk().isLoaded()) {
        l.getChunk().load();
    }
    if (!mcWorld.addEntity(entityPet, CreatureSpawnEvent.SpawnReason.CUSTOM)) {
        owner.sendMessage(EchoPet.getPrefix() + ChatColor.YELLOW + "Failed to spawn pet entity.");
        EchoPet.getManager().removePet(pet, true);
    } else {
        Particle.MAGIC_RUNES.builder().at(l).show();
    }
    return entityPet;
}
 
Example 11
protected void writeAllFormatCodes(Modifier modifier) {
	if (Boolean.TRUE.equals(modifier.isBold())) {
		out.append(ChatColor.BOLD);
	}
	if (Boolean.TRUE.equals(modifier.isItalic())) {
		out.append(ChatColor.ITALIC);
	}
	if (Boolean.TRUE.equals(modifier.isUnderlined())) {
		out.append(ChatColor.UNDERLINE);
	}
	if (Boolean.TRUE.equals(modifier.isStrikethrough())) {
		out.append(ChatColor.STRIKETHROUGH);
	}
	if (Boolean.TRUE.equals(modifier.isRandom())) {
		out.append(ChatColor.MAGIC);
	}
}
 
Example 12
Source Project: MineTinker   Source File: ChatWriter.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static List<String> splitString(String msg, int lineSize) {
	if (msg == null) return new ArrayList<>();
	List<String> res = new ArrayList<>();

	String[] str = msg.split(" ");
	int index = 0;
	while (index < str.length) {
		StringBuilder line = new StringBuilder();
		do {
			index++;
			line.append(str[index - 1]);
			line.append(" ");
		} while (index < str.length && line.length() + str[index].length() < lineSize);
		res.add(ChatColor.WHITE + line.toString().substring(0, line.length() - 1));
	}

	return res;
}
 
Example 13
Source Project: SonarPet   Source File: EchoPetPlugin.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    if (commandLabel.equalsIgnoreCase("echopet")) {
        if (sender.hasPermission("echopet.petadmin")) {
            PluginDescriptionFile pdFile = this.getDescription();
            sender.sendMessage(ChatColor.RED + "-------- SonarPet --------");
            sender.sendMessage(ChatColor.GOLD + "Author: " + ChatColor.YELLOW + "DSH105");
            sender.sendMessage(ChatColor.GOLD + "Version: " + ChatColor.YELLOW + pdFile.getVersion());
            sender.sendMessage(ChatColor.GOLD + "Website: " + ChatColor.YELLOW + pdFile.getWebsite());
            sender.sendMessage(ChatColor.GOLD + "Commands are registered at runtime to provide you with more dynamic control over the command labels.");
            sender.sendMessage(ChatColor.GOLD + "" + ChatColor.UNDERLINE + "Command Registration:");
            sender.sendMessage(ChatColor.GOLD + "Main: " + OPTIONS.getCommandString());
            sender.sendMessage(ChatColor.GOLD + "Admin: " + OPTIONS.getCommandString() + "admin");
        } else {
            Lang.sendTo(sender, Lang.NO_PERMISSION.toString().replace("%perm%", "echopet.petadmin"));
            return true;
        }
    }
    return false;
}
 
Example 14
Source Project: BedwarsRel   Source File: Game.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void updateSignConfig() {
  try {
    File config = new File(
        BedwarsRel.getInstance().getDataFolder() + "/" + GameManager.gamesPath + "/"
            + this.name + "/sign.yml");

    YamlConfiguration cfg = new YamlConfiguration();
    if (config.exists()) {
      cfg = YamlConfiguration.loadConfiguration(config);
    }

    List<Map<String, Object>> locList = new ArrayList<Map<String, Object>>();
    for (Location loc : this.joinSigns.keySet()) {
      locList.add(Utils.locationSerialize(loc));
    }

    cfg.set("signs", locList);
    cfg.save(config);
  } catch (Exception ex) {
    BedwarsRel.getInstance().getBugsnag().notify(ex);
    BedwarsRel.getInstance().getServer().getConsoleSender()
        .sendMessage(ChatWriter.pluginMessage(ChatColor.RED + BedwarsRel
            ._l(BedwarsRel.getInstance().getServer().getConsoleSender(), "errors.savesign")));
  }
}
 
Example 15
Source Project: civcraft   Source File: AdminCivCommand.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void bankrupt_cmd() throws CivException {
	Civilization civ = getNamedCiv(1);
	
	if (args.length < 3) {
		CivMessage.send(sender, CivColor.Yellow+ChatColor.BOLD+"Are you absolutely sure you want to wipe ALL COINS from ALL RESIDENTS and ALL TOWNS of this civ?");
		CivMessage.send(sender, "use /civ bankrupt yes if you do.");
	}
	
	civ.getTreasury().setBalance(0);
	
	for (Town town : civ.getTowns()) {
		town.getTreasury().setBalance(0);
		town.save();
		
		for (Resident resident : town.getResidents()) {
			resident.getTreasury().setBalance(0);
			resident.save();
		}
	}
	
	civ.save();
	CivMessage.sendSuccess(sender, "Bankrupted "+civ.getName());
}
 
Example 16
Source Project: ChestCommands   Source File: FormatUtils.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static List<String> colorizeLore(List<String> input) {
	if (input == null || input.isEmpty()) return input;

	for (int i = 0; i < input.size(); i++) {

		String line = input.get(i);

		if (line.isEmpty()) continue;

		if (line.charAt(0) != ChatColor.COLOR_CHAR) {
			input.set(i, ChestCommands.getSettings().default_color__lore + addColors(line));
		} else {
			input.set(i, addColors(line));
		}
	}
	return input;
}
 
Example 17
Source Project: GriefDefender   Source File: SignUtil.java    License: MIT License 6 votes vote down vote up
private static Consumer<CommandSender> createSaleConfirmationConsumer(CommandSender src, Claim claim, Sign sign, double price) {
    return confirm -> {
        claim.getEconomyData().setSalePrice(price);
        claim.getEconomyData().setForSale(true);
        claim.getEconomyData().setSaleSignPosition(VecHelper.toVector3i(sign.getLocation()));
        claim.getData().save();
        List<String> lines = new ArrayList<>(4);
        lines.add(ChatColor.translateAlternateColorCodes('&', "&7[&bGD&7-&1sell&7]"));
        lines.add(ChatColor.translateAlternateColorCodes('&', LegacyComponentSerializer.legacy().serialize(MessageCache.getInstance().ECONOMY_SIGN_SELL_DESCRIPTION)));
        lines.add(ChatColor.translateAlternateColorCodes('&', "&4$" + String.format("%.2f", price)));
        lines.add(ChatColor.translateAlternateColorCodes('&', LegacyComponentSerializer.legacy().serialize(MessageCache.getInstance().ECONOMY_SIGN_SELL_FOOTER)));

        for (int i = 0; i < lines.size(); i++) {
            sign.setLine(i, lines.get(i));
        }
        sign.update();
        final Component message = GriefDefenderPlugin.getInstance().messageData.getMessage(MessageStorage.ECONOMY_CLAIM_SALE_CONFIRMED,
                ImmutableMap.of("amount", price));
        GriefDefenderPlugin.sendMessage(src, message);
    };
}
 
Example 18
Source Project: LagMonitor   Source File: PingCommand.java    License: MIT License 6 votes vote down vote up
private void displayPingOther(CommandSender sender, Command command, String playerName) {
    if (sender.hasPermission(command.getPermission() + ".other")) {
        RollingOverHistory sampleHistory = plugin.getPingManager().getHistory(playerName);
        if (sampleHistory == null || !canSee(sender, playerName)) {
            sendError(sender, "No data for that player " + playerName);
            return;
        }

        int lastPing = (int) sampleHistory.getLastSample();

        sender.sendMessage(ChatColor.WHITE + playerName + PRIMARY_COLOR + "'s ping is: "
                + ChatColor.DARK_GREEN + lastPing + "ms");

        float pingAverage = LagUtils.round(sampleHistory.getAverage());
        sender.sendMessage(PRIMARY_COLOR + "Average: " + ChatColor.DARK_GREEN + pingAverage + "ms");
    } else {
        sendError(sender, "You don't have enough permission");
    }
}
 
Example 19
@Override
public void run() {

	List<String> lines = Utils.newArrayList();

	lines.add(" ");
	lines.add(ChatColor.RED + "#------------------- Chest Commands Errors -------------------#");
	int count = 1;
	for (String error : errorLogger.getErrors()) {
		lines.add(ChatColor.GRAY + "" + (count++) + ") " + ChatColor.WHITE + error);
	}
	lines.add(ChatColor.RED + "#-------------------------------------------------------------#");

	String output = StringUtils.join(lines, "\n");

	if (ChestCommands.getSettings().use_console_colors) {
		Bukkit.getConsoleSender().sendMessage(output);
	} else {
		System.out.println(ChatColor.stripColor(output));
	}
}
 
Example 20
Source Project: CardinalPGM   Source File: SettingCommands.java    License: MIT License 6 votes vote down vote up
@Command(aliases = {"settings"}, desc = "List all settings.", usage = "[page]")
public static void settings(final CommandContext cmd, CommandSender sender) throws CommandException {
    if (cmd.argsLength() == 0) {
        Bukkit.dispatchCommand(sender, "settings 1");
    } else {
        int page = cmd.getInteger(0);
        if (page > (Settings.getSettings().size() + 7) / 8) {
            throw new CommandException(new LocalizedChatMessage(ChatConstant.ERROR_INVALID_PAGE_NUMBER, "" + (Settings.getSettings().size() + 7) / 8).getMessage(ChatUtil.getLocale(sender)));
        }
        sender.sendMessage(ChatColor.RED + "" + ChatColor.STRIKETHROUGH + "--------------" + ChatColor.YELLOW + " Settings (Page " + page + " of " + ((Settings.getSettings().size() + 7) / 8) + ") " + ChatColor.RED + "" + ChatColor.STRIKETHROUGH + "--------------");
        for (int i = (page - 1) * 8; i < page * 8; i++) {
            if (i < Settings.getSettings().size()) {
                sender.sendMessage(ChatColor.YELLOW + Settings.getSettings().get(i).getNames().get(0) + ": " + ChatColor.WHITE + Settings.getSettings().get(i).getDescription());
            }
        }
    }
}
 
Example 21
Source Project: Survival-Games   Source File: TeleportEvent.java    License: GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void playerTeleport(PlayerTeleportEvent event) {
    Player p = event.getPlayer();
    int id = GameManager.getInstance().getPlayerGameId(p);
    if(id == -1) return;
    if(GameManager.getInstance().getGame(id).isPlayerActive(p) && event.getCause() == PlayerTeleportEvent.TeleportCause.COMMAND){
        p.sendMessage(ChatColor.RED +" Cannot teleport while ingame!");
        event.setCancelled(true);
    }
}
 
Example 22
Source Project: CratesPlus   Source File: Crate.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void loadCrateBase() {
    CratesPlus cratesPlus = configHandler.getCratesPlus();
    if (cratesPlus.getConfig().isSet("Crates." + name + ".Hide Percentages"))
        this.hidePercentages = cratesPlus.getConfig().getBoolean("Crates." + name + ".Hide Percentages");
    if (cratesPlus.getConfig().isSet("Crates." + name + ".Color"))
        this.color = ChatColor.valueOf(cratesPlus.getConfig().getString("Crates." + name + ".Color").toUpperCase());
    if (cratesPlus.getConfig().isSet("Crates." + name + ".Block"))
        this.block = Material.valueOf(cratesPlus.getConfig().getString("Crates." + name + ".Block").toUpperCase());
    if (cratesPlus.getConfig().isSet("Crates." + name + ".Block Data"))
        this.blockData = cratesPlus.getConfig().getInt("Crates." + name + ".Block Data", 0);
    if (cratesPlus.getConfig().isSet("Crates." + name + ".Permission"))
        this.permission = cratesPlus.getConfig().getString("Crates." + name + ".Permission");
    if (cratesPlus.getConfig().isSet("Crates." + name + ".Firework"))
        this.firework = cratesPlus.getConfig().getBoolean("Crates." + name + ".Firework");
    if (cratesPlus.getConfig().isSet("Crates." + name + ".Broadcast"))
        this.broadcast = cratesPlus.getConfig().getBoolean("Crates." + name + ".Broadcast");
    if (cratesPlus.getConfig().isSet("Crates." + name + ".Opener"))
        this.opener = cratesPlus.getConfig().getString("Crates." + name + ".Opener");
    if (cratesPlus.getConfig().isSet("Crates." + name + ".Cooldown"))
        this.cooldown = cratesPlus.getConfig().getInt("Crates." + name + ".Cooldown");

    if (!cratesPlus.getConfig().isSet("Crates." + name + ".Winnings"))
        return;

    if (cratesPlus.getConfig().getConfigurationSection("Crates." + name + ".Winnings") != null) {
        for (String id : cratesPlus.getConfig().getConfigurationSection("Crates." + name + ".Winnings").getKeys(false)) {
            String path = "Crates." + name + ".Winnings." + id;
            Winning winning = new Winning(this, path, cratesPlus, null);
            if (!winning.isValid()) {
                Bukkit.getLogger().warning(path + " is an invalid winning.");
                continue;
            }
            totalPercentage = totalPercentage + winning.getPercentage();
            winnings.add(winning);
        }
    }
}
 
Example 23
Source Project: ce   Source File: Firecracker.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
public Firecracker(String originalName, ChatColor color, String lDescription, long lCooldown, Material mat) {
	super(originalName, color, lDescription, lCooldown, mat);
	triggers.add(Trigger.PROJECTILE_HIT);
	triggers.add(Trigger.PROJECTILE_THROWN);
	triggers.add(Trigger.DAMAGE_GIVEN);

}
 
Example 24
Source Project: ce   Source File: Bandage.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
public Bandage(String originalName, ChatColor color, String lDescription, long lCooldown, Material mat) {
	super(originalName, color, lDescription, lCooldown, mat);
	this.configEntries.put("TotalHealAmount", 10);
	this.configEntries.put("TotalHealTime", 200);
	this.configEntries.put("StopAtFullHealth", true);
	triggers.add(Trigger.INTERACT_RIGHT);
	triggers.add(Trigger.INTERACT_ENTITY);
	triggers.add(Trigger.DAMAGE_GIVEN);
}
 
Example 25
public String getOption(String key, String def) {
	if (options == null) {
		return def;
	}
	
	return ChatColor.translateAlternateColorCodes('&', options.getString(key, def));
}
 
Example 26
Source Project: HoloAPI   Source File: EditCommand.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Command(
        command = "edit <id> <line> <content...>",
        description = "Edit a line of an existing hologram",
        permission = "holoapi.holo.edit",
        help = "The content can be more than one word"
)
public boolean editWithContent(CommandEvent event) {
    final Hologram hologram = HoloAPI.getManager().getHologram(event.variable("id"));
    if (hologram == null) {
        event.respond(Lang.HOLOGRAM_NOT_FOUND.getValue("id", event.variable("id")));
        return true;
    }

    int lineNumber;
    try {
        lineNumber = GeneralUtil.toInteger(event.variable("line_number"));
    } catch (NumberFormatException e) {
        event.respond(Lang.INT_ONLY.getValue("string", event.variable("line_number")));
        return true;
    }

    if (lineNumber > hologram.getLines().length) {
        event.respond(Lang.LINE_INDEX_TOO_BIG.getValue("index", event.variable("line_number")));
        return true;
    }

    hologram.updateLine(lineNumber - 1, event.variable("content"));
    event.respond(Lang.HOLOGRAM_UPDATE_LINE.getValue("index", lineNumber, "input", ChatColor.translateAlternateColorCodes('&', event.variable("content"))));
    return true;
}
 
Example 27
@Test
public void testSetId() throws InterruptedException {
    Player player = server.addPlayer();
    ItemStack item = new CustomItem(Material.CHEST, "&cA mocked Backpack", "", "&7Size: &e" + BACKPACK_SIZE, "&7ID: <ID>", "", "&7&eRight Click&7 to open");

    PlayerProfile profile = TestUtilities.awaitProfile(player);
    int id = profile.createBackpack(BACKPACK_SIZE).getId();

    listener.setBackpackId(player, item, 2, id);
    Assertions.assertEquals(ChatColor.GRAY + "ID: " + player.getUniqueId() + "#" + id, item.getItemMeta().getLore().get(2));

    PlayerBackpack backpack = awaitBackpack(item);
    Assertions.assertEquals(player.getUniqueId(), backpack.getOwner().getUUID());
    Assertions.assertEquals(id, backpack.getId());
}
 
Example 28
Source Project: Statz   Source File: DependencyManager.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Loads all dependencies used for Statz. <br>
 * Statz will check for dependencies and shows the output on the console.
 */
public void loadDependencies() {

    // Make seperate loading bar

    plugin.debugMessage(ChatColor.YELLOW + "---------------[Statz Dependencies]---------------");
    plugin.debugMessage(ChatColor.GREEN + "Searching dependencies...");

    // Load all dependencies
    for (final DependencyHandler depHandler : handlers.values()) {
        // Make sure to respect settings
        boolean succeeded = depHandler.setup(true);

        if (succeeded) {
            StatzDependency dependency = this.getDependencyByHandler(depHandler);

            if (dependency == null)
                continue;

            plugin.debugMessage(ChatColor.GREEN + dependency.getInternalString()
                    + " was found and Statz now tracks its data!");
        }
    }

    // Make seperate stop loading bar
    plugin.debugMessage(ChatColor.YELLOW + "---------------[Statz Dependencies]---------------");

    plugin.debugMessage("Loaded libraries and dependencies");
}
 
Example 29
Source Project: BedwarsRel   Source File: BedwarsRel.java    License: GNU General Public License v3.0 5 votes vote down vote up
public void startMetricsIfEnabled() {
  if (this.metricsEnabled()) {
    new BStatsMetrics(this);
    try {
      McStatsMetrics mcStatsMetrics = new McStatsMetrics(this);
      mcStatsMetrics.start();
    } catch (Exception ex) {
      BedwarsRel.getInstance().getBugsnag().notify(ex);
      this.getServer().getConsoleSender().sendMessage(ChatWriter
          .pluginMessage(ChatColor.RED + "Metrics are enabled, but couldn't send data!"));
    }
  }
}
 
Example 30
private void showHelpForCommand(CommandSender sender, FoundCommandResult result) {
    sender.sendMessage(ChatColor.DARK_RED + "Incorrect command arguments!");
    helpProvider.outputHelp(sender, result, HelpProvider.SHOW_ARGUMENTS);

    List<String> labels = result.getLabels();
    String childLabel = labels.size() >= 2 ? labels.get(1) : "";
    sender.sendMessage(ChatColor.GOLD + "Detailed help: " + ChatColor.WHITE
        + "/" + labels.get(0) + " help " + childLabel);
}