Wire up Party Config pt 1

This commit is contained in:
nossr50 2019-03-16 22:46:30 -07:00
parent f0455b28dc
commit 70b3ca3094
11 changed files with 64 additions and 49 deletions

View File

@ -50,7 +50,9 @@ public class PartyInviteCommand implements CommandExecutor {
if(mcMMO.getConfigManager().getConfigParty().getPartyGeneral().isPartySizeCapped()) if(mcMMO.getConfigManager().getConfigParty().getPartyGeneral().isPartySizeCapped())
if(PartyManager.isPartyFull(target, playerParty)) if(PartyManager.isPartyFull(target, playerParty))
{ {
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull.Invite", target.getName(), playerParty.toString(), MainConfig.getInstance().getPartyMaxSize())); player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull.Invite",
target.getName(), playerParty.toString(),
mcMMO.getConfigManager().getConfigParty().getPartySizeLimit()));
return true; return true;
} }

View File

@ -696,42 +696,6 @@ public class MainConfig extends ConfigValidated {
} }
/* PARTY SETTINGS */ /* PARTY SETTINGS */
public boolean getPartyFriendlyFire() {
return getBooleanValue(PARTY, FRIENDLY_FIRE);
}
public int getPartyMaxSize() {
return getIntValue(PARTY, MAX_SIZE);
}
public int getAutoPartyKickInterval() {
return getIntValue(PARTY, AUTO_KICK_INTERVAL);
}
public int getAutoPartyKickTime() {
return getIntValue(PARTY, OLD_PARTY_MEMBER_CUTOFF);
}
public double getPartyShareBonusBase() {
return getDoubleValue(PARTY, SHARING, EXP_SHARE_BONUS_BASE);
}
public double getPartyShareBonusIncrease() {
return getDoubleValue(PARTY, SHARING, EXP_SHARE_BONUS_INCREASE);
}
public double getPartyShareBonusCap() {
return getDoubleValue(PARTY, SHARING, EXP_SHARE_BONUS_CAP);
}
public double getPartyShareRange() {
return getDoubleValue(PARTY, SHARING, RANGE);
}
public int getPartyLevelCap() {
int cap = getIntValue(PARTY, LEVELING, LEVEL_CAP);
return (cap <= 0) ? Integer.MAX_VALUE : cap;
}
//TODO: Move this to Experience Config //TODO: Move this to Experience Config
public int getPartyXpCurveMultiplier() { public int getPartyXpCurveMultiplier() {

View File

@ -49,6 +49,10 @@ public class ConfigParty {
return partyGeneral; return partyGeneral;
} }
public ConfigSectionPartyXP getPartyXP() {
return partyXP;
}
public String getPartyChatPrefixFormat() { public String getPartyChatPrefixFormat() {
return partyChat.getPartyChatPrefixFormat(); return partyChat.getPartyChatPrefixFormat();
} }

View File

@ -8,7 +8,9 @@ public class ConfigSectionPartyCombat {
public static final boolean PARTY_FRIENDLY_FIRE_DEFAULT = false; public static final boolean PARTY_FRIENDLY_FIRE_DEFAULT = false;
@Setting(value = "Friendly-Fire", comment = "When friendly fire is enabled, players in the same party can injure each other.") @Setting(value = "Friendly-Fire", comment = "When friendly fire is enabled, players in the same party can injure each other." +
"\nThis also allows Party alliances to hurt each other." +
"\nDefault value: "+PARTY_FRIENDLY_FIRE_DEFAULT)
private boolean partyFriendlyFire = PARTY_FRIENDLY_FIRE_DEFAULT; private boolean partyFriendlyFire = PARTY_FRIENDLY_FIRE_DEFAULT;
public boolean isPartyFriendlyFire() { public boolean isPartyFriendlyFire() {

View File

@ -33,4 +33,23 @@ public class ConfigSectionPartyLevel {
@Setting(value = "Party-Feature-Unlock-Level-Requirements") @Setting(value = "Party-Feature-Unlock-Level-Requirements")
private Map<PartyFeature, Integer> partyFeatureUnlockMap = PARTY_FEATURE_MAP_DEFAULT; private Map<PartyFeature, Integer> partyFeatureUnlockMap = PARTY_FEATURE_MAP_DEFAULT;
public static HashMap<PartyFeature, Integer> getPartyFeatureMapDefault() {
return PARTY_FEATURE_MAP_DEFAULT;
}
public int getPartyXpCurveMultiplier() {
return partyXpCurveMultiplier;
}
public boolean isPartyLevelingNeedsNearbyMembers() {
return partyLevelingNeedsNearbyMembers;
}
public boolean isInformPartyMembersOnLevelup() {
return informPartyMembersOnLevelup;
}
public Map<PartyFeature, Integer> getPartyFeatureUnlockMap() {
return partyFeatureUnlockMap;
}
} }

View File

@ -23,4 +23,12 @@ public class ConfigSectionPartyXP {
@Setting(value = "Party-Level", comment = "Parties in mcMMO gain levels just like skills" + @Setting(value = "Party-Level", comment = "Parties in mcMMO gain levels just like skills" +
"\nSettings related to that can be found here!.") "\nSettings related to that can be found here!.")
private ConfigSectionPartyLevel partyLevel = new ConfigSectionPartyLevel(); private ConfigSectionPartyLevel partyLevel = new ConfigSectionPartyLevel();
public ConfigSectionPartyExperienceSharing getPartyExperienceSharing() {
return partyExperienceSharing;
}
public ConfigSectionPartyLevel getPartyLevel() {
return partyLevel;
}
} }

View File

@ -303,7 +303,7 @@ public class EntityListener implements Listener {
Player attackingPlayer = (Player) attacker; Player attackingPlayer = (Player) attacker;
if (event.getDamage(DamageModifier.ABSORPTION) > 0) { if (event.getDamage(DamageModifier.ABSORPTION) > 0) {
//If friendly fire is off don't allow players to hurt one another //If friendly fire is off don't allow players to hurt one another
if(!MainConfig.getInstance().getPartyFriendlyFire()) if(!mcMMO.getConfigManager().getConfigParty().isPartyFriendlyFireEnabled())
if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer) || PartyManager.areAllies(defendingPlayer, attackingPlayer)) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) { if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer) || PartyManager.areAllies(defendingPlayer, attackingPlayer)) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -372,8 +372,9 @@ public class EntityListener implements Listener {
} }
//Party Friendly Fire //Party Friendly Fire
if(!MainConfig.getInstance().getPartyFriendlyFire()) if(!mcMMO.getConfigManager().getConfigParty().isPartyFriendlyFireEnabled())
if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer) || PartyManager.areAllies(defendingPlayer, attackingPlayer)) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) { if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer)
|| PartyManager.areAllies(defendingPlayer, attackingPlayer)) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }

