Java Code Examples for org.bukkit.ChatColor#RED

The following examples show how to use org.bukkit.ChatColor#RED . 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 File: GameJoinSign.java    From BedwarsRel with GNU General Public License v3.0 6 votes vote down vote up
private String getCurrentPlayersString() {
  int maxPlayers = this.game.getMaxPlayers();
  int currentPlayers = 0;
  if (this.game.getState() == GameState.RUNNING) {
    currentPlayers = this.game.getTeamPlayers().size();
  } else if (this.game.getState() == GameState.WAITING) {
    currentPlayers = this.game.getPlayers().size();
  } else {
    currentPlayers = 0;
  }

  String current = "0";
  if (currentPlayers >= maxPlayers) {
    current = ChatColor.RED + String.valueOf(currentPlayers) + ChatColor.WHITE;
  } else {
    current = String.valueOf(currentPlayers);
  }

  return current;
}
 
Example 2
Source File: TicksPerSecondCommand.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
    if (!testPermission(sender)) return true;

    double tps = Math.min(20,  Math.round(net.minecraft.server.MinecraftServer.currentTps * 10) / 10.0);
    ChatColor color;
    if (tps > 19.2D) {
        color = ChatColor.GREEN;
    } else if (tps > 17.4D) {
        color = ChatColor.YELLOW;
    } else {
        color = ChatColor.RED;
    }

    sender.sendMessage(ChatColor.GOLD + "[TPS] " + color + tps);

    return true;
}
 
Example 3
Source File: FireBomb.java    From NBTEditor with GNU General Public License v3.0 5 votes vote down vote up
public FireBomb() {
	super("fire-bomb", ChatColor.RED + "Fire Bomb", Material.FIRE_CHARGE);
	setLore("§bLeft-click to throw the bomb.",
			"§bIt will explode after a few seconds.");
	setDefaultConfig("fuse", 40);
	setDefaultConfig("radius", 9);
}
 
Example 4
Source File: LogicalXNOR.java    From NeuralNetworkAPI with GNU General Public License v3.0 5 votes vote down vote up
public String learn() {

		/**
		 * Simple explanation of these steps:
		 * 
		 * 1) If it is currently learning, change the inputs to either true or false.
		 * 
		 * 2) Let the NN tick and think. This will return the outputs from the
		 * OutpuitNeurons
		 * 
		 * 3) If it is not learning, just return the answer.
		 * 
		 * 4) Else, do the logic and see if the answer it gave (thought[0]) was correct.
		 * 
		 * 5) If it was not correct, use the DeepReinforcementUtil to improve it.
		 * 
		 * 6) After inprovement, return a message with if it was correct, the accuracy,
		 * the inputs, and what it thought was the output,
		 */
		binary.changeValueAt(0, 0, ThreadLocalRandom.current().nextBoolean());
		binary.changeValueAt(0, 1, ThreadLocalRandom.current().nextBoolean());
		boolean[] thought = tickAndThink();
		boolean logic = (binary.getBooleanAt(0, 0) == binary.getBooleanAt(0, 1));
		boolean result = logic == thought[0];
		this.getAccuracy().addEntry(result);

		// IMPROVE IT
		HashMap<Neuron, Double> map = new HashMap<>();
		for (int i = 0; i < thought.length; i++)
			map.put(ai.getNeuronFromId(i), logic ? 1 : -1.0);
		if (!result)
			DeepReinforcementUtil.instantaneousReinforce(this, map, 1);
		return ((result ? ChatColor.GREEN : ChatColor.RED) + "acc " + getAccuracy().getAccuracyAsInt() + "|"
				+ binary.getBooleanAt(0, 0) + " + " + binary.getBooleanAt(0, 1) + " ~~ " + thought[0]);

	}
 
