use of net.md_5.bungee.api.chat.TextComponent in project LandLord by SpatiumPrinceps.
the class Claims method onClaims.
public void onClaims(Player player) {
if (plugin.getConfig().getBoolean("Shop.enable")) {
int claimcount = plugin.getPlayerManager().get(player.getUniqueId()).getClaims();
int regionCount = plugin.getWgHandler().getWG().getRegionManager(player.getWorld()).getRegionCountOfPlayer(plugin.getWgHandler().getWG().wrapPlayer(player));
String message = lm.getString("Commands.Claims.message");
String noClaims = lm.getString("Commands.Claims.noClaims");
if (claimcount > 0) {
player.sendMessage(message.replace("%regions%", regionCount + "").replace("%claims%", claimcount + ""));
} else {
BaseComponent text = new TextComponent(noClaims);
text.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ll shop"));
player.spigot().sendMessage(text);
}
} else {
player.sendMessage(lm.getString("Commands.Claims.disabled"));
}
}
use of net.md_5.bungee.api.chat.TextComponent in project Minigames by AddstarMC.
the class MessageManager method sendClickedCommandMessage.
public static void sendClickedCommandMessage(CommandSender target, String command, String identifier, String key, Object... args) {
BaseComponent init = getMessageStart(MinigameMessageType.INFO);
TextComponent message = new TextComponent(getMessage(identifier, key, args));
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command));
sendMessage(target, init, message);
}
use of net.md_5.bungee.api.chat.TextComponent in project Minigames by AddstarMC.
the class MessageManager method sendMessage.
public static void sendMessage(CommandSender target, MinigameMessageType type, String identifier, String key, Object... args) {
BaseComponent init = getMessageStart(type);
TextComponent message = new TextComponent(getMessage(identifier, key, args));
sendMessage(target, init, message);
}
use of net.md_5.bungee.api.chat.TextComponent in project Minigames by AddstarMC.
the class MessageManager method broadcast.
/**
* Broadcasts a server message without a permission.
*
* @param message - The message to be broadcasted (Can be manipulated with MinigamesBroadcastEvent)
* @param minigame - The Minigame this broadcast is related to.
* @param prefixColor - The color to be used in the prefix.
*/
public static void broadcast(String message, Minigame minigame, org.bukkit.ChatColor prefixColor) {
BaseComponent init = new TextComponent("[Minigames]");
init.setColor(prefixColor.asBungee());
TextComponent m = new TextComponent(" " + message);
MinigamesBroadcastEvent ev = new MinigamesBroadcastEvent(prefixColor + "[Minigames]" + org.bukkit.ChatColor.WHITE, message, minigame);
Bukkit.getPluginManager().callEvent(ev);
// Only send broadcast if event was not cancelled and is not empty
if (!ev.isCancelled() && !ev.getMessage().isEmpty()) {
if (PaperLib.isPaper()) {
Bukkit.getServer().broadcast(init, m);
} else {
Bukkit.getServer().spigot().broadcast(init, m);
}
}
}
use of net.md_5.bungee.api.chat.TextComponent in project Denizen-For-Bukkit by DenizenScript.
the class FormattedTextHelper method stringify.
public static String stringify(BaseComponent component) {
if (component == null) {
return null;
}
StringBuilder builder = new StringBuilder(128);
ChatColor color = component.getColorRaw();
if (color != null) {
builder.append(color);
}
if (boolNotNull(component.isBoldRaw())) {
builder.append(ChatColor.BOLD);
}
if (boolNotNull(component.isItalicRaw())) {
builder.append(ChatColor.ITALIC);
}
if (boolNotNull(component.isStrikethroughRaw())) {
builder.append(ChatColor.STRIKETHROUGH);
}
if (boolNotNull(component.isUnderlinedRaw())) {
builder.append(ChatColor.UNDERLINE);
}
if (boolNotNull(component.isObfuscatedRaw())) {
builder.append(ChatColor.MAGIC);
}
if (component.getFontRaw() != null) {
builder.append(ChatColor.COLOR_CHAR).append("[font=").append(component.getFontRaw()).append("]");
}
boolean hasInsertion = component.getInsertion() != null;
if (hasInsertion) {
builder.append(ChatColor.COLOR_CHAR).append("[insertion=").append(escape(component.getInsertion())).append("]");
}
boolean hasHover = component.getHoverEvent() != null;
if (hasHover) {
HoverEvent hover = component.getHoverEvent();
builder.append(ChatColor.COLOR_CHAR).append("[hover=").append(hover.getAction().name()).append(";").append(escape(NMSHandler.getInstance().stringForHover(hover))).append("]");
}
boolean hasClick = component.getClickEvent() != null;
if (hasClick) {
ClickEvent click = component.getClickEvent();
builder.append(ChatColor.COLOR_CHAR).append("[click=").append(click.getAction().name()).append(";").append(escape(click.getValue())).append("]");
}
if (component instanceof TextComponent) {
builder.append(((TextComponent) component).getText());
} else if (component instanceof TranslatableComponent) {
builder.append(ChatColor.COLOR_CHAR).append("[translate=").append(escape(((TranslatableComponent) component).getTranslate()));
List<BaseComponent> with = ((TranslatableComponent) component).getWith();
if (with != null) {
for (BaseComponent withComponent : with) {
builder.append(";").append(escape(stringify(withComponent)));
}
}
builder.append("]");
} else if (component instanceof SelectorComponent) {
builder.append(ChatColor.COLOR_CHAR).append("[selector=").append(escape(((SelectorComponent) component).getSelector())).append("]");
} else if (component instanceof KeybindComponent) {
builder.append(ChatColor.COLOR_CHAR).append("[keybind=").append(escape(((KeybindComponent) component).getKeybind())).append("]");
} else if (component instanceof ScoreComponent) {
builder.append(ChatColor.COLOR_CHAR).append("[score=").append(escape(((ScoreComponent) component).getName())).append(";").append(escape(((ScoreComponent) component).getObjective())).append(";").append(escape(((ScoreComponent) component).getValue())).append("]");
}
List<BaseComponent> after = component.getExtra();
if (after != null) {
for (BaseComponent afterComponent : after) {
builder.append(stringify(afterComponent));
}
}
if (hasClick) {
builder.append(ChatColor.COLOR_CHAR + "[/click]");
}
if (hasHover) {
builder.append(ChatColor.COLOR_CHAR + "[/hover]");
}
if (hasInsertion) {
builder.append(ChatColor.COLOR_CHAR + "[/insertion]");
}
builder.append(RESET);
String output = builder.toString();
return cleanRedundantCodes(output);
}
Aggregations