Jump to content
Sign in to follow this  
Dally

[PI] Simple Message Coloring System

Recommended Posts

Made this and posted it at Rune-Server. 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: [COLOR=#ff0000]RED [/COLOR][COLOR=#0000ff]BLUE [/COLOR][COLOR=#ffd700]YELLOW [/COLOR][COLOR=#ffa500]ORANGE [/COLOR][COLOR=#800080]PURPLE [/COLOR][COLOR=#ffffff]WHITE [/COLOR][COLOR=#000000]BLACK[/COLOR]

[B]NEW CODE: [/B]
Slight adjustments, such as crowns and a better way of using colors.

Message.java
[CODE]
/**
* [MENTION=117450]Des[/MENTION]cription Uses the stream to send new messages using color and/or crown icons
* [MENTION=11342]Tit[/MENTION]le Message.java
* @author iExample, Devo and GTFO
* [MENTION=3812]Link[/MENTION] [url]http://www.rune-server.org/[/url]
*/

public class Message {

/**
* Sends message with crowns or color.
* [MENTION=75098]Para[/MENTION]m c
* [MENTION=75098]Para[/MENTION]m color
* [MENTION=75098]Para[/MENTION]m message
* [MENTION=75098]Para[/MENTION]m rankIcons
* [MENTION=75098]Para[/MENTION]m crownNumber
* [MENTION=184045]return[/MENTION]
*/
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.
* [MENTION=75098]Para[/MENTION]m crownNumber
* [MENTION=184045]return[/MENTION]
*/
public static MessageCrowns getCrown(int crownNumber) {
return getCrown(crownNumber);
}

/**
* Colors.
* [MENTION=75098]Para[/MENTION]m color
* [MENTION=184045]return[/MENTION]
*/
public static MessageColor getColor(String color) {
return getColor(color);
}
}
[/CODE]

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;
}

}
[/CODE]

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;
}
}
[/CODE]

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);
[/CODE]

[B]OLD LAME CODE:[/B]

[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;
}

}
[/CODE]

Use:
[CODE]
Message.out(c, Message.RED, "Your message goes here");
[/CODE][COLOR=#000000]
[/COLOR]

Share this post


Link to post
Share on other sites
nice contribution im sure someone will have use for this. good job :)

Share this post


Link to post
Share on other sites
mmm Thanks, i just was searching for this :P

Share this post


Link to post
Share on other sites

Join Snow317 , open 24.7 , Cant post the link because dont wanna be banned.

But google us and check us out! Tons of updates daily, And im a active Mainowner! See you ingame! Maybe get a reward if you see this! ;):)

-Snow *MainOwner of Snow317org*

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×