When players are knocked back, an experimental effect is now shown at the spot they were knocked back from; this effect is enabled by default, but can be enabled/disabled with the new /wb whoosh <on/off> command

This commit is contained in:
Brettflan 2011-07-27 16:30:07 -05:00
parent 74835286d9
commit 04971a2007
4 changed files with 52 additions and 4 deletions

View File

@ -1,6 +1,7 @@
package com.wimbli.WorldBorder;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle;
import org.bukkit.Location;
@ -57,11 +58,18 @@ public class BorderCheckTask implements Runnable
ride.teleport(newLoc);
}
else
{ // when riding a pig, player.getVehicle() returns null on older Bukkit releases; in that case an eject is required
{ // if player.getVehicle() returns null (when riding a pig on older Bukkit releases, for instance), player has to be ejected
players[i].leaveVehicle();
players[i].teleport(newLoc);
}
}
if (Config.whooshEffect())
{ // show some smoke and play the extinguish sound effect where the player was beyond the border
world.playEffect(loc, Effect.SMOKE, 4);
world.playEffect(loc, Effect.SMOKE, 4);
world.playEffect(loc, Effect.EXTINGUISH, 0);
}
}
// Config.timeUsed += Config.Now() - startTime; // for monitoring plugin efficiency
}

View File

@ -46,6 +46,7 @@ public class Config
private static boolean DEBUG = false;
private static double knockBack = 3.0;
private static int timerTicks = 4;
private static boolean whooshEffect = true;
// for monitoring plugin efficiency
// public static long timeUsed = 0;
@ -149,6 +150,18 @@ public class Config
return DEBUG;
}
public static void setWhooshEffect(boolean enable)
{
whooshEffect = enable;
Log("\"Whoosh\" knockback effect " + (whooshEffect ? "enabled" : "disabled") + ".");
save(true);
}
public static boolean whooshEffect()
{
return whooshEffect;
}
public static void setKnockBack(double numBlocks)
{
knockBack = numBlocks;
@ -308,21 +321,26 @@ public class Config
}
private static final int currentCfgVersion = 3;
public static void load(WorldBorder master, boolean logIt)
{ // load config from file
plugin = master;
console = new ColouredConsoleSender((CraftServer)plugin.getServer());
cfg = plugin.getConfiguration();
int cfgVersion = cfg.getInt("cfg-version", 1);
int cfgVersion = cfg.getInt("cfg-version", currentCfgVersion);
message = cfg.getString("message");
shapeRound = cfg.getBoolean("round-border", false);
DEBUG = cfg.getBoolean("debug-mode", false);
whooshEffect = cfg.getBoolean("whoosh-effect", true);
knockBack = cfg.getDouble("knock-back-dist", 3.0);
timerTicks = cfg.getInt("timer-delay-ticks", 5);
LogConfig("Using " + (shapeRound ? "round" : "square") + " border, knockback of " + knockBack + " blocks, and timer delay of " + timerTicks + ".");
DEBUG = cfg.getBoolean("debug-mode", false);
StartBorderTimer();
borders.clear();
@ -377,7 +395,7 @@ public class Config
if (logIt)
LogConfig("Configuration loaded.");
if (cfgVersion < 2)
if (cfgVersion < currentCfgVersion)
save(false);
}
@ -389,10 +407,11 @@ public class Config
{ // save config to file
if (cfg == null) return;
cfg.setProperty("cfg-version", 2);
cfg.setProperty("cfg-version", currentCfgVersion);
cfg.setProperty("message", message);
cfg.setProperty("round-border", shapeRound);
cfg.setProperty("debug-mode", DEBUG);
cfg.setProperty("whoosh-effect", whooshEffect);
cfg.setProperty("knock-back-dist", knockBack);
cfg.setProperty("timer-delay-ticks", timerTicks);

View File

@ -293,6 +293,20 @@ public class WBCommand implements CommandExecutor
sender.sendMessage("Debug mode " + (Config.Debug() ? "enabled" : "disabled") + ".");
}
// "whoosh" command from player or console
else if (split.length == 2 && split[0].equalsIgnoreCase("whoosh"))
{
if (!Config.HasPermission(player, "whoosh")) return true;
Config.setWhooshEffect(split[1].equalsIgnoreCase("on"));
if (player != null)
Config.Log((Config.Debug() ? "Enabling" : "Disabling") + " \"whoosh\" knockback effect at the command of player \"" + player.getName() + "\".");
if (player != null)
sender.sendMessage("\"Whoosh\" knockback effect " + (Config.whooshEffect() ? "enabled" : "disabled") + ".");
}
// "knockback" command from player or console
else if (split.length == 2 && split[0].equalsIgnoreCase("knockback"))
{
@ -495,6 +509,7 @@ public class WBCommand implements CommandExecutor
sender.sendMessage(cmd+" wshape " + ((player == null) ? clrReq + "<world>" : clrOpt + "[world]") + clrReq + " <round|square|default>" + clrDesc + " - shape override.");
sender.sendMessage(cmd+" getmsg" + clrDesc + " - display border message.");
sender.sendMessage(cmd+" setmsg " + clrReq + "<text>" + clrDesc + " - set border message.");
sender.sendMessage(cmd+" whoosh " + clrReq + "<on|off>" + clrDesc + " - turn knockback effect on or off.");
sender.sendMessage(cmd+" delay " + clrReq + "<amount>" + clrDesc + " - time between border checks.");
sender.sendMessage(cmd+" reload" + clrDesc + " - re-load data from config.yml.");
sender.sendMessage(cmd+" debug " + clrReq + "<on|off>" + clrDesc + " - turn console debug output on or off.");

View File

@ -19,9 +19,11 @@ commands:
/<command> getmsg - display border message.
/<command> setmsg <text> - set border message.
/<command> knockback <distance> - how far to move the player back.
/<command> whoosh <on/off> - turn knockback effect on or off.
/<command> delay <amount> - time between border checks.
/<command> wshape [world] <round|square|default> - override shape.
/<command> [world] fill [freq] [pad] - generate world out to border.
/<command> debug <on/off> - turn debug mode on or off.
permissions:
worldborder.*:
description: Grants all WorldBorder permissions
@ -40,6 +42,7 @@ permissions:
worldborder.wshape: true
worldborder.fill: true
worldborder.help: true
worldborder.whoosh: true
worldborder.set:
description: Can set borders for any world
default: op
@ -82,3 +85,6 @@ permissions:
worldborder.help:
description: Can view the command reference help pages
default: op
worldborder.whoosh:
description: Can enable/disable "whoosh" knockback effect
default: op