Skip to content

Commit

Permalink
1.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mastercoms committed Dec 25, 2014
1 parent 9ec36ac commit 95944de
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 24 deletions.
Binary file modified Slack.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>us.circuitsoft.slack</groupId>
<artifactId>Slack</artifactId>
<version>1.4.1</version>
<version>1.4.2</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -36,4 +36,4 @@
<scope>provided</scope>
</dependency>
</dependencies>
</project>
</project>
20 changes: 7 additions & 13 deletions src/main/java/us/circuitsoft/slack/bukkit/SlackBukkit.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,28 @@ public void onDisable() {

@EventHandler(priority = EventPriority.MONITOR)
public void onChat(AsyncPlayerChatEvent event) {
if (hasPermission("slack.hide.chat", event.getPlayer())) {
if (isVisible("slack.hide.chat", event.getPlayer())) {
send('"' + event.getMessage() + '"', event.getPlayer().getName());
}
}

@EventHandler(priority = EventPriority.MONITOR)
public void onLogin(PlayerJoinEvent event) {
if (hasPermission("slack.hide.login", event.getPlayer())) {
if (isVisible("slack.hide.login", event.getPlayer())) {
send("logged in", event.getPlayer().getName());
}
}

@EventHandler(priority = EventPriority.MONITOR)
public void onQuit(PlayerQuitEvent event) {
if (hasPermission("slack.hide.logout", event.getPlayer())) {
if (isVisible("slack.hide.logout", event.getPlayer())) {
send("logged out", event.getPlayer().getName());
}
}

@EventHandler(priority = EventPriority.MONITOR)
public void onCommand(PlayerCommandPreprocessEvent event) {
if (isOnBlacklist(event.getMessage()) && hasPermission("slack.hide.command", event.getPlayer()) && !event.getMessage().contains("/slack send")) {
if (isAllowed(event.getMessage()) && isVisible("slack.hide.command", event.getPlayer())) {
send(event.getMessage(), event.getPlayer().getName());
}
}
Expand All @@ -73,9 +73,9 @@ public void send(String message, String name, String iconUrl) {
new SlackBukkitPoster(this, message, name, iconUrl).runTaskAsynchronously(this);
}

private boolean isOnBlacklist(String name) {
private boolean isAllowed(String command) {
if (getConfig().getBoolean("use-blacklist")) {
return !blacklist.contains(name);
return !blacklist.contains(command);
} else {
return true;
}
Expand All @@ -88,20 +88,14 @@ private void updateConfig(String version) {
saveConfig();
}

private boolean hasPermission(String permission, Player player) {
private boolean isVisible(String permission, Player player) {
if (getConfig().getBoolean("use-perms")) {
return !player.hasPermission(permission);
} else {
return true;
}
}

public void execute(String token, String command) {
if (token == null ? getConfig().getString("token") == null : token.equals(getConfig().getString("token"))) {
getServer().dispatchCommand(getServer().getConsoleSender(), command);
}
}

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!cmd.getName().equalsIgnoreCase("slack")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;

import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.json.simple.JSONObject;

import static us.circuitsoft.slack.bukkit.SlackBukkit.getWebhookUrl;

/**
Expand Down Expand Up @@ -53,8 +51,8 @@ public void run() {
webhookConnection.disconnect();
if (plugin.getConfig().getBoolean("debug")) {
plugin.getLogger().log(Level.INFO, "{0} {1}", new Object[]{
webhookConnection.getResponseCode(),
webhookConnection.getResponseMessage()
webhookConnection.getResponseCode(),
webhookConnection.getResponseMessage()
});
}
} catch (MalformedURLException e) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/bungee.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Slack
main: us.circuitsoft.slack.bungee.SlackBungee
version: 1.4.1
author: CircuitSoft
version: 1.4.2
author: CircuitSoft
4 changes: 2 additions & 2 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#The version. Do not touch this.
version: 1.4.1
version: 1.4.2
#The incoming webhook URL you got from Slack.
webhook: https://hooks.slack.com/services/
#Show HTTP response codes in console
Expand All @@ -11,4 +11,4 @@ use-blacklist: false
#Commands that will not show up in Slack when they are executed.
blacklist:
- /login
- /register
- /register
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Slack
version: 1.4.1
version: 1.4.2
description: Link your server to Slack!
author: CircuitSoft
authors: [Janmm14, LaxWasHere, it3d]
Expand Down

0 comments on commit 95944de

Please sign in to comment.