Fixed Econ Format, Added Multiple Placeholders, Updated Pom.

This commit is contained in:
Driftay 2019-08-06 08:01:09 -04:00
parent de76801757
commit ac85687258
12 changed files with 44 additions and 11 deletions

View File

@ -318,7 +318,7 @@
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.8.4</version>
<version>2.8.5</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -194,7 +194,9 @@ public class P extends MPlugin {
}
}
UtilFly.run();
if (getConfig().getBoolean("enable-faction-flight", true)) {
UtilFly.run();
}
Board.getInstance().load();
Board.getInstance().clean();

View File

@ -141,8 +141,7 @@ public class CmdJoin extends FCommand {
}
faction.deinvite(fplayer);
fme.setRole(faction.getDefaultRole());
fplayer.setRole(faction.getDefaultRole());
if (Conf.logFactionJoin) {
if (samePlayer) {
P.p.log(TL.COMMAND_JOIN_JOINEDLOG.toString(), fplayer.getName(), faction.getTag());

View File

@ -34,6 +34,7 @@ public class CmdTitle extends FCommand {
args.remove(0);
String title = TextUtil.implode(args, " ");
title = title.replaceAll(",", "");
if (!canIAdministerYou(fme, you)) {
return;

View File

@ -5,6 +5,7 @@ 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 {
@ -42,7 +43,9 @@ public class CmdMoneyBalance extends FCommand {
}
if (fme != null) {
Econ.sendBalanceInfo(fme, faction);
Econ.sendBalanceInfo((CommandSender) fme, faction);
} else {
Econ.sendBalanceInfo(sender, faction);
}
}

View File

@ -13,6 +13,7 @@ import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.RegisteredServiceProvider;
import java.text.DecimalFormat;
@ -80,12 +81,12 @@ public class Econ {
modifyBalance(Conf.econUniverseAccount, delta);
}
public static void sendBalanceInfo(FPlayer to, EconomyParticipator about) {
public static void sendBalanceInfo(CommandSender to, Faction about) {
if (!shouldBeUsed()) {
P.p.log(Level.WARNING, "Vault does not appear to be hooked into an economy plugin.");
return;
}
to.msg("<a>%s's<i> balance is <h>%s<i>.", about.describeTo(to, true), Econ.moneyString(econ.getBalance(about.getAccountId())));
to.sendMessage(String.format("%s's balance is %s.", about.getTag(), Econ.moneyString(econ.getBalance(about.getAccountId()))));
}
public static boolean canIControllYou(EconomyParticipator i, EconomyParticipator you) {
@ -135,6 +136,7 @@ public class Econ {
public static boolean transferMoney(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount, boolean notify) {
if (!shouldBeUsed()) {
invoker.msg(TL.ECON_OFF);
return false;
}
@ -183,6 +185,12 @@ public class Econ {
return false;
}
// Check if the new balance is over Essential's money cap.
if (Essentials.isOverBalCap(to, econ.getBalance(toAcc) + amount)) {
invoker.msg(TL.ECON_OVER_BAL_CAP, amount);
return false;
}
// Transfer money
EconomyResponse erw = econ.withdrawPlayer(fromAcc, amount);

View File

@ -4,6 +4,7 @@ import com.earth2me.essentials.Teleport;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.iface.EconomyParticipator;
import net.ess3.api.IEssentials;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -25,6 +26,13 @@ public class Essentials {
}
}
public static boolean isOverBalCap(EconomyParticipator participator, double amount) {
if (essentials == null) {
return false;
}
return amount > essentials.getSettings().getMaxMoney().doubleValue();
}
// return false if feature is disabled or Essentials isn't available
public static boolean handleTeleport(Player player, Location loc) {
if (!Conf.homesTeleportCommandEssentialsIntegration || essentials == null) {

View File

@ -495,7 +495,7 @@ public class FactionsEntityListener implements Listener {
}
// You can never hurt faction members or allies
if (relation.isMember() || relation.isAlly()) {
if (relation.isMember() || relation.isAlly() || relation.isTruce()) {
if (notify) {
attacker.msg(TL.PLAYER_PVP_CANTHURT, defender.describeTo(attacker));
}

View File

@ -38,6 +38,10 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
return P.p.getDescription().getVersion();
}
@Override
public boolean persist() {
return true;
}
// Relational placeholders
@Override
@ -95,9 +99,11 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
return String.valueOf(fPlayer.getRolePrefix());
case "player_role":
return fPlayer.hasFaction() ? fPlayer.getRole().getPrefix() : "";
case "player_role_name":
return fPlayer.hasFaction() ? fPlayer.getRole().getTranslation().toString() : TL.PLACEHOLDER_ROLE_NAME.toString();
// Then Faction stuff
case "faction_name":
return fPlayer.hasFaction() ? faction.getTag() : "";
return fPlayer.hasFaction() ? faction.getTag() : TL.NOFACTION_PREFIX.toString();
case "faction_power":
return String.valueOf(faction.getPowerRounded());
case "faction_powermax":
@ -116,7 +122,7 @@ public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements R
return String.valueOf(faction.getTnt());
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 + ")");
return (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? TL.COMMAND_SHOW_BONUS.toString() : TL.COMMAND_SHOW_PENALTY.toString()) + powerBoost + ")";
case "faction_leader":
FPlayer fAdmin = faction.getFPlayerAdmin();
return fAdmin == null ? "Server" : fAdmin.getName().substring(0, fAdmin.getName().length() > 14 ? 13 : fAdmin.getName().length());

View File

@ -767,6 +767,7 @@ public abstract class MemoryFPlayer implements FPlayer {
}
this.resetFactionData();
setFlying(false);
if (myFaction.isNormal() && !perm && myFaction.getFPlayers().isEmpty()) {
// Remove this faction

View File

@ -948,6 +948,8 @@ public enum TL {
PLAYER_NOT_FOUND("&c&l[!] &b%1$s &7is either not online or not in your faction!"),
PLACEHOLDER_ROLE_NAME("None"),
WARBANNER_NOFACTION("&cYou need a faction to use a warbanner!"),
WARBANNER_COOLDOWN("&cThe warbanner is on cooldown for your faction!"),
@ -976,6 +978,8 @@ public enum TL {
ECON_OFF("no %s"), // no balance, no value, no refund, etc
ECON_FORMAT("###,###.###"),
ECON_DISABLED("Factions econ is disabled."),
ECON_OVER_BAL_CAP("&4The amount &e%s &4is over Essentials' balance cap."),
/**
* Relations

View File

@ -274,7 +274,8 @@ public enum TagReplacer {
* @return the string with the new value
*/
public String replace(String original, String value) {
return original.replace(tag, value);
return (original != null && value != null) ? original.replace(tag, value) : original;
}
/**