Last active
August 29, 2015 14:10
-
-
Save cmoore/0c19fa1d6c0dd6dbd737 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package me.swiftymove.Command; | |
import net.canarymod.Canary; | |
import net.canarymod.commandsys.CommandDependencyException; | |
import net.canarymod.plugin.Plugin; | |
public class Main extends Plugin{ | |
@Override | |
public void disable() { | |
} | |
@Override | |
public boolean enable() { | |
try { | |
Canary.commands().registerCommands(new Commands(), getDescriptor().getPlugin(), false); | |
} catch (CommandDependencyException e) { | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} | |
return false; | |
} | |
} | |
NEXT PART UNDER HERE | |
package me.swiftymove.Command; | |
import net.canarymod.api.inventory.ItemType; | |
import net.canarymod.chat.MessageReceiver; | |
import net.canarymod.commandsys.Command; | |
import net.canarymod.commandsys.CommandListener; | |
public class Commands implements CommandListener{ | |
@Command(aliases = {"food"}, | |
description = "Give Player Food", | |
permissions = {"canary.command.food"}, | |
toolTip = "/food", | |
min = 1) | |
public void foodComand(MessageReceiver caller, String[] parameters){ | |
Item chicken = Canary.factory().getItemFactory().newItem(ItemType.CookedChicken); | |
player_for_name(caller.getName()).getInventory().addItem(chicken); | |
} | |
private Player player_for_name(String name) { | |
return Canary | |
.getServer() | |
.getPlayerList() | |
.stream() | |
.filter(x -> x.getName().equals(name)) | |
.findFirst().get(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment