Added some Events (#1096)
* Added PlayerBanEvent, PlayerUnbanEvent, PlayerIpBanEvent, and PlayerIpUnbanEvent. * Removed Unecessary import (oops) * Formatted code * Fixed a little oopsie * Prevent NPE * add another line..
This commit is contained in:
@@ -333,5 +333,39 @@ public class EventType{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class PlayerBanEvent{
|
||||||
|
public final Player player;
|
||||||
|
|
||||||
|
public PlayerBanEvent(Player player){
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class PlayerUnbanEvent{
|
||||||
|
public final Player player;
|
||||||
|
|
||||||
|
public PlayerUnbanEvent(Player player){
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class PlayerIpBanEvent{
|
||||||
|
public final String ip;
|
||||||
|
|
||||||
|
|
||||||
|
public PlayerIpBanEvent(String ip){
|
||||||
|
this.ip = ip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class PlayerIpUnbanEvent{
|
||||||
|
public final String ip;
|
||||||
|
|
||||||
|
|
||||||
|
public PlayerIpUnbanEvent(String ip){
|
||||||
|
this.ip = ip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,11 @@ package io.anuke.mindustry.net;
|
|||||||
import io.anuke.annotations.Annotations.*;
|
import io.anuke.annotations.Annotations.*;
|
||||||
import io.anuke.arc.*;
|
import io.anuke.arc.*;
|
||||||
import io.anuke.arc.collection.*;
|
import io.anuke.arc.collection.*;
|
||||||
|
import io.anuke.mindustry.Vars;
|
||||||
|
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.headless;
|
import static io.anuke.mindustry.Vars.headless;
|
||||||
|
import static io.anuke.mindustry.game.EventType.*;
|
||||||
|
|
||||||
public class Administration{
|
public class Administration{
|
||||||
/** All player info. Maps UUIDs to info. This persists throughout restarts. */
|
/** All player info. Maps UUIDs to info. This persists throughout restarts. */
|
||||||
@@ -76,7 +79,7 @@ public class Administration{
|
|||||||
|
|
||||||
bannedIPs.add(ip);
|
bannedIPs.add(ip);
|
||||||
save();
|
save();
|
||||||
|
Events.fire(new PlayerIpBanEvent(ip));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +91,7 @@ public class Administration{
|
|||||||
getCreateInfo(id).banned = true;
|
getCreateInfo(id).banned = true;
|
||||||
|
|
||||||
save();
|
save();
|
||||||
|
Events.fire(new PlayerBanEvent(Vars.playerGroup.find(p -> id.equals(p.uuid))));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,8 +111,10 @@ public class Administration{
|
|||||||
|
|
||||||
bannedIPs.removeValue(ip, false);
|
bannedIPs.removeValue(ip, false);
|
||||||
|
|
||||||
if(found) save();
|
if(found){
|
||||||
|
save();
|
||||||
|
Events.fire(new PlayerIpUnbanEvent(ip));
|
||||||
|
}
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +131,7 @@ public class Administration{
|
|||||||
info.banned = false;
|
info.banned = false;
|
||||||
bannedIPs.removeAll(info.ips, false);
|
bannedIPs.removeAll(info.ips, false);
|
||||||
save();
|
save();
|
||||||
|
Events.fire(new PlayerUnbanEvent(Vars.playerGroup.find(p -> id.equals(p.uuid))));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user