Adding reload command, minor tweaks, removed commandexecutor

This commit is contained in:
Ne0nx3r0 2012-11-18 11:10:48 -08:00
parent 784947e3bb
commit 154ff71195
5 changed files with 19 additions and 54 deletions

View File

@ -23,7 +23,7 @@ tpthenkick:
- /kick !1p
# special command for toggling GM mode
gm:
0: /gamemode !name !oppositeGameMode
0: /gamemode !oppositeGameMode !name
# hand all parameters in order
s:
"*": /say I want to say "!*", there I said it!

View File

@ -7,9 +7,12 @@ import org.bukkit.plugin.java.JavaPlugin;
public class BetterAlias extends JavaPlugin{
public static AliasManager aliasManager;
public static BetterAlias self;
@Override
public void onEnable() {
public void onEnable()
{
this.self = this;
//Create an alias manager (also loads aliases)
aliasManager = new AliasManager(this);

View File

@ -1,48 +0,0 @@
package com.gmail.Ne0nx3r0;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class BetterAliasCommandExecutor implements CommandExecutor {
private BetterAlias plugin;
public BetterAliasCommandExecutor(BetterAlias plugin)
{
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender cs, Command cmd, String alias, String[] args) {
if (!(cs instanceof Player)){
System.out.println("You can't run this from the console!");
return false;
}
Player player = (Player) cs;
if(cmd.getName().equalsIgnoreCase("to") && args.length == 1 && player.isOp()){
String sPlayerName = args[0].toLowerCase();
for(Player p : plugin.getServer().getOnlinePlayers()){
if(p.getName().toLowerCase().contains(sPlayerName)){
player.chat("/tp "+player.getName()+" "+p.getName());
break;
}
}
}
else if(cmd.getName().equalsIgnoreCase("gm")){
if(player.getGameMode() == GameMode.SURVIVAL){
player.chat("/gamemode "+player.getName()+" 1");
}else{
player.chat("/gamemode "+player.getName()+" 0");
}
}
else if(cmd.getName().equalsIgnoreCase("go") && args.length > 0){
player.chat("/res tp "+args[0]);
}
return true;
}
}

View File

@ -6,6 +6,7 @@ import java.util.regex.Pattern;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
@ -18,8 +19,9 @@ class BetterAliasPlayerListener implements Listener{
this.aliasManager = am;
}
@EventHandler
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent e) {
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent e)
{
String[] cmd = e.getMessage().substring(1).split(" ");
@ -48,7 +50,7 @@ class BetterAliasPlayerListener implements Listener{
}else if(text.equalsIgnoreCase("handItemID")){
text = new Integer(player.getItemInHand().getTypeId()).toString();
}else if(text.equalsIgnoreCase("oppositeGameMode")){
text = (player.getGameMode() == GameMode.SURVIVAL ? "1" : "0");
text = (player.getGameMode() == GameMode.SURVIVAL ? "creative" : "survival");
}else if(text.length() >= 2 && text.substring(1,2).equalsIgnoreCase("p")){
int iParam = -1;
@ -94,5 +96,13 @@ class BetterAliasPlayerListener implements Listener{
e.setCancelled(true);
}
}
else if(cmd[0].equalsIgnoreCase("bareload") && (e.getPlayer().isOp() || e.getPlayer().hasPermission("BetterAlias.reload")))
{
BetterAlias.aliasManager = new AliasManager(BetterAlias.self);
e.getPlayer().sendMessage("BetterAlias reloaded!");
e.setCancelled(true);
}
}
}

View File

@ -1,5 +1,5 @@
name: BetterAlias
main: com.gmail.Ne0nx3r0.BetterAlias
version: '0.3'
version: '0.4'
database: false
description: Command alias system