Compare commits

...

44 Commits
1.7 ... master

Author SHA1 Message Date
Michel Roux 75a9cad1e6 Target 1.7.6 2012-05-30 10:17:37 +02:00
Xéfir Destiny 99fbed29e0 Try to fix NPE without CastException 2012-05-25 00:41:23 +02:00
Michel Roux dfd4e1e1b4 Target 1.7.5 2012-05-19 21:24:24 +02:00
Michel Roux a120301bef NPE when do some command on offline player 2012-05-19 21:23:31 +02:00
Michel Roux d443b464d4 NPE, thanks Malon 2012-05-19 01:08:57 +02:00
Michel Roux a92b82e5da Correction spam nothing 2012-05-18 22:44:04 +02:00
Michel Roux c43340ee15 Fix Player NPE 2012-05-18 18:26:56 +02:00
Michel Roux d9311addab Target 1.7.4 2012-05-15 09:07:40 +02:00
Michel Roux ad43193951 In fact ... no =s 2012-05-15 09:06:23 +02:00
Michel Roux b6dedbd13a But is required in case of fail 2012-05-15 09:05:44 +02:00
Michel Roux b92be6d2a9 Totally usefull, perms is applied on the fly 2012-05-15 09:04:44 +02:00
Michel Roux 80c055d209 Call right function in SimplyCommands 2012-05-15 09:01:26 +02:00
Michel Roux b9dcbbfc09 Call right function in SimplyAPI 2012-05-15 08:58:18 +02:00
Michel Roux 4bac4a1d70 Slit refreshPermissions() in multiple functions 2012-05-15 08:54:40 +02:00
Michel Roux 79bc01d986 Push 1.7.3 release 2012-05-15 00:37:56 +02:00
Michel Roux 8b8a304476 Add setPlayerGroup in API 2012-05-15 00:35:39 +02:00
Michel Roux 9d8879f0b2 Force refreshPermissions in API when you think is usefull to do it 2012-05-15 00:25:05 +02:00
Michel Roux 31c7d8cd7f Forgot permissions in plugin.yml 2012-05-13 18:32:26 +02:00
Michel Roux 6fc78f64f3 Added Macros prevention 2012-05-13 17:47:43 +02:00
Michel Roux 46bc9963fa Small bugfix, target 1.7.2 2012-05-13 17:39:48 +02:00
Michel Roux 63fae3590f Don't commit class 2012-05-12 01:24:02 +02:00
Michel Roux 70f667447a Typo 2012-05-11 21:38:50 +02:00
Michel Roux 7c1376be8a Some much README editing 2012-05-11 21:15:54 +02:00
Michel Roux 7aeed9877f Thanks milkywayz 2012-05-11 21:05:25 +02:00
Michel Roux 5e8c850ee7 Points and spaces 2012-05-11 21:03:02 +02:00
Michel Roux 56af5a4866 Integration of SimplyRank 2012-05-11 21:01:28 +02:00
Michel Roux b4eee29372 Not a list, Bukkit don't like it 2012-05-11 16:32:08 +02:00
Michel Roux d08ff3f275 Cosmetic changes 2012-05-11 16:30:25 +02:00
Michel Roux e50e394cb9 Donation button working 2012-05-11 16:27:58 +02:00
Michel Roux aea566ff30 Test donate image 2012-05-11 16:26:20 +02:00
Michel Roux 892b493c9f Donation link works 2012-05-11 16:20:51 +02:00
Michel Roux a561ac693b Waiting valid link 2012-05-11 16:18:46 +02:00
Michel Roux 187d68902e Rename SimplyWrapper in SimplyWrap
Added Source Code links
Added donate page
2012-05-11 16:17:33 +02:00
Michel Roux c5ac11a347 Small README fix 2012-05-11 12:18:50 +02:00
Michel Roux 0c3601e112 Added reference to SimplyWrapper 2012-05-11 12:15:59 +02:00
Michel Roux 8a648ad0ac Added description 2012-05-11 12:08:21 +02:00
Michel Roux 953e1bf4d7 Missing toLowerCase nearly anywhere 2012-05-11 11:55:04 +02:00
Michel Roux 5f5552b6e4 Added real bukkit site 2012-05-11 11:20:27 +02:00
Michel Roux 066fa619c9 debug at true to display error with config file 2012-05-11 10:15:30 +02:00
Michel Roux 8d49e0ecc0 NPE when import from PermissionsBukkit (1.7.1) 2012-05-11 10:01:18 +02:00
Michel Roux 0ad58581d8 Give the default name group in p player groups 2012-05-10 14:50:44 +02:00
Michel Roux f1817a636d Somes changes in README 2012-05-10 12:15:29 +02:00
Michel Roux b9de5e5353 Remove donation link 2012-05-10 12:07:58 +02:00
Michel Roux d8f2fd5c3c Test Image in GitHub 2012-05-10 12:01:11 +02:00
14 changed files with 211 additions and 38 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
.settings
/bin
.git
*.class

