-
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
0 parents
commit d8850c8
Showing
10 changed files
with
1,087 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
language: java | ||
jdk: | ||
- oraclejdk8 | ||
notifications: | ||
email: true | ||
sudo: false |
Binary file not shown.
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,54 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>io.memyself</groupId> | ||
<artifactId>addresswhitelist</artifactId> | ||
<version>1.0</version> | ||
<repositories> | ||
<repository> | ||
<id>spigotmc-repo</id> | ||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url> | ||
</repository> | ||
</repositories> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.bukkit</groupId> | ||
<artifactId>bukkit</artifactId> | ||
<version>1.8.8-R0.1-SNAPSHOT</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>eu.theindra</groupId> | ||
<artifactId>geoip</artifactId> | ||
<version>2.0</version> | ||
<scope>system</scope> | ||
<systemPath>${project.basedir}/dependencies/geoipAPI.jar</systemPath> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.7.0</version> | ||
<configuration> | ||
<source>1.7</source> | ||
<target>1.7</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>3.0.2</version> | ||
<configuration> | ||
<finalName>AddressWhitelist</finalName> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
</build> | ||
</project> |
66 changes: 66 additions & 0 deletions
66
src/main/java/io/memyself/addresswhitelist/AddressWhitelist.java
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,66 @@ | ||
package io.memyself.addresswhitelist; | ||
|
||
import java.io.File; | ||
|
||
import org.bukkit.ChatColor; | ||
|
||
import org.bukkit.entity.Player; | ||
|
||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import io.memyself.addresswhitelist.bstats.MetricsLite; | ||
|
||
public class AddressWhitelist | ||
extends JavaPlugin { | ||
|
||
@Override | ||
public void onEnable() { | ||
if(!new File(getDataFolder(), "config.yml").exists()) { | ||
saveDefaultConfig(); | ||
|
||
reloadConfig(); | ||
} | ||
new Utilities(this); | ||
|
||
getServer().getPluginManager().registerEvents(new EventListener(this), this); | ||
|
||
getCommand("addresswhitelist").setExecutor(new CommandManager(this)); | ||
|
||
if(getConfig().getBoolean("options.metrics")) { | ||
if(getConfig().getBoolean("options.debug")) getLogger().info("[DEBUG] Will be attempting to submit statistics to bStats.org."); | ||
|
||
new MetricsLite(this); | ||
} | ||
|
||
getLogger().info("AddressWhitelist v" + getDescription().getVersion() + " has been enabled!"); | ||
|
||
int kickCount = 0; | ||
|
||
for(Player player : getServer().getOnlinePlayers()) { | ||
if(!getConfig().getBoolean("options.inverted")) { | ||
if(!getConfig().getStringList("list").contains(player.getAddress().getHostString())) { | ||
player.kickPlayer(ChatColor.translateAlternateColorCodes('&', getConfig().getString("locale.kick-messages.not-in-whitelist"))); | ||
|
||
kickCount++; | ||
} | ||
} else { | ||
if(getConfig().getStringList("list").contains(player.getAddress().getHostString())) { | ||
player.kickPlayer(ChatColor.translateAlternateColorCodes('&', getConfig().getString("locale.kick-messages.in-blacklist"))); | ||
|
||
kickCount++; | ||
} | ||
} | ||
} | ||
|
||
if(kickCount > 0) { | ||
if(kickCount == 1) if(getConfig().getBoolean("options.debug")) getLogger().info("[DEBUG] 1 player was kicked because their IP address was " + (!getConfig().getBoolean("options.inverted") ? "not whitelisted." : "blacklisted.")); | ||
else if(getConfig().getBoolean("options.debug")) getLogger().info("[DEBUG] " + kickCount + " players were kicked because their IP addresses were " + (!getConfig().getBoolean("options.inverted") ? "not whitelisted." : "blacklisted.")); | ||
} | ||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
getLogger().info("AddressWhitelist v" + getDescription().getVersion() + " has been disabled."); | ||
} | ||
|
||
} |
Oops, something went wrong.