@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);
}
}
}
java类org.bukkit.event.player.PlayerChangedWorldEvent的实例源码
InventoryListener.java 文件源码
项目:RPGInventory
阅读 25
收藏 0
点赞 0
评论 0
RespawnListeners.java 文件源码
项目:DragonEggDrop
阅读 22
收藏 0
点赞 0
评论 0
@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);
});
}
}
ModuleDisableElytra.java 文件源码
项目:BukkitOldCombatMechanics
阅读 24
收藏 0
点赞 0
评论 0
@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);
}
ModuleAttackCooldown.java 文件源码
项目:BukkitOldCombatMechanics
阅读 18
收藏 0
点赞 0
评论 0
@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();
}
}
PlayerListener.java 文件源码
项目:WorldGuardExtraFlagsPlugin
阅读 20
收藏 0
点赞 0
评论 0
@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)
{
}
}
}
}
}
WorldsChangedListener.java 文件源码
项目:Statz
阅读 19
收藏 0
点赞 0
评论 0
@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()));
}
PetOwnerListener.java 文件源码
项目:SonarPet
阅读 22
收藏 0
点赞 0
评论 0
@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);
}
}
ChatMessageListener.java 文件源码
项目:BloodMoon
阅读 18
收藏 0
点赞 0
评论 0
@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));
}
}
}
}
WorldChangeEvent.java 文件源码
项目:SuperVanish
阅读 23
收藏 0
点赞 0
评论 0
@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);
}
}
MainScoreboardWorldChange.java 文件源码
项目:buildinggame
阅读 27
收藏 0
点赞 0
评论 0
/**
* 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());
}
}
HoloListener.java 文件源码
项目:HoloAPI
阅读 33
收藏 0
点赞 0
评论 0
@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);
}
}
}
PlayerListener.java 文件源码
项目:SwornPermissions
阅读 29
收藏 0
点赞 0
评论 0
@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);
}
PlayerListener.java 文件源码
项目:AlmuraForgeBridge
阅读 24
收藏 0
点赞 0
评论 0
@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);
}
ZoneListener.java 文件源码
项目:Stoa
阅读 29
收藏 0
点赞 0
评论 0
@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.");
}
}
GoogleAnalyticsEventListener.java 文件源码
项目:GoogleAnalyticsPlugin
阅读 28
收藏 0
点赞 0
评论 0
@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());
}
}
}
WarpListener.java 文件源码
项目:tregmine
阅读 26
收藏 0
点赞 0
评论 0
@EventHandler
public void onWarp(PlayerChangedWorldEvent e) {
Player p = e.getPlayer();
if(p.getWorld().getName() != "Christmas"){
return;
}
plugin.getConfig().set("player." + p.getName() + ".warp", plugin.getConfig().getBoolean("player." + p.getName() + ".warp"));
plugin.saveConfig();
if(plugin.getConfig().getBoolean("whitelist.warp.status") == true
&& plugin.getConfig().getBoolean("player." + p.getName() + ".warp") == false){
World world = Bukkit.getServer().getWorld(plugin.getConfig().getString("portal" + ".returnWorld"));
p.teleport(world.getSpawnLocation());
p.sendMessage(ChatColor.RED + plugin.getConfig().getString("whitelist.warp.message"));
}
}
ZoneListener.java 文件源码
项目:Demigods3
阅读 33
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.MONITOR)
public void onWorldSwitch(PlayerChangedWorldEvent event) {
// Only continue if the player is a character
Player player = event.getPlayer();
DemigodsPlayer playerSave = DemigodsPlayer.of(player);
// Leaving a disabled world
if (Zones.isNoDemigodsWorld(event.getFrom()) && !Zones.isNoDemigodsWorld(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 (!Zones.isNoDemigodsWorld(event.getFrom()) && Zones.isNoDemigodsWorld(player.getWorld())) {
if (playerSave.getCharacter() != null) playerSave.setToMortal();
player.sendMessage(ChatColor.GRAY + "Demigods is disabled in this world.");
}
}
PlayerListener.java 文件源码
项目:ScoreboardStats
阅读 48
收藏 0
点赞 0
评论 0
/**
* Check if the player moves in a scoreboard disabled world
*
* @param worldChange the teleport event
* @see com.github.games647.scoreboardstats.RefreshTask
*/
//ignore cancelled events
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onWorldChange(PlayerChangedWorldEvent worldChange) {
Player player = worldChange.getPlayer();
//new world
if (Settings.isActiveWorld(player.getWorld().getName())) {
//old world
if (!Settings.isActiveWorld(worldChange.getFrom().getName())) {
//Activate the scoreboard if it was disabled
plugin.getRefreshTask().addToQueue(player);
}
} else {
//Disable the scoreboard if the player goes into a disabled world
plugin.getRefreshTask().remove(player);
plugin.getScoreboardManager().unregister(player);
}
}
ServerActionsListener.java 文件源码
项目:SpectatorPlus
阅读 17
收藏 0
点赞 0
评论 0
/**
* Handles MultiverseInventories & other similar plugins.
*
* Disables spectate mode to restore proper inventory before world change; then
* re-enables spectate mode to restore spectator inventory after world change.
*/
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldChange(final PlayerChangedWorldEvent ev)
{
final Spectator spectator = p.getPlayerData(ev.getPlayer());
if (spectator.isSpectating())
{
spectator.setWasSpectatorBeforeWorldChanged(true);
spectator.setSpectating(false, null, true, true);
RunTask.later(new Runnable()
{
@Override
public void run()
{
if (spectator.wasSpectatorBeforeWorldChanged())
{
spectator.setSpectating(true, null, true, true);
spectator.setWasSpectatorBeforeWorldChanged(false);
}
}
}, 5l);
}
}
PlayerListener.java 文件源码
项目:SwornGuns
阅读 23
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerChangedWorld(PlayerChangedWorldEvent event)
{
// Updates a player's guns when they change worlds, useful for per-world permissions
if (plugin.getConfig().getBoolean("updateGunsOnWorldChange", false))
{
final Player player = event.getPlayer();
// This basically ensures that permissions have a chance to
// load and accounts for async world changed event
new BukkitRunnable()
{
@Override
public void run()
{
GunPlayer gp = plugin.getGunPlayer(player);
gp.calculateGuns();
}
}.runTaskLater(plugin, 20L);
}
}
PlayerChangedWorldListener.java 文件源码
项目:SelfMadeRegion
阅读 20
收藏 0
点赞 0
评论 0
@EventHandler
public void onPlayerChangedWorld(PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
String halfPath = player.getName().toLowerCase() + "|";
if (Configuration.players.contains(halfPath + player.getWorld().getName().toLowerCase()) || player.getGameMode() == GameMode.CREATIVE) {
if (!player.getAllowFlight()) {
player.setAllowFlight(true);
}
return;
}
if (Configuration.players.contains(halfPath + event.getFrom().getName().toLowerCase())) {
if (player.getAllowFlight()) {
player.setAllowFlight(false);
}
}
}
OrebfuscatorPlayerListener.java 文件源码
项目:AntiCheat
阅读 29
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerChangeWorld(PlayerChangedWorldEvent event) {
BlockHitManager.clearHistory(event.getPlayer());
if (OrebfuscatorConfig.UseProximityHider) {
ProximityHider.clearBlocksForOldWorld(event.getPlayer());
ProximityHider.addPlayerToCheck(event.getPlayer(), null);
}
}
ChunkUnloader.java 文件源码
项目:EscapeLag
阅读 28
收藏 0
点赞 0
评论 0
@EventHandler
public void LeaveWorldCheck(PlayerChangedWorldEvent event) {
if (ConfigOptimize.chunkUnloader == true && event.getFrom().getPlayers().isEmpty()) {
Chunk[] loadedChunks = event.getFrom().getLoadedChunks();
int lcl = loadedChunks.length;
for (int i = 0; i < lcl; i++) {
Chunk chunk = loadedChunks[i];
if (chunk.isLoaded() == true & ChunkKeeper.ShouldKeepList.contains(chunk) == false) {
chunk.unload();
ChunkUnloaderTimes++;
}
}
}
}
Plugin.java 文件源码
项目:MCGameInfoPlugin
阅读 28
收藏 0
点赞 0
评论 0
@EventHandler
public void on(PlayerChangedWorldEvent event) {
if (getConfig().getBoolean("apiOnly") || !enableGameDetector) { return; }
if (resetPattern.matches(event.getPlayer().getWorld().getName())) {
getClient().leaveGame(event.getPlayer().getName(), event.getPlayer().getUniqueId());
} else {
gamePatterns.stream().filter(pattern ->
pattern.matches(event.getPlayer().getWorld().getName())).forEach(pattern ->
getClient().joinGame(event.getPlayer().getName(), event.getPlayer().getUniqueId(), pattern.getGame()));
}
}
PortalListener.java 文件源码
项目:HCFCore
阅读 25
收藏 0
点赞 0
评论 0
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onWorldChanged(PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
World from = event.getFrom();
World to = player.getWorld();
if (from.getEnvironment() != World.Environment.THE_END && to.getEnvironment() == World.Environment.THE_END && player.hasPotionEffect(PotionEffectType.INCREASE_DAMAGE)) {
player.removePotionEffect(PotionEffectType.INCREASE_DAMAGE);
}
}
PortalListener.java 文件源码
项目:HCFCore
阅读 25
收藏 0
点赞 0
评论 0
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onWorldChanged(PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
World from = event.getFrom();
World to = player.getWorld();
if (from.getEnvironment() != World.Environment.THE_END && to.getEnvironment() == World.Environment.THE_END && player.hasPotionEffect(PotionEffectType.INCREASE_DAMAGE)) {
player.removePotionEffect(PotionEffectType.INCREASE_DAMAGE);
}
}
NametagHandler.java 文件源码
项目:NametagEdit
阅读 32
收藏 0
点赞 0
评论 0
/**
* Some users may have different permissions per world.
* If this is enabled, their tag will be reloaded on TP.
*/
@EventHandler
public void onTeleport(final PlayerChangedWorldEvent event) {
if (!refreshTagOnWorldChange) return;
new BukkitRunnable() {
@Override
public void run() {
applyTagToPlayer(event.getPlayer());
}
}.runTaskLater(plugin, 3);
}
PlayerChangedWorldEventListener.java 文件源码
项目:HoloGUIApi
阅读 18
收藏 0
点赞 0
评论 0
@EventHandler
public void playerChangedWorldEvent(PlayerChangedWorldEvent event)
{
Player player = event.getPlayer();
PlayerGUIPage playerGUIContainer = PlayerData.getPlayerData(player).getPlayerGUIPage();
if(playerGUIContainer != null)
{
playerGUIContainer.destroy();
PlayerData.getPlayerData(player).setPlayerGUIPage(null);
PlayerData.getPlayerData(player).setPlayerPreviousGUIPage(null);
}
for(StationaryGUIDisplayContainer stationaryDisplay : holoGUI.getStationaryDisplays())
{
if(stationaryDisplay.playerInRange(player))
{
if(!stationaryDisplay.isDisplayingToPlayer(player))//player in range of display but not currently viewing the stationary gui, make gui visible
{
stationaryDisplay.display(player);
}
}
else if(stationaryDisplay.isDisplayingToPlayer(player))//player was viewing the stationary gui, but moved out of range. Remove the gui for that player
{
stationaryDisplay.destroy(player);
}
}
}
ExprEventWorld.java 文件源码
项目:SharpSK
阅读 19
收藏 0
点赞 0
评论 0
@Override
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean arg2, ParseResult result) {
if (!ScriptLoader.isCurrentEvent(PlayerChangedWorldEvent.class)) {
return false;
} else {
mark = result.mark;
return true;
}
}
ExprEventWorld.java 文件源码
项目:SharpSK
阅读 23
收藏 0
点赞 0
评论 0
@Override
@Nullable
protected World[] get(Event e) {
if (e.getEventName().equals("PlayerChangedWorldEvent")) {
if (mark == 0) {
return new World[] { ((PlayerChangedWorldEvent) e).getPlayer().getWorld() };
} else if (mark == 1) {
return new World[] { ((PlayerChangedWorldEvent) e).getPlayer().getWorld() };
} else if (mark == -1) {
return new World[] { ((PlayerChangedWorldEvent) e).getFrom() };
}
}
return null;
}