From 04971a200720dde5dfa3fd83e94ba480de53b821 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Wed, 27 Jul 2011 16:30:07 -0500 Subject: [PATCH] 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 command --- .../wimbli/WorldBorder/BorderCheckTask.java | 10 +++++++- src/com/wimbli/WorldBorder/Config.java | 25 ++++++++++++++++--- src/com/wimbli/WorldBorder/WBCommand.java | 15 +++++++++++ src/plugin.yml | 6 +++++ 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/com/wimbli/WorldBorder/BorderCheckTask.java b/src/com/wimbli/WorldBorder/BorderCheckTask.java index 55c9485..8648fbf 100644 --- a/src/com/wimbli/WorldBorder/BorderCheckTask.java +++ b/src/com/wimbli/WorldBorder/BorderCheckTask.java @@ -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 } diff --git a/src/com/wimbli/WorldBorder/Config.java b/src/com/wimbli/WorldBorder/Config.java index 96f6a51..781c24a 100644 --- a/src/com/wimbli/WorldBorder/Config.java +++ b/src/com/wimbli/WorldBorder/Config.java @@ -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); diff --git a/src/com/wimbli/WorldBorder/WBCommand.java b/src/com/wimbli/WorldBorder/WBCommand.java index 6c04370..3dfa795 100644 --- a/src/com/wimbli/WorldBorder/WBCommand.java +++ b/src/com/wimbli/WorldBorder/WBCommand.java @@ -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 + "" : clrOpt + "[world]") + clrReq + " " + clrDesc + " - shape override."); sender.sendMessage(cmd+" getmsg" + clrDesc + " - display border message."); sender.sendMessage(cmd+" setmsg " + clrReq + "" + clrDesc + " - set border message."); + sender.sendMessage(cmd+" whoosh " + clrReq + "" + clrDesc + " - turn knockback effect on or off."); sender.sendMessage(cmd+" delay " + clrReq + "" + clrDesc + " - time between border checks."); sender.sendMessage(cmd+" reload" + clrDesc + " - re-load data from config.yml."); sender.sendMessage(cmd+" debug " + clrReq + "" + clrDesc + " - turn console debug output on or off."); diff --git a/src/plugin.yml b/src/plugin.yml index d174594..85331e8 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -19,9 +19,11 @@ commands: / getmsg - display border message. / setmsg - set border message. / knockback - how far to move the player back. + / whoosh - turn knockback effect on or off. / delay - time between border checks. / wshape [world] - override shape. / [world] fill [freq] [pad] - generate world out to border. + / debug - 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