本文整理汇总了Java中net.dmulloy2.util.FormatUtil类的典型用法代码示例。如果您正苦于以下问题:Java FormatUtil类的具体用法?Java FormatUtil怎么用?Java FormatUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FormatUtil类属于net.dmulloy2.util包,在下文中一共展示了FormatUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getLegacyHeader
import net.dmulloy2.util.FormatUtil; //导入依赖的package包/类
public List<String> getLegacyHeader(int index)
{
List<String> ret = new ArrayList<>();
ret.add(format(getHeader(), plugin.getName(), index, getPageCount()));
List<String> extraHelp = plugin.getExtraHelp();
if (extraHelp != null)
{
for (String extra : extraHelp)
ret.add(FormatUtil.format(extra));
}
ret.add(format("{b}Key: {h}<required> [optional]"));
return ret;
}
开发者ID:dmulloy2,项目名称:SwornAPI,代码行数:17,代码来源:CmdHelp.java
示例2: hasPermission
import net.dmulloy2.util.FormatUtil; //导入依赖的package包/类
/**
* Whether or not a given command sender has a given permission.
*
* @param sender Sender to check
* @param permission Permission to check for
* @param message Whether or not to send an error
* @return True if they have it, false if not
*/
protected final boolean hasPermission(CommandSender sender, IPermission permission, boolean message)
{
Validate.notNull(sender, "sender cannot be null!");
if (! plugin.getPermissionHandler().hasPermission(sender, permission))
{
if (message)
{
StringJoiner hoverText = new StringJoiner("\n");
hoverText.append(FormatUtil.format("&4Permission:"));
hoverText.append(FormatUtil.format("&r{0}", getPermissionString(permission)));
ComponentBuilder builder = new ComponentBuilder(FormatUtil.format("&cError: &4You do not have "));
builder.append(FormatUtil.format("&cpermission")).event(new HoverEvent(Action.SHOW_TEXT, hoverText.toString()));
builder.append(FormatUtil.format(" &4to perform this command!"));
sendMessage(sender, builder.create());
}
return false;
}
return true;
}
开发者ID:dmulloy2,项目名称:SwornAPI,代码行数:32,代码来源:Command.java
示例3: perform
import net.dmulloy2.util.FormatUtil; //导入依赖的package包/类
@Override
public void perform()
{
String key = args[0];
Object val = null;
String valStr = FormatUtil.join(" ", Arrays.copyOfRange(args, 1, args.length));
valStr = valStr.replaceAll("\"", "");
valStr = valStr.trim();
if (valStr.contains("b:"))
val = Util.toBoolean(valStr);
else if (valStr.contains("i:"))
val = NumberUtil.toInt(valStr);
else if (valStr.contains("d:"))
val = NumberUtil.toDouble(valStr);
else if (! valStr.equalsIgnoreCase("null") && ! valStr.isEmpty())
val = valStr;
group.setOption(key, val);
if (val == null)
sendpMessage("Option ''&b{0}&e'' removed from group &b{1}&e.", key, group.getName());
else
sendpMessage("Option ''&b{0}&e'' set to ''&b{1}&e'' for group &b{2}&e.", key, val, group.getName());
}
开发者ID:dmulloy2,项目名称:SwornPermissions,代码行数:27,代码来源:CmdSetOption.java
示例4: perform
import net.dmulloy2.util.FormatUtil; //导入依赖的package包/类
@Override
public void perform()
{
String key = args[0];
Object val = null;
String valStr = FormatUtil.join(" ", Arrays.copyOfRange(args, 1, args.length));
valStr = valStr.replaceAll("\"", "");
valStr = valStr.trim();
if (valStr.contains("b:"))
val = Util.toBoolean(valStr);
else if (valStr.contains("i:"))
val = NumberUtil.toInt(valStr);
else if (valStr.contains("d:"))
val = NumberUtil.toDouble(valStr);
else if (! valStr.equalsIgnoreCase("null") && ! valStr.isEmpty())
val = valStr;
user.setOption(key, val);
if (val == null)
sendpMessage("Option ''&b{0}&e'' removed from user &b{1}&e.", key, user.getName());
else
sendpMessage("Option ''&b{0}&e'' set to ''&b{1}&e'' for user &b{2}&e.", key, val, user.getName());
}
开发者ID:dmulloy2,项目名称:SwornPermissions,代码行数:27,代码来源:CmdSetOption.java
示例5: perform
import net.dmulloy2.util.FormatUtil; //导入依赖的package包/类
@Override
public void perform()
{
String suffix = FormatUtil.join(" ", args);
suffix = suffix.replaceAll("\"", "");
if (suffix.equalsIgnoreCase("null") || suffix.equalsIgnoreCase("remove"))
{
user.resetPrefix();
sendpMessage("&b{0} &esuffix has been reset.", user.describeTo(sender, true));
return;
}
user.setSuffix(suffix);
sendpMessage("&b{0} &esuffix is now \"&r{1}&e\"", user.describeTo(sender, true), suffix);
}
开发者ID:dmulloy2,项目名称:SwornPermissions,代码行数:18,代码来源:CmdSetSuffix.java
示例6: perform
import net.dmulloy2.util.FormatUtil; //导入依赖的package包/类
@Override
public void perform()
{
String prefix = FormatUtil.join(" ", args);
prefix = prefix.replaceAll("\"", "");
if (prefix.equalsIgnoreCase("null") || prefix.equalsIgnoreCase("remove"))
{
user.resetPrefix();
sendpMessage("&b{0} &eprefix has been reset.", user.describeTo(sender, true));
return;
}
user.setPrefix(prefix);
sendpMessage("&b{0} &eprefix is now \"&r{1}&e\"", user.describeTo(sender, true), prefix);
}
开发者ID:dmulloy2,项目名称:SwornPermissions,代码行数:18,代码来源:CmdSetPrefix.java
示例7: getName
import net.dmulloy2.util.FormatUtil; //导入依赖的package包/类
protected final String getName(CommandSender sender)
{
if (sender instanceof BlockCommandSender)
{
BlockCommandSender commandBlock = (BlockCommandSender) sender;
Location location = commandBlock.getBlock().getLocation();
return FormatUtil.format("CommandBlock ({0}, {1}, {2})", location.getBlockX(), location.getBlockY(), location.getBlockZ());
}
else if (sender instanceof ConsoleCommandSender)
{
return "Console";
}
else
{
return sender.getName();
}
}
开发者ID:dmulloy2,项目名称:SwornPermissions,代码行数:18,代码来源:SwornPermissionsCommand.java
示例8: onPlayerChangedWorld
import net.dmulloy2.util.FormatUtil; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerChangedWorld(PlayerChangedWorldEvent event)
{
Player player = event.getPlayer();
User user = plugin.getPermissionHandler().getUser(player);
if (user == null)
{
player.sendMessage(plugin.getPrefix() + FormatUtil.format("Failed to get a user instance! Contact an administrator!"));
return;
}
user = plugin.getPermissionHandler().moveWorld(player, event.getFrom(), player.getWorld());
boolean force = plugin.getConfig().getBoolean("forceUpdate.worldChange", false);
user.updatePermissions(player, force);
}
开发者ID:dmulloy2,项目名称:SwornPermissions,代码行数:17,代码来源:PlayerListener.java
示例9: getPage
import net.dmulloy2.util.FormatUtil; //导入依赖的package包/类
public List<String> getPage(int index)
{
List<String> lines = new ArrayList<String>();
StringBuilder line = new StringBuilder();
line.append(getHeader(index));
lines.add(line.toString());
lines.addAll(getLines((index - 1) * linesPerPage, index * linesPerPage));
if (index != getPageCount())
{
line = new StringBuilder();
line.append(FormatUtil.format(getMessage("leaderboard_nextpage"), index + 1));
lines.add(line.toString());
}
return lines;
}
开发者ID:dmulloy2,项目名称:TeamSparkle,代码行数:20,代码来源:CmdLeaderboard.java
示例10: acceptInput
import net.dmulloy2.util.FormatUtil; //导入依赖的package包/类
@Override
public Prompt acceptInput(ConversationContext context, String input)
{
PlayerData data = plugin.getPlayerDataCache().getData(player);
if (data.getInvited().contains(input.toLowerCase()))
{
player.sendRawMessage(FormatUtil.format("&cError: &4" + plugin.getMessage("already_invited")));
return Prompt.END_OF_CONVERSATION;
}
OfflinePlayer invite = Util.matchOfflinePlayer(input);
if (invite == null || ! invite.hasPlayedBefore())
{
data.getInvited().add(input.toLowerCase());
player.sendRawMessage(FormatUtil.format(plugin.getPrefix() + plugin.getMessage("invite_confirmed"), input));
}
else
{
player.sendRawMessage(FormatUtil.format("&cError: &4" + plugin.getMessage("has_played_before")));
}
return Prompt.END_OF_CONVERSATION;
}
开发者ID:dmulloy2,项目名称:TeamSparkle,代码行数:24,代码来源:InvitePrompt.java
示例11: perform
import net.dmulloy2.util.FormatUtil; //导入依赖的package包/类
@Override
public void perform()
{
ItemStack inHand = CompatUtil.getItemInMainHand(player);
if (inHand == null || inHand.getType() == Material.AIR)
{
err("You must have an item in your hand to do this!");
return;
}
// Join and fix spacing
String str = FormatUtil.join(" ", args)
.replace("\"", "");
String[] split = str.split("\\|");
List<String> lore = new ArrayList<>();
for (String line : split)
lore.add(FormatUtil.format(line));
// Apply
ItemMeta meta = inHand.getItemMeta();
meta.setLore(lore);
inHand.setItemMeta(meta);
sendpMessage("&eYou have set your &b{0}&e''s lore to \"&r{1}&e\"", MaterialUtil.getName(inHand), lore);
}
开发者ID:dmulloy2,项目名称:SwornRPG,代码行数:27,代码来源:CmdLore.java
示例12: perform
import net.dmulloy2.util.FormatUtil; //导入依赖的package包/类
@Override
public void perform()
{
ItemStack inHand = CompatUtil.getItemInMainHand(player);
if (inHand == null || inHand.getType() == Material.AIR)
{
err("You must have an item in your hand to do this!");
return;
}
// Join and fix spacing
String name = FormatUtil.join(" ", args)
.replace("\"", "");
// Format
name = FormatUtil.format(name);
// Apply
ItemMeta meta = inHand.getItemMeta();
meta.setDisplayName(name);
inHand.setItemMeta(meta);
sendpMessage("&eYou have set your &b{0}&e''s name to \"&r{1}&e\"", MaterialUtil.getName(inHand), name);
}
开发者ID:dmulloy2,项目名称:SwornRPG,代码行数:25,代码来源:CmdName.java
示例13: onPlayerEnchant
import net.dmulloy2.util.FormatUtil; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerEnchant(EnchantItemEvent event)
{
int cost = event.getExpLevelCost();
if (cost < 15)
return;
Player player = event.getEnchanter();
if (player == null || plugin.isDisabledWorld(player))
return;
int xp = xpGain + (cost / 2);
String message = plugin.getPrefix() + FormatUtil.format(plugin.getMessage("enchant_gain"), xp);
plugin.getExperienceHandler().handleXpGain(player, xp, message);
}
开发者ID:dmulloy2,项目名称:SwornRPG,代码行数:17,代码来源:Enchanting.java
示例14: onPlayerLevelChange
import net.dmulloy2.util.FormatUtil; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerLevelChange(PlayerLevelChangeEvent event)
{
Player player = event.getPlayer();
if (player.getGameMode() != GameMode.SURVIVAL)
return;
if (isFactionsApplicable(player, true))
return;
if (plugin.isDisabledWorld(player) || plugin.isCamping(player))
return;
// Only give xp for single level changes
int oldLevel = event.getOldLevel();
int newLevel = event.getNewLevel();
if (newLevel - oldLevel != 1)
return;
String message = plugin.getPrefix() + FormatUtil.format(plugin.getMessage("mc_xp_gain"), xpGain);
plugin.getExperienceHandler().handleXpGain(player, xpGain, message);
}
开发者ID:dmulloy2,项目名称:SwornRPG,代码行数:23,代码来源:MinecraftXP.java
示例15: onEntityDamageLowest
import net.dmulloy2.util.FormatUtil; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamageLowest(EntityDamageEvent event)
{
if (event.isCancelled() || event.getDamage() <= 0 || ! gracefulRollEnabled)
return;
if (event.getCause() != DamageCause.FALL)
return;
Entity entity = event.getEntity();
if (plugin.isDisabledWorld(entity))
return;
if (entity instanceof Player)
{
if (Util.random(gracefulRollOdds) == 0)
{
event.setDamage(0);
Player player = (Player) entity;
player.sendMessage(plugin.getPrefix() + FormatUtil.format(plugin.getMessage("graceful_roll")));
}
}
}
开发者ID:dmulloy2,项目名称:SwornRPG,代码行数:24,代码来源:EntityListener.java
示例16: onEntityDeath
import net.dmulloy2.util.FormatUtil; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityDeath(EntityDeathEvent event)
{
Entity killer = event.getEntity().getKiller();
if (killer instanceof Player)
{
Player player = (Player) killer;
double health = player.getHealth();
double maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
if (health > 0.0D && health < maxHealth)
{
PlayerData data = plugin.getPlayerDataCache().getData(player);
int level = data.getLevel(25);
if (Util.random(75 / level) == 0)
{
player.setHealth(Math.min(health + 1.0D, maxHealth));
double heartsStolen = (player.getHealth() - health) / 2;
player.sendMessage(plugin.getPrefix() + FormatUtil.format(plugin.getMessage("life_steal"),
heartsStolen, getName(event.getEntity())));
}
}
}
}
开发者ID:dmulloy2,项目名称:SwornRPG,代码行数:27,代码来源:EntityListener.java
示例17: onPlayerToggleSprint
import net.dmulloy2.util.FormatUtil; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerToggleSprint(PlayerToggleSprintEvent event)
{
if (! speedBoostEnabled || event.isCancelled())
return;
Player player = event.getPlayer();
if (plugin.isDisabledWorld(player))
return;
if (! player.isSprinting() || player.getGameMode() != GameMode.SURVIVAL)
return;
if (plugin.isSwornNationsEnabled() && plugin.getSwornNationsHandler().isApplicable(player, false))
return;
if (Util.random(speedBoostOdds) == 0)
{
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, speedBoostDuration, speedBoostStrength));
player.sendMessage(plugin.getPrefix() + FormatUtil.format(plugin.getMessage("speed_boost")));
}
}
开发者ID:dmulloy2,项目名称:SwornRPG,代码行数:23,代码来源:PlayerListener.java
示例18: onBlockBreakHighest
import net.dmulloy2.util.FormatUtil; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockBreakHighest(BlockBreakEvent event)
{
if (! ironDoorProtection || event.isCancelled())
return;
Player player = event.getPlayer();
if (player.getGameMode() == GameMode.CREATIVE)
return;
Block block = event.getBlock();
if (plugin.isDisabledWorld(block))
return;
// Iron door protection
if (block.getType() == Material.IRON_DOOR_BLOCK)
{
event.setCancelled(true);
player.sendMessage(plugin.getPrefix() + FormatUtil.format(plugin.getMessage("iron_door_protect")));
plugin.debug(plugin.getMessage("log_irondoor_protect"), player.getName(), Util.locationToString(block.getLocation()));
}
}
开发者ID:dmulloy2,项目名称:SwornRPG,代码行数:24,代码来源:BlockListener.java
示例19: onPlayerMoveWaiting
import net.dmulloy2.util.FormatUtil; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerMoveWaiting(PlayerMoveEvent event)
{
if (! event.isCancelled())
{
// If they didnt move, don't do anything.
if (event.getFrom().getBlockX() == event.getTo().getBlockX() && event.getFrom().getBlockZ() == event.getTo().getBlockZ())
return;
Player player = event.getPlayer();
if (plugin.getWaiting().containsKey(player))
{
ParkourJoinTask task = plugin.getWaiting().get(player);
plugin.getWaiting().remove(player);
task.cancel();
player.sendMessage(FormatUtil.format("&cCancelled!"));
}
}
}
开发者ID:dmulloy2,项目名称:SwornParkour,代码行数:21,代码来源:PlayerListener.java
示例20: format
import net.dmulloy2.util.FormatUtil; //导入依赖的package包/类
public String format(String string, Object... args)
{
return FormatUtil.format(string
.replace("{b}", baseColor)
.replace("{a}", accentColor)
.replace("{h}", headerColor),
args);
}
开发者ID:dmulloy2,项目名称:SwornAPI,代码行数:9,代码来源:CommandProps.java
注:本文中的net.dmulloy2.util.FormatUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论