本文整理匯總了Java中org.bukkit.event.player.PlayerChangedWorldEvent.getFrom方法的典型用法代碼示例。如果您正苦於以下問題:Java PlayerChangedWorldEvent.getFrom方法的具體用法?Java PlayerChangedWorldEvent.getFrom怎麽用?Java PlayerChangedWorldEvent.getFrom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.event.player.PlayerChangedWorldEvent
的用法示例。
在下文中一共展示了PlayerChangedWorldEvent.getFrom方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onWorldChanged
import org.bukkit.event.player.PlayerChangedWorldEvent; //導入方法依賴的package包/類
@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);
}
}
示例2: onPlayerChangedWorld
import org.bukkit.event.player.PlayerChangedWorldEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerChangedWorld(PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
World from = event.getFrom();
World to = player.getWorld();
PluginConfig worldConfig = plugin.getConfig(to);
if (plugin.isFeatureEnabled(to, Feature.TEXTURE_PACK)) {
if (!plugin.isActive(from) && plugin.isActive(to)) {
player.setResourcePack(worldConfig.getString(Config.FEATURE_TEXTURE_PACK_BLOODMOON));
} else if (plugin.isActive(from) && !plugin.isActive(to)) {
player.setResourcePack(worldConfig.getString(Config.FEATURE_TEXTURE_PACK_NORMAL));
}
}
}
示例3: onPlayerChangeWorld
import org.bukkit.event.player.PlayerChangedWorldEvent; //導入方法依賴的package包/類
@EventHandler
public void onPlayerChangeWorld(final PlayerChangedWorldEvent event) {
final Player player = event.getPlayer();
logDebug("Player " + player.getName() + " changed to " + player.getWorld().getName() + " from "
+ event.getFrom().getName());
if (inFmtl(player)) {
addPlayer(player);
} else if (event.getFrom() == worldManager.getWorld()) {
removePlayer(player);
}
}
示例4: dutyWorldChange
import org.bukkit.event.player.PlayerChangedWorldEvent; //導入方法依賴的package包/類
@EventHandler
public void dutyWorldChange(PlayerChangedWorldEvent e) {
if (e.getPlayer().hasPermission("commandspy.track")) {
Runnable task = new CommandSpyFile(e.getPlayer().getName(), "General", ("Changed worlds from " + e.getFrom() + " to " + getServer().getName()));
new Thread(task, "CommandSpy").start();
}
}
示例5: onPlayerChangedWorld
import org.bukkit.event.player.PlayerChangedWorldEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerChangedWorld(PlayerChangedWorldEvent event)
{
World world = event.getFrom();
if (plugin.isAllWorlds() || plugin.getWorlds().contains(world.getName().toLowerCase()))
{
if (world.getPlayers().isEmpty())
plugin.unloadLater(world, 20L);
}
}
示例6: dutyWorldChange
import org.bukkit.event.player.PlayerChangedWorldEvent; //導入方法依賴的package包/類
@EventHandler
public void dutyWorldChange(PlayerChangedWorldEvent e) {
if (e.getPlayer().hasPermission("commandspy.track")) {
final String name = e.getPlayer().getName();
final World from = e.getFrom();
final String to = SQDuties.getPluginMain().getServer().getName();
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
scheduler.scheduleAsyncDelayedTask(SQDuties.getPluginMain(), new Runnable() {
@Override
public void run() {
(new CommandSpyFile(name, "General", ("Changed worlds from " + from + " to " + to))).run();
}
},1);
}
}
示例7: onWorldLoad
import org.bukkit.event.player.PlayerChangedWorldEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onWorldLoad(PlayerChangedWorldEvent event) {
//plugin.getLogger().info("DEBUG: " + event.getEventName());
Player player = event.getPlayer();
World from = event.getFrom();
if (from != null) {
//plugin.getLogger().info("DEBUG: from is not null");
// Deduce what the new balance needs to be
// All worlds in the same group use the same balance
List<World> groupWorlds = plugin.getGroupWorlds(from);
//plugin.getLogger().info("DEBUG: from group worlds = " + groupWorlds);
if (groupWorlds.contains(player.getWorld())) {
plugin.getPlayers().setBalance(player, from, 0D);
//plugin.getLogger().info("DEBUG: same group, just shift balance");
// The world they are moving to is in the same group, so keep the balance, but remove it from the
// last world otherwise there will be a dupe
} else {
// The player has moved to a new group
// Save their balance in the old world that they just left
double oldBalance = plugin.roundDown(VaultHelper.econ.getBalance(player),2);
//plugin.getLogger().info("DEBUG: old balance = " + oldBalance);
plugin.getPlayers().setBalance(player, from, oldBalance);
// Now work out what their new balance needs to be
double newBalance = 0D;
// Rationalize all the money in the group worlds and put it into the player's world
//plugin.getLogger().info("DEBUG: new group of worlds = " + plugin.getGroupWorlds(player.getWorld()));
for (World world : plugin.getGroupWorlds(player.getWorld())) {
//plugin.getLogger().info("DEBUG: balance in " + world.getName() + " = " + plugin.getPlayers().getBalance(player, world));
newBalance += plugin.getPlayers().getBalance(player, world);
// Set the balance to zero in these other worlds
if (!world.equals(player.getWorld())) {
plugin.getPlayers().setBalance(player, world, 0D);
}
}
plugin.getPlayers().setBalance(player, player.getWorld(), newBalance);
//plugin.getLogger().info("DEBUG: new Balance = " + newBalance);
// Now make the player's economy balance this value
if (oldBalance > newBalance) {
// Withdraw some money to make the oldBalance = newBalance
EconomyResponse response = VaultHelper.econ.withdrawPlayer(player, (oldBalance-newBalance));
if (!response.transactionSuccess()) {
if (response.errorMessage.equalsIgnoreCase("Loan was not permitted")) {
plugin.getLogger().warning("Negative balances not permitted by economy. Setting balance to zero.");
VaultHelper.econ.withdrawPlayer(player, oldBalance);
}
}
} else if (oldBalance < newBalance) {
VaultHelper.econ.depositPlayer(player, (newBalance-oldBalance));
}
}
// Done - show the balance if requested
if (Settings.showBalance) {
player.sendMessage(ChatColor.GOLD + Settings.newWorldMessage.replace("[balance]"
, VaultHelper.econ.format(VaultHelper.econ.getBalance(player))));
}
}
}