View File

@ -1,11 +1,10 @@
SimplyPerms
===========
![](http://dev.bukkit.org/media/images/40/348/simplyperms3.png)
### *When powerful plugin made Permissions easy !*
SimplyPerms is yet another Permissions plugin manager based on PermissionsBukkit ideas with the new Configuration API.
SimplyPerms is yet another Permissions plugin manager based on PermissionsBukkit ideas with some new really great features !
**WARNING : SimplyPerms is not compatible with PermissionsBukkit or other permissions plugins, SimplyPerms will disable all permissions plugins !**
**WARNING : SimplyPerms is not compatible with PermissionsBukkit or other permissions plugins !**
## [Commands][2]
@ -21,10 +20,44 @@ Please refer to the [PermissionsBukkit documentation][5]
An example configuration file [can be found here][6]
For the database connection, [please refer to this page][7]
## Add-ons
### [SimplyWrap][10]
This make plugins based on PermissionsBukkit API compatible with SimplyPerms.
[You can download it here.][10]
*Not all PermissionsBukkit plugin will work with this ! Try and give me your feedbacks !*
### [SimplyRank][14]
This allow you to use the rank feature with SimplyPerms.
[You can download it here.][14]
With this you can allow someone to grant someone else on a specified group.
Commands :
* /rank [player] [group]
* /ranker [player] [group]
* /setrank [player] [group]
Permission :
* permissions.rank.[groupname]
## [Source code][11]
All my work is available in GitHub :
**[SimplyPerms][11]** / *[SimplyWrap][12] / [SimplyRank][15]*
## Thanks
* [PermissionsBukkit][8] by SpaceManiac for core permissions code
* [AntiGuest][9] by QuickWango for part of authorizations feature
* [milkywayz][16] for the modified PermissionsBukkit to include rank feature
## Todo
@ -32,9 +65,11 @@ For the database connection, [please refer to this page][7]
* Import from other Permissions Plugins
* **Feel free to ask me new features, improvements or bugs :D**
## Donations
## [Donate][13]
I make my plugins with my free time and for free, if you like my work, you can buy me a coffee :D
I make my plugins with my free time and for free, if you like my work, [you can buy me a coffee][13] :D
[![](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)][13]
[2]: http://dev.bukkit.org/server-mods/simplyperms/pages/commands/
[3]: http://dev.bukkit.org/server-mods/simplyperms/pages/permissions-and-authorizations/
@ -44,3 +79,10 @@ I make my plugins with my free time and for free, if you like my work, you can b
[7]: http://dev.bukkit.org/server-mods/simplyperms/pages/database-connection/
[8]: http://dev.bukkit.org/server-mods/permbukkit/
[9]: http://dev.bukkit.org/server-mods/antiguest/
[10]: https://github.com/downloads/Xefir/SimplyWrap/SimplyWrap.jar
[11]: https://github.com/Xefir/SimplyPerms
[12]: https://github.com/Xefir/SimplyWrap
[13]: https://github.com/downloads/Xefir/SimplyPerms/donate.html
[14]: https://github.com/downloads/Xefir/SimplyRank/SimplyRank.jar
[15]: https://github.com/Xefir/SimplyRank
[16]: https://github.com/milkywayz/PermissionsBukkit

15
donate.html Normal file
View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>&nbsp;</title>
</head>
<body onload="document.getElementById('form').submit()">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="form">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="FQ8F4D7JZRPS2">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
</form>
</body>
</html>

View File

@ -18,7 +18,7 @@ db:
value: value
date: date
users:
ConspiracyWizard:
conspiracywizard:
permissions:
permissions.example: true
groups:

View File

@ -16,46 +16,61 @@ public class SimplyAPI implements PermsConfig {
@Override
public void removePlayer(String player) {
plugin.config.removePlayer(player);
plugin.refreshPlayerPermissions(player);
}
@Override
public void removePlayerGroups(String player) {
plugin.config.removePlayerGroups(player);
plugin.refreshPlayerPermissions(player);
}
@Override
public void removePlayerGroup(String player, String group) {
plugin.config.removePlayerGroup(player, group);
plugin.refreshPlayerPermissions(player);
}
@Override
public void setPlayerGroup(String player, String group) {
plugin.config.setPlayerGroup(player, group);
plugin.refreshPlayerPermissions(player);
}
@Override
public void addPlayerGroup(String player, String group) {
plugin.config.addPlayerGroup(player, group);
plugin.refreshPlayerPermissions(player);
}
@Override
public void addPlayerPermission(String player, String permission, boolean value) {
plugin.config.addPlayerPermission(player, permission, value);
plugin.refreshPlayerPermissions(player);
}
@Override
public void addPlayerPermission(String player, String world, String permission, boolean value) {
plugin.config.addPlayerPermission(player, world, permission, value);
plugin.refreshPlayerPermissions(player);
}
@Override
public void removePlayerPermissions(String player) {
plugin.config.removePlayerPermissions(player);
plugin.refreshPlayerPermissions(player);
}
@Override
public void removePlayerPermission(String player, String permission) {
plugin.config.removePlayerPermission(player, permission);
plugin.refreshPlayerPermissions(player);
}
@Override
public void removePlayerPermission(String player, String world, String permission) {
plugin.config.removePlayerPermission(player, world, permission);
plugin.refreshPlayerPermissions(player);
}
@Override
@ -111,16 +126,19 @@ public class SimplyAPI implements PermsConfig {
@Override
public void addGroupInheritance(String group, String inherit) {
plugin.config.addGroupInheritance(group, inherit);
refreshPermissions();
}
@Override
public void removeGroupInheritance(String group, String inherit) {
plugin.config.removeGroupInheritance(group, inherit);
refreshPermissions();
}
@Override
public void removeGroupInheritances(String group) {
plugin.config.removeGroupInheritances(group);
refreshPermissions();
}
@Override
@ -136,31 +154,37 @@ public class SimplyAPI implements PermsConfig {
@Override
public void addGroupPermission(String group, String world, String permission, boolean value) {
plugin.config.addGroupPermission(group, world, permission, value);
refreshPermissions();
}
@Override
public void addGroupPermission(String group, String permission, boolean value) {
plugin.config.addGroupPermission(group, permission, value);
refreshPermissions();
}
@Override
public void removeGroupPermission(String group, String world, String permission) {
plugin.config.removeGroupPermission(group, world, permission);
refreshPermissions();
}
@Override
public void removeGroupPermission(String group, String permission) {
plugin.config.removeGroupPermission(group, permission);
refreshPermissions();
}
@Override
public void removeGroupPermissions(String group) {
plugin.config.removeGroupPermissions(group);
refreshPermissions();
}
@Override
public void removeGroup(String group) {
plugin.config.removeGroup(group);
refreshPermissions();
}
@Override
@ -176,11 +200,13 @@ public class SimplyAPI implements PermsConfig {
@Override
public void addMessage(String key, String message) {
plugin.config.addMessage(key, message);
plugin.refreshConfig();
}
@Override
public void removeMessage(String key) {
plugin.config.removeMessage(key);
plugin.refreshConfig();
}
@Override
@ -191,6 +217,7 @@ public class SimplyAPI implements PermsConfig {
@Override
public void setDefaultGroup(String group) {
plugin.config.setDefaultGroup(group);
refreshPermissions();
}
@Override
@ -201,6 +228,7 @@ public class SimplyAPI implements PermsConfig {
@Override
public void setDebug(boolean debug) {
plugin.config.setDebug(debug);
plugin.refreshConfig();
}
public void refreshPermissions() {

View File

@ -183,10 +183,8 @@ public class SimplyCommands implements CommandExecutor {
try {
manager.run();
plugin.refreshPermissions();
sender.sendMessage(ChatColor.GREEN + "Operation success !");
} catch (Exception e) {
plugin.reloadConfig();
sender.sendMessage(ChatColor.RED + "An error occurred ! Please check server log...");
e.printStackTrace();
}
@ -301,7 +299,7 @@ public class SimplyCommands implements CommandExecutor {
String player = split[2].toLowerCase();
if (!plugin.config.isPlayerInDB(player)) {
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.RED + " is in the default group.");
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.RED + " is in the " + plugin.config.getDefaultGroup() + " group.");
return true;
}
@ -325,7 +323,7 @@ public class SimplyCommands implements CommandExecutor {
plugin.config.addPlayerGroup(player, group);
}
plugin.refreshPermissions();
plugin.refreshPlayerPermissions(player);
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is now in " + ChatColor.WHITE + split[3] + ChatColor.GREEN + ".");
return true;
@ -341,7 +339,7 @@ public class SimplyCommands implements CommandExecutor {
}
plugin.config.addPlayerGroup(player, group);
plugin.refreshPermissions();
plugin.refreshPlayerPermissions(player);
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is now in " + ChatColor.WHITE + group + ChatColor.GREEN + ".");
return true;
@ -357,7 +355,7 @@ public class SimplyCommands implements CommandExecutor {
}
plugin.config.removePlayerGroup(player, group);
plugin.refreshPermissions();
plugin.refreshPlayerPermissions(player);
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is no longer in " + ChatColor.WHITE + group + ChatColor.GREEN + ".");
return true;
@ -372,7 +370,7 @@ public class SimplyCommands implements CommandExecutor {
}
plugin.config.removePlayer(player);
plugin.refreshPermissions();
plugin.refreshPlayerPermissions(player);
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " is no longer in config file.");
return true;
@ -390,7 +388,7 @@ public class SimplyCommands implements CommandExecutor {
}
plugin.config.addPlayerPermission(player, world, perm, value);
plugin.refreshPermissions();
plugin.refreshPlayerPermissions(player);
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " now has " + ChatColor.WHITE + perm + ChatColor.GREEN + " = " + ChatColor.WHITE + value + ChatColor.GREEN + ".");
return true;
@ -412,7 +410,7 @@ public class SimplyCommands implements CommandExecutor {
return true;
}
plugin.config.removePlayerPermission(player, world, perm);
plugin.refreshPermissions();
plugin.refreshPlayerPermissions(player);
sender.sendMessage(ChatColor.GREEN + "Player " + ChatColor.WHITE + player + ChatColor.GREEN + " no longer has " + ChatColor.WHITE + perm + ChatColor.GREEN + " set.");
return true;

View File

@ -92,8 +92,7 @@ public class SimplyPlugin extends JavaPlugin {
}
private void initDatabase() {
if (getConfig().getString("db/type") != null
&& !getConfig().getString("db/type").equals("file")) {
if (!getConfig().getString("db/type", "file").equals("file")) {
ConfigSQL configsql = new ConfigSQL(this);
if (configsql.checkDatabase()) {
config = configsql;
@ -146,20 +145,29 @@ public class SimplyPlugin extends JavaPlugin {
}
}
protected void refreshPermissions() {
protected void refreshConfig() {
try {
getConfig().save(configFile);
reloadConfig();
} catch (IOException e) {
getLogger().warning("Failed to write changed config.yml: " + e.getMessage());
}
for (String player : permissions.keySet()) {
PermissionAttachment attachment = permissions.get(player);
for (String key : attachment.getPermissions().keySet()) {
attachment.unsetPermission(key);
}
}
calculateAttachment(getServer().getPlayer(player));
protected void refreshPlayerPermissions(String player) {
refreshConfig();
if (getServer().getPlayer(player) == null) return;
PermissionAttachment attachment = permissions.get(getServer().getPlayer(player).getName());
for (String key : attachment.getPermissions().keySet()) {
attachment.unsetPermission(key);
}
calculateAttachment(getServer().getPlayer(player));
}
protected void refreshPermissions() {
refreshConfig();
for (String player : permissions.keySet()) {
refreshPlayerPermissions(player);
}
}

View File

@ -30,6 +30,7 @@ public abstract class SimplyPrevents implements Listener {
"chat.Chat",
"chat.CapsLock",
"chat.Flood",
"chat.Macros",
"craft.Brew",
"craft.Chest",
"craft.Dispenser",
@ -70,9 +71,11 @@ public abstract class SimplyPrevents implements Listener {
long current = System.currentTimeMillis();
if (next.longValue() < current) {
player.sendMessage(plugin.config.getMessage(node));
plugin.debug("Event '" + node + "' cancelled for " + player.getName());
throttleTimestamps.put(player, Long.valueOf(current + 3000));
if (!plugin.config.getMessage(node).isEmpty()) {
player.sendMessage(plugin.config.getMessage(node));
plugin.debug("Event '" + node + "' cancelled for " + player.getName());
throttleTimestamps.put(player, Long.valueOf(current + 3000));
}
}
}

View File

@ -31,8 +31,10 @@ public class ImportPermBukkit extends SimplyAPI implements ImportManager {
addPlayerGroup(player, group);
}
for (Entry<String, Object> perm : permBukkit.getConfigurationSection("users/" + player + "/permissions").getValues(false).entrySet()) {
addPlayerPermission(player, perm.getKey(), (Boolean) perm.getValue());
if (permBukkit.getConfigurationSection("users/" + player + "/permissions") != null) {
for (Entry<String, Object> perm : permBukkit.getConfigurationSection("users/" + player + "/permissions").getValues(false).entrySet()) {
addPlayerPermission(player, perm.getKey(), (Boolean) perm.getValue());
}
}
for (String world : plugin.getKeys(permBukkit, "users/" + player + "/worlds")) {
@ -43,8 +45,10 @@ public class ImportPermBukkit extends SimplyAPI implements ImportManager {
}
for (String group : plugin.getKeys(permBukkit, "groups")) {
for (Entry<String, Object> perms : permBukkit.getConfigurationSection("groups/" + group + "/permissions").getValues(false).entrySet()) {
addGroupPermission(group, perms.getKey(), (Boolean) perms.getValue());
if (permBukkit.getConfigurationSection("groups/" + group + "/permissions") != null) {
for (Entry<String, Object> perms : permBukkit.getConfigurationSection("groups/" + group + "/permissions").getValues(false).entrySet()) {
addGroupPermission(group, perms.getKey(), (Boolean) perms.getValue());
}
}
for (String world : plugin.getKeys(permBukkit, "groups/" + group + "/worlds")) {

View File

@ -18,23 +18,33 @@ public class ConfigFile implements PermsConfig {
@Override
public void removePlayer(String player) {
player = player.toLowerCase();
plugin.getConfig().set("users/" + player, null);
}
@Override
public void removePlayerGroups(String player) {
player = player.toLowerCase();
plugin.getConfig().set("users/" + player + "/groups", null);
}
@Override
public void removePlayerGroup(String player, String group) {
player = player.toLowerCase();
List<String> groups = getPlayerGroups(player);
groups.remove(group);
plugin.getConfig().set("users/" + player + "/groups", (groups.isEmpty()) ? null : groups);
}
@Override
public void setPlayerGroup(String player, String group) {
removePlayerGroups(player);
addPlayerGroup(player, group);
}
@Override
public void addPlayerGroup(String player, String group) {
player = player.toLowerCase();
if (group.isEmpty()) return;
List<String> groups = getPlayerGroups(player);
if (!groups.contains(group)) groups.add(group);
@ -48,6 +58,7 @@ public class ConfigFile implements PermsConfig {
@Override
public void addPlayerPermission(String player, String world, String permission, boolean value) {
player = player.toLowerCase();
Map<String, Boolean> permissions = getPlayerPermissions(player, world);
if (permissions.containsKey(permission)) permissions.remove(permission);
permissions.put(permission, value);
@ -61,6 +72,7 @@ public class ConfigFile implements PermsConfig {
@Override
public void removePlayerPermissions(String player) {
player = player.toLowerCase();
plugin.getConfig().set("users/" + player + "/permissions", null);
}
@ -71,6 +83,7 @@ public class ConfigFile implements PermsConfig {
@Override
public void removePlayerPermission(String player, String world, String permission) {
player = player.toLowerCase();
Map<String, Boolean> permissions = getPlayerPermissions(player, world);
permissions.remove(permission);
if (!world.isEmpty()) {
@ -96,6 +109,7 @@ public class ConfigFile implements PermsConfig {
@Override
public List<String> getPlayerGroups(String player) {
player = player.toLowerCase();
return plugin.getConfig().getStringList("users/" + player + "/groups");
}
@ -106,11 +120,12 @@ public class ConfigFile implements PermsConfig {
@Override
public Map<String, Boolean> getPlayerPermissions(String player, String world) {
player = player.toLowerCase();
Map<String, Boolean> finalPerms = new LinkedHashMap<String, Boolean>();
String permNode = (!world.isEmpty()) ? "users/" + player + "/worlds/" + world : "users/" + player + "/permissions";
if (plugin.getNode(permNode) != null) {
for (Entry<String, Object> permPlayer : plugin.getNode(permNode).getValues(false).entrySet()) {
finalPerms.put(permPlayer.getKey(), (Boolean) permPlayer.getValue());
finalPerms.put(permPlayer.getKey(), Boolean.valueOf(permPlayer.getValue().toString()));
}
}
return finalPerms;
@ -118,11 +133,13 @@ public class ConfigFile implements PermsConfig {
@Override
public boolean isPlayerInDB(String player) {
player = player.toLowerCase();
return plugin.getNode("users/" + player) != null;
}
@Override
public List<String> getPlayerWorlds(String player) {
player = player.toLowerCase();
if (plugin.getNode("users/" + player + "/worlds") != null) {
return new ArrayList<String>(plugin.getNode("users/" + player + "/worlds").getKeys(false));
}
@ -197,7 +214,7 @@ public class ConfigFile implements PermsConfig {
String permNode = (!world.isEmpty()) ? "groups/" + group + "/worlds/" + world : "groups/" + group + "/permissions";
if (plugin.getNode(permNode) != null) {
for (Entry<String, Object> permGroup : plugin.getNode(permNode).getValues(false).entrySet()) {
finalPerms.put(permGroup.getKey(), (Boolean) permGroup.getValue());
finalPerms.put(permGroup.getKey(), Boolean.valueOf(permGroup.getValue().toString()));
}
}
return finalPerms;
@ -268,7 +285,7 @@ public class ConfigFile implements PermsConfig {
@Override
public String getMessage(String key) {
return plugin.getConfig().getString("messages/" + key, plugin.getConfig().getString("messages/all")).replace('&', '\u00A7');
return plugin.getConfig().getString("messages/" + key, plugin.getConfig().getString("messages/all", "")).replace('&', '\u00A7');
}
@Override
@ -298,7 +315,7 @@ public class ConfigFile implements PermsConfig {
@Override
public boolean getDebug() {
return plugin.getConfig().getBoolean("debug", false);
return plugin.getConfig().getBoolean("debug", true);
}
@Override

View File

@ -113,6 +113,12 @@ public class ConfigSQL implements PermsConfig {
}
}
@Override
public void setPlayerGroup(String player, String group) {
removePlayerGroups(player);
addPlayerGroup(player, group);
}
private void addPlayerGroup(String player, String group, boolean first) {
if (init()) {
try {

View File

@ -11,6 +11,8 @@ public interface PermsConfig {
public void removePlayerGroup(String player, String group);
public void setPlayerGroup(String player, String group);
public void addPlayerGroup(String player, String group);
public void addPlayerPermission(String player, String permission, boolean value);

View File

@ -0,0 +1,45 @@
package net.crystalyx.bukkit.simplyperms.preventions.chat;
import java.util.HashMap;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import net.crystalyx.bukkit.simplyperms.SimplyPlugin;
import net.crystalyx.bukkit.simplyperms.SimplyPrevents;
public class Macros extends SimplyPrevents {
private HashMap<Player, Long> commandsTimestamps = new HashMap<Player, Long>();
public Macros(SimplyPlugin plugin) {
super(plugin);
}
@EventHandler(priority = EventPriority.LOW)
public void chat(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer();
if (isChatLocked(player)) {
prevent(event, player, "macros,spam");
} else {
setChatLock(player);
}
}
private void setChatLock(Player player) {
commandsTimestamps.put(player, Long.valueOf(System.currentTimeMillis() + 2000));
}
private boolean isChatLocked(Player player) {
Long nextPossible = commandsTimestamps.get(player);
if (nextPossible == null) {
return false;
}
long currentTime = System.currentTimeMillis();
return nextPossible.longValue() >= currentTime;
}
}

View File

@ -1,8 +1,9 @@
name: SimplyPerms
main: net.crystalyx.bukkit.simplyperms.SimplyPlugin
author: Xefir Destiny
website: http://www.crystalyx.net/
version: 1.7
website: http://dev.bukkit.org/server-mods/simplyperms/
version: 1.7.6
dscription: When powerful plugin made Permissions easy !
softdepend: [ PermissionsBukkit ]
commands:
permissions:
@ -252,10 +253,13 @@ permissions:
children:
permissions.allow.capslock: true
permissions.allow.flood: true
permissions.allow.macros: true
permissions.allow.capslock:
description: ALLOWS THE PLAYER TO USE CAPSLOCK
permissions.allow.flood:
description: Allows the player to chat as fast as he wants
permissions.allow.macros:
description: Allows the player to spam commands
permissions.allow.projectile:
description: Allows the player to throw items
children: