Skip to content

Commit 41c6ced

Browse files
authored
Merge pull request #46 from FTBTeam/dev
Dev
2 parents 24f2e45 + 4760989 commit 41c6ced

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+718
-237
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ build
2222
eclipse
2323
run
2424
/classes
25+
26+
.DS_Store
27+
.architectury-transformer

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [2004.1.2]
8+
9+
### Changed
10+
* Ported to Minecraft 1.20.4. Support for Fabric, Forge and NeoForge.
11+
12+
## [2001.2.0]
13+
14+
### Changed
15+
* Technical addition: property defaults are now initialised lazily, via supplier
16+
* No player-visible change to this right now, but it makes it easier for mods to define config-based defaults, e.g. FTB Chunks team properties
17+
* Technically there is an API break, but only if you were trying to construct property objects yourself using the from-network constructor (and there was no good reason to do that!)
18+
* Deprecated the `CustomPartyCreationHandler` object and related API methods
19+
* Replaced with simpler `FTBTeamsAPI#setPartyCreationFromAPIOnly(boolean)` method
20+
* Intended for use in custom modpacks where players shouldn't create teams directly themselves (either via CLI or GUI)
21+
* Updated party team creation API to work without requiring the party-owning player to be online
22+
23+
### Added
24+
* Added fr_fr translation (thanks @HollishKid and @K0LALA)
25+
26+
### Fixed
27+
* Fixed the `/ftbteams party info` command always showing your own party info, regardless of team that was passed to the command
28+
729
## [2001.1.4]
830

931
### Fixed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
id "architectury-plugin" version "3.4-SNAPSHOT"
3-
id "dev.architectury.loom" version "1.2-SNAPSHOT" apply false
3+
id "dev.architectury.loom" version "1.5-SNAPSHOT" apply false
44
}
55

66
architectury {

common/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies {
99
def ENV = System.getenv()
1010

1111
architectury {
12-
common()
12+
common("forge", "fabric", "neoforge")
1313
}
1414

1515
publishing {
@@ -42,4 +42,4 @@ publishing {
4242
}
4343
}
4444
}
45-
}
45+
}

