@EventHandler(priority = EventPriority.MONITOR)
	public void onPlayerChangedWorld(final PlayerChangedWorldEvent event)
	{
		final ISettings settings = ess.getSettings();

		final IUser user = userMap.getUser(event.getPlayer());
		if (settings.getData().getChat().getChangeDisplayname())
		{
			user.updateDisplayName();
		}
		if (!settings.getData().getWorldOptions(event.getPlayer().getLocation().getWorld().getName()).isGodmode() && !Permissions.NOGOD_OVERRIDE.isAuthorized(
				user))
		{
			if (user.getData().isGodmode())
			{
				user.sendMessage(_("§4Warning! God mode in this world disabled."));
			}
		}
		if (settings.getData().getCommands().getTeleport().isCancelRequestsOnWorldChange())
		{
			if (user.getTeleportRequester() != null)
			{
				user.requestTeleport(null, false);
				user.sendMessage(_("teleportRequestsCancelledWorldChange"));
			}
		}
		if (settings.getData().getGeneral().isPtClearOnWorldChange())
		{
			user.getData().clearAllPowertools();
			user.queueSave();
			user.sendMessage(_("§6All powertool commands have been cleared."));
		}
	}
  @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
  public void onPlayerChangeWorld(PlayerChangedWorldEvent event) {
    BlockHitManager.clearHistory(event.getPlayer());

    if (Orebfuscator.config.isProximityHiderEnabled()) {
      ProximityHider.clearBlocksForOldWorld(event.getPlayer());
      ProximityHider.addPlayerToCheck(event.getPlayer(), null);
    }
  }
 @EventHandler
 public void onWorldChange(PlayerChangedWorldEvent e) {
   if (!Config.separateInv) return;
   Player p = e.getPlayer();
   String group = getWorldGroup(p.getWorld()); // get world group (new world)
   if (group == null) return; // only serve those configured
   saveInventory(p, p.getInventory(), e.getFrom()); // save old inventory
   getInventory(p); // sets inv of player
 }
Exemple #4
0
 @EventHandler(priority = EventPriority.LOWEST)
 void playerChangedWorld(PlayerChangedWorldEvent event) {
   if (!plugin.getPlayerManager().isPlayerRegistered(event.getPlayer().getName())) {
     return;
   }
   plugin
       .getChannelManager()
       .playerWorldChange(
           event.getPlayer(), event.getFrom().getName(), event.getPlayer().getWorld().getName());
 }
 @EventHandler(priority = EventPriority.LOWEST)
 public void onPlayerChangedWorld(PlayerChangedWorldEvent event) {
   BukkitMCPlayer currentPlayer =
       (BukkitMCPlayer) Static.GetPlayer(event.getPlayer().getName(), Target.UNKNOWN);
   // Apparently this happens sometimes, so prevent it
   if (!event.getFrom().equals(currentPlayer._Player().getWorld())) {
     EventUtils.TriggerListener(
         Driver.WORLD_CHANGED,
         "world_changed",
         new BukkitPlayerEvents.BukkitMCWorldChangedEvent(event));
   }
 }
  @EventHandler
  public void onSwitchWorld(PlayerChangedWorldEvent change) {
    Game game = Main.getInstance().getGameManager().getGameOfPlayer(change.getPlayer());
    if (game != null) {
      if (game.getState() == GameState.RUNNING) {
        if (!game.getCycle().isEndGameRunning()) {
          if (!game.getPlayerSettings(change.getPlayer()).isTeleporting()) {
            game.playerLeave(change.getPlayer(), false);
          } else {
            game.getPlayerSettings(change.getPlayer()).setTeleporting(false);
          }
        }
      } else if (game.getState() == GameState.WAITING) {
        if (!game.getPlayerSettings(change.getPlayer()).isTeleporting()) {
          game.playerLeave(change.getPlayer(), false);
        } else {
          game.getPlayerSettings(change.getPlayer()).setTeleporting(false);
        }
      }
    }

    if (!Main.getInstance().isHologramsEnabled()
        || Main.getInstance().getHolographicInteractor() == null) {
      return;
    }

    Main.getInstance().getHolographicInteractor().updateHolograms(change.getPlayer());
  }
  @EventHandler
  public void onPlayerWorldSwitch(PlayerChangedWorldEvent e) {
    Player p = e.getPlayer();
    World w = p.getWorld();

    HealthManager.checkPlayerHealth(p, w);
  }
 @EventHandler
 public void potionEffects(PlayerChangedWorldEvent e) {
   if (!Config.separateInv || !Config.removePotionEffects) return;
   Player p = e.getPlayer();
   Collection<PotionEffect> potionEffects = p.getActivePotionEffects();
   if (potionEffects.isEmpty()) return;
   for (PotionEffect pe : potionEffects) {
     if (!p.hasPotionEffect(pe.getType())) continue;
     p.removePotionEffect(pe.getType());
   }
 }
