Merge pull request #134 from ImCarib/1.6.x

shields added
This commit is contained in:
Driftay 2020-06-08 05:39:38 -04:00 committed by GitHub
commit 0b677cb4de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 892 additions and 2333 deletions

27
pom.xml
View File

@ -41,6 +41,10 @@
<configuration> <configuration>
<createDependencyReducedPom>false</createDependencyReducedPom> <createDependencyReducedPom>false</createDependencyReducedPom>
<relocations> <relocations>
<relocation>
<pattern>com.github.cryptomorin</pattern>
<shadedPattern>com.massivecraft.factions.shade.github.cryptomorin</shadedPattern>
</relocation>
<relocation> <relocation>
<pattern>com.github.stefvanschie.inventoryframework</pattern> <pattern>com.github.stefvanschie.inventoryframework</pattern>
<shadedPattern>com.massivecraft.factions.shade.stefvanschie.inventoryframework</shadedPattern> <shadedPattern>com.massivecraft.factions.shade.stefvanschie.inventoryframework</shadedPattern>
@ -108,7 +112,8 @@
<dependency> <dependency>
<groupId>com.github.stefvanschie.inventoryframework</groupId> <groupId>com.github.stefvanschie.inventoryframework</groupId>
<artifactId>IF</artifactId> <artifactId>IF</artifactId>
<version>0.5.19</version> <version>0.5.8</version>
<scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
@ -138,6 +143,18 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>com.github.cryptomorin</groupId>
<artifactId>XSeries</artifactId>
<version>5.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.6</version>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>org.ocpsoft.prettytime</groupId> <groupId>org.ocpsoft.prettytime</groupId>
<artifactId>prettytime</artifactId> <artifactId>prettytime</artifactId>
@ -437,10 +454,10 @@
<id>net.coreprotect</id> <id>net.coreprotect</id>
<url>http://maven.playpro.com/</url> <url>http://maven.playpro.com/</url>
</repository> </repository>
<repository> <repository>
<id>codemc-repo</id> <id>codemc-repo</id>
<url>https://repo.codemc.org/repository/maven-public/</url> <url>https://repo.codemc.org/repository/maven-public/</url>
</repository> </repository>
<repository> <repository>
<id>ess-repo</id> <id>ess-repo</id>
<url>http://ci.ender.zone/plugin/repository/everything/</url> <url>http://ci.ender.zone/plugin/repository/everything/</url>

View File

@ -1,8 +1,8 @@
package com.massivecraft.factions; package com.massivecraft.factions;
import com.cryptomorin.xseries.XMaterial;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.massivecraft.factions.integration.dynmap.DynmapStyle; 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.DefaultPermissions;
import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.fperms.PermissableAction;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -103,6 +103,11 @@ public class Conf {
public static boolean worldGuardChecking = false; public static boolean worldGuardChecking = false;
public static boolean worldGuardBuildPriority = false; public static boolean worldGuardBuildPriority = false;
//SHIELDS
public static boolean useFShieldSystem = true;
public static int shieldTimeHours = 12;
public static int shieldFrameChangeCooldownHours = 24;
//RADIUS CLAIMING //RADIUS CLAIMING
public static boolean useRadiusClaimSystem = true; public static boolean useRadiusClaimSystem = true;

View File

@ -1,5 +1,6 @@
package com.massivecraft.factions; package com.massivecraft.factions;
import com.massivecraft.factions.cmd.shields.struct.frame.ShieldFramePersistence;
import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason; import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason;
import com.massivecraft.factions.iface.EconomyParticipator; import com.massivecraft.factions.iface.EconomyParticipator;
import com.massivecraft.factions.iface.RelationParticipator; import com.massivecraft.factions.iface.RelationParticipator;
@ -59,6 +60,24 @@ public interface Faction extends EconomyParticipator {
void setDiscord(String link); void setDiscord(String link);
boolean isProtected();
void setProtected();
void setUnprotected();
ShieldFramePersistence getShieldFrame();
void setupShieldChange(ShieldFramePersistence frame);
boolean pendingShieldChange();
long getShieldChangeTime();
ShieldFramePersistence getNewFrame();
void applyShield();
void checkPerms(); void checkPerms();
double getReinforcedArmor(); double getReinforcedArmor();

View File

@ -14,6 +14,9 @@ import com.massivecraft.factions.cmd.chest.AntiChestListener;
import com.massivecraft.factions.cmd.reserve.ListParameterizedType; import com.massivecraft.factions.cmd.reserve.ListParameterizedType;
import com.massivecraft.factions.cmd.reserve.ReserveAdapter; import com.massivecraft.factions.cmd.reserve.ReserveAdapter;
import com.massivecraft.factions.cmd.reserve.ReserveObject; import com.massivecraft.factions.cmd.reserve.ReserveObject;
import com.massivecraft.factions.cmd.shields.struct.ShieldTCMP;
import com.massivecraft.factions.cmd.shields.struct.frame.ShieldFrame;
import com.massivecraft.factions.cmd.shields.struct.tasks.ShieldManagement;
import com.massivecraft.factions.discord.Discord; import com.massivecraft.factions.discord.Discord;
import com.massivecraft.factions.discord.DiscordListener; import com.massivecraft.factions.discord.DiscordListener;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
@ -180,7 +183,7 @@ public class FactionsPlugin extends MPlugin {
} }
saveDefaultConfig(); saveDefaultConfig();
this.reloadConfig(); reloadConfig();
//Start wait task executor //Start wait task executor
WaitExecutor.startTask(); WaitExecutor.startTask();
// Load Conf from disk // Load Conf from disk
@ -193,6 +196,7 @@ public class FactionsPlugin extends MPlugin {
com.massivecraft.factions.integration.Essentials.setup(); com.massivecraft.factions.integration.Essentials.setup();
hookedPlayervaults = setupPlayervaults(); hookedPlayervaults = setupPlayervaults();
new ShieldTCMP();
FPlayers.getInstance().load(); FPlayers.getInstance().load();
Factions.getInstance().load(); Factions.getInstance().load();
@ -216,6 +220,7 @@ public class FactionsPlugin extends MPlugin {
Board.getInstance().load(); Board.getInstance().load();
Board.getInstance().clean(); Board.getInstance().clean();
new ShieldManagement();
//Load command aliases //Load command aliases
Aliases.load(); Aliases.load();
// Add Base Commands // Add Base Commands
@ -425,6 +430,7 @@ public class FactionsPlugin extends MPlugin {
.registerTypeAdapter(Inventory.class, new InventoryTypeAdapter()) .registerTypeAdapter(Inventory.class, new InventoryTypeAdapter())
.registerTypeAdapter(ReserveObject.class, new ReserveAdapter()) .registerTypeAdapter(ReserveObject.class, new ReserveAdapter())
.registerTypeAdapter(Location.class, new LocationTypeAdapter()) .registerTypeAdapter(Location.class, new LocationTypeAdapter())
.registerTypeAdapter(ShieldFrame.class, new ShieldFrameAdapter())
.registerTypeAdapterFactory(EnumTypeAdapter.ENUM_FACTORY); .registerTypeAdapterFactory(EnumTypeAdapter.ENUM_FACTORY);
} }
@ -482,7 +488,6 @@ public class FactionsPlugin extends MPlugin {
Conf.save(); Conf.save();
} }
public Economy getEcon() { public Economy getEcon() {
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class); RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
return rsp.getProvider(); return rsp.getProvider();

View File

@ -1,12 +1,12 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.cryptomorin.xseries.XMaterial;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.util.ParticleEffect; import com.massivecraft.factions.util.ParticleEffect;
import com.massivecraft.factions.util.VisualizeUtil; import com.massivecraft.factions.util.VisualizeUtil;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -1,7 +1,7 @@
package com.massivecraft.factions.cmd.audit; package com.massivecraft.factions.cmd.audit;
import com.cryptomorin.xseries.XMaterial;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.XMaterial;
import org.bukkit.Material; import org.bukkit.Material;
/** /**

View File

@ -1,10 +1,10 @@
package com.massivecraft.factions.cmd.check; package com.massivecraft.factions.cmd.check;
import com.cryptomorin.xseries.XMaterial;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.frame.FactionGUI; import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;

View File

@ -1,9 +1,9 @@
package com.massivecraft.factions.cmd.check; package com.massivecraft.factions.cmd.check;
import com.cryptomorin.xseries.XMaterial;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.frame.FactionGUI; import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -0,0 +1,42 @@
package com.massivecraft.factions.cmd.shields;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.cmd.CommandContext;
import com.massivecraft.factions.cmd.CommandRequirements;
import com.massivecraft.factions.cmd.FCommand;
import com.massivecraft.factions.cmd.shields.struct.frame.ShieldFrame;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL;
/**
* Factions - Developed by ImCarib.
* All rights reserved 2020.
* Creation Date: 5/23/2020
*/
public class CmdShield extends FCommand {
public CmdShield() {
this.aliases.add("shield");
this.requirements = new CommandRequirements.Builder(Permission.SHIELD)
.playerOnly()
.memberOnly()
.withAction(PermissableAction.SHIELD)
.build();
}
public void perform(CommandContext context) {
if (!Conf.useFShieldSystem) {
context.msg(TL.GENERIC_DISABLED);
return;
}
(new ShieldFrame()).build(context.fPlayer);
}
public TL getUsageTranslation() {
return TL.COMMAND_SHIELD_DESCRIPTION;
}
}

View File

@ -0,0 +1,41 @@
package com.massivecraft.factions.cmd.shields.struct;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.cmd.shields.struct.frame.ShieldFramePersistence;
import java.util.ArrayList;
import java.util.List;
/**
* Factions - Developed by ImCarib.
* All rights reserved 2020.
* Creation Date: 5/23/2020
*/
public class ShieldTCMP {
private static ShieldTCMP instance;
private List<ShieldFramePersistence> frames = new ArrayList<>();
public ShieldTCMP() {
instance = this;
for (int x = 0; x <= 23; x++) {
int end = (x + Conf.shieldTimeHours > 23) ? (x + Conf.shieldTimeHours - 24) : (x + Conf.shieldTimeHours);
this.frames.add(new ShieldFramePersistence(x, end));
}
}
public static ShieldTCMP getInstance() {
return instance;
}
public ShieldFramePersistence getByStart(int start) {
if (start > 23) return null;
return this.frames.get(start);
}
public List<ShieldFramePersistence> getFrames() {
return this.frames;
}
}

View File

@ -0,0 +1,75 @@
package com.massivecraft.factions.cmd.shields.struct.frame;
import com.cryptomorin.xseries.XMaterial;
import com.github.stefvanschie.inventoryframework.Gui;
import com.github.stefvanschie.inventoryframework.GuiItem;
import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.cmd.shields.struct.tasks.ShieldManagement;
import com.massivecraft.factions.util.ItemBuilder;
import com.massivecraft.factions.util.Placeholder;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.List;
/**
* Factions - Developed by ImCarib.
* All rights reserved 2020.
* Creation Date: 5/23/2020
*/
public class ShieldConfirmationFrame {
private Gui gui;
public ShieldConfirmationFrame() {
this.gui = new Gui(FactionsPlugin.getInstance(),
FactionsPlugin.getInstance().getConfig().getInt("Shields.Frame.Change.Size"),
FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("Shields.Frame.Change.Title")));
}
public void build(FPlayer fme, ShieldFramePersistence frame) {
PaginatedPane pane = new PaginatedPane(0, 0, 9, this.gui.getRows());
List<GuiItem> GUIItems = new ArrayList<>();
for (int x = 0; x <= this.gui.getRows() * 9 - 1; ) {
GUIItems.add(new GuiItem(XMaterial.AIR.parseItem(), e -> e.setCancelled(true)));
x++;
}
ItemStack[] assets = buildAssets(frame);
GUIItems.set(4, new GuiItem(assets[0], e -> e.setCancelled(true)));
GUIItems.set(11, new GuiItem(assets[1], e -> {
e.setCancelled(true);
fme.getFaction().setupShieldChange(frame);
(new ShieldFrame()).build(fme);
}));
GUIItems.set(15, new GuiItem(assets[2], e -> {
e.setCancelled(true);
(new ShieldFrame()).build(fme);
}));
pane.populateWithGuiItems(GUIItems);
this.gui.addPane(pane);
this.gui.update();
this.gui.show(fme.getPlayer());
}
private ItemStack[] buildAssets(ShieldFramePersistence frame) {
String path = "Shields.Frame.Change.Items.";
return new ItemStack[]{new ItemBuilder(
XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString(path + "Info.Type")).get().parseItem())
.name(FactionsPlugin.getInstance().getConfig().getString(path + "Info.Display-Name"))
.lore(FactionsPlugin.getInstance().replacePlaceholders(FactionsPlugin.getInstance().getConfig().getStringList(path + "Info.Lore"),
new Placeholder("{start-time}", frame.getStartTime()),
new Placeholder("{end-time}", frame.getEndTime()),
new Placeholder("{current-time}", ShieldManagement.getCurrentTime()))).build(),
new ItemBuilder(
XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString(path + "Accept.Type")).get().parseItem())
.name(FactionsPlugin.getInstance().getConfig().getString(path + "Accept.Display-Name"))
.lore(FactionsPlugin.getInstance().getConfig().getStringList(path + "Accept.Lore")).build(),
new ItemBuilder(XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString(path + "Deny.Type")).get().parseItem())
.name(FactionsPlugin.getInstance().getConfig().getString(path + "Deny.Display-Name"))
.lore(FactionsPlugin.getInstance().getConfig().getStringList(path + "Deny.Lore")).build()};
}
}

