New Shop Config Format With Help, Removed Useless Code FactionsBlockListener Block Break Revamp, F Wild Revamp (DroppingAnvil) & Alot I can't remember xD
This commit is contained in:
@@ -11,7 +11,7 @@ import com.massivecraft.factions.util.LazyLocation;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.Permissable;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.fupgrades.UpgradeType;
|
||||
import com.massivecraft.factions.zcore.frame.fupgrades.UpgradeType;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -21,18 +21,19 @@ import com.massivecraft.factions.integration.Worldguard;
|
||||
import com.massivecraft.factions.integration.dynmap.EngineDynmap;
|
||||
import com.massivecraft.factions.listeners.*;
|
||||
import com.massivecraft.factions.missions.MissionHandler;
|
||||
import com.massivecraft.factions.shop.ShopConfig;
|
||||
import com.massivecraft.factions.struct.ChatMode;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.util.*;
|
||||
import com.massivecraft.factions.util.Particles.ReflectionUtils;
|
||||
import com.massivecraft.factions.util.adapters.*;
|
||||
import com.massivecraft.factions.util.wait.WaitExecutor;
|
||||
import com.massivecraft.factions.zcore.CommandVisibility;
|
||||
import com.massivecraft.factions.zcore.MPlugin;
|
||||
import com.massivecraft.factions.zcore.file.impl.FileManager;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.Permissable;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.fupgrades.UpgradesListener;
|
||||
import com.massivecraft.factions.zcore.frame.fupgrades.UpgradesListener;
|
||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||
import me.lucko.commodore.CommodoreProvider;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
@@ -55,7 +56,6 @@ import java.lang.reflect.Type;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -95,7 +95,11 @@ public class FactionsPlugin extends MPlugin {
|
||||
private Worldguard wg;
|
||||
private FLogManager fLogManager;
|
||||
private List<ReserveObject> reserveObjects;
|
||||
private FileManager fileManager;
|
||||
|
||||
public FileManager getFileManager() {
|
||||
return fileManager;
|
||||
}
|
||||
|
||||
public FactionsPlugin() {
|
||||
instance = this;
|
||||
@@ -181,16 +185,21 @@ public class FactionsPlugin extends MPlugin {
|
||||
this.saveResource("config.yml", false);
|
||||
this.reloadConfig();
|
||||
}
|
||||
|
||||
//Start wait task executor
|
||||
WaitExecutor.startTask();
|
||||
//Attempt to generate a permission list
|
||||
PermissionList.generateFile();
|
||||
// Load Conf from disk
|
||||
fileManager = new FileManager();
|
||||
getFileManager().setupFiles();
|
||||
Conf.load();
|
||||
fLogManager = new FLogManager();
|
||||
//Dependency checks
|
||||
if (Conf.dependencyCheck && (!Bukkit.getPluginManager().isPluginEnabled("Vault"))) {
|
||||
divider();
|
||||
System.out.println("You are missing dependencies!");
|
||||
System.out.println("Please verify and Vault are installed!");
|
||||
System.out.println("Please verify [Vault] is installed!");
|
||||
Conf.save();
|
||||
Bukkit.getPluginManager().disablePlugin(instance);
|
||||
divider();
|
||||
@@ -264,7 +273,6 @@ public class FactionsPlugin extends MPlugin {
|
||||
//Setup Discord Bot
|
||||
new Discord(this);
|
||||
|
||||
ShopConfig.setup();
|
||||
fLogManager.loadLogs(this);
|
||||
|
||||
getServer().getPluginManager().registerEvents(factionsPlayerListener = new FactionsPlayerListener(), this);
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.zcore.fdisband.FDisbandFrame;
|
||||
import com.massivecraft.factions.zcore.frame.fdisband.FDisbandFrame;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
@@ -3,9 +3,9 @@ package com.massivecraft.factions.cmd;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.util.FactionWarpsFrame;
|
||||
import com.massivecraft.factions.util.WarmUpUtil;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.frame.fwarps.FactionWarpsFrame;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.massivecraft.factions.discord.Discord;
|
||||
import com.massivecraft.factions.event.FPlayerJoinEvent;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.util.CC;
|
||||
import com.massivecraft.factions.zcore.fupgrades.UpgradeType;
|
||||
import com.massivecraft.factions.zcore.frame.fupgrades.UpgradeType;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import net.dv8tion.jda.core.entities.Member;
|
||||
import net.dv8tion.jda.core.exceptions.HierarchyException;
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.discord.Discord;
|
||||
import com.massivecraft.factions.listeners.FactionsPlayerListener;
|
||||
import com.massivecraft.factions.shop.ShopConfig;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
@@ -26,7 +25,7 @@ public class CmdReload extends FCommand {
|
||||
long timeInitStart = System.currentTimeMillis();
|
||||
Conf.load();
|
||||
Conf.save();
|
||||
ShopConfig.loadShop();
|
||||
FactionsPlugin.getInstance().getFileManager().getShop().loadFile();
|
||||
FactionsPlugin.getInstance().reloadConfig();
|
||||
FactionsPlugin.getInstance().loadLang();
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.shop.ShopConfig;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
@@ -30,7 +29,7 @@ public class CmdSaveAll extends FCommand {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ShopConfig.saveShop();
|
||||
FactionsPlugin.getInstance().getFileManager().getShop().saveFile();
|
||||
context.msg(TL.COMMAND_SAVEALL_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ package com.massivecraft.factions.cmd;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.util.Particles.ParticleEffect;
|
||||
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;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.fupgrades.FUpgradeFrame;
|
||||
import com.massivecraft.factions.zcore.frame.fupgrades.FUpgradeFrame;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class CmdUpgrades extends FCommand {
|
||||
|
||||
@@ -4,7 +4,7 @@ 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.FactionGUI;
|
||||
import com.massivecraft.factions.zcore.frame.FactionGUI;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.DyeColor;
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.massivecraft.factions.cmd.check;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.util.FactionGUI;
|
||||
import com.massivecraft.factions.zcore.frame.FactionGUI;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
@@ -165,14 +165,6 @@ public class CmdTntFill extends FCommand {
|
||||
}
|
||||
}
|
||||
|
||||
// Counts the item type available in the inventory.
|
||||
private int inventoryItemCount(Inventory inventory, Material mat) {
|
||||
int count = 0;
|
||||
HashMap<Integer, ? extends ItemStack> items = inventory.all(mat);
|
||||
for (int item : items.keySet())
|
||||
count += inventory.getItem(item).getAmount();
|
||||
return count;
|
||||
}
|
||||
|
||||
public int getAddable(Inventory inv, Material material) {
|
||||
int output = 0;
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.massivecraft.factions.cmd.CommandContext;
|
||||
import com.massivecraft.factions.cmd.CommandRequirements;
|
||||
import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.util.wait.WaitedTask;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@@ -23,51 +24,31 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
|
||||
public class CmdWild extends FCommand {
|
||||
public static HashMap<Player, Integer> waitingTeleport;
|
||||
public class CmdWild extends FCommand implements WaitedTask {
|
||||
public static HashMap<Player, String> teleportRange;
|
||||
public static HashSet<Player> teleporting;
|
||||
public static CmdWild instance;
|
||||
|
||||
public CmdWild() {
|
||||
super();
|
||||
if (instance == null) instance = this;
|
||||
this.aliases.addAll(Aliases.wild);
|
||||
this.requirements = new CommandRequirements.Builder(Permission.WILD)
|
||||
.playerOnly()
|
||||
.build();
|
||||
waitingTeleport = new HashMap<>();
|
||||
teleporting = new HashSet<>();
|
||||
teleportRange = new HashMap<>();
|
||||
startWild();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
if (!waitingTeleport.containsKey(context.player)) {
|
||||
if (!teleportRange.containsKey(context.player)) {
|
||||
context.player.openInventory(new WildGUI(context.player, context.fPlayer).getInventory());
|
||||
} else {
|
||||
context.fPlayer.msg(TL.COMMAND_WILD_WAIT);
|
||||
}
|
||||
}
|
||||
|
||||
public void startWild() {
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.instance, () -> {
|
||||
for (Player p : waitingTeleport.keySet()) {
|
||||
int i = waitingTeleport.get(p) - 1;
|
||||
if (i > 0) {
|
||||
if (i != 1) {
|
||||
p.sendMessage(TL.COMMAND_WILD_WAIT.format((i + " Seconds")));
|
||||
} else {
|
||||
p.sendMessage(TL.COMMAND_WILD_WAIT.format((i + " Second")));
|
||||
}
|
||||
waitingTeleport.replace(p, i);
|
||||
} else {
|
||||
p.sendMessage(TL.COMMAND_WILD_SUCCESS.toString());
|
||||
waitingTeleport.remove(p);
|
||||
attemptTeleport(p);
|
||||
}
|
||||
}
|
||||
}, 0L, 20L);
|
||||
}
|
||||
|
||||
public void attemptTeleport(Player p) {
|
||||
boolean success = false;
|
||||
@@ -121,4 +102,15 @@ public class CmdWild extends FCommand {
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_WILD_DESCRIPTION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSuccess(Player player) {
|
||||
attemptTeleport(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleFailure(Player player) {
|
||||
player.sendMessage(TL.COMMAND_WILD_INTERUPTED.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@ package com.massivecraft.factions.cmd.wild;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.util.FactionGUI;
|
||||
import com.massivecraft.factions.util.wait.WaitExecutor;
|
||||
import com.massivecraft.factions.util.wait.WaitTask;
|
||||
import com.massivecraft.factions.zcore.frame.FactionGUI;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -35,7 +37,7 @@ public class WildGUI implements FactionGUI {
|
||||
if (map.containsKey(slot)) {
|
||||
String zone = map.get(slot);
|
||||
if (fplayer.hasMoney(FactionsPlugin.getInstance().getConfig().getInt("Wild.Zones." + zone + ".Cost"))) {
|
||||
CmdWild.waitingTeleport.put(player, FactionsPlugin.getInstance().getConfig().getInt("Wild.Wait"));
|
||||
WaitExecutor.taskMap.put(player, new WaitTask(FactionsPlugin.getInstance().getConfig().getInt("Wild.Wait"), TL.COMMAND_WILD_INPROGRESS, player, CmdWild.instance));
|
||||
CmdWild.teleportRange.put(player, zone);
|
||||
fplayer.msg(TL.COMMAND_WILD_WAIT, FactionsPlugin.getInstance().getConfig().getInt("Wild.Wait") + " Seconds");
|
||||
player.closeInventory();
|
||||
|
||||
@@ -8,7 +8,6 @@ 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.Particles.ParticleEffect;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
@@ -28,7 +27,6 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -394,8 +392,6 @@ public class FactionsBlockListener implements Listener {
|
||||
String[] components = effect.split(":");
|
||||
player.addPotionEffect(new PotionEffect(Objects.requireNonNull(PotionEffectType.getByName(components[0])), 100, Integer.parseInt(components[1])));
|
||||
}
|
||||
ParticleEffect.LAVA.display(1.0f, 1.0f, 1.0f, 1.0f, 10, banner.getLocation(), 16.0);
|
||||
ParticleEffect.FLAME.display(1.0f, 1.0f, 1.0f, 1.0f, 10, banner.getLocation(), 16.0);
|
||||
if (banner.getType() == bannerType) {
|
||||
continue;
|
||||
}
|
||||
@@ -491,42 +487,49 @@ public class FactionsBlockListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
Block block = event.getBlock();
|
||||
//If there is an error its much safer to not allow the block to be broken
|
||||
try {
|
||||
Block block = event.getBlock();
|
||||
|
||||
Faction at = Board.getInstance().getFactionAt(new FLocation(block));
|
||||
boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial());
|
||||
Faction at = Board.getInstance().getFactionAt(new FLocation(block));
|
||||
boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial());
|
||||
|
||||
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
FPlayer fme = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
||||
if (fme == null || !fme.hasFaction()) return;
|
||||
|
||||
if (isSpawner) {
|
||||
Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER);
|
||||
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
|
||||
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "mine spawners");
|
||||
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (isSpawner && !fme.isAdminBypassing()) {
|
||||
ItemStack item = new ItemStack(block.getType(), 1, block.getData());
|
||||
if (at != null && at.isNormal()) {
|
||||
FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
||||
if (fplayer != null) {
|
||||
BlockState state = block.getState();
|
||||
if (state instanceof CreatureSpawner) {
|
||||
CreatureSpawner spawner = (CreatureSpawner) state;
|
||||
item.setDurability(spawner.getSpawnedType().getTypeId());
|
||||
}
|
||||
handleSpawnerUpdate(at, event.getPlayer(), item, LogTimer.TimerSubType.SPAWNER_BREAK);
|
||||
FPlayer fme = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
||||
if (fme == null || !fme.hasFaction()) return;
|
||||
|
||||
if (isSpawner) {
|
||||
Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER);
|
||||
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
|
||||
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "mine spawners");
|
||||
}
|
||||
}
|
||||
|
||||
if (isSpawner && !fme.isAdminBypassing()) {
|
||||
ItemStack item = new ItemStack(block.getType(), 1, block.getData());
|
||||
if (at != null && at.isNormal()) {
|
||||
FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer());
|
||||
if (fplayer != null) {
|
||||
BlockState state = block.getState();
|
||||
if (state instanceof CreatureSpawner) {
|
||||
CreatureSpawner spawner = (CreatureSpawner) state;
|
||||
item.setDurability(spawner.getSpawnedType().getTypeId());
|
||||
}
|
||||
handleSpawnerUpdate(at, event.getPlayer(), item, LogTimer.TimerSubType.SPAWNER_BREAK);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
event.setCancelled(true);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void FrameRemove(HangingBreakByEntityEvent event) {
|
||||
if (event.getRemover() == null) return;
|
||||
|
||||
@@ -19,7 +19,8 @@ import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
import com.massivecraft.factions.struct.Role;
|
||||
import com.massivecraft.factions.util.CC;
|
||||
import com.massivecraft.factions.util.FactionGUI;
|
||||
import com.massivecraft.factions.util.wait.WaitExecutor;
|
||||
import com.massivecraft.factions.zcore.frame.FactionGUI;
|
||||
import com.massivecraft.factions.util.VisualizeUtil;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
@@ -937,11 +938,7 @@ public class FactionsPlayerListener implements Listener {
|
||||
handler.cancelLogout(e.getPlayer());
|
||||
e.getPlayer().sendMessage(String.valueOf(TL.COMMAND_LOGOUT_MOVED));
|
||||
}
|
||||
|
||||
if (CmdWild.waitingTeleport.containsKey(e.getPlayer())) {
|
||||
CmdWild.waitingTeleport.remove(e.getPlayer());
|
||||
FPlayers.getInstance().getByPlayer(e.getPlayer()).msg(TL.COMMAND_WILD_INTERUPTED);
|
||||
}
|
||||
WaitExecutor.handleAction(e.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -953,10 +950,7 @@ public class FactionsPlayerListener implements Listener {
|
||||
handler.cancelLogout(player);
|
||||
player.sendMessage(String.valueOf(TL.COMMAND_LOGOUT_DAMAGE_TAKEN));
|
||||
}
|
||||
if (CmdWild.waitingTeleport.containsKey(player)) {
|
||||
CmdWild.waitingTeleport.remove(player);
|
||||
FPlayers.getInstance().getByPlayer(player).msg(TL.COMMAND_WILD_INTERUPTED);
|
||||
}
|
||||
WaitExecutor.handleAction(player);
|
||||
if (CmdWild.teleporting.contains(player)) {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("Wild.FallDamage") && e.getCause() == EntityDamageEvent.DamageCause.FALL) {
|
||||
e.setCancelled(true);
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.massivecraft.factions.missions;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.util.FactionGUI;
|
||||
import com.massivecraft.factions.zcore.frame.FactionGUI;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
package com.massivecraft.factions.shop;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ShopConfig {
|
||||
|
||||
/**
|
||||
* @author Driftay
|
||||
*/
|
||||
|
||||
//TODO: Shop YAML Converter mySQL
|
||||
|
||||
public static File shop = new File("plugins/Factions/shop.yml");
|
||||
public static FileConfiguration s = YamlConfiguration.loadConfiguration(shop);
|
||||
|
||||
public static FileConfiguration getShop() {
|
||||
return s;
|
||||
}
|
||||
|
||||
public static void loadShop() {
|
||||
s = YamlConfiguration.loadConfiguration(shop);
|
||||
}
|
||||
|
||||
public static void saveShop() {
|
||||
try {
|
||||
getShop().save(shop);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setup() {
|
||||
if (!shop.exists()) {
|
||||
try {
|
||||
shop.createNewFile();
|
||||
getShop().set("prefix", "&4&lFactionShop&8» &7Purchased &f%item% &7for &b%points% Points&7!");
|
||||
getShop().set("items.1.slot", 1);
|
||||
getShop().set("items.1.block", "STONE");
|
||||
getShop().set("items.1.name", "&aTest Shop");
|
||||
ArrayList lore = new ArrayList<>();
|
||||
lore.add("&cFully Customizable Lore!");
|
||||
lore.add("&b&l{cost} &7Points");
|
||||
getShop().set("items.1.lore", lore);
|
||||
ArrayList t = new ArrayList<>();
|
||||
t.add("broadcast %player% bought Test Shop!");
|
||||
getShop().set("items.1.cmds", t);
|
||||
getShop().set("items.1.cost", 5);
|
||||
getShop().set("items.1.glowing", true);
|
||||
saveShop();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,15 +45,15 @@ public class ShopGUIFrame {
|
||||
ItemStack dummy = buildDummyItem(fplayer.getFaction());
|
||||
for (int x = 0; x <= (gui.getRows() * 9) - 1; x++) GUIItems.add(new GuiItem(dummy, e -> e.setCancelled(true)));
|
||||
|
||||
int items = ShopConfig.getShop().getConfigurationSection("items").getKeys(false).size();
|
||||
int items = FactionsPlugin.getInstance().getFileManager().getShop().getConfig().getConfigurationSection("items").getKeys(false).size();
|
||||
for (int a = 1; a <= items; a++) {
|
||||
String s = a + "";
|
||||
int slot = ShopConfig.getShop().getInt("items." + s + ".slot");
|
||||
ItemStack material = XMaterial.matchXMaterial(Objects.requireNonNull(ShopConfig.getShop().getString("items." + s + ".block"))).get().parseItem();
|
||||
int cost = ShopConfig.getShop().getInt("items." + s + ".cost");
|
||||
String name = ShopConfig.getShop().getString("items." + s + ".name");
|
||||
boolean glowing = ShopConfig.getShop().getBoolean("items." + s + ".glowing");
|
||||
List<String> lore = ShopConfig.getShop().getStringList("items." + s + ".lore");
|
||||
int slot = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt("items." + s + ".slot");
|
||||
ItemStack material = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getFileManager().getShop().fetchString("items." + s + ".block")).get().parseItem();
|
||||
int cost = FactionsPlugin.getInstance().getFileManager().getShop().fetchInt("items." + s + ".cost");
|
||||
String name = FactionsPlugin.getInstance().getFileManager().getShop().fetchString("items." + s + ".name");
|
||||
boolean glowing = FactionsPlugin.getInstance().getFileManager().getShop().fetchBoolean("items." + s + ".glowing");
|
||||
List<String> lore = FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".lore");
|
||||
|
||||
|
||||
ItemStack item = new ItemStack(material);
|
||||
@@ -73,7 +73,7 @@ public class ShopGUIFrame {
|
||||
FPlayer fme = FPlayers.getInstance().getByPlayer((Player) e.getWhoClicked());
|
||||
if (fplayer.getFaction().getPoints() >= cost) {
|
||||
fplayer.getFaction().setPoints(fplayer.getFaction().getPoints() - cost);
|
||||
runCommands(ShopConfig.getShop().getStringList("items." + s + ".cmds"), fplayer.getPlayer());
|
||||
runCommands(FactionsPlugin.getInstance().getFileManager().getShop().fetchStringList("items." + s + ".cmds"), fplayer.getPlayer());
|
||||
for (FPlayer fplayerBuy : fplayer.getFaction().getFPlayers()) {
|
||||
fplayerBuy.getPlayer().sendMessage(TL.SHOP_BOUGHT_BROADCAST_FACTION.toString()
|
||||
.replace("{player}", fplayer.getPlayer().getName())
|
||||
|
||||
@@ -62,7 +62,7 @@ public class InventoryUtil {
|
||||
dataOutput.close();
|
||||
return Base64Coder.encodeLines(outputStream.toByteArray());
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("Cannot into itemstacksz!", e);
|
||||
throw new IllegalStateException("Cannot convert into itemstacks!", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
package com.massivecraft.factions.util.Particles;
|
||||
package com.massivecraft.factions.util;
|
||||
|
||||
/**
|
||||
* Factions - Developed by Driftay.
|
||||
* All rights reserved 2020.
|
||||
* Creation Date: 4/4/2020
|
||||
*/
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
@@ -1595,4 +1600,4 @@ public enum ParticleEffect {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package com.massivecraft.factions.util.Particles;
|
||||
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
|
||||
public enum Particles {
|
||||
|
||||
|
||||
// Gotta use Strings or runtime errors on 1.8, the Particle class does not exist
|
||||
CLOUD(ParticleEffect.CLOUD, "CLOUD"),
|
||||
REDSTONE(ParticleEffect.REDSTONE, "REDSTONE"),
|
||||
NOTE(ParticleEffect.NOTE, "NOTE");
|
||||
|
||||
|
||||
private ParticleEffect sub18;
|
||||
private String over19;
|
||||
|
||||
Particles(ParticleEffect sub18, String over19) {
|
||||
this.sub18 = sub18;
|
||||
this.over19 = over19;
|
||||
}
|
||||
|
||||
|
||||
public void displayAtLocation(Location location, int amt) {
|
||||
if (FactionsPlugin.getInstance().useNonPacketParticles) {
|
||||
// 1.9+ based servers will use the built in particleAPI instead of packet based.
|
||||
// any particle amount higher than 0 made them go everywhere, and the offset at 0 was not working.
|
||||
// So setting the amount to 0 spawns 1 in the precise location
|
||||
location.getWorld().spawnParticle(Particle.valueOf(over19), location, 0);
|
||||
} else {
|
||||
sub18.display((float) 0, (float) 0, (float) 0, (float) 0, amt, location, 16);
|
||||
}
|
||||
}
|
||||
|
||||
public void displayAtLocation(Location location, int amt, ParticleEffect.OrdinaryColor color) {
|
||||
if (FactionsPlugin.getInstance().useNonPacketParticles) {
|
||||
// 1.9-1.11 & 1.13+ based servers will use the built in particleAPI instead of packet based.
|
||||
// any particle amount higher than 0 made them go everywhere, and the offset at 0 was not working.
|
||||
// So setting the amount to 0 spawns 1 in the precise location
|
||||
|
||||
|
||||
// Gotta do this so colorable ones have their data :FactionsPlugin
|
||||
if (this == Particles.REDSTONE || this == Particles.CLOUD || this == Particles.NOTE) {
|
||||
if (FactionsPlugin.getInstance().mc112) {
|
||||
location.getWorld().spawnParticle(Particle.valueOf(over19), location, 0);
|
||||
} else {
|
||||
location.getWorld().spawnParticle(Particle.valueOf(over19), location, 0, new Particle.DustOptions(Color.fromRGB(color.getRed(), color.getGreen(), color.getBlue()), 1));
|
||||
}
|
||||
} else {
|
||||
location.getWorld().spawnParticle(Particle.valueOf(over19), location, 0);
|
||||
}
|
||||
} else {
|
||||
sub18.display(color, location, 16);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
package com.massivecraft.factions.util.Particles;
|
||||
package com.massivecraft.factions.util;
|
||||
|
||||
/**
|
||||
* Factions - Developed by Driftay.
|
||||
* All rights reserved 2020.
|
||||
* Creation Date: 4/4/2020
|
||||
*/
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
@@ -605,4 +610,4 @@ public final class ReflectionUtils {
|
||||
return reference;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
package com.massivecraft.factions.util;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Factions - Developed by Driftay.
|
||||
* All rights reserved 2020.
|
||||
* Creation Date: 1/30/2020
|
||||
*/
|
||||
public class TimeUtil {
|
||||
|
||||
public static long parseDateDiff(String time, boolean future) throws Exception {
|
||||
Pattern timePattern = Pattern.compile("(?:([0-9]+)\\s*y[a-z]*[,\\s]*)?(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?(?:([0-9]+)\\s*w[a-z]*[,\\s]*)?(?:([0-9]+)\\s*d[a-z]*[,\\s]*)?(?:([0-9]+)\\s*h[a-z]*[,\\s]*)?(?:([0-9]+)\\s*m[a-z]*[,\\s]*)?(?:([0-9]+)\\s*(?:s[a-z]*)?)?", 2);
|
||||
Matcher m = timePattern.matcher(time);
|
||||
int years = 0;
|
||||
int months = 0;
|
||||
int weeks = 0;
|
||||
int days = 0;
|
||||
int hours = 0;
|
||||
int minutes = 0;
|
||||
int seconds = 0;
|
||||
boolean found = false;
|
||||
while (m.find()) {
|
||||
if (m.group() != null) {
|
||||
if (m.group().isEmpty()) continue;
|
||||
for (int i = 0; i < m.groupCount(); ++i) {
|
||||
if (m.group(i) != null && !m.group(i).isEmpty()) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) continue;
|
||||
|
||||
if (m.group(1) != null && !m.group(1).isEmpty()) years = Integer.parseInt(m.group(1));
|
||||
|
||||
if (m.group(2) != null && !m.group(2).isEmpty()) months = Integer.parseInt(m.group(2));
|
||||
|
||||
if (m.group(3) != null && !m.group(3).isEmpty()) weeks = Integer.parseInt(m.group(3));
|
||||
|
||||
if (m.group(4) != null && !m.group(4).isEmpty()) days = Integer.parseInt(m.group(4));
|
||||
|
||||
if (m.group(5) != null && !m.group(5).isEmpty()) hours = Integer.parseInt(m.group(5));
|
||||
|
||||
if (m.group(6) != null && !m.group(6).isEmpty()) minutes = Integer.parseInt(m.group(6));
|
||||
|
||||
if (m.group(7) != null && !m.group(7).isEmpty()) {
|
||||
seconds = Integer.parseInt(m.group(7));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) throw new Exception("Illegal Date");
|
||||
|
||||
if (years > 20) throw new Exception("Illegal Date");
|
||||
|
||||
Calendar c = new GregorianCalendar();
|
||||
if (years > 0) c.add(Calendar.YEAR, years * (future ? 1 : -1));
|
||||
|
||||
if (months > 0) c.add(Calendar.MONTH, months * (future ? 1 : -1));
|
||||
|
||||
if (weeks > 0) c.add(Calendar.WEEK_OF_YEAR, weeks * (future ? 1 : -1));
|
||||
|
||||
if (days > 0) c.add(Calendar.DATE, days * (future ? 1 : -1));
|
||||
|
||||
if (hours > 0) c.add(Calendar.HOUR_OF_DAY, hours * (future ? 1 : -1));
|
||||
|
||||
if (minutes > 0) c.add(Calendar.MINUTE, minutes * (future ? 1 : -1));
|
||||
|
||||
if (seconds > 0) c.add(Calendar.SECOND, seconds * (future ? 1 : -1));
|
||||
|
||||
System.out.println("current: " + c.getTimeInMillis() + " Time: " + System.currentTimeMillis() + " Form: " + formatTime(c.getTimeInMillis() / 1000L));
|
||||
return c.getTimeInMillis() / 1000L;
|
||||
}
|
||||
|
||||
public static String formatDifference(long time) {
|
||||
if (time == 0L) return "Never";
|
||||
|
||||
long day = TimeUnit.SECONDS.toDays(time);
|
||||
long hours = TimeUnit.SECONDS.toHours(time) - day * 24L;
|
||||
long minutes = TimeUnit.SECONDS.toMinutes(time) - TimeUnit.SECONDS.toHours(time) * 60L;
|
||||
long seconds = TimeUnit.SECONDS.toSeconds(time) - TimeUnit.SECONDS.toMinutes(time) * 60L;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (day > 0L) sb.append(day).append((day == 1L) ? "day" : "days").append(" ");
|
||||
|
||||
if (hours > 0L) sb.append(hours).append((hours == 1L) ? "h" : "h").append(" ");
|
||||
|
||||
if (minutes > 0L) sb.append(minutes).append((minutes == 1L) ? "m" : "m").append(" ");
|
||||
|
||||
if (seconds > 0L) sb.append(seconds).append((seconds == 1L) ? "s" : "s");
|
||||
|
||||
String diff = sb.toString().trim();
|
||||
return diff.isEmpty() ? "Now" : diff;
|
||||
}
|
||||
|
||||
public static String formatTime(long time) {
|
||||
if (time == System.currentTimeMillis()) return "Now";
|
||||
|
||||
if (time == -1L) return "Never";
|
||||
|
||||
return formatDifference(time - System.currentTimeMillis() / 1000L);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.massivecraft.factions.util;
|
||||
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Updater {
|
||||
public static double currentVersion = 1.1;
|
||||
|
||||
public static void updateIfNeeded(FileConfiguration conf) {
|
||||
double version = conf.getDouble("Config-Version", 0);
|
||||
//Previous version
|
||||
if (version == 0) {
|
||||
//Instructions for this configuration to be updated to current
|
||||
FactionsPlugin.getInstance().log("Your config.yml is pre-versioning so we are going to assign it version 1.0 \n Please regenerate your config.yml if you run into any errors relating to config.");
|
||||
conf.set("Config-Version", 1.0);
|
||||
version = 1.0;
|
||||
}
|
||||
if (version == 1.0) {
|
||||
FactionsPlugin.getInstance().log("Updating config from version 1.0 to 1.1");
|
||||
FactionsPlugin.getInstance().log("Adding randomization support for f missions...");
|
||||
conf.set("Randomization.Enabled", false);
|
||||
conf.set("Randomization.Start-Item.Allowed.Name", "&aStart!");
|
||||
conf.set("Randomization.Start-Item.Allowed.Material", "GREEN_STAINED_GLASS_PANE");
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add("&aStart a new mission!");
|
||||
conf.set("Randomization.Start-Item.Allowed.Lore", lore);
|
||||
conf.set("Randomization.Start-Item.Disallowed.Name", "&4Cannot start new mission");
|
||||
conf.set("Randomization.Start-Item.Disallowed.Material", "GRAY_STAINED_GLASS_PANE");
|
||||
lore.clear();
|
||||
lore.add("&4%reason%");
|
||||
conf.set("Randomization.Start-Item.Disallowed.Lore", lore);
|
||||
conf.set("Randomization.Start-Item.Slot", 28);
|
||||
conf.set("Config-Version", 1.1);
|
||||
currentVersion = 1.1;
|
||||
}
|
||||
//End with save + reload
|
||||
try {
|
||||
conf.save(new File("plugins/Factions/config.yml"));
|
||||
FactionsPlugin.getInstance().reloadConfig();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.massivecraft.factions.util;
|
||||
package com.massivecraft.factions.util.adapters;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.TypeAdapter;
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.massivecraft.factions.util;
|
||||
package com.massivecraft.factions.util.adapters;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.util.InventoryUtil;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.massivecraft.factions.util;
|
||||
package com.massivecraft.factions.util.adapters;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.massivecraft.factions.util;
|
||||
package com.massivecraft.factions.util.adapters;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.massivecraft.factions.util;
|
||||
package com.massivecraft.factions.util.adapters;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.util.LazyLocation;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.logging.Level;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.massivecraft.factions.util;
|
||||
package com.massivecraft.factions.util.adapters;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.massivecraft.factions.util.exceptions;
|
||||
|
||||
/**
|
||||
* @author Saser
|
||||
*/
|
||||
|
||||
public abstract class SaberException extends Exception {
|
||||
public SaberException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.massivecraft.factions.util.exceptions.impl;
|
||||
|
||||
import com.massivecraft.factions.util.exceptions.SaberException;
|
||||
|
||||
/**
|
||||
* @author Saser
|
||||
*/
|
||||
public class DiscordException extends SaberException {
|
||||
public DiscordException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.massivecraft.factions.util.wait;
|
||||
|
||||
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* Factions - Developed by Driftay.
|
||||
* All rights reserved 2020.
|
||||
* Creation Date: 4/4/2020
|
||||
*/
|
||||
public class WaitExecutor {
|
||||
private static boolean enabled = false;
|
||||
public static ConcurrentHashMap<Player, WaitTask> taskMap = new ConcurrentHashMap<>();
|
||||
|
||||
public static void startTask() {
|
||||
if (enabled) return;
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.instance, () ->
|
||||
{
|
||||
for (WaitTask task : taskMap.values()) {
|
||||
int i = task.getWait() - 1;
|
||||
if (i > 0) {
|
||||
if (i != 1) {
|
||||
task.getPlayer().sendMessage(task.getMessage().format((i + " Seconds")));
|
||||
} else {
|
||||
task.getPlayer().sendMessage(task.getMessage().format((i + " Second")));
|
||||
}
|
||||
task.setWait(i);
|
||||
} else {
|
||||
task.success();
|
||||
taskMap.remove(task.getPlayer());
|
||||
}
|
||||
}
|
||||
}, 0L, 20L);
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
public static void handleAction(Player player) {
|
||||
if (!taskMap.containsKey(player)) return;
|
||||
taskMap.get(player).fail();
|
||||
taskMap.remove(player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.massivecraft.factions.util.wait;
|
||||
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author droppinganvil
|
||||
*/
|
||||
|
||||
public class WaitTask {
|
||||
private Integer wait;
|
||||
private TL msg;
|
||||
//Using player as to not have to convert every event
|
||||
private Player player;
|
||||
private WaitedTask origin;
|
||||
|
||||
public WaitTask(Integer wait, TL message, Player player, WaitedTask waitedTask) {
|
||||
this.wait = wait;
|
||||
this.msg = message;
|
||||
this.player = player;
|
||||
this.origin = waitedTask;
|
||||
}
|
||||
|
||||
public Integer getWait() {
|
||||
return wait;
|
||||
}
|
||||
|
||||
public TL getMessage() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public void setWait(Integer i) {
|
||||
wait = i;
|
||||
}
|
||||
|
||||
public void success() {
|
||||
origin.handleSuccess(player);
|
||||
}
|
||||
|
||||
public void fail() {
|
||||
origin.handleFailure(player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.massivecraft.factions.util.wait;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Factions - Developed by Driftay.
|
||||
* All rights reserved 2020.
|
||||
* Creation Date: 4/4/2020
|
||||
*/
|
||||
public interface WaitedTask {
|
||||
void handleSuccess(Player player);
|
||||
|
||||
void handleFailure(Player player);
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
package com.massivecraft.factions.zcore.file;
|
||||
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Factions - Developed by Driftay.
|
||||
* All rights reserved 2020.
|
||||
* Creation Date: 4/4/2020
|
||||
*/
|
||||
public class CustomFile {
|
||||
|
||||
private File file;
|
||||
private YamlConfiguration fileConfig;
|
||||
private HashMap<String, Object> cachedObjects = new HashMap<>();
|
||||
|
||||
public CustomFile(File file) {
|
||||
this.file = file;
|
||||
this.fileConfig = YamlConfiguration.loadConfiguration(file);
|
||||
}
|
||||
|
||||
public void setup(boolean loadFromProject, String inFolder) {
|
||||
if (!getFile().exists()) {
|
||||
if (loadFromProject) {
|
||||
if (!inFolder.equalsIgnoreCase("")) {
|
||||
FactionsPlugin.getInstance().saveResource(inFolder + "/" + file.getName(), false);
|
||||
} else {
|
||||
FactionsPlugin.getInstance().saveResource(file.getName(), false);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
getFile().createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
loadFile();
|
||||
}
|
||||
|
||||
public void loadFile() {
|
||||
this.fileConfig = YamlConfiguration.loadConfiguration(file);
|
||||
this.cachedObjects.clear(); // remove cached objects
|
||||
}
|
||||
|
||||
public void saveFile() {
|
||||
try {
|
||||
getConfig().save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String fetchString(String key) {
|
||||
return (String) getObj(key, dataTypes.STRING);
|
||||
}
|
||||
|
||||
public int fetchInt(String key) {
|
||||
return (int) getObj(key, dataTypes.INT);
|
||||
}
|
||||
|
||||
public double fetchDouble(String key) {
|
||||
return (double) getObj(key, dataTypes.DOUBLE);
|
||||
}
|
||||
|
||||
public List<String> fetchStringList(String key) {
|
||||
return (List<String>) getObj(key, dataTypes.STRINGLIST);
|
||||
}
|
||||
|
||||
public boolean fetchBoolean(String key) {
|
||||
return (boolean) getObj(key, dataTypes.BOOLEAN);
|
||||
}
|
||||
|
||||
public Object getObj(String key, Enum<dataTypes> data) {
|
||||
//check for cache first
|
||||
|
||||
if (getCachedObjects().containsKey(key)) {
|
||||
return getCachedObjects().get(key);
|
||||
}
|
||||
|
||||
if (data.equals(dataTypes.STRING)) {
|
||||
String d = getConfig().getString(key);
|
||||
this.cachedObjects.put(key, d);
|
||||
return d;
|
||||
}
|
||||
|
||||
if (data.equals(dataTypes.DOUBLE)) {
|
||||
double d = getConfig().getDouble(key);
|
||||
this.cachedObjects.put(key, d);
|
||||
return d;
|
||||
}
|
||||
|
||||
if (data.equals(dataTypes.INT)) {
|
||||
int d = getConfig().getInt(key);
|
||||
this.cachedObjects.put(key, d);
|
||||
return d;
|
||||
}
|
||||
|
||||
if (data.equals(dataTypes.BOOLEAN)) {
|
||||
boolean d = getConfig().getBoolean(key);
|
||||
this.cachedObjects.put(key, d);
|
||||
return d;
|
||||
}
|
||||
|
||||
if (data.equals(dataTypes.STRINGLIST)) {
|
||||
List<String> d = getConfig().getStringList(key);
|
||||
this.cachedObjects.put(key, d);
|
||||
return d;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getCachedObjects() {
|
||||
return cachedObjects;
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public void setFile(File file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public void setFileConfig(YamlConfiguration fileConfig) {
|
||||
this.fileConfig = fileConfig;
|
||||
}
|
||||
|
||||
public YamlConfiguration getConfig() {
|
||||
return fileConfig;
|
||||
}
|
||||
|
||||
public enum dataTypes {
|
||||
STRING, INT, DOUBLE, STRINGLIST, BOOLEAN, MAP
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.massivecraft.factions.zcore.file.impl;
|
||||
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.zcore.file.CustomFile;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Factions - Developed by Driftay.
|
||||
* All rights reserved 2020.
|
||||
* Creation Date: 4/4/2020
|
||||
*/
|
||||
public class FileManager {
|
||||
|
||||
private CustomFile shop = new CustomFile(new File(FactionsPlugin.getInstance().getDataFolder() + "/shop.yml"));
|
||||
|
||||
public void setupFiles() {
|
||||
shop.setup(true, "");
|
||||
}
|
||||
|
||||
|
||||
public CustomFile getShop() {
|
||||
return shop;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.massivecraft.factions.util;
|
||||
package com.massivecraft.factions.zcore.frame;
|
||||
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.massivecraft.factions.zcore.fdisband;
|
||||
package com.massivecraft.factions.zcore.frame.fdisband;
|
||||
|
||||
import com.github.stefvanschie.inventoryframework.Gui;
|
||||
import com.github.stefvanschie.inventoryframework.GuiItem;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.massivecraft.factions.zcore.fupgrades;
|
||||
package com.massivecraft.factions.zcore.frame.fupgrades;
|
||||
|
||||
import com.github.stefvanschie.inventoryframework.Gui;
|
||||
import com.github.stefvanschie.inventoryframework.GuiItem;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.massivecraft.factions.zcore.fupgrades;
|
||||
package com.massivecraft.factions.zcore.frame.fupgrades;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.massivecraft.factions.zcore.fupgrades;
|
||||
package com.massivecraft.factions.zcore.frame.fupgrades;
|
||||
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.massivecraft.factions.util;
|
||||
package com.massivecraft.factions.zcore.frame.fwarps;
|
||||
|
||||
import com.github.stefvanschie.inventoryframework.Gui;
|
||||
import com.github.stefvanschie.inventoryframework.GuiItem;
|
||||
@@ -8,6 +8,10 @@ import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
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;
|
||||
@@ -863,12 +863,14 @@ public abstract class MemoryFPlayer implements FPlayer {
|
||||
return true;
|
||||
} else if (currentFaction.getAccess(this, PermissableAction.TERRITORY) == Access.ALLOW) {
|
||||
return true;
|
||||
} else if (currentFaction.isWilderness() && forFaction.getAccess(this, PermissableAction.TERRITORY) == Access.ALLOW) {
|
||||
return true;
|
||||
} else if (myFaction != forFaction) {
|
||||
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_CANTCLAIM.toString(), forFaction.describeTo(this));
|
||||
} else if (forFaction == currentFaction) {
|
||||
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_ALREADYOWN.toString(), forFaction.describeTo(this, true));
|
||||
} else if (this.getRole().value < Role.MODERATOR.value) {
|
||||
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_MUSTBE.toString(), Role.MODERATOR.getTranslation());
|
||||
} else if (forFaction.getAccess(this, PermissableAction.TERRITORY) != Access.ALLOW) {
|
||||
error = TL.COMMAND_CLAIM_DENIED.toString();
|
||||
} else if (forFaction.getFPlayers().size() < Conf.claimsRequireMinFactionMembers) {
|
||||
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_MEMBERS.toString(), Conf.claimsRequireMinFactionMembers);
|
||||
} else if (currentFaction.isSafeZone()) {
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.massivecraft.factions.util.RelationUtil;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.Permissable;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.fupgrades.UpgradeType;
|
||||
import com.massivecraft.factions.zcore.frame.fupgrades.UpgradeType;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import net.dv8tion.jda.core.entities.Member;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@@ -405,6 +405,7 @@ help:
|
||||
- '&c/f points &8- &7Check your factions points.'
|
||||
- '&c/f invsee &8- &7Check a faction members inventory.'
|
||||
- '&c/f stealth &8- &7Go into stealth mode to not disable enemies flight.'
|
||||
- '&c/f notifications &8- &7Disable or enable faction claim notifications.'
|
||||
- '&7&m--------------------&r &e/f help &7&m-----------------------'
|
||||
############################################################
|
||||
# +------------------------------------------------------+ #
|
||||
@@ -625,7 +626,6 @@ f-check:
|
||||
#This option is to see if another faction member can see their faction members that have the invisible potion effect
|
||||
See-Invisible-Faction-Members: false #ONLY WHEN SCOREBOARD IS ENABLED
|
||||
|
||||
|
||||
############################################################
|
||||
# +------------------------------------------------------+ #
|
||||
# | Faction Inventory See | #
|
||||
@@ -634,6 +634,7 @@ See-Invisible-Faction-Members: false #ONLY WHEN SCOREBOARD IS ENABLED
|
||||
#This option is the ability to see other faction members inventories
|
||||
f-inventory-see:
|
||||
Enabled: true
|
||||
|
||||
############################################################
|
||||
# +------------------------------------------------------+ #
|
||||
# | Faction Alt Accounts | #
|
||||
@@ -745,7 +746,6 @@ fcooldowns:
|
||||
Falling-Block-Fix:
|
||||
enabled: true
|
||||
|
||||
|
||||
############################################################
|
||||
# +------------------------------------------------------+ #
|
||||
# | Faction Disband | #
|
||||
@@ -769,8 +769,6 @@ f-disband-gui:
|
||||
Name: ' '
|
||||
Lore:
|
||||
|
||||
|
||||
|
||||
############################################################
|
||||
# +------------------------------------------------------+ #
|
||||
# | Faction GracePeriod | #
|
||||
|
||||
@@ -66,6 +66,7 @@ permissions:
|
||||
factions.kit.halfplayer:
|
||||
description: Can do all but create factions.
|
||||
children:
|
||||
factions.check: true
|
||||
factions.audit: true
|
||||
factions.drain: true
|
||||
factions.wild: true
|
||||
|
||||
36
src/main/resources/shop.yml
Normal file
36
src/main/resources/shop.yml
Normal file
@@ -0,0 +1,36 @@
|
||||
prefix: '&4&lFactionShop&8» &7Purchased &f%item% &7for &b%points% Points&7!'
|
||||
|
||||
items:
|
||||
'1':
|
||||
slot: 1
|
||||
block: STONE #Validated Through XMaterial Class Located At: https://github.com/SaberLLC/Saber-Factions/blob/1.6.x/src/main/java/com/massivecraft/factions/util/XMaterial.java
|
||||
name: '&aShop Item 1' #Display name of the item wanted in shop.
|
||||
lore:
|
||||
- '&cFully Customizable Lore!'
|
||||
- '&b&l{cost} &7Points'
|
||||
cmds: #You can have more then 1 command in this as it is a list of commands!
|
||||
- broadcast %player% bought Test Shop!
|
||||
cost: 5 #The number of faction points it will cost to buy this item.
|
||||
glowing: true #Do we want it to glow or not?
|
||||
'2':
|
||||
slot: 2
|
||||
block: STONE #Validated Through XMaterial Class Located At: https://github.com/SaberLLC/Saber-Factions/blob/1.6.x/src/main/java/com/massivecraft/factions/util/XMaterial.java
|
||||
name: '&aShop Item 2' #Display name of the item wanted in shop.
|
||||
lore:
|
||||
- '&cFully Customizable Lore!'
|
||||
- '&b&l{cost} &7Points'
|
||||
cmds: #You can have more then 1 command in this as it is a list of commands!
|
||||
- broadcast %player% bought Test Shop!
|
||||
cost: 5 #The number of faction points it will cost to buy this item.
|
||||
glowing: true #Do we want it to glow or not?
|
||||
'3':
|
||||
slot: 3
|
||||
block: STONE #Validated Through XMaterial Class Located At: https://github.com/SaberLLC/Saber-Factions/blob/1.6.x/src/main/java/com/massivecraft/factions/util/XMaterial.java
|
||||
name: '&aShop Item 3' #Display name of the item wanted in shop.
|
||||
lore:
|
||||
- '&cFully Customizable Lore!'
|
||||
- '&b&l{cost} &7Points'
|
||||
cmds: #You can have more then 1 command in this as it is a list of commands!
|
||||
- broadcast %player% bought Test Shop!
|
||||
cost: 5 #The number of faction points it will cost to buy this item.
|
||||
glowing: true #Do we want it to glow or not?
|
||||
Reference in New Issue
Block a user