mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-30 13:27:37 +00:00
//UNTESTED: add personal jumppads
This commit is contained in:
parent
7c6c407f78
commit
b4bb2cf4d8
@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Manage jumppads", usage = "/<command> <on | off | info | sideways <on | off> | strength <strength (1-10)>>", aliases = "launchpads,jp")
|
||||
@CommandParameters(description = "Manage jumppads", usage = "/<command> <on | off | info | sideways <on | off>>", aliases = "launchpads,jp")
|
||||
public class Command_jumppads extends FreedomCommand
|
||||
{
|
||||
|
||||
@ -25,28 +25,37 @@ public class Command_jumppads extends FreedomCommand
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("info"))
|
||||
{
|
||||
msg("Jumppads: " + (plugin.jp.getMode().isOn() ? "Enabled" : "Disabled"), ChatColor.BLUE);
|
||||
msg("Sideways: " + (plugin.jp.getMode() == Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS ? "Enabled" : "Disabled"), ChatColor.BLUE);
|
||||
msg("Strength: " + (plugin.jp.getStrength() * 10 - 1), ChatColor.BLUE);
|
||||
msg("Jumppads: " + (plugin.jp.players.get(playerSender).isOn() ? "Enabled" : "Disabled"), ChatColor.BLUE);
|
||||
msg("Sideways: " + (plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS ? "Enabled" : "Disabled"), ChatColor.BLUE);
|
||||
return true;
|
||||
}
|
||||
|
||||
if ("off".equals(args[0]))
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Disabling Jumppads", false);
|
||||
plugin.jp.setMode(Jumppads.JumpPadMode.OFF);
|
||||
if(plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.OFF)
|
||||
{
|
||||
msg("Your jumppads are already disabled.");
|
||||
return true;
|
||||
}
|
||||
msg("Disabled your jumppads.", ChatColor.GRAY);
|
||||
plugin.jp.players.put(playerSender, Jumppads.JumpPadMode.OFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Enabling Jumppads", false);
|
||||
plugin.jp.setMode(Jumppads.JumpPadMode.MADGEEK);
|
||||
if(plugin.jp.players.get(playerSender) != Jumppads.JumpPadMode.OFF)
|
||||
{
|
||||
msg("Your jumppads are already enabled.");
|
||||
return true;
|
||||
}
|
||||
msg("Enabled your jumpppads.", ChatColor.GRAY);
|
||||
plugin.jp.players.put(playerSender, Jumppads.JumpPadMode.MADGEEK);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (plugin.jp.getMode() == Jumppads.JumpPadMode.OFF)
|
||||
if (plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.OFF)
|
||||
{
|
||||
msg("Jumppads are currently disabled, please enable them before changing jumppads settings.");
|
||||
msg("Your jumppads are currently disabled, please enable them before changing jumppads settings.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -54,43 +63,30 @@ public class Command_jumppads extends FreedomCommand
|
||||
{
|
||||
if ("off".equals(args[1]))
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Setting Jumppads mode to: Madgeek", false);
|
||||
plugin.jp.setMode(Jumppads.JumpPadMode.MADGEEK);
|
||||
if(plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.MADGEEK)
|
||||
{
|
||||
msg("Your jumppads are already set to normal mode.");
|
||||
return true;
|
||||
}
|
||||
msg("Set Jumppads mode to: Normal", ChatColor.GRAY);
|
||||
plugin.jp.players.put(playerSender, Jumppads.JumpPadMode.MADGEEK);
|
||||
}
|
||||
else
|
||||
{
|
||||
FUtil.adminAction(sender.getName(), "Setting Jumppads mode to: Normal and Sideways", false);
|
||||
plugin.jp.setMode(Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS);
|
||||
if(plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS)
|
||||
{
|
||||
msg("Your jumppads are already set to normal and sideways mode.");
|
||||
return true;
|
||||
}
|
||||
msg("Set Jumppads mode to: Normal and Sideways", ChatColor.GRAY);
|
||||
plugin.jp.players.put(playerSender, Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS);
|
||||
}
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("strength"))
|
||||
{
|
||||
final float strength;
|
||||
try
|
||||
{
|
||||
strength = Float.parseFloat(args[1]);
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
msg("Invalid Strength");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strength > 10 || strength < 1)
|
||||
{
|
||||
msg("Invalid Strength: The strength may be 1 through 10.");
|
||||
return true;
|
||||
}
|
||||
|
||||
FUtil.adminAction(sender.getName(), "Setting Jumppads strength to: " + String.valueOf(strength), false);
|
||||
plugin.jp.setStrength((strength / 10) + 0.1F);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.totalfreedom.totalfreedommod.fun;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@ -10,6 +11,7 @@ import me.totalfreedom.totalfreedommod.util.MaterialGroup;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@ -22,10 +24,8 @@ public class Jumppads extends FreedomService
|
||||
//
|
||||
@Getter
|
||||
@Setter
|
||||
private JumpPadMode mode = JumpPadMode.MADGEEK;
|
||||
@Getter
|
||||
@Setter
|
||||
private double strength = 0.4;
|
||||
private double strength = 1 + 0.1F;
|
||||
public HashMap<Player, JumpPadMode> players = new HashMap<>();
|
||||
|
||||
public Jumppads(TotalFreedomMod plugin)
|
||||
{
|
||||
@ -44,10 +44,19 @@ public class Jumppads extends FreedomService
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
if(!players.containsKey(event.getPlayer()))
|
||||
{
|
||||
players.put(event.getPlayer(), JumpPadMode.OFF);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event)
|
||||
{
|
||||
if (mode == JumpPadMode.OFF)
|
||||
if (players.get(event.getPlayer()) == JumpPadMode.OFF)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -56,7 +65,7 @@ public class Jumppads extends FreedomService
|
||||
final Block block = event.getTo().getBlock();
|
||||
final Vector velocity = player.getVelocity().clone();
|
||||
|
||||
if (mode == JumpPadMode.MADGEEK)
|
||||
if (players.get(event.getPlayer()) == JumpPadMode.MADGEEK)
|
||||
{
|
||||
Boolean canPush = pushMap.get(player);
|
||||
if (canPush == null)
|
||||
@ -84,7 +93,7 @@ public class Jumppads extends FreedomService
|
||||
velocity.add(new Vector(0.0, strength, 0.0));
|
||||
}
|
||||
|
||||
if (mode == JumpPadMode.NORMAL_AND_SIDEWAYS)
|
||||
if (players.get(event.getPlayer()) == JumpPadMode.NORMAL_AND_SIDEWAYS)
|
||||
{
|
||||
if (MaterialGroup.WOOL_COLORS.contains(block.getRelative(1, 0, 0).getType()))
|
||||
{
|
||||
@ -118,10 +127,10 @@ public class Jumppads extends FreedomService
|
||||
public static enum JumpPadMode
|
||||
{
|
||||
|
||||
OFF(false), NORMAL(true), NORMAL_AND_SIDEWAYS(true), MADGEEK(true);
|
||||
OFF(false), NORMAL_AND_SIDEWAYS(true), MADGEEK(true);
|
||||
private final boolean on;
|
||||
|
||||
private JumpPadMode(boolean on)
|
||||
JumpPadMode(boolean on)
|
||||
{
|
||||
this.on = on;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user