View File

@ -0,0 +1,171 @@
package com.massivecraft.factions.cmd.shields.struct.frame;
import com.cryptomorin.xseries.XMaterial;
import com.github.stefvanschie.inventoryframework.Gui;
import com.github.stefvanschie.inventoryframework.GuiItem;
import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.cmd.shields.struct.ShieldTCMP;
import com.massivecraft.factions.cmd.shields.struct.tasks.ShieldManagement;
import com.massivecraft.factions.util.ItemBuilder;
import com.massivecraft.factions.util.Placeholder;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* Factions - Developed by ImCarib.
* All rights reserved 2020.
* Creation Date: 5/21/2020
*/
public class ShieldFrame {
public Gui gui;
public ShieldFrame() {
this.gui = new Gui(FactionsPlugin.getInstance(), 5, FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("Shields.Frame.Main-Menu.Title")));
}
public static String formatTimeMilliseconds(long milliseconds) {
long seconds = milliseconds / 1000L;
long minutes = seconds / 60L;
seconds %= 60L;
long hours = minutes / 60L;
minutes %= 60L;
long days = hours / 24L;
hours %= 24L;
long months = days / 31L;
days %= 31L;
if (months != 0L)
return months + "M " + days + "d " + hours + "h ";
if (days != 0L)
return days + "d " + hours + "h " + minutes + "m ";
if (hours != 0L)
return hours + "h " + minutes + "m " + seconds + "s";
if (minutes != 0L)
return minutes + "m " + seconds + "s";
if (seconds != 0L)
return seconds + "s";
return "";
}
public void build(FPlayer fme) {
PaginatedPane pane = new PaginatedPane(0, 0, 9, this.gui.getRows());
List<GuiItem> GUIItems = new ArrayList<>();
for (int x = 0; x <= this.gui.getRows() * 9 - 1; x++)
GUIItems.add(new GuiItem(new ItemStack(Material.AIR), e -> e.setCancelled(true)));
for (int slot : FactionsPlugin.getInstance().getConfig().getIntegerList("Shields.Frame.Frame-Type.Barrier.Slots")) {
GUIItems.set(slot, new GuiItem(buildBarrierDummyItem(), e -> e.setCancelled(true)));
}
int x = 0;
for (ShieldFramePersistence frame : ShieldTCMP.getInstance().getFrames()) {
ItemStack item = buildShieldFrames(fme.getFaction(), frame);
if (fme.getFaction().getShieldFrame() != null &&
fme.getFaction().getShieldFrame().equals(frame)) {
GUIItems.set(x, new GuiItem(item, e -> e.setCancelled(true)));
x++;
continue;
}
if (fme.getFaction().getNewFrame() != null &&
fme.getFaction().getNewFrame().equals(frame)) {
GUIItems.set(x, new GuiItem(item, e -> e.setCancelled(true)));
x++;
continue;
}
GUIItems.set(x, new GuiItem(item, e -> {
e.setCancelled(true);
(new ShieldConfirmationFrame()).build(fme, frame);
}));
x++;
}
ItemStack[] assets = getAssets(fme.getFaction());
GUIItems.set(39, new GuiItem(assets[0], e -> e.setCancelled(true)));
GUIItems.set(41, new GuiItem(assets[1], e -> e.setCancelled(true)));
pane.populateWithGuiItems(GUIItems);
this.gui.addPane(pane);
this.gui.update();
this.gui.show(fme.getPlayer());
}
private ItemStack[] getAssets(Faction f) {
ItemStack change;
ConfigurationSection sec = FactionsPlugin.getInstance().getConfig().getConfigurationSection("Shields.Frame.Frame-Type.");
assert sec != null;
ItemStack info = (new ItemBuilder(XMaterial.matchXMaterial(sec.getString("Info-Item.Type")).get().parseItem()).name(sec.getString("Info-Item.Display-Name")).lore(sec.getStringList("Info-Item.Lore")).build());
if (f.pendingShieldChange()) {
change = (new ItemBuilder(XMaterial.matchXMaterial(sec.getString("Shield-Pending.Type")).get().parseItem()).name(sec.getString("Shield-Pending.Display-Name")).lore(FactionsPlugin.getInstance().replacePlaceholders(sec.getStringList("Shield-Pending.Lore"),
new Placeholder("{remaining-time}", timeUntilChange(f)),
new Placeholder("{new-start}", f.getNewFrame().getStartTime()),
new Placeholder("{new-end}", f.getNewFrame().getEndTime())))).build();
} else {
change = (new ItemBuilder(XMaterial.matchXMaterial(sec.getString("NoShield-Pending.Type")).get().parseItem()).name(sec.getString("NoShield-Pending.Display-Name")).lore(sec.getStringList("NoShield-Pending.Lore")).build());
}
return new ItemStack[]{info, change};
}
private String timeUntilChange(Faction f) {
long time = f.getShieldChangeTime();
time -= System.currentTimeMillis();
return formatTimeMilliseconds(time);
}
private ItemStack buildShieldFrames(Faction faction, ShieldFramePersistence frame) {
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("Shields.Frame.Frame-Type");
if (faction.getShieldFrame() != null && faction.getShieldFrame().equals(frame)) {
ItemStack item = XMaterial.matchXMaterial(config.getString("Current-Frame.Type")).get().parseItem();
ItemMeta meta = item.getItemMeta();
meta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().replacePlaceholders(config.getStringList("Current-Frame.Lore"),
new Placeholder("{time-currently}", ShieldManagement.getCurrentTime()),
new Placeholder("{remaining-time}", timeUntilChange(faction)),
new Placeholder("{start-time}", frame.getStartTime()),
new Placeholder("{end-time}", frame.getEndTime()))));
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Current-Frame.Display-Name")));
item.setItemMeta(meta);
return item;
}
if (faction.getNewFrame() != null && faction.getNewFrame().equals(frame)) {
ItemStack item = XMaterial.matchXMaterial(config.getString("New-Frame.Type")).get().parseItem();
ItemMeta meta = item.getItemMeta();
meta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().replacePlaceholders(config.getStringList("New-Frame.Lore"),
new Placeholder("{time-currently}", ShieldManagement.getCurrentTime()),
new Placeholder("{remaining-time}", timeUntilChange(faction)),
new Placeholder("{start-time}", frame.getStartTime()),
new Placeholder("{end-time}", frame.getEndTime()))));
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("New-Frame.Display-Name")));
item.setItemMeta(meta);
return item;
}
ItemStack item = XMaterial.matchXMaterial(config.getString("Regular-Frame.Type")).get().parseItem();
ItemMeta meta = item.getItemMeta();
meta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().replacePlaceholders(config.getStringList("Regular-Frame.Lore"),
new Placeholder("{time-currently}", ShieldManagement.getCurrentTime()),
new Placeholder("{remaining-time}", timeUntilChange(faction)),
new Placeholder("{start-time}", frame.getStartTime()),
new Placeholder("{end-time}", frame.getEndTime()))));
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Regular-Frame.Display-Name")));
item.setItemMeta(meta);
return item;
}
private ItemStack buildBarrierDummyItem() {
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("Shields.Frame.Frame-Type.Barrier.");
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
ItemMeta meta = item.getItemMeta();
if (meta != null) {
List<String> lore = new ArrayList<>();
for (String s : config.getStringList("Lore")) lore.add(FactionsPlugin.getInstance().color(s));
meta.setLore(lore);
meta.setDisplayName(FactionsPlugin.getInstance().color(Objects.requireNonNull(config.getString("Name"))));
item.setItemMeta(meta);
}
return item;
}
}

