Changeset 455 for binary-improvements/AllocsCommands
- Timestamp:
- Jul 31, 2023, 4:06:13 PM (17 months ago)
- Location:
- binary-improvements/AllocsCommands
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/AllocsCommands/AllocsCommands.csproj
r450 r455 60 60 </ItemGroup> 61 61 <ItemGroup> 62 <Compile Include="API.cs" />63 62 <Compile Include="AssemblyInfo.cs" /> 64 63 <Compile Include="Commands\ListKnownPlayers.cs" /> -
binary-improvements/AllocsCommands/Commands/ListKnownPlayers.cs
r446 r455 1 1 using System.Collections.Generic; 2 2 using AllocsFixes.PersistentData; 3 using JetBrains.Annotations; 3 4 4 5 namespace AllocsFixes.CustomCommands { 6 [UsedImplicitly] 5 7 public class ListKnownPlayers : ConsoleCmdAbstract { 6 8 protected override string getDescription () { -
binary-improvements/AllocsCommands/Commands/ListLandProtection.cs
r446 r455 2 2 using System.Collections.Generic; 3 3 using AllocsFixes.PersistentData; 4 using JetBrains.Annotations; 4 5 5 6 namespace AllocsFixes.CustomCommands { 7 [UsedImplicitly] 6 8 public class ListLandProtection : ConsoleCmdAbstract { 7 9 protected override string getDescription () { … … 57 59 userIdFilter = ci.InternalId; 58 60 } else { 59 SdtdConsole.Instance.Output ( "Player name or entity id \"" + _params [0] + "\" not found.");61 SdtdConsole.Instance.Output ($"Player name or entity id \"{_params[0]}\" not found."); 60 62 return; 61 63 } … … 79 81 } catch (Exception e) { 80 82 SdtdConsole.Instance.Output ("Error getting current player's position"); 81 Log.Out ( "Error in ListLandProtection.Run: " + e);83 Log.Out ($"Error in ListLandProtection.Run: {e}"); 82 84 return; 83 85 } … … 102 104 103 105 foreach (KeyValuePair<Player, List<Vector3i>> kvp in claims) { 104 SdtdConsole.Instance.Output (string.Format ( 105 "Player \"{0} ({1})\" owns {4} keystones (protected: {2}, current hardness multiplier: {3})", 106 kvp.Key.Name, 107 kvp.Key.InternalId, 108 kvp.Key.LandProtectionActive, 109 kvp.Key.LandProtectionMultiplier, 110 kvp.Value.Count)); 111 if (!summaryOnly) { 112 foreach (Vector3i v in kvp.Value) { 113 if (parseableOutput) { 114 SdtdConsole.Instance.Output ("LandProtectionOf: id=" + kvp.Key.InternalId + 115 ", playerName=" + kvp.Key.Name + ", location=" + v); 116 } else { 117 SdtdConsole.Instance.Output (" (" + v + ")"); 118 } 106 SdtdConsole.Instance.Output ( 107 $"Player \"{kvp.Key.Name} ({kvp.Key.InternalId})\" owns {kvp.Value.Count} keystones (protected: {kvp.Key.LandProtectionActive}, current hardness multiplier: {kvp.Key.LandProtectionMultiplier})"); 108 if (summaryOnly) { 109 continue; 110 } 111 112 foreach (Vector3i v in kvp.Value) { 113 if (parseableOutput) { 114 SdtdConsole.Instance.Output ($"LandProtectionOf: id={kvp.Key.InternalId}, playerName={kvp.Key.Name}, location={v}"); 115 } else { 116 SdtdConsole.Instance.Output ($" ({v})"); 119 117 } 120 118 } … … 122 120 123 121 if (userIdFilter == null) { 124 SdtdConsole.Instance.Output ( "Total of " + ppl.m_lpBlockMap.Count + "keystones in the game");122 SdtdConsole.Instance.Output ($"Total of {ppl.m_lpBlockMap.Count} keystones in the game"); 125 123 } 126 124 } -
binary-improvements/AllocsCommands/Commands/RemoveLandProtection.cs
r420 r455 2 2 using System.Collections.Generic; 3 3 using AllocsFixes.PersistentData; 4 using JetBrains.Annotations; 4 5 5 6 namespace AllocsFixes.CustomCommands { 7 [UsedImplicitly] 6 8 public class RemoveLandProtection : ConsoleCmdAbstract { 7 9 protected override string getDescription () { … … 47 49 GameManager.Instance.SetBlocksRPC (changes); 48 50 49 SdtdConsole.Instance.Output ("Tried to remove #" + changes.Count + 50 " land protection blocks for player \"" + _id + "\". Note " + 51 "that only blocks in chunks that are currently loaded (close to any player) could be removed. " + 52 "Please check for remaining blocks by running:"); 53 SdtdConsole.Instance.Output (" listlandprotection " + _id); 51 SdtdConsole.Instance.Output ( 52 $"Tried to remove #{changes.Count} land protection blocks for player \"{_id}\". Note that only blocks in chunks that are currently loaded (close to any player) could be removed. Please check for remaining blocks by running:"); 53 SdtdConsole.Instance.Output ($" listlandprotection {_id}"); 54 54 } catch (Exception e) { 55 Log.Out ( "Error in RemoveLandProtection.removeById: " + e);55 Log.Out ($"Error in RemoveLandProtection.removeById: {e}"); 56 56 } 57 57 } 58 58 59 private void removeByPosition ( List<string> _coords) {59 private void removeByPosition (IReadOnlyList<string> _coords) { 60 60 int.TryParse (_coords [0], out int x); 61 61 int.TryParse (_coords [1], out int y); … … 84 84 GameManager.Instance.SetBlocksRPC (changes); 85 85 86 SdtdConsole.Instance.Output ( "Land protection block at (" + v + ") removed");86 SdtdConsole.Instance.Output ($"Land protection block at ({v}) removed"); 87 87 } 88 88 … … 125 125 } catch (Exception e) { 126 126 SdtdConsole.Instance.Output ("Error removing claims"); 127 Log.Out ( "Error in RemoveLandProtection.Run: " + e);127 Log.Out ($"Error in RemoveLandProtection.Run: {e}"); 128 128 } 129 129 } catch (Exception e) { 130 130 SdtdConsole.Instance.Output ("Error getting current player's position"); 131 Log.Out ( "Error in RemoveLandProtection.Run: " + e);131 Log.Out ($"Error in RemoveLandProtection.Run: {e}"); 132 132 } 133 133 } else if (_params.Count == 1) { -
binary-improvements/AllocsCommands/Commands/ShowInventory.cs
r446 r455 1 1 using System.Collections.Generic; 2 2 using AllocsFixes.PersistentData; 3 using JetBrains.Annotations; 3 4 4 5 namespace AllocsFixes.CustomCommands { 6 [UsedImplicitly] 5 7 public class ShowInventory : ConsoleCmdAbstract { 6 8 protected override string getDescription () { … … 44 46 45 47 if (tag == null) { 46 SdtdConsole.Instance.Output ( "Belt of player " + p.Name + ":");48 SdtdConsole.Instance.Output ($"Belt of player {p.Name}:"); 47 49 } 48 50 … … 53 55 54 56 if (tag == null) { 55 SdtdConsole.Instance.Output ( "Bagpack of player " + p.Name + ":");57 SdtdConsole.Instance.Output ($"Bagpack of player {p.Name}:"); 56 58 } 57 59 … … 62 64 63 65 if (tag == null) { 64 SdtdConsole.Instance.Output ( "Equipment of player " + p.Name + ":");66 SdtdConsole.Instance.Output ($"Equipment of player {p.Name}:"); 65 67 } 66 68 … … 68 70 69 71 if (tag != null) { 70 SdtdConsole.Instance.Output ("tracker_item id=" + p.EntityID + ", tag=" + tag + 71 ", SHOWINVENTORY DONE"); 72 SdtdConsole.Instance.Output ($"tracker_item id={p.EntityID}, tag={tag}, SHOWINVENTORY DONE"); 72 73 } 73 74 } 74 75 75 private void PrintInv (List<InvItem> _inv, int _entityId, string _location, string _tag) {76 private static void PrintInv (IReadOnlyList<InvItem> _inv, int _entityId, string _location, string _tag) { 76 77 for (int i = 0; i < _inv.Count; i++) { 77 if (_inv [i] != null) { 78 if (_tag == null) { 79 // no Tag defined -> readable output 80 if (_inv [i].quality < 0) { 81 SdtdConsole.Instance.Output (string.Format (" Slot {0}: {1:000} * {2}", i, 82 _inv [i].count, _inv [i].itemName)); 83 } else { 84 SdtdConsole.Instance.Output (string.Format (" Slot {0}: {1:000} * {2} - quality: {3}", i, 85 _inv [i].count, _inv [i].itemName, _inv [i].quality)); 86 } 78 if (_inv[i] == null) { 79 continue; 80 } 87 81 88 DoParts (_inv [i].parts, 1, null); 82 if (_tag == null) { 83 // no Tag defined -> readable output 84 if (_inv [i].quality < 0) { 85 SdtdConsole.Instance.Output (string.Format (" Slot {0}: {1:000} * {2}", i, 86 _inv [i].count, _inv [i].itemName)); 89 87 } else { 90 // Tag defined -> parseable output 91 string partsMsg = DoParts (_inv [i].parts, 1, ""); 92 string msg = "tracker_item id=" + _entityId + ", tag=" + _tag + ", location=" + _location + 93 ", slot=" + i + ", item=" + _inv [i].itemName + ", qnty=" + _inv [i].count + 94 ", quality=" + _inv [i].quality + ", parts=(" + partsMsg + ")"; 95 SdtdConsole.Instance.Output (msg); 88 SdtdConsole.Instance.Output (string.Format (" Slot {0}: {1:000} * {2} - quality: {3}", i, 89 _inv [i].count, _inv [i].itemName, _inv [i].quality)); 96 90 } 91 92 DoParts (_inv [i].parts, 1, null); 93 } else { 94 // Tag defined -> parseable output 95 string partsMsg = DoParts (_inv [i].parts, 1, ""); 96 string msg = "tracker_item id=" + _entityId + ", tag=" + _tag + ", location=" + _location + 97 ", slot=" + i + ", item=" + _inv [i].itemName + ", qnty=" + _inv [i].count + 98 ", quality=" + _inv [i].quality + ", parts=(" + partsMsg + ")"; 99 SdtdConsole.Instance.Output (msg); 97 100 } 98 101 } 99 102 } 100 103 101 private void PrintEquipment (InvItem[]_equipment, int _entityId, string _location, string _tag) {104 private static void PrintEquipment (IReadOnlyList<InvItem> _equipment, int _entityId, string _location, string _tag) { 102 105 AddEquipment ("head", _equipment, EquipmentSlots.Headgear, _entityId, _location, _tag); 103 106 AddEquipment ("eyes", _equipment, EquipmentSlots.Eyewear, _entityId, _location, _tag); … … 115 118 } 116 119 117 private void AddEquipment (string _slotname, InvItem[]_items, EquipmentSlots _slot, int _entityId,120 private static void AddEquipment (string _slotname, IReadOnlyList<InvItem> _items, EquipmentSlots _slot, int _entityId, 118 121 string _location, string _tag) { 119 122 int[] slotindices = XUiM_PlayerEquipment.GetSlotIndicesByEquipmentSlot (_slot); 120 123 121 124 for (int i = 0; i < slotindices.Length; i++) { 122 if (_items != null && _items [slotindices [i]] != null) { 123 InvItem item = _items [slotindices [i]]; 124 if (_tag == null) { 125 // no Tag defined -> readable output 126 if (item.quality < 0) { 127 SdtdConsole.Instance.Output (string.Format (" Slot {0:8}: {1:000}", _slotname, 128 item.itemName)); 129 } else { 130 SdtdConsole.Instance.Output (string.Format (" Slot {0:8}: {1:000} - quality: {2}", 131 _slotname, item.itemName, item.quality)); 132 } 125 if (_items == null || _items[slotindices[i]] == null) { 126 continue; 127 } 133 128 134 DoParts (_items [slotindices [i]].parts, 1, null); 129 InvItem item = _items [slotindices [i]]; 130 if (_tag == null) { 131 // no Tag defined -> readable output 132 if (item.quality < 0) { 133 SdtdConsole.Instance.Output (string.Format (" Slot {0:8}: {1:000}", _slotname, 134 item.itemName)); 135 135 } else { 136 // Tag defined -> parseable output 137 string partsMsg = DoParts (_items [slotindices [i]].parts, 1, ""); 138 string msg = "tracker_item id=" + _entityId + ", tag=" + _tag + ", location=" + _location + 139 ", slot=" + _slotname + ", item=" + item.itemName + ", qnty=1, quality=" + 140 item.quality + ", parts=(" + partsMsg + ")"; 141 SdtdConsole.Instance.Output (msg); 136 SdtdConsole.Instance.Output (string.Format (" Slot {0:8}: {1:000} - quality: {2}", 137 _slotname, item.itemName, item.quality)); 142 138 } 143 139 144 return; 140 DoParts (_items [slotindices [i]].parts, 1, null); 141 } else { 142 // Tag defined -> parseable output 143 string partsMsg = DoParts (_items [slotindices [i]].parts, 1, ""); 144 string msg = $"tracker_item id={_entityId}, tag={_tag}, location={_location}, slot={_slotname}, item={item.itemName}, qnty=1, quality={item.quality}, parts=({partsMsg})"; 145 SdtdConsole.Instance.Output (msg); 145 146 } 147 148 return; 146 149 } 147 150 } 148 151 149 private string DoParts (InvItem[] _parts, int _indent, string _currentMessage) { 150 if (_parts != null && _parts.Length > 0) { 151 string indenter = new string (' ', _indent * 4); 152 for (int i = 0; i < _parts.Length; i++) { 153 if (_parts [i] != null) { 154 if (_currentMessage == null) { 155 // no currentMessage given -> readable output 156 if (_parts [i].quality < 0) { 157 SdtdConsole.Instance.Output (string.Format ("{0} - {1}", indenter, 158 _parts [i].itemName)); 159 } else { 160 SdtdConsole.Instance.Output (string.Format ("{0} - {1} - quality: {2}", 161 indenter, _parts [i].itemName, _parts [i].quality)); 162 } 152 private static string DoParts (IReadOnlyList<InvItem> _parts, int _indent, string _currentMessage) { 153 if (_parts == null || _parts.Count <= 0) { 154 return _currentMessage; 155 } 163 156 164 DoParts (_parts [i].parts, _indent + 1, null); 165 } else { 166 // currentMessage given -> parseable output 167 if (_currentMessage.Length > 0) { 168 _currentMessage += ","; 169 } 157 string indenter = new string (' ', _indent * 4); 158 for (int i = 0; i < _parts.Count; i++) { 159 if (_parts[i] == null) { 160 continue; 161 } 170 162 171 _currentMessage += _parts [i].itemName + "@" + _parts [i].quality; 172 _currentMessage = DoParts (_parts [i].parts, _indent + 1, _currentMessage); 173 } 163 if (_currentMessage == null) { 164 // no currentMessage given -> readable output 165 if (_parts [i].quality < 0) { 166 SdtdConsole.Instance.Output (string.Format ("{0} - {1}", indenter, 167 _parts [i].itemName)); 168 } else { 169 SdtdConsole.Instance.Output (string.Format ("{0} - {1} - quality: {2}", 170 indenter, _parts [i].itemName, _parts [i].quality)); 174 171 } 172 173 DoParts (_parts [i].parts, _indent + 1, null); 174 } else { 175 // currentMessage given -> parseable output 176 if (_currentMessage.Length > 0) { 177 _currentMessage += ","; 178 } 179 180 _currentMessage += $"{_parts[i].itemName}@{_parts[i].quality}"; 181 _currentMessage = DoParts (_parts [i].parts, _indent + 1, _currentMessage); 175 182 } 176 183 } -
binary-improvements/AllocsCommands/ModInfo.xml
r446 r455 5 5 <Description value="Additional commands for server operation" /> 6 6 <Author value="Christian 'Alloc' Illy" /> 7 <Version value="2 4" />8 <Website value="http ://7dtd.illy.bz" />7 <Version value="25" /> 8 <Website value="https://7dtd.illy.bz" /> 9 9 </ModInfo> 10 10 </xml>
Note:
See TracChangeset
for help on using the changeset viewer.