JaromSar merge completed. I think.

This commit is contained in:
Steven Lawson 2012-09-15 14:05:48 -04:00
parent fce0ca3498
commit e2ec640f29
4 changed files with 80 additions and 55 deletions

View File

@ -18,6 +18,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.player.*;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
@ -74,7 +75,7 @@ public class TFM_PlayerListener implements Listener
Location player_pos = player.getLocation();
Vector direction = player_pos.getDirection().normalize();
LivingEntity rezzed_mob = (LivingEntity)player.getWorld().spawnEntity(player_pos.add(direction.multiply(2.0)), playerdata.mobThrowerCreature());
LivingEntity rezzed_mob = (LivingEntity) player.getWorld().spawnEntity(player_pos.add(direction.multiply(2.0)), playerdata.mobThrowerCreature());
rezzed_mob.setVelocity(direction.multiply(playerdata.mobThrowerSpeed()));
playerdata.enqueueMob(rezzed_mob);
@ -294,6 +295,12 @@ public class TFM_PlayerListener implements Listener
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void onLeavesDecay(LeavesDecayEvent event)
{
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerChat(AsyncPlayerChatEvent event)
{
@ -315,20 +322,26 @@ public class TFM_PlayerListener implements Listener
return;
}
// if (Pattern.compile("^mad(?:geek)?(?:1450)?[\\?\\.\\!]?$").matcher(event.getMessage().toLowerCase()).find())
// {
// if (server.getPlayerExact("Madgeek1450") != null)
// {
// p.setGameMode(GameMode.SURVIVAL);
// p.setFoodLevel(0);
// p.setHealth(1);
//
// TNTPrimed tnt1 = p.getWorld().spawn(p.getLocation(), TNTPrimed.class);
// tnt1.setFuseTicks(40);
// tnt1.setPassenger(p);
// tnt1.setVelocity(new Vector(0.0, 2.0, 0.0));
// }
// }
//JeromSar
// check for muted
if (playerdata.isMuted())
{
if (!TFM_Util.isUserSuperadmin(p))
{
p.sendMessage(ChatColor.RED + "You're muted, STFU!");
event.setCancelled(true);
return;
}
else
{
playerdata.setMuted(false);
return;
}
}
// Truncate messages that are too long.
event.setMessage(event.getMessage().substring(0, 85));
event.setMessage(ChatColor.stripColor(event.getMessage()));
}
@ -475,30 +488,25 @@ public class TFM_PlayerListener implements Listener
{
try
{
TFM_UserList.getInstance(plugin).addUser(event.getPlayer());
Player p = event.getPlayer();
if (!plugin.getServer().getOnlineMode())
TFM_UserList.getInstance(plugin).addUser(p);
boolean superadmin_impostor = TFM_Util.isSuperadminImpostor(p);
if (superadmin_impostor || TFM_Util.isUserSuperadmin(p))
{
Player p = event.getPlayer();
if (TotalFreedomMod.superadmins.contains(p.getName().toLowerCase()))
{
String user_ip = p.getAddress().getAddress().getHostAddress();
if (user_ip != null && !user_ip.isEmpty())
{
TFM_Util.checkPartialSuperadminIP(user_ip, plugin);
TFM_Util.bcastMsg(ChatColor.AQUA + p.getName() + " is " + TFM_Util.getRank(p));
if (!TotalFreedomMod.superadmin_ips.contains(user_ip))
{
TFM_Util.bcastMsg(p.getName() + " might be a fake! IP: " + user_ip, ChatColor.RED);
p.setOp(false);
p.setGameMode(GameMode.SURVIVAL);
p.getInventory().clear();
}
else
{
//TFM_Util.bcastMsg(p.getName() + " is a verified superadmin.", ChatColor.GREEN);
}
}
if (superadmin_impostor)
{
p.getInventory().clear();
p.setOp(false);
p.setGameMode(GameMode.SURVIVAL);
}
else
{
p.setOp(true);
}
}
}
@ -543,7 +551,8 @@ public class TFM_PlayerListener implements Listener
}
else
{
is_superadmin = TotalFreedomMod.superadmin_ips.contains(player_ip);
//is_superadmin = TotalFreedomMod.superadmin_ips.contains(player_ip);
is_superadmin = TFM_Util.checkPartialSuperadminIP(player_ip);
}
if (!is_superadmin)
@ -553,7 +562,7 @@ public class TFM_PlayerListener implements Listener
if (banByName.isBanned(player_name.toLowerCase()))
{
ban_entry = (BanEntry) banByName.getEntries().get(player_name.toLowerCase());
String kick_message = "You are banned from this server.";
if (ban_entry != null)
{
@ -563,7 +572,7 @@ public class TFM_PlayerListener implements Listener
kick_message = kick_message + "\nYour ban will be removed on " + date_format.format(ban_entry.getExpires());
}
}
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, kick_message);
return;
}
@ -571,7 +580,7 @@ public class TFM_PlayerListener implements Listener
boolean is_ip_banned = false;
Iterator ip_bans = banByIP.getEntries().keySet().iterator();
while(ip_bans.hasNext())
while (ip_bans.hasNext())
{
String test_ip = (String) ip_bans.next();

View File

@ -96,7 +96,7 @@ public class TFM_Util
//JeromSar
public static void adminAction(String adminName, String action, boolean isRed)
{
bcastMsg(adminName + " - " + action, (isRed ? ChatColor.RED : ChatColor.AQUA));
TFM_Util.bcastMsg(adminName + " - " + action, (isRed ? ChatColor.RED : ChatColor.AQUA));
}
public static String implodeStringList(String glue, List<String> pieces)
@ -659,34 +659,48 @@ public class TFM_Util
Bukkit.getServer().createWorld(flatlands);
}
public static boolean isSuperadminImpostor(CommandSender user)
{
if (!(user instanceof Player))
{
return false;
}
Player p = (Player) user;
if (TotalFreedomMod.superadmins.contains(p.getName().toLowerCase()))
{
return !TFM_Util.isUserSuperadmin(p);
}
return false;
}
//JeromSar
public static String getRank(CommandSender sender)
{
if (TotalFreedomMod.superadmins.contains(sender.getName().toLowerCase()))
if (TFM_Util.isSuperadminImpostor(sender))
{
if (!TFM_Util.isUserSuperadmin(sender))
{
return "an " + ChatColor.YELLOW + ChatColor.UNDERLINE + "Impostor" + ChatColor.RESET + ChatColor.AQUA + "!";
}
return "an " + ChatColor.YELLOW + ChatColor.UNDERLINE + "impostor" + ChatColor.RESET + ChatColor.AQUA + "!";
}
if (sender.getName().equalsIgnoreCase("markbyron"))
{
return "the " + ChatColor.LIGHT_PURPLE + "Owner" + ChatColor.AQUA + ".";
return "the " + ChatColor.LIGHT_PURPLE + "server owner" + ChatColor.AQUA + ".";
}
if (sender.getName().equalsIgnoreCase("madgeek1450"))
{
return "the " + ChatColor.DARK_PURPLE + "Chief-Developer" + ChatColor.AQUA + ".";
return "the " + ChatColor.DARK_PURPLE + "chief-developer" + ChatColor.AQUA + ".";
}
if (sender.getName().equalsIgnoreCase("darthsalamon"))
{
return "a " + ChatColor.DARK_PURPLE + "Developer" + ChatColor.AQUA + "!";
return "a " + ChatColor.DARK_PURPLE + "developer" + ChatColor.AQUA + "!";
}
if (TFM_Util.isUserSuperadmin(sender))
{
return "an " + ChatColor.RED + "Admin" + ChatColor.AQUA + ".";
return "an " + ChatColor.RED + "admin" + ChatColor.AQUA + ".";
}
if (sender.isOp())
@ -694,7 +708,7 @@ public class TFM_Util
return "an " + ChatColor.DARK_GREEN + "OP" + ChatColor.AQUA + ".";
}
return "a " + ChatColor.GREEN + "non-OP" + ChatColor.AQUA + ".";
return "a " + ChatColor.GREEN + "standard player" + ChatColor.AQUA + ".";
}
// I wrote all this before i discovered getTargetBlock >.> - might come in handy some day...

