Java Code Examples for org.bukkit.entity.Player

The following are top voted examples for showing how to use org.bukkit.entity.Player. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: RealSurvival   File: Utils.java   View source code 6 votes vote down vote up
/**
 * ��ȡ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;
}
 
Example 2
Project: Slimefun4-Chinese-Version   File: AutoBreeder.java   View source code 6 votes vote down vote up
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();
            }
            }
);
        }

    }
 
Example 3
Project: OpenUHC   File: InfiniteEnchanter.java   View source code 6 votes vote down vote up
/**
 * 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);
}
 
Example 4
Project: SurvivalAPI   File: LoveMachineModule.java   View source code 6 votes vote down vote up
@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);
            }
        }
    }
}
 
Example 5
Project: RPGInventory   File: InventoryAPI.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 6
Project: Hub   File: PlayerManager.java   View source code 6 votes vote down vote up
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));
        }
    });
}
 
Example 7
Project: AddGun   File: Utilities.java   View source code 6 votes vote down vote up
/**
 * 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?
	}
}
 
Example 8
Project: uppercore   File: PlayerArgumentParser.java   View source code 6 votes vote down vote up
@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());
}
 
Example 9
Project: HCFCore   File: PlayerBoard.java   View source code 6 votes vote down vote up
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);
}
 
Example 10
Project: PA   File: PlayerEvents.java   View source code 6 votes vote down vote up
@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;
    }
}
 
Example 11
Project: ZentrelaRPG   File: EditNameCommand.java   View source code 6 votes vote down vote up
@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.");
    }
}
 
Example 12
Project: DynamicAC   File: DynamicAC.java   View source code 6 votes vote down vote up
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);
}
 
Example 13
Project: PA   File: ParticleEffect.java   View source code 6 votes vote down vote up
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);
    }
}
 
Example 14
Project: Hub   File: ShopBuyableCategory.java   View source code 6 votes vote down vote up
@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;
}
 
Example 15
Project: HCFCore   File: FactionSetDeathbanMultiplierArgument.java   View source code 6 votes vote down vote up
@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;
    }
}
 
Example 16
Project: AsgardAscension   File: MainInventory.java   View source code 5 votes vote down vote up
public static void setupChallengesInventory(Player player) {
	Inventory inv = Bukkit.createInventory(player, 9, ChatColor.BOLD + "Rank-ups and Challenges");
	inv.setItem(2, ItemStackGenerator.createItem(Material.SLIME_BALL, 0, 0,
			ChatColor.RED + "" + ChatColor.BOLD + "Add Challenge", null));
	inv.setItem(4, ItemStackGenerator.createItem(Material.PAPER, 0, 0,
			ChatColor.RED + "" + ChatColor.BOLD + "Statistics", 
			Arrays.asList(ChatColor.GRAY + "Amount of Challenges: " + ChatColor.RED + plugin.getChallengesFile().getChallengesAmount())));
	inv.setItem(6, ItemStackGenerator.createItem(Material.BOOK_AND_QUILL, 0, 0,
			ChatColor.RED + "" + ChatColor.BOLD + "Edit Challenge", null));
	player.openInventory(inv);
}
 
Example 17
Project: AlphaLibary   File: FakeAPI.java   View source code 5 votes vote down vote up
public static void removeFakeEntity(Player p, FakeEntity fake) {
    List<FakeEntity> list;
    if (getFakeEntities().containsKey(p.getName())) {
        list = getFakeEntities().get(p.getName());
        list.remove(fake);
    } else {
        list = new ArrayList<>();
    }
    getFakeEntities().put(p.getName(), list);
}
 
Example 18
Project: SuperiorCraft   File: SuperiorCraft.java   View source code 5 votes vote down vote up
@EventHandler
public void onPlayerLogin(PlayerLoginEvent e) {
	Player player = e.getPlayer();
	/*if (player.getName().equals("smartzx")) {
   		e.disallow(e.getResult(), "Error 234567");
   	}*/
}
 
Example 19
Project: Hub   File: SongPlayer.java   View source code 5 votes vote down vote up
public void addPlayer(Player p) {
    synchronized (this) {
        if (!playerList.contains(p.getName())) {
            playerList.add(p.getName());
            List<SongPlayer> songs = NoteBlockPlayerMain.playingSongs.get(p.getName());
            if (songs == null) {
                songs = new ArrayList<>();
            }
            songs.add(this);
            NoteBlockPlayerMain.playingSongs.put(p.getName(), songs);
        }
    }
}
 
