Skip to content

Commit

Permalink
ResourcePack
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamesuta committed Nov 1, 2020
1 parent 23f43fe commit 9d92322
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/main/java/net/teamfruit/sushida/ResourcePack.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
7 changes: 7 additions & 0 deletions src/main/java/net/teamfruit/sushida/Sushida.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,20 @@ 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() {
// Plugin startup logic
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<String, Word> wordset = Arrays.stream(Optional.ofNullable(folder.listFiles()).orElseGet(() -> new File[0]))
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/net/teamfruit/sushida/player/PlayerData.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resourcepack:
url: https://cdn.discordapp.com/attachments/711308476516663366/772491049695707176/sushida.zip
hash: 1674dcd21ac4d142b1116ddf4de683605fec845c

0 comments on commit 9d92322

Please sign in to comment.