本文整理汇总了Java中info.servertools.core.util.ServerUtils类的典型用法代码示例。如果您正苦于以下问题:Java ServerUtils类的具体用法?Java ServerUtils怎么用?Java ServerUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ServerUtils类属于info.servertools.core.util包,在下文中一共展示了ServerUtils类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processCommand
import info.servertools.core.util.ServerUtils; //导入依赖的package包/类
@Override
public void processCommand(final ICommandSender sender, final String[] args) throws CommandException {
if (args.length != 2) throw new WrongUsageException(getCommandUsage(sender));
GameProfile gameProfile = ServerUtils.getGameProfile(args[1]).orElseThrow(PlayerNotFoundException::new);
final UUID uuid = gameProfile.getId();
if ("add".equals(args[0])) {
if (silenceHandler.addSilence(uuid)) {
notifyOperators(sender, this, "Silenced %s", args[1]);
} else {
throw new CommandException("That player is already silenced");
}
} else if ("remove".equals(args[0])) {
if (silenceHandler.removeSilence(uuid)) {
notifyOperators(sender, this, "Removed silence on %s", args[1]);
} else {
throw new CommandException("That player was not silenced");
}
} else {
throw new WrongUsageException(getCommandUsage(sender));
}
}
示例2: processCommand
import info.servertools.core.util.ServerUtils; //导入依赖的package包/类
@Override
public void processCommand(final ICommandSender sender, final String[] args) throws CommandException {
GameProfile gameProfile;
if (args.length == 1) {
gameProfile = ServerUtils.getGameProfile(args[0]).orElseThrow(PlayerNotFoundException::new);
} else if (args.length == 0) {
gameProfile = getCommandSenderAsPlayer(sender).getGameProfile();
} else {
throw new WrongUsageException(getCommandUsage(sender));
}
ChatComponentText text = new ChatComponentText(gameProfile.getName() + "'s UUID is: ");
ChatComponentText uuidText = new ChatComponentText(gameProfile.getId().toString());
uuidText.getChatStyle().setColor(EnumChatFormatting.AQUA);
text.appendSibling(uuidText);
sender.addChatMessage(text);
}
示例3: refreshPlayerDisplayName
import info.servertools.core.util.ServerUtils; //导入依赖的package包/类
/**
* Refresh a player's display name
*
* @param uuid
* the player's {@link java.util.UUID UUID}
*/
public static void refreshPlayerDisplayName(UUID uuid) {
for (EntityPlayerMP player : ServerUtils.getAllPlayers()) {
if (uuid.equals(player.getPersistentID())) {
player.refreshDisplayName();
}
}
}
示例4: sendMessage
import info.servertools.core.util.ServerUtils; //导入依赖的package包/类
/**
* Send a messsage to users who are configured to receive backup related messages
*
* @param message the message
*/
public void sendMessage(@Nullable Object message) {
ChatComponentText text = new ChatComponentText(String.valueOf(message));
for (EntityPlayerMP player : ServerUtils.getAllPlayers()) {
if (BackupConfig.sendBackupMessageToOps && ServerUtils.isOP(player.getGameProfile())) {
player.addChatComponentMessage(text);
} else if (BackupConfig.sendBackupMessageToUsers) {
player.addChatComponentMessage(text);
} else if (BackupConfig.backupMessageWhitelist.contains(player.getGameProfile().getName())) {
player.addChatComponentMessage(text);
}
}
}
示例5: addTabCompletionOptions
import info.servertools.core.util.ServerUtils; //导入依赖的package包/类
@Nullable
@Override
public List<String> addTabCompletionOptions(final ICommandSender sender, final String[] args, final BlockPos pos) {
if (args.length <= 1) {
return getListOfStringsMatchingLastWord(args, ServerUtils.getAllUsernames());
} else {
return null;
}
}
示例6: addTabCompletionOptions
import info.servertools.core.util.ServerUtils; //导入依赖的package包/类
@Nullable
@Override
public List<String> addTabCompletionOptions(final ICommandSender sender, final String[] args, final BlockPos pos) {
if (args.length <= 1) {
return getListOfStringsMatchingLastWord(args, "add", "remove");
} else if (args.length == 2) {
return getListOfStringsMatchingLastWord(args, ServerUtils.getAllUsernames());
} else {
return null;
}
}
示例7: canCommandSenderUseCommand
import info.servertools.core.util.ServerUtils; //导入依赖的package包/类
@Override
public boolean canCommandSenderUseCommand(final ICommandSender sender) {
if (!opRequired || !(sender instanceof EntityPlayerMP)) {
return true;
} else {
final EntityPlayerMP player = ((EntityPlayerMP) sender);
return ServerUtils.isEffectiveOp(player.getGameProfile());
}
}
示例8: processCommand
import info.servertools.core.util.ServerUtils; //导入依赖的package包/类
@Override
public void processCommand(final ICommandSender sender, final String[] args) throws CommandException {
sender.addChatMessage(new ChatComponentText(AQUA + "-- TPS Sumary --"));
for (int dimId : DimensionManager.getIDs()) {
final String tickTime = format.format(ServerUtils.getWorldTickTime(dimId));
final String tps = format.format(ServerUtils.getWorldTickTime(dimId));
sender.addChatMessage(new ChatComponentText(" Dim: " + dimId + " Tick Time: " + tickTime + " TPS: " + tps));
}
final String avgTickTime = format.format(ServerUtils.getMeanTickTime());
final String avgTps = format.format(ServerUtils.getMeanTPS());
sender.addChatMessage(new ChatComponentText(" Mean Tick Time: " + avgTickTime + " Mean TPS: " + avgTps));
}
示例9: refreshAllPlayerDisplayNames
import info.servertools.core.util.ServerUtils; //导入依赖的package包/类
/**
* Refresh all players' display names
*/
public static void refreshAllPlayerDisplayNames() {
for (EntityPlayerMP player : ServerUtils.getAllPlayers()) {
player.refreshDisplayName();
}
}
示例10: addTabCompletionOptions
import info.servertools.core.util.ServerUtils; //导入依赖的package包/类
@Override
@Nullable
public List<String> addTabCompletionOptions(final ICommandSender sender, final String[] args, final BlockPos pos) {
return args.length <= 1 ? getListOfStringsMatchingLastWord(args, ServerUtils.getAllUsernames()) : null;
}
示例11: addTabCompletionOptions
import info.servertools.core.util.ServerUtils; //导入依赖的package包/类
@Nullable
@Override
public List<String> addTabCompletionOptions(final ICommandSender sender, final String[] args, final BlockPos pos) {
return args.length <= 1 ? getListOfStringsMatchingLastWord(args, ServerUtils.getAllUsernames()) : null;
}