Created
July 3, 2013 02:25
-
-
Save azenla/5914974 to your computer and use it in GitHub Desktop.
An Example of Minetweak's Command System
This file contains 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 org.minetweak.command; | |
import net.minecraft.src.EnumChatFormatting; | |
import org.minetweak.Minetweak; | |
import org.minetweak.Server; | |
import org.minetweak.entity.Player; | |
import org.minetweak.util.StringUtils; | |
public class CommandBan extends CommandExecutor { | |
@Override | |
public void executeCommand(CommandSender sender, String overallCommand, String[] args) { | |
if (args.length == 0) { | |
sender.sendMessage(EnumChatFormatting.AQUA + "Usage: /ban <player> [reason]"); | |
return; | |
} | |
Player targetPlayer = Minetweak.getPlayerByName(args[0]); | |
if (args.length == 1) { | |
targetPlayer.banPlayer(); | |
} else if (args.length >= 2) { | |
args = StringUtils.dropFirstString(args); | |
String reason = mergeArgs(args); | |
targetPlayer.banPlayer(reason); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment