Some effect for the f home teleport command

This commit is contained in:
Olof Larsson 2011-10-13 12:17:23 +02:00
parent 73ea2b75e0
commit 0039370f05
4 changed files with 108 additions and 1 deletions

View File

@ -77,6 +77,8 @@ public class Conf
public static boolean homesTeleportToOnDeath = true;
public static boolean homesRespawnFromNoPowerLossWorlds = true;
public static boolean homesTeleportCommandEnabled = true;
public static boolean homesTeleportCommandSmokeEffectEnabled = true;
public static float homesTeleportCommandSmokeEffectThickness = 3f;
public static boolean homesTeleportAllowedFromEnemyTerritory = true;
public static boolean homesTeleportAllowedFromDifferentWorld = true;
public static double homesTeleportAllowedEnemyDistance = 32.0;

View File

@ -1,5 +1,8 @@
package com.massivecraft.factions.cmd;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
@ -13,6 +16,7 @@ import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.zcore.util.SmokeUtil;
public class CmdHome extends FCommand
{
@ -122,6 +126,17 @@ public class CmdHome extends FCommand
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
if ( ! payForCommand(Conf.econCostHome, "to change faction home", "for changing faction home")) return;
// Create a smoke effect
if (Conf.homesTeleportCommandSmokeEffectEnabled)
{
List<Location> smokeLocations = new ArrayList<Location>();
smokeLocations.add(me.getLocation());
smokeLocations.add(me.getLocation().add(0, 1, 0));
smokeLocations.add(myFaction.getHome());
smokeLocations.add(myFaction.getHome().add(0, 1, 0));
SmokeUtil.spawnCloudRandom(smokeLocations, Conf.homesTeleportCommandSmokeEffectThickness);
}
me.teleport(myFaction.getHome());
}

View File

@ -29,7 +29,6 @@ import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.util.MiscUtil;

View File

@ -0,0 +1,91 @@
package com.massivecraft.factions.zcore.util;
import java.util.Collection;
import java.util.Random;
import org.bukkit.Effect;
import org.bukkit.Location;
// http://mc.kev009.com/Protocol
// -----------------------------
// Smoke Directions
// -----------------------------
// Direction ID Direction
// 0 South - East
// 1 South
// 2 South - West
// 3 East
// 4 (Up or middle ?)
// 5 West
// 6 North - East
// 7 North
// 8 North - West
//-----------------------------
public class SmokeUtil
{
public static Random random = new Random();
// -------------------------------------------- //
// Spawn once
// -------------------------------------------- //
// Single ========
public static void spawnSingle(Location location, int direction)
{
if (location == null) return;
location.getWorld().playEffect(location, Effect.SMOKE, direction);
}
public static void spawnSingle(Location location)
{
spawnSingle(location, 4);
}
public static void spawnSingleRandom(Location location)
{
spawnSingle(location, random.nextInt(9));
}
// Simple Cloud ========
public static void spawnCloudSimple(Location location)
{
for (int i = 0; i <= 8; i++)
{
spawnSingle(location, i);
}
}
public static void spawnCloudSimple(Collection<Location> locations)
{
for (Location location : locations)
{
spawnCloudSimple(location);
}
}
// Random Cloud ========
public static void spawnCloudRandom(Location location, float thickness)
{
int singles = (int) Math.floor(thickness*9);
for (int i = 0; i < singles; i++)
{
spawnSingleRandom(location);
}
}
public static void spawnCloudRandom(Collection<Location> locations, float thickness)
{
for (Location location : locations)
{
spawnCloudRandom(location, thickness);
}
}
// -------------------------------------------- //
// Attach continuous effects to or locations
// -------------------------------------------- //
// TODO
}