mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-12-30 21:07:47 +01:00
Changes User#sendMessage to Utils#sendMessage
This allows add "prefix" to all messages send from Challenges addon.
This commit is contained in:
parent
99c920fe8f
commit
6fbc9d0676
@ -47,11 +47,14 @@ public class ChallengesPlayerCommand extends CompositeCommand
|
|||||||
map(GameModeAddon::getAdminCommand).
|
map(GameModeAddon::getAdminCommand).
|
||||||
map(optionalAdminCommand -> optionalAdminCommand.map(CompositeCommand::getTopLabel).orElse(this.getTopLabel())).
|
map(optionalAdminCommand -> optionalAdminCommand.map(CompositeCommand::getTopLabel).orElse(this.getTopLabel())).
|
||||||
orElse(this.getTopLabel());
|
orElse(this.getTopLabel());
|
||||||
user.sendMessage("challenges.errors.no-challenges-admin", "[command]", topLabel + " challenges");
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.no-challenges-admin",
|
||||||
|
"[command]",
|
||||||
|
topLabel + " " + this.<ChallengesAddon>getAddon().getChallengesSettings().getAdminMainCommand().split(" ")[0]));
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.errors.no-challenges");
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.no-challenges"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -55,7 +55,7 @@ public class CompleteChallengeCommand extends CompositeCommand
|
|||||||
{
|
{
|
||||||
if (args.isEmpty())
|
if (args.isEmpty())
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.errors.no-name");
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.no-name"));
|
||||||
this.showHelp(this, user);
|
this.showHelp(this, user);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ public class CompleteChallengeCommand extends CompositeCommand
|
|||||||
|
|
||||||
if (!canMultipleTimes && count > 1)
|
if (!canMultipleTimes && count > 1)
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.error.no-multiple-permission");
|
Utils.sendMessage(user, user.getTranslation("challenges.error.no-multiple-permission"));
|
||||||
count = 1;
|
count = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ public class CompleteChallengeCommand extends CompositeCommand
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.errors.unknown-challenge");
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.unknown-challenge"));
|
||||||
this.showHelp(this, user);
|
this.showHelp(this, user);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ public class CompleteCommand extends CompositeCommand
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.errors.no-name");
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.no-name"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -68,7 +68,7 @@ public class CompleteCommand extends CompositeCommand
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.errors.missing-arguments");
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.missing-arguments"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -83,9 +83,9 @@ public class CompleteCommand extends CompositeCommand
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
user.sendMessage("general.errors.unknown-player",
|
Utils.sendMessage(user, user.getTranslation("general.errors.unknown-player",
|
||||||
TextVariables.NAME,
|
TextVariables.NAME,
|
||||||
args.get(0));
|
args.get(0)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -108,9 +108,9 @@ public class CompleteCommand extends CompositeCommand
|
|||||||
|
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.messages.admin.completed",
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.admin.completed",
|
||||||
"[name]", challenge.getFriendlyName(),
|
"[name]", challenge.getFriendlyName(),
|
||||||
"[player]", User.getInstance(targetUUID).getName());
|
"[player]", User.getInstance(targetUUID).getName()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -122,7 +122,7 @@ public class CompleteCommand extends CompositeCommand
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.messages.admin.already-completed");
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.admin.already-completed"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -136,7 +136,7 @@ public class CompleteCommand extends CompositeCommand
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.errors.unknown-challenge");
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.unknown-challenge"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -195,5 +195,5 @@ public class CompleteCommand extends CompositeCommand
|
|||||||
/**
|
/**
|
||||||
* Variable that holds challenge addon. Single casting.
|
* Variable that holds challenge addon. Single casting.
|
||||||
*/
|
*/
|
||||||
private ChallengesAddon addon;
|
private final ChallengesAddon addon;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import world.bentobox.bentobox.api.commands.CompositeCommand;
|
|||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.challenges.ChallengesAddon;
|
import world.bentobox.challenges.ChallengesAddon;
|
||||||
import world.bentobox.challenges.managers.ChallengesManager;
|
import world.bentobox.challenges.managers.ChallengesManager;
|
||||||
|
import world.bentobox.challenges.utils.Utils;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,13 +47,13 @@ public class ReloadChallenges extends CompositeCommand
|
|||||||
if (args.isEmpty())
|
if (args.isEmpty())
|
||||||
{
|
{
|
||||||
this.manager.load();
|
this.manager.load();
|
||||||
user.sendMessage("general.success");
|
Utils.sendMessage(user, user.getTranslation("general.success"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (args.get(0).equalsIgnoreCase("hard"))
|
else if (args.get(0).equalsIgnoreCase("hard"))
|
||||||
{
|
{
|
||||||
this.manager.reload();
|
this.manager.reload();
|
||||||
user.sendMessage("general.success");
|
Utils.sendMessage(user, user.getTranslation("general.success"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -57,7 +57,7 @@ public class ResetCommand extends CompositeCommand
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.errors.no-name");
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.no-name"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -68,7 +68,7 @@ public class ResetCommand extends CompositeCommand
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.errors.missing-arguments");
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.missing-arguments"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -83,7 +83,8 @@ public class ResetCommand extends CompositeCommand
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0));
|
Utils.sendMessage(user, user.getTranslation("general.errors.unknown-player",
|
||||||
|
TextVariables.NAME, args.get(0)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -101,8 +102,8 @@ public class ResetCommand extends CompositeCommand
|
|||||||
|
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.messages.admin.reset-all",
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.admin.reset-all",
|
||||||
"[player]", User.getInstance(targetUUID).getName());
|
"[player]", User.getInstance(targetUUID).getName()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -125,9 +126,9 @@ public class ResetCommand extends CompositeCommand
|
|||||||
|
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.messages.admin.reset",
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.admin.reset",
|
||||||
"[name]", challenge.getFriendlyName(),
|
"[name]", challenge.getFriendlyName(),
|
||||||
"[player]", User.getInstance(targetUUID).getName());
|
"[player]", User.getInstance(targetUUID).getName()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -139,7 +140,7 @@ public class ResetCommand extends CompositeCommand
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.messages.admin.not-completed");
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.admin.not-completed"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -153,7 +154,7 @@ public class ResetCommand extends CompositeCommand
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.errors.unknown-challenge");
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.unknown-challenge"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -735,7 +735,7 @@ public class ChallengesImportManager
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.errors.exist-challenges-or-levels");
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.exist-challenges-or-levels"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -265,7 +265,7 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
user.sendMessage("load-error", "[value]", "NULL");
|
Utils.sendMessage(user, user.getTranslation("load-error", "[value]", "NULL"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -275,7 +275,8 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.errors.invalid-challenge", "[challenge]", challenge.getUniqueId());
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.invalid-challenge",
|
||||||
|
"[challenge]", challenge.getUniqueId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addon.logWarning("Data for challenge `" + challenge.getUniqueId() + "` is not valid. It could be NULL element in item-stack!");
|
this.addon.logWarning("Data for challenge `" + challenge.getUniqueId() + "` is not valid. It could be NULL element in item-stack!");
|
||||||
@ -290,8 +291,8 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.messages.load-skipping",
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.load-skipping",
|
||||||
VALUE, challenge.getFriendlyName());
|
VALUE, challenge.getFriendlyName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -300,8 +301,8 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.messages.load-overwriting",
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.load-overwriting",
|
||||||
VALUE, challenge.getFriendlyName());
|
VALUE, challenge.getFriendlyName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,8 +310,8 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.messages.load-add",
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.load-add",
|
||||||
VALUE, challenge.getFriendlyName());
|
VALUE, challenge.getFriendlyName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,7 +352,7 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
user.sendMessage("load-error", "[value]", "NULL");
|
Utils.sendMessage(user, user.getTranslation("load-error", "[value]", "NULL"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -361,7 +362,8 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.errors.invalid-level", "[level]", level.getUniqueId());
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.invalid-level",
|
||||||
|
"[level]", level.getUniqueId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addon.logWarning("Data for level `" + level.getUniqueId() + "` is not valid. It could be NULL element in item-stack!");
|
this.addon.logWarning("Data for level `" + level.getUniqueId() + "` is not valid. It could be NULL element in item-stack!");
|
||||||
@ -372,7 +374,8 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.errors.load-error", VALUE, level.getFriendlyName());
|
Utils.sendMessage(user, user.getTranslation("challenges.errors.load-error",
|
||||||
|
VALUE, level.getFriendlyName()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -388,8 +391,8 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.messages.load-skipping",
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.load-skipping",
|
||||||
VALUE, level.getFriendlyName());
|
VALUE, level.getFriendlyName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -398,8 +401,8 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.messages.load-overwriting",
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.load-overwriting",
|
||||||
VALUE, level.getFriendlyName());
|
VALUE, level.getFriendlyName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -407,8 +410,8 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.messages.load-add",
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.load-add",
|
||||||
VALUE, level.getFriendlyName());
|
VALUE, level.getFriendlyName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -670,7 +673,7 @@ public class ChallengesManager
|
|||||||
|
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.messages.admin.migrate-start");
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.admin.migrate-start"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -686,7 +689,7 @@ public class ChallengesManager
|
|||||||
|
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.messages.admin.migrate-end");
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.admin.migrate-end"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -697,7 +700,7 @@ public class ChallengesManager
|
|||||||
{
|
{
|
||||||
if (user.isPlayer())
|
if (user.isPlayer())
|
||||||
{
|
{
|
||||||
user.sendMessage("challenges.messages.admin.migrate-not");
|
Utils.sendMessage(user, user.getTranslation("challenges.messages.admin.migrate-not"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -30,6 +30,7 @@ import world.bentobox.challenges.panel.CommonPanel;
|
|||||||
import world.bentobox.challenges.tasks.TryToComplete;
|
import world.bentobox.challenges.tasks.TryToComplete;
|
||||||
import world.bentobox.challenges.utils.Constants;
|
import world.bentobox.challenges.utils.Constants;
|
||||||
import world.bentobox.challenges.utils.LevelStatus;
|
import world.bentobox.challenges.utils.LevelStatus;
|
||||||
|
import world.bentobox.challenges.utils.Utils;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,7 +75,7 @@ public class ChallengesPanel extends CommonPanel
|
|||||||
if (!this.containsChallenges)
|
if (!this.containsChallenges)
|
||||||
{
|
{
|
||||||
this.addon.logError("There are no challenges set up!");
|
this.addon.logError("There are no challenges set up!");
|
||||||
this.user.sendMessage(Constants.ERRORS + "no-challenges");
|
Utils.sendMessage(user, user.getTranslation(Constants.ERRORS + "no-challenges"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,21 +300,22 @@ public class TryToComplete
|
|||||||
// Send message about first completion only if it is completed only once.
|
// Send message about first completion only if it is completed only once.
|
||||||
if (result.getFactor() == 1)
|
if (result.getFactor() == 1)
|
||||||
{
|
{
|
||||||
this.user.sendMessage("challenges.messages.you-completed-challenge", "[value]", this.challenge.getFriendlyName());
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.messages.you-completed-challenge",
|
||||||
|
"[value]", this.challenge.getFriendlyName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.addon.getChallengesSettings().isBroadcastMessages())
|
if (this.addon.getChallengesSettings().isBroadcastMessages())
|
||||||
{
|
{
|
||||||
for (Player player : Bukkit.getOnlinePlayers())
|
Bukkit.getOnlinePlayers().stream().
|
||||||
{
|
filter(player -> this.user.getUniqueId().equals(player.getUniqueId())).
|
||||||
// Only other players should see message.
|
map(User::getInstance).
|
||||||
if (!player.getUniqueId().equals(this.user.getUniqueId()))
|
filter(Objects::nonNull).
|
||||||
{
|
forEach(user -> {
|
||||||
User.getInstance(player).sendMessage("challenges.messages.name-has-completed-challenge",
|
Utils.sendMessage(user, user.getTranslation(
|
||||||
"[name]", this.user.getName(),
|
"challenges.messages.name-has-completed-challenge",
|
||||||
"[value]", this.challenge.getFriendlyName());
|
"[name]", this.user.getName(),
|
||||||
}
|
"[value]", this.challenge.getFriendlyName()));
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// sends title to player on challenge completion
|
// sends title to player on challenge completion
|
||||||
@ -365,13 +366,14 @@ public class TryToComplete
|
|||||||
|
|
||||||
if (result.getFactor() > 1)
|
if (result.getFactor() > 1)
|
||||||
{
|
{
|
||||||
this.user.sendMessage("challenges.messages.you-repeated-challenge-multiple",
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.messages.you-repeated-challenge-multiple",
|
||||||
"[value]", this.challenge.getFriendlyName(),
|
"[value]", this.challenge.getFriendlyName(),
|
||||||
"[count]", Integer.toString(result.getFactor()));
|
"[count]", Integer.toString(result.getFactor())));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.user.sendMessage("challenges.messages.you-repeated-challenge", "[value]", this.challenge.getFriendlyName());
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.messages.you-repeated-challenge",
|
||||||
|
"[value]", this.challenge.getFriendlyName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,19 +411,21 @@ public class TryToComplete
|
|||||||
// Run commands
|
// Run commands
|
||||||
this.runCommands(level.getRewardCommands());
|
this.runCommands(level.getRewardCommands());
|
||||||
|
|
||||||
this.user.sendMessage("challenges.messages.you-completed-level", "[value]", level.getFriendlyName());
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.messages.you-completed-level",
|
||||||
|
"[value]", level.getFriendlyName()));
|
||||||
|
|
||||||
if (this.addon.getChallengesSettings().isBroadcastMessages())
|
if (this.addon.getChallengesSettings().isBroadcastMessages())
|
||||||
{
|
{
|
||||||
for (Player player : this.addon.getServer().getOnlinePlayers())
|
Bukkit.getOnlinePlayers().stream().
|
||||||
{
|
filter(player -> this.user.getUniqueId().equals(player.getUniqueId())).
|
||||||
// Only other players should see message.
|
map(User::getInstance).
|
||||||
if (!player.getUniqueId().equals(this.user.getUniqueId()))
|
filter(Objects::nonNull).
|
||||||
{
|
forEach(user -> {
|
||||||
User.getInstance(player).sendMessage("challenges.messages.name-has-completed-level",
|
Utils.sendMessage(user, user.getTranslation(
|
||||||
"[name]", this.user.getName(), "[value]", level.getFriendlyName());
|
"challenges.messages.name-has-completed-level",
|
||||||
}
|
"[name]", this.user.getName(),
|
||||||
}
|
"[value]", level.getFriendlyName()));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.manager.setLevelComplete(this.user, this.world, level);
|
this.manager.setLevelComplete(this.user, this.world, level);
|
||||||
@ -430,11 +434,11 @@ public class TryToComplete
|
|||||||
if (this.addon.getChallengesSettings().isShowCompletionTitle())
|
if (this.addon.getChallengesSettings().isShowCompletionTitle())
|
||||||
{
|
{
|
||||||
this.user.getPlayer().sendTitle(
|
this.user.getPlayer().sendTitle(
|
||||||
this.parseLevel(this.user.getTranslation("challenges.titles.level-title"), level),
|
this.parseLevel(this.user.getTranslation("challenges.titles.level-title"), level),
|
||||||
this.parseLevel(this.user.getTranslation("challenges.titles.level-subtitle"), level),
|
this.parseLevel(this.user.getTranslation("challenges.titles.level-subtitle"), level),
|
||||||
10,
|
10,
|
||||||
this.addon.getChallengesSettings().getTitleShowtime(),
|
this.addon.getChallengesSettings().getTitleShowtime(),
|
||||||
20);
|
20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -485,7 +489,8 @@ public class TryToComplete
|
|||||||
// Something is not removed.
|
// Something is not removed.
|
||||||
if (sumEverything != removedAmount)
|
if (sumEverything != removedAmount)
|
||||||
{
|
{
|
||||||
this.user.sendMessage("challenges.errors.cannot-remove-items");
|
Utils.sendMessage(this.user,
|
||||||
|
this.user.getTranslation("challenges.errors.cannot-remove-items"));
|
||||||
|
|
||||||
result.removedItems = removedItems;
|
result.removedItems = removedItems;
|
||||||
result.meetsRequirements = false;
|
result.meetsRequirements = false;
|
||||||
@ -658,25 +663,25 @@ public class TryToComplete
|
|||||||
// Check the world
|
// Check the world
|
||||||
if (!this.challenge.isDeployed())
|
if (!this.challenge.isDeployed())
|
||||||
{
|
{
|
||||||
this.user.sendMessage("challenges.errors.not-deployed");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-deployed"));
|
||||||
result = EMPTY_RESULT;
|
result = EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
else if (maxTimes < 1)
|
else if (maxTimes < 1)
|
||||||
{
|
{
|
||||||
this.user.sendMessage("challenges.errors.not-valid-integer");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-valid-integer"));
|
||||||
result = EMPTY_RESULT;
|
result = EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
else if (Util.getWorld(this.world) != Util.getWorld(this.user.getWorld()) ||
|
else if (Util.getWorld(this.world) != Util.getWorld(this.user.getWorld()) ||
|
||||||
!this.challenge.matchGameMode(Utils.getGameMode(this.world)))
|
!this.challenge.matchGameMode(Utils.getGameMode(this.world)))
|
||||||
{
|
{
|
||||||
this.user.sendMessage("general.errors.wrong-world");
|
Utils.sendMessage(this.user, this.user.getTranslation("general.errors.wrong-world"));
|
||||||
result = EMPTY_RESULT;
|
result = EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
// Player is not on island
|
// Player is not on island
|
||||||
else if (ChallengesAddon.CHALLENGES_WORLD_PROTECTION.isSetForWorld(this.world) &&
|
else if (ChallengesAddon.CHALLENGES_WORLD_PROTECTION.isSetForWorld(this.world) &&
|
||||||
!this.addon.getIslands().locationIsOnIsland(this.user.getPlayer(), this.user.getLocation()))
|
!this.addon.getIslands().locationIsOnIsland(this.user.getPlayer(), this.user.getLocation()))
|
||||||
{
|
{
|
||||||
this.user.sendMessage("challenges.errors.not-on-island");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-on-island"));
|
||||||
result = EMPTY_RESULT;
|
result = EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
// Check player permission
|
// Check player permission
|
||||||
@ -684,40 +689,40 @@ public class TryToComplete
|
|||||||
map(i -> i.isAllowed(this.user, ChallengesAddon.CHALLENGES_ISLAND_PROTECTION)).
|
map(i -> i.isAllowed(this.user, ChallengesAddon.CHALLENGES_ISLAND_PROTECTION)).
|
||||||
orElse(false))
|
orElse(false))
|
||||||
{
|
{
|
||||||
this.user.sendMessage("challenges.errors.no-rank");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.no-rank"));
|
||||||
result = EMPTY_RESULT;
|
result = EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
// Check if user has unlocked challenges level.
|
// Check if user has unlocked challenges level.
|
||||||
else if (!this.challenge.getLevel().equals(ChallengesManager.FREE) &&
|
else if (!this.challenge.getLevel().equals(ChallengesManager.FREE) &&
|
||||||
!this.manager.isLevelUnlocked(this.user, this.world, this.manager.getLevel(this.challenge.getLevel())))
|
!this.manager.isLevelUnlocked(this.user, this.world, this.manager.getLevel(this.challenge.getLevel())))
|
||||||
{
|
{
|
||||||
this.user.sendMessage("challenges.errors.challenge-level-not-available");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.challenge-level-not-available"));
|
||||||
result = EMPTY_RESULT;
|
result = EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
// Check max times
|
// Check max times
|
||||||
else if (this.challenge.isRepeatable() && this.challenge.getMaxTimes() > 0 &&
|
else if (this.challenge.isRepeatable() && this.challenge.getMaxTimes() > 0 &&
|
||||||
this.manager.getChallengeTimes(this.user, this.world, this.challenge) >= this.challenge.getMaxTimes())
|
this.manager.getChallengeTimes(this.user, this.world, this.challenge) >= this.challenge.getMaxTimes())
|
||||||
{
|
{
|
||||||
this.user.sendMessage("challenges.errors.not-repeatable");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-repeatable"));
|
||||||
result = EMPTY_RESULT;
|
result = EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
// Check repeatability
|
// Check repeatability
|
||||||
else if (!this.challenge.isRepeatable() && this.manager.isChallengeComplete(this.user, this.world, this.challenge))
|
else if (!this.challenge.isRepeatable() && this.manager.isChallengeComplete(this.user, this.world, this.challenge))
|
||||||
{
|
{
|
||||||
this.user.sendMessage("challenges.errors.not-repeatable");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-repeatable"));
|
||||||
result = EMPTY_RESULT;
|
result = EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
// Check environment
|
// Check environment
|
||||||
else if (!this.challenge.getEnvironment().isEmpty() &&
|
else if (!this.challenge.getEnvironment().isEmpty() &&
|
||||||
!this.challenge.getEnvironment().contains(this.user.getWorld().getEnvironment()))
|
!this.challenge.getEnvironment().contains(this.user.getWorld().getEnvironment()))
|
||||||
{
|
{
|
||||||
this.user.sendMessage("challenges.errors.wrong-environment");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.wrong-environment"));
|
||||||
result = EMPTY_RESULT;
|
result = EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
// Check permission
|
// Check permission
|
||||||
else if (!this.checkPermissions())
|
else if (!this.checkPermissions())
|
||||||
{
|
{
|
||||||
this.user.sendMessage("general.errors.no-permission");
|
Utils.sendMessage(this.user, this.user.getTranslation("general.errors.no-permission"));
|
||||||
result = EMPTY_RESULT;
|
result = EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
else if (type.equals(ChallengeType.INVENTORY_TYPE))
|
else if (type.equals(ChallengeType.INVENTORY_TYPE))
|
||||||
@ -758,7 +763,7 @@ public class TryToComplete
|
|||||||
private boolean checkPermissions()
|
private boolean checkPermissions()
|
||||||
{
|
{
|
||||||
return this.challenge.getRequirements().getRequiredPermissions().isEmpty() ||
|
return this.challenge.getRequirements().getRequiredPermissions().isEmpty() ||
|
||||||
this.challenge.getRequirements().getRequiredPermissions().stream().allMatch(s -> this.user.hasPermission(s));
|
this.challenge.getRequirements().getRequiredPermissions().stream().allMatch(s -> this.user.hasPermission(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -826,7 +831,7 @@ public class TryToComplete
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!this.addon.getServer().dispatchCommand(this.addon.getServer().getConsoleSender(),
|
if (!this.addon.getServer().dispatchCommand(this.addon.getServer().getConsoleSender(),
|
||||||
cmd.replace("[player]", this.user.getName())))
|
cmd.replace("[player]", this.user.getName())))
|
||||||
{
|
{
|
||||||
this.showError(cmd);
|
this.showError(cmd);
|
||||||
}
|
}
|
||||||
@ -896,9 +901,9 @@ public class TryToComplete
|
|||||||
|
|
||||||
if (numInInventory < required.getAmount())
|
if (numInInventory < required.getAmount())
|
||||||
{
|
{
|
||||||
this.user.sendMessage("challenges.errors.not-enough-items",
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-enough-items",
|
||||||
"[items]",
|
"[items]",
|
||||||
Util.prettifyText(required.getType().toString()));
|
Utils.prettifyObject(required, this.user)));
|
||||||
return EMPTY_RESULT;
|
return EMPTY_RESULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1150,13 +1155,13 @@ public class TryToComplete
|
|||||||
return new ChallengeResult().setMeetsRequirements().setCompleteFactor(factor).setBlockQueue(blockFromWorld);
|
return new ChallengeResult().setMeetsRequirements().setCompleteFactor(factor).setBlockQueue(blockFromWorld);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.user.sendMessage("challenges.errors.not-close-enough",
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-close-enough",
|
||||||
"[number]",
|
"[number]", String.valueOf(this.getIslandRequirements().getSearchRadius())));
|
||||||
String.valueOf(this.getIslandRequirements().getSearchRadius()));
|
|
||||||
|
|
||||||
blocks.forEach((k, v) -> user.sendMessage("challenges.errors.you-still-need",
|
blocks.forEach((k, v) -> Utils.sendMessage(this.user,
|
||||||
|
this.user.getTranslation("challenges.errors.you-still-need",
|
||||||
"[amount]", String.valueOf(v),
|
"[amount]", String.valueOf(v),
|
||||||
"[item]", Util.prettifyText(k.toString())));
|
"[item]", Utils.prettifyObject(k, this.user))));
|
||||||
|
|
||||||
|
|
||||||
// kick garbage collector
|
// kick garbage collector
|
||||||
@ -1235,9 +1240,10 @@ public class TryToComplete
|
|||||||
return new ChallengeResult().setMeetsRequirements().setCompleteFactor(factor).setEntityQueue(entityQueue);
|
return new ChallengeResult().setMeetsRequirements().setCompleteFactor(factor).setEntityQueue(entityQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
minimalRequirements.forEach((reqEnt, amount) -> this.user.sendMessage("challenges.errors.you-still-need",
|
minimalRequirements.forEach((reqEnt, amount) ->
|
||||||
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.you-still-need",
|
||||||
"[amount]", String.valueOf(amount),
|
"[amount]", String.valueOf(amount),
|
||||||
"[item]", Util.prettifyText(reqEnt.toString())));
|
"[item]", Utils.prettifyObject(reqEnt, this.user))));
|
||||||
|
|
||||||
// Kick garbage collector
|
// Kick garbage collector
|
||||||
entitiesFound.clear();
|
entitiesFound.clear();
|
||||||
@ -1311,46 +1317,44 @@ public class TryToComplete
|
|||||||
{
|
{
|
||||||
OtherRequirements requirements = this.getOtherRequirements();
|
OtherRequirements requirements = this.getOtherRequirements();
|
||||||
|
|
||||||
if (!this.addon.isLevelProvided() &&
|
if (!this.addon.isLevelProvided() && requirements.getRequiredIslandLevel() != 0)
|
||||||
requirements.getRequiredIslandLevel() != 0)
|
|
||||||
{
|
{
|
||||||
this.user.sendMessage("challenges.errors.missing-addon");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.missing-addon"));
|
||||||
}
|
}
|
||||||
else if (!this.addon.isEconomyProvided() &&
|
else if (!this.addon.isEconomyProvided() &&
|
||||||
requirements.getRequiredMoney() != 0)
|
requirements.getRequiredMoney() != 0)
|
||||||
{
|
{
|
||||||
this.user.sendMessage("challenges.errors.missing-addon");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.missing-addon"));
|
||||||
}
|
}
|
||||||
else if (this.addon.isEconomyProvided() && requirements.getRequiredMoney() < 0)
|
else if (this.addon.isEconomyProvided() && requirements.getRequiredMoney() < 0)
|
||||||
{
|
{
|
||||||
this.user.sendMessage("challenges.errors.incorrect");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.incorrect"));
|
||||||
}
|
}
|
||||||
else if (this.addon.isEconomyProvided() &&
|
else if (this.addon.isEconomyProvided() &&
|
||||||
!this.addon.getEconomyProvider().has(this.user, requirements.getRequiredMoney()))
|
!this.addon.getEconomyProvider().has(this.user, requirements.getRequiredMoney()))
|
||||||
{
|
{
|
||||||
this.user.sendMessage("challenges.errors.not-enough-money",
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-enough-money",
|
||||||
"[value]",
|
"[value]",
|
||||||
Double.toString(requirements.getRequiredMoney()));
|
Double.toString(requirements.getRequiredMoney())));
|
||||||
}
|
}
|
||||||
else if (requirements.getRequiredExperience() < 0)
|
else if (requirements.getRequiredExperience() < 0)
|
||||||
{
|
{
|
||||||
this.user.sendMessage("challenges.errors.incorrect");
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.incorrect"));
|
||||||
}
|
}
|
||||||
else if (this.user.getPlayer().getTotalExperience() < requirements.getRequiredExperience() &&
|
else if (this.user.getPlayer().getTotalExperience() < requirements.getRequiredExperience() &&
|
||||||
this.user.getPlayer().getGameMode() != GameMode.CREATIVE)
|
this.user.getPlayer().getGameMode() != GameMode.CREATIVE)
|
||||||
{
|
{
|
||||||
// Players in creative gamemode has infinite amount of EXP.
|
// Players in creative gamemode has infinite amount of EXP.
|
||||||
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-enough-experience",
|
||||||
this.user.sendMessage("challenges.errors.not-enough-experience",
|
"[value]",
|
||||||
"[value]",
|
Integer.toString(requirements.getRequiredExperience())));
|
||||||
Integer.toString(requirements.getRequiredExperience()));
|
|
||||||
}
|
}
|
||||||
else if (this.addon.isLevelProvided() &&
|
else if (this.addon.isLevelProvided() &&
|
||||||
this.addon.getLevelAddon().getIslandLevel(this.world, this.user.getUniqueId()) < requirements.getRequiredIslandLevel())
|
this.addon.getLevelAddon().getIslandLevel(this.world, this.user.getUniqueId()) < requirements.getRequiredIslandLevel())
|
||||||
{
|
{
|
||||||
this.user.sendMessage("challenges.errors.island-level",
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.island-level",
|
||||||
TextVariables.NUMBER,
|
TextVariables.NUMBER,
|
||||||
String.valueOf(requirements.getRequiredIslandLevel()));
|
String.valueOf(requirements.getRequiredIslandLevel())));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1402,9 +1406,9 @@ public class TryToComplete
|
|||||||
|
|
||||||
if (currentValue < requirements.getAmount())
|
if (currentValue < requirements.getAmount())
|
||||||
{
|
{
|
||||||
this.user.sendMessage("challenges.errors.requirement-not-met",
|
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.requirement-not-met",
|
||||||
TextVariables.NUMBER, String.valueOf(requirements.getAmount()),
|
TextVariables.NUMBER, String.valueOf(requirements.getAmount()),
|
||||||
"[value]", String.valueOf(currentValue));
|
"[value]", String.valueOf(currentValue)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user