New message system and rewrite preventions
This commit is contained in:
parent
15b4508421
commit
f39abd23b3
@ -168,6 +168,11 @@ public class SimplyAPI implements PermsConfig {
|
||||
return plugin.config.getMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage(String key) {
|
||||
return plugin.config.getMessage(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessage(String key, String message) {
|
||||
plugin.config.addMessage(key, message);
|
||||
|
@ -63,25 +63,21 @@ public abstract class SimplyPrevents implements Listener {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void sendMessage(Player player, String message) {
|
||||
public void sendMessage(Player player, String node) {
|
||||
Long next = throttleTimestamps.get(player);
|
||||
next = Long.valueOf(next == null ? 0 : next.longValue());
|
||||
long current = System.currentTimeMillis();
|
||||
|
||||
if (next.longValue() < current) {
|
||||
player.sendMessage(message);
|
||||
player.sendMessage(plugin.config.getMessage(node));
|
||||
plugin.debug("Event '" + node + "' cancelled for " + player.getName());
|
||||
throttleTimestamps.put(player, Long.valueOf(current + 3000));
|
||||
}
|
||||
}
|
||||
|
||||
private void deny(Cancellable event, Player player, String node) {
|
||||
event.setCancelled(true);
|
||||
if (plugin.getConfig().getString("messages/" + node) != null) {
|
||||
sendMessage(player, plugin.getConfig().getString("messages/" + node).replace('&', '\u00A7'));
|
||||
} else if (plugin.getConfig().getString("messages/all") != null) {
|
||||
sendMessage(player, plugin.getConfig().getString("messages/all").replace('&', '\u00A7'));
|
||||
}
|
||||
plugin.debug("Event '" + node + "' cancelled for " + player.getName());
|
||||
sendMessage(player, node);
|
||||
}
|
||||
|
||||
protected boolean prevent(Cancellable event, Player player, String node) {
|
||||
|
@ -266,6 +266,11 @@ public class ConfigFile implements PermsConfig {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage(String key) {
|
||||
return plugin.getConfig().getString("messages/" + key, plugin.getConfig().getString("messages/all")).replace('&', '\u00A7');
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessage(String key, String message) {
|
||||
Map<String, Object> messages = getMessages();
|
||||
|
@ -404,6 +404,11 @@ public class ConfigSQL implements PermsConfig {
|
||||
return config.getMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage(String key) {
|
||||
return config.getMessage(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessage(String key, String message) {
|
||||
config.addMessage(key, message);
|
||||
|
@ -67,6 +67,8 @@ public interface PermsConfig {
|
||||
|
||||
public Map<String, Object> getMessages();
|
||||
|
||||
public String getMessage(String key);
|
||||
|
||||
public void addMessage(String key, String message);
|
||||
|
||||
public void removeMessage(String key);
|
||||
|
Loading…
Reference in New Issue
Block a user