Skip to content

Commit

Permalink
Merge pull request #24 from MultiChat/version-1.6
Browse files Browse the repository at this point in the history
Version 1.6
  • Loading branch information
OllieMartin authored Sep 18, 2018
2 parents 1d4bdfe + 6447c5c commit 5437604
Show file tree
Hide file tree
Showing 118 changed files with 4,559 additions and 1,081 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Development
The public code repo for MultiChat for BungeeCord Spigot
Binary file not shown.
6 changes: 3 additions & 3 deletions multichat/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>xyz.olivermartin.multichat</groupId>
<artifactId>multichat</artifactId>
<version>1.5.2</version>
<version>1.6</version>

<repositories>

Expand Down Expand Up @@ -49,7 +49,7 @@
<dependency>
<groupId>org.spongepowered</groupId>
<artifactId>spongeapi</artifactId>
<version>7.0.0</version>
<version>7.1.0</version>
<scope>provided</scope>
</dependency>

Expand All @@ -72,7 +72,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13-R0.1-SNAPSHOT</version>
<version>1.13.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public static boolean startAnnouncement(final String name, Integer minutes) {
@Override
public void run() {
String message = announcements.get(name.toLowerCase());

message = ChatControl.applyChatRules(message, "announcements", "").get();

for (ProxiedPlayer onlineplayer : ProxyServer.getInstance().getPlayers()) {
onlineplayer.sendMessage(TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&',message)));
Expand Down Expand Up @@ -122,6 +124,8 @@ public static void playAnnouncement(String name) {
if (announcements.containsKey(name.toLowerCase())) {

String message = announcements.get(name.toLowerCase());

message = ChatControl.applyChatRules(message, "announcements", "").get();

for (ProxiedPlayer onlineplayer : ProxyServer.getInstance().getPlayers()) {
onlineplayer.sendMessage(TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&',message)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ public void run() {
} else {

message = bulletin.get(nextBulletin);

message = ChatControl.applyChatRules(message, "bulletins", "").get();

for (ProxiedPlayer onlineplayer : ProxyServer.getInstance().getPlayers()) {
onlineplayer.sendMessage(TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&',message)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Optional;
import java.util.UUID;

import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.event.EventHandler;

/**
Expand All @@ -29,19 +32,58 @@ public static void sendMessage(String message, ServerInfo server) {
DataOutputStream out = new DataOutputStream(stream);

try {
// Players name
out.writeUTF(message);

// Should display name be set?
Configuration configYML = ConfigManager.getInstance().getHandler("config.yml").getConfig();
if (configYML.contains("set_display_name")) {
if (configYML.getBoolean("set_display_name")) {
out.writeUTF("T");
} else {
out.writeUTF("F");
}
} else {
out.writeUTF("T");
}

// Display name format
if (configYML.contains("display_name_format")) {
out.writeUTF(configYML.getString("display_name_format"));
} else {
out.writeUTF("%PREFIX%%NICK%%SUFFIX%");
}

} catch (IOException e) {
e.printStackTrace();
}

server.sendData("multichat:comm", stream.toByteArray());

}

public static void sendCommandMessage(String command, ServerInfo server) {

ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(stream);

try {

// Command
out.writeUTF(command);

} catch (IOException e) {
e.printStackTrace();
}

server.sendData("multichat:action", stream.toByteArray());

}

@EventHandler
public static void onPluginMessage(PluginMessageEvent ev) {

if (!ev.getTag().equals("multichat:comm")) {
if (! (ev.getTag().equals("multichat:comm") || ev.getTag().equals("multichat:prefix") || ev.getTag().equals("multichat:suffix") || ev.getTag().equals("multichat:nick")) ) {
return;
}

Expand All @@ -51,32 +93,150 @@ public static void onPluginMessage(PluginMessageEvent ev) {

if (ev.getTag().equals("multichat:comm")) {

return;

// ByteArrayInputStream stream = new ByteArrayInputStream(ev.getData());
// DataInputStream in = new DataInputStream(stream);
//
// try {
//
// String playerDisplayName = in.readUTF();
// String playerName = in.readUTF();
// ProxiedPlayer player = ProxyServer.getInstance().getPlayer(playerName);
//
// if (player == null) return;
//
// synchronized (player) {
//
// /*
// * TODO Add option to NOT set the bungee display name
// * (While maintaining the fetching prefixes and correct display of them)
// * (Useful for older servers where char limit in place for display names)
// */
//
// if (ConfigManager.getInstance().getHandler("config.yml").getConfig().getBoolean("fetch_spigot_display_names") == true && player != null) {
// player.setDisplayName(playerDisplayName.replaceAll("&(?=[a-f,0-9,k-o,r])", "§"));
// }
//
// }
//
// } catch (IOException e) {
// e.printStackTrace();
// }
}

if (ev.getTag().equals("multichat:nick")) {

ByteArrayInputStream stream = new ByteArrayInputStream(ev.getData());
DataInputStream in = new DataInputStream(stream);

try {

UUID uuid = UUID.fromString(in.readUTF());
String nick = in.readUTF();
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);

if (player == null) return;

synchronized (player) {

/*
* Update the nickname stored somewhere and call for an update of the player
* display name in that location. (Pending the "true" value of fetch display names)
* and a new config option to decide if the display name should be set.
*/

Optional<PlayerMeta> opm = PlayerMetaManager.getInstance().getPlayer(uuid);

if (opm.isPresent()) {

opm.get().nick = nick;
PlayerMetaManager.getInstance().updateDisplayName(uuid);

}

}

} catch (IOException e) {
e.printStackTrace();
}

}

if (ev.getTag().equals("multichat:prefix")) {

ByteArrayInputStream stream = new ByteArrayInputStream(ev.getData());
DataInputStream in = new DataInputStream(stream);

try {

UUID uuid = UUID.fromString(in.readUTF());
String prefix = in.readUTF();
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);

if (player == null) return;

synchronized (player) {

/*
* Update the prefix stored somewhere and call for an update of the player
* display name in that location. (Pending the "true" value of fetch display names)
* and a new config option to decide if the display name should be set.
*/

Optional<PlayerMeta> opm = PlayerMetaManager.getInstance().getPlayer(uuid);

if (opm.isPresent()) {

opm.get().prefix = prefix;
PlayerMetaManager.getInstance().updateDisplayName(uuid);

}

}

} catch (IOException e) {
e.printStackTrace();
}

}

if (ev.getTag().equals("multichat:suffix")) {

ByteArrayInputStream stream = new ByteArrayInputStream(ev.getData());
DataInputStream in = new DataInputStream(stream);

try {

String playerDisplayName = in.readUTF();
String playerName = in.readUTF();
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(playerName);
UUID uuid = UUID.fromString(in.readUTF());
String suffix = in.readUTF();
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);

if (player == null) return;

synchronized (player) {

/*
* TODO Add option to NOT set the bungee display name
* (While maintaining the fetching prefixes and correct display of them)
* (Useful for older servers where char limit in place for display names)
* Update the suffix stored somewhere and call for an update of the player
* display name in that location. (Pending the "true" value of fetch display names)
* and a new config option to decide if the display name should be set.
*/

if (MultiChat.configman.config.getBoolean("fetch_spigot_display_names") == true && player != null) {
player.setDisplayName(playerDisplayName.replaceAll("&(?=[a-f,0-9,k-o,r])", "§"));
Optional<PlayerMeta> opm = PlayerMetaManager.getInstance().getPlayer(uuid);

if (opm.isPresent()) {

opm.get().suffix = suffix;
PlayerMetaManager.getInstance().updateDisplayName(uuid);

}

}

} catch (IOException e) {
e.printStackTrace();
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class CastControl {
public static Map<String,String> castList = new HashMap<String,String>();

public static void sendCast(String castName, String castMessage, ChatStream chatStream) {
castMessage = ChatControl.applyChatRules(castMessage, "casts", "").get();
chatStream.sendMessage(castList.get(castName.toLowerCase()) + " " + castMessage);
}

Expand Down
Loading

0 comments on commit 5437604

Please sign in to comment.