mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-28 12:47:36 +00:00
Merge branch 'master' of https://github.com/TotalFreedom/TotalFreedomMod
Conflicts: appinfo.properties buildnumber.properties src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java
This commit is contained in:
commit
ee87d1147d
@ -1,5 +1,5 @@
|
||||
#Thu, 04 Jul 2013 22:45:10 +0200
|
||||
|
||||
program.VERSION=2.21
|
||||
program.BUILDNUM=255
|
||||
program.BUILDNUM=262
|
||||
program.BUILDDATE=07/04/2013 10\:45 PM
|
||||
|
@ -1,3 +1,3 @@
|
||||
#Build Number for ANT. Do not edit!
|
||||
#Thu Jul 04 22:45:10 CEST 2013
|
||||
build.number=256
|
||||
#Thu Jul 04 12:21:05 EDT 2013
|
||||
build.number=263
|
||||
|
@ -32,7 +32,8 @@ jar.archive.disabled=${jnlp.enabled}
|
||||
jar.compress=false
|
||||
jar.index=${jnlp.enabled}
|
||||
javac.classpath=\
|
||||
${libs.CraftBukkit.classpath}
|
||||
${libs.CraftBukkit.classpath}:\
|
||||
${libs.WorldEdit.classpath}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=-Xlint:unchecked -Xlint:deprecation
|
||||
javac.deprecation=false
|
||||
|
@ -3,6 +3,7 @@ package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
import java.util.Random;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.Achievement;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
@ -31,6 +32,10 @@ public class Command_cake extends TFM_Command
|
||||
{
|
||||
ItemStack heldItem = new ItemStack(Material.CAKE, 1);
|
||||
p.getInventory().setItem(p.getInventory().firstEmpty(), heldItem);
|
||||
p.awardAchievement(Achievement.MINE_WOOD);
|
||||
p.awardAchievement(Achievement.BUILD_WORKBENCH);
|
||||
p.awardAchievement(Achievement.BUILD_HOE);
|
||||
p.awardAchievement(Achievement.BAKE_CAKE);
|
||||
}
|
||||
|
||||
TFM_Util.bcastMsg(output.toString());
|
||||
|
@ -1,7 +1,9 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_WorldEditBridge;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
@ -34,17 +36,11 @@ public class Command_gtfo extends TFM_Command
|
||||
|
||||
TFM_Util.bcastMsg(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
||||
|
||||
// Undo WorldEdits:
|
||||
TFM_WorldEditBridge.getInstance().undo(p, 15);
|
||||
|
||||
// Op Player
|
||||
p.setOp(true);
|
||||
|
||||
//Undo WorldEdits:
|
||||
server.dispatchCommand(p, "/undo 15");
|
||||
|
||||
//rollback
|
||||
|
||||
server.dispatchCommand(sender, "rollback " + p.getName());
|
||||
|
||||
// rollback
|
||||
TFM_RollbackManager.rollback(p);
|
||||
|
||||
// deop
|
||||
p.setOp(false);
|
||||
|
@ -40,7 +40,7 @@ public class Command_invis extends TFM_Command
|
||||
players.add(p.getName());
|
||||
if (smite && !TFM_SuperadminList.isUserSuperadmin(p))
|
||||
{
|
||||
server.dispatchCommand(sender, "smite " + p.getName());
|
||||
Command_smite.smite(p);
|
||||
smites++;
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import java.util.Random;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -115,19 +113,12 @@ public class Command_lockup extends TFM_Command
|
||||
|
||||
playerdata.setLockupScheduleID(server.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable()
|
||||
{
|
||||
private Random random = new Random();
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (p.isOnline())
|
||||
{
|
||||
p.openWorkbench(null, true);
|
||||
|
||||
Location l = p.getLocation().clone();
|
||||
l.setPitch(random.nextFloat() * 360.0f);
|
||||
l.setYaw(random.nextFloat() * 360.0f);
|
||||
p.teleport(l);
|
||||
p.openInventory(p.getInventory());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_WorldEditBridge;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -12,34 +13,12 @@ public class Command_setl extends TFM_Command
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
//server.dispatchCommand(sender, "wildcard gcmd ? /limit 500"); - Madgeek: No, no, hell no.
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "Setting everyone's Worldedit block modification limit to 500.", true);
|
||||
|
||||
TFM_WorldEditBridge web = TFM_WorldEditBridge.getInstance();
|
||||
for (final Player p : server.getOnlinePlayers())
|
||||
{
|
||||
final boolean isOp = p.isOp();
|
||||
|
||||
if (!isOp)
|
||||
{
|
||||
p.setOp(true);
|
||||
}
|
||||
|
||||
server.dispatchCommand(p, "/limit 500");
|
||||
|
||||
if (!isOp)
|
||||
{
|
||||
server.getScheduler().runTaskLater(plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
p.setOp(false);
|
||||
}
|
||||
}, 20L);
|
||||
}
|
||||
web.setLimit(p, 500);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,13 @@ public class Command_smite extends TFM_Command
|
||||
return true;
|
||||
}
|
||||
|
||||
smite(p);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void smite(final Player p)
|
||||
{
|
||||
TFM_Util.bcastMsg(p.getName() + " has been a naughty, naughty boy.", ChatColor.RED);
|
||||
|
||||
//Deop
|
||||
@ -57,7 +64,5 @@ public class Command_smite extends TFM_Command
|
||||
|
||||
//Kill:
|
||||
p.setHealth(0.0);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -676,20 +676,29 @@ public class TFM_PlayerListener implements Listener
|
||||
TFM_ServerInterface.handlePlayerLogin(event);
|
||||
}
|
||||
|
||||
@EventHandler()
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onServerPing(ServerListPingEvent event)
|
||||
{
|
||||
// Colorize :)
|
||||
event.setMotd(ChatColor.translateAlternateColorCodes('&', event.getMotd()));
|
||||
//event.setMotd(ChatColor.translateAlternateColorCodes('&', event.getMotd()));
|
||||
|
||||
event.setMotd(TFM_Util.randomChatColor() + "Total" + TFM_Util.randomChatColor() + "Freedom " + ChatColor.DARK_GRAY
|
||||
+ "-" + TFM_Util.randomChatColor() + " Bukkit v" + TFM_ServerInterface.getVersion());
|
||||
|
||||
if (TFM_ServerInterface.isIPBanned(event.getAddress().getHostAddress()))
|
||||
{
|
||||
event.setMotd(ChatColor.RED + "You are banned!");
|
||||
event.setMotd(ChatColor.RED + "You are banned.");
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.adminOnlyMode)
|
||||
else if (TotalFreedomMod.adminOnlyMode)
|
||||
{
|
||||
event.setMotd(ChatColor.RED + "Server in AdminMode!");
|
||||
event.setMotd(ChatColor.RED + "Server is closed.");
|
||||
}
|
||||
else if (Bukkit.hasWhitelist())
|
||||
{
|
||||
event.setMotd(ChatColor.RED + "Whitelist enabled.");
|
||||
}
|
||||
else if (Bukkit.getOnlinePlayers().length >= Bukkit.getMaxPlayers())
|
||||
{
|
||||
event.setMotd(ChatColor.RED + "Server is full.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -317,4 +317,9 @@ public class TFM_ServerInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getVersion()
|
||||
{
|
||||
return MinecraftServer.getServer().getVersion();
|
||||
}
|
||||
}
|
||||
|
@ -1035,4 +1035,23 @@ public class TFM_Util
|
||||
while (checkClass.getSuperclass() != Object.class && ((checkClass = checkClass.getSuperclass()) != null));
|
||||
return null;
|
||||
}
|
||||
|
||||
public static final List<ChatColor> COLOR_POOL = Arrays.asList(
|
||||
ChatColor.DARK_BLUE,
|
||||
ChatColor.DARK_GREEN,
|
||||
ChatColor.DARK_AQUA,
|
||||
ChatColor.DARK_RED,
|
||||
ChatColor.DARK_PURPLE,
|
||||
ChatColor.GOLD,
|
||||
ChatColor.BLUE,
|
||||
ChatColor.GREEN,
|
||||
ChatColor.AQUA,
|
||||
ChatColor.RED,
|
||||
ChatColor.LIGHT_PURPLE,
|
||||
ChatColor.YELLOW);
|
||||
private static final Random RANDOM = new Random();
|
||||
public static ChatColor randomChatColor()
|
||||
{
|
||||
return COLOR_POOL.get(RANDOM.nextInt(COLOR_POOL.size()));
|
||||
}
|
||||
}
|
||||
|
133
src/me/StevenLawson/TotalFreedomMod/TFM_WorldEditBridge.java
Normal file
133
src/me/StevenLawson/TotalFreedomMod/TFM_WorldEditBridge.java
Normal file
@ -0,0 +1,133 @@
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
||||
import com.sk89q.worldedit.bukkit.BukkitServerInterface;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditAPI;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class TFM_WorldEditBridge
|
||||
{
|
||||
private WorldEditPlugin worldEditPlugin = null;
|
||||
private WorldEditAPI worldEditAPI = null;
|
||||
private BukkitServerInterface bukkitServerInterface = null;
|
||||
|
||||
private TFM_WorldEditBridge()
|
||||
{
|
||||
}
|
||||
|
||||
public WorldEditPlugin getWorldEditPlugin()
|
||||
{
|
||||
if (this.worldEditPlugin == null)
|
||||
{
|
||||
Plugin we = Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
if (we != null)
|
||||
{
|
||||
if (we instanceof WorldEditPlugin)
|
||||
{
|
||||
this.worldEditPlugin = (WorldEditPlugin) we;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.worldEditPlugin;
|
||||
}
|
||||
|
||||
public WorldEditAPI getWorldEditAPI()
|
||||
{
|
||||
if (this.worldEditAPI == null)
|
||||
{
|
||||
WorldEditPlugin wep = getWorldEditPlugin();
|
||||
if (wep != null)
|
||||
{
|
||||
this.worldEditAPI = new WorldEditAPI(wep);
|
||||
}
|
||||
}
|
||||
|
||||
return this.worldEditAPI;
|
||||
}
|
||||
|
||||
public BukkitServerInterface getBukkitServerInterface()
|
||||
{
|
||||
if (this.bukkitServerInterface == null)
|
||||
{
|
||||
WorldEditPlugin wep = this.getWorldEditPlugin();
|
||||
if (wep != null)
|
||||
{
|
||||
this.bukkitServerInterface = new BukkitServerInterface(wep, Bukkit.getServer());
|
||||
}
|
||||
}
|
||||
|
||||
return this.bukkitServerInterface;
|
||||
}
|
||||
|
||||
public BukkitPlayer getBukkitPlayer(Player p)
|
||||
{
|
||||
WorldEditPlugin wep = this.getWorldEditPlugin();
|
||||
BukkitServerInterface bsi = this.getBukkitServerInterface();
|
||||
|
||||
if (wep != null && bsi != null)
|
||||
{
|
||||
return new BukkitPlayer(wep, bsi, p);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void undo(Player p, int count)
|
||||
{
|
||||
try
|
||||
{
|
||||
WorldEditAPI api = this.getWorldEditAPI();
|
||||
if (api != null)
|
||||
{
|
||||
LocalSession session = api.getSession(p);
|
||||
if (session != null)
|
||||
{
|
||||
BukkitPlayer bukkitPlayer = this.getBukkitPlayer(p);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
session.undo(session.getBlockBag(bukkitPlayer), bukkitPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void setLimit(Player p, int limit)
|
||||
{
|
||||
try
|
||||
{
|
||||
WorldEditAPI api = this.getWorldEditAPI();
|
||||
if (api != null)
|
||||
{
|
||||
LocalSession session = api.getSession(p);
|
||||
if (session != null)
|
||||
{
|
||||
session.setBlockChangeLimit(limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static TFM_WorldEditBridge getInstance()
|
||||
{
|
||||
return TFM_WorldEditBridgeHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class TFM_WorldEditBridgeHolder
|
||||
{
|
||||
private static final TFM_WorldEditBridge INSTANCE = new TFM_WorldEditBridge();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user