mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 22:56:45 +01:00
Misc was getting crowded again.
This commit is contained in:
parent
05b21eae5f
commit
13a623ea1f
@ -10,7 +10,6 @@ import org.bukkit.command.TabExecutor;
|
|||||||
import org.bukkit.util.StringUtil;
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
@ -40,7 +39,7 @@ public class KrakenCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String playerName = Misc.getMatchedPlayerName(args[0]);
|
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
|
||||||
|
|
||||||
if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
|
if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
|
||||||
|
@ -10,7 +10,6 @@ import org.bukkit.command.TabExecutor;
|
|||||||
import org.bukkit.util.StringUtil;
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
@ -39,7 +38,7 @@ public abstract class ToggleCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String playerName = Misc.getMatchedPlayerName(args[0]);
|
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
|
||||||
|
|
||||||
if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
|
if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
|
||||||
|
@ -11,7 +11,6 @@ import org.bukkit.util.StringUtil;
|
|||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
@ -22,7 +21,7 @@ public class McremoveCommand implements TabExecutor {
|
|||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
String playerName = Misc.getMatchedPlayerName(args[0]);
|
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
||||||
|
|
||||||
if (UserManager.getPlayer(playerName, true) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false))) {
|
if (UserManager.getPlayer(playerName, true) == null && CommandUtils.unloadedProfile(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false))) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -15,7 +15,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
@ -68,7 +67,7 @@ public abstract class ExperienceCommand implements TabExecutor {
|
|||||||
|
|
||||||
int value = Integer.parseInt(args[2]);
|
int value = Integer.parseInt(args[2]);
|
||||||
|
|
||||||
String playerName = Misc.getMatchedPlayerName(args[0]);
|
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||||
|
|
||||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||||
|
@ -16,7 +16,6 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventUtils;
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
@ -65,7 +64,7 @@ public class SkillresetCommand implements TabExecutor {
|
|||||||
skill = SkillType.getSkill(args[1]);
|
skill = SkillType.getSkill(args[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
String playerName = Misc.getMatchedPlayerName(args[0]);
|
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||||
|
|
||||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||||
|
@ -8,7 +8,7 @@ import org.bukkit.entity.Player;
|
|||||||
import com.gmail.nossr50.datatypes.party.Party;
|
import com.gmail.nossr50.datatypes.party.Party;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class PartyChangeOwnerCommand implements CommandExecutor {
|
public class PartyChangeOwnerCommand implements CommandExecutor {
|
||||||
@ -17,7 +17,7 @@ public class PartyChangeOwnerCommand implements CommandExecutor {
|
|||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
|
Party playerParty = UserManager.getPlayer((Player) sender).getParty();
|
||||||
String targetName = Misc.getMatchedPlayerName(args[1]);
|
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
|
||||||
|
|
||||||
if (!playerParty.getMembers().contains(targetName)) {
|
if (!playerParty.getMembers().contains(targetName)) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
|
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
|
||||||
|
@ -9,7 +9,6 @@ import com.gmail.nossr50.datatypes.party.Party;
|
|||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
@ -18,7 +17,7 @@ public class PartyInviteCommand implements CommandExecutor {
|
|||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
String targetName = Misc.getMatchedPlayerName(args[1]);
|
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
|
||||||
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName, true);
|
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName, true);
|
||||||
|
|
||||||
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
||||||
|
@ -9,7 +9,6 @@ import com.gmail.nossr50.datatypes.party.Party;
|
|||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
@ -19,7 +18,7 @@ public class PartyJoinCommand implements CommandExecutor {
|
|||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
String targetName = Misc.getMatchedPlayerName(args[1]);
|
String targetName = CommandUtils.getMatchedPlayerName(args[1]);
|
||||||
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
|
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
|
||||||
|
|
||||||
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
||||||
|
@ -86,7 +86,7 @@ public class PtpCommand implements TabExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sendTeleportRequest(sender, player, Misc.getMatchedPlayerName(args[0]));
|
sendTeleportRequest(sender, player, CommandUtils.getMatchedPlayerName(args[0]));
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -16,7 +16,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|||||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
@ -29,7 +28,7 @@ public class InspectCommand implements TabExecutor {
|
|||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
String playerName = Misc.getMatchedPlayerName(args[0]);
|
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||||
|
|
||||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||||
|
@ -46,7 +46,7 @@ public class McrankCommand implements TabExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String playerName = Misc.getMatchedPlayerName(args[0]);
|
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||||
|
|
||||||
if (mcMMOPlayer != null) {
|
if (mcMMOPlayer != null) {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.gmail.nossr50.runnables.skills;
|
package com.gmail.nossr50.runnables.skills;
|
||||||
|
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
@ -38,7 +40,7 @@ public class AbilityDisableTask extends BukkitRunnable {
|
|||||||
|
|
||||||
case BERSERK:
|
case BERSERK:
|
||||||
if (HiddenConfig.getInstance().resendChunksAfterBlockAbility()) {
|
if (HiddenConfig.getInstance().resendChunksAfterBlockAbility()) {
|
||||||
Misc.resendChunkRadiusAt(player, 1);
|
resendChunkRadiusAt(player, 1);
|
||||||
}
|
}
|
||||||
// Fallthrough
|
// Fallthrough
|
||||||
|
|
||||||
@ -60,4 +62,18 @@ public class AbilityDisableTask extends BukkitRunnable {
|
|||||||
SkillUtils.sendSkillMessage(player, ability.getAbilityPlayerOff(player));
|
SkillUtils.sendSkillMessage(player, ability.getAbilityPlayerOff(player));
|
||||||
new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLaterAsynchronously(mcMMO.p, PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TICK_CONVERSION_FACTOR);
|
new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLaterAsynchronously(mcMMO.p, PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TICK_CONVERSION_FACTOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void resendChunkRadiusAt(Player player, int radius) {
|
||||||
|
Chunk chunk = player.getLocation().getChunk();
|
||||||
|
World world = player.getWorld();
|
||||||
|
|
||||||
|
int chunkX = chunk.getX();
|
||||||
|
int chunkZ = chunk.getZ();
|
||||||
|
|
||||||
|
for (int x = chunkX - radius; x < chunkX + radius; x++) {
|
||||||
|
for (int z = chunkZ - radius; z < chunkZ + radius; z++) {
|
||||||
|
world.refreshChunk(x, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
package com.gmail.nossr50.util;
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
@ -17,7 +13,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
|
||||||
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
|
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
@ -60,37 +55,6 @@ public final class Misc {
|
|||||||
return (entity == null || entity.hasMetadata("NPC") || entity instanceof NPC || (mcMMO.isCombatTagEnabled() && entity instanceof HumanEntity && ((HumanEntity) entity).getName().contains("PvpLogger")) || entity.getClass().getName().equalsIgnoreCase("cofh.entity.PlayerFake"));
|
return (entity == null || entity.hasMetadata("NPC") || entity instanceof NPC || (mcMMO.isCombatTagEnabled() && entity instanceof HumanEntity && ((HumanEntity) entity).getName().contains("PvpLogger")) || entity.getClass().getName().equalsIgnoreCase("cofh.entity.PlayerFake"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the upgrade tier of the item in hand.
|
|
||||||
*
|
|
||||||
* @param inHand The item to check the tier of
|
|
||||||
* @return the tier of the item
|
|
||||||
*/
|
|
||||||
public static int getTier(ItemStack inHand) {
|
|
||||||
int tier = 0;
|
|
||||||
|
|
||||||
if (ItemUtils.isWoodTool(inHand)) {
|
|
||||||
tier = 1;
|
|
||||||
}
|
|
||||||
else if (ItemUtils.isStoneTool(inHand)) {
|
|
||||||
tier = 2;
|
|
||||||
}
|
|
||||||
else if (ItemUtils.isIronTool(inHand)) {
|
|
||||||
tier = 3;
|
|
||||||
}
|
|
||||||
else if (ItemUtils.isGoldTool(inHand)) {
|
|
||||||
tier = 1;
|
|
||||||
}
|
|
||||||
else if (ItemUtils.isDiamondTool(inHand)) {
|
|
||||||
tier = 4;
|
|
||||||
}
|
|
||||||
else if (ModUtils.isCustomTool(inHand)) {
|
|
||||||
tier = ModUtils.getToolFromItemStack(inHand).getTier();
|
|
||||||
}
|
|
||||||
|
|
||||||
return tier;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if two locations are near each other.
|
* Determine if two locations are near each other.
|
||||||
*
|
*
|
||||||
@ -200,74 +164,6 @@ public final class Misc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void resendChunkRadiusAt(Player player, int radius) {
|
|
||||||
Chunk chunk = player.getLocation().getChunk();
|
|
||||||
int chunkX = chunk.getX();
|
|
||||||
int chunkZ = chunk.getZ();
|
|
||||||
|
|
||||||
for (int x = chunkX - radius; x < chunkX + radius; x++) {
|
|
||||||
for (int z = chunkZ - radius; z < chunkZ + radius; z++) {
|
|
||||||
player.getWorld().refreshChunk(x, z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attempts to match any player names with the given name, and returns a list of all possibly matches.
|
|
||||||
*
|
|
||||||
* This list is not sorted in any particular order.
|
|
||||||
* If an exact match is found, the returned list will only contain a single result.
|
|
||||||
*
|
|
||||||
* @param partialName Name to match
|
|
||||||
* @return List of all possible names
|
|
||||||
*/
|
|
||||||
public static List<String> matchPlayer(String partialName) {
|
|
||||||
List<String> matchedPlayers = new ArrayList<String>();
|
|
||||||
|
|
||||||
for (OfflinePlayer offlinePlayer : mcMMO.p.getServer().getOfflinePlayers()) {
|
|
||||||
String playerName = offlinePlayer.getName();
|
|
||||||
|
|
||||||
if (partialName.equalsIgnoreCase(playerName)) {
|
|
||||||
// Exact match
|
|
||||||
matchedPlayers.clear();
|
|
||||||
matchedPlayers.add(playerName);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (playerName.toLowerCase().contains(partialName.toLowerCase())) {
|
|
||||||
// Partial match
|
|
||||||
matchedPlayers.add(playerName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return matchedPlayers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a matched player name if one was found in the database.
|
|
||||||
*
|
|
||||||
* @param partialName Name to match
|
|
||||||
*
|
|
||||||
* @return Matched name or {@code partialName} if no match was found
|
|
||||||
*/
|
|
||||||
public static String getMatchedPlayerName(String partialName) {
|
|
||||||
if (Config.getInstance().getMatchOfflinePlayers()) {
|
|
||||||
List<String> matches = matchPlayer(partialName);
|
|
||||||
|
|
||||||
if (matches.size() == 1) {
|
|
||||||
partialName = matches.get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Player player = mcMMO.p.getServer().getPlayer(partialName);
|
|
||||||
if (player != null) {
|
|
||||||
partialName = player.getName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return partialName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Random getRandom() {
|
public static Random getRandom() {
|
||||||
return random;
|
return random;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import org.bukkit.OfflinePlayer;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
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.datatypes.player.PlayerProfile;
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||||
@ -219,4 +220,60 @@ public final class CommandUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a matched player name if one was found in the database.
|
||||||
|
*
|
||||||
|
* @param partialName Name to match
|
||||||
|
*
|
||||||
|
* @return Matched name or {@code partialName} if no match was found
|
||||||
|
*/
|
||||||
|
public static String getMatchedPlayerName(String partialName) {
|
||||||
|
if (Config.getInstance().getMatchOfflinePlayers()) {
|
||||||
|
List<String> matches = matchPlayer(partialName);
|
||||||
|
|
||||||
|
if (matches.size() == 1) {
|
||||||
|
partialName = matches.get(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Player player = mcMMO.p.getServer().getPlayer(partialName);
|
||||||
|
|
||||||
|
if (player != null) {
|
||||||
|
partialName = player.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return partialName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to match any player names with the given name, and returns a list of all possibly matches.
|
||||||
|
*
|
||||||
|
* This list is not sorted in any particular order.
|
||||||
|
* If an exact match is found, the returned list will only contain a single result.
|
||||||
|
*
|
||||||
|
* @param partialName Name to match
|
||||||
|
* @return List of all possible names
|
||||||
|
*/
|
||||||
|
private static List<String> matchPlayer(String partialName) {
|
||||||
|
List<String> matchedPlayers = new ArrayList<String>();
|
||||||
|
|
||||||
|
for (OfflinePlayer offlinePlayer : mcMMO.p.getServer().getOfflinePlayers()) {
|
||||||
|
String playerName = offlinePlayer.getName();
|
||||||
|
|
||||||
|
if (partialName.equalsIgnoreCase(playerName)) {
|
||||||
|
// Exact match
|
||||||
|
matchedPlayers.clear();
|
||||||
|
matchedPlayers.add(playerName);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (playerName.toLowerCase().contains(partialName.toLowerCase())) {
|
||||||
|
// Partial match
|
||||||
|
matchedPlayers.add(playerName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return matchedPlayers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -355,7 +355,7 @@ public final class CombatUtils {
|
|||||||
* @param type The type of skill being used
|
* @param type The type of skill being used
|
||||||
*/
|
*/
|
||||||
public static void applyAbilityAoE(Player attacker, LivingEntity target, double damage, SkillType type) {
|
public static void applyAbilityAoE(Player attacker, LivingEntity target, double damage, SkillType type) {
|
||||||
int numberOfTargets = Misc.getTier(attacker.getItemInHand()); // The higher the weapon tier, the more targets you hit
|
int numberOfTargets = getTier(attacker.getItemInHand()); // The higher the weapon tier, the more targets you hit
|
||||||
double damageAmount = Math.max(damage, 1);
|
double damageAmount = Math.max(damage, 1);
|
||||||
|
|
||||||
for (Entity entity : target.getNearbyEntities(2.5, 2.5, 2.5)) {
|
for (Entity entity : target.getNearbyEntities(2.5, 2.5, 2.5)) {
|
||||||
@ -581,4 +581,35 @@ public final class CombatUtils {
|
|||||||
|
|
||||||
return damage;
|
return damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the upgrade tier of the item in hand.
|
||||||
|
*
|
||||||
|
* @param inHand The item to check the tier of
|
||||||
|
* @return the tier of the item
|
||||||
|
*/
|
||||||
|
private static int getTier(ItemStack inHand) {
|
||||||
|
int tier = 0;
|
||||||
|
|
||||||
|
if (ItemUtils.isWoodTool(inHand)) {
|
||||||
|
tier = 1;
|
||||||
|
}
|
||||||
|
else if (ItemUtils.isStoneTool(inHand)) {
|
||||||
|
tier = 2;
|
||||||
|
}
|
||||||
|
else if (ItemUtils.isIronTool(inHand)) {
|
||||||
|
tier = 3;
|
||||||
|
}
|
||||||
|
else if (ItemUtils.isGoldTool(inHand)) {
|
||||||
|
tier = 1;
|
||||||
|
}
|
||||||
|
else if (ItemUtils.isDiamondTool(inHand)) {
|
||||||
|
tier = 4;
|
||||||
|
}
|
||||||
|
else if (ModUtils.isCustomTool(inHand)) {
|
||||||
|
tier = ModUtils.getToolFromItemStack(inHand).getTier();
|
||||||
|
}
|
||||||
|
|
||||||
|
return tier;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user