Plugin Incompatibilty

Discussion in 'Plugin Development' started by Xfqlo23, Mar 3, 2015.

Thread Status:
Not open for further replies.
  1. I've maded two plugins, when i try them one by one, they works fine. But when i do at the same time, i don't know why, one doesn't work.
    If someone can tell me why plugin incompatibility is produced for, I'll be so thankfull.

    If need more info about my plugins, tell me.

    Thanks
     
  2. Offline

    Cheesepro

    @Xfqlo23
    Can you please show us the code?
     
  3. Offline

    PreFiXAUT

    @Xfqlo23 1. WHAT doesn't work. 2. What are your Plugins doing? 3. Do you use CB or Bukkit as lib? 4. If there is a Stacktrace -> Post stacktrace and relevant Classes
     
  4. Offline

    SuchSwegMuchWow

    @Cheesepro Im pretty sure one of your classes have the same name. This happened to me before
     
  5. The 1st i've done is A simple elevator, this is the first plugin that stops working when I add the second.
    There is the main class:
    JSEmain.java (open)
    Code:
    package io.github.xfqlo23.jushelevator;
    
    import java.util.ArrayList;
    import java.util.List;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    
    
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class JSEmain extends JavaPlugin{
        public static final Logger log = Logger.getLogger("Minecraft");
        public JSEevents JSEevents = new JSEevents(this);
        public PluginManager manager = this.getServer().getPluginManager();
      
        @Override
        public void onEnable(){
            log.log(Level.INFO, "JushElevator Activado");
            manager.registerEvents(JSEevents, this);
            JSEdb.load();
        }
      
        @Override
        public void onDisable(){
            log.log(Level.INFO, "JushElevator Desactivado");
        }
    
    
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){      
            if(label.equals("jsedisable")){
                if(sender.getName() == "CONSOLE"){
                    manager.disablePlugin(JSEmain.this);
                }
              
            }
            if(label.equalsIgnoreCase("jsecreate") && args.length >= 1){
                if(isNumber(args[0])){
                    int i = Integer.parseInt(args[0]);
                    switch (args.length){
                        case 1:
                            //auto crear
                            if(sender.hasPermission("jse.create")){
                                if(i <= 10 && i >= 1){
                                    int c = 0;
                                    List<String> ls = new ArrayList<String>();
                                    do{
                                        ls.add("Elevator");
                                        ((Player) sender).getInventory().addItem(newFloor(new ItemStack(Material.WOOL),ls));
                                        c++;
                                    }while(c<i);
                                    sender.sendMessage("Se han añadido "+ i + " Elevator Center");
                                } else sender.sendMessage(JSEmessages.notNumber);
                            }
                        break;
                        case 2:
                            //crear a otro
                            if(sender.hasPermission("jse.admin.create")){
                                if(getServer().getPlayer(args[1]).isOnline()){
                                    if(i <= 10 && i >= 1){
                                        int c = 0;
                                        List<String> ls = new ArrayList<String>();
                                        do{
                                            ls.add("Elevator");
                                            sender.getServer().getPlayer(args[1]).getInventory().addItem(newFloor(new ItemStack(Material.WOOL),ls));
                                            c++;
                                        }while(c<i);
                                        sender.sendMessage("Se han añadido "+ i + " Elevator Center");
                                    } else sender.sendMessage(JSEmessages.notNumber);
                                }else sender.sendMessage(JSEmessages.noPlayer);
                            }
                        break;
                }
                }else{
                    sender.sendMessage(JSEmessages.notNumber);
                }
              
            }
            return true;  
        }
      
        private ItemStack newFloor(ItemStack is, List<String> lore){
            ItemMeta im = is.getItemMeta();
            im.setDisplayName("Elevator Center");
            if(lore != null){
                im.setLore(lore);
            }
            is.setItemMeta(im);
          
          
            return is;
        }
    
        public static boolean isNumber(String string) {
            if (string == null || string.isEmpty()) {
                return false;
            }
            int i = 0;
            if (string.charAt(0) == '-') {
                if (string.length() > 1) {
                    i++;
                } else {
                    return false;
                }
            }
            for (; i < string.length(); i++) {
                if (!Character.isDigit(string.charAt(i))) {
                    return false;
                }
            }
            return true;
        }
    }


    The second I'm doing is a plugin that gives coins for killing people, and next u can buy some things in a custom inventory shop. And there u got the main class:
    KRmain.java (open)

    Code:
    package io.github.xfqlo23.KillRewards;
    
    import io.github.xfqlo23.KillRewards.db.KRitemdb;
    import io.github.xfqlo23.KillRewards.db.KRuserdb;
    import io.github.xfqlo23.KillRewards.events.KRevents;
    import io.github.xfqlo23.KillRewards.gui.KRguiShop;
    
    import java.util.logging.Level;
    import java.util.logging.Logger;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class KRmain extends JavaPlugin{
        public static final Logger log = Logger.getLogger("Minecraft");
        public KRguiShop gui;
       
       
        @Override
        public void onEnable(){
            log.log(Level.INFO, ChatColor.GREEN + "Activado!");
            Bukkit.getPluginManager().registerEvents(new KRevents(this), this);
            KRuserdb.load();
            KRitemdb.load();
        }
       
        @Override
        public void onDisable(){
            log.log(Level.INFO, ChatColor.RED + "Desactivado!");
        }
       
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
            Player p = (Player)sender;
            if(label.equals("krshop")){
                gui.openGUI(p);
               
            }
            if(label.equals("kraddcoins") && p.hasPermission("kr.admin.addcoins")){
                if(args.length == 2){
                    try{
                        KRuserdb.addCoins(p, Integer.parseInt(args[1]));
                    }catch(Exception ex){
                        p.sendMessage(ex.toString());
                    }
                   
                }
            }
            if(label.equals("kradditem") && p.hasPermission("kr.admin.additem")){
               
                if(args.length > 1){
                    try{
                        String finalarg = "";
                        for(String arg:args){
                            finalarg = finalarg + arg + " ";
                        }
                        p.sendMessage("ITEM: " +finalarg);
                        KRitemdb.additems(finalarg);
                    }catch(Exception ex){
                        p.sendMessage(ex.toString());
                    }
                }
            }
           
            return true;   
        }
    }


    I'm pretty sure, that i haven't got more than 1 class with the same name, because i use "Prefix of plugin" + name
    Example:
    1.- JSEmain => JuShElevator
    2.- KRmain => KillRewards
     
  6. Offline

    guitargun

    @Xfqlo23 did you export it correctly (2nd plugin not overwriting the first one) ?, did they both load?
    also
    1. public static final Logger log = Logger.getLogger("Minecraft"); you dont have to use it. the bukkit getLogger() is completely fine
     
  7. @guitargun I exported them correctly, and they loaded nice.

    i changed Logger.getLogger for Bukkit.getLogger and sitll happeing

    The new thing i've seen is

    New thing I've seen is that when I load the plugin and i do a "reload" the 1st one stops working, and when I go out and get back into a minecraft, both are working again.
     
  8. Offline

    mythbusterma

    @Xfqlo23

    Post any errors from your console.
     
  9. My console don't have any errors.
     
  10. Offline

    Cheesepro

    @Xfqlo23
    What do you mean by "doesn't work", does it say internal error? Or when you typed the command nothing comes up? Or else?
     
  11. When i activate the event, nothing comes up, no internal error, no console error, nothing.
     
  12. Offline

    guitargun

    @Xfqlo23 that seems like the plugin isn't loading. try implementing the commandexecutor. I never worked with everything in the main class so dont know if that has to be in
     
  13. I don't have all on the main class.
     
  14. Can anyone tell me why the inconsistency will occur?
     
  15. Offline

    Funergy

    @Xfqlo23 Do the 2 plugins have the same name in the plugin.yml ?

    @guitargun If you put commands in the main class it doesnt need to be imported but you at least need to import JavaPlugin :p
     
Thread Status:
Not open for further replies.

Share This Page