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,46 +110,64 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
return true;
}
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{
player.sendMessage("§cdestination: §eN/A (will not work)");
}
if(hasTriggerBlock){
player.sendMessage("§atriggerBlock: §e" + triggerBlock);
}
else{
ConfigAccessor Config = new ConfigAccessor(plugin, "Config.yml");
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);
Material triggerBlockMat = Material.getMaterial(0);
if(hasTriggerBlock){
try
{
triggerBlockId = Material.getMaterial(Integer.parseInt(triggerBlock));
triggerBlockMat = Material.getMaterial(Integer.parseInt(triggerBlock));
System.out.println(triggerBlockMat.toString());
}
catch(Exception e)
{
triggerBlockId = Material.getMaterial(triggerBlock);
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 config2 = new ConfigAccessor(plugin, "Portals.yml");
String posX = config2.getConfig().getString(portalName + ".pos1.X");
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)");
}
if(hasTriggerBlock){
Portal.create(pos1, pos2, portalName, destination, triggerBlockId);
player.sendMessage("§atriggerBlock: §e" + triggerBlock);
}
else{
ConfigAccessor Config = new ConfigAccessor(plugin, "Config.yml");
player.sendMessage("§ctriggerBlock: §edefault(" + Config.getConfig().getString("DefaultPortalTriggerBlock") + ")");
}
if(hasTriggerBlock){
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;