Code Overhaul + Minor Fixes
This commit is contained in:
parent
7f53b52d1c
commit
8c6107859e
@ -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,15 +66,12 @@ 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() {
|
||||
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 {
|
||||
fme.msg(TL.COMMAND_FWARP_INVALID_WARP, warpName);
|
||||
|
@ -123,9 +123,7 @@ public class CmdHome extends FCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
this.doWarmUp(WarmUpUtil.Warmup.HOME, TL.WARMUPS_NOTIFY_TELEPORT, "Home", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
this.doWarmUp(WarmUpUtil.Warmup.HOME, TL.WARMUPS_NOTIFY_TELEPORT, "Home", () -> {
|
||||
// Create a smoke effect
|
||||
if (Conf.homesTeleportCommandSmokeEffectEnabled) {
|
||||
List<Location> smokeLocations = new ArrayList<>();
|
||||
@ -137,7 +135,6 @@ public class CmdHome extends FCommand {
|
||||
}
|
||||
|
||||
CmdHome.this.me.teleport(CmdHome.this.myFaction.getHome());
|
||||
}
|
||||
}, this.p.getConfig().getLong("warmups.f-home", 0));
|
||||
}
|
||||
|
||||
|
@ -52,19 +52,12 @@ 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) {
|
||||
Collections.sort(factionList, (f1, f2) -> {
|
||||
int f1Size = f1.getFPlayers().size();
|
||||
int f2Size = f2.getFPlayers().size();
|
||||
if (f1Size < f2Size) {
|
||||
@ -73,13 +66,10 @@ public class CmdList extends FCommand {
|
||||
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) {
|
||||
Collections.sort(factionList, (f1, f2) -> {
|
||||
int f1Size = f1.getFPlayersWhereOnline(true).size();
|
||||
int f2Size = f2.getFPlayersWhereOnline(true).size();
|
||||
if (f1Size < f2Size) {
|
||||
@ -88,7 +78,6 @@ public class CmdList extends FCommand {
|
||||
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,9 +71,7 @@ public class CmdSeeChunk extends FCommand {
|
||||
}
|
||||
|
||||
private void startTask() {
|
||||
taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, () -> {
|
||||
Iterator<String> itr = seeChunkMap.keySet().iterator();
|
||||
while (itr.hasNext()) {
|
||||
Object nameObject = itr.next();
|
||||
@ -83,7 +80,6 @@ public class CmdSeeChunk extends FCommand {
|
||||
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);
|
||||
}
|
||||
|
@ -113,9 +113,7 @@ public class EngineDynmap {
|
||||
}
|
||||
|
||||
// Shedule non thread safe sync at the end!
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, () -> {
|
||||
|
||||
final Map<String, TempMarker> homes = createHomes();
|
||||
final Map<String, TempAreaMarker> areas = createAreas();
|
||||
@ -133,7 +131,6 @@ public class EngineDynmap {
|
||||
updateHomes(homes);
|
||||
updateAreas(areas);
|
||||
updatePlayersets(playerSets);
|
||||
}
|
||||
}, 100L, 100L);
|
||||
}
|
||||
|
||||
|
@ -332,12 +332,7 @@ public class FactionsBlockListener implements Listener {
|
||||
as.setCustomNameVisible(true); //This makes the text appear no matter if your looking at the entity or not
|
||||
final ArmorStand armorStand = as;
|
||||
final String tag = fme.getTag();
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(SavageFactions.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
bannerCooldownMap.remove(tag);
|
||||
}
|
||||
}, Long.parseLong(bannerCooldown + ""));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(SavageFactions.plugin, () -> bannerCooldownMap.remove(tag), Long.parseLong(bannerCooldown + ""));
|
||||
final Block banner = e.getBlockPlaced();
|
||||
final Material bannerType = banner.getType();
|
||||
final Faction bannerFaction = fme.getFaction();
|
||||
@ -345,13 +340,11 @@ public class FactionsBlockListener implements Listener {
|
||||
// e.getPlayer().getWorld().playSound(e.getPlayer().getLocation(), Sound.ENTITY_LIGHTNING_IMPACT,2.0F,0.5F);
|
||||
final int radius = SavageFactions.plugin.getConfig().getInt("fbanners.Banner-Effect-Radius");
|
||||
final List<String> effects = SavageFactions.plugin.getConfig().getStringList("fbanners.Effects");
|
||||
final int affectorTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final int affectorTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, () -> {
|
||||
|
||||
for (Entity e : banner.getLocation().getWorld().getNearbyEntities(banner.getLocation(), radius, 255, radius)) {
|
||||
if (e instanceof Player) {
|
||||
Player player = (Player) e;
|
||||
for (Entity e1 : banner.getLocation().getWorld().getNearbyEntities(banner.getLocation(), radius, 255, radius)) {
|
||||
if (e1 instanceof Player) {
|
||||
Player player = (Player) e1;
|
||||
FPlayer fplayer = FPlayers.getInstance().getByPlayer(player);
|
||||
if (fplayer.getFaction() == bannerFaction) {
|
||||
for (String effect : effects) {
|
||||
@ -367,17 +360,13 @@ public class FactionsBlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0L, 20L);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(SavageFactions.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(SavageFactions.plugin, () -> {
|
||||
banner.setType(Material.AIR);
|
||||
as.remove();
|
||||
banner.getWorld().strikeLightningEffect(banner.getLocation());
|
||||
Bukkit.getScheduler().cancelTask(affectorTask);
|
||||
bannerLocations.remove(bannerFaction.getTag());
|
||||
}
|
||||
}, Long.parseLong(bannerTime + ""));
|
||||
} else {
|
||||
fme.msg(TL.WARBANNER_INVALIDLOC);
|
||||
|
@ -196,15 +196,12 @@ public class FactionsChatListener implements Listener {
|
||||
}
|
||||
|
||||
private void doWarmup(final String warp, final FPlayer fme) {
|
||||
WarmUpUtil.process(fme, WarmUpUtil.Warmup.WARP, TL.WARMUPS_NOTIFY_TELEPORT, warp, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
WarmUpUtil.process(fme, WarmUpUtil.Warmup.WARP, TL.WARMUPS_NOTIFY_TELEPORT, warp, () -> {
|
||||
Player player = Bukkit.getPlayer(fme.getPlayer().getUniqueId());
|
||||
if (player != null) {
|
||||
player.teleport(fme.getFaction().getWarp(warp).getLocation());
|
||||
fme.msg(TL.COMMAND_FWARP_WARPED, warp);
|
||||
}
|
||||
}
|
||||
}, SavageFactions.plugin.getConfig().getLong("warmups.f-warp", 0));
|
||||
}
|
||||
|
||||
|
@ -296,13 +296,10 @@ public class FactionsPlayerListener implements Listener {
|
||||
me.login(); // set kills / deaths
|
||||
|
||||
// Check for Faction announcements. Let's delay this so they actually see it.
|
||||
Bukkit.getScheduler().runTaskLater(SavageFactions.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getScheduler().runTaskLater(SavageFactions.plugin, () -> {
|
||||
if (me.isOnline()) {
|
||||
me.getFaction().sendUnreadAnnouncements(me);
|
||||
}
|
||||
}
|
||||
}, 33L); // Don't ask me why.
|
||||
|
||||
if (SavageFactions.plugin.getConfig().getBoolean("scoreboard.default-enabled", false)) {
|
||||
@ -322,13 +319,7 @@ public class FactionsPlayerListener implements Listener {
|
||||
|
||||
|
||||
fallMap.put(me.getPlayer(), false);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(SavageFactions.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fallMap.remove(me.getPlayer());
|
||||
|
||||
}
|
||||
}, 180L);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(SavageFactions.plugin, () -> fallMap.remove(me.getPlayer()), 180L);
|
||||
|
||||
|
||||
if (me.isSpyingChat() && !player.hasPermission(Permission.CHATSPY.node)) {
|
||||
|
@ -45,12 +45,9 @@ public class FTeamWrapper {
|
||||
|
||||
|
||||
if (updating.add(faction)) {
|
||||
Bukkit.getScheduler().runTask(SavageFactions.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getScheduler().runTask(SavageFactions.plugin, () -> {
|
||||
updating.remove(faction);
|
||||
applyUpdates(faction);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -21,12 +21,9 @@ public class WarmUpUtil {
|
||||
player.msg(TL.WARMUPS_ALREADY);
|
||||
} else {
|
||||
player.msg(translationKey.format(action, delay));
|
||||
int id = SavageFactions.plugin.getServer().getScheduler().runTaskLater(SavageFactions.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int id = SavageFactions.plugin.getServer().getScheduler().runTaskLater(SavageFactions.plugin, () -> {
|
||||
player.stopWarmup();
|
||||
runnable.run();
|
||||
}
|
||||
}, delay * 20).getTaskId();
|
||||
player.addWarmup(warmup, id);
|
||||
}
|
||||
|
@ -102,29 +102,23 @@ public class WarpGUI implements InventoryHolder, FactionGUI {
|
||||
} else {
|
||||
fme.setEnteringPassword(true, warp);
|
||||
fme.msg(TL.COMMAND_FWARP_PASSWORD_REQUIRED);
|
||||
Bukkit.getScheduler().runTaskLater(SavageFactions.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getScheduler().runTaskLater(SavageFactions.plugin, () -> {
|
||||
if (fme.isEnteringPassword()) {
|
||||
fme.msg(TL.COMMAND_FWARP_PASSWORD_TIMEOUT);
|
||||
fme.setEnteringPassword(false, "");
|
||||
}
|
||||
}
|
||||
}, SavageFactions.plugin.getConfig().getInt("fwarp-gui.password-timeout", 5) * 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void doWarmup(final String warp) {
|
||||
WarmUpUtil.process(fme, WarmUpUtil.Warmup.WARP, TL.WARMUPS_NOTIFY_TELEPORT, warp, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
WarmUpUtil.process(fme, WarmUpUtil.Warmup.WARP, TL.WARMUPS_NOTIFY_TELEPORT, warp, () -> {
|
||||
Player player = Bukkit.getPlayer(fme.getPlayer().getUniqueId());
|
||||
if (player != null) {
|
||||
player.teleport(fme.getFaction().getWarp(warp).getLocation());
|
||||
fme.msg(TL.COMMAND_FWARP_WARPED, warp);
|
||||
}
|
||||
}
|
||||
}, SavageFactions.plugin.getConfig().getLong("warmups.f-warp", 0));
|
||||
}
|
||||
|
||||
|
@ -278,12 +278,7 @@ public abstract class MPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
if (async) {
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
command.execute(sender, args);
|
||||
}
|
||||
});
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, () -> command.execute(sender, args));
|
||||
} else {
|
||||
command.execute(sender, args);
|
||||
}
|
||||
|
@ -873,12 +873,7 @@ public abstract class MemoryFPlayer implements FPlayer {
|
||||
// Short task so we're just doing it in method. Not clean but eh.
|
||||
if (cooldown > 0) {
|
||||
setTakeFallDamage(false);
|
||||
Bukkit.getScheduler().runTaskLater(SavageFactions.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setTakeFallDamage(true);
|
||||
}
|
||||
}, 20L * cooldown);
|
||||
Bukkit.getScheduler().runTaskLater(SavageFactions.plugin, () -> setTakeFallDamage(true), 20L * cooldown);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,9 +80,7 @@ public class DiscUtil {
|
||||
lock.unlock();
|
||||
}
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(SavageFactions.plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(SavageFactions.plugin, () -> {
|
||||
lock.lock();
|
||||
try {
|
||||
write(file, content);
|
||||
@ -91,7 +89,6 @@ public class DiscUtil {
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user