mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Started work on Jumppads
This commit is contained in:
parent
e23db244a5
commit
656dbf8867
@ -1,5 +1,5 @@
|
|||||||
#Mon, 12 Aug 2013 22:00:24 -0400
|
#Tue, 13 Aug 2013 15:59:09 +0200
|
||||||
|
|
||||||
program.VERSION=2.22
|
program.VERSION=2.22
|
||||||
program.BUILDNUM=428
|
program.BUILDNUM=437
|
||||||
program.BUILDDATE=08/12/2013 10\:00 PM
|
program.BUILDDATE=08/13/2013 03\:59 PM
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#Build Number for ANT. Do not edit!
|
#Build Number for ANT. Do not edit!
|
||||||
#Mon Aug 12 22:00:24 EDT 2013
|
#Tue Aug 13 15:59:09 CEST 2013
|
||||||
build.number=429
|
build.number=438
|
||||||
|
@ -322,6 +322,11 @@ public class TFM_PlayerListener implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (TFM_Jumppads.getInstance().mode.isOn())
|
||||||
|
{
|
||||||
|
TFM_Jumppads.getInstance().PlayerMoveEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
if (TotalFreedomMod.landminesEnabled && TotalFreedomMod.allowExplosions)
|
if (TotalFreedomMod.landminesEnabled && TotalFreedomMod.allowExplosions)
|
||||||
{
|
{
|
||||||
Iterator<TFM_LandmineData> landmines = TFM_LandmineData.landmines.iterator();
|
Iterator<TFM_LandmineData> landmines = TFM_LandmineData.landmines.iterator();
|
||||||
@ -359,6 +364,7 @@ public class TFM_PlayerListener implements Listener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
86
src/me/StevenLawson/TotalFreedomMod/TFM_Jumppads.java
Normal file
86
src/me/StevenLawson/TotalFreedomMod/TFM_Jumppads.java
Normal 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.NORMAL_AND_SIDEWAYS;
|
||||||
|
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.2F, 0F, 0F));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b.getRelative(-1, 0, 0).getTypeId() == blockId)
|
||||||
|
{
|
||||||
|
velocity.add(new Vector(0.2F, 0F, 0F));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b.getRelative(0, 0, 1).getTypeId() == blockId)
|
||||||
|
{
|
||||||
|
velocity.add(new Vector(0F, 0F, -0.2F));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (b.getRelative(0, 0, -1).getTypeId() == blockId)
|
||||||
|
{
|
||||||
|
velocity.add(new Vector(0F, 0F, 0.2F));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user