Changelog will be posted, add alot
This commit is contained in:
@@ -21,8 +21,10 @@ public class Aliases {
|
||||
public static ArrayList<String> claim_auto = new ArrayList<>(Collections.singletonList("autoclaim"));
|
||||
public static ArrayList<String> claim_claim = new ArrayList<>(Collections.singletonList("claim"));
|
||||
public static ArrayList<String> claim_at = new ArrayList<>(Collections.singletonList("claimat"));
|
||||
public static ArrayList<String> claim_claimFill = new ArrayList<>(Arrays.asList("claimfill", "cf"));
|
||||
public static ArrayList<String> claim_line = new ArrayList<>(Arrays.asList("claimline", "cl"));
|
||||
public static ArrayList<String> claim_corner = new ArrayList<>(Arrays.asList("corner"));
|
||||
public static ArrayList<String> delfHome = new ArrayList<>(Arrays.asList("delhome", "deletehome"));
|
||||
public static ArrayList<String> unclaim_all_safe = new ArrayList<>(Arrays.asList("safeunclaimall", "safedeclaimall"));
|
||||
public static ArrayList<String> unclaim_unclaim = new ArrayList<>(Arrays.asList("unclaim", "declaim"));
|
||||
public static ArrayList<String> unclaim_all_unsafe = new ArrayList<>(Arrays.asList("unclaimall", "declaimall"));
|
||||
|
||||
51
src/main/java/com/massivecraft/factions/cmd/CmdDelHome.java
Normal file
51
src/main/java/com/massivecraft/factions/cmd/CmdDelHome.java
Normal file
@@ -0,0 +1,51 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Factions - Developed by Driftay.
|
||||
* All rights reserved 2020.
|
||||
* Creation Date: 3/24/2020
|
||||
*/
|
||||
public class CmdDelHome extends FCommand {
|
||||
|
||||
public CmdDelHome() {
|
||||
this.aliases.addAll(Aliases.delfHome);
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.DELHOME)
|
||||
.memberOnly()
|
||||
.withAction(PermissableAction.SETHOME)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
FactionsPlugin.getInstance().getServer().getScheduler().runTaskAsynchronously(FactionsPlugin.instance, () -> {
|
||||
//Check if homes are enabled
|
||||
if (!Conf.homesEnabled) {
|
||||
context.msg(TL.COMMAND_SETHOME_DISABLED);
|
||||
return;
|
||||
}
|
||||
//If They Don't Have Home
|
||||
if (!context.faction.hasHome()) {
|
||||
context.msg(TL.COMMAND_HOME_NOHOME.toString());
|
||||
context.msg(FactionsPlugin.getInstance().cmdBase.cmdSethome.getUsageTemplate(context));
|
||||
return;
|
||||
}
|
||||
|
||||
context.faction.deleteHome();
|
||||
context.faction.msg(TL.COMMAND_DELHOME_SUCCESS, context.fPlayer.describeTo(context.faction, true));
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_DELHOME_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ 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;
|
||||
@@ -79,7 +78,7 @@ public class CmdDisband extends FCommand {
|
||||
}
|
||||
|
||||
if (!access) {
|
||||
if(Conf.useDisbandGUI && !context.fPlayer.isAdminBypassing() || !context.player.isOp()) {
|
||||
if (Conf.useDisbandGUI && !context.fPlayer.isAdminBypassing() || !context.player.isOp()) {
|
||||
if (!disbandMap.containsKey(context.player.getUniqueId().toString())) {
|
||||
new FDisbandFrame(context.faction).buildGUI(context.fPlayer);
|
||||
return;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class CmdInspect extends FCommand {
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
if(!Conf.useInspectSystem){
|
||||
if (!Conf.useInspectSystem) {
|
||||
context.fPlayer.msg(TL.GENERIC_DISABLED, "Faction Inspection");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public class CmdJoin extends FCommand {
|
||||
}
|
||||
|
||||
faction.deinvite(fplayer);
|
||||
|
||||
|
||||
try {
|
||||
context.fPlayer.setRole(faction.getDefaultRole());
|
||||
FactionsPlugin.instance.logFactionEvent(faction, FLogType.INVITES, context.fPlayer.getName(), CC.Green + "joined", "the faction");
|
||||
|
||||
@@ -21,8 +21,7 @@ public class CmdLeave extends FCommand {
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
|
||||
context.fPlayer.leave(true);
|
||||
context.fPlayer.leave(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
|
||||
|
||||
@@ -41,8 +41,6 @@ public class CmdStuck extends FCommand {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (FactionsPlugin.getInstance().getStuckMap().containsKey(player.getUniqueId())) {
|
||||
long wait = FactionsPlugin.getInstance().getTimers().get(player.getUniqueId()) - System.currentTimeMillis();
|
||||
String time = DurationFormatUtils.formatDuration(wait, TL.COMMAND_STUCK_TIMEFORMAT.toString(), true);
|
||||
|
||||
@@ -168,6 +168,8 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
||||
public CmdLookup cmdLookup = new CmdLookup();
|
||||
public CmdAudit cmdAudit = new CmdAudit();
|
||||
public CmdReserve cmdReserve = new CmdReserve();
|
||||
public CmdDelHome cmdDelHome = new CmdDelHome();
|
||||
public CmdClaimFill cmdClaimFill = new CmdClaimFill();
|
||||
//Variables to know if we already setup certain sub commands
|
||||
public Boolean discordEnabled = false;
|
||||
public Boolean checkEnabled = false;
|
||||
@@ -213,6 +215,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
||||
this.addSubCommand(this.cmdCreate);
|
||||
this.addSubCommand(this.cmdDeinvite);
|
||||
this.addSubCommand(this.cmdDescription);
|
||||
this.addSubCommand(this.cmdDelHome);
|
||||
this.addSubCommand(this.cmdDisband);
|
||||
this.addSubCommand(this.cmdHelp);
|
||||
this.addSubCommand(this.cmdHome);
|
||||
@@ -263,6 +266,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
||||
this.addSubCommand(this.cmdDelFWarp);
|
||||
this.addSubCommand(this.cmdModifyPower);
|
||||
this.addSubCommand(this.cmdLogins);
|
||||
this.addSubCommand(this.cmdClaimFill);
|
||||
this.addSubCommand(this.cmdClaimLine);
|
||||
this.addSubCommand(this.cmdAHome);
|
||||
this.addSubCommand(this.cmdPerm);
|
||||
@@ -355,7 +359,7 @@ public class FCmdRoot extends FCommand implements CommandExecutor {
|
||||
fAuditEnabled = true;
|
||||
}
|
||||
|
||||
if(Conf.useStrikeSystem){
|
||||
if (Conf.useStrikeSystem) {
|
||||
this.addSubCommand(this.cmdStrikes);
|
||||
fStrikes = true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
package com.massivecraft.factions.cmd.claim;
|
||||
|
||||
/**
|
||||
* Created by FactionsUUID Team
|
||||
*/
|
||||
|
||||
import com.massivecraft.factions.Board;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.cmd.Aliases;
|
||||
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.zcore.fperms.Access;
|
||||
import com.massivecraft.factions.zcore.fperms.PermissableAction;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
|
||||
public class CmdClaimFill extends FCommand {
|
||||
|
||||
public CmdClaimFill() {
|
||||
|
||||
// Aliases
|
||||
this.aliases.addAll(Aliases.claim_claimFill);
|
||||
|
||||
// Args
|
||||
this.optionalArgs.put("limit", String.valueOf(Conf.maxFillClaimCount));
|
||||
this.optionalArgs.put("faction", "you");
|
||||
|
||||
this.requirements = new CommandRequirements.Builder(Permission.CLAIM_FILL)
|
||||
.playerOnly()
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform(CommandContext context) {
|
||||
// Args
|
||||
final int limit = context.argAsInt(0, Conf.maxFillClaimCount);
|
||||
|
||||
if (limit > Conf.maxFillClaimCount) {
|
||||
context.msg(TL.COMMAND_CLAIMFILL_ABOVEMAX, Conf.maxFillClaimCount);
|
||||
return;
|
||||
}
|
||||
|
||||
final Faction forFaction = context.argAsFaction(2, context.faction);
|
||||
Location location = context.player.getLocation();
|
||||
FLocation loc = new FLocation(location);
|
||||
|
||||
Faction currentFaction = Board.getInstance().getFactionAt(loc);
|
||||
|
||||
if (currentFaction.equals(forFaction)) {
|
||||
context.msg(TL.CLAIM_ALREADYOWN, forFaction.describeTo(context.fPlayer, true));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!currentFaction.isWilderness()) {
|
||||
context.msg(TL.COMMAND_CLAIMFILL_ALREADYCLAIMED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!context.fPlayer.isAdminBypassing() && forFaction.getAccess(context.fPlayer, PermissableAction.TERRITORY) != Access.ALLOW) {
|
||||
context.msg(TL.CLAIM_CANTCLAIM, forFaction.describeTo(context.fPlayer));
|
||||
return;
|
||||
}
|
||||
|
||||
final double distance = Conf.maxFillClaimDistance;
|
||||
long startX = loc.getX();
|
||||
long startZ = loc.getZ();
|
||||
|
||||
Set<FLocation> toClaim = new HashSet<>();
|
||||
Queue<FLocation> queue = new LinkedList<>();
|
||||
FLocation currentHead;
|
||||
queue.add(loc);
|
||||
toClaim.add(loc);
|
||||
while (!queue.isEmpty() && toClaim.size() <= limit) {
|
||||
currentHead = queue.poll();
|
||||
|
||||
if (Math.abs(currentHead.getX() - startX) > distance || Math.abs(currentHead.getZ() - startZ) > distance) {
|
||||
context.msg(TL.COMMAND_CLAIMFILL_TOOFAR, distance);
|
||||
return;
|
||||
}
|
||||
|
||||
addIf(toClaim, queue, currentHead.getRelative(0, 1));
|
||||
addIf(toClaim, queue, currentHead.getRelative(0, -1));
|
||||
addIf(toClaim, queue, currentHead.getRelative(1, 0));
|
||||
addIf(toClaim, queue, currentHead.getRelative(-1, 0));
|
||||
}
|
||||
|
||||
if (toClaim.size() > limit) {
|
||||
context.msg(TL.COMMAND_CLAIMFILL_PASTLIMIT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (toClaim.size() > context.faction.getPowerRounded() - context.faction.getLandRounded()) {
|
||||
context.msg(TL.COMMAND_CLAIMFILL_NOTENOUGHLANDLEFT, forFaction.describeTo(context.fPlayer), toClaim.size());
|
||||
return;
|
||||
}
|
||||
|
||||
final int limFail = Conf.radiusClaimFailureLimit;
|
||||
int fails = 0;
|
||||
for (FLocation currentLocation : toClaim) {
|
||||
if (!context.fPlayer.attemptClaim(forFaction, currentLocation, true)) {
|
||||
fails++;
|
||||
}
|
||||
if (fails >= limFail) {
|
||||
context.msg(TL.COMMAND_CLAIMFILL_TOOMUCHFAIL, fails);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addIf(Set<FLocation> toClaim, Queue<FLocation> queue, FLocation examine) {
|
||||
if (Board.getInstance().getFactionAt(examine).isWilderness() && !toClaim.contains(examine)) {
|
||||
toClaim.add(examine);
|
||||
queue.add(examine);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TL getUsageTranslation() {
|
||||
return TL.COMMAND_CLAIMFILL_DESCRIPTION;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
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;
|
||||
@@ -20,7 +19,9 @@ import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class CmdTntFill extends FCommand {
|
||||
|
||||
@@ -38,6 +39,24 @@ public class CmdTntFill 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("Tntfill.enabled")) {
|
||||
@@ -146,24 +165,6 @@ public class CmdTntFill extends FCommand {
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// Counts the item type available in the inventory.
|
||||
private int inventoryItemCount(Inventory inventory, Material mat) {
|
||||
int count = 0;
|
||||
|
||||
Reference in New Issue
Block a user