Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.15 KB | None | 0 0
  1. using Rocket.API;
  2. using Rocket.Core.Plugins;
  3. using Rocket.Unturned.Player;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10.  
  11.  
  12.  
  13. namespace UBans
  14. {
  15.     public class UbanCommand : IRocketCommand
  16.     {
  17.         public AllowedCaller AllowedCaller => AllowedCaller.Player;
  18.  
  19.         public string Name => "UBan";
  20.  
  21.         public string Help => "/UBan [Player] [Reason]";
  22.  
  23.         public string Syntax => "<player> <Reason>";
  24.  
  25.         public List<string> Aliases => new List<string>() {"uban","UBAN"};
  26.  
  27.         public List<string> Permissions => new List<string>() { "staff" };
  28.  
  29.         public void Execute(IRocketPlayer caller, string[] command)
  30.         {
  31.             UnturnedPlayer target = UnturnedPlayer.FromName(command[0]);
  32.             UbanCore test = new UbanCore();
  33.             string BanType = command[1].ToLower();
  34.             test.BanSystem(target,BanType,caller);
  35.            
  36.         }
  37.  
  38.     }
  39.     public class UbanCore : RocketPlugin <UbanConfig>
  40.     {
  41.         public static int ReasonCode1 = 1;
  42.         public static int ReasonCode2 = 2;
  43.         public static int ReasonCode3 = 3;
  44.         public static int ReasonCode4 = 4;
  45.  
  46.  
  47.         public string directory = System.IO.Directory.GetCurrentDirectory() + "/..";
  48.         public static UbanCore instance;
  49.         protected override void Load()
  50.         {
  51.             instance = this;
  52.  
  53.             if (File.Exists(directory + "/UBans.txt"))
  54.             {
  55.                 Rocket.Core.Logging.Logger.Log(directory + "UBans Has Been Loaded");
  56.             }
  57.             else
  58.             {
  59.                 File.CreateText(directory + "/UBans.txt");
  60.                 Rocket.Core.Logging.Logger.Log(directory + "UBans Has Created Bans Folder....");
  61.             }
  62.         }
  63.         protected override void Unload()
  64.         {
  65.             instance = null;
  66.         }
  67.         public void BanSystem(UnturnedPlayer target, string BanType, IRocketPlayer caller)
  68.         {
  69.             if (BanType == "masskos" || BanType.Substring(0,5) == "masskos".Substring(0,5) && caller.HasPermission(instance.Configuration.Instance.MassKP))
  70.             {
  71.                 target.Ban("MassKos", instance.Configuration.Instance.MassKos);
  72.  
  73.             }
  74.             else if (BanType == "massvdm" || BanType.Substring(0, 5) == "massvdm".Substring(0, 5) && caller.HasPermission(instance.Configuration.Instance.MassVdmP))
  75.             {
  76.  
  77.                 target.Ban("MassVdm", instance.Configuration.Instance.MassVdm);
  78.  
  79.             }
  80.             else if (BanType == "micspam" || BanType.Substring(0, 5) == "micspam".Substring(0, 5) && caller.HasPermission(instance.Configuration.Instance.MicspamP))
  81.             {
  82.  
  83.                 target.Ban("MicSpam", instance.Configuration.Instance.MicSpam);
  84.  
  85.             }
  86.             else if (BanType == "minge" || BanType.Substring(0, 3) == "minge".Substring(0, 3) && caller.HasPermission(instance.Configuration.Instance.MingeP))
  87.             {
  88.  
  89.                 target.Ban("Minge", instance.Configuration.Instance.Minge);
  90.                 BanWriter(target, ReasonCode4);
  91.                
  92.  
  93.             }
  94.         }
  95.         public void BanWriter(UnturnedPlayer target, int ReasonCode)
  96.         {
  97.  
  98.             using (StreamWriter w = File.AppendText(directory + "/UBans"))
  99.             {
  100.                 w.WriteLine((ulong)target.CSteamID + (ulong)ReasonCode);
  101.                 w.Close();
  102.                
  103.  
  104.             }
  105.  
  106.  
  107.  
  108.         }
  109.  
  110.     }
  111.  
  112.  
  113.     public class UbanConfig : IRocketPluginConfiguration
  114.     {
  115.         public uint MassKos;
  116.         public uint MassVdm;
  117.         public uint Minge;
  118.         public uint MicSpam;
  119.  
  120.         public string MassKP;
  121.         public string MassVdmP;
  122.         public string MingeP;
  123.         public string MicspamP;
  124.  
  125.  
  126.         public void LoadDefaults()
  127.         {
  128.             MassKos = 99999999;
  129.             MassVdm = 99999999;
  130.             Minge = 999999999;
  131.             MicSpam = 500;
  132.  
  133.             MassKP = "U.BanMassK";
  134.             MassVdmP = "U.MassVdmP";
  135.             MingeP = "U.MineP";
  136.             MicspamP = "U.MicP";
  137.  
  138.            
  139.         }
  140.     }
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement