Check System Added and Massive Reformat
This commit is contained in:
parent
84f4e0f732
commit
72f76aeb71
@ -4,7 +4,6 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.massivecraft.factions.integration.dynmap.DynmapStyle;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.fperms.DefaultPermissions;
|
||||
import com.massivecraft.factions.zcore.fperms.Permissable;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -85,6 +84,7 @@ public class Conf {
|
||||
public static int stealthFlyCheckRadius = 32;
|
||||
public static int factionBufferSize = 20;
|
||||
public static boolean removeHomesOnLeave = true;
|
||||
public static boolean useCheckSystem = true;
|
||||
public static boolean gracePeriod = false;
|
||||
public static boolean noEnderpearlsInFly = false;
|
||||
public static boolean broadcastDescriptionChanges = false;
|
||||
@ -365,6 +365,7 @@ public class Conf {
|
||||
static {
|
||||
lockedPermissions.add(PermissableAction.CHEST);
|
||||
}
|
||||
|
||||
static {
|
||||
baseCommandAliases.add("f");
|
||||
|
||||
|
@ -79,6 +79,7 @@ public class FLocation implements Serializable {
|
||||
public static int blockToChunk(int blockVal) { // 1 chunk is 16x16 blocks
|
||||
return blockVal >> 4; // ">> 4" == "/ 16"
|
||||
}
|
||||
|
||||
public static int blockToRegion(int blockVal) { // 1 region is 512x512 blocks
|
||||
return blockVal >> 9; // ">> 9" == "/ 512"
|
||||
}
|
||||
|
@ -30,10 +30,10 @@ public interface FPlayer extends EconomyParticipator {
|
||||
|
||||
boolean hasNotificationsEnabled();
|
||||
|
||||
void setAlt(boolean alt);
|
||||
|
||||
boolean isAlt();
|
||||
|
||||
void setAlt(boolean alt);
|
||||
|
||||
/**
|
||||
* Used to know if stealth is toggled on or off
|
||||
*
|
||||
|
@ -23,6 +23,12 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public interface Faction extends EconomyParticipator {
|
||||
|
||||
long getCheckNotifier();
|
||||
|
||||
void setCheckNotifier(long minutes);
|
||||
|
||||
void sendCheckNotify();
|
||||
|
||||
boolean altInvited(FPlayer fplayer);
|
||||
|
||||
Map<String, Mission> getMissions();
|
||||
@ -200,7 +206,9 @@ public interface Faction extends EconomyParticipator {
|
||||
boolean noMonstersInTerritory();
|
||||
|
||||
boolean isNormal();
|
||||
|
||||
boolean isSystemFaction();
|
||||
|
||||
@Deprecated
|
||||
boolean isNone();
|
||||
|
||||
|
@ -17,7 +17,6 @@ import com.massivecraft.factions.missions.MissionHandler;
|
||||
import com.massivecraft.factions.shop.ShopClickPersistence;
|
||||
import com.massivecraft.factions.shop.ShopConfig;
|
||||
import com.massivecraft.factions.struct.ChatMode;
|
||||
import com.massivecraft.factions.util.Placeholder;
|
||||
import com.massivecraft.factions.util.*;
|
||||
import com.massivecraft.factions.util.Particles.ReflectionUtils;
|
||||
import com.massivecraft.factions.zcore.CommandVisibility;
|
||||
@ -63,9 +62,7 @@ public class P extends MPlugin {
|
||||
// Plugins can check this boolean while hooking in have
|
||||
// a green light to use the api.
|
||||
public static boolean startupFinished = false;
|
||||
private FactionsPlayerListener factionsPlayerListener;
|
||||
|
||||
|
||||
public static Economy econ = null;
|
||||
public boolean PlaceholderApi;
|
||||
// Commands
|
||||
public FCmdRoot cmdBase;
|
||||
@ -78,6 +75,7 @@ public class P extends MPlugin {
|
||||
public boolean useNonPacketParticles = false;
|
||||
public boolean factionsFlight = false;
|
||||
SkriptAddon skriptAddon;
|
||||
private FactionsPlayerListener factionsPlayerListener;
|
||||
private boolean locked = false;
|
||||
private boolean spam = false;
|
||||
private Integer AutoLeaveTask = null;
|
||||
@ -85,7 +83,6 @@ public class P extends MPlugin {
|
||||
private ClipPlaceholderAPIManager clipPlaceholderAPIManager;
|
||||
private boolean mvdwPlaceholderAPIManager = false;
|
||||
private Listener[] eventsListener;
|
||||
public static Economy econ = null;
|
||||
|
||||
|
||||
public P() {
|
||||
@ -198,6 +195,10 @@ public class P extends MPlugin {
|
||||
faction.addFPlayer(fPlayer);
|
||||
}
|
||||
}
|
||||
if (Conf.useCheckSystem) {
|
||||
new CheckWallTask().runTaskTimerAsynchronously(this, 0L, 1200L);
|
||||
this.log(Level.INFO, "Enabling Check Wall Timers!");
|
||||
}
|
||||
|
||||
if (getConfig().getBoolean("enable-faction-flight", true)) {
|
||||
UtilFly.run();
|
||||
@ -300,7 +301,6 @@ public class P extends MPlugin {
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void setupPlaceholderAPI() {
|
||||
Plugin clip = getServer().getPluginManager().getPlugin("PlaceholderAPI");
|
||||
if (clip != null && clip.isEnabled()) {
|
||||
@ -324,7 +324,8 @@ public class P extends MPlugin {
|
||||
|
||||
public List<String> replacePlaceholders(List<String> lore, Placeholder... placeholders) {
|
||||
for (Placeholder placeholder : placeholders) {
|
||||
for (int x = 0; x <= lore.size() - 1; x++) lore.set(x, lore.get(x).replace(placeholder.getTag(), placeholder.getReplace()));
|
||||
for (int x = 0; x <= lore.size() - 1; x++)
|
||||
lore.set(x, lore.get(x).replace(placeholder.getTag(), placeholder.getReplace()));
|
||||
}
|
||||
return lore;
|
||||
}
|
||||
@ -703,6 +704,7 @@ public class P extends MPlugin {
|
||||
getLogger().log(level, s);
|
||||
}
|
||||
}
|
||||
|
||||
public FactionsPlayerListener getFactionsPlayerListener() {
|
||||
return this.factionsPlayerListener;
|
||||
}
|
||||
|
56
src/main/java/com/massivecraft/factions/cmd/CmdCheck.java
Normal file
56
src/main/java/com/massivecraft/factions/cmd/CmdCheck.java
Normal file
@ -0,0 +1,56 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class CmdCheck extends FCommand {
|
||||
|
||||
public CmdCheck() {
|
||||
this.aliases.add("check");
|
||||
|
||||
this.requiredArgs.add("minutes");
|
||||
|
||||
this.permission = Permission.CHECK.node;
|
||||
|
||||
this.disableOnLock = true;
|
||||
this.disableOnSpam = false;
|
||||
|
||||
this.senderMustBePlayer = true;
|
||||
this.senderMustBeMember = true;
|
||||
this.senderMustBeModerator = false;
|
||||
this.senderMustBeColeader = false;
|
||||
this.senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
if (!Conf.useCheckSystem) {
|
||||
msg(TL.GENERIC_DISABLED);
|
||||
return;
|
||||
}
|
||||
|
||||
Access access = myFaction.getAccess(fme, PermissableAction.CHECK);
|
||||
if ((access == Access.DENY || (access == Access.UNDEFINED && !assertMinRole(Role.LEADER))) && !fme.isAdminBypassing()) {
|
||||
fme.msg(TL.GENERIC_NOPERMISSION, "check");
|
||||
return;
|
||||
}
|
||||
int minutes = this.argAsInt(0);
|
||||
if (minutes <= 0) {
|
||||
msg(TL.COMMAND_CHECK_INVALID_NUMBER);
|
||||
} else {
|
||||
myFaction.setCheckNotifier(minutes);
|
||||
msg(TL.COMMAND_CHECK_SUCCESSFUL.format(minutes));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_CHECK_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,6 @@ public class CmdCreate extends FCommand {
|
||||
Econ.setBalance(faction.getAccountId(), Conf.econFactionStartingBalance);
|
||||
|
||||
|
||||
|
||||
if (Conf.logFactionCreate)
|
||||
P.p.log(fme.getName() + TL.COMMAND_CREATE_CREATEDLOG.toString() + tag);
|
||||
|
||||
|
@ -9,6 +9,8 @@ import java.util.UUID;
|
||||
|
||||
public class CmdFGlobal extends FCommand {
|
||||
|
||||
public static List<UUID> toggled = new ArrayList<>();
|
||||
|
||||
public CmdFGlobal() {
|
||||
|
||||
super();
|
||||
@ -26,8 +28,6 @@ public class CmdFGlobal extends FCommand {
|
||||
senderMustBeAdmin = false;
|
||||
}
|
||||
|
||||
public static List<UUID> toggled = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
|
||||
|
@ -68,7 +68,9 @@ public class CmdFWarp extends FCommand {
|
||||
fPlayer.msg(TL.COMMAND_FWARP_WARPED, warpName);
|
||||
}
|
||||
}, this.p.getConfig().getLong("warmups.f-warp", 0));
|
||||
} else { fme.msg(TL.COMMAND_FWARP_INVALID_WARP, warpName); }
|
||||
} else {
|
||||
fme.msg(TL.COMMAND_FWARP_INVALID_WARP, warpName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,6 +164,11 @@ public class CmdFly extends FCommand {
|
||||
}
|
||||
}
|
||||
|
||||
public static void disableFlight(final FPlayer fme) {
|
||||
fme.setFlying(false);
|
||||
flyMap.remove(fme.getPlayer().getName());
|
||||
}
|
||||
|
||||
public boolean isInFlightChecker(Player player) {
|
||||
return flyMap.containsKey(player.getName());
|
||||
}
|
||||
@ -222,12 +227,6 @@ public class CmdFly extends FCommand {
|
||||
}, this.p.getConfig().getLong("warmups.f-fly", 0));
|
||||
}
|
||||
|
||||
public static void disableFlight(final FPlayer fme) {
|
||||
fme.setFlying(false);
|
||||
flyMap.remove(fme.getPlayer().getName());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_FLY_DESCRIPTION;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.integration.Essentials;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
@ -10,7 +9,6 @@ import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.SmokeUtil;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -83,7 +81,6 @@ public class CmdHome extends FCommand {
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!myFaction.hasHome()) {
|
||||
fme.msg(TL.COMMAND_HOME_NOHOME.toString() + (fme.getRole().value < Role.MODERATOR.value ? TL.GENERIC_ASKYOURLEADER.toString() : TL.GENERIC_YOUSHOULD.toString()));
|
||||
fme.sendMessage(p.cmdBase.cmdSethome.getUseageTemplate());
|
||||
@ -91,8 +88,6 @@ public class CmdHome extends FCommand {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (!Conf.homesTeleportAllowedFromEnemyTerritory && fme.isInEnemyTerritory()) {
|
||||
fme.msg(TL.COMMAND_HOME_INENEMY);
|
||||
return;
|
||||
@ -148,7 +143,6 @@ public class CmdHome extends FCommand {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!payForCommand(Conf.econCostHome, TL.COMMAND_HOME_TOTELEPORT.toString(), TL.COMMAND_HOME_FORTELEPORT.toString())) {
|
||||
return;
|
||||
@ -161,7 +155,6 @@ public class CmdHome extends FCommand {
|
||||
// }
|
||||
|
||||
|
||||
|
||||
this.doWarmUp(WarmUpUtil.Warmup.HOME, TL.WARMUPS_NOTIFY_TELEPORT, "Home", () -> {
|
||||
// Create a smoke effect
|
||||
if (Conf.homesTeleportCommandSmokeEffectEnabled) {
|
||||
|
@ -99,7 +99,6 @@ public class CmdJoin extends FCommand {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
||||
if (samePlayer && !canAffordCommand(Conf.econCostJoin, TL.COMMAND_JOIN_TOJOIN.toString())) {
|
||||
return;
|
||||
|
@ -8,7 +8,9 @@ import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import com.massivecraft.factions.zcore.util.TagUtil;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class CmdList extends FCommand {
|
||||
|
@ -23,6 +23,7 @@ public class CmdPaypalSee extends FCommand {
|
||||
senderMustBeAdmin = true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
if (!P.p.getConfig().getBoolean("fpaypal.Enabled")) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
|
@ -23,7 +23,6 @@ public class CmdStealth extends FCommand {
|
||||
public void perform() {
|
||||
|
||||
|
||||
|
||||
Faction faction = fme.getFaction();
|
||||
if (faction != null && !faction.getId().equalsIgnoreCase("0") && !faction.getId().equalsIgnoreCase("none") && !faction.getId().equalsIgnoreCase("safezone") && !faction.getId().equalsIgnoreCase("warzone")) {
|
||||
fme.setStealth(!fme.isStealthEnabled());
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class CmdStrike extends FCommand {
|
||||
|
@ -135,6 +135,7 @@ public class FCmdRoot extends FCommand {
|
||||
public CmdNotifications cmdNotifications = new CmdNotifications();
|
||||
public CmdShop cmdShop = new CmdShop();
|
||||
public CmdMissions cmdMissions = new CmdMissions();
|
||||
public CmdCheck cmdCheck = new CmdCheck();
|
||||
|
||||
|
||||
public FCmdRoot() {
|
||||
@ -255,6 +256,10 @@ public class FCmdRoot extends FCommand {
|
||||
this.addSubCommand(this.cmdFGlobal);
|
||||
this.addSubCommand(this.cmdViewChest);
|
||||
|
||||
if (Conf.useCheckSystem) {
|
||||
this.addSubCommand(this.cmdCheck);
|
||||
}
|
||||
|
||||
if (P.p.getConfig().getBoolean("Missions-Enabled")) {
|
||||
this.addSubCommand(this.cmdMissions);
|
||||
}
|
||||
|
@ -33,10 +33,7 @@ public class CmdGrace extends FCommand {
|
||||
boolean gracePeriod = Conf.gracePeriod;
|
||||
|
||||
if (args.size() == 0) {
|
||||
if (gracePeriod)
|
||||
Conf.gracePeriod = false;
|
||||
else
|
||||
Conf.gracePeriod = true;
|
||||
Conf.gracePeriod = !gracePeriod;
|
||||
}
|
||||
fme.msg(TL.COMMAND_GRACE_TOGGLE, gracePeriod ? "enabled" : "disabled");
|
||||
}
|
||||
|
@ -35,5 +35,7 @@ public class CmdLogout extends FCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() { return TL.COMMAND_LOGOUT_DESCRIPTION; }
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_LOGOUT_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
|
@ -22,15 +22,18 @@ public class LogoutHandler {
|
||||
factionDatas.put(name, this);
|
||||
}
|
||||
|
||||
public static LogoutHandler getByName(String name) {
|
||||
LogoutHandler logoutHandler = factionDatas.get(name);
|
||||
return logoutHandler == null ? new LogoutHandler(name) : factionDatas.get(name);
|
||||
}
|
||||
|
||||
public boolean isLogoutActive(Player player) {
|
||||
return logoutCooldown.containsKey(player.getUniqueId()) && System.currentTimeMillis() < logoutCooldown.get(player.getUniqueId());
|
||||
}
|
||||
|
||||
public void cancelLogout(Player player) {
|
||||
if(logoutCooldown.containsKey(player.getUniqueId())) {
|
||||
logoutCooldown.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
public void applyLogoutCooldown(Player player) {
|
||||
logoutCooldown.put(player.getUniqueId(), System.currentTimeMillis() + (30 * 1000));
|
||||
@ -43,9 +46,4 @@ public class LogoutHandler {
|
||||
}
|
||||
}, Conf.logoutCooldown * 20L);
|
||||
}
|
||||
|
||||
public static LogoutHandler getByName(String name) {
|
||||
LogoutHandler logoutHandler = factionDatas.get(name);
|
||||
return logoutHandler == null ? new LogoutHandler(name) : factionDatas.get(name);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.massivecraft.factions.cmd.points;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
|
@ -116,8 +116,10 @@ public class CmdTnt extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i <= fullStacks - 1; i++) me.getPlayer().getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), 64));
|
||||
if (remainderAmt != 0) me.getPlayer().getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), remainderAmt));
|
||||
for (int i = 0; i <= fullStacks - 1; i++)
|
||||
me.getPlayer().getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), 64));
|
||||
if (remainderAmt != 0)
|
||||
me.getPlayer().getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), remainderAmt));
|
||||
|
||||
fme.getFaction().takeTnt(amount);
|
||||
me.updateInventory();
|
||||
|
@ -101,6 +101,47 @@ public class FactionsBlockListener implements Listener {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean graceisEnabled() {
|
||||
return Conf.gracePeriod;
|
||||
}
|
||||
|
||||
private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction myFaction, Access access, PermissableAction action, boolean shouldHurt) {
|
||||
boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty());
|
||||
if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId())))
|
||||
return true;
|
||||
else if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) {
|
||||
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc)));
|
||||
if (shouldHurt) {
|
||||
player.damage(Conf.actionDeniedPainAmount);
|
||||
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
|
||||
}
|
||||
return false;
|
||||
} else if (!landOwned && access == Access.DENY) { // If land is not owned but access is set to DENY anyway
|
||||
if (shouldHurt) {
|
||||
player.damage(Conf.actionDeniedPainAmount);
|
||||
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
|
||||
}
|
||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
|
||||
return false;
|
||||
} else if (access == Access.ALLOW) return true;
|
||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean CheckActionState(Faction target, FLocation location, FPlayer me, PermissableAction action, boolean pain) {
|
||||
if (Conf.ownedAreasEnabled && target.doesLocationHaveOwnersSet(location) && !target.playerHasOwnershipRights(me, location)) {
|
||||
// If pain should be applied
|
||||
if (pain && Conf.ownedAreaPainBuild)
|
||||
me.msg(TL.ACTIONS_OWNEDTERRITORYPAINDENY.toString().replace("{action}", action.toString()).replace("{faction}", target.getOwnerListString(location)));
|
||||
if (Conf.ownedAreaDenyBuild && pain) return false;
|
||||
else if (Conf.ownedAreaDenyBuild) {
|
||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", target.getTag(me.getFaction())).replace("{action}", action.toString()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return CheckPlayerAccess(me.getPlayer(), me, location, target, target.getAccess(me, action), action, pain);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (!event.canBuild()) {
|
||||
@ -450,11 +491,6 @@ public class FactionsBlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean graceisEnabled() {
|
||||
return Conf.gracePeriod;
|
||||
}
|
||||
|
||||
|
||||
private boolean canPistonMoveBlock(Faction pistonFaction, Location target) {
|
||||
|
||||
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(target));
|
||||
@ -510,41 +546,4 @@ public class FactionsBlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction myFaction, Access access, PermissableAction action, boolean shouldHurt) {
|
||||
boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty());
|
||||
if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId())))
|
||||
return true;
|
||||
else if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) {
|
||||
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc)));
|
||||
if (shouldHurt) {
|
||||
player.damage(Conf.actionDeniedPainAmount);
|
||||
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
|
||||
}
|
||||
return false;
|
||||
} else if (!landOwned && access == Access.DENY) { // If land is not owned but access is set to DENY anyway
|
||||
if (shouldHurt) {
|
||||
player.damage(Conf.actionDeniedPainAmount);
|
||||
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
|
||||
}
|
||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
|
||||
return false;
|
||||
} else if (access == Access.ALLOW) return true;
|
||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean CheckActionState(Faction target, FLocation location, FPlayer me, PermissableAction action, boolean pain) {
|
||||
if (Conf.ownedAreasEnabled && target.doesLocationHaveOwnersSet(location) && !target.playerHasOwnershipRights(me, location)) {
|
||||
// If pain should be applied
|
||||
if (pain && Conf.ownedAreaPainBuild)
|
||||
me.msg(TL.ACTIONS_OWNEDTERRITORYPAINDENY.toString().replace("{action}", action.toString()).replace("{faction}", target.getOwnerListString(location)));
|
||||
if (Conf.ownedAreaDenyBuild && pain) return false;
|
||||
else if (Conf.ownedAreaDenyBuild) {
|
||||
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", target.getTag(me.getFaction())).replace("{action}", action.toString()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return CheckPlayerAccess(me.getPlayer(), me, location, target, target.getAccess(me, action), action, pain);
|
||||
}
|
||||
}
|
||||
|
@ -46,9 +46,8 @@ import java.util.logging.Level;
|
||||
|
||||
public class FactionsPlayerListener implements Listener {
|
||||
|
||||
private Set<FLocation> corners;
|
||||
HashMap<Player, Boolean> fallMap = new HashMap<>();
|
||||
|
||||
private Set<FLocation> corners;
|
||||
// Holds the next time a player can have a map shown.
|
||||
private HashMap<UUID, Long> showTimes = new HashMap<>();
|
||||
// for handling people who repeatedly spam attempts to open a door (or similar) in another faction's territory
|
||||
@ -287,6 +286,173 @@ public class FactionsPlayerListener implements Listener {
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This checks if the current player can execute an action based on it's factions access and surroundings
|
||||
/// It will grant access in the following priorities:
|
||||
/// - If Faction Land is Owned and the Owner is the current player, or player is faction leader.
|
||||
/// - If Faction Land is not Owned and my access value is not set to DENY
|
||||
/// - If none of the filters above matches, then we consider access is set to ALLOW|UNDEFINED
|
||||
/// This check does not performs any kind of bypass check (i.e.: me.isAdminBypassing())
|
||||
/// </summary>
|
||||
/// <param name="player">The player entity which the check will be made upon</param>
|
||||
/// <param name="me">The Faction player object related to the player</param>
|
||||
/// <param name="loc">The World location where the action is being executed</param>
|
||||
/// <param name="myFaction">The faction of the player being checked</param>
|
||||
/// <param name="access">The current's faction access permission for the action</param>
|
||||
private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction factionToCheck, Access access, PermissableAction action, boolean pain) {
|
||||
boolean doPain = pain && Conf.handleExploitInteractionSpam;
|
||||
if (access != null && access != Access.UNDEFINED) {
|
||||
// TODO: Update this once new access values are added other than just allow / deny.
|
||||
boolean landOwned = (factionToCheck.doesLocationHaveOwnersSet(loc) && !factionToCheck.getOwnerList(loc).isEmpty());
|
||||
if ((landOwned && factionToCheck.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(factionToCheck.getId())))
|
||||
return true;
|
||||
else if (landOwned && !factionToCheck.getOwnerListString(loc).contains(player.getName())) {
|
||||
me.msg("<b>You can't do that in this territory, it is owned by: " + factionToCheck.getOwnerListString(loc));
|
||||
if (doPain) {
|
||||
player.damage(Conf.actionDeniedPainAmount);
|
||||
}
|
||||
return false;
|
||||
} else if (!landOwned && access == Access.ALLOW) return true;
|
||||
else {
|
||||
me.msg("You cannot " + action + " in the territory of " + factionToCheck.getTag(me.getFaction()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Approves any permission check if the player in question is a leader AND owns the faction.
|
||||
if (me.getRole().equals(Role.LEADER) && me.getFaction().equals(factionToCheck)) return true;
|
||||
me.msg("You cannot " + action + " in the territory of " + factionToCheck.getTag(me.getFaction()));
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will try to resolve a permission action based on the item material, if it's not usable, will return null
|
||||
/// </summary>
|
||||
private static PermissableAction GetPermissionFromUsableBlock(Block block) {
|
||||
return GetPermissionFromUsableBlock(block.getType());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will try to resolve a permission action based on the item material, if it's not usable, will return null
|
||||
/// <summary>
|
||||
private static PermissableAction GetPermissionFromUsableBlock(Material material) {
|
||||
// Check for doors that might have diff material name in old version.
|
||||
if (material.name().contains("DOOR") || material.name().contains("FENCE_GATE"))
|
||||
return PermissableAction.DOOR;
|
||||
if (material.name().toUpperCase().contains("BUTTON") || material.name().toUpperCase().contains("PRESSURE"))
|
||||
return PermissableAction.BUTTON;
|
||||
if (P.p.mc113) {
|
||||
switch (material) {
|
||||
case LEVER:
|
||||
return PermissableAction.LEVER;
|
||||
|
||||
case ACACIA_BUTTON:
|
||||
case BIRCH_BUTTON:
|
||||
case DARK_OAK_BUTTON:
|
||||
case JUNGLE_BUTTON:
|
||||
case OAK_BUTTON:
|
||||
case SPRUCE_BUTTON:
|
||||
case STONE_BUTTON:
|
||||
return PermissableAction.BUTTON;
|
||||
|
||||
case ACACIA_DOOR:
|
||||
case BIRCH_DOOR:
|
||||
case IRON_DOOR:
|
||||
case JUNGLE_DOOR:
|
||||
case OAK_DOOR:
|
||||
case SPRUCE_DOOR:
|
||||
case DARK_OAK_DOOR:
|
||||
|
||||
case ACACIA_TRAPDOOR:
|
||||
case BIRCH_TRAPDOOR:
|
||||
case DARK_OAK_TRAPDOOR:
|
||||
case IRON_TRAPDOOR:
|
||||
case JUNGLE_TRAPDOOR:
|
||||
case OAK_TRAPDOOR:
|
||||
case SPRUCE_TRAPDOOR:
|
||||
|
||||
case ACACIA_FENCE_GATE:
|
||||
case BIRCH_FENCE_GATE:
|
||||
case DARK_OAK_FENCE_GATE:
|
||||
case JUNGLE_FENCE_GATE:
|
||||
case OAK_FENCE_GATE:
|
||||
case SPRUCE_FENCE_GATE:
|
||||
return PermissableAction.DOOR;
|
||||
|
||||
case CHEST:
|
||||
case TRAPPED_CHEST:
|
||||
case CHEST_MINECART:
|
||||
|
||||
case SHULKER_BOX:
|
||||
case BLACK_SHULKER_BOX:
|
||||
case BLUE_SHULKER_BOX:
|
||||
case BROWN_SHULKER_BOX:
|
||||
case CYAN_SHULKER_BOX:
|
||||
case GRAY_SHULKER_BOX:
|
||||
case GREEN_SHULKER_BOX:
|
||||
case LIGHT_BLUE_SHULKER_BOX:
|
||||
case LIGHT_GRAY_SHULKER_BOX:
|
||||
case LIME_SHULKER_BOX:
|
||||
case MAGENTA_SHULKER_BOX:
|
||||
case ORANGE_SHULKER_BOX:
|
||||
case PINK_SHULKER_BOX:
|
||||
case PURPLE_SHULKER_BOX:
|
||||
case RED_SHULKER_BOX:
|
||||
case WHITE_SHULKER_BOX:
|
||||
case YELLOW_SHULKER_BOX:
|
||||
|
||||
case FURNACE:
|
||||
case DROPPER:
|
||||
case DISPENSER:
|
||||
case ENCHANTING_TABLE:
|
||||
case BREWING_STAND:
|
||||
case CAULDRON:
|
||||
case HOPPER:
|
||||
case BEACON:
|
||||
case JUKEBOX:
|
||||
case ANVIL:
|
||||
case CHIPPED_ANVIL:
|
||||
case DAMAGED_ANVIL:
|
||||
return PermissableAction.CONTAINER;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
switch (material) {
|
||||
case LEVER:
|
||||
return PermissableAction.LEVER;
|
||||
case DARK_OAK_DOOR:
|
||||
case ACACIA_DOOR:
|
||||
case BIRCH_DOOR:
|
||||
case IRON_DOOR:
|
||||
case JUNGLE_DOOR:
|
||||
case SPRUCE_DOOR:
|
||||
|
||||
case ACACIA_FENCE_GATE:
|
||||
case BIRCH_FENCE_GATE:
|
||||
case DARK_OAK_FENCE_GATE:
|
||||
case OAK_FENCE_GATE:
|
||||
case JUNGLE_FENCE_GATE:
|
||||
case SPRUCE_FENCE_GATE:
|
||||
return PermissableAction.DOOR;
|
||||
case CHEST:
|
||||
case ENDER_CHEST:
|
||||
case TRAPPED_CHEST:
|
||||
case DISPENSER:
|
||||
case ENCHANTING_TABLE:
|
||||
case DROPPER:
|
||||
case FURNACE:
|
||||
case HOPPER:
|
||||
case ANVIL:
|
||||
case CHIPPED_ANVIL:
|
||||
case DAMAGED_ANVIL:
|
||||
case BREWING_STAND:
|
||||
return PermissableAction.CONTAINER;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
initPlayer(event.getPlayer());
|
||||
@ -486,13 +652,11 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String convertTime(int time) {
|
||||
String result = String.valueOf(Math.round((System.currentTimeMillis() / 1000L - time) / 36.0D) / 100.0D);
|
||||
return (result.length() == 3 ? result + "0" : result) + "/hrs ago";
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
@ -804,194 +968,10 @@ public class FactionsPlayerListener implements Listener {
|
||||
FTeamWrapper.applyUpdatesLater(event.getFaction());
|
||||
}
|
||||
|
||||
private static class InteractAttemptSpam {
|
||||
private int attempts = 0;
|
||||
private long lastAttempt = System.currentTimeMillis();
|
||||
|
||||
// returns the current attempt count
|
||||
public int increment() {
|
||||
long now = System.currentTimeMillis();
|
||||
if (now > lastAttempt + 2000) {
|
||||
attempts = 1;
|
||||
} else {
|
||||
attempts++;
|
||||
}
|
||||
lastAttempt = now;
|
||||
return attempts;
|
||||
}
|
||||
}
|
||||
|
||||
public Set<FLocation> getCorners() {
|
||||
return this.corners;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This checks if the current player can execute an action based on it's factions access and surroundings
|
||||
/// It will grant access in the following priorities:
|
||||
/// - If Faction Land is Owned and the Owner is the current player, or player is faction leader.
|
||||
/// - If Faction Land is not Owned and my access value is not set to DENY
|
||||
/// - If none of the filters above matches, then we consider access is set to ALLOW|UNDEFINED
|
||||
/// This check does not performs any kind of bypass check (i.e.: me.isAdminBypassing())
|
||||
/// </summary>
|
||||
/// <param name="player">The player entity which the check will be made upon</param>
|
||||
/// <param name="me">The Faction player object related to the player</param>
|
||||
/// <param name="loc">The World location where the action is being executed</param>
|
||||
/// <param name="myFaction">The faction of the player being checked</param>
|
||||
/// <param name="access">The current's faction access permission for the action</param>
|
||||
private static boolean CheckPlayerAccess(Player player, FPlayer me, FLocation loc, Faction factionToCheck, Access access, PermissableAction action, boolean pain) {
|
||||
boolean doPain = pain && Conf.handleExploitInteractionSpam;
|
||||
if (access != null && access != Access.UNDEFINED) {
|
||||
// TODO: Update this once new access values are added other than just allow / deny.
|
||||
boolean landOwned = (factionToCheck.doesLocationHaveOwnersSet(loc) && !factionToCheck.getOwnerList(loc).isEmpty());
|
||||
if ((landOwned && factionToCheck.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(factionToCheck.getId())))
|
||||
return true;
|
||||
else if (landOwned && !factionToCheck.getOwnerListString(loc).contains(player.getName())) {
|
||||
me.msg("<b>You can't do that in this territory, it is owned by: " + factionToCheck.getOwnerListString(loc));
|
||||
if (doPain) {
|
||||
player.damage(Conf.actionDeniedPainAmount);
|
||||
}
|
||||
return false;
|
||||
} else if (!landOwned && access == Access.ALLOW) return true;
|
||||
else {
|
||||
me.msg("You cannot " + action + " in the territory of " + factionToCheck.getTag(me.getFaction()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Approves any permission check if the player in question is a leader AND owns the faction.
|
||||
if (me.getRole().equals(Role.LEADER) && me.getFaction().equals(factionToCheck)) return true;
|
||||
me.msg("You cannot " + action + " in the territory of " + factionToCheck.getTag(me.getFaction()));
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will try to resolve a permission action based on the item material, if it's not usable, will return null
|
||||
/// </summary>
|
||||
private static PermissableAction GetPermissionFromUsableBlock(Block block) {
|
||||
return GetPermissionFromUsableBlock(block.getType());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will try to resolve a permission action based on the item material, if it's not usable, will return null
|
||||
/// <summary>
|
||||
private static PermissableAction GetPermissionFromUsableBlock(Material material) {
|
||||
// Check for doors that might have diff material name in old version.
|
||||
if (material.name().contains("DOOR") || material.name().contains("FENCE_GATE"))
|
||||
return PermissableAction.DOOR;
|
||||
if (material.name().toUpperCase().contains("BUTTON") || material.name().toUpperCase().contains("PRESSURE"))
|
||||
return PermissableAction.BUTTON;
|
||||
if (P.p.mc113) {
|
||||
switch (material) {
|
||||
case LEVER:
|
||||
return PermissableAction.LEVER;
|
||||
|
||||
case ACACIA_BUTTON:
|
||||
case BIRCH_BUTTON:
|
||||
case DARK_OAK_BUTTON:
|
||||
case JUNGLE_BUTTON:
|
||||
case OAK_BUTTON:
|
||||
case SPRUCE_BUTTON:
|
||||
case STONE_BUTTON:
|
||||
return PermissableAction.BUTTON;
|
||||
|
||||
case ACACIA_DOOR:
|
||||
case BIRCH_DOOR:
|
||||
case IRON_DOOR:
|
||||
case JUNGLE_DOOR:
|
||||
case OAK_DOOR:
|
||||
case SPRUCE_DOOR:
|
||||
case DARK_OAK_DOOR:
|
||||
|
||||
case ACACIA_TRAPDOOR:
|
||||
case BIRCH_TRAPDOOR:
|
||||
case DARK_OAK_TRAPDOOR:
|
||||
case IRON_TRAPDOOR:
|
||||
case JUNGLE_TRAPDOOR:
|
||||
case OAK_TRAPDOOR:
|
||||
case SPRUCE_TRAPDOOR:
|
||||
|
||||
case ACACIA_FENCE_GATE:
|
||||
case BIRCH_FENCE_GATE:
|
||||
case DARK_OAK_FENCE_GATE:
|
||||
case JUNGLE_FENCE_GATE:
|
||||
case OAK_FENCE_GATE:
|
||||
case SPRUCE_FENCE_GATE:
|
||||
return PermissableAction.DOOR;
|
||||
|
||||
case CHEST:
|
||||
case TRAPPED_CHEST:
|
||||
case CHEST_MINECART:
|
||||
|
||||
case SHULKER_BOX:
|
||||
case BLACK_SHULKER_BOX:
|
||||
case BLUE_SHULKER_BOX:
|
||||
case BROWN_SHULKER_BOX:
|
||||
case CYAN_SHULKER_BOX:
|
||||
case GRAY_SHULKER_BOX:
|
||||
case GREEN_SHULKER_BOX:
|
||||
case LIGHT_BLUE_SHULKER_BOX:
|
||||
case LIGHT_GRAY_SHULKER_BOX:
|
||||
case LIME_SHULKER_BOX:
|
||||
case MAGENTA_SHULKER_BOX:
|
||||
case ORANGE_SHULKER_BOX:
|
||||
case PINK_SHULKER_BOX:
|
||||
case PURPLE_SHULKER_BOX:
|
||||
case RED_SHULKER_BOX:
|
||||
case WHITE_SHULKER_BOX:
|
||||
case YELLOW_SHULKER_BOX:
|
||||
|
||||
case FURNACE:
|
||||
case DROPPER:
|
||||
case DISPENSER:
|
||||
case ENCHANTING_TABLE:
|
||||
case BREWING_STAND:
|
||||
case CAULDRON:
|
||||
case HOPPER:
|
||||
case BEACON:
|
||||
case JUKEBOX:
|
||||
case ANVIL:
|
||||
case CHIPPED_ANVIL:
|
||||
case DAMAGED_ANVIL:
|
||||
return PermissableAction.CONTAINER;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
switch (material) {
|
||||
case LEVER:
|
||||
return PermissableAction.LEVER;
|
||||
case DARK_OAK_DOOR:
|
||||
case ACACIA_DOOR:
|
||||
case BIRCH_DOOR:
|
||||
case IRON_DOOR:
|
||||
case JUNGLE_DOOR:
|
||||
case SPRUCE_DOOR:
|
||||
|
||||
case ACACIA_FENCE_GATE:
|
||||
case BIRCH_FENCE_GATE:
|
||||
case DARK_OAK_FENCE_GATE:
|
||||
case OAK_FENCE_GATE:
|
||||
case JUNGLE_FENCE_GATE:
|
||||
case SPRUCE_FENCE_GATE:
|
||||
return PermissableAction.DOOR;
|
||||
case CHEST:
|
||||
case ENDER_CHEST:
|
||||
case TRAPPED_CHEST:
|
||||
case DISPENSER:
|
||||
case ENCHANTING_TABLE:
|
||||
case DROPPER:
|
||||
case FURNACE:
|
||||
case HOPPER:
|
||||
case ANVIL:
|
||||
case CHIPPED_ANVIL:
|
||||
case DAMAGED_ANVIL:
|
||||
case BREWING_STAND:
|
||||
return PermissableAction.CONTAINER;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void AsyncPlayerChatEvent(AsyncPlayerChatEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
@ -1026,4 +1006,21 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class InteractAttemptSpam {
|
||||
private int attempts = 0;
|
||||
private long lastAttempt = System.currentTimeMillis();
|
||||
|
||||
// returns the current attempt count
|
||||
public int increment() {
|
||||
long now = System.currentTimeMillis();
|
||||
if (now > lastAttempt + 2000) {
|
||||
attempts = 1;
|
||||
} else {
|
||||
attempts++;
|
||||
}
|
||||
lastAttempt = now;
|
||||
return attempts;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,6 @@ package com.massivecraft.factions.shop;
|
||||
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.cmd.logout.CmdLogout;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class CmdShop extends FCommand {
|
||||
|
@ -18,13 +18,6 @@ import java.util.List;
|
||||
|
||||
public class ShopClickPersistence implements Listener {
|
||||
|
||||
public void runCommands(List<String> list, Player p) {
|
||||
for (String cmd : list) {
|
||||
cmd = cmd.replace("%player%", p.getName());
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||
}
|
||||
}
|
||||
|
||||
public static String color(String line) {
|
||||
line = ChatColor.translateAlternateColorCodes('&', line);
|
||||
return line;
|
||||
@ -37,6 +30,13 @@ public class ShopClickPersistence implements Listener {
|
||||
return lore;
|
||||
}
|
||||
|
||||
public void runCommands(List<String> list, Player p) {
|
||||
for (String cmd : list) {
|
||||
cmd = cmd.replace("%player%", p.getName());
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void click(InventoryClickEvent e) {
|
||||
Inventory i = e.getClickedInventory();
|
||||
|
@ -13,9 +13,11 @@ public class ShopConfig {
|
||||
|
||||
public static File shop = new File("plugins/Factions/shop.yml");
|
||||
public static FileConfiguration s = YamlConfiguration.loadConfiguration(shop);
|
||||
|
||||
public static FileConfiguration getShop() {
|
||||
return s;
|
||||
}
|
||||
|
||||
public static void loadShop() {
|
||||
s = YamlConfiguration.loadConfiguration(shop);
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
@ -18,6 +18,7 @@ public enum Permission {
|
||||
BYPASS("bypass"),
|
||||
CHAT("chat"),
|
||||
CHATSPY("chatspy"),
|
||||
CHECK("check"),
|
||||
CLAIM("claim"),
|
||||
CLAIMAT("claimat"),
|
||||
CLAIM_LINE("claim.line"),
|
||||
|
@ -0,0 +1,23 @@
|
||||
package com.massivecraft.factions.util;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class CheckWallTask extends BukkitRunnable {
|
||||
|
||||
private int overtime;
|
||||
|
||||
public CheckWallTask() {
|
||||
overtime = 0;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
++overtime;
|
||||
for (Faction faction : Factions.getInstance().getAllFactions()) {
|
||||
if (faction.getCheckNotifier() != 0L && overtime % faction.getCheckNotifier() == 0L) {
|
||||
faction.sendCheckNotify();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -4,21 +4,20 @@ import com.github.stefvanschie.inventoryframework.Gui;
|
||||
import com.github.stefvanschie.inventoryframework.GuiItem;
|
||||
import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import java.util.Map;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class FactionWarpsFrame {
|
||||
|
||||
@ -35,7 +34,8 @@ public class FactionWarpsFrame {
|
||||
final List<GuiItem> GUIItems = new ArrayList<>();
|
||||
final List<Integer> slots = section.getIntegerList("warp-slots");
|
||||
int count = 0;
|
||||
for (int x = 0; x <= gui.getRows() * 9 - 1; ++x) GUIItems.add(new GuiItem(buildDummyItem(), e -> e.setCancelled(true)));
|
||||
for (int x = 0; x <= gui.getRows() * 9 - 1; ++x)
|
||||
GUIItems.add(new GuiItem(buildDummyItem(), e -> e.setCancelled(true)));
|
||||
slots.forEach(slot -> GUIItems.set(slot, new GuiItem(XMaterial.AIR.parseItem())));
|
||||
for (final Map.Entry<String, LazyLocation> warp : fplayer.getFaction().getWarps().entrySet()) {
|
||||
if (count > slots.size()) continue;
|
||||
|
@ -1318,7 +1318,8 @@ public enum XMaterial {
|
||||
*/
|
||||
public static String getExactMajorVersion(String version) {
|
||||
// getBukkitVersion()
|
||||
if (version.contains("SNAPSHOT") || version.contains("-R")) version = version.substring(0, version.indexOf("-"));
|
||||
if (version.contains("SNAPSHOT") || version.contains("-R"))
|
||||
version = version.substring(0, version.indexOf("-"));
|
||||
// getVersion()
|
||||
if (version.contains("git")) version = version.substring(version.indexOf("MC:") + 4).replace(")", "");
|
||||
if (version.split(Pattern.quote(".")).length > 2) version = version.substring(0, version.lastIndexOf("."));
|
||||
@ -1334,7 +1335,8 @@ public enum XMaterial {
|
||||
*/
|
||||
private static MinecraftVersion valueOfVersion(String version) {
|
||||
version = getExactMajorVersion(version);
|
||||
if (version.equals("1.10") || version.equals("1.11") || version.equals("1.12")) return MinecraftVersion.VERSION_1_9;
|
||||
if (version.equals("1.10") || version.equals("1.11") || version.equals("1.12"))
|
||||
return MinecraftVersion.VERSION_1_9;
|
||||
version = version.replace(".", "_");
|
||||
if (!version.startsWith("VERSION_")) version = "VERSION_" + version;
|
||||
String check = version;
|
||||
|
@ -1,5 +1,8 @@
|
||||
package com.massivecraft.factions.zcore.fperms;
|
||||
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import javafx.scene.paint.Material;
|
||||
|
||||
public class DefaultPermissions {
|
||||
public boolean ban;
|
||||
public boolean build;
|
||||
@ -27,6 +30,7 @@ public class DefaultPermissions {
|
||||
public boolean tntfill;
|
||||
public boolean withdraw;
|
||||
public boolean chest;
|
||||
public boolean check;
|
||||
public boolean spawner;
|
||||
|
||||
public DefaultPermissions() {
|
||||
@ -59,6 +63,7 @@ public class DefaultPermissions {
|
||||
this.tntfill = def;
|
||||
this.withdraw = def;
|
||||
this.chest = def;
|
||||
this.check = def;
|
||||
this.spawner = def;
|
||||
}
|
||||
|
||||
@ -88,6 +93,7 @@ public class DefaultPermissions {
|
||||
boolean canTntfill,
|
||||
boolean canWithdraw,
|
||||
boolean canChest,
|
||||
boolean canCheck,
|
||||
boolean canSpawners) {
|
||||
this.ban = canBan;
|
||||
this.build = canBuild;
|
||||
@ -115,6 +121,7 @@ public class DefaultPermissions {
|
||||
this.tntfill = canTntfill;
|
||||
this.withdraw = canWithdraw;
|
||||
this.chest = canChest;
|
||||
this.check = canCheck;
|
||||
this.spawner = canSpawners;
|
||||
}
|
||||
|
||||
@ -146,6 +153,7 @@ public class DefaultPermissions {
|
||||
else if (name == "tntfill") return this.tntfill;
|
||||
else if (name == "withdraw") return this.withdraw;
|
||||
else if (name == "chest") return this.chest;
|
||||
else if(name == "check") return this.check;
|
||||
else if (name == "spawner") return this.spawner;
|
||||
else return false;
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ public enum PermissableAction {
|
||||
TNTFILL("tntfill"),
|
||||
WITHDRAW("withdraw"),
|
||||
CHEST("chest"),
|
||||
CHECK("check"),
|
||||
SPAWNER("spawner");
|
||||
|
||||
private String name;
|
||||
|
@ -67,6 +67,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
protected Role defaultRole;
|
||||
protected Map<Permissable, Map<PermissableAction, Access>> permissions = new HashMap<>();
|
||||
protected Set<BanInfo> bans = new HashSet<>();
|
||||
protected long checkNotifier = 0;
|
||||
protected String player;
|
||||
Inventory chest;
|
||||
Map<String, Object> bannerSerialized;
|
||||
@ -97,6 +98,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
this.foundedDate = System.currentTimeMillis();
|
||||
this.maxVaults = Conf.defaultMaxVaults;
|
||||
this.defaultRole = Role.RECRUIT;
|
||||
this.checkNotifier = 0;
|
||||
resetPerms(); // Reset on new Faction so it has default values.
|
||||
}
|
||||
|
||||
@ -122,6 +124,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
invites = old.invites;
|
||||
announcements = old.announcements;
|
||||
this.defaultRole = Role.NORMAL;
|
||||
this.checkNotifier = 0;
|
||||
|
||||
resetPerms(); // Reset on new Faction so it has default values.
|
||||
}
|
||||
@ -342,6 +345,21 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCheckNotifier() {
|
||||
return this.checkNotifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCheckNotifier(final long minutes) {
|
||||
this.checkNotifier = minutes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCheckNotify() {
|
||||
this.sendMessage(TL.CHECK_NOTIFY_MESSAGE.toString());
|
||||
}
|
||||
|
||||
public Set<BanInfo> getBannedPlayers() {
|
||||
return this.bans;
|
||||
}
|
||||
|
@ -280,6 +280,11 @@ public enum TL {
|
||||
COMMAND_CREATE_CREATEDLOG(" created a new faction: "),
|
||||
COMMAND_CREATE_DESCRIPTION("Create a new faction"),
|
||||
|
||||
COMMAND_CHECK_INVALID_NUMBER("&c&l[!] &7You may not set your factions wall check timer to that number!"),
|
||||
COMMAND_CHECK_SUCCESSFUL("&c&l[!] &7You have set your factions wall check timer to &b%1$d &7minutes!"),
|
||||
COMMAND_CHECK_DESCRIPTION("Check your factions walls!"),
|
||||
CHECK_NOTIFY_MESSAGE("\n &c&lFaction Walls&7» &bCheck Your Walls! \n"),
|
||||
|
||||
COMMAND_DEINVITE_CANDEINVITE("&c&l[!]&7 Players you can &cdeinvite: "),
|
||||
COMMAND_DEINVITE_CLICKTODEINVITE("&c&l[!]&7 Click to &crevoke&7 invite for &c%1$s"),
|
||||
COMMAND_DEINVITE_ALREADYMEMBER("&c&l[!]&7 &c%1$s&7 is already a member of &c%2$s"),
|
||||
|
@ -472,6 +472,7 @@ fperm-gui:
|
||||
tntbank: BEACON
|
||||
tntfill: TNT
|
||||
chest: ENDER_CHEST
|
||||
check: WATCH
|
||||
spawner: MOB_SPAWNER
|
||||
home: ENDER_EYE
|
||||
slots:
|
||||
@ -505,8 +506,9 @@ fperm-gui:
|
||||
tntbank: 39
|
||||
tntfill: 41
|
||||
chest: 42
|
||||
check: 50
|
||||
spawner: 38
|
||||
home: 49
|
||||
home: 48
|
||||
# {action} Action name eg: Setwarp, Kick
|
||||
# {action-access} Access name eg: Allow, Deny
|
||||
# {action-access-color} Access color eg: Allow;GREEN
|
||||
|
@ -114,6 +114,8 @@ permissions:
|
||||
factions.banner: true
|
||||
factions.vault: true
|
||||
factions.getvault: true
|
||||
factions.check:
|
||||
description: give players access to use check commands
|
||||
factions.admin:
|
||||
description: hand over your admin rights
|
||||
factions.admin.any:
|
||||
|
Loading…
Reference in New Issue
Block a user