Temp Mute Help!

Discussion in 'Plugin Development' started by SuperOriginal, Feb 25, 2014.

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

    SuperOriginal

    So i'm trying to make a custom mute plugin, and I need help setting up the temp mute feature. How could I make it so if someone types /mute [player] [int][s,m,h,d,w,y] (ex. /mute bob 5s) it mutes them for 5 seconds? Thanks!
     
  2. Offline

    jthort

    supercube101 Use arguments to grab the strings from the command, then add the player to a list and listen to the chat event, and for the players in that list, cancel the event. Next create a new instance of Bukkit timer and run it for five seconds, after it's up remove the player from the list and cancel the timer.

    Useful threads:
    https://forums.bukkit.org/threads/help-with-muting-players-for-x-amount-of-time.203995/
    https://forums.bukkit.org/threads/muting-chat-for-specific-players.217000/

    Useful links:
    http://jd.bukkit.org/rb/apidocs/org/bukkit/event/player/PlayerChatEvent.html
    http://docs.oracle.com/javase/7/docs/api/java/util/List.html
    http://jd.bukkit.org/rb/apidocs/

    Useful tutorials:
    http://thenewboston.org/tutorials.php
    http://wiki.bukkit.org/Scheduler_Programming
    http://docs.oracle.com/javase/tutorial/
    Good luck!
     
    Jaker232 likes this.
  3. Offline

    SuperOriginal

    Ok so now I have another issue, can anyone tell me how to cancel a temp mute? (E.x I tempmute someone for 30 sec but 10 sec in I want to unmute them) How can I cancel the bukkit runnable without cancelling all the other mutes in progress?
     
  4. Offline

    Traks

    Store the task id's. You can cancel them with
    Code:java
    1. Bukkit.getScheduler().cancelTask(id);
     
  5. Offline

    SuperOriginal

    How can I set up the task id's and make them different for every player muted?
     
  6. Offline

    jthort

    supercube101 put the bukkit timer in a new class and create a constructor. Next just call a new instance of the class to start a new timer.
     
  7. Offline

    ImPhantom

    supercube101
    If your using jthorts method then all you would have to do is remove the player from the list that they were put into when they first got muted.
     
Thread Status:
Not open for further replies.

Share This Page