Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #318

Merged
merged 6 commits into from
Sep 9, 2024
Merged

Dev #318

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2101.1.1]

### Added
* Added `/ftbchunks admin open_claim_gui_as` command
* Allows server admins to open the chunk claim gui as any player
* Offline players are also supported, but names of offline players aren't suggested in command tab-completion
* Added team property defaults in server config (see "Team Property Defaults" section)
* Properties for newly-created teams are now taken from these defaults

### Changed
* Reworked the chunk claim GUI for a more polished visual appearance
* Added an "Unclaim All" button (trash can button, top-left) to reset all claims

## [2101.1.0]

### Changed
Expand Down
13 changes: 13 additions & 0 deletions common/src/main/java/dev/ftb/mods/ftbchunks/FTBChunksCommands.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.ftb.mods.ftbchunks;

import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.BoolArgumentType;
import com.mojang.brigadier.arguments.IntegerArgumentType;
Expand All @@ -18,6 +19,7 @@
import dev.ftb.mods.ftbchunks.data.ClaimedChunkManagerImpl;
import dev.ftb.mods.ftbchunks.net.AddWaypointPacket;
import dev.ftb.mods.ftbchunks.net.LoadedChunkViewPacket;
import dev.ftb.mods.ftbchunks.net.OpenClaimGUIPacket;
import dev.ftb.mods.ftbchunks.net.RequestBlockColorPacket;
import dev.ftb.mods.ftbchunks.net.SendGeneralDataPacket;
import dev.ftb.mods.ftblibrary.math.ChunkDimPos;
Expand Down Expand Up @@ -179,6 +181,11 @@ public static void registerCommands(CommandDispatcher<CommandSourceStack> dispat
.executes(context -> viewLoadedChunks(context.getSource(), DimensionArgument.getDimension(context, "dimension")))
)
)
.then(Commands.literal("open_claim_gui_as")
.then(Commands.argument("team", TeamArgument.create())
.executes(FTBChunksCommands::openClaimGuiAs)
)
)
)
.then(Commands.literal("block_color")
// .requires(source -> source.getServer().isSingleplayer())
Expand Down Expand Up @@ -239,6 +246,12 @@ private static int bypassProtection(CommandSourceStack source) throws CommandSyn
return 1;
}

private static int openClaimGuiAs(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
Team team = TeamArgument.get(context, "team");
NetworkManager.sendToPlayer(context.getSource().getPlayerOrException(), new OpenClaimGUIPacket(team.getTeamId()));
return Command.SINGLE_SUCCESS;
}

private interface ChunkCallback {
void accept(ChunkTeamDataImpl data, ChunkDimPos pos) throws CommandSyntaxException;
}
Expand Down
108 changes: 83 additions & 25 deletions common/src/main/java/dev/ftb/mods/ftbchunks/FTBChunksWorldConfig.java

Large diffs are not rendered by default.

