Introduced Brigadier Command System. More Formatting Coming in next commit.

This commit is contained in:
Driftay
2019-09-14 15:13:01 -04:00
parent b06e6e0f04
commit 3c9b606bb9
207 changed files with 4465 additions and 4017 deletions

View File

@@ -50,13 +50,13 @@ public class AutoLeaveProcessTask extends BukkitRunnable {
// Check if they should be exempt from this.
if (!fplayer.willAutoLeave()) {
P.p.debug(Level.INFO, fplayer.getName() + " was going to be auto-removed but was set not to.");
FactionsPlugin.getInstance().debug(Level.INFO, fplayer.getName() + " was going to be auto-removed but was set not to.");
continue;
}
if (fplayer.isOffline() && now - fplayer.getLastLoginTime() > toleranceMillis) {
if (Conf.logFactionLeave || Conf.logFactionKick) {
P.p.log("Player " + fplayer.getName() + " was auto-removed due to inactivity.");
FactionsPlugin.getInstance().log("Player " + fplayer.getName() + " was auto-removed due to inactivity.");
}
// if player is faction admin, sort out the faction since he's going away

View File

@@ -1,7 +1,7 @@
package com.massivecraft.factions.util;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.P;
import com.massivecraft.factions.FactionsPlugin;
public class AutoLeaveTask implements Runnable {
@@ -18,11 +18,11 @@ public class AutoLeaveTask implements Runnable {
}
task = new AutoLeaveProcessTask();
task.runTaskTimer(P.p, 1, 1);
task.runTaskTimer(FactionsPlugin.getInstance(), 1, 1);
// maybe setting has been changed? if so, restart this task at new rate
if (this.rate != Conf.autoLeaveRoutineRunsEveryXMinutes) {
P.p.startAutoLeaveTask(true);
FactionsPlugin.getInstance().startAutoLeaveTask(true);
}
}
}

View File

@@ -35,7 +35,7 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
// Return the plugin version since this expansion is bundled with the dependency
@Override
public String getVersion() {
return P.p.getDescription().getVersion();
return FactionsPlugin.getInstance().getDescription().getVersion();
}
@Override
@@ -84,7 +84,7 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
String humanized = DurationFormatUtils.formatDurationWords(System.currentTimeMillis() - fPlayer.getLastLoginTime(), true, true) + TL.COMMAND_STATUS_AGOSUFFIX;
return fPlayer.isOnline() ? ChatColor.GREEN + TL.COMMAND_STATUS_ONLINE.toString() : (System.currentTimeMillis() - fPlayer.getLastLoginTime() < 432000000 ? ChatColor.YELLOW + humanized : ChatColor.RED + humanized);
case "player_group":
return P.p.getPrimaryGroup(Bukkit.getOfflinePlayer(UUID.fromString(fPlayer.getId())));
return FactionsPlugin.getInstance().getPrimaryGroup(Bukkit.getOfflinePlayer(UUID.fromString(fPlayer.getId())));
case "player_balance":
return Econ.isSetup() ? Econ.getFriendlyBalance(fPlayer) : TL.ECON_OFF.format("balance");
case "player_power":
@@ -131,7 +131,7 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
case "faction_warps":
return String.valueOf(faction.getWarps().size());
case "faction_raidable":
boolean raid = P.p.getConfig().getBoolean("hcf.raidable", false) && faction.getLandRounded() >= faction.getPowerRounded();
boolean raid = FactionsPlugin.getInstance().getConfig().getBoolean("hcf.raidable", false) && faction.getLandRounded() >= faction.getPowerRounded();
return raid ? TL.RAIDABLE_TRUE.toString() : TL.RAIDABLE_FALSE.toString();
case "faction_home_world":
return faction.hasHome() ? faction.getHome().getWorld().getName() : "";

View File

@@ -6,7 +6,7 @@ import com.github.stefvanschie.inventoryframework.pane.PaginatedPane;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit;
@@ -25,8 +25,8 @@ public class FactionWarpsFrame {
private ConfigurationSection section;
public FactionWarpsFrame(final Faction f) {
this.section = P.p.getConfig().getConfigurationSection("fwarp-gui");
this.gui = new Gui(P.p, section.getInt("rows", 3), P.p.color(this.section.getString("name").replace("{faction}", f.getTag())));
this.section = FactionsPlugin.getInstance().getConfig().getConfigurationSection("fwarp-gui");
this.gui = new Gui(FactionsPlugin.getInstance(), section.getInt("rows", 3), FactionsPlugin.getInstance().color(this.section.getString("name").replace("{faction}", f.getTag())));
}
public void buildGUI(final FPlayer fplayer) {
@@ -50,12 +50,12 @@ public class FactionWarpsFrame {
} else {
fplayer.setEnteringPassword(true, warp.getKey());
fplayer.msg(TL.COMMAND_FWARP_PASSWORD_REQUIRED);
Bukkit.getScheduler().runTaskLater(P.p, () -> {
Bukkit.getScheduler().runTaskLater(FactionsPlugin.getInstance(), () -> {
if (fplayer.isEnteringPassword()) {
fplayer.msg(TL.COMMAND_FWARP_PASSWORD_TIMEOUT);
fplayer.setEnteringPassword(false, "");
}
}, P.p.getConfig().getInt("fwarp-gui.password-timeout", 5) * 20);
}, FactionsPlugin.getInstance().getConfig().getInt("fwarp-gui.password-timeout", 5) * 20);
}
}));
++count;
@@ -70,8 +70,8 @@ public class FactionWarpsFrame {
final ConfigurationSection config = this.section.getConfigurationSection("warp-item");
final ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem();
final ItemMeta meta = item.getItemMeta();
meta.setLore(P.p.colorList(P.p.replacePlaceholders(config.getStringList("Lore"), new Placeholder("{warp-protected}", faction.hasWarpPassword(warp.getKey()) ? "Enabled" : "Disabled"), new Placeholder("{warp-cost}", P.p.getConfig().getBoolean("warp-cost.enabled", false) ? Integer.toString(P.p.getConfig().getInt("warp-cost.warp", 5)) : "Disabled"))));
meta.setDisplayName(P.p.color(config.getString("Name").replace("{warp}", warp.getKey())));
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())));
item.setItemMeta(meta);
return item;
}
@@ -80,8 +80,8 @@ public class FactionWarpsFrame {
final ConfigurationSection config = this.section.getConfigurationSection("dummy-item");
final ItemStack item = XMaterial.matchXMaterial(config.getString("Type")).parseItem();
final ItemMeta meta = item.getItemMeta();
meta.setLore(P.p.colorList(config.getStringList("Lore")));
meta.setDisplayName(P.p.color(config.getString("Name")));
meta.setLore(FactionsPlugin.getInstance().colorList(config.getStringList("Lore")));
meta.setDisplayName(FactionsPlugin.getInstance().color(config.getString("Name")));
item.setItemMeta(meta);
return item;
}
@@ -93,12 +93,13 @@ public class FactionWarpsFrame {
player.teleport(fme.getFaction().getWarp(warp).getLocation());
fme.msg(TL.COMMAND_FWARP_WARPED, warp);
}
}, P.p.getConfig().getLong("warmups.f-warp", 0));
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-warp", 0));
}
private boolean transact(FPlayer player) {
if (!P.p.getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing()) return true;
double cost = P.p.getConfig().getDouble("warp-cost.warp", 5);
if (!FactionsPlugin.getInstance().getConfig().getBoolean("warp-cost.enabled", false) || player.isAdminBypassing())
return true;
double cost = FactionsPlugin.getInstance().getConfig().getDouble("warp-cost.warp", 5);
if (!Econ.shouldBeUsed() || cost == 0.0 || player.isAdminBypassing()) return true;
if (Conf.bankEnabled && Conf.bankFactionPaysCosts && player.hasFaction()) {

View File

@@ -1,7 +1,7 @@
package com.massivecraft.factions.util;
import com.google.gson.*;
import com.massivecraft.factions.P;
import com.massivecraft.factions.FactionsPlugin;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@@ -21,7 +21,7 @@ public class LocationTypeAdapter implements JsonSerializer<Location>, JsonDeseri
return object;
} catch (Exception ex) {
ex.printStackTrace();
P.p.log(Level.WARNING, "Error encountered while serializing a Location.");
FactionsPlugin.getInstance().log(Level.WARNING, "Error encountered while serializing a Location.");
return object;
}
}
@@ -38,7 +38,7 @@ public class LocationTypeAdapter implements JsonSerializer<Location>, JsonDeseri
object.get("z").getAsDouble());
} catch (Exception ex) {
ex.printStackTrace();
P.p.log(Level.WARNING, "Error encountered while" +
FactionsPlugin.getInstance().log(Level.WARNING, "Error encountered while" +
" deserializing a Location.");
return null;
}

View File

@@ -2,7 +2,7 @@ package com.massivecraft.factions.util;
import com.google.gson.*;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.P;
import com.massivecraft.factions.FactionsPlugin;
import java.lang.reflect.Type;
import java.util.HashSet;
@@ -50,7 +50,7 @@ public class MapFLocToStringSetTypeAdapter implements JsonDeserializer<Map<FLoca
} catch (Exception ex) {
ex.printStackTrace();
P.p.log(Level.WARNING, "Error encountered while deserializing a Map of FLocations to String Sets.");
FactionsPlugin.getInstance().log(Level.WARNING, "Error encountered while deserializing a Map of FLocations to String Sets.");
return null;
}
}
@@ -95,7 +95,7 @@ public class MapFLocToStringSetTypeAdapter implements JsonDeserializer<Map<FLoca
} catch (Exception ex) {
ex.printStackTrace();
P.p.log(Level.WARNING, "Error encountered while serializing a Map of FLocations to String Sets.");
FactionsPlugin.getInstance().log(Level.WARNING, "Error encountered while serializing a Map of FLocations to String Sets.");
return obj;
}
}

