Skip to content

Commit

Permalink
Prepare release 1.5.0 (#22)
Browse files Browse the repository at this point in the history
* Init next release.

* Update README.md

* Add a command logging before executing visiting.

* Chinese (Taiwan) Translation. (#13)

Completely translate to zh-TW based on en-US locale.

* Create zh-CN.yml (#14)

Added zh-CN language support for Visit addon.

* Update dependencies.

Replace GuiUtils with PanelUtils.

* Implement configurable Visit panel.

* Add BankAddon hook.

Implement functionality to switch addon mode from "user account" to "bank account".

* Fix AdminPanel.

Remove unused buttons and implement missing ones.
Add BlockSelector which allows changing default island icon.

* Switch from FLAG to the RANKED COMMAND.

Remove VISIT_CONFIG_PERMISSION flag and switch to RANKED COMMAND feature that is underutilized currently in BentoBox core.
Using RANKED COMMAND makes more sense than separate flag.

* Fix a bug in visits panel

* Implement UNKNOWN click-type to be as any button

* Implement configurable Visits Config panel.

* Add commented out generated text lines.

* Translate to LV

* Improve VisitEvent.

Add ability to get User object.

* Update config file

* Fixes a missing "API" method in Likes addon.

* Fixes bug that prevented to change "enabled by default".

Apparently BentoBox API do not use defaultSettings to set enabled/disabled value, but uses -1 and any positive number as rank value to change degault value.

* Update VisitPlayerCommand.java (#17)

Added tab-complete for visit command.

Fixes #18

* Update Polish translation (#19)

* Translate pl.yml via GitLocalize

* Translate pl.yml via GitLocalize

* Translate pl.yml via GitLocalize

* Translate pl.yml via GitLocalize

Co-authored-by: mt-gitlocalize <mt@gitlocalize.com>
Co-authored-by: wiktorm12 <wiktorm12@gmail.com>
Co-authored-by: Skillek12321 <dtudtjghfdy.9@gmail.com>
Co-authored-by: xChlebek <karolgaming17@gmail.com>

* Implement messaging when someone visits player island

Add a new flag: RECEIVE_VISIT_MESSAGE_FLAG. This flag allows to toggle if island members should receive `visit.conversations.player-visiting-island` message when a player visits their island.

Fixes #20

* Implement Visit Leave message.

If player visits an island, then next time he leaves it, will send a message to all online members that player left it.

Fixes #21

* Remove unused locale parts.

* Translate lv.yml via GitLocalize (#23)

Co-authored-by: BONNe <bonne@bonne.id.lv>

Co-authored-by: exkuretrol <33695301+exkuretrol@users.noreply.github.com>
Co-authored-by: Katorly <70022443+katorly@users.noreply.github.com>
Co-authored-by: nitrofenix <50662839+nitrofenix@users.noreply.github.com>
Co-authored-by: gitlocalize-app[bot] <55277160+gitlocalize-app[bot]@users.noreply.github.com>
Co-authored-by: mt-gitlocalize <mt@gitlocalize.com>
Co-authored-by: wiktorm12 <wiktorm12@gmail.com>
Co-authored-by: Skillek12321 <dtudtjghfdy.9@gmail.com>
Co-authored-by: xChlebek <karolgaming17@gmail.com>
  • Loading branch information
9 people committed Jan 5, 2023
1 parent 4279c8a commit 7fc8697
Show file tree
Hide file tree
Showing 26 changed files with 3,528 additions and 1,339 deletions.
16 changes: 3 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,10 @@ This is Visit Addon for BentoBox plugin.
## Small information

The main idea of the addon is to allow faster ways how to visit any island.
The main difference from warps addon is that unlike warps, signs are not necessary, and users can travel to any island.
The main difference from warps addon is that unlike warps, signs are not necessary, and users can travel to any island via command or GUI.

Users can visit others by executing `/[player_command] visit <player_name>` or by choosing an island from the GUI which opens after executing command `/[player_command] visit`

However, users can disable the ability to travel to their island via island settings flag "Visit protection".
There is also an option to disable visiting while island members are offline. It can be done by `/[player_command] visit configure` command.

This addon offers also an option to earn money from visitors. In the same GUI, island members can set payment price for visitors. All incoming money will go to the island owner.

There is also protection setting for island owner, which allows specifying minimum rank that can access to island visiting config editor: "Manage visitor config".

Server admins have also an in-game GUI that allows to edit config options.
There is also an option to set tax amount for visitors, that will be taken from player account on each island visit.
More informatioin you can find in addon Wiki Page: [Visit Addon](https://docs.bentobox.world/en/latest/addons/Visit/)

## Compatibility

- [x] BentoBox 1.15.4+
- [x] BentoBox 1.20.0+
52 changes: 49 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@
<!-- More visible way how to change dependency versions -->
<spigot.version>1.17-R0.1-SNAPSHOT</spigot.version>
<!-- BentoBox API version -->
<bentobox.version>1.17.0</bentobox.version>
<bentobox.version>1.21.0</bentobox.version>
<bank.version>1.4.0</bank.version>
<vault.version>1.7</vault.version>
<!-- Panel Utils version -->
<panelutils.version>1.1.0</panelutils.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>1.4.0</build.version>
<build.version>1.5.0</build.version>
<build.number>-LOCAL</build.number>
</properties>

Expand Down Expand Up @@ -157,6 +160,12 @@
<version>${bentobox.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>world.bentobox</groupId>
<artifactId>bank</artifactId>
<version>${bank.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId>
Expand All @@ -166,7 +175,12 @@
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>18.0.0</version>
<version>22.0.0</version>
</dependency>
<dependency>
<groupId>lv.id.bonne</groupId>
<artifactId>panelutils</artifactId>
<version>${panelutils.version}</version>
</dependency>
</dependencies>

Expand Down Expand Up @@ -260,6 +274,38 @@
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.1-SNAPSHOT</version>
<configuration>
<minimizeJar>true</minimizeJar>
<artifactSet>
<includes>
<include>lv.id.bonne:panelutils:*</include>
</includes>
</artifactSet>
<transformers>
<!-- Add a transformer to exclude any other manifest files (possibly from dependencies). -->
<transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
<resource>MANIFEST.MF</resource>
</transformer>
<!-- Add a transformer to include your custom manifest file. -->
<transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
<resource>META-INF/MANIFEST.MF</resource>
<file>src/main/resources/META-INF/MANIFEST.MF</file>
</transformer>
</transformers>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
Expand Down
144 changes: 91 additions & 53 deletions src/main/java/world/bentobox/visit/VisitAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@

import org.bukkit.Bukkit;
import org.bukkit.Material;
import java.util.Optional;

import world.bentobox.bank.Bank;
import world.bentobox.bentobox.api.addons.Addon;
import world.bentobox.bentobox.api.configuration.Config;
import world.bentobox.bentobox.api.flags.Flag;
import world.bentobox.bentobox.api.flags.clicklisteners.CycleClick;
import world.bentobox.bentobox.hooks.VaultHook;
import world.bentobox.bentobox.managers.RanksManager;
import world.bentobox.visit.commands.admin.VisitAdminCommand;
import world.bentobox.visit.commands.player.VisitPlayerCommand;
import world.bentobox.visit.configs.Settings;
import world.bentobox.visit.listeners.IslandLeaveListener;
import world.bentobox.visit.managers.VisitAddonManager;


Expand All @@ -27,11 +26,6 @@
*/
public class VisitAddon extends Addon
{
// ---------------------------------------------------------------------
// Section: Variables
// ---------------------------------------------------------------------


/**
* Executes code when loading the addon. This is called before {@link #onEnable()}. This <b>must</b> be used to
* setup configuration, worlds and commands.
Expand Down Expand Up @@ -59,14 +53,19 @@ public void onLoad()
this.setState(State.DISABLED);
}

// Set up flag with correct default rank permission.
VISIT_CONFIG_PERMISSION = new Flag.Builder("VISIT_CONFIG_PERMISSION", Material.PUMPKIN).
type(Flag.Type.PROTECTION).
defaultRank(this.settings.getDefaultConfigPermission()).
clickHandler(new CycleClick("VISIT_CONFIG_PERMISSION",
RanksManager.MEMBER_RANK,
RanksManager.OWNER_RANK)).
ALLOW_VISITS_FLAG = new Flag.Builder("ALLOW_VISITS_FLAG", Material.PUMPKIN_PIE).
type(Flag.Type.SETTING).
defaultRank(this.settings.isDefaultVisitingEnabled() ? 0 : -1).
build();

RECEIVE_VISIT_MESSAGE_FLAG = new Flag.Builder("RECEIVE_VISIT_MESSAGE_FLAG", Material.PAPER).
type(Flag.Type.SETTING).
defaultRank(0).
build();

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


Expand Down Expand Up @@ -111,7 +110,7 @@ public void onEnable()
{
// Now we add GameModes to our Flags
ALLOW_VISITS_FLAG.addGameModeAddon(gameModeAddon);
VISIT_CONFIG_PERMISSION.addGameModeAddon(gameModeAddon);
RECEIVE_VISIT_MESSAGE_FLAG.addGameModeAddon(gameModeAddon);

// Each GameMode could have Player Command and Admin Command and we could
// want to integrate our Visit Command into these commands.
Expand All @@ -135,24 +134,21 @@ public void onEnable()
{
// After we added all GameModes into flags, we need to register these flags
// into BentoBox.

ALLOW_VISITS_FLAG.setDefaultSetting(this.settings.isDefaultVisitingEnabled());
this.registerFlag(ALLOW_VISITS_FLAG);
this.registerFlag(VISIT_CONFIG_PERMISSION);
this.registerFlag(RECEIVE_VISIT_MESSAGE_FLAG);

this.registerListener(new IslandLeaveListener(this));

INSTANCE = this;
}
}

// BentoBox does not manage money, but it provides VaultHook that does it.
this.vaultHook = this.getPlugin().getVault();

// Even if Vault is installed, it does not mean that economy can be used. It is
// necessary to check it via VaultHook#hook() method.

if (!this.vaultHook.isPresent())
{
this.logWarning("Vault plugin not found. Economy will not work!");
}
@Override
public void allLoaded()
{
super.allLoaded();
this.hookExtensions();
}


Expand Down Expand Up @@ -183,11 +179,6 @@ public void onReload()
}


// ---------------------------------------------------------------------
// Section: Flags
// ---------------------------------------------------------------------


/**
* Executes code when disabling the addon.
*/
Expand All @@ -197,6 +188,47 @@ public void onDisable()
}


// ---------------------------------------------------------------------
// Section: Methods
// ---------------------------------------------------------------------


/**
* This method finds and hooks into visit addon extensions.
*/
private void hookExtensions()
{
// Try to find Level addon and if it does not exist, display a warning
this.getAddonByName("Bank").ifPresentOrElse(addon ->
{
this.bankHook = (Bank) addon;
this.log("Visit Addon hooked into Bank addon.");
}, () ->
{
this.bankHook = null;
});

// Try to find Vault Plugin and if it does not exist, display a warning
this.getPlugin().getVault().ifPresentOrElse(hook ->
{
this.vaultHook = hook;

if (this.vaultHook.hook())
{
this.log("Visit Addon hooked into Economy.");
}
else
{
this.logWarning("Visit Addon could not hook into valid Economy.");
}
}, () ->
{
this.vaultHook = null;
this.logWarning("Vault plugin not found. Economy will not work!");
});
}


/**
* This method saves settings file from memory.
*/
Expand All @@ -217,13 +249,19 @@ public void saveSettings()
*/
public VaultHook getVaultHook()
{
return this.vaultHook.orElse(null);
return this.vaultHook;
}


// ---------------------------------------------------------------------
// Section: Methods
// ---------------------------------------------------------------------
/**
* Gets bank hook.
*
* @return the bank hook
*/
public Bank getBankHook()
{
return this.bankHook;
}


/**
Expand Down Expand Up @@ -259,6 +297,10 @@ public static VisitAddon getInstance()
}


// ---------------------------------------------------------------------
// Section: Variables
// ---------------------------------------------------------------------

/**
* Settings object contains
*/
Expand All @@ -269,26 +311,20 @@ public static VisitAddon getInstance()
*/
private VisitAddonManager addonManager;


// ---------------------------------------------------------------------
// Section: Getters
// ---------------------------------------------------------------------

/**
* Local variable that stores if vaultHook is present.
* Local variable that stores vault hook.
*/
private Optional<VaultHook> vaultHook;
private VaultHook vaultHook;

/**
* Stores instance of the addon.
* Local variable that stores bank addon hook.
*/
private static VisitAddon INSTANCE;
private Bank bankHook;

/**
* This flag allows to change who have access to modify island visitor config option. Owner can change it from
* member rank till owner rank. Default value is set to subowner.
* Stores instance of the addon.
*/
public static Flag VISIT_CONFIG_PERMISSION;
private static VisitAddon INSTANCE;

/**
* Settings flags allows to modifying parameters of the island.
Expand All @@ -299,8 +335,10 @@ public static VisitAddon getInstance()
* <p>
* By default setting is set to false.
*/
public final static Flag ALLOW_VISITS_FLAG =
new Flag.Builder("ALLOW_VISITS_FLAG", Material.PUMPKIN_PIE).
type(Flag.Type.SETTING).
build();
public static Flag ALLOW_VISITS_FLAG;

/**
* This flag allows to toggle if player should receive message that someone visits his island.
*/
public static Flag RECEIVE_VISIT_MESSAGE_FLAG;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@
package world.bentobox.visit.commands.player;


import org.bukkit.Location;
import org.bukkit.event.entity.ItemSpawnEvent;
import java.util.List;
import java.util.Optional;

import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
Expand Down Expand Up @@ -59,6 +55,8 @@ public void setup()
this.setDescription(Constants.PLAYER_COMMANDS + "configure.description");

this.setOnlyPlayer(true);
this.setConfigurableRankCommand();
this.setDefaultCommandRank(this.<VisitAddon>getAddon().getSettings().getDefaultConfigPermission());
}


Expand All @@ -85,7 +83,7 @@ public boolean canExecute(User user, String label, List<String> args)
return false;
}

return island.isAllowed(user, VisitAddon.VISIT_CONFIG_PERMISSION);
return true;
}


Expand Down

0 comments on commit 7fc8697

Please sign in to comment.