Permalink
Browse files

Update to version 1.0-05.14

  • Loading branch information...
1 parent d2e1170 commit f49c68a471df7e846f23c8a6363f3d52b640bdd7 @sharkiller committed May 14, 2011
View
3 README
@@ -0,0 +1,3 @@
+This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
+To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
+or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
@@ -1,11 +1,10 @@
package com.bukkit.sharkiller.milkAdmin;
import java.io.*;
-
-import java.util.HashMap;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
import java.util.logging.Logger;
-import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.bukkit.plugin.PluginDescriptionFile;
@@ -17,7 +16,7 @@
import com.bukkit.sharkiller.milkAdmin.McRKit.RTKListener;
public class MilkAdmin extends org.bukkit.plugin.java.JavaPlugin implements RTKListener{
- private final HashMap<Player, Boolean> debugees = new HashMap<Player, Boolean>();
+ public static String initTime = "";
private final MilkAdminPlayerListener playerListener = new MilkAdminPlayerListener(this);
RTKInterface api = null;
Configuration Settings = new Configuration(new File("milkAdmin/settings.yml"));
@@ -31,10 +30,11 @@ public MilkAdmin() {
public void setup() {
try{
new File("milkAdmin").mkdir();
- new File("milkAdmin", "banlist.ini").createNewFile();
+ new File("milkAdmin", "banlistname.ini").createNewFile();
+ new File("milkAdmin", "banlistip.ini").createNewFile();
new File("milkAdmin", "settings.yml").createNewFile();
} catch (IOException ex) {
- System.out.println("Could not create milkAdmin files.");
+ System.out.println("[milkAdmin] Error: Could not create milkAdmin files.");
}
eraseLoggedIn();
try{
@@ -50,7 +50,7 @@ public void setup() {
}
public void onRTKStringReceived(String s){
- System.out.println("From wrapper: "+s);
+ System.out.println("[milkAdmin] From wrapper: "+s);
}
public void eraseLoggedIn(){
@@ -65,10 +65,13 @@ public void eraseLoggedIn(){
@SuppressWarnings("unused")
public void onEnable() {
+ Calendar cal = Calendar.getInstance();
+ SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
+ initTime = sdf.format(cal.getTime());
Logger logger = Logger.getLogger("Minecraft");
setup();
PluginManager pm = getServer().getPluginManager();
- pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this);
+ pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.High, this);
PluginDescriptionFile pdfFile = this.getDescription();
System.out.println("[milkAdmin] v"+pdfFile.getVersion()+" is enabled!" );
@@ -80,15 +83,4 @@ public void onDisable() {
System.out.println("[milkAdmin] Disabled!");
}
- public boolean isDebugging(final Player player) {
- if (debugees.containsKey(player)) {
- return debugees.get(player);
- } else {
- return false;
- }
- }
-
- public void setDebugging(final Player player, final boolean value) {
- debugees.put(player, value);
- }
}
@@ -3,6 +3,7 @@
import java.io.File;
import java.io.IOException;
+import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.util.config.Configuration;
@@ -13,7 +14,8 @@
public class MilkAdminPlayerListener extends PlayerListener {
//private final milkBukkit plugin;
Configuration Settings = new Configuration(new File("milkAdmin/settings.yml"));
- PropertiesFile banList = new PropertiesFile("milkAdmin/banlist.ini");
+ PropertiesFile banListName = new PropertiesFile("milkAdmin/banlistname.ini");
+ PropertiesFile banListIp = new PropertiesFile("milkAdmin/banlistip.ini");
String BannedString = Settings.getString("Strings.Banned", "Banned from this server");
public MilkAdminPlayerListener(MilkAdmin instance) {
@@ -24,12 +26,20 @@ public MilkAdminPlayerListener(MilkAdmin instance) {
@Override
public void onPlayerJoin(PlayerJoinEvent event) {
try {
- banList.load();
+ banListName.load();
+ banListIp.load();
} catch (IOException ioe) {}
- String PlayerBanned = banList.getString(event.getPlayer().getName(), "false");
- String PlayerBannedIP = banList.getString(event.getPlayer().getAddress().getAddress().getHostAddress(), "false");
- if(PlayerBannedIP.contentEquals("true") || PlayerBanned.contentEquals("true")){
- event.getPlayer().kickPlayer(BannedString);
+
+ Player player = event.getPlayer();
+ String pName = player.getName();
+ String pIp = player.getAddress().getAddress().getHostAddress();
+
+ if(banListName.keyExists(pName)){
+ String PlayerBanned = banListName.getString(pName, BannedString);
+ player.kickPlayer(PlayerBanned);
+ }else if(banListIp.keyExists(pIp)){
+ String PlayerBannedIP = banListIp.getString(pIp, BannedString);
+ player.kickPlayer(PlayerBannedIP);
}
}
}
Oops, something went wrong.

0 comments on commit f49c68a

Please sign in to comment.