View File

@@ -2,7 +2,7 @@ package com.massivecraft.factions.util;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.P;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor;
@@ -68,16 +68,16 @@ public class MiscUtil {
ArrayList<String> errors = new ArrayList<>();
if (getComparisonString(str).length() < Conf.factionTagLengthMin) {
errors.add(P.p.txt.parse(TL.GENERIC_FACTIONTAG_TOOSHORT.toString(), Conf.factionTagLengthMin));
errors.add(FactionsPlugin.getInstance().txt.parse(TL.GENERIC_FACTIONTAG_TOOSHORT.toString(), Conf.factionTagLengthMin));
}
if (str.length() > Conf.factionTagLengthMax) {
errors.add(P.p.txt.parse(TL.GENERIC_FACTIONTAG_TOOLONG.toString(), Conf.factionTagLengthMax));
errors.add(FactionsPlugin.getInstance().txt.parse(TL.GENERIC_FACTIONTAG_TOOLONG.toString(), Conf.factionTagLengthMax));
}
for (char c : str.toCharArray()) {
if (!substanceChars.contains(String.valueOf(c))) {
errors.add(P.p.txt.parse(TL.GENERIC_FACTIONTAG_ALPHANUMERIC.toString(), c));
errors.add(FactionsPlugin.getInstance().txt.parse(TL.GENERIC_FACTIONTAG_ALPHANUMERIC.toString(), c));
}
}
@@ -96,7 +96,7 @@ public class MiscUtil {
// Fix for some data being broken when we added the recruit rank.
if (player.getRole() == null) {
player.setRole(Role.NORMAL);
P.p.log(Level.WARNING, String.format("Player %s had null role. Setting them to normal. This isn't good D:", player.getName()));
FactionsPlugin.getInstance().log(Level.WARNING, String.format("Player %s had null role. Setting them to normal. This isn't good D:", player.getName()));
}
switch (player.getRole()) {

View File

@@ -1,7 +1,7 @@
package com.massivecraft.factions.util;
import com.google.gson.*;
import com.massivecraft.factions.P;
import com.massivecraft.factions.FactionsPlugin;
import java.lang.reflect.Type;
import java.util.logging.Level;
@@ -32,7 +32,7 @@ public class MyLocationTypeAdapter implements JsonDeserializer<LazyLocation>, Js
} catch (Exception ex) {
ex.printStackTrace();
P.p.log(Level.WARNING, "Error encountered while deserializing a LazyLocation.");
FactionsPlugin.getInstance().log(Level.WARNING, "Error encountered while deserializing a LazyLocation.");
return null;
}
}
@@ -52,7 +52,7 @@ public class MyLocationTypeAdapter implements JsonDeserializer<LazyLocation>, Js
return obj;
} catch (Exception ex) {
ex.printStackTrace();
P.p.log(Level.WARNING, "Error encountered while serializing a LazyLocation.");
FactionsPlugin.getInstance().log(Level.WARNING, "Error encountered while serializing a LazyLocation.");
return obj;
}
}

