Skip to content

Commit b9516b0

Browse files
committed
update
1 parent cb441e3 commit b9516b0

File tree

3 files changed

+42
-18
lines changed

3 files changed

+42
-18
lines changed

src/main/java/net/azisaba/lgw/core/configs/SpawnsConfig.java

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
import lombok.NonNull;
55
import lombok.SneakyThrows;
66
import net.azisaba.lgw.core.LeonGunWar;
7+
import org.bukkit.Bukkit;
78
import org.bukkit.Location;
9+
import org.bukkit.World;
810
import org.bukkit.configuration.InvalidConfigurationException;
11+
import org.jetbrains.annotations.Nullable;
912

1013
import java.io.IOException;
1114
import java.util.Collections;
@@ -15,37 +18,57 @@
1518
@Getter
1619
public class SpawnsConfig extends Config {
1720

18-
private Map<String, Location> spawns;
19-
private Location lobby;
20-
private Location onsen;
21+
// 位置データは“文字列の world 名+座標”だけ持つ
22+
private static class Pos {
23+
final String worldName;
24+
final double x, y, z;
25+
final float yaw, pitch;
26+
Pos(String worldName, double x, double y, double z, float yaw, float pitch) {
27+
this.worldName = worldName; this.x=x; this.y=y; this.z=z; this.yaw=yaw; this.pitch=pitch;
28+
}
29+
}
30+
31+
private Map<String, Pos> spawns; // ← Location ではなく Pos を保存
2132

2233
public SpawnsConfig(@NonNull LeonGunWar plugin) {
2334
super(plugin, "configs/spawns.yml", "spawns.yml");
2435
}
2536

26-
@SneakyThrows(value = {Exception.class})
2737
@Override
2838
public void loadConfig() throws IOException, InvalidConfigurationException {
2939
super.loadConfig();
3040

31-
spawns = new HashMap<>();
41+
Map<String, Pos> map = new HashMap<>();
3242
for (String spawnName : config.getValues(false).keySet()) {
33-
Location spawn = new Location(
34-
plugin.getServer().getWorld(config.getString(spawnName + ".world")),
43+
String w = config.getString(spawnName + ".world");
44+
Pos p = new Pos(
45+
w,
3546
config.getDouble(spawnName + ".x"),
3647
config.getDouble(spawnName + ".y"),
3748
config.getDouble(spawnName + ".z"),
3849
(float) config.getDouble(spawnName + ".yaw"),
39-
(float) config.getDouble(spawnName + ".pitch"));
40-
spawns.put(spawnName, spawn);
50+
(float) config.getDouble(spawnName + ".pitch")
51+
);
52+
map.put(spawnName, p);
4153
}
42-
spawns = Collections.unmodifiableMap(spawns);
43-
44-
lobby = spawns.get("lobby");
45-
onsen = spawns.get("onsen");
54+
spawns = Collections.unmodifiableMap(map);
4655
}
4756

48-
public Location getLobby() {
49-
return lobby;
57+
/** 使う直前に World を解決。null のときは null を返す(呼び出し側でフォールバック) */
58+
public @Nullable Location get(String name) {
59+
Pos p = spawns.get(name);
60+
if (p == null) {
61+
Bukkit.getLogger().warning("[LGW] spawn '" + name + "' not found in spawns.yml");
62+
return null;
63+
}
64+
World w = plugin.getServer().getWorld(p.worldName);
65+
if (w == null) {
66+
Bukkit.getLogger().warning("[LGW] spawn '" + name + "' world not loaded or not found: " + p.worldName);
67+
return null;
68+
}
69+
return new Location(w, p.x, p.y, p.z, p.yaw, p.pitch);
5070
}
51-
}
71+
72+
public @Nullable Location getLobby() { return get("lobby"); }
73+
public @Nullable Location getOnsen() { return get("onsen"); }
74+
}

src/main/java/net/azisaba/lgw/core/listeners/signs/MatchModeSignListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class MatchModeSignListener implements Listener {
4747

4848
public MatchModeSignListener() {
4949
defaultItem = create(Material.EMERALD_BLOCK, Chat.f("&e通常のチーム分け&aで開始!"));
50-
kdItem = create(Material.DIAMOND_BLOCK, Chat.f("&cK/Dのチーム分け&aで開始!"));
50+
kdItem = create(Material.DIAMOND_BLOCK, Chat.f("&cK/Dのチーム分け&aで開始!(無効化中)"));
5151
}
5252

5353
/**
@@ -195,7 +195,7 @@ public void onInventoryClick(InventoryClickEvent e) {
195195
if (clicked.isSimilar(defaultItem)) {
196196
distributor = new DefaultTeamDistributor();
197197
} else if (clicked.isSimilar(kdItem)) {
198-
distributor = new KDTeamDistributor();
198+
distributor = new DefaultTeamDistributor();
199199
}
200200

201201
if (distributor == null) {

src/main/resources/plugin.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ version: ${version}
44
authors: ["siloneco", "YukiLeafX", "matsu1213", "Arisa9006", "sysnote8main"]
55
description: ${description}
66
website: ${websiteUrl}
7+
load: POSTWORLD
78
depend: ["CrackShot", "Essentials", "WorldGuard", "PlayerSettings", "KDStatusReloaded", "NameChangeAutomation", "LuckPerms"]
89
softdepend: ["Multiverse-Core", "PlaceholderAPI"]
910
api-version: 1.16

0 commit comments

Comments
 (0)