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


Java StringUtil类代码示例

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


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

示例1: getPromptText

import com.dsh105.commodus.StringUtil; //导入依赖的package包/类
@Override
public String getPromptText(ConversationContext context) {
    String name = (String) context.getSessionData("name");
    boolean success = this.pet.setPetName(name, false);
    if (success) {
        return this.admin ? Lang.ADMIN_NAME_PET.toString()
                .replace("%player%", this.pet.getNameOfOwner())
                .replace("%type%", StringUtil.capitalise(this.pet.getPetType().toString().replace("_", " ")))
                .replace("%name%", name)

                : Lang.NAME_PET.toString()
                .replace("%type%", StringUtil.capitalise(this.pet.getPetType().toString().replace("_", " ")))
                .replace("%name%", name);
    } else {
        return Lang.NAME_NOT_ALLOWED.toString().replace("%name%", name);
    }
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:18,代码来源:NameSuccessPrompt.java

示例2: setRider

import com.dsh105.commodus.StringUtil; //导入依赖的package包/类
public void setRider(IPet newRider){
	if(!isSpawned()) return;
	if(!EchoPet.getOptions().allowRidersFor(this.getPetType())){
		Lang.sendTo(this.getOwner(), Lang.RIDERS_DISABLED.toString().replace("%type%", StringUtil.capitalise(this.getPetType().toString())));
		return;
	}
	if(this.isOwnerRiding()){
		this.ownerRidePet(false);
	}
	if(this.rider != null){
		this.removeRider(true, true);
	}
	if(!newRider.isSpawned()) newRider.spawnPet(getOwner(), false);
	this.rider = (Pet) newRider;
	this.rider.setRider();
	EchoPet.getPlugin().getSpawnUtil().setPassenger(0, getCraftPet(), this.rider.getCraftPet());
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:18,代码来源:Pet.java

示例3: createPet

import com.dsh105.commodus.StringUtil; //导入依赖的package包/类
@Override
  public IPet createPet(Player owner, PetType petType, PetType riderType) {
      if (ReflectionUtil.BUKKIT_VERSION_NUMERIC == 178 && (petType == PetType.HUMAN) || riderType == PetType.HUMAN) {
          Lang.sendTo(owner, Lang.HUMAN_PET_DISABLED.toString());
          return null;
      }
      removePets(owner, true);
      if (!WorldUtil.allowPets(owner.getLocation())) {
          Lang.sendTo(owner, Lang.PETS_DISABLED_HERE.toString().replace("%world%", StringUtil.capitalise(owner.getWorld().getName())));
          return null;
      }
      if (!EchoPet.getOptions().allowPetType(petType)) {
          Lang.sendTo(owner, Lang.PET_TYPE_DISABLED.toString().replace("%type%", StringUtil.capitalise(petType.toString())));
          return null;
      }
      IPet pi = petType.getNewPetInstance(owner);
      if (pi == null) {
          Lang.sendTo(owner, Lang.PET_TYPE_NOT_COMPATIBLE.toString().replace("%type%", StringUtil.capitalise(petType.toString())));
          return null;
      }
pi.createRider(riderType, true);
      forceAllValidData(pi);
      pets.add(pi);
      return pi;
  }
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:26,代码来源:PetManager.java

示例4: generatePetInfo

import com.dsh105.commodus.StringUtil; //导入依赖的package包/类
public static ArrayList<String> generatePetInfo(IPet pt) {
    ArrayList<String> info = new ArrayList<String>();
    info.add(ChatColor.GOLD + " - Pet Type: " + ChatColor.YELLOW + StringUtil.capitalise(pt.getPetType().toString()));
    info.add(ChatColor.GOLD + " - Name: " + ChatColor.YELLOW + pt.getPetName());
    if (pt instanceof IAgeablePet) {
        info.add(ChatColor.GOLD + " - Baby: " + ChatColor.YELLOW + ((IAgeablePet) pt).isBaby());
    }
    if (pt.getPetType() == PetType.ZOMBIE) {
        info.add(ChatColor.GOLD + " - Baby: " + ChatColor.YELLOW + ((IZombiePet) pt).isBaby());
    }
    if (pt.getPetType() == PetType.PIGZOMBIE) {
        info.add(ChatColor.GOLD + " - Baby: " + ChatColor.YELLOW + ((IPigZombiePet) pt).isBaby());
    }
    info.addAll(generatePetDataInfo(pt));

    if (pt.getRider() != null) {
        info.add(ChatColor.RED + "Rider:");
        info.addAll(generatePetInfo(pt.getRider()));
    }

    return info;
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:23,代码来源:PetUtil.java

示例5: onTouch

import com.dsh105.commodus.StringUtil; //导入依赖的package包/类
@Override
public void onTouch(Player who, Action action) {
    String command = this.command.replace("%name%", who.getName());
    command = command.replace("%world%", who.getWorld().getName());

    if (command.startsWith("server ")) {
        String serverName = StringUtil.combineSplit(1, command.split(" "), " ");
        ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
        DataOutputStream out = new DataOutputStream(byteOutput);
        try {
            out.writeUTF("Connect");
            out.writeUTF(serverName);
            who.sendPluginMessage(HoloAPI.getCore(), "BungeeCord", byteOutput.toByteArray());
            return;
        } catch (IOException ignored) {
        }
    }

    if (this.shouldPerformAsConsole()) {
        HoloAPI.getCore().getServer().dispatchCommand(HoloAPI.getCore().getServer().getConsoleSender(), command);
    } else {
        who.performCommand(command);
    }
}
 
开发者ID:DSH105,项目名称:HoloAPI,代码行数:25,代码来源:CommandTouchAction.java

示例6: set

import com.dsh105.commodus.StringUtil; //导入依赖的package包/类
@Command(
        command = "visibility <id> <type>",
        description = "Set the visibility of a particular hologram",
        permission = "holoapi.holo.visibility.set",
        help = {"Valid types for HoloAPI are: all, permission.", "Visibility types dynamically registered using the API may be defined using this command.", "See the Wiki for more information"}
)
public boolean set(CommandEvent event) {
    Hologram hologram = HoloAPI.getManager().getHologram(event.variable("id"));
    if (hologram == null) {
        event.respond(Lang.HOLOGRAM_NOT_FOUND.getValue("id", event.variable("id")));
        return true;
    }

    Visibility visibility = HoloAPI.getVisibilityMatcher().get(event.variable("type"));
    if (visibility == null) {
        event.respond(Lang.INVALID_VISIBILITY.getValue("visibility", event.variable("type")));
        event.respond(Lang.VALID_VISIBILITIES.getValue("vis", StringUtil.combine(", ", HoloAPI.getVisibilityMatcher().getValidVisibilities().keySet())));
        return true;
    }

    hologram.setVisibility(visibility);
    event.respond(Lang.HOLOGRAM_VISIBILITY_SET.getValue("id", event.variable("id"), "visibility", event.variable("type")));
    return true;
}
 
开发者ID:DSH105,项目名称:HoloAPI,代码行数:25,代码来源:VisibilityCommand.java

示例7: clearType

import com.dsh105.commodus.StringUtil; //导入依赖的package包/类
@Command(
        command = "clear <type>",
        description = "Clear all holograms of a certain type",
        permission = "holoapi.holo.clear",
        help = "Valid types are: COMPLEX, SIMPLE, ALL"
)
public boolean clearType(CommandEvent event) {
    if (!VALID_TYPES.contains(event.variable("type").toLowerCase())) {
        event.respond(Lang.INVALID_CLEAR_TYPE.getValue("type", event.variable("type"), "valid", StringUtil.combine(", ", VALID_TYPES)));
        return true;
    }
    clear(event.variable("type"));
    if (event.variable("type").equalsIgnoreCase("COMPLEX")) {
        event.respond(Lang.COMPLEX_HOLOGRAMS_CLEARED.getValue());
    } else if (event.variable("type").equalsIgnoreCase("SIMPLE")) {
        event.respond(Lang.SIMPLE_HOLOGRAMS_CLEARED.getValue());
    } else {
        event.respond(Lang.ALL_HOLOGRAMS_CLEARED.getValue());
    }
    return true;
}
 
开发者ID:DSH105,项目名称:HoloAPI,代码行数:22,代码来源:ClearCommand.java

示例8: dispatch

import com.dsh105.commodus.StringUtil; //导入依赖的package包/类
public <T extends S> boolean dispatch(T sender, String... arguments) {
    String input = StringUtil.combineArray(" ", arguments).trim();

    Controller controller = match(input);

    if (controller != null) {
        return preDispatch(sender, controller, input);
    }

    // command not found - do something else with it
    manager.respond(sender, manager.getMessage(MessagePurpose.COMMAND_NOT_FOUND, "<command>", manager.getCommandPrefix() + input), ResponseLevel.SEVERE);

    Suggestion suggestion = new Suggestion(manager, input, 3);
    if (!suggestion.getSuggestions().isEmpty()) {
        String suggestions = StringUtil.combine("{c1}, {c2}", suggestion.getSuggestions());
        manager.respond(sender, manager.getMessage(MessagePurpose.SUGGESTIONS, "<suggestions>", suggestions), ResponseLevel.SEVERE);
    }
    return true;
}
 
开发者ID:DSH105,项目名称:Influx,代码行数:20,代码来源:Dispatcher.java

示例9: getSpawnEgg

import com.dsh105.commodus.StringUtil; //导入依赖的package包/类
@Override
// This is kind of a dumb way to do this.. But I'm too lazy to fix my reflection
public org.bukkit.inventory.ItemStack getSpawnEgg(org.bukkit.inventory.ItemStack i, String entityTag){
	ItemStack is = CraftItemStack.asNMSCopy(i);
	NBTTagCompound nbt = is.getTag();
	if(nbt == null) nbt = new NBTTagCompound();
	if(!nbt.hasKey("EntityTag")) nbt.set("EntityTag", new NBTTagCompound());
	entityTag = EntityUtil.newToOldEggEntityName(StringUtil.capitalise(entityTag.replace("_", " ")).replace(" ", ""));
	nbt.getCompound("EntityTag").setString("id", entityTag);
	return CraftItemStack.asCraftMirror(is);
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:12,代码来源:SpawnUtil.java

示例10: createRider

import com.dsh105.commodus.StringUtil; //导入依赖的package包/类
@Override
public Pet createRider(final PetType pt, boolean sendFailMessage){
	if(pt == PetType.HUMAN){
		if(sendFailMessage){
			Lang.sendTo(this.getOwner(), Lang.RIDERS_DISABLED.toString().replace("%type%", StringUtil.capitalise(this.getPetType().toString())));
		}
		return null;
	}
	if(!EchoPet.getOptions().allowRidersFor(this.getPetType())){
		if(sendFailMessage){
			Lang.sendTo(this.getOwner(), Lang.RIDERS_DISABLED.toString().replace("%type%", StringUtil.capitalise(this.getPetType().toString())));
		}
		return null;
	}
	if(this.isOwnerRiding()){
		this.ownerRidePet(false);
	}
	if(this.rider != null){
		this.removeRider(true, true);
	}
	IPet newRider = pt.getNewPetInstance(this.getOwner());
	if(newRider == null){
		if(sendFailMessage){
			Lang.sendTo(getOwner(), Lang.PET_TYPE_NOT_COMPATIBLE.toString().replace("%type%", StringUtil.capitalise(getPetType().toString())));
		}
		return null;
	}
	if(isSpawned()) newRider.spawnPet(getOwner(), false);
	this.rider = (Pet) newRider;
	this.rider.setRider();
	if(isSpawned()) EchoPet.getPlugin().getSpawnUtil().setPassenger(0, getCraftPet(), newRider.getCraftPet());
	EchoPet.getSqlManager().saveToDatabase(rider, true);

	return this.rider;
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:36,代码来源:Pet.java

示例11: givePet

import com.dsh105.commodus.StringUtil; //导入依赖的package包/类
/**
 * Gives a {@link com.dsh105.echopet.api.pet.Pet} to the specified {@link Player}
 * <p/>
 * Pets will be spawned immediately next to the target player, linked until it is removed.
 *
 * @param player      the {@link org.bukkit.entity.Player} that will be provided with a {@link
 *                    com.dsh105.echopet.api.pet.Pet}
 * @param petType     the {@link com.dsh105.echopet.compat.api.entity.PetType} (type of {@link
 *                    com.dsh105.echopet.api.pet.Pet}) that will be given to the player
 * @param sendMessage defines if the plugin sends a message to the target {@link Player}
 * @return the {@link com.dsh105.echopet.api.pet.Pet} created
 */
public IPet givePet(Player player, PetType petType, boolean sendMessage) {
    if (player != null && petType != null) {
        IPet pet = EchoPet.getManager().createPet(player, petType, sendMessage);
        if (pet == null) {
            EchoPet.LOG.severe("Failed to give " + petType.toString() + " to " + player.getName() + " through the EchoPetAPI. Maybe this PetType is disabled in the Config.yml?");
            return null;
        }
        if (sendMessage) {
            Lang.sendTo(player, Lang.CREATE_PET.toString().replace("%type%", StringUtil.capitalise(petType.toString())));
        }
        return pet;
    }
    return null;
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:27,代码来源:EchoPetAPI.java

示例12: onPlayerTeleport

import com.dsh105.commodus.StringUtil; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
  public void onPlayerTeleport(final PlayerTeleportEvent event) {
final Player p = event.getPlayer();
final IPet pi = EchoPet.getManager().getPet(p);
Iterator<IPet> i = EchoPet.getManager().getPets().iterator();
while(i.hasNext()){
	IPet pet = i.next();
	if(pet.getEntityPet() instanceof IEntityPacketPet && ((IEntityPacketPet) pet.getEntityPet()).hasInititiated()){
		if(GeometryUtil.getNearbyEntities(event.getTo(), 50).contains(pet)){
			((IEntityPacketPet) pet.getEntityPet()).updatePosition();
		}
	}
}
if(pi != null && pi.isSpawned()){
	if(!WorldUtil.allowPets(event.getTo())){
		Lang.sendTo(p, Lang.PETS_DISABLED_HERE.toString().replace("%world%", StringUtil.capitalise(event.getTo().getWorld().getName())));
		pi.removePet(false, false);
	}else{
		pi.setAsHat(false);
		if(event.getCause() != TeleportCause.UNKNOWN){// This will probably cause issues.. I don't know why more causes don't exist.
			pi.ownerRidePet(false);
			pi.removePet(false, false);
			new BukkitRunnable(){

				@Override
				public void run(){
					if(pi != null){
						if(WorldUtil.allowPets(event.getTo())){
							pi.spawnPet(p, false);
						}
					}
				}
			}.runTaskLater(EchoPet.getPlugin(), 20L);// could be reduced
		}
	}
}
  }
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:38,代码来源:PetOwnerListener.java

示例13: open

import com.dsh105.commodus.StringUtil; //导入依赖的package包/类
public void open(boolean sendMessage){
	PetMenuOpenEvent menuEvent = new PetMenuOpenEvent(this.pet.getOwner(), PetMenuOpenEvent.MenuType.MAIN);
	EchoPet.getPlugin().getServer().getPluginManager().callEvent(menuEvent);
	if(menuEvent.isCancelled()){ return; }
	InventoryView view = this.pet.getOwner().openInventory(this.inv);
	pet.setInventoryView(view);
	if(sendMessage){
		Lang.sendTo(this.pet.getOwner(), Lang.OPEN_MENU.toString().replace("%type%", StringUtil.capitalise(this.pet.getPetType().toString().replace("_", " "))));
	}
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:11,代码来源:PetMenu.java

示例14: showPotionHologram

import com.dsh105.commodus.StringUtil; //导入依赖的package包/类
private void showPotionHologram(Entity e, Collection<PotionEffect> effects) {
    for (PotionEffect effect : effects) {
        int amp = (effect.getAmplifier() < 1 ? 1 : effect.getAmplifier()) + 1;
        String content = Settings.INDICATOR_FORMAT.getValue("potion", effect.getType().getName().toLowerCase());
        content = content.replace("%effect%", StringUtil.capitalise(effect.getType().getName().replace("_", " "))).replace("%amp%", "" + new RomanNumeral(amp));
        Location l = e.getLocation().clone();
        l.setY(l.getY() + Settings.INDICATOR_Y_OFFSET.getValue("potion"));
        HoloAPI.getManager().createSimpleHologram(l, Settings.INDICATOR_TIME_VISIBLE.getValue("potion"), true, content);
    }
}
 
开发者ID:DSH105,项目名称:HoloAPI,代码行数:11,代码来源:IndicatorListener.java

示例15: info

import com.dsh105.commodus.StringUtil; //导入依赖的package包/类
protected static void info(CommandSender sender, Collection<Hologram> holograms) {
    for (Hologram hologram : holograms) {
        ArrayList<String> list = new ArrayList<>();
        list.add(ChatColor.GOLD + "" + ChatColor.UNDERLINE + "Hologram Preview:");
        if (hologram instanceof AnimatedHologram) {
            AnimatedHologram animatedHologram = (AnimatedHologram) hologram;
            if (animatedHologram.isImageGenerated() && (HoloAPI.getAnimationLoader().exists(animatedHologram.getAnimationKey())) || HoloAPI.getAnimationLoader().existsAsUnloadedUrl(animatedHologram.getAnimationKey())) {
                list.add(ChatColor.YELLOW + "" + ChatColor.ITALIC + animatedHologram.getAnimationKey() + " (ANIMATION)");
            } else {
                Collections.addAll(list, animatedHologram.getFrames().get(0).getLines());
            }
        } else {
            if (hologram.getLines().length > 1) {
                for (StoredTag tag : hologram.serialise()) {
                    if (tag.isImage()) {
                        if (HoloAPI.getConfig(ConfigType.MAIN).getBoolean("images." + tag.getContent() + ".requiresBorder", false)) {
                            for (String s : HoloAPI.getImageLoader().getGenerator(tag.getContent()).getLines()) {
                                list.add(HoloAPI.getTagFormatter().formatBasic(ChatColor.WHITE + s));
                            }
                        } else {
                            list.add(ChatColor.YELLOW + "" + ChatColor.ITALIC + tag.getContent() + " (IMAGE)");
                        }
                    } else {
                        list.add(HoloAPI.getTagFormatter().formatBasic(ChatColor.WHITE + tag.getContent()));
                    }
                }
            } else {
                list.add(HoloAPI.getTagFormatter().formatBasic(hologram.getLines()[0]));
            }
        }
        if (list.size() > 1) {
            new PowerMessage("•• " + ChatColor.AQUA + hologram.getSaveId() + ChatColor.DARK_AQUA + " at " + (int) hologram.getDefaultX() + ", " + (int) hologram.getDefaultY() + ", " + (int) hologram.getDefaultZ() + ", " + hologram.getWorldName()).tooltip(list.toArray(StringUtil.EMPTY_STRING_ARRAY)).suggest("/holo teleport " + hologram.getSaveId()).send(sender);
        }
    }
}
 
开发者ID:DSH105,项目名称:HoloAPI,代码行数:36,代码来源:InfoCommand.java


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