-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from jonathan-robertson/dev
Initial Pre-Release
- Loading branch information
Showing
17 changed files
with
630 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: 📦 Automated Release | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
types: [closed] | ||
|
||
jobs: | ||
release: | ||
if: ${{ github.event.pull_request.merged }} | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: 🚚 Get latest code | ||
uses: actions/checkout@v2 | ||
- name: 📦 Package data | ||
run: | | ||
# Edit this line if you want to include additional files | ||
# q stands for quiet, r stands for recursive (to include all files and sub-folders in Config) | ||
zip -qr "${{ github.event.repository.name }}.zip" *.dll Config ModInfo.xml README.md CHANGELOG.md LICENSE | ||
version=$(sed -n '/Version/{s/.*<Version value=\"\(.*\)\"[ ]*\/>.*/\1/;p}' ModInfo.xml) | ||
echo "version=$version" >> $GITHUB_ENV | ||
prerelease=$([[ $version = 0* ]] && echo "true" || echo "false") | ||
echo "prerelease=$prerelease" >> $GITHUB_ENV | ||
# echoes for troubleshooting in case you need them | ||
# echo "name: ${{ github.event.repository.name }}" | ||
# echo "title: ${{ github.event.pull_request.title }}" | ||
# echo "version: $version" | ||
# echo "prerelease: $prerelease" | ||
- name: 📢 Post Release | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
tag: ${{ env.version }} | ||
commit: main | ||
name: ${{ github.event.pull_request.title }} | ||
body: ${{ github.event.pull_request.body }} | ||
generateReleaseNotes: true | ||
artifacts: "${{ github.event.repository.name }}.zip" | ||
prerelease: ${{ env.prerelease }} | ||
# if you'd like to review the generated release before publishing it, enable draft mode | ||
# draft: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Changelog | ||
|
||
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). | ||
|
||
## [TODO] | ||
|
||
- add lcb-remote item | ||
- add lcb-remote item activation toggle lcb | ||
- add lcb-remote recipe | ||
- add lcb-remote to trader inventory' | ||
|
||
## [0.1.0] - 2023-04-02 | ||
|
||
- add console command activate | ||
- add console command check | ||
- add console command deactivate | ||
- add console command debug | ||
- add support for selecting closest overlapping lcb |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<xml> | ||
<ModInfo> | ||
<Name value="LCB Remote" /> | ||
<Description value="Add admin tools and a craftable remote control to turn on/off land claim block boundaries." /> | ||
<Author value="Jonathan Robertson (Kanaverum)" /> | ||
<Version value="0.1.0" /> | ||
<Website value=" https:// github.com/ jonathan-robertson/ lcb-remote" /> | ||
</ModInfo> | ||
</xml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# LCB Remote | ||
|
||
[![🧪 Tested On](https://img.shields.io/badge/🧪%20Tested%20On-A20.6%20b9-blue.svg)](https://7daystodie.com/) [![📦 Automated Release](https://github.com/jonathan-robertson/lcb-remote/actions/workflows/release.yml/badge.svg)](https://github.com/jonathan-robertson/lcb-remote/actions/workflows/release.yml) | ||
|
||
- [LCB Remote](#lcb-remote) | ||
- [Summary](#summary) | ||
- [PLANNED Player Features](#planned-player-features) | ||
- [Admin Commands](#admin-commands) | ||
|
||
## Summary | ||
|
||
7 Days to Die mod: Add admin tools and a craftable remote control to turn on/off land claim block boundaries. | ||
|
||
## PLANNED Player Features | ||
|
||
Adds a craftable remote control that can turn on/off the closest owned land claim block boundaries the player is within range of. | ||
|
||
## Admin Commands | ||
|
||
This mod adds commands for checking and adjusting any land claim block's activation state. | ||
|
||
> ℹ️ When adjusted, the mod will send packages that trick the client into reloading that land claim block's state for the owner (if the owner is online and within range). This means that the land claim owner will not need to log in/out to see the boundaries for this claim appear or disappear when the block's state is modified by the admin. | ||
Command | Description | ||
--- | --- | ||
`lcbr check` | Check the current activation state of the lcb you are within range of. | ||
`lcbr activate` | Activate lcb area frame for the lcb you are within range of (only the lcb owner will see it). | ||
`lcbr deactivate` | Deactivate lcb area frame for the lcb you are within range of. | ||
|
||
> ℹ️ When the `activate` or `deactivate` command is run, the land claim block's owner will see an immediate change to the boundaries without having to leave/return or logout/login. |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace LcbRemote | ||
{ | ||
internal class ConsoleCmdLcbRemote : ConsoleCmdAbstract | ||
{ | ||
private static readonly string[] Commands = new string[] { | ||
"lcbremote", | ||
"lcbr" | ||
}; | ||
private readonly string help; | ||
|
||
public ConsoleCmdLcbRemote() | ||
{ | ||
var dict = new Dictionary<string, string>() { | ||
{ "debug", "toggle debug logging mode" }, | ||
{ "check", "check the current activation state of the lcb you are within range of" }, | ||
{ "activate", "activate lcb area frame for the lcb you are within range of (only the lcb owner will see it)" }, | ||
{ "deactivate", "deactivate lcb area frame for the lcb you are within range of" }, | ||
}; | ||
|
||
var i = 1; var j = 1; | ||
help = $"Usage:\n {string.Join("\n ", dict.Keys.Select(command => $"{i++}. {GetCommands()[0]} {command}").ToList())}\nDescription Overview\n{string.Join("\n", dict.Values.Select(description => $"{j++}. {description}").ToList())}"; | ||
} | ||
|
||
public override string[] GetCommands() | ||
{ | ||
return Commands; | ||
} | ||
|
||
public override string GetDescription() | ||
{ | ||
return "Configure or adjust settings for the LCB Remote mod."; | ||
} | ||
|
||
public override string GetHelp() | ||
{ | ||
return help; | ||
} | ||
|
||
public override void Execute(List<string> _params, CommandSenderInfo _senderInfo) | ||
{ | ||
try | ||
{ | ||
if (_params.Count == 0) | ||
{ | ||
SdtdConsole.Instance.Output($"At least 1 parameter is required; use 'help {Commands[0]}' to learn more."); | ||
return; | ||
} | ||
|
||
switch (_params[0]) | ||
{ | ||
case "debug": | ||
HandleDebug(); | ||
return; | ||
case "check": | ||
HandleCheck(_senderInfo); | ||
return; | ||
case "activate": | ||
HandleActivate(_senderInfo); | ||
return; | ||
case "deactivate": | ||
HandleDeactivate(_senderInfo); | ||
return; | ||
} | ||
|
||
SdtdConsole.Instance.Output($"Invald parameter provided; use 'help {Commands[0]}' to learn more."); | ||
} | ||
catch (Exception e) | ||
{ | ||
SdtdConsole.Instance.Output($"Exception encountered: \"{e.Message}\"\n{e.StackTrace}"); | ||
} | ||
} | ||
|
||
private void HandleDebug() | ||
{ | ||
ModApi.DebugMode = !ModApi.DebugMode; | ||
SdtdConsole.Instance.Output($"Debug Mode has successfully been {(ModApi.DebugMode ? "enabled" : "disabled")}."); | ||
} | ||
|
||
private void HandleCheck(CommandSenderInfo _senderInfo) | ||
{ | ||
if (!TryGetClosestLandClaimData(_senderInfo, out var landClaimOwner, out var landClaimBlockPos)) | ||
{ | ||
return; | ||
} | ||
if (!LandClaimManager.IsLandClaimActive(landClaimBlockPos, out var landClaimActive)) | ||
{ | ||
SdtdConsole.Instance.Output($"No land claim could be found at the expected position of {landClaimBlockPos}."); | ||
return; | ||
} | ||
SdtdConsole.Instance.Output($"The Land Claim Block at position {landClaimBlockPos} is owned by {landClaimOwner.PlayerName} and is currently {(landClaimActive ? "ACTIVATED" : "DEACTIVATED")}."); | ||
} | ||
|
||
private void HandleActivate(CommandSenderInfo _senderInfo) | ||
{ | ||
if (!TryGetClosestLandClaimData(_senderInfo, out var landClaimOwner, out var landClaimBlockPos)) | ||
{ | ||
return; | ||
} | ||
if (!LandClaimManager.ActivateLandClaim(landClaimBlockPos, out var previouslyActive)) | ||
{ | ||
SdtdConsole.Instance.Output($"No land claim could be found at the expected position of {landClaimBlockPos}."); | ||
return; | ||
} | ||
if (previouslyActive) | ||
{ | ||
SdtdConsole.Instance.Output($"The Land Claim Block at position {landClaimBlockPos} owned by {landClaimOwner.PlayerName} and was already active (no action taken)."); | ||
return; | ||
} | ||
SdtdConsole.Instance.Output($"The Land Claim Block at position {landClaimBlockPos} owned by {landClaimOwner.PlayerName} has been activated just now. Please remember that only the owner ({landClaimOwner.PlayerName}) will see the green land claim frame."); | ||
} | ||
|
||
private void HandleDeactivate(CommandSenderInfo _senderInfo) | ||
{ | ||
if (!TryGetClosestLandClaimData(_senderInfo, out var landClaimOwner, out var landClaimBlockPos)) | ||
{ | ||
return; | ||
} | ||
if (!LandClaimManager.DeactivateLandClaim(landClaimBlockPos, out var previouslyDeactivated)) | ||
{ | ||
SdtdConsole.Instance.Output($"No land claim could be found at the expected position of {landClaimBlockPos}."); | ||
return; | ||
} | ||
if (previouslyDeactivated) | ||
{ | ||
SdtdConsole.Instance.Output($"The Land Claim Block at position {landClaimBlockPos} owned by {landClaimOwner.PlayerName} and was already deactivated (no action taken)."); | ||
return; | ||
} | ||
SdtdConsole.Instance.Output($"The Land Claim Block at position {landClaimBlockPos} owned by {landClaimOwner.PlayerName} has been deactivated just now."); | ||
} | ||
|
||
private static bool TryGetClosestLandClaimData(CommandSenderInfo _senderInfo, out PersistentPlayerData landClaimOwner, out Vector3i landClaimBlockPos) | ||
{ | ||
landClaimOwner = null; | ||
landClaimBlockPos = Vector3i.zero; | ||
var entityId = SafelyGetEntityIdFor(_senderInfo.RemoteClientInfo); | ||
if (entityId == -1) | ||
{ | ||
SdtdConsole.Instance.Output("Cannot execute from telnet/rcon, please execute as a client."); | ||
return false; | ||
} | ||
if (!GameManager.Instance.World.Players.dict.TryGetValue(entityId, out var player)) | ||
{ | ||
SdtdConsole.Instance.Output($"Could find online player with entityId of {entityId}."); | ||
return false; | ||
} | ||
var playerBlockPos = player.GetBlockPosition(); | ||
if (!LandClaimManager.TryGetClosestLandClaimPosContaining(playerBlockPos, out landClaimOwner, out landClaimBlockPos)) | ||
{ | ||
SdtdConsole.Instance.Output($"No land claim contains block position {playerBlockPos}."); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
private static int SafelyGetEntityIdFor(ClientInfo clientInfo) | ||
{ | ||
return clientInfo != null | ||
? clientInfo.entityId | ||
: GameManager.Instance.World.GetPrimaryPlayerId(); | ||
} | ||
} | ||
} |
Oops, something went wrong.