Skip to content

Commit afa7c2b

Browse files
committed
Medium changes, added player info and changelog adaption
- Added `chatBoxMessageSize` configuration option to limit message length. - Added checks in Chat Box methods to prevent messages exceeding the limit. - Included UUID and name data in Player Detector `morePlayerInformation`. - Adjusted default chemical filter count to 1000 mB.
1 parent c0a69ab commit afa7c2b

5 files changed

Lines changed: 43 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
9-
## [1.21.1-0.7.50b] - 2025-06-10
10-
## [1.21.1-0.7.50b] - 2025-06-10
11-
## [1.21.1-0.7.49a] - 2025-02-14
9+
10+
### Added
11+
- UUID and Name property to the player lua object of the player detector
12+
13+
### Changed
14+
- Patchouli book texture
15+
- Default chemical filter count from 64 mB to 1000 mB
16+
- Added a configurable char limit to chat box messages
17+
18+
### Fixed
19+
- Fixed that several mekanism integrations would crash the game/server when mekanism is not loaded
20+
- [#746] Fixed that export and import functions from the ME bridge would not find target inventories
21+
- Updated Patchouli book documentation URLs
22+
- Support with the latest mekanism version
1223

1324
## [1.21.1-0.7.50b] - 2025-06-10
1425

src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/ChatBoxPeripheral.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ private boolean checkBrackets(Optional<String> brackets) {
111111
public final MethodResult sendFormattedMessage(@NotNull IArguments arguments) throws LuaException {
112112
return withChatOperation(ignored -> {
113113
String message = arguments.getString(0);
114+
115+
if (message.length() > APConfig.PERIPHERALS_CONFIG.chatBoxMessageSize.get())
116+
return MethodResult.of(null, "Message is too long");
117+
114118
int maxRange = APConfig.PERIPHERALS_CONFIG.chatBoxMaxRange.get();
115119
int range = arguments.optInt(4, -1);
116120
ResourceKey<Level> dimension = getLevel().dimension();
@@ -140,6 +144,10 @@ public final MethodResult sendFormattedMessage(@NotNull IArguments arguments) th
140144
public final MethodResult sendMessage(@NotNull IArguments arguments) throws LuaException {
141145
return withChatOperation(ignored -> {
142146
String message = arguments.getString(0);
147+
148+
if (message.length() > APConfig.PERIPHERALS_CONFIG.chatBoxMessageSize.get())
149+
return MethodResult.of(null, "Message is too long");
150+
143151
int maxRange = APConfig.PERIPHERALS_CONFIG.chatBoxMaxRange.get();
144152
int range = arguments.optInt(4, -1);
145153
ResourceKey<Level> dimension = getLevel().dimension();
@@ -165,6 +173,10 @@ public final MethodResult sendMessage(@NotNull IArguments arguments) throws LuaE
165173
public final MethodResult sendFormattedMessageToPlayer(@NotNull IArguments arguments) throws LuaException {
166174
return withChatOperation(ignored -> {
167175
String message = arguments.getString(0);
176+
177+
if (message.length() > APConfig.PERIPHERALS_CONFIG.chatBoxMessageSize.get())
178+
return MethodResult.of(null, "Message is too long");
179+
168180
String playerName = arguments.getString(1);
169181
int maxRange = APConfig.PERIPHERALS_CONFIG.chatBoxMaxRange.get();
170182
int range = arguments.optInt(5, -1);
@@ -199,6 +211,10 @@ public final MethodResult sendFormattedMessageToPlayer(@NotNull IArguments argum
199211
public final MethodResult sendFormattedToastToPlayer(@NotNull IArguments arguments) throws LuaException {
200212
return withChatOperation(ignored -> {
201213
String message = arguments.getString(0);
214+
215+
if (message.length() > APConfig.PERIPHERALS_CONFIG.chatBoxMessageSize.get())
216+
return MethodResult.of(null, "Message is too long");
217+
202218
String title = arguments.getString(1);
203219
String playerName = arguments.getString(2);
204220
int maxRange = APConfig.PERIPHERALS_CONFIG.chatBoxMaxRange.get();
@@ -241,6 +257,10 @@ public final MethodResult sendFormattedToastToPlayer(@NotNull IArguments argumen
241257
public final MethodResult sendMessageToPlayer(@NotNull IArguments arguments) throws LuaException {
242258
return withChatOperation(ignored -> {
243259
String message = arguments.getString(0);
260+
261+
if (message.length() > APConfig.PERIPHERALS_CONFIG.chatBoxMessageSize.get())
262+
return MethodResult.of(null, "Message is too long");
263+
244264
String playerName = arguments.getString(1);
245265
int maxRange = APConfig.PERIPHERALS_CONFIG.chatBoxMaxRange.get();
246266
int range = arguments.optInt(5, -1);
@@ -270,6 +290,10 @@ public final MethodResult sendMessageToPlayer(@NotNull IArguments arguments) thr
270290
public final MethodResult sendToastToPlayer(@NotNull IArguments arguments) throws LuaException {
271291
return withChatOperation(ignored -> {
272292
String message = arguments.getString(0);
293+
294+
if (message.length() > APConfig.PERIPHERALS_CONFIG.chatBoxMessageSize.get())
295+
return MethodResult.of(null, "Message is too long");
296+
273297
String title = arguments.getString(1);
274298
String playerName = arguments.getString(2);
275299
int maxRange = APConfig.PERIPHERALS_CONFIG.chatBoxMaxRange.get();

src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/PlayerDetectorPeripheral.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ public final Map<String, Object> getPlayerPos(IArguments arguments) throws LuaEx
259259
info.put("y", Math.floor(y * unit) / unit);
260260
info.put("z", Math.floor(z * unit) / unit);
261261
if (APConfig.PERIPHERALS_CONFIG.morePlayerInformation.get()) {
262+
info.put("uuid", existingPlayer.getUUID().toString());
263+
info.put("name", existingPlayer.getName().getString());
262264
info.put("yaw", existingPlayer.yRotO);
263265
info.put("pitch", existingPlayer.xRotO);
264266
info.put("dimension", existingPlayer.level().dimension().location().toString());

src/main/java/de/srendi/advancedperipherals/common/configuration/PeripheralsConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public class PeripheralsConfig implements IAPConfig {
4343
public final ModConfigSpec.BooleanValue enableChatBox;
4444
public final ModConfigSpec.ConfigValue<String> defaultChatBoxPrefix;
4545
public final ModConfigSpec.IntValue chatBoxMaxRange;
46+
public final ModConfigSpec.IntValue chatBoxMessageSize;
4647
public final ModConfigSpec.BooleanValue chatBoxMultiDimensional;
4748
public final ModConfigSpec.BooleanValue chatBoxPreventRunCommand;
4849
public final ModConfigSpec.BooleanValue chatBoxWrapCommand;
@@ -146,6 +147,7 @@ public PeripheralsConfig() {
146147
enableChatBox = builder.comment("Enable the Chat Box or not.").define("enableChatBox", true);
147148
defaultChatBoxPrefix = builder.comment("Defines default chatbox prefix").define("defaultChatBoxPrefix", "AP");
148149
chatBoxMaxRange = builder.comment("Defines the maximal range of the chat box in blocks. -1 for infinite. If the range is not -1, players in other dimensions won't able to receive messages").defineInRange("chatBoxMaxRange", -1, -1, 30000000);
150+
chatBoxMessageSize = builder.comment("Defines the maximal number of characters in a message. Depending on the modpack and server, too large messages can't unexpectedly disconnect players").defineInRange("chatBoxMessageSize", 1024, -0, 8192);
149151
chatBoxMultiDimensional = builder.comment("If true, the chat box is able to send messages to other dimensions than its own").define("chatBoxMultiDimensional", true);
150152
chatBoxPreventRunCommand = builder.comment("If true, the chat box cannot use 'run_command' action").define("chatBoxPreventRunCommand", false);
151153
chatBoxWrapCommand = builder.comment("If true, the chat box will wrap and execute 'run_command' or 'suggest_command' action with zero permission, in order to prevent operators accidently run dangerous commands.").define("chatBoxWrapCommand", true);

src/main/java/de/srendi/advancedperipherals/common/util/inventory/ChemicalFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public class ChemicalFilter extends GenericFilter<ChemicalStack> {
2424

2525
private Holder<Chemical> chemical = MekanismAPI.EMPTY_CHEMICAL.getAsHolder();
2626
private TagKey<Chemical> tag = null;
27-
private long count = 64;
27+
private long count = 1000;
2828
private String fingerprint = "";
2929
public int fromSlot = -1;
3030
public int toSlot = -1;

0 commit comments

Comments
 (0)