Example 5
Source File: LogicalNOR.java    From NeuralNetworkAPI with GNU General Public License v3.0 5 votes vote down vote up
public String learn() {
	/**
	 * Simple explanation of these steps:
	 * 
	 * 1) If it is currently learning, change the inputs to either true or false.
	 * 
	 * 2) Let the NN tick and think. This will return the outputs from the OutpuitNeurons
	 * 
	 * 3) If it is not learning, just return the answer.
	 * 
	 * 4) Else, do the logic and see if the answer it gave (thought[0]) was correct.
	 * 
	 * 5) If it was not correct, use the DeepReinforcementUtil to improve it.
	 * 
	 * 6) After inprovement, return a message with if it was correct, the accuracy, the inputs, and what it thought was the output,
	 */
	binary.changeValueAt(0, 0,
			ThreadLocalRandom.current().nextBoolean());
	binary.changeValueAt(0, 1,
			ThreadLocalRandom.current().nextBoolean());
	boolean[] thought = tickAndThink();
	boolean logic = !(binary.getBooleanAt(0, 0) || binary.getBooleanAt(0, 1));
	boolean wasCorrect = (logic == thought[0]);
	this.getAccuracy().addEntry(wasCorrect);

	// IMPROVE IT
	HashMap<Neuron, Double> map = new HashMap<>();
	for (int i = 0; i < thought.length; i++)
		map.put(ai.getNeuronFromId(i), logic ? 1.0 : -1.0);
	if (!wasCorrect)
		DeepReinforcementUtil.instantaneousReinforce(this, map,1);

	return (wasCorrect ? ChatColor.GREEN : ChatColor.RED) + "acc "
			+ getAccuracy().getAccuracyAsInt() + "|"
			+ binary.getBooleanAt(0, 0) + " + " + binary.getBooleanAt(0, 1)
			+ " ~~ " + thought[0];
	
}
 
Example 6
Source File: LogicalAND.java    From NeuralNetworkAPI with GNU General Public License v3.0 5 votes vote down vote up
public String learn() {
	/**
	 * Simple explanation of these steps:
	 * 
	 * 1) If it is currently learning, change the inputs to either true or false.
	 * 
	 * 2) Let the NN tick and think. This will return the outputs from the OutpuitNeurons
	 * 
	 * 3) If it is not learning, just return the answer.
	 * 
	 * 4) Else, do the logic and see if the answer it gave (thought[0]) was correct.
	 * 
	 * 5) If it was not correct, use the DeepReinforcementUtil to improve it.
	 * 
	 * 6) After inprovement, return a message with if it was correct, the accuracy, the inputs, and what it thought was the output,
	 */
	binary.changeValueAt(0, 0,
			ThreadLocalRandom.current().nextBoolean());
	binary.changeValueAt(0, 1,
			ThreadLocalRandom.current().nextBoolean());
	boolean[] thought = tickAndThink();
	boolean logic = (binary.getBooleanAt(0, 0) && binary.getBooleanAt(0, 1));
	boolean wasCorrect = (logic == thought[0]);
	this.getAccuracy().addEntry(wasCorrect);

	// IMPROVE IT
	HashMap<Neuron, Double> map = new HashMap<>();
	for (int i = 0; i < thought.length; i++)
		map.put(ai.getNeuronFromId(i), logic ? 1.0 : -1.0);
	if (!wasCorrect)
		DeepReinforcementUtil.instantaneousReinforce(this, map,1);

	return (wasCorrect ? ChatColor.GREEN : ChatColor.RED) + "acc "
			+ getAccuracy().getAccuracyAsInt() + "|"
			+ binary.getBooleanAt(0, 0) + " + " + binary.getBooleanAt(0, 1)
			+ " ~~ " + thought[0];
	
}
 
Example 7
Source File: LogicalInverted.java    From NeuralNetworkAPI with GNU General Public License v3.0 5 votes vote down vote up
public String learn() {
	/**
	 * Simple explanation of these steps:
	 * 
	 * 1) If it is currently learning, change the input to either true or false.
	 * 
	 * 2) Let the NN tick and think. This will return the outputs from the
	 * OutpuitNeurons
	 * 
	 * 3) If it is not learning, just return the answer.
	 * 
	 * 4) Else, do the logic and see if the answer it gave (thought[0]) was correct.
	 * 
	 * 5) If it was not correct, use the DeepReinforcementUtil to improve it.
	 * 
	 * 6) After inprovement, return a message with if it was correct, the accuracy,
	 * the inputs, and what it thought was the output,
	 */
	binary.changeValueAt(0, 0, ThreadLocalRandom.current().nextBoolean());
	boolean[] thought = tickAndThink();
	boolean logic = !(binary.getBooleanAt(0, 0));
	boolean result = (logic == thought[0]);
	this.getAccuracy().addEntry(result);

	// IMPROVE IT
	HashMap<Neuron, Double> map = new HashMap<>();
	for (int i = 0; i < thought.length; i++)
		map.put(ai.getNeuronFromId(i), logic ? 1 : -1.0);
	if (!result)
		DeepReinforcementUtil.instantaneousReinforce(this, map, 1);
	return ((result ? ChatColor.GREEN : ChatColor.RED) + "acc " + getAccuracy().getAccuracyAsInt() + "|"
			+ binary.getBooleanAt(0, 0) + " ~~ " + thought[0]);
}
 
