Merge from Driftay/1.6.x

This commit is contained in:
DroppingAnvil 2019-09-24 12:07:58 -05:00 committed by GitHub
commit c2ac4a6517
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 285 additions and 16 deletions

View File

@ -4,7 +4,7 @@
<groupId>com.massivecraft</groupId>
<artifactId>Factions</artifactId>
<version>1.6.9.5-U0.2.1-1.9.4-BETA</version>
<version>1.6.9.5-U0.2.1-1.9.5-BETA</version>
<packaging>jar</packaging>
<name>SaberFactions</name>

View File

@ -23,6 +23,10 @@ import java.util.concurrent.ConcurrentHashMap;
public interface Faction extends EconomyParticipator {
String getDiscord();
void setDiscord(String link);
void checkPerms();
double getReinforcedArmor();
@ -59,6 +63,8 @@ public interface Faction extends EconomyParticipator {
Map<String, Mission> getMissions();
List<String> getCompletedMissions();
void deinviteAlt(FPlayer alt);
void deinviteAllAlts();

View File

@ -10,6 +10,7 @@ import com.massivecraft.factions.cmd.FCmdRoot;
import com.massivecraft.factions.cmd.FCommand;
import com.massivecraft.factions.cmd.check.CheckTask;
import com.massivecraft.factions.cmd.check.WeeWooTask;
import com.massivecraft.factions.cmd.chest.AntiChestListener;
import com.massivecraft.factions.cmd.chest.ChestLogsHandler;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.integration.Worldguard;
@ -86,6 +87,7 @@ public class FactionsPlugin extends MPlugin {
private ClipPlaceholderAPIManager clipPlaceholderAPIManager;
private boolean mvdwPlaceholderAPIManager = false;
private Listener[] eventsListener;
public List<String> itemList = getConfig().getStringList("fchest.Items-Not-Allowed");
public FactionsPlugin() {
@ -268,6 +270,7 @@ public class FactionsPlugin extends MPlugin {
new FUpgradesGUI(),
new UpgradesListener(),
new MissionHandler(this),
new AntiChestListener(),
new ChestLogsHandler()
};

View File

@ -0,0 +1,59 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
public class CmdSeeDiscord extends FCommand{
public CmdSeeDiscord() {
this.aliases.add("seediscord");
this.aliases.add("discord");
this.optionalArgs.put("faction", "yours");
this.requirements = new CommandRequirements.Builder(Permission.DISCORD)
.memberOnly()
.build();
}
@Override
public void perform(CommandContext context) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("fdiscord.Enabled")) {
context.msg(TL.GENERIC_DISABLED);
return;
}
if (context.args.size() == 0) {
if (context.fPlayer.getFaction().getDiscord() == null) {
context.msg(TL.COMMAND_DISCORD_NOTSET);
} else {
context.msg(TL.DISCORD_PLAYER_DISCORD, context.fPlayer.getFaction().getDiscord());
}
} else if (context.args.size() == 1) {
if (context.fPlayer.isAdminBypassing()) {
Faction faction = context.argAsFaction(0);
if (faction != null) {
if (faction.getDiscord() == null) {
context.msg(TL.COMMAND_DISCORDSEE_FACTION_NOTSET, faction.getTag());
} else {
context.msg(TL.COMMAND_DISCORDSEE_FACTION_DISCORD.toString(), faction.getTag(), faction.getDiscord());
}
}
} else {
context.msg(TL.GENERIC_NOPERMISSION, "see another factions discord.");
}
} else {
context.msg(FactionsPlugin.getInstance().cmdBase.cmdSeeDiscord.getUsageTemplate(context));
}
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_DISCORDSEE_DESCRIPTION;
}
}

View File

@ -0,0 +1,65 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
public class CmdSetDiscord extends FCommand {
public CmdSetDiscord(){
super();
this.aliases.add("setdiscord");
this.optionalArgs.put("faction", "yours");
this.requiredArgs.add("link");
this.requirements = new CommandRequirements.Builder(Permission.SETDISCORD)
.playerOnly()
.memberOnly()
.build();
}
@Override
public void perform(CommandContext context) {
if (!FactionsPlugin.getInstance().getConfig().getBoolean("fdiscord.Enabled")) {
context.fPlayer.msg(TL.GENERIC_DISABLED, "discord");
return;
}
if (context.args.size() == 1) {
if (isDiscordInvite(context.argAsString(0))) {
context.fPlayer.getFaction().setDiscord(context.argAsString(0));
context.msg(TL.COMMAND_DISCORDSET_SUCCESSFUL, context.argAsString(0));
} else {
context.msg(TL.COMMAND_DISCORDSET_NOTEMAIL, context.argAsString(0));
}
} else if (context.args.size() == 2) {
if (context.fPlayer.isAdminBypassing()) {
Faction faction = context.argAsFaction(1);
if (faction != null) {
if (isDiscordInvite(context.argAsString(0))) {
context.fPlayer.getFaction().setDiscord(context.argAsString(0));
context.msg(TL.COMMAND_DISCORDSET_ADMIN_SUCCESSFUL, faction.getTag(), context.argAsString(0));
} else {
context.msg(TL.COMMAND_DISCORDSET_ADMIN_FAILED, context.argAsString(0));
}
}
} else {
context.msg(TL.GENERIC_NOPERMISSION, "set another factions discord link!");
}
} else {
context.msg(FactionsPlugin.getInstance().cmdBase.cmdSetDiscord.getUsageTemplate(context));
}
}
private boolean isDiscordInvite(String invite){
return invite.contains("discord.gg") || invite.contains("discord.me");
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_DISCORDSET_DESCRIPTION;
}
}

View File

@ -147,6 +147,8 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
public CmdWeeWoo cmdWeeWoo = new CmdWeeWoo();
public CmdConvertConfig cmdConvertConfig = new CmdConvertConfig();
public CmdSpawnerLock cmdSpawnerLock = new CmdSpawnerLock();
public CmdSetDiscord cmdSetDiscord = new CmdSetDiscord();
public CmdSeeDiscord cmdSeeDiscord = new CmdSeeDiscord();
public FCmdRoot() {
super();
@ -307,6 +309,12 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
FactionsPlugin.getInstance().log(Level.INFO, "Enabling FactionsTop command, this is a very basic /f top please get a dedicated /f top resource if you want land calculation etc.");
this.addSubCommand(this.cmdTop);
}
if (FactionsPlugin.getInstance().getConfig().getBoolean("fdiscord.Enabled")) {
this.addSubCommand(this.cmdSetDiscord);
this.addSubCommand(this.cmdSeeDiscord);
}
if (FactionsPlugin.getInstance().getConfig().getBoolean("fpaypal.Enabled")) {
this.addSubCommand(this.cmdPaypalSet);
this.addSubCommand(this.cmdPaypalSee);

View File

@ -0,0 +1,67 @@
package com.massivecraft.factions.cmd.chest;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
public class AntiChestListener implements Listener {
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
Player player = (Player) e.getWhoClicked();
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
if (!e.getView().getTopInventory().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")))) return;
if (e.isCancelled()) return;
Inventory clicked = e.getClickedInventory();
if (e.getClick().isShiftClick()) {
if (clicked == e.getWhoClicked().getInventory()) {
ItemStack clickedOn = e.getCurrentItem();
if (clickedOn != null && FactionsPlugin.getInstance().itemList.contains(clickedOn.getType().toString())) {
fPlayer.msg(TL.CHEST_ITEM_DENIED_TRANSFER, clickedOn.getType().toString());
e.setCancelled(true);
}
}
}
if (clicked != e.getWhoClicked().getInventory()) {
ItemStack onCursor = e.getCursor();
if (onCursor != null && FactionsPlugin.getInstance().itemList.contains(onCursor.getType().toString())) {
fPlayer.msg(TL.CHEST_ITEM_DENIED_TRANSFER, onCursor.getType().toString());
e.setCancelled(true);
}
}
}
@EventHandler
public void onInventoryDrag(InventoryDragEvent e) {
Player p = (Player) e.getWhoClicked();
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(p);
if (!e.getView().getTopInventory().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")))) return;
if (e.isCancelled()) return;
ItemStack dragged = e.getOldCursor();
if (FactionsPlugin.getInstance().itemList.contains(dragged.getType().toString())) {
int inventorySize = e.getInventory().getSize();
for (int i : e.getRawSlots()) {
if (i < inventorySize) {
fPlayer.msg(TL.CHEST_ITEM_DENIED_TRANSFER, dragged.getType().toString());
e.setCancelled(true);
break;
}
}
}
}
}

View File

@ -35,7 +35,7 @@ public class CmdMoney extends FCommand {
@Override
public void perform(CommandContext context) {
if (!Conf.econEnabled) {
if (!Conf.econEnabled || !Conf.bankEnabled) {
context.msg(TL.ECON_OFF, "economy option is enabled, please set \'econEnabled\' to true in conf.json");
return;
}

View File

@ -55,6 +55,13 @@ public class MissionGUI implements FactionGUI {
if (section == null) {
return;
}
if(FactionsPlugin.getInstance().getConfig().getBoolean("DenyMissionsMoreThenOnce")) {
if (fPlayer.getFaction().getCompletedMissions().contains(missionName)) {
fPlayer.msg(TL.MISSION_ALREAD_COMPLETED);
return;
}
}
ConfigurationSection missionSection = section.getConfigurationSection("Mission");
if (missionSection == null) {
return;

View File

@ -159,5 +159,6 @@ public class MissionHandler implements Listener {
}
fPlayer.getFaction().getMissions().remove(mission.getName());
fPlayer.getFaction().msg(TL.MISSION_MISSION_FINISHED, plugin.color(section.getString("Name")));
fPlayer.getFaction().getCompletedMissions().add(mission.getName());
}
}

View File

@ -3,7 +3,6 @@ package com.massivecraft.factions.shop;
import com.github.stefvanschie.inventoryframework.Gui;
import com.github.stefvanschie.inventoryframework.GuiItem;
import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
import com.google.common.collect.ImmutableList;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
@ -21,7 +20,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

View File

@ -34,6 +34,7 @@ public enum Permission {
DESCRIPTION("description"),
DISBAND("disband"),
DISBAND_ANY("disband.any"),
DISCORD("discord"),
FLY("fly"),
FOCUS("focus"),
GLOBALCHAT("globalchat"),
@ -90,6 +91,7 @@ public enum Permission {
RELOAD("reload"),
SAVE("save"),
SPAM("spam"),
SETDISCORD("setdiscord"),
SETHOME("sethome"),
SETHOME_ANY("sethome.any"),
SETSTRIKES("setstrikes"),

View File

@ -1,6 +1,8 @@
package com.massivecraft.factions.util;
import com.google.gson.*;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FactionsPlugin;
import org.bukkit.inventory.Inventory;
import java.lang.reflect.Type;
@ -20,8 +22,6 @@ public class InventoryTypeAdapter implements JsonSerializer<Inventory>, JsonDese
@Override
public Inventory deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) {
JsonObject object = jsonElement.getAsJsonObject();
return InventoryUtil.fromBase64(object.get("contents").getAsString());
return InventoryUtil.fromBase64(object.get("contents").getAsString(), FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")));
}
}

View File

@ -1,5 +1,6 @@
package com.massivecraft.factions.util;
import com.massivecraft.factions.FactionsPlugin;
import org.bukkit.Bukkit;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@ -71,11 +72,11 @@ public class InventoryUtil {
return toBase64(inventory);
}
public static Inventory fromBase64(String data) {
public static Inventory fromBase64(String data, String invName) {
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
Inventory inventory = Bukkit.getServer().createInventory(null, dataInput.readInt());
Inventory inventory = Bukkit.getServer().createInventory(null, dataInput.readInt(), FactionsPlugin.getInstance().color(invName));
// Read the serialized inventory
for (int i = 0; i < inventory.getSize(); i++) {

View File

@ -8,6 +8,7 @@ import com.massivecraft.factions.util.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -272,7 +273,7 @@ public class FUpgradesGUI implements Listener {
private void updateChests(Faction faction) {
String invName = FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title"));
for (Player player : faction.getOnlinePlayers()) {
for (HumanEntity player : faction.getChestInventory().getViewers()) {
if (player.getInventory().getTitle() != null && player.getInventory().getTitle().equalsIgnoreCase(invName))
player.closeInventory();
}

View File

@ -83,6 +83,8 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
private int tntBankSize;
private int warpLimit;
private double reinforcedArmor;
private List<String> completedMissions;
protected String discord;
// -------------------------------------------- //
@ -112,6 +114,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
this.checks = new ConcurrentHashMap<>();
this.playerWallCheckCount = new ConcurrentHashMap<>();
this.playerBufferCheckCount = new ConcurrentHashMap<>();
this.completedMissions = new ArrayList<>();
resetPerms(); // Reset on new Faction so it has default values.
}
@ -130,6 +133,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
money = old.money;
powerBoost = old.powerBoost;
missions = new ConcurrentHashMap<>();
this.completedMissions = new ArrayList<>();
relationWish = old.relationWish;
claimOwnership = old.claimOwnership;
fplayers = new HashSet<>();
@ -214,6 +218,14 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
return hasWarpPassword(warp) && warpPasswords.get(warp.toLowerCase()).equals(password);
}
public String getDiscord() {
return this.discord;
}
public void setDiscord(String link) {
this.discord = link;
}
public String getPaypal() {
return this.paypal;
}
@ -423,8 +435,14 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
@Override
public Inventory getChestInventory() {
if (chest != null) return chest;
if (chest == null) {
this.chest = Bukkit.createInventory(null, getChestSize(), FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")));
return chest;
}
return chest;
}
private int getChestSize() {
int size = 9;
switch (getUpgrade(UpgradeType.CHEST)) {
case 1:
@ -437,8 +455,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
size = FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Chest.Chest-Size.level-3") * 9;
break;
}
chest = Bukkit.createInventory(null, size, FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")));
return chest;
return size;
}
@ -504,7 +521,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
return this.wallCheckMinutes;
}
public void setWallCheckMinutes(final int wallCheckMinutes) {
public void setWallCheckMinutes(int wallCheckMinutes) {
this.wallCheckMinutes = wallCheckMinutes;
}
@ -512,7 +529,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
return this.bufferCheckMinutes;
}
public void setBufferCheckMinutes(final int bufferCheckMinutes) {
public void setBufferCheckMinutes(int bufferCheckMinutes) {
this.bufferCheckMinutes = bufferCheckMinutes;
}
@ -532,7 +549,7 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
return this.weeWoo;
}
public void setWeeWoo(final boolean weeWoo) {
public void setWeeWoo(boolean weeWoo) {
this.weeWoo = weeWoo;
}
@ -1261,6 +1278,9 @@ public abstract class MemoryFaction implements Faction, EconomyParticipator {
return this.missions;
}
@Override
public List<String> getCompletedMissions() {return this.completedMissions;}
public void clearAllClaimOwnership() {
claimOwnership.clear();
}

View File

@ -239,6 +239,8 @@ public enum TL {
COMMAND_CLAIMLINE_ABOVEMAX("&c&l[!]&7 The &cmaximum&7 limit for claim line is &c%s&7."),
COMMAND_CLAIMLINE_NOTVALID("&c&l[!]&7 &c%s&7 is not a &ccardinal &7direction. You may use &cnorth&7, &ceast&7, &csouth &7or &cwest&7."),
CHEST_ITEM_DENIED_TRANSFER("&c&l[!] &7You may not transfer &b%1$s &7into your factions chest!"),
COMMAND_CONFIG_NOEXIST("&c&l[!]&7 No configuration setting \"&c%1$s&7\" exists."),
COMMAND_CONFIG_SET_TRUE("\" option set to true (enabled)."),
COMMAND_CONFIG_SET_FALSE("\" option set to false (disabled)."),
@ -566,6 +568,18 @@ public enum TL {
COMMAND_OWNERLIST_OWNERS("&c&l[!]&7 Current owner(s) of this land: %1$s"),
COMMAND_OWNERLIST_DESCRIPTION("List owner(s) of this claimed land"),
COMMAND_DISCORDSET_ADMIN_SUCCESSFUL("&c&l[!] &7You have set &b%1$s's &7discord to &b%2$s&7."),
COMMAND_DISCORDSET_ADMIN_FAILED("&c&l[!] &b%1$s &7is not an discord link!"),
COMMAND_DISCORDSET_NOTEMAIL("&c&l[!] &b%1$s &7is not an discord link!"),
COMMAND_DISCORDSET_DESCRIPTION("&c&l[!] &7Set the link of your factions discord."),
COMMAND_DISCORDSET_SUCCESSFUL("&c&l[!] &7Successfully set your factions discord link - &b%1$s&7."),
DISCORD_PLAYER_DISCORD("&c&l[!] &7You're factions discord link is: &b%1$s&7."),
COMMAND_DISCORD_NOTSET("&c&l[!] &7Your faction does not have their discord set!"),
COMMAND_DISCORDSEE_FACTION_NOTSET("&c&l[!] &b%1$s's &7discord has not yet been set!"),
COMMAND_DISCORDSEE_FACTION_DISCORD("&c&l[!] &b%1$s's &7faction has their discord link set to &b%2$s&7."),
COMMAND_DISCORDSEE_DESCRIPTION("&c&l[!] &7View a specific factions discord link with &b/f discord <faction>&b."),
PAYPALSEE_PLAYER_PAYPAL("&c&l[!] &7You're factions paypal is: &b%1$s&7."),
COMMAND_PAYPAL_NOTSET("&c&l[!] &7Your faction does not have their paypal set!"),
COMMAND_PAYPALSET_ADMIN_SUCCESSFUL("&c&l[!] &7You have set &b%1$s's &7paypal to &b%2$s&7."),
@ -999,6 +1013,7 @@ public enum TL {
MISSION_MISSION_STARTED("&f%1$s &dstarted the %2$s &fmission"),
MISSION_ALREAD_COMPLETED("&c&l[!] &7You may not restart a mission you have already completed"),
MISSION_MISSION_ACTIVE("&c&l[!] &7This mission is currently active!"),
MISSION_MISSION_MAX_ALLOWED("&c&l[!] &7You may not have more then &b%1$s &7missions active at once."),
MISSION_MISSION_FINISHED("&c&l[!] &7Your faction has successfully completed %1$s mission!"),

View File

@ -649,6 +649,14 @@ ftnt:
Enabled: true
Bank-Limit: 250000
############################################################
# +------------------------------------------------------+ #
# | Faction Discord | #
# +------------------------------------------------------+ #
############################################################
fdiscord:
Enabled: true
############################################################
# +------------------------------------------------------+ #
# | Faction PayPal | #
@ -737,6 +745,7 @@ Missions-Enabled: true
Missions-GUI-Title: '&bFaction Missions'
MaximumMissionsAllowedAtOnce: 1
Mission-Progress-Format: '&b&lProgression: &f{progress}&7/&e{total}'
DenyMissionsMoreThenOnce: true #this setting to true, means that if they complete a mission they cannot redo the same mission
#Mission Types: KILL, MINE, PLACE, FISH, TAME, ENCHANT, CONSUME
Missions:
@ -848,6 +857,9 @@ fvault:
fchest:
Enabled: true
Inventory-Title: '&2&lFaction Chest'
Items-Not-Allowed:
- 'MOB_SPAWNER'
- 'COOKIE'
# Chest size upgrades can be configured in the upgrades section of config
############################################################

View File

@ -158,6 +158,10 @@ permissions:
description: create a new faction
factions.deinvite:
description: remove a pending invitation
factions.setdiscord:
description: set discord link
factions.discord:
description: view factions discord
factions.description:
description: change the faction description
factions.disband: