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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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: Arc-v2   File: FastConsume.java   Source Code and License 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 28
Project: SkyWarsReloaded   File: ProjectileListener.java   Source Code and License 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 29
Project: uppercore   File: GuiChangeAction.java   Source Code and License 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 30
Project: ZentrelaRPG   File: ManaCommand.java   Source Code and License 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 31
Project: FactionsXL   File: FCommand.java   Source Code and License 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 32
Project: Hub   File: RadioSongPlayer.java   Source Code and License 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 33
Project: CloudNet   File: BukkitListener.java   Source Code and License 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 34
Project: SurvivalAPI   File: SurvivalPlayer.java   Source Code and License 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;
}
 
Example 35
Project: gamecraft   File: GameCommandExecutor.java   Source Code and License 5 votes vote down vote up
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
    GameCommand command = getExecutable(this.command, args);

    if (command != this.command) {
        args = trimArgs(command, args);
    }

    if (sender instanceof Player) {
        GamePlayer player = Main.getInstance().getPlayerManager().getPlayer((Player) sender);

        if (!command.hasPermission(player)) {
            player.sendMessage("");

            return true;
        }

        if (args.length < command.getMinimumArgs()) {
            player.sendMessage("command.usage");

            return true;
        }

        command.execute(player, label, args);
        return true;
    }

    if (args.length < command.getMinimumArgs()) {
        sender.sendMessage("command.usage");

        return true;
    }

    command.execute(sender, label, args);

    return true;
}
 
Example 36
Project: HCFCore   File: FactionListener.java   Source Code and License 5 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCaptureZoneEnter(CaptureZoneEnterEvent event) {
    Player player = event.getPlayer();
    if (getLastLandChangedMeta(player) > 0L)
        return; // delay before re-messaging.

    if (plugin.getUserManager().getUser(player.getUniqueId()).isCapzoneEntryAlerts()) {
        player.sendMessage(
                ChatColor.GRAY + "Now entering cap zone: " + event.getCaptureZone().getDisplayName() + ChatColor.GRAY + '(' + event.getFaction().getName() + ChatColor.GRAY + ')');
    }
}
 
Example 37
Project: UHC   File: DeathHandler.java   Source Code and License 5 votes vote down vote up
public static void serverClose(Player winner) {
    Bukkit.getServer().getOnlinePlayers().forEach(player -> player.kickPlayer(colour(
            "&e---[ Game over! ]---\n" +
            "&b" + winner.getName() + "&a has won the game\n" +
            "&bThank you for participating!"
    )));
    Bukkit.getServer().shutdown();
}
 
Example 38
Project: MT_Communication   File: PlayerManager.java   Source Code and License 5 votes vote down vote up
public void listContacts(Player player) {
	PlayerObject pObject = getPlayer(player);
	if (pObject == null)
		return;
	
	player.sendMessage(MortuusTerraChat.MTC_PREFIX + StringUtilities.color("&6Contacts:"));
	for (String contact : pObject.getContacts()) {
		player.sendMessage(StringUtilities.color("&b+ " + contact));
	}
}
 
Example 39
Project: AstralEdit   File: SelectionManager.java   Source Code and License 5 votes vote down vote up
/**
 * When an object implementing interface <code>Runnable</code> is used
 * to create a thread, starting the thread causes the object's
 * <code>run</code> method to be called in that separately executing
 * thread.
 * <p>
 * The general contract of the method <code>run</code> is that it may
 * take any action whatsoever.
 *
 * @see Thread#run()
 */
@Override
public void run() {
    for (final Player player : this.selections.keySet()) {
        final SelectionHolder selectionHolder = this.selections.get(player);
        if (selectionHolder.isAutoFollowEnabled()) {
            selectionHolder.teleport(player.getLocation());
        }
        if (selectionHolder.isAutoFollowRotateEnabled()) {
            selectionHolder.unSecureRotate(player.getLocation().getYaw());
        }
    }
}
 
Example 40
Project: Ourtown   File: SpawnGUI.java   Source Code and License 5 votes vote down vote up
public SpawnGUI(OurTown pl, Player player) {
    this.plugin = pl;
    this.player = player;
    currentSpawn = plugin.getPlayerSpawn(player);
    ArrayList<String> tmp = plugin.config.spawnConfig.getSpawns();
    if (plugin.config.gui_random) {
        Collections.shuffle(tmp);
    }
    for (int i = 0; i < tmp.size(); i++) {
        spawnPoints.put(i, tmp.get(i));
    }
}
 
Example 41
Project: ProjectAres   File: IdentityProviderImpl.java   Source Code and License 5 votes vote down vote up
@Override
public Identity currentIdentity(CommandSender player) {
    if(player instanceof Player) {
        return currentIdentity(userStore.getUser((Player) player), (Player) player);
    } else {
        return consoleIdentity;
    }
}
 
Example 42
Project: BlockBall   File: LightHologram.java   Source Code and License 5 votes vote down vote up
@Override
public void remove(Player... players) {
    final net.minecraft.server.v1_10_R1.Packet packet = new net.minecraft.server.v1_10_R1.PacketPlayOutEntityDestroy(this.entityArmorStand.getId());
    for (final Player player : players) {
        this.sendPacket(player, packet);
    }
}
 
Example 43
Project: AsgardAscension   File: RuneManager.java   Source Code and License 5 votes vote down vote up
private void handleInvisibility(Player player, Rune rune) {
	for(Player p : Bukkit.getOnlinePlayers()) {
		p.hidePlayer(player);
	}
	new BukkitRunnable() {
		public void run() {
			if(player != null && player.isOnline()) {
				finish(player, true);
			}
		}
	}.runTaskLater(plugin, 100L);
}
 
Example 44
Project: HCFCore   File: FactionListener.java   Source Code and License 5 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerLeftFaction(PlayerLeftFactionEvent event) {
    Optional<Player> optionalPlayer = event.getPlayer();
    if (optionalPlayer.isPresent()) {
        plugin.getUserManager().getUser(optionalPlayer.get().getUniqueId()).setLastFactionLeaveMillis(System.currentTimeMillis());
    }
}
 
Example 45
Project: SurvivalAPI   File: SurvivalGameLoop.java   Source Code and License 5 votes vote down vote up
/**
 * Function to display with a title that the border are reducing
 */
public void displayReducingMessage()
{
    for (Player player : Bukkit.getOnlinePlayers())
    {
        Titles.sendTitle(player, 0, 100, 5, ChatColor.RED + "Attention !", ChatColor.YELLOW + "Les bordures se réduisent !");
        player.playSound(player.getLocation(), Sound.BLAZE_DEATH, 1.0F, 1.0F);
    }

    this.game.getCoherenceMachine().getMessageManager().writeCustomMessage(ChatColor.RED + "Les bordures se réduisent !", true);
}
 
Example 46
Project: PetBlocks   File: PlayerData.java   Source Code and License 5 votes vote down vote up
/**
 * Generates the playerData from a player
 *
 * @param player player
 * @return playerData
 */
public static PlayerData from(Player player) {
    final PlayerData playerStats = new PlayerData();
    playerStats.setName(player.getName());
    playerStats.setUuid(player.getUniqueId());
    return playerStats;
}
 
Example 47
Project: AddGun   File: Animation.java   Source Code and License 5 votes vote down vote up
public Animation(Player target, Vector begin, long beginToPeak, Vector peak, long peakToEnd, Vector end) {
	this.player = target;
	this.begin = begin;
	this.beginToPeak = beginToPeak;
	this.peak = peak;
	this.peakToEnd = peakToEnd;
	this.end = end;
	computeSteps();
}
 
Example 48
Project: PetBlocks   File: PetDataListener.java   Source Code and License 5 votes vote down vote up
private boolean hasPermission(Player player, Permission groupPermission, Permission singlePermission, int slot) {
    if (!PetBlockModifyHelper.hasPermission(player, groupPermission)) {
        if (!PetBlockModifyHelper.hasPermission(player, singlePermission, String.valueOf(slot))) {
            player.sendMessage(Config.getInstance().getPrefix() + Config.getInstance().getNoPermission());
            return false;
        }
    }
    return true;
}
 
