本文整理汇总了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);
}
}
}
示例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);
});
}
}
示例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);
}
示例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();
}
}
示例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)
{
}
}
}
}
}
示例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()));
}
示例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);
}
}
示例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));
}
}
}
}
示例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);
}
}
示例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());
}
}
示例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);
}
}
}
示例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);
}
示例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);
}
示例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.");
}
}
示例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());
}
}
}