示例#1
0
 public ChatCommands(BasePlugin pl)
 {
     plugin = pl;
 }
示例#2
0
 public ConsoleCommands(BasePlugin pl)
 {
     plugin = pl;
 }
示例#3
0
        public void InstallHooks(BasePlugin plugin)
        {
            if (plugin.State != PluginState.Loaded)
            {
                return;
            }

            foreach (string method in plugin.Globals)
            {
                if (!method.StartsWith("On_") && !method.EndsWith("Callback"))
                {
                    continue;
                }

                bool foundHook = true;
                switch (method)
                {
                case "On_AllPluginsLoaded":
                    plugin.OnAllPluginsLoadedHook = OnAllLoaded.Subscribe(s => plugin.OnAllPluginsLoaded(""));
                    break;

                case "On_Chat":
                    plugin.OnChatHook = Hooks.OnChat.Subscribe(c => plugin.OnChat(c));
                    break;

                case "On_ClientAuth":
                    plugin.OnClientAuthHook = Hooks.OnClientAuth.Subscribe(a => plugin.OnClientAuth(a));
                    break;

                case "On_ClientConsole":
                    plugin.OnClientConsoleHook = Hooks.OnClientConsole.Subscribe(c => plugin.OnClientConsole(c));
                    break;

                case "On_Command":
                    plugin.OnCommandHook = Hooks.OnCommand.Subscribe(c => plugin.OnCommand(c));
                    break;

                case "On_CommandPermission":
                    plugin.OnCommandPermissionHook = Hooks.OnCommandPermission.Subscribe(c => plugin.OnCommandPermission(c));
                    break;

                case "On_CorpseHurt":
                    plugin.OnCorpseHurtHook = Hooks.OnCorpseHurt.Subscribe(c => plugin.OnCorpseHurt(c));
                    break;

                case "On_BuildingComplete":
                    plugin.OnBuildingCompleteHook = Hooks.OnBuildingComplete.Subscribe(b => plugin.OnBuildingComplete(b));
                    break;

                case "On_Placement":
                    plugin.OnPlacementHook = Hooks.OnPlacement.Subscribe(b => plugin.OnPlacement(b));
                    break;

                case "On_DoorCode":
                    plugin.OnDoorCodeHook = Hooks.OnDoorCode.Subscribe(b => plugin.OnDoorCode(b));
                    break;

                case "On_DoorUse":
                    plugin.OnDoorUseHook = Hooks.OnDoorUse.Subscribe(d => plugin.OnDoorUse(d));
                    break;

                case "On_NPCHurt":
                    plugin.OnNPCHurtHook = Hooks.OnNPCHurt.Subscribe(n => plugin.OnNPCHurt(n));
                    break;

                case "On_NPCKilled":
                    plugin.OnNPCKilledHook = Hooks.OnNPCDied.Subscribe(n => plugin.OnNPCKilled(n));
                    break;

                case "On_LootingEntity":
                    plugin.OnLootingEntityHook = Hooks.OnLootingEntity.Subscribe(l => plugin.OnLootingEntity(l));
                    break;

                case "On_LootingPlayer":
                    plugin.OnLootingPlayerHook = Hooks.OnLootingPlayer.Subscribe(l => plugin.OnLootingPlayer(l));
                    break;

                case "On_LootingItem":
                    plugin.OnLootingItemHook = Hooks.OnLootingItem.Subscribe(l => plugin.OnLootingItem(l));
                    break;

                case "On_PlayerConnected":
                    plugin.OnPlayerConnectedHook = Hooks.OnPlayerConnected.Subscribe(p => plugin.OnPlayerConnected(p));
                    break;

                case "On_PlayerDisconnected":
                    plugin.OnPlayerDisconnectedHook = Hooks.OnPlayerDisconnected.Subscribe(p => plugin.OnPlayerDisconnected(p));
                    break;

                case "On_PlayerGathering":
                    plugin.OnPlayerGatheringHook = Hooks.OnGathering.Subscribe(g => plugin.OnPlayerGathering(g));
                    break;

                case "On_PlayerHurt":
                    plugin.OnPlayerHurtHook = Hooks.OnPlayerHurt.Subscribe(p => plugin.OnPlayerHurt(p));
                    break;

                case "On_CombatEntityHurt":
                    plugin.OnCombatEntityHurtHook = Hooks.OnCombatEntityHurt.Subscribe(c => plugin.OnCombatEntityHurt(c));
                    break;

                case "On_PlayerDied":
                    plugin.OnPlayerDiedHook = Hooks.OnPlayerDied.Subscribe(p => plugin.OnPlayerDied(p));
                    break;

                case "On_PlayerStartCrafting":
                    plugin.OnPlayerStartCraftingHook = Hooks.OnPlayerStartCrafting.Subscribe(p => plugin.OnPlayerStartCrafting(p));
                    break;

                case "On_PlayerTakeRadiation":
                    plugin.OnPlayerTakeRadiationHook = Hooks.OnPlayerTakeRads.Subscribe(p => plugin.OnPlayerTakeRadiation(p));
                    break;

                case "On_ServerConsole":
                    plugin.OnServerConsoleHook = Hooks.OnServerConsole.Subscribe(c => plugin.OnServerConsole(c));
                    break;

                case "On_ServerInit":
                    plugin.OnServerInitHook = Hooks.OnServerInit.Subscribe(s => plugin.OnServerInit(s));
                    break;

                case "On_ServerShutdown":
                    plugin.OnServerShutdownHook = Hooks.OnServerShutdown.Subscribe(s => plugin.OnServerShutdown(s));
                    break;

                case "On_Respawn":
                    plugin.OnRespawnHook = Hooks.OnRespawn.Subscribe(r => plugin.OnRespawn(r));
                    break;

                case "On_PluginInit":
                    plugin.Invoke("On_PluginInit");
                    break;

                case "On_PluginDeinit":
                    break;

                default:
                    foundHook = false;
                    break;
                }
                if (foundHook)
                {
                    Logger.LogDebug("Found hook: " + method);
                }
            }
        }
