Skip to content

Commit 680bf36

Browse files
feat(noescape): integrate with noescape plugin
1 parent 04f44fe commit 680bf36

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

src/AutoCode.cs

+47
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Oxide.Core;
2+
using Oxide.Core.Plugins;
23
using Oxide.Core.Configuration;
34
using Oxide.Game.Rust.Libraries;
45
using System;
@@ -13,6 +14,9 @@ namespace Oxide.Plugins
1314
[Description("Automatically sets the code on code locks when placed.")]
1415
public class AutoCode : RustPlugin
1516
{
17+
[PluginReference("NoEscape")]
18+
private Plugin pluginNoEscape;
19+
1620
private AutoCodeConfig config;
1721
private Commands commands;
1822
private Data data;
@@ -93,6 +97,30 @@ private void OnItemDeployed(Deployer deployer, BaseEntity lockable, CodeLock cod
9397
return;
9498
}
9599

100+
// NoEscape blocked.
101+
if (pluginNoEscape != null)
102+
{
103+
if (
104+
config.Options.PluginIntegration.NoEscape.BlockRaid &&
105+
pluginNoEscape.Call<bool>("HasPerm", player.UserIDString, "raid.buildblock") &&
106+
pluginNoEscape.Call<bool>("IsRaidBlocked", player.UserIDString)
107+
)
108+
{
109+
Message(player, lang.GetMessage("NoEscape.RaidBlocked", this, player.UserIDString));
110+
return;
111+
}
112+
113+
if (
114+
config.Options.PluginIntegration.NoEscape.BlockCombat &&
115+
pluginNoEscape.Call<bool>("HasPerm", player.UserIDString, "combat.buildblock") &&
116+
pluginNoEscape.Call<bool>("IsCombatBlocked", player.UserIDString)
117+
)
118+
{
119+
Message(player, lang.GetMessage("NoEscape.CombatBlocked", this, player.UserIDString));
120+
return;
121+
}
122+
}
123+
96124
Data.Structure.PlayerSettings settings = data.Inst.playerSettings[player.userID];
97125

98126
// Player doesn't have a code?
@@ -199,6 +227,8 @@ protected override void LoadDefaultMessages()
199227
{ "HelpExtendedQuietMode", "Toggles on/off quiet mode:\n{0}" },
200228
{ "HelpExtendedQuietModeDetails", "Less messages will be shown and your auto-code will be hidden." },
201229
{ "HelpExtendedHelp", "Displays this help message:\n{0}" },
230+
{ "NoEscape.RaidBlocked", "Auto-code disbaled due to raid block." },
231+
{ "NoEscape.CombatBlocked", "Auto-code disbaled due to combat block." },
202232
}, this);
203233
}
204234

@@ -640,6 +670,8 @@ public class OptionsDef
640670
public bool DisplayPermissionErrors = true;
641671

642672
public SpamPreventionDef SpamPrevention = new SpamPreventionDef();
673+
674+
public PluginIntegrationDef PluginIntegration = new PluginIntegrationDef();
643675

644676
public class SpamPreventionDef
645677
{
@@ -650,6 +682,17 @@ public class SpamPreventionDef
650682
public bool UseExponentialLockOutTime = true;
651683
public double LockOutResetFactor = 5.0;
652684
};
685+
686+
public class PluginIntegrationDef
687+
{
688+
public NoEscapeDef NoEscape = new NoEscapeDef();
689+
690+
public class NoEscapeDef
691+
{
692+
public bool BlockRaid = false;
693+
public bool BlockCombat = false;
694+
};
695+
};
653696
};
654697

655698
/// <summary>
@@ -688,6 +731,10 @@ public void Load()
688731
);
689732
RemoveConfigValue(new string[] { "Options", "Spam Prevention", "Exponential Lock Out Time" }); // Remove deprecated version.
690733

734+
// Plugin integration - No Escape.
735+
Options.PluginIntegration.NoEscape.BlockCombat = GetConfigValue(new string[] { "Options", "Plugin Integration", "No Escape", "Block Combat" }, false);
736+
Options.PluginIntegration.NoEscape.BlockRaid = GetConfigValue(new string[] { "Options", "Plugin Integration", "No Escape", "Block Raid" }, true);
737+
691738
// Commands.
692739
plugin.commands.Use = GetConfigValue(new string[] { "Commands", "Use" }, plugin.commands.Use);
693740

0 commit comments

Comments
 (0)