Compare commits
46 Commits
2.2.5-STAB
...
duels
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3771feb01 | ||
|
|
07599fa06d | ||
|
|
3d997bbf16 | ||
|
|
a086f8db7a | ||
|
|
2c13204294 | ||
|
|
43c567ee02 | ||
|
|
dfbfbf9981 | ||
|
|
13399c53c5 | ||
|
|
55d6af7195 | ||
|
|
4f675dfd66 | ||
|
|
22957b641b | ||
|
|
0fc3e47289 | ||
|
|
730693aed1 | ||
|
|
61570be012 | ||
|
|
bcc04e6174 | ||
|
|
d30780e06e | ||
|
|
ed73baf5f1 | ||
|
|
94d2035c78 | ||
|
|
8ff8c78a44 | ||
|
|
591dc2172f | ||
|
|
1a4c860c46 | ||
|
|
ad56264c5d | ||
|
|
def1a8b15a | ||
|
|
8b577d360b | ||
|
|
f34ebc73fa | ||
|
|
c86db7ab51 | ||
|
|
070f239948 | ||
|
|
018f08699d | ||
|
|
5542245b2a | ||
|
|
6eb204587d | ||
|
|
ce1eedd7cd | ||
|
|
417cc57aa7 | ||
|
|
57ac2c8c98 | ||
|
|
25515d863e | ||
|
|
2412931122 | ||
|
|
51838df0d7 | ||
|
|
e3e6f5561c | ||
|
|
a54a7aa4fb | ||
|
|
9de773ddae | ||
|
|
9a32cd9501 | ||
|
|
90d39a3974 | ||
|
|
6544513ca7 | ||
|
|
f7619f0685 | ||
|
|
a20c2ec2eb | ||
|
|
028734a42c | ||
|
|
29b9eadd57 |
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -23,7 +23,7 @@ A clear and concise description of what you expected to happen.
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Server VErsion (please complete the following information):**
|
||||
**Server Version (please complete the following information):**
|
||||
- Spigot Version: [e.g. Paperspigot 1.8.8]
|
||||
- Factions Version [use /f version]
|
||||
- Minecraft Version: [If a bug is dependent on client version]
|
||||
|
||||
37
README.md
37
README.md
@@ -1,9 +1,8 @@
|
||||
# SaberFactions
|
||||
|
||||
 [](https://www.codefactor.io/repository/github/driftay/saber-factions)
|
||||
 [](https://www.codefactor.io/repository/github/driftay/saber-factions) [](https://github.com/SaberLLC/Saber-Factions/blob/1.6.x/LICENSE) 
|
||||
|
||||
SaberFactions is a fork of both FactionsUUID and SavageFactions. Creators of those plugins include DtrShock and ProSavage. Credits to them.
|
||||
SaberFactions is the newest, latest and greatest factions plugin designed for the best and most functional factions experience minecraft has seen!
|
||||
SaberFactions is an exotic, performance optmized, and feature rich factions plugin that focuses on not only making the player experience as great as possibly but maintaining this aspect with the cost of NOTHING! We strive to continue development for SaberFactions as the factions community is strongly growing and seeking new players every day.
|
||||
|
||||
## Some Exciting Features
|
||||
Some of our features include the following
|
||||
@@ -14,21 +13,27 @@ Some of our features include the following
|
||||
* More F Upgrades - Unbreakable Redstone Upgrade, Members Upgrade, and Power Upgrade.
|
||||
* Factions Corner - In the corner of a world? No Problem /f corner will claim your entire buffer for you!
|
||||
* Command Cooldowns - Configurable Command Cooldowns for most "spam" commands. And so Much More to Come!
|
||||
* Faction Points - A point based currency that can be used for any aspect of factions gameplay!
|
||||
* Faction Shop - A shop that essentially lets players buy in-game items in exchange for faction points!
|
||||
* Faction Discord Integration - A discord intergrated factions bot for each faction to have their own personalized discord bot within their faction!
|
||||
* Faction Audit - A full based logging system (GUI designed) to see every aspect of what happens in your faction!
|
||||
* Factions Check System - An automated check system that alerts players when to check walls/buffers!
|
||||
* Faction Reserves - A system designed to reserve a specific faction name for a specific player!
|
||||
|
||||
## Dependency With Maven
|
||||
```
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.Driftay</groupId>
|
||||
<artifactId>Saber-Factions</artifactId>
|
||||
<version>1.4.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.SaberLLC</groupId>
|
||||
<artifactId>Saber-Factions</artifactId>
|
||||
<version>2.2.7-STABLE</version>
|
||||
</dependency>
|
||||
```
|
||||
## Moving Forward
|
||||
|
||||
@@ -36,8 +41,8 @@ Moving forward we plan to take all suggestions into consideration, as they come
|
||||
We Plan on Releasing the latest and greatest factions/skyblock/prison plugins minecraft has to offer and wont settle for anything less
|
||||
|
||||
## Support
|
||||
Our Discord is Currently In Progress of a Massive Overhaul, but we still encourage our community to join and express any concerns/questions/suggestions they may have
|
||||
https://Discord.Saber.pw
|
||||
Have a problem, question, or concer? We encourage our community to join and express any inquiry you may have
|
||||
https://discord.saber.pw
|
||||
|
||||
Look forward to a bright future and a journey with all of you!
|
||||
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>com.massivecraft</groupId>
|
||||
<artifactId>Factions</artifactId>
|
||||
<version>1.6.9.5-2.2.5-RC</version>
|
||||
<version>1.6.9.5-2.2.9-RC</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>SaberFactions</name>
|
||||
|
||||
@@ -22,7 +22,7 @@ public class Conf {
|
||||
public static final transient double DYNMAP_STYLE_FILL_OPACITY = 0.35D;
|
||||
public static final transient String DYNMAP_STYLE_HOME_MARKER = "greenflag";
|
||||
public static final transient boolean DYNMAP_STYLE_BOOST = false;
|
||||
public static List<String> baseCommandAliases = new ArrayList<>();
|
||||
public static List<String> baseCommandAliases = new ArrayList<>(Collections.singletonList("f"));
|
||||
public static boolean allowNoSlashCommand = true;
|
||||
|
||||
// Colors
|
||||
@@ -105,6 +105,9 @@ public class Conf {
|
||||
//AUDIT
|
||||
public static boolean useAuditSystem = true;
|
||||
|
||||
//GUI's
|
||||
public static boolean useDisbandGUI = true;
|
||||
|
||||
//DISCORD
|
||||
public static boolean useDiscordSystem = false;
|
||||
public static String discordBotToken = "<token here>";
|
||||
@@ -408,7 +411,6 @@ public class Conf {
|
||||
}
|
||||
|
||||
static {
|
||||
baseCommandAliases.add("f");
|
||||
|
||||
blacklistedFactionNames.add("somenamehere");
|
||||
|
||||
|
||||
@@ -12,8 +12,10 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@@ -31,6 +33,43 @@ public interface FPlayer extends EconomyParticipator {
|
||||
|
||||
boolean hasNotificationsEnabled();
|
||||
|
||||
/**
|
||||
* Determine if a player has enemies nearby based on the enemy check task in CmdFly
|
||||
* NOTE: THIS VALUE IS ONLY UPDATED WHEN A USER IS USING FLY
|
||||
* @return enemiesNearby as a boolean
|
||||
*/
|
||||
boolean hasEnemiesNearby();
|
||||
|
||||
/**
|
||||
* Set if this FPlayer has an enemy nearby
|
||||
* @param b enemiesNearby
|
||||
*/
|
||||
void setEnemiesNearby(Boolean b);
|
||||
|
||||
/**
|
||||
* Get this players inventory prior to entering the duel (Will be set to null after duel!)
|
||||
* @return Map of old inventory contents
|
||||
*/
|
||||
Map<Integer, ItemStack> getOldInv();
|
||||
|
||||
/**
|
||||
* Set this players stored inventory, this inventory will be retrieved after a duel is complete
|
||||
* @param inv Map of inventory contents
|
||||
*/
|
||||
void setOldInv(Map<Integer, ItemStack> inv);
|
||||
|
||||
/**
|
||||
* Used to check if player has entered a duel and has not proceeded
|
||||
* @return boolean determining if the player is in a duel
|
||||
*/
|
||||
boolean isInDuel();
|
||||
|
||||
/**
|
||||
* Used before and after duels to set the inDuel status of the FPlayer
|
||||
* @param b Desired status
|
||||
*/
|
||||
void setInDuel(Boolean b);
|
||||
|
||||
/**
|
||||
* Get if a player has setup their Discord before
|
||||
* @return if the player setup Discord as a boolean
|
||||
|
||||
@@ -23,6 +23,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public interface Faction extends EconomyParticipator {
|
||||
|
||||
void broadcast(String s);
|
||||
|
||||
String getMemberRoleId();
|
||||
|
||||
void setMemberRoleId(String roleId);
|
||||
|
||||
@@ -26,6 +26,8 @@ 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.Sync.SyncExecutor;
|
||||
import com.massivecraft.factions.util.Wait.WaitExecutor;
|
||||
import com.massivecraft.factions.zcore.CommandVisibility;
|
||||
import com.massivecraft.factions.zcore.MPlugin;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
@@ -52,6 +54,7 @@ import java.io.*;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.OpenOption;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@@ -69,7 +72,6 @@ public class FactionsPlugin extends MPlugin {
|
||||
// Plugins can check this boolean while hooking in have
|
||||
// a green light to use the api.
|
||||
public static boolean startupFinished = false;
|
||||
public static Economy econ = null;
|
||||
public boolean PlaceholderApi;
|
||||
// Commands
|
||||
public FCmdRoot cmdBase;
|
||||
@@ -79,6 +81,7 @@ public class FactionsPlugin extends MPlugin {
|
||||
public boolean mc112 = false;
|
||||
public boolean mc113 = false;
|
||||
public boolean mc114 = false;
|
||||
public boolean mc115 = false;
|
||||
public boolean useNonPacketParticles = false;
|
||||
public boolean factionsFlight = false;
|
||||
SkriptAddon skriptAddon;
|
||||
@@ -165,6 +168,10 @@ public class FactionsPlugin extends MPlugin {
|
||||
FactionsPlugin.instance.log("Minecraft Version 1.14 found.");
|
||||
mc114 = true;
|
||||
break;
|
||||
case 15:
|
||||
FactionsPlugin.instance.log("Minecraft Version 1.15 found.");
|
||||
mc115 = true;
|
||||
break;
|
||||
}
|
||||
migrateFPlayerLeaders();
|
||||
log("==== End Setup ====");
|
||||
@@ -176,25 +183,29 @@ public class FactionsPlugin extends MPlugin {
|
||||
this.saveResource("config.yml", false);
|
||||
this.reloadConfig();
|
||||
}
|
||||
//Start synctask
|
||||
SyncExecutor.startTask();
|
||||
//Start wait task executor
|
||||
WaitExecutor.startTask();
|
||||
//Attempt to generate a permission list
|
||||
PermissionList.generateFile();
|
||||
// Load Conf from disk
|
||||
Conf.load();
|
||||
fLogManager = new FLogManager();
|
||||
//Dependency checks
|
||||
if (Conf.dependencyCheck && (!Bukkit.getPluginManager().isPluginEnabled("Vault") && !Bukkit.getPluginManager().isPluginEnabled("Essentials"))) {
|
||||
if (Conf.dependencyCheck && (!Bukkit.getPluginManager().isPluginEnabled("Vault"))) {
|
||||
divider();
|
||||
System.out.println("You are missing dependencies!");
|
||||
System.out.println("Please verify EssentialsX and Vault are installed!");
|
||||
System.out.println("Please verify Vault is installed!");
|
||||
Conf.save();
|
||||
Bukkit.getPluginManager().disablePlugin(instance);
|
||||
divider();
|
||||
return;
|
||||
}
|
||||
//TODO fix this
|
||||
//Update their config if needed
|
||||
// Updater.updateIfNeeded(getConfig());
|
||||
RegisteredServiceProvider<Economy> rsp = FactionsPlugin.this.getServer().getServicesManager().getRegistration(Economy.class);
|
||||
FactionsPlugin.econ = rsp.getProvider();
|
||||
com.massivecraft.factions.integration.Essentials.setup();
|
||||
hookedPlayervaults = setupPlayervaults();
|
||||
FPlayers.getInstance().load();
|
||||
@@ -210,7 +221,6 @@ public class FactionsPlugin extends MPlugin {
|
||||
if (fPlayer.isAlt()) faction.addAltPlayer(fPlayer);
|
||||
else faction.addFPlayer(fPlayer);
|
||||
}
|
||||
if (getConfig().getBoolean("enable-faction-flight", true)) UtilFly.run();
|
||||
|
||||
|
||||
Board.getInstance().load();
|
||||
@@ -428,6 +438,18 @@ public class FactionsPlugin extends MPlugin {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
try {
|
||||
String path = Paths.get(getDataFolder().getAbsolutePath()).toAbsolutePath().toString() + File.separator + "reserves.json";
|
||||
File file = new File(path);
|
||||
if (!file.exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
file.createNewFile();
|
||||
}
|
||||
Files.write(Paths.get(file.getPath()),getGsonBuilder().create().toJson(reserveObjects).getBytes());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// only save data if plugin actually completely loaded successfully
|
||||
if (this.loadSuccessful) Conf.saveSync();
|
||||
|
||||
@@ -437,6 +459,9 @@ public class FactionsPlugin extends MPlugin {
|
||||
AutoLeaveTask = null;
|
||||
}
|
||||
DiscordListener.saveGuilds();
|
||||
if (Discord.jda != null) {
|
||||
Discord.jda.shutdownNow();
|
||||
}
|
||||
super.onDisable();
|
||||
try {
|
||||
fLogManager.saveLogs();
|
||||
@@ -464,7 +489,7 @@ public class FactionsPlugin extends MPlugin {
|
||||
}
|
||||
|
||||
public ItemStack createItem(Material material, int amount, short datavalue, String name, List<String> lore) {
|
||||
ItemStack item = new ItemStack(XMaterial.matchXMaterial(material.toString()).parseMaterial(), amount, datavalue);
|
||||
ItemStack item = new ItemStack(XMaterial.matchXMaterial(material.toString()).get().parseMaterial(), amount, datavalue);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(color(name));
|
||||
meta.setLore(colorList(lore));
|
||||
|
||||
@@ -6,10 +6,10 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* @author DroppingAnvil
|
||||
*/
|
||||
public class Aliases {
|
||||
/**
|
||||
* @author DroppingAnvil
|
||||
*/
|
||||
public static ArrayList<String> alts_alts = new ArrayList<>(Arrays.asList("alts", "alt"));
|
||||
public static ArrayList<String> alts_list = new ArrayList<>(Arrays.asList("list", "l"));
|
||||
public static ArrayList<String> alts_invite = new ArrayList<>(Collections.singletonList("invite"));
|
||||
@@ -46,7 +46,7 @@ public class Aliases {
|
||||
public static ArrayList<String> relation_truce = new ArrayList<>(Collections.singletonList("truce"));
|
||||
public static ArrayList<String> reserve = new ArrayList<>(Collections.singletonList("reserve"));
|
||||
public static ArrayList<String> roles_demote = new ArrayList<>(Collections.singletonList("demote"));
|
||||
public static ArrayList<String> roles_promote = new ArrayList<>(Collections.singletonList("ally"));
|
||||
public static ArrayList<String> roles_promote = new ArrayList<>(Collections.singletonList("promote"));
|
||||
public static ArrayList<String> tnt_tnt = new ArrayList<>(Collections.singletonList("tnt"));
|
||||
public static ArrayList<String> tnt_tntfill = new ArrayList<>(Collections.singletonList("tntfill"));
|
||||
public static ArrayList<String> wild = new ArrayList<>(Collections.singletonList("wild"));
|
||||
@@ -143,6 +143,7 @@ public class Aliases {
|
||||
public static ArrayList<String> vault = new ArrayList<>(Collections.singletonList("vault"));
|
||||
public static ArrayList<String> viewChest = new ArrayList<>(Arrays.asList("viewchest", "viewpv"));
|
||||
private static transient Aliases i = new Aliases();
|
||||
|
||||
public static void load() {
|
||||
FactionsPlugin.getInstance().persist.loadOrSaveDefault(i, Aliases.class, "aliases");
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class CmdAdmin extends FCommand {
|
||||
|
||||
// if target player is currently admin, demote and replace him
|
||||
if (fyou == admin) {
|
||||
targetFaction.promoteNewLeader();
|
||||
promoteNewLeader(targetFaction);
|
||||
context.msg(TL.COMMAND_ADMIN_DEMOTES, fyou.describeTo(context.fPlayer, true));
|
||||
fyou.msg(TL.COMMAND_ADMIN_DEMOTED, context.player == null ? TL.GENERIC_SERVERADMIN.toString() : context.fPlayer.describeTo(fyou, true));
|
||||
return;
|
||||
@@ -78,9 +78,9 @@ public class CmdAdmin extends FCommand {
|
||||
|
||||
// promote target player, and demote existing admin if one exists
|
||||
if (admin != null) {
|
||||
admin.setRole(Role.COLEADER);
|
||||
setRole(admin, Role.COLEADER);
|
||||
}
|
||||
fyou.setRole(Role.LEADER);
|
||||
setRole(fyou, Role.LEADER);
|
||||
context.msg(TL.COMMAND_ADMIN_PROMOTES, fyou.describeTo(context.fPlayer, true));
|
||||
|
||||
FactionsPlugin.instance.getFlogManager().log(targetFaction, FLogType.RANK_EDIT, context.fPlayer.getName(), fyou.getName(), ChatColor.RED + "Admin");
|
||||
@@ -94,6 +94,18 @@ public class CmdAdmin extends FCommand {
|
||||
});
|
||||
}
|
||||
|
||||
private void setRole(FPlayer fp, Role r) {
|
||||
FactionsPlugin.getInstance().getServer().getScheduler().runTask(FactionsPlugin.instance, () -> {
|
||||
fp.setRole(r);
|
||||
});
|
||||
}
|
||||
|
||||
private void promoteNewLeader(Faction f) {
|
||||
FactionsPlugin.getInstance().getServer().getScheduler().runTask(FactionsPlugin.instance, () -> {
|
||||
f.promoteNewLeader();
|
||||
});
|
||||
}
|
||||
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_ADMIN_DESCRIPTION;
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ public class CmdBanner extends FCommand {
|
||||
warBanner.setAmount(1);
|
||||
context.player.getInventory().addItem(warBanner);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean hasMoney(FPlayer fme, int amt) {
|
||||
Economy econ = FactionsPlugin.getInstance().getEcon();
|
||||
@@ -55,6 +56,7 @@ public class CmdBanner extends FCommand {
|
||||
fme.msg(TL.COMMAND_BANNER_NOTENOUGHMONEY);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void takeMoney(FPlayer fme, int amt) {
|
||||
if (this.hasMoney(fme, amt)) {
|
||||
|
||||
@@ -225,7 +225,7 @@ public class CmdConfig extends FCommand {
|
||||
if (!success.isEmpty()) {
|
||||
if (context.sender instanceof Player) {
|
||||
context.sendMessage(success);
|
||||
FactionsPlugin.getInstance().log(success + TL.COMMAND_CONFIG_LOG.format((Player) context.sender));
|
||||
FactionsPlugin.getInstance().log(success + TL.COMMAND_CONFIG_LOG.format(context.sender));
|
||||
} else // using FactionsPlugin.getInstance().log() instead of sendMessage if run from server console so that "[Factions v#.#.#]" is prepended in server log
|
||||
{
|
||||
FactionsPlugin.getInstance().log(success);
|
||||
|
||||
@@ -115,7 +115,9 @@ public class CmdCreate extends FCommand {
|
||||
Discord.mainGuild.getController().setNickname(m, Discord.getNicknameString(context.fPlayer)).queue();
|
||||
}
|
||||
}
|
||||
} catch (HierarchyException e) {System.out.print(e.getMessage());}
|
||||
} catch (HierarchyException e) {
|
||||
System.out.print(e.getMessage());
|
||||
}
|
||||
//End Discord
|
||||
context.msg(TL.COMMAND_CREATE_YOUSHOULD, FactionsPlugin.getInstance().cmdBase.cmdDescription.getUsageTemplate(context));
|
||||
if (Conf.econEnabled) Econ.setBalance(faction.getAccountId(), Conf.econFactionStartingBalance);
|
||||
|
||||
@@ -13,6 +13,7 @@ public class CmdDebug extends FCommand {
|
||||
this.aliases.add("debug");
|
||||
this.requirements = new CommandRequirements.Builder(Permission.DEBUG).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
FactionsPlugin.getInstance().divider();
|
||||
@@ -51,7 +52,9 @@ public class CmdDebug extends FCommand {
|
||||
System.out.print("Emotes enabled: " + Discord.useEmotes);
|
||||
System.out.print("Leader role null: " + (Discord.leader == null ? "True" : "False"));
|
||||
System.out.print("Attempt Log:");
|
||||
for (DiscordSetupAttempt d : Discord.setupLog) {System.out.print(d.getDifferentialFormatted() + " " + d.getSuccess() + " " + d.getReason());}
|
||||
for (DiscordSetupAttempt d : Discord.setupLog) {
|
||||
System.out.print(d.getDifferentialFormatted() + " " + d.getSuccess() + " " + d.getReason());
|
||||
}
|
||||
System.out.print("End Attempt Log");
|
||||
System.out.print("----End Discord----");
|
||||
System.out.print("--------End Debug Info--------");
|
||||
|
||||
@@ -31,47 +31,47 @@ public class CmdDeinvite extends FCommand {
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
if (context.args.size() == 0) {
|
||||
FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD);
|
||||
for (String id : context.faction.getInvites()) {
|
||||
FPlayer fp = FPlayers.getInstance().getById(id);
|
||||
String name = fp != null ? fp.getName() : id;
|
||||
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
|
||||
}
|
||||
context.sendFancyMessage(msg);
|
||||
if (context.args.size() == 0) {
|
||||
FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD);
|
||||
for (String id : context.faction.getInvites()) {
|
||||
FPlayer fp = FPlayers.getInstance().getById(id);
|
||||
String name = fp != null ? fp.getName() : id;
|
||||
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
|
||||
}
|
||||
context.sendFancyMessage(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
FPlayer you = context.argAsBestFPlayerMatch(0);
|
||||
if (!context.fPlayer.isAdminBypassing()) {
|
||||
Access access = context.faction.getAccess(context.fPlayer, PermissableAction.INVITE);
|
||||
if (access != Access.ALLOW && context.fPlayer.getRole() != Role.LEADER) {
|
||||
context.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage invites");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
FPlayer you = context.argAsBestFPlayerMatch(0);
|
||||
if (!context.fPlayer.isAdminBypassing()) {
|
||||
Access access = context.faction.getAccess(context.fPlayer, PermissableAction.INVITE);
|
||||
if (access != Access.ALLOW && context.fPlayer.getRole() != Role.LEADER) {
|
||||
context.msg(TL.GENERIC_FPERM_NOPERMISSION, "manage invites");
|
||||
return;
|
||||
}
|
||||
if (you == null) {
|
||||
FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD);
|
||||
for (String id : context.faction.getInvites()) {
|
||||
if (context.faction.getInvites().isEmpty()) return;
|
||||
FPlayer fp = FPlayers.getInstance().getById(id);
|
||||
String name = fp != null ? fp.getName() : id;
|
||||
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
|
||||
}
|
||||
context.sendFancyMessage(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (you == null) {
|
||||
FancyMessage msg = new FancyMessage(TL.COMMAND_DEINVITE_CANDEINVITE.toString()).color(ChatColor.GOLD);
|
||||
for (String id : context.faction.getInvites()) {
|
||||
if (context.faction.getInvites().isEmpty()) return;
|
||||
FPlayer fp = FPlayers.getInstance().getById(id);
|
||||
String name = fp != null ? fp.getName() : id;
|
||||
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_DEINVITE_CLICKTODEINVITE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
|
||||
}
|
||||
context.sendFancyMessage(msg);
|
||||
return;
|
||||
}
|
||||
if (you.getFaction() == context.faction) {
|
||||
context.msg(TL.COMMAND_DEINVITE_ALREADYMEMBER, you.getName(), context.faction.getTag());
|
||||
context.msg(TL.COMMAND_DEINVITE_MIGHTWANT, FactionsPlugin.getInstance().cmdBase.cmdKick.getUsageTemplate(context));
|
||||
return;
|
||||
}
|
||||
|
||||
if (you.getFaction() == context.faction) {
|
||||
context.msg(TL.COMMAND_DEINVITE_ALREADYMEMBER, you.getName(), context.faction.getTag());
|
||||
context.msg(TL.COMMAND_DEINVITE_MIGHTWANT, FactionsPlugin.getInstance().cmdBase.cmdKick.getUsageTemplate(context));
|
||||
return;
|
||||
}
|
||||
|
||||
context.faction.deinvite(you);
|
||||
you.msg(TL.COMMAND_DEINVITE_REVOKED, context.fPlayer.describeTo(you), context.faction.describeTo(you));
|
||||
context.faction.msg(TL.COMMAND_DEINVITE_REVOKES, context.fPlayer.describeTo(context.faction), you.describeTo(context.faction));
|
||||
context.faction.deinvite(you);
|
||||
you.msg(TL.COMMAND_DEINVITE_REVOKED, context.fPlayer.describeTo(you), context.faction.describeTo(you));
|
||||
context.faction.msg(TL.COMMAND_DEINVITE_REVOKES, context.fPlayer.describeTo(context.faction), you.describeTo(context.faction));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,14 +4,16 @@ 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.util.UtilFly;
|
||||
import com.massivecraft.factions.zcore.fdisband.FDisbandFrame;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
public class CmdDisband extends FCommand {
|
||||
@@ -35,6 +37,7 @@ public class CmdDisband extends FCommand {
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
long time;
|
||||
// The faction, default to your own.. but null if console sender.
|
||||
Faction faction = context.argAsFaction(0, context.fPlayer == null ? null : context.faction);
|
||||
if (faction == null) return;
|
||||
@@ -42,9 +45,7 @@ public class CmdDisband extends FCommand {
|
||||
boolean isMyFaction = context.fPlayer != null && faction == context.faction;
|
||||
|
||||
if (!isMyFaction) {
|
||||
if (!Permission.DISBAND_ANY.has(context.sender, true)) {
|
||||
return;
|
||||
}
|
||||
if (!Permission.DISBAND_ANY.has(context.sender, true)) return;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,6 +72,22 @@ public class CmdDisband extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
boolean access = false;
|
||||
if (context.fPlayer.getPlayer().hasMetadata("disband_confirm") && (time = context.fPlayer.getPlayer().getMetadata("disband_confirm").get(0).asLong()) != 0L && System.currentTimeMillis() - time <= TimeUnit.SECONDS.toMillis(3L)) {
|
||||
access = true;
|
||||
}
|
||||
|
||||
if (!access) {
|
||||
if(Conf.useDisbandGUI && !context.fPlayer.isAdminBypassing() || !context.player.isOp()) {
|
||||
if (!disbandMap.containsKey(context.player.getUniqueId().toString())) {
|
||||
new FDisbandFrame(context.faction).buildGUI(context.fPlayer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// check for tnt before disbanding.
|
||||
if (!disbandMap.containsKey(context.player.getUniqueId().toString()) && faction.getTnt() > 0) {
|
||||
context.msg(TL.COMMAND_DISBAND_CONFIRM.toString().replace("{tnt}", faction.getTnt() + ""));
|
||||
@@ -89,7 +106,8 @@ public class CmdDisband extends FCommand {
|
||||
follower.msg(TL.COMMAND_DISBAND_BROADCAST_NOTYOURS, amountString, faction.getTag(follower));
|
||||
}
|
||||
}
|
||||
if(FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) context.fPlayer.setFFlying(false, false);
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
||||
context.fPlayer.setFFlying(false, false);
|
||||
} else {
|
||||
context.player.sendMessage(String.valueOf(TL.COMMAND_DISBAND_PLAYER));
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@ import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author droppinganvil
|
||||
*/
|
||||
public class CmdDiscord extends FCommand {
|
||||
public CmdDiscord() {
|
||||
super();
|
||||
@@ -14,6 +17,7 @@ public class CmdDiscord extends FCommand {
|
||||
.playerOnly()
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
if (context.fPlayer.discordSetup()) {
|
||||
|
||||
@@ -7,15 +7,14 @@ import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
/**
|
||||
* @author Saser
|
||||
*/
|
||||
public class CmdDrain extends FCommand{
|
||||
public CmdDrain(){
|
||||
public class CmdDrain extends FCommand {
|
||||
public CmdDrain() {
|
||||
this.aliases.addAll(Aliases.drain);
|
||||
this.requirements = new CommandRequirements.Builder(Permission.DRAIN)
|
||||
.playerOnly()
|
||||
@@ -34,12 +33,12 @@ public class CmdDrain extends FCommand{
|
||||
|
||||
double totalBalance = 0;
|
||||
|
||||
for(FPlayer fPlayer : context.faction.getFPlayers()) {
|
||||
if(context.faction.getFPlayers().size() == 1){
|
||||
for (FPlayer fPlayer : context.faction.getFPlayers()) {
|
||||
if (context.faction.getFPlayers().size() == 1) {
|
||||
context.fPlayer.msg(TL.COMMAND_DRAIN_NO_PLAYERS);
|
||||
return;
|
||||
}
|
||||
if (FPlayers.getInstance().getByPlayer(context.player).equals(fPlayer)){
|
||||
if (FPlayers.getInstance().getByPlayer(context.player).equals(fPlayer)) {
|
||||
continue; // skip the command executor
|
||||
}
|
||||
double balance = FactionsPlugin.getInstance().getEcon().getBalance(fPlayer.getPlayer());
|
||||
|
||||
@@ -34,7 +34,7 @@ public class CmdFly extends FCommand {
|
||||
this.aliases.addAll(Aliases.fly);
|
||||
this.optionalArgs.put("on/off", "flip");
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.FLY)
|
||||
this.requirements = new CommandRequirements.Builder(Permission.FLY_FLY)
|
||||
.playerOnly()
|
||||
.memberOnly()
|
||||
.build();
|
||||
@@ -78,19 +78,15 @@ public class CmdFly extends FCommand {
|
||||
}
|
||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||
Faction myFaction = fPlayer.getFaction();
|
||||
if (myFaction.isWilderness()) {
|
||||
fPlayer.setFlying(false);
|
||||
flyMap.remove(name);
|
||||
continue;
|
||||
}
|
||||
if (player.hasPermission("factions.fly.bypassnearbyenemycheck") || fPlayer.checkIfNearbyEnemies()) {
|
||||
if (!player.hasPermission("factions.fly.bypassnearbyenemycheck") && !fPlayer.isAdminBypassing()) {
|
||||
if (fPlayer.hasEnemiesNearby()) disableFlightSync(fPlayer);
|
||||
checkEnemiesSync(fPlayer);
|
||||
continue;
|
||||
}
|
||||
FLocation myFloc = new FLocation(player.getLocation());
|
||||
if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
|
||||
if (!checkBypassPerms(fPlayer, player, Board.getInstance().getFactionAt(myFloc))) {
|
||||
Bukkit.getScheduler().runTask(FactionsPlugin.instance, () -> fPlayer.setFFlying(false, false));
|
||||
flyMap.remove(name);
|
||||
if (!checkFly(fPlayer, player, Board.getInstance().getFactionAt(myFloc))) {
|
||||
disableFlightSync(fPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,36 +96,17 @@ public class CmdFly extends FCommand {
|
||||
}, 20L, 20L);
|
||||
}
|
||||
|
||||
public static boolean checkBypassPerms(FPlayer fme, Player me, Faction toFac) {
|
||||
public static boolean checkFly(FPlayer fme, Player me, Faction toFac) {
|
||||
if (Conf.denyFlightIfInNoClaimingWorld && !Conf.worldsNoClaiming.isEmpty() && Conf.worldsNoClaiming.stream().anyMatch(me.getWorld().getName()::equalsIgnoreCase))
|
||||
return false;
|
||||
|
||||
if (toFac != fme.getFaction()) {
|
||||
if (!me.hasPermission(Permission.FLY_WILD.node) && toFac.isWilderness() || !me.hasPermission(Permission.FLY_SAFEZONE.node) && toFac.isSafeZone() || !me.hasPermission(Permission.FLY_WARZONE.node) && toFac.isWarZone()) {
|
||||
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
||||
return false;
|
||||
}
|
||||
Access access = toFac.getAccess(fme, PermissableAction.FLY);
|
||||
if ((!(me.hasPermission(Permission.FLY_ENEMY.node) || access == Access.ALLOW)) && toFac.getRelationTo(fme.getFaction()) == Relation.ENEMY) {
|
||||
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
||||
return false;
|
||||
}
|
||||
if (!(me.hasPermission(Permission.FLY_ALLY.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.ALLY) {
|
||||
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
||||
return false;
|
||||
}
|
||||
if (!(me.hasPermission(Permission.FLY_TRUCE.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.TRUCE) {
|
||||
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(me.hasPermission(Permission.FLY_NEUTRAL.node) || access == Access.ALLOW) && toFac.getRelationTo(fme.getFaction()) == Relation.NEUTRAL && !toFac.isSystemFaction()) {
|
||||
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
|
||||
return false;
|
||||
}
|
||||
return me.hasPermission(Permission.FLY.node) && (access != Access.DENY || toFac.isSystemFaction());
|
||||
}
|
||||
return true;
|
||||
if (toFac.getAccess(fme, PermissableAction.FLY) == Access.ALLOW) return true;
|
||||
if (fme.getFaction().isWilderness()) return false;
|
||||
if (toFac.isSystemFaction())
|
||||
return me.hasPermission(toFac.isWilderness() ? Permission.FLY_WILDERNESS.node : toFac.isSafeZone() ? Permission.FLY_SAFEZONE.node : Permission.FLY_WARZONE.node);
|
||||
Relation relationTo = toFac.getRelationTo(fme.getFaction());
|
||||
if (!relationTo.isEnemy() && !relationTo.isMember())
|
||||
return me.hasPermission(Permission.valueOf("FLY_" + relationTo.name()).node);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -145,34 +122,43 @@ public class CmdFly extends FCommand {
|
||||
flyMap.remove(fme.getPlayer().getName());
|
||||
}
|
||||
|
||||
private static void disableFlightSync(FPlayer fme) {
|
||||
Bukkit.getScheduler().runTask(FactionsPlugin.instance, () -> fme.setFFlying(false, false));
|
||||
flyMap.remove(fme.getName());
|
||||
}
|
||||
|
||||
private static void checkEnemiesSync(FPlayer fp) {
|
||||
Bukkit.getScheduler().runTask(FactionsPlugin.instance, fp::checkIfNearbyEnemies);
|
||||
}
|
||||
|
||||
public boolean isInFlightChecker(Player player) {
|
||||
return flyMap.containsKey(player.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
// Disabled by default.
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight", false)) {
|
||||
context.fPlayer.msg(TL.COMMAND_FLY_DISABLED);
|
||||
return;
|
||||
}
|
||||
if (!context.fPlayer.isAdminBypassing()) {
|
||||
List<Entity> entities = context.player.getNearbyEntities(16.0D, 256.0D, 16.0D);
|
||||
|
||||
FLocation myfloc = new FLocation(context.player.getLocation());
|
||||
Faction toFac = Board.getInstance().getFactionAt(myfloc);
|
||||
if (!checkBypassPerms(context.fPlayer, context.player, toFac)) return;
|
||||
List<Entity> entities = context.player.getNearbyEntities(16.0D, 256.0D, 16.0D);
|
||||
|
||||
for (int i = 0; i <= entities.size() - 1; ++i) {
|
||||
if (entities.get(i) instanceof Player) {
|
||||
Player eplayer = (Player) entities.get(i);
|
||||
FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer);
|
||||
if (efplayer.getRelationTo(context.fPlayer) == Relation.ENEMY && !efplayer.isStealthEnabled()) {
|
||||
context.msg(TL.COMMAND_FLY_CHECK_ENEMY);
|
||||
return;
|
||||
for (int i = 0; i <= entities.size() - 1; ++i) {
|
||||
if (entities.get(i) instanceof Player) {
|
||||
Player eplayer = (Player) entities.get(i);
|
||||
FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer);
|
||||
if (efplayer.getRelationTo(context.fPlayer) == Relation.ENEMY && !efplayer.isStealthEnabled()) {
|
||||
context.msg(TL.COMMAND_FLY_CHECK_ENEMY);
|
||||
return;
|
||||
}
|
||||
context.fPlayer.setEnemiesNearby(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FLocation myfloc = new FLocation(context.player.getLocation());
|
||||
Faction toFac = Board.getInstance().getFactionAt(myfloc);
|
||||
if (!checkFly(context.fPlayer, context.player, toFac)) {
|
||||
context.fPlayer.sendMessage(TL.COMMAND_FLY_NO_ACCESS.format(toFac.getTag()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (context.args.size() == 0) {
|
||||
toggleFlight(context.fPlayer.isFlying(), context.fPlayer, context);
|
||||
@@ -188,22 +174,17 @@ public class CmdFly extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
context.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> {
|
||||
fme.setFlying(true);
|
||||
flyMap.put(fme.getPlayer().getName(), true);
|
||||
if (particleTask == null) {
|
||||
startParticles();
|
||||
}
|
||||
|
||||
if (fme.canFlyAtLocation()) {
|
||||
context.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> {
|
||||
fme.setFlying(true);
|
||||
flyMap.put(fme.getPlayer().getName(), true);
|
||||
if (particleTask == null) {
|
||||
startParticles();
|
||||
}
|
||||
|
||||
if (flyTask == null) {
|
||||
startFlyCheck();
|
||||
}
|
||||
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-fly", 0));
|
||||
} else {
|
||||
fme.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(fme.getLastStoodAt()).getTag());
|
||||
}
|
||||
if (flyTask == null) {
|
||||
startFlyCheck();
|
||||
}
|
||||
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-fly", 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -47,7 +47,9 @@ public class CmdGetVault extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!context.fPlayer.takeMoney(amount)) {return;}
|
||||
if (!context.fPlayer.takeMoney(amount)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//success :)
|
||||
context.player.getInventory().addItem(vault);
|
||||
|
||||
@@ -18,6 +18,7 @@ public class CmdHelp extends FCommand {
|
||||
*/
|
||||
|
||||
public ArrayList<ArrayList<String>> helpPages;
|
||||
|
||||
//TODO: Add Help GUI
|
||||
public CmdHelp() {
|
||||
super();
|
||||
|
||||
@@ -139,7 +139,9 @@ public class CmdJoin extends FCommand {
|
||||
Discord.mainGuild.getController().setNickname(m, Discord.getNicknameString(context.fPlayer)).queue();
|
||||
}
|
||||
}
|
||||
} catch (HierarchyException e) {System.out.print(e.getMessage());}
|
||||
} catch (HierarchyException e) {
|
||||
System.out.print(e.getMessage());
|
||||
}
|
||||
|
||||
if (Conf.logFactionJoin) {
|
||||
if (samePlayer) {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class CmdLeave extends FCommand {
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ public class CmdLock extends FCommand {
|
||||
description: use the /f lock [on/off] command to temporarily lock the data files from being overwritten
|
||||
default: op
|
||||
*/
|
||||
|
||||
public CmdLock() {
|
||||
super();
|
||||
this.aliases.addAll(Aliases.lock);
|
||||
|
||||
@@ -31,53 +31,53 @@ public class CmdMod extends FCommand {
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
FPlayer you = context.argAsBestFPlayerMatch(0);
|
||||
if (you == null) {
|
||||
FancyMessage msg = new FancyMessage(TL.COMMAND_MOD_CANDIDATES.toString()).color(ChatColor.GOLD);
|
||||
for (FPlayer player : context.faction.getFPlayersWhereRole(Role.NORMAL)) {
|
||||
String s = player.getName();
|
||||
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " mod " + s);
|
||||
}
|
||||
|
||||
context.sendFancyMessage(msg);
|
||||
return;
|
||||
FPlayer you = context.argAsBestFPlayerMatch(0);
|
||||
if (you == null) {
|
||||
FancyMessage msg = new FancyMessage(TL.COMMAND_MOD_CANDIDATES.toString()).color(ChatColor.GOLD);
|
||||
for (FPlayer player : context.faction.getFPlayersWhereRole(Role.NORMAL)) {
|
||||
String s = player.getName();
|
||||
msg.then(s + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_MOD_CLICKTOPROMOTE.toString() + s).command("/" + Conf.baseCommandAliases.get(0) + " mod " + s);
|
||||
}
|
||||
|
||||
boolean permAny = Permission.MOD_ANY.has(context.sender, false);
|
||||
Faction targetFaction = you.getFaction();
|
||||
if (targetFaction != context.faction && !permAny) {
|
||||
context.msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(context.fPlayer, true));
|
||||
return;
|
||||
}
|
||||
context.sendFancyMessage(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (context.fPlayer != null && context.fPlayer.getRole() != Role.LEADER && !permAny) {
|
||||
context.msg(TL.COMMAND_MOD_NOTADMIN);
|
||||
return;
|
||||
}
|
||||
boolean permAny = Permission.MOD_ANY.has(context.sender, false);
|
||||
Faction targetFaction = you.getFaction();
|
||||
if (targetFaction != context.faction && !permAny) {
|
||||
context.msg(TL.COMMAND_MOD_NOTMEMBER, you.describeTo(context.fPlayer, true));
|
||||
return;
|
||||
}
|
||||
|
||||
if (you == context.fPlayer && !permAny) {
|
||||
context.msg(TL.COMMAND_MOD_SELF);
|
||||
return;
|
||||
}
|
||||
if (context.fPlayer != null && context.fPlayer.getRole() != Role.LEADER && !permAny) {
|
||||
context.msg(TL.COMMAND_MOD_NOTADMIN);
|
||||
return;
|
||||
}
|
||||
|
||||
if (you.getRole() == Role.LEADER) {
|
||||
context.msg(TL.COMMAND_MOD_TARGETISADMIN);
|
||||
return;
|
||||
}
|
||||
if (you == context.fPlayer && !permAny) {
|
||||
context.msg(TL.COMMAND_MOD_SELF);
|
||||
return;
|
||||
}
|
||||
|
||||
if (you.getRole() == Role.MODERATOR) {
|
||||
// Revoke
|
||||
you.setRole(Role.NORMAL);
|
||||
targetFaction.msg(TL.COMMAND_MOD_REVOKED, you.describeTo(targetFaction, true));
|
||||
context.msg(TL.COMMAND_MOD_REVOKES, you.describeTo(context.fPlayer, true));
|
||||
} else {
|
||||
// Give
|
||||
you.setRole(Role.MODERATOR);
|
||||
targetFaction.msg(TL.COMMAND_MOD_PROMOTED, you.describeTo(targetFaction, true));
|
||||
context.msg(TL.COMMAND_MOD_PROMOTES, you.describeTo(context.fPlayer, true));
|
||||
FactionsPlugin.instance.getFlogManager().log(targetFaction, FLogType.RANK_EDIT, context.fPlayer.getName(), you.getName(), ChatColor.LIGHT_PURPLE + "Mod");
|
||||
if (you.getRole() == Role.LEADER) {
|
||||
context.msg(TL.COMMAND_MOD_TARGETISADMIN);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
if (you.getRole() == Role.MODERATOR) {
|
||||
// Revoke
|
||||
you.setRole(Role.NORMAL);
|
||||
targetFaction.msg(TL.COMMAND_MOD_REVOKED, you.describeTo(targetFaction, true));
|
||||
context.msg(TL.COMMAND_MOD_REVOKES, you.describeTo(context.fPlayer, true));
|
||||
} else {
|
||||
// Give
|
||||
you.setRole(Role.MODERATOR);
|
||||
targetFaction.msg(TL.COMMAND_MOD_PROMOTED, you.describeTo(targetFaction, true));
|
||||
context.msg(TL.COMMAND_MOD_PROMOTES, you.describeTo(context.fPlayer, true));
|
||||
FactionsPlugin.instance.getFlogManager().log(targetFaction, FLogType.RANK_EDIT, context.fPlayer.getName(), you.getName(), ChatColor.LIGHT_PURPLE + "Mod");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,7 +29,6 @@ public class CmdPaypalSee extends FCommand {
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (context.args.size() == 0) {
|
||||
if (context.fPlayer.getFaction().getPaypal() == null) {
|
||||
context.msg(TL.COMMAND_PAYPAL_NOTSET);
|
||||
|
||||
@@ -11,11 +11,15 @@ public class CmdPlayerTitleToggle extends FCommand {
|
||||
this.requirements = new CommandRequirements.Builder(Permission.TOGGLE_TITLES)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
context.fPlayer.setTitlesEnabled(!context.fPlayer.hasTitlesEnabled());
|
||||
context.msg(TL.COMMAND_TITLETOGGLE_TOGGLED, context.fPlayer.hasTitlesEnabled() ? FactionsPlugin.getInstance().color("&dEnabled") : FactionsPlugin.getInstance().color("&dDisabled"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {return TL.COMMAND_TITLETOGGLE_DESCRIPTION;}
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_TITLETOGGLE_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.discord.Discord;
|
||||
import com.massivecraft.factions.duels.RequestGUI;
|
||||
import com.massivecraft.factions.listeners.FactionsPlayerListener;
|
||||
import com.massivecraft.factions.shop.ShopConfig;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
@@ -44,6 +45,9 @@ public class CmdReload extends FCommand {
|
||||
FCmdRoot.instance.addVariableCommands();
|
||||
FCmdRoot.instance.rebuild();
|
||||
long timeReload = (System.currentTimeMillis() - timeInitStart);
|
||||
//Duels
|
||||
RequestGUI.inv = null;
|
||||
RequestGUI.responseMap.clear();
|
||||
|
||||
context.msg(TL.COMMAND_RELOAD_TIME, timeReload);
|
||||
}
|
||||
|
||||
@@ -74,7 +74,9 @@ public class CmdSeeChunk extends FCommand {
|
||||
for (Object nameObject : seeChunkMap.keySet()) {
|
||||
String name = nameObject + "";
|
||||
Player player = Bukkit.getPlayer(name);
|
||||
showBorders(player);
|
||||
if (player != null) {
|
||||
showBorders(player);
|
||||
}
|
||||
}
|
||||
manageTask();
|
||||
}, 0, interval);
|
||||
@@ -110,24 +112,19 @@ public class CmdSeeChunk extends FCommand {
|
||||
private void showPillar(Player player, World world, int blockX, int blockZ) {
|
||||
for (int blockY = 0; blockY < player.getLocation().getBlockY() + 30; blockY++) {
|
||||
Location loc = new Location(world, blockX, blockY, blockZ).add(0.5, 0, 0.5);
|
||||
if (loc.getBlock().getType() != Material.AIR) {
|
||||
continue;
|
||||
}
|
||||
if (loc.getBlock().getType() != Material.AIR) continue;
|
||||
if (useParticles) {
|
||||
if (FactionsPlugin.getInstance().useNonPacketParticles) {
|
||||
// Dust options only exists in the 1.13 API, so we use an
|
||||
// alternative method to achieve this in lower versions.
|
||||
if (FactionsPlugin.getInstance().mc113 || FactionsPlugin.getInstance().mc114) {
|
||||
if (FactionsPlugin.getInstance().mc113 || FactionsPlugin.getInstance().mc114 || FactionsPlugin.getInstance().mc115) {
|
||||
player.spawnParticle(Particle.REDSTONE, loc, 0, new Particle.DustOptions(Color.RED, 1));
|
||||
} else {
|
||||
player.getWorld().spawnParticle(Particle.REDSTONE, loc, 0, 255, 0, 0, 1);
|
||||
}
|
||||
|
||||
} else {
|
||||
this.effect.display(0, 0, 0, 0, 1, loc, player);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
Material type = blockY % 5 == 0 ? XMaterial.REDSTONE_LAMP.parseMaterial() : XMaterial.BLACK_STAINED_GLASS.parseMaterial();
|
||||
VisualizeUtil.addLocation(player, loc, type);
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
public class CmdSeeDiscord extends FCommand{
|
||||
public class CmdSeeDiscord extends FCommand {
|
||||
|
||||
/**
|
||||
* @author Driftay
|
||||
@@ -29,7 +29,6 @@ public class CmdSeeDiscord extends FCommand{
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (context.args.size() == 0) {
|
||||
if (context.fPlayer.getFaction().getDiscord() == null) {
|
||||
context.msg(TL.COMMAND_DISCORD_NOTSET);
|
||||
|
||||
@@ -12,7 +12,7 @@ public class CmdSetDiscord extends FCommand {
|
||||
* @author Driftay
|
||||
*/
|
||||
|
||||
public CmdSetDiscord(){
|
||||
public CmdSetDiscord() {
|
||||
super();
|
||||
this.aliases.addAll(Aliases.discord_set);
|
||||
|
||||
@@ -64,7 +64,7 @@ public class CmdSetDiscord extends FCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isDiscordInvite(String invite){
|
||||
private boolean isDiscordInvite(String invite) {
|
||||
return invite.contains("discord.gg") || invite.contains("discord.me");
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
@@ -43,6 +44,16 @@ public class CmdSethome extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!context.args.isEmpty()) {
|
||||
Faction target = context.argAsFaction(0);
|
||||
if (target == null) return;
|
||||
context.faction = target;
|
||||
if (target.getAccess(context.fPlayer, PermissableAction.SETHOME) != Access.ALLOW) {
|
||||
context.fPlayer.msg(TL.GENERIC_FPERM_NOPERMISSION, "set faction home");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||
if (!context.payForCommand(Conf.econCostSethome, TL.COMMAND_SETHOME_TOSET, TL.COMMAND_SETHOME_FORSET)) {
|
||||
return;
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import mkremins.fanciful.FancyMessage;
|
||||
@@ -28,12 +27,12 @@ public class CmdShowInvites extends FCommand {
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
FancyMessage msg = new FancyMessage(TL.COMMAND_SHOWINVITES_PENDING.toString()).color(ChatColor.GOLD);
|
||||
for (String id : context.faction.getInvites()) {
|
||||
FPlayer fp = FPlayers.getInstance().getById(id);
|
||||
String name = fp != null ? fp.getName() : id;
|
||||
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_SHOWINVITES_CLICKTOREVOKE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
|
||||
}
|
||||
FancyMessage msg = new FancyMessage(TL.COMMAND_SHOWINVITES_PENDING.toString()).color(ChatColor.GOLD);
|
||||
for (String id : context.faction.getInvites()) {
|
||||
FPlayer fp = FPlayers.getInstance().getById(id);
|
||||
String name = fp != null ? fp.getName() : id;
|
||||
msg.then(name + " ").color(ChatColor.WHITE).tooltip(TL.COMMAND_SHOWINVITES_CLICKTOREVOKE.format(name)).command("/" + Conf.baseCommandAliases.get(0) + " deinvite " + name);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,7 +11,7 @@ public class CmdSpawnerLock extends FCommand {
|
||||
* @author Illyria Team
|
||||
*/
|
||||
|
||||
public CmdSpawnerLock(){
|
||||
public CmdSpawnerLock() {
|
||||
super();
|
||||
this.aliases.addAll(Aliases.spawnerlock);
|
||||
|
||||
@@ -20,7 +20,7 @@ public class CmdSpawnerLock extends FCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context){
|
||||
public void perform(CommandContext context) {
|
||||
Conf.spawnerLock = !Conf.spawnerLock;
|
||||
context.msg(TL.COMMAND_SPAWNER_LOCK_TOGGLED, Conf.spawnerLock ? FactionsPlugin.getInstance().color("&aEnabled") : FactionsPlugin.getInstance().color("&4Disabled"));
|
||||
}
|
||||
|
||||
@@ -34,56 +34,56 @@ public class CmdTag extends FCommand {
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
|
||||
String tag = context.argAsString(0);
|
||||
String tag = context.argAsString(0);
|
||||
|
||||
// TODO does not first test cover selfcase?
|
||||
if (Factions.getInstance().isTagTaken(tag) && !MiscUtil.getComparisonString(tag).equals(context.faction.getComparisonTag())) {
|
||||
context.msg(TL.COMMAND_TAG_TAKEN);
|
||||
return;
|
||||
// TODO does not first test cover selfcase?
|
||||
if (Factions.getInstance().isTagTaken(tag) && !MiscUtil.getComparisonString(tag).equals(context.faction.getComparisonTag())) {
|
||||
context.msg(TL.COMMAND_TAG_TAKEN);
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<String> errors = MiscUtil.validateTag(tag);
|
||||
if (errors.size() > 0) {
|
||||
context.sendMessage(errors);
|
||||
return;
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
||||
if (!context.canAffordCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE.toString())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// trigger the faction rename event (cancellable)
|
||||
FactionRenameEvent renameEvent = new FactionRenameEvent(context.fPlayer, tag);
|
||||
Bukkit.getServer().getPluginManager().callEvent(renameEvent);
|
||||
if (renameEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// then make 'em pay (if applicable)
|
||||
if (!context.payForCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE, TL.COMMAND_TAG_FORCHANGE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String oldtag = context.faction.getTag();
|
||||
context.faction.setTag(tag);
|
||||
Discord.changeFactionTag(context.faction, oldtag);
|
||||
FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.FTAG_EDIT, context.fPlayer.getName(), tag);
|
||||
|
||||
|
||||
// Inform
|
||||
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
|
||||
if (fplayer.getFactionId().equals(context.faction.getId())) {
|
||||
fplayer.msg(TL.COMMAND_TAG_FACTION, context.fPlayer.describeTo(context.faction, true), context.faction.getTag(context.faction));
|
||||
continue;
|
||||
}
|
||||
|
||||
ArrayList<String> errors = MiscUtil.validateTag(tag);
|
||||
if (errors.size() > 0) {
|
||||
context.sendMessage(errors);
|
||||
return;
|
||||
// Broadcast the tag change (if applicable)
|
||||
if (Conf.broadcastTagChanges) {
|
||||
Faction faction = fplayer.getFaction();
|
||||
fplayer.msg(TL.COMMAND_TAG_CHANGED, context.fPlayer.getColorTo(faction) + oldtag, context.faction.getTag(faction));
|
||||
}
|
||||
|
||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make sure they can pay
|
||||
if (!context.canAffordCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE.toString())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// trigger the faction rename event (cancellable)
|
||||
FactionRenameEvent renameEvent = new FactionRenameEvent(context.fPlayer, tag);
|
||||
Bukkit.getServer().getPluginManager().callEvent(renameEvent);
|
||||
if (renameEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// then make 'em pay (if applicable)
|
||||
if (!context.payForCommand(Conf.econCostTag, TL.COMMAND_TAG_TOCHANGE, TL.COMMAND_TAG_FORCHANGE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String oldtag = context.faction.getTag();
|
||||
context.faction.setTag(tag);
|
||||
Discord.changeFactionTag(context.faction, oldtag);
|
||||
FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.FTAG_EDIT, context.fPlayer.getName(), tag);
|
||||
|
||||
|
||||
// Inform
|
||||
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) {
|
||||
if (fplayer.getFactionId().equals(context.faction.getId())) {
|
||||
fplayer.msg(TL.COMMAND_TAG_FACTION, context.fPlayer.describeTo(context.faction, true), context.faction.getTag(context.faction));
|
||||
continue;
|
||||
}
|
||||
// Broadcast the tag change (if applicable)
|
||||
if (Conf.broadcastTagChanges) {
|
||||
Faction faction = fplayer.getFaction();
|
||||
fplayer.msg(TL.COMMAND_TAG_CHANGED, context.fPlayer.getColorTo(faction) + oldtag, context.faction.getTag(faction));
|
||||
}
|
||||
}
|
||||
FTeamWrapper.updatePrefixes(context.faction);
|
||||
}
|
||||
FTeamWrapper.updatePrefixes(context.faction);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.listeners.FactionsBlockListener;
|
||||
import com.massivecraft.factions.listeners.FactionsPlayerListener;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.util.WarmUpUtil;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
@@ -268,7 +268,6 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
||||
this.addSubCommand(this.cmdPromote);
|
||||
this.addSubCommand(this.cmdDebug);
|
||||
this.addSubCommand(this.cmdDemote);
|
||||
this.addSubCommand(this.cmdDiscord);
|
||||
this.addSubCommand(this.cmdSetDefaultRole);
|
||||
this.addSubCommand(this.cmdMapHeight);
|
||||
this.addSubCommand(this.cmdClaimAt);
|
||||
@@ -309,16 +308,16 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
||||
*/
|
||||
public void addVariableCommands() {
|
||||
//Discord
|
||||
if (Conf.useDiscordSystem && !discordEnabled) {
|
||||
this.addSubCommand(this.cmdInviteBot);
|
||||
this.addSubCommand(this.cmdSetGuild);
|
||||
this.addSubCommand(this.cmdSetDiscord);
|
||||
this.addSubCommand(this.cmdSeeDiscord);
|
||||
this.addSubCommand(this.cmdDiscord);
|
||||
discordEnabled = true;
|
||||
}
|
||||
//Reserve
|
||||
if(Conf.useReserveSystem){
|
||||
if (Conf.useDiscordSystem && !discordEnabled) {
|
||||
this.addSubCommand(this.cmdInviteBot);
|
||||
this.addSubCommand(this.cmdSetGuild);
|
||||
this.addSubCommand(this.cmdSetDiscord);
|
||||
this.addSubCommand(this.cmdSeeDiscord);
|
||||
this.addSubCommand(this.cmdDiscord);
|
||||
discordEnabled = true;
|
||||
}
|
||||
//Reserve
|
||||
if (Conf.useReserveSystem) {
|
||||
this.addSubCommand(this.cmdReserve);
|
||||
}
|
||||
|
||||
@@ -351,7 +350,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
||||
internalFTOPEnabled = true;
|
||||
}
|
||||
|
||||
if(Conf.useAuditSystem){
|
||||
if (Conf.useAuditSystem) {
|
||||
this.addSubCommand(cmdAudit);
|
||||
fAuditEnabled = true;
|
||||
}
|
||||
@@ -395,7 +394,9 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
public void rebuild() {if (CommodoreProvider.isSupported()) brigadierManager.build();}
|
||||
public void rebuild() {
|
||||
if (CommodoreProvider.isSupported()) brigadierManager.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
|
||||
@@ -25,7 +25,7 @@ public class CmdKickAlt extends FCommand {
|
||||
* @author Driftay
|
||||
*/
|
||||
|
||||
public CmdKickAlt(){
|
||||
public CmdKickAlt() {
|
||||
super();
|
||||
this.aliases.addAll(Aliases.alts_kick);
|
||||
this.requiredArgs.add("player name");
|
||||
@@ -86,7 +86,7 @@ public class CmdKickAlt extends FCommand {
|
||||
// This statement allows us to check if they've specifically denied it,
|
||||
// or default to
|
||||
// the old setting of allowing moderators to kick
|
||||
if (access != Access.ALLOW && !context.assertMinRole(Role.MODERATOR)) {
|
||||
if (access != Access.ALLOW && !context.assertMinRole(Role.MODERATOR)) {
|
||||
context.msg(TL.GENERIC_NOPERMISSION, "kick");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -26,10 +26,11 @@ public class CmdAudit extends FCommand {
|
||||
.noErrorOnManyArgs()
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
Faction faction = context.args.size() == 1 && context.sender.isOp() ? context.argAsFaction(0) : context.faction;
|
||||
new FAuditMenu((Player)context.sender, faction).open((Player)context.sender);
|
||||
new FAuditMenu((Player) context.sender, faction).open((Player) context.sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd.audit;
|
||||
/*
|
||||
@author Saser
|
||||
*/
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
@@ -92,9 +93,9 @@ public class FAuditMenu extends GUIMenu {
|
||||
LinkedList<FactionLogs.FactionLog> log = logs.getMostRecentLogs().get(logType);
|
||||
if (log != null) {
|
||||
int slot = logType == FLogType.F_TNT ? 0 : 3;
|
||||
int pagesToShow = (int)Math.max(1.0D, Math.ceil((double)log.size() / (double)perPage));
|
||||
int pagesToShow = (int) Math.max(1.0D, Math.ceil((double) log.size() / (double) perPage));
|
||||
|
||||
for(int page = 1; page <= pagesToShow; ++page) {
|
||||
for (int page = 1; page <= pagesToShow; ++page) {
|
||||
int startIndex = log.size() - (page * perPage - perPage);
|
||||
if (startIndex >= log.size()) {
|
||||
startIndex = log.size() - 1;
|
||||
@@ -102,7 +103,7 @@ public class FAuditMenu extends GUIMenu {
|
||||
|
||||
List<String> lore = Lists.newArrayList("", CC.GreenB + "Logs");
|
||||
|
||||
for(int i = startIndex; i > startIndex - perPage; --i) {
|
||||
for (int i = startIndex; i > startIndex - perPage; --i) {
|
||||
if (i < log.size()) {
|
||||
if (i < 0) {
|
||||
break;
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd.audit;
|
||||
/**
|
||||
* @author Saser
|
||||
*/
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Faction;
|
||||
@@ -45,17 +46,20 @@ public class FChestListener implements Listener {
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||
Faction faction;
|
||||
if(!event.getView().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title")))) return;
|
||||
if (!event.getView().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title"))))
|
||||
return;
|
||||
if (event.getClick() == ClickType.UNKNOWN) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(CC.RedB + "(!) " + CC.Red + "You cannot use that click type inside the /f chest!");
|
||||
return;
|
||||
}
|
||||
ItemStack currentItem = event.getCurrentItem();
|
||||
if (event.getClick() == ClickType.NUMBER_KEY) currentItem = event.getClickedInventory().getItem(event.getSlot());
|
||||
if (event.getClick() == ClickType.NUMBER_KEY)
|
||||
currentItem = event.getClickedInventory().getItem(event.getSlot());
|
||||
Material currentItemType = currentItem != null ? currentItem.getType() : Material.AIR;
|
||||
ItemStack cursorItem = event.getCursor();
|
||||
if (event.getClick() == ClickType.NUMBER_KEY) cursorItem = player.getInventory().getItem(event.getHotbarButton());
|
||||
if (event.getClick() == ClickType.NUMBER_KEY)
|
||||
cursorItem = player.getInventory().getItem(event.getHotbarButton());
|
||||
Material cursorItemType = cursorItem != null ? cursorItem.getType() : Material.AIR;
|
||||
if (fPlayer == null || !(faction = fPlayer.getFaction()).isNormal()) {
|
||||
player.closeInventory();
|
||||
@@ -65,16 +69,16 @@ public class FChestListener implements Listener {
|
||||
if (event.getClickedInventory() == null) return;
|
||||
if (event.getView().getTitle().equalsIgnoreCase(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fchest.Inventory-Title"))) && !event.getClick().isShiftClick()) {
|
||||
if (currentItemType != Material.AIR) {
|
||||
Inventory ours = faction.getChestInventory();
|
||||
if(event.getClickedInventory() == ours) {
|
||||
if (ours == null || !ours.contains(currentItem)) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(CC.RedB + "(!) That item not longer exists!");
|
||||
Bukkit.getLogger().info("[FactionChest] " + player.getName() + " tried to remove " + currentItem + " from /f chest when it didnt contain! Items: " + (ours == null ? "none" : Arrays.toString(ours.getContents())));
|
||||
player.closeInventory();
|
||||
return;
|
||||
}
|
||||
Inventory ours = faction.getChestInventory();
|
||||
if (event.getClickedInventory() == ours) {
|
||||
if (ours == null || !ours.contains(currentItem)) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(CC.RedB + "(!) That item not longer exists!");
|
||||
Bukkit.getLogger().info("[FactionChest] " + player.getName() + " tried to remove " + currentItem + " from /f chest when it didnt contain! Items: " + (ours == null ? "none" : Arrays.toString(ours.getContents())));
|
||||
player.closeInventory();
|
||||
return;
|
||||
}
|
||||
}
|
||||
logRemoveItem(currentItem, fPlayer, player);
|
||||
} else if (cursorItemType != Material.AIR && !event.isShiftClick()) {
|
||||
logAddItem(cursorItem, fPlayer, player);
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd.audit;
|
||||
/**
|
||||
* @author Saser
|
||||
*/
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
@@ -127,7 +128,7 @@ public class FLogManager {
|
||||
}
|
||||
|
||||
try {
|
||||
JSONUtils.saveJSONToFile(logFile, factionLogMap,logToken);
|
||||
JSONUtils.saveJSONToFile(logFile, factionLogMap, logToken);
|
||||
} catch (Exception e1) {
|
||||
Bukkit.getLogger().info("ERROR SAVING JSON LOGS: " + e1.getMessage());
|
||||
e1.printStackTrace();
|
||||
|
||||
@@ -27,8 +27,10 @@ public enum FLogType {
|
||||
private String msg;
|
||||
private int requiredArgs;
|
||||
|
||||
public String getDisplayName() {
|
||||
return this.displayName;
|
||||
FLogType(String displayName, String msg, int requiredArgs) {
|
||||
this.displayName = displayName;
|
||||
this.msg = msg;
|
||||
this.requiredArgs = requiredArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,15 +48,22 @@ public enum FLogType {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() { return name(); }
|
||||
|
||||
public int getSlot() { return FactionsPlugin.getInstance().getConfig().getInt("faudit-gui.slots." + name().toLowerCase()); }
|
||||
|
||||
public Material getMaterial(){
|
||||
return XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("faudit-gui.materials." + name().toLowerCase())).parseMaterial();
|
||||
public String getDisplayName() {
|
||||
return this.displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name();
|
||||
}
|
||||
|
||||
public int getSlot() {
|
||||
return FactionsPlugin.getInstance().getConfig().getInt("faudit-gui.slots." + name().toLowerCase());
|
||||
}
|
||||
|
||||
public Material getMaterial() {
|
||||
return XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("faudit-gui.materials." + name().toLowerCase())).get().parseMaterial();
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return this.msg;
|
||||
@@ -63,10 +72,4 @@ public enum FLogType {
|
||||
public int getRequiredArgs() {
|
||||
return this.requiredArgs;
|
||||
}
|
||||
|
||||
FLogType(String displayName, String msg, int requiredArgs) {
|
||||
this.displayName = displayName;
|
||||
this.msg = msg;
|
||||
this.requiredArgs = requiredArgs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd.audit;
|
||||
/**
|
||||
* @author Saser
|
||||
*/
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -16,8 +17,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class FactionLogs {
|
||||
private Map<FLogType, LinkedList<FactionLog>> mostRecentLogs = new ConcurrentHashMap<>();
|
||||
public static transient SimpleDateFormat format = new SimpleDateFormat("MM/dd hh:mmaa");
|
||||
private Map<FLogType, LinkedList<FactionLog>> mostRecentLogs = new ConcurrentHashMap<>();
|
||||
|
||||
public FactionLogs() {
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd.audit;
|
||||
/**
|
||||
* @author Saser
|
||||
*/
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -65,11 +66,32 @@ public class LogTimer extends ConcurrentHashMap<LogTimer.TimerType, Map<LogTimer
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public enum TimerSubType {
|
||||
SPAWNER_BREAK,
|
||||
SPAWNER_PLACE;
|
||||
|
||||
TimerSubType() {
|
||||
}
|
||||
}
|
||||
|
||||
public enum TimerType {
|
||||
SPAWNER_EDIT;
|
||||
|
||||
TimerType() {
|
||||
}
|
||||
}
|
||||
|
||||
public class Timer {
|
||||
private long startTime;
|
||||
private long count;
|
||||
private Object extraData;
|
||||
|
||||
public Timer(long startTime, long count, Object extraData) {
|
||||
this.startTime = startTime;
|
||||
this.count = count;
|
||||
this.extraData = extraData;
|
||||
}
|
||||
|
||||
LogTimer.Timer increment(long amount) {
|
||||
this.count += amount;
|
||||
return this;
|
||||
@@ -79,47 +101,28 @@ public class LogTimer extends ConcurrentHashMap<LogTimer.TimerType, Map<LogTimer
|
||||
return System.currentTimeMillis() - this.startTime >= expiration;
|
||||
}
|
||||
|
||||
public Timer(long startTime, long count, Object extraData) {
|
||||
this.startTime = startTime;
|
||||
this.count = count;
|
||||
this.extraData = extraData;
|
||||
}
|
||||
|
||||
public long getStartTime() {
|
||||
return this.startTime;
|
||||
}
|
||||
|
||||
public long getCount() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
public Object getExtraData() {
|
||||
return this.extraData;
|
||||
}
|
||||
|
||||
public void setStartTime(long startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public long getCount() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
public void setCount(long count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public Object getExtraData() {
|
||||
return this.extraData;
|
||||
}
|
||||
|
||||
public void setExtraData(Object extraData) {
|
||||
this.extraData = extraData;
|
||||
}
|
||||
}
|
||||
|
||||
public enum TimerSubType {
|
||||
SPAWNER_BREAK,
|
||||
SPAWNER_PLACE;
|
||||
TimerSubType() {
|
||||
}
|
||||
}
|
||||
|
||||
public enum TimerType {
|
||||
SPAWNER_EDIT;
|
||||
TimerType() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,19 +52,19 @@ public class CheckSettingsFrame implements InventoryHolder, FactionGUI {
|
||||
|
||||
public void build() {
|
||||
Faction faction = fPlayer.getFaction();
|
||||
ItemStack wallsStack = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("f-check.wall-check.Type")).parseItem();
|
||||
ItemStack wallsStack = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("f-check.wall-check.Type")).get().parseItem();
|
||||
ItemMeta wallsMeta = wallsStack.getItemMeta();
|
||||
wallsMeta.setDisplayName(TL.CHECK_WALL_CHECK_GUI_ICON.toString());
|
||||
wallsMeta.setLore(Collections.singletonList(TL.CHECK_CHECK_LORE_LINE.format(getFormatted(faction.getWallCheckMinutes()))));
|
||||
wallsStack.setItemMeta(wallsMeta);
|
||||
inventory.setItem(FactionsPlugin.getInstance().getConfig().getInt("f-check.wall-check.slot"), wallsStack);
|
||||
ItemStack bufferStack = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("f-check.buffer-check.Type")).parseItem();
|
||||
ItemStack bufferStack = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("f-check.buffer-check.Type")).get().parseItem();
|
||||
ItemMeta bufferMeta = bufferStack.getItemMeta();
|
||||
bufferMeta.setDisplayName(TL.CHECK_BUFFER_CHECK_GUI_ICON.toString());
|
||||
bufferMeta.setLore(Collections.singletonList(TL.CHECK_CHECK_LORE_LINE.format(getFormatted(faction.getBufferCheckMinutes()))));
|
||||
bufferStack.setItemMeta(bufferMeta);
|
||||
inventory.setItem(FactionsPlugin.getInstance().getConfig().getInt("f-check.buffer-check.slot"), bufferStack);
|
||||
ItemStack historyStack = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("f-check.history.Type")).parseItem();
|
||||
ItemStack historyStack = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("f-check.history.Type")).get().parseItem();
|
||||
ItemMeta historyMeta = historyStack.getItemMeta();
|
||||
historyMeta.setDisplayName(TL.CHECK_HISTORY_GUI_ICON.toString());
|
||||
historyStack.setItemMeta(historyMeta);
|
||||
|
||||
@@ -59,7 +59,7 @@ public class CmdWeeWoo extends FCommand {
|
||||
}
|
||||
context.faction.setWeeWoo(false);
|
||||
context.msg(TL.COMMAND_WEEWOO_STOPPED, context.fPlayer.getNameAndTag());
|
||||
if(!Conf.useDiscordSystem) return;
|
||||
if (!Conf.useDiscordSystem) return;
|
||||
String discordChannelId = context.faction.getWeeWooChannelId();
|
||||
if (discordChannelId != null && !discordChannelId.isEmpty()) {
|
||||
TextChannel textChannel = Discord.jda.getTextChannelById(discordChannelId);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.massivecraft.factions.cmd.claim;
|
||||
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.cmd.Aliases;
|
||||
|
||||
@@ -89,7 +89,7 @@ public class CmdClaimLine extends FCommand {
|
||||
location = location.add(blockFace.getModX() * 16, 0, blockFace.getModZ() * 16);
|
||||
FactionsPlugin.instance.logFactionEvent(forFaction, FLogType.CHUNK_CLAIMS, context.fPlayer.getName(), CC.GreenB + "CLAIMED", String.valueOf(i), new FLocation(context.player.getLocation()).formatXAndZ(","));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
|
||||
@@ -10,8 +10,6 @@ import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.util.CornerTask;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
|
||||
@@ -21,7 +21,6 @@ public class CmdUnclaimall extends FCommand {
|
||||
*/
|
||||
|
||||
//TODO: Add UnclaimAll Confirmation GUI
|
||||
|
||||
public CmdUnclaimall() {
|
||||
this.aliases.addAll(Aliases.unclaim_all_unsafe);
|
||||
|
||||
|
||||
@@ -17,6 +17,9 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* @author droppinganvil
|
||||
*/
|
||||
public class ConvertConfigHandler {
|
||||
|
||||
static File savageConfigFile = new File("plugins/Factions/SavageFactions/config.yml");
|
||||
|
||||
@@ -40,7 +40,7 @@ public class CmdMoney extends FCommand {
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
if (!Conf.econEnabled || !Conf.bankEnabled) {
|
||||
context.msg(TL.ECON_OFF, "economy option is enabled, please set \'econEnabled\' to true in conf.json");
|
||||
context.msg(TL.ECON_OFF, "economy option is enabled, please set 'econEnabled' to true in conf.json");
|
||||
return;
|
||||
}
|
||||
context.commandChain.add(this);
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.massivecraft.factions.cmd.FCommand;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class CmdMoneyBalance extends FCommand {
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ public class CmdGrace extends FCommand {
|
||||
*/
|
||||
|
||||
//TODO: Make Timed Format For Grace Period
|
||||
|
||||
public CmdGrace() {
|
||||
super();
|
||||
this.aliases.addAll(Aliases.grace);
|
||||
|
||||
@@ -84,7 +84,7 @@ public abstract class FRelationCommand extends FCommand {
|
||||
// trigger the faction relation event
|
||||
FactionRelationEvent relationEvent = new FactionRelationEvent(context.faction, them, oldRelation, currentRelation);
|
||||
Bukkit.getServer().getPluginManager().callEvent(relationEvent);
|
||||
FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.RELATION_CHANGE,context.fPlayer.getName(), this.targetRelation.getColor() + this.targetRelation.name(), oldRelation.getColor() + them.getTag());
|
||||
FactionsPlugin.instance.logFactionEvent(context.faction, FLogType.RELATION_CHANGE, context.fPlayer.getName(), this.targetRelation.getColor() + this.targetRelation.name(), oldRelation.getColor() + them.getTag());
|
||||
FactionsPlugin.instance.logFactionEvent(them, FLogType.RELATION_CHANGE, oldRelation.getColor() + context.fPlayer.getName(), this.targetRelation.getColor() + this.targetRelation.name(), "your faction");
|
||||
|
||||
them.msg(TL.COMMAND_RELATIONS_MUTUAL, currentRelationColor + targetRelation.getTranslation(), currentRelationColor + context.faction.getTag());
|
||||
|
||||
@@ -10,14 +10,22 @@ import java.util.ArrayList;
|
||||
public class ListParameterizedType implements ParameterizedType {
|
||||
private Type type;
|
||||
|
||||
public ListParameterizedType(Type type) { this.type = type; }
|
||||
public ListParameterizedType(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type[] getActualTypeArguments() { return new Type[] { this.type }; }
|
||||
public Type[] getActualTypeArguments() {
|
||||
return new Type[]{this.type};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getRawType() { return ArrayList.class; }
|
||||
public Type getRawType() {
|
||||
return ArrayList.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getOwnerType() { return null; }
|
||||
public Type getOwnerType() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,13 +6,16 @@ package com.massivecraft.factions.cmd.reserve;
|
||||
public class ReserveObject {
|
||||
private String name;
|
||||
private String factionName;
|
||||
public ReserveObject(String name, String factionName){
|
||||
|
||||
public ReserveObject(String name, String factionName) {
|
||||
this.name = name;
|
||||
this.factionName = factionName;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getFactionName() {
|
||||
return this.factionName;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,24 @@ public class CmdTnt extends FCommand {
|
||||
.build();
|
||||
}
|
||||
|
||||
public static void removeItems(Inventory inventory, ItemStack item, int toRemove) {
|
||||
if (toRemove <= 0 || inventory == null || item == null)
|
||||
return;
|
||||
for (int i = 0; i < inventory.getSize(); i++) {
|
||||
ItemStack loopItem = inventory.getItem(i);
|
||||
if (loopItem == null || !item.isSimilar(loopItem))
|
||||
continue;
|
||||
if (toRemove <= 0)
|
||||
return;
|
||||
if (toRemove < loopItem.getAmount()) {
|
||||
loopItem.setAmount(loopItem.getAmount() - toRemove);
|
||||
return;
|
||||
}
|
||||
inventory.clear(i);
|
||||
toRemove -= loopItem.getAmount();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
if (!FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) {
|
||||
@@ -110,8 +128,10 @@ public class CmdTnt extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i <= fullStacks - 1; i++) context.player.getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), 64));
|
||||
if (remainderAmt != 0) context.player.getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), remainderAmt));
|
||||
for (int i = 0; i <= fullStacks - 1; i++)
|
||||
context.player.getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), 64));
|
||||
if (remainderAmt != 0)
|
||||
context.player.getInventory().addItem(new ItemStack(XMaterial.TNT.parseMaterial(), remainderAmt));
|
||||
|
||||
context.faction.takeTnt(amount);
|
||||
context.player.updateInventory();
|
||||
@@ -123,7 +143,9 @@ public class CmdTnt extends FCommand {
|
||||
Inventory inv = context.player.getInventory();
|
||||
int invTnt = 0;
|
||||
for (int i = 0; i <= inv.getSize(); i++) {
|
||||
if (inv.getItem(i) == null) { continue; }
|
||||
if (inv.getItem(i) == null) {
|
||||
continue;
|
||||
}
|
||||
if (inv.getItem(i).getType() == Material.TNT) {
|
||||
invTnt += inv.getItem(i).getAmount();
|
||||
}
|
||||
@@ -152,7 +174,6 @@ public class CmdTnt extends FCommand {
|
||||
context.sendMessage(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", context.faction.getTnt() + "").replace("{maxAmount}", context.faction.getTntBankLimit() + ""));
|
||||
}
|
||||
|
||||
|
||||
public boolean inventoryContains(Inventory inventory, ItemStack item) {
|
||||
int count = 0;
|
||||
ItemStack[] items = inventory.getContents();
|
||||
@@ -177,24 +198,6 @@ public class CmdTnt extends FCommand {
|
||||
return check >= howmany;
|
||||
}
|
||||
|
||||
public static void removeItems(Inventory inventory, ItemStack item, int toRemove) {
|
||||
if (toRemove <= 0 || inventory == null || item == null)
|
||||
return;
|
||||
for (int i = 0; i < inventory.getSize(); i++) {
|
||||
ItemStack loopItem = inventory.getItem(i);
|
||||
if (loopItem == null || !item.isSimilar(loopItem))
|
||||
continue;
|
||||
if (toRemove <= 0)
|
||||
return;
|
||||
if (toRemove < loopItem.getAmount()) {
|
||||
loopItem.setAmount(loopItem.getAmount() - toRemove);
|
||||
return;
|
||||
}
|
||||
inventory.clear(i);
|
||||
toRemove -= loopItem.getAmount();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeFromInventory(Inventory inventory, ItemStack item) {
|
||||
int amt = item.getAmount();
|
||||
ItemStack[] items = inventory.getContents();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.massivecraft.factions.cmd.tnt;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.cmd.Aliases;
|
||||
import com.massivecraft.factions.cmd.CommandContext;
|
||||
@@ -23,10 +24,6 @@ import java.util.*;
|
||||
|
||||
public class CmdTntFill extends FCommand {
|
||||
|
||||
/**
|
||||
* @author Illyria Team
|
||||
*/
|
||||
|
||||
public CmdTntFill() {
|
||||
super();
|
||||
this.aliases.addAll(Aliases.tnt_tntfill);
|
||||
@@ -66,15 +63,15 @@ public class CmdTntFill extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (radius > FactionsPlugin.instance.getConfig().getInt("Tntfill.max-radius")) {
|
||||
context.msg(TL.COMMAND_TNTFILL_RADIUSMAX.toString().replace("{max}", FactionsPlugin.instance.getConfig().getInt("Tntfill.max-radius") + ""));
|
||||
if (radius > FactionsPlugin.getInstance().getConfig().getInt("Tntfill.max-radius")) {
|
||||
context.msg(TL.COMMAND_TNTFILL_RADIUSMAX.toString().replace("{max}", FactionsPlugin.getInstance().getConfig().getInt("Tntfill.max-radius") + ""));
|
||||
return;
|
||||
}
|
||||
if (amount > FactionsPlugin.getInstance().getConfig().getInt("Tntfill.max-amount")) {
|
||||
context.msg(TL.COMMAND_TNTFILL_AMOUNTMAX.toString().replace("{max}", FactionsPlugin.getInstance().getConfig().getInt("Tntfill.max-amount") + ""));
|
||||
return;
|
||||
}
|
||||
|
||||
if (amount > FactionsPlugin.instance.getConfig().getInt("Tntfill.max-amount")) {
|
||||
context.msg(TL.COMMAND_TNTFILL_AMOUNTMAX.toString().replace("{max}", FactionsPlugin.instance.getConfig().getInt("Tntfill.max-amount") + ""));
|
||||
return;
|
||||
}
|
||||
// How many dispensers are we to fill in?
|
||||
|
||||
Location start = context.player.getLocation();
|
||||
@@ -89,103 +86,82 @@ public class CmdTntFill extends FCommand {
|
||||
if (block == null) continue;
|
||||
BlockState blockState = block.getState();
|
||||
if (!(blockState instanceof Dispenser)) continue;
|
||||
Dispenser dis = (Dispenser) blockState;
|
||||
// skip if we can't add anything
|
||||
if (isInvFull(dis.getInventory())) continue;
|
||||
opDispensers.add((Dispenser) blockState);
|
||||
}
|
||||
if (opDispensers.isEmpty()) {
|
||||
context.fPlayer.msg(TL.COMMAND_TNTFILL_NODISPENSERS.toString().replace("{radius}", radius + ""));
|
||||
return;
|
||||
}
|
||||
|
||||
// What's the required amount of resources
|
||||
int requiredTnt = (opDispensers.size() * amount);
|
||||
|
||||
// Do I have enough tnt in my inventory?
|
||||
int playerTnt = inventoryItemCount(context.player.getInventory(), Material.TNT);
|
||||
int playerTnt = getTNTInside(context.player);
|
||||
// if player does not have enough tnt, just take whatever he has and add it to the bank
|
||||
// then use the bank as source. If bank < required abort.
|
||||
if (playerTnt < requiredTnt) {
|
||||
// How much TNT will I take from bank?
|
||||
int getFactionTnt = requiredTnt - playerTnt;
|
||||
|
||||
// Do I have enough tnt in bank?
|
||||
if ((context.faction.getTnt() < getFactionTnt)) {
|
||||
if ((context.faction.getTnt() < (requiredTnt - playerTnt))) {
|
||||
context.fPlayer.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
// Take TNT from the bank.
|
||||
removeFromBank(context, getFactionTnt);
|
||||
// move whatever tnt you have to the bank, ignoring limit because its gonna be taken out later anyways
|
||||
context.faction.addTnt(playerTnt);
|
||||
removeItems(context.fPlayer.getPlayer().getInventory(), new ItemStack(Material.TNT), playerTnt);
|
||||
// Take TNT from the bank
|
||||
fillDispensers(context, opDispensers, amount);
|
||||
} else {
|
||||
// Take TNT from the player
|
||||
fillDispensers(context.fPlayer, opDispensers, amount);
|
||||
}
|
||||
fillDispensers(context.fPlayer, opDispensers, amount);
|
||||
// Remove used TNT from player inventory.
|
||||
context.sendMessage(TL.COMMAND_TNTFILL_SUCCESS.toString().replace("{amount}", requiredTnt + "").replace("{dispensers}", opDispensers.size() + ""));
|
||||
}
|
||||
|
||||
// Actually fill every dispenser with the precise amount.
|
||||
private void fillDispensers(FPlayer fPlayer, List<Dispenser> dispensers, int count) {
|
||||
for (Dispenser dispenser : dispensers) {
|
||||
if (takeTnt(fPlayer, count)) {
|
||||
dispenser.getInventory().addItem(new ItemStack(Material.TNT, count));
|
||||
} else {return;}
|
||||
int canBeAdded = getAddable(dispenser.getInventory(), Material.TNT);
|
||||
if (canBeAdded <= 0) continue;
|
||||
int toAdd = Math.min(canBeAdded, count);
|
||||
if (toAdd > getTNTInside(fPlayer.getPlayer())) {
|
||||
fPlayer.msg(TL.COMMAND_TNTFILL_NOTENOUGH.toString());
|
||||
return;
|
||||
}
|
||||
removeItems(fPlayer.getPlayer().getInventory(), new ItemStack(Material.TNT), toAdd);
|
||||
dispenser.getInventory().addItem(new ItemStack(Material.TNT, toAdd));
|
||||
}
|
||||
}
|
||||
|
||||
private void removeFromBank(CommandContext context, int amount) {
|
||||
try {
|
||||
Integer.parseInt(context.args.get(1));
|
||||
} catch (NumberFormatException e) {
|
||||
context.fPlayer.msg(TL.COMMAND_TNT_INVALID_NUM.toString());
|
||||
return;
|
||||
private void fillDispensers(CommandContext context, List<Dispenser> dispensers, int count) {
|
||||
for (Dispenser dispenser : dispensers) {
|
||||
int canBeAdded = getAddable(dispenser.getInventory(), Material.TNT);
|
||||
if (canBeAdded <= 0) continue;
|
||||
int toAdd = Math.min(canBeAdded, count);
|
||||
if (context.faction.getTnt() < toAdd) {
|
||||
context.fPlayer.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
|
||||
return;
|
||||
}
|
||||
context.faction.takeTnt(toAdd);
|
||||
dispenser.getInventory().addItem(new ItemStack(Material.TNT, toAdd));
|
||||
}
|
||||
if (amount < 0) {
|
||||
context.fPlayer.msg(TL.COMMAND_TNT_POSITIVE.toString());
|
||||
return;
|
||||
}
|
||||
if (context.faction.getTnt() < amount) {
|
||||
context.fPlayer.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
|
||||
return;
|
||||
}
|
||||
int fullStacks = amount / 64;
|
||||
int remainderAmt = amount % 64;
|
||||
if ((remainderAmt == 0 && getEmptySlots(context.player) <= fullStacks)) {
|
||||
context.fPlayer.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
|
||||
return;
|
||||
}
|
||||
if (getEmptySlots(context.player) + 1 <= fullStacks) {
|
||||
context.fPlayer.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH_TNT.toString());
|
||||
return;
|
||||
}
|
||||
ItemStack tnt64 = new ItemStack(Material.TNT, 64);
|
||||
for (int i = 0; i <= fullStacks - 1; i++) {
|
||||
context.player.getInventory().addItem(tnt64);
|
||||
}
|
||||
if (remainderAmt != 0) {
|
||||
ItemStack tnt = new ItemStack(Material.TNT, remainderAmt);
|
||||
context.player.getInventory().addItem(tnt);
|
||||
}
|
||||
context.faction.takeTnt(amount);
|
||||
context.player.updateInventory();
|
||||
}
|
||||
|
||||
private boolean takeTnt(FPlayer fme, int amount) {
|
||||
Inventory inv = fme.getPlayer().getInventory();
|
||||
int invTnt = 0;
|
||||
for (int i = 0; i <= inv.getSize(); i++) {
|
||||
if (inv.getItem(i) == null) {
|
||||
public static void removeItems(Inventory inventory, ItemStack item, int toRemove) {
|
||||
if (toRemove <= 0 || inventory == null || item == null)
|
||||
return;
|
||||
for (int i = 0; i < inventory.getSize(); i++) {
|
||||
ItemStack loopItem = inventory.getItem(i);
|
||||
if (loopItem == null || !item.isSimilar(loopItem))
|
||||
continue;
|
||||
if (toRemove <= 0)
|
||||
return;
|
||||
if (toRemove < loopItem.getAmount()) {
|
||||
loopItem.setAmount(loopItem.getAmount() - toRemove);
|
||||
return;
|
||||
}
|
||||
if (inv.getItem(i).getType() == Material.TNT) {
|
||||
invTnt += inv.getItem(i).getAmount();
|
||||
}
|
||||
inventory.clear(i);
|
||||
toRemove -= loopItem.getAmount();
|
||||
}
|
||||
if (amount > invTnt) {
|
||||
fme.msg(TL.COMMAND_TNTFILL_NOTENOUGH.toString());
|
||||
return false;
|
||||
}
|
||||
ItemStack tnt = new ItemStack(Material.TNT, amount);
|
||||
if (fme.getFaction().getTnt() + amount > FactionsPlugin.getInstance().getConfig().getInt("ftnt.Bank-Limit")) {
|
||||
fme.msg(TL.COMMAND_TNT_EXCEEDLIMIT.toString());
|
||||
return false;
|
||||
}
|
||||
removeFromInventory(fme.getPlayer().getInventory(), tnt);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Counts the item type available in the inventory.
|
||||
@@ -197,35 +173,37 @@ public class CmdTntFill extends FCommand {
|
||||
return count;
|
||||
}
|
||||
|
||||
private void removeFromInventory(Inventory inventory, ItemStack item) {
|
||||
int amt = item.getAmount();
|
||||
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()) {
|
||||
if (items[i].getAmount() > amt) {
|
||||
items[i].setAmount(items[i].getAmount() - amt);
|
||||
break;
|
||||
} else if (items[i].getAmount() == amt) {
|
||||
items[i] = null;
|
||||
break;
|
||||
} else {
|
||||
amt -= items[i].getAmount();
|
||||
items[i] = null;
|
||||
public int getAddable(Inventory inv, Material material) {
|
||||
int output = 0;
|
||||
int notempty = 0;
|
||||
for (int i = 0; i < inv.getSize(); ++i) {
|
||||
ItemStack is = inv.getItem(i);
|
||||
if (is != null) {
|
||||
++notempty;
|
||||
if (is.getType() == material) {
|
||||
int amount = is.getAmount();
|
||||
output += 64 - amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
inventory.setContents(items);
|
||||
return output + (inv.getSize() - notempty) * 64;
|
||||
}
|
||||
|
||||
private int getEmptySlots(Player p) {
|
||||
PlayerInventory inventory = p.getInventory();
|
||||
ItemStack[] cont = inventory.getContents();
|
||||
int i = 0;
|
||||
for (ItemStack item : cont)
|
||||
if (item != null && item.getType() != Material.AIR) {
|
||||
i++;
|
||||
public boolean isInvFull(Inventory inv) {
|
||||
return inv.firstEmpty() == -1;
|
||||
}
|
||||
|
||||
public int getTNTInside(Player p) {
|
||||
int result = 0;
|
||||
PlayerInventory pi = p.getInventory();
|
||||
ItemStack[] contents;
|
||||
for (int length = (contents = pi.getContents()).length, i = 0; i < length; ++i) {
|
||||
ItemStack is = contents[i];
|
||||
if (is != null && is.getType() == Material.TNT) {
|
||||
result += is.getAmount();
|
||||
}
|
||||
return 36 - i;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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,47 +24,38 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
|
||||
public class CmdWild extends FCommand {
|
||||
public static HashMap<Player, Integer> waitingTeleport;
|
||||
/**
|
||||
* @author droppinganvil
|
||||
*/
|
||||
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);}
|
||||
} 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;
|
||||
int tries = 0;
|
||||
@@ -84,28 +76,46 @@ public class CmdWild extends FCommand {
|
||||
}
|
||||
tries++;
|
||||
}
|
||||
if (!success) {p.sendMessage(TL.COMMAND_WILD_FAILED.toString());}
|
||||
if (!success) {
|
||||
p.sendMessage(TL.COMMAND_WILD_FAILED.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public void teleportPlayer(Player p, FLocation loc) {
|
||||
Location finalLoc;
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("Wild.Arrival.SpawnAbove")) {
|
||||
finalLoc = new Location(p.getWorld(), loc.getX(), p.getWorld().getHighestBlockYAt(Math.round(loc.getX()), Math.round(loc.getZ())) + FactionsPlugin.getInstance().getConfig().getInt("Wild.Arrival.SpawnAboveBlocks", 1), loc.getZ());
|
||||
} else {finalLoc = new Location(p.getWorld(), loc.getX(), p.getWorld().getHighestBlockYAt(Math.round(loc.getX()), Math.round(loc.getZ())), loc.getZ());}
|
||||
} else {
|
||||
finalLoc = new Location(p.getWorld(), loc.getX(), p.getWorld().getHighestBlockYAt(Math.round(loc.getX()), Math.round(loc.getZ())), loc.getZ());
|
||||
}
|
||||
p.teleport(finalLoc, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
setTeleporting(p);
|
||||
applyEffects(p);
|
||||
}
|
||||
|
||||
public void applyEffects(Player p) {
|
||||
for (String s : FactionsPlugin.getInstance().getConfig().getStringList("Wild.Arrival.Effects")) {
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.getByName(s), 40, 1));
|
||||
}
|
||||
}
|
||||
|
||||
public void setTeleporting(Player p) {
|
||||
teleporting.add(p);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> teleporting.remove(p), FactionsPlugin.getInstance().getConfig().getInt("Wild.Arrival.FallDamageWindow") * 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ 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.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -18,22 +20,28 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author droppinganvil
|
||||
*/
|
||||
//TODO StaticGUI
|
||||
public class WildGUI implements FactionGUI {
|
||||
Player player;
|
||||
FPlayer fplayer;
|
||||
HashMap<Integer, String> map;
|
||||
Inventory inv;
|
||||
|
||||
public WildGUI(Player player, FPlayer fplayer) {
|
||||
this.player = player;
|
||||
this.fplayer = fplayer;
|
||||
map = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(int slot, ClickType action) {
|
||||
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();
|
||||
@@ -44,18 +52,18 @@ public class WildGUI implements FactionGUI {
|
||||
@Override
|
||||
public void build() {
|
||||
inv = Bukkit.createInventory(this, FactionsPlugin.getInstance().getConfig().getInt("Wild.GUI.Size"), FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("Wild.GUI.Name")));
|
||||
ItemStack fillItem = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("Wild.GUI.FillMaterial")).parseItem();
|
||||
ItemStack fillItem = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("Wild.GUI.FillMaterial")).get().parseItem();
|
||||
ItemMeta meta = fillItem.getItemMeta();
|
||||
if(meta == null) return;
|
||||
if (meta == null) return;
|
||||
meta.setDisplayName("");
|
||||
fillItem.setItemMeta(meta);
|
||||
for (int fill = 0; fill < FactionsPlugin.getInstance().getConfig().getInt("Wild.GUI.Size"); ++fill) {
|
||||
inv.setItem(fill, fillItem);
|
||||
}
|
||||
for (String key : Objects.requireNonNull(FactionsPlugin.getInstance().getConfig().getConfigurationSection("Wild.Zones")).getKeys(false)) {
|
||||
ItemStack zoneItem = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("Wild.Zones." + key + ".Material")).parseItem();
|
||||
ItemStack zoneItem = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("Wild.Zones." + key + ".Material")).get().parseItem();
|
||||
ItemMeta zoneMeta = zoneItem.getItemMeta();
|
||||
if(zoneMeta == null) return;
|
||||
if (zoneMeta == null) return;
|
||||
List<String> lore = new ArrayList<>();
|
||||
for (String s : FactionsPlugin.getInstance().getConfig().getStringList("Wild.Zones." + key + ".Lore")) {
|
||||
lore.add(FactionsPlugin.getInstance().color(s));
|
||||
@@ -72,7 +80,9 @@ public class WildGUI implements FactionGUI {
|
||||
@NotNull
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
if (inv == null) {build();}
|
||||
if (inv == null) {
|
||||
build();
|
||||
}
|
||||
return inv;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,9 @@ import java.util.HashSet;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* @author droppinganvil
|
||||
*/
|
||||
public class Discord {
|
||||
//We dont want waitingLink to reset during reload so we are going to set it here
|
||||
public static HashMap<Integer, FPlayer> waitingLink;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.massivecraft.factions.discord;
|
||||
|
||||
/**
|
||||
* @author droppinganvil
|
||||
*/
|
||||
public class DiscordSetupAttempt {
|
||||
private Boolean success;
|
||||
private String reason;
|
||||
|
||||
166
src/main/java/com/massivecraft/factions/duels/Duel.java
Normal file
166
src/main/java/com/massivecraft/factions/duels/Duel.java
Normal file
@@ -0,0 +1,166 @@
|
||||
package com.massivecraft.factions.duels;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author droppinganvil
|
||||
*/
|
||||
public class Duel {
|
||||
private Faction faction1;
|
||||
private Faction faction2;
|
||||
private HashMap<FPlayer, Boolean> eliminationMap;
|
||||
private HashMap<FPlayer, Location> oldLocMap;
|
||||
|
||||
public Duel(Faction faction1, Faction faction2) {
|
||||
this.faction1 = faction1;
|
||||
this.faction2 = faction2;
|
||||
this.eliminationMap = new HashMap<>();
|
||||
this.oldLocMap = new HashMap<>();
|
||||
}
|
||||
|
||||
public Faction getFaction1() {
|
||||
return faction1;
|
||||
}
|
||||
|
||||
public Faction getFaction2() {
|
||||
return faction2;
|
||||
}
|
||||
|
||||
public Set<FPlayer> getEliminated() {
|
||||
Set<FPlayer> list = new HashSet<>();
|
||||
for (Map.Entry<FPlayer, Boolean> entry : eliminationMap.entrySet()) {
|
||||
if (entry.getValue()) list.add(entry.getKey());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public Set<FPlayer> getEliminated(Faction faction) {
|
||||
Set<FPlayer> list = new HashSet<>();
|
||||
for (Map.Entry<FPlayer, Boolean> entry : eliminationMap.entrySet()) {
|
||||
if (entry.getValue() && entry.getKey().getFaction().equals(faction)) list.add(entry.getKey());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public Set<FPlayer> getRemaining() {
|
||||
Set<FPlayer> list = new HashSet<>();
|
||||
for (Map.Entry<FPlayer, Boolean> entry : eliminationMap.entrySet()) {
|
||||
if (!entry.getValue()) list.add(entry.getKey());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public Set<FPlayer> getRemaining(Faction faction) {
|
||||
Set<FPlayer> list = new HashSet<>();
|
||||
for (Map.Entry<FPlayer, Boolean> entry : eliminationMap.entrySet()) {
|
||||
if (!entry.getValue() && entry.getKey().getFaction().equals(faction)) list.add(entry.getKey());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public void handleExit(FPlayer fplayer, Boolean death) {
|
||||
if (death) {
|
||||
eliminationMap.replace(fplayer, false, true);
|
||||
fplayer.getPlayer().spigot().respawn();
|
||||
}
|
||||
fplayer.getPlayer().teleport(oldLocMap.get(fplayer), PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
for (Map.Entry<Integer, ItemStack> entry : fplayer.getOldInv().entrySet()) {
|
||||
fplayer.getPlayer().getInventory().setItem(entry.getKey(), entry.getValue());
|
||||
}
|
||||
fplayer.setOldInv(null);
|
||||
fplayer.setInDuel(false);
|
||||
if (getClearWinner() != null) {
|
||||
handleEnd();
|
||||
}
|
||||
}
|
||||
|
||||
public void handleEnd() {
|
||||
if (FactionsPlugin.getInstance().getConfig().getBoolean("Duels.Broadcast.BroadcastResult.Enabled")) {
|
||||
Bukkit.broadcastMessage(getEndMessage());
|
||||
}
|
||||
for (FPlayer fp : getRemaining()) {
|
||||
handleExit(fp, false);
|
||||
}
|
||||
Map.Entry<Faction, Faction> fvf = (Map.Entry<Faction, Faction>) Duels.duelQueue.entrySet().toArray()[0];
|
||||
if (fvf != null) {
|
||||
Duels.duel = new Duel(fvf.getKey(), fvf.getValue());
|
||||
Duels.preparingDuel = true;
|
||||
Duels.acceptedDuel.clear();
|
||||
Duels.sendRequests(faction1);
|
||||
Duels.sendRequests(faction2);
|
||||
}
|
||||
}
|
||||
|
||||
public Faction getClearWinner() {
|
||||
Set<FPlayer> team1r = getRemaining(faction1);
|
||||
Set<FPlayer> team2r = getRemaining(faction2);
|
||||
if (team1r.isEmpty() && !team2r.isEmpty()) return faction2;
|
||||
if (team2r.isEmpty() && !team1r.isEmpty()) return faction1;
|
||||
return null;
|
||||
}
|
||||
|
||||
private Faction getWinning(Set<FPlayer> s1, Set<FPlayer> s2) {
|
||||
if (s1.size() > s2.size()) return faction1;
|
||||
return faction2;
|
||||
}
|
||||
|
||||
public String getEndMessage() {
|
||||
String temp;
|
||||
Set<FPlayer> team1r = getRemaining(faction1);
|
||||
Set<FPlayer> team2r = getRemaining(faction2);
|
||||
if (team1r.size() == team2r.size()) {
|
||||
//Tied
|
||||
temp = FactionsPlugin.getInstance().getConfig().getString("Duels.Broadcast.BroadcastResult.FormatTie");
|
||||
} else {
|
||||
temp = FactionsPlugin.getInstance().getConfig().getString("Duels.Broadcast.BroadcastResult.Format");
|
||||
}
|
||||
Faction winner = getWinning(team1r, team2r);
|
||||
return ChatColor.translateAlternateColorCodes('&', temp
|
||||
.replace("{team1_tag}", faction1.getTag())
|
||||
.replace("{team2_tag}", faction2.getTag())
|
||||
.replace("{remaining}", String.valueOf(getRemaining(winner).size()))
|
||||
.replace("{tag}", winner.getTag())
|
||||
.replace("{losers_tag}", winner == faction1 ? faction2.getTag() : faction1.getTag()));
|
||||
}
|
||||
|
||||
public String getDeathMessage(Player player) {
|
||||
return ChatColor.translateAlternateColorCodes('&',
|
||||
FactionsPlugin.getInstance().getConfig().getString("Duels.Broadcast.BroadcastKill.Format")
|
||||
.replace("{team1_remaining}", String.valueOf(getRemaining(getFaction1()).size()))
|
||||
.replace("{team2_remaining}", String.valueOf(getRemaining(getFaction2()).size()))
|
||||
.replace("{team1_eliminated}", String.valueOf(getEliminated(getFaction1()).size()))
|
||||
.replace("{team2_eliminated}", String.valueOf(getEliminated(getFaction2()).size()))
|
||||
.replace("{team1_tag}", faction1.getTag())
|
||||
.replace("{team2_tag}", faction2.getTag())
|
||||
.replace("{eliminated_name}", player.getName()));
|
||||
}
|
||||
|
||||
public HashMap<FPlayer, Location> getLocMap() {
|
||||
return oldLocMap;
|
||||
}
|
||||
|
||||
public void addFPlayer(FPlayer fp) {
|
||||
oldLocMap.put(fp, fp.getPlayer().getLocation());
|
||||
eliminationMap.put(fp, false);
|
||||
}
|
||||
|
||||
public void start() {
|
||||
Duels.preparingDuel = false;
|
||||
for (FPlayer fplayer : Duels.acceptedDuel) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
73
src/main/java/com/massivecraft/factions/duels/Duels.java
Normal file
73
src/main/java/com/massivecraft/factions/duels/Duels.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package com.massivecraft.factions.duels;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author droppinganvil
|
||||
*/
|
||||
public class Duels {
|
||||
public static boolean enabled = true;
|
||||
public static long targetTimeout = Integer.toUnsignedLong(FactionsPlugin.getInstance().getConfig().getInt("Duels.WaitTime")) * 1000;
|
||||
public static ConcurrentHashMap<FPlayer, Long> guiMap = new ConcurrentHashMap<>();
|
||||
public static HashSet<FPlayer> acceptedDuel = new HashSet<>();
|
||||
public static HashMap<Faction, Faction> duelQueue = new HashMap<>();
|
||||
public static Boolean preparingDuel = false;
|
||||
public static Duel duel;
|
||||
public static HashSet<SpawnPoint> spawnPoints = new HashSet<>();
|
||||
|
||||
private static void startGUITask() {
|
||||
Bukkit.getScheduler().scheduleAsyncRepeatingTask(FactionsPlugin.instance, () -> {
|
||||
for (Map.Entry<FPlayer, Long> entry : guiMap.entrySet()) {
|
||||
if (System.currentTimeMillis() - entry.getValue() <= targetTimeout) RequestGUI.closeSync(true, entry.getKey());
|
||||
}
|
||||
}, 0L, 20L);
|
||||
}
|
||||
|
||||
public void setup() {
|
||||
enabled = FactionsPlugin.getInstance().getConfig().getBoolean("Duels.Enabled", true);
|
||||
if (enabled) startGUITask();
|
||||
loadSpawnPoints();
|
||||
|
||||
}
|
||||
|
||||
public void loadSpawnPoints() {
|
||||
spawnPoints.clear();
|
||||
loadTeamSpawnPoints(1);
|
||||
loadTeamSpawnPoints(2);
|
||||
}
|
||||
|
||||
public void loadTeamSpawnPoints(Integer i) {
|
||||
FileConfiguration config = FactionsPlugin.getInstance().getConfig();
|
||||
String team = "Team" + i;
|
||||
for (String key : config.getConfigurationSection("Duels.SpawnPoints." + team).getKeys(false)) {
|
||||
spawnPoints.add(new SpawnPoint (i, getSpawnPointLocation(team, key, config), Integer.parseInt(key)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Location getSpawnPointLocation(String team, String key, FileConfiguration config) {
|
||||
String[] locKeyArray = config.getString("Duels.SpawnPoints." + team + "." + key).split(",");
|
||||
return new Location(Bukkit.getWorld(locKeyArray[0]), Double.parseDouble(locKeyArray[1]), Double.parseDouble(locKeyArray[2]), Double.parseDouble(locKeyArray[3]));
|
||||
}
|
||||
|
||||
public static void sendRequests(Faction faction) {
|
||||
for (FPlayer fplayer : faction.getFPlayers()) {
|
||||
if (fplayer.isOnline()) {
|
||||
fplayer.getPlayer().openInventory(RequestGUI.inv);
|
||||
guiMap.put(fplayer, System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
121
src/main/java/com/massivecraft/factions/duels/RequestGUI.java
Normal file
121
src/main/java/com/massivecraft/factions/duels/RequestGUI.java
Normal file
@@ -0,0 +1,121 @@
|
||||
package com.massivecraft.factions.duels;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.util.StaticGUI;
|
||||
import com.massivecraft.factions.util.Sync.SyncExecutor;
|
||||
import com.massivecraft.factions.util.Sync.SyncTask;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* @author droppinganvil
|
||||
*/
|
||||
public class RequestGUI implements StaticGUI {
|
||||
private static ItemStack fillItem;
|
||||
private static RequestResponse fallback;
|
||||
FileConfiguration config = FactionsPlugin.getInstance().getConfig();
|
||||
public static HashMap<Integer, RequestResponse> responseMap = new HashMap<>();
|
||||
public static Inventory inv;
|
||||
private static RequestGUI instance;
|
||||
public static RequestGUI getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public RequestGUI() {
|
||||
if (instance == null) {
|
||||
instance = this;
|
||||
}
|
||||
if (fillItem == null) {
|
||||
fillItem = XMaterial.matchXMaterial(config.getString("Duels.GUI.Fill-Item.Material")).get().parseItem();
|
||||
ItemMeta fillMeta = fillItem.getItemMeta();
|
||||
fillMeta.setDisplayName(" ");
|
||||
fillItem.setItemMeta(fillMeta);
|
||||
}
|
||||
if (fallback == null) {
|
||||
try {
|
||||
fallback = RequestResponse.valueOf(config.getString("Duels.GUI.Fill-Item.Response"));
|
||||
} catch (EnumConstantNotPresentException e) {
|
||||
FactionsPlugin.getInstance().getLogger().log(Level.WARNING, "FallbackResponse is invalid! Using Ignored");
|
||||
fallback = RequestResponse.Ignored;
|
||||
}
|
||||
}
|
||||
if (inv == null) {
|
||||
inv = Bukkit.createInventory(this, 27, "Join Faction Duel");
|
||||
int fi = 0;
|
||||
while (fi != 26) {
|
||||
inv.setItem(fi, fillItem);
|
||||
fi++;
|
||||
}
|
||||
for (String key : config.getConfigurationSection("Duels.GUI.Items").getKeys(false)) {
|
||||
ItemStack item = XMaterial.matchXMaterial(config.getString("Duels.GUI.Items." + key + ".Material")).get().parseItem();
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString("Duels.GUI.Items." + key + ".Name")));
|
||||
List<String> lore = new ArrayList<>();
|
||||
for (String loreEntry : config.getStringList("Duels.GUI.Items." + key + ".Lore")) {
|
||||
lore.add(ChatColor.translateAlternateColorCodes('&', loreEntry));
|
||||
}
|
||||
itemMeta.setLore(lore);
|
||||
item.setItemMeta(itemMeta);
|
||||
int slot = Integer.parseInt(key);
|
||||
responseMap.put(slot, RequestResponse.valueOf(config.getString("Duels.GUI.Items." + key + ".Response")));
|
||||
inv.setItem(slot, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void click(int slot, ClickType action, Player player) {
|
||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||
if (action != ClickType.LEFT) {
|
||||
processResponse(fallback, fPlayer);
|
||||
} else {
|
||||
processResponse(responseMap.get(slot), fPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
public static void processResponse(RequestResponse response, FPlayer fPlayer) {
|
||||
switch (response) {
|
||||
case Accepted:
|
||||
fPlayer.getFaction().broadcast(TL.DUEL_REQUEST_ACCEPTED_PLAYER.format(fPlayer.getNameAndTitle()));
|
||||
Duels.acceptedDuel.add(fPlayer);
|
||||
close(false, fPlayer);
|
||||
break;
|
||||
case Rejected:
|
||||
fPlayer.getFaction().broadcast(TL.DUEL_REQUEST_REJECTED_PLAYER.format(fPlayer.getNameAndTitle()));
|
||||
close(false, fPlayer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void close(Boolean reject, FPlayer fPlayer) {
|
||||
if (reject) {
|
||||
processResponse(RequestResponse.Rejected, fPlayer);
|
||||
}
|
||||
fPlayer.getPlayer().closeInventory();
|
||||
Duels.guiMap.remove(fPlayer);
|
||||
}
|
||||
|
||||
public static void closeSync(Boolean reject, FPlayer fPlayer) {
|
||||
SyncExecutor.taskQueue.add(new SyncTask(RequestGUI.getInstance(), "close", reject, fPlayer));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inv;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.massivecraft.factions.duels;
|
||||
|
||||
/**
|
||||
* @author droppinganvil
|
||||
*/
|
||||
public enum RequestResponse {
|
||||
Accepted,
|
||||
Rejected,
|
||||
Ignored,
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.massivecraft.factions.duels;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class SpawnPoint {
|
||||
private Integer team;
|
||||
private Integer id;
|
||||
private Location location;
|
||||
|
||||
public SpawnPoint(Integer team, Location location, Integer id) {
|
||||
this.team = team;
|
||||
this.location = location;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getTeam() {
|
||||
return team;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public Integer getID() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public class FPlayerRoleChangeEvent extends FactionPlayerEvent implements Cancel
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return false;
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -73,6 +73,9 @@ public class EngineDynmap {
|
||||
}
|
||||
|
||||
public static String escapeHtml(String string) {
|
||||
if (string == null) {
|
||||
return "";
|
||||
}
|
||||
StringBuilder out = new StringBuilder(Math.max(16, string.length()));
|
||||
for (int i = 0; i < string.length(); i++) {
|
||||
char c = string.charAt(i);
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@@ -161,18 +162,20 @@ public class FactionsBlockListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
Faction at = Board.getInstance().getFactionAt(new FLocation(event.getBlockPlaced()));
|
||||
|
||||
if (!event.canBuild()) return;
|
||||
if (event.getBlockPlaced().getType() == Material.FIRE) return;
|
||||
|
||||
boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial());
|
||||
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial()) && Conf.spawnerLock) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString()));
|
||||
|
||||
if (isSpawner) {
|
||||
if (Conf.spawnerLock) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,7 +268,8 @@ public class FactionsBlockListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onHopperPlace(BlockPlaceEvent e) {
|
||||
if (e.getItemInHand().getType() != Material.HOPPER && !FactionsPlugin.instance.getConfig().getBoolean("fvault.No-Hoppers-near-vault")) return;
|
||||
if (e.getItemInHand().getType() != Material.HOPPER && !FactionsPlugin.instance.getConfig().getBoolean("fvault.No-Hoppers-near-vault"))
|
||||
return;
|
||||
Faction factionAt = Board.getInstance().getFactionAt(new FLocation(e.getBlockPlaced().getLocation()));
|
||||
if (factionAt.isWilderness() || factionAt.getVault() == null) return;
|
||||
FPlayer fme = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
||||
@@ -356,11 +360,7 @@ public class FactionsBlockListener implements Listener {
|
||||
return;
|
||||
}
|
||||
for (FPlayer fplayer : fme.getFaction().getFPlayers()) {
|
||||
if (XMaterial.isVersionOrHigher(XMaterial.MinecraftVersion.VERSION_1_9)) {
|
||||
fplayer.getPlayer().sendTitle(FactionsPlugin.getInstance().color(fme.getTag() + " Placed A WarBanner!"), FactionsPlugin.getInstance().color("&7use &c/f tpbanner&7 to tp to the banner!"), 10, 70, 20);
|
||||
} else {
|
||||
fplayer.getPlayer().sendTitle(FactionsPlugin.getInstance().color(fme.getTag() + " Placed A WarBanner!"), FactionsPlugin.getInstance().color("&7use &c/f tpbanner&7 to tp to the banner!"));
|
||||
}
|
||||
fplayer.getPlayer().sendTitle(FactionsPlugin.getInstance().color(fme.getTag() + " Placed A WarBanner!"), FactionsPlugin.getInstance().color("&7use &c/f tpbanner&7 to tp to the banner!"));
|
||||
}
|
||||
bannerCooldownMap.put(fme.getTag(), true);
|
||||
FactionsBlockListener.bannerLocations.put(fme.getTag(), e.getBlockPlaced().getLocation());
|
||||
@@ -380,7 +380,7 @@ public class FactionsBlockListener implements Listener {
|
||||
int radius = FactionsPlugin.getInstance().getConfig().getInt("fbanners.Banner-Effect-Radius");
|
||||
List<String> effects = FactionsPlugin.getInstance().getConfig().getStringList("fbanners.Effects");
|
||||
int affectorTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> {
|
||||
for (Entity e1 : banner.getLocation().getWorld().getNearbyEntities(banner.getLocation(), radius, 255.0, radius)) {
|
||||
for (Entity e1 : Objects.requireNonNull(banner.getLocation().getWorld()).getNearbyEntities(banner.getLocation(), radius, 255.0, radius)) {
|
||||
if (e1 instanceof Player) {
|
||||
Player player = (Player) e1;
|
||||
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
|
||||
@@ -389,7 +389,7 @@ public class FactionsBlockListener implements Listener {
|
||||
}
|
||||
for (String effect : effects) {
|
||||
String[] components = effect.split(":");
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(components[0]), 100, Integer.parseInt(components[1])));
|
||||
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);
|
||||
@@ -493,27 +493,45 @@ 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() == XMaterial.SPAWNER.parseMaterial();
|
||||
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), !isSpawner ? "destroy" : "mine spawners", false)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (block != null && isSpawner) {
|
||||
ItemStack item = new ItemStack(block.getType(), 1, (short) 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);
|
||||
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 (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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,8 @@ import com.massivecraft.factions.struct.ChatMode;
|
||||
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.VisualizeUtil;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.util.*;
|
||||
import com.massivecraft.factions.util.Wait.WaitExecutor;
|
||||
import com.massivecraft.factions.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.persist.MemoryFPlayer;
|
||||
@@ -338,7 +336,7 @@ public class FactionsPlayerListener implements Listener {
|
||||
return PermissableAction.DOOR;
|
||||
if (material.name().toUpperCase().contains("BUTTON") || material.name().toUpperCase().contains("PRESSURE") || material.name().contains("DIODE") || material.name().contains("COMPARATOR"))
|
||||
return PermissableAction.BUTTON;
|
||||
if (FactionsPlugin.instance.mc113 || FactionsPlugin.instance.mc114) {
|
||||
if (FactionsPlugin.instance.mc113 || FactionsPlugin.instance.mc114 || FactionsPlugin.getInstance().mc115) {
|
||||
switch (material) {
|
||||
case LEVER:
|
||||
return PermissableAction.LEVER;
|
||||
@@ -381,6 +379,8 @@ public class FactionsPlayerListener implements Listener {
|
||||
case TRAPPED_CHEST:
|
||||
case CHEST_MINECART:
|
||||
|
||||
case BARREL:
|
||||
|
||||
case SHULKER_BOX:
|
||||
case BLACK_SHULKER_BOX:
|
||||
case BLUE_SHULKER_BOX:
|
||||
@@ -668,7 +668,7 @@ public class FactionsPlayerListener implements Listener {
|
||||
if (!fPlayer.checkIfNearbyEnemies()) {
|
||||
FLocation myFloc = new FLocation(player.getLocation());
|
||||
if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
|
||||
if (!CmdFly.checkBypassPerms(fPlayer, player, Board.getInstance().getFactionAt(myFloc))) {
|
||||
if (!CmdFly.checkFly(fPlayer, player, Board.getInstance().getFactionAt(myFloc))) {
|
||||
fPlayer.setFFlying(false, false);
|
||||
CmdFly.flyMap.remove(name);
|
||||
}
|
||||
@@ -819,7 +819,7 @@ public class FactionsPlayerListener implements Listener {
|
||||
Material type;
|
||||
if (event.getItem() != null) {
|
||||
// Convert 1.8 Material Names -> 1.14
|
||||
type = XMaterial.matchXMaterial(event.getItem().getType().toString()).parseMaterial();
|
||||
type = XMaterial.matchXMaterial(event.getItem().getType().toString()).get().parseMaterial();
|
||||
} else {
|
||||
type = null;
|
||||
}
|
||||
@@ -918,17 +918,22 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onLogoutMove(PlayerMoveEvent e) {
|
||||
LogoutHandler handler = LogoutHandler.getByName(e.getPlayer().getName());
|
||||
|
||||
if (Objects.requireNonNull(e.getTo()).getBlockX() == e.getFrom().getBlockX() &&
|
||||
e.getTo().getBlockY() == e.getFrom().getBlockY() &&
|
||||
e.getTo().getBlockZ() == e.getFrom().getBlockZ())
|
||||
return;
|
||||
|
||||
if (handler.isLogoutActive(e.getPlayer())) {
|
||||
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
|
||||
@@ -940,10 +945,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);
|
||||
@@ -971,11 +973,15 @@ public class FactionsPlayerListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
((FactionGUI) event.getClickedInventory().getHolder()).onClick(event.getRawSlot(), event.getClick());
|
||||
}
|
||||
if (event.getClickedInventory().getHolder() instanceof StaticGUI) {
|
||||
event.setCancelled(true);
|
||||
((StaticGUI) event.getClickedInventory().getHolder()).click(event.getRawSlot(), event.getClick(), (Player) event.getWhoClicked());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerMoveGUI(InventoryDragEvent event) {
|
||||
if (event.getInventory().getHolder() instanceof FactionGUI) event.setCancelled(true);
|
||||
if (event.getInventory().getHolder() instanceof FactionGUI || event.getInventory().getHolder() instanceof StaticGUI) event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
@@ -1060,13 +1066,13 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
FPlayer fp = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
||||
|
||||
if(fp == null) return;
|
||||
if (fp == null) return;
|
||||
|
||||
if (fp.getChatMode() != ChatMode.FACTION) {
|
||||
return;
|
||||
}
|
||||
Faction f = fp.getFaction();
|
||||
if(f == null) return;
|
||||
if (f == null) return;
|
||||
if (f.isSystemFaction()) {
|
||||
return;
|
||||
}
|
||||
@@ -1085,7 +1091,7 @@ public class FactionsPlayerListener implements Listener {
|
||||
}
|
||||
} else {
|
||||
for (Member m : t.getMembers()) {
|
||||
if (m.getEffectiveName().contains(target) | m.getUser().getName().contains(target)){
|
||||
if (m.getEffectiveName().contains(target) | m.getUser().getName().contains(target)) {
|
||||
targets.add("@" + m.getUser().getName() + "#" + m.getUser().getDiscriminator());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class MissionGUI implements FactionGUI {
|
||||
if (configurationSection == null) {
|
||||
return;
|
||||
}
|
||||
ItemStack fillItem = XMaterial.matchXMaterial(configurationSection.getString("FillItem.Material")).parseItem();
|
||||
ItemStack fillItem = XMaterial.matchXMaterial(configurationSection.getString("FillItem.Material")).get().parseItem();
|
||||
ItemMeta fillmeta = fillItem.getItemMeta();
|
||||
fillmeta.setDisplayName("");
|
||||
fillItem.setItemMeta(fillmeta);
|
||||
@@ -109,7 +109,7 @@ public class MissionGUI implements FactionGUI {
|
||||
ConfigurationSection section = configurationSection.getConfigurationSection(key);
|
||||
int slot = section.getInt("Slot");
|
||||
|
||||
ItemStack itemStack = XMaterial.matchXMaterial(section.getString("Material")).parseItem();
|
||||
ItemStack itemStack = XMaterial.matchXMaterial(section.getString("Material")).get().parseItem();
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', section.getString("Name")));
|
||||
List<String> loreLines = new ArrayList<>();
|
||||
@@ -134,7 +134,7 @@ public class MissionGUI implements FactionGUI {
|
||||
if (plugin.getConfig().getBoolean("Randomization.Enabled")) {
|
||||
ItemStack start;
|
||||
ItemMeta meta;
|
||||
start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Allowed.Material")).parseItem();
|
||||
start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Allowed.Material")).get().parseItem();
|
||||
meta = start.getItemMeta();
|
||||
meta.setDisplayName(plugin.color(plugin.getConfig().getString("Randomization.Start-Item.Allowed.Name")));
|
||||
List<String> loree = new ArrayList<>();
|
||||
@@ -144,7 +144,7 @@ public class MissionGUI implements FactionGUI {
|
||||
meta.setLore(loree);
|
||||
start.setItemMeta(meta);
|
||||
if (fPlayer.getFaction().getCompletedMissions().size() >= configurationSection.getKeys(false).size() - 1 && plugin.getConfig().getBoolean("DenyMissionsMoreThenOnce")) {
|
||||
start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Material")).parseItem();
|
||||
start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Material")).get().parseItem();
|
||||
meta = start.getItemMeta();
|
||||
meta.setDisplayName(plugin.color(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Name")));
|
||||
List<String> lore = new ArrayList<>();
|
||||
@@ -155,7 +155,7 @@ public class MissionGUI implements FactionGUI {
|
||||
start.setItemMeta(meta);
|
||||
}
|
||||
if (fPlayer.getFaction().getMissions().size() >= plugin.getConfig().getInt("MaximumMissionsAllowedAtOnce")) {
|
||||
start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Material")).parseItem();
|
||||
start = XMaterial.matchXMaterial(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Material")).get().parseItem();
|
||||
meta = start.getItemMeta();
|
||||
meta.setDisplayName(plugin.color(plugin.getConfig().getString("Randomization.Start-Item.Disallowed.Name")));
|
||||
List<String> lore = new ArrayList<>();
|
||||
|
||||
@@ -47,7 +47,7 @@ public class ShopGUIFrame {
|
||||
for (int a = 1; a <= items; a++) {
|
||||
String s = a + "";
|
||||
int slot = ShopConfig.getShop().getInt("items." + s + ".slot");
|
||||
Material material = XMaterial.matchXMaterial(ShopConfig.getShop().getString("items." + s + ".block")).parseMaterial();
|
||||
Material material = XMaterial.matchXMaterial(ShopConfig.getShop().getString("items." + s + ".block")).get().parseMaterial();
|
||||
int cost = ShopConfig.getShop().getInt("items." + s + ".cost");
|
||||
String name = ShopConfig.getShop().getString("items." + s + ".name");
|
||||
boolean glowing = ShopConfig.getShop().getBoolean("items." + s + ".glowing");
|
||||
@@ -93,7 +93,7 @@ public class ShopGUIFrame {
|
||||
|
||||
private ItemStack buildDummyItem(Faction f) {
|
||||
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("F-Shop.GUI.dummy-item");
|
||||
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem();
|
||||
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null) {
|
||||
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
|
||||
|
||||
@@ -44,8 +44,8 @@ public enum Permission {
|
||||
DISBAND_ANY("disband.any"),
|
||||
DISCORD("discord"),
|
||||
DRAIN("drain"),
|
||||
FLY("fly"),
|
||||
FLY_WILD("fly.wilderness"),
|
||||
FLY_FLY("fly"),
|
||||
FLY_WILDERNESS("fly.wilderness"),
|
||||
FLY_SAFEZONE("fly.safezone"),
|
||||
FLY_WARZONE("fly.warzone"),
|
||||
FLY_ENEMY("fly.enemy"),
|
||||
|
||||
@@ -210,7 +210,7 @@ public enum Relation implements Permissable {
|
||||
String displayName = replacePlaceholders(RELATION_CONFIG.getString("placeholder-item.name", ""));
|
||||
List<String> lore = new ArrayList<>();
|
||||
|
||||
Material material = XMaterial.matchXMaterial(RELATION_CONFIG.getString("materials." + name().toLowerCase())).parseMaterial();
|
||||
Material material = XMaterial.matchXMaterial(RELATION_CONFIG.getString("materials." + name().toLowerCase())).get().parseMaterial();
|
||||
if (material == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public enum Role implements Permissable {
|
||||
String displayName = replacePlaceholders(RELATION_CONFIG.getString("placeholder-item.name", ""));
|
||||
List<String> lore = new ArrayList<>();
|
||||
|
||||
Material material = XMaterial.matchXMaterial(RELATION_CONFIG.getString("materials." + name().toLowerCase(), "STAINED_CLAY")).parseMaterial();
|
||||
Material material = XMaterial.matchXMaterial(RELATION_CONFIG.getString("materials." + name().toLowerCase(), "STAINED_CLAY")).get().parseMaterial();
|
||||
if (material == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@ public enum FactionTag implements Tag {
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
|
||||
ANNOUNCEMENT("{announcement}", (fac) -> { return String.valueOf(fac.getAnnouncements()); }),
|
||||
PEACEFUL("{peaceful}", (fac) -> fac.isPeaceful() ? Conf.colorNeutral + TL.COMMAND_SHOW_PEACEFUL.toString() : ""),
|
||||
PERMANENT("permanent", (fac) -> fac.isPermanent() ? "permanent" : "{notPermanent}"), // no braces needed
|
||||
LAND_VALUE("{land-value}", (fac) -> Econ.shouldBeUsed() ? Econ.moneyString(Econ.calculateTotalLandValue(fac.getLandRounded())) : Tag.isMinimalShow() ? null : TL.ECON_OFF.format("value")),
|
||||
@@ -61,6 +63,19 @@ public enum FactionTag implements Tag {
|
||||
}
|
||||
return Tag.isMinimalShow() ? null : TL.ECON_OFF.format("balance");
|
||||
}),
|
||||
TNT_BALANCE("{tnt-balance}", (fac) -> {
|
||||
if (FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) {
|
||||
return String.valueOf(fac.getTnt());
|
||||
}
|
||||
return Tag.isMinimalShow() ? null : "";
|
||||
}),
|
||||
TNT_MAX("{tnt-max-balance}", (fac) -> {
|
||||
if (FactionsPlugin.instance.getConfig().getBoolean("ftnt.Enabled")) {
|
||||
return String.valueOf(fac.getTntBankLimit());
|
||||
}
|
||||
return Tag.isMinimalShow() ? null : "";
|
||||
}),
|
||||
|
||||
ALLIES_COUNT("{allies}", (fac) -> String.valueOf(fac.getRelationCount(Relation.ALLY))),
|
||||
ENEMIES_COUNT("{enemies}", (fac) -> String.valueOf(fac.getRelationCount(Relation.ENEMY))),
|
||||
TRUCES_COUNT("{truces}", (fac) -> String.valueOf(fac.getRelationCount(Relation.TRUCE))),
|
||||
@@ -80,6 +95,8 @@ public enum FactionTag implements Tag {
|
||||
return String.valueOf(fac.getFPlayersWhereOnline(false).size());
|
||||
}
|
||||
}),
|
||||
FACTION_STRIKES("{faction-strikes}",(fac) -> String.valueOf(fac.getStrikes())),
|
||||
FACTION_POINTS("{faction-points}", (fac) -> String.valueOf(fac.getPoints())),
|
||||
FACTION_SIZE("{members}", (fac) -> String.valueOf(fac.getFPlayers().size())),
|
||||
FACTION_KILLS("{faction-kills}", (fac) -> String.valueOf(fac.getKills())),
|
||||
FACTION_DEATHS("{faction-deaths}", (fac) -> String.valueOf(fac.getDeaths())),
|
||||
|
||||
@@ -100,7 +100,7 @@ public enum FancyTag implements Tag {
|
||||
return tag.getMessage(text, faction, player, groupMap);
|
||||
}
|
||||
}
|
||||
return Collections.EMPTY_LIST; // We really shouldn't be here.
|
||||
return Collections.emptyList(); // We really shouldn't be here.
|
||||
}
|
||||
|
||||
public static boolean anyMatch(String text) {
|
||||
@@ -174,7 +174,7 @@ public enum FancyTag implements Tag {
|
||||
return test != null && test.contains(this.tag);
|
||||
}
|
||||
|
||||
public List<FancyMessage> getMessage(String text, Faction faction, FPlayer player, Map<UUID, String> groupMap) {
|
||||
public List getMessage(String text, Faction faction, FPlayer player, Map<UUID, String> groupMap) {
|
||||
if (!this.foundInString(text)) {
|
||||
return Collections.EMPTY_LIST; // We really, really shouldn't be here.
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ public enum GeneralTag implements Tag {
|
||||
MAX_ALLIES("{max-allies}", () -> getRelation("ally")),
|
||||
MAX_ENEMIES("{max-enemies}", () -> getRelation("enemy")),
|
||||
MAX_TRUCES("{max-truces}", () -> getRelation("truce")),
|
||||
FACTIONLESS("factionless", () -> String.valueOf(FPlayers.getInstance().getOnlinePlayers().stream().filter(p -> !p.hasFaction()).count())),
|
||||
FACTIONLESS_TOTAL("factionless-total", () -> String.valueOf(FPlayers.getInstance().getAllFPlayers().stream().filter(p -> !p.hasFaction()).count())),
|
||||
FACTIONLESS("{factionless}", () -> String.valueOf(FPlayers.getInstance().getOnlinePlayers().stream().filter(p -> !p.hasFaction()).count())),
|
||||
FACTIONLESS_TOTAL("{factionless-total}", () -> String.valueOf(FPlayers.getInstance().getAllFPlayers().stream().filter(p -> !p.hasFaction()).count())),
|
||||
TOTAL_ONLINE("{total-online}", () -> String.valueOf(Bukkit.getOnlinePlayers().size())),
|
||||
;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.massivecraft.factions.util;
|
||||
import com.massivecraft.factions.*;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
import com.massivecraft.factions.tag.FactionTag;
|
||||
import com.massivecraft.factions.tag.Tag;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
@@ -133,8 +134,14 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
|
||||
return faction.isPeaceful() ? Conf.colorNeutral + TL.COMMAND_SHOW_PEACEFUL.toString() : "";
|
||||
case "faction_tntbank_balance":
|
||||
return String.valueOf(faction.getTnt());
|
||||
case "faction_tnt_max_balance":
|
||||
return FactionTag.TNT_MAX.replace(FactionTag.TNT_MAX.getTag(), faction);
|
||||
case "faction_points":
|
||||
return fPlayer.hasFaction() ? String.valueOf(faction.getPoints()) : "0";
|
||||
case "discord_acount":
|
||||
return fPlayer.discordSetup() ? String.valueOf(fPlayer.discordUserID()) : "Not Linked";
|
||||
case "faction_discord":
|
||||
return fPlayer.hasFaction() ? String.valueOf(faction.getDiscord()) : "Not Linked";
|
||||
case "faction_powerboost":
|
||||
double powerBoost = faction.getPowerBoost();
|
||||
return (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_SHOW_BONUS.toString() : TL.COMMAND_SHOW_PENALTY.toString()) + powerBoost + ")";
|
||||
@@ -172,6 +179,8 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
|
||||
return String.valueOf(faction.getFPlayers().size() - faction.getOnlinePlayers().size());
|
||||
case "faction_size":
|
||||
return String.valueOf(faction.getFPlayers().size());
|
||||
case "faction_announcement":
|
||||
return String.valueOf(faction.getAnnouncements());
|
||||
case "faction_kills":
|
||||
return String.valueOf(faction.getKills());
|
||||
case "faction_deaths":
|
||||
|
||||
@@ -72,7 +72,7 @@ public class FactionWarpsFrame {
|
||||
|
||||
private ItemStack buildWarpAsset(final Map.Entry<String, LazyLocation> warp, final Faction faction) {
|
||||
final ConfigurationSection config = this.section.getConfigurationSection("warp-item");
|
||||
final ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem();
|
||||
final ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
||||
final ItemMeta meta = item.getItemMeta();
|
||||
meta.setLore(FactionsPlugin.getInstance().colorList(FactionsPlugin.getInstance().replacePlaceholders(config.getStringList("Lore"), new Placeholder("{warp-protected}", faction.hasWarpPassword(warp.getKey()) ? "Enabled" : "Disabled"), new Placeholder("{warp-cost}", FactionsPlugin.getInstance().getConfig().getBoolean("warp-cost.enabled", false) ? Integer.toString(FactionsPlugin.getInstance().getConfig().getInt("warp-cost.warp", 5)) : "Disabled"))));
|
||||
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name").replace("{warp}", warp.getKey())));
|
||||
@@ -82,7 +82,7 @@ public class FactionWarpsFrame {
|
||||
|
||||
private ItemStack buildDummyItem() {
|
||||
final ConfigurationSection config = this.section.getConfigurationSection("dummy-item");
|
||||
final ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem();
|
||||
final ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
||||
final ItemMeta meta = item.getItemMeta();
|
||||
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
|
||||
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
|
||||
|
||||
@@ -21,14 +21,9 @@ public class ItemBuilder {
|
||||
this.meta = item.getItemMeta();
|
||||
}
|
||||
|
||||
public ItemBuilder(Material material, int amount, int durability) {
|
||||
this(new ItemStack(material, amount, (short) durability));
|
||||
}
|
||||
|
||||
public ItemBuilder(Material material, int amount) {
|
||||
this(material, amount, 0);
|
||||
this(new ItemStack(material, amount));
|
||||
}
|
||||
|
||||
public ItemBuilder(Material material) {
|
||||
this(material, 1);
|
||||
}
|
||||
|
||||
27
src/main/java/com/massivecraft/factions/util/Pair.java
Normal file
27
src/main/java/com/massivecraft/factions/util/Pair.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.massivecraft.factions.util;
|
||||
|
||||
/**
|
||||
* Factions - Developed by FactionsUUID Team.
|
||||
*/
|
||||
public class Pair<Left, Right> {
|
||||
|
||||
public static <Left, Right> Pair<Left, Right> of(Left left, Right right) {
|
||||
return new Pair<>(left, right);
|
||||
}
|
||||
|
||||
private final Left left;
|
||||
private final Right right;
|
||||
|
||||
private Pair(Left left, Right right) {
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
public Left getLeft() {
|
||||
return this.left;
|
||||
}
|
||||
|
||||
public Right getRight() {
|
||||
return this.right;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,9 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author droppinganvil
|
||||
*/
|
||||
public class PermissionList {
|
||||
public static void generateFile() {
|
||||
File file = new File(FactionsPlugin.getInstance().getDataFolder().toString() + "/" + "permissions.yml");
|
||||
|
||||
15
src/main/java/com/massivecraft/factions/util/StaticGUI.java
Normal file
15
src/main/java/com/massivecraft/factions/util/StaticGUI.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.massivecraft.factions.util;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
/**
|
||||
* @author droppinganvil
|
||||
* Inspired by FactionGUI with the difference being that this should be used for GUIs that will not differ between players
|
||||
* Using StaticGUI and only generating one will not require generating one object per player unlike FactionGUI this will save many resources from being used.
|
||||
* @see FactionGUI
|
||||
*/
|
||||
public interface StaticGUI extends InventoryHolder {
|
||||
void click(int slot, ClickType action, Player player);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.massivecraft.factions.util.Sync;
|
||||
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* @author droppinganvil
|
||||
*/
|
||||
public class SyncExecutor {
|
||||
private static boolean started = false;
|
||||
/**
|
||||
* This queue is used to collect task that need to happen async rather than scheduling for every action.
|
||||
*/
|
||||
public static Queue<SyncTask> taskQueue = new LinkedList<>();
|
||||
|
||||
public static void startTask() {
|
||||
if (started) return;
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.instance, () -> {
|
||||
SyncTask syncTask = taskQueue.poll();
|
||||
if (syncTask != null) {
|
||||
try {
|
||||
syncTask.call();
|
||||
} catch (InvocationTargetException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
FactionsPlugin.getInstance().getLogger().log(Level.SEVERE, "A task was not able to execute successfully! Please provide this stacktrace to the Saber team at Discord.Saber.pw");
|
||||
}
|
||||
}
|
||||
}, 0L, 2L);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.massivecraft.factions.util.Sync;
|
||||
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* @author droppinganvil
|
||||
*/
|
||||
public class SyncTask {
|
||||
private Object o;
|
||||
private Method m;
|
||||
private Object[] arguments;
|
||||
private Collection<Class<?>> params;
|
||||
|
||||
public SyncTask(Object target, Method method, Object... arguments) {
|
||||
this.o = target;
|
||||
this.m = method;
|
||||
this.arguments = arguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate sync task without the ability to specify the Method object, made for easy typing
|
||||
* @param target Object the method is on
|
||||
* @param method Method name
|
||||
* @param arguments Objects needed to call method
|
||||
*/
|
||||
public SyncTask(Object target, String method, Object... arguments) {
|
||||
this.o = target;
|
||||
this.arguments = arguments;
|
||||
this.params = new ArrayList<>();
|
||||
for (Object o : this.arguments) {
|
||||
this.params.add(o.getClass());
|
||||
}
|
||||
try {
|
||||
this.m = o.getClass().getMethod(method, (Class<?>[]) params.toArray());
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
FactionsPlugin.getInstance().getLogger().log(Level.SEVERE, "A Method could not be located! This means a task that was supposed to happen did not, this may be a very serious issue");
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Generate sync task without the ability to specify the Method object or arguments, made for easy typing
|
||||
*/
|
||||
public SyncTask(Object target, String method) {
|
||||
this.o = target;
|
||||
try {
|
||||
this.m = o.getClass().getMethod(method);
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
FactionsPlugin.getInstance().getLogger().log(Level.SEVERE, "A Method could not be located! This means a task that was supposed to happen did not, this may be a very serious issue");
|
||||
}
|
||||
}
|
||||
|
||||
public void call() throws InvocationTargetException, IllegalAccessException {
|
||||
m.invoke(o, arguments);
|
||||
}
|
||||
}
|
||||
108
src/main/java/com/massivecraft/factions/util/TimeUtil.java
Normal file
108
src/main/java/com/massivecraft/factions/util/TimeUtil.java
Normal file
@@ -0,0 +1,108 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,10 @@ import org.bukkit.Bukkit;
|
||||
|
||||
|
||||
public class UtilFly {
|
||||
|
||||
/**
|
||||
* UtilFly is being removed very soon as all of its functionality has been updated and moved to CmdFly
|
||||
*/
|
||||
@Deprecated
|
||||
public static void run() {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
||||
return;
|
||||
@@ -22,7 +25,7 @@ public class UtilFly {
|
||||
}
|
||||
}, 0, FactionsPlugin.getInstance().getConfig().getInt("fly-task-interval", 10));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void setFly(FPlayer fp, boolean fly, boolean silent, boolean damage) {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
||||
return;
|
||||
@@ -42,7 +45,7 @@ public class UtilFly {
|
||||
|
||||
setFallDamage(fp, fly, damage);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void checkFly(FPlayer me, Faction factionTo) {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author droppinganvil
|
||||
*/
|
||||
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.FPlayer;
|
||||
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,11 @@
|
||||
package com.massivecraft.factions.util.Wait;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author droppinganvil
|
||||
*/
|
||||
public interface WaitedTask {
|
||||
void handleSuccess(Player player);
|
||||
void handleFailure(Player player);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,151 +0,0 @@
|
||||
package com.massivecraft.factions.util.serializable;
|
||||
|
||||
/**
|
||||
* @author Driftay
|
||||
*/
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
||||
public abstract class SaberGUI {
|
||||
public static Set<String> allGUINames = new HashSet<>();
|
||||
public static Map<UUID, SaberGUI> activeGUIs = new ConcurrentHashMap<>();
|
||||
public SaberGUI parentGUI;
|
||||
protected String title;
|
||||
protected int size;
|
||||
protected Player player;
|
||||
protected Inventory inventory;
|
||||
private Map<Integer, InventoryItem> inventoryItems;
|
||||
private String owningPluginName;
|
||||
private Runnable closeRunnable;
|
||||
|
||||
public SaberGUI(Player player, String title, int size) {
|
||||
this(player, title, size, InventoryType.CHEST);
|
||||
}
|
||||
|
||||
public SaberGUI(Player player, String title, int size, InventoryType type) {
|
||||
this.inventoryItems = new HashMap<>();
|
||||
this.inventory = type == InventoryType.CHEST ? Bukkit.createInventory(null, size, title) : Bukkit.createInventory(null, type, title);
|
||||
this.player = player;
|
||||
this.size = size;
|
||||
this.title = title;
|
||||
allGUINames.add(this.title);
|
||||
}
|
||||
|
||||
public SaberGUI setParentGUI(SaberGUI parent) {
|
||||
this.parentGUI = parent;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void onUnknownItemClick(InventoryClickEvent event) {
|
||||
}
|
||||
|
||||
public abstract void redraw();
|
||||
|
||||
public void openGUI(JavaPlugin owning) {
|
||||
this.owningPluginName = owning.getName();
|
||||
SaberGUI currentlyActive = activeGUIs.get(this.player.getUniqueId());
|
||||
if (currentlyActive != null) {
|
||||
Bukkit.getLogger().info("Closing already open menu first!");
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(owning, () -> {
|
||||
currentlyActive.close();
|
||||
activeGUIs.put(this.player.getUniqueId(), this);
|
||||
this.redraw();
|
||||
this.player.openInventory(this.inventory);
|
||||
});
|
||||
} else {
|
||||
activeGUIs.put(this.player.getUniqueId(), this);
|
||||
this.redraw();
|
||||
this.player.openInventory(this.inventory);
|
||||
}
|
||||
}
|
||||
|
||||
public void setItem(int slot, InventoryItem inventoryItem) {
|
||||
if (inventoryItem != null && inventoryItem.getItem() != null) {
|
||||
this.inventoryItems.put(slot, inventoryItem);
|
||||
this.inventory.setItem(slot, inventoryItem.getItem());
|
||||
} else {
|
||||
this.removeItem(slot);
|
||||
}
|
||||
}
|
||||
|
||||
public void closeWithDelay() {
|
||||
this.closeWithDelay(null);
|
||||
}
|
||||
|
||||
public void closeWithDelay(Consumer<Player> afterClose) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(FactionsPlugin.instance, () -> {
|
||||
this.player.closeInventory();
|
||||
if (afterClose != null) {
|
||||
afterClose.accept(this.player);
|
||||
}
|
||||
|
||||
}, 1L);
|
||||
}
|
||||
|
||||
public void setItem(int slot, ItemStack item, Runnable runnable) {
|
||||
this.setItem(slot, (new InventoryItem(item)).click(runnable));
|
||||
}
|
||||
|
||||
public void onInventoryClose() {
|
||||
if (this.closeRunnable != null) {
|
||||
this.closeRunnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
this.onInventoryClose();
|
||||
this.player.closeInventory();
|
||||
}
|
||||
|
||||
public void removeItem(int slot) {
|
||||
this.inventory.setItem(slot, null);
|
||||
this.inventoryItems.remove(slot);
|
||||
}
|
||||
|
||||
public SaberGUI setOnClose(Runnable runnable) {
|
||||
this.closeRunnable = runnable;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isInventory(Inventory inventory) {
|
||||
return this.inventory.equals(inventory);
|
||||
}
|
||||
|
||||
public static SaberGUI getActiveGUI(UUID uuid) { return activeGUIs.get(uuid); }
|
||||
|
||||
public static void removeGUI(UUID uuid) {
|
||||
activeGUIs.remove(uuid);
|
||||
}
|
||||
|
||||
public SaberGUI getParentGUI() {
|
||||
return this.parentGUI;
|
||||
}
|
||||
|
||||
public Map<Integer, InventoryItem> getInventoryItems() {
|
||||
return this.inventoryItems;
|
||||
}
|
||||
|
||||
public String getOwningPluginName() {
|
||||
return this.owningPluginName;
|
||||
}
|
||||
|
||||
public void setOwningPluginName(String owningPluginName) {
|
||||
this.owningPluginName = owningPluginName;
|
||||
}
|
||||
|
||||
public Runnable getCloseRunnable() {
|
||||
return this.closeRunnable;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.massivecraft.factions.zcore.fdisband;
|
||||
|
||||
import com.github.stefvanschie.inventoryframework.Gui;
|
||||
import com.github.stefvanschie.inventoryframework.GuiItem;
|
||||
import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Factions - Developed by Driftay.
|
||||
* All rights reserved 2020.
|
||||
* Creation Date: 1/18/2020
|
||||
*/
|
||||
public class FDisbandFrame {
|
||||
|
||||
private Gui gui;
|
||||
|
||||
public FDisbandFrame(Faction faction) {
|
||||
this.gui = new Gui(FactionsPlugin.getInstance(), 1, "Confirm Disband");
|
||||
}
|
||||
|
||||
public void buildGUI(FPlayer fPlayer) {
|
||||
int i;
|
||||
PaginatedPane pane = new PaginatedPane(0, 0, 9, this.gui.getRows());
|
||||
List<GuiItem> GUIItems = new ArrayList<>();
|
||||
ItemStack confirm = buildConfirmDummyItem(fPlayer.getFaction());
|
||||
ItemStack deny = buildDenyDummyItem();
|
||||
for (i = 0; i < 5; ++i) {
|
||||
GUIItems.add(new GuiItem(confirm, (e) -> {
|
||||
e.setCancelled(true);
|
||||
fPlayer.getPlayer().setMetadata("disband_confirm", new FixedMetadataValue(FactionsPlugin.getInstance(), System.currentTimeMillis()));
|
||||
fPlayer.getPlayer().closeInventory();
|
||||
fPlayer.getPlayer().performCommand("f disband");
|
||||
}));
|
||||
}
|
||||
//Separator
|
||||
FileConfiguration config = FactionsPlugin.getInstance().getConfig();
|
||||
ItemStack separatorItem = XMaterial.matchXMaterial(config.getString("f-disband-gui.separation-item.Type")).get().parseItem();
|
||||
ItemMeta separatorMeta = separatorItem.getItemMeta();
|
||||
separatorMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString("f-disband-gui.separation-item.Name")));
|
||||
List<String> separatorLore = config.getStringList("f-disband-gui.separation-item.Lore");
|
||||
if (separatorMeta.getLore() != null) separatorMeta.getLore().clear();
|
||||
if (separatorLore != null) {
|
||||
List<String> lore = new ArrayList<>();
|
||||
for (String loreEntry : config.getStringList("f-disband-gui.separation-item.Lore")) {
|
||||
lore.add(ChatColor.translateAlternateColorCodes('&', loreEntry));
|
||||
}
|
||||
separatorMeta.setLore(lore);
|
||||
}
|
||||
GUIItems.set(4, new GuiItem(separatorItem, (e) -> e.setCancelled(true)));
|
||||
//End Separator
|
||||
|
||||
for (i = 5; i < 10; ++i) {
|
||||
GUIItems.add(new GuiItem(deny, (e) -> {
|
||||
e.setCancelled(true);
|
||||
fPlayer.getPlayer().closeInventory();
|
||||
}));
|
||||
}
|
||||
pane.populateWithGuiItems(GUIItems);
|
||||
gui.addPane(pane);
|
||||
gui.update();
|
||||
gui.show(fPlayer.getPlayer());
|
||||
}
|
||||
|
||||
|
||||
private ItemStack buildConfirmDummyItem(Faction faction) {
|
||||
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("f-disband-gui.confirm-item");
|
||||
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null) {
|
||||
List<String> lore = new ArrayList<>();
|
||||
for (String s : config.getStringList("Lore")) {
|
||||
lore.add(FactionsPlugin.getInstance().color(s).replace("{faction}", faction.getTag()));
|
||||
}
|
||||
meta.setLore(lore);
|
||||
meta.setDisplayName(FactionsPlugin.getInstance().color(Objects.requireNonNull(config.getString("Name"))));
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
private ItemStack buildDenyDummyItem() {
|
||||
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("f-disband-gui.deny-item");
|
||||
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null) {
|
||||
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
|
||||
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public enum PermissableAction {
|
||||
|
||||
public ItemStack buildAsset(FPlayer fme, Permissable perm) {
|
||||
ConfigurationSection section = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.action");
|
||||
ItemStack item = XMaterial.matchXMaterial(section.getString("Materials." + this.name)).parseItem();
|
||||
ItemStack item = XMaterial.matchXMaterial(section.getString("Materials." + this.name)).get().parseItem();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
|
||||
meta.setDisplayName(FactionsPlugin.getInstance().color(section.getString("placeholder-item.name").replace("{action}", this.name)));
|
||||
|
||||
@@ -91,7 +91,7 @@ public class PermissableActionFrame {
|
||||
|
||||
private ItemStack buildDummyItem() {
|
||||
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.dummy-item");
|
||||
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem();
|
||||
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
|
||||
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
|
||||
@@ -101,7 +101,7 @@ public class PermissableActionFrame {
|
||||
|
||||
private ItemStack buildBackItem() {
|
||||
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.back-item");
|
||||
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem();
|
||||
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
|
||||
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
|
||||
|
||||
@@ -56,7 +56,7 @@ public class PermissableRelationFrame {
|
||||
}
|
||||
|
||||
private ItemStack buildAsset(String loc, String relation) {
|
||||
ItemStack item = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString(loc)).parseItem();
|
||||
ItemStack item = XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString(loc)).get().parseItem();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(FactionsPlugin.getInstance().color(FactionsPlugin.getInstance().getConfig().getString("fperm-gui.relation.Placeholder-Item.Name").replace("{relation}", relation)));
|
||||
item.setItemMeta(meta);
|
||||
@@ -65,7 +65,7 @@ public class PermissableRelationFrame {
|
||||
|
||||
private ItemStack buildDummyItem() {
|
||||
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fperm-gui.dummy-item");
|
||||
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem();
|
||||
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
|
||||
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
|
||||
|
||||
@@ -25,7 +25,7 @@ public class FUpgradeFrame {
|
||||
|
||||
public FUpgradeFrame(Faction f) {
|
||||
this.gui = new Gui(FactionsPlugin.getInstance(),
|
||||
FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.rows", 5),
|
||||
FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Rows", 5),
|
||||
FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Title").replace("{faction}", f.getTag()));
|
||||
}
|
||||
|
||||
@@ -95,13 +95,13 @@ public class FUpgradeFrame {
|
||||
private void updateFactionPowerBoost(Faction f) {
|
||||
double boost = FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.Power.Power-Boost.level-" + (f.getUpgrade(UpgradeType.POWER) + 1));
|
||||
if (boost < 0.0) return;
|
||||
f.setPowerBoost(f.getPower() + boost);
|
||||
f.setPowerBoost(boost);
|
||||
}
|
||||
|
||||
|
||||
private ItemStack buildDummyItem() {
|
||||
ConfigurationSection config = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fupgrades.MainMenu.DummyItem");
|
||||
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem();
|
||||
ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).get().parseItem();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null) {
|
||||
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user