示例#4
0
        public void RemoveHooks(BasePlugin plugin)
        {
            if (plugin.State != PluginState.Loaded)
            {
                return;
            }

            foreach (string method in plugin.Globals)
            {
                if (!method.StartsWith("On_") && !method.EndsWith("Callback"))
                {
                    continue;
                }

                bool foundHook = true;
                switch (method)
                {
                case "On_AllPluginsLoaded":
                    plugin.OnAllPluginsLoadedHook.Dispose();
                    break;

                case "On_Chat":
                    plugin.OnChatHook.Dispose();
                    break;

                case "On_ClientAuth":
                    plugin.OnClientAuthHook.Dispose();
                    break;

                case "On_ClientConsole":
                    plugin.OnClientConsoleHook.Dispose();
                    break;

                case "On_Command":
                    plugin.OnCommandHook.Dispose();
                    break;

                case "On_CommandPermission":
                    plugin.OnCommandPermissionHook.Dispose();
                    break;

                case "On_CorpseHurt":
                    plugin.OnCorpseHurtHook.Dispose();
                    break;

                case "On_BuildingComplete":
                    plugin.OnBuildingCompleteHook.Dispose();
                    break;

                case "On_Placement":
                    plugin.OnPlacementHook.Dispose();
                    break;

                case "On_DoorCode":
                    plugin.OnDoorCodeHook.Dispose();
                    break;

                case "On_DoorUse":
                    plugin.OnDoorUseHook.Dispose();
                    break;

                case "On_NPCHurt":
                    plugin.OnNPCHurtHook.Dispose();
                    break;

                case "On_NPCKilled":
                    plugin.OnNPCKilledHook.Dispose();
                    break;

                case "On_LootingEntity":
                    plugin.OnLootingEntityHook.Dispose();
                    break;

                case "On_LootingPlayer":
                    plugin.OnLootingPlayerHook.Dispose();
                    break;

                case "On_LootingItem":
                    plugin.OnLootingItemHook.Dispose();
                    break;

                case "On_PlayerConnected":
                    plugin.OnPlayerConnectedHook.Dispose();
                    break;

                case "On_PlayerDisconnected":
                    plugin.OnPlayerDisconnectedHook.Dispose();
                    break;

                case "On_PlayerGathering":
                    plugin.OnPlayerGatheringHook.Dispose();
                    break;

                case "On_PlayerHurt":
                    plugin.OnPlayerHurtHook.Dispose();
                    break;

                case "On_CombatEntityHurt":
                    plugin.OnCombatEntityHurtHook.Dispose();
                    break;

                case "On_PlayerDied":
                    plugin.OnPlayerDiedHook.Dispose();
                    break;

                case "On_PlayerStartCrafting":
                    plugin.OnPlayerStartCraftingHook.Dispose();
                    break;

                case "On_PlayerTakeRadiation":
                    plugin.OnPlayerTakeRadiationHook.Dispose();
                    break;

                case "On_ServerConsole":
                    plugin.OnServerConsoleHook.Dispose();
                    break;

                case "On_ServerInit":
                    plugin.OnServerInitHook.Dispose();
                    break;

                case "On_ServerShutdown":
                    plugin.OnServerShutdownHook.Dispose();
                    break;

                case "On_Respawn":
                    plugin.OnRespawnHook.Dispose();
                    break;

                case "On_PluginInit":
                case "On_PluginDeinit":
                    break;

                default:
                    foundHook = false;
                    break;
                }
                if (foundHook)
                {
                    Logger.LogDebug("Removed hook: " + method);
                }
            }
        }
示例#5
0
 public static Hook Subscribe(string hookname, BasePlugin plugin)
 {
     return(new Hook(hookname, args => plugin.Invoke(hookname, args)));
 }