Skip to content

Commit

Permalink
Switch to enums for simple value configs
Browse files Browse the repository at this point in the history
  • Loading branch information
ArkoSammy12 committed Nov 2, 2023
1 parent 2dbfa5c commit c9e3f41
Show file tree
Hide file tree
Showing 20 changed files with 255 additions and 669 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static void register(LiteralCommandNode<ServerCommandSource> creeperHeali

private static int setExplosionHealDelayCommand(CommandContext<ServerCommandSource> ctx) {
if(Math.round(Math.max(DoubleArgumentType.getDouble(ctx, "seconds"), 0) * 20L) != 0) {
DelaysConfig.setExplosionHealDelay(DoubleArgumentType.getDouble(ctx, "seconds"));
DelaysConfig.EXPLOSION_HEAL_DELAY.getEntry().setValue(DoubleArgumentType.getDouble(ctx, "seconds"));
ctx.getSource().sendMessage(Text.literal("Explosion heal delay has been set to: " + DoubleArgumentType.getDouble(ctx, "seconds") + " second(s)"));
} else {
ctx.getSource().sendMessage(Text.literal("Cannot set explosion heal delay to a very low value").formatted(Formatting.RED));
Expand All @@ -76,7 +76,7 @@ private static int setExplosionHealDelayCommand(CommandContext<ServerCommandSour

private static int setBlockPlacementDelayCommand(CommandContext<ServerCommandSource> ctx) {
if (Math.round(Math.max(DoubleArgumentType.getDouble(ctx, "seconds"), 0) * 20L) != 0) {
DelaysConfig.setBlockPlacementDelay(DoubleArgumentType.getDouble(ctx, "seconds"));
DelaysConfig.BLOCK_PLACEMENT_DELAY.getEntry().setValue(DoubleArgumentType.getDouble(ctx, "seconds"));
AffectedBlock.updateAffectedBlocksTimers();
ctx.getSource().sendMessage(Text.literal("Block placement delay has been set to: " + DoubleArgumentType.getDouble(ctx, "seconds") + " second(s)"));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,79 +144,79 @@ public static void register(LiteralCommandNode<ServerCommandSource> creeperHeali
}

private static int setDropItemsOnCreeperExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ExplosionItemDropConfig.setDropItemsOnCreeperExplosions(BoolArgumentType.getBool(ctx, "value"));
ExplosionItemDropConfig.DROP_ITEMS_ON_CREEPER_EXPLOSIONS.getEntry().setValue(BoolArgumentType.getBool(ctx, "value"));
ctx.getSource().sendMessage(Text.literal("Drop items on Creeper explosions has been set to: " + BoolArgumentType.getBool(ctx, "value")));
return Command.SINGLE_SUCCESS;
}

private static int setDropItemsOnGhastExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ExplosionItemDropConfig.setDropItemsOnGhastExplosions(BoolArgumentType.getBool(ctx, "value"));
ExplosionItemDropConfig.DROP_ITEMS_ON_GHAST_EXPLOSIONS.getEntry().setValue(BoolArgumentType.getBool(ctx, "value"));
ctx.getSource().sendMessage(Text.literal("Drop items on Ghast explosions has been set to: " + BoolArgumentType.getBool(ctx, "value")));
return Command.SINGLE_SUCCESS;
}

private static int setDropItemsOnWitherExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ExplosionItemDropConfig.setDropItemsOnWitherExplosions(BoolArgumentType.getBool(ctx, "value"));
ExplosionItemDropConfig.DROP_ITEMS_ON_WITHER_EXPLOSIONS.getEntry().setValue(BoolArgumentType.getBool(ctx, "value"));
ctx.getSource().sendMessage(Text.literal("Drop items on Wither explosions has been set to: " + BoolArgumentType.getBool(ctx, "value")));
return Command.SINGLE_SUCCESS;
}

private static int setDropItemsOnTNTExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ExplosionItemDropConfig.setDropItemsOnTNTExplosions(BoolArgumentType.getBool(ctx, "value"));
ExplosionItemDropConfig.DROP_ITEMS_ON_TNT_EXPLOSIONS.getEntry().setValue(BoolArgumentType.getBool(ctx, "value"));
ctx.getSource().sendMessage(Text.literal("Drop items on TNT explosions has been set to: " + BoolArgumentType.getBool(ctx, "value")));
return Command.SINGLE_SUCCESS;
}

private static int setDropItemsOnTNTMinecartExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ExplosionItemDropConfig.setDropItemsOnTNTMinecartExplosions(BoolArgumentType.getBool(ctx, "value"));
ExplosionItemDropConfig.DROP_ITEMS_ON_TNT_MINECART_EXPLOSIONS.getEntry().setValue(BoolArgumentType.getBool(ctx, "value"));
ctx.getSource().sendMessage(Text.literal("Drop items on TNT minecart explosions has been set to: " + BoolArgumentType.getBool(ctx, "value")));
return Command.SINGLE_SUCCESS;
}

private static int setDropItemsOnBedAndRespawnAnchorExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ExplosionItemDropConfig.setDropItemsOnBedAndRespawnAnchorExplosions(BoolArgumentType.getBool(ctx, "value"));
ExplosionItemDropConfig.DROP_ITEMS_ON_BED_AND_RESPAWN_ANCHOR_EXPLOSIONS.getEntry().setValue(BoolArgumentType.getBool(ctx, "value"));
ctx.getSource().sendMessage(Text.literal("Drop items on bed and respawn anchor explosions has been set to: " + BoolArgumentType.getBool(ctx, "value")));
return Command.SINGLE_SUCCESS;
}

private static int setDropItemsOnEndCrystalExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ExplosionItemDropConfig.setDropItemsOnEndCrystalExplosions(BoolArgumentType.getBool(ctx, "value"));
ExplosionItemDropConfig.DROP_ITEMS_ON_END_CRYSTAL_EXPLOSIONS.getEntry().setValue(BoolArgumentType.getBool(ctx, "value"));
ctx.getSource().sendMessage(Text.literal("Drop items on end crystal explosions has been set to: " + BoolArgumentType.getBool(ctx, "value")));
return Command.SINGLE_SUCCESS;
}

private static int getDropItemsOnCreeperExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ctx.getSource().sendMessage(Text.literal("Drop items on Creeper explosions currently set to: " + ExplosionItemDropConfig.getDropItemsOnCreeperExplosions()));
ctx.getSource().sendMessage(Text.literal("Drop items on Creeper explosions currently set to: " + ExplosionItemDropConfig.DROP_ITEMS_ON_CREEPER_EXPLOSIONS.getEntry().getValue()));
return Command.SINGLE_SUCCESS;
}

private static int getDropItemsOnGhastExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ctx.getSource().sendMessage(Text.literal("Drop items on Ghast explosions currently set to: " + ExplosionItemDropConfig.getDropItemsOnGhastExplosions()));
ctx.getSource().sendMessage(Text.literal("Drop items on Ghast explosions currently set to: " + ExplosionItemDropConfig.DROP_ITEMS_ON_GHAST_EXPLOSIONS.getEntry().getValue()));
return Command.SINGLE_SUCCESS;
}

private static int getDropItemsOnWitherExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ctx.getSource().sendMessage(Text.literal("Drop items on Wither explosions currently set to: " + ExplosionItemDropConfig.getDropItemsOnWitherExplosions()));
ctx.getSource().sendMessage(Text.literal("Drop items on Wither explosions currently set to: " + ExplosionItemDropConfig.DROP_ITEMS_ON_WITHER_EXPLOSIONS.getEntry().getValue()));
return Command.SINGLE_SUCCESS;
}

private static int getDropItemsOnTNTExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ctx.getSource().sendMessage(Text.literal("Drop items on TNT explosions currently set to: " + ExplosionItemDropConfig.getDropItemsOnTNTExplosions()));
ctx.getSource().sendMessage(Text.literal("Drop items on TNT explosions currently set to: " + ExplosionItemDropConfig.DROP_ITEMS_ON_TNT_EXPLOSIONS.getEntry().getValue()));
return Command.SINGLE_SUCCESS;
}

private static int getDropItemsOnTNTMinecartExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ctx.getSource().sendMessage(Text.literal("Drop items on TNT minecart explosions currently set to: " + ExplosionItemDropConfig.getDropItemsOnTNTMinecartExplosions()));
ctx.getSource().sendMessage(Text.literal("Drop items on TNT minecart explosions currently set to: " + ExplosionItemDropConfig.DROP_ITEMS_ON_TNT_MINECART_EXPLOSIONS.getEntry().getValue()));
return Command.SINGLE_SUCCESS;
}

private static int getDropItemsOnBedAndRespawnAnchorExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ctx.getSource().sendMessage(Text.literal("Drop items on bed and respawn anchor explosions currently set to: " + ExplosionItemDropConfig.getDropItemsOnBedAndRespawnAnchorExplosions()));
ctx.getSource().sendMessage(Text.literal("Drop items on bed and respawn anchor explosions currently set to: " + ExplosionItemDropConfig.DROP_ITEMS_ON_BED_AND_RESPAWN_ANCHOR_EXPLOSIONS.getEntry().getValue()));
return Command.SINGLE_SUCCESS;
}

private static int getDropItemsOnEndCrystalExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ctx.getSource().sendMessage(Text.literal("Drop items on end crystal explosions currently set to: "+ ExplosionItemDropConfig.getDropItemsOnEndCrystalExplosions()));
ctx.getSource().sendMessage(Text.literal("Drop items on end crystal explosions currently set to: "+ ExplosionItemDropConfig.DROP_ITEMS_ON_END_CRYSTAL_EXPLOSIONS.getEntry().getValue()));
return Command.SINGLE_SUCCESS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,79 +144,79 @@ public static void register(LiteralCommandNode<ServerCommandSource> creeperHeali
}

private static int setHealCreeperExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ExplosionSourceConfig.setHealCreeperExplosions(BoolArgumentType.getBool(ctx, "value"));
ExplosionSourceConfig.HEAL_CREEPER_EXPLOSIONS.getEntry().setValue(BoolArgumentType.getBool(ctx, "value"));
ctx.getSource().sendMessage(Text.literal("Heal Creeper explosions has been set to: " + BoolArgumentType.getBool(ctx, "value")));
return Command.SINGLE_SUCCESS;
}

private static int setHealGhastExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ExplosionSourceConfig.setHealGhastExplosions(BoolArgumentType.getBool(ctx, "value"));
ExplosionSourceConfig.HEAL_GHAST_EXPLOSIONS.getEntry().setValue(BoolArgumentType.getBool(ctx, "value"));
ctx.getSource().sendMessage(Text.literal("Heal Ghast explosions has been set to: " + BoolArgumentType.getBool(ctx, "value")));
return Command.SINGLE_SUCCESS;
}

private static int setHealWitherExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ExplosionSourceConfig.setHealWitherExplosions(BoolArgumentType.getBool(ctx, "value"));
ExplosionSourceConfig.HEAL_WITHER_EXPLOSIONS.getEntry().setValue(BoolArgumentType.getBool(ctx, "value"));
ctx.getSource().sendMessage(Text.literal("Heal Wither explosions has been set to: " + BoolArgumentType.getBool(ctx, "value")));
return Command.SINGLE_SUCCESS;
}

private static int setHealTNTExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ExplosionSourceConfig.setHealTNTExplosions(BoolArgumentType.getBool(ctx, "value"));
ExplosionSourceConfig.HEAL_TNT_EXPLOSIONS.getEntry().setValue(BoolArgumentType.getBool(ctx, "value"));
ctx.getSource().sendMessage(Text.literal("Heal TNT explosions has been set to: " + BoolArgumentType.getBool(ctx, "value")));
return Command.SINGLE_SUCCESS;
}

