本文整理汇总了Java中org.bukkit.entity.Player类的典型用法代码示例。如果您正苦于以下问题:Java Player类的具体用法?Java Player怎么用?Java Player使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Player类属于org.bukkit.entity包,在下文中一共展示了Player类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPlayerData
import org.bukkit.entity.Player; //导入依赖的package包/类
/**
* ��ȡPlayerData
* @param rs ����·��
* @param p Player����
* @return PlayerData����
*/
public static PlayerData getPlayerData(Player p){
File data=new File(rs.getDataFolder()+File.separator+"PlayerDatas"+File.separator+p.getUniqueId().toString()+".yml");
PlayerData pd;
if(!data.exists()){
try {data.createNewFile();} catch (IOException e) {}
pd=new PlayerData(p.getUniqueId(),p.getWorld().getName(), rs.getSleepMax(),
rs.getThirstMax(), 0, 37,0, rs.getPhysical_strength());
return pd;
}
YamlConfiguration dataC=YamlConfiguration.loadConfiguration(data);
HashMap<String,Object[]> sickKind=new HashMap<String,Object[]>();
for(String temp:dataC.getStringList("rSickKind")){
List<String> l=dataC.getStringList("sickKind."+temp);
sickKind.put(temp,new Object[]{l.get(0),l.get(1),l.get(2),l.get(3)} );
}
pd=new PlayerData( p.getUniqueId(),dataC.getString("world"), dataC.getDouble("sleep"),
dataC.getDouble("thirst"), dataC.getDouble("temperature"), dataC.getDouble("weight"),
dataC.getDouble("physical_strength"),dataC.getBoolean("sick"),
dataC.getBoolean("isSleep"),Byte.parseByte(dataC.getString("light")),sickKind);
return pd;
}
示例2: constructMenu
import org.bukkit.entity.Player; //导入依赖的package包/类
protected void constructMenu(BlockMenuPreset preset)
{
int ai[];
int k = (ai = border).length;
for(int j = 0; j < k; j++)
{
int i = ai[j];
preset.addItem(i, new CustomItem(new MaterialData(Material.STAINED_GLASS_PANE, (byte)9), " ", new String[0]), new me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler() {
final AutoBreeder this$0;
public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction clickaction)
{
return false;
}
{
this$0 = AutoBreeder.this;
super();
}
}
);
}
}
示例3: onPlayerInit
import org.bukkit.entity.Player; //导入依赖的package包/类
/**
* Gives players the resources necessary to enchant when they start playing in the game.
*
* @param event The event
*/
@EventHandler
public void onPlayerInit(PlayerInitEvent event) {
Player player = event.getPlayer();
Inventory inventory = player.getInventory();
inventory.addItem(
new ItemStack(Material.ENCHANTMENT_TABLE, 64),
new ItemStack(Material.BOOKSHELF, 64),
new ItemStack(Material.BOOKSHELF, 64),
new ItemStack(Material.LAPIS_BLOCK, 64)
);
if (anvils) {
inventory.addItem(new ItemStack(Material.ANVIL, 64));
}
player.setLevel(30);
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1);
}
示例4: run
import org.bukkit.entity.Player; //导入依赖的package包/类
@Override
public void run()
{
for (Pair<UUID, UUID> entry : couples)
{
Player playerA;
Player playerB;
if ((playerA = this.plugin.getServer().getPlayer(entry.getLeft())) != null
&& (playerB = this.plugin.getServer().getPlayer(entry.getRight())) != null)
{
for (Player player : this.plugin.getServer().getOnlinePlayers())
{
ParticleEffect.HEART.display(1.5F, 1.5F, 1.5F, 0.5F, 3, playerA.getLocation(), player);
ParticleEffect.HEART.display(1.5F, 1.5F, 1.5F, 0.5F, 3, playerB.getLocation(), player);
}
}
}
}
示例5: getActiveItems
import org.bukkit.entity.Player; //导入依赖的package包/类
/**
* Get all active item from RPGInventory of specific player
*
* @param player - the player
* @return List of not null active item
*/
@NotNull
public static List<ItemStack> getActiveItems(Player player) {
List<ItemStack> activeItems = new ArrayList<>();
if (!InventoryManager.playerIsLoaded(player)) {
return activeItems;
}
Inventory inventory = InventoryManager.get(player).getInventory();
for (Slot slot : SlotManager.instance().getActiveSlots()) {
ItemStack item = inventory.getItem(slot.getSlotId());
if (!ItemUtils.isEmpty(item) && !InventoryManager.isQuickEmptySlot(item)) {
activeItems.add(item);
}
}
return activeItems;
}
示例6: updateHiders
import org.bukkit.entity.Player; //导入依赖的package包/类
private void updateHiders(Player newConnected)
{
this.hub.getServer().getScheduler().runTaskAsynchronously(this.hub, () ->
{
List<UUID> hidersUUIDList = new ArrayList<>();
hidersUUIDList.addAll(this.hiders);
for (UUID hiderUUID : hidersUUIDList)
{
Player hider = this.hub.getServer().getPlayer(hiderUUID);
if (hider != null && !hider.equals(newConnected))
if (!SamaGamesAPI.get().getPermissionsManager().hasPermission(newConnected, "hub.announce") && !SamaGamesAPI.get().getFriendsManager().areFriends(newConnected.getUniqueId(), hiderUUID))
this.hub.getServer().getScheduler().runTask(this.hub, () -> hider.hidePlayer(newConnected));
}
});
}
示例7: computeTotalXP
import org.bukkit.entity.Player; //导入依赖的package包/类
/**
* Originally adapted from 1.8 computation TODO: doublecheck still valid.
*
* @param e The entity whose current XP to compute
* @return the number of XP in hotbar right now.
*/
public static int computeTotalXP(LivingEntity e) {
if (e instanceof Player) {
Player p = (Player) e;
float cLevel = (float) p.getLevel();
float progress = p.getExp();
float a = 1f, b = 6f, c = 0f, x = 2f, y = 7f;
if (cLevel > 16 && cLevel <= 31) {
a = 2.5f; b = -40.5f; c = 360f; x = 5f; y = -38f;
} else if (cLevel >= 32) {
a = 4.5f; b = -162.5f; c = 2220f; x = 9f; y = -158f;
}
return (int) Math.floor(a * cLevel * cLevel + b * cLevel + c + progress * (x * cLevel + y));
} else {
return 0; //TODO perhaps some fixed amount?
}
}
示例8: onTabCompletion
import org.bukkit.entity.Player; //导入依赖的package包/类
@Override
public List<String> onTabCompletion(CommandSender sender, Class<?> type, List<String> args) {
Stream<? extends Player> players = Bukkit.getOnlinePlayers().stream();
if(sender instanceof Player) {
Player player = (Player) sender;
players = players.filter(player::canSee);
}
Stream<String> strStream = players.map(Player::getName);
if(args.isEmpty())
return strStream.collect(Collectors.toList());
String partial = args.get(0);
return strStream
.filter(s -> StringUtil.startsWithIgnoreCase(s, partial))
.sorted(String.CASE_INSENSITIVE_ORDER)
.collect(Collectors.toList());
}
示例9: PlayerBoard
import org.bukkit.entity.Player; //导入依赖的package包/类
public PlayerBoard(final HCF plugin, final Player player) {
this.sidebarVisible = false;
this.removed = new AtomicBoolean(false);
this.plugin = plugin;
this.player = player;
this.scoreboard = plugin.getServer().getScoreboardManager().getNewScoreboard();
this.bufferedObjective = new BufferedObjective(this.scoreboard);
(this.members = this.scoreboard.registerNewTeam("members")).setPrefix(SettingsYML.TEAMMATE_COLOUR.toString());
this.members.setCanSeeFriendlyInvisibles(true);
(this.neutrals = this.scoreboard.registerNewTeam("neutrals")).setPrefix(SettingsYML.ENEMY_COLOUR.toString());
(this.archers = this.scoreboard.registerNewTeam("archers")).setPrefix(ChatColor.DARK_RED.toString());
(this.allies = this.scoreboard.registerNewTeam("enemies")).setPrefix(SettingsYML.ALLY_COLOUR.toString());
this.focused = this.scoreboard.registerNewTeam("focused");
this.focused.setPrefix(ChatColor.LIGHT_PURPLE.toString());
player.setScoreboard(this.scoreboard);
}
示例10: onDamage
import org.bukkit.entity.Player; //导入依赖的package包/类
@EventHandler
public void onDamage(EntityDamageEvent e){
if(!(e.getEntity() instanceof Player)) return;
Player p = (Player) e.getEntity();
if (plugin.getGm().isInLobby()) e.setCancelled(true);
switch (e.getCause()) {
case LAVA:
e.setCancelled(true);
p.teleport(plugin.getAm().getRandomSpawn());
//RageGames.getPlayer(p).resetPlayer();
p.setHealth(20d);
p.setFireTicks(0);
break;
case FALL:
e.setCancelled(true);
break;
}
}
示例11: executePlayer
import org.bukkit.entity.Player; //导入依赖的package包/类
@Override
public void executePlayer(Player p, PlayerDataRPG pd, String[] args) {
ItemStack item = p.getInventory().getItemInMainHand();
if (item.hasItemMeta()) {
ItemMeta im = item.getItemMeta();
StringBuilder sb = new StringBuilder();
for (int k = 1; k < args.length; k++) {
sb.append(args[k]);
sb.append(' ');
}
String name = ChatColor.translateAlternateColorCodes('&', sb.toString().trim());
im.setDisplayName(name);
item.setItemMeta(im);
p.sendMessage("Updated item.");
}
}
示例12: cpsCheck
import org.bukkit.entity.Player; //导入依赖的package包/类
public void cpsCheck(Player player) {
cpsChecking.put(player, new AtomicInteger(0));
Bukkit.getScheduler().runTaskLater(instance, new Runnable() {
@Override
public void run() {
AtomicInteger integer = cpsChecking.containsKey(player) ? cpsChecking.get(player) : new AtomicInteger
(0);
if(integer.intValue() > 15) {
for(Player staff : onlinestaff) {
staff.sendMessage(ChatColor.RED + player.getName() + " might be using Autoclicker or " +
"Triggerbot(" + integer.intValue() + " CPS)");
}
}
cpsChecking.remove(player);
}
}, 200L);
}
示例13: send_1_7
import org.bukkit.entity.Player; //导入依赖的package包/类
void send_1_7(String name, Collection<? extends Player> receivers, double x, double y, double z, double offsetX, double offsetY, double offsetZ, double speed, int count) throws Exception {
Object packet = PacketParticleConstructorResolver.resolve(new Class[]{
String.class,
float.class,
float.class,
float.class,
float.class,
float.class,
float.class,
float.class,
int.class}).newInstance(//
name,//Particle name
(float) x,//X
(float) y,//Y
(float) z, //Z
(float) offsetX,//X
(float) offsetY,//Y
(float) offsetZ,//Z
(float) speed,//Speed
count//Count
);
for (Player receiver : receivers) {
sendPacket(packet, receiver);
}
}
示例14: getFormattedIcon
import org.bukkit.entity.Player; //导入依赖的package包/类
@Override
public ItemStack getFormattedIcon(Player player)
{
ItemStack stack = getIcon().clone();
ItemMeta meta = stack.getItemMeta();
List<String> lore = meta.getLore() != null ? meta.getLore() : new ArrayList<>();
if (isOwned(player))
lore.add(ChatColor.GREEN + "Objet possédé");
else
lore.add(ChatColor.GRAY + "Prix : " + ChatColor.GOLD + this.itemDescription.getPriceCoins() + " pièces");
meta.setLore(lore);
stack.setItemMeta(meta);
return stack;
}
示例15: onTabComplete
import org.bukkit.entity.Player; //导入依赖的package包/类
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if (args.length != 2) {
return Collections.emptyList();
} else if (args[1].isEmpty()) {
return null;
} else {
List<String> results = new ArrayList<>(plugin.getFactionManager().getFactionNameMap().keySet());
Player senderPlayer = sender instanceof Player ? ((Player) sender) : null;
for (Player player : Bukkit.getOnlinePlayers()) {
// Make sure the player can see.
if (senderPlayer == null || senderPlayer.canSee(player)) {
results.add(player.getName());
}
}
return results;
}
}