mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
JumpPads cleanup
This commit is contained in:
parent
b0090a5412
commit
f9cbf11abb
@ -1,7 +1,6 @@
|
||||
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;
|
||||
@ -24,26 +23,26 @@ public class Command_jumppads extends TFM_Command
|
||||
{
|
||||
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);
|
||||
playerMsg("Jumppads: " + (TFM_Jumppads.getInstance().getMode().isOn() ? "Enabled" : "Disabled"), ChatColor.BLUE);
|
||||
playerMsg("Sideways: " + (TFM_Jumppads.getInstance().getMode() == TFM_Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS ? "Enabled" : "Disabled"), ChatColor.BLUE);
|
||||
playerMsg("Strength: " + (TFM_Jumppads.getInstance().getStrength() * 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;
|
||||
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.OFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Enabling Jumppads", false);
|
||||
TFM_Jumppads.getInstance().mode = Mode.NORMAL;
|
||||
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.NORMAL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TFM_Jumppads.getInstance().mode == Mode.OFF)
|
||||
if (TFM_Jumppads.getInstance().getMode() == TFM_Jumppads.JumpPadMode.OFF)
|
||||
{
|
||||
playerMsg("Jumppads are currently disabled, please enable them before changing jumppads settings.");
|
||||
return true;
|
||||
@ -51,16 +50,15 @@ public class Command_jumppads extends TFM_Command
|
||||
|
||||
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;
|
||||
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.NORMAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Setting Jumppads mode to: Normal and Sideways", false);
|
||||
TFM_Jumppads.getInstance().mode = Mode.NORMAL_AND_SIDEWAYS;
|
||||
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS);
|
||||
}
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("strength"))
|
||||
@ -83,7 +81,7 @@ public class Command_jumppads extends TFM_Command
|
||||
}
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "Setting Jumppads strength to: " + String.valueOf(strength), false);
|
||||
TFM_Jumppads.getInstance().strength = (strength / 10) + 0.1F;
|
||||
TFM_Jumppads.getInstance().setStrength((strength / 10) + 0.1F);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -336,7 +336,7 @@ public class TFM_PlayerListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
if (TFM_Jumppads.getInstance().mode.isOn())
|
||||
if (TFM_Jumppads.getInstance().getMode().isOn())
|
||||
{
|
||||
TFM_Jumppads.getInstance().PlayerMoveEvent(event);
|
||||
}
|
||||
|
@ -8,62 +8,83 @@ 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 static final Material BLOCK_ID = Material.WOOL;
|
||||
public static final double DAMPING_COEFFICIENT = 0.8;
|
||||
private JumpPadMode mode = JumpPadMode.OFF;
|
||||
private double strength = 0.4;
|
||||
|
||||
public void PlayerMoveEvent(PlayerMoveEvent event)
|
||||
{
|
||||
if (mode == Mode.OFF)
|
||||
if (mode == JumpPadMode.OFF)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Player p = event.getPlayer();
|
||||
final Block b = event.getTo().getBlock();
|
||||
Vector velocity = p.getVelocity().clone();
|
||||
final Player player = event.getPlayer();
|
||||
final Block block = event.getTo().getBlock();
|
||||
final Vector velocity = player.getVelocity().clone();
|
||||
|
||||
if (b.getRelative(0, -1, 0).getTypeId() == blockId)
|
||||
if (block.getRelative(0, -1, 0).getType() == BLOCK_ID)
|
||||
{
|
||||
velocity.add(new Vector(0, strength, 0));
|
||||
velocity.add(new Vector(0.0, strength, 0.0));
|
||||
}
|
||||
|
||||
if (mode == Mode.NORMAL_AND_SIDEWAYS)
|
||||
if (mode == JumpPadMode.NORMAL_AND_SIDEWAYS)
|
||||
{
|
||||
if (b.getRelative(1, 0, 0).getTypeId() == blockId)
|
||||
if (block.getRelative(1, 0, 0).getType() == BLOCK_ID)
|
||||
{
|
||||
velocity.add(new Vector(-0.8F * strength, 0F, 0F));
|
||||
velocity.add(new Vector(-DAMPING_COEFFICIENT * strength, 0.0, 0.0));
|
||||
}
|
||||
|
||||
if (b.getRelative(-1, 0, 0).getTypeId() == blockId)
|
||||
if (block.getRelative(-1, 0, 0).getType() == BLOCK_ID)
|
||||
{
|
||||
velocity.add(new Vector(0.8F * strength, 0F, 0F));
|
||||
velocity.add(new Vector(DAMPING_COEFFICIENT * strength, 0.0, 0.0));
|
||||
}
|
||||
|
||||
if (b.getRelative(0, 0, 1).getTypeId() == blockId)
|
||||
if (block.getRelative(0, 0, 1).getType() == BLOCK_ID)
|
||||
{
|
||||
velocity.add(new Vector(0F, 0F, -0.8F * strength));
|
||||
velocity.add(new Vector(0.0, 0.0, -DAMPING_COEFFICIENT * strength));
|
||||
}
|
||||
|
||||
if (b.getRelative(0, 0, -1).getTypeId() == blockId)
|
||||
if (block.getRelative(0, 0, -1).getType() == BLOCK_ID)
|
||||
{
|
||||
velocity.add(new Vector(0F, 0F, 0.8F * strength));
|
||||
velocity.add(new Vector(0.0, 0.0, DAMPING_COEFFICIENT * strength));
|
||||
}
|
||||
}
|
||||
|
||||
if (!p.getVelocity().equals(velocity))
|
||||
if (!player.getVelocity().equals(velocity))
|
||||
{
|
||||
p.setFallDistance(0F);
|
||||
p.setVelocity(velocity);
|
||||
player.setFallDistance(0.0f);
|
||||
player.setVelocity(velocity);
|
||||
}
|
||||
}
|
||||
|
||||
public static enum Mode
|
||||
public JumpPadMode getMode()
|
||||
{
|
||||
return mode;
|
||||
}
|
||||
|
||||
public void setMode(JumpPadMode mode)
|
||||
{
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
public double getStrength()
|
||||
{
|
||||
return strength;
|
||||
}
|
||||
|
||||
public void setStrength(double strength)
|
||||
{
|
||||
this.strength = strength;
|
||||
}
|
||||
|
||||
public static enum JumpPadMode
|
||||
{
|
||||
OFF(false), NORMAL(true), NORMAL_AND_SIDEWAYS(true);
|
||||
private boolean on;
|
||||
|
||||
Mode(boolean on)
|
||||
JumpPadMode(boolean on)
|
||||
{
|
||||
this.on = on;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user