当前位置: 首页>>代码示例>>Java>>正文


Java PlayerChangedWorldEvent类代码示例

本文整理汇总了Java中org.bukkit.event.player.PlayerChangedWorldEvent的典型用法代码示例。如果您正苦于以下问题:Java PlayerChangedWorldEvent类的具体用法?Java PlayerChangedWorldEvent怎么用?Java PlayerChangedWorldEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PlayerChangedWorldEvent类属于org.bukkit.event.player包,在下文中一共展示了PlayerChangedWorldEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onWorldChanged

import org.bukkit.event.player.PlayerChangedWorldEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onWorldChanged(PlayerChangedWorldEvent event) {
    Player player = event.getPlayer();
    if (!InventoryManager.playerIsLoaded(player)) {
        if (InventoryManager.isAllowedWorld(player.getWorld())) {
            InventoryManager.initPlayer(player, InventoryManager.isAllowedWorld(event.getFrom()));
        }

        return;
    }

    if (!InventoryManager.isAllowedWorld(player.getWorld())) {
        InventoryManager.unloadPlayerInventory(player);
    } else {
        if (InventoryManager.get(player).hasPet()) {
            PetManager.respawnPet(player);
        }
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:20,代码来源:InventoryListener.java

示例2: onPlayerSwitchWorlds

import org.bukkit.event.player.PlayerChangedWorldEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerSwitchWorlds(PlayerChangedWorldEvent event) {
	World world = event.getPlayer().getWorld();
	if (world.getEnvironment() != Environment.THE_END) return;
	
	EndWorldWrapper worldWrapper = manager.getWorldWrapper(world);
	
	// Start the respawn countdown if joining an empty world
	if (plugin.getConfig().getBoolean("respawn-on-join", false)) {
		if (world.getPlayers().size() > 1 || worldWrapper.isRespawnInProgress()
				|| world.getEntitiesByClass(EnderDragon.class).size() == 0) 
			return;
		
		manager.getWorldWrapper(world).startRespawn(RespawnType.JOIN);
	}
	
	// Reset end crystal states just in case something went awry
	if (!worldWrapper.isRespawnInProgress()) {
		world.getEntitiesByClass(EnderCrystal.class).forEach(e -> {
			e.setInvulnerable(false);
			e.setBeamTarget(null);
		});
	}
}
 
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:25,代码来源:RespawnListeners.java

示例3: onWorldChange

import org.bukkit.event.player.PlayerChangedWorldEvent; //导入依赖的package包/类
@EventHandler (priority = EventPriority.HIGHEST)
public void onWorldChange(PlayerChangedWorldEvent e){
	Player p = e.getPlayer();
	World w = p.getWorld();
	if(!isEnabled(w)) return;

	PlayerInventory inv = p.getInventory();

	ItemStack chestplate = inv.getChestplate();

	if(chestplate == null || chestplate.getType() != Material.ELYTRA) return;

	inv.setChestplate(new ItemStack(Material.AIR));

	if(inv.firstEmpty() != -1)
		inv.addItem(chestplate);
	else
		w.dropItem(p.getLocation(), chestplate);
}
 
开发者ID:gvlfm78,项目名称:BukkitOldCombatMechanics,代码行数:20,代码来源:ModuleDisableElytra.java

示例4: onWorldChange

import org.bukkit.event.player.PlayerChangedWorldEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onWorldChange(PlayerChangedWorldEvent e) {
	Player player = e.getPlayer();
	World world = player.getWorld();
	
	double GAS = module().getDouble("generic-attack-speed");
	
	AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
	double baseValue = attribute.getBaseValue();
	
	if(!Config.moduleEnabled("disable-attack-cooldown", world))
		GAS = 4; //If module is disabled, set attack speed to 1.9 default
	
	if(baseValue!=GAS){
		attribute.setBaseValue(GAS);
		player.saveData();
	}
}
 
开发者ID:gvlfm78,项目名称:BukkitOldCombatMechanics,代码行数:19,代码来源:ModuleAttackCooldown.java

示例5: onPlayerChangedWorldEvent

import org.bukkit.event.player.PlayerChangedWorldEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerChangedWorldEvent(PlayerChangedWorldEvent event)
{
	Player player = event.getPlayer();
	
	if (WorldGuardExtraFlagsPlugin.isEssentialsEnable()) //Essentials how dare u do this to me!?!
	{
		if (!WorldGuardUtils.hasBypass(player))
		{
			if (player.getGameMode() != GameMode.CREATIVE && !WorldGuardExtraFlagsPlugin.getEssentialsPlugin().getUser(player).isAuthorized("essentials.fly"))
			{
				//Essentials now turns off flight, fuck him
				
				try
				{
					player.setAllowFlight(WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getSessionManager().get(player).getHandler(FlyFlag.class).getCurrentValue());
				}
				catch(Exception ignored)
				{
					
				}
			}
		}
	}
}
 
开发者ID:isokissa3,项目名称:WorldGuardExtraFlagsPlugin,代码行数:26,代码来源:PlayerListener.java

示例6: onWorldSwitch

import org.bukkit.event.player.PlayerChangedWorldEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldSwitch(final PlayerChangedWorldEvent event) {

	final PlayerStat stat = PlayerStat.WORLDS_CHANGED;

	// Get player
	final Player player = (Player) event.getPlayer();

	// Do general check
	if (!plugin.doGeneralCheck(player, stat))
		return;

	// Update value to new stat.
	plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat,
			StatzUtil.makeQuery("uuid", player.getUniqueId().toString(), "value", 1, "world",
					event.getFrom().getName(), "destWorld", player.getWorld().getName()));

}
 
开发者ID:Staartvin,项目名称:Statz,代码行数:19,代码来源:WorldsChangedListener.java

示例7: onWorldChange

import org.bukkit.event.player.PlayerChangedWorldEvent; //导入依赖的package包/类
@EventHandler
public void onWorldChange(PlayerChangedWorldEvent event) {
    final Player p = event.getPlayer();
    final IPet pi = EchoPet.getManager().getPet(p);
    if (pi != null) {
        EchoPet.getManager().saveFileData("autosave", pi);
        EchoPet.getSqlManager().saveToDatabase(pi, false);
        EchoPet.getManager().removePet(pi, false);
        new BukkitRunnable() {

            @Override
            public void run() {
                EchoPet.getManager().loadPets(p, false, false, false);
            }

        }.runTaskLater(EchoPet.getPlugin(), 20L);
    }
}
 
开发者ID:TechzoneMC,项目名称:SonarPet,代码行数:19,代码来源:PetOwnerListener.java

示例8: onPlayerChangedWorld

import org.bukkit.event.player.PlayerChangedWorldEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerChangedWorld(PlayerChangedWorldEvent event) {
    Player player = event.getPlayer();
    World world = player.getWorld();
    PluginConfig worldConfig = plugin.getConfig(world);

    if (plugin.isFeatureEnabled(world, Feature.CHAT_MESSAGE)) {
        String message = worldConfig.getString(Config.FEATURE_CHAT_MESSAGE_START_MESSAGE);

        if (!message.isEmpty()) {
            if (plugin.isActive(world)) {
                player.sendMessage(ChatColor.translateAlternateColorCodes('&', message));
            }
        }
    }
}
 
开发者ID:Samistine,项目名称:BloodMoon,代码行数:17,代码来源:ChatMessageListener.java

示例9: onWorldChange

import org.bukkit.event.player.PlayerChangedWorldEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onWorldChange(PlayerChangedWorldEvent e) {
    try {
        final Player p = e.getPlayer();
        if (!plugin.getVanishStateMgr().isVanished(p.getUniqueId()))
            return;
        // check auto-reappear option
        if (plugin.getSettings().getBoolean("VanishStateFeatures.ReappearOnWorldChange")
                || plugin.getSettings().getBoolean("VanishStateFeatures.CheckPermissionOnWorldChange")
                && !CommandAction.VANISH_SELF.checkPermission(p, plugin)) {
            plugin.getVisibilityChanger().showPlayer(p);
        }
    } catch (Exception er) {
        plugin.logException(er);
    }
}
 
开发者ID:MyzelYam,项目名称:SuperVanish,代码行数:17,代码来源:WorldChangeEvent.java

示例10: onWorldChange

import org.bukkit.event.player.PlayerChangedWorldEvent; //导入依赖的package包/类
/**
    * Handles the main scoreboard for players switching worlds
    *
    * @param e an event representing a player who switched between worlds
    * @see PlayerChangedWorldEvent
    * @since 3.1.1
    */
@EventHandler
public void onWorldChange(PlayerChangedWorldEvent e) {
	YamlConfiguration config = SettingsManager.getInstance().getConfig();
	
	Player player = e.getPlayer();
	MainScoreboardManager manager = MainScoreboardManager.getInstance();
	
	if (!config.getBoolean("scoreboards.main.enable"))
		return;
	
	if (config.getStringList("scoreboards.main.worlds.enable").contains(player.getWorld().getName()))
		//show scoreboard and other stuff
		manager.register(player);
	else if (config.getStringList("scoreboards.main.worlds.enable").contains(e.getFrom().getName())) {
		//show scoreboard and other stuff
		manager.remove(player);
		player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
	}
}
 
开发者ID:stefvanschie,项目名称:buildinggame,代码行数:27,代码来源:MainScoreboardWorldChange.java

示例11: onWorldChange

import org.bukkit.event.player.PlayerChangedWorldEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldChange(PlayerChangedWorldEvent event) {
    final Player player = event.getPlayer();
    for (final Hologram h : HoloAPI.getManager().getAllHolograms().keySet()) {
        if (player.getLocation().getWorld().getName().equals(h.getWorldName()) && h.getVisibility().isVisibleTo(player, h.getSaveId())) {
            if (h instanceof AnimatedHologram && !((AnimatedHologram) h).isAnimating()) {
                ((AnimatedHologram) h).animate();
            }
            h.show(player, true);
        } else if (event.getFrom().getName().equals(h.getWorldName()) && h.getLocationFor(player) != null) {
            new BukkitRunnable() {
                @Override
                public void run() {
                    h.clear(player);
                }
            }.runTaskLater(HoloAPI.getCore(), 20L);
        }
    }
}
 
开发者ID:DSH105,项目名称:HoloAPI,代码行数:20,代码来源:HoloListener.java

示例12: onPlayerChangedWorld

import org.bukkit.event.player.PlayerChangedWorldEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerChangedWorld(PlayerChangedWorldEvent event)
{
	Player player = event.getPlayer();
	User user = plugin.getPermissionHandler().getUser(player);
	if (user == null)
	{
		player.sendMessage(plugin.getPrefix() + FormatUtil.format("Failed to get a user instance! Contact an administrator!"));
		return;
	}

	user = plugin.getPermissionHandler().moveWorld(player, event.getFrom(), player.getWorld());

	boolean force = plugin.getConfig().getBoolean("forceUpdate.worldChange", false);
	user.updatePermissions(player, force);
}
 
开发者ID:dmulloy2,项目名称:SwornPermissions,代码行数:17,代码来源:PlayerListener.java

示例13: onPlayerChangedWorld

import org.bukkit.event.player.PlayerChangedWorldEvent; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerChangedWorld(final PlayerChangedWorldEvent event) {
    Bukkit.getScheduler().scheduleAsyncDelayedTask(BridgePlugin.getInstance(), new Runnable() {
        @Override
        public void run() {
            final ClaimedResidence res = Residence.getResidenceManager().getByLoc(event.getPlayer().getLocation());
            ServerWorldUtil.sendResidenceInfo(event.getPlayer(), res);

            for (Player player : Bukkit.getServer().getOnlinePlayers()) {
                ServerWorldUtil.sendAdditionalWorldInfo(player, player.getWorld().getName(), Bukkit.getOnlinePlayers().size(), Bukkit.getMaxPlayers());
                TitleUtil.sendDisplayName(player, event.getPlayer().getName(), ChatColor.stripColor(event.getPlayer().getDisplayName()) + "\n" + TitleUtil.getCustomTitle(event.getPlayer()));
                TitleUtil.sendDisplayName(event.getPlayer(), player.getName(), ChatColor.stripColor(player.getDisplayName()) + "\n" + TitleUtil.getCustomTitle(player));
            }
        }
    }, 20L);
}
 
开发者ID:AlmuraDev,项目名称:AlmuraForgeBridge,代码行数:18,代码来源:PlayerListener.java

示例14: onWorldSwitch

import org.bukkit.event.player.PlayerChangedWorldEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onWorldSwitch(PlayerChangedWorldEvent event) {
    // Only continue if the player is a character
    Player player = event.getPlayer();
    PlayerModel playerSave = PlayerUtil.fromPlayer(player);

    // Leaving a disabled world
    if (ZoneUtil.isNoStoaWorld(event.getFrom()) && !ZoneUtil.isNoStoaWorld(player.getWorld())) {
        if (playerSave.getCharacter() != null) {
            playerSave.saveMortalInventory(player);
            playerSave.getCharacter().applyToPlayer(player);
        }
        player.sendMessage(ChatColor.YELLOW + "Demigods is enabled in this world.");
    }
    // Entering a disabled world
    else if (!ZoneUtil.isNoStoaWorld(event.getFrom()) && ZoneUtil.isNoStoaWorld(player.getWorld())) {
        if (playerSave.getCharacter() != null) playerSave.setToMortal();
        player.sendMessage(ChatColor.GRAY + "Demigods is disabled in this world.");
    }
}
 
开发者ID:DemigodsRPG,项目名称:Stoa,代码行数:21,代码来源:ZoneListener.java

示例15: onPlayerChangedWorld

import org.bukkit.event.player.PlayerChangedWorldEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerChangedWorld(PlayerChangedWorldEvent event){
	if(enableEventEnter) {
		try {
			Player player = event.getPlayer();
		
			if(!player.hasPermission("googleanalyticsplugin.ignore")) {
				String worldName = player.getLocation().getWorld().getName();
				
				plugin.getTracker().TrackAction(getClientName(plugin, player), getClientId(player), getClientIP(player.getAddress().getAddress()), player.getName(), "Enter", worldName);
			}
		}
		catch(Exception e) {
			plugin.getLogger().warning("Event Listener Error: " + e.getMessage());
		}
	}
}
 
开发者ID:Fox32,项目名称:GoogleAnalyticsPlugin,代码行数:18,代码来源:GoogleAnalyticsEventListener.java


注:本文中的org.bukkit.event.player.PlayerChangedWorldEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。