Skip to content

Commit

Permalink
update BlockUtil
Browse files Browse the repository at this point in the history
  • Loading branch information
HSGamer committed Sep 16, 2024
1 parent 7ed1a2a commit 9725567
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 25 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ A minigame system for Minecraft Server
| [HSCore](https://github.com/HSGamer/HSCore) | [MIT](https://github.com/HSGamer/HSCore/blob/master/LICENSE) |
| [MinigameCore](https://github.com/HSGamer/MinigameCore) | [MIT](https://github.com/HSGamer/MinigameCore/blob/master/LICENSE) |
| [UniHologram](https://github.com/ProjectUnified/UniHologram) | [MIT](https://github.com/ProjectUnified/UniHologram/blob/master/LICENSE) |
| [BlockUtil](https://github.com/HSGamer/BlockUtil) | [MIT](https://github.com/HSGamer/BlockUtil/blob/master/LICENSE) |
| [BlockUtil](https://github.com/ProjectUnified/BlockUtil) | [MIT](https://github.com/ProjectUnified/BlockUtil/blob/master/LICENSE) |
| [XSeries](https://github.com/CryptoMorin/XSeries) | [MIT](https://github.com/CryptoMorin/XSeries/blob/master/LICENSE.txt) |
| [Java-Probability-Collection](https://github.com/HSGamer/Java-Probability-Collection) ([original](https://github.com/lewysDavies/Java-Probability-Collection)) | [MIT](https://github.com/lewysDavies/Java-Probability-Collection/blob/master/LICENSE) |
18 changes: 9 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<core.version>4.3.30</core.version>
<minigamecore.version>3.4.2</minigamecore.version>
<unihologram.version>3.0.2</unihologram.version>
<blockutil.version>3.0.1</blockutil.version>
<blockutil.version>4.0.1</blockutil.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand Down Expand Up @@ -69,7 +69,7 @@
<shadedPattern>me.hsgamer.gamesinthebox.unihologram</shadedPattern>
</relocation>
<relocation>
<pattern>me.hsgamer.blockutil</pattern>
<pattern>io.github.projectunified.blockutil</pattern>
<shadedPattern>me.hsgamer.gamesinthebox.blockutil</shadedPattern>
</relocation>
<relocation>
Expand Down Expand Up @@ -235,7 +235,7 @@
<dependency>
<groupId>me.hsgamer</groupId>
<artifactId>hscore-bukkit-block</artifactId>
<version>${core.version}</version>
<version>4.5.7</version> <!-- TODO: Update to ${core.version} -->
</dependency>
<dependency>
<groupId>me.hsgamer</groupId>
Expand Down Expand Up @@ -321,18 +321,18 @@
</dependency>

<dependency>
<groupId>me.hsgamer</groupId>
<artifactId>block-util</artifactId>
<groupId>io.github.projectunified</groupId>
<artifactId>block-util-fawe</artifactId>
<version>${blockutil.version}</version>
</dependency>
<dependency>
<groupId>me.hsgamer</groupId>
<artifactId>block-util-fawe</artifactId>
<groupId>io.github.projectunified</groupId>
<artifactId>block-util-folia</artifactId>
<version>${blockutil.version}</version>
</dependency>
<dependency>
<groupId>me.hsgamer</groupId>
<artifactId>block-util-folia</artifactId>
<groupId>io.github.projectunified</groupId>
<artifactId>block-util-vanilla</artifactId>
<version>${blockutil.version}</version>
</dependency>

Expand Down
3 changes: 0 additions & 3 deletions src/main/java/me/hsgamer/gamesinthebox/GamesInTheBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package me.hsgamer.gamesinthebox;

import com.google.common.reflect.TypeToken;
import me.hsgamer.blockutil.abstraction.BlockHandlerSettings;
import me.hsgamer.gamesinthebox.command.EditorCommand;
import me.hsgamer.gamesinthebox.command.MainCommand;
import me.hsgamer.gamesinthebox.config.MainConfig;
Expand Down Expand Up @@ -75,8 +74,6 @@ public final class GamesInTheBox extends BasePlugin {

@Override
public void load() {
BlockHandlerSettings.addAll(mainConfig.getBlockUtilSettings());

MessageUtils.setPrefix(messageConfig::getPrefix);
}

Expand Down
48 changes: 39 additions & 9 deletions src/main/java/me/hsgamer/gamesinthebox/config/MainConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
import me.hsgamer.hscore.config.annotation.Comment;
import me.hsgamer.hscore.config.annotation.ConfigPath;

import java.util.Collections;
import java.util.Map;

/**
* The main config
*/
Expand Down Expand Up @@ -48,14 +45,47 @@ default boolean isPlannerAsync() {
}

/**
* Get the settings for BlockUtil
* Get the blocks-per-tick for BlockUtil
*
* @return the blocks-per-tick
*/
@ConfigPath({"block-util", "blocks-per-tick"})
@Comment("The amount of blocks to process per tick")
default int getBlockUtilBlocksPerTick() {
return 50;
}

/**
* Get the block-delay for BlockUtil
*
* @return the block-delay
*/
@ConfigPath({"block-util", "block-delay"})
@Comment("The delay between each block process")
default long getBlockUtilBlockDelay() {
return 0L;
}

/**
* Get the max-blocks for BlockUtil
*
* @return the map of the settings
* @return the max-blocks
*/
@ConfigPath("block-util")
@Comment("Settings for games that involve blocks")
default Map<String, String> getBlockUtilSettings() {
return Collections.emptyMap();
@ConfigPath({"block-util", "max-blocks"})
@Comment("The maximum amount of blocks to process (-1 for unlimited)")
default int getBlockUtilMaxBlocks() {
return 1000;
}

/**
* Check if BlockUtil should use FAWE if available
*
* @return true if it should
*/
@ConfigPath({"block-util", "use-fawe"})
@Comment("Should the plugin use FastAsyncWorldEdit if available ?")
default boolean isBlockUtilUseFawe() {
return true;
}

/**
Expand Down
24 changes: 21 additions & 3 deletions src/main/java/me/hsgamer/gamesinthebox/util/BlockHandlerUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
*/
package me.hsgamer.gamesinthebox.util;

import me.hsgamer.blockutil.abstraction.BlockHandler;
import me.hsgamer.blockutil.api.BlockUtil;
import io.github.projectunified.blockutil.api.BlockHandler;
import io.github.projectunified.blockutil.fawe.FaweBlockHandler;
import io.github.projectunified.blockutil.folia.FoliaBlockHandler;
import io.github.projectunified.blockutil.vanilla.VanillaBlockHandler;
import me.hsgamer.gamesinthebox.GamesInTheBox;
import me.hsgamer.gamesinthebox.config.MainConfig;
import org.bukkit.plugin.java.JavaPlugin;

/**
Expand All @@ -26,7 +30,21 @@ public final class BlockHandlerUtil {
private static final BlockHandler blockHandler;

static {
blockHandler = BlockUtil.getHandler(JavaPlugin.getProvidingPlugin(BlockHandlerUtil.class));
GamesInTheBox plugin = JavaPlugin.getPlugin(GamesInTheBox.class);
MainConfig mainConfig = plugin.getMainConfig();

if (mainConfig.isBlockUtilUseFawe() && FaweBlockHandler.isAvailable()) {
blockHandler = new FaweBlockHandler()
.setMaxBlocks(mainConfig.getBlockUtilMaxBlocks());
} else if (FoliaBlockHandler.isAvailable()) {
blockHandler = new FoliaBlockHandler(plugin)
.setBlocksPerTick(mainConfig.getBlockUtilBlocksPerTick())
.setBlockDelay(mainConfig.getBlockUtilBlockDelay());
} else {
blockHandler = new VanillaBlockHandler(plugin)
.setBlocksPerTick(mainConfig.getBlockUtilBlocksPerTick())
.setBlockDelay(mainConfig.getBlockUtilBlockDelay());
}
}

private BlockHandlerUtil() {
Expand Down

0 comments on commit 9725567

Please sign in to comment.