Skip to content

Commit

Permalink
add: Towny integration
Browse files Browse the repository at this point in the history
  • Loading branch information
MATRIX-feather committed Oct 19, 2024
1 parent 91915ae commit 55ce50d
Show file tree
Hide file tree
Showing 16 changed files with 458 additions and 4 deletions.
11 changes: 11 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ repositories {
includeGroup("de.themoep")
}
}

maven {
url = uri("https://repo.glaremasters.me/repository/towny")
content {
includeGroup("com.palmergames.bukkit.towny")
}
}
}

paperweight.reobfArtifactConfiguration = ReobfArtifactConfiguration.MOJANG_PRODUCTION
Expand All @@ -71,6 +78,8 @@ dependencies {
compileOnly(files("libs/Residence5.1.4.0.jar"))
compileOnly(files("libs/TAB v4.1.2.jar"))

compileOnly("com.palmergames.bukkit.towny:towny:${project.property("towny_version")}")

compileOnly("com.ticxo.modelengine:ModelEngine:${project.property("me_version")}")

//compileOnly("com.github.Gecolay:GSit:${project.property("gsit_version")}")
Expand Down Expand Up @@ -127,6 +136,8 @@ bukkit {

register("play-action")

register("toggle-town-morph-flight")

val featherMorphCommand = register("feathermorph").get()
featherMorphCommand.aliases = listOf("fm");
}
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ gsit_version=1.6.0
papi_version=2.11.5
bstats_version=3.0.2
me_version = R4.0.4
towny_version = 0.100.4.0
6 changes: 3 additions & 3 deletions src/main/java/xyz/nifeather/morph/MorphManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -946,9 +946,6 @@ private void postBuildDisguise(DisguiseBuildResult result,

// 切换CD
skillHandler.switchCooldown(player.getUniqueId(), cdInfo);

// 调用事件
new PlayerMorphEvent(player, state).callEvent();
}

private boolean applyDisguise(MorphParameters parameters,
Expand Down Expand Up @@ -1032,6 +1029,9 @@ private boolean applyDisguise(MorphParameters parameters,

clientHandler.sendCommand(player, new S2CSetAvailableAnimationsCommand(availableAnimations));

// 调用事件
new PlayerMorphEvent(player, state).callEvent();

return true;
}

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/xyz/nifeather/morph/MorphPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import xyz.nifeather.morph.messages.vanilla.VanillaMessageStore;
import xyz.nifeather.morph.misc.NetworkingHelper;
import xyz.nifeather.morph.misc.PlayerOperationSimulator;
import xyz.nifeather.morph.misc.integrations.towny.TownyAdapter;
import xyz.nifeather.morph.misc.recipe.RecipeManager;
import xyz.nifeather.morph.misc.disguiseProperty.DisguiseProperties;
import xyz.nifeather.morph.misc.gui.IconLookup;
Expand Down Expand Up @@ -174,6 +175,12 @@ public void onEnable()
this.registerListener(new ResidenceEventProcessor());
}, true);

softDeps.setHandle("Towny", plugin ->
{
logger.info("Towny detected, applying integrations...");
this.registerListener(new TownyAdapter());
}, true);

softDeps.setHandle("TAB", r ->
{
logger.info("Applying TAB integrations...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import java.util.Map;
import java.util.Stack;
import java.util.concurrent.ConcurrentHashMap;

public class FlyAbility extends MorphAbility<FlyOption>
{
Expand Down Expand Up @@ -248,7 +249,7 @@ public void onGameModeChange(PlayerGameModeChangeEvent e)
}
}

private static final Map<Player, Stack<Object>> blockedPlayersMap = new Object2ObjectOpenHashMap<>();
private static final Map<Player, Stack<Object>> blockedPlayersMap = new ConcurrentHashMap<>();

public static boolean playerBlocked(Player player)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public OptionSubCommand()
subCommands.add(getList("blacklist_nbt_pattern", ConfigOption.BLACKLIST_PATTERNS, null));

subCommands.add(getToggle("ability_check_permissions", ConfigOption.DO_CHECK_ABILITY_PERMISSIONS, null));

subCommands.add(getToggle("towny_allow_flight_in_wilderness", ConfigOption.TOWNY_ALLOW_FLY_IN_WILDERNESS));
}

private ISubCommand getList(String optionName, ConfigOption option,
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/xyz/nifeather/morph/config/ConfigOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ public enum ConfigOption
// SRR -> ServerRenderer
SR_SHOW_PLAYER_DISGUISES_IN_TAB(serverRendererNode().append("show_player_disguises_in_tab"), false),

TOWNY_ALLOW_FLY_IN_WILDERNESS(townyNode().append("allow_fly_in_wilderness"), false),


VERSION(ConfigNode.create().append("version"), 0);

Expand Down Expand Up @@ -202,4 +204,12 @@ private static ConfigNode serverRendererNode()
{
return ConfigNode.create().append("server_renderer");
}
private static ConfigNode integrationNode()
{
return ConfigNode.create().append("integrations");
}
public static ConfigNode townyNode()
{
return integrationNode().append("towny");
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package xyz.nifeather.morph.events;

import com.destroystokyo.paper.event.entity.EntityAddToWorldEvent;
import com.destroystokyo.paper.event.player.PlayerClientOptionsChangeEvent;
import com.destroystokyo.paper.event.player.PlayerPostRespawnEvent;
import de.themoep.inventorygui.InventoryGui;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public static FormattableMessage mirrorIgnoreDisguised()
return getFormattable(getKey("mirror_ignore_disguised"), "使反向控制忽略已伪装的目标");
}

public static FormattableMessage morphFlightForTownX()
{
return getFormattable(getKey("morph_flight_for_town_x"), "[Fallback] <which>的伪装飞行");
}

private static String getKey(String key)
{
return "commands.option.name." + key;
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/xyz/nifeather/morph/messages/CommandStrings.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,24 @@ public static FormattableMessage grantItemSuccess()
return getFormattable(getKey("grant_item_success"), "[Fallback] 成功给与物品。如果没有请检查是否背包已满");
}

public static FormattableMessage unknownError()
{
return getFormattable(getKey("unknown_error"), "[Fallback] <red>执行时发生了意外事故");
}

// towny

public static FormattableMessage townyDoesntHaveTown()
{
return getFormattable(getKey("towny_dont_belong_to_any_town"), "[Fallback] <red>你不属于任何城镇!");
}

public static FormattableMessage townyPlayerNotMayor()
{
return getFormattable(getKey("towny_not_mayor"), "[Fallback] <red>此操作只适用于镇长");
}


private static String getKey(String key)
{
return "commands." + key;
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/xyz/nifeather/morph/messages/CommonStrings.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ public static FormattableMessage commandNotFoundString()
"<color:red>未找到此指令");
}

public static FormattableMessage on()
{
return getFormattable(getKey("on"), "[Fallback] ON");
}

public static FormattableMessage off()
{
return getFormattable(getKey("off"), "[Fallback] OFF");
}

private static String getKey(String key)
{
return "common." + key;
Expand Down
Loading

0 comments on commit 55ce50d

Please sign in to comment.