View File

@@ -1,6 +1,6 @@
package com.massivecraft.factions.util.Particles;
import com.massivecraft.factions.P;
import com.massivecraft.factions.FactionsPlugin;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Particle;
@@ -24,7 +24,7 @@ public enum Particles {
public void displayAtLocation(Location location, int amt) {
if (P.p.useNonPacketParticles) {
if (FactionsPlugin.getInstance().useNonPacketParticles) {
// 1.9+ based servers will use the built in particleAPI instead of packet based.
// any particle amount higher than 0 made them go everywhere, and the offset at 0 was not working.
// So setting the amount to 0 spawns 1 in the precise location
@@ -35,15 +35,15 @@ public enum Particles {
}
public void displayAtLocation(Location location, int amt, ParticleEffect.OrdinaryColor color) {
if (P.p.useNonPacketParticles) {
if (FactionsPlugin.getInstance().useNonPacketParticles) {
// 1.9-1.11 & 1.13+ based servers will use the built in particleAPI instead of packet based.
// any particle amount higher than 0 made them go everywhere, and the offset at 0 was not working.
// So setting the amount to 0 spawns 1 in the precise location
// Gotta do this so colorable ones have their data :P
// Gotta do this so colorable ones have their data :FactionsPlugin
if (this == Particles.REDSTONE || this == Particles.CLOUD || this == Particles.NOTE) {
if (P.p.mc112) {
if (FactionsPlugin.getInstance().mc112) {
location.getWorld().spawnParticle(Particle.valueOf(over19), location, 0);
} else {
location.getWorld().spawnParticle(Particle.valueOf(over19), location, 0, new Particle.DustOptions(Color.fromRGB(color.getRed(), color.getGreen(), color.getBlue()), 1));

View File

@@ -1,7 +1,7 @@
package com.massivecraft.factions.util;
import com.google.gson.*;
import com.massivecraft.factions.P;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.zcore.fperms.Access;
@@ -62,7 +62,7 @@ public class PermissionsMapTypeAdapter implements JsonDeserializer<Map<Permissab
return permissionsMap;
} catch (Exception ex) {
P.p.log(Level.WARNING, "Error encountered while deserializing a PermissionsMap.");
FactionsPlugin.getInstance().log(Level.WARNING, "Error encountered while deserializing a PermissionsMap.");
ex.printStackTrace();
return null;
}

View File

@@ -0,0 +1,6 @@
package com.massivecraft.factions.util;
@FunctionalInterface
public interface QuadFunction<T, U, V, W, R> {
R apply(T t, U u, V v, W w);
}

View File

@@ -1,7 +1,7 @@
package com.massivecraft.factions.util;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.P;
import com.massivecraft.factions.FactionsPlugin;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
@@ -45,7 +45,7 @@ public abstract class SpiralTask implements Runnable {
this.world = Bukkit.getWorld(fLocation.getWorldName());
if (this.world == null) {
P.p.log(Level.WARNING, "[SpiralTask] A valid world must be specified!");
FactionsPlugin.getInstance().log(Level.WARNING, "[SpiralTask] A valid world must be specified!");
this.stop();
return;
}
@@ -56,7 +56,7 @@ public abstract class SpiralTask implements Runnable {
this.readyToGo = true;
// get this party started
this.setTaskID(Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(P.p, this, 2, 2));
this.setTaskID(Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), this, 2, 2));
}
private static long now() {
@@ -187,7 +187,7 @@ public abstract class SpiralTask implements Runnable {
// for successful completion
public void finish() {
// P.p.log("SpiralTask successfully completed!");
// FactionsPlugin.getInstance().log("SpiralTask successfully completed!");
this.stop();
}

View File

@@ -3,7 +3,7 @@ package com.massivecraft.factions.util;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit;
@@ -12,19 +12,19 @@ import org.bukkit.Bukkit;
public class UtilFly {
public static void run() {
if (!P.p.getConfig().getBoolean("enable-faction-flight"))
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
return;
Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, () -> {
Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> {
for (FPlayer fp : FPlayers.getInstance().getOnlinePlayers()) {
if (fp.isFlying())
fp.checkIfNearbyEnemies();
}
}, 0, P.p.getConfig().getInt("fly-task-interval", 10));
}, 0, FactionsPlugin.getInstance().getConfig().getInt("fly-task-interval", 10));
}
public static void setFly(FPlayer fp, boolean fly, boolean silent, boolean damage) {
if (!P.p.getConfig().getBoolean("enable-faction-flight"))
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
return;
fp.getPlayer().setAllowFlight(fly);
@@ -44,7 +44,7 @@ public class UtilFly {
}
public static void checkFly(FPlayer me, Faction factionTo) {
if (!P.p.getConfig().getBoolean("enable-faction-flight"))
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
return;
if (me.isAdminBypassing() && me.isFlying() && me.getPlayer().hasPermission("factions.fly.enemy-bypass"))
@@ -82,13 +82,13 @@ public class UtilFly {
public static void setFallDamage(FPlayer fp, boolean fly, boolean damage) {
if (!fly) {
if (!damage) {
fp.sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", P.p.getConfig().getInt("fly-falldamage-cooldown", 3) + ""));
fp.sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + ""));
}
int cooldown = P.p.getConfig().getInt("fly-falldamage-cooldown", 3);
int cooldown = FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3);
if (cooldown > 0) {
fp.setTakeFallDamage(false);
Bukkit.getScheduler().runTaskLater(P.p, () -> fp.setTakeFallDamage(true), 20L * cooldown);
Bukkit.getScheduler().runTaskLater(FactionsPlugin.getInstance(), () -> fp.setTakeFallDamage(true), 20L * cooldown);
}
}
}

View File

@@ -1,7 +1,7 @@
package com.massivecraft.factions.util;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.P;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.zcore.util.TL;
public class WarmUpUtil {
@@ -21,7 +21,7 @@ public class WarmUpUtil {
player.msg(TL.WARMUPS_ALREADY);
} else {
player.msg(translationKey.format(action, delay));
int id = P.p.getServer().getScheduler().runTaskLater(P.p, () -> {
int id = FactionsPlugin.getInstance().getServer().getScheduler().runTaskLater(FactionsPlugin.getInstance(), () -> {
player.stopWarmup();
runnable.run();
}, delay * 20).getTaskId();