private static int setHealTNTMinecartExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ExplosionSourceConfig.setHealTNTMinecartExplosions(BoolArgumentType.getBool(ctx, "value"));
ExplosionSourceConfig.HEAL_TNT_MINECART_EXPLOSIONS.getEntry().setValue(BoolArgumentType.getBool(ctx, "value"));
ctx.getSource().sendMessage(Text.literal("Heal TNT Minecart explosions has been set to: " + BoolArgumentType.getBool(ctx, "value")));
return Command.SINGLE_SUCCESS;
}

private static int setHealBedAndRespawnAnchorExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ExplosionSourceConfig.setHealBedAndRespawnAnchorExplosions(BoolArgumentType.getBool(ctx, "value"));
ExplosionSourceConfig.HEAL_BED_AND_RESPAWN_ANCHOR_EXPLOSIONS.getEntry().setValue(BoolArgumentType.getBool(ctx, "value"));
ctx.getSource().sendMessage(Text.literal("Heal bed and respawn anchor explosions has been set to: " + BoolArgumentType.getBool(ctx, "value")));
return Command.SINGLE_SUCCESS;
}

private static int setHealEndCrystalExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ExplosionSourceConfig.setHealEndCrystalExplosions(BoolArgumentType.getBool(ctx, "value"));
ExplosionSourceConfig.HEAL_END_CRYSTAL_EXPLOSIONS.getEntry().setValue(BoolArgumentType.getBool(ctx, "value"));
ctx.getSource().sendMessage(Text.literal("Heal end crystal explosions has been set to: " + BoolArgumentType.getBool(ctx, "value")));
return Command.SINGLE_SUCCESS;
}

private static int getHealCreeperExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ctx.getSource().sendMessage(Text.literal("Heal Creeper explosions currently set to: " + ExplosionSourceConfig.getHealCreeperExplosions()));
ctx.getSource().sendMessage(Text.literal("Heal Creeper explosions currently set to: " + ExplosionSourceConfig.HEAL_CREEPER_EXPLOSIONS.getEntry().getValue()));
return Command.SINGLE_SUCCESS;
}

private static int getHealGhastExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ctx.getSource().sendMessage(Text.literal("Heal Ghast explosions currently set to: " + ExplosionSourceConfig.getHealGhastExplosions()));
ctx.getSource().sendMessage(Text.literal("Heal Ghast explosions currently set to: " + ExplosionSourceConfig.HEAL_GHAST_EXPLOSIONS.getEntry().getValue()));
return Command.SINGLE_SUCCESS;
}

private static int getHealWitherExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ctx.getSource().sendMessage(Text.literal("Heal Wither explosions currently set to: " + ExplosionSourceConfig.getHealWitherExplosions()));
ctx.getSource().sendMessage(Text.literal("Heal Wither explosions currently set to: " + ExplosionSourceConfig.HEAL_WITHER_EXPLOSIONS.getEntry().getValue()));
return Command.SINGLE_SUCCESS;
}

private static int getHealTNTExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ctx.getSource().sendMessage(Text.literal("Heal TNT explosions currently set to: " + ExplosionSourceConfig.getHealTNTExplosions()));
ctx.getSource().sendMessage(Text.literal("Heal TNT explosions currently set to: " + ExplosionSourceConfig.HEAL_TNT_EXPLOSIONS.getEntry().getValue()));
return Command.SINGLE_SUCCESS;
}

private static int getHealTNTMinecartExplosionCommand(CommandContext<ServerCommandSource> ctx){
ctx.getSource().sendMessage(Text.literal("Heal TNT minecart explosions currently set to: " + ExplosionSourceConfig.getHealTNTMinecartExplosions()));
ctx.getSource().sendMessage(Text.literal("Heal TNT minecart explosions currently set to: " + ExplosionSourceConfig.HEAL_TNT_MINECART_EXPLOSIONS.getEntry().getValue()));
return Command.SINGLE_SUCCESS;
}

private static int getHealBedAndRespawnAnchorExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ctx.getSource().sendMessage(Text.literal("Heal bed and respawn anchor explosions currently set to: " + ExplosionSourceConfig.getHealBedAndRespawnAnchorExplosions()));
ctx.getSource().sendMessage(Text.literal("Heal bed and respawn anchor explosions currently set to: " + ExplosionSourceConfig.HEAL_BED_AND_RESPAWN_ANCHOR_EXPLOSIONS.getEntry().getValue()));
return Command.SINGLE_SUCCESS;
}

private static int getHealEndCrystalExplosionsCommand(CommandContext<ServerCommandSource> ctx){
ctx.getSource().sendMessage(Text.literal("Heal end crystal explosions currently set to: " + ExplosionSourceConfig.getHealEndCrystalExplosions()));
ctx.getSource().sendMessage(Text.literal("Heal end crystal explosions currently set to: " + ExplosionSourceConfig.HEAL_END_CRYSTAL_EXPLOSIONS.getEntry().getValue()));
return Command.SINGLE_SUCCESS;
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/xd/arkosammy/commands/categories/ModeCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,31 +62,31 @@ public static void register(LiteralCommandNode<ServerCommandSource> creeperHeali
}

private static int setDefaultHealingModeCommand(CommandContext<ServerCommandSource> ctx){
ModeConfig.setHealingMode(ExplosionHealingMode.DEFAULT_MODE.getName());
ModeConfig.MODE.getEntry().setValue(ExplosionHealingMode.DEFAULT_MODE.getName());
ctx.getSource().sendMessage(Text.literal("Explosion healing mode has been set to: " + ExplosionHealingMode.DEFAULT_MODE.getDisplayName()));
return Command.SINGLE_SUCCESS;
}

private static int setDaytimeHealingModeCommand(CommandContext<ServerCommandSource> ctx){
ModeConfig.setHealingMode(ExplosionHealingMode.DAYTIME_HEALING_MODE.getName());
ModeConfig.MODE.getEntry().setValue(ExplosionHealingMode.DAYTIME_HEALING_MODE.getName());
ctx.getSource().sendMessage(Text.literal("Explosion healing mode has been set to: " + ExplosionHealingMode.DAYTIME_HEALING_MODE.getDisplayName()));
return Command.SINGLE_SUCCESS;
}

private static int setDifficultyBasedModeCommand(CommandContext<ServerCommandSource> ctx){
ModeConfig.setHealingMode(ExplosionHealingMode.DIFFICULTY_BASED_HEALING_MODE.getName());
ModeConfig.MODE.getEntry().setValue(ExplosionHealingMode.DIFFICULTY_BASED_HEALING_MODE.getName());
ctx.getSource().sendMessage(Text.literal("Explosion healing mode has been set to: " + ExplosionHealingMode.DIFFICULTY_BASED_HEALING_MODE.getDisplayName()));
return Command.SINGLE_SUCCESS;
}

private static int setBlastResistanceBasedHealingModeCommand(CommandContext<ServerCommandSource> ctx){
ModeConfig.setHealingMode(ExplosionHealingMode.BLAST_RESISTANCE_BASED_HEALING_MODE.getName());
ModeConfig.MODE.getEntry().setValue(ExplosionHealingMode.BLAST_RESISTANCE_BASED_HEALING_MODE.getName());
ctx.getSource().sendMessage(Text.literal("Explosion healing mode has been set to: " + ExplosionHealingMode.BLAST_RESISTANCE_BASED_HEALING_MODE.getDisplayName()));
return Command.SINGLE_SUCCESS;
}

private static int getHealingModeCommand(CommandContext<ServerCommandSource> ctx){
ctx.getSource().sendMessage(Text.literal("Explosion healing mode currently has been set to: " + ExplosionHealingMode.getFromName(ModeConfig.getHealingMode()).getDisplayName()));
ctx.getSource().sendMessage(Text.literal("Explosion healing mode currently has been set to: " + ExplosionHealingMode.getFromName(ModeConfig.MODE.getEntry().getValue()).getDisplayName()));
return Command.SINGLE_SUCCESS;
}

Expand Down
Loading

0 comments on commit c9e3f41

Please sign in to comment.