-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2adc23
commit b789c12
Showing
11 changed files
with
88 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package me.pk2.adminsecure.user.ip; | ||
|
||
import me.pk2.adminsecure.user.ip.object.IPObject; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class IPWhitelister { | ||
private final ArrayList<IPObject> verified; | ||
public IPWhitelister() { | ||
this.verified = new ArrayList<>(); | ||
} | ||
|
||
public IPObject get(Player player) { | ||
IPObject object = new IPObject(player); | ||
for(IPObject ipObject : verified) | ||
if(ipObject.address.contentEquals(object.address)) | ||
return ipObject; | ||
return null; | ||
} | ||
public void put(Player player) { | ||
if(get(player) != null) | ||
return; | ||
verified.add(new IPObject(player)); | ||
} | ||
public void rem(Player player) { | ||
if(get(player) == null) | ||
return; | ||
IPObject object = new IPObject(player); | ||
verified.removeIf(ipObject -> ipObject.address.contentEquals(object.address)); | ||
} | ||
public void shutdown() { verified.clear(); } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package me.pk2.adminsecure.user.ip.object; | ||
|
||
import org.bukkit.entity.Player; | ||
|
||
public class IPObject { | ||
public final String address; | ||
public final int port; | ||
public IPObject(String address) { | ||
if(address.contains("/")) { | ||
String[] split = address.split("/"); | ||
this.address = split[0]; | ||
this.port = Integer.parseInt(split[1]); | ||
return; | ||
} | ||
|
||
this.address = address; | ||
this.port = 0; | ||
} | ||
public IPObject(Player player) { this(player.getAddress().getHostName()); } | ||
} |