本文整理汇总了Java中org.bukkit.Material.COMPASS属性的典型用法代码示例。如果您正苦于以下问题:Java Material.COMPASS属性的具体用法?Java Material.COMPASS怎么用?Java Material.COMPASS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.Material
的用法示例。
在下文中一共展示了Material.COMPASS属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Compass
@EventHandler
public void Compass(PlayerInteractEvent event) {
if (event.getItem() != null && event.getItem().getType() != Material.AIR && event.getItem().getType()==Material.COMPASS) {
Player p = event.getPlayer();
for (int i = 0; i < 500; i+=20) {
List<Entity> entities = p.getNearbyEntities(i, 256, i);
for (Entity e : entities) {
if (e instanceof Player) {
Player found = (Player) e;
if (Team.getTeam(p)!=Team.getTeam(found)) {
Chat.player(p, "&aCompass now points towards " + found.getDisplayName() + "&a!");
p.setCompassTarget(e.getLocation());
return;
}
}
}
}
Chat.player(p, "&cNo enemy players found near you!");
}
}
示例2: onCompassClick
@EventHandler
public void onCompassClick(PlayerInteractEvent event) {
if (event.getItem() == null || event.getItem().getType() != Material.COMPASS)
return;
Player p = event.getPlayer();
ItemStack stack = event.getItem();
if (stack.getItemMeta().hasDisplayName()) {
String display = Chat.stripColor(stack.getItemMeta().getDisplayName());
if (display.equalsIgnoreCase("game picker")) {
Inventory inv = Bukkit.getServer().createInventory(p, 9, Chat.colors("&oMC Zone Games"));
for (int i = 1; i < 12; i++) {
int number = i - 1;
if (i > GameIcon.getList().size())
break;
inv.setItem(i, GameIcon.getList().get(number).getItemStack());
}
p.openInventory(inv);
}
}
}
示例3: onJoin
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player player = e.getPlayer();
player.setPlayerListName(ChatColor.LIGHT_PURPLE + getConfig().getString("players." + player.getName() + ".name") + ChatColor.DARK_AQUA + getConfig().getString("players." + player.getName() + ".suffix"));
AntiCheat.data.add(new PlayerData(player));
//player.kickPlayer("Get out of here!");
if (!getConfig().getString("players." + player.getName() + ".cloaked").equals("yes")) {
if (!player.isOp()) {
e.setJoinMessage(ChatColor.LIGHT_PURPLE + player.getName() + ChatColor.GREEN + " has joined the game");
}
else if (player.isOp()) {
e.setJoinMessage(ChatColor.LIGHT_PURPLE + getConfig().getString("players." + e.getPlayer().getName() + ".name") + ChatColor.DARK_AQUA + getConfig().getString("players." + e.getPlayer().getName() + ".suffix") + ChatColor.GREEN + "joined the game");
}
}
else {
e.setJoinMessage(null);
}
for (Player ps : cloaked) {
player.hidePlayer(ps);
}
if (getConfig().getString("players." + player.getName() + ".cloaked").equals("yes")) {
cloaked.add(player);
}
ItemStack gs = new ItemStack(Material.COMPASS, 1);
ItemMeta gsm = gs.getItemMeta();
gsm.setDisplayName("&f&lGame Selector".replace('&', '�'));
gs.setItemMeta(gsm);
e.getPlayer().getInventory().setItem(8, gs);
}
示例4: onCompassUse
@EventHandler
public void onCompassUse(PlayerInteractEvent event) {
Player p = event.getPlayer();
if (event.getItem() != null && event.getItem().getType() == Material.COMPASS) {
Boolean found = false;
for (int i = 0; i < 5000; i += 25) {
List<Entity> entities = p.getNearbyEntities(i, 256, i);
for (Entity e : entities) {
if (!(e instanceof Player))
continue;
Player t = (Player) e;
if (Gamer.get(t.getName()).isInvisible())
continue;
p.setCompassTarget(e.getLocation());
Chat.player(p, "&2[SG] &aCompass points to &7" + ((Player) e).getDisplayName() + "&a!");
found = true;
break;
}
if (found)
break;
}
if (!found) {
Chat.player(p, "&cNo players in range. Compass points to spawn location.");
Gamer g = Gamer.get(p.getName());
p.setCompassTarget(g.getLocation("spawn-block"));
}
}
}
示例5: LobbySelectorItem
public LobbySelectorItem() {
super("选择大厅",45 ,Material.COMPASS, item.getItemMeta(),2);
// TODO Auto-generated constructor stub
}
示例6: doInteraction
public void doInteraction(Player player, ItemStack stack)
{
if (stack.getType() == Material.COMPASS)
{
this.hub.getGuiManager().openGui(player, new GuiMain(this.hub));
}
else if (stack.getType() == Material.SKULL_ITEM)
{
this.hub.getGuiManager().openGui(player, new GuiProfile(this.hub));
}
else if (stack.getType() == Material.ENDER_CHEST)
{
this.hub.getGuiManager().openGui(player, new GuiCosmetics(this.hub));
}
else if (stack.getType() == Material.GOLD_INGOT)
{
this.hub.getGuiManager().openGui(player, new GuiShop(this.hub));
}
else if (stack.getType() == Material.BARRIER && this.hub.getParkourManager().getPlayerParkour(player.getUniqueId()) != null)
{
this.hub.getParkourManager().getPlayerParkour(player.getUniqueId()).quitPlayer(player);
}
else if (stack.getType() == Material.ENDER_PEARL && this.hub.getParkourManager().getPlayerParkour(player.getUniqueId()) != null)
{
this.hub.getParkourManager().getPlayerParkour(player.getUniqueId()).failPlayer(player);
}
else if (player.getInventory().getHeldItemSlot() == 6)
{
this.hub.getServer().getScheduler().runTask(this.hub, () -> this.hub.getCosmeticManager().getGadgetManager().useSelectedCosmetic(player, stack));
}
else if (stack.getType() == Material.ELYTRA)
{
if (stack.getEnchantments().isEmpty())
{
ItemStack elytra = new ItemStack(Material.ELYTRA);
ItemMeta meta = elytra.getItemMeta();
meta.spigot().setUnbreakable(true);
elytra.setItemMeta(meta);
player.getInventory().setChestplate(elytra);
this.setInventoryToPlayer(player);
}
else
{
player.getInventory().setChestplate(null);
this.setInventoryToPlayer(player);
}
player.playSound(player.getLocation(), Sound.ENTITY_HORSE_SADDLE, 1F, 1F);
}
else if (stack.getType() == Material.FEATHER && player.isGliding() && player.getVelocity().lengthSquared() != 0)
{
if (!SamaGamesAPI.get().getPermissionsManager().hasPermission(player, "network.vip"))
{
player.sendMessage(ChatColor.RED + "Devenez VIP pour utiliser le booster.");
return;
}
Vector velocity = player.getVelocity().add(player.getLocation().getDirection().normalize().multiply(1.5D));
((CraftPlayer)player).getHandle().motX = velocity.getX();
((CraftPlayer)player).getHandle().motY = velocity.getY();
((CraftPlayer)player).getHandle().motZ = velocity.getZ();
((CraftPlayer)player).getHandle().velocityChanged = true;
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ENDERDRAGON_FLAP, 2F, 2F);
this.hub.getServer().getScheduler().runTask(this.hub, () -> SamaGamesAPI.get().getAchievementManager().getAchievementByID(5).unlock(player.getUniqueId()));
}
}
示例7: onCompassClick
@EventHandler
public void onCompassClick(PlayerInteractEvent evt) {
if (evt.getItem() != null && evt.getItem().getType() == Material.COMPASS)
pickCompass(evt.getPlayer());
}
示例8: modItems
public static void modItems(Player p)
{
Inventory inv = p.getInventory();
inv.clear();
ItemStack modCompass = new ItemStack(Material.COMPASS);
ItemStack modBook = new ItemStack(Material.BOOK);
ItemStack modFreeze = new ItemStack(Material.PACKED_ICE);
ItemStack modTp = new ItemStack(Material.EYE_OF_ENDER);
ItemStack modVanish = new ItemStack(Material.FEATHER);
ItemMeta compassMeta = modCompass.getItemMeta();
ItemMeta bookMeta = modBook.getItemMeta();
ItemMeta freezeMeta = modFreeze.getItemMeta();
ItemMeta tpMeta = modTp.getItemMeta();
ItemMeta vanishMeta = modVanish.getItemMeta();
compassMeta.setDisplayName("§cWhoosh");
bookMeta.setDisplayName("§cInspect Player");
freezeMeta.setDisplayName("§cFreeze Player");
vanishMeta.setDisplayName("§cToggle Vanish");
tpMeta.setDisplayName("§cRandom Teleporter");
ArrayList<String> modCompassLore = new ArrayList();
ArrayList<String> modBookLore = new ArrayList();
ArrayList<String> modFreezeLore = new ArrayList();
ArrayList<String> modVanishLore = new ArrayList();
ArrayList<String> modTpLore = new ArrayList();
modCompassLore.add("§7Used to teleport to eye location.");
modBookLore.add("§7Used to inspect a players inventory.");
modFreezeLore.add("§7Used to freeze a player.");
modVanishLore.add("§7Used to toggle vanish.");
modTpLore.add("§7Used to teleport to a random player.");
compassMeta.setLore(modCompassLore);
bookMeta.setLore(modBookLore);
freezeMeta.setLore(modFreezeLore);
vanishMeta.setLore(modVanishLore);
tpMeta.setLore(modTpLore);
modCompass.setItemMeta(compassMeta);
modBook.setItemMeta(bookMeta);
modFreeze.setItemMeta(freezeMeta);
modTp.setItemMeta(tpMeta);
modVanish.setItemMeta(vanishMeta);
inv.setItem(0, modCompass);
inv.setItem(3, modVanish);
inv.setItem(4, modBook);
inv.setItem(5, modFreeze);
inv.setItem(8, modTp);
}