View File

@ -0,0 +1,54 @@
package com.massivecraft.factions.cmd.shields.struct.frame;
import com.massivecraft.factions.cmd.shields.struct.tasks.ShieldManagement;
/**
* Factions - Developed by ImCarib.
* All rights reserved 2020.
* Creation Date: 5/23/2020
*/
public class ShieldFramePersistence {
private int start;
private int end;
public ShieldFramePersistence(int start, int end) {
this.start = start;
this.end = end;
}
public int getEndParsed() {
return this.end;
}
public int getStartParsed() {
return this.start;
}
public String getStartTime() {
return toClockFormat(this.start);
}
public String getEndTime() {
return toClockFormat(this.end);
}
public boolean isHourProtected(int hour) {
if (this.end < this.start) return hour >= this.start;
return (hour >= this.start && hour < this.end);
}
public boolean isProtectedCurrent() {
return isHourProtected(ShieldManagement.getCurrentHour());
}
public String toClockFormat(int x) {
if (x == 0) return "12:00 am";
if (x == 12) return "12:00 pm";
if (x > 12) return (x - 12) + ":00 pm";
return x + ":00 am";
}
}

View File

@ -0,0 +1,57 @@
package com.massivecraft.factions.cmd.shields.struct.tasks;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.cmd.shields.struct.ShieldTCMP;
import org.bukkit.Bukkit;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
/**
* Factions - Developed by ImCarib.
* All rights reserved 2020.
* Creation Date: 5/23/2020
*/
public class ShieldManagement implements Runnable {
private static DateTimeZone zone = DateTimeZone.forID("Canada/Eastern");
private int lastHour;
public ShieldManagement() {
new ShieldTCMP();
this.lastHour = 25;
Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), this, 20L, 1200L);
}
public static int getCurrentHour() {
DateTime time = new DateTime(zone);
return time.getHourOfDay();
}
public static String getCurrentTime() {
DateTime time = new DateTime(zone);
int hour = time.getHourOfDay();
if (hour == 0) hour = 12;
if (hour > 12)
return (hour - 12) + ":" + ((time.getMinuteOfHour() < 10) ? ("0" + time.getMinuteOfHour()) : Integer.valueOf(time.getMinuteOfHour())) + " pm";
return hour + ":" + ((time.getMinuteOfHour() < 10) ? ("0" + time.getMinuteOfHour()) : Integer.valueOf(time.getMinuteOfHour())) + " am";
}
public void run() {
DateTime time = new DateTime(zone);
int hour = time.getHourOfDay();
if (this.lastHour == 25 || this.lastHour != hour) {
long now = System.currentTimeMillis();
Factions.getInstance().getAllFactions().forEach(faction -> {
if (faction.pendingShieldChange() && faction.getShieldChangeTime() < now) faction.applyShield();
if (faction.getShieldFrame() != null) {
if (faction.getShieldFrame().isHourProtected(hour)) faction.setProtected();
} else {
faction.setUnprotected();
}
});
}
}
}

View File

@ -1,5 +1,6 @@
package com.massivecraft.factions.cmd.tnt; package com.massivecraft.factions.cmd.tnt;
import com.cryptomorin.xseries.XMaterial;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.cmd.Aliases; import com.massivecraft.factions.cmd.Aliases;
import com.massivecraft.factions.cmd.CommandContext; import com.massivecraft.factions.cmd.CommandContext;
@ -7,7 +8,6 @@ import com.massivecraft.factions.cmd.CommandRequirements;
import com.massivecraft.factions.cmd.FCommand; import com.massivecraft.factions.cmd.FCommand;
import com.massivecraft.factions.cmd.audit.FLogType; import com.massivecraft.factions.cmd.audit.FLogType;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Material; import org.bukkit.Material;

View File

@ -1,8 +1,8 @@
package com.massivecraft.factions.cmd.wild; package com.massivecraft.factions.cmd.wild;
import com.cryptomorin.xseries.XMaterial;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.util.wait.WaitExecutor; import com.massivecraft.factions.util.wait.WaitExecutor;
import com.massivecraft.factions.util.wait.WaitTask; import com.massivecraft.factions.util.wait.WaitTask;
import com.massivecraft.factions.zcore.frame.FactionGUI; import com.massivecraft.factions.zcore.frame.FactionGUI;

View File

