Merge remote-tracking branch 'origin/1.6.x' into 1.6.x

This commit is contained in:
droppinganvil 2020-02-16 22:59:48 -06:00
commit dfbfbf9981
11 changed files with 171 additions and 27 deletions

View File

@ -23,7 +23,7 @@ A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Server VErsion (please complete the following information):**
**Server Version (please complete the following information):**
- Spigot Version: [e.g. Paperspigot 1.8.8]
- Factions Version [use /f version]
- Minecraft Version: [If a bug is dependent on client version]

View File

@ -4,7 +4,7 @@
<groupId>com.massivecraft</groupId>
<artifactId>Factions</artifactId>
<version>1.6.9.5-2.2.7-RC</version>
<version>1.6.9.5-2.2.9-RC</version>
<packaging>jar</packaging>
<name>SaberFactions</name>

View File

@ -52,6 +52,7 @@ import java.io.*;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.nio.file.Files;
import java.nio.file.OpenOption;
import java.nio.file.Paths;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
@ -430,6 +431,18 @@ public class FactionsPlugin extends MPlugin {
@Override
public void onDisable() {
try {
String path = Paths.get(getDataFolder().getAbsolutePath()).toAbsolutePath().toString() + File.separator + "reserves.json";
File file = new File(path);
if (!file.exists()) {
file.getParentFile().mkdirs();
file.createNewFile();
}
Files.write(Paths.get(file.getPath()),getGsonBuilder().create().toJson(reserveObjects).getBytes());
} catch (IOException e) {
e.printStackTrace();
}
// only save data if plugin actually completely loaded successfully
if (this.loadSuccessful) Conf.saveSync();

View File

@ -72,13 +72,14 @@ public class CmdDisband extends FCommand {
return;
}
boolean access = false;
if (context.fPlayer.getPlayer().hasMetadata("disband_confirm") && (time = context.fPlayer.getPlayer().getMetadata("disband_confirm").get(0).asLong()) != 0L && System.currentTimeMillis() - time <= TimeUnit.SECONDS.toMillis(3L)) {
access = true;
}
if (!access) {
if(Conf.useDisbandGUI) {
if(Conf.useDisbandGUI && !context.fPlayer.isAdminBypassing() || !context.player.isOp()) {
if (!disbandMap.containsKey(context.player.getUniqueId().toString())) {
new FDisbandFrame(context.faction).buildGUI(context.fPlayer);
return;

View File

@ -74,8 +74,10 @@ public class CmdSeeChunk extends FCommand {
for (Object nameObject : seeChunkMap.keySet()) {
String name = nameObject + "";
Player player = Bukkit.getPlayer(name);
if (player != null) {
showBorders(player);
}
}
manageTask();
}, 0, interval);
}
@ -110,24 +112,19 @@ public class CmdSeeChunk extends FCommand {
private void showPillar(Player player, World world, int blockX, int blockZ) {
for (int blockY = 0; blockY < player.getLocation().getBlockY() + 30; blockY++) {
Location loc = new Location(world, blockX, blockY, blockZ).add(0.5, 0, 0.5);
if (loc.getBlock().getType() != Material.AIR) {
continue;
}
if (loc.getBlock().getType() != Material.AIR) continue;
if (useParticles) {
if (FactionsPlugin.getInstance().useNonPacketParticles) {
// Dust options only exists in the 1.13 API, so we use an
// alternative method to achieve this in lower versions.
if (FactionsPlugin.getInstance().mc113 || FactionsPlugin.getInstance().mc114) {
if (FactionsPlugin.getInstance().mc113 || FactionsPlugin.getInstance().mc114 || FactionsPlugin.getInstance().mc115) {
player.spawnParticle(Particle.REDSTONE, loc, 0, new Particle.DustOptions(Color.RED, 1));
} else {
player.getWorld().spawnParticle(Particle.REDSTONE, loc, 0, 255, 0, 0, 1);
}
} else {
this.effect.display(0, 0, 0, 0, 1, loc, player);
}
} else {
Material type = blockY % 5 == 0 ? XMaterial.REDSTONE_LAMP.parseMaterial() : XMaterial.BLACK_STAINED_GLASS.parseMaterial();
VisualizeUtil.addLocation(player, loc, type);

View File

@ -26,7 +26,7 @@ public class CmdTntFill extends FCommand {
public CmdTntFill() {
super();
this.aliases.add("tntfill");
this.aliases.addAll(Aliases.tnt_tntfill);
this.requiredArgs.add("radius");
this.requiredArgs.add("amount");

View File

@ -162,20 +162,22 @@ public class FactionsBlockListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
Faction at = Board.getInstance().getFactionAt(new FLocation(event.getBlockPlaced()));
if (!event.canBuild()) return;
if (event.getBlockPlaced().getType() == Material.FIRE) return;
boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial());
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "build", false)) {
event.setCancelled(true);
return;
}
if (event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial()) && Conf.spawnerLock) {
if (isSpawner) {
if (Conf.spawnerLock) {
event.setCancelled(true);
event.getPlayer().sendMessage(FactionsPlugin.getInstance().color(TL.COMMAND_SPAWNER_LOCK_CANNOT_PLACE.toString()));
}
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockFromTo(BlockFromToEvent event) {
@ -494,12 +496,24 @@ public class FactionsBlockListener implements Listener {
Block block = event.getBlock();
Faction at = Board.getInstance().getFactionAt(new FLocation(block));
boolean isSpawner = event.getBlock().getType() == XMaterial.SPAWNER.parseMaterial();
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), !isSpawner ? "destroy" : "mine spawners", false)) {
boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial());
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {
event.setCancelled(true);
return;
}
if (block != null && isSpawner) {
FPlayer fme = FPlayers.getInstance().getByPlayer(event.getPlayer());
if (fme == null || !fme.hasFaction()) return;
if (isSpawner) {
Access access = fme.getFaction().getAccess(fme, PermissableAction.SPAWNER);
if (access != Access.ALLOW && fme.getRole() != Role.LEADER) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "mine spawners");
}
}
if (isSpawner && !fme.isAdminBypassing()) {
ItemStack item = new ItemStack(block.getType(), 1, block.getData());
if (at != null && at.isNormal()) {
FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer());

View File

@ -338,7 +338,7 @@ public class FactionsPlayerListener implements Listener {
return PermissableAction.DOOR;
if (material.name().toUpperCase().contains("BUTTON") || material.name().toUpperCase().contains("PRESSURE") || material.name().contains("DIODE") || material.name().contains("COMPARATOR"))
return PermissableAction.BUTTON;
if (FactionsPlugin.instance.mc113 || FactionsPlugin.instance.mc114) {
if (FactionsPlugin.instance.mc113 || FactionsPlugin.instance.mc114 || FactionsPlugin.getInstance().mc115) {
switch (material) {
case LEVER:
return PermissableAction.LEVER;
@ -381,6 +381,8 @@ public class FactionsPlayerListener implements Listener {
case TRAPPED_CHEST:
case CHEST_MINECART:
case BARREL:
case SHULKER_BOX:
case BLACK_SHULKER_BOX:
case BLUE_SHULKER_BOX:
@ -918,13 +920,22 @@ public class FactionsPlayerListener implements Listener {
}
}
@EventHandler
public void onLogoutMove(PlayerMoveEvent e) {
LogoutHandler handler = LogoutHandler.getByName(e.getPlayer().getName());
if (Objects.requireNonNull(e.getTo()).getBlockX() == e.getFrom().getBlockX() &&
e.getTo().getBlockY() == e.getFrom().getBlockY() &&
e.getTo().getBlockZ() == e.getFrom().getBlockZ())
return;
if (handler.isLogoutActive(e.getPlayer())) {
handler.cancelLogout(e.getPlayer());
e.getPlayer().sendMessage(String.valueOf(TL.COMMAND_LOGOUT_MOVED));
}
if (CmdWild.waitingTeleport.containsKey(e.getPlayer())) {
CmdWild.waitingTeleport.remove(e.getPlayer());
FPlayers.getInstance().getByPlayer(e.getPlayer()).msg(TL.COMMAND_WILD_INTERUPTED);

View File

@ -0,0 +1,108 @@
package com.massivecraft.factions.util;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Factions - Developed by Driftay.
* All rights reserved 2020.
* Creation Date: 1/30/2020
*/
public class TimeUtil {
public static long parseDateDiff(String time, boolean future) throws Exception {
Pattern timePattern = Pattern.compile("(?:([0-9]+)\\s*y[a-z]*[,\\s]*)?(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?(?:([0-9]+)\\s*w[a-z]*[,\\s]*)?(?:([0-9]+)\\s*d[a-z]*[,\\s]*)?(?:([0-9]+)\\s*h[a-z]*[,\\s]*)?(?:([0-9]+)\\s*m[a-z]*[,\\s]*)?(?:([0-9]+)\\s*(?:s[a-z]*)?)?", 2);
Matcher m = timePattern.matcher(time);
int years = 0;
int months = 0;
int weeks = 0;
int days = 0;
int hours = 0;
int minutes = 0;
int seconds = 0;
boolean found = false;
while (m.find()) {
if (m.group() != null) {
if (m.group().isEmpty()) continue;
for (int i = 0; i < m.groupCount(); ++i) {
if (m.group(i) != null && !m.group(i).isEmpty()) {
found = true;
break;
}
}
if (!found) continue;
if (m.group(1) != null && !m.group(1).isEmpty()) years = Integer.parseInt(m.group(1));
if (m.group(2) != null && !m.group(2).isEmpty()) months = Integer.parseInt(m.group(2));
if (m.group(3) != null && !m.group(3).isEmpty()) weeks = Integer.parseInt(m.group(3));
if (m.group(4) != null && !m.group(4).isEmpty()) days = Integer.parseInt(m.group(4));
if (m.group(5) != null && !m.group(5).isEmpty()) hours = Integer.parseInt(m.group(5));
if (m.group(6) != null && !m.group(6).isEmpty()) minutes = Integer.parseInt(m.group(6));
if (m.group(7) != null && !m.group(7).isEmpty()) {
seconds = Integer.parseInt(m.group(7));
break;
}
break;
}
}
if (!found) throw new Exception("Illegal Date");
if (years > 20) throw new Exception("Illegal Date");
Calendar c = new GregorianCalendar();
if (years > 0) c.add(Calendar.YEAR, years * (future ? 1 : -1));
if (months > 0) c.add(Calendar.MONTH, months * (future ? 1 : -1));
if (weeks > 0) c.add(Calendar.WEEK_OF_YEAR, weeks * (future ? 1 : -1));
if (days > 0) c.add(Calendar.DATE, days * (future ? 1 : -1));
if (hours > 0) c.add(Calendar.HOUR_OF_DAY, hours * (future ? 1 : -1));
if (minutes > 0) c.add(Calendar.MINUTE, minutes * (future ? 1 : -1));
if (seconds > 0) c.add(Calendar.SECOND, seconds * (future ? 1 : -1));
System.out.println("current: " + c.getTimeInMillis() + " Time: " + System.currentTimeMillis() + " Form: " + formatTime(c.getTimeInMillis() / 1000L));
return c.getTimeInMillis() / 1000L;
}
public static String formatDifference(long time) {
if (time == 0L) return "Never";
long day = TimeUnit.SECONDS.toDays(time);
long hours = TimeUnit.SECONDS.toHours(time) - day * 24L;
long minutes = TimeUnit.SECONDS.toMinutes(time) - TimeUnit.SECONDS.toHours(time) * 60L;
long seconds = TimeUnit.SECONDS.toSeconds(time) - TimeUnit.SECONDS.toMinutes(time) * 60L;
StringBuilder sb = new StringBuilder();
if (day > 0L) sb.append(day).append((day == 1L) ? "day" : "days").append(" ");
if (hours > 0L) sb.append(hours).append((hours == 1L) ? "h" : "h").append(" ");
if (minutes > 0L) sb.append(minutes).append((minutes == 1L) ? "m" : "m").append(" ");
if (seconds > 0L) sb.append(seconds).append((seconds == 1L) ? "s" : "s");
String diff = sb.toString().trim();
return diff.isEmpty() ? "Now" : diff;
}
public static String formatTime(long time) {
if (time == System.currentTimeMillis()) return "Now";
if (time == -1L) return "Never";
return formatDifference(time - System.currentTimeMillis() / 1000L);
}
}

View File

@ -25,7 +25,7 @@ public class FUpgradeFrame {
public FUpgradeFrame(Faction f) {
this.gui = new Gui(FactionsPlugin.getInstance(),
FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.rows", 5),
FactionsPlugin.getInstance().getConfig().getInt("fupgrades.MainMenu.Rows", 5),
FactionsPlugin.getInstance().getConfig().getString("fupgrades.MainMenu.Title").replace("{faction}", f.getTag()));
}
@ -95,7 +95,7 @@ public class FUpgradeFrame {
private void updateFactionPowerBoost(Faction f) {
double boost = FactionsPlugin.getInstance().getConfig().getDouble("fupgrades.MainMenu.Power.Power-Boost.level-" + (f.getUpgrade(UpgradeType.POWER) + 1));
if (boost < 0.0) return;
f.setPowerBoost(f.getPower() + boost);
f.setPowerBoost(boost);
}

View File

@ -2,7 +2,7 @@ name: Factions
version: ${project.version}
api-version: 1.13
main: com.massivecraft.factions.FactionsPlugin
authors: [Olof Larsson, Brett Flannigan, drtshock, ProSavage, SvenjaReißaus, FroggyKnight, Driftay]
authors: [Olof Larsson, Brett Flannigan, drtshock, ProSavage, SvenjaReißaus, Driftay]
softdepend: [Skript, CoreProtect, PlayerVaults, PlaceholderAPI, MVdWPlaceholderAPI, PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, iChat, LocalAreaChat, LWC, nChat, ChatManager, CAPI, AuthMe, Vault, Spout, WorldEdit, WorldGuard, AuthDB, CaptureThePoints, CombatTag, dynmap, FactionsTop]
commands: