Skip to content

Commit

Permalink
Merge pull request #21 from BentoBoxWorld/develop
Browse files Browse the repository at this point in the history
Release 2.1.0
  • Loading branch information
BONNe authored Feb 21, 2021
2 parents 1653a37 + f97b232 commit 4b32388
Show file tree
Hide file tree
Showing 53 changed files with 12,934 additions and 8,832 deletions.
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
# Likes Addon
[![Discord](https://img.shields.io/discord/272499714048524288.svg?logo=discord)](https://discord.bentobox.world)
[![Build Status](https://ci.codemc.org/buildStatus/icon?job=BentoBoxWorld/Likes)](https://ci.codemc.org/job/BentoBoxWorld/job/Likes/)
[:page_facing_up:](https://docs.bentobox.world/en/latest/addons/Likes/)

This is Likes Addon that allows to give Like and Dislike to other player islands.

## Where to find

You can download it from [Release tab](https://github.com/BentoBoxWorld/Likes/releases)

Or you can try **nightly builds** where you can check and test new features that will be implemented in next release from [Jenkins Server](https://ci.codemc.org/job/BentoBoxWorld/job/Likes/lastStableBuild/).

If you like this addon but something is missing or is not working as you want, you can always submit an [Issue request](https://github.com/BentoBoxWorld/Likes/issues) or get a support in Discord [BentoBox ![icon](https://avatars2.githubusercontent.com/u/41555324?s=15&v=4)](https://discord.bentobox.world)

## What to expect

This addon allows players to rate other player islands. Addon has 3 working modes:

- Likes: allows adding only like to player island.
- Likes And Dislikes: allows adding like or dislike to player island.
- Stars: allows adding from 1-5 stars to player island.

These mores cannot work together, so choose the one you want to use at the start.

Addon has also Top players GUI that allows viewing best rated players by each top.

## How to use

1. Place the addon jar in the addons folder of the BentoBox plugin.
Expand All @@ -13,8 +34,8 @@ This is Likes Addon that allows to give Like and Dislike to other player islands

## Compatibility

- [x] BentoBox - 1.14.0 version
- [x] BentoBox - 1.15.4 version

## Information

More information can be found in [Wiki Pages](https://docs.bentobox.world/addons/Likes/).
More information can be found in [Wiki Pages](https://docs.bentobox.world/en/latest/addons/Likes/).
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@
<java.version>1.8</java.version>

<!-- SPIGOT API version -->
<spigot.version>1.16.1-R0.1-SNAPSHOT</spigot.version>
<spigot.version>1.16.4-R0.1-SNAPSHOT</spigot.version>
<!-- Vault API version -->
<vault.version>1.7</vault.version>

<!-- BentoBox API version -->
<bentobox.version>1.14.0</bentobox.version>
<bentobox.version>1.16.0-SNAPSHOT</bentobox.version>
<!-- Warps addon version -->
<warps.version>1.7.0</warps.version>

<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>2.0.0</build.version>
<build.version>2.1.1</build.version>
<build.number>-LOCAL</build.number>
</properties>

Expand Down
62 changes: 42 additions & 20 deletions src/main/java/world/bentobox/likes/LikesAddon.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package world.bentobox.likes;
///
// Created by BONNe
// Copyright - 2021
///

package world.bentobox.likes;

import java.util.Arrays;
import java.util.Optional;

import org.bukkit.Bukkit;
import org.eclipse.jdt.annotation.NonNull;
import java.util.Arrays;
import java.util.Optional;

import world.bentobox.bentobox.api.addons.Addon;
import world.bentobox.bentobox.api.addons.GameModeAddon;
Expand Down Expand Up @@ -36,8 +40,8 @@ public class LikesAddon extends Addon


/**
* Executes code when loading the addon. This is called before {@link #onEnable()}.
* This <b>must</b> be used to setup configuration, worlds and commands.
* Executes code when loading the addon. This is called before {@link #onEnable()}. This <b>must</b> be used to
* setup configuration, worlds and commands.
*/
@Override
public void onLoad()
Expand Down Expand Up @@ -65,10 +69,9 @@ public void onLoad()


/**
* Executes code when enabling the addon. This is called after {@link #onLoad()}.
* <br/> Note that commands and worlds registration <b>must</b> be done in {@link
* #onLoad()}, if need be. Failure to do so <b>will</b> result in issues such as
* tab-completion not working for commands.
* Executes code when enabling the addon. This is called after {@link #onLoad()}. <br/> Note that commands and
* worlds registration <b>must</b> be done in {@link #onLoad()}, if need be. Failure to do so <b>will</b> result in
* issues such as tab-completion not working for commands.
*/
@Override
public void onEnable()
Expand Down Expand Up @@ -113,10 +116,10 @@ public void onEnable()
// create GameMode without them.

gameModeAddon.getPlayerCommand().ifPresent(
playerCommand -> new PlayerCommand(this, playerCommand));
playerCommand -> new PlayerCommand(this, playerCommand));

gameModeAddon.getAdminCommand().ifPresent(
adminCommand -> new AdminCommand(this, adminCommand));
adminCommand -> new AdminCommand(this, adminCommand));

// Register all likes addon placeholders
this.registerAddonPlaceholders(gameModeAddon);
Expand All @@ -132,10 +135,10 @@ public void onEnable()
// 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 (!vaultHook.isPresent() || !vaultHook.get().hook())
if (!vaultHook.isPresent())
{
this.vaultHook = null;
this.logWarning("Economy plugin not found by Likes Addon!");
this.logWarning("Vault plugin not found. Economy will not work!");
}
else
{
Expand Down Expand Up @@ -199,17 +202,25 @@ public void onDisable()
// onDisable we would like to save exisitng settings. It is not necessary for
// addons that does not have interface for settings editing!

this.manager.save();
}


/**
* This method saves settings file from memory.
*/
public void saveSettings()
{
if (this.settings != null)
{
new Config<>(this, Settings.class).saveConfigObject(this.settings);
}

this.manager.save();
}


/**
* This is simple method that adds given event to plugin manager.
*
* @param event BentoBoxEvent that is triggered.
*/
public void callEvent(BentoBoxEvent event)
Expand All @@ -220,15 +231,16 @@ public void callEvent(BentoBoxEvent event)

/**
* Registers LikesAddon placeholders for this gameMode Addon.
*
* @param gameModeAddon the gameMode Addon to register the LikesAddon placeholders.
*/
public void registerAddonPlaceholders(@NonNull GameModeAddon gameModeAddon)
{
final PlaceholdersManager mgr = this.getPlugin().getPlaceholdersManager();

Arrays.stream(LikesAddonPlaceholderType.values()).
filter(placeholder -> !mgr.isPlaceholder(gameModeAddon, placeholder.getPlaceholder())).
forEach(placeholder -> mgr.registerPlaceholder(gameModeAddon,
filter(placeholder -> !mgr.isPlaceholder(gameModeAddon, placeholder.getPlaceholder())).
forEach(placeholder -> mgr.registerPlaceholder(gameModeAddon,
placeholder.getPlaceholder(),
new LikesAddonPlaceholder(this, gameModeAddon, placeholder)));
}
Expand All @@ -240,8 +252,18 @@ public void registerAddonPlaceholders(@NonNull GameModeAddon gameModeAddon)


/**
* This getter will allow to access to VaultHook. It is written so that it could
* return null, if Vault is not present.
* @return economyProvided variable.
*/
public boolean isEconomyProvided()
{
return this.vaultHook != null && this.vaultHook.hook();
}


/**
* This getter will allow to access to VaultHook. It is written so that it could return null, if Vault is not
* present.
*
* @return {@code VaultHook} if it is present, {@code null} otherwise.
*/
public VaultHook getVaultHook()
Expand Down Expand Up @@ -277,7 +299,7 @@ public Settings getSettings()
*
* @return the manager (type LikesManager) of this object.
*/
public LikesManager getManager()
public LikesManager getAddonManager()
{
return this.manager;
}
Expand Down
130 changes: 68 additions & 62 deletions src/main/java/world/bentobox/likes/commands/admin/AdminCommand.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
///
// Created by BONNe
// Copyright - 2021
///

package world.bentobox.likes.commands.admin;


Expand All @@ -16,73 +21,74 @@
*/
public class AdminCommand extends CompositeCommand
{
/**
* This is simple constructor for initializing /{gamemode_admin_command} example command.
* @param addon Our Example addon.
* @param parentCommand Parent Command where we hook our command into.
*/
public AdminCommand(LikesAddon addon, CompositeCommand parentCommand)
{
super(addon, parentCommand, "likes");
}
/**
* This is simple constructor for initializing /{gamemode_admin_command} example command.
*
* @param addon Our Example addon.
* @param parentCommand Parent Command where we hook our command into.
*/
public AdminCommand(LikesAddon addon, CompositeCommand parentCommand)
{
super(addon, parentCommand, "likes");
}


/**
* Setups anything that is needed for this command. <br/><br/> It is recommended you
* do the following in this method:
* <ul>
* <li>Register any of the sub-commands of this command;</li>
* <li>Define the permission required to use this command using {@link
* CompositeCommand#setPermission(String)};</li>
* <li>Define whether this command can only be run by players or not using {@link
* CompositeCommand#setOnlyPlayer(boolean)};</li>
* </ul>
*/
@Override
public void setup()
{
this.setPermission("likes.admin");
this.setParametersHelp(Constants.COMMANDS + "admin.help.parameters");
this.setDescription(Constants.COMMANDS + "admin.help.description");
this.setOnlyPlayer(true);
/**
* Setups anything that is needed for this command. <br/><br/> It is recommended you do the following in this
* method:
* <ul>
* <li>Register any of the sub-commands of this command;</li>
* <li>Define the permission required to use this command using {@link
* CompositeCommand#setPermission(String)};</li>
* <li>Define whether this command can only be run by players or not using {@link
* CompositeCommand#setOnlyPlayer(boolean)};</li>
* </ul>
*/
@Override
public void setup()
{
this.setPermission("likes.admin");
this.setParametersHelp(Constants.ADMIN_COMMANDS + "main.parameters");
this.setDescription(Constants.ADMIN_COMMANDS + "main.description");
this.setOnlyPlayer(true);

new PlayerViewCommand((LikesAddon) this.getAddon(), this);
new EditSettingsCommand((LikesAddon) this.getAddon(), this);
}
new PlayerViewCommand(this.getAddon(), this);
new EditSettingsCommand(this.getAddon(), this);
}


/**
* Returns whether the command can be executed by this user or not. It is recommended
* to send messages to let this user know why they could not execute the command. Note
* that this is run previous to {@link #execute(User, String, List)}.
*
* @param user the {@link User} who is executing this command.
* @param label the label which has been used to execute this command. It can be
* {@link CompositeCommand#getLabel()} or an alias.
* @param args the command arguments.
* @return {@code true} if this command can be executed, {@code false} otherwise.
* @since 1.3.0
*/
@Override
public boolean canExecute(User user, String label, List<String> args)
{
return true;
}
/**
* Returns whether the command can be executed by this user or not. It is recommended to send messages to let this
* user know why they could not execute the command. Note that this is run previous to {@link #execute(User, String,
* List)}.
*
* @param user the {@link User} who is executing this command.
* @param label the label which has been used to execute this command. It can be {@link CompositeCommand#getLabel()}
* or an alias.
* @param args the command arguments.
* @return {@code true} if this command can be executed, {@code false} otherwise.
* @since 1.3.0
*/
@Override
public boolean canExecute(User user, String label, List<String> args)
{
return true;
}


/**
* Defines what will be executed when this command is run.
*
* @param user the {@link User} who is executing this command.
* @param label the label which has been used to execute this command. It can be
* {@link CompositeCommand#getLabel()} or an alias.
* @param args the command arguments.
* @return {@code true} if the command executed successfully, {@code false} otherwise.
*/
@Override
public boolean execute(User user, String label, List<String> args)
{
AdminPanel.openPanel((LikesAddon) this.getAddon(), user, this.getWorld(), this.getPermissionPrefix());
return true;
}
/**
* Defines what will be executed when this command is run.
*
* @param user the {@link User} who is executing this command.
* @param label the label which has been used to execute this command. It can be {@link CompositeCommand#getLabel()}
* or an alias.
* @param args the command arguments.
* @return {@code true} if the command executed successfully, {@code false} otherwise.
*/
@Override
public boolean execute(User user, String label, List<String> args)
{
AdminPanel.openPanel(this.getAddon(), user, this.getWorld(), this.getPermissionPrefix());
return true;
}
}
Loading

0 comments on commit 4b32388

Please sign in to comment.