diff --git a/pom.xml b/pom.xml
index 0cc8c75b..2f7b8c2d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -71,6 +71,18 @@
false
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.7.0
+
+
+ 11
+
+
+
diff --git a/src/com/massivecraft/factions/Rel.java b/src/com/massivecraft/factions/Rel.java
index 965649d5..fc3d9922 100644
--- a/src/com/massivecraft/factions/Rel.java
+++ b/src/com/massivecraft/factions/Rel.java
@@ -1,6 +1,7 @@
package com.massivecraft.factions;
import com.massivecraft.factions.entity.MConf;
+import com.massivecraft.factions.entity.MPerm;
import com.massivecraft.massivecore.Colorized;
import com.massivecraft.massivecore.Named;
import com.massivecraft.massivecore.collections.MassiveSet;
@@ -9,7 +10,7 @@ import org.bukkit.ChatColor;
import java.util.Collections;
import java.util.Set;
-public enum Rel implements Colorized, Named
+public enum Rel implements Colorized, Named, MPerm.MPermable
{
// -------------------------------------------- //
// ENUM
@@ -34,8 +35,13 @@ public enum Rel implements Colorized, Named
"an ally", "allies", "an allied faction", "allied factions",
"Ally"
) { @Override public ChatColor getColor() { return MConf.get().colorAlly; } },
+
+ FACTION(
+ "your faction", "your faction", "your faction", "your faction",
+ "Faction"
+ ) { @Override public ChatColor getColor() { return MConf.get().colorMember; } },
- RECRUIT(
+ /*RECRUIT(
"a recruit in your faction", "recruits in your faction", "", "",
"Recruit"
) { @Override public String getPrefix() { return MConf.get().prefixRecruit; } },
@@ -53,7 +59,7 @@ public enum Rel implements Colorized, Named
LEADER(
"your faction leader", "your faction leader", "", "",
"Leader", "Admin", "Owner"
- ) { @Override public String getPrefix() { return MConf.get().prefixLeader; } },
+ ) { @Override public String getPrefix() { return MConf.get().prefixLeader; } },*/
// END OF LIST
;
@@ -102,6 +108,12 @@ public enum Rel implements Colorized, Named
{
return MConf.get().colorMember;
}
+
+ @Override
+ public String getId()
+ {
+ return name();
+ }
// -------------------------------------------- //
// UTIL
@@ -126,12 +138,7 @@ public enum Rel implements Colorized, Named
{
return this.getValue() > rel.getValue();
}
-
- public boolean isRank()
- {
- return this.isAtLeast(Rel.RECRUIT);
- }
-
+
// Used for friendly fire.
public boolean isFriend()
{
diff --git a/src/com/massivecraft/factions/adapter/RelAdapter.java b/src/com/massivecraft/factions/adapter/RelAdapter.java
index 80362ee9..ebe61f12 100644
--- a/src/com/massivecraft/factions/adapter/RelAdapter.java
+++ b/src/com/massivecraft/factions/adapter/RelAdapter.java
@@ -35,6 +35,11 @@ public class RelAdapter implements JsonDeserializer
{
return null;
}
+ catch (Exception ex)
+ {
+ System.out.println(json);
+ throw ex;
+ }
}
}
diff --git a/src/com/massivecraft/factions/chat/tag/ChatTagRole.java b/src/com/massivecraft/factions/chat/tag/ChatTagRole.java
index 4b2f3df9..ec9868e1 100644
--- a/src/com/massivecraft/factions/chat/tag/ChatTagRole.java
+++ b/src/com/massivecraft/factions/chat/tag/ChatTagRole.java
@@ -25,7 +25,7 @@ public class ChatTagRole extends ChatTag
// Get entities
MPlayer usender = MPlayer.get(sender);
- return Txt.upperCaseFirst(usender.getRole().toString().toLowerCase());
+ return Txt.upperCaseFirst(usender.getRank().getName().toLowerCase());
}
}
diff --git a/src/com/massivecraft/factions/chat/tag/ChatTagRoleprefix.java b/src/com/massivecraft/factions/chat/tag/ChatTagRoleprefix.java
index da491d92..ac61fca0 100644
--- a/src/com/massivecraft/factions/chat/tag/ChatTagRoleprefix.java
+++ b/src/com/massivecraft/factions/chat/tag/ChatTagRoleprefix.java
@@ -29,7 +29,7 @@ public class ChatTagRoleprefix extends ChatTag
Faction faction = usender.getFaction();
if (faction.isNone()) return "";
- return usender.getRole().getPrefix();
+ return usender.getRank().getPrefix();
}
}
diff --git a/src/com/massivecraft/factions/chat/tag/ChatTagRoleprefixforce.java b/src/com/massivecraft/factions/chat/tag/ChatTagRoleprefixforce.java
index f54c407e..80122fcb 100644
--- a/src/com/massivecraft/factions/chat/tag/ChatTagRoleprefixforce.java
+++ b/src/com/massivecraft/factions/chat/tag/ChatTagRoleprefixforce.java
@@ -24,7 +24,7 @@ public class ChatTagRoleprefixforce extends ChatTag
// Get entities
MPlayer usender = MPlayer.get(sender);
- return usender.getRole().getPrefix();
+ return usender.getRank().getPrefix();
}
}
diff --git a/src/com/massivecraft/factions/cmd/CmdFactions.java b/src/com/massivecraft/factions/cmd/CmdFactions.java
index c8e00672..b8b2c365 100644
--- a/src/com/massivecraft/factions/cmd/CmdFactions.java
+++ b/src/com/massivecraft/factions/cmd/CmdFactions.java
@@ -39,8 +39,6 @@ public class CmdFactions extends FactionsCommand
public CmdFactionsKick cmdFactionsKick = new CmdFactionsKick();
public CmdFactionsTitle cmdFactionsTitle = new CmdFactionsTitle();
public CmdFactionsRank cmdFactionsRank = new CmdFactionsRank();
- public CmdFactionsRankOld cmdFactionsRankOldPromote = new CmdFactionsRankOld("promote");
- public CmdFactionsRankOld cmdFactionsRankOldDemote = new CmdFactionsRankOld("demote");
public CmdFactionsMoney cmdFactionsMoney = new CmdFactionsMoney();
public CmdFactionsSeeChunk cmdFactionsSeeChunk = new CmdFactionsSeeChunk();
public CmdFactionsSeeChunkOld cmdFactionsSeeChunkOld = new CmdFactionsSeeChunkOld();
@@ -77,7 +75,7 @@ public class CmdFactions extends FactionsCommand
this.addChild(new MassiveCommandDeprecated(this.cmdFactionsUnclaim.cmdFactionsUnclaimAll, "unclaimall"));
this.addChild(new MassiveCommandDeprecated(this.cmdFactionsFlag, "open"));
this.addChild(new MassiveCommandDeprecated(this.cmdFactionsFaction, "show", "who"));
- this.addChild(new MassiveCommandDeprecated(this.cmdFactionsRank, "leader", "owner", "officer", "moderator"));
+ this.addChild(new MassiveCommandDeprecated(this.cmdFactionsRank, "leader", "owner", "officer", "moderator", "demote", "promote"));
}
// -------------------------------------------- //
diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsCreate.java b/src/com/massivecraft/factions/cmd/CmdFactionsCreate.java
index 3b0d352e..0be40103 100644
--- a/src/com/massivecraft/factions/cmd/CmdFactionsCreate.java
+++ b/src/com/massivecraft/factions/cmd/CmdFactionsCreate.java
@@ -1,7 +1,6 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Factions;
-import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqHasntFaction;
import com.massivecraft.factions.cmd.type.TypeFactionNameStrict;
import com.massivecraft.factions.entity.Faction;
@@ -55,7 +54,7 @@ public class CmdFactionsCreate extends FactionsCommand
Faction faction = FactionColl.get().create(factionId);
faction.setName(newName);
- msender.setRole(Rel.LEADER);
+ msender.setRank(faction.getLeaderRank());
msender.setFaction(faction);
EventFactionsMembershipChange joinEvent = new EventFactionsMembershipChange(sender, msender, faction, MembershipChangeReason.CREATE);
diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsJoin.java b/src/com/massivecraft/factions/cmd/CmdFactionsJoin.java
index 5c31a00d..d3355dcc 100644
--- a/src/com/massivecraft/factions/cmd/CmdFactionsJoin.java
+++ b/src/com/massivecraft/factions/cmd/CmdFactionsJoin.java
@@ -116,6 +116,7 @@ public class CmdFactionsJoin extends FactionsCommand
// Apply
mplayer.resetFactionData();
mplayer.setFaction(faction);
+ mplayer.setRank(faction.getLowestRank());
faction.uninvite(mplayer);
diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsKick.java b/src/com/massivecraft/factions/cmd/CmdFactionsKick.java
index 8fd55e2c..a374dfcf 100644
--- a/src/com/massivecraft/factions/cmd/CmdFactionsKick.java
+++ b/src/com/massivecraft/factions/cmd/CmdFactionsKick.java
@@ -1,7 +1,6 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Factions;
-import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.type.TypeMPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
@@ -44,17 +43,17 @@ public class CmdFactionsKick extends FactionsCommand
return;
}
- if (mplayer.getRole() == Rel.LEADER && !msender.isOverriding())
+ if (mplayer.getRank().isLeader() && !msender.isOverriding())
{
throw new MassiveException().addMsg("The leader cannot be kicked.");
}
- if (mplayer.getRole().isMoreThan(msender.getRole()) && ! msender.isOverriding())
+ if (mplayer.getRank().isMoreThan(msender.getRank()) && ! msender.isOverriding())
{
throw new MassiveException().addMsg("You can't kick people of higher rank than yourself.");
}
- if (mplayer.getRole() == msender.getRole() && ! msender.isOverriding())
+ if (mplayer.getRank() == msender.getRank() && ! msender.isOverriding())
{
throw new MassiveException().addMsg("You can't kick people of the same rank as yourself.");
}
@@ -88,7 +87,7 @@ public class CmdFactionsKick extends FactionsCommand
}
// Apply
- if (mplayer.getRole() == Rel.LEADER)
+ if (mplayer.getRank().isLeader())
{
mplayerFaction.promoteNewLeader();
}
diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPermSet.java b/src/com/massivecraft/factions/cmd/CmdFactionsPermSet.java
index d97feaf4..118de24d 100644
--- a/src/com/massivecraft/factions/cmd/CmdFactionsPermSet.java
+++ b/src/com/massivecraft/factions/cmd/CmdFactionsPermSet.java
@@ -1,10 +1,10 @@
package com.massivecraft.factions.cmd;
-import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.type.TypeFaction;
import com.massivecraft.factions.cmd.type.TypeMPerm;
-import com.massivecraft.factions.cmd.type.TypeRel;
+import com.massivecraft.factions.cmd.type.TypeMPermable;
import com.massivecraft.factions.entity.Faction;
+import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.MPerm;
import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.event.EventFactionsPermChange;
@@ -25,7 +25,7 @@ public class CmdFactionsPermSet extends FactionsCommand
{
// Parameters
this.addParameter(TypeMPerm.get(), "perm");
- this.addParameter(TypeRel.get(), "relation");
+ this.addParameter(TypeMPermable.get(), "relation");
this.addParameter(TypeBooleanYes.get(), "yes/no");
this.addParameter(TypeFaction.get(), "faction", "you");
}
@@ -38,10 +38,12 @@ public class CmdFactionsPermSet extends FactionsCommand
public void perform() throws MassiveException
{
// Args
- MPerm perm = this.readArg();
- Rel rel = this.readArg();
- Boolean value = this.readArg();
- Faction faction = this.readArg(msenderFaction);
+ MPerm perm = this.readArgAt(0);
+ Boolean value = this.readArgAt(2);
+ Faction faction = this.readArgAt(3, msenderFaction);
+
+ MPerm.MPermable permable = TypeMPermable.get(faction).read(this.argAt(1), sender);
+
// Do the sender have the right to change perms for this faction?
if ( ! MPerm.getPermPerms().has(msender, faction, true)) return;
@@ -54,25 +56,26 @@ public class CmdFactionsPermSet extends FactionsCommand
}
// Event
- EventFactionsPermChange event = new EventFactionsPermChange(sender, faction, perm, rel, value);
+ EventFactionsPermChange event = new EventFactionsPermChange(sender, faction, perm, permable, value);
event.run();
if (event.isCancelled()) return;
value = event.getNewValue();
+
+ // Apply
+ boolean change = faction.setPermitted(permable, perm, value);
// No change
- if (faction.getPermitted(perm).contains(rel) == value)
+ if (!change)
{
- msg("%s already has %s set to %s for %s.", faction.describeTo(msender), perm.getDesc(true, false), Txt.parse(value ? "YES" : "NOO"), rel.getColor() + rel.getDescPlayerMany());
+ msg("%s already has %s set to %s for %s.", faction.describeTo(msender), perm.getDesc(true, false), Txt.parse(value ? "YES" : "NOO"), permable.getColor() + permable.getName() + "s");
return;
}
-
- // Apply
- faction.setRelationPermitted(perm, rel, value);
+
// The following is to make sure the leader always has the right to change perms if that is our goal.
- if (perm == MPerm.getPermPerms() && MPerm.getPermPerms().getStandard().contains(Rel.LEADER))
+ if (perm == MPerm.getPermPerms() && MConf.get().defaultPermsLeader.contains(MPerm.ID_PERMS))
{
- faction.setRelationPermitted(MPerm.getPermPerms(), Rel.LEADER, true);
+ faction.setPermitted( faction.getLeaderRank(), MPerm.getPermPerms(), true);
}
// Create messages
@@ -80,8 +83,8 @@ public class CmdFactionsPermSet extends FactionsCommand
// Inform sender
messages.add(Txt.titleize("Perm for " + faction.describeTo(msender, true)));
- messages.add(MPerm.getStateHeaders());
- messages.add(Txt.parse(perm.getStateInfo(faction.getPermitted(perm), true)));
+ messages.add(MPerm.getStateHeaders(faction));
+ messages.add(Txt.parse(perm.getStateInfo(faction, true)));
message(messages);
// Inform faction (their message is slighly different)
diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPermShow.java b/src/com/massivecraft/factions/cmd/CmdFactionsPermShow.java
index 587ec9b9..944980e5 100644
--- a/src/com/massivecraft/factions/cmd/CmdFactionsPermShow.java
+++ b/src/com/massivecraft/factions/cmd/CmdFactionsPermShow.java
@@ -40,10 +40,10 @@ public class CmdFactionsPermShow extends FactionsCommand
List