@ -36,8 +36,8 @@ public class TempLine {
if (line.p1.x == this.p1.x && line.p2.x == this.p2.x && line.p1.y == this.p1.y && line.p2.y == this.p2.y) { if (line.p1.x == this.p1.x && line.p2.x == this.p2.x && line.p1.y == this.p1.y && line.p2.y == this.p2.y) {
return true; return true;
} }
return line.p1.x == this.p2.x && line.p2.x == this.p1.x && line.p1.y == this.p2.y && line.p2.y == this.p1.y; return line.p1.x == this.p2.x && line.p2.x == this.p1.x && line.p1.y == this.p2.y && line.p2.y == this.p1.y;
} }
@Override @Override
public int hashCode() { public int hashCode() {

View File

@ -1,5 +1,6 @@
package com.massivecraft.factions.listeners; package com.massivecraft.factions.listeners;
import com.cryptomorin.xseries.XMaterial;
import com.massivecraft.factions.*; import com.massivecraft.factions.*;
import com.massivecraft.factions.cmd.audit.FLogManager; import com.massivecraft.factions.cmd.audit.FLogManager;
import com.massivecraft.factions.cmd.audit.LogTimer; import com.massivecraft.factions.cmd.audit.LogTimer;
@ -8,7 +9,6 @@ import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.ItemBuilder; import com.massivecraft.factions.util.ItemBuilder;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
@ -430,7 +430,7 @@ public class FactionsBlockListener implements Listener {
if (!justCheck) fPlayer.setLastFrostwalkerMessage(); if (!justCheck) fPlayer.setLastFrostwalkerMessage();
// Check if they have build permissions here. If not, block this from happening. // Check if they have build permissions here. If not, block this from happening.
if (!playerCanBuildDestroyBlock(player, location, "frostwalk", justCheck)) if (!playerCanBuildDestroyBlock(player, location, PermissableAction.FROST_WALK.toString(), justCheck))
event.setCancelled(true); event.setCancelled(true);
} }
@ -512,6 +512,7 @@ public class FactionsBlockListener implements Listener {
Player p = (Player) event.getRemover(); Player p = (Player) event.getRemover();
if (!playerCanBuildDestroyBlock(p, event.getEntity().getLocation(), "destroy", true)) { if (!playerCanBuildDestroyBlock(p, event.getEntity().getLocation(), "destroy", true)) {
event.setCancelled(true); event.setCancelled(true);
return;
} }
} }
} }
@ -521,7 +522,7 @@ public class FactionsBlockListener implements Listener {
public void onFarmLandDamage(EntityChangeBlockEvent event) { public void onFarmLandDamage(EntityChangeBlockEvent event) {
if (event.getEntity() instanceof Player) { if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity(); Player player = (Player) event.getEntity();
if (!playerCanBuildDestroyBlock(player, event.getBlock().getLocation(), "destroy", true)) { if (!playerCanBuildDestroyBlock(player, event.getBlock().getLocation(), PermissableAction.DESTROY.name(), true)) {
FPlayer me = FPlayers.getInstance().getByPlayer(player); FPlayer me = FPlayers.getInstance().getByPlayer(player);
Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock().getLocation())); Faction otherFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock().getLocation()));
me.msg(TL.ACTION_DENIED_OTHER, otherFaction.getTag(), "trample crops"); me.msg(TL.ACTION_DENIED_OTHER, otherFaction.getTag(), "trample crops");
@ -529,4 +530,4 @@ public class FactionsBlockListener implements Listener {
} }
} }
} }
} }

View File

@ -257,6 +257,7 @@ public class FactionsEntityListener implements Listener {
private boolean checkExplosionForBlock(Entity boomer, Block block) { private boolean checkExplosionForBlock(Entity boomer, Block block) {
Faction faction = Board.getInstance().getFactionAt(new FLocation(block.getLocation())); Faction faction = Board.getInstance().getFactionAt(new FLocation(block.getLocation()));
if (faction.isProtected()) return false;
if (faction.noExplosionsInTerritory() || (faction.isPeaceful() && Conf.peacefulTerritoryDisableBoom)) if (faction.noExplosionsInTerritory() || (faction.isPeaceful() && Conf.peacefulTerritoryDisableBoom))
return false; return false;

View File

@ -1,7 +1,7 @@
package com.massivecraft.factions.listeners; package com.massivecraft.factions.listeners;
import com.cryptomorin.xseries.XMaterial;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.util.XMaterial;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;

View File

@ -1,5 +1,6 @@
package com.massivecraft.factions.listeners; package com.massivecraft.factions.listeners;
import com.cryptomorin.xseries.XMaterial;
import com.massivecraft.factions.*; import com.massivecraft.factions.*;
import com.massivecraft.factions.cmd.CmdFGlobal; import com.massivecraft.factions.cmd.CmdFGlobal;
import com.massivecraft.factions.cmd.CmdFly; import com.massivecraft.factions.cmd.CmdFly;
@ -20,7 +21,6 @@ import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.CC; import com.massivecraft.factions.util.CC;
import com.massivecraft.factions.util.VisualizeUtil; import com.massivecraft.factions.util.VisualizeUtil;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.util.wait.WaitExecutor; import com.massivecraft.factions.util.wait.WaitExecutor;
import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.fperms.PermissableAction;
@ -335,131 +335,36 @@ public class FactionsPlayerListener implements Listener {
} }
private static PermissableAction GetPermissionFromUsableBlock(Material material) { private static PermissableAction GetPermissionFromUsableBlock(Material material) {
// Check for doors that might have diff material name in old version. if (material.name().contains("_BUTTON")
if (material.name().contains("DOOR") || material.name().contains("FENCE_GATE")) || material.name().contains("COMPARATOR")
return PermissableAction.DOOR; || material.name().contains("PRESSURE")
if (material.name().toUpperCase().contains("BUTTON") || material.name().toUpperCase().contains("PRESSURE") || material.name().contains("DIODE") || material.name().contains("COMPARATOR")) || material.name().contains("REPEATER")
return PermissableAction.BUTTON; || material.name().contains("DIODE")) return PermissableAction.BUTTON;
if (FactionsPlugin.instance.mc113 || FactionsPlugin.instance.mc114 || FactionsPlugin.getInstance().mc115) { if (material.name().contains("_DOOR")
switch (material) { || material.name().contains("_TRAPDOOR")
case LEVER: || material.name().contains("_FENCE_GATE")
return PermissableAction.LEVER; || material.name().startsWith("FENCE_GATE")) return PermissableAction.DOOR;
case ACACIA_BUTTON: if (material.name().contains("SHULKER_BOX")
case BIRCH_BUTTON: || material.name().endsWith("ANVIL")
case DARK_OAK_BUTTON: || material.name().startsWith("CHEST_MINECART")
case JUNGLE_BUTTON: || material.name().endsWith("CHEST")
case OAK_BUTTON: || material.name().endsWith("JUKEBOX")
case SPRUCE_BUTTON: || material.name().endsWith("CAULDRON")
case STONE_BUTTON: || material.name().endsWith("FURNACE")
case COMPARATOR: || material.name().endsWith("HOPPER")
case REPEATER: || material.name().endsWith("BEACON")
return PermissableAction.BUTTON; || material.name().startsWith("TRAPPED_CHEST")
|| material.name().equalsIgnoreCase("ENCHANTING_TABLE")
case ACACIA_DOOR: || material.name().equalsIgnoreCase("ENCHANTMENT_TABLE")
case BIRCH_DOOR: || material.name().endsWith("BREWING_STAND")
case IRON_DOOR: || material.name().equalsIgnoreCase("BARREL")) return PermissableAction.CONTAINER;
case JUNGLE_DOOR: if (material.name().endsWith("LEVER")) return PermissableAction.LEVER;
case OAK_DOOR: switch (material) {
case SPRUCE_DOOR: case DISPENSER:
case DARK_OAK_DOOR: case DROPPER:
return PermissableAction.CONTAINER;
case ACACIA_TRAPDOOR: default:
case BIRCH_TRAPDOOR: return null;
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 BARREL:
case COMPOSTER:
case LOOM:
case CARTOGRAPHY_TABLE:
case GRINDSTONE:
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 BLAST_FURNACE:
case SMOKER:
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 OAK_FENCE_GATE:
case DARK_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 BLAST_FURNACE:
case SMOKER:
case HOPPER:
case ANVIL:
case CHIPPED_ANVIL:
case DAMAGED_ANVIL:
case BREWING_STAND:
return PermissableAction.CONTAINER;
default:
return null;
}
} }
} }
@ -737,9 +642,7 @@ public class FactionsPlayerListener implements Listener {
me.attemptClaim(me.getAutoClaimFor(), newLocation, true); me.attemptClaim(me.getAutoClaimFor(), newLocation, true);
} }
FactionsPlugin.instance.logFactionEvent(me.getAutoClaimFor(), FLogType.CHUNK_CLAIMS, me.getName(), CC.GreenB + "CLAIMED", String.valueOf(1), (new FLocation(player.getLocation())).formatXAndZ(",")); FactionsPlugin.instance.logFactionEvent(me.getAutoClaimFor(), FLogType.CHUNK_CLAIMS, me.getName(), CC.GreenB + "CLAIMED", String.valueOf(1), (new FLocation(player.getLocation())).formatXAndZ(","));
if (Conf.disableFlightOnFactionClaimChange && FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) if (Conf.disableFlightOnFactionClaimChange) CmdFly.disableFlight(me);
CmdFly.disableFlight(me);
} else if (me.isAutoSafeClaimEnabled()) { } else if (me.isAutoSafeClaimEnabled()) {
if (!Permission.MANAGE_SAFE_ZONE.has(player)) { if (!Permission.MANAGE_SAFE_ZONE.has(player)) {
me.setIsAutoSafeClaimEnabled(false); me.setIsAutoSafeClaimEnabled(false);
@ -812,7 +715,11 @@ public class FactionsPlayerListener implements Listener {
Material type; Material type;
if (event.getItem() != null) { if (event.getItem() != null) {
// Convert 1.8 Material Names -> 1.15 // Convert 1.8 Material Names -> 1.15
type = XMaterial.matchXMaterial(event.getItem().getType().toString()).get().parseMaterial(); try {
type = XMaterial.matchXMaterial(event.getItem().getType().toString()).get().parseMaterial();
} catch (NullPointerException npe) {
type = null;
}
} else { } else {
type = null; type = null;
} }
@ -861,7 +768,7 @@ public class FactionsPlayerListener implements Listener {
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == XMaterial.GRASS_BLOCK.parseMaterial() if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == XMaterial.GRASS_BLOCK.parseMaterial()
&& event.hasItem() && event.getItem().getType() == XMaterial.BONE_MEAL.parseMaterial()) { && event.hasItem() && event.getItem().getType() == XMaterial.BONE_MEAL.parseMaterial()) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), "build", true)) { if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD.name(), true)) {
FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString()); FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString());
Faction myFaction = me.getFaction(); Faction myFaction = me.getFaction();

