From 9d92322f6e8cbf60893221769dac609a2630ca80 Mon Sep 17 00:00:00 2001 From: Kamesuta Date: Mon, 2 Nov 2020 04:47:58 +0900 Subject: [PATCH] ResourcePack --- .../net/teamfruit/sushida/ResourcePack.java | 18 ++++++++++++++++++ .../java/net/teamfruit/sushida/Sushida.java | 7 +++++++ .../teamfruit/sushida/player/PlayerData.java | 4 ++++ src/main/resources/config.yml | 3 +++ 4 files changed, 32 insertions(+) create mode 100644 src/main/java/net/teamfruit/sushida/ResourcePack.java create mode 100644 src/main/resources/config.yml diff --git a/src/main/java/net/teamfruit/sushida/ResourcePack.java b/src/main/java/net/teamfruit/sushida/ResourcePack.java new file mode 100644 index 0000000..39a7247 --- /dev/null +++ b/src/main/java/net/teamfruit/sushida/ResourcePack.java @@ -0,0 +1,18 @@ +package net.teamfruit.sushida; + +import org.bukkit.entity.Player; + +public class ResourcePack { + public final String url; + public final String hash; + + public ResourcePack(String url, String hash) { + this.url = url; + this.hash = hash; + } + + public void apply(Player player) { + if (url != null && hash != null) + player.setResourcePack(url, hash); + } +} diff --git a/src/main/java/net/teamfruit/sushida/Sushida.java b/src/main/java/net/teamfruit/sushida/Sushida.java index bdfa7de..6f09850 100644 --- a/src/main/java/net/teamfruit/sushida/Sushida.java +++ b/src/main/java/net/teamfruit/sushida/Sushida.java @@ -22,6 +22,7 @@ public final class Sushida extends JavaPlugin { public static GameLogic logic; public static Plugin plugin; public static BelowNameManager belowName; + public static ResourcePack resourcePack; @Override public void onEnable() { @@ -29,6 +30,12 @@ public void onEnable() { logger = getLogger(); plugin = this; + // リソースパック + saveDefaultConfig(); + String url = getConfig().getString("resourcepack.url"); + String hash = getConfig().getString("resourcepack.hash"); + resourcePack = new ResourcePack(url, hash); + saveResource("wordset/word.yml", false); File folder = new File(getDataFolder(), "wordset"); Map wordset = Arrays.stream(Optional.ofNullable(folder.listFiles()).orElseGet(() -> new File[0])) diff --git a/src/main/java/net/teamfruit/sushida/player/PlayerData.java b/src/main/java/net/teamfruit/sushida/player/PlayerData.java index c334f97..4da2b8c 100644 --- a/src/main/java/net/teamfruit/sushida/player/PlayerData.java +++ b/src/main/java/net/teamfruit/sushida/player/PlayerData.java @@ -86,6 +86,10 @@ public void create() { return; session = new StateContainer(this); session.apply(StateContainer.supply(TitleState::new)); + + // リソースパック + Sushida.resourcePack.apply(player); + if (!getGroup().getMembers().isEmpty()) joinScoreboard(getGroup().getGroupScoreboard()); Sushida.belowName.spawn(this); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml new file mode 100644 index 0000000..a4f8537 --- /dev/null +++ b/src/main/resources/config.yml @@ -0,0 +1,3 @@ +resourcepack: + url: https://cdn.discordapp.com/attachments/711308476516663366/772491049695707176/sushida.zip + hash: 1674dcd21ac4d142b1116ddf4de683605fec845c \ No newline at end of file