mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 06:36:45 +01:00
Wire up Party Config pt 1
This commit is contained in:
parent
f0455b28dc
commit
70b3ca3094
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -49,6 +49,10 @@ public class ConfigParty {
|
||||
return partyGeneral;
|
||||
}
|
||||
|
||||
public ConfigSectionPartyXP getPartyXP() {
|
||||
return partyXP;
|
||||
}
|
||||
|
||||
public String getPartyChatPrefixFormat() {
|
||||
return partyChat.getPartyChatPrefixFormat();
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -33,4 +33,23 @@ public class ConfigSectionPartyLevel {
|
||||
@Setting(value = "Party-Feature-Unlock-Level-Requirements")
|
||||
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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user