View File

@ -1,8 +1,8 @@
package com.massivecraft.factions.missions; package com.massivecraft.factions.missions;
import com.cryptomorin.xseries.XMaterial;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.frame.FactionGUI; import com.massivecraft.factions.zcore.frame.FactionGUI;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -1,5 +1,6 @@
package com.massivecraft.factions.shop; package com.massivecraft.factions.shop;
import com.cryptomorin.xseries.XMaterial;
import com.github.stefvanschie.inventoryframework.Gui; import com.github.stefvanschie.inventoryframework.Gui;
import com.github.stefvanschie.inventoryframework.GuiItem; import com.github.stefvanschie.inventoryframework.GuiItem;
import com.github.stefvanschie.inventoryframework.pane.PaginatedPane; import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
@ -7,7 +8,6 @@ import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -134,6 +134,7 @@ public enum Permission {
SCOREBOARD("scoreboard"), SCOREBOARD("scoreboard"),
SEECHUNK("seechunk"), SEECHUNK("seechunk"),
SETWARP("setwarp"), SETWARP("setwarp"),
SHIELD("shield"),
SHOP("shop"), SHOP("shop"),
TOP("top"), TOP("top"),
VIEWCHEST("viewchest"), VIEWCHEST("viewchest"),

View File

@ -1,8 +1,8 @@
package com.massivecraft.factions.struct; package com.massivecraft.factions.struct;
import com.cryptomorin.xseries.XMaterial;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.fperms.Permissable; import com.massivecraft.factions.zcore.fperms.Permissable;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -1,8 +1,8 @@
package com.massivecraft.factions.struct; package com.massivecraft.factions.struct;
import com.cryptomorin.xseries.XMaterial;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.fperms.Permissable; import com.massivecraft.factions.zcore.fperms.Permissable;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -6,6 +6,7 @@ package com.massivecraft.factions.util;
* Creation Date: 4/4/2020 * Creation Date: 4/4/2020
*/ */
import com.cryptomorin.xseries.XMaterial;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.Location; import org.bukkit.Location;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,37 @@
package com.massivecraft.factions.util.adapters;
import com.google.gson.*;
import com.massivecraft.factions.cmd.shields.struct.ShieldTCMP;
import com.massivecraft.factions.cmd.shields.struct.frame.ShieldFramePersistence;
import java.lang.reflect.Type;
/**
* Factions - Developed by ImCarib.
* All rights reserved 2020.
* Creation Date: 5/23/2020
*/
public class ShieldFrameAdapter implements JsonDeserializer<ShieldFramePersistence>, JsonSerializer<ShieldFramePersistence> {
public ShieldFramePersistence deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
try {
JsonObject obj = json.getAsJsonObject();
int frame = obj.get("id").getAsInt();
return ShieldTCMP.getInstance().getByStart(frame);
} catch (Exception ex) {
ex.printStackTrace();
return null;
}
}
public JsonElement serialize(ShieldFramePersistence src, Type typeOfSrc, JsonSerializationContext context) {
JsonObject obj = new JsonObject();
try {
obj.addProperty("id", src.getStartParsed());
return obj;
} catch (Exception ex) {
ex.printStackTrace();
return obj;
}
}
}

View File

@ -3,14 +3,9 @@ package com.massivecraft.factions.zcore.fperms;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
public enum Access { public enum Access {
/**
* @author Illyria Team
*/
ALLOW("Allow"), ALLOW("Allow"),
DENY("Deny"), UNDEFINED("Undefined"),
UNDEFINED("Undefined"); DENY("Deny");
private final String name; private final String name;
@ -31,11 +26,6 @@ public enum Access {
return null; return null;
} }
public static Access booleanToAccess(boolean access) {
if (access) return Access.ALLOW;
else return Access.DENY;
}
public String getName() { public String getName() {
return this.name.toLowerCase(); return this.name.toLowerCase();
} }

View File

@ -34,6 +34,7 @@ public class DefaultPermissions {
public boolean chest; public boolean chest;
public boolean check; public boolean check;
public boolean drain; public boolean drain;
public boolean shield;
public boolean spawner; public boolean spawner;
public DefaultPermissions() { public DefaultPermissions() {
@ -68,6 +69,7 @@ public class DefaultPermissions {
this.chest = def; this.chest = def;
this.check = def; this.check = def;
this.drain = def; this.drain = def;
this.shield = def;
this.spawner = def; this.spawner = def;
} }
@ -99,6 +101,7 @@ public class DefaultPermissions {
boolean canChest, boolean canChest,
boolean canCheck, boolean canCheck,
boolean canDrain, boolean canDrain,
boolean canShield,
boolean canSpawners) { boolean canSpawners) {
this.ban = canBan; this.ban = canBan;
this.build = canBuild; this.build = canBuild;
@ -128,6 +131,7 @@ public class DefaultPermissions {
this.chest = canChest; this.chest = canChest;
this.check = canCheck; this.check = canCheck;
this.drain = canDrain; this.drain = canDrain;
this.shield = canShield;
this.spawner = canSpawners; this.spawner = canSpawners;
} }
@ -161,6 +165,7 @@ public class DefaultPermissions {
else if (name == "chest") return this.chest; else if (name == "chest") return this.chest;
else if (name == "check") return this.check; else if (name == "check") return this.check;
else if (name == "drain") return this.drain; else if (name == "drain") return this.drain;
else if (name == "shield") return this.shield;
else if (name == "spawner") return this.spawner; else if (name == "spawner") return this.spawner;
else return false; else return false;
} }

View File

@ -1,9 +1,10 @@
package com.massivecraft.factions.zcore.fperms; package com.massivecraft.factions.zcore.fperms;
import com.cryptomorin.xseries.XMaterial;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.Placeholder; import com.massivecraft.factions.util.Placeholder;
import com.massivecraft.factions.util.XMaterial; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
@ -46,6 +47,7 @@ public enum PermissableAction {
WITHDRAW("withdraw"), WITHDRAW("withdraw"),
CHEST("chest"), CHEST("chest"),
CHECK("check"), CHECK("check"),
SHIELD("shield"),
SPAWNER("spawner"); SPAWNER("spawner");
private String name; private String name;
@ -66,9 +68,14 @@ public enum PermissableAction {
return permissableAction; return permissableAction;
} }
} }
return null; return null;
} }
public int getSlot() {
return FactionsPlugin.getInstance().getConfig().getInt("fperm-gui.action.slots." + this.name.toLowerCase());
}
public static Map<PermissableAction, Access> fromDefaults(DefaultPermissions defaultPermissions) { public static Map<PermissableAction, Access> fromDefaults(DefaultPermissions defaultPermissions) {
Map<PermissableAction, Access> defaultMap = new HashMap<>(); Map<PermissableAction, Access> defaultMap = new HashMap<>();
for (PermissableAction permissableAction : PermissableAction.values()) { for (PermissableAction permissableAction : PermissableAction.values()) {
@ -77,17 +84,6 @@ public enum PermissableAction {
return defaultMap; return defaultMap;
} }
public static PermissableAction fromSlot(int slot) {
for (PermissableAction action : PermissableAction.values()) {
if (action.getSlot() == slot) return action;
}
return null;
}
public int getSlot() {
return FactionsPlugin.getInstance().getConfig().getInt("fperm-gui.action.slots." + this.name.toLowerCase());
}
/** /**
* Get the friendly name of this action. Used for editing in commands. * Get the friendly name of this action. Used for editing in commands.
* *
@ -106,17 +102,37 @@ public enum PermissableAction {
ConfigurationSection section = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.action"); ConfigurationSection section = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.action");
ItemStack item = XMaterial.matchXMaterial(section.getString("Materials." + this.name)).get().parseItem(); ItemStack item = XMaterial.matchXMaterial(section.getString("Materials." + this.name)).get().parseItem();
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
if (meta != null) {
meta.setDisplayName(FactionsPlugin.getInstance().color(section.getString("placeholder-item.name").replace("{action}", this.name)));
List<String> lore = section.getStringList("placeholder-item.lore");
meta.setDisplayName(FactionsPlugin.getInstance().color(section.getString("placeholder-item.name").replace("{action}", this.name))); // Reset permissions since a section is null so it was old permission storage.
List<String> lore = section.getStringList("placeholder-item.lore"); if (fme.getFaction().getPermissions().get(perm) == null) {
fme.getFaction().setDefaultPerms();
fme.getFaction().sendMessage(TL.SYSTEM_PERMISSIONS_RESET.toString());
}
lore = FactionsPlugin.getInstance().replacePlaceholders(lore, // TEMP: This check is required for factions created before `Undefined` permission was removed
new Placeholder("{action-access-color}", fme.getFaction().getPermissions().get(perm).get(this).getColor()), if (fme.getFaction().getPermissions().get(perm).get(this) == Access.UNDEFINED) {
new Placeholder("{action-access}", fme.getFaction().getPermissions().get(perm).get(this).getName())); fme.getFaction().getPermissions().get(perm).put(this, Access.DENY);
}
lore = FactionsPlugin.getInstance().replacePlaceholders(lore,
new Placeholder("{action-access-color}", fme.getFaction().getPermissions().get(perm).get(this).getColor()),
new Placeholder("{action-access}", fme.getFaction().getPermissions().get(perm).get(this).getName()));
meta.setLore(FactionsPlugin.getInstance().colorList(lore));
item.setItemMeta(meta);
}
meta.setLore(FactionsPlugin.getInstance().colorList(lore));
item.setItemMeta(meta);
return item; return item;
} }
public static PermissableAction fromSlot(int slot) {
for (PermissableAction action : PermissableAction.values()) {
if (action.getSlot() == slot) return action;
}
return null;
}
} }

View File

@ -1,12 +1,12 @@
package com.massivecraft.factions.zcore.fperms.gui; package com.massivecraft.factions.zcore.fperms.gui;
import com.cryptomorin.xseries.XMaterial;
import com.github.stefvanschie.inventoryframework.Gui; import com.github.stefvanschie.inventoryframework.Gui;
import com.github.stefvanschie.inventoryframework.GuiItem; import com.github.stefvanschie.inventoryframework.GuiItem;
import com.github.stefvanschie.inventoryframework.pane.PaginatedPane; import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.Permissable; import com.massivecraft.factions.zcore.fperms.Permissable;
import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.fperms.PermissableAction;
@ -17,22 +17,17 @@ import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
public class PermissableActionFrame { public class PermissableActionFrame {
/**
* @author Illyria Team
*/
private Gui gui; private Gui gui;
private ConfigurationSection section;
public PermissableActionFrame(Faction f) { public PermissableActionFrame(Faction f) {
ConfigurationSection section = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.action"); section = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.action");
assert section != null;
gui = new Gui(FactionsPlugin.getInstance(), gui = new Gui(FactionsPlugin.getInstance(),
section.getInt("rows", 4), section.getInt("rows", 3),
FactionsPlugin.getInstance().color(Objects.requireNonNull(FactionsPlugin.getInstance().getConfig().getString("fperm-gui.action.name")).replace("{faction}", f.getTag()))); FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fperm-gui.action.name").replace("{faction}", f.getTag())));
} }
public void buildGUI(FPlayer fplayer, Permissable perm) { public void buildGUI(FPlayer fplayer, Permissable perm) {
@ -104,6 +99,9 @@ public class PermissableActionFrame {
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name"))); meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
item.setItemMeta(meta); item.setItemMeta(meta);
} }
return item; return item;
} }
} }

View File

@ -1,5 +1,6 @@
package com.massivecraft.factions.zcore.fperms.gui; package com.massivecraft.factions.zcore.fperms.gui;
import com.cryptomorin.xseries.XMaterial;
import com.github.stefvanschie.inventoryframework.Gui; import com.github.stefvanschie.inventoryframework.Gui;
import com.github.stefvanschie.inventoryframework.GuiItem; import com.github.stefvanschie.inventoryframework.GuiItem;
import com.github.stefvanschie.inventoryframework.pane.PaginatedPane; import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
@ -8,7 +9,6 @@ import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role; import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.fperms.Permissable; import com.massivecraft.factions.zcore.fperms.Permissable;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -16,22 +16,17 @@ import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
public class PermissableRelationFrame { public class PermissableRelationFrame {
/**
* @author Illyria Team
*/
private Gui gui; private Gui gui;
private ConfigurationSection section;
public PermissableRelationFrame(Faction f) { public PermissableRelationFrame(Faction f) {
ConfigurationSection section = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.relation"); section = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.relation");
assert section != null;
gui = new Gui(FactionsPlugin.getInstance(), gui = new Gui(FactionsPlugin.getInstance(),
section.getInt("rows", 4), section.getInt("rows", 3),
FactionsPlugin.getInstance().color(Objects.requireNonNull(FactionsPlugin.getInstance().getConfig().getString("fperm-gui.relation.name")).replace("{faction}", f.getTag()))); FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fperm-gui.relation.name").replace("{faction}", f.getTag())));
} }
public void buildGUI(FPlayer fplayer) { public void buildGUI(FPlayer fplayer) {
@ -89,3 +84,4 @@ public class PermissableRelationFrame {
} }
} }
} }

View File

@ -1,12 +1,12 @@
package com.massivecraft.factions.zcore.frame.fdisband; package com.massivecraft.factions.zcore.frame.fdisband;
import com.cryptomorin.xseries.XMaterial;
import com.github.stefvanschie.inventoryframework.Gui; import com.github.stefvanschie.inventoryframework.Gui;
import com.github.stefvanschie.inventoryframework.GuiItem; import com.github.stefvanschie.inventoryframework.GuiItem;
import com.github.stefvanschie.inventoryframework.pane.PaginatedPane; import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.XMaterial;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;

View File

@ -1,5 +1,6 @@
package com.massivecraft.factions.zcore.frame.fupgrades; package com.massivecraft.factions.zcore.frame.fupgrades;
import com.cryptomorin.xseries.XMaterial;
import com.github.stefvanschie.inventoryframework.Gui; import com.github.stefvanschie.inventoryframework.Gui;
import com.github.stefvanschie.inventoryframework.GuiItem; import com.github.stefvanschie.inventoryframework.GuiItem;
import com.github.stefvanschie.inventoryframework.pane.PaginatedPane; import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
@ -7,7 +8,6 @@ import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.XMaterial;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -1,9 +1,9 @@
package com.massivecraft.factions.zcore.frame.fupgrades; package com.massivecraft.factions.zcore.frame.fupgrades;
import com.cryptomorin.xseries.XMaterial;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin; import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.Placeholder; import com.massivecraft.factions.util.Placeholder;
import com.massivecraft.factions.util.XMaterial;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.Property;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;

View File

@ -1,7 +1,7 @@
package com.massivecraft.factions.zcore.frame.fupgrades; package com.massivecraft.factions.zcore.frame.fupgrades;
import com.cryptomorin.xseries.XMaterial;
import com.massivecraft.factions.*; import com.massivecraft.factions.*;
import com.massivecraft.factions.util.XMaterial;
import org.bukkit.CropState; import org.bukkit.CropState;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;

