Skip to content

Commit

Permalink
PlayerManager update
Browse files Browse the repository at this point in the history
Instead of setting the result in switch, a boolean is now set, and
called against later. This should decrease overall command line usage
later on, when more methods for focus are available.

Now implement notifications on deny.
  • Loading branch information
FerusGrim committed Apr 29, 2014
1 parent 1cb72ec commit ec273f5
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/java/io/github/ferusgrim/GrimList/PlayerManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,23 @@ public void onPlayerLogin(PlayerLoginEvent event){
String uuid = player.getUniqueId().toString();
String playerName = player.getName();
String playerAddress = event.getAddress().getHostAddress();
event.setKickMessage(plugin.mStart + "You're not whitelisted!");
boolean denyUser = false;
switch(plugin.focusOn){
case "file":
plugin.filem.onLoginRecordUpdater(uuid, playerName, playerAddress);
event.setResult(plugin.filem.alreadyOnWhitelist(uuid)? Result.ALLOWED : Result.KICK_WHITELIST);
denyUser = plugin.filem.alreadyOnWhitelist(uuid);
break;
}
if(denyUser){
event.setKickMessage(plugin.mStart + "You're not whitelisted!");
event.setResult(Result.KICK_WHITELIST);
if(plugin.getConfig().getBoolean("Notify.Console")){
plugin.log("INFO", "User was denied access!: " + playerName);
}
if(plugin.getConfig().getBoolean("Notify.Player")){
plugin.getServer().broadcast(plugin.mStart + "User was denied access!: " + playerName, "grimlist.notify");
}
}
}

@EventHandler(priority = EventPriority.HIGH)
Expand Down

0 comments on commit ec273f5

Please sign in to comment.