mirror of
https://github.com/BentoBoxWorld/Challenges.git
synced 2024-11-24 19:45:14 +01:00
Add support for gamemode-specific translations.
This was a request from Floris
This commit is contained in:
parent
e0377fd352
commit
9953459e50
@ -55,7 +55,7 @@ public class ChallengesGlobalPlayerCommand extends CompositeCommand
|
||||
|
||||
if (this.gameModeAddons.isEmpty())
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation(Constants.ERRORS + "not-hooked"));
|
||||
Utils.sendMessage(user, user.getWorld(), Constants.ERRORS + "not-hooked");
|
||||
return false;
|
||||
}
|
||||
else if (this.gameModeAddons.size() == 1)
|
||||
@ -80,7 +80,7 @@ public class ChallengesGlobalPlayerCommand extends CompositeCommand
|
||||
}
|
||||
}
|
||||
|
||||
Utils.sendMessage(user, user.getTranslation("general.errors.wrong-world"));
|
||||
Utils.sendMessage(user, user.getWorld(), "general.errors.wrong-world");
|
||||
}
|
||||
else if (this.<ChallengesAddon>getAddon().getChallengesSettings().getUserGuiMode() == GuiMode.GAMEMODE_LIST)
|
||||
{
|
||||
|
@ -8,6 +8,7 @@ import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
import world.bentobox.challenges.ChallengesAddon;
|
||||
import world.bentobox.challenges.panel.user.ChallengesPanel;
|
||||
import world.bentobox.challenges.utils.Constants;
|
||||
import world.bentobox.challenges.utils.Utils;
|
||||
|
||||
|
||||
@ -31,7 +32,7 @@ public class ChallengesPlayerCommand extends CompositeCommand
|
||||
if (!this.getIWM().inWorld(user.getWorld()) ||
|
||||
!Util.sameWorld(this.getWorld(), user.getWorld())) {
|
||||
// Not a GameMode world.
|
||||
Utils.sendMessage(user, user.getTranslation("general.errors.wrong-world"));
|
||||
Utils.sendMessage(user, user.getWorld(), "general.errors.wrong-world");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -47,13 +48,13 @@ public class ChallengesPlayerCommand extends CompositeCommand
|
||||
map(GameModeAddon::getAdminCommand).
|
||||
map(optionalAdminCommand -> optionalAdminCommand.map(CompositeCommand::getTopLabel).orElse(this.getTopLabel())).
|
||||
orElse(this.getTopLabel());
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.errors.no-challenges-admin",
|
||||
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "no-challenges-admin",
|
||||
"[command]",
|
||||
topLabel + " " + this.<ChallengesAddon>getAddon().getChallengesSettings().getAdminMainCommand().split(" ")[0]));
|
||||
topLabel + " " + this.<ChallengesAddon>getAddon().getChallengesSettings().getAdminMainCommand().split(" ")[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.errors.no-challenges"));
|
||||
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "no-challenges");
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -62,14 +63,14 @@ public class ChallengesPlayerCommand extends CompositeCommand
|
||||
if (this.getIslands().getIsland(this.getWorld(), user) == null)
|
||||
{
|
||||
// Do not open gui if there is no island for this player.
|
||||
Utils.sendMessage(user, user.getTranslation("general.errors.no-island"));
|
||||
Utils.sendMessage(user, this.getWorld(), "general.errors.no-island");
|
||||
return false;
|
||||
} else if (ChallengesAddon.CHALLENGES_WORLD_PROTECTION.isSetForWorld(this.getWorld()) &&
|
||||
!this.getIslands().locationIsOnIsland(user.getPlayer(), user.getLocation()))
|
||||
{
|
||||
// Do not open gui if player is not on the island, but challenges requires island for
|
||||
// completion.
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.errors.not-on-island"));
|
||||
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "not-on-island");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ import world.bentobox.bentobox.util.Util;
|
||||
import world.bentobox.challenges.ChallengesAddon;
|
||||
import world.bentobox.challenges.database.object.Challenge;
|
||||
import world.bentobox.challenges.tasks.TryToComplete;
|
||||
import world.bentobox.challenges.utils.Constants;
|
||||
import world.bentobox.challenges.utils.Utils;
|
||||
|
||||
|
||||
@ -54,7 +55,7 @@ public class CompleteChallengeCommand extends CompositeCommand
|
||||
{
|
||||
if (args.isEmpty())
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.errors.no-name"));
|
||||
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "no-name");
|
||||
this.showHelp(this, user);
|
||||
return false;
|
||||
}
|
||||
@ -73,7 +74,7 @@ public class CompleteChallengeCommand extends CompositeCommand
|
||||
|
||||
if (!canMultipleTimes && count > 1)
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.error.no-multiple-permission"));
|
||||
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "no-multiple-permission");
|
||||
count = 1;
|
||||
}
|
||||
|
||||
@ -87,7 +88,7 @@ public class CompleteChallengeCommand extends CompositeCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.errors.unknown-challenge"));
|
||||
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "unknown-challenge");
|
||||
this.showHelp(this, user);
|
||||
return false;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class ChallengesGlobalAdminCommand extends CompositeCommand
|
||||
|
||||
if (this.gameModeAddons.isEmpty())
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation(Constants.ERRORS + "not-hooked"));
|
||||
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "not-hooked");
|
||||
return false;
|
||||
}
|
||||
else if (this.gameModeAddons.size() == 1)
|
||||
|
@ -56,7 +56,7 @@ public class CompleteCommand extends CompositeCommand
|
||||
{
|
||||
if (user.isPlayer())
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.errors.no-name"));
|
||||
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "no-name");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -67,7 +67,7 @@ public class CompleteCommand extends CompositeCommand
|
||||
{
|
||||
if (user.isPlayer())
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.errors.missing-arguments"));
|
||||
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "missing-arguments");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -82,9 +82,11 @@ public class CompleteCommand extends CompositeCommand
|
||||
{
|
||||
if (user.isPlayer())
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("general.errors.unknown-player",
|
||||
Utils.sendMessage(user,
|
||||
this.getWorld(),
|
||||
"general.errors.unknown-player",
|
||||
TextVariables.NAME,
|
||||
args.get(0)));
|
||||
args.get(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -109,9 +111,11 @@ public class CompleteCommand extends CompositeCommand
|
||||
|
||||
if (user.isPlayer())
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.messages.completed",
|
||||
Utils.sendMessage(user,
|
||||
this.getWorld(),
|
||||
Constants.MESSAGES + "completed",
|
||||
Constants.PARAMETER_NAME, challenge.getFriendlyName(),
|
||||
Constants.PARAMETER_PLAYER, target.getName()));
|
||||
Constants.PARAMETER_PLAYER, target.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -123,7 +127,9 @@ public class CompleteCommand extends CompositeCommand
|
||||
{
|
||||
if (user.isPlayer())
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.messages.already-completed"));
|
||||
Utils.sendMessage(user,
|
||||
this.getWorld(),
|
||||
Constants.MESSAGES + "already-completed");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -137,7 +143,9 @@ public class CompleteCommand extends CompositeCommand
|
||||
{
|
||||
if (user.isPlayer())
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.errors.unknown-challenge"));
|
||||
Utils.sendMessage(user,
|
||||
this.getWorld(),
|
||||
Constants.ERRORS + "unknown-challenge");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -49,13 +49,13 @@ public class ReloadChallenges extends CompositeCommand
|
||||
if (args.isEmpty())
|
||||
{
|
||||
this.manager.load();
|
||||
Utils.sendMessage(user, user.getTranslation("general.success"));
|
||||
Utils.sendMessage(user, this.getWorld(), "general.success");
|
||||
return true;
|
||||
}
|
||||
else if (args.get(0).equalsIgnoreCase("hard"))
|
||||
{
|
||||
this.manager.reload();
|
||||
Utils.sendMessage(user, user.getTranslation("general.success"));
|
||||
Utils.sendMessage(user, this.getWorld(), "general.success");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@ -56,7 +56,7 @@ public class ResetCommand extends CompositeCommand
|
||||
{
|
||||
if (user.isPlayer())
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.errors.no-name"));
|
||||
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "no-name");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -67,7 +67,7 @@ public class ResetCommand extends CompositeCommand
|
||||
{
|
||||
if (user.isPlayer())
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.errors.missing-arguments"));
|
||||
Utils.sendMessage(user, this.getWorld(), Constants.ERRORS + "missing-arguments");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -82,8 +82,11 @@ public class ResetCommand extends CompositeCommand
|
||||
{
|
||||
if (user.isPlayer())
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("general.errors.unknown-player",
|
||||
TextVariables.NAME, args.get(0)));
|
||||
Utils.sendMessage(user,
|
||||
this.getWorld(),
|
||||
Constants.ERRORS + "unknown-player",
|
||||
TextVariables.NAME,
|
||||
args.get(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -102,8 +105,11 @@ public class ResetCommand extends CompositeCommand
|
||||
|
||||
if (user.isPlayer())
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.messages.reset-all",
|
||||
Constants.PARAMETER_PLAYER, target.getName()));
|
||||
Utils.sendMessage(user,
|
||||
this.getWorld(),
|
||||
Constants.MESSAGES + "reset-all",
|
||||
Constants.PARAMETER_PLAYER,
|
||||
target.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -125,9 +131,11 @@ public class ResetCommand extends CompositeCommand
|
||||
|
||||
if (user.isPlayer())
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.messages.reset",
|
||||
Utils.sendMessage(user,
|
||||
this.getWorld(),
|
||||
Constants.MESSAGES + "reset",
|
||||
Constants.PARAMETER_NAME, challenge.getFriendlyName(),
|
||||
Constants.PARAMETER_PLAYER, target.getName()));
|
||||
Constants.PARAMETER_PLAYER, target.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -139,7 +147,9 @@ public class ResetCommand extends CompositeCommand
|
||||
{
|
||||
if (user.isPlayer())
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.messages.not-completed"));
|
||||
Utils.sendMessage(user,
|
||||
this.getWorld(),
|
||||
Constants.MESSAGES + "not-completed");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -153,7 +163,9 @@ public class ResetCommand extends CompositeCommand
|
||||
{
|
||||
if (user.isPlayer())
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.errors.unknown-challenge"));
|
||||
Utils.sendMessage(user,
|
||||
this.getWorld(),
|
||||
Constants.ERRORS + "unknown-challenge");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -82,7 +82,11 @@ public class ChallengesImportManager
|
||||
{
|
||||
if (user != null)
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation(Constants.ERRORS + "no-file", Constants.PARAMETER_FILE, file));
|
||||
Utils.sendMessage(user,
|
||||
world,
|
||||
Constants.ERRORS + "no-file",
|
||||
Constants.PARAMETER_FILE,
|
||||
file);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -98,8 +102,11 @@ public class ChallengesImportManager
|
||||
{
|
||||
if (user != null)
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation(Constants.ERRORS + "no-load",
|
||||
Constants.PARAMETER_FILE, file, TextVariables.DESCRIPTION, e.getMessage()));
|
||||
Utils.sendMessage(user,
|
||||
world,
|
||||
Constants.ERRORS + "no-load",
|
||||
Constants.PARAMETER_FILE, file,
|
||||
TextVariables.DESCRIPTION, e.getMessage());
|
||||
}
|
||||
|
||||
this.addon.logError("Exception when loading file. " + e.getMessage());
|
||||
@ -114,8 +121,9 @@ public class ChallengesImportManager
|
||||
if (user != null)
|
||||
{
|
||||
Utils.sendMessage(user,
|
||||
user.getTranslation(Constants.ERRORS + "not-a-gamemode-world",
|
||||
Constants.PARAMETER_WORLD, world.getName()));
|
||||
world,
|
||||
Constants.ERRORS + "not-a-gamemode-world",
|
||||
Constants.PARAMETER_WORLD, world.getName());
|
||||
}
|
||||
|
||||
this.addon.logWarning("Given world is not a gamemode world.");
|
||||
@ -151,6 +159,7 @@ public class ChallengesImportManager
|
||||
challengeCount = reader.getKeys(false).stream().
|
||||
mapToInt(challengeId -> this.createChallenge(challengeId,
|
||||
prefix,
|
||||
world,
|
||||
reader.getConfigurationSection(challengeId))).
|
||||
sum();
|
||||
}
|
||||
@ -174,9 +183,10 @@ public class ChallengesImportManager
|
||||
if (user != null)
|
||||
{
|
||||
Utils.sendMessage(user,
|
||||
user.getTranslation(Constants.MESSAGES + "import-count",
|
||||
"[levels]", String.valueOf(levelCount),
|
||||
"[challenges]", String.valueOf(challengeCount)));
|
||||
world,
|
||||
Constants.MESSAGES + "import-count",
|
||||
"[levels]", String.valueOf(levelCount),
|
||||
"[challenges]", String.valueOf(challengeCount));
|
||||
}
|
||||
|
||||
this.addon.log("Imported " + challengeCount + " challenges and " +
|
||||
@ -188,11 +198,13 @@ public class ChallengesImportManager
|
||||
* This method creates challenge from given config section.
|
||||
* @param challengeId Challenge ID.
|
||||
* @param prefix GameMode prefix.
|
||||
* @param world world where challenge is created.
|
||||
* @param section Configuration Section that contains information.
|
||||
* @return 1 if challenge is created, otherwise 0.
|
||||
*/
|
||||
private int createChallenge(String challengeId,
|
||||
String prefix,
|
||||
World world,
|
||||
@Nullable ConfigurationSection section)
|
||||
{
|
||||
if (section == null)
|
||||
@ -266,7 +278,7 @@ public class ChallengesImportManager
|
||||
}
|
||||
|
||||
this.addon.getChallengesManager().saveChallenge(challenge);
|
||||
this.addon.getChallengesManager().loadChallenge(challenge, true, null, true);
|
||||
this.addon.getChallengesManager().loadChallenge(challenge, world, true, null, true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -632,7 +644,7 @@ public class ChallengesImportManager
|
||||
}
|
||||
|
||||
this.addon.getChallengesManager().saveLevel(level);
|
||||
this.addon.getChallengesManager().loadLevel(level, true, null, true);
|
||||
this.addon.getChallengesManager().loadLevel(level, world,true, null, true);
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
@ -696,7 +708,7 @@ public class ChallengesImportManager
|
||||
challenge.setLevel(uniqueIDPrefix + challenge.getLevel());
|
||||
}
|
||||
// Load challenge in memory
|
||||
manager.loadChallenge(challenge, false, user, user == null);
|
||||
manager.loadChallenge(challenge, world, false, user, user == null);
|
||||
});
|
||||
|
||||
downloadedChallenges.getLevelList().forEach(challengeLevel -> {
|
||||
@ -709,7 +721,7 @@ public class ChallengesImportManager
|
||||
map(challenge -> uniqueIDPrefix + challenge).
|
||||
collect(Collectors.toSet()));
|
||||
// Load level in memory
|
||||
manager.loadLevel(challengeLevel, false, user, user == null);
|
||||
manager.loadLevel(challengeLevel, world, false, user, user == null);
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -746,7 +758,7 @@ public class ChallengesImportManager
|
||||
{
|
||||
if (user.isPlayer())
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.errors.exist-challenges-or-levels"));
|
||||
Utils.sendMessage(user, world, Constants.ERRORS + "exist-challenges-or-levels");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -773,7 +785,7 @@ public class ChallengesImportManager
|
||||
challenge.setLevel(uniqueIDPrefix + challenge.getLevel());
|
||||
}
|
||||
// Load challenge in memory
|
||||
manager.loadChallenge(challenge, false, user, user == null);
|
||||
manager.loadChallenge(challenge, world, false, user, user == null);
|
||||
});
|
||||
|
||||
downloadedChallenges.getLevelList().forEach(challengeLevel -> {
|
||||
@ -786,7 +798,7 @@ public class ChallengesImportManager
|
||||
map(challenge -> uniqueIDPrefix + challenge).
|
||||
collect(Collectors.toSet()));
|
||||
// Load level in memory
|
||||
manager.loadLevel(challengeLevel, false, user, user == null);
|
||||
manager.loadLevel(challengeLevel, world, false, user, user == null);
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -815,8 +827,9 @@ public class ChallengesImportManager
|
||||
if (user.isPlayer())
|
||||
{
|
||||
Utils.sendMessage(user,
|
||||
user.getTranslation(Constants.ERRORS + "file-exist",
|
||||
Constants.PARAMETER_FILE, fileName));
|
||||
world,
|
||||
Constants.ERRORS + "file-exist",
|
||||
Constants.PARAMETER_FILE, fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -882,9 +895,10 @@ public class ChallengesImportManager
|
||||
if (user.isPlayer())
|
||||
{
|
||||
Utils.sendMessage(user,
|
||||
user.getTranslation(Constants.ERRORS + "no-load",
|
||||
Constants.PARAMETER_FILE, fileName,
|
||||
TextVariables.DESCRIPTION, e.getMessage()));
|
||||
world,
|
||||
Constants.ERRORS + "no-load",
|
||||
Constants.PARAMETER_FILE, fileName,
|
||||
TextVariables.DESCRIPTION, e.getMessage());
|
||||
}
|
||||
|
||||
this.addon.logError("Could not save json file: " + e.getMessage());
|
||||
@ -894,9 +908,10 @@ public class ChallengesImportManager
|
||||
if (user.isPlayer())
|
||||
{
|
||||
Utils.sendMessage(user,
|
||||
user.getTranslation(Constants.CONVERSATIONS + "database-export-completed",
|
||||
Constants.PARAMETER_WORLD, world.getName(),
|
||||
Constants.PARAMETER_FILE, fileName));
|
||||
world,
|
||||
Constants.CONVERSATIONS + "database-export-completed",
|
||||
Constants.PARAMETER_WORLD, world.getName(),
|
||||
Constants.PARAMETER_FILE, fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -28,6 +28,7 @@ import world.bentobox.challenges.events.ChallengeCompletedEvent;
|
||||
import world.bentobox.challenges.events.ChallengeResetAllEvent;
|
||||
import world.bentobox.challenges.events.ChallengeResetEvent;
|
||||
import world.bentobox.challenges.events.LevelCompletedEvent;
|
||||
import world.bentobox.challenges.utils.Constants;
|
||||
import world.bentobox.challenges.utils.LevelStatus;
|
||||
import world.bentobox.challenges.utils.Utils;
|
||||
|
||||
@ -97,7 +98,6 @@ public class ChallengesManager
|
||||
* String for free Challenge Level.
|
||||
*/
|
||||
public static final String FREE = "";
|
||||
public static final String VALUE = "[value]";
|
||||
public static final String USER_ID = "user-id";
|
||||
public static final String CHALLENGE_ID = "challenge-id";
|
||||
public static final String ADMIN_ID = "admin-id";
|
||||
@ -230,7 +230,7 @@ public class ChallengesManager
|
||||
*/
|
||||
private void loadChallenge(@NonNull Challenge challenge)
|
||||
{
|
||||
this.loadChallenge(challenge, true, null, true);
|
||||
this.loadChallenge(challenge, null, true, null, true);
|
||||
}
|
||||
|
||||
|
||||
@ -244,9 +244,10 @@ public class ChallengesManager
|
||||
* @return - true if imported
|
||||
*/
|
||||
public boolean loadChallenge(@Nullable Challenge challenge,
|
||||
boolean overwrite,
|
||||
User user,
|
||||
boolean silent)
|
||||
World world,
|
||||
boolean overwrite,
|
||||
User user,
|
||||
boolean silent)
|
||||
{
|
||||
// This may happen if database somehow failed to load challenge and return
|
||||
// null as input.
|
||||
@ -254,7 +255,10 @@ public class ChallengesManager
|
||||
{
|
||||
if (!silent)
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("load-error", "[value]", "NULL"));
|
||||
Utils.sendMessage(user,
|
||||
world,
|
||||
Constants.ERRORS + "load-error",
|
||||
Constants.PARAMETER_VALUE, "NULL");
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -264,8 +268,10 @@ public class ChallengesManager
|
||||
{
|
||||
if (!silent)
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.errors.invalid-challenge",
|
||||
"[challenge]", challenge.getUniqueId()));
|
||||
Utils.sendMessage(user,
|
||||
world,
|
||||
Constants.ERRORS + "invalid-challenge",
|
||||
Constants.PARAMETER_CHALLENGE, challenge.getUniqueId());
|
||||
}
|
||||
|
||||
this.addon.logWarning("Data for challenge `" + challenge.getUniqueId() + "` is not valid. It could be NULL element in item-stack!");
|
||||
@ -280,8 +286,10 @@ public class ChallengesManager
|
||||
{
|
||||
if (!silent)
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.messages.load-skipping",
|
||||
VALUE, challenge.getFriendlyName()));
|
||||
Utils.sendMessage(user,
|
||||
world,
|
||||
Constants.MESSAGES + "load-skipping",
|
||||
Constants.PARAMETER_VALUE, challenge.getFriendlyName());
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -290,8 +298,10 @@ public class ChallengesManager
|
||||
{
|
||||
if (!silent)
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.messages.load-overwriting",
|
||||
VALUE, challenge.getFriendlyName()));
|
||||
Utils.sendMessage(user,
|
||||
world,
|
||||
Constants.MESSAGES + "load-overwriting",
|
||||
Constants.PARAMETER_VALUE, challenge.getFriendlyName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -299,8 +309,10 @@ public class ChallengesManager
|
||||
{
|
||||
if (!silent)
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.messages.load-add",
|
||||
VALUE, challenge.getFriendlyName()));
|
||||
Utils.sendMessage(user,
|
||||
world,
|
||||
Constants.MESSAGES + "load-add",
|
||||
Constants.PARAMETER_VALUE, challenge.getFriendlyName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -316,7 +328,7 @@ public class ChallengesManager
|
||||
*/
|
||||
private void loadLevel(@NonNull ChallengeLevel level)
|
||||
{
|
||||
this.loadLevel(level, true, null, true);
|
||||
this.loadLevel(level, null, true, null, true);
|
||||
}
|
||||
|
||||
|
||||
@ -331,6 +343,7 @@ public class ChallengesManager
|
||||
* @return boolean that indicate about load status.
|
||||
*/
|
||||
public boolean loadLevel(@Nullable ChallengeLevel level,
|
||||
World world,
|
||||
boolean overwrite,
|
||||
User user,
|
||||
boolean silent)
|
||||
@ -341,7 +354,10 @@ public class ChallengesManager
|
||||
{
|
||||
if (!silent)
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("load-error", "[value]", "NULL"));
|
||||
Utils.sendMessage(user,
|
||||
world,
|
||||
Constants.ERRORS + "load-error",
|
||||
Constants.PARAMETER_VALUE, "NULL");
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -351,8 +367,10 @@ public class ChallengesManager
|
||||
{
|
||||
if (!silent)
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.errors.invalid-level",
|
||||
"[level]", level.getUniqueId()));
|
||||
Utils.sendMessage(user,
|
||||
world,
|
||||
Constants.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!");
|
||||
@ -363,8 +381,10 @@ public class ChallengesManager
|
||||
{
|
||||
if (user != null)
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.errors.load-error",
|
||||
VALUE, level.getFriendlyName()));
|
||||
Utils.sendMessage(user,
|
||||
world,
|
||||
Constants.ERRORS + "load-error",
|
||||
Constants.PARAMETER_VALUE, level.getFriendlyName());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -380,8 +400,10 @@ public class ChallengesManager
|
||||
{
|
||||
if (!silent)
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.messages.load-skipping",
|
||||
VALUE, level.getFriendlyName()));
|
||||
Utils.sendMessage(user,
|
||||
world,
|
||||
Constants.MESSAGES + "load-skipping",
|
||||
Constants.PARAMETER_VALUE, level.getFriendlyName());
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -390,8 +412,10 @@ public class ChallengesManager
|
||||
{
|
||||
if (!silent)
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.messages.load-overwriting",
|
||||
VALUE, level.getFriendlyName()));
|
||||
Utils.sendMessage(user,
|
||||
world,
|
||||
Constants.MESSAGES + "load-overwriting",
|
||||
Constants.PARAMETER_VALUE, level.getFriendlyName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -399,8 +423,10 @@ public class ChallengesManager
|
||||
{
|
||||
if (!silent)
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.messages.load-add",
|
||||
VALUE, level.getFriendlyName()));
|
||||
Utils.sendMessage(user,
|
||||
world,
|
||||
Constants.MESSAGES + "load-add",
|
||||
Constants.PARAMETER_VALUE, level.getFriendlyName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -486,7 +512,7 @@ public class ChallengesManager
|
||||
if (!this.challengeCacheData.containsKey(uniqueID))
|
||||
{
|
||||
if (!this.challengeDatabase.objectExists(uniqueID) ||
|
||||
!this.loadChallenge(this.challengeDatabase.loadObject(uniqueID), false, null, true))
|
||||
!this.loadChallenge(this.challengeDatabase.loadObject(uniqueID), Bukkit.getWorld(level.getWorld()), false, null, true))
|
||||
{
|
||||
this.addon.logError("Cannot find " + uniqueID + " challenge for " + level.getUniqueId());
|
||||
return false;
|
||||
@ -640,7 +666,9 @@ public class ChallengesManager
|
||||
|
||||
if (user.isPlayer())
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.messages.migrate-start"));
|
||||
Utils.sendMessage(user,
|
||||
world,
|
||||
Constants.MESSAGES + "migrate-start");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -656,7 +684,9 @@ public class ChallengesManager
|
||||
|
||||
if (user.isPlayer())
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.messages.migrate-end"));
|
||||
Utils.sendMessage(user,
|
||||
world,
|
||||
Constants.MESSAGES + "migrate-end");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -667,7 +697,9 @@ public class ChallengesManager
|
||||
{
|
||||
if (user.isPlayer())
|
||||
{
|
||||
Utils.sendMessage(user, user.getTranslation("challenges.messages.migrate-not"));
|
||||
Utils.sendMessage(user,
|
||||
world,
|
||||
Constants.MESSAGES + "migrate-not");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -156,7 +156,7 @@ public class EditChallengePanel extends CommonPanel
|
||||
// This will ensure that all main things will be always stored
|
||||
this.addon.getChallengesManager().saveChallenge(this.challenge);
|
||||
// If for some reason challenge is not loaded, do it.
|
||||
this.addon.getChallengesManager().loadChallenge(this.challenge, false, null, true);
|
||||
this.addon.getChallengesManager().loadChallenge(this.challenge, this.world,false, null, true);
|
||||
|
||||
panelBuilder.build();
|
||||
}
|
||||
@ -445,8 +445,10 @@ public class EditChallengePanel extends CommonPanel
|
||||
else
|
||||
{
|
||||
Utils.sendMessage(this.user,
|
||||
this.user.getTranslation(Constants.CONVERSATIONS + "invalid-challenge",
|
||||
"[challenge]", this.challenge.getFriendlyName()));
|
||||
this.world,
|
||||
Constants.CONVERSATIONS + "invalid-challenge",
|
||||
Constants.PARAMETER_CHALLENGE,
|
||||
this.challenge.getFriendlyName());
|
||||
this.challenge.setDeployed(false);
|
||||
}
|
||||
|
||||
|
@ -166,8 +166,9 @@ public class LibraryPanel extends CommonPagedPanel<LibraryEntry>
|
||||
{
|
||||
if (this.libraryEntries.isEmpty())
|
||||
{
|
||||
Utils.sendMessage(this.user, this.user.getTranslation(
|
||||
Constants.ERRORS + "no-library-entries"));
|
||||
Utils.sendMessage(this.user,
|
||||
this.world,
|
||||
Constants.ERRORS + "no-library-entries");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -311,8 +312,9 @@ public class LibraryPanel extends CommonPagedPanel<LibraryEntry>
|
||||
{
|
||||
this.blockedForDownland = true;
|
||||
|
||||
Utils.sendMessage(this.user, this.user.getTranslation(
|
||||
Constants.MESSAGES + "start-downloading"));
|
||||
Utils.sendMessage(this.user,
|
||||
this.world,
|
||||
Constants.MESSAGES + "start-downloading");
|
||||
|
||||
// Run download task after 5 ticks.
|
||||
this.updateTask = this.addon.getPlugin().getServer().getScheduler().
|
||||
|
@ -77,7 +77,7 @@ public class ChallengesPanel extends CommonPanel
|
||||
if (!this.containsChallenges)
|
||||
{
|
||||
this.addon.logError("There are no challenges set up!");
|
||||
Utils.sendMessage(user, user.getTranslation(Constants.ERRORS + "no-challenges"));
|
||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "no-challenges");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -265,18 +265,21 @@ public class TryToComplete
|
||||
// Send message about first completion only if it is completed only once.
|
||||
if (result.getFactor() == 1)
|
||||
{
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.messages.you-completed-challenge",
|
||||
"[value]", this.challenge.getFriendlyName()));
|
||||
Utils.sendMessage(this.user,
|
||||
this.world,
|
||||
Constants.MESSAGES + "you-completed-challenge",
|
||||
Constants.PARAMETER_VALUE, this.challenge.getFriendlyName());
|
||||
}
|
||||
|
||||
if (this.addon.getChallengesSettings().isBroadcastMessages())
|
||||
{
|
||||
Bukkit.getOnlinePlayers().stream().
|
||||
map(User::getInstance).
|
||||
forEach(user -> Utils.sendMessage(user, user.getTranslation(
|
||||
"challenges.messages.name-has-completed-challenge",
|
||||
forEach(user -> Utils.sendMessage(user,
|
||||
this.world,
|
||||
Constants.MESSAGES + "name-has-completed-challenge",
|
||||
Constants.PARAMETER_NAME, this.user.getName(),
|
||||
"[value]", this.challenge.getFriendlyName())));
|
||||
Constants.PARAMETER_VALUE, this.challenge.getFriendlyName()));
|
||||
}
|
||||
|
||||
// sends title to player on challenge completion
|
||||
@ -327,14 +330,18 @@ public class TryToComplete
|
||||
|
||||
if (result.getFactor() > 1)
|
||||
{
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.messages.you-repeated-challenge-multiple",
|
||||
"[value]", this.challenge.getFriendlyName(),
|
||||
"[count]", Integer.toString(result.getFactor())));
|
||||
Utils.sendMessage(this.user,
|
||||
this.world,
|
||||
Constants.MESSAGES + "you-repeated-challenge-multiple",
|
||||
Constants.PARAMETER_VALUE, this.challenge.getFriendlyName(),
|
||||
"[count]", Integer.toString(result.getFactor()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.messages.you-repeated-challenge",
|
||||
"[value]", this.challenge.getFriendlyName()));
|
||||
Utils.sendMessage(this.user,
|
||||
this.world,
|
||||
Constants.MESSAGES + "you-repeated-challenge",
|
||||
Constants.PARAMETER_VALUE, this.challenge.getFriendlyName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -372,17 +379,20 @@ public class TryToComplete
|
||||
// Run commands
|
||||
this.runCommands(level.getRewardCommands());
|
||||
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.messages.you-completed-level",
|
||||
"[value]", level.getFriendlyName()));
|
||||
Utils.sendMessage(this.user,
|
||||
this.world,
|
||||
Constants.MESSAGES + "you-completed-level",
|
||||
Constants.PARAMETER_VALUE, level.getFriendlyName());
|
||||
|
||||
if (this.addon.getChallengesSettings().isBroadcastMessages())
|
||||
{
|
||||
Bukkit.getOnlinePlayers().stream().
|
||||
map(User::getInstance).
|
||||
forEach(user -> Utils.sendMessage(user, user.getTranslation(
|
||||
"challenges.messages.name-has-completed-level",
|
||||
forEach(user -> Utils.sendMessage(user,
|
||||
this.world,
|
||||
Constants.MESSAGES + "name-has-completed-level",
|
||||
Constants.PARAMETER_NAME, this.user.getName(),
|
||||
"[value]", level.getFriendlyName())));
|
||||
Constants.PARAMETER_VALUE, level.getFriendlyName()));
|
||||
}
|
||||
|
||||
this.manager.setLevelComplete(this.user, this.world, level);
|
||||
@ -447,7 +457,8 @@ public class TryToComplete
|
||||
if (sumEverything != removedAmount)
|
||||
{
|
||||
Utils.sendMessage(this.user,
|
||||
this.user.getTranslation("challenges.errors.cannot-remove-items"));
|
||||
this.world,
|
||||
Constants.ERRORS + "cannot-remove-items");
|
||||
|
||||
result.removedItems = removedItems;
|
||||
result.meetsRequirements = false;
|
||||
@ -661,18 +672,18 @@ public class TryToComplete
|
||||
// Check the world
|
||||
if (!this.challenge.isDeployed())
|
||||
{
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-deployed"));
|
||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "not-deployed");
|
||||
result = EMPTY_RESULT;
|
||||
}
|
||||
else if (maxTimes < 1)
|
||||
{
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-valid-integer"));
|
||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "not-valid-integer");
|
||||
result = EMPTY_RESULT;
|
||||
}
|
||||
else if (Util.getWorld(this.world) != Util.getWorld(this.user.getWorld()) ||
|
||||
!this.challenge.matchGameMode(Utils.getGameMode(this.world)))
|
||||
{
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("general.errors.wrong-world"));
|
||||
Utils.sendMessage(this.user, this.world, "general.errors.wrong-world");
|
||||
result = EMPTY_RESULT;
|
||||
}
|
||||
// Player is not on island
|
||||
@ -680,7 +691,7 @@ public class TryToComplete
|
||||
ChallengesAddon.CHALLENGES_WORLD_PROTECTION.isSetForWorld(this.world) &&
|
||||
!this.addon.getIslands().locationIsOnIsland(this.user.getPlayer(), this.user.getLocation()))
|
||||
{
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-on-island"));
|
||||
Utils.sendMessage(this.user, this.world, Constants.MESSAGES + "not-on-island");
|
||||
result = EMPTY_RESULT;
|
||||
}
|
||||
// Check player permission
|
||||
@ -688,27 +699,27 @@ public class TryToComplete
|
||||
map(i -> i.isAllowed(this.user, ChallengesAddon.CHALLENGES_ISLAND_PROTECTION)).
|
||||
orElse(false))
|
||||
{
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.no-rank"));
|
||||
Utils.sendMessage(this.user, this.world, Constants.MESSAGES + "no-rank");
|
||||
result = EMPTY_RESULT;
|
||||
}
|
||||
// Check if user has unlocked challenges level.
|
||||
else if (!this.challenge.getLevel().equals(ChallengesManager.FREE) &&
|
||||
!this.manager.isLevelUnlocked(this.user, this.world, this.manager.getLevel(this.challenge.getLevel())))
|
||||
{
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.challenge-level-not-available"));
|
||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "challenge-level-not-available");
|
||||
result = EMPTY_RESULT;
|
||||
}
|
||||
// Check max times
|
||||
else if (this.challenge.isRepeatable() && this.challenge.getMaxTimes() > 0 &&
|
||||
this.manager.getChallengeTimes(this.user, this.world, this.challenge) >= this.challenge.getMaxTimes())
|
||||
{
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-repeatable"));
|
||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "not-repeatable");
|
||||
result = EMPTY_RESULT;
|
||||
}
|
||||
// Check repeatability
|
||||
else if (!this.challenge.isRepeatable() && this.manager.isChallengeComplete(this.user, this.world, this.challenge))
|
||||
{
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-repeatable"));
|
||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "not-repeatable");
|
||||
result = EMPTY_RESULT;
|
||||
}
|
||||
// Check if timeout is not broken
|
||||
@ -717,22 +728,22 @@ public class TryToComplete
|
||||
long missing = this.manager.getLastCompletionDate(this.user, this.world, challenge) +
|
||||
this.challenge.getTimeout() - System.currentTimeMillis();
|
||||
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.timeout",
|
||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "timeout",
|
||||
"[timeout]", Utils.parseDuration(Duration.ofMillis(this.challenge.getTimeout()), this.user),
|
||||
"[wait-time]", Utils.parseDuration(Duration.ofMillis(missing), this.user)));
|
||||
"[wait-time]", Utils.parseDuration(Duration.ofMillis(missing), this.user));
|
||||
result = EMPTY_RESULT;
|
||||
}
|
||||
// Check environment
|
||||
else if (!this.challenge.getEnvironment().isEmpty() &&
|
||||
!this.challenge.getEnvironment().contains(this.user.getWorld().getEnvironment()))
|
||||
{
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.wrong-environment"));
|
||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "wrong-environment");
|
||||
result = EMPTY_RESULT;
|
||||
}
|
||||
// Check permission
|
||||
else if (!this.checkPermissions())
|
||||
{
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("general.errors.no-permission"));
|
||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "no-permission");
|
||||
result = EMPTY_RESULT;
|
||||
}
|
||||
else if (type.equals(ChallengeType.INVENTORY_TYPE))
|
||||
@ -929,9 +940,9 @@ public class TryToComplete
|
||||
|
||||
if (numInInventory < required.getAmount())
|
||||
{
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-enough-items",
|
||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "not-enough-items",
|
||||
"[items]",
|
||||
Utils.prettifyObject(required, this.user)));
|
||||
Utils.prettifyObject(required, this.user));
|
||||
return EMPTY_RESULT;
|
||||
}
|
||||
|
||||
@ -1194,13 +1205,16 @@ public class TryToComplete
|
||||
return new ChallengeResult().setMeetsRequirements().setCompleteFactor(factor).setBlockQueue(blockFromWorld);
|
||||
}
|
||||
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-close-enough",
|
||||
"[number]", String.valueOf(this.getIslandRequirements().getSearchRadius())));
|
||||
Utils.sendMessage(this.user,
|
||||
this.world,
|
||||
Constants.ERRORS + "not-close-enough",
|
||||
Constants.PARAMETER_NUMBER, String.valueOf(this.getIslandRequirements().getSearchRadius()));
|
||||
|
||||
blocks.forEach((k, v) -> Utils.sendMessage(this.user,
|
||||
this.user.getTranslation("challenges.errors.you-still-need",
|
||||
"[amount]", String.valueOf(v),
|
||||
"[item]", Utils.prettifyObject(k, this.user))));
|
||||
this.world,
|
||||
Constants.ERRORS + "you-still-need",
|
||||
"[amount]", String.valueOf(v),
|
||||
"[item]", Utils.prettifyObject(k, this.user)));
|
||||
|
||||
|
||||
// kick garbage collector
|
||||
@ -1280,9 +1294,11 @@ public class TryToComplete
|
||||
}
|
||||
|
||||
minimalRequirements.forEach((reqEnt, amount) ->
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.you-still-need",
|
||||
Utils.sendMessage(this.user,
|
||||
this.world,
|
||||
Constants.ERRORS + "you-still-need",
|
||||
"[amount]", String.valueOf(amount),
|
||||
"[item]", Utils.prettifyObject(reqEnt, this.user))));
|
||||
"[item]", Utils.prettifyObject(reqEnt, this.user)));
|
||||
|
||||
// Kick garbage collector
|
||||
entitiesFound.clear();
|
||||
@ -1363,42 +1379,47 @@ public class TryToComplete
|
||||
|
||||
if (!this.addon.isLevelProvided() && requirements.getRequiredIslandLevel() != 0)
|
||||
{
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.missing-addon"));
|
||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "missing-addon");
|
||||
}
|
||||
else if (!this.addon.isEconomyProvided() &&
|
||||
requirements.getRequiredMoney() != 0)
|
||||
{
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.missing-addon"));
|
||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "missing-addon");
|
||||
}
|
||||
else if (this.addon.isEconomyProvided() && requirements.getRequiredMoney() < 0)
|
||||
{
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.incorrect"));
|
||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "incorrect");
|
||||
}
|
||||
else if (this.addon.isEconomyProvided() &&
|
||||
!this.addon.getEconomyProvider().has(this.user, requirements.getRequiredMoney()))
|
||||
{
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-enough-money",
|
||||
"[value]",
|
||||
Double.toString(requirements.getRequiredMoney())));
|
||||
Utils.sendMessage(this.user,
|
||||
this.world,
|
||||
Constants.ERRORS + "not-enough-money",
|
||||
Constants.PARAMETER_VALUE, Double.toString(requirements.getRequiredMoney()));
|
||||
}
|
||||
else if (requirements.getRequiredExperience() < 0)
|
||||
{
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.incorrect"));
|
||||
Utils.sendMessage(this.user, this.world, Constants.ERRORS + "incorrect");
|
||||
}
|
||||
else if (this.user.getPlayer().getTotalExperience() < requirements.getRequiredExperience() &&
|
||||
this.user.getPlayer().getGameMode() != GameMode.CREATIVE)
|
||||
{
|
||||
// Players in creative gamemode has infinite amount of EXP.
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.not-enough-experience",
|
||||
"[value]",
|
||||
Integer.toString(requirements.getRequiredExperience())));
|
||||
Utils.sendMessage(this.user,
|
||||
this.world,
|
||||
Constants.ERRORS + "not-enough-experience",
|
||||
Constants.PARAMETER_VALUE,
|
||||
Integer.toString(requirements.getRequiredExperience()));
|
||||
}
|
||||
else if (this.addon.isLevelProvided() &&
|
||||
this.addon.getLevelAddon().getIslandLevel(this.world, this.user.getUniqueId()) < requirements.getRequiredIslandLevel())
|
||||
{
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.island-level",
|
||||
Utils.sendMessage(this.user,
|
||||
this.world,
|
||||
Constants.ERRORS + "island-level",
|
||||
TextVariables.NUMBER,
|
||||
String.valueOf(requirements.getRequiredIslandLevel())));
|
||||
String.valueOf(requirements.getRequiredIslandLevel()));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1464,24 +1485,30 @@ public class TryToComplete
|
||||
switch (Objects.requireNonNull(requirements.getStatistic()).getType())
|
||||
{
|
||||
case ITEM, BLOCK -> {
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.requirement-not-met-material",
|
||||
Utils.sendMessage(this.user,
|
||||
this.world,
|
||||
Constants.ERRORS + "requirement-not-met-material",
|
||||
TextVariables.NUMBER, String.valueOf(requirements.getAmount()),
|
||||
"[statistic]", Utils.prettifyObject(requirements.getStatistic(), this.user),
|
||||
"[material]", Utils.prettifyObject(requirements.getMaterial(), this.user),
|
||||
"[value]", String.valueOf(currentValue)));
|
||||
Constants.PARAMETER_VALUE, String.valueOf(currentValue));
|
||||
}
|
||||
case ENTITY -> {
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.requirement-not-met-entity",
|
||||
Utils.sendMessage(this.user,
|
||||
this.world,
|
||||
Constants.ERRORS + "requirement-not-met-entity",
|
||||
TextVariables.NUMBER, String.valueOf(requirements.getAmount()),
|
||||
"[statistic]", Utils.prettifyObject(requirements.getStatistic(), this.user),
|
||||
"[entity]", Utils.prettifyObject(requirements.getEntity(), this.user),
|
||||
"[value]", String.valueOf(currentValue)));
|
||||
Constants.PARAMETER_VALUE, String.valueOf(currentValue));
|
||||
}
|
||||
default -> {
|
||||
Utils.sendMessage(this.user, this.user.getTranslation("challenges.errors.requirement-not-met",
|
||||
Utils.sendMessage(this.user,
|
||||
this.world,
|
||||
Constants.ERRORS + "requirement-not-met",
|
||||
TextVariables.NUMBER, String.valueOf(requirements.getAmount()),
|
||||
"[statistic]", Utils.prettifyObject(requirements.getStatistic(), this.user),
|
||||
"[value]", String.valueOf(currentValue)));
|
||||
Constants.PARAMETER_VALUE, String.valueOf(currentValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -186,11 +186,14 @@ public class Utils
|
||||
* Send given message to user and add prefix to the start of the message.
|
||||
*
|
||||
* @param user User who need to receive message.
|
||||
* @param message String of message that must be send.
|
||||
* @param world Reference to world where message must be send.
|
||||
* @param translation String of message that must be send.
|
||||
* @param parameters Parameters that must be added to translation.
|
||||
*/
|
||||
public static void sendMessage(User user, String message)
|
||||
public static void sendMessage(User user, World world, String translation, String... parameters)
|
||||
{
|
||||
user.sendMessage(user.getTranslation(Constants.CONVERSATIONS + "prefix") + message);
|
||||
user.sendMessage(user.getTranslation(world, Constants.CONVERSATIONS + "prefix") +
|
||||
user.getTranslation(world, translation, parameters));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user