Example 49
Project: ZorahPractice   File: ScoreboardHandler.java   Source Code and License 5 votes vote down vote up
public ScoreboardHandler() {
	Bukkit.getPluginManager().registerEvents(this, PracticePlugin.getInstance());
	this.timerSidebarProvider = new ProviderResolver();

	Collection<? extends Player> players = Bukkit.getServer().getOnlinePlayers();

	for (Player player : players) {
		this.applyBoard(player).addUpdates(players);
	}
}
 
Example 50
Project: ProjectAres   File: PollCommands.java   Source Code and License 5 votes vote down vote up
@Command(
    aliases = {"next"},
    desc = "Start a poll to change the next map.",
    usage = "[map name]",
    min = 1,
    max = -1
)
@CommandPermissions("poll.next")
public static void pollNext(CommandContext args, CommandSender sender) throws CommandException {
    Player initiator = tc.oc.commons.bukkit.commands.CommandUtils.senderToPlayer(sender);
    PGMMap nextMap = CommandUtils.getMap(args.getJoinedStrings(0), sender);
    startPoll(new PollNextMap(PGM.getPollManager(), Bukkit.getServer(), initiator.getName(), PGM.getMatchManager(), nextMap));
}
 
Example 51
Project: SamaGamesAPI   File: CameraManager.java   Source Code and License 5 votes vote down vote up
/**
 * Get the camera the player is viewing into
 *
 * @param player The player
 *
 * @return The camera instance
 */
public Camera getPlayerCamera(Player player)
{
    for (Camera camera : this.cameras)
        if (camera.isPlayerViewing(player))
            return camera;

    return null;
}
 
Example 52
Project: AsgardAscension   File: PrestigeCommand.java   Source Code and License 4 votes vote down vote up
@Override
public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args) {
	if(!(sender instanceof Player)) {
		sender.sendMessage(Lang.HEADERS_CHALLENGES.toString() + Lang.COMMANDS_ONLY_PLAYER.toString());
		return true;
	}
	Player player = (Player) sender;
	
	if(args.length == 1) {
		if(args[0].equalsIgnoreCase("location")) {
			if(!sender.hasPermission("asgardascension.admin")){
				sender.sendMessage(Lang.HEADERS_MAIN.toString() + Lang.COMMANDS_NO_PERMISSION.toString());
				return true;
			}
			ConfigFile.setPrestigeLocation(Convert.locationToString(player.getLocation(), true));
			player.sendMessage(Lang.HEADERS_MAIN.toString() + Lang.PRESTIGE_SET_LOCATION.toString());
			return true;
		}
	}
	if(plugin.getPlayerManager().getPrestige(player) >= ConfigFile.getMaxPrestige()){
		player.sendMessage(Lang.HEADERS_CHALLENGES.toString()
				+ Lang.PRESTIGE_REACHED_MAX.toString());
		return true;
	}
	if(plugin.getPlayerManager().getRank(player) != plugin.getChallengesFile().getChallengesAmount()) {
		player.sendMessage(Lang.HEADERS_CHALLENGES.toString()
				+ Lang.PRESTIGE_RANK_INSUFFICIENT.toString()
					.replaceAll("%s", plugin.getChallengesFile().getTitle(plugin.getChallengesFile().getChallengesAmount())));
		return true;
	}
	if(args.length == 0){
		player.sendMessage(Lang.HEADERS_CHALLENGES.toString()
				+ Lang.PRESTIGE_READY.toString());
		return true;
	}
	if(args.length == 1){
		if(!args[0].equalsIgnoreCase("confirm")){
			player.sendMessage(Lang.HEADERS_CHALLENGES.toString()
					+ Lang.PRESTIGE_READY.toString());
			return true;
		}
		else {
			plugin.getPlayerManager().setPrestige(player, plugin.getPlayerManager().getPrestige(player) + 1, PrestigeType.SELF);
			plugin.getPlayerManager().setRank(player, 0);
			plugin.getPlayerManager().setTokens(player, plugin.getPlayerManager().getTokens(player) + ConfigFile.getTokensReward());
			player.teleport(ConfigFile.getPrestigeLocation());
			Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() + " group remove Odin");
			Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + player.getName() + " group add A");
			String comm = ConfigFile.getPrestigeCommand();
			comm = comm.replaceAll("%player", player.getName());
			Bukkit.dispatchCommand(Bukkit.getConsoleSender(), comm);
			player.sendMessage(Lang.HEADERS_CHALLENGES.toString() 
					+ Lang.PRESTIGE_ASCENDED.toString()
						.replaceAll("%d", String.valueOf(plugin.getPlayerManager().getPrestige(player))));
			if(ConfigFile.getTokensReward() > 0) {
				player.sendMessage(Lang.HEADERS_CHALLENGES.toString() 
						+ Lang.PRESTIGE_TOKEN_REWARD.toString()
							.replaceAll("%d", String.valueOf(ConfigFile.getTokensReward())));
			}
		}
		return true;
	}
	return true;
}
 
