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

View File

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

View File

@ -51,12 +51,12 @@ public class FactionsIndex {
// -------------------------------------------- // // -------------------------------------------- //
private boolean isConnected(MPlayer mplayer, Faction faction) { private boolean isConnected(MPlayer mplayer, Faction faction) {
if (mplayer == null) { if (mplayer == null) {
throw new NullPointerException("mplayer"); throw new NullPointerException("mplayer");
} }
if (faction == null) { if (faction == null) {
throw new NullPointerException("faction"); throw new NullPointerException("faction");
} }
return mplayer.getFaction() == faction; return mplayer.getFaction() == faction;
} }
@ -78,20 +78,20 @@ public class FactionsIndex {
// -------------------------------------------- // // -------------------------------------------- //
public synchronized void updateAll() { public synchronized void updateAll() {
if (!MPlayerColl.get().isActive()) { if (!MPlayerColl.get().isActive()) {
throw new IllegalStateException("The MPlayerColl is not yet fully activated."); throw new IllegalStateException("The MPlayerColl is not yet fully activated.");
} }
MPlayerColl.get().getAll().forEach(this::update); MPlayerColl.get().getAll().forEach(this::update);
} }
public synchronized void update(MPlayer mplayer) { public synchronized void update(MPlayer mplayer) {
if (mplayer == null) { if (mplayer == null) {
throw new NullPointerException("mplayer"); throw new NullPointerException("mplayer");
} }
if (!FactionColl.get().isActive()) { if (!FactionColl.get().isActive()) {
throw new IllegalStateException("The FactionColl is not yet fully activated."); 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 // 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 // the mplayer object is deattached. Optimally it should be removed
@ -110,12 +110,12 @@ public class FactionsIndex {
Faction factionIndexed = this.getFaction(mplayer); Faction factionIndexed = this.getFaction(mplayer);
Set<Faction> factions = new MassiveSet<>(); Set<Faction> factions = new MassiveSet<>();
if (factionActual != null) { if (factionActual != null) {
factions.add(factionActual); factions.add(factionActual);
} }
if (factionIndexed != null) { if (factionIndexed != null) {
factions.add(factionIndexed); factions.add(factionIndexed);
} }
for (Faction faction : factions) { for (Faction faction : factions) {
boolean connected = this.isConnected(mplayer, faction); boolean connected = this.isConnected(mplayer, faction);
@ -130,9 +130,9 @@ public class FactionsIndex {
} }
public synchronized void update(Faction faction) { public synchronized void update(Faction faction) {
if (faction == null) { if (faction == null) {
throw new NullPointerException("faction"); throw new NullPointerException("faction");
} }
this.getMPlayers(faction).forEach(this::update); 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) { private TerritoryAccess(String hostFactionId, Boolean hostFactionAllowed, Collection<String> grantedIds, String chunkName) {
if (hostFactionId == null) { if (hostFactionId == null) {
throw new NullPointerException("hostFactionId"); throw new NullPointerException("hostFactionId");
} }
if (grantedIds == null) { if (grantedIds == null) {
throw new NullPointerException("grantedIds"); throw new NullPointerException("grantedIds");
} }
this.hostFactionId = hostFactionId; this.hostFactionId = hostFactionId;
Set<String> grantedIdsInner = new MassiveSet<>(); 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) { public static TerritoryAccess valueOf(String hostFactionId, Boolean hostFactionAllowed, Collection<String> grantedIds, String chunkName) {
if (hostFactionId == null) { if (hostFactionId == null) {
throw new NullPointerException("hostFactionId"); throw new NullPointerException("hostFactionId");
} }
if (grantedIds == null) { if (grantedIds == null) {
throw new NullPointerException("grantedIds"); throw new NullPointerException("grantedIds");
} }
return new TerritoryAccess(hostFactionId, hostFactionAllowed, grantedIds, chunkName); return new TerritoryAccess(hostFactionId, hostFactionAllowed, grantedIds, chunkName);
} }
public static TerritoryAccess valueOf(String hostFactionId) { public static TerritoryAccess valueOf(String hostFactionId) {
if (hostFactionId == null) { if (hostFactionId == null) {
throw new NullPointerException("hostFactionId"); throw new NullPointerException("hostFactionId");
} }
return valueOf(hostFactionId, null, Collections.emptySet(), null); return valueOf(hostFactionId, null, Collections.emptySet(), null);
} }
@ -167,9 +167,9 @@ public class TerritoryAccess {
} }
public boolean isGranted(String permableId) { public boolean isGranted(String permableId) {
if (permableId.equals(this.hostFactionId)) { if (permableId.equals(this.hostFactionId)) {
return this.isHostFactionAllowed(); return this.isHostFactionAllowed();
} }
return this.getGrantedIds().contains(permableId); return this.getGrantedIds().contains(permableId);
} }
@ -184,26 +184,26 @@ public class TerritoryAccess {
// -------------------------------------------- // // -------------------------------------------- //
public AccessStatus getTerritoryAccess(MPlayer mplayer) { public AccessStatus getTerritoryAccess(MPlayer mplayer) {
if (isGranted(mplayer.getId())) { if (isGranted(mplayer.getId())) {
return AccessStatus.ELEVATED; return AccessStatus.ELEVATED;
} }
if (isGranted(mplayer.getRank().getId())) { if (isGranted(mplayer.getRank().getId())) {
return AccessStatus.ELEVATED; return AccessStatus.ELEVATED;
} }
if (this.getHostFactionId().equals(mplayer.getFaction().getId())) { if (this.getHostFactionId().equals(mplayer.getFaction().getId())) {
if (this.isHostFactionAllowed()) { if (this.isHostFactionAllowed()) {
return AccessStatus.STANDARD; return AccessStatus.STANDARD;
} else { } else {
return AccessStatus.DECREASED; 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; return AccessStatus.STANDARD;
} }

View File

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

View File

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

View File

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

View File

@ -26,9 +26,9 @@ public class ChatTagRelcolor extends ChatTag {
@Override @Override
public String getReplacement(CommandSender sender, CommandSender recipient) { public String getReplacement(CommandSender sender, CommandSender recipient) {
// Opt out if no recipient // Opt out if no recipient
if (recipient == null) { if (recipient == null) {
return null; return null;
} }
// Get entities // Get entities
MPlayer usender = MPlayer.get(sender); 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 // Check if they have access perms, unless they are checking for their own access
if (mpermable != msender && mpermable != msenderFaction && mpermable != msender.getRank()) { if (mpermable != msender && mpermable != msenderFaction && mpermable != msender.getRank()) {
if (!MPerm.getPermAccess().has(msender, faction, true)) { if (!MPerm.getPermAccess().has(msender, faction, true)) {
return; return;
} }
} }
// Turn into id->chunks // Turn into id->chunks
@ -60,9 +60,9 @@ public class CmdFactionsAccessInspect extends FactionsCommand {
.filter(e -> e.getValue().isGranted(mpermable)) .filter(e -> e.getValue().isGranted(mpermable))
.map(Entry::getKey) .map(Entry::getKey)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
if (!chunks.isEmpty()) { if (!chunks.isEmpty()) {
world2Chunks.put(worldId, chunks); world2Chunks.put(worldId, chunks);
} }
} }
if (world2Chunks.isEmpty()) { if (world2Chunks.isEmpty()) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -50,9 +50,9 @@ public class CmdFactionsInviteRemove extends FactionsCommand {
} }
// MPerm // MPerm
if (!MPerm.getPermInvite().has(msender, msenderFaction, true)) { if (!MPerm.getPermInvite().has(msender, msenderFaction, true)) {
return; return;
} }
for (MPlayer mplayer : mplayers) { for (MPlayer mplayer : mplayers) {
// Already member? // Already member?
@ -79,9 +79,9 @@ public class CmdFactionsInviteRemove extends FactionsCommand {
// Event // Event
EventFactionsInvitedChange event = new EventFactionsInvitedChange(sender, mplayer, msenderFaction, isInvited); EventFactionsInvitedChange event = new EventFactionsInvitedChange(sender, mplayer, msenderFaction, isInvited);
event.run(); event.run();
if (event.isCancelled()) { if (event.isCancelled()) {
continue; continue;
} }
isInvited = event.isNewInvited(); isInvited = event.isNewInvited();
// Inform Player // Inform Player
@ -96,9 +96,9 @@ public class CmdFactionsInviteRemove extends FactionsCommand {
msenderFaction.uninvite(mplayer); msenderFaction.uninvite(mplayer);
// If all, we do this at last. So we only do it once. // If all, we do this at last. So we only do it once.
if (!all) { if (!all) {
msenderFaction.changed(); msenderFaction.changed();
} }
} else { } else {
// Mson // Mson
String command = CmdFactions.get().cmdFactionsInvite.cmdFactionsInviteAdd.getCommandLine(mplayer.getName()); 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 { public void perform() throws MassiveException {
Faction faction = this.readArg(msenderFaction); Faction faction = this.readArg(msenderFaction);
if (faction != msenderFaction && !Perm.MONEY_BALANCE_ANY.has(sender, true)) { if (faction != msenderFaction && !Perm.MONEY_BALANCE_ANY.has(sender, true)) {
return; return;
} }
Econ.sendBalanceInfo(msender, faction); Econ.sendBalanceInfo(msender, faction);
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -43,9 +43,9 @@ public class ReqRankIsAtLeast extends RequirementAbstract {
@Override @Override
public boolean apply(CommandSender sender, MassiveCommand command) { public boolean apply(CommandSender sender, MassiveCommand command) {
if (MUtil.isntSender(sender)) { if (MUtil.isntSender(sender)) {
return false; return false;
} }
MPlayer mplayer = MPlayer.get(sender); MPlayer mplayer = MPlayer.get(sender);
return mplayer.getRank().isAtLeast(this.getRank()); 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) { protected TypeEntityInternalFaction(Class<E> clazz, Faction faction) {
super(clazz); super(clazz);
if (faction == null) { if (faction == null) {
throw new NullPointerException("faction"); throw new NullPointerException("faction");
} }
this.faction = faction; this.faction = faction;
@ -54,18 +54,18 @@ public abstract class TypeEntityInternalFaction<E extends EntityInternal<E>> ext
@Override @Override
public boolean isValid(String arg, CommandSender sender) { public boolean isValid(String arg, CommandSender sender) {
// In the generic case accept all // In the generic case accept all
if (this.getAll().isEmpty()) { if (this.getAll().isEmpty()) {
return true; return true;
} else { } else {
return super.isValid(arg, sender); return super.isValid(arg, sender);
} }
} }
@Override @Override
public Collection<String> getTabList(CommandSender sender, String arg) { public Collection<String> getTabList(CommandSender sender, String arg) {
if (this.getFaction() != null) { if (this.getFaction() != null) {
return super.getTabList(sender, arg); return super.getTabList(sender, arg);
} }
// Default to tab list for the sender // Default to tab list for the sender
Faction faction = MPlayer.get(sender).getFaction(); Faction faction = MPlayer.get(sender).getFaction();

View File

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

View File

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

View File

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

View File

@ -38,27 +38,27 @@ public class ComparatorFactionList extends ComparatorAbstract<Faction> {
@Override @Override
public int compareInner(Faction f1, Faction f2) { public int compareInner(Faction f1, Faction f2) {
// None a.k.a. Wilderness // None a.k.a. Wilderness
if (f1.isNone() && f2.isNone()) { if (f1.isNone() && f2.isNone()) {
return 0; return 0;
} }
if (f1.isNone()) { if (f1.isNone()) {
return -1; return -1;
} }
if (f2.isNone()) { if (f2.isNone()) {
return 1; return 1;
} }
// Players Online // Players Online
int ret = f2.getMPlayersWhereOnlineTo(this.getWatcher()).size() - f1.getMPlayersWhereOnlineTo(this.getWatcher()).size(); int ret = f2.getMPlayersWhereOnlineTo(this.getWatcher()).size() - f1.getMPlayersWhereOnlineTo(this.getWatcher()).size();
if (ret != 0) { if (ret != 0) {
return ret; return ret;
} }
// Players Total // Players Total
ret = f2.getMPlayers().size() - f1.getMPlayers().size(); ret = f2.getMPlayers().size() - f1.getMPlayers().size();
if (ret != 0) { if (ret != 0) {
return ret; return ret;
} }
// Tie by Id // Tie by Id
return ComparatorComparable.get().compare(f1.getId(), f2.getId()); 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 o1 = m1.isOnline();
boolean o2 = m2.isOnline(); boolean o2 = m2.isOnline();
if (o1 && o2) { if (o1 && o2) {
return 0; return 0;
} else if (o1) { } else if (o1) {
return -1; return -1;
} else if (o2) { } else if (o2) {
return +1; return +1;
} }
// Inactivity Time // Inactivity Time
long r1 = m1.getLastActivityMillis(); long r1 = m1.getLastActivityMillis();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -44,31 +44,31 @@ public class EngineFly extends Engine {
public void onMassiveCorePlayerUpdate(EventMassiveCorePlayerUpdate event) { public void onMassiveCorePlayerUpdate(EventMassiveCorePlayerUpdate event) {
// If we are updating a player ... // If we are updating a player ...
Player player = event.getPlayer(); Player player = event.getPlayer();
if (MUtil.isntPlayer(player)) { if (MUtil.isntPlayer(player)) {
return; return;
} }
// ... and that player isn't in creative or spectator mode ... // ... and that player isn't in creative or spectator mode ...
if (EventMassiveCorePlayerUpdate.isFlyAllowed(player, false)) { if (EventMassiveCorePlayerUpdate.isFlyAllowed(player, false)) {
return; return;
} }
// ... and the player is alive ... // ... and the player is alive ...
if (player.isDead()) { if (player.isDead()) {
return; return;
} }
MPlayer mplayer = MPlayer.get(player); MPlayer mplayer = MPlayer.get(player);
// ... and the player enables flying ... // ... and the player enables flying ...
if (!mplayer.isFlying()) { if (!mplayer.isFlying()) {
return; return;
} }
// ... and the player can fly here... // ... and the player can fly here...
if (!canFlyInTerritory(mplayer, PS.valueOf(player))) { if (!canFlyInTerritory(mplayer, PS.valueOf(player))) {
return; return;
} }
// ... set allowed ... // ... set allowed ...
event.setAllowed(true); event.setAllowed(true);
@ -80,27 +80,27 @@ public class EngineFly extends Engine {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void moveChunkDetect(PlayerMoveEvent event) { public void moveChunkDetect(PlayerMoveEvent event) {
// If the player is moving from one chunk to another ... // If the player is moving from one chunk to another ...
if (MUtil.isSameChunk(event)) { if (MUtil.isSameChunk(event)) {
return; return;
} }
Player player = event.getPlayer(); Player player = event.getPlayer();
if (MUtil.isntPlayer(player)) { if (MUtil.isntPlayer(player)) {
return; return;
} }
// ... gather info on the player and the move ... // ... gather info on the player and the move ...
MPlayer mplayer = MPlayer.get(player); MPlayer mplayer = MPlayer.get(player);
PS chunkTo = PS.valueOf(event.getTo()).getChunk(true); PS chunkTo = PS.valueOf(event.getTo()).getChunk(true);
// ... and they are currently flying ... // ... and they are currently flying ...
if (!mplayer.isFlying()) { if (!mplayer.isFlying()) {
return; return;
} }
// ... but can't fly at the new place ... // ... but can't fly at the new place ...
if (canFlyInTerritory(mplayer, chunkTo)) { if (canFlyInTerritory(mplayer, chunkTo)) {
return; return;
} }
// ... then perhaps they should not be // ... then perhaps they should not be
mplayer.setFlying(false); mplayer.setFlying(false);
@ -109,12 +109,12 @@ public class EngineFly extends Engine {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void flagUpdate(EventFactionsFlagChange event) { public void flagUpdate(EventFactionsFlagChange event) {
if (event.getFlag() != MFlag.getFlagFly()) { if (event.getFlag() != MFlag.getFlagFly()) {
return; return;
} }
if (event.isNewValue() == true) { if (event.isNewValue() == true) {
return; return;
} }
// Disable for all players when disabled // Disable for all players when disabled
event.getFaction().getOnlinePlayers().forEach(EngineFly::deactivateForPlayer); event.getFaction().getOnlinePlayers().forEach(EngineFly::deactivateForPlayer);
@ -123,23 +123,23 @@ public class EngineFly extends Engine {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void territoryShield(EntityDamageByEntityEvent event) { public void territoryShield(EntityDamageByEntityEvent event) {
// If flying is diabled on PVP ... // If flying is diabled on PVP ...
if (!MConf.get().flyDisableOnPvp) { if (!MConf.get().flyDisableOnPvp) {
return; return;
} }
// ... and the defender is a player ... // ... and the defender is a player ...
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (MUtil.isntPlayer(entity)) { if (MUtil.isntPlayer(entity)) {
return; return;
} }
Player defender = (Player) entity; Player defender = (Player) entity;
MPlayer mdefender = MPlayer.get(defender); MPlayer mdefender = MPlayer.get(defender);
// ... and the attacker is a player ... // ... and the attacker is a player ...
Entity eattacker = MUtil.getLiableDamager(event); Entity eattacker = MUtil.getLiableDamager(event);
if (!(eattacker instanceof Player)) { if (!(eattacker instanceof Player)) {
return; return;
} }
Player attacker = (Player) eattacker; Player attacker = (Player) eattacker;
MPlayer mattacker = MPlayer.get(attacker); MPlayer mattacker = MPlayer.get(attacker);
@ -206,12 +206,12 @@ public class EngineFly extends Engine {
if (isAdmin) { if (isAdmin) {
boolean overriding = mplayer.isOverriding(); boolean overriding = mplayer.isOverriding();
ex.addMsg("<i>You can change the flag if you are overriding."); ex.addMsg("<i>You can change the flag if you are overriding.");
if (overriding) { if (overriding) {
ex.addMsg("<i>You are already overriding."); ex.addMsg("<i>You are already overriding.");
} else { } else {
ex.addMsg("<i>You can enable override with:"); ex.addMsg("<i>You can enable override with:");
ex.addMessage(CmdFactions.get().cmdFactionsOverride.getTemplate(false, true, mplayer.getSender())); ex.addMessage(CmdFactions.get().cmdFactionsOverride.getTemplate(false, true, mplayer.getSender()));
} }
if (!isDefault) { if (!isDefault) {
ex.addMsg("<i>You can also ask someone with access to the configuration files to make flying enabled by default."); 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) { public static void updateLastActivity(CommandSender sender) {
if (sender == null) { if (sender == null) {
throw new RuntimeException("sender"); throw new RuntimeException("sender");
} }
if (MUtil.isntSender(sender)) { if (MUtil.isntSender(sender)) {
return; return;
} }
MPlayer mplayer = MPlayer.get(sender); MPlayer mplayer = MPlayer.get(sender);
mplayer.setLastActivityMillis(); mplayer.setLastActivityMillis();
} }
public static void updateLastActivitySoon(final CommandSender sender) { public static void updateLastActivitySoon(final CommandSender sender) {
if (sender == null) { if (sender == null) {
throw new RuntimeException("sender"); throw new RuntimeException("sender");
} }
Bukkit.getScheduler().scheduleSyncDelayedTask(Factions.get(), () -> updateLastActivity(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) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void moveChunkDetect(PlayerMoveEvent event) { public void moveChunkDetect(PlayerMoveEvent event) {
// If the player is moving from one chunk to another ... // If the player is moving from one chunk to another ...
if (MUtil.isSameChunk(event)) { if (MUtil.isSameChunk(event)) {
return; return;
} }
Player player = event.getPlayer(); Player player = event.getPlayer();
if (MUtil.isntPlayer(player)) { if (MUtil.isntPlayer(player)) {
return; return;
} }
// ... gather info on the player and the move ... // ... gather info on the player and the move ...
MPlayer mplayer = MPlayer.get(player); MPlayer mplayer = MPlayer.get(player);
@ -67,9 +67,9 @@ public class EngineMoveChunk extends Engine {
} }
private static void sendAutoMapUpdate(MPlayer mplayer, PS ps) { private static void sendAutoMapUpdate(MPlayer mplayer, PS ps) {
if (!mplayer.isMapAutoUpdating()) { if (!mplayer.isMapAutoUpdating()) {
return; return;
} }
AsciiMap map = new AsciiMap(mplayer, ps, false); AsciiMap map = new AsciiMap(mplayer, ps, false);
mplayer.message(map.render()); mplayer.message(map.render());
} }
@ -78,9 +78,9 @@ public class EngineMoveChunk extends Engine {
Faction factionFrom = BoardColl.get().getFactionAt(psFrom); Faction factionFrom = BoardColl.get().getFactionAt(psFrom);
Faction factionTo = BoardColl.get().getFactionAt(psTo); Faction factionTo = BoardColl.get().getFactionAt(psTo);
if (factionFrom == factionTo) { if (factionFrom == factionTo) {
return; return;
} }
if (mplayer.isTerritoryInfoTitles()) { if (mplayer.isTerritoryInfoTitles()) {
String titleMain = parseTerritoryInfo(MConf.get().territoryInfoTitlesMain, mplayer, factionTo); 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) { private static String parseTerritoryInfo(String string, MPlayer mplayer, Faction faction) {
if (string == null) { if (string == null) {
throw new NullPointerException("string"); throw new NullPointerException("string");
} }
if (faction == null) { if (faction == null) {
throw new NullPointerException("faction"); throw new NullPointerException("faction");
} }
string = Txt.parse(string); string = Txt.parse(string);
string = string.replace("{name}", faction.getName()); 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) { private static void sendTerritoryAccessMessage(MPlayer mplayer, PS psFrom, PS psTo) {
if (!MConf.get().territoryAccessShowMessage) { if (!MConf.get().territoryAccessShowMessage) {
return; return;
} }
// Get TerritoryAccess for from & to chunks // Get TerritoryAccess for from & to chunks
TerritoryAccess accessFrom = BoardColl.get().getTerritoryAccessAt(psFrom); TerritoryAccess accessFrom = BoardColl.get().getTerritoryAccessAt(psFrom);
@ -123,9 +123,9 @@ public class EngineMoveChunk extends Engine {
// See if the status has changed // See if the status has changed
AccessStatus statusFrom = accessFrom.getTerritoryAccess(mplayer); AccessStatus statusFrom = accessFrom.getTerritoryAccess(mplayer);
AccessStatus statusTo = accessTo.getTerritoryAccess(mplayer); AccessStatus statusTo = accessTo.getTerritoryAccess(mplayer);
if (statusFrom == statusTo) { if (statusFrom == statusTo) {
return; return;
} }
// Inform // Inform
mplayer.message(statusTo.getStatusMessage()); mplayer.message(statusTo.getStatusMessage());
@ -138,9 +138,9 @@ public class EngineMoveChunk extends Engine {
private static void tryAutoClaim(MPlayer mplayer, PS chunkTo) { private static void tryAutoClaim(MPlayer mplayer, PS chunkTo) {
// If the player is auto claiming ... // If the player is auto claiming ...
Faction autoClaimFaction = mplayer.getAutoClaimFaction(); Faction autoClaimFaction = mplayer.getAutoClaimFaction();
if (autoClaimFaction == null) { if (autoClaimFaction == null) {
return; return;
} }
// ... try claim. // ... try claim.
mplayer.tryClaim(autoClaimFaction, Collections.singletonList(chunkTo)); 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) { public static Boolean isProtected(ProtectCase protectCase, boolean verboose, MPlayer mplayer, PS ps, Object object) {
if (mplayer == null) { if (mplayer == null) {
return null; return null;
} }
if (protectCase == null) { if (protectCase == null) {
return null; return null;
} }
String name = mplayer.getName(); String name = mplayer.getName();
if (MConf.get().playersWhoBypassAllProtection.contains(name)) { if (MConf.get().playersWhoBypassAllProtection.contains(name)) {
return false; return false;
} }
if (mplayer.isOverriding()) { if (mplayer.isOverriding()) {
return false; return false;
} }
MPerm perm = protectCase.getPerm(object); MPerm perm = protectCase.getPerm(object);
if (perm == null) { if (perm == null) {
return null; return null;
} }
if (protectCase != ProtectCase.BUILD) { if (protectCase != ProtectCase.BUILD) {
return !perm.has(mplayer, ps, verboose); return !perm.has(mplayer, ps, verboose);
} }
if (!perm.has(mplayer, ps, false) && MPerm.getPermPainbuild().has(mplayer, ps, false)) { if (!perm.has(mplayer, ps, false) && MPerm.getPermPainbuild().has(mplayer, ps, false)) {
if (!verboose) { if (!verboose) {
return false; return false;
} }
Faction hostFaction = BoardColl.get().getFactionAt(ps); Faction hostFaction = BoardColl.get().getFactionAt(ps);
mplayer.msg("<b>It is painful to build in the territory of %s<b>.", hostFaction.describeTo(mplayer)); mplayer.msg("<b>It is painful to build in the territory of %s<b>.", hostFaction.describeTo(mplayer));
Player player = mplayer.getPlayer(); Player player = mplayer.getPlayer();
if (player != null) { if (player != null) {
player.damage(MConf.get().actionDeniedPainAmount); player.damage(MConf.get().actionDeniedPainAmount);
} }
} }
return !perm.has(mplayer, ps, verboose); 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) { 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); Boolean ret = isProtected(protectCase, verboose, MPlayer.get(player), ps, object);
if (Boolean.TRUE.equals(ret) && cancellable != null) { if (Boolean.TRUE.equals(ret) && cancellable != null) {
cancellable.setCancelled(true); cancellable.setCancelled(true);
} }
return ret; return ret;
} }
public static Boolean build(Entity entity, Block block, Event event) { public static Boolean build(Entity entity, Block block, Event event) {
if (!(event instanceof Cancellable)) { if (!(event instanceof Cancellable)) {
return true; return true;
} }
if (MUtil.isntPlayer(entity)) { if (MUtil.isntPlayer(entity)) {
return false; return false;
} }
Player player = (Player) entity; Player player = (Player) entity;
boolean verboose = !isFake(event); boolean verboose = !isFake(event);
return protect(ProtectCase.BUILD, verboose, player, PS.valueOf(block), block, (Cancellable) 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) { public static boolean canPlayerBuildAt(Object senderObject, PS ps, boolean verboose) {
MPlayer mplayer = MPlayer.get(senderObject); MPlayer mplayer = MPlayer.get(senderObject);
if (mplayer == null) { if (mplayer == null) {
return false; return false;
} }
Boolean ret = isProtected(ProtectCase.BUILD, verboose, mplayer, ps, null); Boolean ret = isProtected(ProtectCase.BUILD, verboose, mplayer, ps, null);
return !Boolean.TRUE.equals(ret); return !Boolean.TRUE.equals(ret);
@ -180,9 +180,9 @@ public class EnginePermBuild extends Engine {
public void build(EntityChangeBlockEvent event) { public void build(EntityChangeBlockEvent event) {
// Handling lilypads being broken by boats // Handling lilypads being broken by boats
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (entity.getType() != EntityType.BOAT || entity.getPassengers().size() <= 0) { if (entity.getType() != EntityType.BOAT || entity.getPassengers().size() <= 0) {
return; return;
} }
Entity player = entity.getPassengers().stream().filter(MUtil::isPlayer).findAny().orElse(entity); Entity player = entity.getPassengers().stream().filter(MUtil::isPlayer).findAny().orElse(entity);
build(player, event.getBlock(), event); build(player, event.getBlock(), event);
@ -196,26 +196,26 @@ public class EnginePermBuild extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void useBlockItem(PlayerInteractEvent event) { public void useBlockItem(PlayerInteractEvent event) {
// If the player right clicks (or is physical with) a block ... // If the player right clicks (or is physical with) a block ...
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) { if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL) {
return; return;
} }
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
Player player = event.getPlayer(); Player player = event.getPlayer();
if (block == null) { if (block == null) {
return; return;
} }
// ... and we are either allowed to use this block ... // ... and we are either allowed to use this block ...
Boolean ret = useBlock(player, block, true, event); Boolean ret = useBlock(player, block, true, event);
if (Boolean.TRUE.equals(ret)) { if (Boolean.TRUE.equals(ret)) {
return; return;
} }
// ... or are allowed to right click with the item, this event is safe to perform. // ... or are allowed to right click with the item, this event is safe to perform.
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) { if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
return; return;
} }
useItem(player, block, event.getMaterial(), event); useItem(player, block, event.getMaterial(), event);
} }
@ -241,9 +241,9 @@ public class EnginePermBuild extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void useEntity(PlayerInteractEntityEvent event) { public void useEntity(PlayerInteractEntityEvent event) {
// Ignore Off Hand // Ignore Off Hand
if (isOffHand(event)) { if (isOffHand(event)) {
return; return;
} }
useEntity(event.getPlayer(), event.getRightClicked(), true, event); useEntity(event.getPlayer(), event.getRightClicked(), true, event);
} }
@ -254,22 +254,22 @@ public class EnginePermBuild extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void handleArmorStand(PlayerInteractAtEntityEvent event) { public void handleArmorStand(PlayerInteractAtEntityEvent event) {
// Ignore Off Hand // Ignore Off Hand
if (isOffHand(event)) { if (isOffHand(event)) {
return; return;
} }
// Gather Info // Gather Info
final Player player = event.getPlayer(); final Player player = event.getPlayer();
if (MUtil.isntPlayer(player)) { if (MUtil.isntPlayer(player)) {
return; return;
} }
final Entity entity = event.getRightClicked(); final Entity entity = event.getRightClicked();
final boolean verboose = true; final boolean verboose = true;
// Only care for armor stands. // Only care for armor stands.
if (entity.getType() != EntityType.ARMOR_STAND) { if (entity.getType() != EntityType.ARMOR_STAND) {
return; return;
} }
// If we can't use, block it // If we can't use, block it
EnginePermBuild.useEntity(player, entity, verboose, event); EnginePermBuild.useEntity(player, entity, verboose, event);
@ -283,16 +283,16 @@ public class EnginePermBuild extends Engine {
public void buildEntity(EntityDamageByEntityEvent event) { public void buildEntity(EntityDamageByEntityEvent event) {
// If a player ... // If a player ...
Entity damager = MUtil.getLiableDamager(event); Entity damager = MUtil.getLiableDamager(event);
if (MUtil.isntPlayer(damager)) { if (MUtil.isntPlayer(damager)) {
return; return;
} }
Player player = (Player) damager; Player player = (Player) damager;
// ... damages an entity which is edited on damage ... // ... damages an entity which is edited on damage ...
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (entity == null || !EnumerationUtil.isEntityTypeEditOnDamage(entity.getType())) { if (entity == null || !EnumerationUtil.isEntityTypeEditOnDamage(entity.getType())) {
return; return;
} }
// ... and the player can't build there, cancel the event // ... and the player can't build there, cancel the event
build(player, entity.getLocation().getBlock(), event); build(player, entity.getLocation().getBlock(), event);
@ -302,23 +302,23 @@ public class EnginePermBuild extends Engine {
public void combustEntity(EntityCombustByEntityEvent event) { public void combustEntity(EntityCombustByEntityEvent event) {
// If a burning projectile ... // If a burning projectile ...
if (!(event.getCombuster() instanceof Projectile)) { if (!(event.getCombuster() instanceof Projectile)) {
return; return;
} }
Projectile entityProjectile = (Projectile) event.getCombuster(); Projectile entityProjectile = (Projectile) event.getCombuster();
// ... fired by a player ... // ... fired by a player ...
ProjectileSource projectileSource = entityProjectile.getShooter(); ProjectileSource projectileSource = entityProjectile.getShooter();
if (MUtil.isntPlayer(projectileSource)) { if (MUtil.isntPlayer(projectileSource)) {
return; return;
} }
Player player = (Player) projectileSource; Player player = (Player) projectileSource;
// ... and hits an entity which is edited on damage (and thus likely to burn) ... // ... and hits an entity which is edited on damage (and thus likely to burn) ...
Entity entityTarget = event.getEntity(); Entity entityTarget = event.getEntity();
if (entityTarget == null || !EnumerationUtil.isEntityTypeEditOnDamage(entityTarget.getType())) { if (entityTarget == null || !EnumerationUtil.isEntityTypeEditOnDamage(entityTarget.getType())) {
return; return;
} }
// ... and the player can't build there, cancel the event // ... and the player can't build there, cancel the event
Block block = entityTarget.getLocation().getBlock(); Block block = entityTarget.getLocation().getBlock();
@ -339,9 +339,9 @@ public class EnginePermBuild extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void blockBuild(BlockPistonExtendEvent event) { public void blockBuild(BlockPistonExtendEvent event) {
// Is checking deactivated by MConf? // Is checking deactivated by MConf?
if (!MConf.get().handlePistonProtectionThroughDenyBuild) { if (!MConf.get().handlePistonProtectionThroughDenyBuild) {
return; return;
} }
Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock())); 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 // 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)); Faction targetFaction = BoardColl.get().getFactionAt(PS.valueOf(targetBlock));
if (targetFaction == pistonFaction) { if (targetFaction == pistonFaction) {
continue; continue;
} }
// Perm check // Perm check
if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) { if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) {
continue; continue;
} }
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -371,9 +371,9 @@ public class EnginePermBuild extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void blockBuild(BlockPistonRetractEvent event) { public void blockBuild(BlockPistonRetractEvent event) {
// Is checking deactivated by MConf? // Is checking deactivated by MConf?
if (!MConf.get().handlePistonProtectionThroughDenyBuild) { if (!MConf.get().handlePistonProtectionThroughDenyBuild) {
return; return;
} }
Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock())); Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock()));
@ -382,20 +382,20 @@ public class EnginePermBuild extends Engine {
// Check for all retracted blocks // Check for all retracted blocks
for (Block block : blocks) { for (Block block : blocks) {
// Is the retracted block air/water/lava? Don't worry about it // Is the retracted block air/water/lava? Don't worry about it
if (block.isEmpty() || block.isLiquid()) { if (block.isEmpty() || block.isLiquid()) {
return; return;
} }
// Members of a faction might not have build rights in their own territory, but pistons should still work regardless // 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)); Faction targetFaction = BoardColl.get().getFactionAt(PS.valueOf(block));
if (targetFaction == pistonFaction) { if (targetFaction == pistonFaction) {
continue; continue;
} }
// Perm check // Perm check
if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) { if (MPerm.getPermBuild().has(pistonFaction, targetFaction)) {
continue; continue;
} }
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -410,27 +410,27 @@ public class EnginePermBuild extends Engine {
@EventHandler(priority = EventPriority.NORMAL) @EventHandler(priority = EventPriority.NORMAL)
public void buildFire(PlayerInteractEvent event) { public void buildFire(PlayerInteractEvent event) {
// If it is a left click on block and the clicked block is not null... // 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) { if (event.getAction() != Action.LEFT_CLICK_BLOCK || event.getClickedBlock() == null) {
return; return;
} }
// ... and the potential block is not null either ... // ... and the potential block is not null either ...
Block potentialBlock = event.getClickedBlock().getRelative(BlockFace.UP, 1); Block potentialBlock = event.getClickedBlock().getRelative(BlockFace.UP, 1);
if (potentialBlock == null) { if (potentialBlock == null) {
return; return;
} }
Material blockType = potentialBlock.getType(); Material blockType = potentialBlock.getType();
// ... and we're only going to check for fire ... (checking everything else would be bad performance wise) // ... and we're only going to check for fire ... (checking everything else would be bad performance wise)
if (blockType != Material.FIRE) { if (blockType != Material.FIRE) {
return; return;
} }
// ... check if they can't build, cancel the event ... // ... check if they can't build, cancel the event ...
if (!Boolean.FALSE.equals(build(event.getPlayer(), potentialBlock, event))) { if (!Boolean.FALSE.equals(build(event.getPlayer(), potentialBlock, event))) {
return; return;
} }
// ... and compensate for client side prediction // ... and compensate for client side prediction
event.getPlayer().sendBlockChange(potentialBlock.getLocation(), blockType, potentialBlock.getState().getRawData()); event.getPlayer().sendBlockChange(potentialBlock.getLocation(), blockType, potentialBlock.getState().getRawData());
@ -442,9 +442,9 @@ public class EnginePermBuild extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void buildMove(BlockFromToEvent event) { public void buildMove(BlockFromToEvent event) {
if (!MConf.get().protectionLiquidFlowEnabled) { if (!MConf.get().protectionLiquidFlowEnabled) {
return; return;
} }
// Prepare fields // Prepare fields
Block fromBlock = event.getBlock(); Block fromBlock = event.getBlock();
@ -455,21 +455,21 @@ public class EnginePermBuild extends Engine {
int chunkToZ = (fromBlock.getZ() + face.getModZ()) >> 4; int chunkToZ = (fromBlock.getZ() + face.getModZ()) >> 4;
// If a liquid (or dragon egg) moves from one chunk to another ... // If a liquid (or dragon egg) moves from one chunk to another ...
if (chunkToX == chunkFromX && chunkToZ == chunkFromZ) { if (chunkToX == chunkFromX && chunkToZ == chunkFromZ) {
return; return;
} }
// ... get the correct board for this block ... // ... get the correct board for this block ...
Board board = BoardColl.get().getFixed(fromBlock.getWorld().getName().toLowerCase(), false); Board board = BoardColl.get().getFixed(fromBlock.getWorld().getName().toLowerCase(), false);
if (board == null) { if (board == null) {
return; return;
} }
// ... get the access map ... // ... get the access map ...
Map<PS, TerritoryAccess> map = board.getMapRaw(); Map<PS, TerritoryAccess> map = board.getMapRaw();
if (map.isEmpty()) { if (map.isEmpty()) {
return; return;
} }
// ... get the faction ids from and to ... // ... get the faction ids from and to ...
PS fromPs = PS.valueOf(chunkFromX, chunkFromZ); PS fromPs = PS.valueOf(chunkFromX, chunkFromZ);
@ -482,22 +482,22 @@ public class EnginePermBuild extends Engine {
String toId = toTa != null ? toTa.getHostFactionId() : Factions.ID_NONE; String toId = toTa != null ? toTa.getHostFactionId() : Factions.ID_NONE;
// ... and the chunks belong to different factions ... // ... and the chunks belong to different factions ...
if (toId.equals(fromId)) { if (toId.equals(fromId)) {
return; return;
} }
// ... and the faction "from" can not build at "to" ... // ... and the faction "from" can not build at "to" ...
Faction fromFac = FactionColl.get().getFixed(fromId); Faction fromFac = FactionColl.get().getFixed(fromId);
if (fromFac == null) { if (fromFac == null) {
fromFac = FactionColl.get().getNone(); fromFac = FactionColl.get().getNone();
} }
Faction toFac = FactionColl.get().getFixed(toId); Faction toFac = FactionColl.get().getFixed(toId);
if (toFac == null) { if (toFac == null) {
toFac = FactionColl.get().getNone(); toFac = FactionColl.get().getNone();
} }
if (MPerm.getPermBuild().has(fromFac, toFac)) { if (MPerm.getPermBuild().has(fromFac, toFac)) {
return; return;
} }
// ... cancel the event! // ... cancel the event!
event.setCancelled(true); event.setCancelled(true);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -41,9 +41,9 @@ public class FactionColl extends Coll<Faction> {
public void setActive(boolean active) { public void setActive(boolean active) {
super.setActive(active); super.setActive(active);
if (!active) { if (!active) {
return; return;
} }
this.createSpecialFactions(); this.createSpecialFactions();
@ -63,9 +63,9 @@ public class FactionColl extends Coll<Faction> {
public Faction getNone() { public Faction getNone() {
String id = Factions.ID_NONE; String id = Factions.ID_NONE;
Faction faction = this.get(id); Faction faction = this.get(id);
if (faction != null) { if (faction != null) {
return faction; return faction;
} }
faction = this.create(id); faction = this.create(id);
@ -100,9 +100,9 @@ public class FactionColl extends Coll<Faction> {
public Faction getSafezone() { public Faction getSafezone() {
String id = Factions.ID_SAFEZONE; String id = Factions.ID_SAFEZONE;
Faction faction = this.get(id); Faction faction = this.get(id);
if (faction != null) { if (faction != null) {
return faction; return faction;
} }
faction = this.create(id); faction = this.create(id);
@ -135,9 +135,9 @@ public class FactionColl extends Coll<Faction> {
public Faction getWarzone() { public Faction getWarzone() {
String id = Factions.ID_WARZONE; String id = Factions.ID_WARZONE;
Faction faction = this.get(id); Faction faction = this.get(id);
if (faction != null) { if (faction != null) {
return faction; return faction;
} }
faction = this.create(id); faction = this.create(id);
@ -197,29 +197,29 @@ public class FactionColl extends Coll<Faction> {
// Fill // Fill
for (Faction fac : FactionColl.get().getAll()) { for (Faction fac : FactionColl.get().getAll()) {
if (fac.getFlag(flagPeaceful)) { if (fac.getFlag(flagPeaceful)) {
continue; continue;
} }
Rel rel = fac.getRelationTo(faction); Rel rel = fac.getRelationTo(faction);
List<String> names = ret.get(rel); List<String> names = ret.get(rel);
if (names == null) { if (names == null) {
continue; continue;
} }
String name = fac.describeTo(faction, true); String name = fac.describeTo(faction, true);
names.add(name); names.add(name);
} }
// Replace TRUCE if peaceful // Replace TRUCE if peaceful
if (!peaceful) { if (!peaceful) {
return ret; return ret;
} }
List<String> names = ret.get(Rel.TRUCE); List<String> names = ret.get(Rel.TRUCE);
if (names == null) { if (names == null) {
return ret; return ret;
} }
ret.put(Rel.TRUCE, Collections.singletonList(MConf.get().colorTruce.toString() + Txt.parse("<italic>*EVERYONE*"))); 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 @Override
public void setActive(boolean active) { public void setActive(boolean active) {
super.setActive(active); super.setActive(active);
if (!active) { if (!active) {
return; return;
} }
MConf.i = this.get(MassiveCore.INSTANCE, true); 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) { public boolean isInteresting(boolean value) {
if (!this.isVisible()) { if (!this.isVisible()) {
return false; return false;
} }
if (this.isEditable()) { if (this.isEditable()) {
return true; return true;
} }
return this.isStandard() != value; return this.isStandard() != value;
} }
@ -377,15 +377,15 @@ public class MFlag extends Entity<MFlag> implements Prioritized, Registerable, N
List<String> ret = new MassiveList<>(); List<String> ret = new MassiveList<>();
// Fill // Fill
if (withValue) { if (withValue) {
ret.add(getStateValue(value, monospaceValue)); ret.add(getStateValue(value, monospaceValue));
} }
if (withName) { if (withName) {
ret.add(this.getStateName()); ret.add(this.getStateName());
} }
if (withDesc) { if (withDesc) {
ret.add(this.getStateDescription(value, specificDesc)); ret.add(this.getStateDescription(value, specificDesc));
} }
// Return // Return
return Txt.implode(ret, " "); return Txt.implode(ret, " ");
@ -404,12 +404,12 @@ public class MFlag extends Entity<MFlag> implements Prioritized, Registerable, N
private ChatColor getStateColor() { private ChatColor getStateColor() {
// Is special? // Is special?
if (!this.isVisible()) { if (!this.isVisible()) {
return ChatColor.GRAY; return ChatColor.GRAY;
} }
if (this.isEditable()) { if (this.isEditable()) {
return ChatColor.LIGHT_PURPLE; return ChatColor.LIGHT_PURPLE;
} }
// Return normal // Return normal
return ChatColor.AQUA; return ChatColor.AQUA;
@ -420,9 +420,9 @@ public class MFlag extends Entity<MFlag> implements Prioritized, Registerable, N
String desc = this.getDesc(); String desc = this.getDesc();
// Is specific? // Is specific?
if (specific) { if (specific) {
desc = value ? this.getDescYes() : this.getDescNo(); desc = value ? this.getDescYes() : this.getDescNo();
} }
// Return // Return
return Txt.parse("<i>%s", desc); return Txt.parse("<i>%s", desc);

View File

@ -36,9 +36,9 @@ public class MFlagColl extends Coll<MFlag> {
@Override @Override
public void setActive(boolean active) { public void setActive(boolean active) {
super.setActive(active); super.setActive(active);
if (!active) { if (!active) {
return; return;
} }
MFlag.setupStandardFlags(); MFlag.setupStandardFlags();
} }
@ -52,9 +52,9 @@ public class MFlagColl extends Coll<MFlag> {
// Fill // Fill
for (MFlag mflag : this.getAll()) { for (MFlag mflag : this.getAll()) {
if (mflag.isRegistered() != registered) { if (mflag.isRegistered() != registered) {
continue; continue;
} }
ret.add(mflag); 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) { public String createDeniedMessage(MPlayer mplayer, Faction hostFaction) {
// Null Check // Null Check
if (mplayer == null) { if (mplayer == null) {
throw new NullPointerException("mplayer"); throw new NullPointerException("mplayer");
} }
if (hostFaction == null) { if (hostFaction == null) {
throw new NullPointerException("hostFaction"); throw new NullPointerException("hostFaction");
} }
String ret = Txt.parse("%s<b> does not allow you to %s<b>.", hostFaction.describeTo(mplayer, true), this.getDesc()); 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) { public boolean has(Faction faction, Faction hostFaction) {
// Null Check // Null Check
if (faction == null) { if (faction == null) {
throw new NullPointerException("faction"); throw new NullPointerException("faction");
} }
if (hostFaction == null) { if (hostFaction == null) {
throw new NullPointerException("hostFaction"); throw new NullPointerException("hostFaction");
} }
return hostFaction.isFactionPermitted(faction, this); return hostFaction.isFactionPermitted(faction, this);
} }
public boolean has(MPlayer mplayer, Faction hostFaction, boolean verboose) { public boolean has(MPlayer mplayer, Faction hostFaction, boolean verboose) {
// Null Check // Null Check
if (mplayer == null) { if (mplayer == null) {
throw new NullPointerException("mplayer"); throw new NullPointerException("mplayer");
} }
if (hostFaction == null) { if (hostFaction == null) {
throw new NullPointerException("hostFaction"); throw new NullPointerException("hostFaction");
} }
if (mplayer.isOverriding()) { if (mplayer.isOverriding()) {
return true; return true;
} }
Rel rel = mplayer.getRelationTo(hostFaction); Rel rel = mplayer.getRelationTo(hostFaction);
MPermable permable = rel == Rel.FACTION ? mplayer.getRank() : rel; MPermable permable = rel == Rel.FACTION ? mplayer.getRank() : rel;
if (hostFaction.isPlayerPermitted(mplayer, this)) { if (hostFaction.isPlayerPermitted(mplayer, this)) {
return true; return true;
} }
if (verboose) { if (verboose) {
mplayer.message(this.createDeniedMessage(mplayer, hostFaction)); mplayer.message(this.createDeniedMessage(mplayer, hostFaction));
} }
return false; return false;
} }
public boolean has(MPlayer mplayer, PS ps, boolean verboose) { public boolean has(MPlayer mplayer, PS ps, boolean verboose) {
// Null Check // Null Check
if (mplayer == null) { if (mplayer == null) {
throw new NullPointerException("mplayer"); throw new NullPointerException("mplayer");
} }
if (ps == null) { if (ps == null) {
throw new NullPointerException("ps"); throw new NullPointerException("ps");
} }
if (mplayer.isOverriding()) { if (mplayer.isOverriding()) {
return true; return true;
} }
TerritoryAccess ta = BoardColl.get().getTerritoryAccessAt(ps); TerritoryAccess ta = BoardColl.get().getTerritoryAccessAt(ps);
Faction hostFaction = ta.getHostFaction(); 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) { public static List<MPermable> getPermables(Faction faction) {
if (faction == null) { if (faction == null) {
throw new NullPointerException("faction"); throw new NullPointerException("faction");
} }
List<MPermable> list = new MassiveList<>(); 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) { public static Optional<MPermable> idToMPermableOptional(String id) {
MPlayer mplayer = MPlayerColl.get().get(id, false); MPlayer mplayer = MPlayerColl.get().get(id, false);
if (mplayer != null) { if (mplayer != null) {
return Optional.of(mplayer); return Optional.of(mplayer);
} }
// Workaround for registered senders // Workaround for registered senders
// Players ussually have a power, which makes sure they are in the coll // Players ussually have a power, which makes sure they are in the coll
if (IdUtil.getRegistryIdToSender().containsKey(id)) { if (IdUtil.getRegistryIdToSender().containsKey(id)) {
return Optional.of(MPlayerColl.get().get(id, true)); return Optional.of(MPlayerColl.get().get(id, true));
} }
Faction faction = Faction.get(id); Faction faction = Faction.get(id);
if (faction != null) { if (faction != null) {
return Optional.of(faction); return Optional.of(faction);
} }
for (Faction f : FactionColl.get().getAll()) { for (Faction f : FactionColl.get().getAll()) {
Rank rank = f.getRank(id); Rank rank = f.getRank(id);
if (rank != null) { if (rank != null) {
return Optional.of(rank); return Optional.of(rank);
} }
} }
if (Rel.ALLY.name().equalsIgnoreCase(id)) { if (Rel.ALLY.name().equalsIgnoreCase(id)) {
return Optional.of(Rel.ALLY); return Optional.of(Rel.ALLY);
} }
if (Rel.TRUCE.name().equalsIgnoreCase(id)) { if (Rel.TRUCE.name().equalsIgnoreCase(id)) {
return Optional.of(Rel.TRUCE); return Optional.of(Rel.TRUCE);
} }
if (Rel.NEUTRAL.name().equalsIgnoreCase(id)) { if (Rel.NEUTRAL.name().equalsIgnoreCase(id)) {
return Optional.of(Rel.NEUTRAL); return Optional.of(Rel.NEUTRAL);
} }
if (Rel.ENEMY.name().equalsIgnoreCase(id)) { if (Rel.ENEMY.name().equalsIgnoreCase(id)) {
return Optional.of(Rel.ENEMY); return Optional.of(Rel.ENEMY);
} }
return Optional.empty(); return Optional.empty();
} }

View File

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

View File

@ -80,24 +80,24 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
@Override @Override
public boolean isDefault() { 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. // 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()) { if (this.hasFaction()) {
return false; return false;
} }
// Role means nothing without a faction. // Role means nothing without a faction.
// Title means nothing without a faction. // Title means nothing without a faction.
if (this.hasPowerBoost()) { if (this.hasPowerBoost()) {
return false; return false;
} }
if (this.getPowerRounded() != (int) Math.round(MConf.get().defaultPlayerPower)) { if (this.getPowerRounded() != (int) Math.round(MConf.get().defaultPlayerPower)) {
return false; return false;
} }
// if (this.isMapAutoUpdating()) return false; // Just having an auto updating map is not in itself reason enough for database storage. // if (this.isMapAutoUpdating()) return false; // Just having an auto updating map is not in itself reason enough for database storage.
if (this.isOverriding()) { if (this.isOverriding()) {
return false; return false;
} }
if (this.isTerritoryInfoTitles() != MConf.get().territoryInfoTitlesDefault) { if (this.isTerritoryInfoTitles() != MConf.get().territoryInfoTitlesDefault) {
return false; return false;
} }
return true; return true;
} }
@ -194,16 +194,16 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
private transient WeakReference<Faction> autoClaimFaction = new WeakReference<>(null); private transient WeakReference<Faction> autoClaimFaction = new WeakReference<>(null);
public Faction getAutoClaimFaction() { public Faction getAutoClaimFaction() {
if (this.isFactionOrphan()) { if (this.isFactionOrphan()) {
return null; return null;
} }
Faction ret = this.autoClaimFaction.get(); Faction ret = this.autoClaimFaction.get();
if (ret == null) { if (ret == null) {
return null; return null;
} }
if (ret.detached()) { if (ret.detached()) {
return null; return null;
} }
return ret; return ret;
} }
@ -302,9 +302,9 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
String afterId = factionId; String afterId = factionId;
// NoChange // NoChange
if (MUtil.equals(beforeId, afterId)) { if (MUtil.equals(beforeId, afterId)) {
return; return;
} }
// Apply // Apply
this.factionId = afterId; this.factionId = afterId;
@ -325,13 +325,13 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
// -------------------------------------------- // // -------------------------------------------- //
public Rank getRank() { public Rank getRank() {
if (this.isFactionOrphan()) { if (this.isFactionOrphan()) {
return FactionColl.get().getNone().getLowestRank(); return FactionColl.get().getNone().getLowestRank();
} }
if (this.rankId == null) { if (this.rankId == null) {
return this.getFaction().getLowestRank(); return this.getFaction().getLowestRank();
} }
return this.getFaction().getRank(this.rankId); 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(); String rankId = rank == null ? null : rank.getId();
// Detect Nochange // Detect Nochange
if (MUtil.equals(this.rankId, rankId)) { if (MUtil.equals(this.rankId, rankId)) {
return; return;
} }
// Apply // Apply
this.rankId = rankId; this.rankId = rankId;
@ -362,13 +362,13 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
} }
public String getTitle() { public String getTitle() {
if (this.isFactionOrphan()) { if (this.isFactionOrphan()) {
return NOTITLE; return NOTITLE;
} }
if (this.hasTitle()) { if (this.hasTitle()) {
return this.title; return this.title;
} }
return NOTITLE; return NOTITLE;
} }
@ -378,9 +378,9 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
String target = Faction.clean(title); String target = Faction.clean(title);
// Detect Nochange // Detect Nochange
if (MUtil.equals(this.title, target)) { if (MUtil.equals(this.title, target)) {
return; return;
} }
// Apply // Apply
this.title = target; this.title = target;
@ -396,9 +396,9 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
@Override @Override
public double getPowerBoost() { public double getPowerBoost() {
Double ret = this.powerBoost; Double ret = this.powerBoost;
if (ret == null) { if (ret == null) {
ret = 0D; ret = 0D;
} }
return ret; return ret;
} }
@ -406,14 +406,14 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
public void setPowerBoost(Double powerBoost) { public void setPowerBoost(Double powerBoost) {
// Clean input // Clean input
Double target = powerBoost; Double target = powerBoost;
if (target == null || target == 0) { if (target == null || target == 0) {
target = null; target = null;
} }
// Detect Nochange // Detect Nochange
if (MUtil.equals(this.powerBoost, target)) { if (MUtil.equals(this.powerBoost, target)) {
return; return;
} }
// Apply // Apply
this.powerBoost = target; this.powerBoost = target;
@ -482,9 +482,9 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
public double getPower() { public double getPower() {
Double ret = this.power; Double ret = this.power;
if (ret == null) { if (ret == null) {
ret = MConf.get().defaultPlayerPower; ret = MConf.get().defaultPlayerPower;
} }
ret = this.getLimitedPower(ret); ret = this.getLimitedPower(ret);
return ret; return ret;
} }
@ -494,9 +494,9 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
Double target = power; Double target = power;
// Detect Nochange // Detect Nochange
if (MUtil.equals(this.power, target)) { if (MUtil.equals(this.power, target)) {
return; return;
} }
// Apply // Apply
this.power = target; this.power = target;
@ -516,26 +516,26 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
// -------------------------------------------- // // -------------------------------------------- //
public boolean isMapAutoUpdating() { public boolean isMapAutoUpdating() {
if (this.mapAutoUpdating == null) { if (this.mapAutoUpdating == null) {
return false; return false;
} }
if (this.mapAutoUpdating == false) { if (this.mapAutoUpdating == false) {
return false; return false;
} }
return true; return true;
} }
public void setMapAutoUpdating(Boolean mapAutoUpdating) { public void setMapAutoUpdating(Boolean mapAutoUpdating) {
// Clean input // Clean input
Boolean target = mapAutoUpdating; Boolean target = mapAutoUpdating;
if (MUtil.equals(target, false)) { if (MUtil.equals(target, false)) {
target = null; target = null;
} }
// Detect Nochange // Detect Nochange
if (MUtil.equals(this.mapAutoUpdating, target)) { if (MUtil.equals(this.mapAutoUpdating, target)) {
return; return;
} }
// Apply // Apply
this.mapAutoUpdating = target; this.mapAutoUpdating = target;
@ -549,12 +549,12 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
// -------------------------------------------- // // -------------------------------------------- //
public boolean isOverriding() { public boolean isOverriding() {
if (this.overriding == null) { if (this.overriding == null) {
return false; return false;
} }
if (this.overriding == false) { if (this.overriding == false) {
return false; return false;
} }
if (!this.hasPermission(Perm.OVERRIDE, true)) { if (!this.hasPermission(Perm.OVERRIDE, true)) {
this.setOverriding(false); this.setOverriding(false);
@ -567,14 +567,14 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
public void setOverriding(Boolean overriding) { public void setOverriding(Boolean overriding) {
// Clean input // Clean input
Boolean target = overriding; Boolean target = overriding;
if (MUtil.equals(target, false)) { if (MUtil.equals(target, false)) {
target = null; target = null;
} }
// Detect Nochange // Detect Nochange
if (MUtil.equals(this.overriding, target)) { if (MUtil.equals(this.overriding, target)) {
return; return;
} }
// Apply // Apply
this.overriding = target; this.overriding = target;
@ -588,26 +588,26 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
// -------------------------------------------- // // -------------------------------------------- //
public boolean isTerritoryInfoTitles() { public boolean isTerritoryInfoTitles() {
if (!MixinTitle.get().isAvailable()) { if (!MixinTitle.get().isAvailable()) {
return false; return false;
} }
if (this.territoryInfoTitles == null) { if (this.territoryInfoTitles == null) {
return MConf.get().territoryInfoTitlesDefault; return MConf.get().territoryInfoTitlesDefault;
} }
return this.territoryInfoTitles; return this.territoryInfoTitles;
} }
public void setTerritoryInfoTitles(Boolean territoryInfoTitles) { public void setTerritoryInfoTitles(Boolean territoryInfoTitles) {
// Clean input // Clean input
Boolean target = territoryInfoTitles; Boolean target = territoryInfoTitles;
if (MUtil.equals(target, MConf.get().territoryInfoTitlesDefault)) { if (MUtil.equals(target, MConf.get().territoryInfoTitlesDefault)) {
target = null; target = null;
} }
// Detect Nochange // Detect Nochange
if (MUtil.equals(this.territoryInfoTitles, target)) { if (MUtil.equals(this.territoryInfoTitles, target)) {
return; return;
} }
// Apply // Apply
this.territoryInfoTitles = target; this.territoryInfoTitles = target;
@ -634,9 +634,9 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
public String getFactionName() { public String getFactionName() {
Faction faction = this.getFaction(); Faction faction = this.getFaction();
if (faction.isNone()) { if (faction.isNone()) {
return ""; return "";
} }
return faction.getName(); return faction.getName();
} }
@ -725,17 +725,17 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
public boolean isInOwnTerritory() { public boolean isInOwnTerritory() {
PS ps = MixinSenderPs.get().getSenderPs(this.getId()); PS ps = MixinSenderPs.get().getSenderPs(this.getId());
if (ps == null) { if (ps == null) {
return false; return false;
} }
return BoardColl.get().getFactionAt(ps) == this.getFaction(); return BoardColl.get().getFactionAt(ps) == this.getFaction();
} }
public boolean isInEnemyTerritory() { public boolean isInEnemyTerritory() {
PS ps = MixinSenderPs.get().getSenderPs(this.getId()); PS ps = MixinSenderPs.get().getSenderPs(this.getId());
if (ps == null) { if (ps == null) {
return false; return false;
} }
return BoardColl.get().getFactionAt(ps).getRelationTo(this) == Rel.ENEMY; return BoardColl.get().getFactionAt(ps).getRelationTo(this) == Rel.ENEMY;
} }
@ -763,9 +763,9 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
// Event // Event
EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(this.getSender(), this, myFaction, MembershipChangeReason.LEAVE); EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(this.getSender(), this, myFaction, MembershipChangeReason.LEAVE);
membershipChangeEvent.run(); membershipChangeEvent.run();
if (membershipChangeEvent.isCancelled()) { if (membershipChangeEvent.isCancelled()) {
return; return;
} }
if (myFaction.isNormal()) { if (myFaction.isNormal()) {
for (MPlayer mplayer : myFaction.getMPlayersWhereOnline(true)) { 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) { public boolean tryClaim(Faction newFaction, Collection<PS> pss, String formatOne, String formatMany) {
// Args // Args
if (formatOne == null) { if (formatOne == null) {
formatOne = "<h>%s<i> %s <h>%d <i>chunk %s<i>."; formatOne = "<h>%s<i> %s <h>%d <i>chunk %s<i>.";
} }
if (formatMany == null) { if (formatMany == null) {
formatMany = "<h>%s<i> %s <h>%d <i>chunks near %s<i>."; formatMany = "<h>%s<i> %s <h>%d <i>chunks near %s<i>.";
} }
if (newFaction == null) { if (newFaction == null) {
throw new NullPointerException("newFaction"); throw new NullPointerException("newFaction");
} }
if (pss == null) { if (pss == null) {
throw new NullPointerException("pss"); throw new NullPointerException("pss");
} }
final Set<PS> chunks = PS.getDistinctChunks(pss); final Set<PS> chunks = PS.getDistinctChunks(pss);
// NoChange // NoChange
@ -840,9 +840,9 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
} }
EventFactionsChunksChange event = new EventFactionsChunksChange(sender, chunks, newFaction); EventFactionsChunksChange event = new EventFactionsChunksChange(sender, chunks, newFaction);
event.run(); event.run();
if (event.isCancelled()) { if (event.isCancelled()) {
return false; return false;
} }
// Apply // Apply
for (PS chunk : chunks) { 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) { public static Set<MPlayer> getClaimInformees(MPlayer msender, Faction... factions) {
Set<MPlayer> ret = new HashSet<>(); Set<MPlayer> ret = new HashSet<>();
if (msender != null) { if (msender != null) {
ret.add(msender); ret.add(msender);
} }
for (Faction faction : factions) { for (Faction faction : factions) {
if (faction == null) { if (faction == null) {
continue; continue;
} }
if (faction.isNone()) { if (faction.isNone()) {
continue; continue;
} }
ret.addAll(faction.getMPlayers()); 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 (Faction f : FactionColl.get().getAll()) {
for (Entry<String, Set<String>> entry : f.getPerms().entrySet()) { for (Entry<String, Set<String>> entry : f.getPerms().entrySet()) {
Set<String> value = entry.getValue(); Set<String> value = entry.getValue();
if (value == null) { if (value == null) {
throw new NullPointerException(entry.getKey()); throw new NullPointerException(entry.getKey());
} }
value.remove(id); value.remove(id);
} }
} }
@ -119,46 +119,46 @@ public class Rank extends EntityInternal<Rank> implements MPerm.MPermable {
// -------------------------------------------- // // -------------------------------------------- //
public boolean isLessThan(Rank otherRank) { public boolean isLessThan(Rank otherRank) {
if (this.getContainer() != otherRank.getContainer()) { if (this.getContainer() != otherRank.getContainer()) {
throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId()); throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId());
} }
return this.getPriority() < otherRank.getPriority(); return this.getPriority() < otherRank.getPriority();
} }
public boolean isMoreThan(Rank otherRank) { public boolean isMoreThan(Rank otherRank) {
if (this.getContainer() != otherRank.getContainer()) { if (this.getContainer() != otherRank.getContainer()) {
throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId()); throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId());
} }
return this.getPriority() > otherRank.getPriority(); return this.getPriority() > otherRank.getPriority();
} }
public boolean isAtLeast(Rank otherRank) { public boolean isAtLeast(Rank otherRank) {
if (this.getContainer() != otherRank.getContainer()) { if (this.getContainer() != otherRank.getContainer()) {
throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId()); throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId());
} }
return this.getPriority() >= otherRank.getPriority(); return this.getPriority() >= otherRank.getPriority();
} }
public boolean isAtMost(Rank otherRank) { public boolean isAtMost(Rank otherRank) {
if (this.getContainer() != otherRank.getContainer()) { if (this.getContainer() != otherRank.getContainer()) {
throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId()); throw new IllegalArgumentException(this.getId() + " : " + otherRank.getId());
} }
return this.getPriority() <= otherRank.getPriority(); return this.getPriority() <= otherRank.getPriority();
} }
public boolean isLeader() { public boolean isLeader() {
for (Rank otherRank : this.getContainer().getAll()) { for (Rank otherRank : this.getContainer().getAll()) {
if (otherRank == this) { if (otherRank == this) {
continue; continue;
} }
if (otherRank.isMoreThan(this)) { if (otherRank.isMoreThan(this)) {
return false; return false;
} }
} }
return true; return true;
} }
@ -166,15 +166,15 @@ public class Rank extends EntityInternal<Rank> implements MPerm.MPermable {
public Rank getRankAbove() { public Rank getRankAbove() {
Rank ret = null; Rank ret = null;
for (Rank otherRank : this.getContainer().getAll()) { for (Rank otherRank : this.getContainer().getAll()) {
if (otherRank == this) { if (otherRank == this) {
continue; continue;
} }
if (otherRank.isLessThan(this)) { if (otherRank.isLessThan(this)) {
continue; continue;
} }
if (ret != null && ret.isLessThan(otherRank)) { if (ret != null && ret.isLessThan(otherRank)) {
continue; continue;
} }
ret = otherRank; ret = otherRank;
} }
@ -184,15 +184,15 @@ public class Rank extends EntityInternal<Rank> implements MPerm.MPermable {
public Rank getRankBelow() { public Rank getRankBelow() {
Rank ret = null; Rank ret = null;
for (Rank otherRank : this.getContainer().getAll()) { for (Rank otherRank : this.getContainer().getAll()) {
if (otherRank == this) { if (otherRank == this) {
continue; continue;
} }
if (otherRank.isMoreThan(this)) { if (otherRank.isMoreThan(this)) {
continue; continue;
} }
if (ret != null && ret.isMoreThan(otherRank)) { if (ret != null && ret.isMoreThan(otherRank)) {
continue; continue;
} }
ret = otherRank; ret = otherRank;
} }

View File

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

View File

@ -81,9 +81,9 @@ public class Warp extends EntityInternal<Warp> implements Named {
// -------------------------------------------- // // -------------------------------------------- //
public boolean verifyIsValid() { public boolean verifyIsValid() {
if (this.isValid()) { if (this.isValid()) {
return true; return true;
} }
Faction fac = this.getFaction(); Faction fac = this.getFaction();
this.detach(); 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()); 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) { public boolean isValidFor(Faction faction) {
if (!MConf.get().warpsMustBeInClaimedTerritory) { if (!MConf.get().warpsMustBeInClaimedTerritory) {
return true; return true;
} }
if (BoardColl.get().getFactionAt(this.getLocation()) == faction) { if (BoardColl.get().getFactionAt(this.getLocation()) == faction) {
return true; return true;
} }
return false; return false;
} }

View File

@ -44,9 +44,9 @@ public class MigratorFaction001Invitations extends MigratorRoot {
// If non-null // If non-null
if (!idList.isJsonNull()) { if (!idList.isJsonNull()) {
// ... and proper type ... // ... and proper type ...
if (!idList.isJsonArray()) { if (!idList.isJsonArray()) {
throw new IllegalArgumentException(idList.toString()); throw new IllegalArgumentException(idList.toString());
} }
// ... fill! // ... fill!
for (JsonElement playerId : idList.getAsJsonArray()) { 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<>(mperm.getStandard());
Set<String> value = new MassiveSet<>(MConf.get().perm2default.get(mperm.getId())); Set<String> value = new MassiveSet<>(MConf.get().perm2default.get(mperm.getId()));
if (value.remove("LEADER")) { if (value.remove("LEADER")) {
value.add(leaderId); value.add(leaderId);
} }
if (value.remove("OFFICER")) { if (value.remove("OFFICER")) {
value.add(officerId); value.add(officerId);
} }
if (value.remove("MEMBER")) { if (value.remove("MEMBER")) {
value.add(memberId); value.add(memberId);
} }
if (value.remove("RECRUIT")) { if (value.remove("RECRUIT")) {
value.add(recruitId); value.add(recruitId);
} }
ret.put(mperm.getId(), value); ret.put(mperm.getId(), value);
} }
@ -106,18 +106,18 @@ public class MigratorFaction002Ranks extends MigratorRoot {
} }
Set<String> value = entry.getValue(); Set<String> value = entry.getValue();
if (value.remove("LEADER")) { if (value.remove("LEADER")) {
value.add(leaderId); value.add(leaderId);
} }
if (value.remove("OFFICER")) { if (value.remove("OFFICER")) {
value.add(officerId); value.add(officerId);
} }
if (value.remove("MEMBER")) { if (value.remove("MEMBER")) {
value.add(memberId); value.add(memberId);
} }
if (value.remove("RECRUIT")) { if (value.remove("RECRUIT")) {
value.add(recruitId); value.add(recruitId);
} }
ret.put(id, value); ret.put(id, value);
} }
} }

View File

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

View File

@ -27,21 +27,21 @@ public class MigratorFaction004WarpsPerms extends MigratorRoot {
@Override @Override
public void migrateInner(JsonObject entity) { public void migrateInner(JsonObject entity) {
JsonElement perms = entity.get("perms"); JsonElement perms = entity.get("perms");
if (perms == null || perms.isJsonNull() || !perms.isJsonObject()) { if (perms == null || perms.isJsonNull() || !perms.isJsonObject()) {
return; return;
} }
JsonObject permsO = perms.getAsJsonObject(); JsonObject permsO = perms.getAsJsonObject();
JsonElement home = permsO.remove("home"); JsonElement home = permsO.remove("home");
if (home != null) { if (home != null) {
permsO.add("warp", home); permsO.add("warp", home);
} }
JsonElement sethome = permsO.remove("sethome"); JsonElement sethome = permsO.remove("sethome");
if (home != null) { if (home != null) {
permsO.add("setwarp", home); 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) { private void removeFromStringsField(JsonObject entity, String fieldName, Collection<String> removals) {
JsonElement stringsElement = entity.get(fieldName); JsonElement stringsElement = entity.get(fieldName);
if (!(stringsElement instanceof JsonArray)) { if (!(stringsElement instanceof JsonArray)) {
return; return;
} }
JsonArray strings = (JsonArray) stringsElement; JsonArray strings = (JsonArray) stringsElement;
for (Iterator<JsonElement> iterator = strings.iterator(); iterator.hasNext(); ) { for (Iterator<JsonElement> iterator = strings.iterator(); iterator.hasNext(); ) {
JsonElement stringElement = iterator.next(); JsonElement stringElement = iterator.next();
if (!(stringElement instanceof JsonPrimitive)) { if (!(stringElement instanceof JsonPrimitive)) {
continue; continue;
} }
JsonPrimitive string = (JsonPrimitive) stringElement; JsonPrimitive string = (JsonPrimitive) stringElement;
if (!removals.contains(string.getAsString())) { if (!removals.contains(string.getAsString())) {
continue; continue;
} }
iterator.remove(); iterator.remove();
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -43,9 +43,9 @@ public class MigratorTerritoryAccess001Restructure extends MigratorRoot {
grantedIds.addAll(playerIdsArr); grantedIds.addAll(playerIdsArr);
} }
if (grantedIds.size() > 0) { if (grantedIds.size() > 0) {
entity.add(TerritoryAccessAdapter.GRANTED_IDS, grantedIds); 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) { public static EventFactionsChunkChangeType get(Faction oldFaction, Faction newFaction, Faction self) {
if (newFaction == oldFaction) { if (newFaction == oldFaction) {
return NONE; return NONE;
} }
if (oldFaction.isNone()) { if (oldFaction.isNone()) {
return BUY; return BUY;
} }
if (newFaction.isNormal()) { if (newFaction.isNormal()) {
return CONQUER; return CONQUER;
} }
if (oldFaction == self) { if (oldFaction == self) {
return SELL; return SELL;
} }
return PILLAGE; return PILLAGE;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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