mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-29 05:55:19 +01:00
custom particle effect on warp
This commit is contained in:
parent
5682b94aef
commit
ff4fd1f3e7
@ -8,10 +8,7 @@ import com.sekwah.advancedportals.bukkit.portals.AdvancedPortal;
|
|||||||
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.*;
|
import net.md_5.bungee.api.chat.*;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.*;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.EndGateway;
|
import org.bukkit.block.EndGateway;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -210,6 +207,8 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
|||||||
String serverName = null;
|
String serverName = null;
|
||||||
String permission = null;
|
String permission = null;
|
||||||
String portalCommand = null;
|
String portalCommand = null;
|
||||||
|
String particleDisp = null;
|
||||||
|
String particleDest = null;
|
||||||
|
|
||||||
ArrayList<PortalArg> extraData = new ArrayList<>();
|
ArrayList<PortalArg> extraData = new ArrayList<>();
|
||||||
|
|
||||||
@ -305,6 +304,12 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
|||||||
} else if (startsWithPortalArg("leavedesti:", args[i])) {
|
} else if (startsWithPortalArg("leavedesti:", args[i])) {
|
||||||
String leaveDesti = parseArgVariable(args, i, "leavedesti:");
|
String leaveDesti = parseArgVariable(args, i, "leavedesti:");
|
||||||
extraData.add(new PortalArg("leavedesti", leaveDesti));
|
extraData.add(new PortalArg("leavedesti", leaveDesti));
|
||||||
|
} else if (startsWithPortalArg("particledisp:", args[i])) {
|
||||||
|
String value = parseArgVariable(args, i, "particledisp:");
|
||||||
|
extraData.add(new PortalArg("particledisp", value));
|
||||||
|
} else if (startsWithPortalArg("particledest:", args[i])) {
|
||||||
|
String value = parseArgVariable(args, i, "particledest:");
|
||||||
|
extraData.add(new PortalArg("particledest", value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!hasName) {
|
if (!hasName) {
|
||||||
@ -426,8 +431,13 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "variables":
|
case "variables":
|
||||||
sender.sendMessage(PluginMessages.customPrefix
|
sender.sendMessage(
|
||||||
+ " \u00A77Variables \u00A7c: \u00A7aname, triggerBlock, desti, destination, bungee, permission, command, cooldowndelay, leavedesti");
|
PluginMessages.customPrefix +
|
||||||
|
" \u00A77Variables \u00A7c: " +
|
||||||
|
"\u00A7aname, triggerBlock, desti, destination, " +
|
||||||
|
"bungee, permission, command, cooldowndelay, leavedesti" +
|
||||||
|
"particledisp, particledest"
|
||||||
|
);
|
||||||
sender.sendMessage("");
|
sender.sendMessage("");
|
||||||
sender.sendMessage("\u00A7aExample command: \u00A7e/portal create name:test triggerId:portal");
|
sender.sendMessage("\u00A7aExample command: \u00A7e/portal create name:test triggerId:portal");
|
||||||
break;
|
break;
|
||||||
@ -897,6 +907,8 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
|||||||
boolean hasCommand = false;
|
boolean hasCommand = false;
|
||||||
boolean hasCooldownDelay = false;
|
boolean hasCooldownDelay = false;
|
||||||
boolean hasLeaveDesti = false;
|
boolean hasLeaveDesti = false;
|
||||||
|
boolean hasDispParticle = false;
|
||||||
|
boolean hasDestParticle = false;
|
||||||
|
|
||||||
// TODO change auto complete when quotes are opened and closed. Such as
|
// TODO change auto complete when quotes are opened and closed. Such as
|
||||||
// autocomplete @Player and stuff when specifying commands
|
// autocomplete @Player and stuff when specifying commands
|
||||||
@ -932,6 +944,12 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
|||||||
case "cooldowndelay":
|
case "cooldowndelay":
|
||||||
hasCooldownDelay = true;
|
hasCooldownDelay = true;
|
||||||
break;
|
break;
|
||||||
|
case "particledisp":
|
||||||
|
hasDispParticle = true;
|
||||||
|
break;
|
||||||
|
case "particledest":
|
||||||
|
hasDestParticle = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -965,6 +983,12 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
|||||||
if (!hasLeaveDesti) {
|
if (!hasLeaveDesti) {
|
||||||
autoComplete.add("leavedesti:");
|
autoComplete.add("leavedesti:");
|
||||||
}
|
}
|
||||||
|
if (!hasDispParticle) {
|
||||||
|
autoComplete.add("particledisp:");
|
||||||
|
}
|
||||||
|
if (!hasDestParticle) {
|
||||||
|
autoComplete.add("particledest:");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.length == 2 && (args[0].equalsIgnoreCase("warp"))) {
|
if (args.length == 2 && (args[0].equalsIgnoreCase("warp"))) {
|
||||||
@ -1007,6 +1031,14 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
|||||||
autoComplete.add(tagStart + object.toString());
|
autoComplete.add(tagStart + object.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (args[args.length - 1].startsWith("particledisp:") || args[args.length - 1].startsWith("particledest:")) {
|
||||||
|
String tagStart = args[args.length - 1].startsWith("particledisp:") ? "particledisp:" : "particledest:";
|
||||||
|
for (Particle particle : Particle.values()) {
|
||||||
|
if(particle.getDataType() != Void.class)
|
||||||
|
continue;
|
||||||
|
autoComplete.add(tagStart + particle.name().toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
Collections.sort(autoComplete);
|
Collections.sort(autoComplete);
|
||||||
for (Object result : autoComplete.toArray()) {
|
for (Object result : autoComplete.toArray()) {
|
||||||
if (!result.toString().startsWith(args[args.length - 1])) {
|
if (!result.toString().startsWith(args[args.length - 1])) {
|
||||||
|
@ -113,22 +113,30 @@ public class Destination {
|
|||||||
return warp(player, name, null, hideActionBar, false);
|
return warp(player, name, null, hideActionBar, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean warp(Player player, String name, boolean hideActionbar, boolean noEffects) {
|
public static boolean warp(Player player, String name, boolean hideActionBar, boolean noEffects) {
|
||||||
|
return warp(player, name, null, hideActionBar, noEffects);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean warp(Player player, String dest, AdvancedPortal disp, boolean hideActionbar, boolean noEffects) {
|
||||||
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
|
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
|
||||||
if (config.getConfig().getString(name + ".world") != null) {
|
if (config.getConfig().getString(dest + ".world") != null) {
|
||||||
Location loc = player.getLocation();
|
Location loc = player.getLocation();
|
||||||
if (Bukkit.getWorld(config.getConfig().getString(name + ".world")) != null) {
|
if (Bukkit.getWorld(config.getConfig().getString(dest + ".world")) != null) {
|
||||||
loc.setWorld(Bukkit.getWorld(config.getConfig().getString(name + ".world")));
|
loc.setWorld(Bukkit.getWorld(config.getConfig().getString(dest + ".world")));
|
||||||
|
|
||||||
loc.setX(config.getConfig().getDouble(name + ".pos.X"));
|
loc.setX(config.getConfig().getDouble(dest + ".pos.X"));
|
||||||
loc.setY(config.getConfig().getDouble(name + ".pos.Y"));
|
loc.setY(config.getConfig().getDouble(dest + ".pos.Y"));
|
||||||
loc.setZ(config.getConfig().getDouble(name + ".pos.Z"));
|
loc.setZ(config.getConfig().getDouble(dest + ".pos.Z"));
|
||||||
|
|
||||||
loc.setPitch((float) config.getConfig().getDouble(name + ".pos.pitch"));
|
loc.setPitch((float) config.getConfig().getDouble(dest + ".pos.pitch"));
|
||||||
loc.setYaw((float) config.getConfig().getDouble(name + ".pos.yaw"));
|
loc.setYaw((float) config.getConfig().getDouble(dest + ".pos.yaw"));
|
||||||
|
|
||||||
|
if (disp != null && disp.getArg("particledisp") != null) {
|
||||||
|
WarpEffects.activateParticle(player, disp.getArg("particledisp"));
|
||||||
|
}
|
||||||
|
|
||||||
if(!noEffects) {
|
if(!noEffects) {
|
||||||
WarpEffects.activateParticles(player);
|
WarpEffects.activateEffect(player);
|
||||||
WarpEffects.activateSound(player);
|
WarpEffects.activateSound(player);
|
||||||
}
|
}
|
||||||
Chunk c = loc.getChunk();
|
Chunk c = loc.getChunk();
|
||||||
@ -145,17 +153,21 @@ public class Destination {
|
|||||||
} else {
|
} else {
|
||||||
player.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
player.teleport(loc, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (disp != null && disp.getArg("particledest") != null) {
|
||||||
|
WarpEffects.activateParticle(player, disp.getArg("particledest"));
|
||||||
|
}
|
||||||
if(!noEffects) {
|
if(!noEffects) {
|
||||||
WarpEffects.activateParticles(player);
|
WarpEffects.activateEffect(player);
|
||||||
WarpEffects.activateSound(player);
|
WarpEffects.activateSound(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PORTAL_MESSAGE_DISPLAY == 1) {
|
if (PORTAL_MESSAGE_DISPLAY == 1) {
|
||||||
player.sendMessage("");
|
player.sendMessage("");
|
||||||
player.sendMessage(PluginMessages.customPrefix + "\u00A7a You have been warped to \u00A7e" + name.replaceAll("_", " ") + "\u00A7a.");
|
player.sendMessage(PluginMessages.customPrefix + "\u00A7a You have been warped to \u00A7e" + dest.replaceAll("_", " ") + "\u00A7a.");
|
||||||
player.sendMessage("");
|
player.sendMessage("");
|
||||||
} else if (PORTAL_MESSAGE_DISPLAY == 2 && !hideActionbar) {
|
} else if (PORTAL_MESSAGE_DISPLAY == 2 && !hideActionbar) {
|
||||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("\u00A7aYou have warped to \u00A7e" + name.replaceAll("_", " ") + "\u00A7a."));
|
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("\u00A7aYou have warped to \u00A7e" + dest.replaceAll("_", " ") + "\u00A7a."));
|
||||||
}
|
}
|
||||||
|
|
||||||
Location newLoc = player.getLocation();
|
Location newLoc = player.getLocation();
|
||||||
@ -171,12 +183,12 @@ public class Destination {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(PluginMessages.customPrefixFail + "\u00A7c The destination you are trying to warp to seems to be linked to a world that doesn't exist!");
|
player.sendMessage(PluginMessages.customPrefixFail + "\u00A7c 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 "
|
plugin.getLogger().log(Level.SEVERE, "The destination '" + dest + "' is linked to the world "
|
||||||
+ config.getConfig().getString(name + ".world") + " which doesnt seem to exist any more!");
|
+ config.getConfig().getString(dest + ".world") + " which doesnt seem to exist any more!");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(PluginMessages.customPrefix + "\u00A7c The destination you are currently attempting to warp to doesnt exist!");
|
player.sendMessage(PluginMessages.customPrefix + "\u00A7c The destination you are currently attempting to warp to doesnt exist!");
|
||||||
plugin.getLogger().log(Level.SEVERE, "The destination '" + name + "' has just had a warp "
|
plugin.getLogger().log(Level.SEVERE, "The destination '" + dest + "' has just had a warp "
|
||||||
+ "attempt and either the data is corrupt or that destination doesn't exist!");
|
+ "attempt and either the data is corrupt or that destination doesn't exist!");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
package com.sekwah.advancedportals.bukkit.effects;
|
package com.sekwah.advancedportals.bukkit.effects;
|
||||||
|
|
||||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||||
|
import com.sekwah.advancedportals.bukkit.portals.AdvancedPortal;
|
||||||
|
import com.sekwah.advancedportals.bukkit.portals.Portal;
|
||||||
|
import jdk.tools.jlink.plugin.Plugin;
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -45,7 +49,7 @@ public class WarpEffects {
|
|||||||
return soundFound;
|
return soundFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void activateParticles(Player player) {
|
public static void activateEffect(Player player) {
|
||||||
Location loc = player.getLocation();
|
Location loc = player.getLocation();
|
||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
switch (plugin.getSettings().getCurrentWarpParticles()){
|
switch (plugin.getSettings().getCurrentWarpParticles()){
|
||||||
@ -62,6 +66,21 @@ public class WarpEffects {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void activateParticle(Player player, String particle_name) {
|
||||||
|
Particle particle = Portal.getParticle(particle_name);
|
||||||
|
if(particle == null) {
|
||||||
|
plugin.getLogger().warning("wrong particle name: " + particle_name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Location loc_from = player.getLocation();
|
||||||
|
|
||||||
|
World world = player.getWorld();
|
||||||
|
|
||||||
|
world.spawnParticle(particle, loc_from, 100, 1, 1, 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static void activateSound(Player player) {
|
public static void activateSound(Player player) {
|
||||||
if(!soundError){
|
if(!soundError){
|
||||||
Location loc = player.getLocation();
|
Location loc = player.getLocation();
|
||||||
|
@ -162,6 +162,14 @@ public class Portal {
|
|||||||
return blockTypes;
|
return blockTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Particle getParticle(String name) {
|
||||||
|
try {
|
||||||
|
return Particle.valueOf(name.toUpperCase());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static String create(Location pos1, Location pos2, String name, String destination,
|
public static String create(Location pos1, Location pos2, String name, String destination,
|
||||||
Set<Material> triggerBlocks, PortalArg... extraData) {
|
Set<Material> triggerBlocks, PortalArg... extraData) {
|
||||||
return create(pos1, pos2, name, destination, triggerBlocks, null, extraData);
|
return create(pos1, pos2, name, destination, triggerBlocks, null, extraData);
|
||||||
@ -534,7 +542,7 @@ public class Portal {
|
|||||||
} else if (portal.getDestiation() != null) {
|
} else if (portal.getDestiation() != null) {
|
||||||
ConfigAccessor configDesti = new ConfigAccessor(plugin, "destinations.yml");
|
ConfigAccessor configDesti = new ConfigAccessor(plugin, "destinations.yml");
|
||||||
if (configDesti.getConfig().getString(portal.getDestiation() + ".world") != null) {
|
if (configDesti.getConfig().getString(portal.getDestiation() + ".world") != null) {
|
||||||
warped = Destination.warp(player, portal.getDestiation(), hasMessage);
|
warped = Destination.warp(player, portal.getDestiation(), portal, hasMessage, false);
|
||||||
if (!warped) {
|
if (!warped) {
|
||||||
if(doKnockback)
|
if(doKnockback)
|
||||||
throwPlayerBack(player);
|
throwPlayerBack(player);
|
||||||
|
Loading…
Reference in New Issue
Block a user