mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-30 12:37:56 +01:00
Moved some stuff around, added a few functions to PartyAPI
This commit is contained in:
parent
8b4c86c8ba
commit
8bbee7fe06
@ -96,6 +96,7 @@ public class ExperienceAPI {
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to add levels to
|
||||
* @param skillType Type of skill to add levels to
|
||||
* @param levels Number of levels to add
|
||||
*/
|
||||
@ -115,4 +116,16 @@ public class ExperienceAPI {
|
||||
public static int getLevel(Player player, SkillType skillType) {
|
||||
return Users.getProfile(player).getSkillLevel(skillType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the power level of a player.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to get the power level for
|
||||
* @return the power level of the player
|
||||
*/
|
||||
public static int getPowerLevel(Player player) {
|
||||
return Users.getProfile(player).getPowerLevel();
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
|
||||
public class PartyAPI {
|
||||
|
||||
@ -45,12 +46,7 @@ public class PartyAPI {
|
||||
* @return true if the two players are in the same party, false otherwise
|
||||
*/
|
||||
public static boolean inSameParty(Player playera, Player playerb) {
|
||||
if (inParty(playera) && inParty(playerb) && getPartyName(playera).equals(getPartyName(playerb))) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
return Party.getInstance().inSameParty(playera, playerb);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -91,4 +87,18 @@ public class PartyAPI {
|
||||
}
|
||||
return parties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all players in this player's party.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to check
|
||||
* @return all the players in the player's party
|
||||
*/
|
||||
public static ArrayList<Player> getPartyMembers(Player player) {
|
||||
return Party.getInstance().getPartyMembers(player);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public class InspectCommand implements CommandExecutor {
|
||||
if (mcPermissions.getInstance().repair(target))
|
||||
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.RepairSkill"), PPt.getSkillLevel(SkillType.REPAIR), PPt.getSkillXpLevel(SkillType.REPAIR), PPt.getXpToLevel(SkillType.REPAIR)));
|
||||
|
||||
sender.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevel") + ChatColor.GREEN + (m.getPowerLevel(target, PPt)));
|
||||
sender.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevel") + ChatColor.GREEN + (PPt.getPowerLevel()));
|
||||
} else {
|
||||
if(sender instanceof Player && !player.isOp())
|
||||
{
|
||||
|
@ -7,7 +7,6 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
@ -71,7 +70,7 @@ public class McstatsCommand implements CommandExecutor {
|
||||
if (mcPermissions.getInstance().repair(player))
|
||||
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.RepairSkill"), PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR)));
|
||||
}
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevel") + ChatColor.GREEN + (m.getPowerLevel(player, PP)));
|
||||
player.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevel") + ChatColor.GREEN + (PP.getPowerLevel()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1131,6 +1131,24 @@ public class PlayerProfile {
|
||||
return (int) (1020 + (skills.get(skillType) * 20)); //Do we REALLY need to cast to int here?
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the power level of a player.
|
||||
*
|
||||
* @return the power level of the player
|
||||
*/
|
||||
public int getPowerLevel() {
|
||||
Player player = Bukkit.getPlayer(playerName);
|
||||
int powerLevel = 0;
|
||||
|
||||
for (SkillType type : SkillType.values()) {
|
||||
if (type.getPermissions(player)) {
|
||||
powerLevel += getSkillLevel(type);
|
||||
}
|
||||
}
|
||||
|
||||
return powerLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the party XP modifier.
|
||||
*
|
||||
|
@ -6,9 +6,9 @@ import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.HUDmmo;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
|
||||
public class mcSpoutListener implements Listener {
|
||||
@ -30,8 +30,9 @@ public class mcSpoutListener implements Listener {
|
||||
|
||||
if (sPlayer.isSpoutCraftEnabled()) {
|
||||
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer)); //Setup Party HUD stuff
|
||||
Users.getProfile(sPlayer).toggleSpoutEnabled();
|
||||
sPlayer.setTitle(String.valueOf(m.getPowerLevel(sPlayer, Users.getProfile(sPlayer))));
|
||||
PlayerProfile PPs = Users.getProfile(sPlayer);
|
||||
PPs.toggleSpoutEnabled();
|
||||
sPlayer.setTitle(String.valueOf(PPs.getPowerLevel()));
|
||||
}
|
||||
}
|
||||
}
|
@ -11,8 +11,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
|
||||
@ -96,25 +94,6 @@ public class m {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the power level of a player.
|
||||
*
|
||||
* @param player The player to get the power level of
|
||||
* @param PP The profile of the player
|
||||
* @return the power level of the player
|
||||
*/
|
||||
public static int getPowerLevel(Player player, PlayerProfile PP) {
|
||||
int powerLevel = 0;
|
||||
|
||||
for (SkillType type : SkillType.values()) {
|
||||
if (type.getPermissions(player)) {
|
||||
powerLevel += PP.getSkillLevel(type);
|
||||
}
|
||||
}
|
||||
|
||||
return powerLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simulate a block break event.
|
||||
*
|
||||
@ -148,7 +127,7 @@ public class m {
|
||||
* @param inHand The item to check the tier of
|
||||
* @return the tier of the item
|
||||
*/
|
||||
public static Integer getTier(ItemStack inHand) {
|
||||
public static int getTier(ItemStack inHand) {
|
||||
int tier = 0;
|
||||
|
||||
if (ItemChecks.isWoodTool(inHand)) {
|
||||
|
@ -175,7 +175,7 @@ public class Skills {
|
||||
ps.statVal = PP.getSkillLevel(skillType);
|
||||
}
|
||||
else {
|
||||
ps.statVal = m.getPowerLevel(player, PP);
|
||||
ps.statVal = PP.getPowerLevel();
|
||||
}
|
||||
|
||||
ps.name = player.getName();
|
||||
|
Loading…
Reference in New Issue
Block a user