Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.projectstrafe.SpongeEssentials.Commands;
- import org.spongepowered.api.entity.player.Player;
- import org.spongepowered.api.text.Texts;
- import org.spongepowered.api.text.format.TextColors;
- import org.spongepowered.api.util.command.CommandException;
- import org.spongepowered.api.util.command.CommandResult;
- import org.spongepowered.api.util.command.CommandSource;
- import org.spongepowered.api.util.command.args.CommandContext;
- import org.spongepowered.api.util.command.spec.CommandExecutor;
- public class ClassName implements CommandExecutor {
- private MAINCLASS plugin; // You can delete these four lines, if you don't want to access the main class
- public ClassName(MAINCLASS plugin) {
- this.plugin = plugin;
- }
- @Override
- public CommandResult execute(CommandSource src, CommandContext args)
- throws CommandException {
- if (src instanceof Player) { // Check if sender is player
- Player p = (Player) src; // Parse sender to player.
- // DO STUFF WITH PLAYER HERE!
- } else {
- src.sendMessage(Texts.of("Only players can execute this command")); //IF not player!
- }
- return CommandResult.success(); //Return success!
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement