Skip to content

Commit e59bfc8

Browse files
committed
v1.4.1
1 parent cdf2461 commit e59bfc8

File tree

11 files changed

+113
-54
lines changed

11 files changed

+113
-54
lines changed

build.gradle

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins {
22
id 'java'
33
id 'idea'
44
id 'maven-publish'
5-
id "com.github.johnrengelman.shadow" version "7.1.2"
5+
id("com.gradleup.shadow") version "9.0.0-beta13"
66
}
77

88
repositories {
@@ -37,15 +37,15 @@ repositories {
3737
}
3838

3939
dependencies {
40-
implementation 'de.tr7zw:item-nbt-api:2.13.1'
40+
implementation 'de.tr7zw:item-nbt-api:2.15.0'
4141
implementation 'com.github.Redempt:RedLib:6.6.1'
4242
implementation 'com.github.Redempt:Crunch:2.0.3'
43-
implementation 'com.github.cryptomorin:XSeries:11.2.0'
44-
implementation 'com.github.Revxrsal.Lamp:common:3.2.1'
45-
implementation 'com.github.Revxrsal.Lamp:bukkit:3.2.1'
43+
implementation 'com.github.cryptomorin:XSeries:13.2.0'
44+
implementation 'com.github.Revxrsal.Lamp:common:3.3.6'
45+
implementation 'com.github.Revxrsal.Lamp:bukkit:3.3.6'
4646
implementation 'com.github.Sven65:Item-Names:1.0.2'
47-
implementation 'org.bstats:bstats-bukkit:3.0.2'
48-
implementation 'com.jeff_media:MorePersistentDataTypes:2.4.0'
47+
implementation 'org.bstats:bstats-bukkit:3.1.0'
48+
implementation 'com.jeff-media:MorePersistentDataTypes:2.4.0'
4949

5050
compileOnly files('libs/folia-api-1.20.4-R0.1-SNAPSHOT.jar') // Modified API jar with Java 8 support
5151
compileOnly 'net.kyori:adventure-api:4.17.0' // Not used but needed for Folia compilation
@@ -55,7 +55,7 @@ dependencies {
5555
}
5656

5757
group = 'me.byteful.plugin'
58-
version = '1.4.0.2'
58+
version = '1.4.1'
5959
description = 'LevelTools'
6060
java.sourceCompatibility = JavaVersion.VERSION_17
6161

@@ -77,7 +77,7 @@ shadowJar {
7777
relocate "redempt.redlib", "me.byteful.plugin.leveltools.libs.redlib"
7878
relocate 'revxrsal.commands', 'me.byteful.plugin.leveltools.libs.lamp'
7979
relocate 'org.bstats', 'me.byteful.plugin.leveltools.libs.bstats'
80-
relocate 'com.jeff_media.morepersistentdatatypes', 'me.byteful.plugin.leveltools.libs.morepersistentdatatypes'
80+
relocate 'com.jeff-media.morepersistentdatatypes', 'me.byteful.plugin.leveltools.libs.morepersistentdatatypes'
8181
}
8282

8383
def targetJavaVersion = 8
@@ -104,6 +104,4 @@ processResources {
104104

105105
compileJava { // Preserve parameter names in the bytecode
106106
options.compilerArgs += ["-parameters"]
107-
options.fork = true
108-
options.forkOptions.executable = "javac"
109107
}

gradle/wrapper/gradle-wrapper.jar

-15.7 KB
Binary file not shown.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=wrapper/dists

gradlew

Lines changed: 33 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gradlew.bat

Lines changed: 9 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/me/byteful/plugin/leveltools/LevelToolsPlugin.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.util.concurrent.TimeUnit;
1010
import me.byteful.plugin.leveltools.api.AnvilCombineMode;
1111
import me.byteful.plugin.leveltools.api.block.BlockDataManager;
12+
import me.byteful.plugin.leveltools.api.block.BlockDataManagerFactory;
1213
import me.byteful.plugin.leveltools.api.block.impl.FileBlockDataManager;
1314
import me.byteful.plugin.leveltools.api.scheduler.Scheduler;
1415
import me.byteful.plugin.leveltools.listeners.AnvilListener;
@@ -54,17 +55,11 @@ public void onEnable() {
5455
setLevelXpFormula();
5556
getLogger().info("Loaded configuration...");
5657

57-
final Path blocksFile = getDataFolder().toPath().resolve("placed_blocks.txt");
58-
59-
if (!Files.exists(blocksFile)) {
60-
try {
61-
blocksFile.toFile().createNewFile();
62-
} catch (IOException e) {
63-
e.printStackTrace();
64-
}
65-
}
66-
67-
blockDataManager = new FileBlockDataManager(blocksFile, scheduler);
58+
blockDataManager = BlockDataManagerFactory.createBlockDataManager(
59+
getDataFolder().toPath(),
60+
getConfig(),
61+
scheduler
62+
);
6863
blockDataManager.load();
6964
getLogger().info("Loaded block data manager...");
7065

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package me.byteful.plugin.leveltools.api.block;
2+
3+
import me.byteful.plugin.leveltools.api.block.impl.FileBlockDataManager;
4+
import me.byteful.plugin.leveltools.api.block.impl.SqliteBlockDataManager;
5+
import me.byteful.plugin.leveltools.api.scheduler.Scheduler;
6+
import org.bukkit.configuration.ConfigurationSection;
7+
8+
import java.nio.file.Path;
9+
import java.sql.SQLException;
10+
11+
public class BlockDataManagerFactory {
12+
public static BlockDataManager createBlockDataManager(Path dataFolder, ConfigurationSection config, Scheduler scheduler) {
13+
String storageType = config.getString("block_data_storage.type", "LEGACY_TEXT");
14+
15+
switch (storageType.toUpperCase()) {
16+
case "SQLITE":
17+
return new SqliteBlockDataManager(dataFolder.resolve("placed_blocks.db"), scheduler);
18+
case "LEGACY_TEXT":
19+
default:
20+
return new FileBlockDataManager(dataFolder.resolve("placed_blocks.txt"), scheduler);
21+
}
22+
}
23+
}

src/main/java/me/byteful/plugin/leveltools/api/block/impl/FileBlockDataManager.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import me.byteful.plugin.leveltools.util.Text;
2020

2121
public class FileBlockDataManager implements BlockDataManager {
22-
private static final int MAX_CACHE_SIZE = 10_000;
22+
private static final int MAX_CACHE_SIZE = 100_000;
2323
private final Set<BlockPosition> cache = ConcurrentHashMap.newKeySet();
2424
private final Path file;
2525
private final ScheduledTask saveTask;
@@ -83,7 +83,8 @@ public void load() {
8383

8484
@Override
8585
public void close() {
86-
cache.clear();
8786
saveTask.stop();
87+
save();
88+
cache.clear();
8889
}
8990
}

src/main/java/me/byteful/plugin/leveltools/listeners/AnvilListener.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,13 @@ public void onAnvilRepair(PrepareAnvilEvent e) {
5757
return;
5858
}
5959

60+
// Use result item to create a new leveltools item instance so other plugins can modify the result and we can still attempt to work with that
61+
// just read the lvl and xp from the original item so it doesnt get reset
62+
final LevelToolsItem original = LevelToolsUtil.createLevelToolsItem(firstItem);
6063
final LevelToolsItem finalItem = LevelToolsUtil.createLevelToolsItem(result);
64+
finalItem.setLevel(original.getLevel());
65+
finalItem.setXp(original.getXp());
66+
finalItem.setLastHandledReward(original.getLastHandledReward());
6167
e.setResult(finalItem.getItemStack()); // This has to be done to patch lore issues.
6268
}
6369
}

src/main/java/me/byteful/plugin/leveltools/util/LevelToolsUtil.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,15 @@ private static void smartSetLore(@NotNull ItemMeta meta, @NotNull List<String> t
273273
return;
274274
}
275275

276-
final int start = findPrefixStart(lore);
276+
final int[] bounds = findPrefixBounds(lore);
277+
final int start = bounds[0];
278+
final int end = bounds[1];
277279
if (start == -1) {
278280
lore.addAll(toAdd);
279281
meta.setLore(lore);
280282

281283
return;
282284
}
283-
final int end = start + toAdd.size();
284285
if (end > lore.size()) {
285286
meta.setLore(toAdd);
286287

@@ -292,14 +293,20 @@ private static void smartSetLore(@NotNull ItemMeta meta, @NotNull List<String> t
292293
meta.setLore(lore);
293294
}
294295

295-
private static int findPrefixStart(@NotNull List<String> lore) {
296+
private static int[] findPrefixBounds(@NotNull List<String> lore) {
297+
final int[] arr = new int[]{-1, -1};
296298
for (int i = 0; i < lore.size(); i++) {
297299
if (decolorize(lore.get(i)).startsWith(LORE_PREFIX)) {
298-
return i;
300+
if (arr[0] == -1) {
301+
arr[0] = i;
302+
arr[1] = i;
303+
} else {
304+
arr[1] = i;
305+
}
299306
}
300307
}
301308

302-
return -1;
309+
return arr;
303310
}
304311

305312
public static void handleReward(LevelToolsItem tool, Player player) {

0 commit comments

Comments
 (0)