Skip to content

Commit

Permalink
remove BanService from Context
Browse files Browse the repository at this point in the history
  • Loading branch information
hoijui committed Mar 19, 2011
1 parent 2feddb5 commit 546b38b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 23 deletions.
13 changes: 0 additions & 13 deletions src/main/java/com/springrts/springls/Context.java
Expand Up @@ -19,7 +19,6 @@


import com.springrts.springls.accounts.AccountsService;
import com.springrts.springls.bans.BanService;
import com.springrts.springls.commands.CommandProcessors;
import java.util.LinkedList;
import java.util.List;
Expand All @@ -38,7 +37,6 @@ public class Context implements LiveStateListener {

private Framework framework;
private AccountsService accountsService;
private BanService banService;
private Battles battles;
private Channels channels;
private Clients clients;
Expand All @@ -56,7 +54,6 @@ public Context() {

this.framework = null;
this.accountsService = null;
this.banService = null;
this.battles = null;
this.channels = null;
this.clients = null;
Expand All @@ -70,7 +67,6 @@ public Context() {
public void init() {

this.accountsService = null;
this.banService = null;
setBattles(new Battles());
setChannels(new Channels());
setClients(new Clients());
Expand Down Expand Up @@ -170,15 +166,6 @@ public void setAccountsService(AccountsService accountsService) {
addLiveStateListener(accountsService);
}

public BanService getBanService() {
return banService;
}

public void setBanService(BanService banService) {

this.banService = banService;
}

public Battles getBattles() {
return battles;
}
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/springrts/springls/bans/Activator.java
Expand Up @@ -41,7 +41,6 @@ public void start(BundleContext context) {

Context springLsContext = Context.getService(context, Context.class);
BanService banService = createBanService(springLsContext);
springLsContext.setBanService(banService);
context.registerService(BanService.class.getName(), banService, null);
}

Expand Down
Expand Up @@ -26,6 +26,7 @@
import com.springrts.springls.util.Misc;
import com.springrts.springls.ServerNotification;
import com.springrts.springls.agreement.Agreement;
import com.springrts.springls.bans.BanService;
import com.springrts.springls.commands.AbstractCommandProcessor;
import com.springrts.springls.commands.CommandProcessingException;
import com.springrts.springls.commands.InvalidNumberOfArgumentsCommandProcessingException;
Expand Down Expand Up @@ -275,15 +276,19 @@ private boolean validateAccount(Client client, int userId, String username,
client.sendLine("DENIED Already logged in");
return false;
}
BanEntry ban = getContext().getBanService().getBanEntry(username,
client.getIp(), userId);
if ((ban != null) && ban.isActive()) {
client.sendLine(String.format(
"DENIED You are banned from this server! (Reason: %s)."
+ " Please contact a server administrator.",
ban.getPublicReason()));
recordFailedLoginAttempt(username);
return false;
BanService banService = getContext().getService(BanService.class);
if (banService != null) {
BanEntry ban = banService.getBanEntry(username, client.getIp(),
userId);
if ((ban != null) && ban.isActive()) {
client.sendLine(String.format(
"DENIED You are banned from this server!"
+ " (Reason: %s)."
+ " Please contact a server administrator.",
ban.getPublicReason()));
recordFailedLoginAttempt(username);
return false;
}
}
if (!acc.isAgreementAccepted()
&& !client.getAccount().isAgreementAccepted())
Expand Down

0 comments on commit 546b38b

Please sign in to comment.