Example 20
Project: RankVouchers   File: UserManager.java   View source code 5 votes vote down vote up
public static UserManager getConfig(Player p) {
    for (UserManager c : configs) {
           if (c.getOwnerUUID().equals(p.getUniqueId())) {
               return c;
            }
    }
    return new UserManager(p);
}
 
Example 21
Project: ProjectAres   File: ResourcePackListener.java   View source code 5 votes vote down vote up
@Override
public void refreshPlayer(final Player player) {
    if(!enabled) return;
    if(!player.isOnline()) return;

    String url = getUrl();
    String sha1 = getSha1();
    if(url == null || sha1 == null) return;

    if(!Objects.equals(lastSentSha1.get(player), sha1)) {
        Instant joined = joinTime.get(player);
        if(joined == null) return;
        long delayMillis = Duration.between(Instant.now(), joined.plus(JOIN_DELAY)).toMillis();

        if(delayMillis <= 0) {
            logger.fine("Sending resource pack " + url + " with SHA1 " + sha1 + " to player " + player.getName());
            lastSentSha1.put(player, sha1);
            player.setResourcePack(url, sha1);
        } else {
            plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
                @Override
                public void run() {
                    refreshPlayer(player);
                }
            }, delayMillis / 50 + 1);
        }
    }
}
 
Example 22
Project: HCFCore   File: ToggleLightningCommand.java   View source code 5 votes vote down vote up
@Override
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            if (!(sender instanceof Player)) {
                sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
                return true;
            }

            FactionUser factionUser = plugin.getUserManager().getUser(((Player) sender).getUniqueId());
            boolean newShowLightning = !factionUser.isShowLightning();
            factionUser.setShowLightning(newShowLightning);

            sender.sendMessage(ChatColor.YELLOW + "You will now " + (newShowLightning ? ChatColor.GREEN + "able" : ChatColor.RED + "unable") + ChatColor.YELLOW + " to see lightning strikes on a players death.");

    return true;
}
 
Example 23
Project: Slimefun4-Chinese-Version   File: Research.java   View source code 5 votes vote down vote up
public boolean canUnlock(Player p)
{
    if(!enabled)
        return true;
    if(!SlimefunStartup.getResearchCfg().getBoolean((new StringBuilder(String.valueOf(id))).append(".enabled").toString()))
        return true;
    return p.getGameMode() == GameMode.CREATIVE && creative_research || p.getLevel() >= cost;
}
 
Example 24
Project: HCFCore   File: PlayerFaction.java   View source code 5 votes vote down vote up
/**
 * Sends an array of messages to all online {@link FactionMember}s ignoring those selected in the var-args.
 *
 * @param messages
 *            the message to send
 * @param ignore
 *            the {@link FactionMember} with {@link UUID}s not to send message to
 */
public void broadcast(String[] messages, UUID... ignore) {
    Preconditions.checkNotNull(messages, "Messages cannot be null");
    Preconditions.checkArgument(messages.length > 0, "Message array cannot be empty");
    Collection<Player> players = getOnlinePlayers();
    Collection<UUID> ignores = ignore.length == 0 ? Collections.emptySet() : Sets.newHashSet(ignore);
    for (Player player : players) {
        if (!ignores.contains(player.getUniqueId())) {
            player.sendMessage(messages);
        }
    }
}
 
Example 25
Project: AlphaLibary   File: MobFakeUtil.java   View source code 5 votes vote down vote up
/**
 * Sets a new name for the {@link FakeMob} for the {@link Player}
 *
 * @param p    the {@link Player} to see the new name of the {@link FakeMob}
 * @param name the actual new name of the {@link FakeMob}
 * @param mob  the {@link FakeMob} to change the name for
 */
public static void setMobname(Player p, String name, FakeMob mob) {
    EntityWrapper e = new EntityWrapper(mob.getNmsEntity());

    e.setCustomName(name.replace("&", "§").replace("_", " "));
    e.setCustomNameVisible(true);

    ReflectionUtil.sendPacket(p, new PPOEntityMetadata(e.getEntityID(), e.getDataWatcher()));
}
 
