org.bukkit.ChatColor Java Examples

The following examples show how to use org.bukkit.ChatColor. 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: HelpCommand.java    From PerWorldInventory with GNU General Public License v3.0 7 votes vote down vote up
@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 #2
Source File: SettingCommands.java    From CardinalPGM with 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 #3
Source File: TinkerListener.java    From MineTinker with 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 File: RecipeBuilder.java    From ProRecipes with 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
Source File: PrimeNumberBot.java    From NeuralNetworkAPI with GNU General Public License v3.0 6 votes vote down vote up
@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
Source File: SetLobbyCommand.java    From BedwarsRel with 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 #7
Source File: BandageUse.java    From Survival-Games with 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 File: CivTutorial.java    From civcraft with 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 File: FallEffect.java    From Civs with 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 File: SpawnUtil.java    From EchoPet with 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
Source File: ChatWriter.java    From MineTinker with 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 #12
Source File: EchoPetPlugin.java    From SonarPet with 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 #13
Source File: Game.java    From BedwarsRel with 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 #14
Source File: AdminCivCommand.java    From civcraft with 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 #15
Source File: FormatUtils.java    From ChestCommands with 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 #16
Source File: SignUtil.java    From GriefDefender with 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 #17
Source File: PingCommand.java    From LagMonitor with 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 #18
Source File: ErrorLoggerTask.java    From ChestCommands with GNU General Public License v3.0 6 votes vote down vote up
@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 #19
Source File: MatchManager.java    From SkyWarsReloaded with 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 #20
Source File: LegacyChat.java    From ProtocolSupport with GNU Affero General Public License v3.0 6 votes vote down vote up
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 #21
Source File: MenuItem.java    From CS-CoreLib with GNU General Public License v3.0 5 votes vote down vote up
public MenuItem(Material type, String name, int durability, String action) {
	super(type);
	ItemMeta im = getItemMeta();
	im.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
	List<String> lore = new ArrayList<String>();
	lore.add("");
	lore.add(ChatColor.GREEN + "> Click to " + action);
	im.setLore(lore);
	setItemMeta(im);
	setDurability((short) durability);
}
 
Example #22
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 #23
Source File: ChatUtil.java    From CardinalPGM with MIT License 5 votes vote down vote up
public static ChatColor getTimerColor(double time) {
    if (time <= 5) {
        return ChatColor.DARK_RED;
    } else if (time <= 30) {
        return ChatColor.GOLD;
    } else if (time <= 60) {
        return ChatColor.YELLOW;
    } else {
        return ChatColor.GREEN;
    }
}
 
Example #24
Source File: SignLayoutConfiguration.java    From HeavySpleef with GNU General Public License v3.0 5 votes vote down vote up
public String getOption(String key, String def) {
	if (options == null) {
		return def;
	}
	
	return ChatColor.translateAlternateColorCodes('&', options.getString(key, def));
}
 
Example #25
Source File: CitizensInteractTaskType.java    From Quests with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onNPCClick(NPCRightClickEvent event) {
    QPlayer qPlayer = QuestsAPI.getPlayerManager().getPlayer(event.getClicker().getUniqueId(), true);
    if (qPlayer == null) {
        return;
    }

    QuestProgressFile questProgressFile = qPlayer.getQuestProgressFile();

    for (Quest quest : super.getRegisteredQuests()) {
        if (questProgressFile.hasStartedQuest(quest)) {
            QuestProgress questProgress = questProgressFile.getQuestProgress(quest);

            for (Task task : quest.getTasksOfType(super.getType())) {
                if (!ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', String.valueOf(task.getConfigValue("npc-name")))).equals(ChatColor
                        .stripColor(ChatColor.translateAlternateColorCodes('&', event.getNPC().getName())))) {
                    return;
                }
                TaskProgress taskProgress = questProgress.getTaskProgress(task.getId());

                if (taskProgress.isCompleted()) {
                    continue;
                }

                taskProgress.setCompleted(true);
            }
        }
    }
}
 
