Party config pt 2

This commit is contained in:
nossr50 2019-03-15 00:45:23 -07:00
parent fb1467551f
commit a812ca42f7
22 changed files with 372 additions and 32 deletions

View File

@ -9,6 +9,7 @@ Key:
Version 2.2.0
mcMMO's config system has been rewritten
Parties no longer have a cap, you can level them forever for bragging rights
Many config files are now generated on demand instead of being copied from within the JAR
All config nodes that used to be styled with CamelCase or otherwise now use hyphens (-) as spaces for readability and consistency
All config nodes will now use Capital letters at the start of each nodes name and after each hyphen (-)
@ -19,6 +20,7 @@ Version 2.2.0
Bug Fixes
Fixed a bug where players who started at level 1 would not be purged from the DB for being "powerless"
Fixed a potential bug where players could be awarded XP for cancelled tame events
Fixed a bug where party size limits were only counting online players
Permission Node Changes
Removed "mcmmo.motd" because it makes no sense to have this as a player permission when its a config option
@ -34,6 +36,7 @@ Version 2.2.0
Automated backup config options will now be found in "automated_backups.conf"
Command config options will now be found in "commands.conf"
Settings related to party chat have been moved to the party config file
Custom item (Chimaera Wing) config options will now be found in "custom_items.conf"
@ -42,6 +45,10 @@ Version 2.2.0
Particle settings will now be found in "particle_spawning.conf"
Party config options will now be found in "party.conf"
Party's "MaxSize" renamed -> "Party-Max-Size"
Party's "AutoKick_Interval" renamed -> "Hours-Between-Cleanup-Operations"
Party's "Old_Party_Member_Cutoff" renamed -> "Offline-Day-Limit"
Added toggle to limit max party size, previously this was done by setting party maximum size above -1
Notification config options will now be found in "chat_and_hud_notifications.conf"
@ -114,6 +121,7 @@ Version 2.2.0
Update_Check, Prefer_Beta
API Changes
Added API method to check if player parties are size capped
Added API method to grab the level cap of a skill by its PrimarySkillType ENUM definition
Added API method to check if a skill was being level capped

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.api;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyLeader;
@ -83,7 +82,7 @@ public final class PartyAPI {
if (party == null) {
party = new Party(new PartyLeader(player.getUniqueId(), player.getName()), partyName);
} else {
} else if(mcMMO.getConfigManager().getConfigParty().getPartyGeneral().isPartySizeCapped()) {
if(PartyManager.isPartyFull(player, party))
{
NotificationManager.sendPlayerInformation(player, NotificationType.PARTY_MESSAGE, "Commands.Party.PartyFull", party.toString());
@ -96,12 +95,20 @@ public final class PartyAPI {
/**
* The max party size of the server
* 0 or less for no size limit
* Limits are only enforced if the enforcement setting is on
* @return the max party size on this server
*/
public static int getMaxPartySize()
{
return MainConfig.getInstance().getPartyMaxSize();
return mcMMO.getConfigManager().getConfigParty().getPartySizeLimit();
}
/**
* Checks if parties are currently size capped which is determined by the user config
* @return true if parties are size capped
*/
public static boolean isPartySizeCapped() {
return mcMMO.getConfigManager().getConfigParty().isPartySizeCapped();
}
/**

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.commands.party.PartySubcommandType;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;

View File

@ -45,9 +45,9 @@ public class PartyInfoCommand implements CommandExecutor {
StringBuilder status = new StringBuilder();
status.append(LocaleLoader.getString("Commands.Party.Status", party.getName(), LocaleLoader.getString("Party.Status." + (party.isLocked() ? "Locked" : "Unlocked")), party.getLevel()));
if (!party.hasReachedLevelCap()) {
/*if (!party.hasReachedLevelCap()) {
status.append(" (").append(party.getXpToLevelPercentage()).append(")");
}
}*/
player.sendMessage(status.toString());
}

View File

@ -4,6 +4,7 @@ import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
@ -46,11 +47,12 @@ public class PartyInviteCommand implements CommandExecutor {
Party playerParty = mcMMOPlayer.getParty();
if(PartyManager.isPartyFull(target, playerParty))
{
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull.Invite", target.getName(), playerParty.toString(), MainConfig.getInstance().getPartyMaxSize()));
return true;
}
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()));
return true;
}
mcMMOTarget.setPartyInvite(playerParty);

View File

@ -3,6 +3,7 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
@ -54,11 +55,12 @@ public class PartyJoinCommand implements CommandExecutor {
return true;
}
if(PartyManager.isPartyFull(player, targetParty))
{
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull", targetParty.toString()));
return true;
}
if(mcMMO.getConfigManager().getConfigParty().getPartyGeneral().isPartySizeCapped())
if(PartyManager.isPartyFull(player, targetParty))
{
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull", targetParty.toString()));
return true;
}
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", partyName));
PartyManager.addToParty(mcMMOPlayer, targetParty);

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;

View File

@ -4,9 +4,6 @@ package com.gmail.nossr50.config;
import com.gmail.nossr50.mcMMO;
import org.bukkit.World;
import java.io.*;
import java.util.ArrayList;
/**
* Blacklist certain features in certain worlds
*/

View File

@ -1,7 +1,100 @@
package com.gmail.nossr50.config.hocon.party;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigParty {
@Setting(value = "Party-Chat",
comment = "Settings related to the display, formatting, and misc settings related to party chat.")
private ConfigSectionPartyChat partyChat = new ConfigSectionPartyChat();
@Setting(value = "Party-Combat",
comment = "Settings related to combat interactions for parties.")
private ConfigSectionPartyCombat partyCombat = new ConfigSectionPartyCombat();
@Setting(value = "Party-General",
comment = "Settings for player parties that don't fit neatly into other categories.")
private ConfigSectionPartyGeneral partyGeneral = new ConfigSectionPartyGeneral();
@Setting(value = "Party-Scheduled-Cleanups",
comment = "Settings related to automatic removal of players who haven't connected to the server in a long time.")
private ConfigSectionPartyCleanup partyCleanup = new ConfigSectionPartyCleanup();
@Setting(value = "Party-XP", comment = "Settings related to leveling parties.")
private ConfigSectionPartyXP partyXP = new ConfigSectionPartyXP();
public int getPartySizeLimit() {
return partyGeneral.getPartySizeLimit();
}
public boolean isPartySizeCapped() {
return partyGeneral.isPartySizeCapped();
}
public ConfigSectionPartyCleanup getPartyCleanup() {
return partyCleanup;
}
public ConfigSectionPartyChat getPartyChat() {
return partyChat;
}
public ConfigSectionPartyCombat getPartyCombat() {
return partyCombat;
}
public ConfigSectionPartyGeneral getPartyGeneral() {
return partyGeneral;
}
public String getPartyChatPrefixFormat() {
return partyChat.getPartyChatPrefixFormat();
}
public String getPartyChatPrefixAlly() {
return partyChat.getPartyChatPrefixAlly();
}
public boolean isPartyLeaderColoredGold() {
return partyChat.isPartyLeaderColoredGold();
}
public boolean isPartyDisplayNamesEnabled() {
return partyChat.isPartyDisplayNamesEnabled();
}
public boolean isPartyFriendlyFireEnabled() {
return partyCombat.isPartyFriendlyFire();
}
/*
public int getPTPCommandCooldown() {
return getIntValue(COMMANDS, PTP, COOLDOWN);
}
public int getPTPCommandWarmup() {
return getIntValue(COMMANDS, PTP, WARMUP);
}
public int getPTPCommandRecentlyHurtCooldown() {
return getIntValue(COMMANDS, PTP, RECENTLY_HURT + COOLDOWN);
}
public int getPTPCommandTimeout() {
return getIntValue(COMMANDS, PTP, REQUEST_TIMEOUT);
}
public boolean getPTPCommandConfirmRequired() {
return getBooleanValue(COMMANDS, PTP, ACCEPT_REQUIRED);
}
public boolean getPTPCommandWorldPermissions() {
return getBooleanValue(COMMANDS, PTP, WORLD_BASED_PERMISSIONS);
}
*/
}

View File

@ -0,0 +1,52 @@
package com.gmail.nossr50.config.hocon.party;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigSectionPartyChat {
public static final String PARTY_CHAT_PREFIX_FORMAT_DEFAULT = "&a(&f{0}&a)";
public static final String PARTY_CHAT_PREFIX_ALLY_DEFAULT = "&a(A)&r";
public static final boolean PARTY_LEADER_GOLD_DEFAULT = true;
public static final boolean PARTY_USE_DISPLAY_NAMES_DEFAULT = true;
@Setting(value = "Prefix-Party-Members",
comment = "This is the formatting used for the prefix at the beginning of a party chat message." +
"Default value: "+PARTY_CHAT_PREFIX_FORMAT_DEFAULT)
private String partyChatPrefixFormat = PARTY_CHAT_PREFIX_FORMAT_DEFAULT;
@Setting(value = "Prefix-Ally",
comment = "This is the formatting used for the prefix at the beginning of a party chat message from an ally." +
"\nDefault value: "+PARTY_CHAT_PREFIX_ALLY_DEFAULT)
private String partyChatPrefixAlly = PARTY_CHAT_PREFIX_ALLY_DEFAULT;
@Setting(value = "Party-Leaders-Name-Uses-Gold-Coloring",
comment = "Changes the party leader to use a gold coloring for their name." +
"\nDefault value: "+PARTY_LEADER_GOLD_DEFAULT)
private boolean isPartyLeaderColoredGold = PARTY_LEADER_GOLD_DEFAULT;
@Setting(value = "Use-Display-Names", comment = "Party chat will use formatted display names instead of the players raw nickname." +
"\nDisplay names are often colored, modified, or styled differently from a players regular name." +
"\nDisplay names are typically modified by chat plugins and the like." +
"\nIf you'd rather player names were just their current Minecraft username, turn this off." +
"\nDefault value: "+PARTY_USE_DISPLAY_NAMES_DEFAULT)
private boolean partyDisplayNamesEnabled = PARTY_USE_DISPLAY_NAMES_DEFAULT;
public String getPartyChatPrefixFormat() {
return partyChatPrefixFormat;
}
public String getPartyChatPrefixAlly() {
return partyChatPrefixAlly;
}
public boolean isPartyLeaderColoredGold() {
return isPartyLeaderColoredGold;
}
public boolean isPartyDisplayNamesEnabled() {
return partyDisplayNamesEnabled;
}
}

View File

@ -0,0 +1,29 @@
package com.gmail.nossr50.config.hocon.party;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigSectionPartyCleanup {
private static final int AUTO_KICK_HOURS_DEFAULT = 12;
public static final int AUTO_KICK_CUTOFF_DAYS_DEFAULT = 7;
@Setting(value = "Hours-Between-Cleanup-Operations",
comment = "How many hours between checking parties for members that meet auto kick requirements." +
"\nDefault value: "+AUTO_KICK_HOURS_DEFAULT)
private int partyAutoKickHoursInterval = AUTO_KICK_HOURS_DEFAULT;
@Setting(value = "Offline-Day-Limit",
comment = "How many days must pass before a player qualifies to be kicked from a party automatically." +
"\nDefault value: "+AUTO_KICK_CUTOFF_DAYS_DEFAULT)
private int partyAutoKickDaysCutoff = AUTO_KICK_CUTOFF_DAYS_DEFAULT;
public int getPartyAutoKickHoursInterval() {
return partyAutoKickHoursInterval;
}
public int getPartyAutoKickDaysCutoff() {
return partyAutoKickDaysCutoff;
}
}

View File

@ -0,0 +1,17 @@
package com.gmail.nossr50.config.hocon.party;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
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.")
private boolean partyFriendlyFire = PARTY_FRIENDLY_FIRE_DEFAULT;
public boolean isPartyFriendlyFire() {
return partyFriendlyFire;
}
}