Example 26
Project: HCFCore   File: VisualiseHandler.java   View source code 5 votes vote down vote up
public LinkedHashMap<Location, VisualBlockData> generate(Player player, Cuboid cuboid, VisualType visualType, boolean canOverwrite) {
    Collection<Location> locations = new HashSet<>(cuboid.getSizeX() * cuboid.getSizeY() * cuboid.getSizeZ());
    Iterator<Location> iterator = cuboid.locationIterator();
    while (iterator.hasNext()) {
        locations.add(iterator.next());
    }

    return this.generate(player, locations, visualType, canOverwrite);
}
 
Example 27
Project: AsgardAscension   File: MainInventory.java   View source code 5 votes vote down vote up
public static void setupChallengesChoseMenu(Player player) {
	Inventory inv = Bukkit.createInventory(player, 9, ChatColor.BOLD + "Challenge type");
	inv.setItem(2, ItemStackGenerator.createItem(Material.GOLD_BOOTS, 0, 0, ChatColor.GRAY + "" + ChatColor.BOLD + "Parkour", null, true));
	inv.setItem(4, ItemStackGenerator.createItem(Material.TORCH, 0, 0, ChatColor.GRAY + "" + ChatColor.BOLD + "Maze", null, true));
	inv.setItem(6, ItemStackGenerator.createItem(Material.GOLD_SWORD, 0, 0, ChatColor.GRAY + "" + ChatColor.BOLD + "Fight", null, true));
	player.openInventory(inv);
}
 
Example 28
Project: ProjectAres   File: TicketDisplay.java   View source code 5 votes vote down vote up
@HandleModel
public void ticketUpdated(@Nullable Ticket before, @Nullable Ticket after, Ticket latest) {
    final Arena arena = arenas.byId(latest.arena_id());
    updateArena(arena);

    final Player player = userStore.find(latest.user());
    if(player != null) {
        final BossBar bar = bars.getUnchecked(arena);
        if(after != null && after.server_id() == null) {
            bar.addPlayer(player);
        } else {
            bar.removePlayer(player);
        }
    }
}
 
Example 29
Project: Warzone   File: InfectionModule.java   View source code 5 votes vote down vote up
public void unfreeze(Player player) {
    player.removePotionEffect(PotionEffectType.JUMP);
    player.removePotionEffect(PotionEffectType.SLOW);
    player.removePotionEffect(PotionEffectType.BLINDNESS);

    player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 50000, 1, true, false));
}
 
Example 30
Project: ZentrelaRPG   File: MisakaCommand.java   View source code 5 votes vote down vote up
@Override
public void execute(CommandSender sender, String[] args) {
    StringBuilder sb = new StringBuilder("");
    for (String s : args) {
        sb.append(s + " ");
    }
    String message = ChatColor.translateAlternateColorCodes('&', sb.toString().trim());
    for (Player p2 : plugin.getServer().getOnlinePlayers()) {
        p2.sendMessage(message);
    }
}
 
Example 31
Project: HCFCore   File: FactionSubclaimListArgument.java   View source code 5 votes vote down vote up
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (!(sender instanceof Player)) {
        sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
        return true;
    }

    Player player = (Player) sender;
    PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);

    if (playerFaction == null) {
        sender.sendMessage(ChatColor.RED + "You are not in a faction.");
        return true;
    }

    List<String> subclaimNames = new ArrayList<>();
    for (Claim claim : playerFaction.getClaims()) {
        subclaimNames.addAll(claim.getSubclaims().stream().map(Subclaim::getName).collect(Collectors.toList()));
    }

    if (subclaimNames.isEmpty()) {
        sender.sendMessage(ChatColor.RED + "Your faction does not own any subclaims.");
        return true;
    }

    sender.sendMessage(ChatColor.YELLOW + "Factions' Subclaims (" + subclaimNames.size() + "): " + ChatColor.AQUA + StringUtils.join(subclaimNames, ", "));
    return true;
}
 
Example 32
Project: Arc-v2   File: FastConsume.java   View source code 5 votes vote down vote up
public boolean check(Player player, InventoryData data) {

        long now = System.currentTimeMillis();
        long last = data.getConsumeTime();
        long total = now - last;

        // check if the time it took to consume the item is less than allowed.
        return total < consumeTime && checkViolation(player, "consume time less than allowed.");
    }
 
