From 08d2f60e6429e928e2e077e5dd51ff33edae469a Mon Sep 17 00:00:00 2001 From: sekwah41 Date: Wed, 11 Jun 2014 18:49:27 +0100 Subject: [PATCH] Various different updates including the warp effects --- Advanced Portals/src/Config.yml | 14 ++++++ .../AdvancedPortalsPlugin.java | 4 +- .../com/sekwah/advancedportals/Assets.java | 15 ++++++ .../com/sekwah/advancedportals/Listeners.java | 2 +- .../destinations/Destination.java | 11 +++-- .../advancedportals/effects/WarpEffects.java | 46 +++++++++++++++++++ .../portalcontrolls/Portal.java | 8 ++-- 7 files changed, 92 insertions(+), 8 deletions(-) create mode 100644 Advanced Portals/src/com/sekwah/advancedportals/Assets.java create mode 100644 Advanced Portals/src/com/sekwah/advancedportals/effects/WarpEffects.java diff --git a/Advanced Portals/src/Config.yml b/Advanced Portals/src/Config.yml index 2c16ab1..5798011 100644 --- a/Advanced Portals/src/Config.yml +++ b/Advanced Portals/src/Config.yml @@ -31,6 +31,20 @@ StopWaterFlow: true ShowSelectionBlockID: STAINED_GLASS ShowSelectionBlockData: 14 +# WarpEffect +# 0 = disabled(no particles) +# 1 = Eye of ender explode efffect(loads of portal particles) +# 2 = Explosion particles +warpParticles: 1 + +# WarpSound generally suggested to keep the same as warpeffect but can usually be used for just the sound and no particle effects +# 0 = disabled(no sound) +# 1 = Enderman Warp Sound +# 2 = Explosion +warpSound: 1 + + + # This changes how long the show seletion lasts in seconds diff --git a/Advanced Portals/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java b/Advanced Portals/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java index 1f83465..b1a61dd 100644 --- a/Advanced Portals/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java +++ b/Advanced Portals/src/com/sekwah/advancedportals/AdvancedPortalsPlugin.java @@ -10,9 +10,11 @@ import com.sekwah.advancedportals.metrics.Metrics; import com.sekwah.advancedportals.portalcontrolls.Portal; public class AdvancedPortalsPlugin extends JavaPlugin { - + public void onEnable() { + new Assets(this); + // Opens a channel that messages bungeeCord this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); diff --git a/Advanced Portals/src/com/sekwah/advancedportals/Assets.java b/Advanced Portals/src/com/sekwah/advancedportals/Assets.java new file mode 100644 index 0000000..abf3ecd --- /dev/null +++ b/Advanced Portals/src/com/sekwah/advancedportals/Assets.java @@ -0,0 +1,15 @@ +package com.sekwah.advancedportals; + +public class Assets { + + public static int currentWarpParticles = 0; + + public static int currentWarpSound = 0; + + public Assets(AdvancedPortalsPlugin plugin) { + ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml"); + currentWarpParticles = config.getConfig().getInt("warpParticles"); + currentWarpSound = config.getConfig().getInt("warpSound"); + } + +} diff --git a/Advanced Portals/src/com/sekwah/advancedportals/Listeners.java b/Advanced Portals/src/com/sekwah/advancedportals/Listeners.java index 4f1bd43..96dc00c 100644 --- a/Advanced Portals/src/com/sekwah/advancedportals/Listeners.java +++ b/Advanced Portals/src/com/sekwah/advancedportals/Listeners.java @@ -115,7 +115,7 @@ public class Listeners implements Listener { public void run(){ finalplayer.removeMetadata("HasWarped", plugin); } - }, 20); + }, 10); } } diff --git a/Advanced Portals/src/com/sekwah/advancedportals/destinations/Destination.java b/Advanced Portals/src/com/sekwah/advancedportals/destinations/Destination.java index 2582043..edf4441 100644 --- a/Advanced Portals/src/com/sekwah/advancedportals/destinations/Destination.java +++ b/Advanced Portals/src/com/sekwah/advancedportals/destinations/Destination.java @@ -19,6 +19,7 @@ import org.bukkit.entity.Player; import com.mysql.jdbc.Util; import com.sekwah.advancedportals.AdvancedPortalsPlugin; import com.sekwah.advancedportals.ConfigAccessor; +import com.sekwah.advancedportals.effects.WarpEffects; public class Destination { @@ -108,6 +109,8 @@ public class Destination { loc.setPitch((float) config.getConfig().getDouble(name + ".pos.pitch")); loc.setYaw((float) config.getConfig().getDouble(name + ".pos.yaw")); + WarpEffects.activateParticles(player); + WarpEffects.activateSound(player); Chunk c = loc.getChunk(); Entity riding = player.getVehicle(); if (!c.isLoaded()) c.load(); @@ -118,15 +121,17 @@ public class Destination { riding.setPassenger(player); } else{ - player.teleport(loc); + player.teleport(loc); } + WarpEffects.activateParticles(player); + WarpEffects.activateSound(player); return true; } else{ if(senderror){ - player.sendMessage("§cThe destination you are trying to warp to seems to be linked to a world that doesn't exist!"); + player.sendMessage("§c[§7AdvancedPortals§c] The destination you are trying to warp to seems to be linked to a world that doesn't exist!"); plugin.getLogger().log(Level.SEVERE, "The destination '" + name + "' is linked to the world " + config.getConfig().getString(name + ".world") + " which doesnt seem to exist any more!"); } @@ -135,7 +140,7 @@ public class Destination { } else{ if(senderror){ - player.sendMessage("§cThere has been a problem warping you to the selected destination!"); + player.sendMessage("§c[§7AdvancedPortals§c] There has been a problem warping you to the selected destination!"); plugin.getLogger().log(Level.SEVERE, "The destination '" + name + "' has just had a warp " + "attempt and either the data is corrupt or that destination doesn't exist!"); } diff --git a/Advanced Portals/src/com/sekwah/advancedportals/effects/WarpEffects.java b/Advanced Portals/src/com/sekwah/advancedportals/effects/WarpEffects.java new file mode 100644 index 0000000..973a97b --- /dev/null +++ b/Advanced Portals/src/com/sekwah/advancedportals/effects/WarpEffects.java @@ -0,0 +1,46 @@ +package com.sekwah.advancedportals.effects; + +import org.bukkit.Effect; +import org.bukkit.Instrument; +import org.bukkit.Location; +import org.bukkit.Note; +import org.bukkit.Sound; +import org.bukkit.World; +import org.bukkit.Note.Tone; +import org.bukkit.entity.Player; + +import com.sekwah.advancedportals.Assets; + +public class WarpEffects { + + public static void activateParticles(Player player) { + Location loc = player.getLocation(); + World world = player.getWorld(); + switch (Assets.currentWarpParticles){ + case 1: + for(int i = 0; i < 10; i++){ + world.playEffect(loc, Effect.ENDER_SIGNAL, 0); + } + loc.add(0D, 1D, 0D); + for(int i = 0; i < 10; i++){ + world.playEffect(loc, Effect.ENDER_SIGNAL, 0); + } + default: break; + } + + + } + + public static void activateSound(Player player) { + Location loc = player.getLocation(); + World world = player.getWorld(); + switch (Assets.currentWarpParticles){ + case 1: + world.playSound(loc, Sound.ENDERMAN_TELEPORT, 1F, 1F); + default: break; + } + + + } + +} diff --git a/Advanced Portals/src/com/sekwah/advancedportals/portalcontrolls/Portal.java b/Advanced Portals/src/com/sekwah/advancedportals/portalcontrolls/Portal.java index 0ce8a5d..cff0ca1 100644 --- a/Advanced Portals/src/com/sekwah/advancedportals/portalcontrolls/Portal.java +++ b/Advanced Portals/src/com/sekwah/advancedportals/portalcontrolls/Portal.java @@ -234,6 +234,8 @@ public class Portal { triggerBlockType = Material.PORTAL; } + // TODO add a for loop which scans through the addArgs and adds them to the config so that the application can use them + String result = create(pos1, pos2, name, destination, triggerBlockType, addArgs); loadPortals(); @@ -320,7 +322,7 @@ public class Portal { // add other variables or filter code here, or somehow have a way to register them if(config.getConfig().getString(portalName + ".bungee") != null){ - + player.sendMessage("§a[§eAdvancedPortals§a] Attempting to warp to §e" + config.getConfig().getString(portalName + ".bungee") + "§a."); ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF("Connect"); out.writeUTF(config.getConfig().getString(portalName + ".bungee")); @@ -337,7 +339,7 @@ public class Portal { return warped; } else{ - player.sendMessage("§cThe destination you are currently attempting to warp to doesnt exist!"); + player.sendMessage("§c[§7AdvancedPortals§c] The destination you are currently attempting to warp to doesnt exist!"); plugin.getLogger().log(Level.SEVERE, "The portal '" + portalName + "' has just had a warp " + "attempt and either the data is corrupt or that destination listed doesn't exist!"); return false; @@ -345,7 +347,7 @@ public class Portal { } else{ - player.sendMessage("§cThe portal you are trying to use doesn't have a destination!"); + player.sendMessage("§c[§7AdvancedPortals§c] The portal you are trying to use doesn't have a destination!"); plugin.getLogger().log(Level.SEVERE, "The portal '" + portalName + "' has just had a warp " + "attempt and either the data is corrupt or portal doesn't exist!"); return false;