Skip to content

Commit 6ed41e6

Browse files
Release 2.4.0 (#27)
2 parents 011813d + ec67c10 commit 6ed41e6

32 files changed

Lines changed: 500 additions & 400 deletions

File tree

.github/workflows/verify.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- uses: actions/checkout@v2.3.4
14-
- name: Set up JDK 8
15-
uses: actions/setup-java@v2
13+
- uses: actions/checkout@v4
14+
- name: Set up JDK 11
15+
uses: actions/setup-java@v4
1616
with:
1717
distribution: adopt
18-
java-version: 8
18+
java-version: 11
1919
- name: Grant execute permission for gradlew
2020
run: chmod +x gradlew
2121
- name: Build with Gradle
2222
run: ./gradlew --build-cache shadowJar
2323
- name: Test with Gradle
24-
run: ./gradlew test
24+
run: ./gradlew test

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.gradle
2+
**/build/
3+
!src/**/build/
4+
gradle.properties
5+
6+
# Ignore Gradle GUI configuration
7+
gradle-app.setting
8+
9+
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
10+
!gradle-wrapper.jar
11+
12+
# Cache of project
13+
.gradletasknamecache
14+
15+
# User-specific stuff
16+
.idea/
17+
*.iml
18+
19+
# CMake
20+
cmake-build-*/
21+
22+
# Maven
23+
target/
24+
pom.xml.tag
25+
pom.xml.releaseBackup
26+
pom.xml.versionsBackup
27+
pom.xml.next
28+
release.properties
29+
dependency-reduced-pom.xml
30+
buildNumber.properties
31+
.mvn/timing.properties
32+
.mvn/wrapper/maven-wrapper.jar

LandLordMap-bluemap/build.gradle.kts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
plugins {
22
id("biz.princeps.java-conventions")
3-
id("com.github.johnrengelman.shadow") version "7.0.0"
3+
id("com.github.johnrengelman.shadow") version "8.1.1"
44
}
55

66
dependencies {
77
implementation(project(":LandLordMap-core"))
8-
compileOnly("org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT")
9-
compileOnly("biz.princeps:landlord-core:4.360")
10-
compileOnly("de.eldoria:eldo-util:1.11.0-DEV")
118
compileOnly("com.github.BlueMap-Minecraft:BlueMapAPI:v1.7.0")
129
}
1310

@@ -40,4 +37,4 @@ tasks {
4037
events("passed", "skipped", "failed")
4138
}
4239
}
43-
}
40+
}

LandLordMap-bluemap/src/main/java/biz/princeps/landlordmap/bluemap/LLBlueMap.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,39 @@
1515

