A whole bunch of assorted changes

This commit is contained in:
alisolarflare 2016-11-28 13:59:25 -05:00
parent 9b4f3f3803
commit c120f2e46f
30 changed files with 359 additions and 480 deletions

View file

@ -1,3 +1,4 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
encoding/src=UTF-8
eclipse.preferences.version=1
encoding/<project>=UTF-8
encoding/metrics=UTF-8
encoding/src=UTF-8

View file

@ -11,10 +11,8 @@ commands:
description: Official g-power command that activates the ghostie powerups
powerdown:
description: Offical g-power command that deactivates the ghostie powerups
pressalilink:
description: Presses an Ali Link pressalilink frequency
setalilink:
description: Creates an Ali Link setalilink frequency
alilink:
description: Arguments: <press/set>
cbgm0:
description: Creative Boundaries Gamemode 0 - allows players to return to survival
cbgm1:

View file

@ -0,0 +1,15 @@
package alisolarflare.architecture.commands.subcommands;
public abstract class ModSubCommand extends SubCommand{
@Override
public boolean getPlayerOnly() {
// TODO Auto-generated method stub
return true;
}
@Override
public boolean getModOnly() {
// TODO Auto-generated method stub
return true;
}
}

View file

@ -0,0 +1,16 @@
package alisolarflare.architecture.commands.subcommands;
public abstract class PlayerSubCommand extends SubCommand{
@Override
public boolean getModOnly() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean getPlayerOnly() {
// TODO Auto-generated method stub
return true;
}
}

View file

@ -0,0 +1,10 @@
package alisolarflare.architecture.commands.subcommands;
import org.bukkit.entity.Player;
public abstract class SubCommand {
public abstract boolean run(Player player, String label, String[] args);
public abstract boolean getPlayerOnly();
public abstract boolean getModOnly();
public abstract String[] GetHelpText(String alias);
}

View file

