More universe disabled checks.

This commit is contained in:
Olof Larsson 2013-04-25 13:25:15 +02:00
parent ac2c7c705c
commit 5047439756
58 changed files with 325 additions and 82 deletions

View File

@ -8,7 +8,7 @@ import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.massivecraft.factions.entity.UPlayer;
import org.bukkit.command.CommandSender;
/**
* The ChatFormater is a system offered by factions for tag parsing.
@ -102,7 +102,7 @@ public class ChatFormatter
// FORMAT
// -------------------------------------------- //
public static String format(String msg, UPlayer fsender, UPlayer frecipient)
public static String format(String msg, CommandSender sender, CommandSender recipient)
{
// We build the return value in this string buffer
StringBuffer ret = new StringBuffer();
@ -137,7 +137,7 @@ public class ChatFormatter
}
else
{
replacement = compute(tag, modifierIds, fsender, frecipient);
replacement = compute(tag, modifierIds, sender, recipient);
if (replacement == null)
{
// If a tag or modifier returns null it's the same as opting out.
@ -159,9 +159,9 @@ public class ChatFormatter
// TAG COMPUTE
// -------------------------------------------- //
public static String compute(ChatTag tag, List<String> modifierIds, UPlayer fsender, UPlayer frecipient)
public static String compute(ChatTag tag, List<String> modifierIds, CommandSender sender, CommandSender recipient)
{
String ret = tag.getReplacement(fsender, frecipient);
String ret = tag.getReplacement(sender, recipient);
if (ret == null) return null;
for (String modifierId : modifierIds)
@ -172,7 +172,7 @@ public class ChatFormatter
// Modify and ignore change if null.
// Modifier can't get or return null.
String modified = modifier.getModified(ret, fsender, frecipient);
String modified = modifier.getModified(ret, sender, recipient);
if (modified == null) continue;
ret = modified;

View File

@ -1,12 +1,11 @@
package com.massivecraft.factions.chat;
import com.massivecraft.factions.entity.UPlayer;
import org.bukkit.command.CommandSender;
public interface ChatModifier
{
public String getId();
public String getModified(String subject, UPlayer fsender, UPlayer frecipient);
public String getModified(String subject, CommandSender sender, CommandSender recipient);
public boolean register();
public boolean unregister();
}

View File

@ -1,11 +1,11 @@
package com.massivecraft.factions.chat;
import com.massivecraft.factions.entity.UPlayer;
import org.bukkit.command.CommandSender;
public interface ChatTag
{
public String getId();
public String getReplacement(UPlayer fsender, UPlayer frecipient);
public String getReplacement(CommandSender sender, CommandSender recipient);
public boolean register();
public boolean unregister();
}

View File

@ -1,7 +1,8 @@
package com.massivecraft.factions.chat.modifier;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.chat.ChatModifierAbstract;
import com.massivecraft.factions.entity.UPlayer;
public class ChatModifierLc extends ChatModifierAbstract
{
@ -18,7 +19,7 @@ public class ChatModifierLc extends ChatModifierAbstract
// -------------------------------------------- //
@Override
public String getModified(String subject, UPlayer fsender, UPlayer frecipient)
public String getModified(String subject, CommandSender sender, CommandSender recipient)
{
return subject.toLowerCase();
}

View File

@ -1,7 +1,8 @@
package com.massivecraft.factions.chat.modifier;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.chat.ChatModifierAbstract;
import com.massivecraft.factions.entity.UPlayer;
public class ChatModifierLp extends ChatModifierAbstract
@ -19,7 +20,7 @@ public class ChatModifierLp extends ChatModifierAbstract
// -------------------------------------------- //
@Override
public String getModified(String subject, UPlayer fsender, UPlayer frecipient)
public String getModified(String subject, CommandSender sender, CommandSender recipient)
{
if (subject.equals("")) return subject;
return " "+subject;

View File

@ -1,7 +1,8 @@
package com.massivecraft.factions.chat.modifier;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.chat.ChatModifierAbstract;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.mcore.util.Txt;
public class ChatModifierParse extends ChatModifierAbstract
@ -19,7 +20,7 @@ public class ChatModifierParse extends ChatModifierAbstract
// -------------------------------------------- //
@Override
public String getModified(String subject, UPlayer fsender, UPlayer frecipient)
public String getModified(String subject, CommandSender sender, CommandSender recipient)
{
return Txt.parse(subject);
}

View File

@ -1,7 +1,8 @@
package com.massivecraft.factions.chat.modifier;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.chat.ChatModifierAbstract;
import com.massivecraft.factions.entity.UPlayer;
public class ChatModifierRp extends ChatModifierAbstract
{
@ -18,7 +19,7 @@ public class ChatModifierRp extends ChatModifierAbstract
// -------------------------------------------- //
@Override
public String getModified(String subject, UPlayer fsender, UPlayer frecipient)
public String getModified(String subject, CommandSender sender, CommandSender recipient)
{
if (subject.equals("")) return subject;
return subject+" ";

View File

@ -1,7 +1,8 @@
package com.massivecraft.factions.chat.modifier;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.chat.ChatModifierAbstract;
import com.massivecraft.factions.entity.UPlayer;
public class ChatModifierUc extends ChatModifierAbstract
{
@ -18,7 +19,7 @@ public class ChatModifierUc extends ChatModifierAbstract
// -------------------------------------------- //
@Override
public String getModified(String subject, UPlayer fsender, UPlayer frecipient)
public String getModified(String subject, CommandSender sender, CommandSender recipient)
{
return subject.toUpperCase();
}

View File

@ -1,7 +1,8 @@
package com.massivecraft.factions.chat.modifier;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.chat.ChatModifierAbstract;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.mcore.util.Txt;
public class ChatModifierUcf extends ChatModifierAbstract
@ -19,7 +20,7 @@ public class ChatModifierUcf extends ChatModifierAbstract
// -------------------------------------------- //
@Override
public String getModified(String subject, UPlayer fsender, UPlayer frecipient)
public String getModified(String subject, CommandSender sender, CommandSender recipient)
{
return Txt.upperCaseFirst(subject);
}

View File

@ -1,5 +1,7 @@
package com.massivecraft.factions.chat.tag;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.chat.ChatTagAbstract;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.UConf;
@ -20,10 +22,15 @@ public class ChatTagName extends ChatTagAbstract
// -------------------------------------------- //
@Override
public String getReplacement(UPlayer fsender, UPlayer frecipient)
public String getReplacement(CommandSender sender, CommandSender recipient)
{
if (!UConf.get(fsender).enabled) return "";
Faction faction = fsender.getFaction();
// Check disabled
if (UConf.isDisabled(sender)) return "";
// Get entities
UPlayer usender = UPlayer.get(sender);
Faction faction = usender.getFaction();
if (faction.isNone()) return "";
return faction.getName();
}

View File

@ -1,5 +1,7 @@
package com.massivecraft.factions.chat.tag;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.chat.ChatTagAbstract;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.UConf;
@ -20,10 +22,15 @@ public class ChatTagNameforce extends ChatTagAbstract
// -------------------------------------------- //
@Override
public String getReplacement(UPlayer fsender, UPlayer frecipient)
public String getReplacement(CommandSender sender, CommandSender recipient)
{
if (!UConf.get(fsender).enabled) return "";
Faction faction = fsender.getFaction();
// Check disabled
if (UConf.isDisabled(sender)) return "";
// Get entities
UPlayer usender = UPlayer.get(sender);
Faction faction = usender.getFaction();
return faction.getName();
}

View File

@ -1,5 +1,7 @@
package com.massivecraft.factions.chat.tag;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.chat.ChatTagAbstract;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.entity.UPlayer;
@ -19,13 +21,18 @@ public class ChatTagRelcolor extends ChatTagAbstract
// -------------------------------------------- //
@Override
public String getReplacement(UPlayer fsender, UPlayer frecipient)
public String getReplacement(CommandSender sender, CommandSender recipient)
{
if (!UConf.get(fsender).enabled) return "";
if (recipient == null) return "";
if (frecipient == null) return "";
// Check disabled
if (UConf.isDisabled(sender)) return "";
// Get entities
UPlayer usender = UPlayer.get(sender);
UPlayer urecipient = UPlayer.get(recipient);
return frecipient.getRelationTo(fsender).getColor().toString();
return urecipient.getRelationTo(usender).getColor().toString();
}
}

View File

@ -1,5 +1,7 @@
package com.massivecraft.factions.chat.tag;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.chat.ChatTagAbstract;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.entity.UPlayer;
@ -20,11 +22,15 @@ public class ChatTagRole extends ChatTagAbstract
// -------------------------------------------- //
@Override
public String getReplacement(UPlayer fsender, UPlayer frecipient)
public String getReplacement(CommandSender sender, CommandSender recipient)
{
if (!UConf.get(fsender).enabled) return "";
// Check disabled
if (UConf.isDisabled(sender)) return "";
return Txt.upperCaseFirst(fsender.getRole().toString().toLowerCase());
// Get entities
UPlayer usender = UPlayer.get(sender);
return Txt.upperCaseFirst(usender.getRole().toString().toLowerCase());
}
}

View File

@ -1,5 +1,7 @@
package com.massivecraft.factions.chat.tag;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.chat.ChatTagAbstract;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.entity.UPlayer;
@ -19,11 +21,15 @@ public class ChatTagRoleprefix extends ChatTagAbstract
// -------------------------------------------- //
@Override
public String getReplacement(UPlayer fsender, UPlayer frecipient)
public String getReplacement(CommandSender sender, CommandSender recipient)
{
if (!UConf.get(fsender).enabled) return "";
// Check disabled
if (UConf.isDisabled(sender)) return "";
return fsender.getRole().getPrefix();
// Get entities
UPlayer usender = UPlayer.get(sender);
return usender.getRole().getPrefix();
}
}

View File

@ -1,5 +1,7 @@
package com.massivecraft.factions.chat.tag;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.chat.ChatTagAbstract;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.entity.UPlayer;
@ -19,12 +21,16 @@ public class ChatTagTitle extends ChatTagAbstract
// -------------------------------------------- //
@Override
public String getReplacement(UPlayer fsender, UPlayer frecipient)
public String getReplacement(CommandSender sender, CommandSender recipient)
{
if (!UConf.get(fsender).enabled) return "";
// Check disabled
if (UConf.isDisabled(sender)) return "";
if (!fsender.hasTitle()) return "";
return fsender.getTitle();
// Get entities
UPlayer usender = UPlayer.get(sender);
if (!usender.hasTitle()) return "";
return usender.getTitle();
}
}

View File

@ -5,6 +5,7 @@ import com.massivecraft.factions.Perm;
import com.massivecraft.factions.TerritoryAccess;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
@ -25,12 +26,13 @@ public class CmdFactionsAccess extends FCommand
this.setDesc("view or grant access for the claimed territory you are in");
// TODO: Missing permission node here!?
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqIsPlayer.get());
}
@Override
public void perform()
{
{
String type = this.arg(0);
type = (type == null) ? "" : type.toLowerCase();
PS chunk = PS.valueOf(me).getChunk(true);

View File

@ -13,26 +13,27 @@ public class CmdFactionsAdmin extends FCommand
this.addOptionalArg("on/off", "flip");
//this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.ADMIN.node));
}
@Override
public void perform()
{
Boolean target = this.arg(0, ARBoolean.get(), !usender.isUsingAdminMode());
{
Boolean target = this.arg(0, ARBoolean.get(), !msender.isUsingAdminMode());
if (target == null) return;
usender.setUsingAdminMode(target);
msender.setUsingAdminMode(target);
if ( usender.isUsingAdminMode())
if (msender.isUsingAdminMode())
{
usender.msg("<i>You have enabled admin bypass mode.");
Factions.get().log(usender.getName() + " has ENABLED admin bypass mode.");
msender.msg("<i>You have enabled admin bypass mode.");
Factions.get().log(msender.getId() + " has ENABLED admin bypass mode.");
}
else
{
usender.msg("<i>You have disabled admin bypass mode.");
Factions.get().log(usender.getName() + " DISABLED admin bypass mode.");
msender.msg("<i>You have disabled admin bypass mode.");
Factions.get().log(msender.getId() + " DISABLED admin bypass mode.");
}
}
}

View File

@ -3,7 +3,9 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
import com.massivecraft.mcore.ps.PS;
@ -16,6 +18,7 @@ public class CmdFactionsAutoClaim extends FCommand
this.addOptionalArg("faction", "you");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.AUTOCLAIM.node));
this.addRequirements(ReqIsPlayer.get());
}
@ -23,7 +26,12 @@ public class CmdFactionsAutoClaim extends FCommand
@Override
public void perform()
{
// Check disabled
if (UConf.isDisabled(sender, sender)) return;
// Args
Faction forFaction = this.arg(0, ARFaction.get(usenderFaction), usenderFaction);
if (forFaction == null || forFaction == usender.getAutoClaimFaction())
{
usender.setAutoClaimFaction(null);

View File

@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.task.SpiralTask;
@ -22,13 +23,14 @@ public class CmdFactionsClaim extends FCommand
this.addOptionalArg("radius", "1");
this.addOptionalArg("faction", "you");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.CLAIM.node));
this.addRequirements(ReqIsPlayer.get());
}
@Override
public void perform()
{
{
// Args
Integer radius = this.arg(0, ARInteger.get(), 1);
if (radius == null) return;

View File

@ -5,6 +5,7 @@ import java.util.ArrayList;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.UPlayerColls;
import com.massivecraft.factions.entity.Faction;
@ -24,12 +25,13 @@ public class CmdFactionsCreate extends FCommand
this.addRequiredArg("name");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.CREATE.node));
}
@Override
public void perform()
{
{
// Args
String newName = this.arg(0);

View File

@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
@ -15,6 +16,7 @@ public class CmdFactionsDemote extends FCommand
this.addRequiredArg("player");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.DEMOTE.node));
//To demote someone from member -> recruit you must be an officer.
@ -24,7 +26,7 @@ public class CmdFactionsDemote extends FCommand
@Override
public void perform()
{
{
UPlayer you = this.arg(0, ARUPlayer.getStartAny(usender));
if (you == null) return;

View File

@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.event.FactionsEventDescriptionChange;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
@ -16,13 +17,14 @@ public class CmdFactionsDescription extends FCommand
this.addRequiredArg("desc");
this.setErrorOnToManyArgs(false);
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.DESCRIPTION.node));
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
}
@Override
public void perform()
{
{
// Args
String newDescription = this.argConcatFrom(0);

View File

@ -1,6 +1,7 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.UPlayerColls;
import com.massivecraft.factions.entity.Faction;
@ -22,13 +23,14 @@ public class CmdFactionsDisband extends FCommand
this.addAliases("disband");
this.addOptionalArg("faction", "you");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.DISBAND.node));
}
@Override
public void perform()
{
{
// Args
Faction faction = this.arg(0, ARFaction.get(usender), usenderFaction);
if (faction == null) return;

View File

@ -4,6 +4,7 @@ import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFFlag;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.mcore.cmd.arg.ARBoolean;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
@ -20,12 +21,13 @@ public class CmdFactionsFlag extends FCommand
this.addOptionalArg("flag", "all");
this.addOptionalArg("yes/no", "read");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.FLAG.node));
}
@Override
public void perform()
{
{
Faction faction = this.arg(0, ARFaction.get(sender), usenderFaction);
if (faction == null) return;

View File

@ -8,6 +8,7 @@ import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.factions.entity.UConf;
@ -28,6 +29,7 @@ public class CmdFactionsHome extends FCommand
this.addAliases("home");
this.addRequirements(ReqHasPerm.get(Perm.HOME.node));
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqIsPlayer.get());
this.addRequirements(ReqRoleIsAtLeast.get(Rel.RECRUIT));
}

View File

@ -4,6 +4,7 @@ import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.event.FactionsEventInvitedChange;
import com.massivecraft.mcore.cmd.arg.ARBoolean;
@ -19,6 +20,7 @@ public class CmdFactionsInvite extends FCommand
this.addRequiredArg("player");
this.addOptionalArg("yes/no", "toggle");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.INVITE.node));
this.addRequirements(ReqIsPlayer.get());
}

View File

@ -4,6 +4,7 @@ import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf;
@ -21,6 +22,7 @@ public class CmdFactionsJoin extends FCommand
this.addRequiredArg("faction");
this.addOptionalArg("player", "you");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.JOIN.node));
}

View File

@ -5,6 +5,7 @@ import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColls;
@ -23,6 +24,7 @@ public class CmdFactionsKick extends FCommand
this.addRequiredArg("player");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.KICK.node));
}

View File

@ -4,6 +4,7 @@ import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.UPlayerColls;
import com.massivecraft.factions.entity.Faction;
@ -22,6 +23,7 @@ public class CmdFactionsLeader extends FCommand
this.addRequiredArg("player");
this.addOptionalArg("faction", "you");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.LEADER.node));
}

View File

@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
@ -11,6 +12,7 @@ public class CmdFactionsLeave extends FCommand {
{
this.addAliases("leave");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.LEAVE.node));
this.addRequirements(ReqRoleIsAtLeast.get(Rel.RECRUIT));
}

View File

@ -5,6 +5,7 @@ import java.util.List;
import com.massivecraft.factions.FactionListComparator;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.mcore.cmd.arg.ARInteger;
@ -14,13 +15,13 @@ import com.massivecraft.mcore.util.Txt;
public class CmdFactionsList extends FCommand
{
public CmdFactionsList()
{
this.addAliases("ls", "list");
this.addOptionalArg("page", "1");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.LIST.node));
}

View File

@ -1,6 +1,7 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.mcore.cmd.arg.ARBoolean;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
@ -15,6 +16,7 @@ public class CmdFactionsMap extends FCommand
this.addOptionalArg("on/off", "once");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.MAP.node));
this.addRequirements(ReqIsPlayer.get());
}

View File

@ -4,6 +4,7 @@ import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.integration.Econ;
@ -17,7 +18,6 @@ import org.bukkit.ChatColor;
public class CmdFactionsMoneyDeposit extends FCommand
{
public CmdFactionsMoneyDeposit()
{
this.addAliases("d", "deposit");
@ -25,6 +25,7 @@ public class CmdFactionsMoneyDeposit extends FCommand
this.addRequiredArg("amount");
this.addOptionalArg("faction", "you");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.MONEY_DEPOSIT.node));
this.addRequirements(ReqBankCommandsEnabled.get());
}

View File

@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.Factions;
@ -25,6 +26,7 @@ public class CmdFactionsMoneyTransferFf extends FCommand
this.addRequiredArg("faction");
this.addRequiredArg("faction");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.MONEY_F2F.node));
this.addRequirements(ReqBankCommandsEnabled.get());
}

View File

@ -4,6 +4,7 @@ import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf;
@ -27,6 +28,7 @@ public class CmdFactionsMoneyTransferFp extends FCommand
this.addRequiredArg("faction");
this.addRequiredArg("player");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.MONEY_F2P.node));
this.addRequirements(ReqBankCommandsEnabled.get());
}

View File

@ -4,6 +4,7 @@ import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf;
@ -27,6 +28,7 @@ public class CmdFactionsMoneyTransferPf extends FCommand
this.addRequiredArg("player");
this.addRequiredArg("faction");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.MONEY_P2F.node));
this.addRequirements(ReqBankCommandsEnabled.get());
}

View File

@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf;
@ -25,6 +26,7 @@ public class CmdFactionsMoneyWithdraw extends FCommand
this.addRequiredArg("amount");
this.addOptionalArg("faction", "you");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.MONEY_WITHDRAW.node));
this.addRequirements(ReqBankCommandsEnabled.get());
}

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
@ -14,13 +15,13 @@ import com.massivecraft.mcore.cmd.req.ReqHasPerm;
public class CmdFactionsName extends FCommand
{
public CmdFactionsName()
{
this.addAliases("name");
this.addRequiredArg("new name");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.NAME.node));
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
}

View File

@ -3,19 +3,20 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
public class CmdFactionsOfficer extends FCommand
{
public CmdFactionsOfficer()
{
this.addAliases("officer");
this.addRequiredArg("player");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.OFFICER.node));
}

View File

@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.event.FactionsEventOpenChange;
import com.massivecraft.mcore.cmd.arg.ARBoolean;
@ -15,6 +16,7 @@ public class CmdFactionsOpen extends FCommand
this.addOptionalArg("yes/no", "toggle");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.OPEN.node));
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
}

View File

@ -6,6 +6,7 @@ import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARFPerm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.arg.ARRel;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.mcore.cmd.arg.ARBoolean;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
@ -23,6 +24,7 @@ public class CmdFactionsPerm extends FCommand
this.addOptionalArg("yes/no", "read");
this.setErrorOnToManyArgs(false);
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.PERM.node));
}

View File

@ -4,6 +4,7 @@ import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.mcore.cmd.arg.ARDouble;
@ -19,6 +20,7 @@ public class CmdFactionsPowerBoost extends FCommand
this.addRequiredArg("name");
this.addRequiredArg("#");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.POWERBOOST.node));
}

View File

@ -3,18 +3,19 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
public class CmdFactionsPromote extends FCommand
{
public CmdFactionsPromote()
{
this.addAliases("promote");
this.addRequiredArg("player");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.PROMOTE.node));
//To promote someone from recruit -> member you must be an officer.

View File

@ -5,6 +5,7 @@ import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.event.FactionsEventRelationChange;
@ -16,6 +17,7 @@ public abstract class CmdFactionsRelationAbstract extends FCommand
public CmdFactionsRelationAbstract()
{
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.RELATION.node));
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
}

View File

@ -16,6 +16,7 @@ public class CmdFactionsSeeChunk extends FCommand
{
this.addAliases("sc", "seechunk");
//this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.SEE_CHUNK.node));
this.addRequirements(ReqIsPlayer.get());
}

View File

@ -7,6 +7,7 @@ import java.util.List;
import java.util.Map;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
@ -30,6 +31,7 @@ public class CmdFactionsShow extends FCommand
this.addOptionalArg("faction", "you");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.SHOW.node));
}

View File

@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.event.FactionsEventTitleChange;
@ -18,6 +19,7 @@ public class CmdFactionsTitle extends FCommand
this.addRequiredArg("player");
this.addOptionalArg("title", "");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.TITLE.node));
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
}

View File

@ -1,5 +1,6 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.FPerm;
@ -14,6 +15,7 @@ public class CmdFactionsUnclaim extends FCommand
{
this.addAliases("unclaim", "declaim");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.UNCLAIM.node));
this.addRequirements(ReqIsPlayer.get());
}

View File

@ -6,6 +6,7 @@ import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.BoardColls;
@ -22,6 +23,7 @@ public class CmdFactionsUnclaimall extends FCommand
{
this.addAliases("unclaimall", "declaimall");
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.UNCLAIM_ALL.node));
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
}

View File

@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.mcore.cmd.MCommand;
@ -17,6 +18,13 @@ public abstract class FCommand extends MCommand
public void fixSenderVars()
{
this.msender = MPlayer.get(sender);
this.usender = null;
this.usenderFaction = null;
// Check disabled
if (UConf.isDisabled(sender)) return;
this.usender = UPlayer.get(this.sender);
this.usenderFaction = this.usender.getFaction();
}

View File

@ -0,0 +1,36 @@
package com.massivecraft.factions.cmd.req;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.mcore.cmd.MCommand;
import com.massivecraft.mcore.cmd.req.ReqAbstract;
public class ReqFactionsEnabled extends ReqAbstract
{
private static final long serialVersionUID = 1L;
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ReqFactionsEnabled i = new ReqFactionsEnabled();
public static ReqFactionsEnabled get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public boolean apply(CommandSender sender, MCommand command)
{
return !UConf.isDisabled(sender);
}
@Override
public String createErrorMessage(CommandSender sender, MCommand command)
{
return UConf.getDisabledMessage(sender);
}
}

View File

@ -6,12 +6,16 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.event.FactionsEventChunkChangeType;
import com.massivecraft.mcore.store.Entity;
import com.massivecraft.mcore.store.SenderEntity;
import com.massivecraft.mcore.util.MUtil;
import com.massivecraft.mcore.util.Txt;
public class UConf extends Entity<UConf>
{
@ -30,6 +34,34 @@ public class UConf extends Entity<UConf>
public boolean enabled = true;
public static boolean isDisabled(Object universe)
{
return isDisabled(universe, null);
}
public static String getDisabledMessage(Object universe)
{
UConf uconf = UConf.get(universe);
return Txt.parse("<i>Factions are disabled in the <h>%s <i>universe.", uconf.getUniverse());
}
public static boolean isDisabled(Object universe, Object inform)
{
UConf uconf = UConf.get(universe);
if (uconf.enabled) return false;
if (inform instanceof CommandSender)
{
((CommandSender)inform).sendMessage(getDisabledMessage(universe));
}
else if (inform instanceof SenderEntity)
{
((SenderEntity<?>)inform).sendMessage(getDisabledMessage(universe));
}
return true;
}
// -------------------------------------------- //
// SPECIAL FACTION IDS
// -------------------------------------------- //

View File

@ -10,7 +10,6 @@ import com.dthielke.herochat.ChannelChatEvent;
import com.dthielke.herochat.Herochat;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.chat.ChatFormatter;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.MConf;
@ -54,7 +53,7 @@ public class HerochatEngine implements Listener
String format = event.getFormat();
format = format.replaceAll("&r", "§r");
format = ChatFormatter.format(format, UPlayer.get(event.getSender().getPlayer()), null);
format = ChatFormatter.format(format, event.getSender().getPlayer(), null);
event.setFormat(format);
}

View File

@ -10,7 +10,6 @@ import org.bukkit.plugin.EventExecutor;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.chat.ChatFormatter;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.MConf;
public class FactionsListenerChat implements Listener
@ -91,7 +90,7 @@ public class FactionsListenerChat implements Listener
public static void parseTags(AsyncPlayerChatEvent event)
{
String format = event.getFormat();
format = ChatFormatter.format(format, UPlayer.get(event.getPlayer()), null);
format = ChatFormatter.format(format, event.getPlayer(), null);
event.setFormat(format);
}

View File

@ -60,6 +60,7 @@ import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.entity.UPlayerColl;
import com.massivecraft.factions.entity.UPlayerColls;
import com.massivecraft.factions.event.FactionsEventPowerChange;
import com.massivecraft.factions.event.FactionsEventPowerChange.PowerChangeReason;
@ -96,9 +97,12 @@ public class FactionsListenerMain implements Listener
{
// If the player is moving from one chunk to another ...
if (MUtil.isSameChunk(event)) return;
Player player = event.getPlayer();
// Check Disabled
if (UConf.isDisabled(player)) return;
// ... gather info on the player and the move ...
Player player = event.getPlayer();
UPlayer uplayer = UPlayerColls.get().get(event.getTo()).get(player);
PS chunkFrom = PS.valueOf(event.getFrom()).getChunk(true);
@ -171,6 +175,10 @@ public class FactionsListenerMain implements Listener
{
// If a player dies ...
Player player = event.getEntity();
// Check Disabled
if (UConf.isDisabled(player)) return;
UPlayer uplayer = UPlayer.get(player);
// ... and powerloss can happen here ...
@ -247,13 +255,16 @@ public class FactionsListenerMain implements Listener
}
public boolean canCombatDamageHappen(EntityDamageByEntityEvent event, boolean notify)
{
{
// If the defender is a player ...
Entity edefender = event.getEntity();
if (!(edefender instanceof Player)) return true;
Player defender = (Player)edefender;
UPlayer fdefender = UPlayer.get(edefender);
// Check Disabled
if (UConf.isDisabled(defender)) return true;
// ... and the attacker is someone else ...
Entity eattacker = event.getDamager();
if (eattacker instanceof Projectile)
@ -376,7 +387,6 @@ public class FactionsListenerMain implements Listener
{
// If a player was kicked from the server ...
Player player = event.getPlayer();
UPlayer uplayer = UPlayer.get(player);
// ... and if the if player was banned (not just kicked) ...
if (!event.getReason().equals("Banned by admin.")) return;
@ -385,12 +395,18 @@ public class FactionsListenerMain implements Listener
if (!MConf.get().removePlayerDataWhenBanned) return;
// ... get rid of their stored info.
if (uplayer.getRole() == Rel.LEADER)
for (UPlayerColl coll : UPlayerColls.get().getColls())
{
uplayer.getFaction().promoteNewLeader();
UPlayer uplayer = coll.get(player, false);
if (uplayer == null) continue;
if (uplayer.getRole() == Rel.LEADER)
{
uplayer.getFaction().promoteNewLeader();
}
uplayer.leave();
uplayer.detach();
}
uplayer.leave();
uplayer.detach();
}
// -------------------------------------------- //
@ -414,6 +430,10 @@ public class FactionsListenerMain implements Listener
{
// If a player is trying to run a command ...
Player player = event.getPlayer();
// Check Disabled
if (UConf.isDisabled(player)) return;
UPlayer uplayer = UPlayer.get(player);
// ... and the player does not have adminmode ...
@ -474,6 +494,9 @@ public class FactionsListenerMain implements Listener
// If a monster is spawning ...
if ( ! Const.ENTITY_TYPES_MONSTERS.contains(event.getEntityType())) return;
// Check Disabled
if (UConf.isDisabled(event.getLocation())) return;
// ... at a place where monsters are forbidden ...
PS ps = PS.valueOf(event.getLocation());
Faction faction = BoardColls.get().getFactionAt(ps);
@ -493,6 +516,9 @@ public class FactionsListenerMain implements Listener
Entity target = event.getTarget();
if (target == null) return;
// Check Disabled
if (UConf.isDisabled(target)) return;
// ... at a place where monsters are forbidden ...
PS ps = PS.valueOf(target);
Faction faction = BoardColls.get().getFactionAt(ps);
@ -518,9 +544,13 @@ public class FactionsListenerMain implements Listener
{
// If a hanging entity was broken by an explosion ...
if (event.getCause() != RemoveCause.EXPLOSION) return;
Entity entity = event.getEntity();
// Check Disabled
if (UConf.isDisabled(entity)) return;
// ... and the faction there has explosions disabled ...
Faction faction = BoardColls.get().getFactionAt(PS.valueOf(event.getEntity()));
Faction faction = BoardColls.get().getFactionAt(PS.valueOf(entity));
if (faction.getFlag(FFlag.EXPLOSIONS)) return;
// ... then cancel.
@ -530,6 +560,19 @@ public class FactionsListenerMain implements Listener
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void blockExplosion(EntityExplodeEvent event)
{
// If an entity is exploding ...
Entity entity = event.getEntity();
// Check Disabled
if (UConf.isDisabled(entity)) return;
// Check the entity. Are explosions disabled there?
if (BoardColls.get().getFactionAt(PS.valueOf(event.getEntity())).getFlag(FFlag.EXPLOSIONS) == false)
{
event.setCancelled(true);
return;
}
// Individually check the flag state for each block
Iterator<Block> iter = event.blockList().iterator();
while (iter.hasNext())
@ -538,12 +581,6 @@ public class FactionsListenerMain implements Listener
Faction faction = BoardColls.get().getFactionAt(PS.valueOf(block));
if (faction.getFlag(FFlag.EXPLOSIONS) == false) iter.remove();
}
// Check the entity. Are explosions disabled there?
if (BoardColls.get().getFactionAt(PS.valueOf(event.getEntity())).getFlag(FFlag.EXPLOSIONS) == false)
{
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@ -552,6 +589,9 @@ public class FactionsListenerMain implements Listener
// If a wither is changing a block ...
Entity entity = event.getEntity();
if (!(entity instanceof Wither)) return;
// Check Disabled
if (UConf.isDisabled(entity)) return;
// ... and the faction there has explosions disabled ...
PS ps = PS.valueOf(event.getBlock());
@ -573,6 +613,9 @@ public class FactionsListenerMain implements Listener
Entity entity = event.getEntity();
if (!(entity instanceof Enderman)) return;
// Check Disabled
if (UConf.isDisabled(entity)) return;
// ... and the faction there has endergrief disabled ...
PS ps = PS.valueOf(event.getBlock());
Faction faction = BoardColls.get().getFactionAt(ps);
@ -588,6 +631,9 @@ public class FactionsListenerMain implements Listener
public void blockFireSpread(Block block, Cancellable cancellable)
{
// Check Disabled
if (UConf.isDisabled(block)) return;
// If the faction at the block has firespread disabled ...
PS ps = PS.valueOf(block);
Faction faction = BoardColls.get().getFactionAt(ps);

View File

@ -3,6 +3,7 @@ package com.massivecraft.factions.task;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.mcore.ModuloRepeatTask;
import com.massivecraft.mcore.util.TimeUnit;
@ -36,6 +37,9 @@ public class TaskEconLandReward extends ModuloRepeatTask
{
for (FactionColl coll : FactionColls.get().getColls())
{
// Check disabled
if (UConf.isDisabled(coll)) continue;
coll.econLandRewardRoutine();
}
}

View File

@ -1,6 +1,7 @@
package com.massivecraft.factions.task;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.entity.UPlayerColl;
import com.massivecraft.factions.entity.UPlayerColls;
import com.massivecraft.mcore.ModuloRepeatTask;
@ -36,6 +37,9 @@ public class TaskPlayerDataRemove extends ModuloRepeatTask
{
for (UPlayerColl coll : UPlayerColls.get().getColls())
{
// Check disabled
if (UConf.isDisabled(coll)) continue;
coll.removePlayerDataAfterInactiveDaysRoutine();
}
}

View File

@ -4,6 +4,7 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.event.FactionsEventPowerChange;
import com.massivecraft.factions.event.FactionsEventPowerChange.PowerChangeReason;
@ -42,6 +43,9 @@ public class TaskPlayerPowerUpdate extends ModuloRepeatTask
for (Player player : Bukkit.getOnlinePlayers())
{
// Check disabled
if (UConf.isDisabled(player)) continue;
if (player.isDead()) continue;
UPlayer uplayer = UPlayer.get(player);