Merge branch 'master' into mg_untested

This commit is contained in:
StevenLawson 2013-08-13 12:29:12 -04:00
commit 5c8f98089e
5 changed files with 193 additions and 5 deletions

View File

@ -1,5 +1,5 @@
#Mon, 12 Aug 2013 22:00:24 -0400
#Tue, 13 Aug 2013 18:21:17 +0200
program.VERSION=2.22
program.BUILDNUM=428
program.BUILDDATE=08/12/2013 10\:00 PM
program.BUILDNUM=446
program.BUILDDATE=08/13/2013 06\:21 PM

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Mon Aug 12 22:00:24 EDT 2013
build.number=429
#Tue Aug 13 18:21:17 CEST 2013
build.number=447

View File

@ -0,0 +1,96 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Jumppads;
import me.StevenLawson.TotalFreedomMod.TFM_Jumppads.Mode;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Manage jumppads", usage = "/<command> <on | off | info |sideways <on | off> | strength <strength (1-10)>>", aliases = "launchpads,jp")
public class Command_jumppads extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0 || args.length > 2)
{
return false;
}
if (args.length == 1)
{
if (args[0].equalsIgnoreCase("info"))
{
playerMsg("Jumppads: " + (TFM_Jumppads.getInstance().mode.isOn() ? "Enabled" : "Disabled"), ChatColor.BLUE);
playerMsg("Sideways: " + (TFM_Jumppads.getInstance().mode == Mode.NORMAL_AND_SIDEWAYS ? "Enabled" : "Disabled"), ChatColor.BLUE);
playerMsg("Strength: " + (TFM_Jumppads.getInstance().strength * 10 - 1), ChatColor.BLUE);
return true;
}
if (TFM_Util.isStopCommand(args[0]))
{
TFM_Util.adminAction(sender.getName(), "Disabling Jumppads", false);
TFM_Jumppads.getInstance().mode = Mode.OFF;
}
else
{
TFM_Util.adminAction(sender.getName(), "Enabling Jumppads", false);
TFM_Jumppads.getInstance().mode = Mode.NORMAL;
}
}
else
{
if (TFM_Jumppads.getInstance().mode == Mode.OFF)
{
playerMsg("Jumppads are currently disabled, please enable them before changing jumppads settings.");
return true;
}
if (args[0].equalsIgnoreCase("sideways"))
{
if (TFM_Util.isStopCommand(args[1]))
{
TFM_Util.adminAction(sender.getName(), "Setting Jumppads mode to: Normal", false);
TFM_Jumppads.getInstance().mode = Mode.NORMAL;
}
else
{
TFM_Util.adminAction(sender.getName(), "Setting Jumppads mode to: Normal and Sideways", false);
TFM_Jumppads.getInstance().mode = Mode.NORMAL_AND_SIDEWAYS;
}
}
else if (args[0].equalsIgnoreCase("strength"))
{
final float strength;
try
{
strength = Float.parseFloat(args[1]);
}
catch (NumberFormatException ex)
{
playerMsg("Invalid Strength");
return true;
}
if (strength > 10 || strength < 1)
{
playerMsg("Invalid Strength: The strength may be 1 through 10.");
return true;
}
TFM_Util.adminAction(sender.getName(), "Setting Jumppads strength to: " + String.valueOf(strength), false);
TFM_Jumppads.getInstance().strength = (strength / 10) + 0.1F;
}
else
{
return false;
}
}
return true;
}
}

View File

@ -335,6 +335,11 @@ public class TFM_PlayerListener implements Listener
}
}
if (TFM_Jumppads.getInstance().mode.isOn())
{
TFM_Jumppads.getInstance().PlayerMoveEvent(event);
}
if (TotalFreedomMod.landminesEnabled && TotalFreedomMod.allowExplosions)
{
Iterator<TFM_LandmineData> landmines = TFM_LandmineData.landmines.iterator();
@ -372,6 +377,7 @@ public class TFM_PlayerListener implements Listener
}
}
}
}
@EventHandler(priority = EventPriority.NORMAL)

View File

@ -0,0 +1,86 @@
package me.StevenLawson.TotalFreedomMod;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.util.Vector;
public class TFM_Jumppads
{
final int blockId = Material.WOOL.getId();
public Mode mode = Mode.OFF;
public float strength = 0.4F;
public void PlayerMoveEvent(PlayerMoveEvent event)
{
if (mode == Mode.OFF)
{
return;
}
final Player p = event.getPlayer();
final Block b = event.getTo().getBlock();
Vector velocity = p.getVelocity().clone();
if (b.getRelative(0, -1, 0).getTypeId() == blockId)
{
velocity.add(new Vector(0, strength, 0));
}
if (mode == Mode.NORMAL_AND_SIDEWAYS)
{
if (b.getRelative(1, 0, 0).getTypeId() == blockId)
{
velocity.add(new Vector(-0.8F * strength, 0F, 0F));
}
if (b.getRelative(-1, 0, 0).getTypeId() == blockId)
{
velocity.add(new Vector(0.8F * strength, 0F, 0F));
}
if (b.getRelative(0, 0, 1).getTypeId() == blockId)
{
velocity.add(new Vector(0F, 0F, -0.8F * strength));
}
if (b.getRelative(0, 0, -1).getTypeId() == blockId)
{
velocity.add(new Vector(0F, 0F, 0.8F * strength));
}
}
if (!p.getVelocity().equals(velocity))
{
p.setFallDistance(0F);
p.setVelocity(velocity);
}
}
public static enum Mode
{
OFF(false), NORMAL(true), NORMAL_AND_SIDEWAYS(true);
private boolean on;
Mode(boolean on)
{
this.on = on;
}
public boolean isOn()
{
return on;
}
}
public static TFM_Jumppads getInstance()
{
return TFM_JumpadsHolder.INSTANCE;
}
private static class TFM_JumpadsHolder
{
private static final TFM_Jumppads INSTANCE = new TFM_Jumppads();
}
}