F TNT Take Fix

This commit is contained in:
Driftay 2019-07-27 22:49:45 -04:00
parent 4a794fe706
commit 11fb6dcd7d
17 changed files with 649 additions and 34 deletions

View File

@ -3,6 +3,7 @@ package com.massivecraft.factions;
import com.massivecraft.factions.event.FactionDisbandEvent.PlayerDisbandReason;
import com.massivecraft.factions.iface.EconomyParticipator;
import com.massivecraft.factions.iface.RelationParticipator;
import com.massivecraft.factions.shop.Pair;
import com.massivecraft.factions.struct.BanInfo;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role;
@ -13,6 +14,7 @@ import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.fupgrades.UpgradeType;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@ -28,6 +30,11 @@ public interface Faction extends EconomyParticipator {
void deinviteAllAlts();
Map<String, Pair<Integer, Long>> getActivePotions();
Map<String, Long> getBoosters();
Map<String, Pair<Integer, Long>> getPotionEffects();
void altInvite(FPlayer fplayer);

View File

@ -10,6 +10,8 @@ import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.integration.Worldguard;
import com.massivecraft.factions.integration.dynmap.EngineDynmap;
import com.massivecraft.factions.listeners.*;
import com.massivecraft.factions.shop.handlers.BoosterHandler;
import com.massivecraft.factions.shop.handlers.PotionHandler;
import com.massivecraft.factions.struct.ChatMode;
import com.massivecraft.factions.util.*;
import com.massivecraft.factions.util.Particles.ReflectionUtils;
@ -230,6 +232,9 @@ public class SaberFactions extends MPlugin {
log("Skript addon registered!");
}
this.getServer().getScheduler().runTaskTimerAsynchronously(this, new BoosterHandler(), 100L, 100L);
this.getServer().getScheduler().runTaskTimerAsynchronously(this, new PotionHandler(this), 100L, 100L);
getServer().getPluginManager().registerEvents(factionsPlayerListener = new FactionsPlayerListener(), this);
// Register Event Handlers

View File

@ -0,0 +1,26 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.shop.ShopGUI;
import com.massivecraft.factions.zcore.util.TL;
public class CmdShop extends FCommand {
public CmdShop() {
this.aliases.add("shop");
this.senderMustBePlayer = true;
this.senderMustBeColeader = true;
}
@Override
public void perform() {
ShopGUI shopGUI = new ShopGUI(p, fme);
shopGUI.build();
fme.getPlayer().openInventory(shopGUI.getInventory());
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_SHOP_DESCRIPTION;
}
}

View File

@ -102,8 +102,8 @@ public class CmdTnt extends FCommand {
fme.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH);
return;
}
int fullStacks = amount / 64;
int remainderAmt = amount % 64;
int fullStacks = Math.round(amount / 6);
int remainderAmt = amount - (fullStacks * 64);
if ((remainderAmt == 0 && !hasAvaliableSlot(me, fullStacks))) {
fme.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_SPACE);
return;
@ -112,14 +112,10 @@ public class CmdTnt extends FCommand {
fme.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_SPACE);
return;
}
ItemStack tnt64 = new ItemStack(Material.TNT, 64);
for (int i = 0; i <= fullStacks - 1; i++) {
me.getInventory().addItem(tnt64);
}
if (remainderAmt != 0) {
ItemStack tnt = new ItemStack(Material.TNT, remainderAmt);
me.getInventory().addItem(tnt);
}
for (int i = 0; i <= fullStacks - 1; i++) me.getPlayer().getInventory().addItem(new ItemStack(Material.TNT, 64));
if (remainderAmt != 0) me.getPlayer().getInventory().addItem(new ItemStack(Material.TNT, remainderAmt));
fme.getFaction().takeTnt(amount);
me.updateInventory();
fme.msg(TL.COMMAND_TNT_WIDTHDRAW_SUCCESS);
@ -132,22 +128,8 @@ public class CmdTnt extends FCommand {
}
public boolean inventoryContains(Inventory inventory, ItemStack item) {
int count = 0;
ItemStack[] items = inventory.getContents();
for (int i = 0; i < items.length; i++) {
if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) {
count += items[i].getAmount();
}
if (count >= item.getAmount()) {
return true;
}
}
return false;
}
public boolean hasAvaliableSlot(Player player, int howmany) {
Integer check = 0;
int check = 0;
for (ItemStack item : player.getInventory().getContents()) {
if (item == null) {
check++;

View File

@ -34,9 +34,7 @@ public class CmdViewChest extends FCommand {
if (faction == null) {
return;
}
me.openInventory(faction.getChestInventory());
}
@Override

View File

@ -124,6 +124,7 @@ public class FCmdRoot extends FCommand {
public CmdFGlobal cmdFGlobal = new CmdFGlobal();
public CmdViewChest cmdViewChest = new CmdViewChest();
public CmdPoints cmdPoints = new CmdPoints();
public CmdShop cmdShop = new CmdShop();
@ -242,7 +243,7 @@ public class FCmdRoot extends FCommand {
this.addSubCommand(this.cmdCorner);
this.addSubCommand(this.cmdFGlobal);
this.addSubCommand(this.cmdViewChest);
this.addSubCommand(this.cmdShop);
if (SaberFactions.plugin.getConfig().getBoolean("f-inventory-see.Enabled")) {
this.addSubCommand(this.cmdInventorySee);

View File

@ -0,0 +1,20 @@
package com.massivecraft.factions.shop;
public class Pair<K, V> {
private K key;
private V value;
public Pair(K key, V value) {
this.key = key;
this.value = value;
}
public K getKey() {
return this.key;
}
public V getValue() {
return this.value;
}
}

View File

@ -0,0 +1,148 @@
package com.massivecraft.factions.shop;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.SaberFactions;
import com.massivecraft.factions.util.FactionGUI;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.*;
public class ShopBoosterGUI implements FactionGUI {
private SaberFactions plugin;
private FPlayer fPlayer;
private Inventory inventory;
private Map<Integer, String> items;
public ShopBoosterGUI(SaberFactions plugin, FPlayer fPlayer) {
this.items = new HashMap<>();
this.plugin = plugin;
this.fPlayer = fPlayer;
this.inventory = plugin.getServer().createInventory(this, plugin.getConfig().getInt("BoosterGUISize") * 9, TL.SHOP_BOOSTER_TITLE.toString());
}
@Override
public void onClick(int slot, ClickType action) {
if (slot == plugin.getConfig().getInt("BackButtonSlot")) {
ShopGUI shopGUI = new ShopGUI(plugin, fPlayer);
shopGUI.build();
fPlayer.getPlayer().openInventory(shopGUI.getInventory());
return;
}
String booster = items.getOrDefault(slot, null);
if (booster == null) {
return;
}
ConfigurationSection section = plugin.getConfig().getConfigurationSection("BoosterGUI").getConfigurationSection(booster);
if (section == null) {
return;
}
Faction faction = fPlayer.getFaction();
int max = plugin.getConfig().getInt("MaxActiveBooster");
if (faction.getActivePotions().size() >= max) {
fPlayer.msg(TL.SHOP_GUI_BOOSTER_MAX_REACHED, max);
return;
}
if (fPlayer.getFaction().getBoosters().containsKey(booster)) {
fPlayer.msg(TL.SHOP_GUI_BOOSTER_ACTIVE_ALREADY_ACTIVE);
return;
}
int cost = section.getInt("PointCost");
if (faction.getPoints() < cost) {
fPlayer.msg(TL.SHOP_GUI_BOOSTER_CANNOT_AFFORD, cost);
return;
}
String name = ChatColor.translateAlternateColorCodes('&', section.getString("Name"));
faction.setPoints(faction.getPoints() - cost);
String string;
String type = string = section.getString("Type");
switch (string) {
case "COMMAND": {
for (String command : section.getStringList("Commands")) {
this.plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), command.replace("%faction%", fPlayer.getFaction().getTag()));
}
break;
}
case "COMMAND_ONLINE": {
for (FPlayer player : fPlayer.getFaction().getFPlayersWhereOnline(true)) {
for (String command2 : section.getStringList("Commands")) {
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), command2.replace("%faction%", fPlayer.getFaction().getTag()).replace("%player_name%", player.getName()).replace("%player_uuid%", player.getPlayer().getUniqueId().toString()));
}
}
break;
}
case "COMMAND_OFFLINE": {
for (FPlayer player : fPlayer.getFaction().getFPlayers()) {
for (String command2 : section.getStringList("Commands")) {
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), command2.replace("%faction%", fPlayer.getFaction().getTag()).replace("%player_name%", player.getName()).replace("%player_uuid%", this.plugin.getServer().getOfflinePlayer(player.getName()).getUniqueId().toString()));
}
}
break;
}
}
fPlayer.getFaction().getBoosters().put(booster, System.currentTimeMillis() + section.getInt("CooldownMinutes") * 60000);
faction.msg(TL.SHOP_POTION_GUI_ACTIVATED, fPlayer.getNameAndTitle(), name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase());
build();
fPlayer.getPlayer().openInventory(inventory);
}
@Override
public void build() {
ConfigurationSection configurationSection = plugin.getConfig().getConfigurationSection("BoosterGUI");
if (configurationSection == null) {
return;
}
Set<String> boosters = fPlayer.getFaction().getBoosters().keySet();
for (String key : configurationSection.getKeys(false)) {
ConfigurationSection section = configurationSection.getConfigurationSection(key);
int slot = Integer.valueOf(key);
int price = section.getInt("PointCost");
ItemStack itemStack = new ItemStack(Material.valueOf(section.getString("Material")));
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', section.getString("Name")));
List<String> loreLines = new ArrayList<>();
for (String line : section.getStringList("Lore")) {
loreLines.add(ChatColor.translateAlternateColorCodes('&', line.replace("%price%", String.valueOf(price))));
}
if (boosters.contains(key)) {
itemMeta.addEnchant(Enchantment.SILK_TOUCH, 1, true);
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
loreLines.add(TL.SHOP_GUI_BOOSTER_ACTIVE_LORE_LINE.toString());
}
itemMeta.setLore(loreLines);
itemStack.setItemMeta(itemMeta);
inventory.setItem(slot, itemStack);
items.put(slot, key);
}
ConfigurationSection backSection = plugin.getConfig().getConfigurationSection("BackButton");
if (backSection != null) {
ItemStack backStack = new ItemStack(Material.valueOf(backSection.getString("Material")));
ItemMeta backMeta = backStack.getItemMeta();
backMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', backSection.getString("Name")));
backStack.setItemMeta(backMeta);
inventory.setItem(plugin.getConfig().getInt("BackButtonSlot"), backStack);
}
ConfigurationSection pointsSection = plugin.getConfig().getConfigurationSection("PointsItem");
if (pointsSection != null) {
ItemStack pointsStack = new ItemStack(Material.valueOf(pointsSection.getString("Material")));
ItemMeta pointsMeta = pointsStack.getItemMeta();
pointsMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', pointsSection.getString("Name").replace("%points%", String.valueOf(fPlayer.getFaction().getPoints()))));
pointsStack.setItemMeta(pointsMeta);
inventory.setItem(plugin.getConfig().getInt("PointsSlot"), pointsStack);
}
}
public Inventory getInventory() {
return inventory;
}
}

