Fix relation limit glitch
Hand merged from HCF. Fixes issue where factions could exceed the max relation setting in config.
This commit is contained in:
parent
cb0043600d
commit
362bb55a0f
@ -52,7 +52,7 @@ public abstract class FRelationCommand extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (exceedsMaxRelations(targetRelation)) {
|
||||
if (hasMaxRelations(them, targetRelation)) {
|
||||
// We message them down there with the count.
|
||||
return;
|
||||
}
|
||||
@ -102,15 +102,19 @@ public abstract class FRelationCommand extends FCommand {
|
||||
FTeamWrapper.updatePrefixes(them);
|
||||
}
|
||||
|
||||
private boolean exceedsMaxRelations(Relation targetRelation) {
|
||||
if (P.p.getConfig().getBoolean("max-relations.enabled", false)) {
|
||||
private boolean hasMaxRelations(Faction them, Relation targetRelation) {
|
||||
int max = P.p.getConfig().getInt("max-relations." + targetRelation.toString(), -1);
|
||||
// -1 means don't care.
|
||||
if (max != -1 && myFaction.getRelationCount(targetRelation) >= max) {
|
||||
// Message them now as long as we have the count.
|
||||
msg(TL.COMMAND_RELATIONS_EXCEEDS_MAX, max, targetRelation.getPluralTranslation());
|
||||
if (P.p.getConfig().getBoolean("max-relations.enabled", false)) {
|
||||
if (max != -1) {
|
||||
if (myFaction.getRelationCount(targetRelation) >= max) {
|
||||
msg(TL.COMMAND_RELATIONS_EXCEEDS_ME, max, targetRelation.getPluralTranslation());
|
||||
return true;
|
||||
}
|
||||
if (them.getRelationCount(targetRelation) > max) {
|
||||
msg(TL.COMMAND_RELATIONS_EXCEEDS_THEY, max, targetRelation.getPluralTranslation());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -392,7 +392,8 @@ public enum TL {
|
||||
COMMAND_RELATIONS_PEACEFUL("<i>This will have no effect while your faction is peaceful."),
|
||||
COMMAND_RELATIONS_PEACEFULOTHER("<i>This will have no effect while their faction is peaceful."),
|
||||
COMMAND_RELATIONS_DESCRIPTION("Set relation wish to another faction"),
|
||||
COMMAND_RELATIONS_EXCEEDS_MAX("<i>Failed to set relation wish. You can only have %1$d %2%s."),
|
||||
COMMAND_RELATIONS_EXCEEDS_ME("<i>Failed to set relation wish. You can only have %1$s %2$s."),
|
||||
COMMAND_RELATIONS_EXCEEDS_THEY("<i>Failed to set relation wish. They can only have %1$s %2$s."),
|
||||
|
||||
COMMAND_RELATIONS_PROPOSAL_1("%1$s<i> wishes to be your %2$s"),
|
||||
COMMAND_RELATIONS_PROPOSAL_2("<i>Type <c>/%1$s %2$s %3$s<i> to accept."),
|
||||
|
Loading…
Reference in New Issue
Block a user