當前位置: 首頁>>代碼示例>>Java>>正文


Java SkullType.PLAYER屬性代碼示例

本文整理匯總了Java中org.bukkit.SkullType.PLAYER屬性的典型用法代碼示例。如果您正苦於以下問題:Java SkullType.PLAYER屬性的具體用法?Java SkullType.PLAYER怎麽用?Java SkullType.PLAYER使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.bukkit.SkullType的用法示例。


在下文中一共展示了SkullType.PLAYER屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

@Override
public void run() {
	if (loc == null) {
		return;
	}
	Block b = loc.getBlock();
	if (b.getType() != Material.SKULL) {
		return;
	}
	Skull skull = (Skull) b.getState();
	if (type == SkullType.PLAYER) {
		skull.setSkullType(type);
		skull.setOwner(owner);
	} else {
		skull.setSkullType(type);
	}
	skull.update();
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:18,代碼來源:AntiDamageSkull.java

示例2: getSkullType

static SkullType getSkullType(int id) {
    switch (id) {
        case 0:
            return SkullType.SKELETON;
        case 1:
            return SkullType.WITHER;
        case 2:
            return SkullType.ZOMBIE;
        case 3:
            return SkullType.PLAYER;
        case 4:
            return SkullType.CREEPER;
        default:
            throw new AssertionError(id);
    }
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:16,代碼來源:CraftSkull.java

示例3: setOwner

public boolean setOwner(String name) {
    if (name == null || name.length() > MAX_OWNER_LENGTH) {
        return false;
    }

    GameProfile profile = MinecraftServer.getServer().func_152358_ax().func_152655_a (name);
    if (profile == null) {
        return false;
    }

    if (skullType != SkullType.PLAYER) {
        skullType = SkullType.PLAYER;
    }

    this.profile = profile;
    return true;
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:17,代碼來源:CraftSkull.java

示例4: update

@Override
public boolean update(boolean force, boolean applyPhysics) {
    boolean result = super.update(force, applyPhysics);

    if (result) {
        if (skullType == SkullType.PLAYER) {
            skull.func_152106_a(profile);
        } else {
            skull.func_152107_a(getSkullType(skullType));
        }

        skull.func_145903_a(rotation);
        skull.markDirty();
    }

    return result;
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:17,代碼來源:CraftSkull.java

示例5: update

@Override
public boolean update(boolean force, boolean applyPhysics) {
    boolean result = super.update(force, applyPhysics);

    if (result) {
        if (skullType == SkullType.PLAYER) {
            skull.setGameProfile(profile);
        } else {
            skull.setSkullType(getSkullType(skullType));
        }

        skull.setRotation(rotation);
        skull.update();
    }

    return result;
}
 
開發者ID:tgnmc,項目名稱:Craftbukkit,代碼行數:17,代碼來源:CraftSkull.java

示例6: setOwner

public boolean setOwner(String name) {
    if (name == null || name.length() > MAX_OWNER_LENGTH) {
        return false;
    }

    GameProfile profile = MinecraftServer.getServer().getUserCache().getProfile(name);
    if (profile == null) {
        return false;
    }

    if (skullType != SkullType.PLAYER) {
        skullType = SkullType.PLAYER;
    }

    this.profile = profile;
    return true;
}
 
開發者ID:tgnmc,項目名稱:Craftbukkit,代碼行數:17,代碼來源:CraftSkull.java

示例7: getSkullType

static SkullType getSkullType(int id) {
    switch (id) {
        default:
        case 0:
            return SkullType.SKELETON;
        case 1:
            return SkullType.WITHER;
        case 2:
            return SkullType.ZOMBIE;
        case 3:
            return SkullType.PLAYER;
        case 4:
            return SkullType.CREEPER;
        case 5:
            return SkullType.DRAGON;
    }
}
 
開發者ID:bergerkiller,項目名稱:SpigotSource,代碼行數:17,代碼來源:CraftSkull.java

示例8: setSkullType

public void setSkullType(SkullType skullType) {
    this.skullType = skullType;

    if (skullType != SkullType.PLAYER) {
        profile = null;
    }
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:7,代碼來源:CraftSkull.java

示例9: convert

@Override
@Nullable
public ItemType convert(final Object o) {
	final SkullType type;
	if (o instanceof Skeleton || o instanceof SkeletonData) {
		if (o instanceof SkeletonData ? ((SkeletonData) o).isWither() : ((Skeleton) o).getSkeletonType() == SkeletonType.WITHER) {
			type = SkullType.WITHER;
		} else {
			type = SkullType.SKELETON;
		}
	} else if (o instanceof Zombie || o instanceof EntityData && Zombie.class.isAssignableFrom(((EntityData<?>) o).getType())) {
		type = SkullType.ZOMBIE;
	} else if (o instanceof OfflinePlayer || o instanceof PlayerData) {
		type = SkullType.PLAYER;
	} else if (o instanceof Creeper || o instanceof CreeperData) {
		type = SkullType.CREEPER;
	} else {
		return null;
	}
	@SuppressWarnings("deprecation")
	final ItemType i = new ItemType(Material.SKULL_ITEM.getId(), (short) type.ordinal());
	if (o instanceof OfflinePlayer) {
		final SkullMeta s = (SkullMeta) Bukkit.getItemFactory().getItemMeta(Material.SKULL_ITEM);
		s.setOwner(((OfflinePlayer) o).getName());
		i.setItemMeta(s);
	}
	return i;
}
 
開發者ID:nfell2009,項目名稱:Skript,代碼行數:28,代碼來源:ExprSkull.java

示例10: getSkullType

static SkullType getSkullType(int id) {
    switch (id) {
        default:
        case 0:
            return SkullType.SKELETON;
        case 1:
            return SkullType.WITHER;
        case 2:
            return SkullType.ZOMBIE;
        case 3:
            return SkullType.PLAYER;
        case 4:
            return SkullType.CREEPER;
    }
}
 
開發者ID:tgnmc,項目名稱:Craftbukkit,代碼行數:15,代碼來源:CraftSkull.java

示例11: setOwner

public boolean setOwner(String name) {
    if (name == null || name.length() > MAX_OWNER_LENGTH) {
        return false;
    }
    player = name;

    if (skullType != SkullType.PLAYER) {
        skullType = SkullType.PLAYER;
    }

    return true;
}
 
開發者ID:AlmuraDev,項目名稱:Almura-Server,代碼行數:12,代碼來源:CraftSkull.java

示例12: setSkullType

public void setSkullType(SkullType skullType) {
    this.skullType = skullType;

    if (skullType != SkullType.PLAYER) {
        player = "";
    }
}
 
開發者ID:AlmuraDev,項目名稱:Almura-Server,代碼行數:7,代碼來源:CraftSkull.java

示例13: setOwningPlayer

@Override
public void setOwningPlayer(OfflinePlayer player) {
    Preconditions.checkNotNull(player, "player");

    if (skullType != SkullType.PLAYER) {
        skullType = SkullType.PLAYER;
    }

    this.profile = new GameProfile(player.getUniqueId(), player.getName());
}
 
開發者ID:bergerkiller,項目名稱:SpigotSource,代碼行數:10,代碼來源:CraftSkull.java

示例14: searchForMarkers

/**
 * Searches the map for "markers". Most of the time these are implemented as tile entities (skulls)
 *
 * @param map    the map to scan
 * @param center the center location
 * @param range  the range in where to scan
 */
public void searchForMarkers(@Nonnull Map map, @Nonnull Vector3D center, int range, @Nonnull UUID gameid) {
    World world = Bukkit.getWorld(map.getLoadedName(gameid));
    if (world == null) {
        throw new MapException("Could not find world " + map.getLoadedName(gameid) + "(" + map.getInfo().getName() + ")" + ". Is it loaded?");
    }

    List<Marker> markers = new ArrayList<>();
    List<ChestMarker> chestMarkers = new ArrayList<>();

    int startX = (int) center.getX();
    int startY = (int) center.getZ();

    int minX = Math.min(startX - range, startX + range);
    int minZ = Math.min(startY - range, startY + range);

    int maxX = Math.max(startX - range, startX + range);
    int maxZ = Math.max(startY - range, startY + range);

    for (int x = minX; x <= maxX; x += 16) {
        for (int z = minZ; z <= maxZ; z += 16) {
            Chunk chunk = world.getChunkAt(x >> 4, z >> 4);
            for (BlockState te : chunk.getTileEntities()) {
                if (te.getType() == Material.SKULL) {
                    Skull skull = (Skull) te;
                    if (skull.getSkullType() == SkullType.PLAYER) {
                        String markerData = getMarkerData(skull);
                        if (markerData == null) continue;
                        MarkerDefinition markerDefinition = mapHandler.createMarkerDefinition(markerData);
                        markers.add(new Marker(new Vector3D(skull.getX(), skull.getY(), skull.getZ()),
                                DirectionUtil.directionToYaw(skull.getRotation()),
                                markerData, markerDefinition));
                    }
                } else if (te.getType() == Material.CHEST) {
                    Chest chest = (Chest) te;
                    String name = chest.getBlockInventory().getName();
                    ItemStack[] items = new ItemStack[chest.getBlockInventory()
                            .getStorageContents().length];
                    for (int i = 0; i < items.length; i++) {
                        ItemStack is = chest.getBlockInventory().getItem(i);
                        if (is == null) {
                            items[i] = new ItemStack(Material.AIR);
                        } else {
                            items[i] = is;
                        }
                    }
                    chestMarkers
                            .add(new ChestMarker(new Vector3D(chest.getX(), chest.getY(), chest.getZ()), name,
                                    items));
                }
            }
        }
    }

    map.setMarkers(markers);
    map.setChestMarkers(chestMarkers);
}
 
開發者ID:VoxelGamesLib,項目名稱:VoxelGamesLibv2,代碼行數:63,代碼來源:MapScanner.java

示例15: searchForMarkers

@Override
public void searchForMarkers(@Nonnull Map map, @Nonnull Vector3D center, int range) {
    World world = Bukkit.getWorld(map.getWorldName());
    if (world == null) {
        throw new MapException("Could not find world " + map.getWorldName() + ". Is it loaded?");
    }

    List<Marker> markers = new ArrayList<>();
    List<ChestMarker> chestMarkers = new ArrayList<>();

    int startX = (int) center.getX();
    int startY = (int) center.getZ();

    int minX = Math.min(startX - range, startX + range);
    int minZ = Math.min(startY - range, startY + range);

    int maxX = Math.max(startX - range, startX + range);
    int maxZ = Math.max(startY - range, startY + range);

    for (int x = minX; x <= maxX; x += 16) {
        for (int z = minZ; z <= maxZ; z += 16) {
            Chunk chunk = world.getChunkAt(x >> 4, z >> 4);
            for (BlockState te : chunk.getTileEntities()) {
                if (te.getType() == Material.SKULL) {
                    Skull skull = (Skull) te;
                    if (skull.getSkullType() == SkullType.PLAYER) {
                        if (skull.getOwningPlayer() != null) {
                            String markerData = skull.getOwningPlayer().getName();
                            if (markerData == null) {
                                log.warning("owning player name null?!");
                                markerData = skull.getOwner();
                            }
                            markers.add(new Marker(new Vector3D(skull.getX(), skull.getY(), skull.getZ()),
                                    DirectionUtil.directionToYaw(directionConverter.toVGL(skull.getRotation())), markerData));
                        } else {
                            log.warning("unknown owner");
                        }
                    }
                } else if (te.getType() == Material.CHEST) {
                    Chest chest = (Chest) te;
                    String name = chest.getBlockInventory().getName();
                    Item[] items = new Item[chest.getBlockInventory().getStorageContents().length];
                    for (int i = 0; i < items.length; i++) {
                        ItemStack is = chest.getBlockInventory().getItem(i);
                        Item item = injector.getInstance(Item.class);
                        if (is == null) {
                            //noinspection unchecked
                            item.setImplementationType(new ItemStack(Material.AIR));
                            items[i] = item;
                        } else {
                            //noinspection unchecked
                            item.setImplementationType(is);
                            items[i] = item;
                        }
                    }
                    chestMarkers.add(new ChestMarker(new Vector3D(chest.getX(), chest.getY(), chest.getZ()), name, items));
                }
            }
        }
    }

    map.setMarkers(markers);
    map.setChestMarkers(chestMarkers);
}
 
開發者ID:VoxelGamesLib,項目名稱:VoxelGamesLib,代碼行數:64,代碼來源:BukkitMapScanner.java


注:本文中的org.bukkit.SkullType.PLAYER屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。