View File

@ -0,0 +1,59 @@
package com.massivecraft.factions.shop;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.SaberFactions;
import com.massivecraft.factions.util.FactionGUI;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class ShopGUI implements FactionGUI {
private SaberFactions plugin;
private FPlayer fPlayer;
private Inventory inventory;
public ShopGUI(SaberFactions plugin, FPlayer fPlayer) {
this.plugin = plugin;
this.fPlayer = fPlayer;
this.inventory = plugin.getServer().createInventory(this, 27, plugin.color(plugin.getConfig().getString("F-Shop.Gui-Title")));
}
@Override
public void onClick(int slot, ClickType action) {
if (slot == 11) {
ShopPotionGUI potionGUI = new ShopPotionGUI(plugin, fPlayer);
potionGUI.build();
fPlayer.getPlayer().openInventory(potionGUI.getInventory());
} else if (slot == 15) {
ShopBoosterGUI boosterGUI = new ShopBoosterGUI(plugin, fPlayer);
boosterGUI.build();
fPlayer.getPlayer().openInventory(boosterGUI.getInventory());
}
}
@Override
public void build() {
ItemStack potionStack = new ItemStack(Material.POTION);
PotionMeta potionMeta = (PotionMeta) potionStack.getItemMeta();
potionMeta.addCustomEffect(new PotionEffect(PotionEffectType.REGENERATION, 1, 1), true);
potionMeta.setDisplayName(ChatColor.LIGHT_PURPLE + ChatColor.BOLD.toString() + "Potion Shop");
potionStack.setItemMeta(potionMeta);
inventory.setItem(11, potionStack);
ItemStack boosterStack = new ItemStack(Material.GOLDEN_APPLE);
ItemMeta boosterMeta = boosterStack.getItemMeta();
boosterMeta.setDisplayName(ChatColor.WHITE + ChatColor.BOLD.toString() + "Booster Shop");
boosterStack.setItemMeta(boosterMeta);
inventory.setItem(15, boosterStack);
}
public Inventory getInventory() {
return this.inventory;
}
}

