Havent really been on in a while and started to get back into RSPS. Anyways, this took me about 5 minutes to write. Its nothing fancy and it's simple as the title says, it works and could be useful. Its not much of a system...but we'll consider it as one
Colors: RED BLUE YELLOW ORANGE PURPLE WHITE BLACK
NEW CODE:
Slight adjustments, such as crowns and a better way of using colors.
Message.java
Code:
/**
* @description Uses the stream to send new messages using color and/or crown icons
* @title Message.java
* @author iExample
* @link http://www.rune-server.org/
*/
public class Message {
/**
* Sends message with crowns or color.
* @param c
* @param color
* @param message
* @param rankIcons
* @param crownNumber
* @return
*/
public static boolean out(Client c, String color, String message, int crownNumber, boolean rankIcons) {
if (c.getOutStream() != null) {
c.outStream.createFrameVarSize(253);
if(rankIcons == true) {
c.outStream.writeString("<img="+getCrown(crownNumber)+"><col="+getColor(color)+">"+message+"</col>");
} else {
c.outStream.writeString("<col="+getColor(color)+">"+message+"</col>");
}
c.outStream.endFrameVarSize();
}
return false;
}
/**
* Crowns.
* @param crownNumber
* @return
*/
public static MessageCrowns getCrown(int crownNumber) {
return getCrown(crownNumber);
}
/**
* Colors.
* @param color
* @return
*/
public static MessageColor getColor(String color) {
return getColor(color);
}
}
MessageColor.java
Code:
package server.world.messages;
public enum MessageColor {
RED("FF0000"),
GREEN("00FF00"),
YELLOW("FFFF00"),
BLUE("0000FF"),
ORANGE("FF7F00"),
PURPLE("800080"),
WHITE("FFFFFF"),
BLACK("0"),
CYAN("65535"),
LIME("65280"),
GREY("808080");
private String hex;
private MessageColor(String color) {
this.hex = color;
}
public String getColor() {
return this.hex;
}
}
MessageCrowns.java:
Code:
package server.world.messages;
public enum MessageCrowns {
/**
* You might have to update the int(s) to the correct crown id.
*/
OWNER(1),
MODERATOR(2),
DONATOR(3);
private int iconName;
private MessageCrowns(int icon) {
this.iconName = icon;
}
public int getRanking() {
return this.iconName;
}
}
Use(The boolean represents the use of crowns and the int represents the crown id):
Code:
Message.out(c, "RED", "Your message goes here", 1, true);
OLD LAME CODE:
Code:
import server.model.players.Client;
public class Message {
public final static String
RED = "ff0000",
GREEN = "00ff00",
YELLOW = "ffff00",
BLUE = "0000ff",
ORANGE = "ff7f00",
PURPLE = "800080",
WHITE = "ffffff",
GREY = "808080",
BLACK = "000000";
public static boolean out(Client player, String color, String message) {
if (player.getOutStream() != null) {
player.outStream.createFrameVarSize(253);
player.outStream.writeString("<col="+color+">"+message+"</col>");
player.outStream.endFrameVarSize();
}
return false;
}
}
Use:
Code:
Message.out(c, Message.RED, "Your message goes here");