Example #26
Source File: TutorialListener.java    From ServerTutorial with MIT License 5 votes vote down vote up
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    String name = player.getName();
    if (event.getAction() != Action.PHYSICAL) {
        if (TutorialManager.getManager().isInTutorial(name) && TutorialManager.getManager().getCurrentTutorial
                (name).getViewType() != ViewType.TIME) {
            if (TutorialManager.getManager().getCurrentTutorial(name).getTotalViews() == TutorialManager
                    .getManager().getCurrentView(name)) {
                plugin.getEndTutorial().endTutorial(player);
            } else {
                plugin.incrementCurrentView(name);
                TutorialUtils.getTutorialUtils().messageUtils(player);
                Caching.getCaching().setTeleport(player, true);
                player.teleport(TutorialManager.getManager().getTutorialView(name).getLocation());
            }
        }
    }
    if ((event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK) &&
            !TutorialManager.getManager().isInTutorial(name)) {
        Block block = event.getClickedBlock();
        if (block.getType() == Material.SIGN || block.getType() == Material.WALL_SIGN) {
            Sign sign = (Sign) block.getState();
            String match = ChatColor.stripColor(TutorialUtils.color(TutorialManager.getManager().getConfigs()
                    .signSetting()));
            if (sign.getLine(0).equalsIgnoreCase(match) && sign.getLine(1) != null) {
                plugin.startTutorial(sign.getLine(1), player);
            }
        }
    }
}
 
Example #27
Source File: Main.java    From ArmorStandTools with MIT License 5 votes vote down vote up
void setPlayerSkull(Player p, ArmorStand as) {
    Block b = Utils.findAnAirBlock(p.getLocation());
    if(b == null) {
        p.sendMessage(ChatColor.RED + Config.noAirError);
        return;
    }
    b.setType(Material.SIGN);
    nms.openSign(p, b);
    b.setMetadata("armorStand", new FixedMetadataValue(this, as.getUniqueId()));
    b.setMetadata("setSkull", new FixedMetadataValue(this, true));
}
 
Example #28
Source File: SilentNightListener.java    From UhcCore with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onEnable() {
    // Disable Anonymous when enabled.
    if (isActivated(Scenario.ANONYMOUS)){
        getScenarioManager().removeScenario(Scenario.ANONYMOUS);
    }

    // Check for ProtocolLib
    if (!getGameManager().getConfiguration().getProtocolLibLoaded()){
        Bukkit.broadcastMessage(ChatColor.RED + "[UhcCore] For Anonymous ProtocolLib needs to be installed!");
        getScenarioManager().removeScenario(Scenario.SILENTNIGHT);
    }
}
 
Example #29
Source File: MobSelector.java    From CloudNet with Apache License 2.0 5 votes vote down vote up
private ItemStack transform(MobItemLayout mobItemLayout, ServerInfo serverInfo) {
    Material material = ItemStackBuilder.getMaterialIgnoreVersion(mobItemLayout.getItemName(), mobItemLayout.getItemId());
    return material == null ? null : ItemStackBuilder.builder(material, 1, mobItemLayout.getSubId()).lore(new ArrayList<>(
        CollectionWrapper.transform(mobItemLayout.getLore(), new Catcher<String, String>() {
            @Override
            public String doCatch(String key) {
                return initPatterns(ChatColor.translateAlternateColorCodes('&', key), serverInfo);
            }
        }))).displayName(initPatterns(ChatColor.translateAlternateColorCodes('&', mobItemLayout.getDisplay()), serverInfo)).build();
}
 
Example #30
Source File: CustomScoreBoard.java    From CombatLogX with GNU General Public License v3.0 5 votes vote down vote up
private void initializeScoreboard() {
    ChatColor[] colorArray = ChatColor.values();
    for(int i = 0; i < colorArray.length; i++) {
        ChatColor color = colorArray[i];
        Team team = this.scoreboard.registerNewTeam("line" + i);
        team.addEntry(color.toString());

        CustomLine line = new CustomLine(color, i, team);
        this.lineList.add(line);
    }
}