Skip to content

Commit c8b1c77

Browse files
committed
Merge branch 'mc/26.1.1' into mc/26w14a
# Conflicts: # fabric/build.gradle.kts # gradle.properties # mojmap/src/main/java/dev/qixils/crowdcontrol/plugin/fabric/commands/TakeItemCommand.java
2 parents c4679bf + 89ea284 commit c8b1c77

39 files changed

Lines changed: 2065 additions & 114 deletions

CHANGELOG.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,21 @@
22

33
A list of all changes made to the software in reverse chronological order.
44

5+
## 4.5.2
6+
7+
- Paper: Added support for 26.1.1 and its new _Age Nearby Mobs_ effects
8+
- Paper: Fixed _Take Item_ not respecting limits
9+
- _Replace Blocks with Gravel_ no longer replaces liquids
10+
- Fixed minor issues with the Soft Lock Observer and tweaked its default settings
11+
- Custom Effects now respect item and entity limit settings
12+
- Due to limitations in the Paper mod this only works on custom effects with 1 action for now
13+
- On Fabric/NeoForge, stacked actions may target different random players
14+
- Fabric/NeoForge 26.1+: More config options are available in the GUI
15+
516
## 4.5.1
617

7-
- Fabric: Added support for Herdcraft/26w14a/Minecraft's April Fools
818
- Fabric/NeoForge 26.1+: Config GUI is now available when YACL is installed
9-
- Additional options will be available at a later date
19+
- Fabric: Added support for Herdcraft/26w14a/Minecraft's April Fools
1020

1121
## 4.5.0
1222

build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ plugins {
77
id("com.gradleup.shadow") version "8.3.10" apply true
88
id("net.fabricmc.fabric-loom") version "1.15-SNAPSHOT" apply false
99
id("net.neoforged.moddev") version "2.0.141" apply false
10-
id("xyz.jpenilla.run-paper") version "2.3.1" apply false // Adds runServer and runMojangMappedServer tasks for testing
11-
id("de.eldoria.plugin-yml.bukkit") version "0.8.0" apply false // Generates plugin.yml
12-
id("io.papermc.paperweight.userdev") version "2.0.0-beta.19" apply false
10+
id("xyz.jpenilla.run-paper") version "3.0.2" apply false // Adds runServer and runMojangMappedServer tasks for testing
11+
id("de.eldoria.plugin-yml.bukkit") version "0.9.0" apply false // Generates plugin.yml
12+
id("io.papermc.paperweight.userdev") version "2.0.0-beta.21" apply false
1313
id("me.modmuss50.mod-publish-plugin") version "1.1.0" apply false
1414
}
1515

