Skip to content

Commit 8eff2bd

Browse files
committed
add transform provider protector
1 parent 39b19f2 commit 8eff2bd

5 files changed

Lines changed: 64 additions & 2 deletions

File tree

buildSrc/src/main/groovy/multiloader-common.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,19 @@ repositories {
146146
includeGroup('com.jamieswhiteshirt')
147147
}
148148
}
149+
150+
exclusiveContent {
151+
forRepository {
152+
maven {
153+
name = 'CurseForge'
154+
url = 'https://cursemaven.com'
155+
}
156+
}
157+
filter {
158+
includeGroup('curse.maven')
159+
}
160+
}
161+
149162
exclusiveContent {
150163
forRepository {
151164
maven {

common/src/main/java/com/github/litermc/vsplit/api/clean/ShipCleaner.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public final class ShipCleaner {
3535
static {
3636
registerListener(ShipBlockCountCleaner.INSTANCE);
3737
registerListener(ShipPlayerProtectionCleaner.INSTANCE);
38+
registerListener(ShipTransformProviderProtectionCleaner.INSTANCE);
3839
}
3940

4041
private ShipCleaner() {}

common/src/main/java/com/github/litermc/vsplit/config/Config.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ public final class Config {
7979
new ResourceLocation("computercraft", "computer_normal")
8080
);
8181

82+
/**
83+
* Prevent ships has transform providers to be cleaned (e.g. Create: Interactive contraptions)
84+
*/
85+
public static boolean enableTransformProviderProtection = true;
86+
8287
/**
8388
* Prevent ship cleanup within player's certain distance.
8489
*/

common/src/main/java/com/github/litermc/vsplit/config/ConfigSpec.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public final class ConfigSpec {
2626
public static final ConfigFile.Value<CoreBlockBehaviour> CORE_BLOCK_BEHAVIOUR;
2727
public static final ConfigFile.Value<List<? extends String>> CORE_BLOCKS;
2828

29+
public static final ConfigFile.Value<Boolean> ENABLE_TRANSFORM_PROVIDER_PROTECTION;
2930
public static final ConfigFile.Value<Boolean> ENABLE_PLAYER_PROTECTION;
3031
public static final ConfigFile.Value<Integer> PLAYER_PROTECTION_RADIUS;
3132

@@ -127,8 +128,12 @@ private ConfigSpec() {}
127128

128129
{
129130
builder
130-
.comment("Block count cleaner settings")
131-
.push("block_count_cleaner");
131+
.comment("Clean protection settings")
132+
.push("clean_protection");
133+
134+
ENABLE_TRANSFORM_PROVIDER_PROTECTION = builder
135+
.comment("Prevent ships has transform providers to be cleaned (e.g. Create: Interactive contraptions)")
136+
.define("enable_transform_provider_protection", Config.enableTransformProviderProtection);
132137

133138
ENABLE_PLAYER_PROTECTION = builder
134139
.comment("Prevent ship cleanup within player's certain distance.")
@@ -152,14 +157,18 @@ public static void syncServer(Path path) {
152157
Config.asyncShipSplit = ASYNC_SHIP_SPLIT.get();
153158
Config.enableTreeFalling = ENABLE_TREE_FALLING.get();
154159
Config.decayMethod = DECAY_METHOD.get();
160+
155161
Config.enableShipPeriodicCleanup = ENABLE_SHIP_PERIODIC_CLEANUP.get();
156162
Config.shipCleanPeriod = SHIP_CLEAN_PERIOD.get();
157163
Config.shipCleanMethod = SHIP_CLEAN_METHOD.get();
158164
Config.cleanupMessageLevel = CLEANUP_MESSAGE_LEVEL.get();
165+
159166
Config.enableBlockCountCleanup = ENABLE_BLOCK_COUNT_CLEANUP.get();
160167
Config.minimumBlocksShipNeeds = MINIMUM_BLOCKS_SHIP_NEEDS.get();
161168
Config.coreBlockBehaviour = CORE_BLOCK_BEHAVIOUR.get();
162169
Config.coreBlocks = Set.copyOf(CORE_BLOCKS.get().stream().map(ResourceLocation::new).toList());
170+
171+
Config.enableTransformProviderProtection = ENABLE_TRANSFORM_PROVIDER_PROTECTION.get();
163172
Config.enablePlayerProtection = ENABLE_PLAYER_PROTECTION.get();
164173
Config.playerProtectionRadius = PLAYER_PROTECTION_RADIUS.get();
165174
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.github.litermc.vsplit.impl.clean;
2+
3+
import com.github.litermc.vsplit.api.clean.ICleanListener;
4+
import com.github.litermc.vsplit.config.Config;
5+
6+
import net.minecraft.network.chat.Component;
7+
8+
import java.util.function.Consumer;
9+
10+
public final class ShipTransformProviderProtectionCleaner implements ICleanListener {
11+
public static final ShipTransformProviderProtectionCleaner INSTANCE = new ShipTransformProviderProtectionCleaner();
12+
13+
@Override
14+
public int getShipCleanPriority() {
15+
return 10080;
16+
}
17+
18+
@Override
19+
public void onShipClean(final Context context) {
20+
if (!Config.enableTransformProviderProtection) {
21+
return;
22+
}
23+
if (!context.getCleanSuggestion()) {
24+
return;
25+
}
26+
if (context.getShip().getTransformProvider() != null) {
27+
context.setCleanSuggestion(false);
28+
return;
29+
}
30+
}
31+
32+
@Override
33+
public void checkShipCleanStatus(final Context context, final Consumer<Component> messageConsumer) {}
34+
}

0 commit comments

Comments
 (0)