Revert "Merge pull request #134 from ImCarib/1.6.x"

This reverts commit 0b677cb4de, reversing
changes made to a355b1d0c8.
This commit is contained in:
DroppingAnvil 2020-06-08 15:52:29 -04:00
parent 7b94367eb4
commit cdc07ed5eb
43 changed files with 2322 additions and 881 deletions

27
pom.xml
View File

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

View File

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

View File

@ -1,6 +1,5 @@
package com.massivecraft.factions;
import com.massivecraft.factions.cmd.shields.struct.frame.ShieldFramePersistence;
import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason;
import com.massivecraft.factions.iface.EconomyParticipator;
import com.massivecraft.factions.iface.RelationParticipator;
@ -60,24 +59,6 @@ public interface Faction extends EconomyParticipator {
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();
double getReinforcedArmor();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,42 +0,0 @@
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

@ -1,41 +0,0 @@
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

@ -1,75 +0,0 @@
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

@ -1,171 +0,0 @@
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

@ -1,54 +0,0 @@
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

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

View File

@ -1,8 +1,8 @@
package com.massivecraft.factions.cmd.wild;
import com.cryptomorin.xseries.XMaterial;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.util.wait.WaitExecutor;
import com.massivecraft.factions.util.wait.WaitTask;
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) {
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
public int hashCode() {

View File

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

View File

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

View File

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

View File

@ -1,6 +1,5 @@
package com.massivecraft.factions.listeners;
import com.cryptomorin.xseries.XMaterial;
import com.massivecraft.factions.*;
import com.massivecraft.factions.cmd.CmdFGlobal;
import com.massivecraft.factions.cmd.CmdFly;
@ -21,6 +20,7 @@ import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.CC;
import com.massivecraft.factions.util.VisualizeUtil;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.util.wait.WaitExecutor;
import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
@ -335,36 +335,131 @@ public class FactionsPlayerListener implements Listener {
}
private static PermissableAction GetPermissionFromUsableBlock(Material material) {
if (material.name().contains("_BUTTON")
|| material.name().contains("COMPARATOR")
|| material.name().contains("PRESSURE")
|| material.name().contains("REPEATER")
|| material.name().contains("DIODE")) return PermissableAction.BUTTON;
if (material.name().contains("_DOOR")
|| material.name().contains("_TRAPDOOR")
|| material.name().contains("_FENCE_GATE")
|| material.name().startsWith("FENCE_GATE")) return PermissableAction.DOOR;
if (material.name().contains("SHULKER_BOX")
|| material.name().endsWith("ANVIL")
|| material.name().startsWith("CHEST_MINECART")
|| material.name().endsWith("CHEST")
|| material.name().endsWith("JUKEBOX")
|| material.name().endsWith("CAULDRON")
|| material.name().endsWith("FURNACE")
|| material.name().endsWith("HOPPER")
|| material.name().endsWith("BEACON")
|| material.name().startsWith("TRAPPED_CHEST")
|| material.name().equalsIgnoreCase("ENCHANTING_TABLE")
|| material.name().equalsIgnoreCase("ENCHANTMENT_TABLE")
|| material.name().endsWith("BREWING_STAND")
|| material.name().equalsIgnoreCase("BARREL")) return PermissableAction.CONTAINER;
if (material.name().endsWith("LEVER")) return PermissableAction.LEVER;
switch (material) {
case DISPENSER:
case DROPPER:
return PermissableAction.CONTAINER;
default:
return null;
// 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") || material.name().contains("DIODE") || material.name().contains("COMPARATOR"))
return PermissableAction.BUTTON;
if (FactionsPlugin.instance.mc113 || FactionsPlugin.instance.mc114 || FactionsPlugin.getInstance().mc115) {
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:
case COMPARATOR:
case REPEATER:
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 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;
}
}
}
@ -642,7 +737,9 @@ public class FactionsPlayerListener implements Listener {
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(","));
if (Conf.disableFlightOnFactionClaimChange) CmdFly.disableFlight(me);
if (Conf.disableFlightOnFactionClaimChange && FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
CmdFly.disableFlight(me);
} else if (me.isAutoSafeClaimEnabled()) {
if (!Permission.MANAGE_SAFE_ZONE.has(player)) {
me.setIsAutoSafeClaimEnabled(false);
@ -715,11 +812,7 @@ public class FactionsPlayerListener implements Listener {
Material type;
if (event.getItem() != null) {
// Convert 1.8 Material Names -> 1.15
try {
type = XMaterial.matchXMaterial(event.getItem().getType().toString()).get().parseMaterial();
} catch (NullPointerException npe) {
type = null;
}
type = XMaterial.matchXMaterial(event.getItem().getType().toString()).get().parseMaterial();
} else {
type = null;
}
@ -768,7 +861,7 @@ public class FactionsPlayerListener implements Listener {
Block block = event.getClickedBlock();
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getType() == XMaterial.GRASS_BLOCK.parseMaterial()
&& event.hasItem() && event.getItem().getType() == XMaterial.BONE_MEAL.parseMaterial()) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), PermissableAction.BUILD.name(), true)) {
if (!FactionsBlockListener.playerCanBuildDestroyBlock(event.getPlayer(), block.getLocation(), "build", true)) {
FPlayer me = FPlayers.getInstance().getById(event.getPlayer().getUniqueId().toString());
Faction myFaction = me.getFaction();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@ -1,10 +1,9 @@
package com.massivecraft.factions.zcore.fperms;
import com.cryptomorin.xseries.XMaterial;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.Placeholder;
import com.massivecraft.factions.zcore.util.TL;
import com.massivecraft.factions.util.XMaterial;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@ -47,7 +46,6 @@ public enum PermissableAction {
WITHDRAW("withdraw"),
CHEST("chest"),
CHECK("check"),
SHIELD("shield"),
SPAWNER("spawner");
private String name;
@ -68,7 +66,6 @@ public enum PermissableAction {
return permissableAction;
}
}
return null;
}
@ -109,29 +106,16 @@ public enum PermissableAction {
ConfigurationSection section = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.action");
ItemStack item = XMaterial.matchXMaterial(section.getString("Materials." + this.name)).get().parseItem();
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");
// Reset permissions since a section is null so it was old permission storage.
if (fme.getFaction().getPermissions().get(perm) == null) {
fme.getFaction().setDefaultPerms();
fme.getFaction().sendMessage(TL.SYSTEM_PERMISSIONS_RESET.toString());
}
meta.setDisplayName(FactionsPlugin.getInstance().color(section.getString("placeholder-item.name").replace("{action}", this.name)));
List<String> lore = section.getStringList("placeholder-item.lore");
// TEMP: This check is required for factions created before `Undefined` permission was removed
if (fme.getFaction().getPermissions().get(perm).get(this) == Access.UNDEFINED) {
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);
}
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);
return item;
}

View File

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

View File

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

View File

@ -1,12 +1,12 @@
package com.massivecraft.factions.zcore.frame.fdisband;
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.util.XMaterial;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;

View File

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

View File

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

View File

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

View File

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

View File

@ -972,36 +972,38 @@ public abstract class MemoryFPlayer implements FPlayer {
}
public void setFFlying(boolean fly, boolean damage) {
Player player = getPlayer();
if (player == null) return;
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) {
Player player = getPlayer();
if (player == null) return;
player.setAllowFlight(fly);
player.setFlying(fly);
player.setAllowFlight(fly);
player.setFlying(fly);
if (!damage) {
msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled");
if (!damage) {
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) {
sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + ""));
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);
}
}
} else {
msg(TL.COMMAND_FLY_DAMAGE);
isFlying = fly;
}
// 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() {

