Skip to content

Commit

Permalink
Add options for handling chunks that are too large to be saved
Browse files Browse the repository at this point in the history
Remove blacklisted items from Entities and TileEntities
Remove All Entities and TileEntities
Alert players with permission sledgehammer.broadcast.chunksave
Reference: SpongePowered/Sponge#2156
  • Loading branch information
LXGaming committed Jan 30, 2019
1 parent 47ed05f commit a9b40f0
Show file tree
Hide file tree
Showing 9 changed files with 399 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ targetCompatibility = 1.8

group = "io.github.lxgaming"
archivesBaseName = "Sledgehammer"
version = "1.12.2-1.2.17"
version = "1.12.2-1.2.18"

minecraft {
version = "1.12.2-14.23.5.2768"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,12 @@ private void registerMappings() {
getMixinMappings().put("io.github.lxgaming.sledgehammer.mixin.core.network.MixinNetHandlerPlayServer_Event", MixinCategory::isInteractEvents);
getMixinMappings().put("io.github.lxgaming.sledgehammer.mixin.core.network.MixinNetworkManager", MixinCategory::isFlushNetworkOnTick);
getMixinMappings().put("io.github.lxgaming.sledgehammer.mixin.core.network.MixinNetworkSystem", MixinCategory::isNetworkSystem);
getMixinMappings().put("io.github.lxgaming.sledgehammer.mixin.core.server.MixinDedicatedServer", (module) -> true);
getMixinMappings().put("io.github.lxgaming.sledgehammer.mixin.core.server.MixinDedicatedServer", category -> true);
getMixinMappings().put("io.github.lxgaming.sledgehammer.mixin.core.world.biome.MixinBiomeProvider", MixinCategory::isBiomeProvider);
getMixinMappings().put("io.github.lxgaming.sledgehammer.mixin.core.world.chunk.storage.MixinAnvilChunkLoader", category ->
category.isChunkSaveAlert() || category.isChunkSavePurgeBlacklist() || category.isChunkSavePurgeAll());
getMixinMappings().put("io.github.lxgaming.sledgehammer.mixin.core.world.chunk.storage.MixinRegionFileChunkBuffer", category ->
category.isChunkSaveAlert() || category.isChunkSavePurgeBlacklist() || category.isChunkSavePurgeAll());

// Mixin Forge
getMixinMappings().put("io.github.lxgaming.sledgehammer.mixin.forge.common.MixinForgeHooks_Advancement", MixinCategory::isAdvancementStacktrace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,24 @@
@ConfigSerializable
public class MessageCategory {

@Setting(value = "move-outside-border", comment = "Sent to the player when attempting to move outside the world border")
private String moveOutsideBorder = "&cCannot move outside of the world border";
@Setting(value = "chunk-save", comment = "Sent to the player when a chunk fails to save")
private String chunkSave = "&fChunk ([X], [Z]) &cfailed to save";

@Setting(value = "item-teleport", comment = "Sent to the player when a thrown item gets deleted")
private String itemTeleport = "&f[ID] &cwas lost in time and space";

public String getMoveOutsideBorder() {
return moveOutsideBorder;
@Setting(value = "move-outside-border", comment = "Sent to the player when attempting to move outside the world border")
private String moveOutsideBorder = "&cCannot move outside of the world border";

public String getChunkSave() {
return chunkSave;
}

public String getItemTeleport() {
return itemTeleport;
}

public String getMoveOutsideBorder() {
return moveOutsideBorder;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ public class MixinCategory {
@Setting(value = "ceremony-rain", comment = "Prevents Totemic from changing the weather")
private boolean ceremonyRain = false;

@Setting(value = "chunk-save-alert", comment = "Alerts players with permission (sledgehammer.broadcast.chunksave) when a chunk fails to save")
private boolean chunkSaveAlert = false;

@Setting(value = "chunk-save-blacklist", comment = "Items to removed from chunks")
private List<String> chunkSaveBlacklist = Lists.newArrayList("minecraft:writable_book", "minecraft:written_book");

@Setting(value = "chunk-save-purge-blacklist", comment = "Removes all blacklisted items from chunks that fail to save")
private boolean chunkSavePurgeBlacklist = false;

@Setting(value = "chunk-save-purge-all", comment = "Removes all Entities and TileEntities from chunks that fail to save")
private boolean chunkSavePurgeAll = false;

@Setting(value = "flush-network-on-tick", comment = "Reduce Network usage by postponing flush")
private boolean flushNetworkOnTick = false;

Expand Down Expand Up @@ -90,6 +102,22 @@ public boolean isCeremonyRain() {
return ceremonyRain;
}

public boolean isChunkSaveAlert() {
return chunkSaveAlert;
}

public List<String> getChunkSaveBlacklist() {
return chunkSaveBlacklist;
}

public boolean isChunkSavePurgeBlacklist() {
return chunkSavePurgeBlacklist;
}

public boolean isChunkSavePurgeAll() {
return chunkSavePurgeAll;
}

public boolean isFlushNetworkOnTick() {
return flushNetworkOnTick;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2019 Alex Thomson
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.github.lxgaming.sledgehammer.exception;

import java.io.IOException;

public class ChunkSaveException extends IOException {

public ChunkSaveException() {
}

public ChunkSaveException(String message) {
super(message);
}

public ChunkSaveException(String message, Throwable cause) {
super(message, cause);
}

public ChunkSaveException(Throwable cause) {
super(cause);
}
}
Loading

0 comments on commit a9b40f0

Please sign in to comment.