View File

@ -6,6 +6,7 @@ import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.hocon.database.ConfigSectionCleaning; import com.gmail.nossr50.config.hocon.database.ConfigSectionCleaning;
import com.gmail.nossr50.config.hocon.database.ConfigSectionMySQL; import com.gmail.nossr50.config.hocon.database.ConfigSectionMySQL;
import com.gmail.nossr50.config.hocon.party.ConfigSectionPartyExperienceSharing;
import com.gmail.nossr50.config.hocon.playerleveling.ConfigLeveling; import com.gmail.nossr50.config.hocon.playerleveling.ConfigLeveling;
import com.gmail.nossr50.config.hocon.scoreboard.ConfigScoreboard; import com.gmail.nossr50.config.hocon.scoreboard.ConfigScoreboard;
import com.gmail.nossr50.database.DatabaseManager; import com.gmail.nossr50.database.DatabaseManager;
@ -326,6 +327,15 @@ public class mcMMO extends JavaPlugin {
return configManager.getConfigDatabase().getConfigSectionCleaning(); return configManager.getConfigDatabase().getConfigSectionCleaning();
} }
/**
* Returns settings for Party XP sharing from the users config
* @return settings for the Party XP sharing from the users config
*/
public static ConfigSectionPartyExperienceSharing getPartyXPShareSettings()
{
return configManager.getConfigParty().getPartyXP().getPartyExperienceSharing();
}
/** /**
* Returns settings for Scoreboards from the users config * Returns settings for Scoreboards from the users config
* @return settings for Scoreboards from the users config * @return settings for Scoreboards from the users config
@ -480,7 +490,7 @@ public class mcMMO extends JavaPlugin {
} }
// Automatically remove old members from parties // Automatically remove old members from parties
long kickIntervalTicks = MainConfig.getInstance().getAutoPartyKickInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR; long kickIntervalTicks = getConfigManager().getConfigParty().getPartyCleanup().getPartyAutoKickHoursInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR;
if (kickIntervalTicks == 0) { if (kickIntervalTicks == 0) {
new PartyAutoKickTask().runTaskLater(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup. new PartyAutoKickTask().runTaskLater(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup.

View File

@ -130,7 +130,7 @@ public final class PartyManager {
if (party != null) { if (party != null) {
Player player = mcMMOPlayer.getPlayer(); Player player = mcMMOPlayer.getPlayer();
double range = MainConfig.getInstance().getPartyShareRange(); double range = mcMMO.getPartyXPShareSettings().getPartyShareRange();
for (Player member : party.getOnlineMembers()) { for (Player member : party.getOnlineMembers()) {
if (!player.equals(member) && member.isValid() && Misc.isNear(player.getLocation(), member.getLocation(), range)) { if (!player.equals(member) && member.isValid() && Misc.isNear(player.getLocation(), member.getLocation(), range)) {
@ -148,7 +148,7 @@ public final class PartyManager {
if (party != null) { if (party != null) {
Player player = mcMMOPlayer.getPlayer(); Player player = mcMMOPlayer.getPlayer();
double range = MainConfig.getInstance().getPartyShareRange(); double range = mcMMO.getPartyXPShareSettings().getPartyShareRange();
for (Player member : party.getVisibleMembers(player)) { for (Player member : party.getVisibleMembers(player)) {
if (!player.equals(member) if (!player.equals(member)
@ -403,9 +403,11 @@ public final class PartyManager {
/* /*
* Don't let players join a full party * Don't let players join a full party
*/ */
if(MainConfig.getInstance().getPartyMaxSize() > 0 && invite.getMembers().size() >= MainConfig.getInstance().getPartyMaxSize()) if(mcMMO.getConfigManager().getConfigParty().isPartySizeCapped() && invite.getMembers().size() >= mcMMO.getConfigManager().getConfigParty().getPartySizeLimit())
{ {
NotificationManager.sendPlayerInformation(mcMMOPlayer.getPlayer(), NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull.InviteAccept", invite.getName(), String.valueOf(MainConfig.getInstance().getPartyMaxSize())); NotificationManager.sendPlayerInformation(mcMMOPlayer.getPlayer(),
NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull.InviteAccept",
invite.getName(), String.valueOf(mcMMO.getConfigManager().getConfigParty().getPartySizeLimit()));
return; return;
} }

