本文整理匯總了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;
}