48 changes: 45 additions & 3 deletions common/src/main/java/dev/ftb/mods/ftbchunks/api/ChunkTeamData.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,36 @@ public interface ChunkTeamData {
* @param source the command source (player or console) unclaiming the chunk
* @param pos the combined dimension and chunk pos
* @param checkOnly true if just simulating the unclaim
* @param adminOverride if true, admins can unclaim regardless chunk ownership
*
* @return the result of the attempt
*/
ClaimResult unclaim(CommandSourceStack source, ChunkDimPos pos, boolean checkOnly);
ClaimResult unclaim(CommandSourceStack source, ChunkDimPos pos, boolean checkOnly, boolean adminOverride);

/**
* Try to release any claim on the given chunk for this team.
*
* @param source the command source (player or console) unclaiming the chunk
* @param pos the combined dimension and chunk pos
* @param checkOnly true if just simulating the unclaim
*
* @return the result of the attempt
*/
default ClaimResult unclaim(CommandSourceStack source, ChunkDimPos pos, boolean checkOnly) {
return unclaim(source, pos, checkOnly, true);
}

/**
* Try to force-load the given chunk for this team.
*
* @param source the command source (player or console) force-loading the chunk
* @param pos the combined dimension and chunk pos
* @param checkOnly true if just simulating the force-load
* @param adminOverride if true, admins can force-load regardless chunk ownership
*
* @return the result of the attempt
*/
ClaimResult forceLoad(CommandSourceStack source, ChunkDimPos pos, boolean checkOnly, boolean adminOverride);

/**
* Try to force-load the given chunk for this team.
Expand All @@ -83,7 +109,21 @@ public interface ChunkTeamData {
*
* @return the result of the attempt
*/
ClaimResult forceLoad(CommandSourceStack source, ChunkDimPos pos, boolean checkOnly);
default ClaimResult forceLoad(CommandSourceStack source, ChunkDimPos pos, boolean checkOnly) {
return forceLoad(source, pos, checkOnly, true);
}

/**
* Try to cancel any force-load this team has for the given chunk.
*
* @param source the command source (player or console) un-force-loading the chunk
* @param pos the combined dimension and chunk pos
* @param checkOnly true if just simulating the un-force-load
* @param adminOverride if true, admins can un-force regardless chunk ownership
*
* @return the un-force-load result
*/
ClaimResult unForceLoad(CommandSourceStack source, ChunkDimPos pos, boolean checkOnly, boolean adminOverride);

/**
* Try to cancel any force-load this team has for the given chunk.
Expand All @@ -94,7 +134,9 @@ public interface ChunkTeamData {
*
* @return the un-force-load result
*/
ClaimResult unForceLoad(CommandSourceStack source, ChunkDimPos pos, boolean checkOnly);
default ClaimResult unForceLoad(CommandSourceStack source, ChunkDimPos pos, boolean checkOnly) {
return unForceLoad(source, pos, checkOnly, true);
}

/**
* Convenience method to check if the given player ID is a member of this team
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.ftb.mods.ftbchunks.api;

import dev.ftb.mods.ftbchunks.FTBChunksWorldConfig;
import dev.ftb.mods.ftbteams.api.property.BooleanProperty;
import dev.ftb.mods.ftbteams.api.property.PrivacyMode;
import dev.ftb.mods.ftbteams.api.property.PrivacyProperty;
Expand All @@ -12,34 +13,34 @@
*/
public class FTBChunksProperties {
public static final BooleanProperty ALLOW_ALL_FAKE_PLAYERS
= new BooleanProperty(FTBChunksAPI.rl("allow_fake_players"), false);
= new BooleanProperty(FTBChunksAPI.rl("allow_fake_players"), FTBChunksWorldConfig.DEF_ALLOW_FAKE_PLAYERS::get);
public static final StringListProperty ALLOW_NAMED_FAKE_PLAYERS
= new StringListProperty(FTBChunksAPI.rl("allow_named_fake_players"), new ArrayList<>());
= new StringListProperty(FTBChunksAPI.rl("allow_named_fake_players"), () -> new ArrayList<>(FTBChunksWorldConfig.DEF_ALLOW_NAMED_FAKE_PLAYERS.get()));
public static final BooleanProperty ALLOW_FAKE_PLAYERS_BY_ID
= new BooleanProperty(FTBChunksAPI.rl("allow_fake_players_by_id"), true);
= new BooleanProperty(FTBChunksAPI.rl("allow_fake_players_by_id"), FTBChunksWorldConfig.DEF_ALLOW_FAKE_PLAYER_IDS::get);
public static final PrivacyProperty ENTITY_INTERACT_MODE
= new PrivacyProperty(FTBChunksAPI.rl("entity_interact_mode"), PrivacyMode.ALLIES);
= new PrivacyProperty(FTBChunksAPI.rl("entity_interact_mode"), FTBChunksWorldConfig.DEF_ENTITY_INTERACT::get);
public static final PrivacyProperty NONLIVING_ENTITY_ATTACK_MODE
= new PrivacyProperty(FTBChunksAPI.rl("nonliving_entity_attack_mode"), PrivacyMode.ALLIES);
= new PrivacyProperty(FTBChunksAPI.rl("nonliving_entity_attack_mode"), FTBChunksWorldConfig.DEF_NONLIVING_ENTITY_ATTACK::get);
public static final BooleanProperty ALLOW_EXPLOSIONS
= new BooleanProperty(FTBChunksAPI.rl("allow_explosions"), false);
= new BooleanProperty(FTBChunksAPI.rl("allow_explosions"), FTBChunksWorldConfig.DEF_ALLOW_EXPLOSIONS::get);
public static final BooleanProperty ALLOW_MOB_GRIEFING
= new BooleanProperty(FTBChunksAPI.rl("allow_mob_griefing"), false);
= new BooleanProperty(FTBChunksAPI.rl("allow_mob_griefing"), FTBChunksWorldConfig.DEF_MOB_GRIEFING::get);
public static final PrivacyProperty CLAIM_VISIBILITY
= new PrivacyProperty(FTBChunksAPI.rl("claim_visibility"), PrivacyMode.PUBLIC);
= new PrivacyProperty(FTBChunksAPI.rl("claim_visibility"), FTBChunksWorldConfig.DEF_CLAIM_VISIBILITY::get);
public static final PrivacyProperty LOCATION_MODE
= new PrivacyProperty(FTBChunksAPI.rl("location_mode"), PrivacyMode.ALLIES);
= new PrivacyProperty(FTBChunksAPI.rl("location_mode"), FTBChunksWorldConfig.DEF_PLAYER_VISIBILITY::get);
public static final BooleanProperty ALLOW_PVP
= new BooleanProperty(FTBChunksAPI.rl("allow_pvp"), true);
= new BooleanProperty(FTBChunksAPI.rl("allow_pvp"), FTBChunksWorldConfig.DEF_PVP::get);

// FTB Chunks on Forge adds two separate block edit & interact properties
public static final PrivacyProperty BLOCK_EDIT_MODE
= new PrivacyProperty(FTBChunksAPI.rl("block_edit_mode"), PrivacyMode.ALLIES);
= new PrivacyProperty(FTBChunksAPI.rl("block_edit_mode"), FTBChunksWorldConfig.DEF_BLOCK_EDIT::get);
public static final PrivacyProperty BLOCK_INTERACT_MODE
= new PrivacyProperty(FTBChunksAPI.rl("block_interact_mode"), PrivacyMode.ALLIES);
= new PrivacyProperty(FTBChunksAPI.rl("block_interact_mode"), FTBChunksWorldConfig.DEF_BLOCK_INTERACT::get);

// FTB Chunks on Fabric adds a combined block edit & interact property
public static final PrivacyProperty BLOCK_EDIT_AND_INTERACT_MODE
= new PrivacyProperty(FTBChunksAPI.rl("block_edit_and_interact_mode"), PrivacyMode.ALLIES);
= new PrivacyProperty(FTBChunksAPI.rl("block_edit_and_interact_mode"), FTBChunksWorldConfig.DEF_BLOCK_EDIT_INTERACT::get);

}
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,11 @@ public EventResult keyPressed(Minecraft client, int keyCode, int scanCode, int a
FTBChunksClientConfig.saveConfig();
return EventResult.interruptTrue();
} else if (doesKeybindMatch(openClaimManagerKey, keyCode, scanCode, modifiers)) {
ChunkScreen.openChunkScreen();
try {
ChunkScreen.openChunkScreen();
}catch (Exception e){
e.printStackTrace();
}
return EventResult.interruptTrue();
} else if (doesKeybindMatch(zoomInKey, keyCode, scanCode, modifiers)) {
return changeZoom(true);
Expand Down Expand Up @@ -1167,6 +1171,10 @@ public List<Component> getChunkSummary() {
return list;
}

public GeneralChunkData getGeneralChunkData() {
return generalChunkData;
}

public int getMinimapTextureId() {
return minimapTextureId;
}
Expand Down
Loading
Loading