mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-25 03:55:23 +01:00
added error catcher for portal command args.
This commit is contained in:
parent
7bcd88fd1d
commit
06794ac4a7
@ -2,6 +2,7 @@ package com.sekwah.advancedportals.effects;
|
||||
|
||||
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
|
||||
import com.sekwah.advancedportals.Assets;
|
||||
import com.sekwah.advancedportals.portals.AdvancedPortal;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
@ -17,20 +18,29 @@ public class WarpEffects {
|
||||
public static boolean soundError = false;
|
||||
|
||||
public WarpEffects(AdvancedPortalsPlugin plugin) {
|
||||
try {
|
||||
sounds[0] = Sound.valueOf("ENTITY_ENDERMEN_TELEPORT");
|
||||
plugin.getLogger().info("Sounds found");
|
||||
|
||||
sounds[0] = findSound(plugin, "ENTITY_ENDERMEN_TELEPORT", "ENDERMAN_TELEPORT");
|
||||
|
||||
// SPIGOT STOP CHANGING THE BLOODY NAMES! we already knew what an explosion was...
|
||||
sounds[1] = findSound(plugin, "ENTITY_GENERIC_EXPLODE", "EXPLODE");
|
||||
|
||||
}
|
||||
|
||||
public Sound findSound(AdvancedPortalsPlugin plugin, String newName, String oldName){
|
||||
Sound soundFound = null;
|
||||
try{
|
||||
soundFound = Sound.valueOf(newName);
|
||||
plugin.getLogger().info(newName + " found");
|
||||
} catch (IllegalArgumentException e) {
|
||||
plugin.getLogger().info("Using old effect names");
|
||||
try {
|
||||
sounds[0] = Sound.valueOf("ENDERMAN_TELEPORT");
|
||||
soundFound = Sound.valueOf(oldName);
|
||||
plugin.getLogger().info("Using old effect name: " + oldName);
|
||||
} catch (IllegalArgumentException e2) {
|
||||
plugin.getLogger().warning("There was an error using both the old and new names.");
|
||||
plugin.getLogger().warning("There was an error using both the old and new names for " + newName);
|
||||
soundError = true;
|
||||
}
|
||||
}
|
||||
|
||||
sounds[1] = Sound.EXPLODE;
|
||||
return soundFound;
|
||||
}
|
||||
|
||||
public static void activateParticles(Player player) {
|
||||
|
@ -379,7 +379,12 @@ public class Portal {
|
||||
if (command.startsWith("#")) {
|
||||
command = command.substring(1);
|
||||
plugin.getLogger().log(Level.INFO, "Portal command: " + command);
|
||||
plugin.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
try{
|
||||
plugin.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
}
|
||||
catch(Exception e){
|
||||
plugin.getLogger().warning("Error while executing: " + command);
|
||||
}
|
||||
} else if (command.startsWith("!")) {
|
||||
command = command.substring(1);
|
||||
boolean wasOp = player.isOp();
|
||||
|
Loading…
Reference in New Issue
Block a user