View File

@ -0,0 +1,37 @@
package com.gmail.nossr50.config.hocon.party;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigSectionPartyExperienceSharing {
@Setting(value = "XP-Share-Base")
private double partyShareXPBonusBase = 1.1D;
@Setting(value = "XP-Share-Increase")
private double partyShareBonusIncrease = 1.05D;
@Setting(value = "XP-Share-Cap")
private double partyShareBonusCap = 1.5D;
@Setting(value = "XP-Share-Range",
comment = "How far away you can be from a party member and still receive shared XP.")
private double partyShareRange = 75.0D;
public double getPartyShareXPBonusBase() {
return partyShareXPBonusBase;
}
public double getPartyShareBonusIncrease() {
return partyShareBonusIncrease;
}
public double getPartyShareBonusCap() {
return partyShareBonusCap;
}
public double getPartyShareRange() {
return partyShareRange;
}
}

View File

@ -0,0 +1,19 @@
package com.gmail.nossr50.config.hocon.party;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigSectionPartyGeneral {
@Setting(value = "Party-Limitations")
private ConfigSectionPartyLimit configSectionPartyLimit = new ConfigSectionPartyLimit();
public int getPartySizeLimit() {
return configSectionPartyLimit.partyMaxSize;
}
public boolean isPartySizeCapped() {
return configSectionPartyLimit.useCap;
}
}

