Catching up to current version
This commit is contained in:
parent
b974339b52
commit
3781d66047
|
@ -1,24 +1,23 @@
|
||||||
package com.ne0nx3r0.betteralias;
|
package com.ne0nx3r0.betteralias;
|
||||||
|
|
||||||
import com.ne0nx3r0.betteralias.alias.AliasManager;
|
import com.ne0nx3r0.betteralias.alias.AliasManager;
|
||||||
import com.ne0nx3r0.betteralias.command.BetterAliasCommandExecutor;
|
import com.ne0nx3r0.betteralias.command.BetterAliasCommandExecutor;
|
||||||
import com.ne0nx3r0.betteralias.listener.BetterAliasCommandListener;
|
import com.ne0nx3r0.betteralias.listener.BetterAliasCommandListener;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public class BetterAlias extends JavaPlugin
|
public class BetterAlias extends JavaPlugin
|
||||||
{
|
{
|
||||||
public AliasManager aliasManager;
|
public AliasManager aliasManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable()
|
public void onEnable()
|
||||||
{
|
{
|
||||||
this.aliasManager = new AliasManager(this);
|
this.aliasManager = new AliasManager(this);
|
||||||
|
|
||||||
this.getServer().getPluginManager().registerEvents(new BetterAliasCommandListener(this), this);
|
this.getServer().getPluginManager().registerEvents(new BetterAliasCommandListener(this), this);
|
||||||
|
|
||||||
|
BetterAliasCommandExecutor betterAliasCommandExecutor = new BetterAliasCommandExecutor(this);
|
||||||
BetterAliasCommandExecutor betterAliasCommandExecutor = new BetterAliasCommandExecutor(this);
|
|
||||||
|
this.getCommand("bareload").setExecutor(betterAliasCommandExecutor);
|
||||||
this.getCommand("bareload").setExecutor(betterAliasCommandExecutor);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -1,92 +1,92 @@
|
||||||
package com.ne0nx3r0.betteralias.listener;
|
package com.ne0nx3r0.betteralias.listener;
|
||||||
|
|
||||||
import com.ne0nx3r0.betteralias.BetterAlias;
|
import com.ne0nx3r0.betteralias.BetterAlias;
|
||||||
import com.ne0nx3r0.betteralias.alias.Alias;
|
import com.ne0nx3r0.betteralias.alias.Alias;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.server.ServerCommandEvent;
|
import org.bukkit.event.server.ServerCommandEvent;
|
||||||
|
|
||||||
public class BetterAliasCommandListener implements Listener
|
public class BetterAliasCommandListener implements Listener
|
||||||
{
|
{
|
||||||
private final BetterAlias plugin;
|
private final BetterAlias plugin;
|
||||||
|
|
||||||
public BetterAliasCommandListener(BetterAlias plugin)
|
public BetterAliasCommandListener(BetterAlias plugin)
|
||||||
{
|
{
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent e)
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent e)
|
||||||
{
|
{
|
||||||
String sCommand = null;
|
String sCommand = null;
|
||||||
String sArgs = "";
|
String sArgs = "";
|
||||||
|
|
||||||
if(e.getMessage().contains(" "))
|
if(e.getMessage().contains(" "))
|
||||||
{
|
{
|
||||||
sCommand = e.getMessage().substring(1,e.getMessage().indexOf(" "));
|
sCommand = e.getMessage().substring(1,e.getMessage().indexOf(" "));
|
||||||
sArgs = e.getMessage().substring(e.getMessage().indexOf(" ")+1);
|
sArgs = e.getMessage().substring(e.getMessage().indexOf(" ")+1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sCommand = e.getMessage().substring(1);
|
sCommand = e.getMessage().substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Alias alias = plugin.aliasManager.getAlias(sCommand);
|
Alias alias = plugin.aliasManager.getAlias(sCommand);
|
||||||
|
|
||||||
if(alias != null)
|
if(alias != null)
|
||||||
{
|
{
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
|
|
||||||
if(alias.hasPermission()
|
if(alias.hasPermission()
|
||||||
&& !player.hasPermission("betteralias."+alias.getPermissionNode()))
|
&& !player.hasPermission("betteralias."+alias.getPermissionNode()))
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED+"You do not have permission to use this alias.");
|
player.sendMessage(ChatColor.RED+"You do not have permission to use this alias.");
|
||||||
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(plugin.aliasManager.sendAliasCommands(
|
if(plugin.aliasManager.sendAliasCommands(
|
||||||
alias,
|
alias,
|
||||||
(CommandSender) e.getPlayer(),
|
(CommandSender) e.getPlayer(),
|
||||||
sArgs));
|
sArgs));
|
||||||
{
|
{
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onConsoleCommand(ServerCommandEvent e)
|
public void onConsoleCommand(ServerCommandEvent e)
|
||||||
{
|
{
|
||||||
Alias alias;
|
Alias alias;
|
||||||
String sCommand = null;
|
String sCommand = null;
|
||||||
|
|
||||||
if(e.getCommand().contains(" "))
|
if(e.getCommand().contains(" "))
|
||||||
{
|
{
|
||||||
sCommand = e.getCommand().substring(e.getCommand().indexOf(" ")+1);
|
sCommand = e.getCommand().substring(e.getCommand().indexOf(" ")+1);
|
||||||
|
|
||||||
alias = plugin.aliasManager.getAlias(e.getCommand().substring(0,e.getCommand().indexOf(" ")));
|
alias = plugin.aliasManager.getAlias(e.getCommand().substring(0,e.getCommand().indexOf(" ")));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
alias = plugin.aliasManager.getAlias(e.getCommand());
|
alias = plugin.aliasManager.getAlias(e.getCommand());
|
||||||
|
|
||||||
sCommand = "";
|
sCommand = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(alias != null)
|
if(alias != null)
|
||||||
{
|
{
|
||||||
if(plugin.aliasManager.sendAliasCommands(alias,e.getSender(),sCommand))
|
if(plugin.aliasManager.sendAliasCommands(alias,e.getSender(),sCommand))
|
||||||
{
|
{
|
||||||
e.setCommand("bareload donothing");
|
e.setCommand("bareload donothing");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue