Added F Drain Command (A Command which allows players with permission to obtain all the money in faction members balances.)
This commit is contained in:
parent
3a22bb348e
commit
4e11234a08
@ -99,6 +99,8 @@ public class Conf {
|
||||
public static boolean autoLeaveDeleteFPlayerData = true; // Let them just remove player from Faction.
|
||||
public static boolean worldGuardChecking = false;
|
||||
public static boolean worldGuardBuildPriority = false;
|
||||
public static boolean factionsDrainEnabled = false;
|
||||
|
||||
//DISCORD
|
||||
public static boolean useDiscordSystem = false;
|
||||
public static String discordBotToken = "<token here>";
|
||||
|
64
src/main/java/com/massivecraft/factions/cmd/CmdDrain.java
Normal file
64
src/main/java/com/massivecraft/factions/cmd/CmdDrain.java
Normal file
@ -0,0 +1,64 @@
|
||||
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.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(){
|
||||
this.aliases.add("drain");
|
||||
this.requirements = new CommandRequirements.Builder(Permission.DRAIN)
|
||||
.playerOnly()
|
||||
.memberOnly()
|
||||
.withAction(PermissableAction.DRAIN)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
if (!Conf.factionsDrainEnabled) {
|
||||
context.fPlayer.msg(TL.GENERIC_DISABLED, "Factions Drain");
|
||||
return;
|
||||
}
|
||||
|
||||
double totalBalance = 0;
|
||||
|
||||
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)){
|
||||
continue; // skip the command executor
|
||||
}
|
||||
double balance = FactionsPlugin.getInstance().getEcon().getBalance(fPlayer.getPlayer());
|
||||
if (balance > 0) {
|
||||
FactionsPlugin.getInstance().getEcon().depositPlayer(context.player, balance);
|
||||
FactionsPlugin.getInstance().getEcon().withdrawPlayer(fPlayer.getPlayer(), balance);
|
||||
totalBalance = (totalBalance + balance);
|
||||
}
|
||||
}
|
||||
context.fPlayer.msg(TL.COMMAND_DRAIN_RECIEVED_AMOUNT, commas(totalBalance));
|
||||
}
|
||||
|
||||
public String commas(final double amount) {
|
||||
final DecimalFormat formatter = new DecimalFormat("#,###.00");
|
||||
return formatter.format(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -20,7 +20,7 @@ public class CmdSethome extends FCommand {
|
||||
.memberOnly()
|
||||
.withAction(PermissableAction.SETHOME)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
|
@ -162,6 +162,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
||||
public CmdSetGuild cmdSetGuild = new CmdSetGuild();
|
||||
public CmdDiscord cmdDiscord = new CmdDiscord();
|
||||
public CmdDebug cmdDebug = new CmdDebug();
|
||||
public CmdDrain cmdDrain = new CmdDrain();
|
||||
//Variables to know if we already setup certain sub commands
|
||||
public Boolean discordEnabled = false;
|
||||
public Boolean checkEnabled = false;
|
||||
@ -291,6 +292,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
||||
this.addSubCommand(this.cmdViewChest);
|
||||
this.addSubCommand(this.cmdConvertConfig);
|
||||
this.addSubCommand(this.cmdSpawnerLock);
|
||||
this.addSubCommand(this.cmdDrain);
|
||||
addVariableCommands();
|
||||
if (CommodoreProvider.isSupported()) brigadierManager.build();
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class CmdWild extends FCommand {
|
||||
}
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
if (!waitingTeleport.keySet().contains(context.player)) {
|
||||
if (!waitingTeleport.containsKey(context.player)) {
|
||||
context.player.openInventory(new WildGUI(context.player, context.fPlayer).getInventory());
|
||||
} else {context.fPlayer.msg(TL.COMMAND_WILD_WAIT);}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package com.massivecraft.factions.cmd.wild;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.integration.Essentials;
|
||||
import com.massivecraft.factions.util.FactionGUI;
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
@ -1052,16 +1052,21 @@ public class FactionsPlayerListener implements Listener {
|
||||
if (!Discord.useDiscord) {
|
||||
return;
|
||||
}
|
||||
|
||||
String[] msg = e.getChatMessage().split(" ");
|
||||
if (msg.length == 0 | !msg[msg.length - 1].contains("@")) {
|
||||
return;
|
||||
}
|
||||
FPlayer fp = FPlayers.getInstance().getByPlayer(e.getPlayer());
|
||||
if (fp == null | fp.getChatMode() != ChatMode.FACTION) {
|
||||
|
||||
if(fp == null) return;
|
||||
|
||||
if (fp.getChatMode() != ChatMode.FACTION) {
|
||||
return;
|
||||
}
|
||||
Faction f = fp.getFaction();
|
||||
if (f == null | f.isSystemFaction()) {
|
||||
if(f == null) return;
|
||||
if (f.isSystemFaction()) {
|
||||
return;
|
||||
}
|
||||
if (f.getGuildId() == null | f.getFactionChatChannelId() == null) {
|
||||
|
@ -42,6 +42,7 @@ public enum Permission {
|
||||
DISBAND("disband"),
|
||||
DISBAND_ANY("disband.any"),
|
||||
DISCORD("discord"),
|
||||
DRAIN("drain"),
|
||||
FLY("fly"),
|
||||
FLY_WILD("fly.wilderness"),
|
||||
FLY_SAFEZONE("fly.safezone"),
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.massivecraft.factions.zcore.fperms;
|
||||
|
||||
import com.massivecraft.factions.util.XMaterial;
|
||||
|
||||
public class DefaultPermissions {
|
||||
|
||||
/**
|
||||
@ -33,6 +35,7 @@ public class DefaultPermissions {
|
||||
public boolean withdraw;
|
||||
public boolean chest;
|
||||
public boolean check;
|
||||
public boolean drain;
|
||||
public boolean spawner;
|
||||
|
||||
public DefaultPermissions() {
|
||||
@ -66,6 +69,7 @@ public class DefaultPermissions {
|
||||
this.withdraw = def;
|
||||
this.chest = def;
|
||||
this.check = def;
|
||||
this.drain = def;
|
||||
this.spawner = def;
|
||||
}
|
||||
|
||||
@ -96,6 +100,7 @@ public class DefaultPermissions {
|
||||
boolean canWithdraw,
|
||||
boolean canChest,
|
||||
boolean canCheck,
|
||||
boolean canDrain,
|
||||
boolean canSpawners) {
|
||||
this.ban = canBan;
|
||||
this.build = canBuild;
|
||||
@ -124,6 +129,7 @@ public class DefaultPermissions {
|
||||
this.withdraw = canWithdraw;
|
||||
this.chest = canChest;
|
||||
this.check = canCheck;
|
||||
this.drain = canDrain;
|
||||
this.spawner = canSpawners;
|
||||
}
|
||||
|
||||
@ -156,6 +162,7 @@ public class DefaultPermissions {
|
||||
else if (name == "withdraw") return this.withdraw;
|
||||
else if (name == "chest") return this.chest;
|
||||
else if (name == "check") return this.check;
|
||||
else if (name == "drain") return this.drain;
|
||||
else if (name == "spawner") return this.spawner;
|
||||
else return false;
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ public enum PermissableAction {
|
||||
BAN("ban"),
|
||||
BUILD("build"),
|
||||
DESTROY("destroy"),
|
||||
DRAIN("drain"),
|
||||
FROST_WALK("frostwalk"),
|
||||
PAIN_BUILD("painbuild"),
|
||||
DOOR("door"),
|
||||
|
@ -959,6 +959,11 @@ public enum TL {
|
||||
COMMAND_WARUNCLAIMALL_SUCCESS("You unclaimed ALL war zone land."),
|
||||
COMMAND_WARUNCLAIMALL_LOG("%1$s unclaimed all war zones."),
|
||||
|
||||
COMMAND_DRAIN_NO_PLAYERS("&c&l[!] &cYou cannot drain a faction with no other members!"),
|
||||
COMMAND_DRAIN_RECIEVED_AMOUNT("&c&l[!] &fYou have drained all of your faction members for &b%1$s."),
|
||||
COMMAND_DRAIN_INVALID_AMOUNT("&c&l[!] &fYou cannot drain a faction with no worth."),
|
||||
|
||||
|
||||
COMMAND_WILD_DESCRIPTION("Teleport to a random location"),
|
||||
COMMAND_WILD_WAIT("&c&l[!] &7Teleporting in %1$s"),
|
||||
COMMAND_WILD_SUCCESS("&c&l[!] &7Teleporting..."),
|
||||
|
@ -490,6 +490,7 @@ fperm-gui:
|
||||
tntfill: TNT
|
||||
chest: ENDER_CHEST
|
||||
check: WATCH
|
||||
drain: BUCKET
|
||||
spawner: MOB_SPAWNER
|
||||
home: ENDER_EYE
|
||||
slots:
|
||||
@ -525,6 +526,7 @@ fperm-gui:
|
||||
chest: 42
|
||||
check: 50
|
||||
spawner: 38
|
||||
drain: 49
|
||||
home: 48
|
||||
# {action} Action name eg: Setwarp, Kick
|
||||
# {action-access} Access name eg: Allow, Deny
|
||||
|
@ -65,6 +65,7 @@ permissions:
|
||||
factions.kit.halfplayer:
|
||||
description: Can do all but create factions.
|
||||
children:
|
||||
factions.drain: true
|
||||
factions.wild: true
|
||||
factions.missions: true
|
||||
factions.tntfill: true
|
||||
|
Loading…
Reference in New Issue
Block a user