View File

@ -0,0 +1,36 @@
package com.gmail.nossr50.config.hocon.party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
import java.util.HashMap;
import java.util.Map;
@ConfigSerializable
public class ConfigSectionPartyLevel {
private static final HashMap<PartyFeature, Integer> PARTY_FEATURE_MAP_DEFAULT;
static {
PARTY_FEATURE_MAP_DEFAULT = new HashMap<>();
PARTY_FEATURE_MAP_DEFAULT.put(PartyFeature.TELEPORT, 2);
PARTY_FEATURE_MAP_DEFAULT.put(PartyFeature.ALLIANCE, 5);
PARTY_FEATURE_MAP_DEFAULT.put(PartyFeature.ITEM_SHARE, 8);
PARTY_FEATURE_MAP_DEFAULT.put(PartyFeature.XP_SHARE, 0);
PARTY_FEATURE_MAP_DEFAULT.put(PartyFeature.CHAT, 0);
}
@Setting(value = "Party-XP-Rate-Multiplier")
private int partyXpCurveMultiplier = 3;
@Setting(value = "Party-Leveling-Requires-Nearby-Party-Members")
private boolean partyLevelingNeedsNearbyMembers = true;
@Setting(value = "Send-Levelup-Notifications-To-Party")
private boolean informPartyMembersOnLevelup = true;
@Setting(value = "Party-Feature-Unlock-Level-Requirements")
private Map<PartyFeature, Integer> partyFeatureUnlockMap = PARTY_FEATURE_MAP_DEFAULT;
}