View File

@ -1,7 +1,6 @@
package com.massivecraft.factions.zcore.persist;
import com.massivecraft.factions.*;
import com.massivecraft.factions.cmd.shields.struct.frame.ShieldFramePersistence;
import com.massivecraft.factions.discord.Discord;
import com.massivecraft.factions.event.FPlayerLeaveEvent;
import com.massivecraft.factions.event.FactionDisbandEvent;
@ -96,10 +95,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
private String weeWooFormat;
private String guildId;
private String memberRoleId;
private ShieldFramePersistence shieldFrame;
private boolean isProtected;
private long applyShieldUpdate;
private ShieldFramePersistence newFrame;
// -------------------------------------------- //
// Construct
@ -189,48 +185,6 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
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) {
List<String> list = announcements.containsKey(fPlayer.getId()) ? announcements.get(fPlayer.getId()) : new ArrayList<>();
list.add(msg);

View File

@ -926,9 +926,6 @@ public enum TL {
COMMAND_TAG_CHANGED("The faction %1$s changed their name to %2$s."),
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_FORCHANGE("for changing a players title"),
COMMAND_TITLE_CHANGED("%1$s changed a title: %2$s"),
@ -1297,9 +1294,6 @@ public enum TL {
WARMUPS_ALREADY("&cYou are already warming up."),
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("");
public static SimpleDateFormat sdf;

View File

@ -422,6 +422,7 @@ help:
# 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:
# Left Click: ALLOW
# Middle Click: UNDEFINED
# Right Click: DENY
#
#
@ -433,14 +434,10 @@ help:
# 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
# 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:
relation:
# GUI Name
name: '&7Faction Permissions'
name: '&8&lFaction Permissions'
# Amount of inventory rows, No larger than 5
rows: 4
# These are the slots where the relations are going to be placed on the first GUI
@ -466,13 +463,14 @@ fperm-gui:
enemy: DIAMOND_AXE
neutral: WOOD_AXE
Placeholder-Item:
Name: '&cClick to edit {relation} permissions!'
Name: '&c{relation}&f permissions!'
action:
name: 'Faction Permissions'
rows: 6
Access-Colors:
Allow: '&a'
Deny: '&c'
Undefined: '&7'
Materials:
build: COBBLESTONE
destroy: DIAMOND_PICKAXE
@ -502,7 +500,6 @@ fperm-gui:
check: WATCH
drain: BUCKET
spawner: MOB_SPAWNER
shield: DIAMOND_CHESTPLATE
home: ENDER_EYE
slots:
# Uses same format as above to inform the player of clicked relation
@ -538,19 +535,19 @@ fperm-gui:
check: 50
spawner: 38
drain: 49
shield: 51
home: 48
# {action} Action name eg: Setwarp, Kick
# {action-access} Access name eg: Allow, Deny
# {action-access-color} Access color eg: Allow;GREEN
placeholder-item:
name: '&e&l(!) &ePermission: &6&n{action}'
name: '&c&lPermission to {action}'
lore:
- ''
- '&6&l * &eStatus: &8[{action-access-color}{action-access}&8]'
- '&4&l* &cStatus: &f{action-access-color}{action-access}'
- ''
- '&7Left click to &a&nAllow&7.'
- '&7Right click to &c&nDeny&7.'
- '&2&l* &aLeft click to &a&lAllow&a.'
- '&4&l* &cRight click to &c&lDeny&c.'
- '&8&l* &7Middle click to &7&lUndefine&7.'
# Back item will be take you to the previous GUI
back-item:
Type: ARROW
@ -563,6 +560,7 @@ fperm-gui:
Name: ' '
Lore:
- ' '
############################################################
# +------------------------------------------------------+ #
# | Faction Warp GUI | #
@ -1434,112 +1432,6 @@ 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 | #
# +------------------------------------------------------+ #
############################################################
@ -1556,51 +1448,51 @@ Wild:
FillMaterial: BLACK_STAINED_GLASS_PANE
Zones:
# You may create your own zones here please just follow the original format #
Close:
World: world
Range:
MinX: -200
MaxX: 200
MinZ: -200
MaxZ: 200
Cost: 5000
Material: IRON_INGOT
Lore:
- '&eTeleport to a random location close by'
- '&e X &b-200 &f- &b200 &eZ &b-200 &f- &b200'
- '&2&l&o$5000'
Name: '&cLow Range'
Slot: 1
Medium:
World: world
Range:
MinX: -400
MaxX: 400
MinZ: -400
MaxZ: 400
Cost: 10000
Material: GOLD_INGOT
Lore:
- '&eTeleport to a random location in a medium proximity'
- '&e X &b-400 &f- &b400 &eZ &b-400 &f- &b400'
- '&2&l&o$10000'
Name: '&cMedium Range'
Slot: 4
Far:
World: world
Range:
MinX: -800
MaxX: 800
MinZ: -800
MaxZ: 800
Cost: 15000
Material: DIAMOND
Lore:
- '&eTeleport to a random location far away'
- '&e X &b-800 &f- &b800 &eZ &b-800 &f- &b800'
- '&2&l&o$15000'
Name: '&cHigh Range'
Slot: 7
Close:
World: world
Range:
MinX: -200
MaxX: 200
MinZ: -200
MaxZ: 200
Cost: 5000
Material: IRON_INGOT
Lore:
- '&eTeleport to a random location close by'
- '&e X &b-200 &f- &b200 &eZ &b-200 &f- &b200'
- '&2&l&o$5000'
Name: '&cLow Range'
Slot: 1
Medium:
World: world
Range:
MinX: -400
MaxX: 400
MinZ: -400
MaxZ: 400
Cost: 10000
Material: GOLD_INGOT
Lore:
- '&eTeleport to a random location in a medium proximity'
- '&e X &b-400 &f- &b400 &eZ &b-400 &f- &b400'
- '&2&l&o$10000'
Name: '&cMedium Range'
Slot: 4
Far:
World: world
Range:
MinX: -800
MaxX: 800
MinZ: -800
MaxZ: 800
Cost: 15000
Material: DIAMOND
Lore:
- '&eTeleport to a random location far away'
- '&e X &b-800 &f- &b800 &eZ &b-800 &f- &b800'
- '&2&l&o$15000'
Name: '&cHigh Range'
Slot: 7
# Settings that change how a player arrives to their random location #
Arrival:
# if FallDamage is false and the player is about to take fall damage while in the FallDamageWindow it will be denied #