Example 53
Project: Hub   File: AbstractCommand.java   Source Code and License 4 votes vote down vote up
protected boolean hasPermission(Player player)
{
    return SamaGamesAPI.get().getPermissionsManager().hasPermission(player, this.permission);
}
 
Example 54
Project: mczone   File: Sidebar.java   Source Code and License 4 votes vote down vote up
public void add(Player p) {
	p.setScoreboard(scoreboard);
}
 
Example 55
Project: Kineticraft   File: Pictionary.java   Source Code and License 4 votes vote down vote up
private int getScore(Player p) {
    return MetadataManager.getValue(p, "dmtScore");
}
 
Example 56
Project: Kineticraft   File: GUICutsceneEditor.java   Source Code and License 4 votes vote down vote up
public GUICutsceneEditor(Player player, Cutscene c) {
    super(player, "Cutscene Editor");
    this.cutscene = c;
}
 
Example 57
Project: mczone   File: PetInstance.java   Source Code and License 4 votes vote down vote up
public Player getPlayer() {
	return Bukkit.getPlayerExact(owner);
}
 
Example 58
Project: NeverLag   File: GUISortPingHolder.java   Source Code and License 4 votes vote down vote up
public static void put(Player p, GUISortPing sortPing) {
	put(p.getName(), sortPing);
}
 
Example 59
Project: BlockBall   File: GlobalJoinCommandExecutor.java   Source Code and License 4 votes vote down vote up
@Override
public void onCommandSend(CommandSender sender, String[] args) {
    if (sender instanceof Player) {
        final Player player = (Player) sender;
        Game game;
        if ((game = this.controller.isInGameLobby(player)) != null)
            game.leave(player);
        if ((game = this.controller.getGameFromPlayer(player)) != null)
            game.leave(player);
        if (args.length >= 3) {
            String s = "";
            for (int i = 1; i < args.length; i++) {
                if (!s.isEmpty())
                    s += " ";
                s += args[i];
            }
            args = new String[]{args[0], s};
        }
        if (args.length == 2 &&
                ((tryPInt(args[0]) && (game = this.controller.getGameFromArenaId(Integer.parseInt(args[0]))) != null) ||
                        ((game = this.controller.getGameFromAlias(args[0])) != null))) {
            if (ChatColor.stripColor(game.getArena().getTeamMeta().getRedTeamName()).equalsIgnoreCase(ChatColor.stripColor(args[1]))) {
                if (game instanceof MiniGameEntity) {
                    if ((((MiniGameEntity) game)).isLobbyFull())
                        player.sendMessage(Language.PREFIX + Language.ARENA_LOBBYFULL_MESSAGE);
                    else
                        ((MiniGameEntity) game).joinLobby(player);
                } else {
                    if (!game.join(player, Team.RED)) {
                        player.sendMessage(Language.PREFIX + game.getArena().getTeamMeta().getTeamFullMessage());
                    }
                }
            } else if (ChatColor.stripColor(game.getArena().getTeamMeta().getBlueTeamName()).equalsIgnoreCase(ChatColor.stripColor(args[1]))) {
                if (game instanceof MiniGameEntity) {
                    if ((((MiniGameEntity) game)).isLobbyFull())
                        player.sendMessage(Language.PREFIX + Language.ARENA_LOBBYFULL_MESSAGE);
                    else
                        ((MiniGameEntity) game).joinLobby(player);
                } else {
                    if (!game.join(player, Team.BLUE)) {
                        player.sendMessage(Language.PREFIX + game.getArena().getTeamMeta().getTeamFullMessage());
                    }
                }
            }
        } else if (args.length == 1 && ((tryPInt(args[0]) && (game = this.controller.getGameFromArenaId(Integer.parseInt(args[0]))) != null) || ((game = this.controller.getGameFromAlias(args[0])) != null))) {
            if (game instanceof MiniGameEntity) {
                if ((((MiniGameEntity) game)).isLobbyFull())
                    player.sendMessage(Language.PREFIX + Language.ARENA_LOBBYFULL_MESSAGE);
                else
                    ((MiniGameEntity) game).joinLobby(player);
            }
        }
    }
}
 
