mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-30 00:56:47 +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>
|
* </br>
|
||||||
* This function is designed for API usage.
|
* 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 skillType Type of skill to add levels to
|
||||||
* @param levels Number of levels to add
|
* @param levels Number of levels to add
|
||||||
*/
|
*/
|
||||||
@ -115,4 +116,16 @@ public class ExperienceAPI {
|
|||||||
public static int getLevel(Player player, SkillType skillType) {
|
public static int getLevel(Player player, SkillType skillType) {
|
||||||
return Users.getProfile(player).getSkillLevel(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 org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.Users;
|
import com.gmail.nossr50.Users;
|
||||||
|
import com.gmail.nossr50.party.Party;
|
||||||
|
|
||||||
public class PartyAPI {
|
public class PartyAPI {
|
||||||
|
|
||||||
@ -45,12 +46,7 @@ public class PartyAPI {
|
|||||||
* @return true if the two players are in the same party, false otherwise
|
* @return true if the two players are in the same party, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean inSameParty(Player playera, Player playerb) {
|
public static boolean inSameParty(Player playera, Player playerb) {
|
||||||
if (inParty(playera) && inParty(playerb) && getPartyName(playera).equals(getPartyName(playerb))) {
|
return Party.getInstance().inSameParty(playera, playerb);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,4 +87,18 @@ public class PartyAPI {
|
|||||||
}
|
}
|
||||||
return parties;
|
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))
|
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(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 {
|
} else {
|
||||||
if(sender instanceof Player && !player.isOp())
|
if(sender instanceof Player && !player.isOp())
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,6 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gmail.nossr50.Users;
|
import com.gmail.nossr50.Users;
|
||||||
import com.gmail.nossr50.m;
|
|
||||||
import com.gmail.nossr50.mcPermissions;
|
import com.gmail.nossr50.mcPermissions;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.SkillType;
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
@ -71,7 +70,7 @@ public class McstatsCommand implements CommandExecutor {
|
|||||||
if (mcPermissions.getInstance().repair(player))
|
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(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;
|
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?
|
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.
|
* Calculate the party XP modifier.
|
||||||
*
|
*
|
||||||
|
@ -6,9 +6,9 @@ import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
|
|||||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||||
|
|
||||||
import com.gmail.nossr50.Users;
|
import com.gmail.nossr50.Users;
|
||||||
import com.gmail.nossr50.m;
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.datatypes.HUDmmo;
|
import com.gmail.nossr50.datatypes.HUDmmo;
|
||||||
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.spout.SpoutStuff;
|
import com.gmail.nossr50.spout.SpoutStuff;
|
||||||
|
|
||||||
public class mcSpoutListener implements Listener {
|
public class mcSpoutListener implements Listener {
|
||||||
@ -30,8 +30,9 @@ public class mcSpoutListener implements Listener {
|
|||||||
|
|
||||||
if (sPlayer.isSpoutCraftEnabled()) {
|
if (sPlayer.isSpoutCraftEnabled()) {
|
||||||
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer)); //Setup Party HUD stuff
|
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer)); //Setup Party HUD stuff
|
||||||
Users.getProfile(sPlayer).toggleSpoutEnabled();
|
PlayerProfile PPs = Users.getProfile(sPlayer);
|
||||||
sPlayer.setTitle(String.valueOf(m.getPowerLevel(sPlayer, 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.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
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.FakeBlockBreakEvent;
|
||||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||||
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
|
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.
|
* Simulate a block break event.
|
||||||
*
|
*
|
||||||
@ -148,7 +127,7 @@ public class m {
|
|||||||
* @param inHand The item to check the tier of
|
* @param inHand The item to check the tier of
|
||||||
* @return the tier of the item
|
* @return the tier of the item
|
||||||
*/
|
*/
|
||||||
public static Integer getTier(ItemStack inHand) {
|
public static int getTier(ItemStack inHand) {
|
||||||
int tier = 0;
|
int tier = 0;
|
||||||
|
|
||||||
if (ItemChecks.isWoodTool(inHand)) {
|
if (ItemChecks.isWoodTool(inHand)) {
|
||||||
|
@ -175,7 +175,7 @@ public class Skills {
|
|||||||
ps.statVal = PP.getSkillLevel(skillType);
|
ps.statVal = PP.getSkillLevel(skillType);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ps.statVal = m.getPowerLevel(player, PP);
|
ps.statVal = PP.getPowerLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
ps.name = player.getName();
|
ps.name = player.getName();
|
||||||
|
Loading…
Reference in New Issue
Block a user