Package org.bukkit.craftbukkit.v1_7_R4.entity

Examples of org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer


        World world = interactLocation.getWorld();
        boolean currentState = (interactLocation.getBlock().getData() & 0x8) > 0;
        String state = switchState.toString();

        // Try for a linked player
        CraftPlayer craftPlayer = (CraftPlayer) player;
        if (craftPlayer == null && Bukkit.getOnlinePlayers().size() > 0) {
            // If there's none, link any player
            if (Bukkit.getOnlinePlayers().size() > 0) {
                craftPlayer = (CraftPlayer) Bukkit.getOnlinePlayers().toArray()[0];
            }
            else if (Depends.citizens != null) {
                // If there are no players, link any Human NPC
                for (NPC npc: CitizensAPI.getNPCRegistry()) {
                    if (npc.isSpawned() && npc.getEntity() instanceof Player) {
                        craftPlayer = (CraftPlayer) npc.getEntity();
                        break;
                    }
                }
                // TODO: backup if no human NPC available? (Fake EntityPlayer instance?)
            }
        }

        if ((state.equals("ON") && !currentState) ||
            (state.equals("OFF") && currentState) ||
             state.equals("TOGGLE")) {

            try {
                if (interactLocation.getBlock().getType() == Material.IRON_DOOR_BLOCK) {
                    Location block;
                    if (interactLocation.clone().add(0, -1, 0).getBlock().getType() == Material.IRON_DOOR_BLOCK)
                        block = interactLocation.clone().add(0, -1, 0);
                    else
                        block = interactLocation;
                    block.getBlock().setData((byte) (block.getBlock().getData() ^ 4));
                }
                else {

                    // TODO: Rewrite the below code to not use freakin' NMS!
                    Block.getById(interactLocation.getBlock().getType().getId())
                        .interact(((CraftWorld)world).getHandle(),
                                interactLocation.getBlockX(),
                                interactLocation.getBlockY(),
                                interactLocation.getBlockZ(),
                                craftPlayer != null ? craftPlayer.getHandle(): null, 0, 0f, 0f, 0f);
                }

                dB.echoDebug(scriptEntry, "Switched " + interactLocation.getBlock().getType().toString() + "! Current state now: " +
                        ((interactLocation.getBlock().getData() & 0x8) > 0 ? "ON" : "OFF"));
View Full Code Here


            // Register the command
            forceCommand(name, command, new DenizenCommandHelpTopic(command));
            // Register each alias
            for (String alias : command.getAliases()) {
                if (denizenCommands.containsKey(alias)) continue;
                forceCommand(alias, command, new CommandAliasHelpTopic("/" + alias, name,
                        DenizenAPI.getCurrentInstance().getServer().getHelpMap()));
            }
        }
    }
View Full Code Here

        if(this.autosave) savePlayerData();
    }
    public Inventory getEnderChest() {
        InventoryEnderChest endchest = new InventoryEnderChest();
        endchest.a(this.compound.getList("EnderItems", 0));
        return new CraftInventory(endchest);
    }
View Full Code Here

    public org.bukkit.inventory.PlayerInventory getInventory() {
        if (InventoryScriptHelper.offlineInventories.containsKey(getUniqueId()))
            return InventoryScriptHelper.offlineInventories.get(getUniqueId());
        PlayerInventory inventory = new PlayerInventory(null);
        inventory.b(this.compound.getList("Inventory", 10));
        org.bukkit.inventory.PlayerInventory inv = new CraftInventoryPlayer(inventory);
        InventoryScriptHelper.offlineInventories.put(getUniqueId(), inv);
        return inv;
    }
View Full Code Here

        InventoryScriptHelper.offlineInventories.put(getUniqueId(), inv);
        return inv;
    }

    public void setInventory(org.bukkit.inventory.Inventory inventory) {
        CraftInventoryPlayer inv = new CraftInventoryPlayer(new PlayerInventory(null));
        inv.setContents(inventory.getContents());
        this.compound.set("Inventory", inv.getInventory().a(new NBTTagList()));
        if(this.autosave) savePlayerData();
    }
View Full Code Here

TOP

Related Classes of org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.