コード例 #1
0
ファイル: BoxesPlugin.cs プロジェクト: mawize/Boxes
        public override void Initialize()
        {
            // init DB
            DB = TShock.DB;
            boxman = BoxManager.GetInstance();
            boxman.EnsureTableExists(DB);

            // hook setup
            Hooks.GameHooks.PostInitialize += OnPostInit;
            GetDataHandlers.TileEdit += OnTileEdit;

            // permission Setup
            bool managebox = false;
            bool adminbox = false;

            // look if there are already set up permissions
            foreach (Group group in TShock.Groups.groups)
            {
                if (group.Name != "superadmin")
                {
                    if (group.HasPermission("boxes.manage"))
                        managebox = true;
                    if (group.HasPermission("boxes.admin"))
                        adminbox = true;
                }
            }
            List<string> perm = new List<string>();

            // if not we set this for default user
            if (!managebox)
                perm.Add("boxes.manage");
            TShock.Groups.AddPermissions("default", perm);

            if (!adminbox)
                perm.Add("boxes.admin");
            TShock.Groups.AddPermissions("trustedadmin", perm);

            // register chatcommand
            cmds = new Commands();
            TShockAPI.Commands.ChatCommands.Add(new Command("boxes.manage", cmds.Boxes, Commands.COMMAND_NAME));
        }
コード例 #2
0
ファイル: BoxManager.cs プロジェクト: mawize/Boxes
 public static BoxManager GetInstance()
 {
     if(instance==null)
         instance = new BoxManager();
     return instance;
 }