当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils类代码示例

本文整理汇总了Java中net.minecraft.util.StringUtils的典型用法代码示例。如果您正苦于以下问题:Java StringUtils类的具体用法?Java StringUtils怎么用?Java StringUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StringUtils类属于net.minecraft.util包,在下文中一共展示了StringUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addBrewTooltip

import net.minecraft.util.StringUtils; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
public static void addBrewTooltip(ItemStack stack, List<String> tooltip) {
	List<BrewEffect> brewsFromStack = BrewUtils.getBrewsFromStack(stack);
	for (BrewEffect effect : brewsFromStack) {
		IBrew brew = effect.getBrew();

		String name = " - " + I18n.format("brew." + brew.getName() + ".tooltip") + " ";
		String amplifier = (effect.getAmplifier() <= 0) ? "" : (RomanNumber.getRoman(effect.getAmplifier())) + " ";
		String duration = effect.isInstant() ? I18n.format("brew.instant") : StringUtils.ticksToElapsedTime(effect.getDuration());

		tooltip.add(TextFormatting.DARK_AQUA + "" + TextFormatting.ITALIC + name + amplifier + "(" + duration + ")");
	}
	if (brewsFromStack.isEmpty()) {
		tooltip.add(TextFormatting.DARK_GRAY + "" + TextFormatting.ITALIC + "---");
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:17,代码来源:BrewUtils.java

示例2: lookupNames

import net.minecraft.util.StringUtils; //导入依赖的package包/类
private static void lookupNames(MinecraftServer server, Collection<String> names, ProfileLookupCallback callback)
{
    String[] astring = (String[])Iterators.toArray(Iterators.filter(names.iterator(), new Predicate<String>()
    {
        public boolean apply(String p_apply_1_)
        {
            return !StringUtils.isNullOrEmpty(p_apply_1_);
        }
    }), String.class);

    if (server.isServerInOnlineMode())
    {
        server.getGameProfileRepository().findProfilesByNames(astring, Agent.MINECRAFT, callback);
    }
    else
    {
        for (String s : astring)
        {
            UUID uuid = EntityPlayer.getUUID(new GameProfile((UUID)null, s));
            GameProfile gameprofile = new GameProfile(uuid, s);
            callback.onProfileLookupSucceeded(gameprofile);
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:25,代码来源:PreYggdrasilConverter.java

示例3: readFromNBT

import net.minecraft.util.StringUtils; //导入依赖的package包/类
public void readFromNBT(NBTTagCompound compound)
{
    super.readFromNBT(compound);
    this.skullType = compound.getByte("SkullType");
    this.skullRotation = compound.getByte("Rot");

    if (this.skullType == 3)
    {
        if (compound.hasKey("Owner", 10))
        {
            this.playerProfile = NBTUtil.readGameProfileFromNBT(compound.getCompoundTag("Owner"));
        }
        else if (compound.hasKey("ExtraType", 8))
        {
            String s = compound.getString("ExtraType");

            if (!StringUtils.isNullOrEmpty(s))
            {
                this.playerProfile = new GameProfile((UUID)null, s);
                this.updatePlayerProfile();
            }
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:25,代码来源:TileEntitySkull.java

示例4: addInformation

import net.minecraft.util.StringUtils; //导入依赖的package包/类
/**
 * allows items to add custom lines of information to the mouseover description
 */
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
{
    if (stack.hasTagCompound())
    {
        NBTTagCompound nbttagcompound = stack.getTagCompound();
        String s = nbttagcompound.getString("author");

        if (!StringUtils.isNullOrEmpty(s))
        {
            tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocalFormatted("book.byAuthor", new Object[] {s}));
        }

        tooltip.add(EnumChatFormatting.GRAY + StatCollector.translateToLocal("book.generation." + nbttagcompound.getInteger("generation")));
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:19,代码来源:ItemEditableBook.java

示例5: renderDemo

import net.minecraft.util.StringUtils; //导入依赖的package包/类
public void renderDemo(ScaledResolution p_175185_1_)
{
    this.mc.mcProfiler.startSection("demo");
    String s = "";

    if (this.mc.theWorld.getTotalWorldTime() >= 120500L)
    {
        s = I18n.format("demo.demoExpired", new Object[0]);
    }
    else
    {
        s = I18n.format("demo.remainingTime", new Object[] {StringUtils.ticksToElapsedTime((int)(120500L - this.mc.theWorld.getTotalWorldTime()))});
    }

    int i = this.getFontRenderer().getStringWidth(s);
    this.getFontRenderer().drawStringWithShadow(s, (float)(p_175185_1_.getScaledWidth() - i - 10), 5.0F, 16777215);
    this.mc.mcProfiler.endSection();
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:19,代码来源:GuiIngame.java

示例6: renderDemo

import net.minecraft.util.StringUtils; //导入依赖的package包/类
public void renderDemo(ScaledResolution scaledRes)
{
    this.mc.mcProfiler.startSection("demo");
    String s;

    if (this.mc.theWorld.getTotalWorldTime() >= 120500L)
    {
        s = I18n.format("demo.demoExpired", new Object[0]);
    }
    else
    {
        s = I18n.format("demo.remainingTime", new Object[] {StringUtils.ticksToElapsedTime((int)(120500L - this.mc.theWorld.getTotalWorldTime()))});
    }

    int i = this.getFontRenderer().getStringWidth(s);
    this.getFontRenderer().drawStringWithShadow(s, (float)(scaledRes.getScaledWidth() - i - 10), 5.0F, 16777215);
    this.mc.mcProfiler.endSection();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:19,代码来源:GuiIngame.java

示例7: updateGameprofile

import net.minecraft.util.StringUtils; //导入依赖的package包/类
public GameProfile updateGameprofile(GameProfile input) {
    if (input != null && !StringUtils.isNullOrEmpty(input.getName())) {
        if (input.isComplete() && input.getProperties().containsKey("textures")) {
            return input;
        } else if (profileCache != null && sessionService != null) {
            GameProfile gameprofile = profileCache.getGameProfileForUsername(input.getName());

            if (gameprofile == null) {
                return input;
            } else {
                Property property = (Property) Iterables.getFirst(gameprofile.getProperties().get("textures"), (Object) null);

                if (property == null) {
                    gameprofile = sessionService.fillProfileProperties(gameprofile, true);
                }

                return gameprofile;
            }
        } else {
            return input;
        }
    } else {
        return input;
    }
}
 
开发者ID:CreeperShift,项目名称:WirelessCharger,代码行数:26,代码来源:TilePersonalCharger.java

示例8: resolve

import net.minecraft.util.StringUtils; //导入依赖的package包/类
public void resolve(ICommandSender sender)
{
    MinecraftServer minecraftserver = sender.getServer();

    if (minecraftserver != null && minecraftserver.isAnvilFileSet() && StringUtils.isNullOrEmpty(this.value))
    {
        Scoreboard scoreboard = minecraftserver.worldServerForDimension(0).getScoreboard();
        ScoreObjective scoreobjective = scoreboard.getObjective(this.objective);

        if (scoreboard.entityHasObjective(this.name, scoreobjective))
        {
            Score score = scoreboard.getOrCreateScore(this.name, scoreobjective);
            this.setValue(String.format("%d", new Object[] {Integer.valueOf(score.getScorePoints())}));
            return;
        }
    }

    this.value = "";
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:20,代码来源:TextComponentScore.java

示例9: handleUpdateScore

import net.minecraft.util.StringUtils; //导入依赖的package包/类
/**
 * Either updates the score with a specified value or removes the score for an objective
 */
public void handleUpdateScore(S3CPacketUpdateScore packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Scoreboard scoreboard = this.clientWorldController.getScoreboard();
    ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.getObjectiveName());

    if (packetIn.getScoreAction() == S3CPacketUpdateScore.Action.CHANGE)
    {
        Score score = scoreboard.getValueFromObjective(packetIn.getPlayerName(), scoreobjective);
        score.setScorePoints(packetIn.getScoreValue());
    }
    else if (packetIn.getScoreAction() == S3CPacketUpdateScore.Action.REMOVE)
    {
        if (StringUtils.isNullOrEmpty(packetIn.getObjectiveName()))
        {
            scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), (ScoreObjective)null);
        }
        else if (scoreobjective != null)
        {
            scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), scoreobjective);
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:27,代码来源:NetHandlerPlayClient.java

示例10: handleUpdateScore

import net.minecraft.util.StringUtils; //导入依赖的package包/类
/**
 * Either updates the score with a specified value or removes the score for an
 * objective
 */
public void handleUpdateScore(S3CPacketUpdateScore packetIn) {
	PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
	Scoreboard scoreboard = this.clientWorldController.getScoreboard();
	ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.getObjectiveName());

	if (packetIn.getScoreAction() == S3CPacketUpdateScore.Action.CHANGE) {
		Score score = scoreboard.getValueFromObjective(packetIn.getPlayerName(), scoreobjective);
		score.setScorePoints(packetIn.getScoreValue());
	} else if (packetIn.getScoreAction() == S3CPacketUpdateScore.Action.REMOVE) {
		if (StringUtils.isNullOrEmpty(packetIn.getObjectiveName())) {
			scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), (ScoreObjective) null);
		} else if (scoreobjective != null) {
			scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), scoreobjective);
		}
	}
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:21,代码来源:NetHandlerPlayClient.java

示例11: handleUpdateScore

import net.minecraft.util.StringUtils; //导入依赖的package包/类
/**
 * Either updates the score with a specified value or removes the score for an objective
 */
public void handleUpdateScore(SPacketUpdateScore packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Scoreboard scoreboard = this.clientWorldController.getScoreboard();
    ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.getObjectiveName());

    if (packetIn.getScoreAction() == SPacketUpdateScore.Action.CHANGE)
    {
        Score score = scoreboard.getOrCreateScore(packetIn.getPlayerName(), scoreobjective);
        score.setScorePoints(packetIn.getScoreValue());
    }
    else if (packetIn.getScoreAction() == SPacketUpdateScore.Action.REMOVE)
    {
        if (StringUtils.isNullOrEmpty(packetIn.getObjectiveName()))
        {
            scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), (ScoreObjective)null);
        }
        else if (scoreobjective != null)
        {
            scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), scoreobjective);
        }
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:27,代码来源:NetHandlerPlayClient.java

示例12: addInformation

import net.minecraft.util.StringUtils; //导入依赖的package包/类
/**
 * allows items to add custom lines of information to the mouseover description
 */
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
{
    if (stack.hasTagCompound())
    {
        NBTTagCompound nbttagcompound = stack.getTagCompound();
        String s = nbttagcompound.getString("author");

        if (!StringUtils.isNullOrEmpty(s))
        {
            tooltip.add(TextFormatting.GRAY + I18n.translateToLocalFormatted("book.byAuthor", new Object[] {s}));
        }

        tooltip.add(TextFormatting.GRAY + I18n.translateToLocal("book.generation." + nbttagcompound.getInteger("generation")));
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:19,代码来源:ItemWrittenBook.java

示例13: renderDemo

import net.minecraft.util.StringUtils; //导入依赖的package包/类
public void renderDemo(ScaledResolution scaledRes)
{
    this.mc.mcProfiler.startSection("demo");
    String s;

    if (this.mc.world.getTotalWorldTime() >= 120500L)
    {
        s = I18n.format("demo.demoExpired", new Object[0]);
    }
    else
    {
        s = I18n.format("demo.remainingTime", new Object[] {StringUtils.ticksToElapsedTime((int)(120500L - this.mc.world.getTotalWorldTime()))});
    }

    int i = this.getFontRenderer().getStringWidth(s);
    this.getFontRenderer().drawStringWithShadow(s, (float)(scaledRes.getScaledWidth() - i - 10), 5.0F, 16777215);
    this.mc.mcProfiler.endSection();
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:19,代码来源:GuiIngame.java

示例14: save

import net.minecraft.util.StringUtils; //导入依赖的package包/类
public boolean save(boolean p_189712_1_)
{
    if (this.mode == TileEntityStructure.Mode.SAVE && !this.worldObj.isRemote && !StringUtils.isNullOrEmpty(this.name))
    {
        BlockPos blockpos = this.getPos().add(this.position);
        WorldServer worldserver = (WorldServer)this.worldObj;
        MinecraftServer minecraftserver = this.worldObj.getMinecraftServer();
        TemplateManager templatemanager = worldserver.getStructureTemplateManager();
        Template template = templatemanager.getTemplate(minecraftserver, new ResourceLocation(this.name));
        template.takeBlocksFromWorld(this.worldObj, blockpos, this.size, !this.ignoreEntities, Blocks.STRUCTURE_VOID);
        template.setAuthor(this.author);
        return !p_189712_1_ || templatemanager.writeTemplate(minecraftserver, new ResourceLocation(this.name));
    }
    else
    {
        return false;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:19,代码来源:TileEntityStructure.java

示例15: mouseClicked

import net.minecraft.util.StringUtils; //导入依赖的package包/类
/**
 * Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
 */
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
	super.mouseClicked(mouseX, mouseY, mouseButton);

	synchronized (this.threadLock) {
		if (!this.openGLWarning1.isEmpty() && !StringUtils.isNullOrEmpty(this.openGLWarningLink)
				&& mouseX >= this.openGLWarningX1 && mouseX <= this.openGLWarningX2
				&& mouseY >= this.openGLWarningY1 && mouseY <= this.openGLWarningY2) {
			GuiConfirmOpenLink guiconfirmopenlink = new GuiConfirmOpenLink(this, this.openGLWarningLink, 13, true);
			guiconfirmopenlink.disableSecurityWarning();
			this.mc.displayGuiScreen(guiconfirmopenlink);
		}
	}

	if (this.areRealmsNotificationsEnabled()) {
		this.realmsNotification.mouseClicked(mouseX, mouseY, mouseButton);
	}

	if (Reflector.ForgeHooksClient_mainMenuMouseClick.exists()) {
		Reflector.call(Reflector.ForgeHooksClient_mainMenuMouseClick,
				new Object[] { Integer.valueOf(mouseX), Integer.valueOf(mouseY), Integer.valueOf(mouseButton),
						this.fontRendererObj, Integer.valueOf(this.width) });
	}
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:27,代码来源:GuiMainMenu.java


注:本文中的net.minecraft.util.StringUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。