Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Mar 13th, 2018 51 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. package pl.xzedster.core.commands;
  2.  
  3. import java.util.*;
  4. import org.bukkit.command.*;
  5. import pl.xzedster.core.lang.*;
  6. import pl.xzedster.core.utils.*;
  7.  
  8. public abstract class Command extends org.bukkit.command.Command
  9. {
  10.     private final String name;
  11.     private final String usage;
  12.     private final String desc;
  13.     private final String permission;
  14.    
  15.     public Command(final String name, final String desc, final String usage, final String permission, final String... aliases) {
  16.         super(name, desc, usage, (List)Arrays.asList(aliases));
  17.         this.name = name;
  18.         this.usage = usage;
  19.         this.desc = desc;
  20.         this.permission = permission;
  21.     }
  22.    
  23.     public boolean execute(final CommandSender sender, final String label, final String[] args) {
  24.         if ((this.permission != null || this.permission != "") && !sender.hasPermission(this.permission)) {
  25.             String msg = Lang.MSG_ERROR_DONTHAVEPERMISSION;
  26.             msg = msg.replace("{PERM}", this.getPermission());
  27.             return ChatUtil.sendMessage(sender, msg);
  28.         }
  29.         return this.onExecute(sender, args);
  30.     }
  31.    
  32.     public abstract boolean onExecute(final CommandSender p0, final String[] p1);
  33.    
  34.     public String getName() {
  35.         return this.name;
  36.     }
  37.    
  38.     public String getUsage() {
  39.         return this.usage;
  40.     }
  41.    
  42.     public String getDesc() {
  43.         return this.desc;
  44.     }
  45.    
  46.     public String getPermission() {
  47.         return this.permission;
  48.     }
  49. }
  50.  
  51.  
  52.  
  53.  
  54. package pl.xzedster.core.commands;
  55.  
  56. import java.util.*;
  57. import pl.xzedster.core.utils.*;
  58. import org.bukkit.command.*;
  59. import org.bukkit.plugin.*;
  60. import org.bukkit.*;
  61.  
  62. public class CommandManager
  63. {
  64.     public static final HashMap<String, Command> commands;
  65.     private static final Reflection.FieldAccessor<SimpleCommandMap> f;
  66.     private static CommandMap cmdMap;
  67.    
  68.     static {
  69.         commands = new HashMap<String, Command>();
  70.         f = Reflection.getField(SimplePluginManager.class, "commandMap", SimpleCommandMap.class);
  71.         CommandManager.cmdMap = (CommandMap)CommandManager.f.get(Bukkit.getServer().getPluginManager());
  72.     }
  73.    
  74.     public static void register(final Command cmd) {
  75.         if (CommandManager.cmdMap == null) {
  76.             CommandManager.cmdMap = (CommandMap)CommandManager.f.get(Bukkit.getServer().getPluginManager());
  77.         }
  78.         CommandManager.cmdMap.register(cmd.getName(), (org.bukkit.command.Command)cmd);
  79.         CommandManager.commands.put(cmd.getName(), cmd);
  80.     }
  81. }
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88. package pl.xzedster.core.commands;
  89.  
  90. import org.bukkit.command.*;
  91. import org.bukkit.entity.*;
  92. import pl.xzedster.core.utils.*;
  93.  
  94. public abstract class PlayerCommand extends Command
  95. {
  96.     public PlayerCommand(final String name, final String desc, final String usage, final String permission, final String... aliases) {
  97.         super(name, desc, usage, permission, aliases);
  98.     }
  99.    
  100.     @Override
  101.     public boolean onExecute(final CommandSender sender, final String[] args) {
  102.         if (!(sender instanceof Player)) {
  103.             return ChatUtil.sendMessage(sender, "&cTej komendy nie mozesz uzyc z poziomu konsoli!");
  104.         }
  105.         return this.onCommand((Player)sender, args);
  106.     }
  107.    
  108.     public abstract boolean onCommand(final Player p0, final String[] p1);
  109. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top