Few small updates

This commit is contained in:
sekwah41 2013-12-17 22:22:16 +00:00
parent 4f1e493fc3
commit 409f3453ac
4 changed files with 20 additions and 9 deletions

View File

@ -80,10 +80,13 @@ public class Listeners implements Listener {
|| Portal.triggers[portalId].equals(player.getEyeLocation().getBlock().getType())){
if((Portal.pos1[portalId].getX() + 1D) >= loc.getX() && (Portal.pos1[portalId].getY() + 1D) >= loc.getY() && (Portal.pos1[portalId].getZ() + 1D) >= loc.getZ()){
if(Portal.pos2[portalId].getX() <= loc.getX() && Portal.pos2[portalId].getY() <= loc.getY() && Portal.pos2[portalId].getZ() <= loc.getZ()){
Portal.activate(player, portal.toString());
boolean warped = Portal.activate(player, portal.toString());
DataCollector.playerWarped();
// event.setCancelled(!warped); fix the warpback
final Player finalplayer = event.getPlayer();
if(player.getGameMode().equals(GameMode.CREATIVE)){
player.setMetadata("HasWarped", new FixedMetadataValue(plugin, true));

View File

@ -16,8 +16,7 @@ import org.bukkit.event.entity.EntityExplodeEvent;
import com.sekwah.advancedportals.portalcontrolls.Portal;
public class PortalProtect implements Listener {
@SuppressWarnings("unused")
private final AdvancedPortalsPlugin plugin;
// The needed config values will be stored so they are easier to access later
@ -101,13 +100,14 @@ public class PortalProtect implements Listener {
if(Portal.worldName[portalId].equals(block.getWorld().getName())){
if((Portal.pos1[portalId].getX() + PortalProtectionRadius) >= block.getX() && (Portal.pos1[portalId].getY() + PortalProtectionRadius) >= block.getY() && (Portal.pos1[portalId].getZ() + PortalProtectionRadius) >= block.getZ()){
if((Portal.pos2[portalId].getX() - PortalProtectionRadius) <= block.getX() && (Portal.pos2[portalId].getY() - PortalProtectionRadius) <= block.getY() && (Portal.pos2[portalId].getZ() - PortalProtectionRadius) <= block.getZ()){
System.out.println("Remove");
blockList.remove(i);
i--;
}
}
}

View File

@ -83,7 +83,7 @@ public class Destination {
config.saveConfig();
}
public static void warp(Player player, String name){
public static boolean warp(Player player, String name){
ConfigAccessor config = new ConfigAccessor(plugin, "Destinations.yml");
if(config.getConfig().getString(name + ".world") != null){
Location loc = player.getLocation();
@ -98,10 +98,13 @@ public class Destination {
loc.setYaw((float) config.getConfig().getDouble(name + ".pos.yaw"));
player.teleport(loc);
return true;
}
else{
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!");
return false;
}
}

View File

@ -213,25 +213,30 @@ public class Portal {
loadPortals();
}
public static void activate(Player player, String portalName) {
public static boolean activate(Player player, String portalName) {
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
// add other variables or filter code here, or somehow have a way to register them
if(config.getConfig().getString(portalName + ".destination") != null){
ConfigAccessor configDesti = new ConfigAccessor(plugin, "Destinations.yml");
String destiName = config.getConfig().getString(portalName + ".destination");
if(configDesti.getConfig().getString(destiName + ".world") != null){
Destination.warp(player, destiName);
boolean warped = Destination.warp(player, destiName);
return warped;
}
else{
player.sendMessage("§cThe destination you are 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;
}
}
else{
player.sendMessage("§cThe destination you are 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 portal doesn't exist!");
return false;
}
// add code for if the portal doesnt have a destination but a teleport location