Finished Jumppads

This commit is contained in:
JeromSar 2013-08-13 17:16:33 +02:00
parent 656dbf8867
commit 6fcaed6253
4 changed files with 106 additions and 10 deletions

View File

@ -1,5 +1,5 @@
#Tue, 13 Aug 2013 15:59:09 +0200
#Tue, 13 Aug 2013 17:15:05 +0200
program.VERSION=2.22
program.BUILDNUM=437
program.BUILDDATE=08/13/2013 03\:59 PM
program.BUILDNUM=445
program.BUILDDATE=08/13/2013 05\:15 PM

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Tue Aug 13 15:59:09 CEST 2013
build.number=438
#Tue Aug 13 17:15:05 CEST 2013
build.number=446

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, 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 hight to: " + String.valueOf(strength), false);
TFM_Jumppads.getInstance().strength = (strength / 10) + 0.1F;
}
else
{
return false;
}
}
return true;
}
}

View File

@ -9,7 +9,7 @@ import org.bukkit.util.Vector;
public class TFM_Jumppads
{
final int blockId = Material.WOOL.getId();
public Mode mode = Mode.NORMAL_AND_SIDEWAYS;
public Mode mode = Mode.OFF;
public float strength = 0.4F;
public void PlayerMoveEvent(PlayerMoveEvent event)
@ -32,22 +32,22 @@ public class TFM_Jumppads
{
if (b.getRelative(1, 0, 0).getTypeId() == blockId)
{
velocity.add(new Vector(-0.2F, 0F, 0F));
velocity.add(new Vector(-0.8F * strength, 0F, 0F));
}
if (b.getRelative(-1, 0, 0).getTypeId() == blockId)
{
velocity.add(new Vector(0.2F, 0F, 0F));
velocity.add(new Vector(0.8F * strength, 0F, 0F));
}
if (b.getRelative(0, 0, 1).getTypeId() == blockId)
{
velocity.add(new Vector(0F, 0F, -0.2F));
velocity.add(new Vector(0F, 0F, -0.8F * strength));
}
if (b.getRelative(0, 0, -1).getTypeId() == blockId)
{
velocity.add(new Vector(0F, 0F, 0.2F));
velocity.add(new Vector(0F, 0F, 0.8F * strength));
}
}