55import com .github .elic0de .thejpspit .spigot .command .PitCommand ;
66import com .github .elic0de .thejpspit .spigot .command .SpawnCommand ;
77import com .github .elic0de .thejpspit .spigot .config .PitPreferences ;
8+ import com .github .elic0de .thejpspit .spigot .config .Settings ;
89import com .github .elic0de .thejpspit .spigot .database .Database ;
910import com .github .elic0de .thejpspit .spigot .database .SqLiteDatabase ;
1011import com .github .elic0de .thejpspit .spigot .game .Game ;
2122import com .github .elic0de .thejpspit .spigot .item .items .ItemTurtleShell ;
2223import com .github .elic0de .thejpspit .spigot .item .items .ItemUltimateSword ;
2324import com .github .elic0de .thejpspit .spigot .item .items .ItemVividSword ;
25+ import com .github .elic0de .thejpspit .spigot .listener .BlockPlaceListener ;
2426import com .github .elic0de .thejpspit .spigot .listener .CombatTagger ;
2527import com .github .elic0de .thejpspit .spigot .listener .EventListener ;
2628import com .github .elic0de .thejpspit .spigot .network .PluginMessageReceiver ;
3436import com .github .elic0de .thejpspit .spigot .villager .villagers .ShopVillager ;
3537import com .google .gson .Gson ;
3638import com .google .gson .GsonBuilder ;
39+ import java .io .File ;
40+ import java .io .IOException ;
41+ import java .lang .reflect .InvocationTargetException ;
3742import java .util .ArrayList ;
3843import java .util .List ;
3944import java .util .Optional ;
4045import java .util .concurrent .atomic .AtomicBoolean ;
4146import java .util .logging .Level ;
47+ import net .william278 .annotaml .Annotaml ;
4248import org .bukkit .Bukkit ;
4349import org .bukkit .GameRule ;
4450import org .bukkit .plugin .PluginManager ;
4753public final class TheJpsPit extends JavaPlugin {
4854
4955 private static TheJpsPit instance ;
56+ private Settings settings ;
5057 private Game game ;
5158 private Database database ;
5259 private KillRatingHelper ratingHelper ;
@@ -67,9 +74,25 @@ public void onLoad() {
6774 instance = this ;
6875 }
6976
77+ private void loadConfig () throws RuntimeException {
78+ try {
79+ this .settings = Annotaml .create (new File (getDataFolder (), "config.yml" ), Settings .class )
80+ .get ();
81+ } catch (IOException | InvocationTargetException | InstantiationException |
82+ IllegalAccessException e ) {
83+ getLogger ().log (Level .SEVERE , "Failed to load configuration files" , e );
84+ throw new RuntimeException (e );
85+ }
86+ }
87+
88+ public void reload () {
89+ loadConfig ();
90+ }
91+
7092 @ Override
7193 public void onEnable () {
7294 // Initialize TheJpsPit
95+ this .loadConfig ();
7396 saveConfig ();
7497 final AtomicBoolean initialized = new AtomicBoolean (true );
7598 game = new Game ();
@@ -169,6 +192,7 @@ private void registerCommands() {
169192 private void registerListener () {
170193 new EventListener ();
171194 new CombatTagger ();
195+ new BlockPlaceListener ();
172196 }
173197
174198 private void registerHooks () {
@@ -207,6 +231,9 @@ public void onDisable() {
207231 getServer ().getMessenger ().unregisterOutgoingPluginChannel (this );
208232 getServer ().getMessenger ().unregisterIncomingPluginChannel (this );
209233
234+ // 置かれたブロックを削除
235+ BlockPlaceListener .removeBlocks ();
236+
210237 Bukkit .getOnlinePlayers ().forEach (player -> {
211238 final PitPlayer pitPlayer = PitPlayerManager .getPitPlayer (player );
212239 game .leave (pitPlayer );
@@ -217,6 +244,10 @@ public void onDisable() {
217244 Bukkit .getScheduler ().cancelTasks (this );
218245 }
219246
247+ public Settings getSettings () {
248+ return settings ;
249+ }
250+
220251 private List <Hook > getHooks () {
221252 return hooks ;
222253 }
0 commit comments