common/src/main/java/dev/qixils/crowdcontrol/common/LimitConfig.java

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
* The configuration for effect limits.
1414
*/
1515
public final class LimitConfig {
16-
private final boolean hostsBypass;
17-
private final @NotNull Map<String, Integer> itemLimits;
18-
private final int itemDefaultLimit;
19-
private final @NotNull Map<String, Integer> entityLimits;
20-
private final int entityDefaultLimit;
16+
private boolean hostsBypass;
17+
private @NotNull Map<String, Integer> itemLimits;
18+
private int itemDefaultLimit;
19+
private @NotNull Map<String, Integer> entityLimits;
20+
private int entityDefaultLimit;
2121

2222
/**
2323
* Constructs a new limit configuration.
@@ -30,10 +30,8 @@ public LimitConfig(boolean hostsBypass,
3030
@Nullable Map<String, Integer> itemLimits,
3131
@Nullable Map<String, Integer> entityLimits) {
3232
this.hostsBypass = hostsBypass;
33-
this.itemLimits = new HashMap<>(validateNotNullElseGet(itemLimits, Collections::emptyMap));
34-
itemDefaultLimit = this.itemLimits.getOrDefault("default", 0);
35-
this.entityLimits = new HashMap<>(validateNotNullElseGet(entityLimits, Collections::emptyMap));
36-
entityDefaultLimit = this.entityLimits.getOrDefault("default", 0);
33+
itemLimits(validateNotNullElseGet(itemLimits, Collections::emptyMap));
34+
entityLimits(validateNotNullElseGet(entityLimits, Collections::emptyMap));
3735
}
3836

3937
/**
@@ -53,6 +51,19 @@ public boolean hostsBypass() {
5351
return hostsBypass;
5452
}
5553

54+
public void hostsBypass(boolean hostsBypass) {
55+
this.hostsBypass = hostsBypass;
56+
}
57+
58+
public int defaultItemLimit() {
59+
return itemDefaultLimit;
60+
}
61+
62+
public void defaultItemLimit(int defaultItemLimit) {
63+
itemLimits.put("default", defaultItemLimit);
64+
this.itemDefaultLimit = defaultItemLimit;
65+
}
66+
5667
/**
5768
* Gets the limit on the given item effect.
5869
*
@@ -72,6 +83,20 @@ public int getItemLimit(@NotNull String item) {
7283
return Collections.unmodifiableMap(itemLimits);
7384
}
7485

86+
public void itemLimits(Map<String, Integer> itemLimits) {
87+
this.itemLimits = new HashMap<>(itemLimits);
88+
itemDefaultLimit = this.itemLimits.getOrDefault("default", 0);
89+
}
90+
91+
public int defaultEntityLimit() {
92+
return entityDefaultLimit;
93+
}
94+
95+
public void defaultEntityLimit(int defaultEntityLimit) {
96+
entityLimits.put("default", defaultEntityLimit);
97+
this.entityDefaultLimit = defaultEntityLimit;
98+
}
99+
75100
/**
76101
* Gets the limit on the given entity effect.
77102
*
@@ -91,6 +116,11 @@ public int getEntityLimit(@NotNull String entity) {
91116
return Collections.unmodifiableMap(entityLimits);
92117
}
93118

119+
public void entityLimits(Map<String, Integer> entityLimits) {
120+
this.entityLimits = new HashMap<>(entityLimits);
121+
entityDefaultLimit = this.entityLimits.getOrDefault("default", 0);
122+
}
123+
94124
@Override
95125
public String toString() {
96126
return "LimitConfig{" +

common/src/main/java/dev/qixils/crowdcontrol/common/Plugin.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,10 @@ public boolean isGlobal() {
335335
return global;
336336
}
337337

338+
public void setIsGlobal(boolean isGlobal) {
339+
global = isGlobal;
340+
}
341+
338342
/**
339343
* Returns a collection of strings representing the names of hosts.
340344
* <p>
@@ -350,6 +354,14 @@ public Collection<String> getHosts() {
350354
return hosts;
351355
}
352356

357+
public Collection<String> getRawHosts() {
358+
return new ArrayList<>(hosts);
359+
}
360+
361+
public void setRawHosts(Collection<String> hosts) {
362+
this.hosts = new HashSet<>(hosts);
363+
}
364+
353365
/**
354366
* Whether to announce the execution of effects in chat.
355367
*

common/src/main/java/dev/qixils/crowdcontrol/common/SoftLockConfig.java

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,16 @@
99
*/
1010
public class SoftLockConfig {
1111

12-
public static final int DEF_PERIOD = 120;
13-
public static final int DEF_DEATHS = 6;
12+
public static final int DEF_PERIOD = 60;
13+
public static final int DEF_DEATHS = 5;
1414
public static final int DEF_SEARCH_HORIZ = 20;
1515
public static final int DEF_SEARCH_VERT = 8;
1616

17-
private final Duration period;
18-
private final int deaths;
19-
private final int searchHoriz;
20-
private final int searchVert;
17+
private int period;
18+
private transient Duration periodDuration;
19+
private int deaths;
20+
private int searchHoriz;
21+
private int searchVert;
2122

2223
/**
2324
* Creates a new soft-lock config.
@@ -29,26 +30,24 @@ public SoftLockConfig() {
2930
/**
3031
* Creates a new soft-lock config.
3132
*
32-
* @param period the monitoring period
33+
* @param period the monitoring period, in seconds
3334
* @param deaths the death count threshold
34-
* @param searchHoriz the horizontal search radius
35-
* @param searchVert the vertical search radius
3635
*/
37-
public SoftLockConfig(Duration period, int deaths, int searchHoriz, int searchVert) {
36+
public SoftLockConfig(int period, int deaths, int searchHoriz, int searchVert) {
3837
this.period = period;
38+
this.periodDuration = Duration.ofSeconds(period);
3939
this.deaths = deaths;
4040
this.searchHoriz = searchHoriz;
4141
this.searchVert = searchVert;
4242
}
4343

4444
/**
45-
* Creates a new soft-lock config.
45+
* How long the monitoring period is in seconds.
4646
*
47-
* @param period the monitoring period, in seconds
48-
* @param deaths the death count threshold
47+
* @return monitoring period in seconds
4948
*/
50-
public SoftLockConfig(int period, int deaths, int searchHoriz, int searchVert) {
51-
this(Duration.ofSeconds(period), deaths, searchHoriz, searchVert);
49+
public int getPeriod() {
50+
return period;
5251
}
5352

5453
/**
@@ -57,8 +56,16 @@ public SoftLockConfig(int period, int deaths, int searchHoriz, int searchVert) {
5756
* @return monitoring period
5857
*/
5958
@NotNull
60-
public Duration getPeriod() {
61-
return period;
59+
public Duration getPeriodDuration() {
60+
return periodDuration;
61+
}
62+
63+
public void setPeriod(Duration period) {
64+
this.period = (int) period.toSeconds();
65+
}
66+
67+
public void setPeriod(int period) {
68+
this.period = period;
6269
}
6370

6471
/**
@@ -70,6 +77,10 @@ public int getDeaths() {
7077
return deaths;
7178
}
7279

80+
public void setDeaths(int deaths) {
81+
this.deaths = deaths;
82+
}
83+
7384
/**
7485
* The horizontal entity search radius.
7586
*
@@ -79,6 +90,10 @@ public int getSearchH() {
7990
return searchHoriz;
8091
}
8192

93+
public void setSearchH(int searchHoriz) {
94+
this.searchHoriz = searchHoriz;
95+
}
96+
8297
/**
8398
* The vertical entity search radius.
8499
*
@@ -87,4 +102,8 @@ public int getSearchH() {
87102
public int getSearchV() {
88103
return searchVert;
89104
}
105+
106+
public void setSearchV(int searchVert) {
107+
this.searchVert = searchVert;
108+
}
90109
}

common/src/main/java/dev/qixils/crowdcontrol/common/SoftLockObserver.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ protected int getSearchV() {
5252
* @param player The player who died.
5353
*/
5454
protected void onDeath(P player) {
55-
UUID uuid = plugin.playerMapper().tryGetUniqueId(player)
56-
.orElseThrow(() -> new IllegalArgumentException("Expected player to have a UUID"));
55+
Optional<UUID> uuidOpt = plugin.playerMapper().tryGetUniqueId(player);
56+
if (uuidOpt.isEmpty()) return;
57+
UUID uuid = uuidOpt.get();
58+
5759
DeathData data = deathData.computeIfAbsent(uuid, $ -> new DeathData(plugin.getSoftLockConfig()));
5860
if (data.isSoftLocked()) {
5961
onSoftLock(player);
@@ -67,13 +69,12 @@ private static final class DeathData {
6769

6870
public DeathData(@NotNull SoftLockConfig config) {
6971
this.config = config;
70-
addDeath();
7172
}
7273

7374
private void addDeath() {
7475
LocalDateTime now = LocalDateTime.now();
75-
deaths.removeIf(d -> d.isBefore(now.minus(config.getPeriod())));
7676
deaths.add(now);
77+
deaths.removeIf(d -> d.isBefore(now.minus(config.getPeriodDuration())));
7778
}
7879

7980
public boolean isSoftLocked() {

common/src/main/java/dev/qixils/crowdcontrol/common/command/Command.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,10 @@ default boolean isMainThread() {
454454
}
455455

456456
default CCEffectResponse executeLimit(@NotNull PublicEffectPayload request, @NotNull List<P> players, int playerLimit, @NotNull Function<P, CCEffectResponse> supplier) {
457-
if (isMainThread()) {
458-
getPlugin().getSLF4JLogger().error("Effect {} is implemented incorrectly, invoking executeLimit from main thread, please report this!", getEffectName());
459-
return new CCInstantEffectResponse(request.getRequestId(), ResponseStatus.FAIL_PERMANENT, "Effect is implemented incorrectly");
460-
}
457+
// if (isMainThread()) {
458+
// getPlugin().getSLF4JLogger().error("Effect {} is implemented incorrectly, invoking executeLimit from main thread, please report this!", getEffectName());
459+
// return new CCInstantEffectResponse(request.getRequestId(), ResponseStatus.FAIL_PERMANENT, "Effect is implemented incorrectly");
460+
// }
461461
boolean hostsBypass = getPlugin().getLimitConfig().hostsBypass();
462462
int victims = 0;
463463
CCEffectResponse successResp = null;

common/src/main/resources/assets/crowdcontrol/default.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ custom-effects: {
107107
soft-lock-observer: {
108108

109109
# How long the monitoring period is, in seconds.
110-
period: 120
110+
period: 60
111111

112112
# How many deaths must be counted within the monitoring period to trigger the fail-safes.
113113
deaths: 5
Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,38 @@
11
{
2-
"config.crowdcontrol.title": "Crowd Control",
3-
"config.crowdcontrol.category.general": "General",
4-
"config.crowdcontrol.announce.name": "Announce Effects",
5-
"config.crowdcontrol.announce.description": "Whether to post an alert in chat when an effect has been activated.",
6-
"config.crowdcontrol.hide_names.name": "Name Visibilty",
7-
"config.crowdcontrol.hide_names.description": "Determines where to show the names of viewers who have purchased effects.",
8-
"config.crowdcontrol.hide_names.option.none": "Show",
9-
"config.crowdcontrol.hide_names.option.chat": "Hide in chat",
10-
"config.crowdcontrol.hide_names.option.all": "Hide everywhere",
11-
"config.crowdcontrol.advanced_settings": "Advanced settings can be found in the mod's config file.",
12-
"config.crowdcontrol.missing": "Please install Yet Another Config Lib to visually configure the config, or manually edit the crowdcontrol.conf file.",
13-
"config.crowdcontrol.missing_back": "Back"
2+
"config.crowdcontrol.title": "Crowd Control",
3+
"config.crowdcontrol.category.general": "General",
4+
"config.crowdcontrol.announce.name": "Announce Effects",
5+
"config.crowdcontrol.announce.description": "Whether to post an alert in chat when an effect has been activated.",
6+
"config.crowdcontrol.hide_names.name": "Name Visibilty",
7+
"config.crowdcontrol.hide_names.description": "Determines where to show the names of viewers who have purchased effects.",
8+
"config.crowdcontrol.hide_names.option.none": "Show",
9+
"config.crowdcontrol.hide_names.option.chat": "Hide in chat",
10+
"config.crowdcontrol.hide_names.option.all": "Hide everywhere",
11+
"config.crowdcontrol.global.name": "Share Effects",
12+
"config.crowdcontrol.global.description": "Enables global mode which applies incoming effects to every player on the world.",
13+
"config.crowdcontrol.hosts.name": "Hosts",
14+
"config.crowdcontrol.hosts.description": "Specify other players that are allowed to use server-wide effects like setting the server difficulty. Can be Minecraft usernames, UUIDs, Crowd Control usernames, or Crowd Control IDs. Irrelevant with Share Effects enabled.",
15+
"config.crowdcontrol.soft_lock.name": "Soft-Lock Detector",
16+
"config.crowdcontrol.soft_lock.description": "Detects and prevents players getting stuck in a death loop by removing nearby sources of damage.",
17+
"config.crowdcontrol.soft_lock.period.name": "Monitoring Period (seconds)",
18+
"config.crowdcontrol.soft_lock.period.description": "How long the monitoring period is, in seconds.",
19+
"config.crowdcontrol.soft_lock.deaths.name": "Required Deaths",
20+
"config.crowdcontrol.soft_lock.deaths.description": "How many deaths must be observed during the monitoring period to trigger.",
21+
"config.crowdcontrol.soft_lock.horiz_radius.name": "Horizontal Search Radius",
22+
"config.crowdcontrol.soft_lock.vert_radius.name": "Vertical Search Radius",
23+
"config.crowdcontrol.soft_lock.radius.description": "Radius to search for damage sources.",
24+
"config.crowdcontrol.category.limits": "Limits",
25+
"config.crowdcontrol.hosts_bypass.name": "Hosts Bypass Limits",
26+
"config.crowdcontrol.hosts_bypass.description": "Whether users listed in the Hosts config are excluded from any limits defined below.",
27+
"config.crowdcontrol.default_item_limit.name": "Default Item Limit",
28+
"config.crowdcontrol.default_item_limit.description": "Default limit for how many players can receive one Give Item effect. 0 is unlimited. Applicable only to sessions with multiple linked players.",
29+
"config.crowdcontrol.item_limit.name": "Item Limits",
30+
"config.crowdcontrol.item_limit.description": "Individual limits for how many players can receive one Give Item effect. 0 is unlimited. Applicable only to sessions with multiple linked players.",
31+
"config.crowdcontrol.default_entity_limit.name": "Default Entity Limit",
32+
"config.crowdcontrol.default_entity_limit.description": "Default limit for how many players can receive one Summon/Remove Entity effect. 0 is unlimited. Applicable only to sessions with multiple linked players.",
33+
"config.crowdcontrol.entity_limit.name": "Entity Limits",
34+
"config.crowdcontrol.entity_limit.description": "Individual limits for how many players can receive one Summon/Remove Entity effect. 0 is unlimited. Applicable only to sessions with multiple linked players.",
35+
"config.crowdcontrol.advanced_settings": "Custom Effects can be defined in the mod's config file.",
36+
"config.crowdcontrol.missing": "Please install Yet Another Config Lib to visually configure the config, or manually edit the crowdcontrol.conf file.",
37+
"config.crowdcontrol.missing_back": "Back"
1438
}

common/src/main/resources/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ custom-effects:
8787
soft-lock-observer:
8888

8989
# How long the monitoring period is, in seconds.
90-
period: 120
90+
period: 60
9191

9292
# How many deaths must be counted within the monitoring period to trigger the fail-safes.
9393
deaths: 5

0 commit comments

Comments
 (0)