View File

@ -0,0 +1,122 @@
package com.massivecraft.factions.shop;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.SaberFactions;
import com.massivecraft.factions.util.FactionGUI;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import java.util.*;
public class ShopPotionGUI implements FactionGUI {
private SaberFactions plugin;
private FPlayer fPlayer;
private Inventory inventory;
private Map<Integer, Pair<String, Pair<Integer, Integer>>> items;
public ShopPotionGUI(SaberFactions plugin, FPlayer fPlayer) {
this.items = new HashMap<>();
this.plugin = plugin;
this.fPlayer = fPlayer;
this.inventory = plugin.getServer().createInventory(this, plugin.getConfig().getInt("PotionGUISize") * 9, TL.SHOP_POTION_TITLE.toString());
}
@Override
public void onClick(int slot, ClickType action) {
if (slot == plugin.getConfig().getInt("BackButtonSlot")) {
ShopGUI shopGUI = new ShopGUI(plugin, fPlayer);
shopGUI.build();
fPlayer.getPlayer().openInventory(shopGUI.getInventory());
return;
}
Pair<String, Pair<Integer, Integer>> pair = items.getOrDefault(slot, null);
if (pair == null) {
return;
}
Faction faction = fPlayer.getFaction();
int max = plugin.getConfig().getInt("MaxActivePotions");
if (faction.getActivePotions().size() >= max) {
fPlayer.msg(TL.SHOP_POTION_GUI_MAX_REACHED, max);
return;
}
if (faction.getActivePotions().containsKey(pair.getKey())) {
fPlayer.msg(TL.SHOP_POTION_GUI_POTION_TYPE_ALREADY_ACTIVE);
return;
}
if (faction.getPoints() < pair.getValue().getValue()) {
fPlayer.msg(TL.SHOP_POTION_GUI_INSUFFICIENT_POINTS, pair.getValue().getValue());
return;
}
faction.setPoints(faction.getPoints() - pair.getValue().getValue());
faction.getActivePotions().put(pair.getKey(), new Pair<>(pair.getValue().getKey(), System.currentTimeMillis() + plugin.getConfig().getInt("PotionsLastHours") * 3600000));
faction.msg(TL.SHOP_POTION_GUI_ACTIVATED, fPlayer.getNameAndTitle(), pair.getKey().substring(0, 1).toUpperCase() + pair.getKey().substring(1).toLowerCase().replace('_', ' '));
build();
fPlayer.getPlayer().openInventory(inventory);
}
@Override
public void build() {
ConfigurationSection configurationSection = plugin.getConfig().getConfigurationSection("PotionShop");
if (configurationSection == null) {
return;
}
Set<String> activePotions = fPlayer.getFaction().getActivePotions().keySet();
for (String key : configurationSection.getKeys(false)) {
ConfigurationSection section = configurationSection.getConfigurationSection(key);
int slot = Integer.valueOf(key);
int level = section.getInt("Level");
int price = section.getInt("PointCost");
String potionType = section.getString("PotionType");
ItemStack itemStack = new ItemStack(Material.POTION);
PotionMeta itemMeta = (PotionMeta) itemStack.getItemMeta();
itemMeta.addCustomEffect(new PotionEffect(PotionEffectType.getByName(potionType), 1, level), true);
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', section.getString("Name")));
List<String> loreLines = new ArrayList<>();
for (String line : section.getStringList("Lore")) {
loreLines.add(ChatColor.translateAlternateColorCodes('&', line).replace("%price%", String.valueOf(price)));
}
if (activePotions.contains(potionType)) {
itemMeta.addEnchant(Enchantment.SILK_TOUCH, 1, true);
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
loreLines.add(TL.SHOP_POTION_GUI_ACTIVATED_LORE_LINE.toString());
}
itemMeta.setLore(loreLines);
itemStack.setItemMeta(itemMeta);
inventory.setItem(slot, itemStack);
items.put(slot, new Pair<>(potionType, new Pair<>(level, price)));
}
ConfigurationSection backSection = plugin.getConfig().getConfigurationSection("BackButton");
if (backSection != null) {
ItemStack backStack = new ItemStack(Material.valueOf(backSection.getString("Material")));
ItemMeta backMeta = backStack.getItemMeta();
backMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', backSection.getString("Name")));
backStack.setItemMeta(backMeta);
inventory.setItem(plugin.getConfig().getInt("BackButtonSlot"), backStack);
}
ConfigurationSection pointsSection = plugin.getConfig().getConfigurationSection("PointsItem");
if (pointsSection != null) {
ItemStack pointsStack = new ItemStack(Material.valueOf(pointsSection.getString("Material")));
ItemMeta pointsMeta = pointsStack.getItemMeta();
pointsMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', pointsSection.getString("Name").replace("%points%", String.valueOf(fPlayer.getFaction().getPoints()))));
pointsStack.setItemMeta(pointsMeta);
inventory.setItem(plugin.getConfig().getInt("PointsSlot"), pointsStack);
}
}
public Inventory getInventory() {
return inventory;
}
}

