Skip to content

Commit

Permalink
Add an option to not remove blocks that cannot be replaced with Bette…
Browse files Browse the repository at this point in the history
…rSponge
  • Loading branch information
me4502 committed May 22, 2022
1 parent fee7c23 commit eef222e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 28 deletions.
Expand Up @@ -33,9 +33,6 @@ public class LanguageManager {
put("mech.group", "You are not in the required group!");
put("mech.restock", "Mechanism Restocked!");

put("mech.anchor.create", "Chunk Anchor Created!");
put("mech.anchor.already-anchored", "This chunk is already anchored!");

put("mech.area.create", "Toggle Area Created!");
put("mech.area.missing", "The area or namespace does not exist.");

Expand Down Expand Up @@ -63,10 +60,6 @@ public class LanguageManager {
put("mech.command-items.wait", "You have to wait %time% seconds to use this again!");
put("mech.command-items.need", "You need %item% to use this command!");

put("mech.cook.create", "Cooking Pot Created!");
put("mech.cook.ouch", "Ouch! That was hot!");
put("mech.cook.add-fuel", "You put fuel into the cooking pot, and watch as the fire roars!");

put("mech.custom-crafting.recipe-permission", "You do not have permission to craft this recipe.");

put("mech.door.create", "Door Created!");
Expand All @@ -84,22 +77,11 @@ public class LanguageManager {
put("mech.hiddenswitch.key", "The key did not fit!");
put("mech.hiddenswitch.toggle", "You hear the muffled click of a switch!");

put("mech.map.create", "Map Changer Created!");
put("mech.map.invalid", "Invalid Map ID!");

put("mech.pay.create", "Pay Created!");
put("mech.pay.success", "Payment Successful! You paid: ");
put("mech.pay.not-enough-money", "Payment Failed! You don't have enough money.");
put("mech.pay.failed-to-pay", "Payment Failed! The money failed to be exchanged.");

put("mech.teleport.create", "Teleporter Created!");
put("mech.teleport.alert", "You Teleported!");
put("mech.teleport.range", "Out of Range!");
put("mech.teleport.sign", "There is no Sign at your Destination!");
put("mech.teleport.arriveonly", "You can only arrive at this teleporter!");
put("mech.teleport.invalidcoords", "The entered coordinates are invalid!");
put("mech.teleport.obstruct", "Your destination is obstructed!");

put("circuits.pipes.create", "Pipe created!");
put("circuits.pipes.pipe-not-found", "Failed to find pipe!");

Expand Down
Expand Up @@ -119,23 +119,23 @@ public void onRedstoneChange(SourcedBlockRedstoneEvent event) {
}

private boolean isValidSponge(Material type) {
return type == Material.SPONGE || (includeWet && type == Material.WET_SPONGE);
return type == Material.SPONGE || includeWet && type == Material.WET_SPONGE;
}

private boolean isRemovableWater(Material material) {
return material == Material.WATER || material == Material.SEAGRASS
return material == Material.WATER || destructive && (material == Material.SEAGRASS
|| material == Material.TALL_SEAGRASS || material == Material.KELP_PLANT
|| material == Material.KELP;
|| material == Material.KELP);
}

private void setBlockToWater(Block block, Block source) {
if (block.getType().isAir()) {
BlockData sourceData = source.getBlockData();
int level = 0;
if (sourceData instanceof Levelled) {
int sourceLevel = ((Levelled) sourceData).getLevel();
if (sourceData instanceof Levelled levelled) {
int sourceLevel = levelled.getLevel();
if (sourceLevel != 0) {
level = Math.max(((Levelled) sourceData).getLevel() + 1, 7);
level = Math.max(levelled.getLevel() + 1, 7);
}
}
if (CraftBook.getInstance().getPlatform().getConfiguration().obeyPluginProtections) {
Expand Down Expand Up @@ -166,9 +166,9 @@ public void removeWater(Block block) {
water.setType(Material.AIR);
} else {
BlockData data = water.getBlockData();
if (data instanceof Waterlogged) {
((Waterlogged) data).setWaterlogged(false);
water.setBlockData(data);
if (data instanceof Waterlogged waterlogged) {
waterlogged.setWaterlogged(false);
water.setBlockData(waterlogged);
}
}
}
Expand Down Expand Up @@ -266,6 +266,7 @@ public void addWater(Block block) {
private boolean sphereRange;
private boolean redstone;
private boolean includeWet;
private boolean destructive;

@Override
public void loadFromConfiguration(YAMLProcessor config) {
Expand All @@ -280,5 +281,8 @@ public void loadFromConfiguration(YAMLProcessor config) {

config.setComment("require-redstone", "Whether to require redstone to suck up water or not.");
redstone = config.getBoolean("require-redstone", false);

config.setComment("destructive", "Whether to remove blocks that spread water such as kelp. These will not be returned when the sponge is de-activated.");
destructive = config.getBoolean("destructive", true);
}
}
Expand Up @@ -179,7 +179,7 @@ public void onThink(SelfTriggerThinkEvent event) {
ItemStack toRemove = i.clone();
toRemove.setAmount(1);
inventory.removeItem(toRemove);
// chest.update(); Oii

currentCookProgress -= 50;
break;
}
Expand Down

0 comments on commit eef222e

Please sign in to comment.