Plugin per world

Discussion in 'Spigot Plugin Development' started by maxouland1, Jun 6, 2015.

  1. Hello !

    I have make a plugin but I want add a config for choose the world for the plugin: The plugin work in a specific world.
    Do you have a solution ?
  2. on any events the plugin listens to just have a world check at the beginning of them and exit out of it.
    public void onBreak(BlockBreakEvent event){
    Block b = event.getBlock();
    if (!b.getLocation().getWorld().getName().equals(worldName){

    make worldname a variable that's loaded from config
  3. No for BlockBreak but for PlayerEvent.

    public void onPlayerJoin13(PlayerJoinEvent e) {
    Player player = e.getPlayer();

  4. same thing, just player.getWorld
  5. It doesn't work.
  6. In your event, command, or whatever your plugin has, just check the world the player is in.


    Code (Text):
    public void onChat(AsyncPlayerChatEvent e) {
        if (e.getPlayer().getWorld().getName().equals("MyWorld")) {
             // in world, continue code
        } else {
            // not in world, deny stuff
  7. Thank you !!
  8. No problem :)