Exemplo n.º 1
0
        public bool HasPermissions(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Permission name cannot be null");
            }

            name = name.ToLower();

            if (IsPermissionSet(name))
            {
                return(permissions[name].Value);
            }
            else
            {
                Permission perm = Bukkit.getServer().getPluginManager().getPermission(name);

                if (perm != null)
                {
                    return(perm.Default.getValue(IsOP()));
                }
                else
                {
                    return(Permission.DEFAULT_PERMISSION.getValue(IsOp()));
                }
            }
        }
Exemplo n.º 2
0
 public void Cancel()
 {
     lock (syncLock)
     {
         Bukkit.getScheduler().cancelTask(GetTaskId());
     }
 }
Exemplo n.º 3
0
 public IBukkitTask RunTaskTimerAsynchronously(IPlugin plugin, long delay, long period)
 {
     lock (syncLock)
     {
         CheckState();
         return(SetupId(Bukkit.getScheduler().RunTaskTimerAsynchronously(plugin, this, delay, period)));
     }
 }
Exemplo n.º 4
0
 public IBukkitTask RunTaskLater(IPlugin plugin, long delay)
 {
     lock (syncLock)
     {
         CheckState();
         return(SetupId(Bukkit.getScheduler().RunTaskLater(plugin, this, delay)));
     }
 }
Exemplo n.º 5
0
 public IBukkitTask RunTaskAsynchronously(IPlugin plugin)
 {
     lock (syncLock)
     {
         CheckState();
         return(SetupId(Bukkit.getScheduler().RunTaskAsynchronously(plugin, this)));
     }
 }
Exemplo n.º 6
0
 public IBukkitTask RunTask(IPlugin plugin)
 {
     lock (syncLock)
     {
         CheckState();
         return(setupId(Bukkit.getScheduler().runTask(plugin, this)));
     }
 }
Exemplo n.º 7
0
        public void DisablePlugin(IPlugin plugin)
        {
            Debug.Assert(plugin is CSharpPlugin, "Plugin is not associated with this PluginLoader");

            if (plugin.IsEnabled())
            {
                String message = String.Format("Disabling {0}", plugin.PluginDescription.FullName);
                plugin.GetLogger().Info(message);

                Bukkit.Server.GetPluginManager().CallEvent(new PluginDisableEvent(plugin));

                var cPlugin = (CSharpPlugin)plugin;

                try
                {
                    cPlugin.SetEnabled(false);
                }
                catch (Exception ex)
                {
                    Bukkit.GetLogger().Log(Level.SEVERE, "Error occurred while disabling " + plugin.GetDescription().FullName + " (Is it up to date?)", ex);
                }
            }
        }
Exemplo n.º 8
0
        public PermissionAttachment AddAttachment(IPlugin plugin, int ticks)
        {
            if (plugin == null)
            {
                throw new ArgumentException("Plugin cannot be null");
            }
            else if (!plugin.Enabled)
            {
                throw new ArgumentException("Plugin " + plugin.PluginDescription.FullName + " is disabled");
            }

            PermissionAttachment result = AddAttachment(plugin);

            if (Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new RemoveAttachmentRunnable(result), ticks) == -1)
            {
                Bukkit.getServer().getLogger().log(Level.WARNING, "Could not add PermissionAttachment to " + parent + " for plugin " + plugin.PluginDescription.FullName + ": Scheduler returned -1");
                result.Remove();
                return(null);
            }
            else
            {
                return(result);
            }
        }