Only changes enough to make everything work

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

33
pom.xml
View File

@ -2,16 +2,8 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- Parent -->
<!--<parent>
<groupId>com.massivecraft.massivesuper</groupId>
<artifactId>MassiveSuper</artifactId>
<version>3.3.3</version>
<relativePath>../MassiveSuper</relativePath>
</parent>-->
<!-- Basics -->
<groupId>net.knarcraft</groupId>
<groupId>com.massivecraft.factions</groupId>
<artifactId>Factions</artifactId>
<packaging>jar</packaging>
@ -26,8 +18,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
</properties>
<repositories>
@ -36,8 +28,8 @@
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>engine-hub-repo</id>
@ -59,7 +51,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.1-R0.1-SNAPSHOT</version>
<version>1.19.4-R0.1-SNAPSHOT</version>
</dependency>
<!-- MassiveCore -->
<dependency>
@ -67,7 +59,7 @@
<artifactId>MassiveCore</artifactId>
<version>RELEASE</version>
<scope>system</scope>
<systemPath>lib\MassiveCore.jar</systemPath>
<systemPath>${project.basedir}\lib\MassiveCore.jar</systemPath>
</dependency>
<!-- WorldEdit -->
<dependency>
@ -93,9 +85,10 @@
</dependency>
<!-- Vault -->
<dependency>
<groupId>net.milkbowl.vault</groupId>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
<!-- LWC -->
<dependency>
@ -103,7 +96,7 @@
<artifactId>lwc</artifactId>
<version>RELEASE</version>
<scope>system</scope>
<systemPath>lib\LWC.jar</systemPath>
<systemPath>${project.basedir}\lib\LWC.jar</systemPath>
</dependency>
<!-- PlaceholderAPI -->
<dependency>
@ -118,7 +111,7 @@
<artifactId>VentureChat</artifactId>
<version>RELEASE</version>
<scope>system</scope>
<systemPath>lib\VentureChat.jar</systemPath>
<systemPath>${project.basedir}\lib\VentureChat.jar</systemPath>
</dependency>
<!-- Dynmap -->
<dependency>
@ -146,8 +139,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>17</source>
<target>17</target>
<source>16</source>
<target>16</target>
</configuration>
</plugin>
</plugins>

View File

