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


Java EchoPet类代码示例

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


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

示例1: initiateEntityPet

import com.dsh105.echopet.compat.api.plugin.EchoPet; //导入依赖的package包/类
private void initiateEntityPet() {
    this.resetEntitySize();
    this.fireProof = true;
    if (this.FIELD_JUMP == null) {
        try {
this.FIELD_JUMP = EntityLiving.class.getDeclaredField("bd");// Usually right below lastDamage float. Has 3 floats after it.
            this.FIELD_JUMP.setAccessible(true);
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        }
    }
    this.getBukkitEntity().setMaxHealth(pet.getPetType().getMaxHealth());
    this.setHealth((float) pet.getPetType().getMaxHealth());
    this.jumpHeight = EchoPet.getOptions().getRideJumpHeight(this.getPet().getPetType());
    this.rideSpeed = EchoPet.getOptions().getRideSpeed(this.getPet().getPetType());
    this.setPathfinding();
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:18,代码来源:EntityPet.java

示例2: initiateEntityPet

import com.dsh105.echopet.compat.api.plugin.EchoPet; //导入依赖的package包/类
private void initiateEntityPet(){
	this.resetEntitySize();
	this.fireProof = true;
	if(this.FIELD_JUMP == null){
		try{
			this.FIELD_JUMP = EntityLiving.class.getDeclaredField("bd");// Usually right below lastDamage float. Has 3 floats after it. EntityLiving
			this.FIELD_JUMP.setAccessible(true);
		}catch(NoSuchFieldException e){
			e.printStackTrace();
		}
	}
	this.getBukkitEntity().setMaxHealth(pet.getPetType().getMaxHealth());
	this.setHealth((float) pet.getPetType().getMaxHealth());
	this.jumpHeight = EchoPet.getOptions().getRideJumpHeight(this.getPet().getPetType());
	this.rideSpeed = EchoPet.getOptions().getRideSpeed(this.getPet().getPetType());
	this.setPathfinding();
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:18,代码来源:EntityPet.java

示例3: onTabComplete

import com.dsh105.echopet.compat.api.plugin.EchoPet; //导入依赖的package包/类
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
    List<String> list = new ArrayList<String>();
    String cmdString = EchoPet.getPlugin().getCommandString();
    if (cmd.getName().equalsIgnoreCase(cmdString)) {
        String[] completions;
        if (args.length >= 2) {
            completions = getCompletions(args.length, args[args.length - 2]);
        } else {
            completions = getCompletions(args.length);
        }
        for (String s : completions) {
            if (s.startsWith(args[args.length - 1])) {
                list.add(s);
            }
        }
    }
    return list;
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:20,代码来源:CommandComplete.java

示例4: start

import com.dsh105.echopet.compat.api.plugin.EchoPet; //导入依赖的package包/类
@Override
public void start(final IPet pet){
	cancel();
	
	collectTrails(this);
	
	for(int delay : trailDelays.keySet()){
		final Set<Trail> trails = trailDelays.get(delay);
		trailRunnables.put(delay, new BukkitRunnable(){

			public void run(){
				if(pet == null || pet.getOwner() == null || pet.getCraftPet() == null || pet.getCraftPet().getLocation() == null){
					cancel();
					return;
				}
				for(Trail trail : trails){
					trail.displayTrail(pet);
				}
			}
		}.runTaskTimer(EchoPet.getPlugin(), delay, delay));
	}
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:23,代码来源:ParticleTrail.java

示例5: spawnPet

import com.dsh105.echopet.compat.api.plugin.EchoPet; //导入依赖的package包/类
public IEntityPet spawnPet(Player owner, boolean ignoreHidden){
	if(entityPet != null) return entityPet;
	if(owner != null){
		if(!EchoPet.getPlugin().getVanishProvider().isVanished(owner)){// We don't spawn pets at all if the player is vanished due to bounding boxes.
			if(isHidden && !ignoreHidden) return null;
			this.entityPet = EchoPet.getPlugin().getSpawnUtil().spawn(this, owner);
			if(this.entityPet != null){
				this.applyPetName();
				this.teleportToOwner();
				for(PetData pd : getPetData())// hrrm..
					EchoPet.getManager().setData(this, pd, true);
				for(Trail t : trails)
					t.start(this);
				if(lastRider != null && !lastRider.isSpawned()){
					setRider(lastRider);
					setLastRider(null);
				}
			}
		}
	}else{
		EchoPet.getManager().saveFileData("autosave", this);
		EchoPet.getSqlManager().saveToDatabase(this, false);
		EchoPet.getManager().removePet(this, false);
	}
	return entityPet;
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:27,代码来源:Pet.java

示例6: setPetName

import com.dsh105.echopet.compat.api.plugin.EchoPet; //导入依赖的package包/类
@Override
public boolean setPetName(String name, boolean sendFailMessage){
	if(PetNames.allow(name, this)){
		this.name = ChatColor.translateAlternateColorCodes('&', name);
		if(EchoPet.getPlugin().getMainConfig().getBoolean("stripDiacriticsFromNames", true)){
			this.name = StringSimplifier.stripDiacritics(this.name);
		}
		if(this.name == null || this.name.equalsIgnoreCase("")){
			this.name = this.petType.getDefaultName(this.getNameOfOwner());
		}
		this.applyPetName();
		return true;
	}else{
		if(sendFailMessage){
			if(this.getOwner() != null){
				Lang.sendTo(this.getOwner(), Lang.NAME_NOT_ALLOWED.toString().replace("%name%", name));
			}
		}
		return false;
	}
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:22,代码来源:Pet.java

示例7: teleport

import com.dsh105.echopet.compat.api.plugin.EchoPet; //导入依赖的package包/类
@Override
public boolean teleport(Location to){
	if(this.getOwner() == null || this.getOwner().getLocation() == null){
		EchoPet.getManager().saveFileData("autosave", this);
		EchoPet.getSqlManager().saveToDatabase(this, false);
		EchoPet.getManager().removePet(this, false);
		return false;
	}
	if(!isSpawned()) return false;
	PetTeleportEvent teleportEvent = new PetTeleportEvent(this, this.getLocation(), to);
	EchoPet.getPlugin().getServer().getPluginManager().callEvent(teleportEvent);
	if(teleportEvent.isCancelled()) return false;
	Location l = teleportEvent.getTo();
	if(l.getWorld() == this.getLocation().getWorld()){
		if(this.getRider() != null){
			this.getRider().getCraftPet().eject();
			this.getRider().getCraftPet().teleport(l);
		}
		this.getCraftPet().teleport(l);
		if(this.getRider() != null){
			this.getCraftPet().setPassenger(this.getRider().getCraftPet());
		}
		return true;
	}
	return false;
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:27,代码来源:Pet.java

示例8: setRider

import com.dsh105.echopet.compat.api.plugin.EchoPet; //导入依赖的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

示例9: initiateEntityPet

import com.dsh105.echopet.compat.api.plugin.EchoPet; //导入依赖的package包/类
private void initiateEntityPet(){
	this.resetEntitySize();
	this.fireProof = true;
	if(this.FIELD_JUMP == null){
		try{
			this.FIELD_JUMP = EntityLiving.class.getDeclaredField("bd");// Usually right below lastDamage float. Has 3 floats after it.
			this.FIELD_JUMP.setAccessible(true);
		}catch(NoSuchFieldException e){
			e.printStackTrace();
		}
	}
	this.getBukkitEntity().setMaxHealth(pet.getPetType().getMaxHealth());
	this.setHealth((float) pet.getPetType().getMaxHealth());
	this.jumpHeight = EchoPet.getOptions().getRideJumpHeight(this.getPet().getPetType());
	this.rideSpeed = EchoPet.getOptions().getRideSpeed(this.getPet().getPetType());
	this.setPathfinding();
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:18,代码来源:EntityPet.java

示例10: initiateEntityPet

import com.dsh105.echopet.compat.api.plugin.EchoPet; //导入依赖的package包/类
private void initiateEntityPet() {
    this.resetEntitySize();
    this.fireProof = true;
    if (this.FIELD_JUMP == null) {
        try {
this.FIELD_JUMP = EntityLiving.class.getDeclaredField("aY");// Usually right below lastDamage float. Has 3 floats after it.
            this.FIELD_JUMP.setAccessible(true);
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        }
    }
    this.getBukkitEntity().setMaxHealth(pet.getPetType().getMaxHealth());
    this.setHealth((float) pet.getPetType().getMaxHealth());
    this.jumpHeight = EchoPet.getOptions().getRideJumpHeight(this.getPet().getPetType());
    this.rideSpeed = EchoPet.getOptions().getRideSpeed(this.getPet().getPetType());
    this.setPathfinding();
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:18,代码来源:EntityPet.java

示例11: createPet

import com.dsh105.echopet.compat.api.plugin.EchoPet; //导入依赖的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

示例12: saveFileData

import com.dsh105.echopet.compat.api.plugin.EchoPet; //导入依赖的package包/类
@Override
public void saveFileData(String type, Player p, PetStorage UPD) {
    clearFileData(type, p);
    PetType pt = UPD.petType;
    PetData[] data = UPD.petDataList.toArray(new PetData[UPD.petDataList.size()]);
    String petName = UPD.petName;

    String path = type + "." + UUIDMigration.getIdentificationFor(p);
    EchoPet.getConfig(EchoPet.ConfigType.DATA).set(path + ".pet.type", pt.toString());
    EchoPet.getConfig(EchoPet.ConfigType.DATA).set(path + ".pet.name", petName);

    for (PetData pd : data) {
        EchoPet.getConfig(EchoPet.ConfigType.DATA).set(path + ".pet.data." + pd.toString().toLowerCase(), true);
    }
    EchoPet.getConfig(EchoPet.ConfigType.DATA).saveConfig();
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:17,代码来源:PetManager.java

示例13: initiateEntityPet

import com.dsh105.echopet.compat.api.plugin.EchoPet; //导入依赖的package包/类
private void initiateEntityPet(){
	this.resetEntitySize();
	this.fireProof = true;
	if(this.FIELD_JUMP == null){
		try{
			this.FIELD_JUMP = EntityLiving.class.getDeclaredField("be");// Usually right below lastDamage float. Has 3 floats after it.
			this.FIELD_JUMP.setAccessible(true);
		}catch(NoSuchFieldException e){
			e.printStackTrace();
		}
	}
	this.getBukkitEntity().setMaxHealth(pet.getPetType().getMaxHealth());
	this.setHealth((float) pet.getPetType().getMaxHealth());
	this.jumpHeight = EchoPet.getOptions().getRideJumpHeight(this.getPet().getPetType());
	this.rideSpeed = EchoPet.getOptions().getRideSpeed(this.getPet().getPetType());
	this.setPathfinding();
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:18,代码来源:EntityPet.java

示例14: onPlayerInteractEntity

import com.dsh105.echopet.compat.api.plugin.EchoPet; //导入依赖的package包/类
@EventHandler
  public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
      Player p = event.getPlayer();
      Entity e = event.getRightClicked();
int slot = p.getInventory().getHeldItemSlot();
if(slot >= 0 && slot < 9){
	ItemStack itemInHand = p.getInventory().getContents()[slot];
	if(itemInHand != null && itemInHand.getType() != Material.AIR && itemInHand.isSimilar(SelectorLayout.getSelectorItem())){
		new SelectorMenu(p, 0).open(p);
		event.setCancelled(true);
		return;
	}
      }

      if (ReflectionUtil.getEntityHandle(e) instanceof IEntityPet) {
          IPet pet = ((IEntityPet) ReflectionUtil.getEntityHandle(e)).getPet();
          event.setCancelled(true);
          PetInteractEvent iEvent = new PetInteractEvent(pet, p, PetInteractEvent.Action.RIGHT_CLICK, false);
          EchoPet.getPlugin().getServer().getPluginManager().callEvent(iEvent);
          if (!iEvent.isCancelled()) {
              pet.getEntityPet().onInteract(p);
              return;
          }
      }
  }
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:26,代码来源:PetOwnerListener.java

示例15: migrateTables

import com.dsh105.echopet.compat.api.plugin.EchoPet; //导入依赖的package包/类
/**
 * Migrate old tables using EchoPet's SQL connection pool
 * <p/>
 * In the process of migration, old tables will be dropped
 */
public static void migrateTables() {
    Connection conn = null;

    try {
        conn = EchoPet.getPlugin().getDbPool().getConnection();
        for (MigrationStrategy strategy : tableMigrationStrategies) {
            if (conn.getMetaData().getTables(null, null, strategy.getTableName(), null).next()) {
                strategy.createTargetTable(conn);
                strategy.migrate(conn);
                strategy.dropOldTable(conn);
            }
        }

    } catch (SQLException e) {
        Logger.log(Logger.LogLevel.SEVERE, "Failed to migrate old SQL table(s)", e, true);
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (SQLException ignored) {
            }
        }
    }
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:30,代码来源:TableMigrationUtil.java


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