Added toggle to disable party system

This commit is contained in:
nossr50 2019-03-18 07:46:33 -07:00
parent b0b326d080
commit 3a21a913c6
6 changed files with 55 additions and 8 deletions

View File

@ -10,6 +10,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
You can now disable the party system completely
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 (-)
@ -45,6 +46,7 @@ Version 2.2.0
Particle settings will now be found in "particle_spawning.conf"
Party config options will now be found in "party.conf"
Added toggle to completely disable parties
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"

View File

@ -6,6 +6,7 @@ import com.gmail.nossr50.commands.party.teleport.PtpCommand;
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.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
@ -59,6 +60,10 @@ public class PartyCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
//If the party system is disabled, don't fire this command
if(!mcMMO.getConfigManager().getConfigParty().isPartySystemEnabled())
return true;
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}

View File

@ -91,6 +91,8 @@ public class ConfigParty {
return partyCombat.isPartyFriendlyFire();
}
public boolean isPartySystemEnabled() { return partyGeneral.isEnablePartySystem(); }
/*

View File

@ -6,9 +6,15 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigSectionPartyGeneral {
public static final boolean PARTY_SYSTEM_DEFAULT = true;
@Setting(value = "Party-Limitations")
private ConfigSectionPartyLimit configSectionPartyLimit = new ConfigSectionPartyLimit();
@Setting(value = "Enable-Party-System", comment = "Turn this off to completely disable the mcMMO party system." +
"\nDefault value: "+PARTY_SYSTEM_DEFAULT)
private boolean enablePartySystem = PARTY_SYSTEM_DEFAULT;
public int getPartySizeLimit() {
return configSectionPartyLimit.partyMaxSize;
}
@ -16,4 +22,8 @@ public class ConfigSectionPartyGeneral {
public boolean isPartySizeCapped() {
return configSectionPartyLimit.useCap;
}
public boolean isEnablePartySystem() {
return enablePartySystem;
}
}

View File

@ -137,6 +137,7 @@ public class mcMMO extends JavaPlugin {
registerCoreSkills();
registerCustomRecipes();
if(getConfigManager().getConfigParty().isPartySystemEnabled())
PartyManager.loadParties();
formulaManager = new FormulaManager();
@ -499,6 +500,9 @@ public class mcMMO extends JavaPlugin {
new UserPurgeTask().runTaskTimerAsynchronously(this, purgeIntervalTicks, purgeIntervalTicks);
}
//Party System Stuff
if(mcMMO.configManager.getConfigParty().isPartySystemEnabled())
{
// Automatically remove old members from parties
long kickIntervalTicks = getConfigManager().getConfigParty().getPartyCleanup().getPartyAutoKickHoursInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR;
@ -508,6 +512,8 @@ public class mcMMO extends JavaPlugin {
else if (kickIntervalTicks > 0) {
new PartyAutoKickTask().runTaskTimer(this, kickIntervalTicks, kickIntervalTicks);
}
}
// Update power level tag scoreboards
new PowerLevelUpdatingTask().runTaskTimer(this, 2 * Misc.TICK_CONVERSION_FACTOR, 2 * Misc.TICK_CONVERSION_FACTOR);

View File

@ -108,6 +108,11 @@ public final class PartyManager {
* @return true if they are in the same party, false otherwise
*/
public static boolean inSameParty(Player firstPlayer, Player secondPlayer) {
//If the party system is disabled, return false
if(!mcMMO.getConfigManager().getConfigParty().isPartySystemEnabled())
return false;
Party firstParty = UserManager.getPlayer(firstPlayer).getParty();
Party secondParty = UserManager.getPlayer(secondPlayer).getParty();
@ -119,6 +124,11 @@ public final class PartyManager {
}
public static boolean areAllies(Player firstPlayer, Player secondPlayer) {
//If the party system is disabled, return false
if(!mcMMO.getConfigManager().getConfigParty().isPartySystemEnabled())
return false;
Party firstParty = UserManager.getPlayer(firstPlayer).getParty();
Party secondParty = UserManager.getPlayer(secondPlayer).getParty();
@ -217,6 +227,10 @@ public final class PartyManager {
* @return the existing party, null otherwise
*/
public static Party getParty(String partyName) {
//If the party system is disabled, return null
if(!mcMMO.getConfigManager().getConfigParty().isPartySystemEnabled())
return null;
for (Party party : parties) {
if (party.getName().equalsIgnoreCase(partyName)) {
return party;
@ -234,6 +248,10 @@ public final class PartyManager {
*/
@Deprecated
public static Party getPlayerParty(String playerName) {
//If the party system is disabled, return null
if(!mcMMO.getConfigManager().getConfigParty().isPartySystemEnabled())
return null;
for (Party party : parties) {
if (party.getMembers().keySet().contains(playerName)) {
return party;
@ -250,6 +268,10 @@ public final class PartyManager {
* @return the existing party, null otherwise
*/
public static Party getPlayerParty(String playerName, UUID uuid) {
//If the party system is disabled, return null
if(!mcMMO.getConfigManager().getConfigParty().isPartySystemEnabled())
return null;
for (Party party : parties) {
LinkedHashMap<UUID, String> members = party.getMembers();
if (members.keySet().contains(uuid) || members.values().contains(playerName)) {