Skip to content

Commit 9f4db8c

Browse files
author
Adam Walker
committed
Merge pull request #3 from mbax/master
ROUND THREE
2 parents 785b6a0 + f30b885 commit 9f4db8c

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

src/uk/co/crashcraft/mcma/Main.java

+13-16
Original file line numberDiff line numberDiff line change
@@ -44,39 +44,29 @@ public void onDisable() {
4444
@Override
4545
public void onEnable() {
4646
if (!this.gitVersion.contains("GITREVISION") || !this.buildVersion.contains("BUILDVERSION")) {
47-
this.logger.log("Using v" + this.getServer().getVersion() + " git-" + this.gitVersion + " b" + this.buildVersion + "bamboo");
47+
this.logger.log("Initializing v" + this.getServer().getVersion() + " git-" + this.gitVersion + " b" + this.buildVersion + "bamboo");
4848
} else {
49-
this.logger.log("Using v" + this.getServer().getVersion());
49+
this.logger.log("Initializing v" + this.getServer().getVersion());
5050
}
51-
this.logger.log("Please wait.. Starting.");
5251

5352
this.pluginManager = this.getServer().getPluginManager();
5453
this.craftServer = (CraftServer) this.getServer();
5554

56-
if (!this.craftServer.getServer().onlineMode) {
57-
this.logger.log(MCACLogger.logState.FATAL, "You must be running in online mode!");
55+
if(!this.onlineCheck()){
5856
return;
5957
}
6058

61-
this.logger.log(MCACLogger.logState.INFO, "Checking Compatibility");
62-
6359
final Plugin noCheatPlug = this.pluginManager.getPlugin("NoCheat");
6460
if (noCheatPlug == null) {
6561
this.logger.log(MCACLogger.logState.FATAL, "NoCheat could not be found!");
6662
return;
6763
}
68-
6964
this.noCheat = (NoCheat) noCheatPlug;
7065

71-
this.logger.log(MCACLogger.logState.INFO, "Found NoCheat");
72-
73-
this.logger.log(MCACLogger.logState.INFO, "Hooking Listeners");
74-
7566
this.pluginManager.registerEvent(Type.PLAYER_PRELOGIN, new PlayerListener () {
7667
@Override
7768
public void onPlayerPreLogin(PlayerPreLoginEvent event) {
78-
if (!Main.this.craftServer.getServer().onlineMode) {
79-
Main.this.logger.log(MCACLogger.logState.FATAL, "You must be running in online mode!");
69+
if(!Main.this.onlineCheck()){
8070
return;
8171
}
8272
final String playerName = event.getName();
@@ -172,8 +162,8 @@ public boolean hasErrored (HashMap<String, String> response) {
172162
if (error.contains("Server Disabled")) {
173163
this.broadcastView(ChatColor.RED + "MCAC Abuse Detected");
174164
this.broadcastView("Abuse of the MCAC System was detected and resulted in this server being blacklisted.");
175-
this.logger.log(MCACLogger.logState.SEVERE, "The server API key has been disabled by an MCAC ");
176-
this.logger.log(MCACLogger.logState.FATAL, "To appeal this decision, please contact an administrator");
165+
this.logger.log(MCACLogger.logState.SEVERE, "The server API key has been disabled by MCAC.");
166+
this.logger.log(MCACLogger.logState.FATAL, "To appeal this decision, please contact an administrator.");
177167
} else {
178168
this.broadcastView( ChatColor.RED + "Unexpected reply from MCAC API!");
179169
this.logger.log(MCACLogger.logState.SEVERE, "API returned an invalid error:");
@@ -193,4 +183,11 @@ public boolean hasErrored (HashMap<String, String> response) {
193183
public Plugin pluginInterface( String pluginName ){
194184
return this.getServer().getPluginManager().getPlugin(pluginName);
195185
}
186+
187+
public boolean onlineCheck(){
188+
if (!this.craftServer.getServer().onlineMode) {
189+
this.logger.log(MCACLogger.logState.FATAL, "You must be running in online mode!");
190+
return false;
191+
} return true;
192+
}
196193
}

0 commit comments

Comments
 (0)