-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
200 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
bukkit/src/main/java/io/wdsj/asw/bukkit/proxy/bungee/BungeeCordChannel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.wdsj.asw.bukkit.proxy.bungee; | ||
|
||
public class BungeeCordChannel { | ||
public static final String BUNGEE_CHANNEL = "BungeeCord"; | ||
public static final String SUB_CHANNEL = "asw"; | ||
} |
40 changes: 40 additions & 0 deletions
40
bukkit/src/main/java/io/wdsj/asw/bukkit/proxy/bungee/BungeeReceiver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.wdsj.asw.bukkit.proxy.bungee; | ||
|
||
import com.google.common.io.ByteArrayDataInput; | ||
import com.google.common.io.ByteStreams; | ||
import io.wdsj.asw.bukkit.setting.PluginMessages; | ||
import io.wdsj.asw.bukkit.setting.PluginSettings; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.plugin.messaging.PluginMessageListener; | ||
|
||
import java.util.Collection; | ||
|
||
import static io.wdsj.asw.bukkit.AdvancedSensitiveWords.messagesManager; | ||
import static io.wdsj.asw.bukkit.AdvancedSensitiveWords.settingsManager; | ||
|
||
public class BungeeReceiver implements PluginMessageListener { | ||
@Override | ||
public void onPluginMessageReceived(String channel, Player player, byte[] message) { | ||
if (channel.equals(BungeeCordChannel.BUNGEE_CHANNEL)) { | ||
ByteArrayDataInput input = ByteStreams.newDataInput(message); | ||
String subChannel = input.readUTF(); | ||
if (subChannel.equals(BungeeCordChannel.SUB_CHANNEL)) { | ||
String playerName = input.readUTF(); | ||
String eventType = input.readUTF(); | ||
String originalMessage = input.readUTF(); | ||
String serverName = input.readUTF(); | ||
if (settingsManager.getProperty(PluginSettings.NOTICE_OPERATOR)) { | ||
Collection<? extends Player> players = Bukkit.getOnlinePlayers(); | ||
String msg = ChatColor.translateAlternateColorCodes('&', messagesManager.getProperty(PluginMessages.ADMIN_REMINDER).replace("%player%", playerName + "(" + serverName + ")").replace("%type%", eventType).replace("%message%", originalMessage)); | ||
for (Player iPlayer : players) { | ||
if (iPlayer.hasPermission("advancedsensitivewords.notice")) { | ||
iPlayer.sendMessage(msg); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
bukkit/src/main/java/io/wdsj/asw/bukkit/proxy/bungee/BungeeSender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.wdsj.asw.bukkit.proxy.bungee; | ||
|
||
import com.google.common.io.ByteArrayDataOutput; | ||
import com.google.common.io.ByteStreams; | ||
import io.wdsj.asw.bukkit.AdvancedSensitiveWords; | ||
import io.wdsj.asw.bukkit.event.EventType; | ||
import org.bukkit.entity.Player; | ||
|
||
public class BungeeSender { | ||
public static void send(Player violatedPlayer, EventType eventType, String originalMessage) { | ||
ByteArrayDataOutput out = ByteStreams.newDataOutput(); | ||
out.writeUTF(BungeeCordChannel.SUB_CHANNEL); | ||
out.writeUTF(violatedPlayer.getName()); | ||
out.writeUTF(eventType.toString()); | ||
out.writeUTF(originalMessage); | ||
byte[] data = out.toByteArray(); | ||
violatedPlayer.sendPluginMessage(AdvancedSensitiveWords.getInstance(), BungeeCordChannel.BUNGEE_CHANNEL, data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 11 additions & 2 deletions
13
bungee/src/main/java/io/wdsj/asw/bungee/AdvancedSensitiveWords.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,25 @@ | ||
package io.wdsj.asw.bungee; | ||
|
||
import io.wdsj.asw.bungee.listener.PluginMessageListener; | ||
import net.md_5.bungee.api.plugin.Plugin; | ||
|
||
public final class AdvancedSensitiveWords extends Plugin { | ||
public static final String BUNGEE_CHANNEL = "BungeeCord"; | ||
public static final String SUB_CHANNEL = "asw"; | ||
|
||
private static AdvancedSensitiveWords instance; | ||
public static AdvancedSensitiveWords getInstance() { | ||
return instance; | ||
} | ||
|
||
@Override | ||
public void onEnable() { | ||
// Plugin startup logic | ||
instance = this; | ||
getProxy().getPluginManager().registerListener(this, new PluginMessageListener()); | ||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
// Plugin shutdown logic | ||
getProxy().getPluginManager().unregisterListener(new PluginMessageListener()); | ||
} | ||
} |
Oops, something went wrong.