Skip to content

Commit

Permalink
Implement configurable Visit panel.
Browse files Browse the repository at this point in the history
  • Loading branch information
BONNe committed Feb 1, 2022
1 parent c2c9b9a commit bf580cc
Show file tree
Hide file tree
Showing 7 changed files with 706 additions and 413 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<!-- More visible way how to change dependency versions -->
<spigot.version>1.17-R0.1-SNAPSHOT</spigot.version>
<!-- BentoBox API version -->
<bentobox.version>1.19.0</bentobox.version>
<bentobox.version>1.20.0-SNAPSHOT</bentobox.version>
<vault.version>1.7</vault.version>
<!-- Panel Utils version -->
<panelutils.version>1.0.0</panelutils.version>
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/world/bentobox/visit/VisitAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public void onLoad()
this.setState(State.DISABLED);
}

// Save existing panels.
this.saveResource("panels/main_panel.yml", false);

// Set up flag with correct default rank permission.
VISIT_CONFIG_PERMISSION = new Flag.Builder("VISIT_CONFIG_PERMISSION", Material.PUMPKIN).
type(Flag.Type.PROTECTION).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ else if (args.size() == 1 || args.size() == 2 && Objects.equals(args.get(1), "by
{
// Return preprocess result from teleportation.
return this.<VisitAddon>getAddon().getAddonManager().
preprocessTeleportation(user, this.island);
preprocessTeleportation(user, this.island, false);
}
}
}
Expand Down
48 changes: 33 additions & 15 deletions src/main/java/world/bentobox/visit/managers/VisitAddonManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,47 +257,65 @@ public boolean withdrawCredits(User user, double credits)
* @param island Island where user need to be teleported.
* @return {@code true} if teleportation can be performed, {@code false} otherwise.
*/
public boolean preprocessTeleportation(User user, Island island)
public boolean preprocessTeleportation(User user, Island island, boolean silent)
{
double payment = this.getTaxAmount() + this.getIslandEarnings(island);

if (Flags.PREVENT_TELEPORT_WHEN_FALLING.isSetForWorld(user.getWorld()) &&
user.getPlayer().getFallDistance() > 0)
user.getPlayer().getFallDistance() > 0)
{
// We're sending the "hint" to the player to tell them they cannot teleport while falling.
Utils.sendMessage(user,
if (!silent)
{
// We're sending the "hint" to the player to tell them they cannot teleport while falling.
Utils.sendMessage(user,
user.getTranslation(Flags.PREVENT_TELEPORT_WHEN_FALLING.getHintReference()));
}
}
else if (island.isBanned(user.getUniqueId()))
{
// Banned players are not allowed.
Utils.sendMessage(user,
if (!silent)
{
// Banned players are not allowed.
Utils.sendMessage(user,
user.getTranslation("commands.island.ban.you-are-banned"));
}
}
else if (!island.isAllowed(user, Flags.LOCK))
{
// Island is locked.
Utils.sendMessage(user,
if (!silent)
{
// Island is locked.
Utils.sendMessage(user,
user.getTranslation("protection.locked"));
}
}
else if (!island.isAllowed(VisitAddon.ALLOW_VISITS_FLAG))
{
// Visits are disabled in settings.
Utils.sendMessage(user,
if (!silent)
{
// Visits are disabled in settings.
Utils.sendMessage(user,
user.getTranslation(VisitAddon.ALLOW_VISITS_FLAG.getHintReference()));
}
}
else if (!this.canVisitOffline(island))
{
// Send a message that noone is online from this island
Utils.sendMessage(user,
if (!silent)
{
// Send a message that noone is online from this island
Utils.sendMessage(user,
user.getTranslation(Constants.ERRORS + "noone-is-online"));
}
}
else if (payment > 0 && !this.hasCredits(user, payment))
{
// Send a message that player has not enough credits.
Utils.sendMessage(user,
if (!silent)
{
// Send a message that player has not enough credits.
Utils.sendMessage(user,
user.getTranslation(Constants.ERRORS + "not-enough-credits",
Constants.PARAMETER_NUMBER, String.valueOf(payment)));
Constants.PARAMETER_NUMBER, String.valueOf(payment)));
}
}
else
{
Expand Down

0 comments on commit bf580cc

Please sign in to comment.