Skip to content

Commit

Permalink
make it configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
deirn committed Jun 3, 2021
1 parent 23279d6 commit 28279fd
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 46 deletions.
9 changes: 9 additions & 0 deletions src/base/java/badasintended/megane/config/MeganeConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ public class MeganeConfig {
public final PetOwner petOwner = new PetOwner();
public final Effect effect = new Effect();

private boolean catchServerErrors = true;
private boolean spawnEgg = true;
private boolean playerHead = true;

public boolean getCatchServerErrors() {
return catchServerErrors;
}

public boolean getSpawnEgg() {
return spawnEgg;
}
Expand All @@ -35,6 +40,10 @@ public boolean getPlayerHead() {
return playerHead;
}

public void setCatchServerErrors(boolean catchServerErrors) {
this.catchServerErrors = catchServerErrors;
}

public void setSpawnEgg(boolean spawnEgg) {
this.spawnEgg = spawnEgg;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public OptionsListWidget getOptions() {
}
})));

options.add(sided(SERVER, bool("catchServerErrors", config().getCatchServerErrors(), config()::setCatchServerErrors)));
options.add(sided(CLIENT, bool("spawnEgg", config().getSpawnEgg(), config()::setSpawnEgg)));
options.add(sided(CLIENT, bool("playerHead", config().getPlayerHead(), config()::setPlayerHead)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import static badasintended.megane.util.MeganeUtils.ISSUE_URL;
import static badasintended.megane.util.MeganeUtils.LOGGER;
import static badasintended.megane.util.MeganeUtils.config;
import static net.minecraft.util.registry.Registry.BLOCK;

public abstract class BlockData implements IServerDataProvider<BlockEntity> {
Expand Down Expand Up @@ -54,6 +55,9 @@ public final void appendServerData(CompoundTag data, ServerPlayerEntity player,
BlockPos pos = blockEntity.getPos();
player.sendSystemMessage(ERROR_TEXT, Util.NIL_UUID);
LOGGER.error("Something went wrong when retrieving data for {} at ({}, {}, {})", blockEntity.getClass().getName(), pos.getX(), pos.getY(), pos.getZ());
if (!config().getCatchServerErrors()) {
throw t;
}
LOGGER.error("Stacktrace:", t);

if (registry != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import static badasintended.megane.util.MeganeUtils.ISSUE_URL;
import static badasintended.megane.util.MeganeUtils.LOGGER;
import static badasintended.megane.util.MeganeUtils.config;
import static net.minecraft.util.registry.Registry.ENTITY_TYPE;

public abstract class EntityData implements IServerDataProvider<LivingEntity> {
Expand Down Expand Up @@ -54,6 +55,9 @@ public final void appendServerData(CompoundTag data, ServerPlayerEntity player,
Vec3d pos = entity.getPos();
player.sendSystemMessage(ERROR_TEXT, Util.NIL_UUID);
LOGGER.error("Something went wrong when retrieving data for {} at ({}, {}, {})", entity.getClass().getName(), pos.getX(), pos.getY(), pos.getZ());
if (!config().getCatchServerErrors()) {
throw t;
}
LOGGER.error("Stacktrace:", t);

if (registry != null) {
Expand Down
94 changes: 48 additions & 46 deletions src/runtime/resources/assets/megane/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,50 @@
{
"config.waila.megane" : "Megane",
"config.megane.side.server" : "§7This option will get overloaded by the server",
"config.megane.side.and" : "§7Both client and server needs to have the same value",
"config.megane.side.plus" : "§7Server values will be added to the list",
"config.megane.side.client" : "§7This option is client side only",
"config.megane.enabled" : "Enabled",
"config.megane.expand" : "Expand when Sneaking",
"config.megane.add" : "Add New",
"config.megane.blacklist" : "Blacklist",
"config.megane.inventory" : "Block Inventory",
"config.megane.entityInventory" : "Entity Inventory",
"config.megane.inventory.itemCount" : "Show Item Count",
"config.megane.inventory.nbt" : "NBT Data",
"config.megane.inventory.nbt_desc" : "§7While this makes two stack with same item but different NBT not merged in the tooltip, this makes the packet sent to client significantly bigger, so it's not recommended for dedicated server",
"config.megane.inventory.maxWidth" : "Max Width",
"config.megane.inventory.maxHeight" : "Max Height",
"config.megane.inventory.blacklist" : "Inventory Blacklist",
"config.megane.energy" : "Energy",
"config.megane.energy.color" : "Bar Colors",
"config.megane.energy.color_desc" : "RRGGBB",
"config.megane.energy.unit" : "Units",
"config.megane.energy.blacklist" : "Energy Blacklist",
"config.megane.fluid" : "Fluid",
"config.megane.fluid.color" : "Bar Colors",
"config.megane.fluid.color_desc" : "RRGGBB",
"config.megane.fluid.blacklist" : "Fluid Blacklist",
"config.megane.progress" : "Progress",
"config.megane.progress.showWhenZero": "Show when 0%",
"config.megane.progress.blacklist" : "Progress Blacklist",
"config.megane.owner" : "Pet Owner",
"config.megane.owner.offline" : "Show Offline Owner",
"config.megane.owner.offline_desc" : "§7If enabled it will try to get offline owner name by sending a request to §5https://sessionserver.mojang.com §7and cache the result for later use. Otherwise just show \"???\" instead",
"config.megane.owner.blacklist" : "Pet Owner Blacklist",
"config.megane.effect" : "Status Effect",
"config.megane.effect.level" : "Show Level",
"config.megane.effect.hidden" : "Show Hidden Effect",
"config.megane.effect.roman" : "Use Roman Numeral",
"config.megane.effect.blacklist" : "Status Effect Blacklist",
"config.megane.playerHead" : "Player Head Icon",
"config.megane.spawnEgg" : "Spawn Egg Icon",
"megane.energy" : "Energy",
"megane.level" : "Level",
"megane.owner" : "Owner",
"megane.fluid.unknown" : "Unknown Fluid",
"megane.configToast.title" : "Megane Config Reset",
"megane.configToast.desc" : "Found version %d, not %d"
"config.waila.megane" : "Megane",
"config.megane.side.server" : "§7This option will get overloaded by the server",
"config.megane.side.and" : "§7Both client and server needs to have the same value",
"config.megane.side.plus" : "§7Server values will be added to the list",
"config.megane.side.client" : "§7This option is client side only",
"config.megane.enabled" : "Enabled",
"config.megane.expand" : "Expand when Sneaking",
"config.megane.add" : "Add New",
"config.megane.blacklist" : "Blacklist",
"config.megane.inventory" : "Block Inventory",
"config.megane.entityInventory" : "Entity Inventory",
"config.megane.inventory.itemCount" : "Show Item Count",
"config.megane.inventory.nbt" : "NBT Data",
"config.megane.inventory.nbt_desc" : "§7While this makes two stack with same item but different NBT not merged in the tooltip, this makes the packet sent to client significantly bigger, so it's not recommended for dedicated server",
"config.megane.inventory.maxWidth" : "Max Width",
"config.megane.inventory.maxHeight" : "Max Height",
"config.megane.inventory.blacklist" : "Inventory Blacklist",
"config.megane.energy" : "Energy",
"config.megane.energy.color" : "Bar Colors",
"config.megane.energy.color_desc" : "RRGGBB",
"config.megane.energy.unit" : "Units",
"config.megane.energy.blacklist" : "Energy Blacklist",
"config.megane.fluid" : "Fluid",
"config.megane.fluid.color" : "Bar Colors",
"config.megane.fluid.color_desc" : "RRGGBB",
"config.megane.fluid.blacklist" : "Fluid Blacklist",
"config.megane.progress" : "Progress",
"config.megane.progress.showWhenZero" : "Show when 0%",
"config.megane.progress.blacklist" : "Progress Blacklist",
"config.megane.owner" : "Pet Owner",
"config.megane.owner.offline" : "Show Offline Owner",
"config.megane.owner.offline_desc" : "§7If enabled it will try to get offline owner name by sending a request to §5https://sessionserver.mojang.com §7and cache the result for later use. Otherwise just show \"???\" instead",
"config.megane.owner.blacklist" : "Pet Owner Blacklist",
"config.megane.effect" : "Status Effect",
"config.megane.effect.level" : "Show Level",
"config.megane.effect.hidden" : "Show Hidden Effect",
"config.megane.effect.roman" : "Use Roman Numeral",
"config.megane.effect.blacklist" : "Status Effect Blacklist",
"config.megane.playerHead" : "Player Head Icon",
"config.megane.spawnEgg" : "Spawn Egg Icon",
"config.megane.catchServerErrors" : "Catch Server Errors",
"config.megane.catchServerErrors_desc": "§7Make errors on block/entity data provider not crashing the server but instead, just simply disable the data for that specific block/entity",
"megane.energy" : "Energy",
"megane.level" : "Level",
"megane.owner" : "Owner",
"megane.fluid.unknown" : "Unknown Fluid",
"megane.configToast.title" : "Megane Config Reset",
"megane.configToast.desc" : "Found version %d, not %d"
}

0 comments on commit 28279fd

Please sign in to comment.