Example 8
Source File: SushchestvoCommand.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
private boolean getToggle(CommandSender sender, String[] args)
{
    try
    {
        Setting toggle = MinecraftServer.getServer().sushchestvoConfig.getSettings().get(args[1]);
        // check config directly
        if (toggle == null && MinecraftServer.getServer().sushchestvoConfig.isSet(args[1]))
        {
            if (MinecraftServer.getServer().sushchestvoConfig.isBoolean(args[1]))
            {
                toggle = new BoolSetting(MinecraftServer.getServer().sushchestvoConfig, args[1], MinecraftServer.getServer().sushchestvoConfig.getBoolean(args[1], false), "");
            }
            else if (MinecraftServer.getServer().sushchestvoConfig.isInt(args[1]))
            {
                toggle = new IntSetting(MinecraftServer.getServer().sushchestvoConfig, args[1], MinecraftServer.getServer().sushchestvoConfig.getInt(args[1], 1), "");
            }
            if (toggle != null)
            {
                MinecraftServer.getServer().sushchestvoConfig.getSettings().put(toggle.path, toggle);
                MinecraftServer.getServer().sushchestvoConfig.load();
            }
        }
        if (toggle == null)
        {
            sender.sendMessage(ChatColor.RED + "Could not find option: " + args[1]);
            return false;
        }
        Object value = toggle.getValue();
        String option = (Boolean.TRUE.equals(value) ? ChatColor.GREEN : ChatColor.RED) + " " + value;
        sender.sendMessage(ChatColor.GOLD + args[1] + " " + option);
    }
    catch (Exception ex)
    {
        sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
        ex.printStackTrace();
    }
    return true;
}
 
Example 9
Source File: PrimeNumberBot.java    From NeuralNetworkAPI with GNU General Public License v3.0 5 votes vote down vote up
public String learn() {
	boolean[] bbb = numberToBinaryBooleans((lastNumber++ % 1023)/* (int) (Math.random() * 1023) */);
	for (int i = 0; i < bbb.length; i++) {
		binary.changeNumberAt(0, i, (bbb[i]) ? 1 : 0);
		binary.changeNumberAt(1, i, (bbb[i]) ? 0 : 1);
	}

	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);

	wasCorrect = (result == thought[0]);

	this.getAccuracy().addEntry(wasCorrect);
	accuracy = (float) this.getAccuracy().getAccuracy();

	// IMPROVE IT
	HashMap<Neuron, Double> map = new HashMap<>();
	map.put(ai.getNeuronFromId(0), result ? 1 : -1.0);
	if (!wasCorrect)
		DeepReinforcementUtil.instantaneousReinforce(this, map, 1);
	return ((wasCorrect ? ChatColor.GREEN : ChatColor.RED) + "acc " + ((int) (100 * accuracy)) + "|=" + number
			+ "|correctResp=" + result + "|WasPrime-Score "
			+ ((int) (100 * (ai.getNeuronFromId(0).getTriggeredStength()))));
}
 
Example 10
Source File: RadiationCommandHandler.java    From CraftserveRadiation with Apache License 2.0 5 votes vote down vote up
private boolean onSafe(Player sender, String label, String[] args) {
    String usage = ChatColor.RED + "/" + label + " safe <radius>";
    if (args.length == 1) {
        sender.sendMessage(ChatColor.RED + "Provide safe-from-radiation zone radius in the first argument. Radius will be relative to your current position.");
        sender.sendMessage(usage);
        return true;
    }

    int radius;
    try {
        radius = Integer.parseInt(args[1]);
    } catch (NumberFormatException e) {
        sender.sendMessage(ChatColor.RED + "Number was expected, but " + args[1] + " was provided.");
        sender.sendMessage(ChatColor.RED + usage);
        return true;
    }

    if (radius <= 0) {
        sender.sendMessage(ChatColor.RED + "Radius must be positive.");
        sender.sendMessage(ChatColor.RED + usage);
        return true;
    }

    RegionContainer container = this.worldGuardMatcher.getRegionContainer();
    if (container == null) {
        sender.sendMessage(ChatColor.RED + "Sorry, region container is not currently accessible.");
        return true;
    }

    if (this.define(sender, container, REGION_ID, radius)) {
        BlockVector2 origin = BukkitAdapter.asBlockVector(sender.getLocation()).toBlockVector2();
        sender.sendMessage(ChatColor.GREEN + "A new safe-from-radiation zone has been created in radius " +
                radius + " at the origin at " + origin + " in world " + sender.getWorld().getName() + ".");
    }
    return true;
}
 
