Ban and mute support, commands included.

This commit is contained in:
lare96
2015-09-02 09:22:33 -04:00
parent 5376b08161
commit c3ebfb46a8
5 changed files with 100 additions and 1 deletions
@@ -162,6 +162,10 @@ public final class BinaryPlayerSerializer extends PlayerSerializer {
Map<String, Attribute<?>> attributes = readAttributes(in);
attributes.forEach(player::setAttribute);
if (player.isBanned()) {
return new PlayerLoaderResponse(LoginConstants.STATUS_ACCOUNT_DISABLED);
}
return new PlayerLoaderResponse(LoginConstants.STATUS_OK, player);
}
@@ -23,6 +23,10 @@ public final class ChatMessageHandler extends MessageHandler<ChatMessage> {
@Override
public void handle(Player player, ChatMessage message) {
if (player.isMuted()) {
message.terminate();
return;
}
player.getBlockSet().add(SynchronizationBlock.createChatBlock(player, message));
}
@@ -19,7 +19,6 @@ import org.apollo.game.message.impl.UpdateRunEnergyMessage;
import org.apollo.game.model.Appearance;
import org.apollo.game.model.Position;
import org.apollo.game.model.World;
import org.apollo.game.model.World.RegistrationStatus;
import org.apollo.game.model.entity.attr.Attribute;
import org.apollo.game.model.entity.attr.AttributeDefinition;
import org.apollo.game.model.entity.attr.AttributeMap;
@@ -65,9 +64,14 @@ import com.google.common.base.Preconditions;
public final class Player extends Mob {
static {
// TODO this should be a time rather than a flag
AttributeMap.define("muted", AttributeDefinition.forBoolean(false, AttributePersistence.PERSISTENT));
AttributeMap.define("banned", AttributeDefinition.forBoolean(false, AttributePersistence.PERSISTENT));
AttributeMap.define("run_energy", AttributeDefinition.forInt(100, AttributePersistence.PERSISTENT));
}
/**
* This player's bank.
*/
@@ -457,6 +461,22 @@ public final class Player extends Mob {
return energy.getValue();
}
/**
* Returns if this player is banned or not.
*/
public boolean isBanned() {
Attribute<Boolean> banned = attributes.get("banned");
return banned.getValue();
}
/**
* Returns if this player is muted or not.
*/
public boolean isMuted() {
Attribute<Boolean> muted = attributes.get("muted");
return muted.getValue();
}
/**
* Gets this player's {@link ScreenBrightness}.
*
@@ -719,6 +739,10 @@ public final class Player extends Mob {
send(new IdAssignmentMessage(index, members));
sendMessage("Welcome to RuneScape.");
if (isMuted()) {
sendMessage("You are currently muted. Other players will not see your chat messages.");
}
int[] tabs = InterfaceConstants.DEFAULT_INVENTORY_TABS;
for (int tab = 0; tab < tabs.length; tab++) {
send(new SwitchTabInterfaceMessage(tab, tabs[tab]));