Jump to content
Hash

Yell handler

Recommended Posts

This is for rs2hd, you can easily convert to any other sources. Here it is:

[code]package org.thematics.util;

import org.thematics.Server;
import org.thematics.server.player.Player;
import org.thematics.server.world.World;

/**
* Class handling different rights yell.
* [MENTION=52317]auth[/MENTION]or Guillaume
*
*/

public class YellHandler {

private static boolean canYell(Player player) {
if (player.getMute()) {
player.getActionSender().sendMessage(
"You are muted, and therefore can't yell.");
return false;
}

if (Server.getFirewall().isIpMuted(player)) {
player.getActionSender()
.sendMessage(
"You are ip-muted, and therefore can't yell with any of your accounts.");
return false;
}

return true;
}

public static void handleYell(Player player, String command) {
if (!canYell(player))
return;

String yellText = command.substring(5);
yellText = Censor.replace(yellText);

for (Player players : World.getWorld().getPlayers())
if (player.getRights() == 3)
players.getActionSender()
.sendMessage(
new StringBuilder()
.append("<shad=3399FF><img=1>[Developer]<img=1>")
.append(player.getDisplayName())
.append(": ")
.append(Misc.optimizeText(yellText))
.toString());

else if (player.getRights() == 2)
players.getActionSender()
.sendMessage(
new StringBuilder()
.append("<shad=FCB514><img=1>[Administrator]")
.append(player.getDisplayName())
.append(": ")
.append(Misc.optimizeText(yellText))
.toString());

else if (player.getRights() == 1)
players.getActionSender()
.sendMessage(
new StringBuilder()
.append("<shad=A9ACB6><img=0>[Moderator]")
.append(player.getDisplayName())
.append(": ")
.append(Misc.optimizeText(yellText))
.toString());

else if (player.donator() == 1)
players.getActionSender()
.sendMessage(
new StringBuilder()
.append("<shad=458B00>[Donator]")
.append(player.getDisplayName())
.append(": ")
.append(Misc.optimizeText(yellText))
.toString());
}
}
[/code]

In CommandPacketHandler.java and CommandsPacketHandler.java, where there is yell command, put this:

[code] YellHandler.handleYell(player, command);[/code]

You can add whatever you want with it, I only made the skeleton and you do the rest yourself. Edited by Hash

Share this post


Link to post
Share on other sites
[quote name='emperor'][url]http://bit.ly/qivjmi[/url][/quote]lolololol;

Thanks, though. Looks gewd

Share this post


Link to post
Share on other sites
[quote name='Emperor'][url]http://bit.ly/QivjmI[/url][/QUOTE]

No absolute need to use static...

Share this post


Link to post
Share on other sites
[quote name='Hash']No absolute need to use static...[/QUOTE]

So you think constructing a new YellHandler instance every time someone yells is a good idea?

Share this post


Link to post
Share on other sites
Never thought that yell was used often. Pretty slow brain today I guess.

Share this post


Link to post
Share on other sites

×