Example 11
Source File: LogicalNAND.java    From NeuralNetworkAPI with GNU General Public License v3.0 5 votes vote down vote up
public String learn() {
	/**
	 * Simple explanation of these steps:
	 * 
	 * 1) If it is currently learning, change the inputs to either true or false.
	 * 
	 * 2) Let the NN tick and think. This will return the outputs from the OutpuitNeurons
	 * 
	 * 3) If it is not learning, just return the answer.
	 * 
	 * 4) Else, do the logic and see if the answer it gave (thought[0]) was correct.
	 * 
	 * 5) If it was not correct, use the DeepReinforcementUtil to improve it.
	 * 
	 * 6) After inprovement, return a message with if it was correct, the accuracy, the inputs, and what it thought was the output,
	 */
	binary.changeValueAt(0, 0,
			ThreadLocalRandom.current().nextBoolean());
	binary.changeValueAt(0, 1,
			ThreadLocalRandom.current().nextBoolean());
	boolean[] thought = tickAndThink();
	boolean logic = !(binary.getBooleanAt(0, 0)&& binary.getBooleanAt(0, 1));
	boolean wasCorrect = (logic == thought[0]);
	this.getAccuracy().addEntry(wasCorrect);

	// IMPROVE IT
	HashMap<Neuron, Double> map = new HashMap<>();
	for (int i = 0; i < thought.length; i++)
		map.put(ai.getNeuronFromId(i), logic ? 1.0 : -1.0);
	if (!wasCorrect)
		DeepReinforcementUtil.instantaneousReinforce(this, map,1);

	return (wasCorrect ? ChatColor.GREEN : ChatColor.RED) + "acc "
			+ getAccuracy().getAccuracyAsInt() + "|"
			+ binary.getBooleanAt(0, 0) + " + " + binary.getBooleanAt(0, 1)
			+ " ~~ " + thought[0];
	
}
 
Example 12
Source File: GameJoinSign.java    From BedwarsRel with GNU General Public License v3.0 5 votes vote down vote up
private String getStatus() {
  String status = null;
  if (this.game.getState() == GameState.WAITING && this.game.isFull()) {
    status = ChatColor.RED + BedwarsRel._l("sign.gamestate.full");
  } else {
    status = BedwarsRel._l("sign.gamestate." + this.game.getState().toString().toLowerCase());
  }

  return status;
}
 
Example 13
Source File: PlayerStatisticManager.java    From BedwarsRel with GNU General Public License v3.0 5 votes vote down vote up
private String getComparisonString(Integer value) {
  if (value > 0) {
    return ChatColor.GREEN + "+" + value;
  } else if (value < 0) {
    return ChatColor.RED + String.valueOf(value);
  } else {
    return String.valueOf(value);
  }
}
 
Example 14
Source File: ServerListener.java    From BedwarsRel with GNU General Public License v3.0 5 votes vote down vote up
private String getStatus(Game game) {
  String status = null;
  if (game.getState() == GameState.WAITING && game.isFull()) {
    status = ChatColor.RED + BedwarsRel._l("sign.gamestate.full");
  } else {
    status = BedwarsRel._l("sign.gamestate." + game.getState().toString().toLowerCase());
  }

  return status;
}
 
Example 15
Source File: PluginUtils.java    From TabooLib with MIT License 5 votes vote down vote up
public static String getFormattedName(Plugin plugin, boolean includeVersions) {
    ChatColor color = plugin.isEnabled() ? ChatColor.GREEN : ChatColor.RED;
    String pluginName = color + plugin.getName() + ChatColor.RESET;
    if (includeVersions) {
        pluginName = pluginName + " (" + plugin.getDescription().getVersion() + ")";
    }
    return pluginName;
}
 
Example 16
Source File: CommandHandler.java    From NyaaUtils with MIT License 5 votes vote down vote up
private ChatColor pingColor(double ping) {
    if (ping <= 30) {
        return ChatColor.GREEN;
    } else if (ping <= 60) {
        return ChatColor.DARK_GREEN;
    } else if (ping <= 100) {
        return ChatColor.YELLOW;
    } else if (ping <= 150) {
        return ChatColor.GOLD;
    }
    return ChatColor.RED;
}
 
