Code Overhaul + Minor Fixes
This commit is contained in:
@@ -19,7 +19,6 @@ public class CmdAdmin extends FCommand {
|
||||
this.aliases.add("setleader");
|
||||
|
||||
this.requiredArgs.add("player name");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.ADMIN.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
@@ -51,12 +51,7 @@ public class CmdCheckpoint extends FCommand {
|
||||
|
||||
if (checkfaction.getId().equals(Factions.getInstance().getWilderness().getId()) || checkfaction.getId().equals(fme.getFaction().getId())) {
|
||||
fme.msg(TL.COMMAND_CHECKPOINT_GO);
|
||||
this.doWarmUp(WarmUpUtil.Warmup.CHECKPOINT, TL.WARMUPS_NOTIFY_TELEPORT, "Checkpoint", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fme.getPlayer().teleport(fme.getFaction().getCheckpoint());
|
||||
}
|
||||
}, this.p.getConfig().getLong("warmups.f-checkpoint", 0));
|
||||
this.doWarmUp(WarmUpUtil.Warmup.CHECKPOINT, TL.WARMUPS_NOTIFY_TELEPORT, "Checkpoint", () -> fme.getPlayer().teleport(fme.getFaction().getCheckpoint()), this.p.getConfig().getLong("warmups.f-checkpoint", 0));
|
||||
} else {
|
||||
fme.msg(TL.COMMAND_CHECKPOINT_CLAIMED);
|
||||
}
|
||||
|
||||
@@ -81,12 +81,7 @@ public class CmdDisband extends FCommand {
|
||||
if (!disbandMap.containsKey(me.getUniqueId().toString()) && faction.getTnt() > 0) {
|
||||
msg(TL.COMMAND_DISBAND_CONFIRM.toString().replace("{tnt}", faction.getTnt() + ""));
|
||||
disbandMap.put(me.getUniqueId().toString(), faction.getId());
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(SavageFactions.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
disbandMap.remove(me.getUniqueId().toString());
|
||||
}
|
||||
}, 200L);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(SavageFactions.plugin, () -> disbandMap.remove(me.getUniqueId().toString()), 200L);
|
||||
} else if (faction.getId().equals(disbandMap.get(me.getUniqueId().toString())) || faction.getTnt() == 0) {
|
||||
if (SavageFactions.plugin.getConfig().getBoolean("faction-disband-broadcast", true)) {
|
||||
for (FPlayer follower : FPlayers.getInstance().getOnlinePlayers()) {
|
||||
|
||||
@@ -66,14 +66,11 @@ public class CmdFWarp extends FCommand {
|
||||
}
|
||||
final FPlayer fPlayer = fme;
|
||||
final UUID uuid = fme.getPlayer().getUniqueId();
|
||||
this.doWarmUp(WarmUpUtil.Warmup.WARP, TL.WARMUPS_NOTIFY_TELEPORT, warpName, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if (player != null) {
|
||||
player.teleport(fPlayer.getFaction().getWarp(warpName).getLocation());
|
||||
fPlayer.msg(TL.COMMAND_FWARP_WARPED, warpName);
|
||||
}
|
||||
this.doWarmUp(WarmUpUtil.Warmup.WARP, TL.WARMUPS_NOTIFY_TELEPORT, warpName, () -> {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if (player != null) {
|
||||
player.teleport(fPlayer.getFaction().getWarp(warpName).getLocation());
|
||||
fPlayer.msg(TL.COMMAND_FWARP_WARPED, warpName);
|
||||
}
|
||||
}, this.p.getConfig().getLong("warmups.f-warp", 0));
|
||||
} else {
|
||||
|
||||
@@ -123,21 +123,18 @@ public class CmdHome extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
this.doWarmUp(WarmUpUtil.Warmup.HOME, TL.WARMUPS_NOTIFY_TELEPORT, "Home", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Create a smoke effect
|
||||
if (Conf.homesTeleportCommandSmokeEffectEnabled) {
|
||||
List<Location> smokeLocations = new ArrayList<>();
|
||||
smokeLocations.add(loc);
|
||||
smokeLocations.add(loc.add(0, 1, 0));
|
||||
smokeLocations.add(CmdHome.this.myFaction.getHome());
|
||||
smokeLocations.add(CmdHome.this.myFaction.getHome().clone().add(0, 1, 0));
|
||||
SmokeUtil.spawnCloudRandom(smokeLocations, Conf.homesTeleportCommandSmokeEffectThickness);
|
||||
}
|
||||
|
||||
CmdHome.this.me.teleport(CmdHome.this.myFaction.getHome());
|
||||
this.doWarmUp(WarmUpUtil.Warmup.HOME, TL.WARMUPS_NOTIFY_TELEPORT, "Home", () -> {
|
||||
// Create a smoke effect
|
||||
if (Conf.homesTeleportCommandSmokeEffectEnabled) {
|
||||
List<Location> smokeLocations = new ArrayList<>();
|
||||
smokeLocations.add(loc);
|
||||
smokeLocations.add(loc.add(0, 1, 0));
|
||||
smokeLocations.add(CmdHome.this.myFaction.getHome());
|
||||
smokeLocations.add(CmdHome.this.myFaction.getHome().clone().add(0, 1, 0));
|
||||
SmokeUtil.spawnCloudRandom(smokeLocations, Conf.homesTeleportCommandSmokeEffectThickness);
|
||||
}
|
||||
|
||||
CmdHome.this.me.teleport(CmdHome.this.myFaction.getHome());
|
||||
}, this.p.getConfig().getLong("warmups.f-home", 0));
|
||||
}
|
||||
|
||||
|
||||
@@ -52,43 +52,32 @@ public class CmdList extends FCommand {
|
||||
// remove exempt factions
|
||||
if (fme != null && fme.getPlayer() != null && !fme.getPlayer().hasPermission("factions.show.bypassexempt")) {
|
||||
List<String> exemptFactions = SavageFactions.plugin.getConfig().getStringList("show-exempt");
|
||||
Iterator<Faction> factionIterator = factionList.iterator();
|
||||
|
||||
while (factionIterator.hasNext()) {
|
||||
Faction next = factionIterator.next();
|
||||
if (exemptFactions.contains(next.getTag()))
|
||||
factionIterator.remove();
|
||||
}
|
||||
factionList.removeIf(next -> exemptFactions.contains(next.getTag()));
|
||||
}
|
||||
|
||||
// Sort by total followers first
|
||||
Collections.sort(factionList, new Comparator<Faction>() {
|
||||
@Override
|
||||
public int compare(Faction f1, Faction f2) {
|
||||
int f1Size = f1.getFPlayers().size();
|
||||
int f2Size = f2.getFPlayers().size();
|
||||
if (f1Size < f2Size) {
|
||||
return 1;
|
||||
} else if (f1Size > f2Size) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
Collections.sort(factionList, (f1, f2) -> {
|
||||
int f1Size = f1.getFPlayers().size();
|
||||
int f2Size = f2.getFPlayers().size();
|
||||
if (f1Size < f2Size) {
|
||||
return 1;
|
||||
} else if (f1Size > f2Size) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
// Then sort by how many members are online now
|
||||
Collections.sort(factionList, new Comparator<Faction>() {
|
||||
@Override
|
||||
public int compare(Faction f1, Faction f2) {
|
||||
int f1Size = f1.getFPlayersWhereOnline(true).size();
|
||||
int f2Size = f2.getFPlayersWhereOnline(true).size();
|
||||
if (f1Size < f2Size) {
|
||||
return 1;
|
||||
} else if (f1Size > f2Size) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
Collections.sort(factionList, (f1, f2) -> {
|
||||
int f1Size = f1.getFPlayersWhereOnline(true).size();
|
||||
int f2Size = f2.getFPlayersWhereOnline(true).size();
|
||||
if (f1Size < f2Size) {
|
||||
return 1;
|
||||
} else if (f1Size > f2Size) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
ArrayList<String> lines = new ArrayList<>();
|
||||
|
||||
@@ -30,7 +30,6 @@ public class CmdReload extends FCommand {
|
||||
SavageFactions.plugin.reloadConfig();
|
||||
SavageFactions.plugin.changeItemIDSInConfig();
|
||||
SavageFactions.plugin.loadLang();
|
||||
int version = Integer.parseInt(ReflectionUtils.PackageType.getServerVersion().split("_")[1]);
|
||||
|
||||
|
||||
if (SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight")) {
|
||||
|
||||
@@ -17,9 +17,8 @@ public class CmdSeeChunk extends FCommand {
|
||||
|
||||
//Used a hashmap cuz imma make a particle selection gui later, will store it where the boolean is rn.
|
||||
public static HashMap<String, Boolean> seeChunkMap = new HashMap<>();
|
||||
Long interval = 10L;
|
||||
Long interval;
|
||||
private boolean useParticles;
|
||||
private int length;
|
||||
private ParticleEffect effect;
|
||||
private int taskID = -1;
|
||||
|
||||
@@ -72,18 +71,15 @@ public class CmdSeeChunk extends FCommand {
|
||||
}
|
||||
|
||||
private void startTask() {
|
||||
taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Iterator<String> itr = seeChunkMap.keySet().iterator();
|
||||
while (itr.hasNext()) {
|
||||
Object nameObject = itr.next();
|
||||
String name = nameObject + "";
|
||||
Player player = Bukkit.getPlayer(name);
|
||||
showBorders(player);
|
||||
}
|
||||
manageTask();
|
||||
taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, () -> {
|
||||
Iterator<String> itr = seeChunkMap.keySet().iterator();
|
||||
while (itr.hasNext()) {
|
||||
Object nameObject = itr.next();
|
||||
String name = nameObject + "";
|
||||
Player player = Bukkit.getPlayer(name);
|
||||
showBorders(player);
|
||||
}
|
||||
manageTask();
|
||||
}, 0, interval);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@ public class CmdShowClaims extends FCommand {
|
||||
chunks.setLength(0);
|
||||
}
|
||||
}
|
||||
|
||||
sendMessage("");
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ public class CmdTnt extends FCommand {
|
||||
return;
|
||||
}
|
||||
if (fme.getFaction().getTnt() < amount) {
|
||||
fme.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH.toString());
|
||||
fme.msg(TL.COMMAND_TNT_WIDTHDRAW_NOTENOUGH);
|
||||
return;
|
||||
}
|
||||
int fullStacks = amount / 64;
|
||||
|
||||
@@ -30,16 +30,9 @@ public class CmdTpBanner extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
final FactionsPlayerListener fpl = new FactionsPlayerListener();
|
||||
|
||||
if (FactionsBlockListener.bannerLocations.containsKey(fme.getTag())) {
|
||||
fme.msg(TL.COMMAND_TPBANNER_SUCCESS);
|
||||
this.doWarmUp(WarmUpUtil.Warmup.BANNER, TL.WARMUPS_NOTIFY_TELEPORT, "Banner", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
me.teleport(FactionsBlockListener.bannerLocations.get(fme.getTag()));
|
||||
}
|
||||
}, this.p.getConfig().getLong("warmups.f-banner", 0));
|
||||
this.doWarmUp(WarmUpUtil.Warmup.BANNER, TL.WARMUPS_NOTIFY_TELEPORT, "Banner", () -> me.teleport(FactionsBlockListener.bannerLocations.get(fme.getTag())), this.p.getConfig().getLong("warmups.f-banner", 0));
|
||||
} else {
|
||||
fme.msg(TL.COMMAND_TPBANNER_NOTSET);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user