Filled Eula compliant plugin: ServerFly

Discussion in 'Plugin Requests' started by MinniPvP, Jun 17, 2016.

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

    MinniPvP

    Plugin category: Fun

    Minecraft version: 1.8.8

    Suggested name: ServerFly

    What I want: I am looking for someone to create me a plugin which will allow me to sell fly (it would be awesome if I could change the time with a command) The thing is that I want everyone that is logged in on the server to get it. Making the plugin Eula compliant.

    Ideas for commands: /flyall 1m|h(how long) (m=minute/h=hour)

    Ideas for permissions: ServerFly.flyall. I would also like a bypass perm for the Admins etc to bypass this plugin. ServerFly.Bypass

    When I'd like it by: As fast as possible if you guys can do it.

    I really appreciate it for taking your time to read the post, and at least considered in making the plugin :)

    Best Regards
    - MinniPvP
     
    Last edited: Jun 17, 2016
  2. Offline

    MrGeneralQ

    I got so much to do already on my to-do list. When the list is done and still nobody is helping you with this, then i'll try.
     
  3. Offline

    ipodtouch0218

    What would this do?

    Should the plugin give flyall to people who join while it's active?
     
  4. Offline

    Minesuchtiiii

    If you could explain a bit more what the plugin should do I would give it a try. So you want to give everyone fly with /flyall [time] ? And why do you need a bypass permission?
     
  5. Offline

    MinniPvP

    Okay, thanks.

    That is the permission to execute the command (/flyall [time]).

    I basically want a plugin that should be executed when someone buys for example a fly perk for 30 minutes in the donation shop. When they have paid, and the command has been executed (Will be using Buycraft) every player which is on the server at that moment, will get fly.

    The reason I wanted the bypass command, is that I don't want the Admins and Owners to get a time limit on their fly while the command is active. I am not sure if I need it, but if I don't let me know!
     
  6. Offline

    ipodtouch0218

  7. Offline

    Minesuchtiiii

    So let me sum this up. If a players buys fly, everyone on the server will get fly. Admins and Operators with the bypass permission won't get it, because they can fly all the time? So I would have to hook Buycraft into the plugin. Shall they be able to always buy the same "fly time" like 10 minutes?
     
  8. Offline

    MinniPvP

    Really? That's awesome! I really appreciate it :)
    Do you know when you could be done, if not that's fine.

    I want the flytime to be at 30 minutes.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
  9. Offline

    ipodtouch0218

    @MinniPvP
    It should be done in around.. max an hour.

    Should players that recently joined (while the event is going) get fly too?
     
  10. Offline

    MinniPvP

    If you could do that it would be awesome. Could you do that so the players that join after the fly has been bought will only get the remaining time of the fly.

    So if I buy the fly, and a player joins 15 minutes after I have bought it, he will only get 15 minutes of fly.

    Thanks!
     
  11. Offline

    ipodtouch0218

    @MinniPvP
    I'm not good with the "1h" and "1m" thing, so you will just have to put in "60" for 1 hour. Is that fine?
    It will go by minutes.
     
  12. Offline

    MinniPvP

    Yeah that's fine :)
     
  13. Offline

    ipodtouch0218

    @MinniPvP
    Should fall damage be disabled for people who were flying when it disabled? I am testing right now and took tons of fall damage when it disabled.
     
  14. Offline

    MinniPvP

    Yeah. Never thought about that, but yeah. I just have a quick question. Will this work with CombatLog/CombatTag? If a player gets hit or interacts in pvp?

    If not, will you be able to make it work with CombatLog/CombatTag, so that they lose their fly when they are in combat?
     
  15. Offline

    ipodtouch0218

    @MinniPvP
    I can do that through CombatTag.
    Bypass won't lose their fly.
     
  16. Offline

    MinniPvP

    Thank you!
     
  17. Offline

    ipodtouch0218

    @MinniPvP
    Turns out I can't figure out how to use CombatTag.
    However, I can just disable fly for "x" time when they get hit or hit someone.

    EDIT: Just tell me the time you want for the delay
     
  18. Offline

    MinniPvP

    The comba time is sat to 10 seconds.
     
  19. Offline

    I Al Istannen

    @ipodtouch0218
    Hey, I wrote a small recursive parser to parse a positive duration to milliseconds. (so "10s" to 10,000 and "1m" to 60,000). It also supports chaining "1s 2m" with any length an in any order. It is quite easy, and just written for you. This means, you can request changes and I will try to implement it. So far it seems to work.
    Usage:
    "long durationInMillis = parseDuration(<String>);"
    You can catch the RuntimeException to notify the user of parsing errors.
    Here it is, it is just a static method:
    Code:
        /**
         * Small recursive parser by I Al Istannen. Bug me about it, I know it is bad!
         *
         * Format:
         * <br>"xxS" ==> milliseconds
         * <br>"xxs" ==> seconds
         * <br>"xxm" ==> minutes
         * <br>"xxh" ==> hours
         * <br>"xxd" ==> days
         *
         * @param input The input string
         * @return The time in milliseconds
         * @throws RuntimeException If an error occured while parsing.
         */
        public static long parseDuration(String input) throws RuntimeException {
            return new Object() {
    
                private int pos = -1, ch;
            
                /**
                 * Goes to the next char
                 */
                private void nextChar() {
                    ch = ++pos < input.length() ? input.charAt(pos) : -1;
                }
            
                /**
                 * Eats a char
                 *
                 * @param charToEat The chat to eat
                 * @return True if the char was found and eaten
                 */
                private boolean eat(int charToEat) {
                    while(ch == ' ') {
                        nextChar();
                    }
                    if(ch == charToEat) {
                        nextChar();
                        return true;
                    }
                    return false;
                }
            
                public long parse() {
                    nextChar();
                    return parsePart();
                }
            
                private long parsePart() {
                    long number = parseNumber();
                    while(ch != -1) {
                        number += parseNumber();
                    }
                
                    return number;
                }
            
                private long parseNumber() {
                    while(ch == ' ') {
                        nextChar();
                    }
                    long number = 0;
                    int start = pos;
                    if(ch >= '0' && ch <= '9') {
                        while(ch >= '0' && ch <= '9') {
                            nextChar();
                        }
                        number = Long.parseLong(input.substring(start, pos));
                    
                        if(eat('S')) {
                            // well, it is already in ms
                        }
                        else if(eat('s')) {
                            number *= 1000;
                        }
                        else if(eat('m')) {
                            number = TimeUnit.MINUTES.toMillis(number);
                        }
                        else if(eat('h')) {
                            number = TimeUnit.HOURS.toMillis(number);                
                        }
                        else if(eat('d')) {
                            number = TimeUnit.DAYS.toMillis(number);                
                        }
                        else {
                            throw new RuntimeException("No unit given near pos " + pos + " starting at " + start);
                        }
                    }
                    else {
                        throw new RuntimeException("Unexpected char at pos " + pos + " " + ch + " '" + (char) ch + "'");
                    }
                
                    return number;
                }
            
            }.parse();
        }
     
    Last edited: Jun 17, 2016
    ipodtouch0218 likes this.
  20. Offline

    ipodtouch0218

    @I Al Istannen
    Thanks :) Got it to work.


    @MinniPvP
    I'm having trouble getting the anti-fly PVP thing working.
    In CombatTagPlus' config files, you can set tagged players to not fly using these booleans (true/false) in the config:
    Code:
    # Prevent tagged players from flying during combat.
    disable-flying: false
    
    # This message is displayed when a player attempts to fly within pvp if flying is disabled in pvp.
    disable-flying-message: '&bFlying &cis disabled in combat.'
    If that's all that you want in the plugin, it's ready to go, including @I Al Istannen's help with "1d, 1s" etc, meaning that works
     
  21. Offline

    I Al Istannen

    @ipodtouch0218
    That is great!
    Glad it works ;)

    Looking forward to how your plugin turns out!
     
  22. Offline

    MinniPvP

    Thank you so much! I really appreciate that you took your time and effort into creating the plugin for me! Is there somewhere I have to go to download the plugin, or will you send it here?

    Thank you too :)
     
  23. Offline

    ipodtouch0218

  24. Offline

    MinniPvP

    @ipodtouch0218. I just thought about something awesome that you could add if possible.

    Will you have the possibility to add extra time to the time that has already been bought. Because I found one problem, and that is if one donates for 30 minutes of fly, and then someone else donates for 30 minutes, when there has just been 15 minutes after the first guy bought it. The time will just reset, and the first guy doesn't get the amount of fly he donated for.

    Would you be able so that when someone buys the fly for 30 min, and then someone else buys it again, the minutes will just be added to the remaining time?

    EDIT: I found the problem. The plugin works excellent, and I am really greatful that you took your time to create me this plugin.
    Will you be able to do what I wrote above?
     
    Last edited: Jun 17, 2016
  25. Offline

    ipodtouch0218

    @MinniPvP
    It may be essentials conflicting with the plugin. Not really sure...
    I'll add the additional time feature, but the time will be reset on a server-restart.
     
  26. Offline

    MinniPvP

    Awesome, thanks! I found the problem, I was using a regionfly plugin, but I deleted it. Now everything works perfectly, and I would love if you could add the time feature.

    One last thing. Will you be able to add a command like /flyall stop. So that I can turn it off or not? If not that's perfectly fine.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
  27. Offline

    ipodtouch0218

  28. Offline

    I Al Istannen

    @ipodtouch0218
    Looks quite nice :)
    What I noticed from glancing at your code, is this:
    Code:
    if (sender instanceof Player) {
      sender.sendMessage
    } else {
      Bukkit.getConsoleSender().sendMessage
    }
    
    You can just delete the if there. You can call sender.sendMessage everytime, no matter if the console executed the command.

    Then you copied the code for "IncorrectUsage" and "NoPermission" two times, extracting that in an own method (sendIncorrectUsage or so) may be cleaner. But this is a minor thing.

    And you used String#replaceAll, which takes a RegEx. Just wanted to make you sure you know that many characters (RegEx meta chars) will break this method if you don't actually put a RegEx in there. You can use String#replace, which will just replace all occurences.

    As often as you use "ChatColor.translateAlternateColorCodes" for a String from the config, a new method like "getColoredStringFromConfig(String key)" which returns the already colored String could save you some work.

    But it does really look quite nice, keep it up :)
     
  29. Offline

    MinniPvP

    Thank you!
     
  30. Offline

    ipodtouch0218

    @I Al Istannen
    Doesn't String#replace take a char not a string? That's why I'm using String#replaceAll
    I'll do all the other things you told me to also.

    EDIT: Nevermind, it does both.
     
    Last edited: Jun 17, 2016
Thread Status:
Not open for further replies.

Share This Page