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; package com.wimbli.WorldBorder;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Vehicle; import org.bukkit.entity.Vehicle;
import org.bukkit.Location; import org.bukkit.Location;
@ -57,11 +58,18 @@ public class BorderCheckTask implements Runnable
ride.teleport(newLoc); ride.teleport(newLoc);
} }
else 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].leaveVehicle();
players[i].teleport(newLoc); 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 // 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 boolean DEBUG = false;
private static double knockBack = 3.0; private static double knockBack = 3.0;
private static int timerTicks = 4; private static int timerTicks = 4;
private static boolean whooshEffect = true;
// for monitoring plugin efficiency // for monitoring plugin efficiency
// public static long timeUsed = 0; // public static long timeUsed = 0;
@ -149,6 +150,18 @@ public class Config
return DEBUG; 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) public static void setKnockBack(double numBlocks)
{ {
knockBack = numBlocks; knockBack = numBlocks;
@ -308,21 +321,26 @@ public class Config
} }
private static final int currentCfgVersion = 3;
public static void load(WorldBorder master, boolean logIt) public static void load(WorldBorder master, boolean logIt)
{ // load config from file { // load config from file
plugin = master; plugin = master;
console = new ColouredConsoleSender((CraftServer)plugin.getServer()); console = new ColouredConsoleSender((CraftServer)plugin.getServer());
cfg = plugin.getConfiguration(); cfg = plugin.getConfiguration();
int cfgVersion = cfg.getInt("cfg-version", 1); int cfgVersion = cfg.getInt("cfg-version", currentCfgVersion);
message = cfg.getString("message"); message = cfg.getString("message");
shapeRound = cfg.getBoolean("round-border", false); shapeRound = cfg.getBoolean("round-border", false);
DEBUG = cfg.getBoolean("debug-mode", false); DEBUG = cfg.getBoolean("debug-mode", false);
whooshEffect = cfg.getBoolean("whoosh-effect", true);
knockBack = cfg.getDouble("knock-back-dist", 3.0); knockBack = cfg.getDouble("knock-back-dist", 3.0);
timerTicks = cfg.getInt("timer-delay-ticks", 5); timerTicks = cfg.getInt("timer-delay-ticks", 5);
LogConfig("Using " + (shapeRound ? "round" : "square") + " border, knockback of " + knockBack + " blocks, and timer delay of " + timerTicks + "."); LogConfig("Using " + (shapeRound ? "round" : "square") + " border, knockback of " + knockBack + " blocks, and timer delay of " + timerTicks + ".");
DEBUG = cfg.getBoolean("debug-mode", false);
StartBorderTimer(); StartBorderTimer();
borders.clear(); borders.clear();
@ -377,7 +395,7 @@ public class Config
if (logIt) if (logIt)
LogConfig("Configuration loaded."); LogConfig("Configuration loaded.");
if (cfgVersion < 2) if (cfgVersion < currentCfgVersion)
save(false); save(false);
} }
@ -389,10 +407,11 @@ public class Config
{ // save config to file { // save config to file
if (cfg == null) return; if (cfg == null) return;
cfg.setProperty("cfg-version", 2); cfg.setProperty("cfg-version", currentCfgVersion);
cfg.setProperty("message", message); cfg.setProperty("message", message);
cfg.setProperty("round-border", shapeRound); cfg.setProperty("round-border", shapeRound);
cfg.setProperty("debug-mode", DEBUG); cfg.setProperty("debug-mode", DEBUG);
cfg.setProperty("whoosh-effect", whooshEffect);
cfg.setProperty("knock-back-dist", knockBack); cfg.setProperty("knock-back-dist", knockBack);
cfg.setProperty("timer-delay-ticks", timerTicks); 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") + "."); 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 // "knockback" command from player or console
else if (split.length == 2 && split[0].equalsIgnoreCase("knockback")) 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+" 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+" getmsg" + clrDesc + " - display border message.");
sender.sendMessage(cmd+" setmsg " + clrReq + "<text>" + clrDesc + " - set 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+" delay " + clrReq + "<amount>" + clrDesc + " - time between border checks.");
sender.sendMessage(cmd+" reload" + clrDesc + " - re-load data from config.yml."); 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."); 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> getmsg - display border message.
/<command> setmsg <text> - set border message. /<command> setmsg <text> - set border message.
/<command> knockback <distance> - how far to move the player back. /<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> delay <amount> - time between border checks.
/<command> wshape [world] <round|square|default> - override shape. /<command> wshape [world] <round|square|default> - override shape.
/<command> [world] fill [freq] [pad] - generate world out to border. /<command> [world] fill [freq] [pad] - generate world out to border.
/<command> debug <on/off> - turn debug mode on or off.
permissions: permissions:
worldborder.*: worldborder.*:
description: Grants all WorldBorder permissions description: Grants all WorldBorder permissions
@ -40,6 +42,7 @@ permissions:
worldborder.wshape: true worldborder.wshape: true
worldborder.fill: true worldborder.fill: true
worldborder.help: true worldborder.help: true
worldborder.whoosh: true
worldborder.set: worldborder.set:
description: Can set borders for any world description: Can set borders for any world
default: op default: op
@ -82,3 +85,6 @@ permissions:
worldborder.help: worldborder.help:
description: Can view the command reference help pages description: Can view the command reference help pages
default: op default: op
worldborder.whoosh:
description: Can enable/disable "whoosh" knockback effect
default: op