Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
educatalan02 committed May 11, 2019
1 parent a9dc464 commit ef56d3d
Show file tree
Hide file tree
Showing 17 changed files with 652 additions and 0 deletions.
80 changes: 80 additions & 0 deletions AdvancedGodVanish.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{783A99C7-18EF-42BF-BF14-94D5296B06FB}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Library</OutputType>
<LangVersion>7.3</LangVersion>
<AssemblyName>AdvancedGodVanish</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<DebugSymbols>true</DebugSymbols>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Compile Include="AdvancedGodVanish\AdvancedGodVanish.cs" />
<Compile Include="AdvancedGodVanish\AdvancedGodVanishConfiguration.cs" />
<Compile Include="AdvancedGodVanish\CommandGod.cs" />
<Compile Include="AdvancedGodVanish\CommandRemoteGod.cs" />
<Compile Include="AdvancedGodVanish\CommandRemoteVanish.cs" />
<Compile Include="AdvancedGodVanish\CommandVanish.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Assembly-CSharp">
<HintPath>lib\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>lib\Assembly-CSharp-firstpass.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Rocket.API">
<HintPath>lib\Rocket.API.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Rocket.Core">
<HintPath>lib\Rocket.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Rocket.Unturned">
<HintPath>lib\Rocket.Unturned.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine">
<HintPath>lib\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>lib\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.PhysicsModule">
<HintPath>lib\UnityEngine.PhysicsModule.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
25 changes: 25 additions & 0 deletions AdvancedGodVanish.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2047
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdvancedGodVanish", "AdvancedGodVanish.csproj", "{783A99C7-18EF-42BF-BF14-94D5296B06FB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{783A99C7-18EF-42BF-BF14-94D5296B06FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{783A99C7-18EF-42BF-BF14-94D5296B06FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{783A99C7-18EF-42BF-BF14-94D5296B06FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{783A99C7-18EF-42BF-BF14-94D5296B06FB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F1DCD3D5-C850-472F-B28F-86B839D6F494}
EndGlobalSection
EndGlobal
130 changes: 130 additions & 0 deletions AdvancedGodVanish/AdvancedGodVanish.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
using Rocket.API.Collections;
using Rocket.Core.Logging;
using Rocket.Core.Plugins;
using Rocket.Unturned.Player;
using SDG.Unturned;
using System.Collections.Generic;
using System.IO;

namespace AdvancedGodVanish
{
public class AdvancedGodVanish : RocketPlugin<AdvancedGodVanishConfiguration>
{
public static AdvancedGodVanish Instance;

public string Creator = " educatalan02";

public string Version = "1.1";

public static string Discord = "https://discord.gg/Q89FmUk";

public string SteamContact = "http://steamcommunity.com/id/xXThe_HunterXx";

public string directory = System.IO.Directory.GetCurrentDirectory() + "/..";

public override TranslationList DefaultTranslations
{
get
{
TranslationList translationList = new TranslationList();
translationList.Add("Log_God_Turned_On", " has turned on the god mode for the player: ");
translationList.Add("Log_God_Turned_Off", " has turned off the god mode for the player: ");
translationList.Add("Log_Vanish_Turned_On", " has turned on the vanish mode for the player: ");
translationList.Add("Log_Vanish_Turned_Off", " has turned off the vanish mode for the player: ");
translationList.Add("God_on_Public", " has turned on the god mode.");
translationList.Add("God_off_Public", " has turned off the god mode.");
translationList.Add("Vanish_on_Public", " has turned on the vanish mode.");
translationList.Add("Vanish_off_Public", " has turned off the vanish mode.");
translationList.Add("God_on_Private", "You have turned on the god mode!");
translationList.Add("God_off_Private", "You have turned off the god mode!");
translationList.Add("Vanish_on_Private", "You have turned on the vanish mode!");
translationList.Add("Vanish_off_Private", "You have turned off the vanish mode!");
translationList.Add("god_on_console", " has turned on the god mode.");
translationList.Add("god_off_console", " has turned off the god mode.");
translationList.Add("vanish_on_console", " has turned on the vanish mode.");
translationList.Add("vanish_off_console", " has turned off the vanish mode.");
translationList.Add("players_godmode_turned_on", "God mode turned on for the player:");
translationList.Add("players_godmode_turned_off", "God mode turned off for the player:");
translationList.Add("players_vanishmode_turned_on", "Vanish mode turned on for the player:");
translationList.Add("players_vanishmode_turned_off", "Vanish mode turned off for the player:");
translationList.Add("your_vanishmode_turned_on", "Your vanish mode has been turned on.");
translationList.Add("your_vanishmode_turned_off", "Your vanish mode has been turned off.");
translationList.Add("your_godmode_turned_on", "Your god mode has been turned on.");
translationList.Add("your_godmode_turned_off", "Your god mode has been turned off.");
translationList.Add("global_players_godmode_turned_on", " turned on the godmode for the player: ");
translationList.Add("global_players_godmode_turned_off", "turned off the godmode for the player: ");
translationList.Add("global_players_vanishmode_turned_on", "turned on the vanishmode for the player: ");
translationList.Add("global_players_vanishmode_turned_off", "turned off the vanishmode for the player: ");
translationList.Add("usage_remotegod", "Usage: /RemoteGod");
translationList.Add("usage_remotevanish", "Usage: /RemoteVanish");
return translationList;
}
}

protected override void Load()
{
Instance = this;
if (Instance.Configuration.Instance.Enabled)
{
Logger.LogWarning("If the plugin is loaded at the first time, you need to restart your server once.");
Logger.LogWarning("Checking Announcer...");
Logger.LogWarning("Checking RemoteAnnouncer...");
Logger.LogWarning("Checking GodVanishLog...");
if (Instance.Configuration.Instance.AnnouncerEnabled)
{
Logger.LogWarning("Announcer Enabled!");
}
else
{
Logger.LogWarning("Announcer Disabled");
}
if (Instance.Configuration.Instance.RemoteAnnouncerEnabled)
{
Logger.LogWarning("RemoteAnnouncer Enabled!");
}
else
{
Logger.LogWarning("RemoteAnnouncer Disabled");
}
if (File.Exists(directory + "/GodVanishLog.txt"))
{
Logger.Log(directory + "/GodVanishLog.txt already exists. Loopholing the file...");
}
else
{
File.CreateText(directory + "/GodVanishLog.txt");
}
Logger.LogWarning("Plugin loaded");
Logger.LogWarning("Plugin fixed by " + Creator);
Logger.LogWarning("Version: " + Assembly.GetName().Version + " Support: " + Discord);

}
else
{
base.UnloadPlugin();
Logger.LogWarning("The plugin is disabled via the config file!");
}
}

protected override void Unload()
{
Instance = null;
if (!Instance.Configuration.Instance.Enabled)
{
Logger.LogWarning("Unloading plugin...");
Logger.LogWarning("Plugin unloaded!");
}
}

public List<UnturnedPlayer> Players()
{
List<UnturnedPlayer> list = new List<UnturnedPlayer>();
foreach (SteamPlayer client in Provider.clients)
{
UnturnedPlayer item = UnturnedPlayer.FromSteamPlayer(client);
list.Add(item);
}
return list;
}
}
}
83 changes: 83 additions & 0 deletions AdvancedGodVanish/AdvancedGodVanishConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using Rocket.API;

namespace AdvancedGodVanish
{
public class AdvancedGodVanishConfiguration : IRocketPluginConfiguration, IDefaultable
{
public bool Enabled;

public bool AnnouncerEnabled;

public bool RemoteAnnouncerEnabled;

public bool LoggingEnabled;

public string VanishOffPrivateColor;

public string VanishOffPublicColor;

public string VanishOnPublicColor;

public string VanishOnPrivateColor;

public string GodOffPrivateColor;

public string GodOffPublicColor;

public string GodOnPublicColor;

public string GodOnPrivateColor;

public string YourGodModeTurnedOffColor;

public string YourGodModeTurnedOnColor;

public string playersgodmodeturnedonColor;

public string playersgodmodeturnedoffColor;

public string playersvanishmodeturnedonColor;

public string playersvanishmodeturnedoffColor;

public string YourVanishModeTurnedOffColor;

public string YourVanishModeTurnedOnColor;

public string globalplayersvanishmodeturnedoffColor;

public string globalplayersvanishmodeturnedonColor;

public string UsageColor;

public string PlayerNotFoundColor;

public void LoadDefaults()
{
Enabled = true;
LoggingEnabled = true;
AnnouncerEnabled = true;
RemoteAnnouncerEnabled = false;
VanishOffPrivateColor = "red";
VanishOffPublicColor = "white";
VanishOnPublicColor = "yellow";
VanishOnPrivateColor = "green";
GodOffPrivateColor = "cyan";
GodOffPublicColor = "white";
GodOnPublicColor = "blue";
GodOnPrivateColor = "gray";
YourGodModeTurnedOffColor = "yellow";
YourGodModeTurnedOnColor = "blue";
YourVanishModeTurnedOffColor = "green";
YourVanishModeTurnedOnColor = "cyan";
playersvanishmodeturnedoffColor = "red";
playersvanishmodeturnedonColor = "yellow";
playersgodmodeturnedoffColor = "blue";
playersgodmodeturnedonColor = "green";
globalplayersvanishmodeturnedoffColor = "red";
globalplayersvanishmodeturnedonColor = "blue";
UsageColor = "yellow";
PlayerNotFoundColor = "red";
}
}
}
76 changes: 76 additions & 0 deletions AdvancedGodVanish/CommandGod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using Rocket.API;
using Rocket.Core.Logging;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Player;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using Logger = Rocket.Core.Logging.Logger;

namespace AdvancedGodVanish
{
public class CommandGod : IRocketCommand
{
public string directory = Directory.GetCurrentDirectory() + "/..";

public AllowedCaller AllowedCaller => AllowedCaller.Player;

public string Name => "God";

public string Help => "Toggle godmode";

public string Syntax => string.Empty;

public List<string> Aliases => new List<string>();

public List<string> Permissions
{
get
{
List<string> list = new List<string>();
list.Add("God");
return list;
}
}

public void Execute(IRocketPlayer caller, string[] command)
{

UnturnedPlayer unturnedPlayer = (UnturnedPlayer)caller;
if (unturnedPlayer.Features.GodMode)
{
unturnedPlayer.Features.GodMode = false;
Logger.LogWarning(unturnedPlayer.CharacterName + AdvancedGodVanish.Instance.Translate("god_off_console"));
UnturnedChat.Say(caller, AdvancedGodVanish.Instance.Translate("God_off_Private"), UnturnedChat.GetColorFromName(AdvancedGodVanish.Instance.Configuration.Instance.GodOffPrivateColor, Color.red));
if (AdvancedGodVanish.Instance.Configuration.Instance.AnnouncerEnabled)
{
UnturnedChat.Say(unturnedPlayer.CharacterName + AdvancedGodVanish.Instance.Translate("God_off_Public"), UnturnedChat.GetColorFromName(AdvancedGodVanish.Instance.Configuration.Instance.GodOffPublicColor, Color.red));
if (AdvancedGodVanish.Instance.Configuration.Instance.LoggingEnabled)
{
using (StreamWriter streamWriter = File.AppendText(directory + "/GodVanishLog.txt"))
{
streamWriter.WriteLine("[God]" + unturnedPlayer.CharacterName + "[" + unturnedPlayer.DisplayName + "]" + AdvancedGodVanish.Instance.Translate("god_off_console") + " Steam64ID: " + unturnedPlayer.CSteamID + streamWriter.NewLine);
streamWriter.Close();
}
}
}
return;
}
unturnedPlayer.Features.GodMode = true;
Logger.LogWarning(unturnedPlayer.CharacterName + AdvancedGodVanish.Instance.Translate("god_on_console"));
if (AdvancedGodVanish.Instance.Configuration.Instance.AnnouncerEnabled)
{
UnturnedChat.Say(unturnedPlayer.CharacterName + AdvancedGodVanish.Instance.Translate("God_on_Public"), UnturnedChat.GetColorFromName(AdvancedGodVanish.Instance.Configuration.Instance.GodOnPublicColor, Color.red));
UnturnedChat.Say(caller, AdvancedGodVanish.Instance.Translate("God_on_Private"), UnturnedChat.GetColorFromName(AdvancedGodVanish.Instance.Configuration.Instance.GodOnPrivateColor, Color.red));
if (AdvancedGodVanish.Instance.Configuration.Instance.LoggingEnabled)
{
using (StreamWriter streamWriter2 = File.AppendText(directory + "/GodVanishLog.txt"))
{
streamWriter2.WriteLine("[God]" + unturnedPlayer.CharacterName + "[" + unturnedPlayer.DisplayName + "]" + AdvancedGodVanish.Instance.Translate("god_on_console") + " Steam64ID: " + unturnedPlayer.CSteamID + streamWriter2.NewLine);
streamWriter2.Close();
}
}
}
}
}
}
Loading

0 comments on commit ef56d3d

Please sign in to comment.