Gamemode Changing problem

Discussion in 'Plugin Development' started by monkeymanboy, Sep 28, 2013.

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

    monkeymanboy

    I'm setting up a system of creative for my plots world
    heres my code
    Code:java
    1. @EventHandler
    2. public void GamemodeWorld(PlayerChangedWorldEvent event){
    3. if(!(event.getPlayer().getGameMode() == GameMode.ADVENTURE))
    4. if(!event.getPlayer().getWorld().getName().equals("plotworld")){
    5. event.getPlayer().setGameMode(GameMode.SURVIVAL);
    6. } else if(event.getPlayer().getWorld().getName().equals("plotworld")){
    7. if(event.getPlayer().hasPermission("plotworld.premium"));
    8. event.getPlayer().setGameMode(GameMode.CREATIVE);
    9. }
    10. }
    11. @EventHandler
    12. public void GamemodeLogin(PlayerLoginEvent event){
    13. if(event.getPlayer().hasPermission("plotworld.premium")){
    14. if(!event.getPlayer().getWorld().getName().equals("plotworld"))
    15. event.getPlayer().setGameMode(GameMode.SURVIVAL);
    16. } else
    17. event.getPlayer().setGameMode(GameMode.SURVIVAL);
    18. }

    PROBLEMS: It make my gamemode creative then survival again if I go to plotworld and if I join in plotworld it sets me back to survival if im in creative
     

  2. @monkeymanboy
    that's not a plugin error. that's because you changed world. you have different Player.dat, so you'll have different gamemode, i don't know if theres a work around sorry!

    EDIT: ok so i took another look, you'll need to add a clock, so every 10 secconds, annyone in plotworld will change to creative, and if you dont want to do that, just add an essential sign, and make it
    Code:
    [GAMEMODE]
    CREATIVE
    and give the perm to everyone in plotworld, that would be my probfix.
     
  3. Offline

    monkeymanboy

    2000callum Couldn't I just add a delay then so that it changes it as soon as they are in that world?
     

  4. monkeymanboy thats actually smarter, i dont know how that would work, but what im thinking is PlayerListener and use a wait, count down 4 secconds, and then do it. because that would make it less ram consuming, as-well as less code-script you'll have to write, i just took a lookinto bukkit and couldent find a working code with my no-lage, but im sure you can work it out!
     
  5. Offline

    monkeymanboy

    2000callum I think I can just do this
    Code:java
    1. this.getServer().getScheduler().scheduleAsyncDelayedTask(this, new Runnable() {

    EDIT: works
     
  6. well, ok glad it worked. i hope i helped you, + you just helped me aswell!
     
Thread Status:
Not open for further replies.

Share This Page