Jump to content
Sign in to follow this  
own4g3

Yell Handler

Recommended Posts

[code]
package com.rs.game.player.content;

/**
* Handles player's yell.
* @author Raghav/Own4g3
*
*/
public enum YellHandler {

CUSTOM_YELL(new String[]{"Own4g3", "Raghav"}, new String[]{"<img=0><col=800080>[SEXY BEAST]<img=0>", "<col=ff0000>[<img=0>LOLHEY!]"}),
DONOR(null, new String[]{"<col=00ff00>[Donor]"}),
PLAYER(null, new String[]{"[Normal Player]"});

String []playerName, yellTag;

/**
* Creates a new {@code YellHandler}
* @param playerName The player's display name.
* @param yellTag Player's yell tag.
*/
YellHandler(String[] playerName, String[] yellTag) {
this.playerName = playerName;
this.yellTag = yellTag;
}

/**
* Gets the player's name.
* @return playerName
*/
public String[] getPlayerName() {
return playerName;
}

/**
* Gets the player's yell tag.
* @return yellTag
*/
public String[] yellTag() {
return yellTag;
}
}

[/code]

Now, Implement it.

[code]
for (int i = 0; i < YellHandler.CUSTOM_YELL.getPlayerName().length; i++) {
if (player.getDisplayName().contains(YellHandler.CUSTOM_YELL.getPlayerName()[i])) {
sendMessageToAll(YellHandler.CUSTOM_YELL.yellTag()[i] + YellHandler.CUSTOM_YELL.getPlayerName()[i] + ": " + message);
return;
}
}
if (player.isDonator())
sendMessageToAll(YellHandler.DONOR.yellTag()[0] + player.getDisplayName() + ": " + message);
else
sendMessageToAll(YellHandler.PLAYER.yellTag()[0] + player.getDisplayName() + " :" + message);
[/code]

[IMG]http://screensnapr.com/e/X6uwRP.png[/IMG]

This supports, custom yell for any player, donor yell and normal player's yell.

:) Edited by own4g3

Share this post


Link to post
Share on other sites
[quote name='Intensive Tony']It isn't needed but always handy thanks.[/QUOTE]

Not needed?

It's A LOT cleaner.

Share this post


Link to post
Share on other sites
Pretty sure something like...
[CODE]if(player.hasCustomYell()) {
YELL SHIT HERE
} else {
switch(player.getRights()) {
case 2:
YELL SHIT
break;
case 1:
YELL SHIT
break;
case 0:
if(player.isDonator()) {
YELL SHIT
} else {
YELL SHIT
}
}[/CODE]

All you need is a boolean for if they have a custom yell, a String which actually IS the custom yell, and that ^

Share this post


Link to post
Share on other sites
[quote name='hellman2741']Pretty sure something like...
[CODE]if(player.hasCustomYell()) {
YELL SHIT HERE
} else {
switch(player.getRights()) {
case 2:
YELL SHIT
break;
case 1:
YELL SHIT
break;
case 0:
if(player.isDonator()) {
YELL SHIT
} else {
YELL SHIT
}
}[/CODE]

All you need is a boolean for if they have a custom yell, a String which actually IS the custom yell, and that ^[/QUOTE]

For that, you'll have to save one boolean and a string for all the players which is useless imo.

It can be done in many ways.
I prefer this one. :p

Share this post


Link to post
Share on other sites
[quote name='own4g3']Not needed?

It's A LOT cleaner.[/QUOTE]

I beg to differ.

Share this post


Link to post
Share on other sites
[quote name='titandino']I beg to differ.[/QUOTE]

You are still programming, why?
I would've quit a long time ago being a fucking idiot like you.

Share this post


Link to post
Share on other sites
[quote name='lube']You are still programming, why?
I would've quit a long time ago being a fucking idiot like you.[/QUOTE]

I love ban evaders. I still program because I love to prove people like you wrong.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×