@ -22,9 +22,9 @@ public class ExtractorFactionAccountId implements Extractor {
public Object extract(Object o) {
if (o instanceof Faction) {
String factionId = ((Faction) o).getId();
if (factionId == null) {
return null;
}
if (factionId == null) {
return null;
}
return Factions.FACTION_MONEY_ACCOUNT_ID_PREFIX + factionId;
}

View File

@ -51,12 +51,12 @@ public class FactionsIndex {
// -------------------------------------------- //
private boolean isConnected(MPlayer mplayer, Faction faction) {
if (mplayer == null) {
throw new NullPointerException("mplayer");
}
if (faction == null) {
throw new NullPointerException("faction");
}
if (mplayer == null) {
throw new NullPointerException("mplayer");
}
if (faction == null) {
throw new NullPointerException("faction");
}
return mplayer.getFaction() == faction;
}
@ -78,20 +78,20 @@ public class FactionsIndex {
// -------------------------------------------- //
public synchronized void updateAll() {
if (!MPlayerColl.get().isActive()) {
throw new IllegalStateException("The MPlayerColl is not yet fully activated.");
}
if (!MPlayerColl.get().isActive()) {
throw new IllegalStateException("The MPlayerColl is not yet fully activated.");
}
MPlayerColl.get().getAll().forEach(this::update);
}
public synchronized void update(MPlayer mplayer) {
if (mplayer == null) {
throw new NullPointerException("mplayer");
}
if (!FactionColl.get().isActive()) {
throw new IllegalStateException("The FactionColl is not yet fully activated.");
}
if (mplayer == null) {
throw new NullPointerException("mplayer");
}
if (!FactionColl.get().isActive()) {
throw new IllegalStateException("The FactionColl is not yet fully activated.");
}
// TODO: This is not optimal but here we remove a player from the index when
// the mplayer object is deattached. Optimally it should be removed
@ -110,12 +110,12 @@ public class FactionsIndex {
Faction factionIndexed = this.getFaction(mplayer);
Set<Faction> factions = new MassiveSet<>();
if (factionActual != null) {
factions.add(factionActual);
}
if (factionIndexed != null) {
factions.add(factionIndexed);
}
if (factionActual != null) {
factions.add(factionActual);
}
if (factionIndexed != null) {
factions.add(factionIndexed);
}
for (Faction faction : factions) {
boolean connected = this.isConnected(mplayer, faction);
@ -130,9 +130,9 @@ public class FactionsIndex {
}
public synchronized void update(Faction faction) {
if (faction == null) {
throw new NullPointerException("faction");
}
if (faction == null) {
throw new NullPointerException("faction");
}
this.getMPlayers(faction).forEach(this::update);
}

View File

@ -117,12 +117,12 @@ public class TerritoryAccess {
}
private TerritoryAccess(String hostFactionId, Boolean hostFactionAllowed, Collection<String> grantedIds, String chunkName) {
if (hostFactionId == null) {
throw new NullPointerException("hostFactionId");
}
if (grantedIds == null) {
throw new NullPointerException("grantedIds");
}
if (hostFactionId == null) {
throw new NullPointerException("hostFactionId");
}
if (grantedIds == null) {
throw new NullPointerException("grantedIds");
}
this.hostFactionId = hostFactionId;
Set<String> grantedIdsInner = new MassiveSet<>();
@ -142,19 +142,19 @@ public class TerritoryAccess {
// -------------------------------------------- //
public static TerritoryAccess valueOf(String hostFactionId, Boolean hostFactionAllowed, Collection<String> grantedIds, String chunkName) {
if (hostFactionId == null) {
throw new NullPointerException("hostFactionId");
}
if (grantedIds == null) {
throw new NullPointerException("grantedIds");
}
if (hostFactionId == null) {
throw new NullPointerException("hostFactionId");
}
if (grantedIds == null) {
throw new NullPointerException("grantedIds");
}
return new TerritoryAccess(hostFactionId, hostFactionAllowed, grantedIds, chunkName);
}
public static TerritoryAccess valueOf(String hostFactionId) {
if (hostFactionId == null) {
throw new NullPointerException("hostFactionId");
}
if (hostFactionId == null) {
throw new NullPointerException("hostFactionId");
}
return valueOf(hostFactionId, null, Collections.emptySet(), null);
}
@ -167,9 +167,9 @@ public class TerritoryAccess {
}
public boolean isGranted(String permableId) {
if (permableId.equals(this.hostFactionId)) {
return this.isHostFactionAllowed();
}
if (permableId.equals(this.hostFactionId)) {
return this.isHostFactionAllowed();
}
return this.getGrantedIds().contains(permableId);
}
@ -184,26 +184,26 @@ public class TerritoryAccess {
// -------------------------------------------- //
public AccessStatus getTerritoryAccess(MPlayer mplayer) {
if (isGranted(mplayer.getId())) {
return AccessStatus.ELEVATED;
}
if (isGranted(mplayer.getRank().getId())) {
return AccessStatus.ELEVATED;
}
if (isGranted(mplayer.getId())) {
return AccessStatus.ELEVATED;
}
if (isGranted(mplayer.getRank().getId())) {
return AccessStatus.ELEVATED;
}
if (this.getHostFactionId().equals(mplayer.getFaction().getId())) {
if (this.isHostFactionAllowed()) {
return AccessStatus.STANDARD;
} else {
return AccessStatus.DECREASED;
}
if (this.isHostFactionAllowed()) {
return AccessStatus.STANDARD;
} else {
return AccessStatus.DECREASED;
}
}
if (isGranted(mplayer.getFaction().getId())) {
return AccessStatus.ELEVATED;
}
if (isGranted(RelationUtil.getRelationOfThatToMe(mplayer, this.getHostFaction()).toString())) {
return AccessStatus.ELEVATED;
}
if (isGranted(mplayer.getFaction().getId())) {
return AccessStatus.ELEVATED;
}
if (isGranted(RelationUtil.getRelationOfThatToMe(mplayer, this.getHostFaction()).toString())) {
return AccessStatus.ELEVATED;
}
return AccessStatus.STANDARD;
}

View File

@ -68,28 +68,28 @@ public class TerritoryAccessAdapter implements JsonDeserializer<TerritoryAccess>
hostFactionId = element.getAsString();
element = obj.get(HOST_FACTION_ALLOWED);
if (element != null) {
hostFactionAllowed = element.getAsBoolean();
}
if (element != null) {
hostFactionAllowed = element.getAsBoolean();
}
element = obj.get(GRANTED_IDS);
if (element != null) {
grantedIds = context.deserialize(element, SET_OF_STRING_TYPE);
}
if (element != null) {
grantedIds = context.deserialize(element, SET_OF_STRING_TYPE);
}
element = obj.get(CHUNK_NAME);
if (element != null) {
chunkName = element.getAsString();
}
if (element != null) {
chunkName = element.getAsString();
}
return TerritoryAccess.valueOf(hostFactionId, hostFactionAllowed, grantedIds, chunkName);
}
@Override
public JsonElement serialize(TerritoryAccess src, Type typeOfSrc, JsonSerializationContext context) {
if (src == null) {
return null;
}
if (src == null) {
return null;
}
// isDefault <=> simple hostFactionId string
if (src.isDefault()) {

View File

@ -24,9 +24,9 @@ public class ChatModifierRp extends ChatModifier {
@Override
public String getModified(String subject, CommandSender sender, CommandSender recipient) {
if (subject.equals("")) {
return subject;
}
if (subject.equals("")) {
return subject;
}
return subject + " ";
}

View File

@ -31,9 +31,9 @@ public class ChatTagName extends ChatTag {
// No "force"
Faction faction = usender.getFaction();
if (faction.isNone()) {
return "";
}
if (faction.isNone()) {
return "";
}
return faction.getName();
}

View File

@ -26,9 +26,9 @@ public class ChatTagRelcolor extends ChatTag {
@Override
public String getReplacement(CommandSender sender, CommandSender recipient) {
// Opt out if no recipient
if (recipient == null) {
return null;
}
if (recipient == null) {
return null;
}
// Get entities
MPlayer usender = MPlayer.get(sender);

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);
}
}
}

View File

@ -38,27 +38,27 @@ public class ComparatorFactionList extends ComparatorAbstract<Faction> {
@Override
public int compareInner(Faction f1, Faction f2) {
// None a.k.a. Wilderness
if (f1.isNone() && f2.isNone()) {
return 0;
}
if (f1.isNone()) {
return -1;
}
if (f2.isNone()) {
return 1;
}
if (f1.isNone() && f2.isNone()) {
return 0;
}
if (f1.isNone()) {
return -1;
}
if (f2.isNone()) {
return 1;
}
// Players Online
int ret = f2.getMPlayersWhereOnlineTo(this.getWatcher()).size() - f1.getMPlayersWhereOnlineTo(this.getWatcher()).size();
if (ret != 0) {
return ret;
}
if (ret != 0) {
return ret;
}
// Players Total
ret = f2.getMPlayers().size() - f1.getMPlayers().size();
if (ret != 0) {
return ret;
}
if (ret != 0) {
return ret;
}
// Tie by Id
return ComparatorComparable.get().compare(f1.getId(), f2.getId());

View File

@ -30,13 +30,13 @@ public class ComparatorMPlayerInactivity extends ComparatorAbstract<MPlayer> imp
boolean o1 = m1.isOnline();
boolean o2 = m2.isOnline();
if (o1 && o2) {
return 0;
} else if (o1) {
return -1;
} else if (o2) {
return +1;
}
if (o1 && o2) {
return 0;
} else if (o1) {
return -1;
} else if (o2) {
return +1;
}
// Inactivity Time
long r1 = m1.getLastActivityMillis();

View File

@ -28,9 +28,9 @@ public class ComparatorMPlayerPower extends ComparatorAbstract<MPlayer> implemen
public int compareInner(MPlayer m1, MPlayer m2) {
// Power
int ret = m1.getPowerRounded() - m2.getPowerRounded();
if (ret != 0) {
return ret;
}
if (ret != 0) {
return ret;
}
// MaxPower
return m1.getPowerMaxRounded() - m2.getPowerMaxRounded();

View File

@ -28,9 +28,9 @@ public class ComparatorMPlayerRole extends ComparatorAbstract<MPlayer> implement
@Override
public int compareInner(MPlayer m1, MPlayer m2) {
// Rank
if (m1.getFaction() != m2.getFaction()) {
throw new IllegalArgumentException("Noncomparable players");
}
if (m1.getFaction() != m2.getFaction()) {
throw new IllegalArgumentException("Noncomparable players");
}
Rank r1 = m1.getRank();
Rank r2 = m2.getRank();
return r2.getPriority() - r1.getPriority();

View File

@ -44,9 +44,9 @@ public class EngineCanCombatHappen extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void canCombatDamageHappen(EntityDamageByEntityEvent event) {
if (this.canCombatDamageHappen(event, true)) {
return;
}
if (this.canCombatDamageHappen(event, true)) {
return;
}
event.setCancelled(true);
Entity damager = event.getDamager();
@ -61,32 +61,32 @@ public class EngineCanCombatHappen extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void canCombatDamageHappen(EntityCombustByEntityEvent event) {
EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), EntityDamageEvent.DamageCause.FIRE, 0D);
if (this.canCombatDamageHappen(sub, false)) {
return;
}
if (this.canCombatDamageHappen(sub, false)) {
return;
}
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void canCombatDamageHappen(PotionSplashEvent event) {
// If a harmful potion is splashing ...
if (!MUtil.isHarmfulPotion(event.getPotion())) {
return;
}
if (!MUtil.isHarmfulPotion(event.getPotion())) {
return;
}
ProjectileSource projectileSource = event.getPotion().getShooter();
if (!(projectileSource instanceof Entity)) {
return;
}
if (!(projectileSource instanceof Entity)) {
return;
}
Entity thrower = (Entity) projectileSource;
// ... scan through affected entities to make sure they're all valid targets.
for (LivingEntity affectedEntity : event.getAffectedEntities()) {
EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(thrower, affectedEntity, EntityDamageEvent.DamageCause.CUSTOM, 0D);
if (this.canCombatDamageHappen(sub, true)) {
continue;
}
if (this.canCombatDamageHappen(sub, true)) {
continue;
}
// affected entity list doesn't accept modification (iter.remove() is a no-go), but this works
event.setIntensity(affectedEntity, 0.0);
@ -96,14 +96,14 @@ public class EngineCanCombatHappen extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void canCombatDamageHappen(AreaEffectCloudApplyEvent event) {
// If a harmful potion effect cloud is present ...
if (!MUtil.isHarmfulPotion(event.getEntity().getBasePotionData().getType().getEffectType())) {
return;
}
if (!MUtil.isHarmfulPotion(event.getEntity().getBasePotionData().getType().getEffectType())) {
return;
}
ProjectileSource projectileSource = event.getEntity().getSource();
if (!(projectileSource instanceof Entity)) {
return;
}
if (!(projectileSource instanceof Entity)) {
return;
}
Entity thrower = (Entity) projectileSource;
@ -114,9 +114,9 @@ public class EngineCanCombatHappen extends Engine {
for (LivingEntity affectedEntity : event.getAffectedEntities()) {
EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(thrower, affectedEntity, EntityDamageEvent.DamageCause.CUSTOM, 0D);
// Notification disabled due to the iterating nature of effect clouds.
if (EngineCanCombatHappen.get().canCombatDamageHappen(sub, false)) {
continue;
}
if (EngineCanCombatHappen.get().canCombatDamageHappen(sub, false)) {
continue;
}
affectedList.add(affectedEntity);
}
@ -137,9 +137,9 @@ public class EngineCanCombatHappen extends Engine {
// If the defender is a player ...
Entity edefender = event.getEntity();
if (MUtil.isntPlayer(edefender)) {
return true;
}
if (MUtil.isntPlayer(edefender)) {
return true;
}
Player defender = (Player) edefender;
MPlayer mdefender = MPlayer.get(edefender);
@ -148,9 +148,9 @@ public class EngineCanCombatHappen extends Engine {
// (we check null here since there may not be an attacker)
// (lack of attacker situations can be caused by other bukkit plugins)
if (eattacker != null && eattacker.equals(edefender)) {
return true;
}
if (eattacker != null && eattacker.equals(edefender)) {
return true;
}
// ... gather defender PS and faction information ...
PS defenderPs = PS.valueOf(defender.getLocation());
@ -160,9 +160,9 @@ public class EngineCanCombatHappen extends Engine {
if (MUtil.isPlayer(eattacker)) {
MPlayer mplayer = MPlayer.get(eattacker);
if (mplayer != null && mplayer.isOverriding()) {
return true;
}
if (mplayer != null && mplayer.isOverriding()) {
return true;
}
}
// ... PVP flag may cause a damage block ...
@ -184,16 +184,16 @@ public class EngineCanCombatHappen extends Engine {
}
// ... and if the attacker is a player ...
if (MUtil.isntPlayer(eattacker)) {
return true;
}
if (MUtil.isntPlayer(eattacker)) {
return true;
}
Player attacker = (Player) eattacker;
MPlayer uattacker = MPlayer.get(attacker);
// ... does this player bypass all protection? ...
if (MConf.get().playersWhoBypassAllProtection.contains(attacker.getName())) {
return true;
}
if (MConf.get().playersWhoBypassAllProtection.contains(attacker.getName())) {
return true;
}
// ... gather attacker PS and faction information ...
PS attackerPs = PS.valueOf(attacker.getLocation());
@ -204,25 +204,25 @@ public class EngineCanCombatHappen extends Engine {
// NOTE: This check is probably not that important but we could keep it anyways.
if (attackerPsFaction.getFlag(MFlag.getFlagPvp()) == false) {
ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, DisallowCause.PEACEFUL_LAND, event);
if (!ret && notify) {
uattacker.msg("<i>PVP is disabled in %s.", attackerPsFaction.describeTo(uattacker));
}
if (!ret && notify) {
uattacker.msg("<i>PVP is disabled in %s.", attackerPsFaction.describeTo(uattacker));
}
return ret;
}
// ... are PVP rules completely ignored in this world? ...
if (!MConf.get().worldsPvpRulesEnabled.contains(defenderPs.getWorld())) {
return true;
}
if (!MConf.get().worldsPvpRulesEnabled.contains(defenderPs.getWorld())) {
return true;
}
Faction defendFaction = mdefender.getFaction();
Faction attackFaction = uattacker.getFaction();
if (attackFaction.isNone() && MConf.get().disablePVPForFactionlessPlayers) {
ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, DisallowCause.FACTIONLESS, event);
if (!ret && notify) {
uattacker.msg("<i>You can't hurt other players until you join a faction.");
}
if (!ret && notify) {
uattacker.msg("<i>You can't hurt other players until you join a faction.");
}
return ret;
} else if (defendFaction.isNone()) {
if (defenderPsFaction == attackFaction && MConf.get().enablePVPAgainstFactionlessInAttackersLand) {
@ -230,9 +230,9 @@ public class EngineCanCombatHappen extends Engine {
return true;
} else if (MConf.get().disablePVPForFactionlessPlayers) {
ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, DisallowCause.FACTIONLESS, event);
if (!ret && notify) {
uattacker.msg("<i>You can't hurt players who are not currently in a faction.");
}
if (!ret && notify) {
uattacker.msg("<i>You can't hurt players who are not currently in a faction.");
}
return ret;
} else if (attackFaction.isNone() && MConf.get().enablePVPBetweenFactionlessPlayers) {
// Allow factionless vs factionless
@ -245,9 +245,9 @@ public class EngineCanCombatHappen extends Engine {
// Check the relation
if (relation.isFriend() && defenderPsFaction.getFlag(MFlag.getFlagFriendlyire()) == false) {
ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, DisallowCause.FRIENDLYFIRE, event);
if (!ret && notify) {
uattacker.msg("<i>You can't hurt %s<i>.", relation.getDescPlayerMany());
}
if (!ret && notify) {
uattacker.msg("<i>You can't hurt %s<i>.", relation.getDescPlayerMany());
}
return ret;
}

View File

@ -60,9 +60,9 @@ public class EngineChunkChange extends Engine {
final Set<PS> chunks = event.getChunks();
// Override Mode? Sure!
if (mplayer.isOverriding()) {
return;
}
if (mplayer.isOverriding()) {
return;
}
// CALC: Is there at least one normal faction among the current ones?
boolean currentFactionsContainsAtLeastOneNormal = false;
@ -156,9 +156,9 @@ public class EngineChunkChange extends Engine {
// HOW: Next we check if the new faction has permission to claim nearby the nearby factions.
MPerm claimnear = MPerm.getPermClaimnear();
for (Faction nearbyFaction : nearbyFactions) {
if (claimnear.has(mplayer, nearbyFaction, true)) {
continue;
}
if (claimnear.has(mplayer, nearbyFaction, true)) {
continue;
}
event.setCancelled(true);
return;
}
@ -217,14 +217,14 @@ public class EngineChunkChange extends Engine {
Set<PS> oldChunks = entry.getValue();
// ... that is an actual faction ...
if (oldFaction.isNone()) {
continue;
}
if (oldFaction.isNone()) {
continue;
}
// ... for which the mplayer lacks permission ...
if (MPerm.getPermTerritory().has(mplayer, oldFaction, false)) {
continue;
}
if (MPerm.getPermTerritory().has(mplayer, oldFaction, false)) {
continue;
}
// ... consider all reasons to forbid "overclaiming/warclaiming" ...

View File

@ -29,9 +29,9 @@ public class EngineCleanInactivity extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void ageBonus(EventMassiveCorePlayerCleanInactivityToleranceMillis event) {
if (event.getColl() != MPlayerColl.get()) {
return;
}
if (event.getColl() != MPlayerColl.get()) {
return;
}
applyPlayerAgeBonus(event);
applyFactionAgeBonus(event);
@ -47,9 +47,9 @@ public class EngineCleanInactivity extends Engine {
// Calculate the Bonus!
Long bonus = calculateBonus(age, MConf.get().cleanInactivityToleranceMillisPlayerAgeToBonus);
if (bonus == null) {
return;
}
if (bonus == null) {
return;
}
// Apply
event.getToleranceCauseMillis().put("Player Age Bonus", bonus);
@ -65,30 +65,30 @@ public class EngineCleanInactivity extends Engine {
// Calculate the Bonus!
Long bonus = calculateBonus(age, MConf.get().cleanInactivityToleranceMillisFactionAgeToBonus);
if (bonus == null) {
return;
}
if (bonus == null) {
return;
}
// Apply
event.getToleranceCauseMillis().put("Faction Age Bonus", bonus);
}
private Long calculateBonus(long age, Map<Long, Long> ageToBonus) {
if (ageToBonus.isEmpty()) {
return null;
}
if (ageToBonus.isEmpty()) {
return null;
}
Long bonus = 0L;
for (Entry<Long, Long> entry : ageToBonus.entrySet()) {
Long key = entry.getKey();
if (key == null) {
continue;
}
if (key == null) {
continue;
}
Long value = entry.getValue();
if (value == null) {
continue;
}
if (value == null) {
continue;
}
if (age >= key) {
bonus = value;

View File

@ -36,15 +36,15 @@ public class EngineDenyCommands extends Engine {
public void denyCommands(PlayerCommandPreprocessEvent event) {
// If a player is trying to run a command ...
Player player = event.getPlayer();
if (MUtil.isntPlayer(player)) {
return;
}
if (MUtil.isntPlayer(player)) {
return;
}
MPlayer mplayer = MPlayer.get(player);
// ... and the player is not overriding ...
if (mplayer.isOverriding()) {
return;
}
if (mplayer.isOverriding()) {
return;
}
// ... clean up the command ...
String command = event.getMessage();
@ -72,19 +72,19 @@ public class EngineDenyCommands extends Engine {
if (MConf.get().denyCommandsDistance > -1 && !MConf.get().denyCommandsDistanceBypassIn.contains(factionAtRel)) {
for (Player otherplayer : player.getWorld().getPlayers()) {
MPlayer othermplayer = MPlayer.get(otherplayer);
if (othermplayer == mplayer) {
continue;
}
if (othermplayer == mplayer) {
continue;
}
double distance = player.getLocation().distance(otherplayer.getLocation());
if (MConf.get().denyCommandsDistance > distance) {
continue;
}
if (MConf.get().denyCommandsDistance > distance) {
continue;
}
Rel playerRel = mplayer.getRelationTo(othermplayer);
if (!MConf.get().denyCommandsDistanceRelation.containsKey(playerRel)) {
continue;
}
if (!MConf.get().denyCommandsDistanceRelation.containsKey(playerRel)) {
continue;
}
String desc = playerRel.getDescPlayerOne();
@ -95,17 +95,17 @@ public class EngineDenyCommands extends Engine {
}
// ... if there is no relation here then there are no further checks ...
if (factionAtRel == null) {
return;
}
if (factionAtRel == null) {
return;
}
List<String> deniedCommands = MConf.get().denyCommandsTerritoryRelation.get(factionAtRel);
if (deniedCommands == null) {
return;
}
if (!MUtil.containsCommand(command, deniedCommands)) {
return;
}
if (deniedCommands == null) {
return;
}
if (!MUtil.containsCommand(command, deniedCommands)) {
return;
}
mplayer.msg("<b>You can't use \"<h>/%s<b>\" in %s territory.", command, Txt.getNicedEnum(factionAtRel));
event.setCancelled(true);

View File

@ -45,9 +45,9 @@ public class EngineDenyTeleport extends Engine {
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void canTeleportHappen(PlayerTeleportEvent event) {
Entry<TeleportCause, TerritoryType> entry = shouldBeCancelled(event);
if (entry == null) {
return;
}
if (entry == null) {
return;
}
event.setCancelled(true);
@ -56,18 +56,18 @@ public class EngineDenyTeleport extends Engine {
String teleportDesc = Txt.getNicedEnum(cause);
String denyDesc = "";
if (deny == TerritoryType.ENEMY) {
denyDesc = "enemy";
}
if (deny == TerritoryType.WILDERNESS) {
denyDesc = "wilderness";
}
if (deny == TerritoryType.OWN) {
denyDesc = "your own";
}
if (deny == TerritoryType.OTHER) {
denyDesc = "other faction's";
}
if (deny == TerritoryType.ENEMY) {
denyDesc = "enemy";
}
if (deny == TerritoryType.WILDERNESS) {
denyDesc = "wilderness";
}
if (deny == TerritoryType.OWN) {
denyDesc = "your own";
}
if (deny == TerritoryType.OTHER) {
denyDesc = "other faction's";
}
Player player = event.getPlayer();
MixinMessage.get().msgOne(player, "<b>Teleportation with %s is not allowed in %s territory.", teleportDesc, denyDesc);
@ -75,9 +75,9 @@ public class EngineDenyTeleport extends Engine {
private Entry<TeleportCause, TerritoryType> shouldBeCancelled(PlayerTeleportEvent event) {
Player player = event.getPlayer();
if (MUtil.isntPlayer(player)) {
return null;
}
if (MUtil.isntPlayer(player)) {
return null;
}
MPlayer mplayer = MPlayer.get(player);
@ -92,37 +92,37 @@ public class EngineDenyTeleport extends Engine {
MConf mconf = MConf.get();
if (cause == TeleportCause.CHORUS_FRUIT) {
if (!mconf.allowChorusFruitInEnemyTerritory && types.contains(TerritoryType.ENEMY)) {
return Couple.valueOf(cause, TerritoryType.ENEMY);
}
if (!mconf.allowChorusFruitInEnemyTerritory && types.contains(TerritoryType.ENEMY)) {
return Couple.valueOf(cause, TerritoryType.ENEMY);
}
if (!mconf.allowChorusFruitInWildernessTerritory && types.contains(TerritoryType.WILDERNESS)) {
return Couple.valueOf(cause, TerritoryType.WILDERNESS);
}
if (!mconf.allowChorusFruitInWildernessTerritory && types.contains(TerritoryType.WILDERNESS)) {
return Couple.valueOf(cause, TerritoryType.WILDERNESS);
}
if (!mconf.allowChorusFruitInOwnTerritory && types.contains(TerritoryType.OWN)) {
return Couple.valueOf(cause, TerritoryType.OWN);
}
if (!mconf.allowChorusFruitInOwnTerritory && types.contains(TerritoryType.OWN)) {
return Couple.valueOf(cause, TerritoryType.OWN);
}
if (!mconf.allowChorusFruitInOtherTerritory && types.contains(TerritoryType.OTHER)) {
return Couple.valueOf(cause, TerritoryType.OTHER);
}
if (!mconf.allowChorusFruitInOtherTerritory && types.contains(TerritoryType.OTHER)) {
return Couple.valueOf(cause, TerritoryType.OTHER);
}
} else if (cause == TeleportCause.ENDER_PEARL) {
if (!mconf.allowEnderPearlInEnemyTerritory && types.contains(TerritoryType.ENEMY)) {
return Couple.valueOf(cause, TerritoryType.ENEMY);
}
if (!mconf.allowEnderPearlInEnemyTerritory && types.contains(TerritoryType.ENEMY)) {
return Couple.valueOf(cause, TerritoryType.ENEMY);
}
if (!mconf.allowEnderPearlInWildernessTerritory && types.contains(TerritoryType.WILDERNESS)) {
return Couple.valueOf(cause, TerritoryType.WILDERNESS);
}
if (!mconf.allowEnderPearlInWildernessTerritory && types.contains(TerritoryType.WILDERNESS)) {
return Couple.valueOf(cause, TerritoryType.WILDERNESS);
}
if (!mconf.allowEnderPearlInOwnTerritory && types.contains(TerritoryType.OWN)) {
return Couple.valueOf(cause, TerritoryType.OWN);
}
if (!mconf.allowEnderPearlInOwnTerritory && types.contains(TerritoryType.OWN)) {
return Couple.valueOf(cause, TerritoryType.OWN);
}
if (!mconf.allowEnderPearlInOtherTerritory && types.contains(TerritoryType.OTHER)) {
return Couple.valueOf(cause, TerritoryType.OTHER);
}
if (!mconf.allowEnderPearlInOtherTerritory && types.contains(TerritoryType.OTHER)) {
return Couple.valueOf(cause, TerritoryType.OTHER);
}
} else {
// Don't cancel other kinds of teleports
}
@ -134,15 +134,15 @@ public class EngineDenyTeleport extends Engine {
Faction territoryFaction = BoardColl.get().getFactionAt(territory);
Rel relation = territoryFaction.getRelationTo(mplayer);
if (territoryFaction.isNone()) {
return TerritoryType.WILDERNESS;
}
if (relation == Rel.ENEMY) {
return TerritoryType.ENEMY;
}
if (relation == Rel.FACTION) {
return TerritoryType.OWN;
}
if (territoryFaction.isNone()) {
return TerritoryType.WILDERNESS;
}
if (relation == Rel.ENEMY) {
return TerritoryType.ENEMY;
}
if (relation == Rel.FACTION) {
return TerritoryType.OWN;
}
return TerritoryType.OTHER;
}

View File

@ -38,9 +38,9 @@ public class EngineExploit extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void obsidianGenerators(BlockFromToEvent event) {
if (!MConf.get().handleExploitObsidianGenerators) {
return;
}
if (!MConf.get().handleExploitObsidianGenerators) {
return;
}
// thanks to ObGenBlocker and WorldGuard for this method
Block block = event.getToBlock();
@ -57,12 +57,12 @@ public class EngineExploit extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void enderPearlClipping(PlayerTeleportEvent event) {
if (!MConf.get().handleExploitEnderPearlClipping) {
return;
}
if (event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) {
return;
}
if (!MConf.get().handleExploitEnderPearlClipping) {
return;
}
if (event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) {
return;
}
// this exploit works when the target location is within 0.31 blocks or so of a door or glass block or similar...
Location target = event.getTo();
@ -109,26 +109,26 @@ public class EngineExploit extends Engine {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void portalTrapRemoveAnimation(PlayerTeleportEvent event) {
// If there is a teleport caused by a nether portal ...
if (!MConf.get().handleNetherPortalTrap || event.getCause() != TeleportCause.NETHER_PORTAL) {
return;
}
if (!MConf.get().handleNetherPortalTrap || event.getCause() != TeleportCause.NETHER_PORTAL) {
return;
}
Player player = event.getPlayer();
Block from = event.getTo().getBlock();
// ... and the player can't build at the destination ...
if (EnginePermBuild.canPlayerBuildAt(player, PS.valueOf(from), false)) {
return;
}
if (EnginePermBuild.canPlayerBuildAt(player, PS.valueOf(from), false)) {
return;
}
// ... reset the old portal blocks stored ...
this.portalReset(player);
// ... get all the portal blocks belonging to the new portal at the destination ...
List<Block> portalTrap = getPortal(from);
if (portalTrap.isEmpty()) {
return;
}
if (portalTrap.isEmpty()) {
return;
}
// ... and then store those blocks and send an update as if they were air.
this.portalTraps.put(player.getUniqueId(), portalTrap);
@ -138,18 +138,18 @@ public class EngineExploit extends Engine {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void portalUpdate(PlayerMoveEvent event) {
// If a player moves ...
if (!MConf.get().handleNetherPortalTrap || MUtil.isSameBlock(event)) {
return;
}
if (!MConf.get().handleNetherPortalTrap || MUtil.isSameBlock(event)) {
return;
}
Player player = event.getPlayer();
UUID uuid = player.getUniqueId();
// ... and he recently used a portal ...
List<Block> portalTrap = this.portalTraps.get(uuid);
if (portalTrap == null) {
return;
}
if (portalTrap == null) {
return;
}
Location locationTo = event.getTo();
Location locationFrom = portalTrap.get(0).getLocation();
@ -172,17 +172,17 @@ public class EngineExploit extends Engine {
// If a player has already a portal registered to him ...
List<Block> portalTrap = this.portalTraps.get(uuid);
if (portalTrap == null) {
return;
}
if (portalTrap == null) {
return;
}
// ... remove them from the registry ...
this.portalTraps.remove(uuid);
// ... and send updates if the player and portal are in the same world.
if (!player.getWorld().equals(portalTrap.get(0).getWorld())) {
return;
}
if (!player.getWorld().equals(portalTrap.get(0).getWorld())) {
return;
}
portalUpdateReset(player, portalTrap);
}
@ -212,9 +212,9 @@ public class EngineExploit extends Engine {
for (int x = -(NETHER_TRAP_RADIUS_CHECK); x <= NETHER_TRAP_RADIUS_CHECK; x++) {
for (int y = -(NETHER_TRAP_RADIUS_CHECK); y <= NETHER_TRAP_RADIUS_CHECK; y++) {
for (int z = -(NETHER_TRAP_RADIUS_CHECK); z <= NETHER_TRAP_RADIUS_CHECK; z++) {
if (from.getRelative(x, y, z).getType() == Material.NETHER_PORTAL) {
ret.add(from.getRelative(x, y, z));
}
if (from.getRelative(x, y, z).getType() == Material.NETHER_PORTAL) {
ret.add(from.getRelative(x, y, z));
}
}
}
}

View File

@ -30,16 +30,16 @@ public class EngineFlagEndergrief extends Engine {
public void blockEndergrief(EntityChangeBlockEvent event) {
// If an enderman is changing a block ...
Entity entity = event.getEntity();
if (!(entity instanceof Enderman)) {
return;
}
if (!(entity instanceof Enderman)) {
return;
}
// ... and the faction there has endergrief disabled ...
PS ps = PS.valueOf(event.getBlock());
Faction faction = BoardColl.get().getFactionAt(ps);
if (faction.getFlag(MFlag.getFlagEndergrief())) {
return;
}
if (faction.getFlag(MFlag.getFlagEndergrief())) {
return;
}
// ... stop the block alteration.
event.setCancelled(true);

View File

@ -47,16 +47,16 @@ public class EngineFlagExplosion extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void blockExplosion(HangingBreakEvent event) {
// If a hanging entity was broken by an explosion ...
if (event.getCause() != RemoveCause.EXPLOSION) {
return;
}
if (event.getCause() != RemoveCause.EXPLOSION) {
return;
}
Entity entity = event.getEntity();
// ... and the faction there has explosions disabled ...
Faction faction = BoardColl.get().getFactionAt(PS.valueOf(entity.getLocation()));
if (faction.isExplosionsAllowed()) {
return;
}
if (faction.isExplosionsAllowed()) {
return;
}
// ... then cancel.
event.setCancelled(true);
@ -65,19 +65,19 @@ public class EngineFlagExplosion extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void blockExplosion(EntityDamageEvent event) {
// If an explosion damages ...
if (!DAMAGE_CAUSE_EXPLOSIONS.contains(event.getCause())) {
return;
}
if (!DAMAGE_CAUSE_EXPLOSIONS.contains(event.getCause())) {
return;
}
// ... an entity that is modified on damage ...
if (!EnumerationUtil.isEntityTypeEditOnDamage(event.getEntityType())) {
return;
}
if (!EnumerationUtil.isEntityTypeEditOnDamage(event.getEntityType())) {
return;
}
// ... and the faction has explosions disabled ...
if (BoardColl.get().getFactionAt(PS.valueOf(event.getEntity())).isExplosionsAllowed()) {
return;
}
if (BoardColl.get().getFactionAt(PS.valueOf(event.getEntity())).isExplosionsAllowed()) {
return;
}
// ... then cancel!
event.setCancelled(true);
@ -117,9 +117,9 @@ public class EngineFlagExplosion extends Engine {
faction2allowed.put(faction, allowed);
}
if (!allowed) {
iterator.remove();
}
if (!allowed) {
iterator.remove();
}
}
}
@ -127,17 +127,17 @@ public class EngineFlagExplosion extends Engine {
public void blockExplosion(EntityChangeBlockEvent event) {
// If a wither is changing a block ...
Entity entity = event.getEntity();
if (!(entity instanceof Wither)) {
return;
}
if (!(entity instanceof Wither)) {
return;
}
// ... and the faction there has explosions disabled ...
PS ps = PS.valueOf(event.getBlock());
Faction faction = BoardColl.get().getFactionAt(ps);
if (faction.isExplosionsAllowed()) {
return;
}
if (faction.isExplosionsAllowed()) {
return;
}
// ... stop the block alteration.
event.setCancelled(true);

View File

@ -35,9 +35,9 @@ public class EngineFlagFireSpread extends Engine {
PS ps = PS.valueOf(block);
Faction faction = BoardColl.get().getFactionAt(ps);
if (faction.getFlag(MFlag.getFlagFirespread())) {
return;
}
if (faction.getFlag(MFlag.getFlagFirespread())) {
return;
}
// then cancel the event.
cancellable.setCancelled(true);
@ -46,9 +46,9 @@ public class EngineFlagFireSpread extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void blockFireSpread(BlockIgniteEvent event) {
// If fire is spreading ...
if (event.getCause() != IgniteCause.SPREAD && event.getCause() != IgniteCause.LAVA) {
return;
}
if (event.getCause() != IgniteCause.SPREAD && event.getCause() != IgniteCause.LAVA) {
return;
}
// ... consider blocking it.
blockFireSpread(event.getBlock(), event);
@ -58,9 +58,9 @@ public class EngineFlagFireSpread extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void blockFireSpread(BlockSpreadEvent event) {
// If fire is spreading ...
if (event.getNewState().getType() != Material.FIRE) {
return;
}
if (event.getNewState().getType() != Material.FIRE) {
return;
}
// ... consider blocking it.
blockFireSpread(event.getBlock(), event);

View File

@ -52,9 +52,9 @@ public class EngineFlagSpawn extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void blockMonstersAndAnimals(CreatureSpawnEvent event) {
// If this is a natural spawn ..
if (!NATURAL_SPAWN_REASONS.contains(event.getSpawnReason())) {
return;
}
if (!NATURAL_SPAWN_REASONS.contains(event.getSpawnReason())) {
return;
}
// ... get the spawn location ...
Location location = event.getLocation();
@ -62,17 +62,17 @@ public class EngineFlagSpawn extends Engine {
// ... get the faction there ...
Faction faction = BoardColl.get().getFactionAt(ps);
if (faction == null) {
return;
}
if (faction == null) {
return;
}
// ... get the entity type ...
EntityType type = event.getEntityType();
// ... and if this type can't spawn in the faction ...
if (canSpawn(faction, type)) {
return;
}
if (canSpawn(faction, type)) {
return;
}
// ... then cancel.
event.setCancelled(true);

View File

@ -30,16 +30,16 @@ public class EngineFlagZombiegrief extends Engine {
public void denyZombieGrief(EntityBreakDoorEvent event) {
// If a zombie is breaking a door ...
Entity entity = event.getEntity();
if (!(entity instanceof Zombie)) {
return;
}
if (!(entity instanceof Zombie)) {
return;
}
// ... and the faction there has zombiegrief disabled ...
PS ps = PS.valueOf(event.getBlock());
Faction faction = BoardColl.get().getFactionAt(ps);
if (faction.getFlag(MFlag.getFlagZombiegrief())) {
return;
}
if (faction.getFlag(MFlag.getFlagZombiegrief())) {
return;
}
// ... stop the door breakage.
event.setCancelled(true);

View File

@ -44,31 +44,31 @@ public class EngineFly extends Engine {
public void onMassiveCorePlayerUpdate(EventMassiveCorePlayerUpdate event) {
// If we are updating a player ...
Player player = event.getPlayer();
if (MUtil.isntPlayer(player)) {
return;
}
if (MUtil.isntPlayer(player)) {
return;
}
// ... and that player isn't in creative or spectator mode ...
if (EventMassiveCorePlayerUpdate.isFlyAllowed(player, false)) {
return;
}
if (EventMassiveCorePlayerUpdate.isFlyAllowed(player, false)) {
return;
}
// ... and the player is alive ...
if (player.isDead()) {
return;
}
if (player.isDead()) {
return;
}
MPlayer mplayer = MPlayer.get(player);
// ... and the player enables flying ...
if (!mplayer.isFlying()) {
return;
}
if (!mplayer.isFlying()) {
return;
}
// ... and the player can fly here...
if (!canFlyInTerritory(mplayer, PS.valueOf(player))) {
return;
}
if (!canFlyInTerritory(mplayer, PS.valueOf(player))) {
return;
}
// ... set allowed ...
event.setAllowed(true);
@ -80,27 +80,27 @@ public class EngineFly extends Engine {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void moveChunkDetect(PlayerMoveEvent event) {
// If the player is moving from one chunk to another ...
if (MUtil.isSameChunk(event)) {
return;
}
if (MUtil.isSameChunk(event)) {
return;
}
Player player = event.getPlayer();
if (MUtil.isntPlayer(player)) {
return;
}
if (MUtil.isntPlayer(player)) {
return;
}
// ... gather info on the player and the move ...
MPlayer mplayer = MPlayer.get(player);
PS chunkTo = PS.valueOf(event.getTo()).getChunk(true);
// ... and they are currently flying ...
if (!mplayer.isFlying()) {
return;
}
if (!mplayer.isFlying()) {
return;
}
// ... but can't fly at the new place ...
if (canFlyInTerritory(mplayer, chunkTo)) {
return;
}
if (canFlyInTerritory(mplayer, chunkTo)) {
return;
}
// ... then perhaps they should not be
mplayer.setFlying(false);
@ -109,12 +109,12 @@ public class EngineFly extends Engine {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void flagUpdate(EventFactionsFlagChange event) {
if (event.getFlag() != MFlag.getFlagFly()) {
return;
}
if (event.isNewValue() == true) {
return;
}
if (event.getFlag() != MFlag.getFlagFly()) {
return;
}
if (event.isNewValue() == true) {
return;
}
// Disable for all players when disabled
event.getFaction().getOnlinePlayers().forEach(EngineFly::deactivateForPlayer);
@ -123,23 +123,23 @@ public class EngineFly extends Engine {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void territoryShield(EntityDamageByEntityEvent event) {
// If flying is diabled on PVP ...
if (!MConf.get().flyDisableOnPvp) {
return;
}
if (!MConf.get().flyDisableOnPvp) {
return;
}
// ... and the defender is a player ...
Entity entity = event.getEntity();
if (MUtil.isntPlayer(entity)) {
return;
}
if (MUtil.isntPlayer(entity)) {
return;
}
Player defender = (Player) entity;
MPlayer mdefender = MPlayer.get(defender);
// ... and the attacker is a player ...
Entity eattacker = MUtil.getLiableDamager(event);
if (!(eattacker instanceof Player)) {
return;
}
if (!(eattacker instanceof Player)) {
return;
}
Player attacker = (Player) eattacker;
MPlayer mattacker = MPlayer.get(attacker);
@ -206,12 +206,12 @@ public class EngineFly extends Engine {
if (isAdmin) {
boolean overriding = mplayer.isOverriding();
ex.addMsg("<i>You can change the flag if you are overriding.");
if (overriding) {
ex.addMsg("<i>You are already overriding.");
} else {
ex.addMsg("<i>You can enable override with:");
ex.addMessage(CmdFactions.get().cmdFactionsOverride.getTemplate(false, true, mplayer.getSender()));
}
if (overriding) {
ex.addMsg("<i>You are already overriding.");
} else {
ex.addMsg("<i>You can enable override with:");
ex.addMessage(CmdFactions.get().cmdFactionsOverride.getTemplate(false, true, mplayer.getSender()));
}
if (!isDefault) {
ex.addMsg("<i>You can also ask someone with access to the configuration files to make flying enabled by default.");

View File

@ -27,21 +27,21 @@ public class EngineLastActivity extends Engine {
// -------------------------------------------- //
public static void updateLastActivity(CommandSender sender) {
if (sender == null) {
throw new RuntimeException("sender");
}
if (MUtil.isntSender(sender)) {
return;
}
if (sender == null) {
throw new RuntimeException("sender");
}
if (MUtil.isntSender(sender)) {
return;
}
MPlayer mplayer = MPlayer.get(sender);
mplayer.setLastActivityMillis();
}
public static void updateLastActivitySoon(final CommandSender sender) {
if (sender == null) {
throw new RuntimeException("sender");
}
if (sender == null) {
throw new RuntimeException("sender");
}
Bukkit.getScheduler().scheduleSyncDelayedTask(Factions.get(), () -> updateLastActivity(sender));
}

View File

@ -37,13 +37,13 @@ public class EngineMoveChunk extends Engine {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void moveChunkDetect(PlayerMoveEvent event) {
// If the player is moving from one chunk to another ...
if (MUtil.isSameChunk(event)) {
return;
}
if (MUtil.isSameChunk(event)) {
return;
}
Player player = event.getPlayer();
if (MUtil.isntPlayer(player)) {
return;
}
if (MUtil.isntPlayer(player)) {
return;
}
// ... gather info on the player and the move ...
MPlayer mplayer = MPlayer.get(player);
@ -67,9 +67,9 @@ public class EngineMoveChunk extends Engine {
}
private static void sendAutoMapUpdate(MPlayer mplayer, PS ps) {
if (!mplayer.isMapAutoUpdating()) {
return;
}
if (!mplayer.isMapAutoUpdating()) {
return;
}
AsciiMap map = new AsciiMap(mplayer, ps, false);
mplayer.message(map.render());
}
@ -78,9 +78,9 @@ public class EngineMoveChunk extends Engine {
Faction factionFrom = BoardColl.get().getFactionAt(psFrom);
Faction factionTo = BoardColl.get().getFactionAt(psTo);
if (factionFrom == factionTo) {
return;
}
if (factionFrom == factionTo) {
return;
}
if (mplayer.isTerritoryInfoTitles()) {
String titleMain = parseTerritoryInfo(MConf.get().territoryInfoTitlesMain, mplayer, factionTo);
@ -96,12 +96,12 @@ public class EngineMoveChunk extends Engine {
}
private static String parseTerritoryInfo(String string, MPlayer mplayer, Faction faction) {
if (string == null) {
throw new NullPointerException("string");
}
if (faction == null) {
throw new NullPointerException("faction");
}
if (string == null) {
throw new NullPointerException("string");
}
if (faction == null) {
throw new NullPointerException("faction");
}
string = Txt.parse(string);
string = string.replace("{name}", faction.getName());
@ -112,9 +112,9 @@ public class EngineMoveChunk extends Engine {
}
private static void sendTerritoryAccessMessage(MPlayer mplayer, PS psFrom, PS psTo) {
if (!MConf.get().territoryAccessShowMessage) {
return;
}
if (!MConf.get().territoryAccessShowMessage) {
return;
}
// Get TerritoryAccess for from & to chunks
TerritoryAccess accessFrom = BoardColl.get().getTerritoryAccessAt(psFrom);
@ -123,9 +123,9 @@ public class EngineMoveChunk extends Engine {
// See if the status has changed
AccessStatus statusFrom = accessFrom.getTerritoryAccess(mplayer);
AccessStatus statusTo = accessTo.getTerritoryAccess(mplayer);
if (statusFrom == statusTo) {
return;
}
if (statusFrom == statusTo) {
return;
}
// Inform
mplayer.message(statusTo.getStatusMessage());
@ -138,9 +138,9 @@ public class EngineMoveChunk extends Engine {
private static void tryAutoClaim(MPlayer mplayer, PS chunkTo) {
// If the player is auto claiming ...
Faction autoClaimFaction = mplayer.getAutoClaimFaction();
if (autoClaimFaction == null) {
return;
}
if (autoClaimFaction == null) {
return;
}
// ... try claim.
mplayer.tryClaim(autoClaimFaction, Collections.singletonList(chunkTo));

View File

@ -62,39 +62,39 @@ public class EnginePermBuild extends Engine {
// -------------------------------------------- //
public static Boolean isProtected(ProtectCase protectCase, boolean verboose, MPlayer mplayer, PS ps, Object object) {
if (mplayer == null) {
return null;
}
if (protectCase == null) {
return null;
}
if (mplayer == null) {
return null;
}
if (protectCase == null) {
return null;
}
String name = mplayer.getName();
if (MConf.get().playersWhoBypassAllProtection.contains(name)) {
return false;
}
if (mplayer.isOverriding()) {
return false;
}
if (MConf.get().playersWhoBypassAllProtection.contains(name)) {
return false;
}
if (mplayer.isOverriding()) {
return false;
}
MPerm perm = protectCase.getPerm(object);
if (perm == null) {
return null;
}
if (protectCase != ProtectCase.BUILD) {
return !perm.has(mplayer, ps, verboose);
}
if (perm == null) {
return null;
}
if (protectCase != ProtectCase.BUILD) {
return !perm.has(mplayer, ps, verboose);
}
if (!perm.has(mplayer, ps, false) && MPerm.getPermPainbuild().has(mplayer, ps, false)) {
if (!verboose) {
return false;
}
if (!verboose) {
return false;
}
Faction hostFaction = BoardColl.get().getFactionAt(ps);
mplayer.msg("<b>It is painful to build in the territory of %s<b>.", hostFaction.describeTo(mplayer));
Player player = mplayer.getPlayer();
if (player != null) {
player.damage(MConf.get().actionDeniedPainAmount);
}
if (player != null) {
player.damage(MConf.get().actionDeniedPainAmount);
}
}
return !perm.has(mplayer, ps, verboose);
@ -102,20 +102,20 @@ public class EnginePermBuild extends Engine {
public static Boolean protect(ProtectCase protectCase, boolean verboose, Player player, PS ps, Object object, Cancellable cancellable) {
Boolean ret = isProtected(protectCase, verboose, MPlayer.get(player), ps, object);
if (Boolean.TRUE.equals(ret) && cancellable != null) {
cancellable.setCancelled(true);
}
if (Boolean.TRUE.equals(ret) && cancellable != null) {
cancellable.setCancelled(true);
}
return ret;
}
public static Boolean build(Entity entity, Block block, Event event) {
if (!(event instanceof Cancellable)) {
return true;
}
if (MUtil.isntPlayer(entity)) {
return false;
}
if (!(event instanceof Cancellable)) {
return true;
}
if (MUtil.isntPlayer(entity)) {
return false;
}
Player player = (Player) entity;
boolean verboose = !isFake(event);
return protect(ProtectCase.BUILD, verboose, player, PS.valueOf(block), block, (Cancellable) event);
@ -139,9 +139,9 @@ public class EnginePermBuild extends Engine {
public static boolean canPlayerBuildAt(Object senderObject, PS ps, boolean verboose) {
MPlayer mplayer = MPlayer.get(senderObject);
if (mplayer == null) {
return false;
}
if (mplayer == null) {
return false;
}
Boolean ret = isProtected(ProtectCase.BUILD, verboose, mplayer, ps, null);
return !Boolean.TRUE.equals(ret);
@ -180,9 +180,9 @@ public class EnginePermBuild extends Engine {
public void build(EntityChangeBlockEvent event) {
// Handling lilypads being broken by boats
Entity entity = event.getEntity();
if (entity.getType() != EntityType.BOAT || entity.getPassengers().size() <= 0) {
return;
}
if (entity.getType() != EntityType.BOAT || entity.getPassengers().size() <= 0) {
return;
}
Entity player = entity.getPassengers().stream().filter(MUtil::isPlayer).findAny().orElse(entity);
build(player, event.getBlock(), event);
@ -196,26 +196,26 @@ public class EnginePermBuild extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void useBlockItem(PlayerInteractEvent event) {
// If the player right clicks (or is physical with) a block ...
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) {
return;
}
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) {
return;
}
Block block = event.getClickedBlock();
Player player = event.getPlayer();
if (block == null) {
return;
}
if (block == null) {
return;
}
// ... and we are either allowed to use this block ...
Boolean ret = useBlock(player, block, true, event);
if (Boolean.TRUE.equals(ret)) {
return;
}
if (Boolean.TRUE.equals(ret)) {
return;
}
// ... or are allowed to right click with the item, this event is safe to perform.
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
return;
}
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
return;
}
useItem(player, block, event.getMaterial(), event);
}
@ -241,9 +241,9 @@ public class EnginePermBuild extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void useEntity(PlayerInteractEntityEvent event) {
// Ignore Off Hand
if (isOffHand(event)) {
return;
}
if (isOffHand(event)) {
return;
}
useEntity(event.getPlayer(), event.getRightClicked(), true, event);
}
@ -254,22 +254,22 @@ public class EnginePermBuild extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void handleArmorStand(PlayerInteractAtEntityEvent event) {
// Ignore Off Hand
if (isOffHand(event)) {
return;
}
if (isOffHand(event)) {
return;
}
// Gather Info
final Player player = event.getPlayer();
if (MUtil.isntPlayer(player)) {
return;
}
if (MUtil.isntPlayer(player)) {
return;
}
final Entity entity = event.getRightClicked();
final boolean verboose = true;
// Only care for armor stands.
if (entity.getType() != EntityType.ARMOR_STAND) {
return;
}
if (entity.getType() != EntityType.ARMOR_STAND) {
return;
}
// If we can't use, block it
EnginePermBuild.useEntity(player, entity, verboose, event);
@ -283,16 +283,16 @@ public class EnginePermBuild extends Engine {
public void buildEntity(EntityDamageByEntityEvent event) {
// If a player ...
Entity damager = MUtil.getLiableDamager(event);
if (MUtil.isntPlayer(damager)) {
return;
}
if (MUtil.isntPlayer(damager)) {
return;
}
Player player = (Player) damager;
// ... damages an entity which is edited on damage ...
Entity entity = event.getEntity();
if (entity == null || !EnumerationUtil.isEntityTypeEditOnDamage(entity.getType())) {
return;
}
if (entity == null || !EnumerationUtil.isEntityTypeEditOnDamage(entity.getType())) {
return;
}
// ... and the player can't build there, cancel the event
build(player, entity.getLocation().getBlock(), event);
@ -302,23 +302,23 @@ public class EnginePermBuild extends Engine {
public void combustEntity(EntityCombustByEntityEvent event) {
// If a burning projectile ...
if (!(event.getCombuster() instanceof Projectile)) {
return;
}
if (!(event.getCombuster() instanceof Projectile)) {
return;
}
Projectile entityProjectile = (Projectile) event.getCombuster();
// ... fired by a player ...
ProjectileSource projectileSource = entityProjectile.getShooter();
if (MUtil.isntPlayer(projectileSource)) {
return;
}
if (MUtil.isntPlayer(projectileSource)) {
return;
}
Player player = (Player) projectileSource;
// ... and hits an entity which is edited on damage (and thus likely to burn) ...
Entity entityTarget = event.getEntity();
if (entityTarget == null || !EnumerationUtil.isEntityTypeEditOnDamage(entityTarget.getType())) {
return;
}
if (entityTarget == null || !EnumerationUtil.isEntityTypeEditOnDamage(entityTarget.getType())) {
return;
}
// ... and the player can't build there, cancel the event
Block block = entityTarget.getLocation().getBlock();
@ -339,9 +339,9 @@ public class EnginePermBuild extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void blockBuild(BlockPistonExtendEvent event) {
// Is checking deactivated by MConf?
if (!MConf.get().handlePistonProtectionThroughDenyBuild) {
return;
}
if (!MConf.get().handlePistonProtectionThroughDenyBuild) {
return;
}
Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock()));
@ -354,14 +354,14 @@ public class EnginePermBuild extends Engine {
// Members of a faction might not have build rights in their own territory, but pistons should still work regardless
Faction targetFaction = BoardColl.get().getFactionAt(PS.valueOf(targetBlock));
if (targetFaction == pistonFaction) {
continue;
}
if (targetFaction == pistonFaction) {
continue;
}
// Perm check
if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) {
continue;
}
if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) {
continue;
}
event.setCancelled(true);
return;
@ -371,9 +371,9 @@ public class EnginePermBuild extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void blockBuild(BlockPistonRetractEvent event) {
// Is checking deactivated by MConf?
if (!MConf.get().handlePistonProtectionThroughDenyBuild) {
return;
}
if (!MConf.get().handlePistonProtectionThroughDenyBuild) {
return;
}
Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock()));
@ -382,20 +382,20 @@ public class EnginePermBuild extends Engine {
// Check for all retracted blocks
for (Block block : blocks) {
// Is the retracted block air/water/lava? Don't worry about it
if (block.isEmpty() || block.isLiquid()) {
return;
}
if (block.isEmpty() || block.isLiquid()) {
return;
}
// Members of a faction might not have build rights in their own territory, but pistons should still work regardless
Faction targetFaction = BoardColl.get().getFactionAt(PS.valueOf(block));
if (targetFaction == pistonFaction) {
continue;
}
if (targetFaction == pistonFaction) {
continue;
}
// Perm check
if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) {
continue;
}
if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) {
continue;
}
event.setCancelled(true);
return;
@ -410,27 +410,27 @@ public class EnginePermBuild extends Engine {
@EventHandler(priority = EventPriority.NORMAL)
public void buildFire(PlayerInteractEvent event) {
// If it is a left click on block and the clicked block is not null...
if (event.getAction() != Action.LEFT_CLICK_BLOCK || event.getClickedBlock() == null) {
return;
}
if (event.getAction() != Action.LEFT_CLICK_BLOCK || event.getClickedBlock() == null) {
return;
}
// ... and the potential block is not null either ...
Block potentialBlock = event.getClickedBlock().getRelative(BlockFace.UP, 1);
if (potentialBlock == null) {
return;
}
if (potentialBlock == null) {
return;
}
Material blockType = potentialBlock.getType();
// ... and we're only going to check for fire ... (checking everything else would be bad performance wise)
if (blockType != Material.FIRE) {
return;
}
if (blockType != Material.FIRE) {
return;
}
// ... check if they can't build, cancel the event ...
if (!Boolean.FALSE.equals(build(event.getPlayer(), potentialBlock, event))) {
return;
}
if (!Boolean.FALSE.equals(build(event.getPlayer(), potentialBlock, event))) {
return;
}
// ... and compensate for client side prediction
event.getPlayer().sendBlockChange(potentialBlock.getLocation(), blockType, potentialBlock.getState().getRawData());
@ -442,9 +442,9 @@ public class EnginePermBuild extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void buildMove(BlockFromToEvent event) {
if (!MConf.get().protectionLiquidFlowEnabled) {
return;
}
if (!MConf.get().protectionLiquidFlowEnabled) {
return;
}
// Prepare fields
Block fromBlock = event.getBlock();
@ -455,21 +455,21 @@ public class EnginePermBuild extends Engine {
int chunkToZ = (fromBlock.getZ() + face.getModZ()) >> 4;
// If a liquid (or dragon egg) moves from one chunk to another ...
if (chunkToX == chunkFromX && chunkToZ == chunkFromZ) {
return;
}
if (chunkToX == chunkFromX && chunkToZ == chunkFromZ) {
return;
}
// ... get the correct board for this block ...
Board board = BoardColl.get().getFixed(fromBlock.getWorld().getName().toLowerCase(), false);
if (board == null) {
return;
}
if (board == null) {
return;
}
// ... get the access map ...
Map<PS, TerritoryAccess> map = board.getMapRaw();
if (map.isEmpty()) {
return;
}
if (map.isEmpty()) {
return;
}
// ... get the faction ids from and to ...
PS fromPs = PS.valueOf(chunkFromX, chunkFromZ);
@ -482,22 +482,22 @@ public class EnginePermBuild extends Engine {
String toId = toTa != null ? toTa.getHostFactionId() : Factions.ID_NONE;
// ... and the chunks belong to different factions ...
if (toId.equals(fromId)) {
return;
}
if (toId.equals(fromId)) {
return;
}
// ... and the faction "from" can not build at "to" ...
Faction fromFac = FactionColl.get().getFixed(fromId);
if (fromFac == null) {
fromFac = FactionColl.get().getNone();
}
if (fromFac == null) {
fromFac = FactionColl.get().getNone();
}
Faction toFac = FactionColl.get().getFixed(toId);
if (toFac == null) {
toFac = FactionColl.get().getNone();
}
if (MPerm.getPermBuild().has(fromFac, toFac)) {
return;
}
if (toFac == null) {
toFac = FactionColl.get().getNone();
}
if (MPerm.getPermBuild().has(fromFac, toFac)) {
return;
}
// ... cancel the event!
event.setCancelled(true);

View File

@ -31,20 +31,20 @@ public class EnginePlayerData extends Engine {
// ... and if the if player was banned (not just kicked) ...
//if (!event.getReason().equals("Banned by admin.")) return;
if (!player.isBanned()) {
return;
}
if (!player.isBanned()) {
return;
}
// ... and we remove player data when banned ...
if (!MConf.get().removePlayerWhenBanned) {
return;
}
if (!MConf.get().removePlayerWhenBanned) {
return;
}
// ... get rid of their stored info.
MPlayer mplayer = MPlayerColl.get().get(player, false);
if (mplayer == null) {
return;
}
if (mplayer == null) {
return;
}
if (mplayer.getRank().isLeader()) {
mplayer.getFaction().promoteNewLeader();

View File

@ -35,15 +35,15 @@ public class EnginePower extends Engine {
public void powerLossOnDeath(PlayerDeathEvent event) {
// If a player dies ...
Player player = event.getEntity();
if (MUtil.isntPlayer(player)) {
return;
}
if (MUtil.isntPlayer(player)) {
return;
}
// ... and this is the first death event this tick ...
// (yeah other plugins can case death event to fire twice the same tick)
if (PlayerUtil.isDuplicateDeathEvent(event)) {
return;
}
if (PlayerUtil.isDuplicateDeathEvent(event)) {
return;
}
MPlayer mplayer = MPlayer.get(player);
@ -65,9 +65,9 @@ public class EnginePower extends Engine {
EventFactionsPowerChange powerChangeEvent = new EventFactionsPowerChange(null, mplayer, PowerChangeReason.DEATH, newPower);
powerChangeEvent.run();
if (powerChangeEvent.isCancelled()) {
return;
}
if (powerChangeEvent.isCancelled()) {
return;
}
newPower = powerChangeEvent.getNewPower();
mplayer.setPower(newPower);

View File

@ -39,9 +39,9 @@ public class EngineSeeChunk extends Engine {
// -------------------------------------------- //
public static void leaveAndWorldChangeRemoval(Player player) {
if (MUtil.isntPlayer(player)) {
return;
}
if (MUtil.isntPlayer(player)) {
return;
}
final MPlayer mplayer = MPlayer.get(player);
mplayer.setSeeingChunk(false);
@ -68,9 +68,9 @@ public class EngineSeeChunk extends Engine {
// Do we have a new period?
final long now = System.currentTimeMillis();
final long length = 500;
if (!PeriodUtil.isNewPeriod(this, length, now)) {
return;
}
if (!PeriodUtil.isNewPeriod(this, length, now)) {
return;
}
// Get the period number
final long period = PeriodUtil.getPeriod(length, now);
@ -89,15 +89,15 @@ public class EngineSeeChunk extends Engine {
// For each player
for (Player player : Bukkit.getOnlinePlayers()) {
// Hide for dead players since the death screen looks better without.
if (player.isDead()) {
continue;
}
if (player.isDead()) {
continue;
}
// The player must obviously have the feature activated.
MPlayer mplayer = MPlayer.get(player);
if (!mplayer.isSeeingChunk()) {
continue;
}
if (!mplayer.isSeeingChunk()) {
continue;
}
// Calculate locations and play the effect there.
List<Location> locations = getLocations(player, steps, step);
@ -110,18 +110,18 @@ public class EngineSeeChunk extends Engine {
public static List<Location> getLocations(Player player, int steps, int step) {
// Clean Args
if (player == null) {
throw new NullPointerException("player");
}
if (steps < 1) {
throw new InvalidParameterException("steps must be larger than 0");
}
if (step < 0) {
throw new InvalidParameterException("step must at least be 0");
}
if (step >= steps) {
throw new InvalidParameterException("step must be less than steps");
}
if (player == null) {
throw new NullPointerException("player");
}
if (steps < 1) {
throw new InvalidParameterException("steps must be larger than 0");
}
if (step < 0) {
throw new InvalidParameterException("step must at least be 0");
}
if (step >= steps) {
throw new InvalidParameterException("step must be less than steps");
}
// Create Ret
List<Location> ret = new ArrayList<>();
@ -137,14 +137,14 @@ public class EngineSeeChunk extends Engine {
final int zmax = zmin + 15;
int keepEvery = 5;
if (keepEvery <= 0) {
keepEvery = Integer.MAX_VALUE;
}
if (keepEvery <= 0) {
keepEvery = Integer.MAX_VALUE;
}
int skipEvery = 0;
if (skipEvery <= 0) {
skipEvery = Integer.MAX_VALUE;
}
if (skipEvery <= 0) {
skipEvery = Integer.MAX_VALUE;
}
int x = xmin;
int z = zmin;
@ -154,36 +154,36 @@ public class EngineSeeChunk extends Engine {
while (x + 1 <= xmax) {
x++;
i++;
if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) {
ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5));
}
if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) {
ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5));
}
}
// Add #2
while (z + 1 <= zmax) {
z++;
i++;
if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) {
ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5));
}
if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) {
ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5));
}
}
// Add #3
while (x - 1 >= xmin) {
x--;
i++;
if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) {
ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5));
}
if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) {
ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5));
}
}
// Add #4
while (z - 1 >= zmin) {
z--;
i++;
if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) {
ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5));
}
if (i % steps == step && (i % keepEvery == 0 && i % skipEvery != 0)) {
ret.add(new Location(world, x + 0.5, y + 0.5, z + 0.5));
}
}
// Return Ret

View File

@ -32,33 +32,33 @@ public class EngineTeleportHomeOnDeath extends Engine {
public void teleportToHomeOnDeath(PlayerRespawnEvent event, EventPriority priority) {
// If a player is respawning ...
final Player player = event.getPlayer();
if (MUtil.isntPlayer(player)) {
return;
}
if (MUtil.isntPlayer(player)) {
return;
}
final MPlayer mplayer = MPlayer.get(player);
// ... homes are enabled, active and at this priority ...
if (!MConf.get().warpsEnabled) {
return;
}
if (!MConf.get().warpsTeleportToOnDeathActive) {
return;
}
if (MConf.get().warpsTeleportToOnDeathPriority != priority) {
return;
}
if (!MConf.get().warpsEnabled) {
return;
}
if (!MConf.get().warpsTeleportToOnDeathActive) {
return;
}
if (MConf.get().warpsTeleportToOnDeathPriority != priority) {
return;
}
// ... and the player has a faction ...
final Faction faction = mplayer.getFaction();
if (faction.isNone()) {
return;
}
if (faction.isNone()) {
return;
}
// ... and the faction has a home ...
List<Warp> warps = faction.getWarps().getAll((java.util.function.Predicate<Warp>) (warp -> warp.getName().equalsIgnoreCase(MConf.get().warpsTeleportToOnDeathName)));
if (warps.isEmpty()) {
return;
}
if (warps.isEmpty()) {
return;
}
Warp warp = warps.get(0);

View File

@ -31,32 +31,32 @@ public class EngineTerritoryShield extends Engine {
public void territoryShield(EntityDamageByEntityEvent event) {
// If the entity is a player ...
Entity entity = event.getEntity();
if (MUtil.isntPlayer(entity)) {
return;
}
if (MUtil.isntPlayer(entity)) {
return;
}
Player player = (Player) entity;
MPlayer mplayer = MPlayer.get(player);
// ... and the attacker is a player ...
Entity attacker = MUtil.getLiableDamager(event);
if (!(attacker instanceof Player)) {
return;
}
if (!(attacker instanceof Player)) {
return;
}
// ... and that player has a faction ...
if (!mplayer.hasFaction()) {
return;
}
if (!mplayer.hasFaction()) {
return;
}
// ... and that player is in their own territory ...
if (!mplayer.isInOwnTerritory()) {
return;
}
if (!mplayer.isInOwnTerritory()) {
return;
}
// ... and a territoryShieldFactor is configured ...
if (MConf.get().territoryShieldFactor <= 0) {
return;
}
if (MConf.get().territoryShieldFactor <= 0) {
return;
}
// ... then scale the damage ...
double factor = 1D - MConf.get().territoryShieldFactor;

View File

@ -24,9 +24,9 @@ public class EngineVisualizations extends Engine {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerMoveClearVisualizations(PlayerMoveEvent event) {
if (MUtil.isSameBlock(event)) {
return;
}
if (MUtil.isSameBlock(event)) {
return;
}
VisualizeUtil.clear(event.getPlayer());
}

View File

@ -40,12 +40,12 @@ public class Board extends Entity<Board> implements BoardInterface {
@Override
public boolean isDefault() {
if (this.map == null) {
return true;
}
if (this.map.isEmpty()) {
return true;
}
if (this.map == null) {
return true;
}
if (this.map.isEmpty()) {
return true;
}
return false;
}
@ -83,15 +83,15 @@ public class Board extends Entity<Board> implements BoardInterface {
@Override
public TerritoryAccess getTerritoryAccessAt(PS ps) {
if (ps == null) {
throw new NullPointerException("ps");
}
if (ps == null) {
throw new NullPointerException("ps");
}
ps = ps.getChunkCoords(true);
TerritoryAccess ret = this.map.get(ps);
if (ret == null || ret.getHostFaction() == null) {
ret = TerritoryAccess.valueOf(Factions.ID_NONE);
}
if (ret == null || ret.getHostFaction() == null) {
ret = TerritoryAccess.valueOf(Factions.ID_NONE);
}
return ret;
}
@ -161,9 +161,9 @@ public class Board extends Entity<Board> implements BoardInterface {
@Override
public Map<Faction, Set<PS>> getFactionToChunks(boolean withWorld) {
Function<Entry<PS, TerritoryAccess>, PS> mapper = Entry::getKey;
if (withWorld) {
mapper = mapper.andThen(ps -> ps.withWorld(this.getId()));
}
if (withWorld) {
mapper = mapper.andThen(ps -> ps.withWorld(this.getId()));
}
return map.entrySet().stream().collect(Collectors.groupingBy(
entry -> entry.getValue().getHostFaction(), // This specifies how to get the key
@ -180,18 +180,18 @@ public class Board extends Entity<Board> implements BoardInterface {
@Override
public int getCount(Faction faction) {
if (faction == null) {
throw new NullPointerException("faction");
}
if (faction == null) {
throw new NullPointerException("faction");
}
return this.getCount(faction.getId());
}
@Override
public int getCount(String factionId) {
if (factionId == null) {
throw new NullPointerException("factionId");
}
if (factionId == null) {
throw new NullPointerException("factionId");
}
return (int) this.map.values().stream()
.map(TerritoryAccess::getHostFactionId)
@ -234,24 +234,24 @@ public class Board extends Entity<Board> implements BoardInterface {
Faction faction = this.getFactionAt(ps);
nearby = ps.withChunkX(ps.getChunkX() + 1);
if (faction != this.getFactionAt(nearby)) {
return true;
}
if (faction != this.getFactionAt(nearby)) {
return true;
}
nearby = ps.withChunkX(ps.getChunkX() - 1);
if (faction != this.getFactionAt(nearby)) {
return true;
}
if (faction != this.getFactionAt(nearby)) {
return true;
}
nearby = ps.withChunkZ(ps.getChunkZ() + 1);
if (faction != this.getFactionAt(nearby)) {
return true;
}
if (faction != this.getFactionAt(nearby)) {
return true;
}
nearby = ps.withChunkZ(ps.getChunkZ() - 1);
if (faction != this.getFactionAt(nearby)) {
return true;
}
if (faction != this.getFactionAt(nearby)) {
return true;
}
return false;
}
@ -269,24 +269,24 @@ public class Board extends Entity<Board> implements BoardInterface {
PS nearby = null;
nearby = ps.withChunkX(ps.getChunkX() + 1);
if (faction == this.getFactionAt(nearby)) {
return true;
}
if (faction == this.getFactionAt(nearby)) {
return true;
}
nearby = ps.withChunkX(ps.getChunkX() - 1);
if (faction == this.getFactionAt(nearby)) {
return true;
}
if (faction == this.getFactionAt(nearby)) {
return true;
}
nearby = ps.withChunkZ(ps.getChunkZ() + 1);
if (faction == this.getFactionAt(nearby)) {
return true;
}
if (faction == this.getFactionAt(nearby)) {
return true;
}
nearby = ps.withChunkZ(ps.getChunkZ() - 1);
if (faction == this.getFactionAt(nearby)) {
return true;
}
if (faction == this.getFactionAt(nearby)) {
return true;
}
return false;
}

View File

@ -48,15 +48,15 @@ public class BoardColl extends Coll<Board> implements BoardInterface {
@Override
public String fixId(Object oid) {
if (oid == null) {
return null;
}
if (oid instanceof String) {
return (String) oid;
}
if (oid instanceof Board) {
return ((Board) oid).getId();
}
if (oid == null) {
return null;
}
if (oid instanceof String) {
return (String) oid;
}
if (oid instanceof Board) {
return ((Board) oid).getId();
}
boolean debug = MassiveCoreMConf.get().debugEnabled;
String ret = MUtil.extract(String.class, "worldName", oid);
@ -72,25 +72,25 @@ public class BoardColl extends Coll<Board> implements BoardInterface {
@Override
public TerritoryAccess getTerritoryAccessAt(PS ps) {
if (ps == null) {
throw new NullPointerException("ps");
}
if (ps == null) {
throw new NullPointerException("ps");
}
Board board = this.get(ps.getWorld());
if (board == null) {
return null;
}
if (board == null) {
return null;
}
return board.getTerritoryAccessAt(ps);
}
@Override
public Faction getFactionAt(PS ps) {
if (ps == null) {
throw new NullPointerException("ps");
}
if (ps == null) {
throw new NullPointerException("ps");
}
Board board = this.get(ps.getWorld());
if (board == null) {
return null;
}
if (board == null) {
return null;
}
return board.getFactionAt(ps);
}
@ -98,25 +98,25 @@ public class BoardColl extends Coll<Board> implements BoardInterface {
@Override
public void setTerritoryAccessAt(PS ps, TerritoryAccess territoryAccess) {
if (ps == null) {
throw new NullPointerException("ps");
}
if (ps == null) {
throw new NullPointerException("ps");
}
Board board = this.get(ps.getWorld());
if (board == null) {
return;
}
if (board == null) {
return;
}
board.setTerritoryAccessAt(ps, territoryAccess);
}
@Override
public void setFactionAt(PS ps, Faction faction) {
if (ps == null) {
throw new NullPointerException("ps");
}
if (ps == null) {
throw new NullPointerException("ps");
}
Board board = this.get(ps.getWorld());
if (board == null) {
return;
}
if (board == null) {
return;
}
board.setFactionAt(ps, faction);
}
@ -124,13 +124,13 @@ public class BoardColl extends Coll<Board> implements BoardInterface {
@Override
public void removeAt(PS ps) {
if (ps == null) {
throw new NullPointerException("ps");
}
if (ps == null) {
throw new NullPointerException("ps");
}
Board board = this.get(ps.getWorld());
if (board == null) {
return;
}
if (board == null) {
return;
}
board.removeAt(ps);
}
@ -190,9 +190,9 @@ public class BoardColl extends Coll<Board> implements BoardInterface {
}
// Enforce create
if (ret == null) {
ret = new MassiveMap<>();
}
if (ret == null) {
ret = new MassiveMap<>();
}
// Return
return ret;
@ -250,13 +250,13 @@ public class BoardColl extends Coll<Board> implements BoardInterface {
@Override
public boolean isBorderPs(PS ps) {
if (ps == null) {
throw new NullPointerException("ps");
}
if (ps == null) {
throw new NullPointerException("ps");
}
Board board = this.get(ps.getWorld());
if (board == null) {
return false;
}
if (board == null) {
return false;
}
return board.isBorderPs(ps);
}
@ -267,22 +267,22 @@ public class BoardColl extends Coll<Board> implements BoardInterface {
@Override
public boolean isConnectedPs(PS ps, Faction faction) {
if (ps == null) {
throw new NullPointerException("ps");
}
if (ps == null) {
throw new NullPointerException("ps");
}
Board board = this.get(ps.getWorld());
if (board == null) {
return false;
}
if (board == null) {
return false;
}
return board.isConnectedPs(ps, faction);
}
@Override
public boolean isAnyConnectedPs(Set<PS> pss, Faction faction) {
for (PS ps : pss) {
if (this.isConnectedPs(ps, faction)) {
return true;
}
if (this.isConnectedPs(ps, faction)) {
return true;
}
}
return false;
}
@ -296,9 +296,9 @@ public class BoardColl extends Coll<Board> implements BoardInterface {
}
public Set<String> getClaimedWorlds(String factionId) {
if (factionId == null) {
throw new NullPointerException("factionId");
}
if (factionId == null) {
throw new NullPointerException("factionId");
}
return this.getAll().stream()
.filter(board -> board.hasClaimed(factionId))
.map(Board::getId)
@ -314,16 +314,16 @@ public class BoardColl extends Coll<Board> implements BoardInterface {
// Distance 1 returns 3x3 = 9 chunks.
public static Set<PS> getNearbyChunks(PS psChunk, int distance) {
// Fix Args
if (psChunk == null) {
throw new NullPointerException("psChunk");
}
if (psChunk == null) {
throw new NullPointerException("psChunk");
}
psChunk = psChunk.getChunk(true);
// Create
Set<PS> ret = new MassiveSet<>();
if (distance < 0) {
return ret;
}
if (distance < 0) {
return ret;
}
// Fill
int chunkX = psChunk.getChunkX();
@ -347,16 +347,16 @@ public class BoardColl extends Coll<Board> implements BoardInterface {
public static Set<PS> getNearbyChunks(Collection<PS> chunks, int distance) {
// Fix Args
if (chunks == null) {
throw new NullPointerException("chunks");
}
if (chunks == null) {
throw new NullPointerException("chunks");
}
// Create
Set<PS> ret = new MassiveSet<>();
if (distance < 0) {
return ret;
}
if (distance < 0) {
return ret;
}
// Fill
for (PS chunk : chunks) {
@ -369,9 +369,9 @@ public class BoardColl extends Coll<Board> implements BoardInterface {
public static Set<Faction> getDistinctFactions(Collection<PS> chunks) {
// Fix Args
if (chunks == null) {
throw new NullPointerException("chunks");
}
if (chunks == null) {
throw new NullPointerException("chunks");
}
// Create
Set<Faction> ret = new MassiveSet<>();
@ -379,9 +379,9 @@ public class BoardColl extends Coll<Board> implements BoardInterface {
// Fill
for (PS chunk : chunks) {
Faction faction = get().getFactionAt(chunk);
if (faction == null) {
continue;
}
if (faction == null) {
continue;
}
ret.add(faction);
}
@ -398,9 +398,9 @@ public class BoardColl extends Coll<Board> implements BoardInterface {
for (PS chunk : chunks) {
chunk = chunk.getChunk(true);
Faction faction = get().getFactionAt(chunk);
if (faction == null) {
faction = none;
}
if (faction == null) {
faction = none;
}
ret.put(chunk, faction);
}
@ -414,9 +414,9 @@ public class BoardColl extends Coll<Board> implements BoardInterface {
outer:
for (PS ps : pss) {
if (discovered.contains(ps)) {
continue outer;
}
if (discovered.contains(ps)) {
continue outer;
}
List<PS> forest = new MassiveList<>();
forests.add(forest);
@ -426,9 +426,9 @@ public class BoardColl extends Coll<Board> implements BoardInterface {
inner:
while (!stack.empty()) {
PS elm = stack.pop();
if (discovered.contains(elm)) {
continue inner;
}
if (discovered.contains(elm)) {
continue inner;
}
System.out.println(elm);
discovered.add(elm);
forest.add(elm);
@ -444,9 +444,9 @@ public class BoardColl extends Coll<Board> implements BoardInterface {
}
private static void addIfInSource(PS ps, Stack<PS> stack, Collection<PS> source) {
if (source.contains(ps)) {
stack.push(ps);
}
if (source.contains(ps)) {
stack.push(ps);
}
}
}

View File

@ -87,9 +87,9 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
@Override
public void preDetach(String id) {
if (!this.isLive()) {
return;
}
if (!this.isLive()) {
return;
}
// NOTE: Existence check is required for compatibility with some plugins.
// If they have money ...
@ -198,9 +198,9 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
String target = name;
// Detect Nochange
if (MUtil.equals(this.name, target)) {
return;
}
if (MUtil.equals(this.name, target)) {
return;
}
// Apply
this.name = target;
@ -220,9 +220,9 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
}
public String getName(RelationParticipator observer) {
if (observer == null) {
return getName();
}
if (observer == null) {
return getName();
}
return this.getName(this.getColorTo(observer).toString());
}
@ -245,9 +245,9 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
String target = clean(description);
// Detect Nochange
if (MUtil.equals(this.description, target)) {
return;
}
if (MUtil.equals(this.description, target)) {
return;
}
// Apply
this.description = target;
@ -260,9 +260,9 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
public String getDescriptionDesc() {
String motd = this.getDescription();
if (motd == null) {
motd = NODESCRIPTION;
}
if (motd == null) {
motd = NODESCRIPTION;
}
return motd;
}
@ -285,9 +285,9 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
String target = clean(motd);
// Detect Nochange
if (MUtil.equals(this.motd, target)) {
return;
}
if (MUtil.equals(this.motd, target)) {
return;
}
// Apply
this.motd = target;
@ -303,9 +303,9 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
}
private static String getMotdDesc(String motd) {
if (motd == null) {
motd = NOMOTD;
}
if (motd == null) {
motd = NOMOTD;
}
return motd;
}
@ -339,9 +339,9 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
public void setCreatedAtMillis(long createdAtMillis) {
// Detect Nochange
if (MUtil.equals(this.createdAtMillis, createdAtMillis)) {
return;
}
if (MUtil.equals(this.createdAtMillis, createdAtMillis)) {
return;
}
// Apply
this.createdAtMillis = createdAtMillis;
@ -367,28 +367,28 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
}
public Warp getWarp(Object oid) {
if (oid == null) {
throw new NullPointerException("oid");
}
if (oid == null) {
throw new NullPointerException("oid");
}
Warp warp = this.getWarps().get(oid);
if (warp == null) {
return null;
}
if (warp == null) {
return null;
}
if (!warp.verifyIsValid()) {
return null;
}
if (!warp.verifyIsValid()) {
return null;
}
return warp;
}
public PS getWarpPS(Object oid) {
if (oid == null) {
throw new NullPointerException("oid");
}
if (oid == null) {
throw new NullPointerException("oid");
}
Warp warp = this.getWarp(oid);
if (warp == null) {
return null;
}
if (warp == null) {
return null;
}
return warp.getLocation();
}
@ -408,9 +408,9 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
@Override
public double getPowerBoost() {
Double ret = this.powerBoost;
if (ret == null) {
ret = 0D;
}
if (ret == null) {
ret = 0D;
}
return ret;
}
@ -419,14 +419,14 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
// Clean input
Double target = powerBoost;
if (target == null || target == 0) {
target = null;
}
if (target == null || target == 0) {
target = null;
}
// Detect Nochange
if (MUtil.equals(this.powerBoost, target)) {
return;
}
if (MUtil.equals(this.powerBoost, target)) {
return;
}
// Apply
this.powerBoost = target;
@ -440,29 +440,29 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
// -------------------------------------------- //
public double getMoney() {
if (!MConf.get().econEnabled) {
throw new UnsupportedOperationException("econ not enabled");
}
if (!MConf.get().bankEnabled) {
throw new UnsupportedOperationException("bank not enabled");
}
if (!MConf.get().useNewMoneySystem) {
throw new UnsupportedOperationException("this server does not use the new econ system");
}
if (!MConf.get().econEnabled) {
throw new UnsupportedOperationException("econ not enabled");
}
if (!MConf.get().bankEnabled) {
throw new UnsupportedOperationException("bank not enabled");
}
if (!MConf.get().useNewMoneySystem) {
throw new UnsupportedOperationException("this server does not use the new econ system");
}
return this.convertGet(this.money, 0D);
}
public void setMoney(Double money) {
if (!MConf.get().econEnabled) {
throw new UnsupportedOperationException("econ not enabled");
}
if (!MConf.get().bankEnabled) {
throw new UnsupportedOperationException("bank not enabled");
}
if (!MConf.get().useNewMoneySystem) {
throw new UnsupportedOperationException("this server does not use the new econ system");
}
if (!MConf.get().econEnabled) {
throw new UnsupportedOperationException("econ not enabled");
}
if (!MConf.get().bankEnabled) {
throw new UnsupportedOperationException("bank not enabled");
}
if (!MConf.get().useNewMoneySystem) {
throw new UnsupportedOperationException("this server does not use the new econ system");
}
this.money = this.convertSet(money, this.money, 0D);
}
@ -517,9 +517,9 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
}
public Rank getRank(String rankId) {
if (rankId == null) {
throw new NullPointerException("rankId");
}
if (rankId == null) {
throw new NullPointerException("rankId");
}
return this.getRanks().getFixed(rankId);
}
@ -536,9 +536,9 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
public Rank getLeaderRank() {
Rank ret = null;
for (Rank rank : this.getRanks().getAll()) {
if (ret != null && ret.isMoreThan(rank)) {
continue;
}
if (ret != null && ret.isMoreThan(rank)) {
continue;
}
ret = rank;
}
@ -548,9 +548,9 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
public Rank getLowestRank() {
Rank ret = null;
for (Rank rank : this.getRanks().getAll()) {
if (ret != null && ret.isLessThan(rank)) {
continue;
}
if (ret != null && ret.isLessThan(rank)) {
continue;
}
ret = rank;
}
@ -568,16 +568,16 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
}
public void addVote(Vote vote) {
if (vote == null) {
throw new NullPointerException("vote");
}
if (vote == null) {
throw new NullPointerException("vote");
}
this.getVotes().attach(vote);
}
public Optional<Vote> getVoteByName(String name) {
if (name == null) {
throw new NullPointerException("name");
}
if (name == null) {
throw new NullPointerException("name");
}
return this.getVotes().getAll().stream().filter(vote -> vote.getName().equalsIgnoreCase(name)).findFirst();
}
@ -596,9 +596,9 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
MassiveMapDef<String, Rel> target = new MassiveMapDef<>(relationWishes);
// Detect Nochange
if (MUtil.equals(this.relationWishes, target)) {
return;
}
if (MUtil.equals(this.relationWishes, target)) {
return;
}
// Apply
this.relationWishes = target;
@ -611,9 +611,9 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
public Rel getRelationWish(String factionId) {
Rel ret = this.getRelationWishes().get(factionId);
if (ret == null) {
ret = Rel.NEUTRAL;
}
if (ret == null) {
ret = Rel.NEUTRAL;
}
return ret;
}
@ -664,9 +664,9 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
// ... resolve object and skip unknowns ...
MFlag mflag = MFlag.get(id);
if (mflag == null) {
continue;
}
if (mflag == null) {
continue;
}
ret.put(mflag, entry.getValue());
}
@ -687,23 +687,23 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
MassiveMapDef<String, Boolean> target = new MassiveMapDef<>();
for (Map.Entry<String, Boolean> entry : flagIds.entrySet()) {
String key = entry.getKey();
if (key == null) {
continue;
}
if (key == null) {
continue;
}
key = key.toLowerCase(); // Lowercased Keys Version 2.6.0 --> 2.7.0
Boolean value = entry.getValue();
if (value == null) {
continue;
}
if (value == null) {
continue;
}
target.put(key, value);
}
// Detect Nochange
if (MUtil.equals(this.flags, target)) {
return;
}
if (MUtil.equals(this.flags, target)) {
return;
}
// Apply
this.flags = new MassiveMapDef<>(target);
@ -715,67 +715,67 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
// FINER
public boolean getFlag(String flagId) {
if (flagId == null) {
throw new NullPointerException("flagId");
}
if (flagId == null) {
throw new NullPointerException("flagId");
}
Boolean ret = this.flags.get(flagId);
if (ret != null) {
return ret;
}
if (ret != null) {
return ret;
}
MFlag flag = MFlag.get(flagId);
if (flag == null) {
throw new NullPointerException("flag");
}
if (flag == null) {
throw new NullPointerException("flag");
}
return flag.isStandard();
}
public boolean getFlag(MFlag flag) {
if (flag == null) {
throw new NullPointerException("flag");
}
if (flag == null) {
throw new NullPointerException("flag");
}
String flagId = flag.getId();
if (flagId == null) {
throw new NullPointerException("flagId");
}
if (flagId == null) {
throw new NullPointerException("flagId");
}
Boolean ret = this.flags.get(flagId);
if (ret != null) {
return ret;
}
if (ret != null) {
return ret;
}
return flag.isStandard();
}
public Boolean setFlag(String flagId, boolean value) {
if (flagId == null) {
throw new NullPointerException("flagId");
}
if (flagId == null) {
throw new NullPointerException("flagId");
}
Boolean ret = this.flags.put(flagId, value);
if (ret == null || ret != value) {
this.changed();
}
if (ret == null || ret != value) {
this.changed();
}
return ret;
}
public Boolean setFlag(MFlag flag, boolean value) {
if (flag == null) {
throw new NullPointerException("flag");
}
if (flag == null) {
throw new NullPointerException("flag");
}
String flagId = flag.getId();
if (flagId == null) {
throw new NullPointerException("flagId");
}
if (flagId == null) {
throw new NullPointerException("flagId");
}
Boolean ret = this.flags.put(flagId, value);
if (ret == null || ret != value) {
this.changed();
}
if (ret == null || ret != value) {
this.changed();
}
return ret;
}
@ -819,18 +819,18 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
// IS PERMITTED
public boolean isPlayerPermitted(MPlayer mplayer, String permId) {
if (isPermitted(mplayer.getId(), permId)) {
return true;
}
if (isPermitted(mplayer.getFaction().getId(), permId)) {
return true;
}
if (isPermitted(mplayer.getRank().getId(), permId)) {
return true;
}
if (isPermitted(RelationUtil.getRelationOfThatToMe(mplayer, this).toString(), permId)) {
return true;
}
if (isPermitted(mplayer.getId(), permId)) {
return true;
}
if (isPermitted(mplayer.getFaction().getId(), permId)) {
return true;
}
if (isPermitted(mplayer.getRank().getId(), permId)) {
return true;
}
if (isPermitted(RelationUtil.getRelationOfThatToMe(mplayer, this).toString(), permId)) {
return true;
}
return false;
}
@ -840,12 +840,12 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
}
public boolean isFactionPermitted(Faction faction, String permId) {
if (isPermitted(faction.getId(), permId)) {
return true;
}
if (isPermitted(RelationUtil.getRelationOfThatToMe(faction, this).toString(), permId)) {
return true;
}
if (isPermitted(faction.getId(), permId)) {
return true;
}
if (isPermitted(RelationUtil.getRelationOfThatToMe(faction, this).toString(), permId)) {
return true;
}
return false;
}
@ -855,17 +855,17 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
}
public Set<String> getPermitted(String permId) {
if (permId == null) {
throw new NullPointerException("permId");
}
if (permId == null) {
throw new NullPointerException("permId");
}
Set<String> permables = this.perms.get(permId);
if (permables == null) {
// No perms was found, but likely this is just a new MPerm.
// So if this does not exist in the database, throw an error.
if (!doesPermExist(permId)) {
throw new NullPointerException(permId + " caused null");
}
if (!doesPermExist(permId)) {
throw new NullPointerException(permId + " caused null");
}
permables = new MassiveSet<>();
this.perms.put(permId, permables);
@ -887,21 +887,21 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
}
public boolean isPermitted(String permableId, String permId) {
if (permableId == null) {
throw new NullPointerException("permableId");
}
if (permId == null) {
throw new NullPointerException("permId");
}
if (permableId == null) {
throw new NullPointerException("permableId");
}
if (permId == null) {
throw new NullPointerException("permId");
}
// TODO: Isn't this section redundant and just a copy of that from getPermitted?
Set<String> permables = this.perms.get(permId);
if (permables == null) {
// No perms was found, but likely this is just a new MPerm.
// So if this does not exist in the database, throw an error.
if (!doesPermExist(permId)) {
throw new NullPointerException(permId + " caused null");
}
if (!doesPermExist(permId)) {
throw new NullPointerException(permId + " caused null");
}
// Otherwise handle it
return false;
@ -919,9 +919,9 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
if (perms == null) {
// No perms was found, but likely this is just a new MPerm.
// So if this does not exist in the database, throw an error.
if (!doesPermExist(permId)) {
throw new NullPointerException(permId + " caused null");
}
if (!doesPermExist(permId)) {
throw new NullPointerException(permId + " caused null");
}
// Otherwise handle it
Set<String> permables = new MassiveSet<>();
@ -934,9 +934,9 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
} else {
changed = this.getPerms().get(permId).remove(mpermable.getId()) | changed;
}
if (changed) {
this.changed();
}
if (changed) {
this.changed();
}
return changed;
}
@ -969,16 +969,16 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
// FINER GET
public Double getTaxFor(String id) {
if (id == null) {
throw new NullPointerException("id");
}
if (id == null) {
throw new NullPointerException("id");
}
return this.tax.get(id);
}
public Double getTaxFor(Identified identified) {
if (identified == null) {
throw new NullPointerException("identified");
}
if (identified == null) {
throw new NullPointerException("identified");
}
return this.getTaxFor(identified.getId());
}
@ -987,30 +987,30 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
}
public Optional<Entry<String, Double>> getTaxAndReasonForPlayer(MPlayer mplayer) {
if (mplayer == null) {
throw new NullPointerException("mplayer");
}
if (mplayer == null) {
throw new NullPointerException("mplayer");
}
if (mplayer.getFaction() != this) {
throw new IllegalArgumentException("Player " + mplayer.getId() + " not in " + this.getId());
}
if (mplayer.getFaction() != this) {
throw new IllegalArgumentException("Player " + mplayer.getId() + " not in " + this.getId());
}
Double ret = null;
ret = this.getTaxFor(mplayer);
if (ret != null) {
return Optional.of(new Couple<>(mplayer.getId(), ret));
}
if (ret != null) {
return Optional.of(new Couple<>(mplayer.getId(), ret));
}
ret = this.getTaxFor(mplayer.getRank());
if (ret != null) {
return Optional.of(new Couple<>(mplayer.getRank().getId(), ret));
}
if (ret != null) {
return Optional.of(new Couple<>(mplayer.getRank().getId(), ret));
}
ret = this.getTaxFor(IDENTIFIER_TAX_BASE);
if (ret != null) {
return Optional.of(new Couple<>(IDENTIFIER_TAX_BASE, ret));
}
if (ret != null) {
return Optional.of(new Couple<>(IDENTIFIER_TAX_BASE, ret));
}
return Optional.empty();
}
@ -1061,9 +1061,9 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
@Override
public String getDisplayName(Object senderObject) {
MPlayer mplayer = MPlayer.get(senderObject);
if (mplayer == null) {
return this.getName();
}
if (mplayer == null) {
return this.getName();
}
return this.describeTo(mplayer);
}
@ -1074,9 +1074,9 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
// TODO: Implement a has enough feature.
public double getPower() {
if (this.getFlag(MFlag.getFlagInfpower())) {
return 999999;
}
if (this.getFlag(MFlag.getFlagInfpower())) {
return 999999;
}
double ret = 0;
for (MPlayer mplayer : this.getMPlayers()) {
@ -1090,9 +1090,9 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
}
public double getPowerMax() {
if (this.getFlag(MFlag.getFlagInfpower())) {
return 999999;
}
if (this.getFlag(MFlag.getFlagInfpower())) {
return 999999;
}
double ret = 0;
for (MPlayer mplayer : this.getMPlayers()) {
@ -1170,9 +1170,9 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
public MPlayer getLeader() {
List<MPlayer> ret = this.getMPlayersWhereRank(this.getLeaderRank());
if (ret.size() == 0) {
return null;
}
if (ret.size() == 0) {
return null;
}
return ret.get(0);
}
@ -1186,14 +1186,14 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
// Fill Ret
for (CommandSender sender : IdUtil.getLocalSenders()) {
if (MUtil.isntSender(sender)) {
continue;
}
if (MUtil.isntSender(sender)) {
continue;
}
MPlayer mplayer = MPlayer.get(sender);
if (mplayer.getFaction() != this) {
continue;
}
if (mplayer.getFaction() != this) {
continue;
}
ret.add(sender);
}
@ -1208,14 +1208,14 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
// Fill Ret
for (Player player : Bukkit.getOnlinePlayers()) {
if (MUtil.isntPlayer(player)) {
continue;
}
if (MUtil.isntPlayer(player)) {
continue;
}
MPlayer mplayer = MPlayer.get(player);
if (mplayer.getFaction() != this) {
continue;
}
if (mplayer.getFaction() != this) {
continue;
}
ret.add(player);
}
@ -1226,12 +1226,12 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
// used when current leader is about to be removed from the faction; promotes new leader, or disbands faction if no other members left
public void promoteNewLeader() {
if (!this.isNormal()) {
return;
}
if (this.getFlag(MFlag.getFlagPermanent()) && MConf.get().permanentFactionsDisableLeaderPromotion) {
return;
}
if (!this.isNormal()) {
return;
}
if (this.getFlag(MFlag.getFlagPermanent()) && MConf.get().permanentFactionsDisableLeaderPromotion) {
return;
}
MPlayer oldLeader = this.getLeader();
Rank leaderRank = oldLeader.getRank();
@ -1239,14 +1239,14 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
List<MPlayer> replacements = Collections.emptyList();
for (Rank rank = leaderRank; rank != null; rank = rank.getRankBelow()) {
//Skip first
if (rank == leaderRank) {
continue;
}
if (rank == leaderRank) {
continue;
}
replacements = this.getMPlayersWhereRank(rank);
if (!replacements.isEmpty()) {
break;
}
if (!replacements.isEmpty()) {
break;
}
}
// if we found a replacement
@ -1305,12 +1305,12 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
boolean explosions = this.getFlag(MFlag.getFlagExplosions());
boolean offlineexplosions = this.getFlag(MFlag.getFlagOfflineexplosions());
if (explosions && offlineexplosions) {
return true;
}
if (!explosions && !offlineexplosions) {
return false;
}
if (explosions && offlineexplosions) {
return true;
}
if (!explosions && !offlineexplosions) {
return false;
}
boolean online = this.isFactionConsideredOnline();
@ -1357,14 +1357,14 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
// FIXME this probably needs to be moved elsewhere
public static String clean(String message) {
String target = message;
if (target == null) {
return null;
}
if (target == null) {
return null;
}
target = target.trim();
if (target.isEmpty()) {
target = null;
}
if (target.isEmpty()) {
target = null;
}
return target;
}

View File

@ -41,9 +41,9 @@ public class FactionColl extends Coll<Faction> {
public void setActive(boolean active) {
super.setActive(active);
if (!active) {
return;
}
if (!active) {
return;
}
this.createSpecialFactions();
@ -63,9 +63,9 @@ public class FactionColl extends Coll<Faction> {
public Faction getNone() {
String id = Factions.ID_NONE;
Faction faction = this.get(id);
if (faction != null) {
return faction;
}
if (faction != null) {
return faction;
}
faction = this.create(id);
@ -100,9 +100,9 @@ public class FactionColl extends Coll<Faction> {
public Faction getSafezone() {
String id = Factions.ID_SAFEZONE;
Faction faction = this.get(id);
if (faction != null) {
return faction;
}
if (faction != null) {
return faction;
}
faction = this.create(id);
@ -135,9 +135,9 @@ public class FactionColl extends Coll<Faction> {
public Faction getWarzone() {
String id = Factions.ID_WARZONE;
Faction faction = this.get(id);
if (faction != null) {
return faction;
}
if (faction != null) {
return faction;
}
faction = this.create(id);
@ -197,29 +197,29 @@ public class FactionColl extends Coll<Faction> {
// Fill
for (Faction fac : FactionColl.get().getAll()) {
if (fac.getFlag(flagPeaceful)) {
continue;
}
if (fac.getFlag(flagPeaceful)) {
continue;
}
Rel rel = fac.getRelationTo(faction);
List<String> names = ret.get(rel);
if (names == null) {
continue;
}
if (names == null) {
continue;
}
String name = fac.describeTo(faction, true);
names.add(name);
}
// Replace TRUCE if peaceful
if (!peaceful) {
return ret;
}
if (!peaceful) {
return ret;
}
List<String> names = ret.get(Rel.TRUCE);
if (names == null) {
return ret;
}
if (names == null) {
return ret;
}
ret.put(Rel.TRUCE, Collections.singletonList(MConf.get().colorTruce.toString() + Txt.parse("<italic>*EVERYONE*")));

View File

@ -30,9 +30,9 @@ public class MConfColl extends Coll<MConf> {
@Override
public void setActive(boolean active) {
super.setActive(active);
if (!active) {
return;
}
if (!active) {
return;
}
MConf.i = this.get(MassiveCore.INSTANCE, true);
}

View File

@ -363,12 +363,12 @@ public class MFlag extends Entity<MFlag> implements Prioritized, Registerable, N
// -------------------------------------------- //
public boolean isInteresting(boolean value) {
if (!this.isVisible()) {
return false;
}
if (this.isEditable()) {
return true;
}
if (!this.isVisible()) {
return false;
}
if (this.isEditable()) {
return true;
}
return this.isStandard() != value;
}
@ -377,15 +377,15 @@ public class MFlag extends Entity<MFlag> implements Prioritized, Registerable, N
List<String> ret = new MassiveList<>();
// Fill
if (withValue) {
ret.add(getStateValue(value, monospaceValue));
}
if (withName) {
ret.add(this.getStateName());
}
if (withDesc) {
ret.add(this.getStateDescription(value, specificDesc));
}
if (withValue) {
ret.add(getStateValue(value, monospaceValue));
}
if (withName) {
ret.add(this.getStateName());
}
if (withDesc) {
ret.add(this.getStateDescription(value, specificDesc));
}
// Return
return Txt.implode(ret, " ");
@ -404,12 +404,12 @@ public class MFlag extends Entity<MFlag> implements Prioritized, Registerable, N
private ChatColor getStateColor() {
// Is special?
if (!this.isVisible()) {
return ChatColor.GRAY;
}
if (this.isEditable()) {
return ChatColor.LIGHT_PURPLE;
}
if (!this.isVisible()) {
return ChatColor.GRAY;
}
if (this.isEditable()) {
return ChatColor.LIGHT_PURPLE;
}
// Return normal
return ChatColor.AQUA;
@ -420,9 +420,9 @@ public class MFlag extends Entity<MFlag> implements Prioritized, Registerable, N
String desc = this.getDesc();
// Is specific?
if (specific) {
desc = value ? this.getDescYes() : this.getDescNo();
}
if (specific) {
desc = value ? this.getDescYes() : this.getDescNo();
}
// Return
return Txt.parse("<i>%s", desc);

View File

@ -36,9 +36,9 @@ public class MFlagColl extends Coll<MFlag> {
@Override
public void setActive(boolean active) {
super.setActive(active);
if (!active) {
return;
}
if (!active) {
return;
}
MFlag.setupStandardFlags();
}
@ -52,9 +52,9 @@ public class MFlagColl extends Coll<MFlag> {
// Fill
for (MFlag mflag : this.getAll()) {
if (mflag.isRegistered() != registered) {
continue;
}
if (mflag.isRegistered() != registered) {
continue;
}
ret.add(mflag);
}

View File

@ -438,12 +438,12 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
public String createDeniedMessage(MPlayer mplayer, Faction hostFaction) {
// Null Check
if (mplayer == null) {
throw new NullPointerException("mplayer");
}
if (hostFaction == null) {
throw new NullPointerException("hostFaction");
}
if (mplayer == null) {
throw new NullPointerException("mplayer");
}
if (hostFaction == null) {
throw new NullPointerException("hostFaction");
}
String ret = Txt.parse("%s<b> does not allow you to %s<b>.", hostFaction.describeTo(mplayer, true), this.getDesc());
@ -484,54 +484,54 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
public boolean has(Faction faction, Faction hostFaction) {
// Null Check
if (faction == null) {
throw new NullPointerException("faction");
}
if (hostFaction == null) {
throw new NullPointerException("hostFaction");
}
if (faction == null) {
throw new NullPointerException("faction");
}
if (hostFaction == null) {
throw new NullPointerException("hostFaction");
}
return hostFaction.isFactionPermitted(faction, this);
}
public boolean has(MPlayer mplayer, Faction hostFaction, boolean verboose) {
// Null Check
if (mplayer == null) {
throw new NullPointerException("mplayer");
}
if (hostFaction == null) {
throw new NullPointerException("hostFaction");
}
if (mplayer == null) {
throw new NullPointerException("mplayer");
}
if (hostFaction == null) {
throw new NullPointerException("hostFaction");
}
if (mplayer.isOverriding()) {
return true;
}
if (mplayer.isOverriding()) {
return true;
}
Rel rel = mplayer.getRelationTo(hostFaction);
MPermable permable = rel == Rel.FACTION ? mplayer.getRank() : rel;
if (hostFaction.isPlayerPermitted(mplayer, this)) {
return true;
}
if (hostFaction.isPlayerPermitted(mplayer, this)) {
return true;
}
if (verboose) {
mplayer.message(this.createDeniedMessage(mplayer, hostFaction));
}
if (verboose) {
mplayer.message(this.createDeniedMessage(mplayer, hostFaction));
}
return false;
}
public boolean has(MPlayer mplayer, PS ps, boolean verboose) {
// Null Check
if (mplayer == null) {
throw new NullPointerException("mplayer");
}
if (ps == null) {
throw new NullPointerException("ps");
}
if (mplayer == null) {
throw new NullPointerException("mplayer");
}
if (ps == null) {
throw new NullPointerException("ps");
}
if (mplayer.isOverriding()) {
return true;
}
if (mplayer.isOverriding()) {
return true;
}
TerritoryAccess ta = BoardColl.get().getTerritoryAccessAt(ps);
Faction hostFaction = ta.getHostFaction();
@ -555,9 +555,9 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
// -------------------------------------------- //
public static List<MPermable> getPermables(Faction faction) {
if (faction == null) {
throw new NullPointerException("faction");
}
if (faction == null) {
throw new NullPointerException("faction");
}
List<MPermable> list = new MassiveList<>();
@ -597,40 +597,40 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
public static Optional<MPermable> idToMPermableOptional(String id) {
MPlayer mplayer = MPlayerColl.get().get(id, false);
if (mplayer != null) {
return Optional.of(mplayer);
}
if (mplayer != null) {
return Optional.of(mplayer);
}
// Workaround for registered senders
// Players ussually have a power, which makes sure they are in the coll
if (IdUtil.getRegistryIdToSender().containsKey(id)) {
return Optional.of(MPlayerColl.get().get(id, true));
}
if (IdUtil.getRegistryIdToSender().containsKey(id)) {
return Optional.of(MPlayerColl.get().get(id, true));
}
Faction faction = Faction.get(id);
if (faction != null) {
return Optional.of(faction);
}
if (faction != null) {
return Optional.of(faction);
}
for (Faction f : FactionColl.get().getAll()) {
Rank rank = f.getRank(id);
if (rank != null) {
return Optional.of(rank);
}
if (rank != null) {
return Optional.of(rank);
}
}
if (Rel.ALLY.name().equalsIgnoreCase(id)) {
return Optional.of(Rel.ALLY);
}
if (Rel.TRUCE.name().equalsIgnoreCase(id)) {
return Optional.of(Rel.TRUCE);
}
if (Rel.NEUTRAL.name().equalsIgnoreCase(id)) {
return Optional.of(Rel.NEUTRAL);
}
if (Rel.ENEMY.name().equalsIgnoreCase(id)) {
return Optional.of(Rel.ENEMY);
}
if (Rel.ALLY.name().equalsIgnoreCase(id)) {
return Optional.of(Rel.ALLY);
}
if (Rel.TRUCE.name().equalsIgnoreCase(id)) {
return Optional.of(Rel.TRUCE);
}
if (Rel.NEUTRAL.name().equalsIgnoreCase(id)) {
return Optional.of(Rel.NEUTRAL);
}
if (Rel.ENEMY.name().equalsIgnoreCase(id)) {
return Optional.of(Rel.ENEMY);
}
return Optional.empty();
}

View File

@ -39,9 +39,9 @@ public class MPermColl extends Coll<MPerm> {
@Override
public void setActive(boolean active) {
super.setActive(active);
if (!active) {
return;
}
if (!active) {
return;
}
MPerm.setupStandardPerms();
}
@ -88,9 +88,9 @@ public class MPermColl extends Coll<MPerm> {
// Fill
for (MPerm mperm : this.getAll()) {
if (mperm.isRegistered() != registered) {
continue;
}
if (mperm.isRegistered() != registered) {
continue;
}
ret.add(mperm);
}

View File

@ -80,24 +80,24 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
@Override
public boolean isDefault() {
// Last activity millis is data we use for clearing out cleanable players. So it does not in itself make the player data worth keeping.
if (this.hasFaction()) {
return false;
}
if (this.hasFaction()) {
return false;
}
// Role means nothing without a faction.
// Title means nothing without a faction.
if (this.hasPowerBoost()) {
return false;
}
if (this.getPowerRounded() != (int) Math.round(MConf.get().defaultPlayerPower)) {
return false;
}
if (this.hasPowerBoost()) {
return false;
}
if (this.getPowerRounded() != (int) Math.round(MConf.get().defaultPlayerPower)) {
return false;
}
// if (this.isMapAutoUpdating()) return false; // Just having an auto updating map is not in itself reason enough for database storage.
if (this.isOverriding()) {
return false;
}
if (this.isTerritoryInfoTitles() != MConf.get().territoryInfoTitlesDefault) {
return false;
}
if (this.isOverriding()) {
return false;
}
if (this.isTerritoryInfoTitles() != MConf.get().territoryInfoTitlesDefault) {
return false;
}
return true;
}
@ -194,16 +194,16 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
private transient WeakReference<Faction> autoClaimFaction = new WeakReference<>(null);
public Faction getAutoClaimFaction() {
if (this.isFactionOrphan()) {
return null;
}
if (this.isFactionOrphan()) {
return null;
}
Faction ret = this.autoClaimFaction.get();
if (ret == null) {
return null;
}
if (ret.detached()) {
return null;
}
if (ret == null) {
return null;
}
if (ret.detached()) {
return null;
}
return ret;
}
@ -302,9 +302,9 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
String afterId = factionId;
// NoChange
if (MUtil.equals(beforeId, afterId)) {
return;
}
if (MUtil.equals(beforeId, afterId)) {
return;
}
// Apply
this.factionId = afterId;
@ -325,13 +325,13 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
// -------------------------------------------- //
public Rank getRank() {
if (this.isFactionOrphan()) {
return FactionColl.get().getNone().getLowestRank();
}
if (this.isFactionOrphan()) {
return FactionColl.get().getNone().getLowestRank();
}
if (this.rankId == null) {
return this.getFaction().getLowestRank();
}
if (this.rankId == null) {
return this.getFaction().getLowestRank();
}
return this.getFaction().getRank(this.rankId);
}
@ -340,9 +340,9 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
String rankId = rank == null ? null : rank.getId();
// Detect Nochange
if (MUtil.equals(this.rankId, rankId)) {
return;
}
if (MUtil.equals(this.rankId, rankId)) {
return;
}
// Apply
this.rankId = rankId;
@ -362,13 +362,13 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
}
public String getTitle() {
if (this.isFactionOrphan()) {
return NOTITLE;
}
if (this.isFactionOrphan()) {
return NOTITLE;
}
if (this.hasTitle()) {
return this.title;
}
if (this.hasTitle()) {
return this.title;
}
return NOTITLE;
}
@ -378,9 +378,9 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
String target = Faction.clean(title);
// Detect Nochange
if (MUtil.equals(this.title, target)) {
return;
}
if (MUtil.equals(this.title, target)) {
return;
}
// Apply
this.title = target;
@ -396,9 +396,9 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
@Override
public double getPowerBoost() {
Double ret = this.powerBoost;
if (ret == null) {
ret = 0D;
}
if (ret == null) {
ret = 0D;
}
return ret;
}
@ -406,14 +406,14 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
public void setPowerBoost(Double powerBoost) {
// Clean input
Double target = powerBoost;
if (target == null || target == 0) {
target = null;
}
if (target == null || target == 0) {
target = null;
}
// Detect Nochange
if (MUtil.equals(this.powerBoost, target)) {
return;
}
if (MUtil.equals(this.powerBoost, target)) {
return;
}
// Apply
this.powerBoost = target;
@ -482,9 +482,9 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
public double getPower() {
Double ret = this.power;
if (ret == null) {
ret = MConf.get().defaultPlayerPower;
}
if (ret == null) {
ret = MConf.get().defaultPlayerPower;
}
ret = this.getLimitedPower(ret);
return ret;
}
@ -494,9 +494,9 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
Double target = power;
// Detect Nochange
if (MUtil.equals(this.power, target)) {
return;
}
if (MUtil.equals(this.power, target)) {
return;
}
// Apply
this.power = target;
@ -516,26 +516,26 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
// -------------------------------------------- //
public boolean isMapAutoUpdating() {
if (this.mapAutoUpdating == null) {
return false;
}
if (this.mapAutoUpdating == false) {
return false;
}
if (this.mapAutoUpdating == null) {
return false;
}
if (this.mapAutoUpdating == false) {
return false;
}
return true;
}
public void setMapAutoUpdating(Boolean mapAutoUpdating) {
// Clean input
Boolean target = mapAutoUpdating;
if (MUtil.equals(target, false)) {
target = null;
}
if (MUtil.equals(target, false)) {
target = null;
}
// Detect Nochange
if (MUtil.equals(this.mapAutoUpdating, target)) {
return;
}
if (MUtil.equals(this.mapAutoUpdating, target)) {
return;
}
// Apply
this.mapAutoUpdating = target;
@ -549,12 +549,12 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
// -------------------------------------------- //
public boolean isOverriding() {
if (this.overriding == null) {
return false;
}
if (this.overriding == false) {
return false;
}
if (this.overriding == null) {
return false;
}
if (this.overriding == false) {
return false;
}
if (!this.hasPermission(Perm.OVERRIDE, true)) {
this.setOverriding(false);
@ -567,14 +567,14 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
public void setOverriding(Boolean overriding) {
// Clean input
Boolean target = overriding;
if (MUtil.equals(target, false)) {
target = null;
}
if (MUtil.equals(target, false)) {
target = null;
}
// Detect Nochange
if (MUtil.equals(this.overriding, target)) {
return;
}
if (MUtil.equals(this.overriding, target)) {
return;
}
// Apply
this.overriding = target;
@ -588,26 +588,26 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
// -------------------------------------------- //
public boolean isTerritoryInfoTitles() {
if (!MixinTitle.get().isAvailable()) {
return false;
}
if (this.territoryInfoTitles == null) {
return MConf.get().territoryInfoTitlesDefault;
}
if (!MixinTitle.get().isAvailable()) {
return false;
}
if (this.territoryInfoTitles == null) {
return MConf.get().territoryInfoTitlesDefault;
}
return this.territoryInfoTitles;
}
public void setTerritoryInfoTitles(Boolean territoryInfoTitles) {
// Clean input
Boolean target = territoryInfoTitles;
if (MUtil.equals(target, MConf.get().territoryInfoTitlesDefault)) {
target = null;
}
if (MUtil.equals(target, MConf.get().territoryInfoTitlesDefault)) {
target = null;
}
// Detect Nochange
if (MUtil.equals(this.territoryInfoTitles, target)) {
return;
}
if (MUtil.equals(this.territoryInfoTitles, target)) {
return;
}
// Apply
this.territoryInfoTitles = target;
@ -634,9 +634,9 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
public String getFactionName() {
Faction faction = this.getFaction();
if (faction.isNone()) {
return "";
}
if (faction.isNone()) {
return "";
}
return faction.getName();
}
@ -725,17 +725,17 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
public boolean isInOwnTerritory() {
PS ps = MixinSenderPs.get().getSenderPs(this.getId());
if (ps == null) {
return false;
}
if (ps == null) {
return false;
}
return BoardColl.get().getFactionAt(ps) == this.getFaction();
}
public boolean isInEnemyTerritory() {
PS ps = MixinSenderPs.get().getSenderPs(this.getId());
if (ps == null) {
return false;
}
if (ps == null) {
return false;
}
return BoardColl.get().getFactionAt(ps).getRelationTo(this) == Rel.ENEMY;
}
@ -763,9 +763,9 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
// Event
EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(this.getSender(), this, myFaction, MembershipChangeReason.LEAVE);
membershipChangeEvent.run();
if (membershipChangeEvent.isCancelled()) {
return;
}
if (membershipChangeEvent.isCancelled()) {
return;
}
if (myFaction.isNormal()) {
for (MPlayer mplayer : myFaction.getMPlayersWhereOnline(true)) {
@ -800,20 +800,20 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
public boolean tryClaim(Faction newFaction, Collection<PS> pss, String formatOne, String formatMany) {
// Args
if (formatOne == null) {
formatOne = "<h>%s<i> %s <h>%d <i>chunk %s<i>.";
}
if (formatMany == null) {
formatMany = "<h>%s<i> %s <h>%d <i>chunks near %s<i>.";
}
if (formatOne == null) {
formatOne = "<h>%s<i> %s <h>%d <i>chunk %s<i>.";
}
if (formatMany == null) {
formatMany = "<h>%s<i> %s <h>%d <i>chunks near %s<i>.";
}
if (newFaction == null) {
throw new NullPointerException("newFaction");
}
if (newFaction == null) {
throw new NullPointerException("newFaction");
}
if (pss == null) {
throw new NullPointerException("pss");
}
if (pss == null) {
throw new NullPointerException("pss");
}
final Set<PS> chunks = PS.getDistinctChunks(pss);
// NoChange
@ -840,9 +840,9 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
}
EventFactionsChunksChange event = new EventFactionsChunksChange(sender, chunks, newFaction);
event.run();
if (event.isCancelled()) {
return false;
}
if (event.isCancelled()) {
return false;
}
// Apply
for (PS chunk : chunks) {
@ -882,17 +882,17 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
public static Set<MPlayer> getClaimInformees(MPlayer msender, Faction... factions) {
Set<MPlayer> ret = new HashSet<>();
if (msender != null) {
ret.add(msender);
}
if (msender != null) {
ret.add(msender);
}
for (Faction faction : factions) {
if (faction == null) {
continue;
}
if (faction.isNone()) {
continue;
}
if (faction == null) {
continue;
}
if (faction.isNone()) {
continue;
}
ret.addAll(faction.getMPlayers());
}

View File

@ -25,9 +25,9 @@ public class Rank extends EntityInternal<Rank> implements MPerm.MPermable {
for (Faction f : FactionColl.get().getAll()) {
for (Entry<String, Set<String>> entry : f.getPerms().entrySet()) {
Set<String> value = entry.getValue();
if (value == null) {
throw new NullPointerException(entry.getKey());
}
if (value == null) {
throw new NullPointerException(entry.getKey());
}
value.remove(id);
}
}
@ -119,46 +119,46 @@ public class Rank extends EntityInternal<Rank> implements MPerm.MPermable {
// -------------------------------------------- //
public boolean isLessThan(Rank otherRank) {
if (this.getContainer() != otherRank.getContainer()) {
throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId());
}
if (this.getContainer() != otherRank.getContainer()) {
throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId());
}
return this.getPriority() < otherRank.getPriority();
}
public boolean isMoreThan(Rank otherRank) {
if (this.getContainer() != otherRank.getContainer()) {
throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId());
}
if (this.getContainer() != otherRank.getContainer()) {
throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId());
}
return this.getPriority() > otherRank.getPriority();
}
public boolean isAtLeast(Rank otherRank) {
if (this.getContainer() != otherRank.getContainer()) {
throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId());
}
if (this.getContainer() != otherRank.getContainer()) {
throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId());
}
return this.getPriority() >= otherRank.getPriority();
}
public boolean isAtMost(Rank otherRank) {
if (this.getContainer() != otherRank.getContainer()) {
throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId());
}
if (this.getContainer() != otherRank.getContainer()) {
throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId());
}
return this.getPriority() <= otherRank.getPriority();
}
public boolean isLeader() {
for (Rank otherRank : this.getContainer().getAll()) {
if (otherRank == this) {
continue;
}
if (otherRank == this) {
continue;
}
if (otherRank.isMoreThan(this)) {
return false;
}
if (otherRank.isMoreThan(this)) {
return false;
}
}
return true;
}
@ -166,15 +166,15 @@ public class Rank extends EntityInternal<Rank> implements MPerm.MPermable {
public Rank getRankAbove() {
Rank ret = null;
for (Rank otherRank : this.getContainer().getAll()) {
if (otherRank == this) {
continue;
}
if (otherRank.isLessThan(this)) {
continue;
}
if (ret != null && ret.isLessThan(otherRank)) {
continue;
}
if (otherRank == this) {
continue;
}
if (otherRank.isLessThan(this)) {
continue;
}
if (ret != null && ret.isLessThan(otherRank)) {
continue;
}
ret = otherRank;
}
@ -184,15 +184,15 @@ public class Rank extends EntityInternal<Rank> implements MPerm.MPermable {
public Rank getRankBelow() {
Rank ret = null;
for (Rank otherRank : this.getContainer().getAll()) {
if (otherRank == this) {
continue;
}
if (otherRank.isMoreThan(this)) {
continue;
}
if (ret != null && ret.isMoreThan(otherRank)) {
continue;
}
if (otherRank == this) {
continue;
}
if (otherRank.isMoreThan(this)) {
continue;
}
if (ret != null && ret.isMoreThan(otherRank)) {
continue;
}
ret = otherRank;
}

View File

@ -86,25 +86,25 @@ public class Vote extends EntityInternal<Vote> implements Named {
// -------------------------------------------- //
public void setVote(MPlayer mplayer, String choice) {
if (mplayer == null) {
throw new NullPointerException("mplayer");
}
if (choice == null) {
throw new NullPointerException("choice");
}
if (mplayer == null) {
throw new NullPointerException("mplayer");
}
if (choice == null) {
throw new NullPointerException("choice");
}
if (!this.getOptions().contains(choice)) {
throw new IllegalArgumentException(choice + " is not in " + this.getOptions());
}
if (!this.getOptions().contains(choice)) {
throw new IllegalArgumentException(choice + " is not in " + this.getOptions());
}
id2Vote.put(mplayer.getId(), choice);
this.changed();
}
public String getVote(MPlayer mplayer) {
if (mplayer == null) {
throw new NullPointerException("mplayer");
}
if (mplayer == null) {
throw new NullPointerException("mplayer");
}
return this.getId2Vote().get(mplayer.getId());
}

View File

@ -81,9 +81,9 @@ public class Warp extends EntityInternal<Warp> implements Named {
// -------------------------------------------- //
public boolean verifyIsValid() {
if (this.isValid()) {
return true;
}
if (this.isValid()) {
return true;
}
Faction fac = this.getFaction();
this.detach();
fac.msg("<b>Your faction warp <h>%s <b>has been un-set since it is no longer in your territory.", this.getName());
@ -91,12 +91,12 @@ public class Warp extends EntityInternal<Warp> implements Named {
}
public boolean isValidFor(Faction faction) {
if (!MConf.get().warpsMustBeInClaimedTerritory) {
return true;
}
if (BoardColl.get().getFactionAt(this.getLocation()) == faction) {
return true;
}
if (!MConf.get().warpsMustBeInClaimedTerritory) {
return true;
}
if (BoardColl.get().getFactionAt(this.getLocation()) == faction) {
return true;
}
return false;
}

View File

@ -44,9 +44,9 @@ public class MigratorFaction001Invitations extends MigratorRoot {
// If non-null
if (!idList.isJsonNull()) {
// ... and proper type ...
if (!idList.isJsonArray()) {
throw new IllegalArgumentException(idList.toString());
}
if (!idList.isJsonArray()) {
throw new IllegalArgumentException(idList.toString());
}
// ... fill!
for (JsonElement playerId : idList.getAsJsonArray()) {

View File

@ -74,18 +74,18 @@ public class MigratorFaction002Ranks extends MigratorRoot {
//Set<String> value = new MassiveSet<>(mperm.getStandard());
Set<String> value = new MassiveSet<>(MConf.get().perm2default.get(mperm.getId()));
if (value.remove("LEADER")) {
value.add(leaderId);
}
if (value.remove("OFFICER")) {
value.add(officerId);
}
if (value.remove("MEMBER")) {
value.add(memberId);
}
if (value.remove("RECRUIT")) {
value.add(recruitId);
}
if (value.remove("LEADER")) {
value.add(leaderId);
}
if (value.remove("OFFICER")) {
value.add(officerId);
}
if (value.remove("MEMBER")) {
value.add(memberId);
}
if (value.remove("RECRUIT")) {
value.add(recruitId);
}
ret.put(mperm.getId(), value);
}
@ -106,18 +106,18 @@ public class MigratorFaction002Ranks extends MigratorRoot {
}
Set<String> value = entry.getValue();
if (value.remove("LEADER")) {
value.add(leaderId);
}
if (value.remove("OFFICER")) {
value.add(officerId);
}
if (value.remove("MEMBER")) {
value.add(memberId);
}
if (value.remove("RECRUIT")) {
value.add(recruitId);
}
if (value.remove("LEADER")) {
value.add(leaderId);
}
if (value.remove("OFFICER")) {
value.add(officerId);
}
if (value.remove("MEMBER")) {
value.add(memberId);
}
if (value.remove("RECRUIT")) {
value.add(recruitId);
}
ret.put(id, value);
}
}

View File

@ -35,13 +35,13 @@ public class MigratorFaction003Warps extends MigratorRoot {
@Override
public void migrateInner(JsonObject entity) {
JsonElement jsonHome = entity.remove("home");
if (jsonHome == null || jsonHome.isJsonNull()) {
return;
}
if (jsonHome == null || jsonHome.isJsonNull()) {
return;
}
if (!jsonHome.isJsonObject()) {
throw new RuntimeException("not JsonObject " + jsonHome);
}
if (!jsonHome.isJsonObject()) {
throw new RuntimeException("not JsonObject " + jsonHome);
}
PS psHome = MassiveCore.gson.fromJson(jsonHome, PS.class);
Warp warp = new Warp("home", psHome);

View File

@ -27,21 +27,21 @@ public class MigratorFaction004WarpsPerms extends MigratorRoot {
@Override
public void migrateInner(JsonObject entity) {
JsonElement perms = entity.get("perms");
if (perms == null || perms.isJsonNull() || !perms.isJsonObject()) {
return;
}
if (perms == null || perms.isJsonNull() || !perms.isJsonObject()) {
return;
}
JsonObject permsO = perms.getAsJsonObject();
JsonElement home = permsO.remove("home");
if (home != null) {
permsO.add("warp", home);
}
if (home != null) {
permsO.add("warp", home);
}
JsonElement sethome = permsO.remove("sethome");
if (home != null) {
permsO.add("setwarp", home);
}
if (home != null) {
permsO.add("setwarp", home);
}
}
}

View File

@ -49,21 +49,21 @@ public class MigratorMConf001EnumerationUtil extends MigratorRoot {
private void removeFromStringsField(JsonObject entity, String fieldName, Collection<String> removals) {
JsonElement stringsElement = entity.get(fieldName);
if (!(stringsElement instanceof JsonArray)) {
return;
}
if (!(stringsElement instanceof JsonArray)) {
return;
}
JsonArray strings = (JsonArray) stringsElement;
for (Iterator<JsonElement> iterator = strings.iterator(); iterator.hasNext(); ) {
JsonElement stringElement = iterator.next();
if (!(stringElement instanceof JsonPrimitive)) {
continue;
}
if (!(stringElement instanceof JsonPrimitive)) {
continue;
}
JsonPrimitive string = (JsonPrimitive) stringElement;
if (!removals.contains(string.getAsString())) {
continue;
}
if (!removals.contains(string.getAsString())) {
continue;
}
iterator.remove();
}

View File

@ -69,9 +69,9 @@ public class MigratorMConf004Rank extends MigratorRoot {
boolean success = false;
for (Iterator<JsonElement> it = array.iterator(); it.hasNext(); ) {
JsonElement e = it.next();
if (!e.getAsString().equals("MEMBER")) {
continue;
}
if (!e.getAsString().equals("MEMBER")) {
continue;
}
it.remove();
success = true;
}

View File

@ -28,23 +28,23 @@ public class MigratorMPerm001Warps extends MigratorRoot {
public void migrateInner(JsonObject entity) {
JsonElement jsonName = entity.get("name");
String name = jsonName.getAsString();
if (name.equalsIgnoreCase("home")) {
name = "warp";
}
if (name.equalsIgnoreCase("sethome")) {
name = "setwarp";
}
if (name.equalsIgnoreCase("home")) {
name = "warp";
}
if (name.equalsIgnoreCase("sethome")) {
name = "setwarp";
}
entity.addProperty("name", name);
JsonElement jsonDesc = entity.get("desc");
String desc = jsonDesc.getAsString();
if (desc.equalsIgnoreCase("teleport home")) {
desc = "teleport to warp";
}
if (desc.equalsIgnoreCase("set the home")) {
desc = "set warps";
}
if (desc.equalsIgnoreCase("teleport home")) {
desc = "teleport to warp";
}
if (desc.equalsIgnoreCase("set the home")) {
desc = "set warps";
}
entity.addProperty("desc", desc);
}

View File

@ -32,9 +32,9 @@ public class MigratorMPerm002MoveStandard extends MigratorRoot {
@Override
public void migrateInner(JsonObject entity) {
JsonElement jsonStandard = entity.remove("standard");
if (jsonStandard == null || !jsonStandard.isJsonArray()) {
return;
}
if (jsonStandard == null || !jsonStandard.isJsonArray()) {
return;
}
JsonArray jsonArray = jsonStandard.getAsJsonArray();
Set<String> result = new MassiveSet<>();

View File

@ -48,32 +48,32 @@ public class MigratorMPlayer001Ranks extends MigratorRoot {
JsonElement jsonFaction = entity.get("factionId");
String factionId;
if (jsonFaction == null) {
factionId = MConf.get().defaultPlayerFactionId;
} else {
factionId = jsonFaction.getAsString();
}
if (jsonFaction == null) {
factionId = MConf.get().defaultPlayerFactionId;
} else {
factionId = jsonFaction.getAsString();
}
Faction faction = FactionColl.get().get(factionId);
if (faction == null) {
faction = FactionColl.get().getNone();
}
if (faction == null) {
faction = FactionColl.get().getNone();
}
// Get rank
Rank rank = null;
if (role != null) {
Collection<Rank> ranks = faction.getRanks().getAll();
for (Rank r : ranks) {
if (!r.getName().equalsIgnoreCase(role)) {
continue;
}
if (!r.getName().equalsIgnoreCase(role)) {
continue;
}
rank = r;
break;
}
}
if (rank == null) {
rank = faction.getLowestRank();
}
if (rank == null) {
rank = faction.getLowestRank();
}
entity.add("rankId", new JsonPrimitive(rank.getId()));
}

View File

@ -43,9 +43,9 @@ public class MigratorTerritoryAccess001Restructure extends MigratorRoot {
grantedIds.addAll(playerIdsArr);
}
if (grantedIds.size() > 0) {
entity.add(TerritoryAccessAdapter.GRANTED_IDS, grantedIds);
}
if (grantedIds.size() > 0) {
entity.add(TerritoryAccessAdapter.GRANTED_IDS, grantedIds);
}
}
}

View File

@ -51,18 +51,18 @@ public enum EventFactionsChunkChangeType implements Colorized {
// -------------------------------------------- //
public static EventFactionsChunkChangeType get(Faction oldFaction, Faction newFaction, Faction self) {
if (newFaction == oldFaction) {
return NONE;
}
if (oldFaction.isNone()) {
return BUY;
}
if (newFaction.isNormal()) {
return CONQUER;
}
if (oldFaction == self) {
return SELL;
}
if (newFaction == oldFaction) {
return NONE;
}
if (oldFaction.isNone()) {
return BUY;
}
if (newFaction.isNormal()) {
return CONQUER;
}
if (oldFaction == self) {
return SELL;
}
return PILLAGE;
}

View File

@ -25,16 +25,16 @@ public class Econ {
// -------------------------------------------- //
public static boolean payForAction(double cost, MPlayer usender, String actionDescription) {
if (!isEnabled()) {
return true;
}
if (cost == 0D) {
return true;
}
if (!isEnabled()) {
return true;
}
if (cost == 0D) {
return true;
}
if (usender.isOverriding()) {
return true;
}
if (usender.isOverriding()) {
return true;
}
Faction usenderFaction = usender.getFaction();
@ -50,20 +50,20 @@ public class Econ {
// -------------------------------------------- //
public static void modifyUniverseMoney(Object universe, double delta) {
if (!isEnabled()) {
return;
}
if (!isEnabled()) {
return;
}
if (MConf.get().econUniverseAccount == null) {
return;
}
if (MConf.get().econUniverseAccount.length() == 0) {
return;
}
if (MConf.get().econUniverseAccount == null) {
return;
}
if (MConf.get().econUniverseAccount.length() == 0) {
return;
}
if (!Money.exists(MConf.get().econUniverseAccount)) {
return;
}
if (!Money.exists(MConf.get().econUniverseAccount)) {
return;
}
Money.spawn(MConf.get().econUniverseAccount, null, delta);
}
@ -74,19 +74,19 @@ public class Econ {
public static boolean isMePermittedYou(EconomyParticipator me, EconomyParticipator you, MPerm mperm) {
// Null means special system invocation and is always to be accepted.
if (me == null) {
return true;
}
if (me == null) {
return true;
}
// Always accept when in admin mode.
if (me instanceof MPlayer && ((MPlayer) me).isOverriding()) {
return true;
}
if (me instanceof MPlayer && ((MPlayer) me).isOverriding()) {
return true;
}
// Always accept control of self
if (me == you) {
return true;
}
if (me == you) {
return true;
}
Faction fMe = RelationUtil.getFaction(me);
Faction fYou = RelationUtil.getFaction(you);
@ -94,18 +94,18 @@ public class Econ {
// A faction can always transfer away the money of it's members and its own money...
// This will however probably never happen as a faction does not have free will.
// Ohh by the way... Yes it could. For daily rent to the faction.
if (me == fMe && fMe == fYou) {
return true;
}
if (me == fMe && fMe == fYou) {
return true;
}
// Factions can be controlled by those that have permissions
if (you instanceof Faction) {
if (me instanceof Faction && mperm.has((Faction) me, fYou)) {
return true;
}
if (me instanceof MPlayer && mperm.has((MPlayer) me, fYou, false)) {
return true;
}
if (me instanceof Faction && mperm.has((Faction) me, fYou)) {
return true;
}
if (me instanceof MPlayer && mperm.has((MPlayer) me, fYou, false)) {
return true;
}
}
// Otherwise you may not! ;,,;
@ -117,9 +117,9 @@ public class Econ {
}
public static boolean transferMoney(EconomyParticipator from, EconomyParticipator to, EconomyParticipator by, double amount, boolean notify) {
if (!isEnabled()) {
return false;
}
if (!isEnabled()) {
return false;
}
// The amount must be positive.
// If the amount is negative we must flip and multiply amount with -1.
@ -209,9 +209,9 @@ public class Econ {
}
public static boolean hasAtLeast(EconomyParticipator ep, double delta, String toDoThis) {
if (!isEnabled()) {
return true;
}
if (!isEnabled()) {
return true;
}
if (getMoney(ep) < delta) {
if (toDoThis != null && !toDoThis.isEmpty()) {
@ -223,12 +223,12 @@ public class Econ {
}
public static boolean modifyMoney(EconomyParticipator ep, double delta, String actionDescription) {
if (!isEnabled()) {
return false;
}
if (delta == 0) {
return true;
}
if (!isEnabled()) {
return false;
}
if (delta == 0) {
return true;
}
String You = ep.describeTo(ep, true);
String you = ep.describeTo(ep, false);
@ -288,15 +288,15 @@ public class Econ {
if (fromFaction) {
Faction faction = (Faction) from;
double money = faction.getMoney();
if (amount > money) {
return false;
}
if (amount > money) {
return false;
}
faction.setMoney(money - amount);
} else if (from != null) {
boolean temp = Money.despawn(from, by, amount);
if (temp == false) {
return temp;
}
if (temp == false) {
return temp;
}
}
// Handle to

View File

@ -185,9 +185,9 @@ public class AreaMarkerValues {
false // not persistent
);
if (ret == null) {
return null;
}
if (ret == null) {
return null;
}
// Description
ret.setDescription(this.getDescription());
@ -253,20 +253,20 @@ public class AreaMarkerValues {
public static boolean equals(AreaMarker marker, double[] x, double[] z) {
int length = marker.getCornerCount();
if (x.length != length) {
return false;
}
if (z.length != length) {
return false;
}
if (x.length != length) {
return false;
}
if (z.length != length) {
return false;
}
for (int i = 0; i < length; i++) {
if (marker.getCornerX(i) != x[i]) {
return false;
}
if (marker.getCornerZ(i) != z[i]) {
return false;
}
if (marker.getCornerX(i) != x[i]) {
return false;
}
if (marker.getCornerZ(i) != z[i]) {
return false;
}
}
return true;

View File

@ -105,9 +105,9 @@ public class DynmapStyle {
@SafeVarargs
public static <T> T coalesce(T... items) {
for (T item : items) {
if (item != null) {
return item;
}
if (item != null) {
return item;
}
}
return null;
}

View File

@ -98,18 +98,18 @@ public class EngineDynmap extends Engine {
public void updateFactionsDynmap(Map<String, AreaMarkerValues> areas) {
long before = System.currentTimeMillis();
if (!Bukkit.isPrimaryThread()) {
throw new IllegalStateException("async");
}
if (!Bukkit.isPrimaryThread()) {
throw new IllegalStateException("async");
}
if (!fetchDynmapAPI()) {
return;
}
if (!fetchDynmapAPI()) {
return;
}
// createLayer() is thread safe but it makes use of fields set in fetchDynmapAPI() so we must have it after.
if (!updateLayer(createLayer())) {
return;
}
if (!updateLayer(createLayer())) {
return;
}
updateAreas(areas);
@ -125,9 +125,9 @@ public class EngineDynmap extends Engine {
// Thread Safe / Asynchronous: Yes
public static void logTimeSpent(String name, long start) {
if (!MConf.get().dynmapLogTimeSpent) {
return;
}
if (!MConf.get().dynmapLogTimeSpent) {
return;
}
long end = System.currentTimeMillis();
long duration = end - start;
@ -220,14 +220,14 @@ public class EngineDynmap extends Engine {
public Map<String, AreaMarkerValues> createAreas(String world, Faction faction, Set<PS> chunks) {
// If the faction is visible ...
if (!isVisible(faction, world)) {
return Collections.emptyMap();
}
if (!isVisible(faction, world)) {
return Collections.emptyMap();
}
// ... and has any chunks ...
if (chunks.isEmpty()) {
return Collections.emptyMap();
}
if (chunks.isEmpty()) {
return Collections.emptyMap();
}
Map<String, AreaMarkerValues> ret = new MassiveMap<>();
@ -257,11 +257,11 @@ public class EngineDynmap extends Engine {
Set<PS> points = new MassiveSet<>();
for (PS corner : polygonCorners) {
if (points.contains(corner)) {
points.remove(corner);
} else {
points.add(corner);
}
if (points.contains(corner)) {
points.remove(corner);
} else {
points.add(corner);
}
}
Map<PS, PS> edges_h = new MassiveMap<>();
@ -311,23 +311,23 @@ public class EngineDynmap extends Engine {
}
private int zThenX(PS a, PS b) {
if (a.getChunkZ() < b.getChunkZ() || (a.getChunkZ().equals(b.getChunkZ()) && a.getChunkX() < b.getChunkX())) {
return -1;
} else if (a.equals(b)) {
return 0;
} else {
return 1;
}
if (a.getChunkZ() < b.getChunkZ() || (a.getChunkZ().equals(b.getChunkZ()) && a.getChunkX() < b.getChunkX())) {
return -1;
} else if (a.equals(b)) {
return 0;
} else {
return 1;
}
}
private int xThenZ(PS a, PS b) {
if (a.getChunkX() < b.getChunkX() || (a.getChunkX().equals(b.getChunkX()) && a.getChunkZ() < b.getChunkZ())) {
return -1;
} else if (a.equals(b)) {
return 0;
} else {
return 1;
}
if (a.getChunkX() < b.getChunkX() || (a.getChunkX().equals(b.getChunkX()) && a.getChunkZ() < b.getChunkZ())) {
return -1;
} else if (a.equals(b)) {
return 0;
} else {
return 1;
}
}
private static PS getMinimum(Collection<PS> pss) {
@ -433,9 +433,9 @@ public class EngineDynmap extends Engine {
String partial = IntegrationDynmap.FACTIONS_AREA_ + world + "__" + faction.getId() + "__";
// If different than last time, then reset the counter
if (!partial.equals(lastPartialMarkerId)) {
markerIdx = 0;
}
if (!partial.equals(lastPartialMarkerId)) {
markerIdx = 0;
}
this.lastPartialMarkerId = partial;
@ -481,9 +481,9 @@ public class EngineDynmap extends Engine {
// MOTD (probably shouldn't be shown but if the server owner specifies it, I don't care)
String motd = faction.getMotd();
if (motd != null) {
ret = addToHtml(ret, "motd", motd);
}
if (motd != null) {
ret = addToHtml(ret, "motd", motd);
}
// Age
long ageMillis = faction.getAge();
@ -572,9 +572,9 @@ public class EngineDynmap extends Engine {
}
public static String getHtmlPlayerName(MPlayer mplayer) {
if (mplayer == null) {
return "none";
}
if (mplayer == null) {
return "none";
}
return StringEscapeUtils.escapeHtml(mplayer.getName());
}
@ -583,15 +583,15 @@ public class EngineDynmap extends Engine {
}
public static String addToHtml(String ret, String target, String replace) {
if (ret == null) {
throw new NullPointerException("ret");
}
if (target == null) {
throw new NullPointerException("target");
}
if (replace == null) {
throw new NullPointerException("replace");
}
if (ret == null) {
throw new NullPointerException("ret");
}
if (target == null) {
throw new NullPointerException("target");
}
if (replace == null) {
throw new NullPointerException("replace");
}
target = "%" + target + "%";
replace = ChatColor.stripColor(replace);
@ -601,12 +601,12 @@ public class EngineDynmap extends Engine {
// Thread Safe / Asynchronous: Yes
private boolean isVisible(Faction faction, String world) {
if (faction == null) {
throw new NullPointerException("faction");
}
if (world == null) {
throw new NullPointerException("world");
}
if (faction == null) {
throw new NullPointerException("faction");
}
if (world == null) {
throw new NullPointerException("world");
}
final String factionId = faction.getId();
final String factionName = faction.getName();
@ -614,12 +614,12 @@ public class EngineDynmap extends Engine {
Set<String> ids = MUtil.set(factionId, factionName, worldId);
if (factionId == null) {
throw new NullPointerException("faction id");
}
if (factionName == null) {
throw new NullPointerException("faction name");
}
if (factionId == null) {
throw new NullPointerException("faction id");
}
if (factionName == null) {
throw new NullPointerException("faction name");
}
Set<String> visible = MConf.get().dynmapVisibleFactions;
Set<String> hidden = MConf.get().dynmapHiddenFactions;
@ -708,9 +708,9 @@ public class EngineDynmap extends Engine {
// If it is in the source
// Remove it from there to avoid double-counting (and endless recursion)
if (!source.remove(next)) {
continue;
}
if (!source.remove(next)) {
continue;
}
// Add to destination
destination.add(next);

View File

@ -86,9 +86,9 @@ public class LayerValues {
public MarkerSet create(MarkerAPI markerApi, String id) {
MarkerSet ret = markerApi.createMarkerSet(id, this.label, null, false); // ("null, false" at the end means "all icons allowed, not perisistent")
if (ret == null) {
return null;
}
if (ret == null) {
return null;
}
// Minimum Zoom
if (this.minimumZoom > 0) {

View File

@ -119,9 +119,9 @@ public class MarkerValues {
false // not persistent
);
if (ret == null) {
return null;
}
if (ret == null) {
return null;
}
ret.setDescription(this.getDescription());
@ -165,9 +165,9 @@ public class MarkerValues {
public static MarkerIcon getMarkerIcon(MarkerAPI markerApi, String name) {
MarkerIcon ret = markerApi.getMarkerIcon(name);
if (ret == null) {
ret = markerApi.getMarkerIcon(IntegrationDynmap.DYNMAP_STYLE_HOME_MARKER);
}
if (ret == null) {
ret = markerApi.getMarkerIcon(IntegrationDynmap.DYNMAP_STYLE_HOME_MARKER);
}
return ret;
}

View File

@ -55,12 +55,12 @@ public class EngineLwc extends Engine {
public void removeProtectionsOnChunkChange(Faction newFaction, EventFactionsChunkChangeType type, Set<PS> chunks) {
// If we are supposed to clear at this chunk change type ...
Boolean remove = MConf.get().lwcRemoveOnChange.get(type);
if (remove == null) {
return;
}
if (remove == false) {
return;
}
if (remove == null) {
return;
}
if (remove == false) {
return;
}
// ... then remove for all other factions than the new one.
// First we wait one tick to make sure the chunk ownership changes have been applied.
@ -112,9 +112,9 @@ public class EngineLwc extends Engine {
String ownerName = protection.getOwner();
String ownerId = IdUtil.getId(ownerName);
MPlayer owner = MPlayer.get(ownerId);
if (nonAliens.contains(owner)) {
continue;
}
if (nonAliens.contains(owner)) {
continue;
}
protection.remove();
}
}

View File

@ -46,15 +46,15 @@ public class FactionsLwcModule extends JavaModule {
@Override
public void onRegisterProtection(LWCProtectionRegisterEvent event) {
// If this feature is enabled ...
if (!MConf.get().lwcMustHaveBuildRightsToCreate) {
return;
}
if (!MConf.get().lwcMustHaveBuildRightsToCreate) {
return;
}
// ... and the player don't have build rights here ...
// NOTE: We verbosely check the build rights so that a proper info message is sent
if (EnginePermBuild.canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getBlock()), true)) {
return;
}
if (EnginePermBuild.canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getBlock()), true)) {
return;
}
// ... then cancel the event.
event.setCancelled(true);
@ -63,9 +63,9 @@ public class FactionsLwcModule extends JavaModule {
@Override
public void onProtectionInteract(LWCProtectionInteractEvent event) {
// If this feature is enabled ...
if (!MConf.get().lwcRemoveIfNoBuildRights) {
return;
}
if (!MConf.get().lwcRemoveIfNoBuildRights) {
return;
}
// ... gather data ...
final Protection protection = event.getProtection();
@ -75,16 +75,16 @@ public class FactionsLwcModule extends JavaModule {
final String ownerName = protection.getOwner();
final String ownerId = IdUtil.getId(ownerName);
final MPlayer mowner = MPlayer.get(ownerId);
if (mowner == null) {
return;
}
if (mowner == null) {
return;
}
// ... and if the protection owner no longer has build rights for the area ...
// NOTE: We silently check the build rights for the protection owner.
// NOTE: The protection owner may even be offline at the moment.
if (EnginePermBuild.canPlayerBuildAt(mowner, ps, false)) {
return;
}
if (EnginePermBuild.canPlayerBuildAt(mowner, ps, false)) {
return;
}
// ... remove the protection ...
protection.remove();

View File

@ -27,15 +27,15 @@ public class IntegrationPlaceholderAPI extends Integration {
@Override
public void setIntegrationActiveInner(boolean active) {
if (active) {
PlaceholderFactions.get().register();
}
if (active) {
PlaceholderFactions.get().register();
}
}
public static void ensureRegistered() {
if (PlaceholderFactions.get().isRegistered()) {
return;
}
if (PlaceholderFactions.get().isRegistered()) {
return;
}
PlaceholderFactions.get().register();
}
@ -44,13 +44,13 @@ public class IntegrationPlaceholderAPI extends Integration {
@EventHandler(priority = EventPriority.MONITOR)
public void lookForCommand(PlayerCommandPreprocessEvent event) {
String str = event.getMessage();
if (str.startsWith("/")) {
str = str.substring(1);
}
if (str.startsWith("/")) {
str = str.substring(1);
}
if (!str.startsWith("papi")) {
return;
}
if (!str.startsWith("papi")) {
return;
}
Bukkit.getScheduler().runTaskLater(this.getPlugin(), IntegrationPlaceholderAPI::ensureRegistered, 10L);
}

View File

@ -40,14 +40,14 @@ public class PlaceholderFactions extends PlaceholderExpansion {
@Override
public String onPlaceholderRequest(Player player, String params) {
if (player == null) {
return null;
}
if (player == null) {
return null;
}
MPlayer mplayer = MPlayer.get(player);
if ("role".equals(params)) {
params = "rank";
}
if ("role".equals(params)) {
params = "rank";
}
DecimalFormat df = new DecimalFormat("#.##");
switch (params) {

View File

@ -50,9 +50,9 @@ public class EngineVentureChat extends Engine {
// If the channel is the Factions channel
boolean factionChat = channelName.equalsIgnoreCase(MConf.get().ventureChatFactionChannelName);
boolean allyChat = channelName.equalsIgnoreCase(MConf.get().ventureChatAllyChannelName);
if (!(factionChat || allyChat)) {
return;
}
if (!(factionChat || allyChat)) {
return;
}
MPlayer mplayer = MPlayer.get(player);
Faction faction = mplayer.getFaction();

View File

@ -50,53 +50,53 @@ public class EngineWorldGuard extends Engine {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void checkForRegion(EventFactionsChunksChange event) {
// Skip checks if the configuration has worldguardCheckEnabled disabled
if (!MConf.get().worldguardCheckEnabled) {
return;
}
if (!MConf.get().worldguardCheckEnabled) {
return;
}
// Permanent Factions should not apply this rule
if (event.getNewFaction().getFlag(MFlag.ID_PERMANENT)) {
return;
}
if (event.getNewFaction().getFlag(MFlag.ID_PERMANENT)) {
return;
}
MPlayer mplayer = event.getMPlayer();
Player player = mplayer.getPlayer();
// Only do this for players
if (player == null) {
return;
}
if (player == null) {
return;
}
LocalPlayer wrapperPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
if (!MConf.get().worldguardCheckWorldsEnabled.contains(player)) {
return;
}
if (!MConf.get().worldguardCheckWorldsEnabled.contains(player)) {
return;
}
// For overriders don't bother checking
if (mplayer.isOverriding()) {
return;
}
if (mplayer.isOverriding()) {
return;
}
for (PS chunk : event.getChunks()) {
// Grab any regions in the chunk
final List<ProtectedRegion> regions = this.getProtectedRegionsFor(chunk);
// Ensure there are actually regions to go over
if (regions == null || regions.isEmpty()) {
continue;
}
if (regions == null || regions.isEmpty()) {
continue;
}
for (ProtectedRegion region : regions) {
// Ensure it's not the global region, and check if they're a member
if (region instanceof GlobalProtectedRegion || region.isMember(wrapperPlayer)) {
continue;
}
if (region instanceof GlobalProtectedRegion || region.isMember(wrapperPlayer)) {
continue;
}
// Check for a permission - can't use Perm enum for this
if (player.hasPermission("factions.allowregionclaim." + region.getId())) {
continue;
}
if (player.hasPermission("factions.allowregionclaim." + region.getId())) {
continue;
}
// No permission, notify player and stop claiming
mplayer.msg("<b>You cannot claim the chunk at %s, %s as there is a region in the way.", chunk.getChunkX(), chunk.getChunkZ());

View File

@ -35,9 +35,9 @@ public class PredicateCommandSenderFaction implements Predicate<CommandSender>,
@Override
public boolean test(CommandSender sender) {
if (MUtil.isntSender(sender)) {
return false;
}
if (MUtil.isntSender(sender)) {
return false;
}
MPlayer mplayer = MPlayer.get(sender);
return this.factionId.equals(mplayer.getFaction().getId());

View File

@ -35,13 +35,13 @@ public class PredicateMPlayerRank implements Predicate<MPlayer> {
@Override
public boolean test(MPlayer mplayer) {
if (mplayer == null) {
return false;
}
if (mplayer == null) {
return false;
}
Faction faction = mplayer.getFaction();
if (!faction.hasRank(this.getRank())) {
throw new IllegalStateException("rank: " + rank.getId() + " player:" + mplayer.getId());
}
if (!faction.hasRank(this.getRank())) {
throw new IllegalStateException("rank: " + rank.getId() + " player:" + mplayer.getId());
}
return mplayer.getRank() == this.rank;
}
}

View File

@ -106,9 +106,9 @@ public class TaskTax extends Task {
for (Couple<MPlayer, Double> couple : taxes) {
double tax = doTaxPlayer(couple);
if (tax == 0D) {
continue;
}
if (tax == 0D) {
continue;
}
// Log data
Faction faction = couple.getFirst().getFaction();
@ -143,11 +143,11 @@ public class TaskTax extends Task {
if (success) {
// Inform player
if (mplayer.isOnline()) {
if (tax > 0) {
mplayer.msg("<i>You were just taxed <reset>%s <i> by your faction.", Money.format(tax)); // Tax
} else {
mplayer.msg("<i>You were just paid <reset>%s <i> by your faction.", Money.format(-tax)); // Salary
}
if (tax > 0) {
mplayer.msg("<i>You were just taxed <reset>%s <i> by your faction.", Money.format(tax)); // Tax
} else {
mplayer.msg("<i>You were just paid <reset>%s <i> by your faction.", Money.format(-tax)); // Salary
}
}
return tax;
@ -155,9 +155,9 @@ public class TaskTax extends Task {
{
faction.msg("%s<i> couldn't afford tax!", mplayer.describeTo(faction));
boolean kicked = tryKickPlayer(mplayer);
if (!kicked) {
faction.msg("%s <i>could not afford tax.", mplayer.describeTo(faction));
}
if (!kicked) {
faction.msg("%s <i>could not afford tax.", mplayer.describeTo(faction));
}
return 0D;
} else // If a salary
{
@ -168,40 +168,40 @@ public class TaskTax extends Task {
private boolean shouldBeTaxed(long now, MPlayer mplayer) {
// Must have faction
if (!mplayer.hasFaction()) {
return false;
}
if (!mplayer.hasFaction()) {
return false;
}
// Must have been online recently
long offlinePeriod;
if (mplayer.isOnline()) {
offlinePeriod = 0;
} else {
offlinePeriod = now - mplayer.getLastActivityMillis();
}
if (mplayer.isOnline()) {
offlinePeriod = 0;
} else {
offlinePeriod = now - mplayer.getLastActivityMillis();
}
int inactiveDays = MConf.get().taxInactiveDays;
if (inactiveDays > 0 && offlinePeriod > inactiveDays * TimeUnit.MILLIS_PER_DAY) {
return false;
}
if (inactiveDays > 0 && offlinePeriod > inactiveDays * TimeUnit.MILLIS_PER_DAY) {
return false;
}
return true;
}
private boolean tryKickPlayer(MPlayer mplayer) {
Faction faction = mplayer.getFaction();
if (mplayer.getRank().isLeader()) {
return false;
}
if (!faction.getFlag(MFlag.getFlagTaxKick())) {
return false;
}
if (mplayer.getRank().isLeader()) {
return false;
}
if (!faction.getFlag(MFlag.getFlagTaxKick())) {
return false;
}
EventFactionsMembershipChange event = new EventFactionsMembershipChange(null, mplayer, FactionColl.get().getNone(), MembershipChangeReason.KICK);
event.run();
if (event.isCancelled()) {
return false;
}
if (event.isCancelled()) {
return false;
}
faction.msg("%s <i>could not afford tax and was kicked from your faction.", mplayer.describeTo(faction));

Some files were not shown because too many files have changed in this diff Show More