Spigot Anti-SignCrash 1.2

Stop the 1.8 Sign-Hack with this simple plugin!

  1. Caspus submitted a new resource:

    Anti-SignHack - Stop the 1.8 Sign-Hack with this simple plugin!

    Read more about this resource...
     
  2. Why don't you use a loop?

    ie.
    Code (Text):

    for(int i=0;i<4;i++){
        String line = e.getLine().toString();
        if(line.length() > 15 && e.getPlayer().hasPermission("antisignhack.exempt")){
            e.setLine(3, "");
            Bukkit.dispatchCommand(console, "ban " + pName + " Attempted Sign Hack.");
            Bukkit.broadcast(ChatColor.translateAlternateColorCodes('&', "&c&lWARNING &4&l>> &f" + pName + " has attemped to do a sign hack and was banned."), "antisignhack.notfiy");
        }
    }
     
    (this is just example code, I didn't fix the other numerous problems with your code)
     
  3. Just in case they would try to loop it or try to do any type of bypass.
     
  4. What numerous problems are there? I am the developer of this plugin I can fix them. I really see nothing wrong, I have tested with it a friend. And why did you decompile it...?
     
  5. It's possible to hack with signs? lol
     
  6. Using a loop would not cause any additional errors.

    Just to name one, you should use ChatColor.<color-name> rather than ChatColor.translateAlternateColorCodes('&', string);.
     
  7. That causes no errors. I use that for ease of access. Plus, in the next update for the plugin, I am going to make it more custom...
     
  8. Just because it causes no errors does not mean it is a good idea. It is slightly slower to run ChatColor.tranaslateAlternateColorCodes() each time the plugin is run rather than having a pre-concatenated string.
     
  9. A) You decompiled the plugin... without my or Caspus' permission, which can cause some problems, because I don't know you.
    B) Why are you complaining? It works. Also, as I said, I am going to use ChatColor.translateAlternateColorCodes() to make the plugin more custom.
     
  10. A) I decompiled the plugin because I wanted to check for anything nefarious. Basically, I was doing Spigot a favour.
    B) I noticed some issues with the code, so I decided to be nice and help you learn how to code better/properly.
     
    • Like Like x 2
  11. You are not teaching my how to code properly. Many, many, many, MANY other users use this way as well. You have only stated one issue as well.
     
  12. ^^^
    Some people just put useless stuff that doesn't do anything
    Then says that it works
    Like an anti-lag plugin I found
    It just teleports the sender to themselves :3
     
  13. Stop trying to use the bandwagon fallacy.
    Also, lets see if you can find one instance of this in Spigot's codebase. I think we can all agree that Spigot is a well coded program :).
     
    • Agree Agree x 1
  14. Anyway, he is allowed to decompile
    1. Use loops, or you will look like a noob
    2. He is trying to help you, so listen :/
    3. Just use the section symbol
     
  15. 1. ... it works...
    2. Not really...
    3. I am going to use this method to make it customizable in a config...
     
  16. Here are the rest of the (obvious) issues in the form of a correctly coded method that does the same thing:
    Code (Text):
    @SuppressWarnings("unused") //I'm not sure if these are visible in the final compile, but you should use them anyway
        @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) //if the action is already cancelled by EventPriority.HIGHEST (it should never be cancelled in EventPriority.MONITOR) there is no reason to check it yourself
        public void signChangeEvent(SignChangeEvent e){
            for(String line : e.getLines()){ //you are calling toString() on an object that is already a String, this makes no sense
                if(line.length() > 15){
                    CommandSender console = Bukkit.getServer().getConsoleSender(); //only get the console sender once it is known there is an error to avoid having to get the sender every single time that a sign is placed -- even legitimate ones
                    Player player = e.getPlayer();
                    e.setCancelled(true); //cancel the event because resources do not need to be wasted checking other lines, and to avoid a duplicate message
                    Bukkit.getServer().dispatchCommand(console, "ban " + e.getPlayer().getName() + " Attempted Sign Hack."); //always do Bukkit.getServer().<method> rather than Bukkit.<method> to ensure that you are using the correct methods rather than a wrapper thereof
                    Bukkit.getServer().broadcast(ChatColor.DARK_RED + "WARNING >> " + ChatColor.RED + player.getName() + " has attempted a sign hack and has been banned.", "antisignhack.notify"); //simplified color codes to improve readability, avoiding translateAlternateColorCodes() to improve performance
                }
            }
        }
    You may use this in your plugin if you state you are doing so here.

    This causes issues when there are multiple developers (ie. if you hand the plugin to someone else, open source pull requests, someone decompiles it, etc.) if those developers are on different operating systems. For instance, when I was programming in Eclipse on Windows it worked fine. But, then when I switched to Linux I found that I had to use a hex editor to remove the faulty symbols. Of course, the reverse happens as well. Lastly, those are hard to type and it is easier to just use ChatColor.<color>.
     
  17. You guys really aren't listenening. I am using translateColorCodes to make the plugin CUSTOMIZABLE IN THE CONFIG FILE. Please stop trying to change that. I really don't understand why you are changing things. The. Plugin. Works.
     
    • Like Like x 1
  18. That may be so, but it is still better practice to use loops. For instance, if you need to make a change to the code then it is easier to change one set of code inside a loop rather than changing all of the code in all places where you have the same code. This issue is even worse when you have more than just four occurrences of the same code.

    What am I doing then?

    THAT. IS. IRREVELANT. (mostly)
     
  19. 1. It doesn't matter whether it works or not, you will never be hired as a developer/work for servers without using loops. You should be using loops whether it works or not.
    2. *facepalm*
    3. Then hurry up and make the config :p

    Also, why do you have a test server, you are encouraging people to come and test their hacks? lol
     
  20. You should then not be using translateAlternateColorCodes() until you actually implement the config file.