MaxCore API

Aug 22, 2015
MaxCore API
  • MaxCore API



    Utils

    1st part
    first lets go to your main class part .
    you must add this at your void onEnable() or onLoad()
    Code (Java):
    if(Bukkit.getServer().getPluginManager().getPlugin("MaxCore") == null) {
                Bukkit.getServer().getLogger().severe(ChatColor.RED + "Could not found MaxCore plugin");
                Bukkit.getServer().getPluginManager().disablePlugin(this);
                return;
            }
    }
    and you must add depend or softdepend at your plugin.yml
    like this
    PHP:
    softdepend: [MaxCore]

    // OR

    depend: [MaxCore]
    2nd part ( Message Utils )
    exactly at first you must get the instance of my message util do this to get the instance
    Code (Java):
    public MessageUtils getInstance() {
            return MessageUtils.getInstance();
        }
    now lets use the message util to create a simple commands
    1st example
    Code (Java):
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if(cmd.getName().equalsIgnoreCase("broadcast")) {
                String msg = getInstance().getMessage(args, 0);
               // the 0 stands for starts at args[0]
                Bukkit.broadcastMessage(msg);
                return true;
            }
            return false;
        }
    2nd example
    Code (Java):
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if(cmd.getName().equalsIgnoreCase("clearchat")) {
                Player p = (Player) sender;
                getInstance().clearchat(p);
                return true;
            }
    3rd part ( StringUtils )
    like what we did at message utils at first .
    Code (Java):
    public StringUtils getInstance() {
       return StringUtils.getInstance();
    }
    well lets use it with event
    Code (Java):
    @EventHandler
    public void onChat(AsyncPlayerChatEvent e) {
    String msg = getInstance().colorize(e.getMessage());
      e.setMessage(msg);
    }
  • Loading...
  • Loading...