mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-26 17:05:01 +00:00
Landmines...
This commit is contained in:
parent
98712619f5
commit
98ee190b57
@ -0,0 +1,34 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_LandmineData;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Command_landmine extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (senderIsConsole)
|
||||
{
|
||||
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
|
||||
}
|
||||
else if (sender.isOp())
|
||||
{
|
||||
Block landmine = sender_p.getLocation().getBlock().getRelative(BlockFace.DOWN);
|
||||
landmine.setType(Material.TNT);
|
||||
plugin.landmines.add(new TFM_LandmineData(landmine.getLocation(), sender_p));
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -27,7 +27,7 @@ public class Command_wildcard extends TFM_Command
|
||||
{
|
||||
String out_command = base_command.replaceAll("\\x3f", p.getName());
|
||||
sender.sendMessage("Running Command: " + out_command);
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), out_command);
|
||||
Bukkit.getServer().dispatchCommand(sender, out_command);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1,16 +1,20 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Listener;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Pattern;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_LandmineData;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -30,54 +34,47 @@ public class TFM_PlayerListener extends PlayerListener
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
Action action = event.getAction();
|
||||
Material material = event.getMaterial();
|
||||
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
||||
if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
if (event.getMaterial() == Material.WATER_BUCKET)
|
||||
if (material == Material.WATER_BUCKET)
|
||||
{
|
||||
int slot = player.getInventory().getHeldItemSlot();
|
||||
ItemStack heldItem = new ItemStack(Material.COOKIE, 1);
|
||||
player.getInventory().setItem(slot, heldItem);
|
||||
|
||||
player.getInventory().setItemInHand(new ItemStack(Material.COOKIE, 1));
|
||||
player.sendMessage(ChatColor.GOLD + "Does this look like a waterpark to you?");
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
else if (event.getMaterial() == Material.LAVA_BUCKET)
|
||||
else if (material == Material.LAVA_BUCKET)
|
||||
{
|
||||
int slot = player.getInventory().getHeldItemSlot();
|
||||
ItemStack heldItem = new ItemStack(Material.COOKIE, 1);
|
||||
player.getInventory().setItem(slot, heldItem);
|
||||
|
||||
player.getInventory().setItemInHand(new ItemStack(Material.COOKIE, 1));
|
||||
player.sendMessage(ChatColor.GOLD + "LAVA NO FUN, YOU EAT COOKIE INSTEAD, NO?");
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)
|
||||
else if (action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK)
|
||||
{
|
||||
if (event.getMaterial() == Material.STICK)
|
||||
if (material == Material.STICK)
|
||||
{
|
||||
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(player, plugin);
|
||||
if (playerdata.mobThrowerEnabled())
|
||||
{
|
||||
Location player_pos = player.getLocation();
|
||||
Vector direction = player_pos.getDirection().normalize();
|
||||
Location rez_pos = player_pos.add(direction.multiply(2.0));
|
||||
|
||||
LivingEntity rezzed_mob = player.getWorld().spawnCreature(rez_pos, playerdata.mobThrowerCreature());
|
||||
LivingEntity rezzed_mob = player.getWorld().spawnCreature(player_pos.add(direction.multiply(2.0)), playerdata.mobThrowerCreature());
|
||||
rezzed_mob.setVelocity(direction.multiply(playerdata.mobThrowerSpeed()));
|
||||
playerdata.enqueueMob(rezzed_mob);
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
else if (event.getMaterial() == Material.SULPHUR)
|
||||
else if (material == Material.SULPHUR)
|
||||
{
|
||||
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(player, plugin);
|
||||
|
||||
|
||||
if (playerdata.isMP44Armed())
|
||||
{
|
||||
if (playerdata.toggleMP44Firing())
|
||||
@ -161,6 +158,29 @@ public class TFM_PlayerListener extends PlayerListener
|
||||
p.setVelocity(new Vector(0, playerdata.orbitStrength(), 0));
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<TFM_LandmineData> landmines = plugin.landmines.iterator();
|
||||
while (landmines.hasNext())
|
||||
{
|
||||
TFM_LandmineData landmine = landmines.next();
|
||||
|
||||
if (!landmine.player.equals(p))
|
||||
{
|
||||
if (p.getWorld().equals(landmine.landmine_pos.getWorld()))
|
||||
{
|
||||
if (p.getLocation().distance(landmine.landmine_pos) <= 2.0)
|
||||
{
|
||||
landmine.landmine_pos.getBlock().setType(Material.AIR);
|
||||
TNTPrimed primed_tnt = landmine.landmine_pos.getWorld().spawn(landmine.landmine_pos, TNTPrimed.class);
|
||||
primed_tnt.setFuseTicks(100);
|
||||
primed_tnt.setPassenger(p);
|
||||
primed_tnt.setVelocity(new Vector(0.0, 10.0, 0.0));
|
||||
p.setGameMode(GameMode.SURVIVAL);
|
||||
landmines.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
16
src/me/StevenLawson/TotalFreedomMod/TFM_LandmineData.java
Normal file
16
src/me/StevenLawson/TotalFreedomMod/TFM_LandmineData.java
Normal file
@ -0,0 +1,16 @@
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TFM_LandmineData
|
||||
{
|
||||
public Location landmine_pos;
|
||||
public Player player;
|
||||
|
||||
public TFM_LandmineData(Location landmine_pos, Player player)
|
||||
{
|
||||
this.landmine_pos = landmine_pos;
|
||||
this.player = player;
|
||||
}
|
||||
}
|
@ -38,6 +38,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
public static final String NOT_FROM_CONSOLE = "This command may not be used from the console.";
|
||||
|
||||
public Map<Player, TFM_UserInfo> userinfo = new HashMap<Player, TFM_UserInfo>();
|
||||
public List<TFM_LandmineData> landmines = new ArrayList<TFM_LandmineData>();
|
||||
public boolean allPlayersFrozen = false;
|
||||
|
||||
@Override
|
||||
|
@ -46,6 +46,9 @@ commands:
|
||||
gtfo:
|
||||
description: Superadmin command - Makes someone GTFO (deop and ip ban by username).
|
||||
usage: /<command> <partialname>
|
||||
landmine:
|
||||
description: Set a landmine trap.
|
||||
usage: /<command>
|
||||
lavadmg:
|
||||
description: Superadmin command - Enable/disable lava damage.
|
||||
usage: /<command> <on | off>
|
||||
|
Loading…
Reference in New Issue
Block a user