RuneHive-Game
Loading...
Searching...
No Matches
Yell.java
Go to the documentation of this file.
1package com.runehive.content;
2
3import com.runehive.game.world.World;
4import com.runehive.game.world.entity.mob.player.Player;
5import com.runehive.game.world.entity.mob.player.PlayerRight;
6import com.runehive.net.packet.out.SendMessage;
7import com.runehive.util.Utility;
8
9import java.util.Arrays;
10
11/**
12 * Handles the yelling command.
13 *
14 * @author Daniel
15 */
16public class Yell {
17
18 /** Array of all invalid strings. */
19 public static final String[] INVALID = {
20 ".com", "@cr", "<img=", "</col", "<col=",
21 "@whi@", "@blu@", "@gre@", "@red@",
22 "@mag@", "@cya@"
23 };
24
25 /** Yells a message to the server. */
26 public static void yell(Player player, String message) {
27 if (!PlayerRight.isDonator(player) && !PlayerRight.isHelper(player) && !PlayerRight.isOwner(player)) {
28 player.send(new SendMessage("You must be a donator to use this command!"));
29 return;
30 }
31
32 if (!player.settings.yell) {
33 player.send(new SendMessage("You can not send a yell message as you have the yell setting disabled!"));
34 return;
35 }
36
37 if (player.punishment.isMuted()) {
38 player.message("You are muted and can not yell!");
39 return;
40 }
41
42 if (player.punishment.isJailed()) {
43 player.message("You are jailed and can not yell!");
44 return;
45 }
46
47
48 if (Arrays.stream(INVALID).anyMatch(message::contains)) {
49 player.send(new SendMessage("Your message contains invalid characters."));
50 return;
51 }
52 final String prefix = "[<col=" + player.right.getColor() + ">" + player.right.getName() + "</col>] <col=" + player.right.getColor() + ">" + player.getName();
53 final String formatted_message = prefix + "</col>: " + Utility.capitalizeSentence(message);
54 World.sendMessage(formatted_message, exception -> exception.settings.yell);
55 System.out.println("Yell" +formatted_message);
56 }
57}
Handles the yelling command.
Definition Yell.java:16
static void yell(Player player, String message)
Yells a message to the server.
Definition Yell.java:26
static final String[] INVALID
Array of all invalid strings.
Definition Yell.java:19
Represents the game world.
Definition World.java:46
static void sendMessage(String... messages)
Sends a global message.
Definition World.java:396
This class represents a character controlled by a player.
Definition Player.java:125
String getName()
Gets the name of this entity.
Definition Player.java:774
The OutgoingPacket that sends a message to a Players chatbox in the client.
Handles miscellaneous methods.
Definition Utility.java:27
static String capitalizeSentence(final String string)
Capitalize each letter after .
Definition Utility.java:99
static boolean isDonator(Player player)
Checks if the player has donator status.
static boolean isHelper(Player player)
Checks if the player is a HELPER member.