Updated some features and stopped some bugs

This commit is contained in:
sekwah41 2013-12-22 22:51:42 +00:00
parent aba79ceae4
commit ccf89a79a9
3 changed files with 56 additions and 27 deletions

View File

@ -110,12 +110,51 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
return true;
}
World world = org.bukkit.Bukkit.getWorld(player.getMetadata("Pos1World").get(0).asString());
Location pos1 = new Location(world, player.getMetadata("Pos1X").get(0).asInt(), player.getMetadata("Pos1Y").get(0).asInt(), player.getMetadata("Pos1Z").get(0).asInt());
Location pos2 = new Location(world, player.getMetadata("Pos2X").get(0).asInt(), player.getMetadata("Pos2Y").get(0).asInt(), player.getMetadata("Pos2Z").get(0).asInt());
Material triggerBlockMat = Material.getMaterial(0);
if(hasTriggerBlock){
try
{
triggerBlockMat = Material.getMaterial(Integer.parseInt(triggerBlock));
System.out.println(triggerBlockMat.toString());
}
catch(Exception e)
{
try
{
triggerBlockMat = Material.getMaterial(triggerBlock.toUpperCase());
System.out.println(triggerBlockMat.toString());
}
catch(Exception exeption)
{
hasTriggerBlock = false;
player.sendMessage("§cThe trigger block entered is not a valid block name in minecraft!");
}
}
}
ConfigAccessor portalconfig = new ConfigAccessor(plugin, "Portals.yml");
String posX = portalconfig.getConfig().getString(portalName + ".pos1.X");
ConfigAccessor desticonfig = new ConfigAccessor(plugin, "Destinations.yml");
String destiPosX = desticonfig.getConfig().getString(destination + ".pos1.X");
if(posX == null){
player.sendMessage("");
player.sendMessage("§a[§eAdvancedPortals§a]§e You have created a new portal with the following details:");
player.sendMessage("§aname: §e" + portalName);
if(hasDestination){
player.sendMessage("§adestination: §e" + destination);
}
else if(destiPosX == null){
player.sendMessage("§cdestination: §e" + destination + " (undefined destination)");
}
else{
player.sendMessage("§cdestination: §eN/A (will not work)");
}
@ -127,29 +166,8 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
player.sendMessage("§ctriggerBlock: §edefault(" + Config.getConfig().getString("DefaultPortalTriggerBlock") + ")");
}
World world = org.bukkit.Bukkit.getWorld(player.getMetadata("Pos1World").get(0).asString());
Location pos1 = new Location(world, player.getMetadata("Pos1X").get(0).asInt(), player.getMetadata("Pos1Y").get(0).asInt(), player.getMetadata("Pos1Z").get(0).asInt());
Location pos2 = new Location(world, player.getMetadata("Pos2X").get(0).asInt(), player.getMetadata("Pos2Y").get(0).asInt(), player.getMetadata("Pos2Z").get(0).asInt());
Material triggerBlockId = Material.getMaterial(0);
if(hasTriggerBlock){
try
{
triggerBlockId = Material.getMaterial(Integer.parseInt(triggerBlock));
}
catch(Exception e)
{
triggerBlockId = Material.getMaterial(triggerBlock);
}
}
ConfigAccessor config2 = new ConfigAccessor(plugin, "Portals.yml");
String posX = config2.getConfig().getString(portalName + ".pos1.X");
if(posX == null){
if(hasTriggerBlock){
Portal.create(pos1, pos2, portalName, destination, triggerBlockId);
Portal.create(pos1, pos2, portalName, destination, triggerBlockMat);
}
else{
Portal.create(pos1, pos2, portalName, destination);

View File

@ -74,6 +74,7 @@ public class Listeners implements Listener {
Location fromloc = event.getFrom();
Location loc = event.getTo();
Location eyeloc = event.getTo();
//System.out.println(loc.getBlock().getType()); // for debugging, remove or comment out when not needed
eyeloc.setY(eyeloc.getY() + player.getEyeHeight());
Object[] portals = Portal.Portals;
int portalId = 0;

View File

@ -87,7 +87,7 @@ public class Portal {
}
public static void create(Location pos1, Location pos2 , String name, String destination , Material triggerBlockId) {
public static void create(Location pos1, Location pos2 , String name, String destination , Material triggerBlock) {
int LowX = 0;
@ -127,7 +127,7 @@ public class Portal {
config.getConfig().set(name.toLowerCase() + ".world", pos1.getWorld().getName());
config.getConfig().set(name.toLowerCase() + ".triggerblock", triggerBlockId.toString());
config.getConfig().set(name.toLowerCase() + ".triggerblock", checkMaterial(triggerBlock));
config.getConfig().set(name.toLowerCase() + ".destination", destination);
@ -141,11 +141,21 @@ public class Portal {
config.saveConfig();
DataCollector.portalCreated(triggerBlockId.toString());
DataCollector.portalCreated(triggerBlock.toString());
loadPortals();
}
private static String checkMaterial(Material triggerBlock) {
if(triggerBlock.equals(Material.WATER)){
return "STATIONARY_WATER";
}
else if(triggerBlock.equals(Material.LAVA)){
return "STATIONARY_LAVA";
}
return triggerBlock.toString();
}
@SuppressWarnings("deprecation")
public static void create(Location pos1, Location pos2, String name, String destination) { // add stuff for destination names or coordinates
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
@ -226,7 +236,7 @@ public class Portal {
return warped;
}
else{
player.sendMessage("§cThe destination you are attempting to warp to doesnt exist!");
player.sendMessage("§cThe 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;