本文整理汇总了Java中org.bukkit.World.getEntities方法的典型用法代码示例。如果您正苦于以下问题:Java World.getEntities方法的具体用法?Java World.getEntities怎么用?Java World.getEntities使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.World
的用法示例。
在下文中一共展示了World.getEntities方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.bukkit.World; //导入方法依赖的package包/类
@Override
public void run() {
for (final Player player : PetBlockListener.this.manager.timeBlocked.keySet().toArray(new Player[PetBlockListener.this.manager.timeBlocked.size()])) {
PetBlockListener.this.manager.timeBlocked.put(player, PetBlockListener.this.manager.timeBlocked.get(player) - 1);
if (PetBlockListener.this.manager.timeBlocked.get(player) <= 0) {
PetBlockListener.this.manager.timeBlocked.remove(player);
PetBlockListener.this.providePet(player, (petMeta, petBlock) -> PetBlockListener.this.setPetBlock(player, petMeta));
}
}
for (final World world : Bukkit.getWorlds()) {
for (final Entity entity : world.getEntities()) {
if (entity instanceof ArmorStand && PetBlockListener.this.isDeadPet(entity)) {
entity.remove();
} else if (!PetBlockListener.this.isPet(entity) && entity.getCustomName() != null && entity.getCustomName().equals("PetBlockIdentifier")) {
entity.remove();
}
}
}
}
示例2: getEntities_OnePlayerInWorld_ListContainsOnlyPlayer
import org.bukkit.World; //导入方法依赖的package包/类
@Test
public void getEntities_OnePlayerInWorld_ListContainsOnlyPlayer()
{
World world = server.addSimpleWorld("world");
server.addSimpleWorld("otherWorld");
Player player = server.addPlayer();
player.teleport(world.getSpawnLocation());
List<Entity> entities = world.getEntities();
assertNotNull(entities);
assertEquals(1, entities.size());
assertSame(player, entities.get(0));
}
示例3: getEntities_OnePlayerInDifferentWorld_EmptyList
import org.bukkit.World; //导入方法依赖的package包/类
@Test
public void getEntities_OnePlayerInDifferentWorld_EmptyList()
{
World world = server.addSimpleWorld("world");
World otherWorld = server.addSimpleWorld("otherWorld");
Player player = server.addPlayer();
player.teleport(otherWorld.getSpawnLocation());
List<Entity> entities = world.getEntities();
assertNotNull(entities);
assertEquals(0, entities.size());
}
示例4: run
import org.bukkit.World; //导入方法依赖的package包/类
@Override
public void run() {
for (final World world : Bukkit.getWorlds()) {
for (final Entity entity : world.getEntities()) {
if (BallListener.this.isDeadBall(entity)) {
entity.remove();
}
}
}
}
示例5: WorldInfo
import org.bukkit.World; //导入方法依赖的package包/类
public WorldInfo(World world) {
this.worldName = world.getName();
this.totalOnline = world.getPlayers().size();
for (Entity entity : world.getEntities()) {
this.totalEntity++;
if (entity instanceof Animals) {
this.totalAnimals++;
} else if (entity instanceof Monster) {
this.totalMonsters++;
} else if (entity instanceof Item) {
this.totalDropItem++;
}
}
for (Chunk loadedChunk : world.getLoadedChunks()) {
this.totalChunk++;
for (BlockState tiles : loadedChunk.getTileEntities()) {
this.totalTiles++;
if (tiles instanceof Hopper) {
this.totalHopper++;
} else if (tiles instanceof Chest) {
this.totalChest++;
} else if (tiles instanceof Dispenser) {
this.totalDispenser++;
} else if (tiles instanceof Dropper) {
this.totalDropper++;
} else if (tiles instanceof BrewingStand) {
this.totalBrewingStand++;
}
}
}
}
示例6: clearJunk
import org.bukkit.World; //导入方法依赖的package包/类
public void clearJunk(){
World world = Bukkit.getWorld("kaospvp");
List<Entity> list = world.getEntities();
for(Entity e : list){
if(e instanceof Item){
Item it = (Item) e;
if( it.getItemStack().getType() == Material.POTION &&
it.getItemStack().getDurability() == 16453){
e.remove();
}
if( it.getItemStack().getType() == Material.GOLDEN_APPLE &&
it.getItemStack().getDurability() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.ARROW){
e.remove();
}
if( it.getItemStack().getType() == Material.GLASS_BOTTLE){
e.remove();
}
if( it.getItemStack().getType() == Material.DIAMOND_BOOTS &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.DIAMOND_LEGGINGS &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.DIAMOND_CHESTPLATE &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.DIAMOND_HELMET &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.DIAMOND_SWORD &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.BOW &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.WOOD_AXE ||
it.getItemStack().getType() == Material.STONE_AXE ||
it.getItemStack().getType() == Material.GOLD_AXE ||
it.getItemStack().getType() == Material.IRON_AXE ||
it.getItemStack().getType() == Material.DIAMOND_AXE){
e.remove();
}
}
}
}
示例7: clean
import org.bukkit.World; //导入方法依赖的package包/类
public void clean(boolean cleanItem, boolean cleanEntity) { // TODO: 支持清理阈值与 forceclean
if (cleanItem) itemTimeCounter = 0;
if (cleanEntity) entityTimeCounter = 0;
int itemCount = 0, mobCount = 0, entityCount = 0;
for (World world : Bukkit.getWorlds()) {
String worldName = world.getName();
if ((!cleanItem || cm.cleanItemWorldWhitelist.contains(worldName)) &&
(!cleanEntity || cm.cleanEntityWorldWhitelist.contains(worldName))) {
continue; // 如果这个世界既不允许清理掉落物也不允许清理实体就不浪费时间了
}
for (Entity entity : world.getEntities()) {
if (entity instanceof Item) {
// 世界白名单之前检查过了, 没必要再次检查
if (canCleanItem((Item) entity, false)) {
itemCount++;
}
} else {
if (canClean(entity)) {
entity.remove();
if (entity instanceof LivingEntity) {
mobCount++;
} else {
entityCount++;
}
}
}
}
}
if (cm.cleanItemBroadcast && itemCount > 0) {
NeverLagUtils.broadcastIfOnline(i18n.tr("item.broadcast", itemCount));
}
if (cm.cleanEntityBroadcast) {
if (mobCount > 0) {
NeverLagUtils.broadcastIfOnline(i18n.tr("mob", mobCount));
}
if (entityCount > 0) {
NeverLagUtils.broadcastIfOnline(i18n.tr("entity", entityCount));
}
}
}
示例8: onCommand
import org.bukkit.World; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void onCommand(CommandSender sender, String[] args) {
String type = args[0].toLowerCase();
if (!COMPLETION_LIST.contains(type)) {
sender.sendMessage(i18n.tr("illegalType", COMPLETION_LIST));
return;
}
int count = 0;
for (World w : Bukkit.getWorlds()) {
for (Entity entity : w.getEntities()) {
if (entity instanceof Player || NeverLagUtils.checkCustomNpc(entity)) {
continue;
}
switch (args[0].toLowerCase()) {
case "monsters":
case "monster":
if (entity instanceof Monster) {
entity.remove();
count++;
}
break;
case "animals":
case "animal":
if (entity instanceof Animals) {
entity.remove();
count++;
}
break;
case "dropitems":
case "dropitem":
case "items":
case "item":
if (entity instanceof Item) {
entity.remove();
count++;
}
break;
default:
if (entity.getType().getName().equalsIgnoreCase(args[0])) {
entity.remove();
count++;
}
break;
}
}
}
sender.sendMessage(i18n.tr("success", args[0], count));
}