use of com.gmail.nossr50.datatypes.party.Party in project Foundation by kangarko.
the class ItemsAdderHook method getActivePartyChat.
String getActivePartyChat(final Player player) {
try {
final McMMOPlayer mcplayer = UserManager.getPlayer(player);
if (mcplayer != null) {
final Party party = mcplayer.getParty();
final ChatChannel channelType = mcplayer.getChatChannel();
return channelType == ChatChannel.PARTY || channelType == ChatChannel.PARTY_OFFICER && party != null ? party.getName() : null;
}
} catch (final Throwable throwable) {
if (!errorLogged) {
Common.warning("Failed getting mcMMO party chat for " + player.getName() + " due to error. Returning null." + " Ensure you have the latest mcMMO version, if so, contact plugin authors to update the integration. Error was: " + throwable);
errorLogged = true;
}
}
return null;
}
use of com.gmail.nossr50.datatypes.party.Party in project Depenizen by DenizenScript.
the class McMMOCommand method execute.
@Override
public void execute(ScriptEntry scriptEntry) {
ElementTag action = scriptEntry.getElement("action");
ElementTag state = scriptEntry.getElement("state");
ElementTag type = scriptEntry.getElement("type");
ElementTag quantity = scriptEntry.getElement("quantity");
ElementTag party = scriptEntry.getElement("party");
ElementTag skill = scriptEntry.getElement("skill");
PlayerTag player = Utilities.getEntryPlayer(scriptEntry);
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), action, type, state, quantity, party, skill);
}
switch(Action.valueOf(action.asString().toUpperCase())) {
case ADD:
{
if (quantity.asDouble() >= 0 && skill != null && player != null) {
switch(Type.valueOf(type.asString().toUpperCase())) {
case LEVELS:
{
if (player.isOnline()) {
ExperienceAPI.addLevel(player.getPlayerEntity(), skill.asString(), quantity.asInt());
} else {
ExperienceAPI.addLevelOffline(player.getName(), skill.asString(), quantity.asInt());
}
break;
}
case XP:
{
if (player.isOnline()) {
ExperienceAPI.addRawXP(player.getPlayerEntity(), skill.asString(), quantity.asFloat());
} else {
ExperienceAPI.addRawXPOffline(player.getName(), skill.asString(), quantity.asFloat());
}
}
}
} else if (party != null && PartyManager.getParty(party.asString()) != null) {
PartyAPI.addToParty(player.getPlayerEntity(), party.asString());
}
break;
}
case REMOVE:
{
if (quantity.asDouble() >= 0 && skill != null && player != null) {
switch(Type.valueOf(type.asString().toUpperCase())) {
case LEVELS:
{
if (player.isOnline()) {
ExperienceAPI.setLevel(player.getPlayerEntity(), skill.asString(), ExperienceAPI.getLevel(player.getPlayerEntity(), skill.asString()) - quantity.asInt());
} else {
ExperienceAPI.setLevelOffline(player.getName(), skill.asString(), ExperienceAPI.getLevelOffline(player.getName(), skill.asString()) - quantity.asInt());
}
break;
}
case XP:
{
if (player.isOnline()) {
ExperienceAPI.removeXP(player.getPlayerEntity(), skill.asString(), quantity.asInt());
} else {
ExperienceAPI.removeXPOffline(player.getName(), skill.asString(), quantity.asInt());
}
break;
}
}
} else if (player != null && player.isOnline() && party != null && PartyManager.getParty(party.asString()) != null) {
if (PartyAPI.getPartyLeader(party.asString()).equals(player.getName())) {
PartyManager.disbandParty(PartyManager.getParty(party.asString()));
} else {
PartyAPI.removeFromParty(player.getPlayerEntity());
}
} else if (player != null) {
mcMMO.getDatabaseManager().removeUser(player.getName(), player.getUUID());
}
break;
}
case SET:
{
if (quantity.asDouble() >= 0 && skill != null && player != null) {
switch(Type.valueOf(type.asString().toUpperCase())) {
case LEVELS:
{
if (player.isOnline()) {
ExperienceAPI.setLevel(player.getPlayerEntity(), skill.asString(), quantity.asInt());
} else {
ExperienceAPI.setLevelOffline(player.getName(), skill.asString(), quantity.asInt());
}
break;
}
case XP:
{
if (player.isOnline()) {
ExperienceAPI.setXP(player.getPlayerEntity(), skill.asString(), quantity.asInt());
} else {
ExperienceAPI.setXPOffline(player.getName(), skill.asString(), quantity.asInt());
}
break;
}
}
} else {
switch(Type.valueOf(type.asString().toUpperCase())) {
case LEADER:
{
if (party != null && PartyManager.getParty(party.asString()) != null) {
PartyAPI.setPartyLeader(party.asString(), player.getName());
}
break;
}
case XPRATE:
{
if (quantity.asInt() > 0) {
ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(quantity.asInt());
}
break;
}
case HARDCORE:
{
if (skill == null) {
return;
}
PrimarySkillType skillType = PrimarySkillType.getSkill(skill.asString());
boolean isEnabled = mcMMO.p.getGeneralConfig().getHardcoreStatLossEnabled(skillType);
switch(State.valueOf(state.asString().toUpperCase())) {
case TOGGLE:
{
mcMMO.p.getGeneralConfig().setHardcoreStatLossEnabled(skillType, !isEnabled);
break;
}
case TRUE:
{
mcMMO.p.getGeneralConfig().setHardcoreStatLossEnabled(skillType, true);
break;
}
case FALSE:
{
mcMMO.p.getGeneralConfig().setHardcoreStatLossEnabled(skillType, false);
break;
}
}
break;
}
case VAMPIRISM:
{
if (skill == null) {
return;
}
PrimarySkillType skillType = PrimarySkillType.getSkill(skill.asString());
boolean isEnabled = mcMMO.p.getGeneralConfig().getHardcoreVampirismEnabled(skillType);
switch(State.valueOf(state.asString().toUpperCase())) {
case TOGGLE:
{
mcMMO.p.getGeneralConfig().setHardcoreVampirismEnabled(skillType, !isEnabled);
break;
}
case TRUE:
{
mcMMO.p.getGeneralConfig().setHardcoreVampirismEnabled(skillType, true);
break;
}
case FALSE:
{
mcMMO.p.getGeneralConfig().setHardcoreVampirismEnabled(skillType, false);
break;
}
}
break;
}
}
}
break;
}
}
}
use of com.gmail.nossr50.datatypes.party.Party in project Depenizen by DenizenScript.
the class PartyTag method forPlayer.
public static PartyTag forPlayer(PlayerTag player) {
McMMOPlayer pl = UserManager.getOfflinePlayer(player.getOfflinePlayer());
if (pl == null) {
return null;
}
Party party = pl.getParty();
if (party == null) {
return null;
}
return new PartyTag(party);
}
use of com.gmail.nossr50.datatypes.party.Party in project Depenizen by DenizenScript.
the class PartyTag method valueOf.
@Fetchable("party")
public static PartyTag valueOf(String string, TagContext context) {
if (string == null) {
return null;
}
// //////
// Match party name
string = string.replace("party@", "");
Party party = PartyManager.getParty(string);
if (party == null) {
return null;
}
return new PartyTag(party);
}
Aggregations