common/src/main/java/dev/ftb/mods/ftbteams/FTBTeamsAPIImpl.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
public enum FTBTeamsAPIImpl implements FTBTeamsAPI.API {
1616
INSTANCE;
1717

18-
private CustomPartyCreationHandler partyCreationOverride = null;
18+
private boolean partyCreationFromAPIOnly = false;
1919

2020
@Override
2121
public boolean isManagerLoaded() {
@@ -38,21 +38,26 @@ public ClientTeamManager getClientManager() {
3838
}
3939

4040
@Override
41-
public CustomPartyCreationHandler getCustomPartyCreationHandler() {
42-
return partyCreationOverride;
41+
public CustomPartyCreationHandler setCustomPartyCreationHandler(CustomPartyCreationHandler partyCreationOverride) {
42+
return null;
4343
}
4444

4545
@Override
46-
public TeamMessage createMessage(UUID sender, Component text) {
47-
return new TeamMessageImpl(sender, System.currentTimeMillis(), text);
46+
public CustomPartyCreationHandler getCustomPartyCreationHandler() {
47+
return null;
4848
}
4949

5050
@Override
51-
public CustomPartyCreationHandler setCustomPartyCreationHandler(CustomPartyCreationHandler partyCreationOverride) {
52-
CustomPartyCreationHandler prev = this.partyCreationOverride;
53-
this.partyCreationOverride = partyCreationOverride;
54-
return prev;
51+
public void setPartyCreationFromAPIOnly(boolean apiOnly) {
52+
partyCreationFromAPIOnly = apiOnly;
5553
}
5654

55+
public boolean isPartyCreationFromAPIOnly() {
56+
return partyCreationFromAPIOnly;
57+
}
5758

59+
@Override
60+
public TeamMessage createMessage(UUID sender, Component text) {
61+
return new TeamMessageImpl(sender, System.currentTimeMillis(), text);
62+
}
5863
}

common/src/main/java/dev/ftb/mods/ftbteams/api/CustomPartyCreationHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import dev.ftb.mods.ftblibrary.ui.input.MouseButton;
44

55
@FunctionalInterface
6+
@Deprecated
67
public interface CustomPartyCreationHandler {
78
void createParty(MouseButton button);
89
}

common/src/main/java/dev/ftb/mods/ftbteams/api/FTBTeamsAPI.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,33 @@ public interface API {
9292
*
9393
* @param handler the new handler to use
9494
* @return the previous handler
95+
* @deprecated use {@link #setPartyCreationFromAPIOnly(boolean)}
9596
*/
97+
@Deprecated
9698
@Nullable
9799
CustomPartyCreationHandler setCustomPartyCreationHandler(@Nullable CustomPartyCreationHandler handler);
98100

99101
/**
100102
* Get the custom party creation handler in effect, if any
101103
* @return the current custom handler, or null if none is in effect
104+
* @deprecated see {@link #setPartyCreationFromAPIOnly(boolean)}
102105
*/
106+
@Deprecated
103107
@Nullable
104108
CustomPartyCreationHandler getCustomPartyCreationHandler();
105109

110+
/**
111+
* By setting api-only team creation to true, this prevents players from creating teams using either the
112+
* command interface or GUI interface of FTB Teams. Parties will only be creatable by other mods via the
113+
* FTB Teams API. This is intended for use with custom modpacks which link team creation with e.g. base
114+
* creation.
115+
* <p>
116+
* By default, FTB Teams allows party creation via all methods.
117+
*
118+
* @param apiOnly true to allow party creation via API only, false to allow normal creation
119+
*/
120+
void setPartyCreationFromAPIOnly(boolean apiOnly);
121+
106122
TeamMessage createMessage(UUID sender, Component text);
107123
}
108124
}

common/src/main/java/dev/ftb/mods/ftbteams/api/Team.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package dev.ftb.mods.ftbteams.api;
22

3+
import dev.ftb.mods.ftblibrary.icon.Color4I;
34
import dev.ftb.mods.ftbteams.api.property.TeamProperties;
45
import dev.ftb.mods.ftbteams.api.property.TeamProperty;
56
import dev.ftb.mods.ftbteams.api.property.TeamPropertyCollection;
67
import net.minecraft.nbt.CompoundTag;
78
import net.minecraft.network.chat.Component;
89
import net.minecraft.server.level.ServerPlayer;
10+
import org.jetbrains.annotations.Nullable;
911

1012
import java.util.*;
1113

@@ -216,4 +218,14 @@ default boolean isClientTeam() {
216218
* @return true if the team object is still valid, false otherwise
217219
*/
218220
boolean isValid();
221+
222+
/**
223+
* Create a party team from this team, which must be an individual player's team. The player must not be in an
224+
* existing team.
225+
*
226+
* @param description the long description text (an empty string is acceptable)
227+
* @param color the color for the new team; if null, then a random color is chosen
228+
* @return the newly-created party team
229+
*/
230+
Team createParty(String description, @Nullable Color4I color);
219231
}

common/src/main/java/dev/ftb/mods/ftbteams/api/TeamManager.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package dev.ftb.mods.ftbteams.api;
22

3+
import com.mojang.brigadier.exceptions.CommandSyntaxException;
4+
import dev.ftb.mods.ftblibrary.icon.Color4I;
35
import net.minecraft.nbt.CompoundTag;
46
import net.minecraft.server.MinecraftServer;
57
import net.minecraft.server.level.ServerPlayer;
8+
import org.jetbrains.annotations.Nullable;
69

710
import java.util.Collection;
811
import java.util.Map;
@@ -111,4 +114,16 @@ public interface TeamManager {
111114
* any data in the compound returned by {@link #getExtraData()}.
112115
*/
113116
void markDirty();
117+
118+
/**
119+
* Attempt to create a party team for the given player
120+
* @param player the player to create the team for
121+
* @param name the human-readable team name (something like "{player}'s team" is suggested)
122+
* @param description a text description of the team, may be null
123+
* @param color a color definition; if null, a random color will be picked
124+
* @return the new party team
125+
* @throws CommandSyntaxException if there was any kind of failure creating the team,
126+
* most commonly that the player is already in a party
127+
*/
128+
Team createPartyTeam(ServerPlayer player, String name, @Nullable String description, @Nullable Color4I color) throws CommandSyntaxException;
114129
}

common/src/main/java/dev/ftb/mods/ftbteams/api/event/TeamCreatedEvent.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@
22

33
import dev.ftb.mods.ftbteams.api.Team;
44
import net.minecraft.server.level.ServerPlayer;
5+
import org.jetbrains.annotations.NotNull;
6+
import org.jetbrains.annotations.Nullable;
7+
8+
import java.util.UUID;
59

610
/**
711
* Fired server-side when a new team is created; could be a player, party, or server team.
812
*/
913
public class TeamCreatedEvent extends TeamEvent {
1014
private final ServerPlayer creator;
15+
private final UUID creatorId;
1116

12-
public TeamCreatedEvent(Team team, ServerPlayer creator) {
17+
public TeamCreatedEvent(Team team, @Nullable ServerPlayer creator, @NotNull UUID creatorId) {
1318
super(team);
1419
this.creator = creator;
20+
this.creatorId = creatorId;
1521
}
1622

1723
/**
@@ -22,4 +28,13 @@ public TeamCreatedEvent(Team team, ServerPlayer creator) {
2228
public ServerPlayer getCreator() {
2329
return creator;
2430
}
31+
32+
/**
33+
* Get the UUID of the player responsible for creation of the team.
34+
*
35+
* @return the creator's UUID
36+
*/
37+
public UUID getCreatorId() {
38+
return creatorId;
39+
}
2540
}

0 commit comments

Comments
 (0)