mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 14:16:45 +01:00
Tweaks to API
This commit is contained in:
parent
70b1c23f50
commit
f643010f4b
@ -7,17 +7,21 @@ import com.gmail.nossr50.datatypes.chat.ChatChannel;
|
|||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
|
||||||
import com.gmail.nossr50.events.McMMOReplaceVanillaTreasureEvent;
|
import com.gmail.nossr50.events.McMMOReplaceVanillaTreasureEvent;
|
||||||
|
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.party.ShareHandler;
|
import com.gmail.nossr50.party.ShareHandler;
|
||||||
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
|
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
|
||||||
import com.gmail.nossr50.skills.fishing.FishingManager;
|
import com.gmail.nossr50.skills.fishing.FishingManager;
|
||||||
|
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
|
||||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||||
import com.gmail.nossr50.skills.repair.Repair;
|
import com.gmail.nossr50.skills.repair.Repair;
|
||||||
import com.gmail.nossr50.skills.repair.RepairManager;
|
import com.gmail.nossr50.skills.repair.RepairManager;
|
||||||
import com.gmail.nossr50.skills.salvage.Salvage;
|
import com.gmail.nossr50.skills.salvage.Salvage;
|
||||||
import com.gmail.nossr50.skills.salvage.SalvageManager;
|
import com.gmail.nossr50.skills.salvage.SalvageManager;
|
||||||
|
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||||
import com.gmail.nossr50.util.*;
|
import com.gmail.nossr50.util.*;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
@ -28,9 +32,11 @@ import com.gmail.nossr50.util.sounds.SoundType;
|
|||||||
import com.gmail.nossr50.worldguard.WorldGuardManager;
|
import com.gmail.nossr50.worldguard.WorldGuardManager;
|
||||||
import com.gmail.nossr50.worldguard.WorldGuardUtils;
|
import com.gmail.nossr50.worldguard.WorldGuardUtils;
|
||||||
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.entity.minecart.PoweredMinecart;
|
import org.bukkit.entity.minecart.PoweredMinecart;
|
||||||
@ -195,7 +201,6 @@ public class PlayerListener implements Listener {
|
|||||||
*
|
*
|
||||||
* @param event The event to monitor
|
* @param event The event to monitor
|
||||||
*/
|
*/
|
||||||
*/
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPlayerWorldChange(PlayerChangedWorldEvent event) {
|
public void onPlayerWorldChange(PlayerChangedWorldEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
@ -3,7 +3,6 @@ package com.gmail.nossr50.util.player;
|
|||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
|
||||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@ -104,12 +103,8 @@ public final class UserManager {
|
|||||||
return playerCollection;
|
return playerCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is called by PlayerQuitEvent to tear down the mcMMOPlayer.
|
|
||||||
*
|
|
||||||
* @param syncSave if true, data is saved synchronously
|
|
||||||
*/
|
|
||||||
public static void logout(@NotNull McMMOPlayer mmoPlayer, boolean syncSave) {
|
public static void logout(@NotNull McMMOPlayer mmoPlayer, boolean syncSave) {
|
||||||
|
//TODO: T&C copy impl again from master
|
||||||
Player targetPlayer = mmoPlayer.getPlayer();
|
Player targetPlayer = mmoPlayer.getPlayer();
|
||||||
BleedTimerTask.bleedOut(targetPlayer);
|
BleedTimerTask.bleedOut(targetPlayer);
|
||||||
|
|
||||||
@ -136,17 +131,16 @@ public final class UserManager {
|
|||||||
mcMMO.getDatabaseManager().cleanupUser(targetPlayer.getUniqueId());
|
mcMMO.getDatabaseManager().cleanupUser(targetPlayer.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Deprecated
|
||||||
* Get the McMMOPlayer of a player by name.
|
public static @NotNull McMMOPlayer getPlayer(@NotNull String playerName) {
|
||||||
*
|
|
||||||
* @param playerName The name of the player whose McMMOPlayer to retrieve
|
|
||||||
* @return the player's McMMOPlayer object
|
|
||||||
*/
|
|
||||||
public static McMMOPlayer getPlayer(String playerName) {
|
|
||||||
return retrieveMcMMOPlayer(playerName, false);
|
return retrieveMcMMOPlayer(playerName, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static McMMOPlayer getOfflinePlayer(OfflinePlayer player) {
|
public static @NotNull McMMOPlayer queryPlayer(@NotNull String playerName) {
|
||||||
|
return retrieveMcMMOPlayer(playerName, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static @NotNull McMMOPlayer getOfflinePlayer(@NotNull OfflinePlayer player) {
|
||||||
if (player instanceof Player) {
|
if (player instanceof Player) {
|
||||||
return getPlayer((Player) player);
|
return getPlayer((Player) player);
|
||||||
}
|
}
|
||||||
@ -154,16 +148,11 @@ public final class UserManager {
|
|||||||
return retrieveMcMMOPlayer(player.getName(), true);
|
return retrieveMcMMOPlayer(player.getName(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static McMMOPlayer getOfflinePlayer(String playerName) {
|
public static @NotNull McMMOPlayer getOfflinePlayer(@NotNull String playerName) {
|
||||||
return retrieveMcMMOPlayer(playerName, true);
|
return retrieveMcMMOPlayer(playerName, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static @NotNull McMMOPlayer queryPlayer(@NotNull Player player) {
|
||||||
* Gets the McMMOPlayer object for a player, this can be null if the player has not yet been loaded.
|
|
||||||
* @param player target player
|
|
||||||
* @return McMMOPlayer object for this player, null if Player has not been loaded
|
|
||||||
*/
|
|
||||||
public static McMMOPlayer getPlayer(Player player) {
|
|
||||||
//Avoid Array Index out of bounds
|
//Avoid Array Index out of bounds
|
||||||
if(player != null && player.hasMetadata(mcMMO.playerDataKey))
|
if(player != null && player.hasMetadata(mcMMO.playerDataKey))
|
||||||
return (McMMOPlayer) player.getMetadata(mcMMO.playerDataKey).get(0).value();
|
return (McMMOPlayer) player.getMetadata(mcMMO.playerDataKey).get(0).value();
|
||||||
@ -171,7 +160,15 @@ public final class UserManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static McMMOPlayer retrieveMcMMOPlayer(String playerName, boolean offlineValid) {
|
public static @NotNull McMMOPlayer getPlayer(@NotNull Player player) {
|
||||||
|
//Avoid Array Index out of bounds
|
||||||
|
if(player != null && player.hasMetadata(mcMMO.playerDataKey))
|
||||||
|
return (McMMOPlayer) player.getMetadata(mcMMO.playerDataKey).get(0).value();
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static @NotNull McMMOPlayer retrieveMcMMOPlayer(@NotNull String playerName, boolean offlineValid) {
|
||||||
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
|
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user