mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-01 14:38:53 +00:00
refactor: housekeeping, update docs
This commit is contained in:
1 parent
046d8e99f7
commit
842f7d4297
6 files changed
+109
-104
No files matched your search
+10
-2
@@ -6,7 +6,15 @@ HuskHomes supports restricting certain actions behind an economic cost. Players
|
||||
|
||||
> **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. Then, set `enabled` to `true` under the `economy` section of [`config.yml`](config-files).
|
||||
To enable the Economy Hook on a Spigot/Paper server, install both [Vault](https://www.spigotmc.org/resources/vault.34315/) and a compatible economy plugin. Then, set `enabled` to `true` under the `economy` section of [`config.yml`](config-files).
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Fabric setup</summary>
|
||||
|
||||
> **Applies to:** Fabric
|
||||
|
||||
To enable the Economy Hook on a Fabric server, the [Impactor Economy](https://modrinth.com/mod/impactor) mod must be installed to provide an API for plugins to perform economy operations. Then, set `enabled` to `true` under the `economy` section of [`config.yml`](config-files).
|
||||
</details>
|
||||
|
||||
<details>
|
||||
@@ -14,7 +22,7 @@ To enable the Economy Hook on Sponge server, install both [Vault](https://www.sp
|
||||
|
||||
> **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).
|
||||
To enable the Economy Hook on a 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
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
If you have [PlaceholderAPI](https://github.com/PlaceholderAPI/PlaceholderAPI) installed, HuskHomes (v4.0.5+) will automatically register a hook providing a number of placeholders that will be replaced with their appropriate values.
|
||||
HuskHomes (v4.0.5+) can register a hook providing a number of placeholders that will be replaced with their appropriate values.
|
||||
|
||||
On Spigot/Paper, this requires [PlaceholderAPI](https://github.com/PlaceholderAPI/PlaceholderAPI); on Fabric, [Fabric PlaceholderAPI](https://modrinth.com/mod/placeholder-api) is needed instead.
|
||||
|
||||
## List of placeholders
|
||||
| Placeholder | Description | Example Value |
|
||||
|
||||
+4
-10
@@ -6,22 +6,14 @@ apply plugin: 'fabric-loom'
|
||||
loom.serverOnlyMinecraftJar()
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url "https://maven.impactdev.net/repository/development/"
|
||||
name "Impactor Economy"
|
||||
}
|
||||
maven {
|
||||
url "https://maven.nucleoid.xyz/"
|
||||
name "placeholderapi"
|
||||
}
|
||||
maven { url 'https://maven.impactdev.net/repository/development/' }
|
||||
maven { url 'https://maven.nucleoid.xyz/' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${fabric_minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${fabric_yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
|
||||
modImplementation("net.impactdev.impactor.api:economy:${impactor_api_version}")
|
||||
modImplementation include("eu.pb4:placeholder-api:${placeholder_api_version}")
|
||||
|
||||
// Fabric API modules
|
||||
Set<String> fabricApiModules = [
|
||||
@@ -37,6 +29,8 @@ dependencies {
|
||||
}
|
||||
modImplementation include("net.kyori:adventure-platform-fabric:${adventure_platform_fabric_version}")
|
||||
modImplementation include("me.lucko:fabric-permissions-api:${fabric_permissions_api_version}")
|
||||
modImplementation include("eu.pb4:placeholder-api:${fabric_placeholder_api_version}")
|
||||
modImplementation("net.impactdev.impactor.api:economy:${fabric_impactor_api_version}")
|
||||
|
||||
implementation include("redis.clients:jedis:$jedis_version")
|
||||
implementation include("org.apache.commons:commons-pool2:$commons_pool_version")
|
||||
|
||||
@@ -53,7 +53,7 @@ import net.william278.huskhomes.database.SqLiteDatabase;
|
||||
import net.william278.huskhomes.event.FabricEventDispatcher;
|
||||
import net.william278.huskhomes.hook.FabricImpactorEconomyHook;
|
||||
import net.william278.huskhomes.hook.Hook;
|
||||
import net.william278.huskhomes.hook.PlaceHolderAPIHook;
|
||||
import net.william278.huskhomes.hook.FabricPlaceholderAPIHook;
|
||||
import net.william278.huskhomes.listener.EventListener;
|
||||
import net.william278.huskhomes.listener.FabricEventListener;
|
||||
import net.william278.huskhomes.manager.Manager;
|
||||
@@ -203,7 +203,7 @@ public class FabricHuskHomes implements DedicatedServerModInitializer, HuskHomes
|
||||
}
|
||||
|
||||
if (isDependencyLoaded("placeholder-api")) {
|
||||
getHooks().add(new PlaceHolderAPIHook(this));
|
||||
getHooks().add(new FabricPlaceholderAPIHook(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+88
-87
@@ -1,88 +1,89 @@
|
||||
/*
|
||||
* 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.hook;
|
||||
|
||||
import eu.pb4.placeholders.api.PlaceholderResult;
|
||||
import eu.pb4.placeholders.api.Placeholders;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.william278.huskhomes.FabricHuskHomes;
|
||||
import net.william278.huskhomes.user.FabricUser;
|
||||
import net.william278.huskhomes.user.OnlineUser;
|
||||
import net.william278.huskhomes.user.SavedUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlaceHolderAPIHook extends Hook {
|
||||
|
||||
public PlaceHolderAPIHook(@NotNull FabricHuskHomes plugin) {
|
||||
super(plugin, "Fabric PlaceholderAPI");
|
||||
}
|
||||
|
||||
private Identifier createIdentifier(String placeholderName) {
|
||||
return new Identifier("huskhomes", placeholderName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
Placeholders.register(createIdentifier("player"), (ctx, arg) -> {
|
||||
if (!ctx.hasPlayer()) {
|
||||
return PlaceholderResult.invalid("No player!");
|
||||
}
|
||||
|
||||
|
||||
if (arg == null) {
|
||||
return PlaceholderResult.invalid("No argument for player!");
|
||||
}
|
||||
|
||||
assert ctx.player() != null;
|
||||
final OnlineUser player = FabricUser.adapt(ctx.player(), (FabricHuskHomes) plugin);
|
||||
|
||||
final String response = switch (arg) {
|
||||
case "homes_count" -> String.valueOf(plugin.getManager().homes()
|
||||
.getUserHomes()
|
||||
.getOrDefault(player.getUsername(), List.of()).size());
|
||||
case "max_homes" -> String.valueOf(plugin.getManager().homes().getMaxHomes(player));
|
||||
case "max_public_homes" -> String.valueOf(plugin.getManager().homes().getMaxPublicHomes(player));
|
||||
case "free_home_slots" -> String.valueOf(plugin.getManager().homes().getFreeHomes(player));
|
||||
case "home_slots" -> String.valueOf(plugin.getSavedUser(player)
|
||||
.map(SavedUser::getHomeSlots).orElse(0));
|
||||
case "homes_list" -> String.join(", ", plugin.getManager().homes()
|
||||
.getUserHomes()
|
||||
.getOrDefault(player.getUsername(), List.of()));
|
||||
case "public_homes_count" -> String.valueOf(plugin.getManager().homes()
|
||||
.getPublicHomes()
|
||||
.getOrDefault(player.getUsername(), List.of()).size());
|
||||
case "public_homes_list" -> String.join(", ", plugin.getManager().homes()
|
||||
.getPublicHomes()
|
||||
.getOrDefault(player.getUsername(), List.of()));
|
||||
case "ignoring_tp_requests" -> String.valueOf(plugin.getManager().requests()
|
||||
.isIgnoringRequests(player));
|
||||
default -> null;
|
||||
};
|
||||
|
||||
if (response == null) {
|
||||
return PlaceholderResult.invalid("invaild argument for player!");
|
||||
}
|
||||
|
||||
return PlaceholderResult.value(response);
|
||||
});
|
||||
}
|
||||
/*
|
||||
* 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.hook;
|
||||
|
||||
import eu.pb4.placeholders.api.PlaceholderResult;
|
||||
import eu.pb4.placeholders.api.Placeholders;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.william278.huskhomes.FabricHuskHomes;
|
||||
import net.william278.huskhomes.user.FabricUser;
|
||||
import net.william278.huskhomes.user.OnlineUser;
|
||||
import net.william278.huskhomes.user.SavedUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FabricPlaceholderAPIHook extends Hook {
|
||||
|
||||
public FabricPlaceholderAPIHook(@NotNull FabricHuskHomes plugin) {
|
||||
super(plugin, "Fabric PlaceholderAPI");
|
||||
}
|
||||
|
||||
@SuppressWarnings("SameParameterValue")
|
||||
@NotNull
|
||||
private Identifier createIdentifier(@NotNull String name) {
|
||||
return new Identifier("huskhomes", name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
Placeholders.register(createIdentifier("player"), (ctx, arg) -> {
|
||||
if (!ctx.hasPlayer()) {
|
||||
return PlaceholderResult.invalid("No player!");
|
||||
}
|
||||
|
||||
if (arg == null) {
|
||||
return PlaceholderResult.invalid("No argument for player!");
|
||||
}
|
||||
|
||||
assert ctx.player() != null;
|
||||
final OnlineUser player = FabricUser.adapt(ctx.player(), (FabricHuskHomes) plugin);
|
||||
|
||||
final String response = switch (arg) {
|
||||
case "homes_count" -> String.valueOf(plugin.getManager().homes()
|
||||
.getUserHomes()
|
||||
.getOrDefault(player.getUsername(), List.of()).size());
|
||||
case "max_homes" -> String.valueOf(plugin.getManager().homes().getMaxHomes(player));
|
||||
case "max_public_homes" -> String.valueOf(plugin.getManager().homes().getMaxPublicHomes(player));
|
||||
case "free_home_slots" -> String.valueOf(plugin.getManager().homes().getFreeHomes(player));
|
||||
case "home_slots" -> String.valueOf(plugin.getSavedUser(player)
|
||||
.map(SavedUser::getHomeSlots).orElse(0));
|
||||
case "homes_list" -> String.join(", ", plugin.getManager().homes()
|
||||
.getUserHomes()
|
||||
.getOrDefault(player.getUsername(), List.of()));
|
||||
case "public_homes_count" -> String.valueOf(plugin.getManager().homes()
|
||||
.getPublicHomes()
|
||||
.getOrDefault(player.getUsername(), List.of()).size());
|
||||
case "public_homes_list" -> String.join(", ", plugin.getManager().homes()
|
||||
.getPublicHomes()
|
||||
.getOrDefault(player.getUsername(), List.of()));
|
||||
case "ignoring_tp_requests" -> String.valueOf(plugin.getManager().requests()
|
||||
.isIgnoringRequests(player));
|
||||
default -> null;
|
||||
};
|
||||
|
||||
if (response == null) {
|
||||
return PlaceholderResult.invalid("Invaild argument for player!");
|
||||
}
|
||||
|
||||
return PlaceholderResult.value(response);
|
||||
});
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -24,5 +24,5 @@ fabric_yarn_mappings=1.20.4+build.3
|
||||
fabric_api_version=0.95.4+1.20.4
|
||||
fabric_permissions_api_version=0.2-SNAPSHOT
|
||||
adventure_platform_fabric_version=5.11.0
|
||||
impactor_api_version=5.1.1-SNAPSHOT
|
||||
placeholder_api_version=2.3.0+1.20.3
|
||||
fabric_impactor_api_version=5.1.1-SNAPSHOT
|
||||
fabric_placeholder_api_version=2.3.0+1.20.3
|
||||
Reference in new issue
Block a user