Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 10 additions & 24 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<java.version>1.16</java.version>
<project.bukkitAPIVersion>1.15</project.bukkitAPIVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<towny.version>0.101.2.5</towny.version>
<towny.version>0.102.0.0</towny.version>
</properties>

<repositories>
Expand All @@ -38,32 +38,18 @@
</repositories>

<dependencies>

<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.21.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- <dependency>
<groupId>com.palmergames.bukkit.towny</groupId>
<artifactId>towny</artifactId>
<version>${towny.version}</version>
<scope>provided</scope>
</dependency>-->
<dependency>
<groupId>com.github.TownyAdvanced.Towny</groupId>
<artifactId>towny</artifactId>
<version>master-4907b3123a-1</version>
</dependency>
<!--
<dependency>
<groupId>us.dynmap</groupId>
<artifactId>dynmap-api</artifactId>
<version>2.5</version>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.21.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.palmergames.bukkit.towny</groupId>
<artifactId>towny</artifactId>
<version>${towny.version}</version>
<scope>provided</scope>
</dependency>
-->
<dependency>
<groupId>us.dynmap</groupId>
<artifactId>dynmap-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class TownyProvinces extends JavaPlugin {
public static final Object PRICE_RECALCULATION_JOB_LOCK = new Object();
public static final Object MAP_DISPLAY_JOB_LOCK = new Object();
private static TownyProvinces plugin;
private static final Version requiredTownyVersion = Version.fromString("0.101.2.5");
private static final Version requiredTownyVersion = Version.fromString("0.102.0.0");
private final TaskScheduler scheduler;

public TownyProvinces() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public static boolean startTask() {

public static void reloadIntegrations() {

mapDisplayTask.cancel();
if (mapDisplayTask != null)
mapDisplayTask.cancel();
synchronized (TownyProvinces.MAP_DISPLAY_JOB_LOCK) {
synchronized (TownyProvinces.REGION_REGENERATION_JOB_LOCK) {
synchronized (TownyProvinces.PRICE_RECALCULATION_JOB_LOCK) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package io.github.townyadvanced.townyprovinces.objects;

import com.palmergames.bukkit.towny.object.Coord;
import com.palmergames.util.FileMgmt;
import io.github.townyadvanced.townyprovinces.settings.TownyProvincesSettings;
import io.github.townyadvanced.townyprovinces.util.FileUtil;

import org.bukkit.Location;

import java.io.File;
Expand Down Expand Up @@ -36,7 +37,7 @@ public class Region {
private Set<Province> provinces; //Set of provinces. Assigned when required

public Region(File regionDefinitionFile) {
Map<String, String> regionDefinitions = FileMgmt.loadFileIntoHashMap(regionDefinitionFile);
Map<String, String> regionDefinitions = FileUtil.loadFileIntoHashMap(regionDefinitionFile);
Comment thread
Goosius1 marked this conversation as resolved.
this.name = TownyProvincesSettings.getRegionName(regionDefinitions);
this.brushSquareRadiusInChunks = TownyProvincesSettings.getBrushSquareRadiusInChunks(regionDefinitions);
this.provinceSquareRadius = TownyProvincesSettings.calculateProvinceSquareRadius(regionDefinitions);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
package io.github.townyadvanced.townyprovinces.util;

import com.palmergames.bukkit.towny.Towny;
import com.palmergames.util.FileMgmt;
import io.github.townyadvanced.townyprovinces.TownyProvinces;
import io.github.townyadvanced.townyprovinces.messaging.Messaging;
import org.bukkit.Bukkit;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import java.util.logging.Level;

public class FileUtil {

Expand Down Expand Up @@ -124,4 +131,22 @@ public static boolean createRegionDefinitionsFolderAndSampleFiles() {
return false;
}
}

public static HashMap<String, String> loadFileIntoHashMap(File file) {

HashMap<String, String> keys = new HashMap<>();
try (FileInputStream fis = new FileInputStream(file);
InputStreamReader isr = new InputStreamReader(fis, StandardCharsets.UTF_8)) {
Properties properties = new Properties();
properties.load(isr);
for (String key : properties.stringPropertyNames()) {
String value = properties.getProperty(key);
keys.put(key, String.valueOf(value));
}
} catch (IOException e) {
Towny.getPlugin().getLogger().log(Level.WARNING, "An exception occurred while reading file " + file.getName(), e);
}
return keys;

}
}