mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +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;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@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
|
public class Command_jumppads extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -25,28 +25,37 @@ public class Command_jumppads extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (args[0].equalsIgnoreCase("info"))
|
if (args[0].equalsIgnoreCase("info"))
|
||||||
{
|
{
|
||||||
msg("Jumppads: " + (plugin.jp.getMode().isOn() ? "Enabled" : "Disabled"), ChatColor.BLUE);
|
msg("Jumppads: " + (plugin.jp.players.get(playerSender).isOn() ? "Enabled" : "Disabled"), ChatColor.BLUE);
|
||||||
msg("Sideways: " + (plugin.jp.getMode() == Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS ? "Enabled" : "Disabled"), ChatColor.BLUE);
|
msg("Sideways: " + (plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS ? "Enabled" : "Disabled"), ChatColor.BLUE);
|
||||||
msg("Strength: " + (plugin.jp.getStrength() * 10 - 1), ChatColor.BLUE);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("off".equals(args[0]))
|
if ("off".equals(args[0]))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Disabling Jumppads", false);
|
if(plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.OFF)
|
||||||
plugin.jp.setMode(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
|
else
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Enabling Jumppads", false);
|
if(plugin.jp.players.get(playerSender) != Jumppads.JumpPadMode.OFF)
|
||||||
plugin.jp.setMode(Jumppads.JumpPadMode.MADGEEK);
|
{
|
||||||
|
msg("Your jumppads are already enabled.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
msg("Enabled your jumpppads.", ChatColor.GRAY);
|
||||||
|
plugin.jp.players.put(playerSender, Jumppads.JumpPadMode.MADGEEK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,43 +63,30 @@ public class Command_jumppads extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if ("off".equals(args[1]))
|
if ("off".equals(args[1]))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Setting Jumppads mode to: Madgeek", false);
|
if(plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.MADGEEK)
|
||||||
plugin.jp.setMode(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
|
else
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Setting Jumppads mode to: Normal and Sideways", false);
|
if(plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS)
|
||||||
plugin.jp.setMode(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
|
else
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.fun;
|
package me.totalfreedom.totalfreedommod.fun;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@ -10,6 +11,7 @@ import me.totalfreedom.totalfreedommod.util.MaterialGroup;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
@ -22,10 +24,8 @@ public class Jumppads extends FreedomService
|
|||||||
//
|
//
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private JumpPadMode mode = JumpPadMode.MADGEEK;
|
private double strength = 1 + 0.1F;
|
||||||
@Getter
|
public HashMap<Player, JumpPadMode> players = new HashMap<>();
|
||||||
@Setter
|
|
||||||
private double strength = 0.4;
|
|
||||||
|
|
||||||
public Jumppads(TotalFreedomMod plugin)
|
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
|
@EventHandler
|
||||||
public void onPlayerMove(PlayerMoveEvent event)
|
public void onPlayerMove(PlayerMoveEvent event)
|
||||||
{
|
{
|
||||||
if (mode == JumpPadMode.OFF)
|
if (players.get(event.getPlayer()) == JumpPadMode.OFF)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -56,7 +65,7 @@ public class Jumppads extends FreedomService
|
|||||||
final Block block = event.getTo().getBlock();
|
final Block block = event.getTo().getBlock();
|
||||||
final Vector velocity = player.getVelocity().clone();
|
final Vector velocity = player.getVelocity().clone();
|
||||||
|
|
||||||
if (mode == JumpPadMode.MADGEEK)
|
if (players.get(event.getPlayer()) == JumpPadMode.MADGEEK)
|
||||||
{
|
{
|
||||||
Boolean canPush = pushMap.get(player);
|
Boolean canPush = pushMap.get(player);
|
||||||
if (canPush == null)
|
if (canPush == null)
|
||||||
@ -84,7 +93,7 @@ public class Jumppads extends FreedomService
|
|||||||
velocity.add(new Vector(0.0, strength, 0.0));
|
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()))
|
if (MaterialGroup.WOOL_COLORS.contains(block.getRelative(1, 0, 0).getType()))
|
||||||
{
|
{
|
||||||
@ -118,10 +127,10 @@ public class Jumppads extends FreedomService
|
|||||||
public static enum JumpPadMode
|
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 final boolean on;
|
||||||
|
|
||||||
private JumpPadMode(boolean on)
|
JumpPadMode(boolean on)
|
||||||
{
|
{
|
||||||
this.on = on;
|
this.on = on;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user