View File

@ -0,0 +1,28 @@
package com.massivecraft.factions.shop.handlers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class BoosterHandler implements Runnable {
@Override
public void run() {
final long currentTime = System.currentTimeMillis();
for (final Faction faction : Factions.getInstance().getAllFactions()) {
final List<String> remove = new ArrayList<>();
for (final Map.Entry<String, Long> entry : faction.getBoosters().entrySet()) {
if (entry.getValue() < currentTime) {
remove.add(entry.getKey());
}
}
remove.forEach((r) ->{
Long n = faction.getBoosters().remove(r);
});
}
}
}

View File

@ -0,0 +1,46 @@
package com.massivecraft.factions.shop.handlers;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.SaberFactions;
import com.massivecraft.factions.shop.Pair;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class PotionHandler implements Runnable {
private SaberFactions plugin;
public PotionHandler(SaberFactions plugin) {
this.plugin = plugin;
}
@Override
public void run() {
long currentTime = System.currentTimeMillis();
for (Faction faction : Factions.getInstance().getAllFactions()) {
List<String> remove = new ArrayList<String>();
for (Map.Entry<String, Pair<Integer, Long>> entry : faction.getActivePotions().entrySet()) {
if (entry.getValue().getValue() < currentTime) {
remove.add(entry.getKey());
} else {
PotionEffect potionEffect = new PotionEffect(PotionEffectType.getByName(entry.getKey()), 400, entry.getValue().getKey(), false, false);
for (FPlayer fPlayer : faction.getFPlayersWhereOnline(true)) {
if (!fPlayer.isInOwnTerritory()) {
continue;
}
this.plugin.getServer().getScheduler().runTask(this.plugin, () -> fPlayer.getPlayer().addPotionEffect(potionEffect, true));
}
}
}
remove.forEach(key -> {
Pair<Integer, Long> pair = faction.getActivePotions().remove(key);
});
}
}
}

