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...
this makes no sense. Inventories don't contain integers, they contain itemstacks... read the API more.
Code: inventory.removeItem(new ItemStack (Mat, Int)); I believe that removes every instance of block/item it finds.
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
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.
Code: this.getServer().getPluginManager().registerEvents(this, this); And implement Listener in your class.
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?
Well you could write it yourself or you could look up the plugin "OpenInv" which does exactly that already.
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
Plenty of tutorials/threads that talk about executing a command on someone else. Kindly use the search function.