Skip to content

Commit

Permalink
Merge pull request #61 from RedstoneFuture/Improvements/Commands
Browse files Browse the repository at this point in the history
Improvements/commands (B)
  • Loading branch information
daniel-naegele authored Jan 31, 2023
2 parents d6d4761 + 710f50d commit e30211d
Show file tree
Hide file tree
Showing 10 changed files with 621 additions and 272 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import co.aikar.commands.PaperCommandManager;
import de.butzlabben.missilewars.commands.MWCommands;
import de.butzlabben.missilewars.commands.SetupCommands;
import de.butzlabben.missilewars.commands.StatsCommands;
import de.butzlabben.missilewars.commands.UserCommands;
import de.butzlabben.missilewars.configuration.Config;
Expand Down Expand Up @@ -57,9 +58,13 @@ public class MissileWars extends JavaPlugin {
private static MissileWars instance;
public final String version = getDescription().getVersion();
private SignRepository signRepository;
public PaperCommandManager commandManager;

private boolean foundFAWE;

private PlayerListener playerListener;
private SignListener signListener;

public MissileWars() {
instance = this;
}
Expand Down Expand Up @@ -99,7 +104,7 @@ public void onEnable() {
Arenas.load();
SetupUtil.checkShields();

GameManager.getInstance().loadGames();
GameManager.getInstance().loadGamesOnStartup();

new Metrics(this, 3749);

Expand Down Expand Up @@ -143,8 +148,11 @@ public void onDisable() {
* This method registers all events of the missilewars event listener.
*/
private void registerEvents() {
Bukkit.getPluginManager().registerEvents(new PlayerListener(), this);
Bukkit.getPluginManager().registerEvents(new SignListener(), this);
playerListener = new PlayerListener();
signListener = new SignListener();

Bukkit.getPluginManager().registerEvents(playerListener, this);
Bukkit.getPluginManager().registerEvents(signListener, this);
}

/**
Expand All @@ -156,11 +164,12 @@ private void registerCommands() {
// Using the Paper Command Manager does not mean the plugin requires Paper.
// It simply lets it take advantage of Paper specific features if available,
// such as Asynchronous Tab Completions.
PaperCommandManager manager = new PaperCommandManager(this);
commandManager = new PaperCommandManager(this);

manager.registerCommand(new MWCommands());
manager.registerCommand(new StatsCommands());
manager.registerCommand(new UserCommands());
commandManager.registerCommand(new MWCommands());
commandManager.registerCommand(new StatsCommands());
commandManager.registerCommand(new UserCommands());
commandManager.registerCommand(new SetupCommands());
}

/**
Expand All @@ -178,7 +187,7 @@ public boolean foundFAWE() {
private void deleteTempWorlds() {
File[] dirs = Bukkit.getWorldContainer().listFiles();
if (dirs == null) return;

for (File dir : dirs) {
if (dir.getName().startsWith("mw-")) {
try {
Expand Down Expand Up @@ -220,4 +229,12 @@ private void sendPluginInfo() {
Logger.BOOT.log("Other authors: " + sb);
}
}

public PlayerListener getPlayerListener() {
return playerListener;
}

public SignListener getSignListener() {
return signListener;
}
}
Loading

0 comments on commit e30211d

Please sign in to comment.