View File

@ -1,8 +1,9 @@
package com.massivecraft.factions.util;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.InventoryHolder;
public interface FactionGUI {
public interface FactionGUI extends InventoryHolder {
void onClick(int slot, ClickType action);

View File

@ -120,6 +120,7 @@ public enum PermissableAction {
accessValue = "allow";
break;
case DENY:
accessValue = "deny";
break;
case UNDEFINED:
accessValue = "undefined";
@ -127,7 +128,9 @@ public enum PermissableAction {
}
// If under the 1.13 version we will use the colorable option.
if (!SaberFactions.plugin.mc113 && !SaberFactions.plugin.mc114) { //TODO see if it's working in other version than 1.13 and 1.14
if (!SaberFactions.plugin.mc113 && !SaberFactions.plugin.mc114) {
//TODO see if it's working in other version than 1.13 and 1.14
DyeColor dyeColor = null;
try {

View File

@ -8,6 +8,7 @@ import com.massivecraft.factions.iface.EconomyParticipator;
import com.massivecraft.factions.iface.RelationParticipator;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.scoreboards.FTeamWrapper;
import com.massivecraft.factions.shop.Pair;
import com.massivecraft.factions.struct.BanInfo;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Relation;
@ -72,6 +73,8 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
private long lastDeath;
private int strikes = 0;
private int points = 0;
private Map<String, Pair<Integer, Long>> potionEffects;
private Map<String, Long> boosters;
// -------------------------------------------- //
// Construct
@ -93,7 +96,8 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
this.foundedDate = System.currentTimeMillis();
this.maxVaults = Conf.defaultMaxVaults;
this.defaultRole = Role.RECRUIT;
potionEffects = new ConcurrentHashMap<>();
boosters = new ConcurrentHashMap<>();
resetPerms(); // Reset on new Faction so it has default values.
}
@ -114,6 +118,8 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
relationWish = old.relationWish;
claimOwnership = old.claimOwnership;
fplayers = new HashSet<>();
potionEffects = new ConcurrentHashMap<>();
boosters = new ConcurrentHashMap<>();
alts = new HashSet<>();
invites = old.invites;
announcements = old.announcements;
@ -428,6 +434,11 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
chest.setContents(contents);
}
@Override
public Map<String, Long> getBoosters() {
return this.boosters;
}
@Override
public void setBannerPattern(ItemStack banner) {
@ -965,8 +976,6 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
public Set<FPlayer> getFPlayersWhereOnline(boolean online) {
Set<FPlayer> ret = new HashSet<>();
if (!this.isNormal()) return ret;
for (FPlayer fplayer : fplayers) {
if (fplayer.isOnline() == online) {
@ -1242,6 +1251,16 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
return claimOwnership.get(loc);
}
@Override
public Map<String, Pair<Integer, Long>> getActivePotions() {
return this.potionEffects;
}
@Override
public Map<String, Pair<Integer, Long>> getPotionEffects() {
return this.potionEffects;
}
public String getOwnerListString(FLocation loc) {
Set<String> ownerData = claimOwnership.get(loc);
if (ownerData == null || ownerData.isEmpty()) {

View File

@ -166,6 +166,7 @@ public enum TL {
COMMAND_AUTOHELP_HELPFOR("Help for command \""),
COMMAND_HOME_OTHER_NOTSET("&c&l[!] &7%s does not have their faction home set!"),
COMMAND_HOME_TELEPORT_OTHER("&c&l[!] &7You have teleported to %s's faction home!"),
COMMAND_SHOP_DESCRIPTION("opens shop gui"),
COMMAND_BAN_DESCRIPTION("Ban players from joining your Faction."),
COMMAND_BAN_TARGET("&c&l[!] &7You were &cbanned &7from &c%1$s"), // banned player perspective
@ -771,6 +772,20 @@ public enum TL {
COMMAND_TOGGLESB_DISABLED("You can't toggle scoreboards while they are disabled."),
SHOP_POTION_TITLE("&c&lPotion Shop"),
SHOP_POTION_GUI_ACTIVATED_LORE_LINE("&a&lPotion Type Active"),
SHOP_POTION_GUI_ACTIVATED("&d%1$s activated &f%2$s &dfor your faction!"),
SHOP_POTION_GUI_INSUFFICIENT_POINTS("&c&l[!] &7Your faction can't afford that, you need &d%1$s &7faction points"),
SHOP_POTION_GUI_POTION_TYPE_ALREADY_ACTIVE("&c&l[!] &7This Potion Type is Already Active for Your Faction!"),
SHOP_POTION_GUI_MAX_REACHED("&c&l[!] &7You may not have more than %1$s potions at the same time"),
SHOP_BOOSTER_TITLE("&b&lBooster Shop"),
SHOP_GUI_BOOSTER_MAX_REACHED("&c&l[!] &7You may not have more than %1$s boosters at the same time"),
SHOP_GUI_BOOSTER_ACTIVE_ALREADY_ACTIVE("&a&lActive"),
SHOP_GUI_BOOSTER_CANNOT_AFFORD("&c&l[!] &7Your faction can't afford that, you need &d%1$s faction points"),
SHOP_GUI_BOOSTER_ACTIVE_LORE_LINE("&a&lActive"),
COMMAND_TOP_DESCRIPTION("Sort Factions to see the top of some criteria."),
COMMAND_TOP_TOP("Top Factions by %s. Page %d/%d"),
COMMAND_TOP_LINE("%d. &6%s: &c%s"), // Rank. Faction: Value

View File

@ -1117,11 +1117,146 @@ fupgrades:
- '&e&lClick to &nUnlock'
slots:
- 22
############################################################
# +------------------------------------------------------+ #
# | Faction Banners | #
# | Faction Shop | #
# +------------------------------------------------------+ #
############################################################
F-Shop:
Gui-Title: '&c&lFaction Shop'
BackButtonSlot: 0
BackButton:
Material: "ARROW"
Name: "&8<< Back"
PointsSlot: 4
PointsItem:
Material: "PAPER"
Name: "&dYour Faction has &f&n%points% Points"
#Potions Shop#
PotionGUISize: 3
PotionsLastHours: 6
MaxActivePotions: 2
PotionShop:
'9':
Name: "&dFire Resistance"
Lore:
- "&ffor 6 hours"
- ""
- "&d&lPrice: &f&l%price%"
PotionType: "FIRE_RESISTANCE"
Level: 0
PointCost: 100
'10':
Name: "&dStrength II"
Lore:
- "&ffor 6 hours"
- ""
- "&d&lPrice: &f&l%price%"
PotionType: "INCREASE_DAMAGE"
Level: 1
PointCost: 100
'11':
Name: "&dSpeed II"
Lore:
- "&ffor 6 hours"
- ""
- "&d&lPrice: &f&l%price%"
PotionType: "SPEED"
Level: 1
PointCost: 100
'12':
Name: "&dRegeneration"
Lore:
- "&ffor 6 hours"
- ""
- "&d&lPrice: &f&l%price%"
PotionType: "REGENERATION"
Level: 0
PointCost: 100
'13':
Name: "&dWater Breathing"
Lore:
- "&ffor 6 hours"
- ""
- "&d&lPrice: &f&l%price%"
PotionType: "WATER_BREATHING"
Level: 0
PointCost: 100
'14':
Name: "&dSaturation"
Lore:
- "&ffor 6 hours"
- ""
- "&d&lPrice: &f&l%price%"
PotionType: "SATURATION"
Level: 0
PointCost: 100
'15':
Name: "&dHaste II"
Lore:
- "&ffor 6 hours"
- ""
- "&d&lPrice: &f&l%price%"
PotionType: "FAST_DIGGING"
Level: 1
PointCost: 100
'16':
Name: "&dJump Boost II"
Lore:
- "&ffor 6 hours"
- ""
- "&d&lPrice: &f&l%price%"
PotionType: "JUMP"
Level: 1
PointCost: 100
'17':
Name: "&dHealth Boost"
Lore:
- "&ffor 6 hours"
- ""
- "&d&lPrice: &f&l%price%"
PotionType: "HEALTH_BOOST"
Level: 0
PointCost: 100
#Booster Shop#
#PlaceHolders: %faction% - %player_name% - %player_uuid%
#Booster Types:
# COMMAND - Faction Based Boosters
# COMMAND_ONLINE - Faction, Player, and Offline Player based
# COMMAND_OFFLINE - Offline Faction Members, Players, and UUID Based
# Multiple Commands Supported!
BoosterGUISize: 3 #Rows
MaxActiveBooster: 2
BoosterGUI:
'11': #Represents Whereabouts in the GUI
Material: "DIAMOND"
Name: "&aCool Booster"
Lore:
- "&ffor 30 minutes"
- ""
- "&d&lPrice: &f&l%price%"
CooldownMinutes: 30
Type: "COMMAND"
Commands: ["bc booster bought! %faction% enjoy your booster!"]
PointCost: 100
'15':
Material: "GHAST_TEAR"
Name: "&cCool Booster"
Lore:
- "&ffor 30 minutes"
- ""
- "&d&lPrice: &f&l%price%"
CooldownMinutes: 30
Type: "COMMAND_OFFLINE"
Commands: ["bc booster bought by %player_name%"] #Will broadcast that <player> bought said booster.
PointCost: 100
fbanners:
Enabled: true
Item: