Refactor player notifications

This commit is contained in:
kuroppoi 2023-01-27 21:22:35 +01:00
parent b1f6c6b369
commit 65538ef9ab
29 changed files with 120 additions and 126 deletions

View file

@ -1,6 +1,6 @@
package brainwine.gameserver.command;
import static brainwine.gameserver.entity.player.NotificationType.ALERT;
import static brainwine.gameserver.entity.player.NotificationType.SYSTEM;
import java.util.Collection;
import java.util.HashMap;
@ -108,7 +108,7 @@ public class CommandManager {
Command command = commands.getOrDefault(commandName, aliases.get(commandName));
if(command == null || !command.canExecute(executor)) {
executor.notify("Unknown command. Type '/help' for a list of commands.", ALERT);
executor.notify("Unknown command. Type '/help' for a list of commands.", SYSTEM);
return;
}

View file

@ -1,6 +1,5 @@
package brainwine.gameserver.command.commands;
import static brainwine.gameserver.entity.player.NotificationType.ALERT;
import static brainwine.gameserver.entity.player.NotificationType.SYSTEM;
import brainwine.gameserver.GameServer;
@ -13,24 +12,24 @@ public class AdminCommand extends Command {
@Override
public void execute(CommandExecutor executor, String[] args) {
if(args.length == 0) {
executor.notify(String.format("Usage: %s", getUsage(executor)), ALERT);
executor.notify(String.format("Usage: %s", getUsage(executor)), SYSTEM);
return;
}
Player target = GameServer.getInstance().getPlayerManager().getPlayer(args[0]);
if(target == null) {
executor.notify("This player does not exist.", ALERT);
executor.notify("This player does not exist.", SYSTEM);
return;
} else if(target == executor) {
executor.notify("You cannot change your own administrator status.", ALERT);
executor.notify("You cannot change your own administrator status.", SYSTEM);
return;
}
boolean admin = args.length == 1 ? true : Boolean.parseBoolean(args[1]);
if(target.isAdmin() == admin) {
executor.notify(admin ? "This player is already an administrator." : "This player is not an administrator.", ALERT);
executor.notify(admin ? "This player is already an administrator." : "This player is not an administrator.", SYSTEM);
return;
}

View file

@ -1,7 +1,6 @@
package brainwine.gameserver.command.commands;
import static brainwine.gameserver.entity.player.NotificationType.ALERT;
import static brainwine.gameserver.entity.player.NotificationType.CHAT;
import static brainwine.gameserver.entity.player.NotificationType.POPUP;
import static brainwine.gameserver.entity.player.NotificationType.SYSTEM;
import brainwine.gameserver.GameServer;
@ -14,7 +13,7 @@ public class BroadcastCommand extends Command {
@Override
public void execute(CommandExecutor executor, String[] args) {
if(args.length == 0) {
executor.notify(String.format("Usage: %s", getUsage(executor)), ALERT);
executor.notify(String.format("Usage: %s", getUsage(executor)), SYSTEM);
return;
}
@ -24,7 +23,7 @@ public class BroadcastCommand extends Command {
player.notify(text, SYSTEM);
}
executor.notify("Your message has been broadcasted.", ALERT);
executor.notify("Your message has been broadcasted.", POPUP);
}
@Override

View file

@ -1,6 +1,6 @@
package brainwine.gameserver.command.commands;
import static brainwine.gameserver.entity.player.NotificationType.ALERT;
import static brainwine.gameserver.entity.player.NotificationType.SYSTEM;
import brainwine.gameserver.command.Command;
import brainwine.gameserver.command.CommandExecutor;
@ -16,7 +16,7 @@ public class EntityCommand extends Command {
@Override
public void execute(CommandExecutor executor, String[] args) {
if(args.length == 0) {
executor.notify(String.format("Usage: %s", getUsage(executor)), ALERT);
executor.notify(String.format("Usage: %s", getUsage(executor)), SYSTEM);
return;
}
@ -25,7 +25,7 @@ public class EntityCommand extends Command {
EntityConfig config = EntityRegistry.getEntityConfig(name);
if(config == null) {
executor.notify(String.format("Entity with name '%s' does not exist.", name), NotificationType.ALERT);
executor.notify(String.format("Entity with name '%s' does not exist.", name), NotificationType.SYSTEM);
return;
}

View file

@ -1,6 +1,6 @@
package brainwine.gameserver.command.commands;
import static brainwine.gameserver.entity.player.NotificationType.ALERT;
import static brainwine.gameserver.entity.player.NotificationType.SYSTEM;
import java.util.Arrays;
import java.util.regex.Pattern;
@ -21,7 +21,7 @@ public class ExportCommand extends Command {
@Override
public void execute(CommandExecutor executor, String[] args) {
if(args.length < 5) {
executor.notify(String.format("Usage: %s", getUsage(executor)), ALERT);
executor.notify(String.format("Usage: %s", getUsage(executor)), SYSTEM);
return;
}
@ -30,10 +30,10 @@ public class ExportCommand extends Command {
String name = String.join(" ", Arrays.copyOfRange(args, 4, args.length));
if(prefabManager.getPrefab(name) != null) {
executor.notify("A prefab with that name already exists.", ALERT);
executor.notify("A prefab with that name already exists.", SYSTEM);
return;
} else if(!PREFAB_NAME_PATTERN.matcher(name).matches()) {
executor.notify("Please enter a valid prefab name. Example: dungeons/my_epic_dungeon (or just my_epic_dungeon)", ALERT);
executor.notify("Please enter a valid prefab name. Example: dungeons/my_epic_dungeon (or just my_epic_dungeon)", SYSTEM);
return;
}
@ -48,35 +48,35 @@ public class ExportCommand extends Command {
width = Integer.parseInt(args[2]);
height = Integer.parseInt(args[3]);
} catch(NumberFormatException e) {
executor.notify("Parameters must be valid numbers.", ALERT);
executor.notify("Parameters must be valid numbers.", SYSTEM);
return;
}
if(width < 0 || height < 0) {
executor.notify("Width and height must be positive.", ALERT);
executor.notify("Width and height must be positive.", SYSTEM);
return;
} else if(width * height > SIZE_LIMIT) {
executor.notify(String.format("Sorry, your prefab is too large. Max size: %s blocks.", SIZE_LIMIT), ALERT);
executor.notify(String.format("Sorry, your prefab is too large. Max size: %s blocks.", SIZE_LIMIT), SYSTEM);
return;
} else if(x < 0 || x + width >= zone.getWidth() || y < 0 || y + height >= zone.getHeight()) {
executor.notify("These coordinates are out of bounds.", ALERT);
executor.notify("These coordinates are out of bounds.", SYSTEM);
return;
}
Prefab prefab = zone.chop(x, y, width, height);
if(prefab == null) {
executor.notify("Sorry, something went wrong. Please try again.", ALERT);
executor.notify("Sorry, something went wrong. Please try again.", SYSTEM);
return;
}
executor.notify(String.format("Exporting your prefab as '%s' ...", name), ALERT);
executor.notify(String.format("Exporting your prefab as '%s' ...", name), SYSTEM);
try {
prefabManager.addPrefab(name, prefab);
executor.notify(String.format("Your prefab '%s' was successfully exported!", name), ALERT);
executor.notify(String.format("Your prefab '%s' was successfully exported!", name), SYSTEM);
} catch (Exception e) {
executor.notify(String.format("An error occured while exporting prefab '%s': %s", name, e.getMessage()), ALERT);
executor.notify(String.format("An error occured while exporting prefab '%s': %s", name, e.getMessage()), SYSTEM);
}
}

View file

@ -1,6 +1,6 @@
package brainwine.gameserver.command.commands;
import static brainwine.gameserver.entity.player.NotificationType.ALERT;
import static brainwine.gameserver.entity.player.NotificationType.SYSTEM;
import brainwine.gameserver.GameServer;
import brainwine.gameserver.command.Command;
@ -24,7 +24,7 @@ public class GenerateZoneCommand extends Command {
int seed = (int)(Math.random() * Integer.MAX_VALUE);
if(args.length > 0 && args.length < 2) {
executor.notify(String.format("Usage: %s", getUsage(executor)), ALERT);
executor.notify(String.format("Usage: %s", getUsage(executor)), SYSTEM);
return;
}
@ -33,15 +33,16 @@ public class GenerateZoneCommand extends Command {
width = Integer.parseInt(args[0]);
height = Integer.parseInt(args[1]);
} catch(NumberFormatException e) {
executor.notify("Zone width and height must be valid numbers.", ALERT);
executor.notify("Zone width and height must be valid numbers.", SYSTEM);
return;
}
if(width < MIN_WIDTH || width > MAX_WIDTH || height < MIN_HEIGHT || height > MAX_HEIGHT) {
executor.notify(String.format("Zones must be between %sx%s and %sx%s blocks.", MIN_WIDTH, MIN_HEIGHT, MAX_WIDTH, MAX_HEIGHT), ALERT);
executor.notify(String.format("Zones must be between %sx%s and %sx%s blocks.",
MIN_WIDTH, MIN_HEIGHT, MAX_WIDTH, MAX_HEIGHT), SYSTEM);
return;
} else if(width % Zone.DEFAULT_CHUNK_WIDTH != 0 || height % Zone.DEFAULT_CHUNK_HEIGHT != 0) {
executor.notify(String.format("Zone size must be a multiple of %s", Zone.DEFAULT_CHUNK_WIDTH), ALERT);
executor.notify(String.format("Zone size must be a multiple of %s", Zone.DEFAULT_CHUNK_WIDTH), SYSTEM);
return;
}
}
@ -57,7 +58,7 @@ public class GenerateZoneCommand extends Command {
generator = ZoneGenerator.getZoneGenerator(name);
if(generator == null) {
executor.notify(String.format("The zone generator '%s' does not exist.", name), ALERT);
executor.notify(String.format("The zone generator '%s' does not exist.", name), SYSTEM);
return;
}
} else {
@ -77,13 +78,13 @@ public class GenerateZoneCommand extends Command {
}
}
executor.notify("Your zone is being generated. It should be ready soon!", ALERT);
executor.notify("Your zone is being generated. It should be ready soon!", SYSTEM);
generator.generateZoneAsync(biome, width, height, seed, zone -> {
if(zone == null) {
executor.notify("An unexpected error occured while generating your zone.", ALERT);
executor.notify("An unexpected error occured while generating your zone.", SYSTEM);
} else {
GameServer.getInstance().getZoneManager().addZone(zone);
executor.notify(String.format("Your zone '%s' is ready for exploration!", zone.getName()), ALERT);
executor.notify(String.format("Your zone '%s' is ready for exploration!", zone.getName()), SYSTEM);
}
});
}

View file

@ -1,6 +1,5 @@
package brainwine.gameserver.command.commands;
import static brainwine.gameserver.entity.player.NotificationType.ALERT;
import static brainwine.gameserver.entity.player.NotificationType.SYSTEM;
import java.util.ArrayList;
@ -18,14 +17,14 @@ public class GiveCommand extends Command {
@Override
public void execute(CommandExecutor executor, String[] args) {
if(args.length < 2) {
executor.notify(String.format("Usage: %s", getUsage(executor)), ALERT);
executor.notify(String.format("Usage: %s", getUsage(executor)), SYSTEM);
return;
}
Player target = GameServer.getInstance().getPlayerManager().getPlayer(args[0]);
if(target == null) {
executor.notify("That player does not exist.", ALERT);
executor.notify("That player does not exist.", SYSTEM);
return;
}
@ -50,7 +49,7 @@ public class GiveCommand extends Command {
}
if(item.isAir()) {
executor.notify("This item does not exist.", ALERT);
executor.notify("This item does not exist.", SYSTEM);
return;
}
@ -64,7 +63,7 @@ public class GiveCommand extends Command {
try {
quantity = Integer.parseInt(args[2]);
} catch(NumberFormatException e) {
executor.notify("Quantity must be a valid number.", ALERT);
executor.notify("Quantity must be a valid number.", SYSTEM);
return;
}
}
@ -74,14 +73,14 @@ public class GiveCommand extends Command {
target.getInventory().addItem(item, quantity, true);
}
target.alert(String.format("You received %s %s from an administrator.", quantity, title));
target.notify(String.format("You received %s %s from an administrator.", quantity, title), SYSTEM);
executor.notify(String.format("Gave %s %s to %s", quantity, title, target.getName()), SYSTEM);
} else {
for(Item item : items) {
target.getInventory().removeItem(item, -quantity, true);
}
target.alert(String.format("%s %s was taken from your inventory.", -quantity, title));
target.notify(String.format("%s %s was taken from your inventory.", -quantity, title), SYSTEM);
executor.notify(String.format("Took %s %s from %s", -quantity, title, target.getName()), SYSTEM);
}
}

View file

@ -1,6 +1,6 @@
package brainwine.gameserver.command.commands;
import static brainwine.gameserver.entity.player.NotificationType.ALERT;
import static brainwine.gameserver.entity.player.NotificationType.SYSTEM;
import brainwine.gameserver.GameServer;
import brainwine.gameserver.command.Command;
@ -15,7 +15,7 @@ public class HealthCommand extends Command {
if(args.length < 2) {
if(args.length == 0 || !(executor instanceof Player)) {
executor.notify(String.format("Usage: %s", getUsage(executor)), ALERT);
executor.notify(String.format("Usage: %s", getUsage(executor)), SYSTEM);
return;
}
target = (Player)executor;
@ -24,10 +24,10 @@ public class HealthCommand extends Command {
}
if(target == null) {
executor.notify("This player does not exist.", ALERT);
executor.notify("This player does not exist.", SYSTEM);
return;
} else if(!target.isOnline()) {
executor.notify("This player is offline.", ALERT);
executor.notify("This player is offline.", SYSTEM);
return;
}
@ -36,15 +36,15 @@ public class HealthCommand extends Command {
try {
health = Float.parseFloat(args[0]);
} catch(NumberFormatException e) {
executor.notify("Health must be a valid number.", ALERT);
executor.notify("Health must be a valid number.", SYSTEM);
return;
}
target.setHealth(health);
target.alert(String.format("Your health has been set to %s", target.getHealth()));
target.notify(String.format("Your health has been set to %s", target.getHealth()), SYSTEM);
if(target != executor) {
executor.notify(String.format("Set %s's health to %s", target.getName(), target.getHealth()), ALERT);
executor.notify(String.format("Set %s's health to %s", target.getName(), target.getHealth()), SYSTEM);
}
}

View file

@ -1,6 +1,5 @@
package brainwine.gameserver.command.commands;
import static brainwine.gameserver.entity.player.NotificationType.ALERT;
import static brainwine.gameserver.entity.player.NotificationType.SYSTEM;
import brainwine.gameserver.GameServer;
@ -14,7 +13,7 @@ public class ImportCommand extends Command {
@Override
public void execute(CommandExecutor executor, String[] args) {
if(args.length < 1) {
executor.notify(String.format("Usage: %s", getUsage(executor)), ALERT);
executor.notify(String.format("Usage: %s", getUsage(executor)), SYSTEM);
return;
}
@ -30,7 +29,7 @@ public class ImportCommand extends Command {
x = Integer.parseInt(args[1]);
y = Integer.parseInt(args[2]);
} catch(NumberFormatException e) {
player.notify("X and Y must be valid numbers.", ALERT);
player.notify("X and Y must be valid numbers.", SYSTEM);
return;
}
}
@ -39,7 +38,7 @@ public class ImportCommand extends Command {
Prefab prefab = GameServer.getInstance().getPrefabManager().getPrefab(name);
if(prefab == null) {
player.notify("Sorry, could not find a prefab with that name.", ALERT);
player.notify("Sorry, could not find a prefab with that name.", SYSTEM);
return;
}

View file

@ -1,6 +1,5 @@
package brainwine.gameserver.command.commands;
import static brainwine.gameserver.entity.player.NotificationType.ALERT;
import static brainwine.gameserver.entity.player.NotificationType.SYSTEM;
import java.util.Arrays;
@ -15,17 +14,17 @@ public class KickCommand extends Command {
@Override
public void execute(CommandExecutor executor, String[] args) {
if(args.length < 1) {
executor.notify(String.format("Usage: %s", getUsage(executor)), ALERT);
executor.notify(String.format("Usage: %s", getUsage(executor)), SYSTEM);
return;
}
Player player = GameServer.getInstance().getPlayerManager().getPlayer(args[0]);
if(player == null) {
executor.notify("This player does not exist.", ALERT);
executor.notify("This player does not exist.", SYSTEM);
return;
} else if(!player.isOnline()) {
executor.notify("This player is offline.", ALERT);
executor.notify("This player is offline.", SYSTEM);
return;
}

View file

@ -1,6 +1,5 @@
package brainwine.gameserver.command.commands;
import static brainwine.gameserver.entity.player.NotificationType.ALERT;
import static brainwine.gameserver.entity.player.NotificationType.SYSTEM;
import brainwine.gameserver.GameServer;
@ -16,7 +15,7 @@ public class PlayerIdCommand extends Command {
if(!(executor instanceof Player)) {
if(args.length < 1) {
executor.notify(String.format("Usage: %s", getUsage(executor)), ALERT);
executor.notify(String.format("Usage: %s", getUsage(executor)), SYSTEM);
return;
}
} else {

View file

@ -1,7 +1,5 @@
package brainwine.gameserver.command.commands;
import static brainwine.gameserver.entity.player.NotificationType.ALERT;
import org.apache.commons.validator.routines.EmailValidator;
import org.mindrot.jbcrypt.BCrypt;
@ -11,6 +9,8 @@ import brainwine.gameserver.command.CommandExecutor;
import brainwine.gameserver.dialog.DialogHelper;
import brainwine.gameserver.entity.player.Player;
import static brainwine.gameserver.entity.player.NotificationType.SYSTEM;
public class RegisterCommand extends Command {
@Override
@ -18,7 +18,7 @@ public class RegisterCommand extends Command {
Player player = (Player)executor;
if(player.isRegistered()) {
player.notify("You have already registered your account.", ALERT);
player.notify("You have already registered your account.", SYSTEM);
return;
}
@ -31,17 +31,17 @@ public class RegisterCommand extends Command {
String password = input[1].toString();
if(email.length() > 128 || !EmailValidator.getInstance().isValid(email)) {
player.alert("Please enter a valid e-mail address.");
player.notify("Please enter a valid e-mail address.");
return;
}
if(GameServer.getInstance().getPlayerManager().isEmailTaken(email)) {
player.alert("Sorry, this e-mail address is already in use.");
player.notify("Sorry, this e-mail address is already in use.");
return;
}
if(!password.matches("^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).{8,64}$")) {
player.alert("Please enter a valid password.");
player.notify("Please enter a valid password.");
return;
}
@ -50,7 +50,7 @@ public class RegisterCommand extends Command {
player.setEmail(email);
player.setPassword(BCrypt.hashpw(password, BCrypt.gensalt()));
player.checkRegistration();
player.alert("Your account has been successfully registered!");
player.notify("Your account has been successfully registered!");
});
}

View file

@ -1,6 +1,6 @@
package brainwine.gameserver.command.commands;
import static brainwine.gameserver.entity.player.NotificationType.ALERT;
import static brainwine.gameserver.entity.player.NotificationType.SYSTEM;
import brainwine.gameserver.GameServer;
import brainwine.gameserver.command.Command;
@ -13,25 +13,25 @@ public class RickrollCommand extends Command {
@Override
public void execute(CommandExecutor executor, String[] args) {
if(args.length < 1) {
executor.notify(String.format("Usage: %s", getUsage(executor)), ALERT);
executor.notify(String.format("Usage: %s", getUsage(executor)), SYSTEM);
return;
}
Player player = GameServer.getInstance().getPlayerManager().getPlayer(args[0]);
if(player == null) {
executor.notify("This player does not exist.", ALERT);
executor.notify("This player does not exist.", SYSTEM);
return;
} else if(!player.isOnline()) {
executor.notify("This player is offline.", ALERT);
executor.notify("This player is offline.", SYSTEM);
return;
} else if(!player.isV3()) {
executor.notify("Cannot open URLs on iOS clients.", ALERT);
executor.notify("Cannot open URLs on iOS clients.", SYSTEM);
return;
}
player.sendMessage(new EventMessage("openUrl", "https://www.youtube.com/watch?v=dQw4w9WgXcQ"));
executor.notify(String.format("Successfully rickrolled %s!", player.getName()), ALERT);
executor.notify(String.format("Successfully rickrolled %s!", player.getName()), SYSTEM);
}
@Override

View file

@ -1,6 +1,6 @@
package brainwine.gameserver.command.commands;
import static brainwine.gameserver.entity.player.NotificationType.ALERT;
import static brainwine.gameserver.entity.player.NotificationType.SYSTEM;
import brainwine.gameserver.command.Command;
import brainwine.gameserver.command.CommandExecutor;
@ -12,7 +12,7 @@ public class SayCommand extends Command {
@Override
public void execute(CommandExecutor executor, String[] args) {
if(args.length == 0) {
executor.notify(String.format("Usage: %s", getUsage(executor)), ALERT);
executor.notify(String.format("Usage: %s", getUsage(executor)), SYSTEM);
return;
}

View file

@ -1,6 +1,5 @@
package brainwine.gameserver.command.commands;
import static brainwine.gameserver.entity.player.NotificationType.ALERT;
import static brainwine.gameserver.entity.player.NotificationType.SYSTEM;
import brainwine.gameserver.GameServer;
@ -17,7 +16,7 @@ public class SeedCommand extends Command {
if(!(executor instanceof Player)) {
if(args.length < 1) {
executor.notify(String.format("Usage: %s", getUsage(executor)), ALERT);
executor.notify(String.format("Usage: %s", getUsage(executor)), SYSTEM);
return;
}
} else {
@ -29,7 +28,7 @@ public class SeedCommand extends Command {
}
if(target == null) {
executor.notify("This zone does not exist.", ALERT);
executor.notify("This zone does not exist.", SYSTEM);
return;
}

View file

@ -51,7 +51,7 @@ public class SkillPointsCommand extends Command {
}
target.setSkillPoints(amount);
target.alert(String.format("Your skill point count has been set to %s.", amount));
target.notify(String.format("Your skill point count has been set to %s.", amount), SYSTEM);
executor.notify(String.format("Successfully set %s's skill point count to %s.", target.getName(), amount), SYSTEM);
}

View file

@ -1,6 +1,6 @@
package brainwine.gameserver.command.commands;
import static brainwine.gameserver.entity.player.NotificationType.ALERT;
import static brainwine.gameserver.entity.player.NotificationType.SYSTEM;
import brainwine.gameserver.command.Command;
import brainwine.gameserver.command.CommandExecutor;
@ -11,7 +11,7 @@ public class TeleportCommand extends Command {
@Override
public void execute(CommandExecutor executor, String[] args) {
if(args.length != 2) {
executor.notify(String.format("Usage: %s", getUsage(executor)), ALERT);
executor.notify(String.format("Usage: %s", getUsage(executor)), SYSTEM);
return;
}
@ -23,12 +23,12 @@ public class TeleportCommand extends Command {
x = Integer.parseInt(args[0]);
y = Integer.parseInt(args[1]);
} catch(NumberFormatException e) {
player.notify("x and y must be numerical.", ALERT);
player.notify("x and y must be numerical.", SYSTEM);
return;
}
if(!player.getZone().areCoordinatesInBounds(x, y)) {
player.notify("Cannot teleport out of bounds!", ALERT);
player.notify("Cannot teleport out of bounds!", SYSTEM);
return;
}

View file

@ -1,6 +1,6 @@
package brainwine.gameserver.command.commands;
import static brainwine.gameserver.entity.player.NotificationType.ALERT;
import static brainwine.gameserver.entity.player.NotificationType.SYSTEM;
import brainwine.gameserver.command.Command;
import brainwine.gameserver.command.CommandExecutor;
@ -12,7 +12,7 @@ public class ThinkCommand extends Command {
@Override
public void execute(CommandExecutor executor, String[] args) {
if(args.length == 0) {
executor.notify(String.format("Usage: %s", getUsage(executor)), ALERT);
executor.notify(String.format("Usage: %s", getUsage(executor)), SYSTEM);
return;
}

View file

@ -1,6 +1,5 @@
package brainwine.gameserver.command.commands;
import static brainwine.gameserver.entity.player.NotificationType.ALERT;
import static brainwine.gameserver.entity.player.NotificationType.SYSTEM;
import brainwine.gameserver.GameServer;
@ -17,7 +16,7 @@ public class ZoneIdCommand extends Command {
if(!(executor instanceof Player)) {
if(args.length < 1) {
executor.notify(String.format("Usage: %s", getUsage(executor)), ALERT);
executor.notify(String.format("Usage: %s", getUsage(executor)), SYSTEM);
return;
}
} else {
@ -29,7 +28,7 @@ public class ZoneIdCommand extends Command {
}
if(target == null) {
executor.notify("This zone does not exist.", ALERT);
executor.notify("This zone does not exist.", SYSTEM);
return;
}

View file

@ -4,18 +4,20 @@ import com.fasterxml.jackson.annotation.JsonValue;
public enum NotificationType {
ALERT(1),
STANDARD(2),
POPUP(1),
SYSTEM(2),
EMOTE(3),
INVISIBLE_DIALOG(5),
FANCY_EMOTE(4),
INVISIBLE_DIALOG(5), // v2 only
LARGE(6),
ACCOMPLISHMENT(10),
SYSTEM(11),
REWARD(12),
PEER_ACCOMPLISHMENT(11),
REWARD(12), // v2 only
CHAT(20),
LEVEL_UP(21),
ACHIEVEMENT(22),
WELCOME(333);
LEVEL_UP(21), // v3 only
ACHIEVEMENT(22), // v3 only
WELCOME(333), // v2 only
MAINTENANCE(503); // v2 only
private final int id;

View file

@ -187,12 +187,11 @@ public class Player extends Entity implements CommandExecutor {
@Override
public void notify(Object message, NotificationType type) {
if(type == NotificationType.SYSTEM && !isV3()) {
sendMessage(new NotificationMessage(message, NotificationType.STANDARD));
return;
if(type == NotificationType.SYSTEM && isV3()) {
sendMessage(new NotificationMessage(message, NotificationType.PEER_ACCOMPLISHMENT));
} else {
sendMessage(new NotificationMessage(message, type));
}
sendMessage(new NotificationMessage(message, type));
}
@Override
@ -408,7 +407,7 @@ public class Player extends Entity implements CommandExecutor {
Consumer<Object[]> handler = dialogs.remove(id);
if(handler == null) {
alert("Sorry, the request has expired.");
notify("Sorry, the request has expired.");
} else {
// TODO since we're dealing with user input, should we just try-catch this?
handler.accept(input);
@ -514,8 +513,8 @@ public class Player extends Entity implements CommandExecutor {
sendMessageToPeers(new NotificationMessage(message, type));
}
public void alert(String text) {
notify(text, NotificationType.ALERT);
public void notify(Object message) {
notify(message, NotificationType.POPUP);
}
public void setHeldItem(Item item) {
@ -782,9 +781,9 @@ public class Player extends Entity implements CommandExecutor {
String notification = achievement.getNotification();
if(notification == null) {
alert(String.format("You're %s to the %s achievement!", description, title));
notify(String.format("You're %s to the %s achievement!", description, title));
} else {
alert(String.format("You've %s - %s to the %s achievement!",
notify(String.format("You've %s - %s to the %s achievement!",
notification.replace("*", String.valueOf(progress)), description, title));
}

View file

@ -130,7 +130,7 @@ public class BlockMineRequest extends PlayerRequest {
}
private void fail(Player player, String reason) {
player.alert(reason);
player.notify(reason);
Block block = player.getZone().getBlock(x, y);
player.sendDelayedMessage(new BlockChangeMessage(x, y, layer, block.getItem(layer), block.getMod(layer)));
player.sendDelayedMessage(new InventoryMessage(player.getInventory().getClientConfig(item)));

View file

@ -117,7 +117,7 @@ public class BlockPlaceRequest extends PlayerRequest {
}
private void fail(Player player, String reason) {
player.alert(reason);
player.notify(reason);
Block block = player.getZone().getBlock(x, y);
player.sendDelayedMessage(new BlockChangeMessage(x, y, layer, block.getItem(layer), block.getMod(layer)));
player.sendDelayedMessage(new InventoryMessage(player.getInventory().getClientConfig(item)));

View file

@ -58,12 +58,12 @@ public class BlockUseRequest extends PlayerRequest {
switch(publicUse) {
case "owner":
player.alert(String.format("This %s is owned by %s.",
player.notify(String.format("This %s is owned by %s.",
item.getTitle().toLowerCase(), owner == null ? "nobody.." : owner.getName()));
break;
}
} else {
player.alert("Sorry, that belongs to somebody else.");
player.notify("Sorry, that belongs to somebody else.");
return;
}
}
@ -127,7 +127,7 @@ public class BlockUseRequest extends PlayerRequest {
String dungeonId = MapHelper.getString(metadata, "@");
if(dungeonId != null && item.hasUse(ItemUseType.FIELDABLE) && zone.isDungeonIntact(dungeonId)) {
player.alert("This container is secured by protectors in the area.");
player.notify("This container is secured by protectors in the area.");
break;
}
@ -135,14 +135,14 @@ public class BlockUseRequest extends PlayerRequest {
Loot loot = GameServer.getInstance().getLootManager().getRandomLoot(player, item.getLootCategories());
if(loot == null) {
player.alert("No eligible loot could be found for this container.");
player.notify("No eligible loot could be found for this container.");
} else {
metadata.remove("$");
player.awardLoot(loot, item.getLootGraphic());
player.getStatistics().trackContainerLooted(item);
}
} else {
player.alert("Sorry, this container can't be looted right now.");
player.notify("Sorry, this container can't be looted right now.");
}
if(mod != 0) {

View file

@ -27,7 +27,7 @@ public class ChangeAppearanceRequest extends PlayerRequest {
String meta = "" + data.get("meta");
if(meta.equals("randomize")) {
player.alert("Sorry, you can't randomize your appearance yet.");
player.notify("Sorry, you can't randomize your appearance yet.");
} else {
player.showDialog(DialogHelper.getWardrobeDialog(meta));
}
@ -49,7 +49,7 @@ public class ChangeAppearanceRequest extends PlayerRequest {
Item item = ItemRegistry.getItem((int)value);
if(!item.isBase() && !player.getInventory().hasItem(item)) {
player.alert("Sorry, but you do not own this.");
player.notify("Sorry, but you do not own this.");
return;
}

View file

@ -28,7 +28,7 @@ public class CraftRequest extends PlayerRequest {
@Override
public void process(Player player) {
if(item.isAir() || !item.isCraftable()) {
player.alert("Sorry, you can't craft this item.");
player.notify("Sorry, you can't craft this item.");
return;
}
@ -37,7 +37,7 @@ public class CraftRequest extends PlayerRequest {
Pair<Skill, Integer> craftingSkill = item.getCraftingSkill();
if(player.getTotalSkillLevel(craftingSkill.getFirst()) < craftingSkill.getLast()) {
player.alert("You are not skilled enough to craft this item.");
player.notify("You are not skilled enough to craft this item.");
return;
}
}
@ -50,7 +50,7 @@ public class CraftRequest extends PlayerRequest {
Item item = ingredient.getItem();
if(!inventory.hasItem(item, ingredient.getQuantity() * quantity)) {
player.alert(String.format("You do not have enough %s to craft this.", item.getTitle()));
player.notify(String.format("You do not have enough %s to craft this.", item.getTitle()));
return;
}
}
@ -65,7 +65,7 @@ public class CraftRequest extends PlayerRequest {
-> metaBlock.getItem() == craftingHelper.getItem()).count();
if(quantityMissing > 0) {
player.alert(String.format("You can't craft this item because your workshop is lacking %sx %s.",
player.notify(String.format("You can't craft this item because your workshop is lacking %sx %s.",
quantityMissing, craftingHelper.getItem().getTitle()));
return;
}

View file

@ -37,7 +37,7 @@ public class DialogRequest extends PlayerRequest {
onSkillUpgrade(player);
break;
default:
player.alert("Sorry, this action is not implemented yet.");
player.notify("Sorry, this action is not implemented yet.");
break;
}
return;
@ -50,7 +50,7 @@ public class DialogRequest extends PlayerRequest {
private void onSkillUpgrade(Player player) {
if(player.getSkillPoints() <= 0) {
player.alert("Sorry, you are out of skill points. Level up to earn some more!");
player.notify("Sorry, you are out of skill points. Level up to earn some more!");
return;
}
@ -61,7 +61,7 @@ public class DialogRequest extends PlayerRequest {
.collect(Collectors.toList());
if(upgradeableSkills.isEmpty()) {
player.alert("You've maxed out all available skills!");
player.notify("You've maxed out all available skills!");
return;
}
@ -81,14 +81,14 @@ public class DialogRequest extends PlayerRequest {
}
if(player.getSkillPoints() <= 0) {
player.alert("Sorry, you are out of skill points. Level up to earn some more!");
player.notify("Sorry, you are out of skill points. Level up to earn some more!");
return;
}
Skill skill = Skill.fromId(input[0].toString());
if(!player.getUpgradeableSkills().contains(skill)) {
player.alert("Sorry, you cannot upgrade that skill right now.");
player.notify("Sorry, you cannot upgrade that skill right now.");
return;
}

View file

@ -12,7 +12,7 @@ public class TransactionRequest extends PlayerRequest {
@Override
public void process(Player player) {
player.alert("Sorry, the crown store has not been implemented yet.");
player.notify("Sorry, the crown store has not been implemented yet.");
player.sendMessage(new StatMessage("crowns", player.getCrowns()));
}
}

View file

@ -16,10 +16,10 @@ public class ZoneChangeRequest extends PlayerRequest {
Zone zone = GameServer.getInstance().getZoneManager().getZoneByName(zoneName);
if(zone == null) {
player.alert("Sorry, could not find a zone with name " + zoneName);
player.notify("Sorry, could not find a zone with name " + zoneName);
return;
} else if(zone == player.getZone()) {
player.alert("You're already in " + zoneName);
player.notify("You're already in " + zoneName);
return;
}