本文整理汇总了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();
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例8: setSkullType
public void setSkullType(SkullType skullType) {
this.skullType = skullType;
if (skullType != SkullType.PLAYER) {
profile = null;
}
}
示例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;
}
示例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;
}
}
示例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;
}
示例12: setSkullType
public void setSkullType(SkullType skullType) {
this.skullType = skullType;
if (skullType != SkullType.PLAYER) {
player = "";
}
}
示例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());
}
示例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);
}
示例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);
}