disable gamemode changed message

Discussion in 'Plugin Development' started by NoLiver92, Aug 24, 2013.

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

    NoLiver92

    how do i, well what it says in the title?
     
  2. Offline

    EcMiner

    You can't
     
  3. Offline

    NoLiver92

    doesnt essentials bypass it though? EcMiner
     
  4. Offline

    bennie3211

    no, those messages are handled client sides! There is no bypass for it!
     
  5. you could block /gamemode 0/1/2, and then make a new command like /gm or something
     
  6. Offline

    KingNyuels

    Try this Listener:
    Code:java
    1.  
    2. List<Player> changedGamemode = new ArrayList<Player>();
    3. @EventHandler(priority = EventPriority.NORMAL)
    4. public void onGameModeChange(PlayerGameModeChangeEvent Event) {
    5. if (changedGamemode.contains(Event.getPlayer())) {
    6. changedGamemode.remove(Event.getPlayer());
    7. } else {
    8. Player p = Event.getPlayer();
    9. changedGamemode.add(p);
    10. GameMode gm = Event.getNewGameMode();
    11. Event.setCancelled(true);
    12. p.sendMessage("Message at GameModeChange here!");
    13. p.setGameMode(gm);
    14. }
    15. }
     
  7. Offline

    NoLiver92

    Datdenkikniet I have but the problem is the test in white "your gamemode has changed" comes up everytime the gm changes
     
  8. KingNyuels
    First of, use camel case. event not Event.
    Also, you don't do anything with the list, you never add anything to it.
    And you shouldn't store the player object here, as soon as the player in the list logs off there will be memory leaks.
    And since you never add anyone to the list, this will crash the server. You cancel the game mode change, but then change it again, which fires a new event, which you cancel etc.
    (sorry for messy message, typed it on my phone)

    What op wants to achieve most likely isn't possible since it is probably a client side message
     
  9. Offline

    KingNyuels

    naithantu
    I use the List, to check, if the Player recently changed his gamemode. If true, i remove him from the List and NOT cancel the Event. I cancel it if the player is not in the List.

    KingNyuels
     
Thread Status:
Not open for further replies.

Share This Page