本文整理汇总了Java中org.bukkit.entity.Entity.setCustomName方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.setCustomName方法的具体用法?Java Entity.setCustomName怎么用?Java Entity.setCustomName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Entity
的用法示例。
在下文中一共展示了Entity.setCustomName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@Override
public void execute() {
Entity e = getEntity();
if (customName != null)
e.setCustomName(ChatColor.DARK_GREEN + customName);
e.setCustomNameVisible(showName);
MetadataManager.setMetadata(e, "csKeep", dontRemove);
MetadataManager.setMetadata(e, "csInvincible", keepInvincible);
}
示例2: newPlayer
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public boolean newPlayer(final Channel channel, String proposedUsername, String token) {
String theirName;
boolean authenticated = false;
if (validateClientAuthKey(proposedUsername, token)) {
theirName = proposedUsername;
authenticated = true;
// TODO: more features when logging in as an authenticated user: move to their last spawn?
} else {
if (!proposedUsername.equals("")) { // blank = anonymous
webSocketServerThread.sendLine(channel, "T,Failed to login as "+proposedUsername);
}
if (!allowAnonymous) {
webSocketServerThread.sendLine(channel,"T,This server requires authentication.");
return false;
}
int theirID = ++this.lastPlayerID;
theirName = "webguest" + theirID;
}
String ip = webSocketServerThread.getRemoteIPandPort(channel);
webSocketServerThread.log(Level.INFO, "New web client joined: " + theirName +
(authenticated ? " (authenticated)" : " (anonymous)") + " from " + ip);
this.channelId2name.put(channel.id(), theirName);
this.name2channel.put(theirName, channel);
webSocketServerThread.sendLine(channel, "T,Welcome to WebSandboxMC, "+theirName+"!");
if (this.entityClass != null) {
// Spawn an entity in the web user's place
Location location = webSocketServerThread.blockBridge.spawnLocation;
Entity entity = webSocketServerThread.blockBridge.world.spawn(location, (Class) this.entityClass);
if (setCustomNames) {
entity.setCustomName(theirName); // name tag
entity.setCustomNameVisible(true);
}
if (disableGravity) {
entity.setGravity(false); // allow flying
}
if (disableAI) {
if (entity instanceof LivingEntity) {
LivingEntity livingEntity = (LivingEntity) entity;
livingEntity.setAI(false);
}
}
channelId2Entity.put(channel.id(), entity);
entityId2Username.put(entity.getEntityId(), theirName);
// Notify other web clients (except this one) of this new user
webSocketServerThread.broadcastLineExcept(channel.id(), "P," + entity.getEntityId() + "," + webSocketServerThread.playersBridge.encodeLocation(location));
webSocketServerThread.broadcastLineExcept(channel.id(), "N," + entity.getEntityId() + "," + theirName);
}
// TODO: should this go to Bukkit chat, too/instead? make configurable?
webSocketServerThread.broadcastLine("T," + theirName + " has joined.");
return true;
}