Java Code Examples for org.bukkit.entity.Player#setCanPickupItems()

The following examples show how to use org.bukkit.entity.Player#setCanPickupItems() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListenerLogin.java    From CombatLogX with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true)
public void onJoin(PlayerJoinEvent e) {
    Player player = e.getPlayer();
    player.setCanPickupItems(false);

    NPCManager npcManager = this.expansion.getNPCManager();
    NPC npc = npcManager.getNPC(player);
    if(npc != null) npc.despawn(DespawnReason.PLUGIN);
    
    Runnable task = () -> {
        punish(player);
        player.setCanPickupItems(true);
    };

    JavaPlugin plugin = this.expansion.getPlugin().getPlugin();
    BukkitScheduler scheduler = Bukkit.getScheduler();
    scheduler.runTaskLater(plugin, task, 1L);
}
 
Example 2
Source File: Players.java    From CardinalPGM with MIT License 4 votes vote down vote up
public static void canInteract(Player player, boolean state) {
    player.setAffectsSpawning(state);
    player.setCollidesWithEntities(state);
    player.setCanPickupItems(state);
}