本文整理匯總了Java中org.bukkit.entity.Villager.addPotionEffect方法的典型用法代碼示例。如果您正苦於以下問題:Java Villager.addPotionEffect方法的具體用法?Java Villager.addPotionEffect怎麽用?Java Villager.addPotionEffect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.entity.Villager
的用法示例。
在下文中一共展示了Villager.addPotionEffect方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: spawnVillager
import org.bukkit.entity.Villager; //導入方法依賴的package包/類
/**
* Spawns a Villager of the given VillagerType at the provided Location
*
* @param type - the Type of the Villager you wish to Spawn
* @param location - the Location at which you want the Villager to be
* @return Villager - the Villager that you had set at the provided Location if you wish to use it
*/
public Villager spawnVillager(VillagerType type, Location location) {
if (!location.getChunk().isLoaded()) {
location.getChunk().load();
}
Villager villager = (Villager) location.getWorld().spawnEntity(location, EntityType.VILLAGER);
villager.setAdult();
villager.setAgeLock(true);
villager.setProfession(Profession.FARMER);
villager.setRemoveWhenFarAway(false);
villager.setCustomName(type.getColor() + type.getName());
villager.setCustomNameVisible(true);
villager.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, -6, true), true);
villager.teleport(location, TeleportCause.PLUGIN);
villager.setHealth(20.0D);
return villager;
}
示例2: onCommand
import org.bukkit.entity.Villager; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if (command.getName().equalsIgnoreCase("spawnNPC")) {
if (!player.hasPermission("deathswap.admin")) {
player.sendMessage(ChatUtil.formatWithPrefix("&cYou do not have permission to use this command!"));
return true;
}
Villager villager = (Villager) player.getLocation().getWorld().spawnEntity(player.getLocation(), EntityType.VILLAGER);
villager.setCustomName(ChatUtil.format("&aJoin DeathSwap"));
villager.setProfession(Villager.Profession.BUTCHER);
villager.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 999999, 999999));
}
}
return false;
}
示例3: onCommand
import org.bukkit.entity.Villager; //導入方法依賴的package包/類
public boolean onCommand(CommandSender sender, Command cmd, String tag, String[] args) {
if (tag.equalsIgnoreCase("test")) {
for (Player online : Bukkit.getOnlinePlayers()) {
final Villager villager = (Villager) online.getLocation().getWorld().spawnEntity(online.getLocation().subtract(3,0,3), EntityType.VILLAGER);
villager.setCustomName(online.getName());
villager.setCustomNameVisible(true);
villager.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1));
villager.setMetadata("cancel", (MetadataValue)new FixedMetadataValue((Plugin)plugin, (Object)true));
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
public void run() {
vilager.removeMetaData("cancel");
villager.remove();
}
}, 10);
}
}
return false;
}
示例4: SpawnVillager
import org.bukkit.entity.Villager; //導入方法依賴的package包/類
public static Villager SpawnVillager(World world, Location loc, String name){
if(EpicSystem.useCitizens()) return null;
//Check if villager exists
if(GetEntity(world, name) != null){
RemoveVillager(world, name);
}
//Set properties
Villager villager = (Villager) world.spawnEntity(loc, EntityType.VILLAGER);
villager.setCustomName(name);
villager.setCustomNameVisible(true);
villager.setAgeLock(true);
villager.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1000000000, 100000000));
villager.setCanPickupItems(false);
QuestEntity epicVillager = new QuestEntity(villager);
epicVillager.originalLocation = loc;
entityList.put(villager, epicVillager);
return villager;
}
示例5: spawn
import org.bukkit.entity.Villager; //導入方法依賴的package包/類
public static void spawn(){
for(Location loc : mineageddon()){
final Villager v = HubVillager.spawn(loc);
v.setAdult();
v.setCustomName(ChatColor.RED + "" + ChatColor.BOLD + "Mineageddon");
v.setCustomNameVisible(true);
v.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 10000000,100,false));
}
}
示例6: spawn
import org.bukkit.entity.Villager; //導入方法依賴的package包/類
void spawn( Location rootLocation, Plugin plugin ) {
Location loc = new Location( rootLocation.getWorld(), rootLocation.getX() + location.getX(), rootLocation.getY() + location.getY(), rootLocation.getZ() + location.getZ() );
switch ( size ) {
case SMALL:
loc.setY( loc.getY() - 1.5 );
loc.setPitch( (float) headPose.getY() );
loc.setYaw( (float) headPose.getX() );
armorStand = spawnArmorStand( loc, plugin );
armorStand.setVisible( false );
armorStand.setAI( false );
villager = (Villager) loc.getWorld().spawnEntity( loc, EntityType.VILLAGER );
EntityVillager entityVillager = ( (CraftVillager) villager ).getHandle();
entityVillager.yaw = loc.getYaw();
entityVillager.pitch = loc.getPitch();
clearPathFinding( entityVillager );
entityVillager.getControllerLook().a( loc.getX(), loc.getY(), loc.getZ(), loc.getPitch(), loc.getYaw() );
entityVillager.setPositionRotation( loc.getX(), loc.getY(), loc.getZ(), loc.getPitch(), loc.getYaw() );
entityVillager.noclip = true;
entityVillager.b( true );//silent
entityVillager.collides = false;
entityVillager.yaw = loc.getYaw();
entityVillager.pitch = loc.getPitch();
entityVillager.lastPitch = loc.getPitch();
entityVillager.lastYaw = loc.getYaw();
entityVillager.aO = loc.getYaw();
entityVillager.aM = loc.getYaw();
villager.setBaby();
villager.addPotionEffect( new PotionEffect( PotionEffectType.INVISIBILITY, 9999999, 255, false, false ) );
villager.setInvulnerable( true );
villager.getEquipment().setHelmet( item );
armorStand.setPassenger( villager );
break;
case MEDIUM:
armorStand = spawnArmorStand( loc, plugin );
armorStand.setSmall( true );
armorStand.setVisible( false );
armorStand.setAI( false );
armorStand.setCustomName( customName );
armorStand.getEquipment().setHelmet( item );
armorStand.setHeadPose( new EulerAngle( Math.toRadians( headPose.getX() ), Math.toRadians( headPose.getY() ), Math.toRadians( headPose.getZ() ) ) );
( (NoGravityArmorStand) ( (CraftArmorStand) armorStand ).getHandle() ).update();
break;
case LARGE:
armorStand = spawnArmorStand( loc, plugin );
armorStand.setVisible( false );
armorStand.setAI( false );
armorStand.setCustomName( customName );
armorStand.getEquipment().setHelmet( item );
armorStand.setHeadPose( new EulerAngle( Math.toRadians( headPose.getX() ), Math.toRadians( headPose.getY() ), Math.toRadians( headPose.getZ() ) ) );
( (NoGravityArmorStand) ( (CraftArmorStand) armorStand ).getHandle() ).update();
break;
case SOLID:
blockState = loc.getBlock().getState();
loc.getBlock().setTypeIdAndData( item.getTypeId(), (byte) item.getDurability(), false );
System.out.println( loc.getBlock().getType() );
break;
}
}