-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDisableIndustrialConveyor.cs
78 lines (72 loc) · 3.2 KB
/
DisableIndustrialConveyor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using Oxide.Core;
using Rust;
using System.Collections.Generic;
namespace Oxide.Plugins
{
[Info("DisableIndustrialConveyor", "Tacman", "1.5.1")]
[Description("Disables placement of Industrial Conveyors on the server.")]
public class DisableIndustrialConveyor : RustPlugin
{
private void OnServerInitialized()
{
permission.RegisterPermission("disableindustrialconveyor.bypass", this);
// Define the translations for each language
Dictionary<string, Dictionary<string, string>> messages = new Dictionary<string, Dictionary<string, string>>
{
["en"] = new Dictionary<string, string>
{
["NotAllowed"] = "Industrial Conveyors are disabled on this server."
},
["fr"] = new Dictionary<string, string>
{
["NotAllowed"] = "Les transporteurs industriels sont désactivés sur ce serveur."
},
["de"] = new Dictionary<string, string>
{
["NotAllowed"] = "Industrieförderer sind auf diesem Server deaktiviert."
},
["es"] = new Dictionary<string, string>
{
["NotAllowed"] = "Los transportadores industriales están desactivados en este servidor."
},
["ru"] = new Dictionary<string, string>
{
["NotAllowed"] = "Промышленные конвейеры отключены на этом сервере."
},
["zh"] = new Dictionary<string, string>
{
["NotAllowed"] = "本服务器禁止使用工业传送带。"
},
["nl"] = new Dictionary<string, string>
{
["NotAllowed"] = "Industriële transportbanden zijn uitgeschakeld op deze server."
}
};
// Loop through each language and create the language file if it doesn't exist
foreach (string code in messages.Keys)
{
string fileName = $"{code}.json";
string filePath = $"{Interface.Oxide.LangDirectory}/{Name}/{fileName}";
// Create the language file if it doesn't exist
if (!Interface.Oxide.DataFileSystem.ExistsDatafile(filePath))
{
lang.RegisterMessages(messages[code], this, code);
Puts($"Created {code} language file.");
}
}
}
private object CanBuild(Planner planner, Construction prefab)
{
if (prefab.fullName.Contains("industrialconveyor"))
{
var player = planner.GetOwnerPlayer();
if (player != null && !permission.UserHasPermission(player.UserIDString, "disableindustrialconveyor.bypass"))
{
player.ChatMessage(lang.GetMessage("NotAllowed", this, player.UserIDString));
return false;
}
}
return null;
}
}
}