@ -8,23 +8,21 @@ import org.bukkit.Server;
import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.architecture.Component;
import alisolarflare.components.alilinks.commands.PressAliLink;
import alisolarflare.components.alilinks.commands.SetAliLink;
import alisolarflare.components.alilinks.commands.AliLink;
import alisolarflare.components.alilinks.entities.Link;
public class AliLinkComponent extends Component {
private List<Link> linkList;
private List<Map<String,String>> linkData;
private List<Map<String,String>> linkMap;
@Override
public void register(JavaPlugin plugin) {
this.linkList = MapToLinkList(plugin.getConfig().getMapList("aliLinkList"), plugin.getServer());
for (Link link: linkList){
linkData.add(link.toMap());
linkMap.add(link.toMap());
}
registerCommand(plugin, new PressAliLink(plugin, linkList));
registerCommand(plugin, new SetAliLink(plugin.getConfig(), linkList, linkData));
registerCommand(plugin, new AliLink(plugin, linkList));
}
@SuppressWarnings("unchecked")

View file

@ -1,65 +1,86 @@
package alisolarflare.components.alilinks.commands;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import alisolarflare.architecture.commands.PlayerCommand;
import alisolarflare.components.alilinks.entities.Link;
public class SetAliLink extends PlayerCommand {
public List<Link> linkList;
public List<Map<String, String>> linkData;
private FileConfiguration config;
public SetAliLink(FileConfiguration config, List<Link> linkList, List<Map<String, String>> linkData) {
this.linkList = linkList;
this.linkData = linkData;
this.config = config;
}
@Override
public boolean OnCommand(Player player, String label, String[] args) {
if (args == null || args.length < 1) {
player.sendMessage("You must specify a link frequency");
player.sendMessage("/pressalilink [name]");
return false;
}
String frequency = args[0];
World world = player.getWorld();
int x = player.getLocation().getBlockX();
int y = player.getLocation().getBlockY();
int z = player.getLocation().getBlockZ();
if (args.length > 4) {
boolean arg1isNumber = StringUtils.isNumericSpace(args[1]);
boolean arg2isNumber = StringUtils.isNumericSpace(args[2]);
boolean arg3isNumber = StringUtils.isNumericSpace(args[3]);
if (arg1isNumber && arg2isNumber && arg3isNumber) {
x = Integer.parseInt(args[1]);
y = Integer.parseInt(args[2]);
z = Integer.parseInt(args[3]);
}
}
Link link = new Link(frequency, world, x, y, z);
linkList.add(link);
linkData.add(link.toMap());
saveLinkList();
return true;
}
private void saveLinkList(){
config.set("aliLinkList", linkData);
}
@Override
public String[] GetHelpText(String alias){
return new String[]{
"Usage: /setalilink <frequency> [x] [y] [z]"
};
}
}
package alisolarflare.components.alilinks.commands;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.architecture.commands.PlayerCommand;
import alisolarflare.components.alilinks.entities.Link;
public class AliLink extends PlayerCommand{
private JavaPlugin plugin;
private List<Link> linkList;
public AliLink(JavaPlugin plugin, List<Link> linkList) {
this.plugin = plugin;
this.linkList = linkList;
}
@Override
public boolean OnCommand(Player player, String alias, String[] args) {
if(args.length < 1)
return false;
switch (args[0].toLowerCase()){
case "press":
return press(player, alias, args);
case "set":
return set(player, alias, args);
default:
return false;
}
}
/**"Usage: /pressalilink <frequency>"*/
private boolean press(Player player, String alias, String[] inputFrequencies) {
if (inputFrequencies.length == 0) {
player.sendMessage("You must specify a link frequency");
return false;
}
List<String> inputFrequencyList= Arrays.asList(inputFrequencies);
for (Link link : linkList) {
if(inputFrequencyList.contains(link.frequency)){
link.press(plugin);
}
}
player.sendMessage("Link pressed!");
return true;
}
/**Usage: /setalilink <frequency> [x] [y] [z]*/
public boolean set(Player player, String label, String[] args) {
if (args == null || args.length < 1) {
player.sendMessage("You must specify a link frequency");
player.sendMessage("/pressalilink [name]");
return false;
}
String frequency = args[0];
World world = player.getWorld();
int x = player.getLocation().getBlockX();
int y = player.getLocation().getBlockY();
int z = player.getLocation().getBlockZ();
if (args.length > 4) {
boolean arg1isNumber = StringUtils.isNumericSpace(args[1]);
boolean arg2isNumber = StringUtils.isNumericSpace(args[2]);
boolean arg3isNumber = StringUtils.isNumericSpace(args[3]);
if (arg1isNumber && arg2isNumber && arg3isNumber) {
x = Integer.parseInt(args[1]);
y = Integer.parseInt(args[2]);
z = Integer.parseInt(args[3]);
}
}
Link link = new Link(frequency, world, x, y, z);
linkList.add(link);
return true;
}
}

View file

@ -1,43 +0,0 @@
package alisolarflare.components.alilinks.commands;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.architecture.commands.PlayerCommand;
import alisolarflare.components.alilinks.entities.Link;
public class PressAliLink extends PlayerCommand {
private JavaPlugin plugin;
private List<Link> linkList;
public PressAliLink(JavaPlugin plugin, List<Link> linkList) {
this.plugin = plugin;
this.linkList = linkList;
}
@Override
public boolean OnCommand(Player player, String label, String[] inputFrequencies) {
if (inputFrequencies.length < 1) {
player.sendMessage("You must specify a link frequency");
return false;
}
for (Link link : linkList) {
for (String frequency : inputFrequencies) {
if (frequency.equals(link.frequency)) {
link.press(plugin);
}
}
}
player.sendMessage("Link pressed!");
return true;
}
@Override
public String[] GetHelpText(String alias){
return new String[]{
"Usage: /pressalilink <frequency>"
};
}
}

View file

@ -12,6 +12,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.components.alilinks.tasks.UnpressTask;
public class Link{
public String frequency;
public World world;
public int x;

View file

@ -23,8 +23,6 @@ public class Cbgm0 extends PlayerCommand{
return true;
}
public String[] GetHelpText(String alias){
return new String[]{
"Creative Boundaries Usage: /cbgm0"
};
return new String[]{"Creative Boundaries Usage: /cbgm0"};
}
}

View file

@ -1,6 +0,0 @@
package alisolarflare.components.creativeboundaries.listeners;
import org.bukkit.event.Listener;
public class ItemRestrictionListener implements Listener {
}

View file

@ -4,13 +4,6 @@ import org.bukkit.Location;
import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.architecture.Component;
import alisolarflare.components.easyuhc.commands.ActivatePowers;
import alisolarflare.components.easyuhc.commands.SetUHCLobby;
import alisolarflare.components.easyuhc.commands.SetWorldBorders;
import alisolarflare.components.easyuhc.commands.SpreadPlayers;
import alisolarflare.components.easyuhc.commands.StartTimer;
import alisolarflare.components.easyuhc.commands.StartUHC;
import alisolarflare.components.easyuhc.commands.TeleportToUHC;
public class EasyUHCComponent extends Component{
public Location lobbyLocation;
@ -19,14 +12,14 @@ public class EasyUHCComponent extends Component{
registerCommand(plugin, new ActivatePowers());
registerCommand(plugin, new SetUHCLobby(this));
registerCommand(plugin, new SetWorldBorders());
registerCommand(plugin, new SetWorldBorders());
registerCommand(plugin, new SpreadPlayers());
registerCommand(plugin, new StartTimer());
registerCommand(plugin, new StartUHC());
registerCommand(plugin, new TeleportToUHC());
// registerCommand(plugin, new ActivatePowers());
// registerCommand(plugin, new SetUHCLobby(this));
// registerCommand(plugin, new SetWorldBorders());
// registerCommand(plugin, new SetWorldBorders());
// registerCommand(plugin, new SpreadPlayers());
// registerCommand(plugin, new StartTimer());
// registerCommand(plugin, new StartUHC());
// registerCommand(plugin, new TeleportToUHC());
}
}

View file

@ -1,13 +0,0 @@
package alisolarflare.components.easyuhc.commands;
import org.bukkit.entity.Player;
import alisolarflare.architecture.commands.ModCommand;
public class ActivatePowers extends ModCommand{
@Override
public boolean OnCommand(Player player, String alias, String[] args) {
return false;
}
}

View file

@ -1,20 +0,0 @@
package alisolarflare.components.easyuhc.commands;
import org.bukkit.entity.Player;
import alisolarflare.architecture.commands.ModCommand;
import alisolarflare.components.easyuhc.EasyUHCComponent;
public class SetUHCLobby extends ModCommand{
EasyUHCComponent module;
public SetUHCLobby(EasyUHCComponent easyUHCModule) {
this.module = easyUHCModule;
}
@Override
public boolean OnCommand(Player player, String alias, String[] args) {
module.lobbyLocation = player.getLocation();
return false;
}
}

View file

@ -1,14 +0,0 @@
package alisolarflare.components.easyuhc.commands;
import org.bukkit.entity.Player;
import alisolarflare.architecture.commands.ModCommand;
public class SetWorldBorders extends ModCommand {
@Override
public boolean OnCommand(Player player, String alias, String[] args) {
return false;
}
}

View file

@ -1,14 +0,0 @@
package alisolarflare.components.easyuhc.commands;
import org.bukkit.entity.Player;
import alisolarflare.architecture.commands.ModCommand;
public class ShrinkWorldBorders extends ModCommand {
@Override
public boolean OnCommand(Player player, String alias, String[] args) {
// TODO Auto-generated method stub
return false;
}
}

View file

@ -1,15 +0,0 @@
package alisolarflare.components.easyuhc.commands;
import org.bukkit.entity.Player;
import alisolarflare.architecture.commands.ModCommand;
public class SpreadPlayers extends ModCommand{
@Override
public boolean OnCommand(Player player, String alias, String[] args) {
// TODO Auto-generated method stub
return false;
}
}

View file

@ -1,14 +0,0 @@
package alisolarflare.components.easyuhc.commands;
import org.bukkit.entity.Player;
import alisolarflare.architecture.commands.ModCommand;
public class StartTimer extends ModCommand{
@Override
public boolean OnCommand(Player player, String alias, String[] args) {
// TODO Auto-generated method stub
return false;
}
}

View file

@ -1,14 +0,0 @@
package alisolarflare.components.easyuhc.commands;
import org.bukkit.entity.Player;
import alisolarflare.architecture.commands.ModCommand;
public class StartUHC extends ModCommand{
@Override
public boolean OnCommand(Player player, String alias, String[] args) {
// TODO Auto-generated method stub
return false;
}
}

View file

@ -1,14 +0,0 @@
package alisolarflare.components.easyuhc.commands;
import org.bukkit.entity.Player;
import alisolarflare.architecture.commands.PlayerCommand;
public class TeleportToUHC extends PlayerCommand{
@Override
public boolean OnCommand(Player player, String alias, String[] args) {
// TODO Auto-generated method stub
return false;
}
}

View file

@ -14,39 +14,57 @@ public class PlayerProximityLoop extends BukkitRunnable implements Listener{
private Location startLocation;
private Location endLocation;
private int sX;
private int sY;
private int sZ;
private int eX;
private int eY;
private int eZ;
public PlayerProximityLoop(JavaPlugin plugin, FlairDoorComponent component) {
this.plugin = plugin;
this.component = component;
this.startLocation = component.startLocation;
this.endLocation = component.endLocation;
setStartLocation(component.startLocation);
setEndLocation(component.endLocation);
this.runTaskTimer(plugin, 0, 20);
}
public void setStartLocation(Location location){
this.sX = startLocation.getBlockX();
this.sY = startLocation.getBlockY();
this.sZ = startLocation.getBlockZ();
this.startLocation = location;
this.endLocation.setWorld(location.getWorld());
}
public void setEndLocation(Location location){
this.eX = startLocation.getBlockX();
this.eY = startLocation.getBlockY();
this.eZ = startLocation.getBlockZ();
this.endLocation = location;
this.startLocation.setWorld(location.getWorld());
}
@Override
public void run() {
if (startLocation == null || endLocation == null){
return;
}
int sX = startLocation.getBlockX();
int sY = startLocation.getBlockY();
int sZ = startLocation.getBlockZ();
int eX = endLocation.getBlockX();
int eY = endLocation.getBlockY();
int eZ = endLocation.getBlockZ();
int playerX;
int playerY;
int playerZ;
Location playerLocation;
for (Player player : plugin.getServer().getOnlinePlayers()){
playerX = player.getLocation().getBlockX();
playerY = player.getLocation().getBlockY();
playerZ = player.getLocation().getBlockZ();
if(player.getLocation().getWorld() != startLocation.getWorld())
playerLocation = player.getLocation();
if(playerLocation.getWorld() != startLocation.getWorld())
continue;
if((playerX < sX && playerX < eX) ||(playerX > sX && playerX > eX))
playerX = playerLocation.getBlockX();
if((playerX < sX && playerX < eX) || (playerX > sX && playerX > eX))
continue;
if((playerY < sY && playerY < eY) ||(playerY > sY && playerY > eY))
playerY = playerLocation.getBlockY();
if((playerY < sY && playerY < eY) || (playerY > sY && playerY > eY))
continue;
if((playerZ < sZ && playerZ < eZ) ||(playerZ > sZ && playerZ > eZ))
playerZ = playerLocation.getBlockZ();
if((playerZ < sZ && playerZ < eZ) || (playerZ > sZ && playerZ > eZ))
continue;
component.playersToBeFlaired.add(player);

View file

@ -1,110 +1,111 @@
package alisolarflare.components.magic.tricks;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class BoomBowListener implements Listener {
JavaPlugin plugin;
public BoomBowListener(JavaPlugin plugin){
this.plugin = plugin;
}
@EventHandler
public void ClickEvent(PlayerInteractEvent event){
FlyBowBoost(event);
}
public void FlyBowBoost(PlayerInteractEvent event){
//ACTION SANITATION
if(!(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)) return;
if(!(event.getPlayer().isGliding())) return;
if(!(event.getMaterial() == Material.BOW)) return;
//BOW SANITATION
ItemStack bow = event.getItem();
if(!(bow.containsEnchantment(Enchantment.ARROW_KNOCKBACK))) return;
if(!(bow.getEnchantmentLevel(Enchantment.ARROW_KNOCKBACK) == 3)) return;
if(!(bow.getItemMeta().getDisplayName().contains("BOOM BOW"))) return;
//PLAYER SANITATION
Player player = event.getPlayer();
if(player.getGameMode().equals(GameMode.CREATIVE))return;
if(bow.containsEnchantment(Enchantment.ARROW_INFINITE)){
//HAS INIFINITY
Activate(event);
}else if((player.getInventory().contains(Material.TNT))){
//HAS TNT
Activate(event);
//Reduce tnt by 1
int tntSlot = player.getInventory().first(Material.TNT);
ItemStack tntStack = player.getInventory().getItem(tntSlot);
if(tntStack.getAmount() > 3){
tntStack.setAmount(tntStack.getAmount()-3);
}else{
player.getInventory().remove(tntStack);
}
if (bow.getDurability() < 0){
player.getInventory().clear(player.getInventory().getHeldItemSlot());
}
}else{
return;
}
}
public void Activate(PlayerInteractEvent event){
//INIT - Player variables
Player player = event.getPlayer();
Location playerLocation = player.getLocation();
ItemStack boomBow = player.getInventory().getItemInMainHand();
//TODO: NERF - boomDecay
//TODO: NERF - endCrystal
//TODO: NERF - healthReduction
//TODO: NERF - localized
if(BoomBowRule.boomDecay)
new BoomDecayTask(player).runTaskTimer(plugin, 1, 1);
if(BoomBowRule.endCrystal){
//BoomBowCyrstalSpawn
}
if(BoomBowRule.healthReduction){
player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 400, -1));
}
if(BoomBowRule.localized);
//SET - Player Velocity
player.setVelocity(playerLocation.getDirection().normalize().multiply(3.0));
//CREATE - Explosion + damage
player.getWorld().playSound(playerLocation, Sound.ENTITY_GENERIC_EXPLODE, 10, -20);
player.getWorld().spawnParticle(Particle.EXPLOSION_HUGE, playerLocation, 2);
player.damage(7.42425, player);
boomBow.setDurability((short) (boomBow.getDurability() + 3));
if(boomBow.getDurability() < 0){
player.getInventory().setItemInMainHand(null);
player.getWorld().playSound(playerLocation, Sound.ENTITY_ITEM_BREAK, 0, 0)
;
}
}
}
package alisolarflare.components.magic.tricks;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class BoomBowListener implements Listener {
JavaPlugin plugin;
public BoomBowListener(JavaPlugin plugin){
this.plugin = plugin;
}
@EventHandler
public void ClickEvent(PlayerInteractEvent event){
FlyBowBoost(event);
}
public void FlyBowBoost(PlayerInteractEvent event){
//ACTION SANITATION
if(!(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)) return;
if(!(event.getPlayer().isGliding())) return;
if(!(event.getMaterial() == Material.BOW)) return;
//BOW SANITATION
ItemStack bow = event.getItem();
if(!(bow.containsEnchantment(Enchantment.ARROW_KNOCKBACK))) return;
if(!(bow.getEnchantmentLevel(Enchantment.ARROW_KNOCKBACK) == 3)) return;
if(!(bow.getItemMeta().getDisplayName().contains("BOOM BOW"))) return;
//PLAYER SANITATION
Player player = event.getPlayer();
PlayerInventory inventory = player.getInventory();
if(player.getGameMode().equals(GameMode.SPECTATOR))return;
if(bow.containsEnchantment(Enchantment.ARROW_INFINITE)){
//HAS INIFINITY
Activate(event);
}else if((inventory.contains(Material.TNT))){
//HAS TNT
Activate(event);
//Reduce TNT
ItemStack tnt = inventory.getItem(inventory.first(Material.TNT));
if(tnt.getAmount() > 3){
tnt.setAmount(tnt.getAmount()-3);
}else{
inventory.remove(tnt);
}
if (bow.getDurability() < 0){
inventory.clear(inventory.getHeldItemSlot());
}
}else{
return;
}
}
public void Activate(PlayerInteractEvent event){
//INIT - Player variables
Player player = event.getPlayer();
Location playerLocation = player.getLocation();
ItemStack boomBow = player.getInventory().getItemInMainHand();
//TODO: NERF - boomDecay
//TODO: NERF - endCrystal
//TODO: NERF - healthReduction
//TODO: NERF - localized
if(BoomBowRule.boomDecay)
new BoomDecayTask(player).runTaskTimer(plugin, 1, 1);
if(BoomBowRule.endCrystal){
//BoomBowCyrstalSpawn
}
if(BoomBowRule.healthReduction){
player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 400, -1));
}
if(BoomBowRule.localized);
//SET - Player Velocity
player.setVelocity(playerLocation.getDirection().normalize().multiply(3.0));
//CREATE - Explosion + damage
player.getWorld().playSound(playerLocation, Sound.ENTITY_GENERIC_EXPLODE, 10, -20);
player.getWorld().spawnParticle(Particle.EXPLOSION_HUGE, playerLocation, 2);
player.damage(7.42425, player);
boomBow.setDurability((short) (boomBow.getDurability() + 3));
if(boomBow.getDurability() > 385){
player.getInventory().setItemInMainHand(null);
player.getWorld().playSound(playerLocation, Sound.ENTITY_ITEM_BREAK, 0, 0);
}
}
}