View File

@ -9,6 +9,7 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.ShareMode; import com.gmail.nossr50.datatypes.party.ShareMode;
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.mcMMO;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
@ -44,7 +45,9 @@ public final class ShareHandler {
nearMembers.add(mcMMOPlayer.getPlayer()); nearMembers.add(mcMMOPlayer.getPlayer());
int partySize = nearMembers.size(); int partySize = nearMembers.size();
double shareBonus = Math.min(MainConfig.getInstance().getPartyShareBonusBase() + (partySize * MainConfig.getInstance().getPartyShareBonusIncrease()), MainConfig.getInstance().getPartyShareBonusCap()); double shareBonus = Math.min(mcMMO.getPartyXPShareSettings().getPartyShareXPBonusBase()
+ (partySize * mcMMO.getPartyXPShareSettings().getPartyShareBonusIncrease()),
mcMMO.getPartyXPShareSettings().getPartyShareBonusCap());
float splitXp = (float) (xp / partySize * shareBonus); float splitXp = (float) (xp / partySize * shareBonus);
for (Player member : nearMembers) { for (Player member : nearMembers) {

View File

@ -14,7 +14,7 @@ import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
public class PartyAutoKickTask extends BukkitRunnable { public class PartyAutoKickTask extends BukkitRunnable {
private final static long KICK_TIME = 24L * 60L * 60L * 1000L * MainConfig.getInstance().getAutoPartyKickTime(); private final static long KICK_TIME = 24L * 60L * 60L * 1000L * mcMMO.getConfigManager().getConfigParty().getPartyCleanup().getPartyAutoKickHoursInterval();
@Override @Override
public void run() { public void run() {