Better world feature sets.

This commit is contained in:
Olof Larsson 2014-09-17 22:29:33 +02:00
parent cf859f2e61
commit 07ab309e1c
4 changed files with 53 additions and 40 deletions

View File

@ -0,0 +1,33 @@
package com.massivecraft.factions;
import java.util.LinkedHashSet;
import java.util.Set;
import org.bukkit.World;
public class WorldExceptionSet
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
public boolean standard = true;
public Set<String> exceptions = new LinkedHashSet<String>();
// -------------------------------------------- //
// CONTAINS
// -------------------------------------------- //
public boolean contains(String world)
{
if (this.exceptions.contains(world)) return !this.standard;
return this.standard;
}
public boolean contains(World world)
{
return this.contains(world.getName());
}
}

View File

@ -6,7 +6,6 @@ import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeSet;
import java.util.UUID; import java.util.UUID;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -18,6 +17,7 @@ import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.FPerm; import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Rel; import com.massivecraft.factions.Rel;
import com.massivecraft.factions.WorldExceptionSet;
import com.massivecraft.factions.event.EventFactionsChunkChangeType; import com.massivecraft.factions.event.EventFactionsChunkChangeType;
import com.massivecraft.factions.integration.dynmap.DynmapStyle; import com.massivecraft.factions.integration.dynmap.DynmapStyle;
import com.massivecraft.factions.listeners.FactionsListenerChat; import com.massivecraft.factions.listeners.FactionsListenerChat;
@ -55,6 +55,21 @@ public class MConf extends Entity<MConf>
public List<String> aliasesF = MUtil.list("f"); public List<String> aliasesF = MUtil.list("f");
// -------------------------------------------- //
// WORLDS FEATURE ENABLED
// -------------------------------------------- //
public WorldExceptionSet worldsClaimingEnabled = new WorldExceptionSet();
public WorldExceptionSet worldsPowerLossEnabled = new WorldExceptionSet();
public WorldExceptionSet worldsPvpRulesEnabled = new WorldExceptionSet();
// -------------------------------------------- //
// DERPY OVERRIDES
// -------------------------------------------- //
// mainly for other plugins/mods that use a fake player to take actions, which shouldn't be subject to our protections
public Set<String> playersWhoBypassAllProtection = new LinkedHashSet<String>();
// -------------------------------------------- // // -------------------------------------------- //
// TASKS // TASKS
// -------------------------------------------- // // -------------------------------------------- //
@ -268,41 +283,6 @@ public class MConf extends Entity<MConf>
public String prefixMember = "+"; public String prefixMember = "+";
public String prefixRecruit = "-"; public String prefixRecruit = "-";
// -------------------------------------------- //
// DERPY OVERRIDES
// -------------------------------------------- //
// TODO: Should worldsNoPowerLoss rather be a bukkit permission node?
// TODO: These are derpy because they possibly use an invalid design approach.
// After universe support is added. Would some of these be removed?
// Could it also be more customizeable using some sort of permission lookup map?
// mainly for other plugins/mods that use a fake player to take actions, which shouldn't be subject to our protections
public Set<String> playersWhoBypassAllProtection = new LinkedHashSet<String>();
public Set<String> worldsNoClaiming = new LinkedHashSet<String>();
public Set<String> getWorldsNoClaiming()
{
Set<String> ret = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
ret.addAll(this.worldsNoClaiming);
return ret;
}
public Set<String> worldsNoPowerLoss = new LinkedHashSet<String>();
public Set<String> getWorldsNoPowerLoss()
{
Set<String> ret = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
ret.addAll(this.worldsNoPowerLoss);
return ret;
}
public Set<String> worldsIgnorePvP = new LinkedHashSet<String>();
public Set<String> getWorldsIgnlorePvP()
{
Set<String> ret = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
ret.addAll(this.worldsIgnorePvP);
return ret;
}
// -------------------------------------------- // // -------------------------------------------- //
// EXPLOITS // EXPLOITS
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -702,11 +702,11 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
return true; return true;
} }
if (!this.isUsingAdminMode()) if ( ! this.isUsingAdminMode())
{ {
if (newFaction.isNormal()) if (newFaction.isNormal())
{ {
if (mconf.getWorldsNoClaiming().contains(ps.getWorld())) if (!mconf.worldsClaimingEnabled.contains(ps.getWorld()))
{ {
msg("<b>Sorry, this world has land claiming disabled."); msg("<b>Sorry, this world has land claiming disabled.");
return false; return false;

View File

@ -201,7 +201,7 @@ public class FactionsListenerMain implements Listener
return; return;
} }
if (MConf.get().getWorldsNoPowerLoss().contains(player.getWorld().getName())) if (!MConf.get().worldsPowerLossEnabled.contains(player.getWorld()))
{ {
mplayer.msg("<i>You didn't lose any power due to the world you died in."); mplayer.msg("<i>You didn't lose any power due to the world you died in.");
return; return;
@ -342,7 +342,7 @@ public class FactionsListenerMain implements Listener
} }
// ... are PVP rules completely ignored in this world? ... // ... are PVP rules completely ignored in this world? ...
if (MConf.get().getWorldsIgnlorePvP().contains(defenderPs.getWorld())) return true; if (!MConf.get().worldsPvpRulesEnabled.contains(defenderPs.getWorld())) return true;
Faction defendFaction = udefender.getFaction(); Faction defendFaction = udefender.getFaction();
Faction attackFaction = uattacker.getFaction(); Faction attackFaction = uattacker.getFaction();