1616
public class LLBlueMap extends JavaPlugin {
1717

18-
ILandLord landLordAPI;
19-
Configuration configuration;
20-
BlueMapIntegration blueMapIntegration;
18+
private ILandLord landLordAPI;
19+
private Configuration configuration;
20+
private BlueMapIntegration blueMapIntegration;
2121

2222
@Override
2323
public void onEnable() {
24-
logToConsole(Level.INFO, "Loading configuration...");
24+
getLogger().info( "Loading configuration...");
2525
saveDefaultConfig();
2626
configuration = new Configuration(this);
2727

2828
blueMapIntegration = new BlueMapIntegration(this);
2929

30-
final PluginManager pluginManager = Bukkit.getPluginManager();
31-
logToConsole(Level.INFO, "Loading listeners...");
30+
PluginManager pluginManager = getServer().getPluginManager();
31+
getLogger().info("Loading listeners...");
3232
pluginManager.registerEvents(new LandlordListener(this, blueMapIntegration), this);
3333

34-
logToConsole(Level.INFO, "Loading commands...");
34+
getLogger().info( "Loading commands...");
3535
PrincepsLib.getCommandManager().registerCommand(new Commands(this));
3636

37-
logToConsole(Level.INFO, "Loading APIs...");
37+
getLogger().info( "Loading APIs...");
3838
landLordAPI = (ILandLord) pluginManager.getPlugin("Landlord");
3939

4040
BlueMapAPI.onEnable(blueMapAPI -> {
41-
logToConsole(Level.INFO, "BlueMap integration is initializing...");
41+
getLogger().info( "BlueMap integration is initializing...");
4242
blueMapIntegration.hookBlueMap(blueMapAPI);
43-
logToConsole(Level.INFO, "BlueMap integration has been successfully enabled/reloaded!");
43+
getLogger().info( "BlueMap integration has been successfully enabled/reloaded!");
4444
});
4545
}
4646

4747
@Override
4848
public void onDisable() {
4949
BlueMapAPI.getInstance().ifPresent(blueMapAPI -> blueMapIntegration.unhookBlueMap(blueMapAPI));
50-
logToConsole(Level.INFO, "Thank you :)");
51-
}
52-
53-
public void logToConsole(Level level, String message) {
54-
Bukkit.getLogger().log(level, "[" + getName() + "] " + message);
50+
getLogger().info("Thank you :)");
5551
}
5652

5753
public Configuration getConfiguration() {

LandLordMap-bluemap/src/main/java/biz/princeps/landlordmap/bluemap/commands/CommandReload.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void onCommand(Properties properties, Arguments arguments) {
2626
plugin.reloadConfig();
2727
plugin.getConfiguration().load();
2828

29-
final Optional<BlueMapAPI> optionalBlueMapAPI = BlueMapAPI.getInstance();
29+
Optional<BlueMapAPI> optionalBlueMapAPI = BlueMapAPI.getInstance();
3030
if (optionalBlueMapAPI.isPresent()) {
3131
plugin.getBlueMapIntegration().hookBlueMap(optionalBlueMapAPI.get());
3232
properties.sendMessage("§aConfig successfully reloaded!");
@@ -35,4 +35,4 @@ public void onCommand(Properties properties, Arguments arguments) {
3535
}
3636
}
3737

38-
}
38+
}

LandLordMap-bluemap/src/main/java/biz/princeps/landlordmap/bluemap/commands/Commands.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ public Commands(LLBlueMap plugin) {
2222
plugin.getConfig().getStringList("CommandSettings.Main.aliases").toArray(new String[]{}));
2323
this.plugin = plugin;
2424

25-
this.addSubcommand(new CommandReload(plugin));
25+
addSubcommand(new CommandReload(plugin));
2626
}
2727

2828
@Override
2929
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
30-
final List<String> completions = new ArrayList<>();
30+
List<String> completions = new ArrayList<>();
3131

