So many improvements

This commit is contained in:
DroppingAnvil 2019-10-13 02:53:45 -05:00 committed by GitHub
commit 40d6054275
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 12 deletions

View File

@ -2,6 +2,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.listeners.FactionsPlayerListener;
import com.massivecraft.factions.shop.ShopConfig;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
@ -28,6 +29,11 @@ public class CmdReload extends FCommand {
if (FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight")) {
FactionsPlugin.getInstance().factionsFlight = true;
}
if (!FactionsPlugin.getInstance().mc17) {
FactionsPlayerListener.loadCorners();
}
long timeReload = (System.currentTimeMillis() - timeInitStart);
context.msg(TL.COMMAND_RELOAD_TIME, timeReload);

View File

@ -47,7 +47,7 @@ import java.util.logging.Level;
public class FactionsPlayerListener implements Listener {
HashMap<Player, Boolean> fallMap = new HashMap<>();
private Set<FLocation> corners;
public static Set<FLocation> corners;
// Holds the next time a player can have a map shown.
private HashMap<UUID, Long> showTimes = new HashMap<>();
// for handling people who repeatedly spam attempts to open a door (or similar) in another faction's territory
@ -58,16 +58,20 @@ public class FactionsPlayerListener implements Listener {
initPlayer(player);
}
if (!FactionsPlugin.getInstance().mc17) {
this.corners = new HashSet<>();
loadCorners();
}
}
public static void loadCorners() {
FactionsPlayerListener.corners = new HashSet<>();
for (World world : FactionsPlugin.getInstance().getServer().getWorlds()) {
WorldBorder border = world.getWorldBorder();
if (border != null) {
int cornerCoord = (int) ((border.getSize() - 1.0) / 2.0);
this.corners.add(new FLocation(world.getName(), FLocation.blockToChunk(cornerCoord), FLocation.blockToChunk(cornerCoord)));
this.corners.add(new FLocation(world.getName(), FLocation.blockToChunk(cornerCoord), FLocation.blockToChunk(-cornerCoord)));
this.corners.add(new FLocation(world.getName(), FLocation.blockToChunk(-cornerCoord), FLocation.blockToChunk(cornerCoord)));
this.corners.add(new FLocation(world.getName(), FLocation.blockToChunk(-cornerCoord), FLocation.blockToChunk(-cornerCoord)));
}
FactionsPlayerListener.corners.add(new FLocation(world.getName(), FLocation.blockToChunk(cornerCoord), FLocation.blockToChunk(cornerCoord)));
FactionsPlayerListener.corners.add(new FLocation(world.getName(), FLocation.blockToChunk(cornerCoord), FLocation.blockToChunk(-cornerCoord)));
FactionsPlayerListener.corners.add(new FLocation(world.getName(), FLocation.blockToChunk(-cornerCoord), FLocation.blockToChunk(cornerCoord)));
FactionsPlayerListener.corners.add(new FLocation(world.getName(), FLocation.blockToChunk(-cornerCoord), FLocation.blockToChunk(-cornerCoord)));
}
}
}

View File

@ -28,6 +28,9 @@ public class CornerTask extends BukkitRunnable {
FLocation fLocation = surrounding.remove(0);
if (fPlayer.attemptClaim(fPlayer.getFaction(), fLocation, true)) {
++amount;
} else {
fPlayer.sendMessage(TL.COMMAND_CORNER_FAIL_WITH_FEEDBACK.toString().replace("&", "§") + amount);
cancel();
}
}
}

View File

@ -123,6 +123,7 @@ public enum TL {
COMMAND_CORNER_CANT_CLAIM("&c&l[!] &cYou may not claim this corner!"),
COMMAND_CORNER_CLAIMED("\n&2&l[!] &aYou have claimed the corner successfully, totalling in &b%1$d &achunks!\n"),
COMMAND_CORNER_ATTEMPTING_CLAIM("&c&l[!] &7Attempting to claim corner..."),
COMMAND_CORNER_FAIL_WITH_FEEDBACK("&c&l[!] &cOne or more claims in this corner could not be claimed! Total chunks claimed:&b "),
COMMAND_CORNER_NOT_CORNER("&c&l[!] &7You must be in a corner to use this command!"),
COMMAND_CORNER_DESCRIPTION("claim a corner at world border"),
COMMAND_CORNERLIST_DESCRIPTION("list of all corners"),