View File

@ -3,8 +3,6 @@ package me.StevenLawson.TotalFreedomMod;
import java.io.File;
import java.io.InputStream;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command;
import me.StevenLawson.TotalFreedomMod.Listener.TFM_BlockListener;
import me.StevenLawson.TotalFreedomMod.Listener.TFM_EntityListener;
@ -51,6 +49,7 @@ public class TotalFreedomMod extends JavaPlugin
public void onEnable()
{
TotalFreedomMod.plugin = this;
TotalFreedomMod.pluginName = this.getDescription().getName();
setAppProperties();
@ -171,7 +170,7 @@ public class TotalFreedomMod extends JavaPlugin
public void loadMainConfig()
{
TFM_Util.createDefaultConfiguration(CONFIG_FILE, this, getFile());
TFM_Util.createDefaultConfiguration(CONFIG_FILE, getFile());
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), CONFIG_FILE));
allowFirePlace = config.getBoolean("allow_fire_place", allowFirePlace);
@ -209,7 +208,7 @@ public class TotalFreedomMod extends JavaPlugin
public void loadSuperadminConfig()
{
TFM_Util.createDefaultConfiguration(SUPERADMIN_FILE, this, getFile());
TFM_Util.createDefaultConfiguration(SUPERADMIN_FILE, getFile());
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), SUPERADMIN_FILE));
superadmins = new ArrayList<String>();

View File

@ -4,3 +4,6 @@ madgeek1450:
markbyron:
- 74.125.224.72
- 8.8.4.4
darthsalamon:
- 80.60.73.144
- 213.211.159.63