RuneHive-Game
Loading...
Searching...
No Matches
Yell.java
Go to the documentation of this file.
1
package
com.runehive.content;
2
3
import
com.runehive.game.world.World;
4
import
com.runehive.game.world.entity.mob.player.Player;
5
import
com.runehive.game.world.entity.mob.player.PlayerRight;
6
import
com.runehive.net.packet.out.SendMessage;
7
import
com.runehive.util.Utility;
8
9
import
java.util.Arrays;
10
11
/**
12
* Handles the yelling command.
13
*
14
* @author Daniel
15
*/
16
public
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
}
com.runehive.content.Yell
Handles the yelling command.
Definition
Yell.java:16
com.runehive.content.Yell.yell
static void yell(Player player, String message)
Yells a message to the server.
Definition
Yell.java:26
com.runehive.content.Yell.INVALID
static final String[] INVALID
Array of all invalid strings.
Definition
Yell.java:19
com.runehive.game.world.World
Represents the game world.
Definition
World.java:46
com.runehive.game.world.World.sendMessage
static void sendMessage(String... messages)
Sends a global message.
Definition
World.java:396
com.runehive.game.world.entity.mob.player.Player
This class represents a character controlled by a player.
Definition
Player.java:125
com.runehive.game.world.entity.mob.player.Player.message
void message(String message)
Definition
Player.java:572
com.runehive.game.world.entity.mob.player.Player.getName
String getName()
Gets the name of this entity.
Definition
Player.java:774
com.runehive.game.world.entity.mob.player.Player.settings
final Settings settings
Definition
Player.java:324
com.runehive.game.world.entity.mob.player.Player.punishment
final PlayerPunishment punishment
Definition
Player.java:334
com.runehive.game.world.entity.mob.player.Player.send
void send(OutgoingPacket encoder)
Definition
Player.java:420
com.runehive.game.world.entity.mob.player.Player.right
PlayerRight right
Definition
Player.java:216
com.runehive.game.world.entity.mob.player.Settings.yell
boolean yell
The yell flag.
Definition
Settings.java:27
com.runehive.game.world.entity.mob.player.requests.PlayerPunishment.isMuted
boolean isMuted()
Definition
PlayerPunishment.java:40
com.runehive.game.world.entity.mob.player.requests.PlayerPunishment.isJailed
boolean isJailed()
Definition
PlayerPunishment.java:58
com.runehive.net.packet.out.SendMessage
The OutgoingPacket that sends a message to a Players chatbox in the client.
Definition
SendMessage.java:14
com.runehive.util.Utility
Handles miscellaneous methods.
Definition
Utility.java:27
com.runehive.util.Utility.capitalizeSentence
static String capitalizeSentence(final String string)
Capitalize each letter after .
Definition
Utility.java:99
com.runehive.game.world.entity.mob.player.PlayerRight
Holds all the player right data.
Definition
PlayerRight.java:11
com.runehive.game.world.entity.mob.player.PlayerRight.getName
String getName()
Gets the name of the rank.
Definition
PlayerRight.java:275
com.runehive.game.world.entity.mob.player.PlayerRight.isDonator
static boolean isDonator(Player player)
Checks if the player has donator status.
Definition
PlayerRight.java:111
com.runehive.game.world.entity.mob.player.PlayerRight.getColor
static String getColor(PlayerRight right)
Definition
PlayerRight.java:164
com.runehive.game.world.entity.mob.player.PlayerRight.isHelper
static boolean isHelper(Player player)
Checks if the player is a HELPER member.
Definition
PlayerRight.java:104
com.runehive.game.world.entity.mob.player.PlayerRight.isOwner
static boolean isOwner(Player player)
Definition
PlayerRight.java:69