Example 33
Project: HCFCore   File: BlockHitFixListener.java   View source code 5 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onEntityDamageByEntity(EntityDamageEvent event) {
    Player attacker = BukkitUtils.getFinalAttacker(event, true);
    if (attacker != null) {
        Long lastInteractTime = lastInteractTimes.get(attacker.getUniqueId());
        if (lastInteractTime != null && lastInteractTime - System.currentTimeMillis() > 0L) {
            event.setCancelled(true);
        }
    }
}
 
Example 34
Project: SkyWarsReloaded   File: ProjectileListener.java   View source code 5 votes vote down vote up
@EventHandler
public void projectileLaunch(ProjectileLaunchEvent e) {
	 Projectile projectile = e.getEntity();
	 if (projectile instanceof Snowball || projectile instanceof Egg || projectile instanceof Arrow) {
		 if (projectile.getShooter() instanceof Player) {
			 GamePlayer shooter = SkyWarsReloaded.getPC().getPlayer(((Player) projectile.getShooter()).getUniqueId());
			 String effect = shooter.getProjEffect();
			 if (effect != null) {
				 if (!effect.equalsIgnoreCase("normal") && shooter.inGame()) {
					 SkyWarsReloaded.getProjC().addProjectile(projectile, shooter.getProjEffect());
				 }
			 }
		 }
	 }
}
 
Example 35
Project: uppercore   File: GuiChangeAction.java   View source code 5 votes vote down vote up
@Override
public void run(Player player) {
    String guiId = this.guiId.resolve(player);
    GuiId gui = guis().get(guiId);
    if (gui == null) {
        Uppercore.logger().severe("Cannot find gui \"" + guiId + "\"");
        return;
    }
    guis().change(player, gui.get());
}
 
Example 36
Project: ZentrelaRPG   File: ManaCommand.java   View source code 5 votes vote down vote up
@Override
public void executePlayer(Player p, PlayerDataRPG pd, String[] args) {
    if (infMana.contains(p.getName())) {
        p.sendMessage("you have mana costs now noob");
        infMana.remove(p.getName());
    } else {
        p.sendMessage("infinite mana op!!");
        pd.mana = 10;
        infMana.add(p.getName());
    }
}
 
Example 37
Project: FactionsXL   File: FCommand.java   View source code 5 votes vote down vote up
public FPlayer getFSenderOrFromArg(CommandSender sender, String[] args, int index) {
    FPlayer fSender = null;
    if (args.length > index) {
        fSender = plugin.getFPlayerCache().getByName(args[index]);
        if (fSender == null) {
            ParsingUtil.sendMessage(sender, FMessage.ERROR_NO_SUCH_PLAYER.getMessage(), args[index]);
        }
    } else if (sender instanceof Player) {
        fSender = plugin.getFPlayerCache().getByPlayer((Player) sender);
    } else {
        ParsingUtil.sendMessage(sender, FMessage.ERROR_SPECIFY_PLAYER.getMessage());
    }
    return fSender;
}
 
Example 38
Project: Hub   File: RadioSongPlayer.java   View source code 5 votes vote down vote up
@Override
public void playTick(Player p, int tick) {
    byte playerVolume = NoteBlockPlayerMain.getPlayerVolume(p);

    for (Layer l : song.getLayerHashMap().values()) {
        Note note = l.getNote(tick);
        if (note == null) {
            continue;
        }
        p.playSound(p.getLocation(),
                Instrument.getInstrument(note.getInstrument()),
                (l.getVolume() * (int) volume * (int) playerVolume) / 1000000f,
                NotePitch.getPitch(note.getKey() - 33));
    }
}
 
Example 39
Project: CloudNet   File: BukkitListener.java   View source code 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST)
public void handle0(AsyncPlayerPreLoginEvent e)
{
    for(Player all : Bukkit.getOnlinePlayers())
        if(all.getUniqueId().equals(e.getUniqueId()))
            e.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, "§cYou have to connect from a internal proxy server!");
}
 
Example 40
Project: SurvivalAPI   File: SurvivalPlayer.java   View source code 5 votes vote down vote up
/**
 * Constructor
 *
 * @param player Parent player
 */
public SurvivalPlayer(Player player)
{
    super(player);

    this.kills = new ArrayList<>();
    this.damageReporter = new DamageReporter(player.getUniqueId());
    this.team = null;
    this.waitingspawn = null;
}