Add new economy actions, update API docs to use new repo, add metrics to Sponge (#398)

This commit is contained in:
William authored and GitHub committed 2023-05-09 19:24:24 +01:00
1 parent 8b609010ec
commit 40cb340b15
33 files changed
+437 -159

No files matched your search

+2 -2
View File
@@ -4,8 +4,8 @@
<a href="https://github.com/WiIIiam278/HuskHomes2/actions/workflows/ci.yml">
<img src="https://img.shields.io/github/actions/workflow/status/WiIIiam278/HuskHomes2/ci.yml?branch=master&logo=github"/>
</a>
<a href="https://jitpack.io/#net.william278/HuskHomes2">
<img src="https://img.shields.io/jitpack/version/net.william278/HuskHomes2?color=%2300fb9a&label=api&logo=gradle" />
<a href="https://repo.william278.net/#/releases/net/william278/huskhomes/">
<img src="https://repo.william278.net/api/badge/latest/releases/net/william278/huskhomes?color=00fb9a&name=Maven&prefix=v" />
</a>
<a href="https://discord.gg/tVYhJfyDWG">
<img src="https://img.shields.io/discord/818135932103557162.svg?label=&logo=discord&logoColor=fff&color=7389D8&labelColor=6A7EC2" />
@@ -437,6 +437,10 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes, BukkitTask
@Override
public void registerMetrics(int metricsId) {
if (!getVersion().getMetadata().isBlank()) {
return;
}
try {
final Metrics metrics = new Metrics(this, metricsId);
metrics.addCustomChart(new SimplePie("bungee_mode", () -> Boolean.toString(getSettings().doCrossServer())));
@@ -448,8 +452,8 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes, BukkitTask
metrics.addCustomChart(new SimplePie("using_economy", () -> Boolean.toString(getSettings().doEconomy())));
metrics.addCustomChart(new SimplePie("using_map", () -> Boolean.toString(getSettings().doMapHook())));
getMapHook().ifPresent(hook -> metrics.addCustomChart(new SimplePie("map_type", hook::getName)));
} catch (Exception e) {
log(Level.WARNING, "Failed to register metrics", e);
} catch (Throwable e) {
log(Level.WARNING, "Failed to register bStats metrics (" + e.getMessage() + ")");
}
}
@@ -471,7 +475,7 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes, BukkitTask
@Override
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, byte[] message) {
if (broker != null && broker instanceof PluginMessageBroker pluginMessenger
&& getSettings().getBrokerType() == Broker.Type.PLUGIN_MESSAGE) {
&& getSettings().getBrokerType() == Broker.Type.PLUGIN_MESSAGE) {
pluginMessenger.onReceive(channel, BukkitUser.adapt(player), message);
}
}
@@ -45,10 +45,7 @@ import net.william278.huskhomes.user.ConsoleUser;
import net.william278.huskhomes.user.OnlineUser;
import net.william278.huskhomes.user.SavedUser;
import net.william278.huskhomes.user.User;
import net.william278.huskhomes.util.SafetyResolver;
import net.william278.huskhomes.util.TaskRunner;
import net.william278.huskhomes.util.UnsafeBlocks;
import net.william278.huskhomes.util.Validator;
import net.william278.huskhomes.util.*;
import org.intellij.lang.annotations.Subst;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -66,7 +63,7 @@ import java.util.stream.Stream;
/**
* Represents a cross-platform instance of the plugin
*/
public interface HuskHomes extends TaskRunner, EventDispatcher, SafetyResolver {
public interface HuskHomes extends TaskRunner, EventDispatcher, SafetyResolver, TransactionResolver {
int SPIGOT_RESOURCE_ID = 83767;
@@ -267,10 +264,6 @@ public interface HuskHomes extends TaskRunner, EventDispatcher, SafetyResolver {
.findFirst();
}
default Optional<EconomyHook> getEconomyHook() {
return getHook(EconomyHook.class);
}
default Optional<MapHook> getMapHook() {
return getHook(MapHook.class);
}
@@ -283,49 +276,6 @@ public interface HuskHomes extends TaskRunner, EventDispatcher, SafetyResolver {
.collect(Collectors.toList());
}
/**
* Perform an economy check on the {@link OnlineUser}; returning {@code true} if it passes the check
*
* @param player the player to perform the check on
* @param action the action to perform
* @return {@code true} if the action passes the check, {@code false} if the user has insufficient funds
*/
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
default boolean validateEconomyCheck(@NotNull OnlineUser player, @NotNull EconomyHook.Action action) {
final Optional<Double> cost = getSettings().getEconomyCost(action).map(Math::abs);
if (cost.isPresent() && !player.hasPermission(EconomyHook.BYPASS_PERMISSION)) {
final Optional<EconomyHook> hook = getEconomyHook();
if (hook.isPresent()) {
if (cost.get() > hook.get().getPlayerBalance(player)) {
getLocales().getLocale("error_insufficient_funds", hook.get().formatCurrency(cost.get()))
.ifPresent(player::sendMessage);
return false;
}
}
}
return true;
}
/**
* Execute an economy transaction if needed, updating the player's balance
*
* @param player the player to deduct the cost from if needed
* @param action the action to deduct the cost from if needed
*/
default void performEconomyTransaction(@NotNull OnlineUser player, @NotNull EconomyHook.Action action) {
if (!getSettings().doEconomy()) return;
final Optional<Double> cost = getSettings().getEconomyCost(action).map(Math::abs);
if (cost.isPresent() && !player.hasPermission(EconomyHook.BYPASS_PERMISSION)) {
final Optional<EconomyHook> hook = getEconomyHook();
if (hook.isPresent()) {
hook.get().changePlayerBalance(player, -cost.get());
getLocales().getLocale(action.confirmationLocaleId, hook.get().formatCurrency(cost.get()))
.ifPresent(player::sendMessage);
}
}
}
/**
* Returns a resource read from the plugin resources folder
*
@@ -171,7 +171,7 @@ public class EditHomeCommand extends SavedPositionCommand<Home> {
}
// Check against economy
if (executor instanceof OnlineUser user && !plugin.validateEconomyCheck(user, EconomyHook.Action.MAKE_HOME_PUBLIC)) {
if (executor instanceof OnlineUser user && !plugin.canPerformTransaction(user, EconomyHook.Action.MAKE_HOME_PUBLIC)) {
return;
}
@@ -191,7 +191,7 @@ public class EditHomeCommand extends SavedPositionCommand<Home> {
// Perform transaction
if (executor instanceof OnlineUser user) {
plugin.performEconomyTransaction(user, EconomyHook.Action.MAKE_HOME_PUBLIC);
plugin.performTransaction(user, EconomyHook.Action.MAKE_HOME_PUBLIC);
}
final String privacy = home.isPublic() ? "public" : "private";
@@ -20,6 +20,7 @@
package net.william278.huskhomes.command;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.hook.EconomyHook;
import net.william278.huskhomes.position.Home;
import net.william278.huskhomes.teleport.Teleportable;
import net.william278.huskhomes.user.CommandUser;
@@ -52,7 +53,11 @@ public abstract class HomeCommand extends SavedPositionCommand<Home> {
return;
}
this.teleport(executor, optionalTeleporter.get(), home);
this.teleport(
executor, optionalTeleporter.get(), home,
(executor instanceof OnlineUser user && home.getOwner().equals(user)
? EconomyHook.Action.HOME_TELEPORT : EconomyHook.Action.PUBLIC_HOME_TELEPORT)
);
}
}
@@ -100,7 +100,7 @@ public class RtpCommand extends Command implements UserListTabProvider {
}
// Check they have sufficient funds
if (!plugin.validateEconomyCheck(teleporter, EconomyHook.Action.RANDOM_TELEPORT)) {
if (!plugin.canPerformTransaction(teleporter, EconomyHook.Action.RANDOM_TELEPORT)) {
return Optional.empty();
}
@@ -20,6 +20,7 @@
package net.william278.huskhomes.command;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.hook.EconomyHook;
import net.william278.huskhomes.position.Home;
import net.william278.huskhomes.position.SavedPosition;
import net.william278.huskhomes.position.Warp;
@@ -95,7 +96,7 @@ public abstract class SavedPositionCommand<T extends SavedPosition> extends Comm
final Home home = optionalHome.get();
if (executor instanceof OnlineUser user && !home.isPublic() && !user.equals(home.getOwner())
&& !user.hasPermission(getOtherPermission())) {
&& !user.hasPermission(getOtherPermission())) {
plugin.getLocales().getLocale("error_public_home_invalid", ownerUsername, ownerHomeName)
.ifPresent(executor::sendMessage);
return Optional.empty();
@@ -137,7 +138,7 @@ public abstract class SavedPositionCommand<T extends SavedPosition> extends Comm
return Optional.empty();
}
if (executor instanceof OnlineUser user && plugin.getSettings().doPermissionRestrictWarps()
&& !user.hasPermission(Warp.getWildcardPermission()) && !user.hasPermission(Warp.getPermission(warpName))) {
&& !user.hasPermission(Warp.getWildcardPermission()) && !user.hasPermission(Warp.getPermission(warpName))) {
plugin.getLocales().getLocale("error_warp_invalid", warpName)
.ifPresent(executor::sendMessage);
return Optional.empty();
@@ -156,7 +157,8 @@ public abstract class SavedPositionCommand<T extends SavedPosition> extends Comm
});
}
protected void teleport(@NotNull CommandUser executor, @NotNull Teleportable teleporter, @NotNull T position) {
protected void teleport(@NotNull CommandUser executor, @NotNull Teleportable teleporter, @NotNull T position,
@NotNull EconomyHook.Action... economyActions) {
if (!teleporter.equals(executor) && !executor.hasPermission(getPermission("other"))) {
plugin.getLocales().getLocale("error_no_permission")
.ifPresent(executor::sendMessage);
@@ -165,6 +167,7 @@ public abstract class SavedPositionCommand<T extends SavedPosition> extends Comm
final TeleportBuilder builder = Teleport.builder(plugin)
.teleporter(teleporter)
.economyActions(economyActions)
.target(position);
try {
if (executor.equals(teleporter)) {
@@ -173,7 +176,7 @@ public abstract class SavedPositionCommand<T extends SavedPosition> extends Comm
builder.toTeleport().execute();
}
} catch (TeleportationException e) {
e.displayMessage(executor, plugin, new String[0]);
e.displayMessage(executor, plugin, teleporter.getUsername());
}
}
@@ -20,6 +20,7 @@
package net.william278.huskhomes.command;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.hook.EconomyHook;
import net.william278.huskhomes.position.Position;
import net.william278.huskhomes.teleport.Teleport;
import net.william278.huskhomes.teleport.TeleportBuilder;
@@ -68,6 +69,7 @@ public class SpawnCommand extends Command {
final TeleportBuilder builder = Teleport.builder(plugin)
.teleporter(teleporter)
.economyActions(EconomyHook.Action.SPAWN_TELEPORT)
.target(spawn);
try {
if (teleporter.equals(executor)) {
@@ -20,6 +20,7 @@
package net.william278.huskhomes.command;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.hook.EconomyHook;
import net.william278.huskhomes.manager.RequestsManager;
import net.william278.huskhomes.teleport.TeleportRequest;
import net.william278.huskhomes.user.OnlineUser;
@@ -53,6 +54,7 @@ public class TeleportRequestCommand extends InGameCommand implements UserListTab
return;
}
// Ensure the user does not send a request to themselves
final String target = optionalTarget.get();
if (target.equalsIgnoreCase(onlineUser.getUsername())) {
plugin.getLocales().getLocale("error_teleport_request_self")
@@ -60,6 +62,11 @@ public class TeleportRequestCommand extends InGameCommand implements UserListTab
return;
}
// Validate economy check
if (!plugin.canPerformTransaction(onlineUser, EconomyHook.Action.SEND_TELEPORT_REQUEST)) {
return;
}
try {
manager.sendTeleportRequest(onlineUser, target, requestType);
} catch (IllegalArgumentException e) {
@@ -68,6 +75,7 @@ public class TeleportRequestCommand extends InGameCommand implements UserListTab
return;
}
plugin.performTransaction(onlineUser, EconomyHook.Action.SEND_TELEPORT_REQUEST);
plugin.getLocales()
.getLocale((requestType == TeleportRequest.Type.TPA ? "tpa" : "tpahere")
+ "_request_sent", target)
@@ -20,6 +20,7 @@
package net.william278.huskhomes.command;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.hook.EconomyHook;
import net.william278.huskhomes.position.Warp;
import net.william278.huskhomes.teleport.Teleportable;
import net.william278.huskhomes.user.CommandUser;
@@ -61,6 +62,6 @@ public class WarpCommand extends SavedPositionCommand<Warp> {
return;
}
this.teleport(executor, optionalTeleporter.get(), warp);
this.teleport(executor, optionalTeleporter.get(), warp, EconomyHook.Action.WARP_TELEPORT);
}
}
@@ -29,10 +29,8 @@ import net.william278.huskhomes.network.Broker;
import net.william278.huskhomes.position.World;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.*;
import java.util.stream.Collectors;
/**
* Plugin settings, read from config.yml
@@ -240,13 +238,14 @@ public class Settings {
@YamlKey("economy.free_home_slots")
private int freeHomeSlots = 5;
@YamlComment("Require money to perform certain actions. Check https://william278.net/docs/huskhomes/economy-hook for available actions")
@YamlKey("economy.costs")
private Map<String, Double> economyCosts = Map.of(
EconomyHook.Action.ADDITIONAL_HOME_SLOT.name().toLowerCase(), EconomyHook.Action.ADDITIONAL_HOME_SLOT.getDefaultCost(),
EconomyHook.Action.MAKE_HOME_PUBLIC.name().toLowerCase(), EconomyHook.Action.MAKE_HOME_PUBLIC.getDefaultCost(),
EconomyHook.Action.RANDOM_TELEPORT.name().toLowerCase(), EconomyHook.Action.RANDOM_TELEPORT.getDefaultCost(),
EconomyHook.Action.BACK_COMMAND.name().toLowerCase(), EconomyHook.Action.BACK_COMMAND.getDefaultCost()
);
private Map<String, Double> economyCosts = Arrays.stream(EconomyHook.Action.values())
.filter(action -> action.getDefaultCost() > 0)
.collect(Collectors.toMap(
action -> action.name().toLowerCase(Locale.ENGLISH),
EconomyHook.Action::getDefaultCost)
);
// Mapping plugins
@YamlComment("Display public homes/warps on your web map (supports Dynmap and BlueMap)")
@@ -488,7 +487,7 @@ public class Settings {
if (!doEconomy()) {
return Optional.empty();
}
final Double cost = economyCosts.get(action.name().toLowerCase());
final Double cost = economyCosts.get(action.name().toLowerCase(Locale.ENGLISH));
if (cost != null && cost > 0d) {
return Optional.of(cost);
}
@@ -20,9 +20,12 @@
package net.william278.huskhomes.hook;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.config.Locales;
import net.william278.huskhomes.user.OnlineUser;
import org.jetbrains.annotations.NotNull;
import java.util.Locale;
/**
* A hook that provides economy features
*/
@@ -59,25 +62,61 @@ public abstract class EconomyHook extends Hook {
public abstract String formatCurrency(final double amount);
/**
* Identifies actions that incur an economic cost if economy is enabled
* Send the player a message notifying them that they have been charged
* for performing an action
*
* @param user the user to notify
* @param plugin the plugin instance
* @param action the action that was performed
*/
public final void notifyDeducted(@NotNull OnlineUser user, @NotNull HuskHomes plugin, @NotNull Action action) {
plugin.getSettings().getEconomyCost(action)
.flatMap(cost -> plugin.getLocales().getLocale(
"economy_transaction_complete",
formatCurrency(cost),
Locales.escapeText(plugin.getLocales()
.getRawLocale("economy_action_" + action.name().toLowerCase(Locale.ENGLISH))
.orElse(action.name()))
))
.ifPresent(user::sendMessage);
}
/**
* Identifies actions that have a price associated with performing them
*/
public enum Action {
ADDITIONAL_HOME_SLOT(100.00, "economy_action_additional_home_slot"),
MAKE_HOME_PUBLIC(50.00, "economy_action_make_home_public"),
RANDOM_TELEPORT(25.00, "economy_action_random_teleport"),
BACK_COMMAND(0.00, "economy_action_back_command");
/*
* Home and public home slots
*/
ADDITIONAL_HOME_SLOT(100.00),
MAKE_HOME_PUBLIC(50.00),
BACK_COMMAND(0.00),
/*
* Teleportation actions
*/
RANDOM_TELEPORT(25.00),
HOME_TELEPORT(0.00),
PUBLIC_HOME_TELEPORT(0.00),
WARP_TELEPORT(0.00),
SPAWN_TELEPORT(0.00),
/*
* Teleport request actions
*/
SEND_TELEPORT_REQUEST(0.00),
ACCEPT_TELEPORT_REQUEST(0.00);
private final double defaultCost;
@NotNull
public final String confirmationLocaleId;
Action(final double defaultCost, @NotNull String confirmationLocaleId) {
Action(double defaultCost) {
this.defaultCost = defaultCost;
this.confirmationLocaleId = confirmationLocaleId;
}
public double getDefaultCost() {
return defaultCost;
}
}
}
@@ -176,11 +176,11 @@ public class HomesManager {
throw new ValidationException(ValidationException.Type.NOT_ENOUGH_HOME_SLOTS);
}
if (!plugin.validateEconomyCheck(online, EconomyHook.Action.ADDITIONAL_HOME_SLOT)) {
if (!plugin.canPerformTransaction(online, EconomyHook.Action.ADDITIONAL_HOME_SLOT)) {
throw new ValidationException(ValidationException.Type.NOT_ENOUGH_MONEY);
}
plugin.performEconomyTransaction(online, EconomyHook.Action.ADDITIONAL_HOME_SLOT);
plugin.performTransaction(online, EconomyHook.Action.ADDITIONAL_HOME_SLOT);
plugin.editUserData(online, (SavedUser saved) -> saved.setHomeSlots(saved.getHomeSlots() + 1));
}
@@ -21,6 +21,7 @@ package net.william278.huskhomes.manager;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.config.Settings;
import net.william278.huskhomes.hook.EconomyHook;
import net.william278.huskhomes.network.Message;
import net.william278.huskhomes.network.Payload;
import net.william278.huskhomes.teleport.Teleport;
@@ -254,6 +255,12 @@ public class RequestsManager {
.ifPresent(recipient::sendMessage);
return;
}
// Validate the economy check
if (accepted && !plugin.canPerformTransaction(recipient, EconomyHook.Action.ACCEPT_TELEPORT_REQUEST)) {
return;
}
handleRequestResponse(lastRequest.get(), recipient, accepted);
}
@@ -301,6 +308,7 @@ public class RequestsManager {
// If the request is a tpa here request, teleport the recipient to the sender
if (accepted && request.getType() == TeleportRequest.Type.TPA_HERE) {
final TeleportBuilder builder = Teleport.builder(plugin)
.economyActions(EconomyHook.Action.ACCEPT_TELEPORT_REQUEST)
.teleporter(recipient);
// Strict /tpahere requests will teleport to where the sender was when typing the command
@@ -313,7 +321,7 @@ public class RequestsManager {
try {
builder.toTimedTeleport().execute();
} catch (TeleportationException e) {
e.displayMessage(recipient, plugin, new String[0]);
e.displayMessage(recipient, plugin);
}
}
}));
@@ -344,10 +352,11 @@ public class RequestsManager {
Teleport.builder(plugin)
.teleporter(requester)
.target(request.getRecipientName())
.economyActions(EconomyHook.Action.ACCEPT_TELEPORT_REQUEST)
.toTimedTeleport()
.execute();
} catch (TeleportationException e) {
e.displayMessage(requester, plugin, new String[0]);
e.displayMessage(requester, plugin);
}
}
}
@@ -177,7 +177,7 @@ public class Teleport {
// Check economy actions
protected void validateEconomyActions() throws TeleportationException {
if (economyActions.stream()
.map(action -> plugin.validateEconomyCheck(executor, action))
.map(action -> plugin.canPerformTransaction(executor, action))
.anyMatch(result -> !result)) {
throw new TeleportationException(TeleportationException.Type.ECONOMY_ACTION_FAILED);
}
@@ -185,7 +185,7 @@ public class Teleport {
// Perform transactions on economy actions
private void executeEconomyActions() {
economyActions.forEach(action -> plugin.performEconomyTransaction(executor, action));
economyActions.forEach(action -> plugin.performTransaction(executor, action));
}
@NotNull
@@ -41,4 +41,12 @@ public interface Teleportable {
return new Username(teleporter);
}
/**
* Get the username of the teleporter
*
* @return the username string
*/
@NotNull
String getUsername();
}
@@ -51,4 +51,15 @@ public record Username(@NotNull String name) implements Teleportable, Target {
? plugin.getOnlineUserExact(name) : plugin.getOnlineUser(name);
}
/**
* Get the username {@link String} being represented by this object
*
* @return the username
*/
@NotNull
@Override
public String getUsername() {
return name;
}
}
@@ -0,0 +1,87 @@
/*
* This file is part of HuskHomes, licensed under the Apache License 2.0.
*
* Copyright (c) William278 <[email protected]>
* Copyright (c) contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.william278.huskhomes.util;
import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.hook.EconomyHook;
import net.william278.huskhomes.user.OnlineUser;
import org.jetbrains.annotations.NotNull;
import java.util.Optional;
/**
* Utility class for resolving and performing economy transactions through an {@link EconomyHook}
*/
public interface TransactionResolver {
/**
* Perform an economy check on the {@link OnlineUser}; returning {@code true} if it passes the check
*
* @param player the {@link OnlineUser player} to perform the check on
* @param action the {@link EconomyHook.Action action} to perform
* @return {@code true} if the action passes the check, {@code false} if the user has insufficient funds
*/
default boolean canPerformTransaction(@NotNull OnlineUser player, @NotNull EconomyHook.Action action) {
return getPlugin().getSettings().getEconomyCost(action)
.map(Math::abs)
.flatMap(c -> player.hasPermission(EconomyHook.BYPASS_PERMISSION) ? Optional.empty() : Optional.of(c))
.map(c -> getEconomyHook()
.map(hook -> {
if (hook.getPlayerBalance(player) < c) {
getPlugin().getLocales().getLocale("error_insufficient_funds", hook.formatCurrency(c))
.ifPresent(player::sendMessage);
return false;
}
return true;
})
.orElse(true))
.orElse(true);
}
/**
* Execute an economy transaction if needed, updating the player's balance
*
* @param player the {@link OnlineUser player} to deduct the cost from if needed
* @param action the {@link EconomyHook.Action action} to deduct the cost from if needed
*/
default void performTransaction(@NotNull OnlineUser player, @NotNull EconomyHook.Action action) {
getPlugin().getSettings().getEconomyCost(action)
.map(Math::abs)
.flatMap(c -> player.hasPermission(EconomyHook.BYPASS_PERMISSION) ? Optional.empty() : Optional.of(c))
.ifPresent(cost -> getEconomyHook().ifPresent(hook -> {
hook.changePlayerBalance(player, -cost);
hook.notifyDeducted(player, getPlugin(), action);
}));
}
/**
* Get the {@link EconomyHook} instance, if present
*
* @return the {@link EconomyHook} instance
*/
@NotNull
default Optional<EconomyHook> getEconomyHook() {
return getPlugin().getHook(EconomyHook.class);
}
@NotNull
HuskHomes getPlugin();
}
+11 -4
View File
@@ -89,10 +89,17 @@ delete_all_homes_confirm: '[Предупреждение:](#ff3300) [Сигур
delete_all_warps_confirm: '[Предупреждение:](#ff3300) [Сигурни ли сте, че желаете да изтриете всеки уарп?](#ff7e5e)\n[Веднъж щом потвърдите, няма да бъде възможно да ги възстановите.](gray)\n[→](gray) [[Потвърди]](#ff3300 show_text=&#ff3300&Натиснете, за да потвърдите изтриването. То не може да бъде отменено. run_command=/delwarp all confirm)'
delete_all_homes_success: '[Успешно изтрихте Вашият/Вашите](#00fb9a) [%1%](#00fb9a bold) [дом(ове).](#00fb9a)'
delete_all_warps_success: '[Успешно изтрихте целият/всичките](#00fb9a) [%1%](#00fb9a bold) [сървърен(и) уарп(ове).](#00fb9a)'
economy_action_additional_home_slot: '[ℹ Spent %1% to set an additional home.](gray)'
economy_action_make_home_public: '[ℹ Spent %1% to make your home public.](gray)'
economy_action_random_teleport: '[ℹ Spent %1% to randomly teleport.](gray)'
economy_action_back_command: '[ℹ Spent %1% to return to your last position.](gray)'
economy_transaction_complete: '[ℹ %1% has been deducted from your account. (%2%)](gray)'
economy_action_additional_home_slot: 'Bought an additional home slot'
economy_action_make_home_public: 'Made a home public'
economy_action_back_command: 'Used the /back command'
economy_action_random_teleport: 'Used the /rtp command'
economy_action_home_teleport: 'Used the /home command'
economy_action_public_home_teleport: 'Used the /phome command'
economy_action_warp_teleport: 'Used the /warp command'
economy_action_spawn_teleport: 'Used the /spawn command'
economy_action_send_teleport_request: 'Sent a teleport request'
economy_action_accept_teleport_request: 'Accepted a teleport request'
return_by_death_notification: '[Return to where you died?](gray) [[⏪ Teleport…]](#00fb9a show_text=&#00fb9a&Click to teleport\n&7Return to where you died run_command=/huskhomes:back)'
map_hook_public_homes_marker_set_name: 'Public Homes'
map_hook_warps_marker_set_name: 'Warps'
+11 -4
View File
@@ -89,10 +89,17 @@ delete_all_homes_confirm: '[Warnung:](#ff3300) [Bist du dir sicher, dass du alle
delete_all_warps_confirm: '[Warnung:](#ff3300) [Bist du dir sicher, dass du alle Warps löschen möchtest?](#ff7e5e)\n[Sobald dies bestätigt wurde, ist es nicht mehr möglich diese wiederherzustellen.](gray)\n[→](gray) [[Bestätigen]](#ff3300 show_text=&#ff3300&Klicke um die Löschung zu bestätigen. Dies kann nicht rückgängig gemacht werden! run_command=/huskhomes:delwarp all confirm)'
delete_all_homes_success: '[Erfolgreich alle](#00fb9a) [%1%](#00fb9a bold) [Homes gelöscht.](#00fb9a)'
delete_all_warps_success: '[Erfolgreich alle](#00fb9a) [%1%](#00fb9a bold) [Warps gelöscht.](#00fb9a)'
economy_action_additional_home_slot: '[ℹ %1% für das Setzen eines neuen Homes ausgegeben.](gray)'
economy_action_make_home_public: '[ℹ %1% für das Setzen deines Homes auf öffentlich ausgegeben.](gray)'
economy_action_random_teleport: '[ℹ %1% ausgegeben, um zufällig teleportiert zu werden.](gray)'
economy_action_back_command: '[ℹ %1% ausgegeben, um zu deiner letzten Position zurückzukehren.](gray)'
economy_transaction_complete: '[ℹ %1% has been deducted from your account. (%2%)](gray)'
economy_action_additional_home_slot: 'Bought an additional home slot'
economy_action_make_home_public: 'Made a home public'
economy_action_back_command: 'Used the /back command'
economy_action_random_teleport: 'Used the /rtp command'
economy_action_home_teleport: 'Used the /home command'
economy_action_public_home_teleport: 'Used the /phome command'
economy_action_warp_teleport: 'Used the /warp command'
economy_action_spawn_teleport: 'Used the /spawn command'
economy_action_send_teleport_request: 'Sent a teleport request'
economy_action_accept_teleport_request: 'Accepted a teleport request'
return_by_death_notification: '[Dorthin zurückkehren, wo du gestorben bist?](gray) [[⏪ Teleportieren…]](#00fb9a show_text=&#00fb9a&Klicke, um dich zu teleportieren\n&7Kehre dorthin zurück, wo du gestorben bist run_command=/huskhomes:back)'
map_hook_public_homes_marker_set_name: 'Öffentliche Homes'
map_hook_warps_marker_set_name: 'Warps'
+11 -4
View File
@@ -89,10 +89,17 @@ delete_all_homes_confirm: '[Warning:](#ff3300) [Are you sure you want to delete
delete_all_warps_confirm: '[Warning:](#ff3300) [Are you sure you want to delete every warp?](#ff7e5e)\n[Once you confirm, it will not be possible to recover them.](gray)\n[→](gray) [[Confirm]](#ff3300 show_text=&#ff3300&Click to confirm deletion. This cannot be undone. run_command=/delwarp all confirm)'
delete_all_homes_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [home(s).](#00fb9a)'
delete_all_warps_success: '[Successfully deleted](#00fb9a) [%1%](#00fb9a bold) [server warp(s).](#00fb9a)'
economy_action_additional_home_slot: '[ℹ Spent %1% to set an additional home.](gray)'
economy_action_make_home_public: '[ℹ Spent %1% to make your home public.](gray)'
economy_action_random_teleport: '[ℹ Spent %1% to randomly teleport.](gray)'
economy_action_back_command: '[ℹ Spent %1% to return to your last position.](gray)'
economy_transaction_complete: '[ℹ %1% has been deducted from your account. (%2%)](gray)'
economy_action_additional_home_slot: 'Bought an additional home slot'
economy_action_make_home_public: 'Made a home public'
economy_action_back_command: 'Used the /back command'
economy_action_random_teleport: 'Used the /rtp command'
economy_action_home_teleport: 'Used the /home command'
economy_action_public_home_teleport: 'Used the /phome command'
economy_action_warp_teleport: 'Used the /warp command'
economy_action_spawn_teleport: 'Used the /spawn command'
economy_action_send_teleport_request: 'Sent a teleport request'
economy_action_accept_teleport_request: 'Accepted a teleport request'
return_by_death_notification: '[Return to where you died?](gray) [[⏪ Teleport…]](#00fb9a show_text=&#00fb9a&Click to teleport\n&7Return to where you died run_command=/huskhomes:back)'
map_hook_public_homes_marker_set_name: 'Public Homes'
map_hook_warps_marker_set_name: 'Warps'
+11 -4
View File
@@ -89,10 +89,17 @@ delete_all_homes_confirm: '[Advertencia:](#ff3300) [¿Estás seguro de que quier
delete_all_warps_confirm: '[Advertencia:](#ff3300) [¿Estás seguro de que quieres borrar todos los warps?](#ff7e5e)\n[Una vez confirmados, no será posible recuperarlos.](gray)\n[→](gray) [[Confirmar]](#ff3300 show_text=&#ff3300&Clic para confirmar la eliminación. Esto no se puede deshacer. run_command=/delwarp all confirm)'
delete_all_homes_success: '[Eliminado con éxito](#00fb9a) [%1%](#00fb9a bold) [Casa(s).](#00fb9a)'
delete_all_warps_success: '[Eliminado con éxito](#00fb9a) [%1%](#00fb9a bold) [server warp(s).](#00fb9a)'
economy_action_additional_home_slot: '[ℹ Paga %1% para establecer un hogar adicional.](gray)'
economy_action_make_home_public: '[ℹ Paga %1% Para hacer tu casa pública.](gray)'
economy_action_random_teleport: '[ℹ Paga %1% para teletransportarse aleatoriamente.](gray)'
economy_action_back_command: '[ℹ Paga %1% para volver a su última posición.](gray)'
economy_transaction_complete: '[ℹ %1% has been deducted from your account. (%2%)](gray)'
economy_action_additional_home_slot: 'Bought an additional home slot'
economy_action_make_home_public: 'Made a home public'
economy_action_back_command: 'Used the /back command'
economy_action_random_teleport: 'Used the /rtp command'
economy_action_home_teleport: 'Used the /home command'
economy_action_public_home_teleport: 'Used the /phome command'
economy_action_warp_teleport: 'Used the /warp command'
economy_action_spawn_teleport: 'Used the /spawn command'
economy_action_send_teleport_request: 'Sent a teleport request'
economy_action_accept_teleport_request: 'Accepted a teleport request'
return_by_death_notification: '[¿Regresar al lugar donde murió?](gray) [[⏪ Teletransportar…]](#00fb9a show_text=&#00fb9a&Clic para teletransportarte\n&7Regresa al lugar donde moriste run_command=/huskhomes:back)'
map_hook_public_homes_marker_set_name: 'Public Homes'
map_hook_warps_marker_set_name: 'Warps'
+11 -4
View File
@@ -89,10 +89,17 @@ delete_all_homes_confirm: '[Attenzione:](#ff3300) [Sei sicuro di voler eliminare
delete_all_warps_confirm: '[Attenzione:](#ff3300) [Sei sicuro di voler eliminare tutti i warp?](#ff7e5e)\n[Una volta confermato non sarà possibile recuperarli.](gray)\n[→](gray) [[Conferma]](#ff3300 show_text=&#ff3300&Clicca per confermare. AZIONE IRREVERSIBILE. run_command=/delwarp all confirm)'
delete_all_homes_success: '[Eliminata con successo la](#00fb9a) [%1%](#00fb9a bold) [home.](#00fb9a)'
delete_all_warps_success: '[Eliminati con successo tutti i](#00fb9a) [%1%](#00fb9a bold) [warp.](#00fb9a)'
economy_action_additional_home_slot: '[ℹ Hai pagato %1% per impostare una nuova home.](gray)'
economy_action_make_home_public: '[ℹ Hai pagato %1% per impostare la tua home come pubblica.](gray)'
economy_action_random_teleport: '[ℹ Hai pagato %1% per teletrasportarti randomicamente.](gray)'
economy_action_back_command: '[ℹ Hai pagato %1% per tornare alla posizione precedente.](gray)'
economy_transaction_complete: '[ℹ %1% has been deducted from your account. (%2%)](gray)'
economy_action_additional_home_slot: 'Bought an additional home slot'
economy_action_make_home_public: 'Made a home public'
economy_action_back_command: 'Used the /back command'
economy_action_random_teleport: 'Used the /rtp command'
economy_action_home_teleport: 'Used the /home command'
economy_action_public_home_teleport: 'Used the /phome command'
economy_action_warp_teleport: 'Used the /warp command'
economy_action_spawn_teleport: 'Used the /spawn command'
economy_action_send_teleport_request: 'Sent a teleport request'
economy_action_accept_teleport_request: 'Accepted a teleport request'
return_by_death_notification: '[Vuoi ritornare dove sei morto?](gray) [[⏪ Teletrasportati…]](#00fb9a show_text=&#00fb9a&Clicca per teletrasportarti\n&7e tornare dove sei morto run_command=/huskhomes:back)'
map_hook_public_homes_marker_set_name: 'Home pubbliche'
map_hook_warps_marker_set_name: 'Warp'
+11 -4
View File
@@ -89,10 +89,17 @@ delete_all_homes_confirm: '[Ostrzeżenie:](#ff3300) [Czy chcesz skasować wszyst
delete_all_warps_confirm: '[Ostrzeżenie:](#ff3300) [Czy chcesz skasować wszystkie warpy?](#ff7e5e)\n[Jest to nie odwracalna zmiana.](gray)\n[→](gray) [[Potwierdź]](#ff3300 show_text=&#ff3300&Potwierdź usunięcie, nie da się tego przywrócić. run_command=/delwarp all confirm)'
delete_all_homes_success: '[Pomyślnie usunąłem twoje](#00fb9a) [%1%](#00fb9a bold) [domy.](#00fb9a)'
delete_all_warps_success: '[Pomyślnie usunąłem wszyskie](#00fb9a) [%1%](#00fb9a bold) [warpów.](#00fb9a)'
economy_action_additional_home_slot: '[ℹ Spent %1% to set an additional home.](gray)'
economy_action_make_home_public: '[ℹ Spent %1% to make your home public.](gray)'
economy_action_random_teleport: '[ℹ Spent %1% to randomly teleport.](gray)'
economy_action_back_command: '[ℹ Spent %1% to return to your last position.](gray)'
economy_transaction_complete: '[ℹ %1% has been deducted from your account. (%2%)](gray)'
economy_action_additional_home_slot: 'Bought an additional home slot'
economy_action_make_home_public: 'Made a home public'
economy_action_back_command: 'Used the /back command'
economy_action_random_teleport: 'Used the /rtp command'
economy_action_home_teleport: 'Used the /home command'
economy_action_public_home_teleport: 'Used the /phome command'
economy_action_warp_teleport: 'Used the /warp command'
economy_action_spawn_teleport: 'Used the /spawn command'
economy_action_send_teleport_request: 'Sent a teleport request'
economy_action_accept_teleport_request: 'Accepted a teleport request'
return_by_death_notification: '[Return to where you died?](gray) [[⏪ Teleport…]](#00fb9a show_text=&#00fb9a&Click to teleport\n&7Return to where you died run_command=/huskhomes:back)'
map_hook_public_homes_marker_set_name: 'Public Homes'
map_hook_warps_marker_set_name: 'Warps'
+11 -4
View File
@@ -89,10 +89,17 @@ delete_all_homes_confirm: '[Uyarı:](#ff3300) [Tüm evlerinizi silmek istediğin
delete_all_warps_confirm: '[Uyarı:](#ff3300) [Tüm warpları silmek istediğinizden emin misiniz?](#ff7e5e)\n[Onayladıktan sonra, onları kurtarmak mümkün olmayacak.](gray)\n[→](gray) [[Onayla]](#ff3300 show_text=&#ff3300&Silme işlemini onaylamak için tıklayın. Bu geri alınamaz. run_command=/delwarp all confirm)'
delete_all_homes_success: '[Başarıyla](#00fb9a) [%1%](#00fb9a bold) [ev(ler) silindi.](#00fb9a)'
delete_all_warps_success: '[Başaryla](#00fb9a) [%1%](#00fb9a bold) [warp(lar) silindi.](#00fb9a)'
economy_action_additional_home_slot: '[ℹ Ek bir ev ayarlamak için %1% harcadınız.](gray)'
economy_action_make_home_public: '[ℹ Evinizi herkese açık hale getirmek için %1% harcadınız.](gray)'
economy_action_random_teleport: '[ℹ Rastgele ışınlanmak için %1% harcadınız.](gray)'
economy_action_back_command: '[ℹ Son konumunuza dönmek için %1% harcadınız.](gray)'
economy_transaction_complete: '[ℹ %1% has been deducted from your account. (%2%)](gray)'
economy_action_additional_home_slot: 'Bought an additional home slot'
economy_action_make_home_public: 'Made a home public'
economy_action_back_command: 'Used the /back command'
economy_action_random_teleport: 'Used the /rtp command'
economy_action_home_teleport: 'Used the /home command'
economy_action_public_home_teleport: 'Used the /phome command'
economy_action_warp_teleport: 'Used the /warp command'
economy_action_spawn_teleport: 'Used the /spawn command'
economy_action_send_teleport_request: 'Sent a teleport request'
economy_action_accept_teleport_request: 'Accepted a teleport request'
return_by_death_notification: '[Öldüğün yere dön?](gray) [[⏪ Işınlanma…]](#00fb9a show_text=&#00fb9a&Işınlanmak için tıklayın\n&7Öldüğün yere dön run_command=/huskhomes:back)'
map_hook_public_homes_marker_set_name: 'Public Homes'
map_hook_warps_marker_set_name: 'Warps'
+11 -4
View File
@@ -89,10 +89,17 @@ delete_all_homes_confirm: '[Warning:](#ff3300) [Ви впевнені, що хо
delete_all_warps_confirm: '[Warning:](#ff3300) [Ви впевнені, що бажаєте видалити усі варпи?] (#ff7e5e)\n[Після підтвердження відновити їх буде неможливо.](gray)\n[→](gray) [[Підтвердити]](#ff3300 show_text=&#ff3300&Натисніть, щоб підтвердити видалення. Цю дію неможливо скасувати. run_command=/delwarp all confirm)'
delete_all_homes_success: '[Успішно видалено твої домівки](#00fb9a) [%1%](#00fb9a bold) [.](#00fb9a)'
delete_all_warps_success: '[Успішно видалено усі варпи серверу](#00fb9a) [%1%](#00fb9a bold) [.](#00fb9a)'
economy_action_additional_home_slot: '[ℹ Spent %1% to set an additional home.](gray)'
economy_action_make_home_public: '[ℹ Spent %1% to make your home public.](gray)'
economy_action_random_teleport: '[ℹ Spent %1% to randomly teleport.](gray)'
economy_action_back_command: '[ℹ Spent %1% to return to your last position.](gray)'
economy_transaction_complete: '[ℹ %1% has been deducted from your account. (%2%)](gray)'
economy_action_additional_home_slot: 'Bought an additional home slot'
economy_action_make_home_public: 'Made a home public'
economy_action_back_command: 'Used the /back command'
economy_action_random_teleport: 'Used the /rtp command'
economy_action_home_teleport: 'Used the /home command'
economy_action_public_home_teleport: 'Used the /phome command'
economy_action_warp_teleport: 'Used the /warp command'
economy_action_spawn_teleport: 'Used the /spawn command'
economy_action_send_teleport_request: 'Sent a teleport request'
economy_action_accept_teleport_request: 'Accepted a teleport request'
return_by_death_notification: '[Return to where you died?](gray) [[⏪ Teleport…]](#00fb9a show_text=&#00fb9a&Click to teleport\n&7Return to where you died run_command=/huskhomes:back)'
map_hook_public_homes_marker_set_name: 'Public Homes'
map_hook_warps_marker_set_name: 'Warps'
+11 -4
View File
@@ -89,10 +89,17 @@ delete_all_homes_confirm: '[警告:](#ff3300) [您确定删除这个家?](#ff7e5
delete_all_warps_confirm: '[警告:](#ff3300) [您确定删除这个地标?](#ff7e5e)\n[此操作无法撤消!](gray)\n[→](gray) [[删除]](#ff3300 show_text=&#ff3300&点击删除, 此操作无法撤消! run_command=/delwarp all confirm)'
delete_all_homes_success: '[成功删除家](#00fb9a) [%1%](#00fb9a bold) [.](#00fb9a)'
delete_all_warps_success: '[成功删除服务器](#00fb9a) [%1%](#00fb9a bold) [所有的地标](#00fb9a)'
economy_action_additional_home_slot: '[ℹ 花费 %1% 设置了一个额外的家.](gray)'
economy_action_make_home_public: '[ℹ 花费 %1% 将家设为公开.](gray)'
economy_action_random_teleport: '[ℹ 花费 %1% 使用随机传送.](gray)'
economy_action_back_command: '[ℹ 花费 %1% 回到上一位置.](gray)'
economy_transaction_complete: '[ℹ %1% has been deducted from your account. (%2%)](gray)'
economy_action_additional_home_slot: 'Bought an additional home slot'
economy_action_make_home_public: 'Made a home public'
economy_action_back_command: 'Used the /back command'
economy_action_random_teleport: 'Used the /rtp command'
economy_action_home_teleport: 'Used the /home command'
economy_action_public_home_teleport: 'Used the /phome command'
economy_action_warp_teleport: 'Used the /warp command'
economy_action_spawn_teleport: 'Used the /spawn command'
economy_action_send_teleport_request: 'Sent a teleport request'
economy_action_accept_teleport_request: 'Accepted a teleport request'
return_by_death_notification: '[回到上一个位置?](gray) [[⏪ 点击传送…]](#00fb9a show_text=&#00fb9a&点击传送\n&7返回上一位置 run_command=/huskhomes:back)'
map_hook_public_homes_marker_set_name: '公开的家'
map_hook_warps_marker_set_name: '地标'
+11 -4
View File
@@ -89,10 +89,17 @@ delete_all_homes_confirm: '[警告:](#ff3300) [您確定刪除這個家?](#ff7e5
delete_all_warps_confirm: '[警告:](#ff3300) [您確定刪除這個地標?](#ff7e5e)\n[此操作無法撤消!](gray)\n[→](gray) [[確認]](#ff3300 show_text=&#ff3300&點擊刪除, 此操作無法撤消! run_command=/delwarp all confirm)'
delete_all_homes_success: '[成功刪除家](#00fb9a) [%1%](#00fb9a bold) [.](#00fb9a)'
delete_all_warps_success: '[成功刪除伺服器](#00fb9a) [%1%](#00fb9a bold) [所有的地標](#00fb9a)'
economy_action_additional_home_slot: '[ℹ 花費 %1% 設置了一個額外的家.](gray)'
economy_action_make_home_public: '[ℹ 花費 %1% 將家設為公開.](gray)'
economy_action_random_teleport: '[ℹ 花費 %1% 使用隨機傳送.](gray)'
economy_action_back_command: '[ℹ 花費 %1% 回到上一位置.](gray)'
economy_transaction_complete: '[ℹ %1% has been deducted from your account. (%2%)](gray)'
economy_action_additional_home_slot: 'Bought an additional home slot'
economy_action_make_home_public: 'Made a home public'
economy_action_back_command: 'Used the /back command'
economy_action_random_teleport: 'Used the /rtp command'
economy_action_home_teleport: 'Used the /home command'
economy_action_public_home_teleport: 'Used the /phome command'
economy_action_warp_teleport: 'Used the /warp command'
economy_action_spawn_teleport: 'Used the /spawn command'
economy_action_send_teleport_request: 'Sent a teleport request'
economy_action_accept_teleport_request: 'Accepted a teleport request'
return_by_death_notification: '[回到上一個位置?](gray) [[⏪ 傳送…]](#00fb9a show_text=&#00fb9a&點擊傳送\n&7返回上一位置 run_command=/huskhomes:back)'
map_hook_public_homes_marker_set_name: '公開的家'
map_hook_warps_marker_set_name: '地標'
+17 -12
View File
@@ -1,9 +1,9 @@
The HuskHomes API provides methods for getting, editing and updating user homes and warps, as well as functionality for building and executing (cross-server) teleports.
The API is distributed via [JitPack](https://jitpack.io/#net.william278/HuskHomes2), where you can also [view the JavaDocs](https://javadoc.jitpack.io/net/william278/HuskHomes2/latest/javadoc/).
The API is distributed on Maven through [repo.william278.net](https://repo.william278.net/#/releases/net/william278/huskhomes/) and can be included in any Maven, Gradle, etc. project. JavaDocs are [available here](https://repo.william278.net/javadoc/releases/net/william278/huskhomes/latest).
## Compatibility
![HuskHomes CI](https://jitpack.io/v/WiIIiam278/HuskHomes2.svg)
[![Maven](https://repo.william278.net/api/badge/latest/releases/net/william278/huskhomes?color=00fb9a&name=Maven&prefix=v)](https://repo.william278.net/#/releases/net/william278/huskhomes/)
The HuskHomes API shares version numbering with the plugin itself for consistency and convenience. Please note minor and patch plugin releases may make API additions and deprecations, but will not introduce breaking changes without notice.
@@ -14,6 +14,11 @@ The HuskHomes API shares version numbering with the plugin itself for consistenc
| v2.x | _v2.0&mdash;v2.11.2_ | ❌ |
| v1.x | _v1.5&mdash;v1.5.11_ | ❌ |
<details>
<summary>Targeting older versions</summary>
HuskHomes versions prior to `v4.3.1` are distributed on [JitPack](https://jitpack.io/#/net/william278/HuskHomes2), and you will need to use the `https://jitpack.io` repository instead.
</details>
## Table of contents
1. Adding the API to your project
@@ -25,21 +30,21 @@ The HuskHomes API shares version numbering with the plugin itself for consistenc
<details>
<summary>Maven setup information</summary>
Add the repository to your `pom.xml` as per below.
Add the repository to your `pom.xml` as per below. You can alternatively specify `/snapshots` for the repository containing the latest development builds (not recommended).
```xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
<id>william278.net</id>
<url>https://repo.william278.net/releases</url>
</repository>
</repositories>
```
Add the dependency to your `pom.xml` as per below. Replace `version` with the latest version of HuskHomes (without the v): ![Latest version](https://img.shields.io/github/v/tag/WiIIiam278/HuskHomes2?color=%23282828&label=%20&style=flat-square)
Add the dependency to your `pom.xml` as per below. Replace `VERSION` with the latest version of HuskHomes (without the v): ![Latest version](https://img.shields.io/github/v/tag/WiIIiam278/HuskHomes2?color=%23282828&label=%20&style=flat-square)
```xml
<dependency>
<groupId>net.william278</groupId>
<artifactId>HuskHomes2</artifactId>
<version>version</version>
<artifactId>huskhomes</artifactId>
<version>VERSION</version>
<scope>provided</scope>
</dependency>
```
@@ -49,19 +54,19 @@ Add the dependency to your `pom.xml` as per below. Replace `version` with the la
<details>
<summary>Gradle setup information</summary>
Add the dependency like so to your `build.gradle`:
Add the dependency as per below to your `build.gradle`. You can alternatively specify `/snapshots` for the repository containing the latest development builds (not recommended).
```groovy
allprojects {
repositories {
maven { url 'https://jitpack.io' }
maven { url 'https://repo.william278.net/releases' }
}
}
```
Add the dependency as per below. Replace `version` with the latest version of HuskHomes (without the v): ![Latest version](https://img.shields.io/github/v/tag/WiIIiam278/HuskHomes2?color=%23282828&label=%20&style=flat-square)
Add the dependency as per below. Replace `VERSION` with the latest version of HuskHomes (without the v): ![Latest version](https://img.shields.io/github/v/tag/WiIIiam278/HuskHomes2?color=%23282828&label=%20&style=flat-square)
```groovy
dependencies {
compileOnly 'net.william278:HuskHomes2:version'
compileOnly 'net.william278:huskhomes:VERSION'
}
```
</details>
+2 -2
View File
@@ -100,11 +100,11 @@ economy:
# Use this currency for payments (works only with RedisEconomy), defaults to Vault currency
redis_economy_name: vault
free_home_slots: 5
# Require money to perform certain actions. Check https://william278.net/docs/huskhomes/economy-hook for available actions
costs:
additional_home_slot: 100.0
random_teleport: 25.0
make_home_public: 50.0
back_command: 0.0
random_teleport: 25.0
map_hook:
# Display public homes/warps on your web map (supports Dynmap and BlueMap)
enabled: true
+56 -10
View File
@@ -1,20 +1,66 @@
HuskHomes supports charging players' Vault economy balances for performing certain actions. This requires the Vault plugin and a compatible economy plugin.
HuskHomes supports restricting certain actions behind an economic cost. Players must have enough money in their account to perform the action, otherwise the action will not be allowed. The cost of the action will be deducted from the player's account just before the action is performed.
To enable the economy hook, set `enabled` to `true` under the `economy` section of the config. Players with the `huskhomes.bypass.economy` permission bypass economy checks and don't need to pay for things.
## Setup
<details>
<summary>Spigot & Paper setup</summary>
> **Applies to:** Spigot, Paper
To enable the Economy Hook on Sponge server, install both [Vault](https://www.spigotmc.org/resources/vault.34315/) and a compatible economy plugin. Extended support for [RedisEconomy](https://github.com/Emibergo02/RedisEconomy) is also provided, and the `redis_economy_name` setting can be used to specify the currency to use for transactions. Then, set `enabled` to `true` under the `economy` section of [`config.yml`](config-files).
</details>
<details>
<summary>Sponge setup</summary>
> **Applies to:** Sponge
To enable the Economy Hook on Sponge server, you require a mod installed for managing player economy accounts through the Sponge economy API. Then, set `enabled` to `true` under the `economy` section of [`config.yml`](config-files).
</details>
### Bypassing economy checks
Players with the `huskhomes.bypass.economy` [permission node](commands) bypass economy checks and can perform economy actions without paying.
## Home slots
With the economy hook enabled, players will need to pay for home slots beyond their initial "free" allotment.
The price will be levied against the player when they attempt to set home and have no free slots left. A warning message will notify the player of this when they have set their last free home slot.
You can configure the number of 'free home slots' a user gets using the `free_home_slots` setting in the `economy` section. The default is `5`.
You can configure the number of 'free home slots' a user gets using the `free_home_slots` setting in the `economy` section of the config. The default is `5`.
## Economy actions
You can set prices to charge for these actions.
You can set the economy cost for the following actions in the `costs` section of the `config.yml` file. Note that this section by default only has the `additional_home_slot`, `make_home_public` and `random_teleport` actions defined. Add the other actions to this section of the file and associate a price with them to enable them.
| Action | Description | Default Price |
|------------------------|---------------------------------------------|---------------|
| `ADDITIONAL_HOME_SLOT` | When a user wants to buy another home slot | `$100.00` |
| `MAKE_HOME_PUBLIC` | When a user wants to make their home public | `$50.00` |
| `RANDOM_TELEPORT` | When a user executes /rtp | `$25.00` |
| `BACK_COMMAND` | When a user executes /back | `$0.00` |
### Table of actions
| Economy Action | Description | Default Cost |
|---------------------------|-------------------------------------------------------------|-------------:|
| `additional_home_slot` | When a user wants to buy another home slot | `$100.00` |
| `make_home_public` | When a user wants to make their home public | `$50.00` |
| `random_teleport` | When a user executes /rtp | `$25.00` |
| `back_command` | When a user executes /back to return to their last position | `$0.00` |
| `home_teleport` | When a user executes /home to teleport to a home | `$0.00` |
| `public_home_teleport` | When a user uses /phome to teleport to a public home | `$0.00` |
| `warp_teleport` | When a user uses /warp to teleport to a warp | `$0.00` |
| `spawn_teleport` | When a user uses /spawn to teleport to spawn | `$0.00` |
| `send_teleport_request` | When a user sends a teleport request | `$0.00` |
| `accept_teleport_request` | When a user accepts an incoming teleport request | `$0.00` |
### Example config
<details>
<summary>Defining economy costs (config.yml)</summary>
```yaml
# Require money to perform certain actions. Check https://william278.net/docs/huskhomes/economy-hook for available actions
costs:
additional_home_slot: 100.0
make_home_public: 50.0
random_teleport: 25.0
back_command: 0.0
home_teleport: 0.0
public_home_teleport: 0.0
warp_teleport: 0.0
spawn_teleport: 0.0
send_teleport_request: 0.0
accept_teleport_request: 0.0
```
</details>
+4 -2
View File
@@ -6,11 +6,12 @@ plugins {
}
dependencies {
implementation project(path: ':common')
implementation 'org.bstats:bstats-sponge:3.0.2'
implementation 'redis.clients:jedis:' + jedis_version
implementation 'com.mysql:mysql-connector-j:' + mysql_driver_version
implementation 'org.xerial:sqlite-jdbc:' + sqlite_driver_version
implementation project(path: ':common')
}
sponge {
@@ -71,4 +72,5 @@ shadowJar {
relocate 'dev.dejvokep.boostedyaml', 'net.william278.huskhomes.libraries.boostedyaml'
relocate 'org.yaml.snakeyaml', 'net.william278.huskhomes.libraries.snakeyaml'
relocate 'com.google.gson', 'net.william278.huskhomes.libraries.gson'
relocate 'org.bstats', 'net.william278.huskhomes.libraries.bstats'
}
@@ -51,6 +51,8 @@ import net.william278.huskhomes.util.SpongeSafetyResolver;
import net.william278.huskhomes.util.SpongeTaskRunner;
import net.william278.huskhomes.util.UnsafeBlocks;
import net.william278.huskhomes.util.Validator;
import org.bstats.charts.SimplePie;
import org.bstats.sponge.Metrics;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.api.Game;
@@ -83,6 +85,10 @@ import java.util.stream.Collectors;
@Plugin("huskhomes")
public class SpongeHuskHomes implements HuskHomes, SpongeTaskRunner, SpongeSafetyResolver, SpongeEventDispatcher, RawPlayDataHandler<EngineConnection> {
/**
* Metrics ID for <a href="https://bstats.org/plugin/sponge/HuskHomes/18423">HuskHomes on Sponge</a>.
*/
private static final int METRICS_ID = 18423;
private static final ResourceKey PLUGIN_MESSAGE_CHANNEL_KEY = ResourceKey.of("bungeecord", "main");
// Instance of the plugin
@@ -99,6 +105,8 @@ public class SpongeHuskHomes implements HuskHomes, SpongeTaskRunner, SpongeSafet
private PluginContainer pluginContainer;
@Inject
private Game game;
@Inject
private Metrics.Factory metricsFactory;
private Set<SavedUser> savedUsers;
private Settings settings;
@@ -156,6 +164,7 @@ public class SpongeHuskHomes implements HuskHomes, SpongeTaskRunner, SpongeSafet
});
}
// Check for updates
this.checkForUpdates();
}
@@ -184,6 +193,9 @@ public class SpongeHuskHomes implements HuskHomes, SpongeTaskRunner, SpongeSafet
.collect(Collectors.joining(", ")));
}
});
// Hook into bStats
initialize("metrics", (plugin) -> this.registerMetrics(METRICS_ID));
}
@Listener
@@ -410,7 +422,24 @@ public class SpongeHuskHomes implements HuskHomes, SpongeTaskRunner, SpongeSafet
@Override
public void registerMetrics(int metricsId) {
// No metrics for Sponge
if (!getVersion().getMetadata().isBlank()) {
return;
}
try {
final Metrics metrics = metricsFactory.make(METRICS_ID);
metrics.addCustomChart(new SimplePie("bungee_mode", () -> Boolean.toString(getSettings().doCrossServer())));
if (getSettings().doCrossServer()) {
metrics.addCustomChart(new SimplePie("messenger_type", () -> getSettings().getBrokerType().getDisplayName()));
}
metrics.addCustomChart(new SimplePie("language", () -> getSettings().getLanguage().toLowerCase()));
metrics.addCustomChart(new SimplePie("database_type", () -> getSettings().getDatabaseType().getDisplayName()));
metrics.addCustomChart(new SimplePie("using_economy", () -> Boolean.toString(getSettings().doEconomy())));
metrics.addCustomChart(new SimplePie("using_map", () -> Boolean.toString(getSettings().doMapHook())));
getMapHook().ifPresent(hook -> metrics.addCustomChart(new SimplePie("map_type", hook::getName)));
} catch (Throwable e) {
log(Level.WARNING, "Failed to register bStats metrics (" + e.getMessage() + ")");
}
}
@Override