1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[Not Important] AdvancedReport explanation

Discussion in 'Plugins/Codes' started by A Christmas Hangar, Sep 20, 2016.

  1. A Christmas Hangar

    A Christmas Hangar Member

    Joined:
    Sep 15, 2015
    Messages:
    2,548
    Likes Received:
    1,495
    Trophy Points:
    113
    Gender:
    Male
    Location:
    Kepler452B
    Home Page:
    The title is 10/10

    Thi is a "guide"/tutorial/something that help you understand how "Advanced Reports" works, quite simple and easy to explain


    There isn't the command executor thing, why? I am lazy.
    Code:
    package eu.hangar;
     
     
     
     
    import java.util.List;
     
    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.event.Listener;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class Main extends JavaPlugin implements Listener {
     
     
        public void onEnable(){   //config requirments
            getServer().getPluginManager().registerEvents(this, this);
            getConfig().options().copyDefaults(true);
            saveConfig();
            }
         
     
          List<String> Reports = getConfig().getStringList("Reports"); //creates the list
           public boolean onCommand(CommandSender sender, Command cmd, String aliases,
                    String[] args) {
     
                if (cmd.getName().equalsIgnoreCase("report")) { //command
                   Player p = (Player) sender;
                    if (args.length == 0) { //gets the args
                        if(!p.hasPermission("report.staff")){ //! means no
                           p.sendMessage(ChatColor.GREEN +""+ ChatColor.STRIKETHROUGH +"=                                                   =");
                           p.sendMessage(ChatColor.BLUE + "Usage:");
                           p.sendMessage(ChatColor.BLUE + "/report player <playername> will report a player");
                           p.sendMessage(ChatColor.BLUE + "/report check <playername> will check if the player is reported");
                           p.sendMessage(ChatColor.GREEN +""+ ChatColor.STRIKETHROUGH +"=                                                   =");
                        }else{ //if they di have perms
                             p.sendMessage(ChatColor.GREEN +""+ ChatColor.STRIKETHROUGH +"=                                                   =");
                               p.sendMessage(ChatColor.BLUE + "Usage:");
                               p.sendMessage(ChatColor.BLUE + "/report player <playername> will report a player");
                               p.sendMessage(ChatColor.BLUE + "/report claim <playername> will remove the report. TO-DO: TP to the player");
                               p.sendMessage(ChatColor.BLUE + "/report check <playername> will check if the player is reported");
                               p.sendMessage(ChatColor.GREEN +""+ ChatColor.STRIKETHROUGH +"=                                                   =");
                         
                        }
                         
                    }
                    if (args.length == 2) {
                        Player target = Bukkit.getPlayer(args[1]); //the target, needs to be bungee
     
                     
                        if (args[0].equalsIgnoreCase("player")) {
                            if(target != null){ //checks if the target exists
                             if (!Reports.contains(args[1])){
                                p.sendMessage(ChatColor.BLUE + target.getName() + " was reported. Report ID " + target.getUniqueId());
                                Reports.add(target.getName().toString()); //adds the player to the list, reason of why it is not possible to bypass
                           
                             }else{ //the player is reported
                                p.sendMessage(ChatColor.RED + "That player is alredy reported! ");
                                return true;
                            }
                            }else{ //the targte doesn't exists
                                p.sendMessage(ChatColor.RED + "Invalid player");
                            }
                        }
     
                        if (args[0].equalsIgnoreCase("check")) {
                           if(target !=null){
                             
                           if(args.length !=2){ //missing arguments
                               p.sendMessage(ChatColor.RED + "Not enough arguments");
                           }
                           else if (!Reports.contains(args[1])) {//wheres that player?
                                    p.sendMessage(ChatColor.BLUE + "That player was never reported");
                                 }else{//the target is reported
                                     p.sendMessage(ChatColor.BLUE + "That player was reported");
                                     return true;
                            }
                        }else{
                            p.sendMessage(ChatColor.RED + "Invalid player");
                        }
                        }
                        if (args[0].equalsIgnoreCase("claim")) {
                          if(p.hasPermission("report.claim")){
                            if (target != null) {
                              Reports.remove(args[1]);//bye bye reported
                              p.sendMessage(ChatColor.BLUE + "Report claimed");
                              p.teleport(target); //;-;
                              return true;
                            }else{
                                p.sendMessage(ChatColor.RED + "Invalid player");
                        }
                    }else{ //perms
                        p.sendMessage(ChatColor.RED + "Not enough permissions");
                    }
                }
                return true;
            }
                return true;
     
        }
                return true;
    }}

    If someone could "improve" the code, give me tips, etc, I'd be very happy
     
  2. A Christmas Hangar

    A Christmas Hangar Member

    Joined:
    Sep 15, 2015
    Messages:
    2,548
    Likes Received:
    1,495
    Trophy Points:
    113
    Gender:
    Male
    Location:
    Kepler452B
    Home Page:
    Traducido el funcionamineto a español


    Code:
    package eu.hangar;
     
     
     
     
    import java.util.List;
     
    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.event.Listener;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class Main extends JavaPlugin implements Listener {
     
     
        public void onEnable(){   //config.yml
            getServer().getPluginManager().registerEvents(this, this);
            getConfig().options().copyDefaults(true);
            saveConfig();
            }
      
     
          List<String> Reports = getConfig().getStringList("Reports"); //crea la lista
           public boolean onCommand(CommandSender sender, Command cmd, String aliases,
                    String[] args) {
     
                if (cmd.getName().equalsIgnoreCase("report")) { //comando
                   Player p = (Player) sender;
                    if (args.length == 0) { //gets the args
                        if(!p.hasPermission("report.staff")){ //! significa no
                           p.sendMessage(ChatColor.GREEN +""+ ChatColor.STRIKETHROUGH +"=                                                   =");
                           p.sendMessage(ChatColor.BLUE + "Usage:");
                           p.sendMessage(ChatColor.BLUE + "/report player <playername> will report a player");
                           p.sendMessage(ChatColor.BLUE + "/report check <playername> will check if the player is reported");
                           p.sendMessage(ChatColor.GREEN +""+ ChatColor.STRIKETHROUGH +"=                                                   =");
                        }else{ //if they di have perms
                             p.sendMessage(ChatColor.GREEN +""+ ChatColor.STRIKETHROUGH +"=                                                   =");
                               p.sendMessage(ChatColor.BLUE + "Usage:");
                               p.sendMessage(ChatColor.BLUE + "/report player <playername> will report a player");
                               p.sendMessage(ChatColor.BLUE + "/report claim <playername> will remove the report. TO-DO: TP to the player");
                               p.sendMessage(ChatColor.BLUE + "/report check <playername> will check if the player is reported");
                               p.sendMessage(ChatColor.GREEN +""+ ChatColor.STRIKETHROUGH +"=                                                   =");
                      
                        }
                      
                    }
                    if (args.length == 2) {
                        Player target = Bukkit.getPlayer(args[1]); //crea el objetivo
     
                  
                        if (args[0].equalsIgnoreCase("player")) {
                            if(target != null){ //checks if the target exists
                             if (!Reports.contains(args[1])){
                                p.sendMessage(ChatColor.BLUE + target.getName() + " was reported. Report ID " + target.getUniqueId());
                                Reports.add(target.getName().toString()); //añade el reporte a la lista
    
                             }else{ //si el jugador ha sidonreportado....
                                p.sendMessage(ChatColor.RED + "That player is alredy reported! ");
                                return true;
                            }
                            }else{ //the targte doesn't exists
                                p.sendMessage(ChatColor.RED + "Invalid player");
                            }
                        }
     
                        if (args[0].equalsIgnoreCase("check")) {
                           if(target !=null){
                          
                           if(args.length !=2){ //faltan argumentos!
                               p.sendMessage(ChatColor.RED + "Not enough arguments");
                           }
                           else if (!Reports.contains(args[1])) {//El jugador nunca ha sido denunciado
                                    p.sendMessage(ChatColor.BLUE + "That player was never reported");
                                 }else{//el jugador ha sido reportado
                                     p.sendMessage(ChatColor.BLUE + "That player was reported");
                                     return true;
                            }
                        }else{
                            p.sendMessage(ChatColor.RED + "Invalid player");
                        }
                        }
                        if (args[0].equalsIgnoreCase("claim")) {
                          if(p.hasPermission("report.claim")){
                            if (target != null) {
                              Reports.remove(args[1]);//adios denuncia
                              p.sendMessage(ChatColor.BLUE + "Report claimed");
                              p.teleport(target); //;-;
                              return true;
                            }else{
                                p.sendMessage(ChatColor.RED + "Invalid player");
                        }
                    }else{ //permisos
                        p.sendMessage(ChatColor.RED + "Not enough permissions");
                    }
                }
                return true;
            }
                return true;
     
        }
                return true;
    }}
    @HackersDontWin
     
  3. AmiB00s

    AmiB00s Member

    Joined:
    Jun 28, 2016
    Messages:
    132
    Likes Received:
    126
    Trophy Points:
    43
    Gender:
    Male
    Location:
    DerpLand
    No entiendo nada xD
     
  4. A Christmas Hangar

    A Christmas Hangar Member

    Joined:
    Sep 15, 2015
    Messages:
    2,548
    Likes Received:
    1,495
    Trophy Points:
    113
    Gender:
    Male
    Location:
    Kepler452B
    Home Page:
    Aprende Java y vuelve por aquí :V
     
  5. LooksLikeHacks

    LooksLikeHacks Member

    Joined:
    Feb 5, 2016
    Messages:
    629
    Likes Received:
    189
    Trophy Points:
    43
    Gender:
    Male
    Occupation:
    Just Do It
    Location:
    devil joker harambes home
    Home Page:
    Dont understand any of this. The only thing i can code is HTML/JavaScript and CSS
     
    A Christmas Hangar likes this.
  6. A Christmas Hangar

    A Christmas Hangar Member

    Joined:
    Sep 15, 2015
    Messages:
    2,548
    Likes Received:
    1,495
    Trophy Points:
    113
    Gender:
    Male
    Location:
    Kepler452B
    Home Page:
    Wasn't Javascript amlittle bit similar to Java? I just know how to do simple sh** with HTML & CSS, but my **it works
     
  7. mateu9999

    mateu9999 Member

    Joined:
    Dec 6, 2015
    Messages:
    4,174
    Likes Received:
    2,584
    Trophy Points:
    113
    Gender:
    Male
    Occupation:
    Anime or Minecraft......
    Location:
    Inside you....
    ._. Mind blown...
    So easy!!!
    :/ expected more code...
     
  8. A Christmas Hangar

    A Christmas Hangar Member

    Joined:
    Sep 15, 2015
    Messages:
    2,548
    Likes Received:
    1,495
    Trophy Points:
    113
    Gender:
    Male
    Location:
    Kepler452B
    Home Page:
    It's actually easy. Made it while I was ill, 69/10 coding abilities.




    Kids, do not do that unless you want to lose a week of school/high school/college
     
  9. hyperBravo

    hyperBravo Member

    Joined:
    Mar 28, 2016
    Messages:
    988
    Likes Received:
    508
    Trophy Points:
    93
    Gender:
    Male
    Occupation:
    Infested Siege Tank
    Location:
    Infested Factory
    It's all OOP. The basics aren't hard to learn. It's first with object creation/handling and inheritance. There's much more of course but I don't know the rest besides those.
     
    A Christmas Hangar likes this.
  10. A Christmas Hangar

    A Christmas Hangar Member

    Joined:
    Sep 15, 2015
    Messages:
    2,548
    Likes Received:
    1,495
    Trophy Points:
    113
    Gender:
    Male
    Location:
    Kepler452B
    Home Page:
    ^^^


    Learn Java before start with spigot coding