mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2025-01-27 02:21:24 +01:00
Few small updates
This commit is contained in:
parent
4f1e493fc3
commit
409f3453ac
@ -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));
|
||||
|
@ -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--;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user