Filled Command Potions

Discussion in 'Plugin Requests' started by Xp10d3, Jul 17, 2020.

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

    Xp10d3

    ~Plugin Category:~ Misc/RPG
    ~Version:~ 1.8.8
    ~What I want:~
    Pretty simple. I think... This is a permission based plugin. Basically, an Admin can do ~/ppot create <name> <color> [custom_model_data] [partical]~ and it will give that user the potion. Let me break this down... Basically, /ppot create creates a potion. If an user drinks that potion, they get a permission that is specified. There are a few properties. <name> is the name of the potion. **Please support Essentials colors** (like &a, &l, etc.). <color> is the color of the potion. Now, since you can't actually SET the color (I don't think), you can just specify what type of potion. For example, if FIRE_RESISTANCE is entered, the potion will LOOK like a fire resistance potion. Or if JUMP_BOOST is entered, the potion will look like a jump boost potion. Next is [custom_model_data], or what custom model data is given to the potion. If I am to use a texture pack, I can change the texture of the actual potion. This is an optional property. Finally is the last property. [partical], or what partical is shown after drinking the potion. There can be many different ones, like HASTE which will show a yellow color, or JUMP_BOOST which will show a green color. Anyways, after creating the potion, the owner/Admin can go into the config file and modify the potion or create an entirely new one in the config. I just added an in-game command to make things easier for myself. ~If you want you can make this entirely config based, I don't care :p~ The config should look something like this:
    Code:
    potions:
      &1[Language Potion]: #The name of the potion.
        color: JUMP #What potion this is based on.
        custom-model-data: 5 #Setting this to -1 disables custom model data.
        partical: HASTE #What particals are shown after drinking the potion.
        empty-after-drink: true #Whether the potion is empty after drinking the potion. If set to false, after drinking the potion it will immediately replenishes.
        time: 5 #How many ticks it takes before the potion effect expires. In this case, it's 5 ticks (yes I know how long a tick is; this is just an example).
        command-on-drink: #The command(s) that is given upon drinking the potion. {player} is the player that drinks the potion.
          - lp user {player} permission set language.gardese
          - ban {player} test lol
        command-expire: #The command(s) that is sent once the potion effect expires. {player} is the player that drank the potion.
          - lp user {player} permission unset language.gardese
          - kick {player} test lol
    
    That's pretty much it...
    ~Commands:~
    /ppot create <name> <color> [custom_model_data] [partical]: Explained in ~What I want~.
    ~Permissions:~
    perm.pot.create: Ability to use /ppot.
    ~When I want this:~ A.S.A.P. of course.
     
  2. Offline

    Xp10d3

  3. Offline

    RageRoringTiger

    Sounds like a cool idea! I might try to make it but I don't have much time :p
     
    Last edited: Jul 19, 2020
  4. Offline

    Xp10d3

    Alright, thanks so much!
     
  5. Offline

    Xp10d3

  6. Offline

    Xp10d3

  7. Offline

    RageRoringTiger

    @Xp10d3 Sorry was looking at upgrading my rig the past couple of days. I hopefully should finish the plugin tonight (but we'll see how it goes :p).

    EDIT: LOL so much for that deadline... I'll have it done tomorrow.
     
    Last edited: Jul 24, 2020
  8. Offline

    Xp10d3

    All g >P Gl with your new rig :D
     
  9. Offline

    RageRoringTiger

    Last edited: Jul 25, 2020
  10. Offline

    Xp10d3

    Thanks so much! I'll try and test this today. I'll let you know about any bugs and such. If there isn't I'll reply and mark this thread as solved.
     
  11. Offline

    RageRoringTiger

    @Xp10d3 xD I left some debug stuff in the plugin but I'll remove it when I fix the plugin.

    EDIT: LOL! The issue was caused by me not changing & -> § (For colors) when checking the potion. It works now!
     
    Last edited: Jul 26, 2020
  12. Offline

    Xp10d3

    Alright, thanks! Been super busy so I'll try and test this today if I got time.
    EDIT 7/28/2020: ahhhh still busy. Will let you know on any updates when I can.
     
    Last edited: Jul 28, 2020
  13. Offline

    Xp10d3

    Hey I downloaded the latest version (and used version 1.1 as well) and get a bunch of errors:
    https://hastebin.com/yusetusowi.cs
    That's me doing /cpot <potion>, /cpot <potion> <user>, /cpot, etc. I'm using Paper with the MC version 1.8.8.
     
  14. Offline

    Wick

    The first few errors are because it seemed to be coded against a later version of spigot/paper, where to change the potion colour he used PotionMeta#setColor which was implemented later on with a particular minecraft update which I can't remember off the top of my head.

    @RageRoringTiger an index in a list will never be null, you need to check for the length of the argument list, so this line is useless and will still cause an ArrayOutOfBounds error (same one in the hastebin)
    Code:
    args[0].equals(null)
    Bukkit#getPlayer returns a player, you don't need to check if it is a player after, only if it's null where no player could be found
    Code:
    Player target = Bukkit.getPlayerExact(args[1]);
                            if (target instanceof Player) {
    I also highly recommend avoiding trees of if statements with negative checks, compare:
    Code:
    if (sender instanceof Player) {
                        if (sender.hasPermission("commandpotions.createpotion")) {
                                 .... code...
    }
    }
    with
    Code:
    if (!(sender instanceof Player)) {
         return false;
    }
    
    if !(sender.hasPermission("commandpotions.createpotion")) {
        return false;
    }
    
    ..code...
    You also spelt usage wrong :^)
    Code:
    sender.sendMessage(ChatColor.RED + "Useage: /cpot <potion> <player>");
     
    Xp10d3 likes this.
  15. Offline

    Xp10d3

  16. Offline

    Xp10d3

  17. Offline

    Xp10d3

    Okay if anyone wants to change the plugin/fix the bugs/make a new plugin let me know. No new updates from RageRoringTiger or on the GitHub.
     
  18. Offline

    RageRoringTiger

    @Xp10d3 Sorry its been so long, life has been a mess recently and I haven't really been able to get on. If I have time I'll try and complete the plugin but if anyone else wants it, have fun.
     
    Xp10d3 likes this.
  19. Offline

    Xp10d3

  20. Offline

    colmalle

    Custom model data wasn't added in 1.14?
     
  21. Offline

    troveg

    Yes you are correct,it was added in 1.14 and tbh i don't know how it can be done in 1.8.8 but he also said that it's optional so i guess it doesn't really matter

    EDIT: Also what would happen if the player disconnected does the timer freeze or the command still get executed if the timer reaches 0 and the player is offline
     
    Last edited: Aug 24, 2020
  22. Offline

    Xp10d3

    Ah, sorry. My bad. I was planning on adding a texture pack to my server, but I guess that won't be the case xD You can just remove the custom model data part than.

    If the player disconnects, the timer continues and the command still gets executed. You can remove the timer entirely if the player is offline.
     
  23. Offline

    troveg

    So if the player disconnects the command-expire will trigger instantly?Also the same should happen in case of a server restart/reload?
     
    Last edited: Aug 24, 2020
  24. Offline

    Xp10d3

    Sorry for the late reply. Yes, the command expire will trigger instantly. Same should happen for server restart/reload. I'm busy and won't be on Bukkit as much as before, but I'll pop in as often as possible.

    EDIT: Someone finished this, marking as filled.
     
    Last edited: Sep 10, 2020
Thread Status:
Not open for further replies.

Share This Page