Example 60
Project: SamaGamesAPI   File: Achievement.java   Source Code and License 4 votes vote down vote up
/**
 * Send reward message to player
 *
 * @param uuid Player
 */
protected void sendRewardMessage(UUID uuid)
{
    Bukkit.getScheduler().runTask(SamaGamesAPI.get().getPlugin(), () ->
    {
        Player player = Bukkit.getPlayer(uuid);

        if (player == null)
            return;

        Reflection.playSound(player, player.getLocation(), Reflection.PackageType.getServerVersion().equals("v1_8_R3") ? "LEVEL_UP" : "ENTITY_PLAYER_LEVELUP", 1L, 1L);

        Firework firework = player.getWorld().spawn(player.getLocation(), Firework.class);
        FireworkMeta fireworkMeta = firework.getFireworkMeta();
        fireworkMeta.setPower(2);
        fireworkMeta.addEffect(FIREWORK_EFFECT);
        firework.setFireworkMeta(fireworkMeta);

        String[] array = new String[this.description.length + 2];
        array[0] = ChatColor.AQUA + this.displayName;
        array[1] = "";

        for (int i = 0; i < this.description.length; i++)
            array[i + 2] = ChatColor.GRAY + this.description[i];

        String finalDisplayName = "";

        for (char letter : this.getDisplayName().toCharArray())
            finalDisplayName += ChatColor.AQUA + "" + letter;

        FancyMessage message = new FancyMessage(ChatColor.DARK_AQUA + "\u25A0 ")
                .then(ChatColor.AQUA + player.getName())
                .then(ChatColor.WHITE + " a débloqué l'objectif : ")
                .then(finalDisplayName)
                .tooltip(array)
                .then(ChatColor.WHITE + " ! ")
                .then(ChatColor.DARK_AQUA + "\u25A0");

        try
        {
            FancyMessage personalMessage = new FancyMessage(ChatColor.DARK_AQUA + "\u25A0 ")
                    .then(ChatColor.AQUA + player.getName())
                    .then(ChatColor.WHITE + " a débloqué l'objectif : ")
                    .then(finalDisplayName)
                    .tooltip(array)
                    .then(ChatColor.WHITE + " ! ")
                    .then(ChatColor.DARK_AQUA + "[Tweeter]")
                    .tooltip(ChatColor.AQUA + "Partager sur Twitter")
                    .link("https://twitter.com/intent/tweet?text=Je+viens+de+d%C3%A9bloquer+l%27objectif+%27" + URLEncoder.encode(this.getDisplayName(), "UTF-8") + "%27+sur+%40SamaGames_Mc+%21")
                    .then(ChatColor.DARK_AQUA + " \u25A0");

            personalMessage.send(player);
            Bukkit.getOnlinePlayers().stream().filter(p -> p.getUniqueId() != uuid).forEach(message::send);
        }
        catch (UnsupportedEncodingException e)
        {
            e.printStackTrace();
            Bukkit.getOnlinePlayers().forEach(message::send);
        }
    });
}