本文整理汇总了Java中org.bukkit.entity.Player.hasMetadata方法的典型用法代码示例。如果您正苦于以下问题:Java Player.hasMetadata方法的具体用法?Java Player.hasMetadata怎么用?Java Player.hasMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Player
的用法示例。
在下文中一共展示了Player.hasMetadata方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerJoin
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW)
public void onPlayerJoin(PlayerJoinEvent e){
Player p = e.getPlayer();
if (p.hasMetadata("NPC")) return;
if (plugin.getConfig().getString("spawn").equalsIgnoreCase("NONE")) {
if (e.getPlayer().hasPermission("admin")) {
WCServer.getUser(e.getPlayer()).sendMessagePrefix("&7El spawn no está definido. Puedes hacerlo poniendo /forcespawn set en las coordenadas que quieras");
}
} else {
e.getPlayer().teleport(Utils.stringToLocation(plugin.getConfig().getString("spawn")));
}
e.setJoinMessage(Utils.colorize(plugin.getConfig().getString("join")).replace("{0}", e.getPlayer().getName()));
}
示例2: onDisable
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void onDisable()
{
PluginDescriptionFile pdfFile = getDescription();
Logger logger = getLogger();
getServer().getScheduler().cancelTasks(this);
getServer().resetRecipes();
usingPlayers = new ArrayList<Player>();
//Avoid WorkbenchShare glitch
for(Player p : Bukkit.getOnlinePlayers())
{
if (p.hasMetadata("shared_workbench"))
{
Block workbench = (p.getMetadata("shared_workbench").get(0).value() instanceof Block) ? (Block)p.getMetadata("shared_workbench").get(0).value() : null;
if(workbench != null && workbench.getType() == Material.WORKBENCH)
{
if (workbench.hasMetadata("shared_players"))
workbench.removeMetadata("shared_players", Survival.instance);
else
p.getOpenInventory().getTopInventory().clear();
p.closeInventory();
}
p.removeMetadata("shared_workbench", Survival.instance);
}
}
logger.info(pdfFile.getName() + " has been disabled.");
}
示例3: onInventoryClose
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClose(InventoryCloseEvent e)
{
if (!(e.getPlayer() instanceof Player))
return;
final Player p = (Player) e.getPlayer();
if (!p.hasMetadata("shared_workbench"))
return;
if (e.getInventory().getType() == InventoryType.WORKBENCH)
{
// Workaround to get the accessed WorkBench
final Block workbench = p.getTargetBlock((Set<Material>) null, 8);
if (!workbench.hasMetadata("shared_players") || workbench.getType() != Material.WORKBENCH)
{
if (p.getOpenInventory().getTopInventory() != null)
p.getOpenInventory().getTopInventory().clear();
p.removeMetadata("shared_workbench", Survival.instance);
return;
}
@SuppressWarnings("unchecked")
List<UUID> list = (workbench.getMetadata("shared_players").get(0).value() instanceof List<?>) ? (List<UUID>)workbench.getMetadata("shared_players").get(0).value() : new ArrayList<UUID>();
list.remove(p.getUniqueId());
if (list.isEmpty())
workbench.removeMetadata("shared_players", Survival.instance);
else
{
e.getInventory().clear();
workbench.setMetadata("shared_players", new FixedMetadataValue(Survival.instance, list));
}
}
}
示例4: onPlayerQuit
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onPlayerQuit(PlayerQuitEvent e)
{
if (!(e.getPlayer() instanceof Player))
return;
final Player p = (Player) e.getPlayer();
if (!p.hasMetadata("shared_workbench"))
return;
Block workbench = (p.getMetadata("shared_workbench").get(0).value() instanceof Block) ? (Block)p.getMetadata("shared_workbench").get(0).value() : null;
if (workbench != null && workbench.hasMetadata("shared_players") && workbench.getType() == Material.WORKBENCH)
{
@SuppressWarnings("unchecked")
List<UUID> list = (workbench.getMetadata("shared_players").get(0).value() instanceof List<?>) ? (List<UUID>)workbench.getMetadata("shared_players").get(0).value() : new ArrayList<UUID>();
list.remove(p.getUniqueId());
if (list.isEmpty())
workbench.removeMetadata("shared_players", Survival.instance);
else
workbench.setMetadata("shared_players", new FixedMetadataValue(Survival.instance, list));
}
p.removeMetadata("shared_workbench", Survival.instance);
}
示例5: addPlayers
import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void addPlayers(){
Iterator<? extends Player> ps= Bukkit.getOnlinePlayers().iterator();
while (ps.hasNext()){
Player p = (Player)ps.next();
if(worldExists(p.getWorld().getName())&&!p.hasMetadata("NPC"))
playersDatas.put(p.getUniqueId(), Utils.getPlayerData(p));
}
}
示例6: join
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void join(PlayerJoinEvent e){
Player p=e.getPlayer();
if(p.hasMetadata("NPC"))return;
if(!rs.worldExists(p.getWorld().getName()))return;
File data=new File(rs.getDataFolder()+File.separator+"PlayerDatas"+File.separator+p.getUniqueId().toString()+".yml");
if(!data.exists()){//�������ļ��Ƿ����,������������ʼ��һ���ļ�
try {data.createNewFile();} catch (IOException e1) {}
PlayerData pd=new PlayerData(p.getUniqueId(),p.getWorld().getName(), rs.getSleepMax(), rs.getThirstMax(), 0, 37, 0, rs.getPhysical_strength());
pd.savaData();
}
rs.addPlayerData(p, Utils.getPlayerData(p));
return;
}
示例7: onEnableMod
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void onEnableMod()
{
Player[] arrayOfPlayer;
int j = (arrayOfPlayer = Bukkit.getOnlinePlayers()).length;
for (int i = 0; i < j; i++)
{
Player online = arrayOfPlayer[i];
if (online.hasMetadata("ModMode"))
{
online.removeMetadata("ModMode", HCF.getInstance());
enterMod(online);
}
}
}
示例8: getTag
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static PlayerTag getTag(Player player) {
if(!player.hasMetadata(PlayerStevesBattleGrounds.PLAYER_TAG_METADATA_KEY)) return null;
return ((PlayerTagMetadata) player.getMetadata(PlayerStevesBattleGrounds.PLAYER_TAG_METADATA_KEY).get(0).value())
.tag;
}
示例9: setPlayer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void setPlayer(Player player) {
this.player = player;
if(!player.hasMetadata("id"))
player.setMetadata("id", new FixedMetadataValue(VanillaPlus.getInstance(), id));
}