Example 17
Source File: StartTimer.java    From CardinalPGM with MIT License 5 votes vote down vote up
private ChatMessage waitingPlayerMessage(int players) {
    List<TeamModule> teams = Teams.getTeams().stream()
            .filter((team) -> !team.isObserver() && team.size() < team.getMin()).limit(2).collect(Collectors.toList());
    return new UnlocalizedChatMessage(ChatColor.RED + "{0}",
            new LocalizedChatMessage(players == 1 ? ChatConstant.UI_WAITING_PLAYER : ChatConstant.UI_WAITING_PLAYERS,
                    ChatColor.AQUA + "" + players + ChatColor.RED,
                    teams.size() == 1 ? teams.get(0).getCompleteName() : ""));
}
 
Example 18
Source File: Poll.java    From CardinalPGM with MIT License 4 votes vote down vote up
private String command() {
    return ChatColor.RED + "\"" + ChatColor.GOLD + command + ChatColor.RED + "\"";
}
 
Example 19
Source File: NumberAdder.java    From NeuralNetworkAPI with GNU General Public License v3.0 4 votes vote down vote up
public String learn() {
	boolean[] bbb = numberToBinaryBooleans((int) (Math.random() * (Math.pow(2, max_bytes))));
	boolean[] bbb2 = numberToBinaryBooleans((int) (Math.random() * (Math.pow(2, max_bytes))));
	for (int i = 0; i < bbb.length; i++) {
		this.binary.changeValueAt(0, i, (bbb[i]));
		((NumberAdder) base).binary.changeValueAt(1, i, (!bbb[i]));
	}
	for (int i = 0; i < bbb2.length; i++) {
		((NumberAdder) base).binary.changeValueAt(2, i, (bbb2[i]));
		((NumberAdder) base).binary.changeValueAt(3, i, (!bbb2[i]));
	}
	boolean[] thought = tickAndThink();

	boolean[] booleanBase = new boolean[10];
	for (int i = 0; i < 10; i++) {
		booleanBase[i] = base.binary.getBooleanAt(0, i);
	}

	boolean[] booleanBase2 = new boolean[10];
	for (int i = 0; i < 10; i++) {
		booleanBase2[i] = base.binary.getBooleanAt(2, i);
	}
	int number = binaryBooleansToNumber(booleanBase);
	int number2 = binaryBooleansToNumber(booleanBase2);
	int number3 = binaryBooleansToNumber(thought);

	boolean result = number + number2 == number3;
	boolean[] correctvalues = numberToBinaryBooleans(number + number2);

	this.getAccuracy().addEntry(result);

	StringBuilder sb = new StringBuilder();
	int amountOfMistakes = 0;
	for (int i = 0; i < Math.max(correctvalues.length, thought.length); i++) {
		if (i < thought.length && thought[i]) {
			sb.append((correctvalues.length > i && correctvalues[i] ? ChatColor.DARK_GREEN : ChatColor.DARK_RED)
					+ "+" + ((int) Math.pow(2, i)));
			if (!(correctvalues.length > i && correctvalues[i]))
				amountOfMistakes++;
		} else if (i < correctvalues.length && correctvalues[i]) {
			sb.append(ChatColor.GRAY + "+" + ((int) Math.pow(2, i)));
			amountOfMistakes++;
		}
	}

	// IMPROVE IT
	HashMap<Neuron, Double> map = new HashMap<>();
	for (int i = 0; i < thought.length; i++) {
		map.put(base.ai.getNeuronFromId(i), correctvalues.length > i && correctvalues[i] ? 1 : -1.0);
	}

	// amountOfMistakes = (int) Math.pow(2,amountOfMistakes);
	if (!result)
		DeepReinforcementUtil.instantaneousReinforce(base, map, amountOfMistakes);
	return ((result ? ChatColor.GREEN : ChatColor.RED) + "acc " + getAccuracy().getAccuracyAsInt() + "|" + number
			+ " + " + number2 + " = " + number3 + "|  " + sb.toString());
}
 
Example 20
Source File: HealthDisplay.java    From EliteMobs with GNU General Public License v3.0 3 votes vote down vote up
private static ChatColor setHealthColor(int currentHealth, int maxHealth) {

        double healthPercentage = currentHealth * 100 / maxHealth;

        if (healthPercentage > 75) {

            return ChatColor.DARK_GREEN;

        }

        if (healthPercentage > 50) {

            return ChatColor.GREEN;

        }

        if (healthPercentage > 25) {

            return ChatColor.RED;

        }

        if (healthPercentage > 0) {

            return ChatColor.DARK_RED;

        }

        return ChatColor.DARK_RED;

    }