View File

@ -0,0 +1,26 @@
package com.gmail.nossr50.config.hocon.party;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigSectionPartyLimit {
public static final boolean USE_LIMIT_DEFAULT = false;
public static final int PARTY_SIZE_LIMIT_DEFAULT = 5;
@Setting(value = "Max-Party-Size",
comment = "The maximum size for parties, parties bigger than this size will be dismantled." +
"\nThis setting is only used if \"Enforce-Size-Limit\" is true." +
"\nPlayers can bypass this limit with the following permission node \"mcmmo.bypass.partylimit\"" +
"\nDefault value: "+PARTY_SIZE_LIMIT_DEFAULT)
public int partyMaxSize = PARTY_SIZE_LIMIT_DEFAULT;
@Setting(value = "Enforce-Size-Limit",
comment = "Limits parties to a maximum size defined by \"Max-Party-Size\"" +
"\nParties over the current limit will be dismantled" +
"\nPlayers can bypass this limit with the following permission node \"mcmmo.bypass.partylimit\"" +
"\nDefault value: "+USE_LIMIT_DEFAULT)
public boolean useCap = USE_LIMIT_DEFAULT;
}

View File

@ -0,0 +1,22 @@
package com.gmail.nossr50.config.hocon.party;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigSectionPartyXP {
@Setting(value = "Party-Experience-Sharing", comment = "Settings for party XP sharing." +
"\nThe formula for determining shared XP is like this..." +
"\n x = XP-Share-Base" +
"\n y = Number of Party members in XP share range" +
"\n z = XP-Share-Increase" +
"\n shareBonus = (y * z) + x" +
"\nNOTE: shareBonus will never be bigger than XP-Share-Cap" +
"\n xpGained = Amount of XP gained before being split" +
"\n\n SHARED_XP = (xpGained / y * shareBonus)" +
"\nSHARED_XP is what will be given to nearby party members." +
"\n\nKeep in mind, if you gain XP in say Acrobatics and then that XP is shared with your party members, " +
"that doesn't mean that you will get extra XP from the XP sharing.")
private ConfigSectionPartyExperienceSharing partyExperienceSharing = new ConfigSectionPartyExperienceSharing();
}

View File

@ -218,10 +218,10 @@ public class Party {
float xpRemoved = 0;
while (getXp() >= getXpToLevel()) {
if (hasReachedLevelCap()) {
/*if (hasReachedLevelCap()) {
setXp(0);
return;
}
}*/
xpRemoved += levelUp();
levelsGained++;
@ -247,10 +247,6 @@ public class Party {
PartyManager.informPartyMembersLevelUp(this, levelsGained, getLevel());
}
public boolean hasReachedLevelCap() {
return MainConfig.getInstance().getPartyLevelCap() < getLevel() + 1;
}
public void setXpShareMode(ShareMode xpShareMode) {
this.xpShareMode = xpShareMode;
}

View File

@ -1,6 +1,6 @@
package com.gmail.nossr50.datatypes.treasure;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.mcMMO;
import org.bukkit.inventory.ItemStack;
public abstract class Treasure {
@ -42,7 +42,7 @@ public abstract class Treasure {
public int getDropLevel() {
//If they are in retro mode all requirements are scaled up by 10
if(MainConfig.getInstance().getIsRetroMode())
if(mcMMO.isRetroModeEnabled())
return dropLevel * 10;
return dropLevel;

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50;
import com.gmail.nossr50.config.ConfigManager;
import com.gmail.nossr50.config.CoreSkillsConfig;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.hocon.database.ConfigSectionCleaning;
import com.gmail.nossr50.config.hocon.database.ConfigSectionMySQL;

View File

@ -61,7 +61,8 @@ public final class PartyManager {
*/
public static boolean isPartyFull(Player player, Party targetParty)
{
return !Permissions.partySizeBypass(player) && MainConfig.getInstance().getPartyMaxSize() >= 1 && targetParty.getOnlineMembers().size() >= MainConfig.getInstance().getPartyMaxSize();
return !Permissions.partySizeBypass(player)
&& targetParty.getMembers().size() >= mcMMO.getConfigManager().getConfigParty().getPartySizeLimit();
}
/**

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.util;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.config.RankConfig;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.json.McMMOUrl;