本文整理匯總了Java中org.bukkit.event.player.PlayerChangedWorldEvent.getPlayer方法的典型用法代碼示例。如果您正苦於以下問題:Java PlayerChangedWorldEvent.getPlayer方法的具體用法?Java PlayerChangedWorldEvent.getPlayer怎麽用?Java PlayerChangedWorldEvent.getPlayer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.event.player.PlayerChangedWorldEvent
的用法示例。
在下文中一共展示了PlayerChangedWorldEvent.getPlayer方法的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: 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);
}
示例3: 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();
}
}
示例4: 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)
{
}
}
}
}
}
示例5: 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()));
}
示例6: 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);
}
}
示例7: 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));
}
}
}
}
示例8: 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);
}
}
示例9: 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());
}
}
示例10: 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);
}
}
}
示例11: 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);
}
示例12: 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.");
}
}
示例13: 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());
}
}
}
示例14: onWarp
import org.bukkit.event.player.PlayerChangedWorldEvent; //導入方法依賴的package包/類
@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"));
}
}
示例15: 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();
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.");
}
}