Only changes enough to make everything work

This commit is contained in:
2023-04-01 14:52:14 +02:00
parent bb0be8a3f0
commit b4e7b8ea44
103 changed files with 2003 additions and 2010 deletions

View File

@@ -45,9 +45,9 @@ public class CmdFactionsAccessInspect extends FactionsCommand {
// Check if they have access perms, unless they are checking for their own access
if (mpermable != msender && mpermable != msenderFaction && mpermable != msender.getRank()) {
if (!MPerm.getPermAccess().has(msender, faction, true)) {
return;
}
if (!MPerm.getPermAccess().has(msender, faction, true)) {
return;
}
}
// Turn into id->chunks
@@ -60,9 +60,9 @@ public class CmdFactionsAccessInspect extends FactionsCommand {
.filter(e -> e.getValue().isGranted(mpermable))
.map(Entry::getKey)
.collect(Collectors.toSet());
if (!chunks.isEmpty()) {
world2Chunks.put(worldId, chunks);
}
if (!chunks.isEmpty()) {
world2Chunks.put(worldId, chunks);
}
}
if (world2Chunks.isEmpty()) {

View File

@@ -52,9 +52,9 @@ public abstract class CmdFactionsAccessSetX extends CmdFactionsAccessAbstract {
final MPermable mpermable = this.getMPermable(hostFaction);
final Set<PS> chunks = this.getChunks();
if (chunks == null) {
throw new NullPointerException("chunks");
}
if (chunks == null) {
throw new NullPointerException("chunks");
}
// Apply / Inform
setAccess(chunks, mpermable, this.isGranting());

View File

@@ -54,9 +54,9 @@ public class CmdFactionsClean extends FactionsCommand {
int ret = 0;
for (MPlayer mplayer : MPlayerColl.get().getAll()) {
if (!mplayer.isFactionOrphan()) {
continue;
}
if (!mplayer.isFactionOrphan()) {
continue;
}
mplayer.resetFactionData();
ret += 1;
@@ -70,9 +70,9 @@ public class CmdFactionsClean extends FactionsCommand {
for (Faction faction : FactionColl.get().getAll()) {
EntityInternalMap<Invitation> invitations = faction.getInvitations();
if (invitations.isEmpty()) {
continue;
}
if (invitations.isEmpty()) {
continue;
}
ret += invitations.size();
Set<String> invitationIds = new MassiveSet<>(invitations.keySet());
@@ -93,9 +93,9 @@ public class CmdFactionsClean extends FactionsCommand {
for (Iterator<Entry<String, Rel>> iterator = faction.getRelationWishes().entrySet().iterator(); iterator.hasNext(); ) {
Entry<String, Rel> entry = iterator.next();
String factionId = entry.getKey();
if (FactionColl.get().containsId(factionId)) {
continue;
}
if (FactionColl.get().containsId(factionId)) {
continue;
}
iterator.remove();
ret += 1;
@@ -115,9 +115,9 @@ public class CmdFactionsClean extends FactionsCommand {
TerritoryAccess territoryAccess = entry.getValue();
String factionId = territoryAccess.getHostFactionId();
if (FactionColl.get().containsId(factionId)) {
continue;
}
if (FactionColl.get().containsId(factionId)) {
continue;
}
board.removeAt(ps);
ret += 1;
@@ -137,9 +137,9 @@ public class CmdFactionsClean extends FactionsCommand {
boolean changed = false;
for (String grantedIds : territoryAccess.getGrantedIds()) {
if (MPerm.idToMPermableOptional(grantedIds).isPresent()) {
continue;
}
if (MPerm.idToMPermableOptional(grantedIds).isPresent()) {
continue;
}
territoryAccess = territoryAccess.withGrantedId(grantedIds, false);
ret += 1;

View File

@@ -45,9 +45,9 @@ public class CmdFactionsCreate extends FactionsCommand {
// Event
EventFactionsCreate createEvent = new EventFactionsCreate(sender, factionId, newName);
createEvent.run();
if (createEvent.isCancelled()) {
return;
}
if (createEvent.isCancelled()) {
return;
}
// Apply
Faction faction = FactionColl.get().create(factionId);

View File

@@ -38,14 +38,14 @@ public class CmdFactionsDisband extends FactionsCommand {
Faction faction = this.readArg();
String confirmationString = this.readArg(null);
if (MConf.get().requireConfirmationForFactionDisbanding) {
ConfirmationUtil.tryConfirm(this);
}
if (MConf.get().requireConfirmationForFactionDisbanding) {
ConfirmationUtil.tryConfirm(this);
}
// MPerm
if (!MPerm.getPermDisband().has(msender, faction, true)) {
return;
}
if (!MPerm.getPermDisband().has(msender, faction, true)) {
return;
}
// Verify
if (faction.getFlag(MFlag.getFlagPermanent())) {
@@ -55,9 +55,9 @@ public class CmdFactionsDisband extends FactionsCommand {
// Event
EventFactionsDisband event = new EventFactionsDisband(me, faction);
event.run();
if (event.isCancelled()) {
return;
}
if (event.isCancelled()) {
return;
}
// Merged Apply and Inform

View File

@@ -45,14 +45,14 @@ public class CmdFactionsFly extends MassiveCommandToggle {
public void setValue(boolean value) throws MassiveException {
MPlayer mplayer = MPlayer.get(sender);
Player player = me;
if (player == null) {
throw new MassiveException().addMsg("<b>Could not find player.");
}
if (player == null) {
throw new MassiveException().addMsg("<b>Could not find player.");
}
PS ps = PS.valueOf(player);
if (value) {
EngineFly.canFlyInTerritoryOrThrow(mplayer, ps);
}
if (value) {
EngineFly.canFlyInTerritoryOrThrow(mplayer, ps);
}
mplayer.setFlying(value);
EngineMassiveCorePlayerUpdate.update(player, false);

View File

@@ -37,9 +37,9 @@ public class CmdFactionsInviteAdd extends FactionsCommand {
long creationMillis = System.currentTimeMillis();
// MPerm
if (!MPerm.getPermInvite().has(msender, msenderFaction, true)) {
return;
}
if (!MPerm.getPermInvite().has(msender, msenderFaction, true)) {
return;
}
for (MPlayer mplayer : mplayers) {
// Already member?
@@ -55,9 +55,9 @@ public class CmdFactionsInviteAdd extends FactionsCommand {
// Event
EventFactionsInvitedChange event = new EventFactionsInvitedChange(sender, mplayer, msenderFaction, isInvited);
event.run();
if (event.isCancelled()) {
continue;
}
if (event.isCancelled()) {
continue;
}
isInvited = event.isNewInvited();
// Inform

View File

@@ -42,14 +42,14 @@ public class CmdFactionsInviteList extends FactionsCommand {
Faction faction = this.readArg(msenderFaction);
if (faction != msenderFaction && !Perm.INVITE_LIST_OTHER.has(sender, true)) {
return;
}
if (faction != msenderFaction && !Perm.INVITE_LIST_OTHER.has(sender, true)) {
return;
}
// MPerm
if (!MPerm.getPermInvite().has(msender, msenderFaction, true)) {
return;
}
if (!MPerm.getPermInvite().has(msender, msenderFaction, true)) {
return;
}
// Pager Create
final List<Entry<String, Invitation>> invitations = new MassiveList<>(faction.getInvitations().entrySet());

View File

@@ -50,9 +50,9 @@ public class CmdFactionsInviteRemove extends FactionsCommand {
}
// MPerm
if (!MPerm.getPermInvite().has(msender, msenderFaction, true)) {
return;
}
if (!MPerm.getPermInvite().has(msender, msenderFaction, true)) {
return;
}
for (MPlayer mplayer : mplayers) {
// Already member?
@@ -79,9 +79,9 @@ public class CmdFactionsInviteRemove extends FactionsCommand {
// Event
EventFactionsInvitedChange event = new EventFactionsInvitedChange(sender, mplayer, msenderFaction, isInvited);
event.run();
if (event.isCancelled()) {
continue;
}
if (event.isCancelled()) {
continue;
}
isInvited = event.isNewInvited();
// Inform Player
@@ -96,9 +96,9 @@ public class CmdFactionsInviteRemove extends FactionsCommand {
msenderFaction.uninvite(mplayer);
// If all, we do this at last. So we only do it once.
if (!all) {
msenderFaction.changed();
}
if (!all) {
msenderFaction.changed();
}
} else {
// Mson
String command = CmdFactions.get().cmdFactionsInvite.cmdFactionsInviteAdd.getCommandLine(mplayer.getName());

View File

@@ -28,9 +28,9 @@ public class CmdFactionsMoneyBalance extends FactionsCommand {
public void perform() throws MassiveException {
Faction faction = this.readArg(msenderFaction);
if (faction != msenderFaction && !Perm.MONEY_BALANCE_ANY.has(sender, true)) {
return;
}
if (faction != msenderFaction && !Perm.MONEY_BALANCE_ANY.has(sender, true)) {
return;
}
Econ.sendBalanceInfo(msender, faction);
}

View File

@@ -29,16 +29,16 @@ public class CmdFactionsName extends FactionsCommand {
Faction faction = this.readArg(msenderFaction);
// MPerm
if (!MPerm.getPermName().has(msender, faction, true)) {
return;
}
if (!MPerm.getPermName().has(msender, faction, true)) {
return;
}
// Event
EventFactionsNameChange event = new EventFactionsNameChange(sender, faction, newName);
event.run();
if (event.isCancelled()) {
return;
}
if (event.isCancelled()) {
return;
}
newName = event.getNewName();
// Apply

View File

@@ -38,9 +38,9 @@ public class CmdFactionsPermSet extends FactionsCommand {
MPerm.MPermable permable = TypeMPermable.get(faction).read(this.argAt(1), sender);
// Do the sender have the right to change perms for this faction?
if (!MPerm.getPermPerms().has(msender, faction, true)) {
return;
}
if (!MPerm.getPermPerms().has(msender, faction, true)) {
return;
}
// Is this perm editable?
if (!msender.isOverriding() && !perm.isEditable()) {
@@ -54,9 +54,9 @@ public class CmdFactionsPermSet extends FactionsCommand {
// Event
EventFactionsPermChange event = new EventFactionsPermChange(sender, faction, perm, permable, value);
event.run();
if (event.isCancelled()) {
return;
}
if (event.isCancelled()) {
return;
}
value = event.getNewValue();
// Apply

View File

@@ -45,9 +45,9 @@ public class CmdFactionsPermView extends FactionsCommand {
List<MPerm> perms = new MassiveList<>();
for (MPerm mperm : MPerm.getAll()) {
if (faction.isPermitted(permable.getId(), mperm.getId())) {
perms.add(mperm);
}
if (faction.isPermitted(permable.getId(), mperm.getId())) {
perms.add(mperm);
}
}
if (perms.isEmpty()) {
@@ -66,13 +66,13 @@ public class CmdFactionsPermView extends FactionsCommand {
List<Mson> msons = new MassiveList<>();
if (mplayer.getFaction() != faction) {
msons.add(Mson.parse("<command>[faction]").command(this, mplayer.getFaction().getName(), faction.getName()));
}
if (mplayer.getFaction() != faction) {
msons.add(Mson.parse("<command>[faction]").command(this, mplayer.getFaction().getName(), faction.getName()));
}
msons.add(Mson.parse("<command>[rank]").command(this, mplayer.getFaction().getName() + "-" + mplayer.getRank().getName(), faction.getName()));
if (mplayer.getFaction() != faction) {
msons.add(Mson.parse("<command>[relation]").command(this, faction.getRelationTo(mplayer).toString(), faction.getName()));
}
if (mplayer.getFaction() != faction) {
msons.add(Mson.parse("<command>[relation]").command(this, faction.getRelationTo(mplayer).toString(), faction.getName()));
}
Mson msons2 = Mson.implode(msons, Mson.SPACE);
message(mson(mson("Commands: ").color(ChatColor.YELLOW), msons2));
}

View File

@@ -76,9 +76,9 @@ public class CmdFactionsRankSet extends FactionsCommand {
// Event
EventFactionsRankChange event = new EventFactionsRankChange(sender, target, rank);
event.run();
if (event.isCancelled()) {
return;
}
if (event.isCancelled()) {
return;
}
rank = event.getNewRank();
// Change the rank.
@@ -136,9 +136,9 @@ public class CmdFactionsRankSet extends FactionsCommand {
private void ensureAllowed() throws MassiveException {
// People with permission don't follow the normal rules.
if (msender.isOverriding()) {
return;
}
if (msender.isOverriding()) {
return;
}
// If somone gets the leadership of wilderness (Which has happened before).
// We can at least try to limit their powers.
@@ -205,9 +205,9 @@ public class CmdFactionsRankSet extends FactionsCommand {
// Event
EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(sender, msender, endFaction, MembershipChangeReason.RANK);
membershipChangeEvent.run();
if (membershipChangeEvent.isCancelled()) {
throw new MassiveException();
}
if (membershipChangeEvent.isCancelled()) {
throw new MassiveException();
}
// Apply
target.resetFactionData();

View File

@@ -34,9 +34,9 @@ public class CmdFactionsRelationSet extends FactionsCommand {
Rel newRelation = this.readArg();
// MPerm
if (!MPerm.getPermRel().has(msender, msenderFaction, true)) {
return;
}
if (!MPerm.getPermRel().has(msender, msenderFaction, true)) {
return;
}
// Verify
if (otherFaction == msenderFaction) {
@@ -49,9 +49,9 @@ public class CmdFactionsRelationSet extends FactionsCommand {
// Event
EventFactionsRelationChange event = new EventFactionsRelationChange(sender, msenderFaction, otherFaction, newRelation);
event.run();
if (event.isCancelled()) {
return;
}
if (event.isCancelled()) {
return;
}
newRelation = event.getNewRelation();
// try to set the new relation

View File

@@ -51,21 +51,21 @@ public class CmdFactionsTaxFaction extends FactionsCommand {
MPlayer mplayer = MPlayer.get(id);
String name;
if (Faction.IDENTIFIER_TAX_BASE.equals(id)) {
name = "Default";
} else if (rank != null) {
name = rank.getName();
} else if (mplayer != null) {
name = mplayer.getDisplayName(msender);
} else {
continue;
}
if (Faction.IDENTIFIER_TAX_BASE.equals(id)) {
name = "Default";
} else if (rank != null) {
name = rank.getName();
} else if (mplayer != null) {
name = mplayer.getDisplayName(msender);
} else {
continue;
}
anyTax = true;
msg("<k>%s: <v>%.2f", name, tax);
}
if (!anyTax) {
msg("<i>No players in this faction pays taxes.");
}
if (!anyTax) {
msg("<i>No players in this faction pays taxes.");
}
}
}

View File

@@ -30,9 +30,9 @@ public class CmdFactionsTerritorytitles extends FactionsCommand {
@Override
public Visibility getVisibility() {
// We hide the command if titles aren't available.
if (!MixinTitle.get().isAvailable()) {
return Visibility.INVISIBLE;
}
if (!MixinTitle.get().isAvailable()) {
return Visibility.INVISIBLE;
}
return super.getVisibility();
}

View File

@@ -33,9 +33,9 @@ public class CmdFactionsVoteCreate extends FactionsCommandWarp {
List<String> options = this.readArg();
// MPerm
if (!MPerm.getPermCreateVote().has(msender, msenderFaction, true)) {
return;
}
if (!MPerm.getPermCreateVote().has(msender, msenderFaction, true)) {
return;
}
if (msenderFaction.getVoteByName(name).isPresent()) {
throw new MassiveException().addMsg("<b>There is already a vote called <h>%s<b>.", name);
@@ -44,9 +44,9 @@ public class CmdFactionsVoteCreate extends FactionsCommandWarp {
// Make sure there are no duplicated
List<String> options2 = new MassiveList<>();
for (String str : options) {
if (options2.stream().anyMatch(str::equalsIgnoreCase)) {
continue;
}
if (options2.stream().anyMatch(str::equalsIgnoreCase)) {
continue;
}
options2.add(str);
}
@@ -56,9 +56,9 @@ public class CmdFactionsVoteCreate extends FactionsCommandWarp {
// Event
EventFactionsVoteAdd event = new EventFactionsVoteAdd(sender, msenderFaction, vote);
event.run();
if (event.isCancelled()) {
return;
}
if (event.isCancelled()) {
return;
}
vote = event.getVote();
// Apply

View File

@@ -28,9 +28,9 @@ public class CmdFactionsVoteDo extends FactionsCommandWarp {
String option = this.readArg();
// Any and MPerm
if (!MPerm.getPermVote().has(msender, msenderFaction, true)) {
return;
}
if (!MPerm.getPermVote().has(msender, msenderFaction, true)) {
return;
}
if (vote.getOptions().stream().noneMatch(option::equalsIgnoreCase)) {
throw new MassiveException().addMsg("<b>No option in <h>%s <b>matches <h>%s<b>.", vote.getName(), option);

View File

@@ -26,16 +26,16 @@ public class CmdFactionsVoteRemove extends FactionsCommandWarp {
Vote vote = TypeVote.get(msenderFaction).read(this.arg(), sender);
// Any and MPerm
if (!MPerm.getPermCreateVote().has(msender, msenderFaction, true)) {
return;
}
if (!MPerm.getPermCreateVote().has(msender, msenderFaction, true)) {
return;
}
// Event
EventFactionsVoteRemove event = new EventFactionsVoteRemove(sender, msenderFaction, vote);
event.run();
if (event.isCancelled()) {
return;
}
if (event.isCancelled()) {
return;
}
vote = event.getVote();
// Apply

View File

@@ -51,14 +51,14 @@ public class CmdFactionsWarpGo extends FactionsCommandWarp {
String warpDesc = Txt.parse("<h>%s <i>in <reset>%s<i>", warp.getName(), faction.describeTo(msender, false));
// Must be valid
if (!warp.verifyIsValid()) {
return;
}
if (!warp.verifyIsValid()) {
return;
}
// Any and MPerm
if (!MPerm.getPermWarp().has(msender, faction, true)) {
return;
}
if (!MPerm.getPermWarp().has(msender, faction, true)) {
return;
}
if (!MConf.get().warpsTeleportAllowedFromEnemyTerritory && msender.isInEnemyTerritory()) {
throw new MassiveException().addMsg("<b>You cannot teleport to %s <b>while in the territory of an enemy faction.", warp);
@@ -94,18 +94,18 @@ public class CmdFactionsWarpGo extends FactionsCommandWarp {
double z = locationHere.getZ();
for (Player p : w.getPlayers()) {
if (MUtil.isntPlayer(p)) {
continue;
}
if (MUtil.isntPlayer(p)) {
continue;
}
if (!p.isOnline() || p.isDead() || p == me || p.getWorld() != w) {
continue;
}
if (!p.isOnline() || p.isDead() || p == me || p.getWorld() != w) {
continue;
}
MPlayer fp = MPlayer.get(p);
if (msender.getRelationTo(fp) != Rel.ENEMY) {
continue;
}
if (msender.getRelationTo(fp) != Rel.ENEMY) {
continue;
}
Location l = p.getLocation();
double dx = Math.abs(x - l.getX());
@@ -114,9 +114,9 @@ public class CmdFactionsWarpGo extends FactionsCommandWarp {
double max = MConf.get().warpsTeleportAllowedEnemyDistance;
// box-shaped distance check
if (dx > max || dy > max || dz > max) {
continue;
}
if (dx > max || dy > max || dz > max) {
continue;
}
throw new MassiveException().addMsg("<b>You cannot teleport to %s <b>while an enemy is within %f blocks of you.", warpDesc, max);
}
@@ -125,9 +125,9 @@ public class CmdFactionsWarpGo extends FactionsCommandWarp {
// Event
EventFactionsWarpTeleport event = new EventFactionsWarpTeleport(sender, warp);
event.run();
if (event.isCancelled()) {
return;
}
if (event.isCancelled()) {
return;
}
// Apply
try {

View File

@@ -30,9 +30,9 @@ public class ReqHasFaction extends RequirementAbstract {
@Override
public boolean apply(CommandSender sender, MassiveCommand command) {
if (MUtil.isntSender(sender)) {
return false;
}
if (MUtil.isntSender(sender)) {
return false;
}
MPlayer mplayer = MPlayer.get(sender);
return mplayer.hasFaction();

View File

@@ -30,9 +30,9 @@ public class ReqHasntFaction extends RequirementAbstract {
@Override
public boolean apply(CommandSender sender, MassiveCommand command) {
if (MUtil.isntSender(sender)) {
return true;
}
if (MUtil.isntSender(sender)) {
return true;
}
MPlayer mplayer = MPlayer.get(sender);
return !mplayer.hasFaction();

View File

@@ -43,9 +43,9 @@ public class ReqRankIsAtLeast extends RequirementAbstract {
@Override
public boolean apply(CommandSender sender, MassiveCommand command) {
if (MUtil.isntSender(sender)) {
return false;
}
if (MUtil.isntSender(sender)) {
return false;
}
MPlayer mplayer = MPlayer.get(sender);
return mplayer.getRank().isAtLeast(this.getRank());

View File

@@ -26,9 +26,9 @@ public abstract class TypeEntityInternalFaction<E extends EntityInternal<E>> ext
protected TypeEntityInternalFaction(Class<E> clazz, Faction faction) {
super(clazz);
if (faction == null) {
throw new NullPointerException("faction");
}
if (faction == null) {
throw new NullPointerException("faction");
}
this.faction = faction;
@@ -54,18 +54,18 @@ public abstract class TypeEntityInternalFaction<E extends EntityInternal<E>> ext
@Override
public boolean isValid(String arg, CommandSender sender) {
// In the generic case accept all
if (this.getAll().isEmpty()) {
return true;
} else {
return super.isValid(arg, sender);
}
if (this.getAll().isEmpty()) {
return true;
} else {
return super.isValid(arg, sender);
}
}
@Override
public Collection<String> getTabList(CommandSender sender, String arg) {
if (this.getFaction() != null) {
return super.getTabList(sender, arg);
}
if (this.getFaction() != null) {
return super.getTabList(sender, arg);
}
// Default to tab list for the sender
Faction faction = MPlayer.get(sender).getFaction();

View File

@@ -38,9 +38,9 @@ public class TypeMPermable extends TypeAbstract<MPerm.MPermable> {
public TypeMPermable(Faction faction) {
super(MPerm.MPermable.class);
if (faction == null) {
throw new NullPointerException("faction");
}
if (faction == null) {
throw new NullPointerException("faction");
}
this.faction = faction;
}
@@ -121,9 +121,9 @@ public class TypeMPermable extends TypeAbstract<MPerm.MPermable> {
public Collection<String> getTabList(CommandSender sender, String arg) {
List<String> ret = new MassiveList<>();
Faction faction = this.getFaction();
if (faction == null) {
faction = MPlayer.get(sender).getFaction();
}
if (faction == null) {
faction = MPlayer.get(sender).getFaction();
}
// Always add ranks, relations, other factions and other players
ret.addAll(faction.getRanks().getAll().stream().map(Rank::getName).collect(Collectors.toList()));
@@ -135,12 +135,12 @@ public class TypeMPermable extends TypeAbstract<MPerm.MPermable> {
if (arg.length() >= 2) {
for (Faction f : FactionColl.get().getAll()) {
String name = f.getName();
if (arg.length() <= name.length() && !name.toLowerCase().startsWith(arg.toLowerCase())) {
continue;
}
if (arg.length() > name.length() && !arg.toLowerCase().startsWith(name.toLowerCase())) {
continue;
}
if (arg.length() <= name.length() && !name.toLowerCase().startsWith(arg.toLowerCase())) {
continue;
}
if (arg.length() > name.length() && !arg.toLowerCase().startsWith(name.toLowerCase())) {
continue;
}
ret.addAll(f.getRanks().getAll().stream().map(r -> name + "-" + r.getName()).collect(Collectors.toList()));
}
@@ -182,11 +182,11 @@ public class TypeMPermable extends TypeAbstract<MPerm.MPermable> {
@Override
public boolean isValid(String arg, CommandSender sender) {
// In the generic case accept all
if (this.getFaction() == null) {
return true;
} else {
return super.isValid(arg, sender);
}
if (this.getFaction() == null) {
return true;
} else {
return super.isValid(arg, sender);
}
}
}

View File

@@ -77,13 +77,13 @@ public class TypeRank extends TypeEntityInternalFaction<Rank> {
if (this.currentRank != null) {
// You can't use "promote" to make someone leader.
Rank promote = getPromote(currentRank);
if (value == promote && !promote.isLeader()) {
names.add("promote");
}
if (value == promote && !promote.isLeader()) {
names.add("promote");
}
if (value == getDemote(currentRank)) {
names.add("demote");
}
if (value == getDemote(currentRank)) {
names.add("demote");
}
}
return names;
@@ -92,15 +92,15 @@ public class TypeRank extends TypeEntityInternalFaction<Rank> {
private static Rank getPromote(Rank rank) {
Rank ret = null;
for (Rank r : rank.getFaction().getRanks().getAll()) {
if (rank == r) {
continue;
}
if (rank.isMoreThan(r)) {
continue;
}
if (ret != null && ret.isLessThan(r)) {
continue;
}
if (rank == r) {
continue;
}
if (rank.isMoreThan(r)) {
continue;
}
if (ret != null && ret.isLessThan(r)) {
continue;
}
ret = r;
}
@@ -110,15 +110,15 @@ public class TypeRank extends TypeEntityInternalFaction<Rank> {
private static Rank getDemote(Rank rank) {
Rank ret = null;
for (Rank r : rank.getFaction().getRanks().getAll()) {
if (rank == r) {
continue;
}
if (rank.isLessThan(r)) {
continue;
}
if (ret != null && ret.isMoreThan(r)) {
continue;
}
if (rank == r) {
continue;
}
if (rank.isLessThan(r)) {
continue;
}
if (ret != null && ret.isMoreThan(r)) {
continue;
}
ret = r;
}

View File

@@ -37,9 +37,9 @@ public class TypeTaxable extends TypeAbstract<String> {
public TypeTaxable(Faction faction) {
super(String.class);
if (faction == null) {
throw new NullPointerException("faction");
}
if (faction == null) {
throw new NullPointerException("faction");
}
this.faction = faction;
}
@@ -90,9 +90,9 @@ public class TypeTaxable extends TypeAbstract<String> {
public Collection<String> getTabList(CommandSender sender, String arg) {
List<String> ret = new MassiveList<>();
Faction faction = this.getFaction();
if (faction == null) {
faction = MPlayer.get(sender).getFaction();
}
if (faction == null) {
faction = MPlayer.get(sender).getFaction();
}
// Always add ranks, relations, other factions and other players
ret.addAll(faction.getRanks().getAll().stream().map(Rank::getName).collect(Collectors.toList()));
@@ -124,11 +124,11 @@ public class TypeTaxable extends TypeAbstract<String> {
@Override
public boolean isValid(String arg, CommandSender sender) {
// In the generic case accept all
if (this.getFaction() == null) {
return true;
} else {
return super.isValid(arg, sender);
}
if (this.getFaction() == null) {
return true;
} else {
return super.isValid(arg, sender);
}
}
}