Exemple #9
0
  /**
   * Monitor PlayerChangedWorld events.
   *
   * @param event The event to watch
   */
  @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
  public void onPlayerWorldChangeEvent(PlayerChangedWorldEvent event) {
    Player player = event.getPlayer();
    PlayerProfile profile = Users.getProfile(player);

    if (profile == null) {
      return;
    }

    if (profile.getGodMode()) {
      if (!Permissions.getInstance().mcgod(player)) {
        profile.toggleGodMode();
        player.sendMessage(LocaleLoader.getString("Commands.GodMode.Forbidden"));
      }
    }

    if (profile.inParty()) {
      if (!Permissions.getInstance().party(player)) {
        profile.removeParty();
        player.sendMessage(LocaleLoader.getString("Party.Forbidden"));
      }
    }
  }
  @Override
  public void executeTyped(Listener listener, PlayerChangedWorldEvent event) throws EventException {

    boolean saveRequired = false;
    String fromName = event.getFrom().getName();
    String toName = event.getPlayer().getWorld().getName();

    logger.finer("Player change from " + fromName + " to " + toName);

    try {

      // Save old game mode if required
      String fromWorldMode = plugin.getConfig().getString("worlds." + fromName + ".mode");
      if (fromWorldMode != null) {
        ModeOptions fromMode = ModeOptions.valueOf(fromWorldMode);
        if (fromMode == ModeOptions.REMEMBER) {
          GameMode fromGameMode =
              GameMode.valueOf(plugin.getConfig().getString("worlds." + fromName + ".gamemode"));
          String rememberWorldString =
              plugin
                  .getConfig()
                  .getString(
                      "players." + event.getPlayer().getUniqueId().toString() + "." + fromName);
          { // transition code
            String rememberWorldStringOld =
                plugin
                    .getConfig()
                    .getString("players." + event.getPlayer().getName() + "." + fromName);
            if (rememberWorldStringOld != null) {
              rememberWorldString = rememberWorldStringOld;
              plugin
                  .getConfig()
                  .set(
                      "players." + event.getPlayer().getUniqueId().toString() + "." + fromName,
                      rememberWorldString);
              plugin
                  .getConfig()
                  .set("players." + event.getPlayer().getName() + "." + fromName, null);
              saveRequired = true;
            }
          }
          if (event.getPlayer().getGameMode() != fromGameMode) {
            if (rememberWorldString == null
                || GameMode.valueOf(rememberWorldString) != event.getPlayer().getGameMode()) {
              logger.info("The player has a gamemode different to default. Saving");
              plugin
                  .getConfig()
                  .set(
                      "players." + event.getPlayer().getUniqueId().toString() + "." + fromName,
                      event.getPlayer().getGameMode().toString());
              saveRequired = true;
            }
          }
          if (rememberWorldString != null && event.getPlayer().getGameMode() == fromGameMode) {
            logger.info("The player used to have a unique gamemode but now it is the default");
            plugin.getConfig().set("players." + event.getPlayer().getName(), null);
            saveRequired = true;
          }
        }
      }

      // Change to new gamemode
      String newWorldMode = plugin.getConfig().getString("worlds." + toName + ".mode");
      if (newWorldMode != null) {
        ModeOptions toMode = ModeOptions.valueOf(newWorldMode);
        GameMode toGameMode =
            GameMode.valueOf(plugin.getConfig().getString("worlds." + toName + ".gamemode"));

        if (toMode == ModeOptions.REMEMBER) {
          String rememberWorldString =
              plugin
                  .getConfig()
                  .getString(
                      "players." + event.getPlayer().getUniqueId().toString() + "." + toName);
          { // transition code
            String rememberWorldStringOld =
                plugin
                    .getConfig()
                    .getString("players." + event.getPlayer().getName() + "." + toName);
            if (rememberWorldStringOld != null) {
              rememberWorldString = rememberWorldStringOld;
              plugin
                  .getConfig()
                  .set(
                      "players." + event.getPlayer().getUniqueId().toString() + "." + toName,
                      rememberWorldString);
              plugin.getConfig().set("players." + event.getPlayer().getName() + "." + toName, null);
              saveRequired = true;
            }
          }
          if (rememberWorldString != null) {
            toGameMode = GameMode.valueOf(rememberWorldString);
          }
        }
        if (event.getPlayer().getGameMode() != toGameMode) {
          logger.finer("Changing game mode to " + toGameMode);
          event.getPlayer().setGameMode(toGameMode);
        }
      } else {
        logger.fine("There is no setting for " + toName);
      }
    } finally {
      if (saveRequired) {
        plugin.saveConfig();
      }
    }
  }
 @EventHandler(priority = EventPriority.LOWEST)
 public void onWorldChange(PlayerChangedWorldEvent event) {
   plugin.calculateAttachment(event.getPlayer());
 }
 /**
  * This method is called when a player changes worlds.
  *
  * @param event The Event that was fired.
  */
 @EventHandler(priority = EventPriority.MONITOR)
 public void playerChangedWorld(PlayerChangedWorldEvent event) {
   // Permissions now determine whether or not to handle a gamemode.
   this.handleGameModeAndFlight(event.getPlayer(), event.getPlayer().getWorld());
   playerWorld.put(event.getPlayer().getName(), event.getPlayer().getWorld().getName());
 }