1 Command at a time

Discussion in 'Plugin Help/Development/Requests' started by SuperBoy1097, Sep 24, 2014.

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

    SuperBoy1097

    Plugin category: IDK

    Suggested name: 1Command

    What I want:
    So i want a plugin that you can only use that command for 1 unless you kill yourself and you can set it on a config, not just that I want it like multiple only 1 command per life, Like you can edit it on the config like put multiple commands together so its like 1 command example
    1commands:
    /kit phantom
    /kit pvp
    /kit monk
    like if u do /kit monk u cant do like /kit pvp too cause u picked monk. I just did this cause I have 2 different kit plugins so they can have like 2 abilities at once which is not fair so I want it like mix them up so u cant use that multiple times

    Ideas for commands:

    /rld command - reloads the plugin

    Ideas for permissions:
    1command.bypass - bypasses so u can use multiple commands
    1cmmand.reload - allows you to reload the plugin
    1command.default - for default so they can't use that command multiple times

    When I'd like it by: A.S.A.P!!!!
     
  2. Offline

    yourmaster01

    I assume you would have certain items to give for each kit(hard coded or in the config)
     
  3. Offline

    dsouzamatt

    SuperBoy1097 I'll make this. Give me half an hour.

    Edit: You can download it here

    You can add the commands to the list, "commands" in the config, and set the message that will be sent to players when they try to use more than one command from that list in their life (chat colour codes supported) under "message". Use /rld 1command to reload the config after you have made any changes.
     
  4. Offline

    SuperBoy1097

    thanks :D, but where is the download?
     
  5. Offline

    dsouzamatt

  6. Offline

    SuperBoy1097

    dsouzamatt likes this.
  7. Offline

    SuperBoy1097

    I need your help, so im using a plugin called SimpleGui Creater and if I do /kit pvp 2 times it says you can only use that command in 1 life or somethin but when i pick a kit like /pvp and i right click the book and click on an item and it excecutes the command /phantom it doesnt say the 1 command at a time and I can still use the command if i do that
     
  8. Offline

    dsouzamatt

  9. Offline

    SuperBoy1097

    what do you mean?
     
  10. Offline

    timtower Moderator Moderator

    Your server log in http://pastebin.com or similar please.
     
  11. Offline

    SuperBoy1097

  12. Offline

    timtower Moderator Moderator

  13. Offline

    dsouzamatt

    SuperBoy1097 Is that what shows when you right click the book in your gui?
     
  14. Offline

    SuperBoy1097

    yeas

    why do you need it? theres no errors or something it just a glitch

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
  15. Offline

    timtower Moderator Moderator

    Glitches can be caused by errors.
     
  16. Offline

    SuperBoy1097

    oh ok here http://pastebin.com/dNFFDcmJ but its not the full one cause i have a lot of plugins
     
  17. Offline

    dsouzamatt

    SuperBoy1097 Hmm... I'm not sure why it's not working. I'll take a look at the plugin on the weekend.
     
  18. Offline

    SuperBoy1097

    thanks :D
     
  19. Offline

    dsouzamatt

    SuperBoy1097 Sorry, I've been busy and haven't had time to work out what the problem is.

    It seems like you plugin is sending the command as the player from the stacktrace that you've shown, but I'm not sure then why the PlayerCommandPreprocessEvent is not firing.

    If anyone else has any ideas, here's the one and only class below:
    Code:java
    1. package me.dsouzamatt.Command;
    2.  
    3. import java.util.ArrayList;
    4. import java.util.List;
    5.  
    6. import org.bukkit.ChatColor;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.event.EventHandler;
    9. import org.bukkit.event.EventPriority;
    10. import org.bukkit.event.Listener;
    11. import org.bukkit.event.entity.PlayerDeathEvent;
    12. import org.bukkit.event.player.PlayerCommandPreprocessEvent;
    13. import org.bukkit.event.server.ServerCommandEvent;
    14. import org.bukkit.plugin.java.JavaPlugin;
    15.  
    16. public class Main extends JavaPlugin implements Listener
    17. {
    18. List<String> commands = new ArrayList<String>();
    19. List<String> players = new ArrayList<String>();
    20.  
    21. @Override
    22. public void onEnable()
    23. {
    24. getServer().getPluginManager().registerEvents(this, this);
    25. loadConfig();
    26. }
    27.  
    28. @Override
    29. public void onDisable()
    30. {
    31. getConfig().set("commands", commands);
    32. getConfig().set("players", players);
    33. saveConfig();
    34. }
    35.  
    36. private void loadConfig()
    37. {
    38. saveDefaultConfig();
    39.  
    40. if(getConfig().getStringList("commands") != null)
    41. {
    42. commands = getConfig().getStringList("commands");
    43. }
    44. else System.out.println("Could not find any commands");
    45.  
    46. if(getConfig().get("players") != null)
    47. {
    48. players = getConfig().getStringList("players");
    49. }
    50. else System.out.println("Could not find any players");
    51. }
    52.  
    53. @EventHandler
    54. public void onConsole(ServerCommandEvent e)
    55. {
    56. if(e.getCommand().toLowerCase().contains("rld 1command"))
    57. {
    58. reloadConfig();
    59. System.out.println("Config for 1Command reloaded");
    60. loadConfig();
    61. }
    62. }
    63.  
    64. @EventHandler(priority = EventPriority.HIGHEST)
    65. public void onPreProcess(PlayerCommandPreprocessEvent e)
    66. {
    67. if(e.getMessage().toLowerCase().contains("rld 1command"))
    68. {
    69. if(e.getPlayer().isOp())
    70. {
    71. reloadConfig();
    72. e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', "&aConfig for &b1Command &areloaded"));
    73. loadConfig();
    74. }
    75. return;
    76. }
    77.  
    78. for(String s:commands)
    79. {
    80. if(e.getMessage().contains(s))
    81. {
    82. Player p = e.getPlayer();
    83.  
    84. if(players.contains(p.getUniqueId().toString()))
    85. {
    86. e.setCancelled(true);
    87.  
    88. if(getConfig().getString("message") != null)
    89. {
    90. p.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("message")));
    91. }
    92. return;
    93.  
    94. }
    95. players.add(p.getUniqueId().toString());
    96. return;
    97.  
    98. }
    99. }
    100. }
    101.  
    102. @EventHandler
    103. public void onDeath(PlayerDeathEvent e)
    104. {
    105. if(players.contains(e.getEntity().getUniqueId().toString()))
    106. {
    107. players.remove(e.getEntity().getUniqueId().toString());
    108. }
    109. }
    110. }
    111.  
     
  20. Offline

    drpk

    dsouzamatt include the / when checking the command message
     
  21. Offline

    timtower Moderator Moderator

    drpk Using contains though, should work just fine the way it is.
     
  22. Offline

    drpk

    timtower oh whoops, thought he was using startsWith()
     
  23. Offline

    timtower Moderator Moderator

    drpk Yeah, didn't notice it at first also :p
    dsouzamatt Try to println messages before you do any checks, then see where it stops sending them.
     
  24. Offline

    SuperBoy1097

    So what do I do?
     
  25. Offline

    timtower Moderator Moderator

    You? Nothing really, just wait till somebody fixes it.
     
  26. Offline

    SuperBoy1097

  27. Offline

    SuperBoy1097

  28. Offline

    dsouzamatt

    SuperBoy1097 I'm having trouble getting the gui plugin to work. What version is your server?
     
  29. Offline

    SuperBoy1097

    I think its spigot 1.7.10, but i think its fine you don't have to do it :D
     
  30. Offline

    dsouzamatt

    Ok, so it's working now?
     
Thread Status:
Not open for further replies.

Share This Page