From 70b3ca30942661196f22b35ebfbe1f9518aa21e9 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 16 Mar 2019 22:46:30 -0700 Subject: [PATCH] Wire up Party Config pt 1 --- .../commands/party/PartyInviteCommand.java | 4 ++- .../com/gmail/nossr50/config/MainConfig.java | 36 ------------------- .../config/hocon/party/ConfigParty.java | 4 +++ .../hocon/party/ConfigSectionPartyCombat.java | 4 ++- .../hocon/party/ConfigSectionPartyLevel.java | 19 ++++++++++ .../hocon/party/ConfigSectionPartyXP.java | 8 +++++ .../nossr50/listeners/EntityListener.java | 9 ++--- src/main/java/com/gmail/nossr50/mcMMO.java | 12 ++++++- .../com/gmail/nossr50/party/PartyManager.java | 10 +++--- .../com/gmail/nossr50/party/ShareHandler.java | 5 ++- .../runnables/party/PartyAutoKickTask.java | 2 +- 11 files changed, 64 insertions(+), 49 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java index 42f25cb2a..23f45401d 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyInviteCommand.java @@ -50,7 +50,9 @@ public class PartyInviteCommand implements CommandExecutor { if(mcMMO.getConfigManager().getConfigParty().getPartyGeneral().isPartySizeCapped()) 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; } diff --git a/src/main/java/com/gmail/nossr50/config/MainConfig.java b/src/main/java/com/gmail/nossr50/config/MainConfig.java index 5d80289c3..d13d7e0e5 100644 --- a/src/main/java/com/gmail/nossr50/config/MainConfig.java +++ b/src/main/java/com/gmail/nossr50/config/MainConfig.java @@ -696,42 +696,6 @@ public class MainConfig extends ConfigValidated { } /* 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 public int getPartyXpCurveMultiplier() { diff --git a/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigParty.java b/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigParty.java index b09e253f5..ffe6d1367 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigParty.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigParty.java @@ -49,6 +49,10 @@ public class ConfigParty { return partyGeneral; } + public ConfigSectionPartyXP getPartyXP() { + return partyXP; + } + public String getPartyChatPrefixFormat() { return partyChat.getPartyChatPrefixFormat(); } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigSectionPartyCombat.java b/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigSectionPartyCombat.java index dbc82a86e..39644359c 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigSectionPartyCombat.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigSectionPartyCombat.java @@ -8,7 +8,9 @@ public class ConfigSectionPartyCombat { 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; public boolean isPartyFriendlyFire() { diff --git a/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigSectionPartyLevel.java b/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigSectionPartyLevel.java index e029c507a..bc21eae83 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigSectionPartyLevel.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigSectionPartyLevel.java @@ -33,4 +33,23 @@ public class ConfigSectionPartyLevel { @Setting(value = "Party-Feature-Unlock-Level-Requirements") private Map partyFeatureUnlockMap = PARTY_FEATURE_MAP_DEFAULT; + public static HashMap getPartyFeatureMapDefault() { + return PARTY_FEATURE_MAP_DEFAULT; + } + + public int getPartyXpCurveMultiplier() { + return partyXpCurveMultiplier; + } + + public boolean isPartyLevelingNeedsNearbyMembers() { + return partyLevelingNeedsNearbyMembers; + } + + public boolean isInformPartyMembersOnLevelup() { + return informPartyMembersOnLevelup; + } + + public Map getPartyFeatureUnlockMap() { + return partyFeatureUnlockMap; + } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigSectionPartyXP.java b/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigSectionPartyXP.java index 9ee6e372b..7fc9516e4 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigSectionPartyXP.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/party/ConfigSectionPartyXP.java @@ -23,4 +23,12 @@ public class ConfigSectionPartyXP { @Setting(value = "Party-Level", comment = "Parties in mcMMO gain levels just like skills" + "\nSettings related to that can be found here!.") private ConfigSectionPartyLevel partyLevel = new ConfigSectionPartyLevel(); + + public ConfigSectionPartyExperienceSharing getPartyExperienceSharing() { + return partyExperienceSharing; + } + + public ConfigSectionPartyLevel getPartyLevel() { + return partyLevel; + } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index 695102542..13a3dfbe4 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -303,7 +303,7 @@ public class EntityListener implements Listener { Player attackingPlayer = (Player) attacker; if (event.getDamage(DamageModifier.ABSORPTION) > 0) { //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))) { event.setCancelled(true); return; @@ -372,11 +372,12 @@ public class EntityListener implements Listener { } //Party Friendly Fire - if(!MainConfig.getInstance().getPartyFriendlyFire()) - if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer) || PartyManager.areAllies(defendingPlayer, attackingPlayer)) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) { + if(!mcMMO.getConfigManager().getConfigParty().isPartyFriendlyFireEnabled()) + if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer) + || PartyManager.areAllies(defendingPlayer, attackingPlayer)) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) { event.setCancelled(true); return; - } + } } CombatUtils.processCombatAttack(event, attacker, target); diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 104c99cfb..63a97feda 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -6,6 +6,7 @@ import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.config.hocon.database.ConfigSectionCleaning; 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.scoreboard.ConfigScoreboard; import com.gmail.nossr50.database.DatabaseManager; @@ -326,6 +327,15 @@ public class mcMMO extends JavaPlugin { 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 * @return settings for Scoreboards from the users config @@ -480,7 +490,7 @@ public class mcMMO extends JavaPlugin { } // 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) { new PartyAutoKickTask().runTaskLater(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup. diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index 2d8f950a3..f7d30f25d 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -130,7 +130,7 @@ public final class PartyManager { if (party != null) { Player player = mcMMOPlayer.getPlayer(); - double range = MainConfig.getInstance().getPartyShareRange(); + double range = mcMMO.getPartyXPShareSettings().getPartyShareRange(); for (Player member : party.getOnlineMembers()) { if (!player.equals(member) && member.isValid() && Misc.isNear(player.getLocation(), member.getLocation(), range)) { @@ -148,7 +148,7 @@ public final class PartyManager { if (party != null) { Player player = mcMMOPlayer.getPlayer(); - double range = MainConfig.getInstance().getPartyShareRange(); + double range = mcMMO.getPartyXPShareSettings().getPartyShareRange(); for (Player member : party.getVisibleMembers(player)) { if (!player.equals(member) @@ -403,9 +403,11 @@ public final class PartyManager { /* * 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; } diff --git a/src/main/java/com/gmail/nossr50/party/ShareHandler.java b/src/main/java/com/gmail/nossr50/party/ShareHandler.java index 238327682..a4e5743f5 100644 --- a/src/main/java/com/gmail/nossr50/party/ShareHandler.java +++ b/src/main/java/com/gmail/nossr50/party/ShareHandler.java @@ -9,6 +9,7 @@ import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.ShareMode; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.player.UserManager; import org.bukkit.entity.Item; @@ -44,7 +45,9 @@ public final class ShareHandler { nearMembers.add(mcMMOPlayer.getPlayer()); 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); for (Player member : nearMembers) { diff --git a/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java b/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java index c18ffa49b..7e954285b 100644 --- a/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/party/PartyAutoKickTask.java @@ -14,7 +14,7 @@ import java.util.Map.Entry; import java.util.UUID; 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 public void run() {