how to get data from other plugins?

Discussion in 'Plugin Development' started by Helldragger, Mar 12, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Helldragger

    Hey there!
    I'm a new dev and I'm working on my first plugin ever, since some days I was developping without problems, my plugin was okay, working without problems, but some friends asked me to handle PermissionEX prefixes, and then ,I'm blocked because I can't get them however the way I used to! Could you help me please?

    here is the ways I used to get these:
    Code:java
    1. PermissionManager ownPEX = PermissionsEx.getPermissionManager();
    2. //the first way tested:
    3. String formatPrefix = ownPEX.getUser(sender).getPrefix().toString();
    4. //an other way:
    5. player = ownPEX.getUser(player).getPrefix() + ownPEX.getUser(player).getName() + ownPEX.getUser(player).getSuffix();

    when these lines are running, it skip my loop and consider like if there wasn't any code,like a continue tag!
    here is the part where my code is:

    Code:
    String sender = chat.getPlayer().getName();
            String message = chat.getMessage();
            if(playerRPenabled.get(sender)){ //si le mode RP est activé
               
                try
                {
                    //mise en forme du message
                    //message formatting then :
                    String format = chat.getPlayer().getName();
                   
                    if (isPermissionEXenabled){
                        logger.info("onPlayerChat + permissions EX ok!");
                       
                        //TODO debugger ici! * (start of bugged zone)
    //just here, the plugin "jump" the code to ..
     
                        String formatPrefix = ownPEX.getUser(sender).getPrefix().toString();
                        logger.info("getPrefix?");
     
                        int CouleurPrefix = formatPrefix.indexOf("&");//detection de code couleur
                        //si il y a un code de couleur detecté dans le préfixe:
     
                        while (CouleurPrefix != -1){
                            //on recupere le code couleur detecté
                            String CouleurString =  formatPrefix.subSequence(CouleurPrefix, CouleurPrefix+1).toString();
                            //on recupere la couleur liée
                            ChatColor CouleurCode = ChatColor.valueOf( CouleurString );
                            //on l'ajoute à la place du code
                            String[] Prefixes = formatPrefix.split(CouleurString);
                            if (Prefixes.length > 1){
                                formatPrefix = Prefixes[0] + CouleurCode + Prefixes[1];
                            }else if(Prefixes.length == 1){
                                formatPrefix = CouleurCode + Prefixes[0];
                            }else{
                                logger.warning("ERROR WHEN CATCHING PREFIXES");
                            }
                           
                            CouleurPrefix = formatPrefix.indexOf("&"); //retenter la detection
                        }
                               
                        logger.info("FormatPrefix = "+formatPrefix);
                        String formatSuffix = ownPEX.getUser(sender).getSuffix();
                        //idem pour les suffixes.
                       
                       //same than prefixes but with suffixes
                          
                        
                       
                        logger.info("FormatSuffix = "+formatSuffix);
                       
                        format = formatPrefix + format + formatSuffix;
                        logger.info("format = "+format);
                        //TODO fin de zone a debugger (end of bugged zone)
                    }
                   
                    //envoi du message a chaque joueur proche.
                   
                    //code that send this mail to nearby players
                    }   
                   
                   
                    chat.setCancelled(true); //this cancel the general chat sending of this mail to other players to receive this.
                }
                catch (Exception e) {   
                   
                }
               
            }else{ //si le mode RP n'est pas activé
    //Where the bug make the plugin JUMP to!
                chat.setMessage(message);
            }
           
            return;
        }
     
  2. Offline

    Freelix2000

    Did you depend on PEX in your plugin.yml? If not, tag me and I'll explain how.
     
Thread Status:
Not open for further replies.

Share This Page