View file

@ -17,6 +17,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
public class CannonBowListener implements Listener {
public final static String launchedTNTName = "CANNON BOW TNT:42170";
JavaPlugin plugin;
public CannonBowListener(JavaPlugin plugin){
this.plugin = plugin;
@ -24,32 +25,33 @@ public class CannonBowListener implements Listener {
@EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent event){
if(event.getEntity().getType() != EntityType.ARROW)
return;
//ENTITY SANITATION
if(event.getEntity().getType() != EntityType.ARROW)return;
//ARROW SANITATION
Arrow arrow = (Arrow) event.getEntity();
if (!(arrow.isCritical()) || !(arrow.getShooter() instanceof Player))
return;
if (!(arrow.isCritical()) || !(arrow.getShooter() instanceof Player))return;
//PLAYER SANITATION
Player player = (Player) arrow.getShooter();
if (!player.getInventory().contains(Material.TNT))return;
//BOW SANITATION
ItemStack bow;
if ((bow = player.getInventory().getItemInMainHand()).getType() != Material.BOW)
return;
if (!bow.containsEnchantment(Enchantment.PROTECTION_EXPLOSIONS))
return;
if(!(bow.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS) == 10))
return;
if (!bow.getItemMeta().getDisplayName().toUpperCase().contains("CANNON BOW"))
return;
if (!player.getInventory().contains(Material.TNT))
return;
if (!((bow = player.getInventory().getItemInMainHand()).getType() == Material.BOW))return;
if (!(bow.containsEnchantment(Enchantment.PROTECTION_EXPLOSIONS)))return;
if (!(bow.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS) == 10))return;
if (!(bow.getItemMeta().getDisplayName().toUpperCase().contains("CANNON BOW")))return;
TNTPrimed tnt = (TNTPrimed) arrow.getWorld().spawnEntity(arrow.getLocation(), EntityType.PRIMED_TNT);
tnt.setVelocity(player.getEyeLocation().getDirection().normalize().multiply(1.0));
tnt.setCustomName("CANNON BOW TNT");
tnt.setCustomName(launchedTNTName);
tnt.setFuseTicks(40);
player.setVelocity(player.getEyeLocation().getDirection().normalize().multiply(-1));
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 2.0F, 0);
player.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, player.getLocation(), 1);
player.getWorld().spawnParticle(Particle.EXPLOSION_HUGE, player.getLocation(), 2);
arrow.remove();
return;
@ -57,10 +59,9 @@ public class CannonBowListener implements Listener {
@EventHandler
public void onTnTExplode(EntityExplodeEvent event) {
if (event.getEntityType() != EntityType.PRIMED_TNT)
return;
if (!event.getEntity().getCustomName().equals("CANNON BOW TNT"))
return;
if (event.getEntityType() != EntityType.PRIMED_TNT) return;
if (!event.getEntity().getCustomName().equals(launchedTNTName)) return;
Location loc = event.getEntity().getLocation();
event.getEntity().getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 3, false, false);
event.setCancelled(true);

View file

@ -2,6 +2,7 @@ package alisolarflare.components.minigames;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import alisolarflare.architecture.Component;
@ -14,7 +15,7 @@ import alisolarflare.components.minigames.data.SpawnSet;
public class MinigameComponent extends Component{
public SpawnSet spawnSet;
public List<String> fighters;
private GameState gameState;
public GameState gameState;
@Override
public void register(JavaPlugin plugin) {
@ -25,9 +26,11 @@ public class MinigameComponent extends Component{
registerCommand(plugin, new ListFighters(this));
}
public GameState getGameState() {return gameState;}
public void setGameState(GameState gameState) {this.gameState = gameState;}
public class Fighter {
public Player player;
public String colour;
public Fighter(Player player, String colour){
this.colour = colour;
}
}
}

View file

@ -1,28 +1,25 @@
package alisolarflare.components.minigames.commands;
import java.util.List;
import org.bukkit.entity.Player;
import alisolarflare.architecture.commands.PlayerCommand;
import alisolarflare.components.minigames.MinigameComponent;
public class JoinMinigame extends PlayerCommand {
private MinigameComponent module;
private List<String> fighterList;
public JoinMinigame(MinigameComponent module) {
this.module = module;
public JoinMinigame(MinigameComponent component) {
this.fighterList = component.fighters;
}
@Override
public boolean OnCommand(Player player, String arg2, String[] arg3) {
String name = player.getName();
if (module.fighters.contains(name)) {
public boolean OnCommand(Player player, String arg2, String[] arg3) {
if (fighterList.contains(player.getName())) {
player.sendMessage("You are already in the minigame!");
return true;
}
module.fighters.add(name);
if (module.fighters.contains(name)) {
}else{
fighterList.add(player.getName());
player.sendMessage("You have joined the minigame!");
}
return true;

View file

@ -1,16 +1,17 @@
package alisolarflare.components.minigames.commands;
import java.util.List;
import org.bukkit.entity.Player;
import alisolarflare.architecture.commands.PlayerCommand;
import alisolarflare.components.minigames.MinigameComponent;
public class LeaveMinigame extends PlayerCommand {
private List<String> fighters;
private MinigameComponent module;
public LeaveMinigame(MinigameComponent module) {
this.module = module;
public LeaveMinigame(MinigameComponent components) {
this.fighters = components.fighters;
}
@Override
@ -18,15 +19,14 @@ public class LeaveMinigame extends PlayerCommand {
if(!(player instanceof Player))
player.sendMessage("You must be a player to use this command!");
String name = player.getName();
if (!(module.fighters.contains(name))) {
if (!(fighters.contains(name))) {
player.sendMessage("You are not fighting!");
return true;
}
while(module.fighters.contains(name)){
module.fighters.remove(name);
while(fighters.contains(name)){
fighters.remove(name);
}
player.sendMessage("You have left the fighters category!");

View file

@ -6,15 +6,15 @@ import alisolarflare.architecture.commands.PlayerCommand;
import alisolarflare.components.minigames.MinigameComponent;
public class ListFighters extends PlayerCommand {
private MinigameComponent lobby;
private MinigameComponent component;
public ListFighters(MinigameComponent lobby) {
this.lobby = lobby;
public ListFighters(MinigameComponent component) {
this.component = component;
}
@Override
public boolean OnCommand(Player player, String arg2, String[] arg3) {
player.sendMessage(lobby.fighters.toString());
player.sendMessage(component.fighters.toString());
return true;
}
@Override

View file

@ -7,7 +7,7 @@ import alisolarflare.components.minigames.data.SpawnSet;
public class SetColourSpawn extends ModCommand{
private SpawnSet spawnSet;
public SetColourSpawn(SpawnSet spawnSet){
this.spawnSet = spawnSet;
}
@ -17,41 +17,41 @@ public class SetColourSpawn extends ModCommand{
player.sendMessage("ERROR: Arguments required.");
return false;
}
String input = args[0];
input.toLowerCase();
switch(input){
case ("r"):
player.sendMessage("Setting Red Spawn...");
spawnSet.setRSpawn(player.getLocation());
spawnSet.RSpawn = player.getLocation();
player.sendMessage("Red Spawn Set!");
break;
case ("o"):
player.sendMessage("Setting Orange Spawn...");
spawnSet.setRSpawn(player.getLocation());
spawnSet.OSpawn = player.getLocation();
player.sendMessage("Orange Spawn Set!");
break;
case ("y"):
player.sendMessage("Setting Yellow Spawn...");
spawnSet.setRSpawn(player.getLocation());
spawnSet.YSpawn = player.getLocation();
player.sendMessage("Yellow Spawn Set!");
break;
case ("g"):
player.sendMessage("Setting Green Spawn...");
spawnSet.setRSpawn(player.getLocation());
spawnSet.GSpawn = player.getLocation();
player.sendMessage("Green Spawn Set!");
break;
case ("b"):
player.sendMessage("Setting Blue Spawn...");
spawnSet.setRSpawn(player.getLocation());
spawnSet.BSpawn = player.getLocation();
player.sendMessage("Blue Spawn Set!");
break;
case ("p"):
player.sendMessage("Setting Purple Spawn...");
spawnSet.setRSpawn(player.getLocation());
spawnSet.PSpawn = player.getLocation();
player.sendMessage("Purple Spawn Set!");
break;
break;
}
return true;
}

View file

@ -3,25 +3,11 @@ package alisolarflare.components.minigames.data;
import org.bukkit.Location;
public class SpawnSet {
private Location RSpawn;
private Location OSpawn;
private Location YSpawn;
private Location GSpawn;
private Location BSpawn;
private Location PSpawn;
public Location getRSpawn(){return RSpawn;}
public Location getOSpawn(){return OSpawn;}
public Location getYSpawn(){return YSpawn;}
public Location getGSpawn(){return GSpawn;}
public Location getBSpawn(){return BSpawn;}
public Location getPSpawn(){return PSpawn;}
public void setRSpawn(Location RSpawn){this.RSpawn = RSpawn; return;}
public void setOSpawn(Location OSpawn){this.OSpawn = OSpawn; return;}
public void setYSpawn(Location YSpawn){this.YSpawn = YSpawn; return;}
public void setGSpawn(Location GSpawn){this.GSpawn = GSpawn; return;}
public void setBSpawn(Location BSpawn){this.BSpawn = BSpawn; return;}
public void setPSpawn(Location PSpawn){this.PSpawn = PSpawn; return;}
public Location RSpawn;
public Location OSpawn;
public Location YSpawn;
public Location GSpawn;
public Location BSpawn;
public Location PSpawn;
}

View file

@ -1,11 +0,0 @@
package alisolarflare.components.minigames.entities;
import org.bukkit.entity.Player;
public class Fighter {
public Player player;
public String colour;
public Fighter(Player player, String colour){
this.colour = colour;
}
}