View File

@ -1,5 +1,6 @@
package com.massivecraft.factions.zcore.frame.fwarps; package com.massivecraft.factions.zcore.frame.fwarps;
import com.cryptomorin.xseries.XMaterial;
import com.github.stefvanschie.inventoryframework.Gui; import com.github.stefvanschie.inventoryframework.Gui;
import com.github.stefvanschie.inventoryframework.GuiItem; import com.github.stefvanschie.inventoryframework.GuiItem;
import com.github.stefvanschie.inventoryframework.pane.PaginatedPane; import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
@ -11,7 +12,6 @@ import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.util.LazyLocation; import com.massivecraft.factions.util.LazyLocation;
import com.massivecraft.factions.util.Placeholder; import com.massivecraft.factions.util.Placeholder;
import com.massivecraft.factions.util.WarmUpUtil; import com.massivecraft.factions.util.WarmUpUtil;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;

View File

@ -972,38 +972,36 @@ public abstract class MemoryFPlayer implements FPlayer {
} }
public void setFFlying(boolean fly, boolean damage) { public void setFFlying(boolean fly, boolean damage) {
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) { Player player = getPlayer();
Player player = getPlayer(); if (player == null) return;
if (player == null) return;
player.setAllowFlight(fly); player.setAllowFlight(fly);
player.setFlying(fly); player.setFlying(fly);
if (!damage) { if (!damage) {
msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled"); msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled");
if (!fly) {
sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + ""));
}
} else {
msg(TL.COMMAND_FLY_DAMAGE);
}
// If leaving fly mode, don't let them take fall damage for x seconds.
if (!fly) { if (!fly) {
int cooldown = FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3); sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + ""));
CmdFly.flyMap.remove(player.getName());
// If the value is 0 or lower, make them take fall damage.
// Otherwise, start a timer and have this cancel after a few seconds.
// Short task so we're just doing it in method. Not clean but eh.
if (cooldown > 0) {
setTakeFallDamage(false);
Bukkit.getScheduler().runTaskLater(FactionsPlugin.getInstance(), () -> setTakeFallDamage(true), 20L * cooldown);
}
} }
} else {
isFlying = fly; msg(TL.COMMAND_FLY_DAMAGE);
} }
// If leaving fly mode, don't let them take fall damage for x seconds.
if (!fly) {
int cooldown = FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3);
CmdFly.flyMap.remove(player.getName());
// If the value is 0 or lower, make them take fall damage.
// Otherwise, start a timer and have this cancel after a few seconds.
// Short task so we're just doing it in method. Not clean but eh.
if (cooldown > 0) {
setTakeFallDamage(false);
Bukkit.getScheduler().runTaskLater(FactionsPlugin.getInstance(), () -> setTakeFallDamage(true), 20L * cooldown);
}
}
isFlying = fly;
} }
public boolean isInFactionsChest() { public boolean isInFactionsChest() {

View File

@ -1,6 +1,7 @@
package com.massivecraft.factions.zcore.persist; package com.massivecraft.factions.zcore.persist;
import com.massivecraft.factions.*; import com.massivecraft.factions.*;
import com.massivecraft.factions.cmd.shields.struct.frame.ShieldFramePersistence;
import com.massivecraft.factions.discord.Discord; import com.massivecraft.factions.discord.Discord;
import com.massivecraft.factions.event.FPlayerLeaveEvent; import com.massivecraft.factions.event.FPlayerLeaveEvent;
import com.massivecraft.factions.event.FactionDisbandEvent; import com.massivecraft.factions.event.FactionDisbandEvent;
@ -95,7 +96,10 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
private String weeWooFormat; private String weeWooFormat;
private String guildId; private String guildId;
private String memberRoleId; private String memberRoleId;
private ShieldFramePersistence shieldFrame;
private boolean isProtected;
private long applyShieldUpdate;
private ShieldFramePersistence newFrame;
// -------------------------------------------- // // -------------------------------------------- //
// Construct // Construct
@ -185,6 +189,48 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
return this.announcements; return this.announcements;
} }
public boolean isProtected() {
return this.isProtected;
}
public long getShieldChangeTime() {
return this.applyShieldUpdate;
}
public ShieldFramePersistence getNewFrame() {
return this.newFrame;
}
public void setProtected() {
this.isProtected = true;
}
public void setUnprotected() {
this.isProtected = false;
}
public ShieldFramePersistence getShieldFrame() {
return this.shieldFrame;
}
public void applyShield() {
this.shieldFrame = this.newFrame;
this.applyShieldUpdate = 0L;
}
public void setupShieldChange(ShieldFramePersistence frame) {
if (this.shieldFrame == null) {
this.shieldFrame = frame;
} else {
this.newFrame = frame;
this.applyShieldUpdate = System.currentTimeMillis() + (3600000 * Conf.shieldFrameChangeCooldownHours);
}
}
public boolean pendingShieldChange() {
return (this.applyShieldUpdate != 0L);
}
public void addAnnouncement(FPlayer fPlayer, String msg) { public void addAnnouncement(FPlayer fPlayer, String msg) {
List<String> list = announcements.containsKey(fPlayer.getId()) ? announcements.get(fPlayer.getId()) : new ArrayList<>(); List<String> list = announcements.containsKey(fPlayer.getId()) ? announcements.get(fPlayer.getId()) : new ArrayList<>();
list.add(msg); list.add(msg);

View File

@ -926,6 +926,9 @@ public enum TL {
COMMAND_TAG_CHANGED("The faction %1$s changed their name to %2$s."), COMMAND_TAG_CHANGED("The faction %1$s changed their name to %2$s."),
COMMAND_TAG_DESCRIPTION("Change the faction tag"), COMMAND_TAG_DESCRIPTION("Change the faction tag"),
COMMAND_SHIELD_DESCRIPTION("Modify/Enable Faction Shield Timings"),
COMMAND_TITLE_TOCHANGE("to change a players title"), COMMAND_TITLE_TOCHANGE("to change a players title"),
COMMAND_TITLE_FORCHANGE("for changing a players title"), COMMAND_TITLE_FORCHANGE("for changing a players title"),
COMMAND_TITLE_CHANGED("%1$s changed a title: %2$s"), COMMAND_TITLE_CHANGED("%1$s changed a title: %2$s"),
@ -1290,6 +1293,9 @@ public enum TL {
WARMUPS_ALREADY("&cYou are already warming up."), WARMUPS_ALREADY("&cYou are already warming up."),
WARMUPS_CANCELLED("&cYou have cancelled your warmup."), WARMUPS_CANCELLED("&cYou have cancelled your warmup."),
SYSTEM_PERMISSIONS_RESET("&cYour faction's permissions have been reset to default due to a transfer"),
PLACEHOLDERAPI_NULL(""); PLACEHOLDERAPI_NULL("");
public static SimpleDateFormat sdf; public static SimpleDateFormat sdf;

View File

@ -421,7 +421,6 @@ help:
# 2nd: The Action GUI, here you define the permission of the clicked Action using click types, # 2nd: The Action GUI, here you define the permission of the clicked Action using click types,
# depending on the click type it will set the permission differently: # depending on the click type it will set the permission differently:
# Left Click: ALLOW # Left Click: ALLOW
# Middle Click: UNDEFINED
# Right Click: DENY # Right Click: DENY
# #
# #
@ -433,10 +432,14 @@ help:
# indicating the current relation (Uses relation item placeholder) # indicating the current relation (Uses relation item placeholder)
# 2nd: Dummy items, these items server no other purpose than to look good, they have their own # 2nd: Dummy items, these items server no other purpose than to look good, they have their own
# items defined in dummy items, and can later be assigned to specific slots in the GUI's # items defined in dummy items, and can later be assigned to specific slots in the GUI's
# If you would like to set default permissions in the /f perms gui find the option 'useDefaultPermissions' in conf.json.
# This can be useful if you would like to create
# A template for factions in your server to have for /f perms.
fperm-gui: fperm-gui:
relation: relation:
# GUI Name # GUI Name
name: '&8&lFaction Permissions' name: '&7Faction Permissions'
# Amount of inventory rows, No larger than 5 # Amount of inventory rows, No larger than 5
rows: 4 rows: 4
# These are the slots where the relations are going to be placed on the first GUI # These are the slots where the relations are going to be placed on the first GUI
@ -462,14 +465,13 @@ fperm-gui:
enemy: DIAMOND_AXE enemy: DIAMOND_AXE
neutral: WOOD_AXE neutral: WOOD_AXE
Placeholder-Item: Placeholder-Item:
Name: '&c{relation}&f permissions!' Name: '&cClick to edit {relation} permissions!'
action: action:
name: 'Faction Permissions' name: 'Faction Permissions'
rows: 6 rows: 6
Access-Colors: Access-Colors:
Allow: '&a' Allow: '&a'
Deny: '&c' Deny: '&c'
Undefined: '&7'
Materials: Materials:
build: COBBLESTONE build: COBBLESTONE
destroy: DIAMOND_PICKAXE destroy: DIAMOND_PICKAXE
@ -499,6 +501,7 @@ fperm-gui:
check: WATCH check: WATCH
drain: BUCKET drain: BUCKET
spawner: MOB_SPAWNER spawner: MOB_SPAWNER
shield: DIAMOND_CHESTPLATE
home: ENDER_EYE home: ENDER_EYE
slots: slots:
# Uses same format as above to inform the player of clicked relation # Uses same format as above to inform the player of clicked relation
@ -534,19 +537,19 @@ fperm-gui:
check: 50 check: 50
spawner: 38 spawner: 38
drain: 49 drain: 49
shield: 51
home: 48 home: 48
# {action} Action name eg: Setwarp, Kick # {action} Action name eg: Setwarp, Kick
# {action-access} Access name eg: Allow, Deny # {action-access} Access name eg: Allow, Deny
# {action-access-color} Access color eg: Allow;GREEN # {action-access-color} Access color eg: Allow;GREEN
placeholder-item: placeholder-item:
name: '&c&lPermission to {action}' name: '&e&l(!) &ePermission: &6&n{action}'
lore: lore:
- '' - ''
- '&4&l* &cStatus: &f{action-access-color}{action-access}' - '&6&l * &eStatus: &8[{action-access-color}{action-access}&8]'
- '' - ''
- '&2&l* &aLeft click to &a&lAllow&a.' - '&7Left click to &a&nAllow&7.'
- '&4&l* &cRight click to &c&lDeny&c.' - '&7Right click to &c&nDeny&7.'
- '&8&l* &7Middle click to &7&lUndefine&7.'
# Back item will be take you to the previous GUI # Back item will be take you to the previous GUI
back-item: back-item:
Type: ARROW Type: ARROW
@ -559,7 +562,6 @@ fperm-gui:
Name: ' ' Name: ' '
Lore: Lore:
- ' ' - ' '
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
# | Faction Warp GUI | # # | Faction Warp GUI | #
@ -1431,6 +1433,112 @@ Tntfill:
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
# | Faction Shields | #
# +------------------------------------------------------+ #
############################################################
Shields:
Frame:
Main-Menu:
Title: '&c&lShield'
Frame-Type:
Barrier:
Type: BARRIER
Name: ' '
Lore:
- ' '
Slots:
- 24
- 25
- 26
Info-Item:
Type: PAPER
Display-Name: '&e&lShield Information'
Lore:
- '&fDuring Shielded Times, a faction cannot'
- '&fbe raided by cannons/explosions.'
- ''
- '&fChanging the Shield window'
- '&ftakes &e1 day &fto update.'
- ''
- '&cAbuse of this mechanic in any way will be'
- '&cpunished severely!'
NoShield-Pending:
Type: CLOCK
Display-Name: '&e&lPending Shield Change'
Lore:
- ' '
- '&cThere is no pending change to'
- '&cyour faction''s Shield window.'
Shield-Pending:
Type: CLOCK
Display-Name: '&e&lPending Shield Change'
Lore:
- ' '
- '&fYour faction is currently awaiting a shield change!'
- '&fYour shield will be updated in:'
- ' '
- '&a{remaining-time} &fto &a&l{new-start} &f&m--->&a&l {new-end}'
Current-Frame:
Type: GREEN_STAINED_GLASS_PANE
Display-Name: ' '
Lore:
- ' '
- ' &aYour shield hours are currently'
- ' '
- ' &e&l{start-time} &f&m--->&e&l {end-time}'
- ' &eTotal Time: &f12 Hours.'
- ' '
- ' &7( Current Time: {time-currently} )'
New-Frame:
Type: ORANGE_STAINED_GLASS_PANE
Display-Name: ' '
Lore:
- ' '
- ' &fYour factions shielded window is'
- ' &fcurrently set to change in &e{remaining-time} &fto'
- ' '
- ' &e&l{start-time} &f&m--->&e&l {end-time}'
- ' &eTotal Time: &f12 Hours.'
- ' '
- ' &7( Current Time: {time-currently} )'
Regular-Frame:
Type: RED_STAINED_GLASS_PANE
Display-Name: ' '
Lore:
- ' '
- ' &aClick to change the shield window to'
- ' '
- ' &e&l{start-time} &f&m--->&e&l {end-time}'
- ' &eTotal Time: &f12 Hours.'
- ' '
- ' &7( Current Time: {time-currently} )'
Change:
Size: 3
Title: '&e&lShield Confirmation'
Items:
Accept:
Type: GREEN_STAINED_GLASS_PANE
Display-Name: '&a&lConfirm Shield Change'
Lore:
- ' '
Deny:
Type: RED_STAINED_GLASS_PANE
Display-Name: '&c&lCancel Shield Change'
Lore:
- ' '
Info:
Type: CLOCK
Display-Name: ' '
Lore:
- ' '
- ' &aClick confirm to change your shield to'
- ' &e&l{start-time} &f&m--->&e&l {end-time}'
- ' &eTotal Time: 12 Hours.'
- ' '
- ' &7( Current Time: {current-time} )'
- ' &7( Change takes 24 hours to apply! )'
############################################################
# +------------------------------------------------------+ #
# | Faction Wild | # # | Faction Wild | #
# +------------------------------------------------------+ # # +------------------------------------------------------+ #
############################################################ ############################################################
@ -1447,51 +1555,51 @@ Wild:
FillMaterial: BLACK_STAINED_GLASS_PANE FillMaterial: BLACK_STAINED_GLASS_PANE
Zones: Zones:
# You may create your own zones here please just follow the original format # # You may create your own zones here please just follow the original format #
Close: Close:
World: world World: world
Range: Range:
MinX: -200 MinX: -200
MaxX: 200 MaxX: 200
MinZ: -200 MinZ: -200
MaxZ: 200 MaxZ: 200
Cost: 5000 Cost: 5000
Material: IRON_INGOT Material: IRON_INGOT
Lore: Lore:
- '&eTeleport to a random location close by' - '&eTeleport to a random location close by'
- '&e X &b-200 &f- &b200 &eZ &b-200 &f- &b200' - '&e X &b-200 &f- &b200 &eZ &b-200 &f- &b200'
- '&2&l&o$5000' - '&2&l&o$5000'
Name: '&cLow Range' Name: '&cLow Range'
Slot: 1 Slot: 1
Medium: Medium:
World: world World: world
Range: Range:
MinX: -400 MinX: -400
MaxX: 400 MaxX: 400
MinZ: -400 MinZ: -400
MaxZ: 400 MaxZ: 400
Cost: 10000 Cost: 10000
Material: GOLD_INGOT Material: GOLD_INGOT
Lore: Lore:
- '&eTeleport to a random location in a medium proximity' - '&eTeleport to a random location in a medium proximity'
- '&e X &b-400 &f- &b400 &eZ &b-400 &f- &b400' - '&e X &b-400 &f- &b400 &eZ &b-400 &f- &b400'
- '&2&l&o$10000' - '&2&l&o$10000'
Name: '&cMedium Range' Name: '&cMedium Range'
Slot: 4 Slot: 4
Far: Far:
World: world World: world
Range: Range:
MinX: -800 MinX: -800
MaxX: 800 MaxX: 800
MinZ: -800 MinZ: -800
MaxZ: 800 MaxZ: 800
Cost: 15000 Cost: 15000
Material: DIAMOND Material: DIAMOND
Lore: Lore:
- '&eTeleport to a random location far away' - '&eTeleport to a random location far away'
- '&e X &b-800 &f- &b800 &eZ &b-800 &f- &b800' - '&e X &b-800 &f- &b800 &eZ &b-800 &f- &b800'
- '&2&l&o$15000' - '&2&l&o$15000'
Name: '&cHigh Range' Name: '&cHigh Range'
Slot: 7 Slot: 7
# Settings that change how a player arrives to their random location # # Settings that change how a player arrives to their random location #
Arrival: Arrival:
# if FallDamage is false and the player is about to take fall damage while in the FallDamageWindow it will be denied # # if FallDamage is false and the player is about to take fall damage while in the FallDamageWindow it will be denied #