3232
if (args.length == 1) {
3333
subCommandMap.forEach((name, subCommand) -> {
@@ -45,4 +45,4 @@ public List<String> tabComplete(CommandSender sender, String alias, String[] arg
4545
public void onCommand(Properties properties, Arguments arguments) {
4646
}
4747

48-
}
48+
}

LandLordMap-bluemap/src/main/java/biz/princeps/landlordmap/bluemap/config/Configuration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public Configuration(LLBlueMap plugin) {
3434
}
3535

3636
public void load() {
37-
final FileConfiguration config = plugin.getConfig();
37+
FileConfiguration config = plugin.getConfig();
3838

3939
updateTaskFrequency = config.getLong("update-task-frequency");
4040
maxProcessedPerUpdate = config.getInt("max-processed-per-update");

LandLordMap-bluemap/src/main/java/biz/princeps/landlordmap/bluemap/integration/BlueMapIntegration.java

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ public class BlueMapIntegration {
3030

3131
public BlueMapIntegration(LLBlueMap plugin) {
3232
this.plugin = plugin;
33-
this.config = plugin.getConfiguration();
33+
config = plugin.getConfiguration();
3434

35-
this.queue = new ConcurrentHashMap<>();
35+
queue = new ConcurrentHashMap<>();
3636
}
3737

3838
private MarkerSet buildMarkerSet(MarkerAPI markerAPI) {
@@ -42,51 +42,51 @@ private MarkerSet buildMarkerSet(MarkerAPI markerAPI) {
4242
public void hookBlueMap(BlueMapAPI blueMapAPI) {
4343
Bukkit.getScheduler().runTaskAsynchronously(plugin, bukkitTask -> {
4444
try {
45-
final MarkerAPI markerAPI = blueMapAPI.getMarkerAPI();
46-
plugin.logToConsole(Level.INFO, "Loading Landlord markers...");
45+
MarkerAPI markerAPI = blueMapAPI.getMarkerAPI();
46+
plugin.getLogger().info("Loading Landlord markers...");
4747

48-
final MarkerSet markerSet = buildMarkerSet(markerAPI);
49-
final int size = markerSet.getMarkers().size();
48+
MarkerSet markerSet = buildMarkerSet(markerAPI);
49+
int size = markerSet.getMarkers().size();
5050

51-
plugin.logToConsole(Level.INFO, "Updating Landlord markers...");
51+
plugin.getLogger().info("Updating Landlord markers...");
5252
markerSet.setLabel(config.getMarkerSetLabel());
5353
markerSet.setDefaultHidden(config.isMarkerSetDefaultHidden());
5454
markerSet.setToggleable(config.isMarkerSetToggleable());
5555

5656
if (size == 0) {
57-
plugin.logToConsole(Level.WARNING, "Landlord markers not found!");
57+
plugin.getLogger().warning("Landlord markers not found!");
5858
importLands(blueMapAPI, markerAPI, markerSet);
5959
} else {
60-
plugin.logToConsole(Level.INFO, size + " Landlord markers found!");
60+
plugin.getLogger().info(size + " Landlord markers found!");
6161
markerAPI.save();
6262
}
63-
plugin.logToConsole(Level.INFO, "Loading update task...");
63+
plugin.getLogger().info("Loading update task...");
6464
initUpdateTask();
6565
} catch (IOException e) {
66-
e.printStackTrace();
66+
plugin.getLogger().log(Level.SEVERE, "Could not retrieve marker api", e);
6767
}
6868
});
6969
}
7070

7171
public void unhookBlueMap(BlueMapAPI blueMapAPI) {
7272
try {
7373
updateTask.cancel();
74-
final MarkerAPI markerAPI = blueMapAPI.getMarkerAPI();
74+
MarkerAPI markerAPI = blueMapAPI.getMarkerAPI();
7575

76-
final Set<IOwnedLand> ownedLands = plugin.getLandLordAPI().getWGManager().getRegions();
77-
plugin.logToConsole(Level.WARNING, "Checking " + ownedLands.size() + " lands and processing " + queue.size() + " remaining updates, this could take a while...");
76+
Set<IOwnedLand> ownedLands = plugin.getLandLordAPI().getWGManager().getRegions();
77+
plugin.getLogger().warning("Checking " + ownedLands.size() + " lands and processing " + queue.size() + " remaining updates, this could take a while...");
7878

7979
for (IOwnedLand ownedLand : plugin.getLandLordAPI().getWGManager().getRegions()) {
80-
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(ownedLand.getOwner());
81-
final Instant lastPlayed = Instant.ofEpochMilli(offlinePlayer.getLastPlayed());
80+
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(ownedLand.getOwner());
81+
Instant lastPlayed = Instant.ofEpochMilli(offlinePlayer.getLastPlayed());
8282

8383
if (lastPlayed.isBefore(Instant.now().minus(config.getMarkerSetLifetime(), ChronoUnit.DAYS))) {
8484
enqueueLand(ownedLand, UpdateReason.UNCLAIM);
8585
}
8686
}
8787
processQueue(blueMapAPI, markerAPI, buildMarkerSet(markerAPI), Integer.MAX_VALUE);
8888
} catch (IOException e) {
89-
e.printStackTrace();
89+
plugin.getLogger().log(Level.SEVERE, "Could not retrieve marker api", e);
9090
}
9191
}
9292

@@ -97,17 +97,17 @@ public void initUpdateTask() {
9797
updateTask = Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, () ->
9898
BlueMapAPI.getInstance().ifPresent(blueMapAPI -> {
9999
try {
100-
final MarkerAPI markerAPI = blueMapAPI.getMarkerAPI();
100+
MarkerAPI markerAPI = blueMapAPI.getMarkerAPI();
101101
processQueue(blueMapAPI, markerAPI, buildMarkerSet(markerAPI), config.getMaxProcessedPerUpdate());
102102
} catch (IOException e) {
103-
e.printStackTrace();
103+
plugin.getLogger().log(Level.SEVERE, "Could not retrieve marker api", e);
104104
}
105105
}), config.getUpdateTaskFrequency(), config.getUpdateTaskFrequency());
106106
}
107107

108108
private void importLands(BlueMapAPI blueMapAPI, MarkerAPI markerAPI, MarkerSet markerSet) {
109-
final Set<IOwnedLand> ownedLands = plugin.getLandLordAPI().getWGManager().getRegions();
110-
plugin.logToConsole(Level.WARNING, "Importing " + ownedLands.size() + " lands, this could take a while...");
109+
Set<IOwnedLand> ownedLands = plugin.getLandLordAPI().getWGManager().getRegions();
110+
plugin.getLogger().warning("Importing " + ownedLands.size() + " lands, this could take a while...");
111111

112112
// final BlueMapIsland blueMapIsland = new BlueMapIsland(plugin, plugin.getLandLordAPI().getWGManager().getRegion("world_1429_-2113"));
113113
//
@@ -145,8 +145,8 @@ private void importLands(BlueMapAPI blueMapAPI, MarkerAPI markerAPI, MarkerSet m
145145
// }
146146

147147
for (IOwnedLand ownedLand : plugin.getLandLordAPI().getWGManager().getRegions()) {
148-
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(ownedLand.getOwner());
149-
final Instant lastPlayed = Instant.ofEpochMilli(offlinePlayer.getLastPlayed());
148+
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(ownedLand.getOwner());
149+
Instant lastPlayed = Instant.ofEpochMilli(offlinePlayer.getLastPlayed());
150150

151151
if (lastPlayed.isAfter(Instant.now().minus(config.getMarkerSetLifetime(), ChronoUnit.DAYS))) {
152152
enqueueLand(ownedLand, UpdateReason.CLAIM);
@@ -157,20 +157,15 @@ private void importLands(BlueMapAPI blueMapAPI, MarkerAPI markerAPI, MarkerSet m
157157
}
158158

159159
public void enqueueLand(IOwnedLand ownedLand, UpdateReason updateReason) {
160-
if (ownedLand == null || ownedLand.getOwner() == null)
161-
return;
160+
if (ownedLand == null || ownedLand.getOwner() == null) return;
162161

163162
queue.compute(ownedLand, (queuedOwnedLand, queuedUpdateReason) -> {
164-
if (queuedUpdateReason == null) {
165-
return updateReason;
166-
}
163+
if (queuedUpdateReason == null) return updateReason;
167164

168165
switch (queuedUpdateReason) {
169166
case CLAIM:
170167
case UNCLAIM:
171-
if (updateReason == UpdateReason.MANAGE) {
172-
return queuedUpdateReason;
173-
}
168+
if (updateReason == UpdateReason.MANAGE) return queuedUpdateReason;
174169
default:
175170
return updateReason;
176171
}
@@ -181,21 +176,21 @@ private void processQueue(BlueMapAPI blueMapAPI, MarkerAPI markerAPI, MarkerSet
181176
int iterations = 0;
182177

183178
for (Iterator<Map.Entry<IOwnedLand, UpdateReason>> iterator = queue.entrySet().iterator(); iterator.hasNext() && iterations < limit; ) {
184-
final Map.Entry<IOwnedLand, UpdateReason> entry = iterator.next();
179+
Map.Entry<IOwnedLand, UpdateReason> entry = iterator.next();
185180

186181
new BlueMapLand(plugin, entry.getKey()).process(blueMapAPI, markerSet, entry.getValue());
187182

188183
iterator.remove();
189184
iterations++;
190185
}
191186

192-
if (iterations == 0)
193-
return;
187+
if (iterations == 0) return;
188+
194189
try {
195190
markerAPI.save();
196191
} catch (IOException e) {
197-
e.printStackTrace();
192+
plugin.getLogger().log(Level.SEVERE, "Could not save to marker api", e);
198193
}
199194
}
200195

201-
}
196+
}

0 commit comments

Comments
 (0)