How does MCWarfare make their tutorial (bukkit)?

Discussion in 'Plugin Development' started by mrpickles71, Jun 30, 2013.

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

    mrpickles71

    So I joined this one server to see what kinds of neat things the server has that I might want on mine. Right when you join this server, you need to take a tutorial to advance. During this tutorial, the server denies access to chat, inventory, changing item in hand, and pressing ESC. Also, as I have not been able to find out how to do, the server displays a message (not in chat) right in the middle of your screen. I was wondering what code allows all of these things to be done, for I thought none of these were possible. Thanks

    IP For Server Above: mcwarfare.net
     
  2. Offline

    Aqua

    mrpickles71 I dont know how they disabled the Esc button... But the onscreen chat is made by setting the name of an item.
    They blocked chat, inventory and item in hand change by cancelling the event they belong to.

    Yes, I was in the server.
     
  3. mrpickles71
    There is an event for EVERYTHING that can happen. They just cancelled the events.
     
  4. What...I didn't know that exists? Is this correct? (I guess not?)
     
  5. Offline

    blablubbabc

    I might remember there was something like maybe "closeInventory() each tick" which prevents player from pressing ESC. (preventing them from leaving the server via menu, muhaha)
     
  6. InventoryOpenEvent event, event.setCancelled(true); ?
     
  7. Offline

    skipperguy12

    blablubbabc
    I thought that only closed things like Player Inventories or Chest Inventories?
     
  8. Offline

    Mre30

    I just checked that out... all i can say is ... wow! Very neat!
     
  9. Offline

    LucasEmanuel

    CaptainBern
    InventoryOpenEvent does not fire when a player open their own inventory. :)
     
  10. LucasEmanuel
    Yes it does. CaptainBern
    Yes it is correct, otherwise how would the client know when to bring up menus? The options key activates an event which triggers the menu. This however is clientside and requires a serverside mod (i beleive) to read it from a plugin.
     
  11. Offline

    LucasEmanuel

    Mineblemone
    Um, no it doesn't. It's purely client-side.
     
  12. Offline

    blablubbabc

    I am not sure. I just might remember that this was the case in a version of Spectate, where when you spectated someone you werent't abel to stop spectating (chat was closing also all the time) or leave the server that easy ;P I thought it was because of closeInventory() ..
     
  13. blablubbabc
    It uses a serverside mod (probably) to check for clientside menuOpen event.
     
  14. Offline

    zack6849

    You can't just listen for a client side event like that without a client side modification.
     
  15. Offline

    Rprrr

    I honestly don't see what's so 'special' about this tutorial thing on their server.

    To keep closing the inventory, they're just calling p.closeInventory(); every tick. Everything else is quite simple to make, too.

    And, I don't see why you would choose to annoy your players so much by blocking the ESC-menu. Seems just stupid to me, I wouldn't play on a server that doesn't even allow me to use the disconnect button. I'd say the admins / developers are quite stupid, but that's just my opinion.
     
  16. Rprrr
    That would lag, they cancel the open inventory event.
    zack6849
    Yes you can, you need the server side modification to listen to what is already coded as a client side event.
     
  17. Offline

    Rprrr

    Mineblemone
    Please, read the previous posts in the topic before posting. You obviously didn't, as LucasEmanuel clearly stated the InventoryOpenEvent isn't called for when the player opens his own inventory.

    Also, a simple runnable that runs on every tick wouldn't even cause that much lag - in fact, everything that happens in Minecraft, in the Minecraft server software ánd in Bukkit runs on ticks that are often called 20 times per second. I don't know what you're basing that on, but you wouldn't even notice the lag.

    The fact that they're actually doing this with a runnable becomes even more clear when I press escape rapidly; sometimes I manage to get the escape menu for a split second. Same's for opening my inventory.

    Also, you can't, as zack6849 already stated, simply do a server modification to detect such events without doing a client modification.

    Please read, try to understand what is said and don't just repeat yourself. Especially not when when you do not seem to have too much knowledge of Bukkit plugin development.
     
    zack6849 likes this.
  18. Offline

    slayr288

    Here's a simple way to do this, and is probably how their server does it.
    Code:
        @Override
        public void onEnable() {
            getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                public void run() {
                    for (Player p : getServer().getOnlinePlayers()) {
                        if (p.hasPermission("plugin.tutorial")) {
                            p.closeInventory();
                        } else
                            continue;
                    }
                }
            }, 20L, 1L);
        }
    This will not allow anyone with the permission 'plugin.tutorial' to chat, open an inventory, or use the 'esc' button.
     
  19. Offline

    zack6849

    wouldnt you need
    Code:
     if (!p.hasPermission("plugin.tutorial")) {
    
    Because you close the inventory constantly if they DO have the node
     
  20. Offline

    Mre30

    I'll make this simple...

    He asked for a tutorial/general help, not opinions.

    So... put out, or get out.

    And I agree, the chat on the screen, is probably a item they give a player with that meta.displayname

    The most simple way, would be to cancel the esc like others have said, make perm warps, set your warps.

    While coding, (simple way lol) force the player to run the warp command, freeze them, add the item to slot 1, cancel slot sel and run the warp command again when they right click and make it then else.

    You may hold the record for if then else statements lol... but it would get the job done xD
     
  21. Offline

    slayr288

    zack6849
    True, forgot about permission inheritance.
     
  22. Offline

    mrpickles71

    The only thin I am curious about is that you can't see any items in your inventory. Can you add a display name to AIR?
     
  23. Offline

    GodzOfMadness

    mrpickles71 When I joined the server, I was holding a stick. They also said to turn tool tips on so yes, they were changing the display name of the item.
     
  24. Offline

    x128

    I saw a plugin a few months back for exactly what you're talking about on BukkitDev. Can't seem to find it now.
     
  25. Offline

    mrpickles71

    kk sweet thanks GodzOfMadness and everyone else who helped

    one last thing though, how do they prevent you from changing item in hand (1-9)?

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

    GodzOfMadness

    gabrielhowat likes this.
  27. Offline

    gabrielhowat

    To make the player can not change the slot of your quick bar:

    Code:java
    1. Bukkit.getServer().getScheduler()
    2. .scheduleSyncRepeatingTask(this, new Runnable() {
    3.  
    4. public void run() {
    5. for (Player p : Bukkit.getOnlinePlayers()) {
    6.  
    7. p.getInventory().setHeldItemSlot(0); // The number is the slot of quick bar (0-8)
    8.  
    9.  
    10. }
    11. }
    12. }, 0L, 1L);
     
Thread Status:
Not open for further replies.

Share This Page