Plugin help!!!

Discussion in 'Plugin Development' started by Linux1337, Aug 17, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Linux1337

    Hello,

    Im trying to make a plugin that will take away bedrock and other items you dont want players to have when they log on or when a mod/admin does /checkinv. So far its giving me an error :(

    This is my code:
    package com.skycraft.blockcheck;

    import org.bukkit.entity.Player;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.inventory.PlayerInventory;
    import org.bukkit.plugin.java.JavaPlugin;

    public class BlockCheck extends JavaPlugin{
    public void onEnable() {
    getLogger().info("BlockCheck has been enabled!");
    }

    public void onDisable() {
    getLogger().info("BlockCheck has been disabled!");
    }
    public void onPlayerJoin(PlayerJoinEvent evt) {
    Player player = evt.getPlayer();
    PlayerInventory inventory = player.getInventory();

    if (inventory.contains(Material.BEDROCK)) {
    inventory.remove(Material.BEDROCK);
    player.sendMessage("Welcome! You seem to have some illegal items in your inventory! Dont worry, We took it away!");
    }
    }
    }



    Here is my plugin.yml file:
    name: Test
    main: com.skycraft.blockcheck.BlockCheck
    version: 1.0.0

    Thx in advance

    Edit: The error is gone but it dosent work...
     
  2. Offline

    JDigital1337

    this makes no sense.​
    Inventories don't contain integers, they contain itemstacks...​
    read the API more.​
     
  3. Offline

    RedXVIII

  4. Offline

    Linux1337

    Can someone correct the errors?
     
  5. Offline

    Ogaron

    Code:
    inventory.removeItem(new ItemStack (Mat, Int));
    I believe that removes every instance of block/item it finds.
     
  6. Offline

    toothplck1

    Code:
    if (inventory.contains(Material.BEDROCK)) {
    inventory.remove(Material.BEDROCK);
    player.sendMessage("Welcome! You seem to have some illegal items in your inventory! Dont worry, We took it away!");
    }
    I would use this as it removes all bedrock in said inventory
     
  7. Offline

    Linux1337

    Thx guys!

    do i have to include something in plugin.yml for this action?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  8. Offline

    toothplck1

    Nothing other than plugin info, although you do need to register your class as an event listener.
     
  9. Offline

    WarmakerT

    Code:
    this.getServer().getPluginManager().registerEvents(this, this);
    And implement Listener in your class.
     
  10. Offline

    Linux1337

    and also i want to have a mod/admin issue the command /checkinv <player> or /checkinv all
    /checkinv player checks the inv of a specific player
    /checkinv all checks the inv of all the people currently on the server

    does anyone know the code to do this?
     
  11. Offline

    toothplck1

    Well you could write it yourself or you could look up the plugin "OpenInv" which does exactly that already.
     
  12. Offline

    Linux1337

    openinv does nothing that i need, i want /checkinv <Player> to auto-check to see if there is any bedrock and remove it if there is without opening the inventory to the cmd issuer
     
  13. Offline

    Firefly

    Plenty of tutorials/threads that talk about executing a command on someone else. Kindly use the search function.
     
Thread Status:
Not open for further replies.

Share This Page