Skip to content

Commit

Permalink
Dev. progress for v3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCSDev committed Jan 28, 2024
1 parent d0c6947 commit cea91aa
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ else if(!isInstanceValid(this))
//register common-side commands
CommandManagerEvent.COMMAND_REGISTRATION_CALLBACK.register((dispatcher, commandRegAccess, regEnv) ->
{
//check the config property
if(!getConfig().registerCommands) return;

//register commands
StatisticsCommand.register(dispatcher, commandRegAccess);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class BetterStatsConfig extends AutoConfig
// --------------------------------------------------
public @SerializedAs("client-guiMobsFollowCursor") boolean guiMobsFollowCursor = true;
public @SerializedAs("server-enableSAS") boolean enableServerSAS = true;
public @SerializedAs("server-registerCommands") boolean registerCommands = true;
// ==================================================
public BetterStatsConfig(String name) { super(name); }
// ==================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import io.github.thecsdev.betterstats.network.BetterStatsNetworkHandler;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
Expand Down Expand Up @@ -132,7 +132,7 @@ else if(stat.getType() == Stats.CRAFTED && FIRST_CRAFTED_ITEMS.contains(stat.get
}
}
// --------------------------------------------------
private static final MutableText formatEntityText(Entity entity)
private static final MutableText formatPlayerText(PlayerEntity entity)
{
Objects.requireNonNull(entity);
final MutableText pText = literal("").append(entity.getDisplayName()).formatted(Formatting.YELLOW);
Expand Down Expand Up @@ -184,7 +184,7 @@ private static final MutableText formatItemText(Item item)
*/
public static final void broadcastFirstMine(ServerPlayerEntity player, Block minedBlock) throws NullPointerException
{
final var pText = formatEntityText(player);
final var pText = formatPlayerText(player);
final var bText = formatBlockText(minedBlock);
broadcastBssMessage(player.getServer(),
literal("").append(WATERMARK).append(" ").append(translatable(TXT_FIRST_MINED, pText, bText)),
Expand All @@ -200,13 +200,23 @@ public static final void broadcastFirstMine(ServerPlayerEntity player, Block min
*/
public static final void broadcastFirstCraft(ServerPlayerEntity player, Item craftedItem) throws NullPointerException
{
final var pText = formatEntityText(player);
final var pText = formatPlayerText(player);
final var iText = formatItemText(craftedItem);
broadcastBssMessage(player.getServer(),
literal("").append(WATERMARK).append(" ").append(translatable(TXT_FIRST_CRAFTED, pText, iText)),
literal("").append(WATERMARK).append(" ")
.append(pText).append(" just crafted their first ").append(iText).append("."));
}

/*public static final void broadcastFirstTame(ServerPlayerEntity player, EntityType<?> entity) throws NullPointerException
{
final var pText = formatEntityText(player);
final var eText = formatEntityText(entity);
broadcastBssMessage(player.getServer(),
literal("").append(WATERMARK).append(" ").append(translatable(TXT_FIRST_CRAFTED, pText, iText)),
literal("").append(WATERMARK).append(" ")
.append(pText).append(" just crafted their first ").append(iText).append("."));
}*/
// --------------------------------------------------
/**
* Broadcasts a stat announcement to all users in the server.<br/><br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ else if(!isInstanceValid(this))
//register common-side commands
CommandManagerEvent.COMMAND_REGISTRATION_CALLBACK.register((dispatcher, commandRegAccess, regEnv) ->
{
//check the config property
if(!getConfig().registerCommands) return;

//register commands
StatisticsCommand.register(dispatcher, commandRegAccess);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class BetterStatsConfig extends AutoConfig
// --------------------------------------------------
public @SerializedAs("client-guiMobsFollowCursor") boolean guiMobsFollowCursor = true;
public @SerializedAs("server-enableSAS") boolean enableServerSAS = true;
public @SerializedAs("server-registerCommands") boolean registerCommands = true;
// ==================================================
public BetterStatsConfig(String name) { super(name); }
// ==================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import io.github.thecsdev.betterstats.network.BetterStatsNetworkHandler;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
Expand Down Expand Up @@ -132,7 +132,7 @@ else if(stat.getType() == Stats.CRAFTED && FIRST_CRAFTED_ITEMS.contains(stat.get
}
}
// --------------------------------------------------
private static final MutableText formatEntityText(Entity entity)
private static final MutableText formatPlayerText(PlayerEntity entity)
{
Objects.requireNonNull(entity);
final MutableText pText = literal("").append(entity.getDisplayName()).formatted(Formatting.YELLOW);
Expand Down Expand Up @@ -184,7 +184,7 @@ private static final MutableText formatItemText(Item item)
*/
public static final void broadcastFirstMine(ServerPlayerEntity player, Block minedBlock) throws NullPointerException
{
final var pText = formatEntityText(player);
final var pText = formatPlayerText(player);
final var bText = formatBlockText(minedBlock);
broadcastBssMessage(player.getServer(),
literal("").append(WATERMARK).append(" ").append(translatable(TXT_FIRST_MINED, pText, bText)),
Expand All @@ -200,13 +200,23 @@ public static final void broadcastFirstMine(ServerPlayerEntity player, Block min
*/
public static final void broadcastFirstCraft(ServerPlayerEntity player, Item craftedItem) throws NullPointerException
{
final var pText = formatEntityText(player);
final var pText = formatPlayerText(player);
final var iText = formatItemText(craftedItem);
broadcastBssMessage(player.getServer(),
literal("").append(WATERMARK).append(" ").append(translatable(TXT_FIRST_CRAFTED, pText, iText)),
literal("").append(WATERMARK).append(" ")
.append(pText).append(" just crafted their first ").append(iText).append("."));
}

/*public static final void broadcastFirstTame(ServerPlayerEntity player, EntityType<?> entity) throws NullPointerException
{
final var pText = formatEntityText(player);
final var eText = formatEntityText(entity);
broadcastBssMessage(player.getServer(),
literal("").append(WATERMARK).append(" ").append(translatable(TXT_FIRST_CRAFTED, pText, iText)),
literal("").append(WATERMARK).append(" ")
.append(pText).append(" just crafted their first ").append(iText).append("."));
}*/
// --------------------------------------------------
/**
* Broadcasts a stat announcement to all users in the server.<br/><br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,9 @@
"betterstats.client.gui.screen.hud.betterstatshudscreen.tutorial_3": "Press Escape (ESC) to close this screen.",

"betterstats.network.betterstatsnetworkhandler.toggle_tooltip": "Toggle 'betterstats' server connection",
"betterstats.network.betterstatsnetworkhandler.consent_warning": "IMPORTANT:\nBy enabling this feature, the server will find out that you are using a modified client with 'betterstats' installed. To protect your privacy, do not use this feature on servers that may not allow modified clients or this mod.\n\nEnabling this feature adds some extra features that are available when the mod is installed on the server as well."
"betterstats.network.betterstatsnetworkhandler.consent_warning": "IMPORTANT:\nBy enabling this feature, the server will find out that you are using a modified client with 'betterstats' installed. To protect your privacy, do not use this feature on servers that may not allow modified clients or this mod.\n\nEnabling this feature adds some extra features that are available when the mod is installed on the server as well.",


"betterstats.util.stats.statannouncementsystem.mined_first_time": "%s just mined their first %s.",
"betterstats.util.stats.statannouncementsystem.crafted_first_time": "%s just crafted their first %s."
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ else if(!isInstanceValid(this))
//register common-side commands
CommandManagerEvent.COMMAND_REGISTRATION_CALLBACK.register((dispatcher, commandRegAccess, regEnv) ->
{
//check the config property
if(!getConfig().registerCommands) return;

//register commands
StatisticsCommand.register(dispatcher, commandRegAccess);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class BetterStatsConfig extends AutoConfig
// --------------------------------------------------
public @SerializedAs("client-guiMobsFollowCursor") boolean guiMobsFollowCursor = true;
public @SerializedAs("server-enableSAS") boolean enableServerSAS = true;
public @SerializedAs("server-registerCommands") boolean registerCommands = true;
// ==================================================
public BetterStatsConfig(String name) { super(name); }
// ==================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import io.github.thecsdev.betterstats.network.BetterStatsNetworkHandler;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
Expand Down Expand Up @@ -132,7 +132,7 @@ else if(stat.getType() == Stats.CRAFTED && FIRST_CRAFTED_ITEMS.contains(stat.get
}
}
// --------------------------------------------------
private static final MutableText formatEntityText(Entity entity)
private static final MutableText formatPlayerText(PlayerEntity entity)
{
Objects.requireNonNull(entity);
final MutableText pText = literal("").append(entity.getDisplayName()).formatted(Formatting.YELLOW);
Expand Down Expand Up @@ -184,7 +184,7 @@ private static final MutableText formatItemText(Item item)
*/
public static final void broadcastFirstMine(ServerPlayerEntity player, Block minedBlock) throws NullPointerException
{
final var pText = formatEntityText(player);
final var pText = formatPlayerText(player);
final var bText = formatBlockText(minedBlock);
broadcastBssMessage(player.getServer(),
literal("").append(WATERMARK).append(" ").append(translatable(TXT_FIRST_MINED, pText, bText)),
Expand All @@ -200,13 +200,23 @@ public static final void broadcastFirstMine(ServerPlayerEntity player, Block min
*/
public static final void broadcastFirstCraft(ServerPlayerEntity player, Item craftedItem) throws NullPointerException
{
final var pText = formatEntityText(player);
final var pText = formatPlayerText(player);
final var iText = formatItemText(craftedItem);
broadcastBssMessage(player.getServer(),
literal("").append(WATERMARK).append(" ").append(translatable(TXT_FIRST_CRAFTED, pText, iText)),
literal("").append(WATERMARK).append(" ")
.append(pText).append(" just crafted their first ").append(iText).append("."));
}

/*public static final void broadcastFirstTame(ServerPlayerEntity player, EntityType<?> entity) throws NullPointerException
{
final var pText = formatEntityText(player);
final var eText = formatEntityText(entity);
broadcastBssMessage(player.getServer(),
literal("").append(WATERMARK).append(" ").append(translatable(TXT_FIRST_CRAFTED, pText, iText)),
literal("").append(WATERMARK).append(" ")
.append(pText).append(" just crafted their first ").append(iText).append("."));
}*/
// --------------------------------------------------
/**
* Broadcasts a stat announcement to all users in the server.<br/><br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,9 @@
"betterstats.client.gui.screen.hud.betterstatshudscreen.tutorial_3": "Press Escape (ESC) to close this screen.",

"betterstats.network.betterstatsnetworkhandler.toggle_tooltip": "Toggle 'betterstats' server connection",
"betterstats.network.betterstatsnetworkhandler.consent_warning": "IMPORTANT:\nBy enabling this feature, the server will find out that you are using a modified client with 'betterstats' installed. To protect your privacy, do not use this feature on servers that may not allow modified clients or this mod.\n\nEnabling this feature adds some extra features that are available when the mod is installed on the server as well."
"betterstats.network.betterstatsnetworkhandler.consent_warning": "IMPORTANT:\nBy enabling this feature, the server will find out that you are using a modified client with 'betterstats' installed. To protect your privacy, do not use this feature on servers that may not allow modified clients or this mod.\n\nEnabling this feature adds some extra features that are available when the mod is installed on the server as well.",


"betterstats.util.stats.statannouncementsystem.mined_first_time": "%s just mined their first %s.",
"betterstats.util.stats.statannouncementsystem.crafted_first_time": "%s just crafted their first %s."
}

0 comments on commit cea91aa

Please sign in to comment.