Skip to content

Instantly share code, notes, and snippets.

@joserobjr
Created February 5, 2020 00:51
Show Gist options
  • Save joserobjr/64230084dbde2195503b88c28105787b to your computer and use it in GitHub Desktop.
Save joserobjr/64230084dbde2195503b88c28105787b to your computer and use it in GitHub Desktop.
name: OffhandTestPlugin
main: sample.OffhandTestPlugin
version: 1.0.0
api: ["1.0.9"]
commands:
test-offhand:
permission: test-offhand
permissions:
test-offhand:
default: true
package sample;
import cn.nukkit.Player;
import cn.nukkit.command.Command;
import cn.nukkit.command.CommandSender;
import cn.nukkit.plugin.PluginBase;
public class OffhandTestPlugin extends PluginBase {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player) sender;
sender.sendMessage("You have this in your offhand: "+player.getOffhandInventory().getItem(0).getName());
player.getInventory().clearAll();
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment